Skip to content

Commit

Permalink
Updated CCIP Config Example to be up-to-date
Browse files Browse the repository at this point in the history
  • Loading branch information
silaslenihan committed Jan 10, 2025
1 parent e2a9566 commit 0ff41fb
Showing 1 changed file with 70 additions and 40 deletions.
110 changes: 70 additions & 40 deletions pkg/solana/chainwriter/ccip_example_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@ import (

func TestConfig() {
// Fake constant addresses for the purpose of this example.
registryAddress := "4Nn9dsYBcSTzRbK9hg9kzCUdrCSkMZq1UR6Vw1Tkaf6A"
routerProgramAddress := "4Nn9dsYBcSTzRbK9hg9kzCUdrCSkMZq1UR6Vw1Tkaf6B"
routerAccountConfigAddress := "4Nn9dsYBcSTzRbK9hg9kzCUdrCSkMZq1UR6Vw1Tkaf6C"
cpiSignerAddress := "4Nn9dsYBcSTzRbK9hg9kzCUdrCSkMZq1UR6Vw1Tkaf6D"
systemProgramAddress := "4Nn9dsYBcSTzRbK9hg9kzCUdrCSkMZq1UR6Vw1Tkaf6E"
computeBudgetProgramAddress := "4Nn9dsYBcSTzRbK9hg9kzCUdrCSkMZq1UR6Vw1Tkaf6F"
sysvarProgramAddress := "4Nn9dsYBcSTzRbK9hg9kzCUdrCSkMZq1UR6Vw1Tkaf6G"
commonAddressesLookupTable := solana.MustPublicKeyFromBase58("4Nn9dsYBcSTzRbK9hg9kzCUdrCSkMZq1UR6Vw1Tkaf6H")
routerLookupTable := solana.MustPublicKeyFromBase58("4Nn9dsYBcSTzRbK9hg9kzCUdrCSkMZq1UR6Vw1Tkaf6I")

computeBudgetProgramAddress := solana.ComputeBudget.String()
sysvarProgramAddress := solana.SysVarInstructionsPubkey.String()

userAddress := "4Nn9dsYBcSTzRbK9hg9kzCUdrCSkMZq1UR6Vw1Tkaf6J"

executionReportSingleChainIDL := `{"name":"ExecutionReportSingleChain","type":{"kind":"struct","fields":[{"name":"source_chain_selector","type":"u64"},{"name":"message","type":{"defined":"Any2SolanaRampMessage"}},{"name":"root","type":{"array":["u8",32]}},{"name":"proofs","type":{"vec":{"array":["u8",32]}}}]}},{"name":"Any2SolanaRampMessage","type":{"kind":"struct","fields":[{"name":"header","type":{"defined":"RampMessageHeader"}},{"name":"sender","type":{"vec":"u8"}},{"name":"data","type":{"vec":"u8"}},{"name":"receiver","type":{"array":["u8",32]}},{"name":"extra_args","type":{"defined":"SolanaExtraArgs"}}]}},{"name":"RampMessageHeader","type":{"kind":"struct","fields":[{"name":"message_id","type":{"array":["u8",32]}},{"name":"source_chain_selector","type":"u64"},{"name":"dest_chain_selector","type":"u64"},{"name":"sequence_number","type":"u64"},{"name":"nonce","type":"u64"}]}},{"name":"SolanaExtraArgs","type":{"kind":"struct","fields":[{"name":"compute_units","type":"u32"},{"name":"allow_out_of_order_execution","type":"bool"}]}}`
Expand Down Expand Up @@ -42,7 +39,7 @@ func TestConfig() {
Accounts: PDALookups{
Name: "RegistryTokenState",
PublicKey: AccountConstant{
Address: registryAddress,
Address: routerProgramAddress,
IsSigner: false,
IsWritable: false,
},
Expand All @@ -60,7 +57,6 @@ func TestConfig() {
// these lookup tables and appends them to the transaction to reduce the size of the transaction.
StaticLookupTables: []solana.PublicKey{
commonAddressesLookupTable,
routerLookupTable,
},
},
// The Accounts field is where the user specifies which accounts to include in the transaction. Each Lookup
Expand All @@ -81,7 +77,7 @@ func TestConfig() {
Name: "PerChainConfig",
// PublicKey is a constant account in this case, not a lookup.
PublicKey: AccountConstant{
Address: registryAddress,
Address: routerProgramAddress,
IsSigner: false,
IsWritable: false,
},
Expand Down Expand Up @@ -132,7 +128,7 @@ func TestConfig() {
// Account constant
AccountConstant{
Name: "Registry",
Address: registryAddress,
Address: routerProgramAddress,
IsSigner: false,
IsWritable: false,
},
Expand All @@ -141,7 +137,7 @@ func TestConfig() {
Name: "RegistryTokenConfig",
// constant public key
PublicKey: AccountConstant{
Address: registryAddress,
Address: routerProgramAddress,
IsSigner: false,
IsWritable: false,
},
Expand All @@ -159,10 +155,31 @@ func TestConfig() {
IsSigner: false,
IsWritable: false,
},
// Account constant
AccountConstant{
Name: "RouterAccountConfig",
Address: routerAccountConfigAddress,
// PDA lokoup with constant seed
PDALookups{
Name: "RouterAccountConfig",
PublicKey: AccountConstant{
Address: routerProgramAddress,
IsSigner: false,
IsWritable: false,
},
Seeds: []Seed{
{Static: []byte("config")},
},
IsSigner: false,
IsWritable: false,
},
// PDA lokoup with constant seed
PDALookups{
Name: "RouterAccountState",
PublicKey: AccountConstant{
Address: routerProgramAddress,
IsSigner: false,
IsWritable: false,
},
Seeds: []Seed{
{Static: []byte("state")},
},
IsSigner: false,
IsWritable: false,
},
Expand Down Expand Up @@ -216,18 +233,18 @@ func TestConfig() {
{Dynamic: AccountLookup{Location: "Message.Header.DestChainSelector"}},
},
},
// Account constant
AccountConstant{
Name: "CPISigner",
Address: cpiSignerAddress,
IsSigner: true,
IsWritable: false,
},
// Account constant
AccountConstant{
Name: "SystemProgram",
Address: systemProgramAddress,
IsSigner: true,
// PDA lokoup with constant seed
PDALookups{
Name: "CPISigner",
PublicKey: AccountConstant{
Address: routerProgramAddress,
IsSigner: false,
IsWritable: false,
},
Seeds: []Seed{
{Static: []byte("external_token_pools_signer")},
},
IsSigner: false,
IsWritable: false,
},
// Account constant
Expand Down Expand Up @@ -257,7 +274,6 @@ func TestConfig() {
LookupTables: LookupTables{
StaticLookupTables: []solana.PublicKey{
commonAddressesLookupTable,
routerLookupTable,
},
},
Accounts: []Lookup{
Expand All @@ -268,10 +284,31 @@ func TestConfig() {
IsSigner: false,
IsWritable: false,
},
// Account constant
AccountConstant{
Name: "RouterAccountConfig",
Address: routerAccountConfigAddress,
// PDA lokoup with constant seed
PDALookups{
Name: "RouterAccountConfig",
PublicKey: AccountConstant{
Address: routerProgramAddress,
IsSigner: false,
IsWritable: false,
},
Seeds: []Seed{
{Static: []byte("config")},
},
IsSigner: false,
IsWritable: false,
},
// PDA lokoup with constant seed
PDALookups{
Name: "RouterAccountState",
PublicKey: AccountConstant{
Address: routerProgramAddress,
IsSigner: false,
IsWritable: false,
},
Seeds: []Seed{
{Static: []byte("state")},
},
IsSigner: false,
IsWritable: false,
},
Expand All @@ -294,13 +331,6 @@ func TestConfig() {
IsWritable: false,
},
// Account constant
AccountConstant{
Name: "SystemProgram",
Address: systemProgramAddress,
IsSigner: true,
IsWritable: false,
},
// Account constant
AccountConstant{
Name: "ComputeBudgetProgram",
Address: computeBudgetProgramAddress,
Expand Down

0 comments on commit 0ff41fb

Please sign in to comment.