diff --git a/solana/modules/nft_bridge/program/src/api/complete_transfer.rs b/solana/modules/nft_bridge/program/src/api/complete_transfer.rs index 576012c28..de9ca5894 100644 --- a/solana/modules/nft_bridge/program/src/api/complete_transfer.rs +++ b/solana/modules/nft_bridge/program/src/api/complete_transfer.rs @@ -101,7 +101,13 @@ pub fn complete_native( } // Verify VAA - if accs.vaa.token_address != accs.mint.info().key.to_bytes() { + // Please refer to transfer.rs for why the token id is used to store the mint + if accs.vaa.token_address != [1u8; 32] { + return Err(InvalidMint.into()); + } + let mut token_id_bytes = [0u8; 32]; + accs.vaa.token_id.to_big_endian(&mut token_id_bytes); + if token_id_bytes != accs.mint.info().key.to_bytes() { return Err(InvalidMint.into()); } if accs.vaa.token_chain != CHAIN_ID_SOLANA { diff --git a/solana/modules/nft_bridge/program/src/api/transfer.rs b/solana/modules/nft_bridge/program/src/api/transfer.rs index 7bef27578..3add7f39c 100644 --- a/solana/modules/nft_bridge/program/src/api/transfer.rs +++ b/solana/modules/nft_bridge/program/src/api/transfer.rs @@ -187,15 +187,18 @@ pub fn transfer_native( Metadata::from_account_info(accs.spl_metadata.info()).ok_or(InvalidMetadata)?; // Post message + // Given there is no tokenID equivalent on Solana and each distinct token address is translated + // into a new contract on EVM based chains (which is costly), we use a static token_address + // and encode the mint in the token_id. let payload = PayloadTransfer { - token_address: accs.mint.info().key.to_bytes(), + token_address: [1u8; 32], token_chain: 1, to: data.target_address, to_chain: data.target_chain, symbol: metadata.data.symbol, name: metadata.data.name, uri: metadata.data.uri, - token_id: U256::from(0), // TODO + token_id: U256::from_big_endian(&accs.mint.info().key.to_bytes()), }; let params = ( bridge::instruction::Instruction::PostMessage, diff --git a/solana/modules/nft_bridge/program/src/wasm.rs b/solana/modules/nft_bridge/program/src/wasm.rs index 3c0c267ce..bd59bbe79 100644 --- a/solana/modules/nft_bridge/program/src/wasm.rs +++ b/solana/modules/nft_bridge/program/src/wasm.rs @@ -168,6 +168,8 @@ pub fn complete_transfer_native_ix( payload: vaa.payload, }; + let mut mint_bytes = [0u8; 32]; + payload.token_id.to_big_endian(&mut mint_bytes); let ix = complete_native( program_id, bridge_id, @@ -175,7 +177,7 @@ pub fn complete_transfer_native_ix( message_key, post_vaa_data, to_authority, - Pubkey::new(&payload.token_address), + Pubkey::new(&mint_bytes), CompleteNativeData {}, ) .unwrap();