Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
PabloMansanet committed Dec 23, 2024
1 parent d6cd830 commit 9b9cbf0
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 86 deletions.
12 changes: 2 additions & 10 deletions chains/solana/contracts/programs/ccip-router/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -696,16 +696,6 @@ pub mod ccip_router {
/// The message will be sent to the receiver on the destination chain selector.
/// This message emits the event CCIPSendRequested with all the necessary data to be retrieved by the OffChain Code
///
/// # Additional accounts
///
/// In addition to the fixed amount of accounts defined in the `GetFee` context,
/// the following accounts must be provided:
///
/// * First, the billing token config accounts for each token involved, including the
/// fee token, sequentially.
/// * Then, the per chain / per token config of those tokens, sequentially in the same
/// order, for the destination chain.
///
/// # Arguments
///
/// * `ctx` - The context containing the accounts required for sending the message.
Expand All @@ -721,6 +711,8 @@ pub mod ccip_router {

let dest_chain = &mut ctx.accounts.dest_chain_state;

// TODO this is incorrect and breaks when transfering a token. Derive these accounts
// from the lookup table instead.
let (token_billing_config_accounts, per_chain_per_token_config_accounts) =
get_accounts_for_fee_retrieval(&ctx.remaining_accounts, &message)?;
let fee = fee_for_msg(
Expand Down
10 changes: 0 additions & 10 deletions chains/solana/contracts/target/idl/ccip_router.json
Original file line number Diff line number Diff line change
Expand Up @@ -1036,16 +1036,6 @@
"The message will be sent to the receiver on the destination chain selector.",
"This message emits the event CCIPSendRequested with all the necessary data to be retrieved by the OffChain Code",
"",
"# Additional accounts",
"",
"In addition to the fixed amount of accounts defined in the `GetFee` context,",
"the following accounts must be provided:",
"",
"* First, the billing token config accounts for each token involved, including the",
"fee token, sequentially.",
"* Then, the per chain / per token config of those tokens, sequentially in the same",
"order, for the destination chain.",
"",
"# Arguments",
"",
"* `ctx` - The context containing the accounts required for sending the message.",
Expand Down
47 changes: 1 addition & 46 deletions chains/solana/contracts/tests/ccip/ccip_router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1878,32 +1878,6 @@ func TestCCIPRouter(t *testing.T) {
instruction, err := raw.ValidateAndBuild()
require.NoError(t, err)

// // TESTBLOCK accounts exist
// {
// deserializedTokenConfigPda := ccip_router.BillingTokenConfigWrapper{}
// deserializedBillingPda := ccip_router.PerChainPerTokenConfig{}
// deserializedEvmDestChainStatePda := ccip_router.DestChainState{}

// err = utils.GetAccountDataBorshInto(ctx, solanaGoClient, wsol.billingConfigPDA, config.DefaultCommitment, &deserializedTokenConfigPda)
// require.NoError(t, err)
// t.Log(deserializedTokenConfigPda)
// err := utils.GetAccountDataBorshInto(ctx, solanaGoClient, token0BillingConfigPda, config.DefaultCommitment, &deserializedTokenConfigPda)
// require.NoError(t, err)
// t.Log(deserializedTokenConfigPda)

// err = utils.GetAccountDataBorshInto(ctx, solanaGoClient, wsol.perChainPerTokenConfigPDA, config.DefaultCommitment, &deserializedBillingPda)
// require.NoError(t, err)
// t.Log(deserializedBillingPda)
// err = utils.GetAccountDataBorshInto(ctx, solanaGoClient, token0PerChainPerConfigPda, config.DefaultCommitment, &deserializedBillingPda)
// require.NoError(t, err)
// t.Log(deserializedBillingPda)

// err = utils.GetAccountDataBorshInto(ctx, solanaGoClient, config.EvmDestChainStatePDA, config.DefaultCommitment, &deserializedEvmDestChainStatePda)
// require.NoError(t, err)
// t.Log(deserializedEvmDestChainStatePda)

// }

feeResult := utils.SendAndConfirm(ctx, t, solanaGoClient, []solana.Instruction{instruction}, user, config.DefaultCommitment)
require.NotNil(t, feeResult)
t.Log(feeResult.Meta.LogMessages)
Expand Down Expand Up @@ -2071,8 +2045,6 @@ func TestCCIPRouter(t *testing.T) {
config.ExternalTokenPoolsSignerPDA,
)
raw.GetFeeTokenUserAssociatedAccountAccount().WRITE()
raw.AccountMetaSlice.Append(solana.Meta(wsol.billingConfigPDA))
raw.AccountMetaSlice.Append(solana.Meta(wsol.perChainPerTokenConfigPDA))
instruction, err := raw.ValidateAndBuild()
require.NoError(t, err)
result := testutils.SendAndConfirm(ctx, t, solanaGoClient, []solana.Instruction{instruction}, user, config.DefaultCommitment)
Expand Down Expand Up @@ -2134,8 +2106,6 @@ func TestCCIPRouter(t *testing.T) {
config.ExternalTokenPoolsSignerPDA,
)
raw.GetFeeTokenUserAssociatedAccountAccount().WRITE()
raw.AccountMetaSlice.Append(solana.Meta(wsol.billingConfigPDA))
raw.AccountMetaSlice.Append(solana.Meta(wsol.perChainPerTokenConfigPDA))
instruction, err := raw.ValidateAndBuild()
require.NoError(t, err)
result := testutils.SendAndConfirm(ctx, t, solanaGoClient, []solana.Instruction{instruction}, user, config.DefaultCommitment)
Expand Down Expand Up @@ -2198,8 +2168,6 @@ func TestCCIPRouter(t *testing.T) {
config.ExternalTokenPoolsSignerPDA,
)
raw.GetFeeTokenUserAssociatedAccountAccount().WRITE()
raw.AccountMetaSlice.Append(solana.Meta(wsol.billingConfigPDA))
raw.AccountMetaSlice.Append(solana.Meta(wsol.perChainPerTokenConfigPDA))
instruction, err := raw.ValidateAndBuild()
require.NoError(t, err)
result := testutils.SendAndConfirm(ctx, t, solanaGoClient, []solana.Instruction{instruction}, user, config.DefaultCommitment)
Expand Down Expand Up @@ -2261,8 +2229,6 @@ func TestCCIPRouter(t *testing.T) {
config.ExternalTokenPoolsSignerPDA,
)
raw.GetFeeTokenUserAssociatedAccountAccount().WRITE()
raw.AccountMetaSlice.Append(solana.Meta(token2022.billingConfigPDA))
raw.AccountMetaSlice.Append(solana.Meta(token2022.perChainPerTokenConfigPDA))
instruction, err := raw.ValidateAndBuild()
require.NoError(t, err)
result := testutils.SendAndConfirm(ctx, t, solanaGoClient, []solana.Instruction{instruction}, user, config.DefaultCommitment)
Expand Down Expand Up @@ -2321,8 +2287,6 @@ func TestCCIPRouter(t *testing.T) {
config.ExternalTokenPoolsSignerPDA,
)
raw.GetFeeTokenUserAssociatedAccountAccount().WRITE()
raw.AccountMetaSlice.Append(solana.Meta(wsol.billingConfigPDA))
raw.AccountMetaSlice.Append(solana.Meta(wsol.perChainPerTokenConfigPDA))
instruction, err := raw.ValidateAndBuild()
require.NoError(t, err)

Expand Down Expand Up @@ -2356,8 +2320,6 @@ func TestCCIPRouter(t *testing.T) {
config.ExternalTokenPoolsSignerPDA,
)
raw.GetFeeTokenUserAssociatedAccountAccount().WRITE()
raw.AccountMetaSlice.Append(solana.Meta(wsol.billingConfigPDA))
raw.AccountMetaSlice.Append(solana.Meta(wsol.perChainPerTokenConfigPDA))
instruction, err := raw.ValidateAndBuild()
require.NoError(t, err)

Expand Down Expand Up @@ -2391,8 +2353,7 @@ func TestCCIPRouter(t *testing.T) {
)

// do NOT mark the user ATA as writable
raw.AccountMetaSlice.Append(solana.Meta(wsol.billingConfigPDA))
raw.AccountMetaSlice.Append(solana.Meta(wsol.perChainPerTokenConfigPDA))

instruction, err := raw.ValidateAndBuild()
require.NoError(t, err)

Expand Down Expand Up @@ -2439,8 +2400,6 @@ func TestCCIPRouter(t *testing.T) {
config.ExternalTokenPoolsSignerPDA,
)
raw.GetFeeTokenUserAssociatedAccountAccount().WRITE()
raw.AccountMetaSlice.Append(solana.Meta(wsol.billingConfigPDA))
raw.AccountMetaSlice.Append(solana.Meta(wsol.perChainPerTokenConfigPDA))
instruction, err := raw.ValidateAndBuild()
require.NoError(t, err)

Expand Down Expand Up @@ -2483,8 +2442,6 @@ func TestCCIPRouter(t *testing.T) {
config.ExternalTokenPoolsSignerPDA,
)
raw.GetFeeTokenUserAssociatedAccountAccount().WRITE()
raw.AccountMetaSlice.Append(solana.Meta(token2022.billingConfigPDA))
raw.AccountMetaSlice.Append(solana.Meta(token2022.perChainPerTokenConfigPDA))
instruction, err := raw.ValidateAndBuild()
require.NoError(t, err)
testutils.SendAndFailWith(ctx, t, solanaGoClient, []solana.Instruction{instruction}, anotherUser, config.DefaultCommitment, []string{ccip_router.InvalidInputs_CcipRouterError.String()})
Expand Down Expand Up @@ -2518,8 +2475,6 @@ func TestCCIPRouter(t *testing.T) {
config.ExternalTokenPoolsSignerPDA,
)
raw.GetFeeTokenUserAssociatedAccountAccount().WRITE()
raw.AccountMetaSlice.Append(solana.Meta(token2022.billingConfigPDA))
raw.AccountMetaSlice.Append(solana.Meta(token2022.perChainPerTokenConfigPDA))
instruction, err := raw.ValidateAndBuild()
require.NoError(t, err)
result := testutils.SendAndConfirm(ctx, t, solanaGoClient, []solana.Instruction{instruction}, anotherUser, config.DefaultCommitment)
Expand Down
10 changes: 0 additions & 10 deletions chains/solana/gobindings/ccip_router/CcipSend.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions chains/solana/gobindings/ccip_router/instructions.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9b9cbf0

Please sign in to comment.