Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated ccip transform args to use predefined contract names #1068

Merged
merged 5 commits into from
Feb 11, 2025
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
13 changes: 7 additions & 6 deletions pkg/solana/chainwriter/chain_writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
idl "github.com/smartcontractkit/chainlink-ccip/chains/solana"
"github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings/ccip_offramp"
"github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings/ccip_router"
ccipconsts "github.com/smartcontractkit/chainlink-ccip/pkg/consts"
"github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3"

"github.com/smartcontractkit/chainlink-solana/pkg/monitoring/testutils"
Expand Down Expand Up @@ -749,9 +750,9 @@ func TestChainWriter_CCIPOfframp(t *testing.T) {
// simplified CCIP Config - does not contain full account list
ccipCWConfig := chainwriter.ChainWriterConfig{
Programs: map[string]chainwriter.ProgramConfig{
"ccip-offramp": {
ccipconsts.ContractNameOffRamp: {
Methods: map[string]chainwriter.MethodConfig{
"execute": {
ccipconsts.MethodExecute: {
FromAddress: admin.String(),
InputModifications: []codec.ModifierConfig{
&codec.RenameModifierConfig{
Expand Down Expand Up @@ -795,7 +796,7 @@ func TestChainWriter_CCIPOfframp(t *testing.T) {
},
},
},
"commit": {
ccipconsts.MethodCommit: {
FromAddress: admin.String(),
InputModifications: []codec.ModifierConfig{
&codec.RenameModifierConfig{
Expand Down Expand Up @@ -827,7 +828,7 @@ func TestChainWriter_CCIPOfframp(t *testing.T) {
IDL: ccipOfframpIDL,
},
// Requires only the IDL for the CCIPArgsTransform to fetch the TokenAdminRegistry
"ccip-router": {
ccipconsts.ContractNameRouter: {
IDL: ccipRouterIDL,
},
},
Expand Down Expand Up @@ -899,7 +900,7 @@ func TestChainWriter_CCIPOfframp(t *testing.T) {
},
}

submitErr := cw.SubmitTransaction(ctx, "ccip-offramp", "execute", args, txID, offrampAddr.String(), nil, nil)
submitErr := cw.SubmitTransaction(ctx, ccipconsts.ContractNameOffRamp, ccipconsts.MethodExecute, args, txID, offrampAddr.String(), nil, nil)
require.NoError(t, submitErr)
})

Expand Down Expand Up @@ -947,7 +948,7 @@ func TestChainWriter_CCIPOfframp(t *testing.T) {
return true
}), &txID, mock.Anything).Return(nil).Once()

submitErr := cw.SubmitTransaction(ctx, "ccip-offramp", "commit", args, txID, offrampAddr.String(), nil, nil)
submitErr := cw.SubmitTransaction(ctx, ccipconsts.ContractNameOffRamp, ccipconsts.MethodCommit, args, txID, offrampAddr.String(), nil, nil)
require.NoError(t, submitErr)
})
}
Expand Down
9 changes: 5 additions & 4 deletions pkg/solana/chainwriter/transform_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/gagliardetto/solana-go"
"github.com/smartcontractkit/chainlink-ccip/chains/solana/gobindings/ccip_offramp"
ccipconsts "github.com/smartcontractkit/chainlink-ccip/pkg/consts"
"github.com/smartcontractkit/chainlink-ccip/pkg/types/ccipocr3"
)

Expand Down Expand Up @@ -38,9 +39,9 @@ func FindTransform(id string) (func(context.Context, *SolanaChainWriterService,
// with the indexes of the token pool addresses in the accounts slice.
func CCIPArgsTransform(ctx context.Context, cw *SolanaChainWriterService, args any, accounts solana.AccountMetaSlice, toAddress string) (any, error) {
// Fetch offramp config to use to fetch the router address
offrampProgramConfig, ok := cw.config.Programs["ccip-offramp"]
offrampProgramConfig, ok := cw.config.Programs[ccipconsts.ContractNameOffRamp]
if !ok {
return nil, fmt.Errorf("ccip-offramp program not found in config")
return nil, fmt.Errorf("%s program not found in config", ccipconsts.ContractNameOffRamp)
}
// PDA lookup to fetch router address
routerAddrLookup := PDALookups{
Expand All @@ -67,9 +68,9 @@ func CCIPArgsTransform(ctx context.Context, cw *SolanaChainWriterService, args a
}

// Fetch router config to use to fetch TokenAdminRegistry
routerProgramConfig, ok := cw.config.Programs["ccip-router"]
routerProgramConfig, ok := cw.config.Programs[ccipconsts.ContractNameRouter]
if !ok {
return nil, fmt.Errorf("ccip-router program not found in config")
return nil, fmt.Errorf("%s program not found in config", ccipconsts.ContractNameRouter)
}

routerAddress := accountMetas[0].PublicKey
Expand Down
Loading