Problem
A user has fungible tokens on both chain A and chain B. This user bridges a token from chain A to chain B, and now they want to bridge it back. How do you determine whether to call bridgeTokens() or bridgeBackTokens() on chain B?
Solution
Given a fungible or non-fungible token, we need to determine whether the token has been bridged or not. This is important so that we don't end up wrapping existing wrapped tokens.
Implementation
Use isWrappedToken() on the origin bridge to prevent fungible tokens from being wrapped. The return response should be Promise<boolean> .
Note
Functions to call
Fungible: bridgeTokens() or bridgeTokensBack()
Non-Fungible: bridgeNonFungibleTokens() or bridgeNonFungibleTokensBack()
Problem
A user has fungible tokens on both chain A and chain B. This user bridges a token from chain A to chain B, and now they want to bridge it back. How do you determine whether to call
bridgeTokens()orbridgeBackTokens()on chain B?Solution
Given a fungible or non-fungible token, we need to determine whether the token has been bridged or not. This is important so that we don't end up wrapping existing wrapped tokens.
Implementation
Use
isWrappedToken()on the origin bridge to prevent fungible tokens from being wrapped. The return response should bePromise<boolean>.Note
Functions to call
Fungible:
bridgeTokens()orbridgeTokensBack()Non-Fungible:
bridgeNonFungibleTokens()orbridgeNonFungibleTokensBack()