From 8d9b97c9680ba9bbc1920f6ae33ed2bbc1a9ea19 Mon Sep 17 00:00:00 2001 From: Silas Lenihan Date: Fri, 17 Jan 2025 15:14:18 -0500 Subject: [PATCH] Cleaned up example --- pkg/solana/chainwriter/ccip_example_config.go | 17 ++++++++++++----- pkg/solana/chainwriter/helpers.go | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/pkg/solana/chainwriter/ccip_example_config.go b/pkg/solana/chainwriter/ccip_example_config.go index 4676bf9c9..04e218960 100644 --- a/pkg/solana/chainwriter/ccip_example_config.go +++ b/pkg/solana/chainwriter/ccip_example_config.go @@ -5,11 +5,21 @@ import ( "fmt" "reflect" + ag_binary "github.com/gagliardetto/binary" "github.com/gagliardetto/solana-go" ) const registryAddress = "4Nn9dsYBcSTzRbK9hg9kzCUdrCSkMZq1UR6Vw1Tkaf6A" +// Should match type here: https://github.com/smartcontractkit/chainlink-ccip/blob/6bb9583526ce7c281005d66ffdf4a5300fc8ddc9/chains/solana/gobindings/ccip_router/accounts.go#L707-L713 +type TokenAdminRegistry struct { + Version uint8 + Administrator solana.PublicKey + PendingAdministrator solana.PublicKey + LookupTable solana.PublicKey + WritableIndexes [2]ag_binary.Uint128 +} + func TestConfig() { // Fake constant addresses for the purpose of this example. routerProgramAddress := "4Nn9dsYBcSTzRbK9hg9kzCUdrCSkMZq1UR6Vw1Tkaf6B" @@ -55,6 +65,7 @@ func TestConfig() { IsSigner: false, IsWritable: false, InternalField: InternalField{ + Type: reflect.TypeOf(TokenAdminRegistry{}), Location: "LookupTable", }, }, @@ -403,15 +414,11 @@ func CCIPArgsTransform(ctx context.Context, cw *SolanaChainWriterService, args a Accounts: PDALookups{ Name: "RegistryTokenState", PublicKey: AccountConstant{ - Address: registryAddress, - IsSigner: false, - IsWritable: false, + Address: registryAddress, }, Seeds: []Seed{ {Dynamic: AccountLookup{Location: "Message.TokenAmounts.DestTokenAddress"}}, }, - IsSigner: false, - IsWritable: false, InternalField: InternalField{ Type: reflect.TypeOf(DataAccount{}), Location: "LookupTable", diff --git a/pkg/solana/chainwriter/helpers.go b/pkg/solana/chainwriter/helpers.go index 7d146a25a..c67bb7ca5 100644 --- a/pkg/solana/chainwriter/helpers.go +++ b/pkg/solana/chainwriter/helpers.go @@ -52,7 +52,7 @@ func GetValuesAtLocation(args any, location string) ([][]byte, error) { binary.LittleEndian.PutUint64(buf, num) vals = append(vals, buf) } else { - return nil, fmt.Errorf("invalid value format at path: %s", location) + return nil, fmt.Errorf("invalid value format at path: %s, type: %s", location, reflect.TypeOf(value).String()) } }