diff --git a/evm/bridge-token-factory/contracts/BridgeTokenFactory.sol b/evm/bridge-token-factory/contracts/BridgeTokenFactory.sol index cda31ef8..09467fd5 100644 --- a/evm/bridge-token-factory/contracts/BridgeTokenFactory.sol +++ b/evm/bridge-token-factory/contracts/BridgeTokenFactory.sol @@ -134,7 +134,8 @@ contract BridgeTokenFactory is bytes memory borshEncoded = bytes.concat( bytes1(uint8(BridgeTypes.PayloadType.TransferMessage)), Borsh.encodeUint128(payload.nonce), - Borsh.encodeString(payload.token), + bytes1(omniBridgeChainId), + Borsh.encodeAddress(payload.tokenAddress), Borsh.encodeUint128(payload.amount), bytes1(omniBridgeChainId), Borsh.encodeAddress(payload.recipient), @@ -149,19 +150,18 @@ contract BridgeTokenFactory is } completedTransfers[payload.nonce] = true; - address tokenAddress = nearToEthToken[payload.token]; - if (tokenAddress != address(0)) { - BridgeToken(tokenAddress).mint(payload.recipient, payload.amount); + if (isBridgeToken[payload.tokenAddress]) { + BridgeToken(payload.tokenAddress).mint(payload.recipient, payload.amount); } else { - IERC20(tokenAddress).safeTransfer(payload.recipient, payload.amount); + IERC20(payload.tokenAddress).safeTransfer(payload.recipient, payload.amount); } finTransferExtension(payload); emit BridgeTypes.FinTransfer( payload.nonce, - payload.token, + payload.tokenAddress, payload.amount, payload.recipient, payload.feeRecipient diff --git a/evm/bridge-token-factory/contracts/BridgeTypes.sol b/evm/bridge-token-factory/contracts/BridgeTypes.sol index d324178a..5ea129c0 100644 --- a/evm/bridge-token-factory/contracts/BridgeTypes.sol +++ b/evm/bridge-token-factory/contracts/BridgeTypes.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.24; library BridgeTypes { struct FinTransferPayload { uint128 nonce; - string token; + address tokenAddress; uint128 amount; address recipient; string feeRecipient; @@ -36,7 +36,7 @@ library BridgeTypes { event FinTransfer( uint128 indexed nonce, - string token, + address tokenAddress, uint128 amount, address recipient, string feeRecipient diff --git a/near/nep141-locker/src/lib.rs b/near/nep141-locker/src/lib.rs index 27bf5983..f6333e86 100644 --- a/near/nep141-locker/src/lib.rs +++ b/near/nep141-locker/src/lib.rs @@ -397,10 +397,17 @@ impl Contract { require!(&transfer_message.fee == fee, "Invalid fee"); } + let token_address = self + .get_token_address( + transfer_message.get_destination_chain(), + self.get_token_id(&transfer_message.token), + ) + .unwrap_or_else(|| env::panic_str("ERR_FAILED_TO_GET_TOKEN_ADDRESS")); + let transfer_payload = TransferMessagePayload { prefix: PayloadType::TransferMessage, nonce, - token: self.get_token_id(&transfer_message.token), + token_address, amount: U128(transfer_message.amount.0 - transfer_message.fee.fee.0), recipient: transfer_message.recipient, fee_recipient, diff --git a/near/omni-types/src/lib.rs b/near/omni-types/src/lib.rs index 62ec1d52..d81aa3dc 100644 --- a/near/omni-types/src/lib.rs +++ b/near/omni-types/src/lib.rs @@ -292,6 +292,10 @@ impl TransferMessage { pub fn get_transfer_id(&self) -> TransferId { (self.get_origin_chain(), self.origin_nonce.0) } + + pub fn get_destination_chain(&self) -> ChainKind { + self.recipient.get_chain() + } } #[derive(BorshDeserialize, BorshSerialize, Serialize, Deserialize, Debug, Clone)] @@ -305,7 +309,7 @@ pub enum PayloadType { pub struct TransferMessagePayload { pub prefix: PayloadType, pub nonce: U128, - pub token: AccountId, + pub token_address: OmniAddress, pub amount: U128, pub recipient: OmniAddress, pub fee_recipient: Option,