From 6494ebac3ef44cdd532019b3ffa793370a40c4b5 Mon Sep 17 00:00:00 2001 From: Jordan Krage Date: Fri, 27 Jun 2025 17:55:22 -0500 Subject: [PATCH] alias CR/CW types to pkg/types/aptos --- relayer/chainreader/config/config.go | 116 +++++++--------------- relayer/chainreader/loop/loop_reader.go | 2 + relayer/chainwriter/config.go | 49 +++++---- relayer/codec/decode_util.go | 4 + relayer/relay.go | 1 + relayer/testutils/keystore.go | 5 +- relayer/write_target/write_target_test.go | 1 + 7 files changed, 70 insertions(+), 108 deletions(-) diff --git a/relayer/chainreader/config/config.go b/relayer/chainreader/config/config.go index e04bb4705..8789f6514 100644 --- a/relayer/chainreader/config/config.go +++ b/relayer/chainreader/config/config.go @@ -1,82 +1,38 @@ package config -import ( - "github.com/smartcontractkit/chainlink-common/pkg/types" -) - -type ChainReaderConfig struct { - IsLoopPlugin bool - Modules map[string]*ChainReaderModule -} - -type ChainReaderModule struct { - // The module name (optional). When not provided, the key in the map under which this module - // is stored is used. - Name string - Functions map[string]*ChainReaderFunction - Events map[string]*ChainReaderEvent -} - -type ChainReaderFunction struct { - // The function name (optional). When not provided, the key in the map under which this function - // is stored is used. - Name string - Params []AptosFunctionParam - - ResultFieldRenames map[string]RenamedField - ResultTupleToStruct []string - ResultUnwrapStruct []string -} - -type AptosFunctionParam struct { - // The function parameter name. - Name string - // The function parameter Move type. - Type string - // True if this is a required parameter, false otherwise. - Required bool - // If this is not a required parameter and it is not provided, this default value will be used. - DefaultValue any -} - -type ChainReaderEvent struct { - // The struct where the event handle is defined. - EventHandleStructName string - - // The name of the event handle field. - // This field can be defined as path to the nested - // struct that stores the event, e.g. "token_pool_state.burned_events" - EventHandleFieldName string - - // The event account address. - // This field can be defined in several ways: - // - Empty string, which means the event account address is the address of the bound contract. - // - An exact address hex string (eg. 0x1234 or 1234) containing the events. - // - A fully qualified function name (eg. 0x1234::my_contract::get_event_address) which - // takes no parameters and returns the actual event account address. - // - A name containing the module name and function name components - // (eg. my_first_contract::get_event_address) stored at the address of the bound contract, - // which takes no parameters and returns the actual event account address. - EventAccountAddress string - - // Renames of event field names (optional). When not provided, the field names are used as-is. - EventFieldRenames map[string]RenamedField - - // Renames provided filters to match the event field names (optional). When not provided, the filters are used as-is. - EventFilterRenames map[string]string -} - -type RenamedField struct { - // The new field name (optional). This does not need to be provided if this field does not need - // to be renamed. - NewName string - - // Rename sub-fields. This assumes that the event field value is a struct or a map with string keys. - SubFieldRenames map[string]RenamedField -} - -type SequenceWithMetadata struct { - Sequence types.Sequence - TxVersion uint64 - TxHash string -} +import "github.com/smartcontractkit/chainlink-common/pkg/types/aptos" + +// Deprecated +// +//go:fix inline +type ChainReaderConfig = aptos.ContractReaderConfig + +// Deprecated +// +//go:fix inline +type ChainReaderModule = aptos.ContractReaderModule + +// Deprecated +// +//go:fix inline +type ChainReaderFunction = aptos.ContractReaderFunction + +// Deprecated +// +//go:fix inline +type AptosFunctionParam = aptos.FunctionParam + +// Deprecated +// +//go:fix inline +type ChainReaderEvent = aptos.ContractReaderEvent + +// Deprecated +// +//go:fix inline +type RenamedField = aptos.RenamedField + +// Deprecated +// +//go:fix inline +type SequenceWithMetadata = aptos.SequenceWithMetadata diff --git a/relayer/chainreader/loop/loop_reader.go b/relayer/chainreader/loop/loop_reader.go index 62c1b46b4..ce2466515 100644 --- a/relayer/chainreader/loop/loop_reader.go +++ b/relayer/chainreader/loop/loop_reader.go @@ -18,6 +18,8 @@ import ( // Both `logger` and `cr` parameters must be non-nil. // // Deprecated: use loop.NewLoopChainReader +// +//go:fix inline func NewLoopChainReader(logger logger.Logger, cr types.ContractReader) types.ContractReader { return loop.NewLoopChainReader(logger, cr) } diff --git a/relayer/chainwriter/config.go b/relayer/chainwriter/config.go index 0cf98a667..02bac65ed 100644 --- a/relayer/chainwriter/config.go +++ b/relayer/chainwriter/config.go @@ -1,37 +1,34 @@ package chainwriter import ( - crconfig "github.com/smartcontractkit/chainlink-aptos/relayer/chainreader/config" + "github.com/smartcontractkit/chainlink-common/pkg/types/aptos" ) -type FeeStrategy int +// Deprecated +// +//go:fix inline +type FeeStrategy = aptos.FeeStrategy +// Deprecated +// +//go:fix inline const ( - DeprioritizedFeeStrategy FeeStrategy = -1 - DefaultFeeStrategy FeeStrategy = 0 - PrioritizedFeeStrategy FeeStrategy = 1 + DeprioritizedFeeStrategy = aptos.DeprioritizedFeeStrategy + DefaultFeeStrategy = aptos.DefaultFeeStrategy + PrioritizedFeeStrategy = aptos.PrioritizedFeeStrategy ) -type ChainWriterConfig struct { - Modules map[string]*ChainWriterModule - FeeStrategy FeeStrategy -} +// Deprecated +// +//go:fix inline +type ChainWriterConfig = aptos.ContractWriterConfig -type ChainWriterModule struct { - // The module name (optional). When not provided, the key in the map under which this module - // is stored is used. - Name string - Functions map[string]*ChainWriterFunction -} +// Deprecated +// +//go:fix inline +type ChainWriterModule = aptos.ContractWriterModule -type ChainWriterFunction struct { - // The function name (optional). When not provided, the key in the map under which this function - // is stored is used. - Name string - // The public key of the sending account. - PublicKey string - // The account address (optional). When not provided, the address is calculated - // from the public key. - FromAddress string - Params []crconfig.AptosFunctionParam -} +// Deprecated +// +//go:fix inline +type ChainWriterFunction = aptos.ContractWriterFunction diff --git a/relayer/codec/decode_util.go b/relayer/codec/decode_util.go index b6da7f36f..8af767872 100644 --- a/relayer/codec/decode_util.go +++ b/relayer/codec/decode_util.go @@ -3,11 +3,15 @@ package codec import "github.com/smartcontractkit/chainlink-aptos/codec" // Deprecated: use codec.DecodeAptosJsonArray +// +//go:fix inline func DecodeAptosJsonArray(from []any, to ...any) error { return codec.DecodeAptosJsonArray(from, to...) } // Deprecated: use codec.DecodeAptosJsonValue +// +//go:fix inline func DecodeAptosJsonValue(from any, to any) error { return codec.DecodeAptosJsonValue(from, to) } diff --git a/relayer/relay.go b/relayer/relay.go index a5172dad7..5c83ba0d3 100644 --- a/relayer/relay.go +++ b/relayer/relay.go @@ -25,6 +25,7 @@ var _ types.AptosService = (*relayer)(nil) var _ loop.Relayer = (*relayer)(nil) type relayer struct { + types.UnimplementedRelayer chain chain.Chain lggr logger.Logger diff --git a/relayer/testutils/keystore.go b/relayer/testutils/keystore.go index 3137b02a0..5cac3b2e1 100644 --- a/relayer/testutils/keystore.go +++ b/relayer/testutils/keystore.go @@ -6,15 +6,16 @@ import ( "fmt" "testing" - "github.com/smartcontractkit/chainlink-common/pkg/loop" + "github.com/smartcontractkit/chainlink-common/pkg/types/core" ) type TestKeystore struct { + core.UnimplementedKeystore t *testing.T Keys map[string]ed25519.PrivateKey } -var _ loop.Keystore = &TestKeystore{} +var _ core.Keystore = &TestKeystore{} func NewTestKeystore(t *testing.T) *TestKeystore { return &TestKeystore{t: t, Keys: map[string]ed25519.PrivateKey{}} diff --git a/relayer/write_target/write_target_test.go b/relayer/write_target/write_target_test.go index 64d149cff..a5f1cc79d 100644 --- a/relayer/write_target/write_target_test.go +++ b/relayer/write_target/write_target_test.go @@ -8,6 +8,7 @@ import ( "time" "github.com/shopspring/decimal" + "github.com/smartcontractkit/chainlink-common/pkg/beholder" "github.com/smartcontractkit/chainlink-common/pkg/capabilities" "github.com/smartcontractkit/chainlink-common/pkg/capabilities/consensus/ocr3/types"