Skip to content
Draft
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
67 changes: 67 additions & 0 deletions chain/mcms/adapters/chain_access.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package adapters

import (
aptoslib "github.com/aptos-labs/aptos-go-sdk"
"github.com/block-vision/sui-go-sdk/sui"
solrpc "github.com/gagliardetto/solana-go/rpc"
"github.com/smartcontractkit/mcms/sdk/evm"
mcmssui "github.com/smartcontractkit/mcms/sdk/sui"

"github.com/smartcontractkit/chainlink-deployments-framework/chain"
)

// ChainAccessAdapter adapts CLDF's chain.BlockChains into a selector + lookup style API.
// It used to make compatible with mcms lib chain access interface.
type ChainAccessAdapter struct {
inner chain.BlockChains
}

// Wrap returns a ChainAccessAdapter adapter around the given CLDF BlockChains.
func Wrap(inner chain.BlockChains) ChainAccessAdapter {
return ChainAccessAdapter{inner: inner}
}

// Selectors returns all known chain selectors (sorted by CLDF).
func (a ChainAccessAdapter) Selectors() []uint64 {
return a.inner.ListChainSelectors()
}

// EVMClient returns a EVM client for the given selector.
func (a ChainAccessAdapter) EVMClient(selector uint64) (evm.ContractDeployBackend, bool) {
ch, ok := a.inner.EVMChains()[selector]
if !ok {
return nil, false
}

return ch.Client, true
}

// SolanaClient returns the Solana RPC client for the given selector.
func (a ChainAccessAdapter) SolanaClient(selector uint64) (*solrpc.Client, bool) {
ch, ok := a.inner.SolanaChains()[selector]
if !ok {
return nil, false
}

return ch.Client, true
}

// AptosClient returns the Aptos RPC client for the given selector.
func (a ChainAccessAdapter) AptosClient(selector uint64) (aptoslib.AptosRpcClient, bool) {
ch, ok := a.inner.AptosChains()[selector]
if !ok {
return nil, false
}

return ch.Client, true
}

// SuiClient returns the Sui API client and signer for the given selector.
func (a ChainAccessAdapter) SuiClient(selector uint64) (sui.ISuiAPI, mcmssui.SuiSigner, bool) {

Check failure on line 60 in chain/mcms/adapters/chain_access.go

View workflow job for this annotation

GitHub Actions / Tests

undefined: mcmssui.SuiSigner
ch, ok := a.inner.SuiChains()[selector]
if !ok {
return nil, nil, false
}

return ch.Client, ch.Signer, true
}
84 changes: 84 additions & 0 deletions chain/mcms/adapters/chain_access_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package adapters

import (
"testing"

solrpc "github.com/gagliardetto/solana-go/rpc"
"github.com/stretchr/testify/require"

"github.com/smartcontractkit/chainlink-deployments-framework/chain"
"github.com/smartcontractkit/chainlink-deployments-framework/chain/aptos"
"github.com/smartcontractkit/chainlink-deployments-framework/chain/evm"
"github.com/smartcontractkit/chainlink-deployments-framework/chain/solana"
chainsui "github.com/smartcontractkit/chainlink-deployments-framework/chain/sui"
)

func TestChainAccess_UnknownSelector(t *testing.T) {
t.Parallel()

a := Wrap(chain.NewBlockChains(nil))

evmClient, ok := a.EVMClient(999)
require.False(t, ok)
require.Nil(t, evmClient)

solClient, ok := a.SolanaClient(999)
require.False(t, ok)
require.Nil(t, solClient)

aptosClient, ok := a.AptosClient(999)
require.False(t, ok)
require.Nil(t, aptosClient)

suiClient, suiSigner, ok := a.SuiClient(999)
require.False(t, ok)
require.Nil(t, suiClient)
require.Nil(t, suiSigner)
}

func TestChainAccess_SelectorsAndLookups(t *testing.T) {
t.Parallel()

const (
evmSel = uint64(111)
solSel = uint64(222)
aptosSel = uint64(333)
suiSel = uint64(444)
)

evmOnchain := evm.NewMockOnchainClient(t)
solClient := solrpc.New("http://example.invalid")
suiSigner, err := chainsui.NewSignerFromSeed(make([]byte, 32))
require.NoError(t, err)

chains := chain.NewBlockChains(map[uint64]chain.BlockChain{
evmSel: evm.Chain{Selector: evmSel, Client: evmOnchain},
solSel: solana.Chain{Selector: solSel, Client: solClient},
aptosSel: aptos.Chain{Selector: aptosSel, Client: nil},
suiSel: chainsui.Chain{
ChainMetadata: chainsui.ChainMetadata{Selector: suiSel},
Client: nil,
Signer: suiSigner,
},
})

a := Wrap(chains)
require.Equal(t, chains.ListChainSelectors(), a.Selectors())

gotEVM, ok := a.EVMClient(evmSel)
require.True(t, ok)
require.Equal(t, evmOnchain, gotEVM)

gotSol, ok := a.SolanaClient(solSel)
require.True(t, ok)
require.Equal(t, solClient, gotSol)

gotAptos, ok := a.AptosClient(aptosSel)
require.True(t, ok)
require.Nil(t, gotAptos)

gotSuiClient, gotSuiSigner, ok := a.SuiClient(suiSel)
require.True(t, ok)
require.Nil(t, gotSuiClient)
require.Equal(t, suiSigner, gotSuiSigner)
}
34 changes: 17 additions & 17 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/smartcontractkit/chainlink-deployments-framework

go 1.24.5
go 1.25.3

replace github.com/fbsobreira/gotron-sdk => github.com/smartcontractkit/chainlink-tron/relayer/gotron-sdk v0.0.4

Expand All @@ -15,7 +15,7 @@ require (
github.com/aws/aws-sdk-go-v2/service/kms v1.49.4
github.com/block-vision/sui-go-sdk v1.1.2
github.com/cosmos/go-bip39 v1.0.0
github.com/ethereum/go-ethereum v1.16.7
github.com/ethereum/go-ethereum v1.16.8
github.com/fbsobreira/gotron-sdk v0.0.0-20250403083053-2943ce8c759b
github.com/gagliardetto/binary v0.8.0
github.com/gagliardetto/solana-go v1.13.0
Expand All @@ -27,9 +27,9 @@ require (
github.com/pelletier/go-toml/v2 v2.2.4
github.com/segmentio/ksuid v1.0.4
github.com/smartcontractkit/ccip-owner-contracts v0.1.0
github.com/smartcontractkit/chain-selectors v1.0.85
github.com/smartcontractkit/chain-selectors v1.0.89
github.com/smartcontractkit/chainlink-aptos v0.0.0-20251024142440-51f2ad2652a2
github.com/smartcontractkit/chainlink-ccip v0.1.1-solana.0.20250903115155-a68d8c28ae1d
github.com/smartcontractkit/chainlink-ccip v0.1.1-solana.0.20260107192940-0be702ef3ff5
github.com/smartcontractkit/chainlink-ccip/chains/solana v0.0.0-20250805210128-7f8a0f403c3a
github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings v0.0.0-20250805210128-7f8a0f403c3a
github.com/smartcontractkit/chainlink-protos/job-distributor v0.17.0
Expand All @@ -38,15 +38,15 @@ require (
github.com/smartcontractkit/chainlink-testing-framework/seth v1.51.2
github.com/smartcontractkit/chainlink-tron/relayer v0.0.11-0.20250815105909-75499abc4335
github.com/smartcontractkit/freeport v0.1.3-0.20250716200817-cb5dfd0e369e
github.com/smartcontractkit/libocr v0.0.0-20250707144819-babe0ec4e358
github.com/smartcontractkit/libocr v0.0.0-20250912173940-f3ab0246e23d
github.com/smartcontractkit/mcms v0.31.1
github.com/spf13/cobra v1.8.1
github.com/spf13/cobra v1.10.1
github.com/spf13/pflag v1.0.10
github.com/spf13/viper v1.21.0
github.com/stretchr/testify v1.11.1
github.com/testcontainers/testcontainers-go v0.39.0
github.com/testcontainers/testcontainers-go/modules/postgres v0.38.0
github.com/xssnick/tonutils-go v1.13.0
github.com/xssnick/tonutils-go v1.14.1
github.com/zksync-sdk/zksync2-go v1.1.1-0.20250620124214-2c742ee399c6
go.uber.org/zap v1.27.1
golang.org/x/crypto v0.46.0
Expand All @@ -71,10 +71,12 @@ require (
github.com/klauspost/cpuid/v2 v2.2.10 // indirect
github.com/lib/pq v1.10.9 // indirect
github.com/minio/sha256-simd v1.0.1 // indirect
github.com/smartcontractkit/chainlink-common v0.9.5-0.20250908082700-aa3f5927af8c // indirect
github.com/smartcontractkit/chainlink-common/pkg/chipingress v0.0.1 // indirect
github.com/smartcontractkit/chainlink-protos/cre/go v0.0.0-20250829155125-f4655b0b4605 // indirect
github.com/smartcontractkit/chainlink-common v0.9.6-0.20260109203210-6efadaacad99 // indirect
github.com/smartcontractkit/chainlink-common/pkg/chipingress v0.0.10 // indirect
github.com/smartcontractkit/chainlink-protos/cre/go v0.0.0-20251124151448-0448aefdaab9 // indirect
github.com/smartcontractkit/chainlink-protos/linking-service/go v0.0.0-20251002192024-d2ad9222409b // indirect
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/telemetry v0.0.0-20251208220230-2638a1023523 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)

Expand Down Expand Up @@ -159,13 +161,12 @@ require (
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v1.0.0 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/graph-gophers/graphql-go v1.5.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.0.1 // indirect
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.2 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 // indirect
github.com/hashicorp/go-bexpr v0.1.10 // indirect
github.com/hashicorp/go-hclog v1.6.3 // indirect
github.com/hashicorp/go-plugin v1.6.3 // indirect
github.com/hashicorp/go-plugin v1.7.0 // indirect
github.com/hashicorp/yamux v0.1.2 // indirect
github.com/hasura/go-graphql-client v0.14.5 // indirect
github.com/hdevalence/ed25519consensus v0.2.0 // indirect
Expand Down Expand Up @@ -218,7 +219,6 @@ require (
github.com/mostynb/zstdpool-freelist v0.0.0-20201229113212-927304c0c3b1 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/oasisprotocol/curve25519-voi v0.0.0-20230904125328-1f23a7beb09a // indirect
github.com/oklog/run v1.2.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.1.1 // indirect
Expand All @@ -231,7 +231,7 @@ require (
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
github.com/prometheus/client_golang v1.22.0 // indirect
github.com/prometheus/client_golang v1.23.0 // indirect
github.com/prometheus/client_model v0.6.2 // indirect
github.com/prometheus/common v0.65.0 // indirect
github.com/prometheus/procfs v0.16.1 // indirect
Expand All @@ -241,7 +241,7 @@ require (
github.com/rs/zerolog v1.34.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sagikazarmark/locafero v0.11.0 // indirect
github.com/samber/lo v1.49.1
github.com/samber/lo v1.52.0
github.com/santhosh-tekuri/jsonschema/v5 v5.3.1 // indirect
github.com/scylladb/go-reflectx v1.0.1 // indirect
github.com/shirou/gopsutil v3.21.11+incompatible // indirect
Expand Down Expand Up @@ -273,9 +273,9 @@ require (
github.com/x448/float16 v0.8.4 // indirect
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 // indirect
github.com/yusufpapurcu/wmi v1.2.4 // indirect
go.mongodb.org/mongo-driver v1.17.0 // indirect
go.mongodb.org/mongo-driver v1.17.2 // indirect
go.opentelemetry.io/auto/sdk v1.2.1 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.61.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.63.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0 // indirect
go.opentelemetry.io/otel v1.38.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.12.2 // indirect
Expand Down
Loading
Loading