diff --git a/programs/protocol-contracts-solana/src/lib.rs b/programs/protocol-contracts-solana/src/lib.rs index b85a2cd..1be08b7 100644 --- a/programs/protocol-contracts-solana/src/lib.rs +++ b/programs/protocol-contracts-solana/src/lib.rs @@ -163,6 +163,7 @@ pub mod gateway { return err!(Errors::NonceMismatch); } let mut concatenated_buffer = Vec::new(); + concatenated_buffer.extend_from_slice("withdraw".as_bytes()); concatenated_buffer.extend_from_slice(&pda.chain_id.to_be_bytes()); concatenated_buffer.extend_from_slice(&nonce.to_be_bytes()); concatenated_buffer.extend_from_slice(&amount.to_be_bytes()); @@ -203,10 +204,13 @@ pub mod gateway { msg!("mismatch nonce"); return err!(Errors::NonceMismatch); } + let mut concatenated_buffer = Vec::new(); + concatenated_buffer.extend_from_slice("withdraw_spl_token".as_bytes()); concatenated_buffer.extend_from_slice(&pda.chain_id.to_be_bytes()); concatenated_buffer.extend_from_slice(&nonce.to_be_bytes()); concatenated_buffer.extend_from_slice(&amount.to_be_bytes()); + concatenated_buffer.extend_from_slice(&ctx.accounts.from.key().to_bytes()); concatenated_buffer.extend_from_slice(&ctx.accounts.to.key().to_bytes()); require!( message_hash == hash(&concatenated_buffer[..]).to_bytes(), diff --git a/tests/protocol-contracts-solana.ts b/tests/protocol-contracts-solana.ts index 498b8de..32545c9 100644 --- a/tests/protocol-contracts-solana.ts +++ b/tests/protocol-contracts-solana.ts @@ -184,9 +184,11 @@ describe("some tests", () => { const amount = new anchor.BN(500_000); const nonce = pdaAccountData.nonce; const buffer = Buffer.concat([ + Buffer.from("withdraw_spl_token","utf-8"), chain_id_bn.toArrayLike(Buffer, 'be', 8), nonce.toArrayLike(Buffer, 'be', 8), amount.toArrayLike(Buffer, 'be', 8), + pda_ata.address.toBuffer(), wallet_ata.toBuffer(), ]); const message_hash = keccak256(buffer); @@ -251,6 +253,7 @@ describe("some tests", () => { const amount = new anchor.BN(500000000); const to = wallet.publicKey; const buffer = Buffer.concat([ + Buffer.from("withdraw","utf-8"), chain_id_bn.toArrayLike(Buffer, 'be', 8), nonce.toArrayLike(Buffer, 'be', 8), amount.toArrayLike(Buffer, 'be', 8),