Skip to content

Commit

Permalink
Cleaned up example
Browse files Browse the repository at this point in the history
  • Loading branch information
silaslenihan committed Jan 17, 2025
1 parent da4f63e commit 8d9b97c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
17 changes: 12 additions & 5 deletions pkg/solana/chainwriter/ccip_example_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -55,6 +65,7 @@ func TestConfig() {
IsSigner: false,
IsWritable: false,
InternalField: InternalField{
Type: reflect.TypeOf(TokenAdminRegistry{}),
Location: "LookupTable",
},
},
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion pkg/solana/chainwriter/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}

Expand Down

0 comments on commit 8d9b97c

Please sign in to comment.