diff --git a/programs/svm-spoke/src/instructions/deposit.rs b/programs/svm-spoke/src/instructions/deposit.rs index a522bdb37..0bc5c4eab 100644 --- a/programs/svm-spoke/src/instructions/deposit.rs +++ b/programs/svm-spoke/src/instructions/deposit.rs @@ -53,7 +53,6 @@ pub struct DepositV3<'info> { )] pub vault: InterfaceAccount<'info, TokenAccount>, - // TODO: why are we using mint::token_program,token::token_program and associated_token::token_program? #[account( mint::token_program = token_program, // IDL build fails when requiring `address = input_token` for mint, thus using a custom constraint. diff --git a/programs/svm-spoke/src/instructions/fill.rs b/programs/svm-spoke/src/instructions/fill.rs index 14083e360..37babe567 100644 --- a/programs/svm-spoke/src/instructions/fill.rs +++ b/programs/svm-spoke/src/instructions/fill.rs @@ -28,16 +28,16 @@ pub struct FillV3Relay<'info> { pub state: Account<'info, State>, #[account( - token::token_program = token_program, // TODO: consistent token imports + mint::token_program = token_program, address = relay_data.output_token @ CustomError::InvalidMint )] pub mint_account: InterfaceAccount<'info, Mint>, #[account( mut, - associated_token::mint = mint_account, // TODO: consistent token imports - associated_token::authority = signer, - associated_token::token_program = token_program + token::mint = mint_account, + token::authority = signer, + token::token_program = token_program )] pub relayer_token_account: InterfaceAccount<'info, TokenAccount>, diff --git a/programs/svm-spoke/src/instructions/slow_fill.rs b/programs/svm-spoke/src/instructions/slow_fill.rs index a2450cecf..843fe497b 100644 --- a/programs/svm-spoke/src/instructions/slow_fill.rs +++ b/programs/svm-spoke/src/instructions/slow_fill.rs @@ -146,7 +146,7 @@ pub struct ExecuteV3SlowRelayLeaf<'info> { pub fill_status: Account<'info, FillStatusAccount>, #[account( - token::token_program = token_program, + mint::token_program = token_program, address = slow_fill_leaf.relay_data.output_token @ CustomError::InvalidMint )] pub mint: InterfaceAccount<'info, Mint>, diff --git a/test/svm/SvmSpoke.Fill.ts b/test/svm/SvmSpoke.Fill.ts index 21efbd880..fb06a0e88 100644 --- a/test/svm/SvmSpoke.Fill.ts +++ b/test/svm/SvmSpoke.Fill.ts @@ -3,6 +3,7 @@ import { BN } from "@coral-xyz/anchor"; import { ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID, + createAccount, createMint, getOrCreateAssociatedTokenAccount, mintTo, @@ -390,4 +391,34 @@ describe("svm_spoke.fill", () => { "Token Program should not be invoked" ); }); + + it("Fills a V3 relay from custom relayer token account", async () => { + // Create and mint to custom relayer token account + const customKeypair = Keypair.generate(); + const customRelayerTA = await createAccount(connection, payer, mint, relayer.publicKey, customKeypair); + await mintTo(connection, payer, mint, customRelayerTA, owner, seedBalance); + + // Save balances before the the fill + const iRelayerBal = (await getAccount(connection, customRelayerTA)).amount; + const iRecipientBal = (await getAccount(connection, recipientTA)).amount; + + // Fill relay from custom relayer token account + accounts.relayerTokenAccount = customRelayerTA; + const relayHash = Array.from(calculateRelayHashUint8Array(relayData, chainId)); + await program.methods + .fillV3Relay(relayHash, relayData, new BN(1), relayer.publicKey) + .accounts(accounts) + .signers([relayer]) + .rpc(); + + // Verify balances after the fill + const fRelayerBal = (await getAccount(connection, customRelayerTA)).amount; + const fRecipientBal = (await getAccount(connection, recipientTA)).amount; + assertSE(fRelayerBal, iRelayerBal - BigInt(relayAmount), "Relayer's balance should be reduced by the relay amount"); + assertSE( + fRecipientBal, + iRecipientBal + BigInt(relayAmount), + "Recipient's balance should be increased by the relay amount" + ); + }); });