Skip to content

Commit

Permalink
updated CCIP example
Browse files Browse the repository at this point in the history
  • Loading branch information
silaslenihan committed Nov 20, 2024
1 parent e0d37f3 commit 13cf316
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 19 deletions.
1 change: 0 additions & 1 deletion .github/actions/projectserum_version/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ runs:
run: |
PSVERSION=$(make projectserum_version)
echo "PSVERSION=${PSVERSION}" >>$GITHUB_OUTPUT
EVM2AnyRampMessage
51 changes: 33 additions & 18 deletions pkg/solana/chainwriter/chain_writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@ import (
"github.com/smartcontractkit/chainlink-solana/pkg/solana/chainwriter"
)

type RegistryTokenState struct {
PoolProgram [32]byte `json:"pool_program"`
PoolConfig [32]byte `json:"pool_config"`
TokenProgram [32]byte `json:"token_program"`
TokenState [32]byte `json:"token_state"`
PoolAssociatedTokenAccount [32]byte `json:"pool_associated_token_account"`
}

func TestGetAddresses(t *testing.T) {
// Fake constant addresses for the purpose of this example.
registryAddress := "4Nn9dsYBcSTzRbK9hg9kzCUdrCSkMZq1UR6Vw1Tkaf6A"
Expand Down Expand Up @@ -95,7 +87,7 @@ func TestGetAddresses(t *testing.T) {
// A) The PublicKey lookup resolves to multiple addresses (i.e. multiple token addresses)
// B) The Seeds or ValueSeeds resolve to multiple values
chainwriter.PDALookups{
Name: "PerChainRateLimit",
Name: "PerChainConfig",
// PublicKey is a constant account in this case, not a lookup.
PublicKey: chainwriter.AccountConstant{
Address: registryAddress,
Expand All @@ -105,6 +97,7 @@ func TestGetAddresses(t *testing.T) {
// Similar to the RegistryTokenState above, the user is looking up PDA accounts based on the dest tokens.
Seeds: []chainwriter.Lookup{
chainwriter.AccountLookup{Location: "Message.TokenAmounts.DestTokenAddress"},
chainwriter.AccountLookup{Location: "Message.Header.DestChainSelector"},
},
IsSigner: false,
IsWritable: false,
Expand Down Expand Up @@ -182,6 +175,22 @@ func TestGetAddresses(t *testing.T) {
IsSigner: false,
IsWritable: false,
},
// PDA lookup to get the Router Chain Config
chainwriter.PDALookups{
Name: "RouterChainConfig",
// The public key is a constant Router address.
PublicKey: chainwriter.AccountConstant{
Address: routerProgramAddress,
IsSigner: false,
IsWritable: false,
},
Seeds: []chainwriter.Lookup{
chainwriter.AccountLookup{Location: "Message.Header.DestChainSelector"},
chainwriter.AccountLookup{Location: "Message.Header.SourceChainSelector"},
},
IsSigner: false,
IsWritable: false,
},
// PDA lookup to get the Router Report Accounts.
chainwriter.PDALookups{
Name: "RouterReportAccount",
Expand Down Expand Up @@ -213,7 +222,7 @@ func TestGetAddresses(t *testing.T) {
// with the public key to generate one or multiple PDA accounts.
Seeds: []chainwriter.Lookup{
chainwriter.AccountLookup{Location: "Message.Receiver"},
chainwriter.AccountLookup{Location: "Message.DestChainSelector"},
chainwriter.AccountLookup{Location: "Message.Header.DestChainSelector"},
},
},
// Account constant
Expand Down Expand Up @@ -261,7 +270,20 @@ func TestGetAddresses(t *testing.T) {
},
},
Accounts: []chainwriter.Lookup{

// Account constant
chainwriter.AccountConstant{
Name: "RouterProgram",
Address: routerProgramAddress,
IsSigner: false,
IsWritable: false,
},
// Account constant
chainwriter.AccountConstant{
Name: "RouterAccountConfig",
Address: routerAccountConfigAddress,
IsSigner: false,
IsWritable: false,
},
// PDA lookup to get the Router Report Accounts.
chainwriter.PDALookups{
Name: "RouterReportAccount",
Expand All @@ -281,13 +303,6 @@ func TestGetAddresses(t *testing.T) {
IsWritable: false,
},
// Account constant
chainwriter.AccountConstant{
Name: "CPISigner",
Address: cpiSignerAddress,
IsSigner: true,
IsWritable: false,
},
// Account constant
chainwriter.AccountConstant{
Name: "SystemProgram",
Address: systemProgramAddress,
Expand Down

0 comments on commit 13cf316

Please sign in to comment.