Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 13 additions & 15 deletions core/capabilities/ccip/configs/aptos/chain_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,27 @@ package aptosconfig
import (
"fmt"

"github.com/smartcontractkit/chainlink-aptos/codec"
"github.com/smartcontractkit/chainlink-common/pkg/types/aptos"
"github.com/smartcontractkit/chainlink-common/pkg/types/ccip/consts"

"github.com/smartcontractkit/chainlink-aptos/relayer/chainreader/config"
"github.com/smartcontractkit/chainlink-aptos/relayer/chainwriter"
"github.com/smartcontractkit/chainlink-aptos/relayer/utils"
)

func GetChainWriterConfig(publicKeyStr string) (chainwriter.ChainWriterConfig, error) {
fromAddress, err := utils.HexPublicKeyToAddress(publicKeyStr)
func GetChainWriterConfig(publicKeyStr string) (aptos.ContractWriterConfig, error) {
fromAddress, err := codec.HexPublicKeyToAddress(publicKeyStr)
if err != nil {
return chainwriter.ChainWriterConfig{}, fmt.Errorf("failed to parse Aptos address from public key %s: %w", publicKeyStr, err)
return aptos.ContractWriterConfig{}, fmt.Errorf("failed to parse Aptos address from public key %s: %w", publicKeyStr, err)
}

return chainwriter.ChainWriterConfig{
Modules: map[string]*chainwriter.ChainWriterModule{
return aptos.ContractWriterConfig{
Modules: map[string]*aptos.ContractWriterModule{
consts.ContractNameOffRamp: {
Name: "offramp",
Functions: map[string]*chainwriter.ChainWriterFunction{
Functions: map[string]*aptos.ContractWriterFunction{
consts.MethodCommit: {
Name: "commit",
PublicKey: publicKeyStr,
FromAddress: fromAddress.String(),
Params: []config.AptosFunctionParam{
FromAddress: fromAddress,
Params: []aptos.FunctionParam{
{
Name: "ReportContext",
Type: "vector<vector<u8>>",
Expand All @@ -46,8 +44,8 @@ func GetChainWriterConfig(publicKeyStr string) (chainwriter.ChainWriterConfig, e
consts.MethodExecute: {
Name: "execute",
PublicKey: publicKeyStr,
FromAddress: fromAddress.String(),
Params: []config.AptosFunctionParam{
FromAddress: fromAddress,
Params: []aptos.FunctionParam{
{
Name: "ReportContext",
Type: "vector<vector<u8>>",
Expand All @@ -63,6 +61,6 @@ func GetChainWriterConfig(publicKeyStr string) (chainwriter.ChainWriterConfig, e
},
},
},
FeeStrategy: chainwriter.DefaultFeeStrategy,
FeeStrategy: aptos.DefaultFeeStrategy,
}, nil
}
68 changes: 34 additions & 34 deletions core/capabilities/ccip/configs/aptos/contract_reader.go
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package aptosconfig

import (
"github.com/smartcontractkit/chainlink-aptos/relayer/chainreader/config"
"github.com/smartcontractkit/chainlink-common/pkg/types/aptos"
"github.com/smartcontractkit/chainlink-common/pkg/types/ccip/consts"
)

func GetChainReaderConfig() (config.ChainReaderConfig, error) {
return config.ChainReaderConfig{
func GetChainReaderConfig() (aptos.ContractReaderConfig, error) {

Check warning on line 8 in core/capabilities/ccip/configs/aptos/contract_reader.go

View check run for this annotation

CL-sonarqube-production / SonarQube Code Analysis

This function has 390 lines of code, which is greater than the 180 authorized. Split it into smaller functions.

[S138] Functions and methods should not have too many lines See more on https://sonarqube.main.prod.cldev.sh/project/issues?id=smartcontractkit_chainlink&pullRequest=23065&issues=3b615b8d-89d8-49af-b8dd-57a249655ee2&open=3b615b8d-89d8-49af-b8dd-57a249655ee2
return aptos.ContractReaderConfig{
IsLoopPlugin: true,
Modules: map[string]*config.ChainReaderModule{
Modules: map[string]*aptos.ContractReaderModule{
consts.ContractNameRMNRemote: {
Name: "rmn_remote",
Functions: map[string]*config.ChainReaderFunction{
Functions: map[string]*aptos.ContractReaderFunction{
consts.MethodNameGetReportDigestHeader: {
Name: "get_report_digest_header",
},
Expand All @@ -27,18 +27,18 @@
},
consts.ContractNameRMNProxy: {
Name: "rmn_remote",
Functions: map[string]*config.ChainReaderFunction{
Functions: map[string]*aptos.ContractReaderFunction{
consts.MethodNameGetARM: {
Name: "get_arm",
},
},
},
consts.ContractNameFeeQuoter: {
Name: "fee_quoter",
Functions: map[string]*config.ChainReaderFunction{
Functions: map[string]*aptos.ContractReaderFunction{
consts.MethodNameFeeQuoterGetTokenPrice: {
Name: "get_token_price",
Params: []config.AptosFunctionParam{
Params: []aptos.FunctionParam{
{
Name: "token",
Type: "address",
Expand All @@ -48,7 +48,7 @@
},
consts.MethodNameFeeQuoterGetTokenPrices: {
Name: "get_token_prices",
Params: []config.AptosFunctionParam{
Params: []aptos.FunctionParam{
{
Name: "tokens",
Type: "vector<address>",
Expand All @@ -61,7 +61,7 @@
},
consts.MethodNameGetFeePriceUpdate: {
Name: "get_dest_chain_gas_price",
Params: []config.AptosFunctionParam{
Params: []aptos.FunctionParam{
{
Name: "destChainSelector",
Type: "u64",
Expand All @@ -73,10 +73,10 @@
},
consts.ContractNameOffRamp: {
Name: "offramp",
Functions: map[string]*config.ChainReaderFunction{
Functions: map[string]*aptos.ContractReaderFunction{
consts.MethodNameGetExecutionState: {
Name: "get_execution_state",
Params: []config.AptosFunctionParam{
Params: []aptos.FunctionParam{
{
Name: "sourceChainSelector",
Type: "u64",
Expand All @@ -91,7 +91,7 @@
},
consts.MethodNameGetMerkleRoot: {
Name: "get_merkle_root",
Params: []config.AptosFunctionParam{
Params: []aptos.FunctionParam{
{
Name: "root",
Type: "vector<u8>",
Expand All @@ -101,7 +101,7 @@
},
consts.MethodNameOffRampLatestConfigDetails: {
Name: "latest_config_details",
Params: []config.AptosFunctionParam{
Params: []aptos.FunctionParam{
{
Name: "ocrPluginType",
Type: "u8",
Expand All @@ -123,7 +123,7 @@
},
consts.MethodNameGetSourceChainConfig: {
Name: "get_source_chain_config",
Params: []config.AptosFunctionParam{
Params: []aptos.FunctionParam{
{
Name: "sourceChainSelector",
Type: "u64",
Expand All @@ -132,12 +132,12 @@
},
},
},
Events: map[string]*config.ChainReaderEvent{
Events: map[string]*aptos.ContractReaderEvent{
consts.EventNameExecutionStateChanged: {
EventHandleStructName: "OffRampState",
EventHandleFieldName: "execution_state_changed_events",
EventAccountAddress: "offramp::get_state_address",
EventFieldRenames: map[string]config.RenamedField{
EventFieldRenames: map[string]aptos.RenamedField{
"source_chain_selector": {
NewName: "SourceChainSelector",
},
Expand All @@ -162,10 +162,10 @@
EventHandleStructName: "OffRampState",
EventHandleFieldName: "commit_report_accepted_events",
EventAccountAddress: "offramp::get_state_address",
EventFieldRenames: map[string]config.RenamedField{
EventFieldRenames: map[string]aptos.RenamedField{
"blessed_merkle_roots": {
NewName: "BlessedMerkleRoots",
SubFieldRenames: map[string]config.RenamedField{
SubFieldRenames: map[string]aptos.RenamedField{
"source_chain_selector": {
NewName: "SourceChainSelector",
},
Expand All @@ -185,7 +185,7 @@
},
"unblessed_merkle_roots": {
NewName: "UnblessedMerkleRoots",
SubFieldRenames: map[string]config.RenamedField{
SubFieldRenames: map[string]aptos.RenamedField{
"source_chain_selector": {
NewName: "SourceChainSelector",
},
Expand All @@ -205,10 +205,10 @@
},
"price_updates": {
NewName: "PriceUpdates",
SubFieldRenames: map[string]config.RenamedField{
SubFieldRenames: map[string]aptos.RenamedField{
"token_price_updates": {
NewName: "TokenPriceUpdates",
SubFieldRenames: map[string]config.RenamedField{
SubFieldRenames: map[string]aptos.RenamedField{
"source_token": {
NewName: "SourceToken",
},
Expand All @@ -219,7 +219,7 @@
},
"gas_price_updates": {
NewName: "GasPriceUpdates",
SubFieldRenames: map[string]config.RenamedField{
SubFieldRenames: map[string]aptos.RenamedField{
"dest_chain_selector": {
NewName: "DestChainSelector",
},
Expand All @@ -236,7 +236,7 @@
EventHandleStructName: "OffRampState",
EventHandleFieldName: "ocr3_base_state.config_set_events",
EventAccountAddress: "offramp::get_state_address",
EventFieldRenames: map[string]config.RenamedField{
EventFieldRenames: map[string]aptos.RenamedField{
"ocr_plugin_type": {
NewName: "OcrPluginType",
},
Expand All @@ -258,13 +258,13 @@
EventHandleStructName: "OffRampState",
EventHandleFieldName: "source_chain_config_set_events",
EventAccountAddress: "offramp::get_state_address",
EventFieldRenames: map[string]config.RenamedField{
EventFieldRenames: map[string]aptos.RenamedField{
"source_chain_selector": {
NewName: "SourceChainSelector",
},
"source_chain_config": {
NewName: "SourceChainConfig",
SubFieldRenames: map[string]config.RenamedField{
SubFieldRenames: map[string]aptos.RenamedField{
"router": {NewName: "Router"},
"is_enabled": {NewName: "IsEnabled"},
"min_seq_nr": {NewName: "MinSeqNr"},
Expand All @@ -278,7 +278,7 @@
},
consts.ContractNameOnRamp: {
Name: "onramp",
Functions: map[string]*config.ChainReaderFunction{
Functions: map[string]*aptos.ContractReaderFunction{
consts.MethodNameOnRampGetDynamicConfig: {
Name: "get_dynamic_config",
},
Expand All @@ -287,7 +287,7 @@
},
consts.MethodNameOnRampGetDestChainConfig: {
Name: "get_dest_chain_config_v2",
Params: []config.AptosFunctionParam{
Params: []aptos.FunctionParam{
{
Name: "destChainSelector",
Type: "u64",
Expand All @@ -298,7 +298,7 @@
},
consts.MethodNameGetExpectedNextSequenceNumber: {
Name: "get_expected_next_sequence_number",
Params: []config.AptosFunctionParam{
Params: []aptos.FunctionParam{
{
Name: "destChainSelector",
Type: "u64",
Expand All @@ -307,12 +307,12 @@
},
},
},
Events: map[string]*config.ChainReaderEvent{
Events: map[string]*aptos.ContractReaderEvent{
consts.EventNameCCIPMessageSent: {
EventHandleStructName: "OnRampState",
EventHandleFieldName: "ccip_message_sent_events",
EventAccountAddress: "onramp::get_state_address",
EventFieldRenames: map[string]config.RenamedField{
EventFieldRenames: map[string]aptos.RenamedField{
"dest_chain_selector": {
NewName: "DestChainSelector",
SubFieldRenames: nil,
Expand All @@ -323,10 +323,10 @@
},
"message": {
NewName: "Message",
SubFieldRenames: map[string]config.RenamedField{
SubFieldRenames: map[string]aptos.RenamedField{
"header": {
NewName: "Header",
SubFieldRenames: map[string]config.RenamedField{
SubFieldRenames: map[string]aptos.RenamedField{
"source_chain_selector": {
NewName: "SourceChainSelector",
},
Expand Down Expand Up @@ -367,7 +367,7 @@
},
"token_amounts": {
NewName: "TokenAmounts",
SubFieldRenames: map[string]config.RenamedField{
SubFieldRenames: map[string]aptos.RenamedField{
"source_pool_address": {
NewName: "SourcePoolAddress",
},
Expand Down
18 changes: 9 additions & 9 deletions core/scripts/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ require (
github.com/umbracle/fastrlp v0.0.0-20220527094140-59d5dd30e722
github.com/urfave/cli v1.22.17
go.uber.org/zap v1.28.0
golang.org/x/sync v0.21.0
golang.org/x/text v0.38.0
golang.org/x/sync v0.22.0
golang.org/x/text v0.40.0
google.golang.org/protobuf v1.36.11
gopkg.in/yaml.v3 v3.0.1
k8s.io/api v0.35.3
Expand Down Expand Up @@ -488,7 +488,7 @@ require (
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966 // indirect
github.com/smartcontractkit/ccip-owner-contracts v0.1.0 // indirect
github.com/smartcontractkit/chainlink-aptos v0.0.0-20260708114855-e953eeb028a7 // indirect
github.com/smartcontractkit/chainlink-aptos/codec v0.0.0-20260708114855-e953eeb028a7 // indirect
github.com/smartcontractkit/chainlink-aptos/codec v0.0.0-20260709173141-5c4e651312f7 // indirect
github.com/smartcontractkit/chainlink-ccip v0.1.1-solana.0.20260625091148-e5618f5682ee // indirect
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20260624154507-ea7ff77a0ddb // indirect
github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings v0.0.0-20260624154507-ea7ff77a0ddb // indirect
Expand Down Expand Up @@ -614,15 +614,15 @@ require (
go.yaml.in/yaml/v3 v3.0.4 // indirect
go.yaml.in/yaml/v4 v4.0.0-rc.4 // indirect
golang.org/x/arch v0.22.0 // indirect
golang.org/x/crypto v0.53.0 // indirect
golang.org/x/crypto v0.54.0 // indirect
golang.org/x/exp v0.0.0-20260508232706-74f9aab9d74a // indirect
golang.org/x/mod v0.36.0 // indirect
golang.org/x/net v0.55.0 // indirect
golang.org/x/mod v0.37.0 // indirect
golang.org/x/net v0.56.0 // indirect
golang.org/x/oauth2 v0.36.0 // indirect
golang.org/x/sys v0.46.0 // indirect
golang.org/x/term v0.44.0 // indirect
golang.org/x/sys v0.47.0 // indirect
golang.org/x/term v0.45.0 // indirect
golang.org/x/time v0.15.0 // indirect
golang.org/x/tools v0.45.0 // indirect
golang.org/x/tools v0.47.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
gonum.org/v1/gonum v0.17.0 // indirect
google.golang.org/genproto v0.0.0-20250505200425-f936aa4a68b2 // indirect
Expand Down
Loading
Loading