diff --git a/src/components/bridge/bridgeStepper.vue b/src/components/bridge/bridgeStepper.vue index 5577564..57a3829 100644 --- a/src/components/bridge/bridgeStepper.vue +++ b/src/components/bridge/bridgeStepper.vue @@ -324,6 +324,7 @@ export default { this.updateFromChain(this.getToChain); this.$store.commit("bridge/setToChain", tempHolder); this.updateToChain(tempHolder); + this.updateTPortTokens(); }, formSubmitted() { diff --git a/src/store/tport/actions.js b/src/store/tport/actions.js index 2526f19..273dfce 100644 --- a/src/store/tport/actions.js +++ b/src/store/tport/actions.js @@ -1,7 +1,8 @@ import { ethers } from "ethers"; // Get evm bridge tokens from tokens table of tport.start -export const updateTPortTokens = async function ({ commit, getters }, details) { +export const updateTPortTokens = async function ({ commit, getters, rootGetters }, details) { + commit("setTPortTokens", { tokens: [] }); var contract = null; var chain = null; if (details) { @@ -25,17 +26,28 @@ export const updateTPortTokens = async function ({ commit, getters }, details) { reverse: false, show_payer: false, }); + const bridge_toChain = rootGetters["bridge/getToChain"]; + const tport_chains = getters.getEvmNetworkList; + let tport_chain = tport_chains.find((el) => el.name.toUpperCase() === bridge_toChain.NETWORK_NAME.toUpperCase()); + if (tport_chain == null) { + const bridge_fromChain = rootGetters["bridge/getFromChain"]; + tport_chain = tport_chains.find((el) => el.name.toUpperCase() === bridge_fromChain.NETWORK_NAME.toUpperCase()); + } + const tport_remoteId = tport_chain.remoteId; for (let asset of tableResults.rows) { - if ('token_info' in asset) - asset.token = asset.token_info; - asset = { - ...asset, - symbol: this.$getSymFromAsset(asset.token), - decimals: this.$getDecimalFromAsset(asset.token), - contract: asset.token.contract, - amount: 0, - }; - tokens.push(asset); + const availableRemoteContracts = asset.remote_contracts.map((el) => el.key); + if (availableRemoteContracts.includes(tport_remoteId)) { + if ('token_info' in asset) + asset.token = asset.token_info; + asset = { + ...asset, + symbol: this.$getSymFromAsset(asset.token), + decimals: this.$getDecimalFromAsset(asset.token), + contract: asset.token.contract, + amount: 0, + }; + tokens.push(asset); + } } commit("setTPortTokens", { tokens }); } catch (error) { @@ -328,17 +340,17 @@ export const updateTportTokenBalancesEvm = async function ( ) balance = 0; else { - if (typeof token === "undefined") { + if (typeof token === "undefined") { console.error("TPort Token not found"); } else { const remoteContractAddress = token.remote_contracts.find( (el) => el.key === getters.getEvmRemoteId ).value; - const remoteInstance = new web3.eth.Contract( + const remoteInstance = new web3.eth.Contract( this._vm.$erc20Abi, remoteContractAddress ); // TODO Add check to validate abi - const remotebalance = await remoteInstance.methods + const remotebalance = await remoteInstance.methods .balanceOf(getters.getEvmAccountName) .call(); balance = Number( diff --git a/yarn.lock b/yarn.lock index b366c18..c399032 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6552,6 +6552,11 @@ has-property-descriptors@^1.0.0: dependencies: get-intrinsic "^1.1.1" +has-symbol-support-x@^1.4.1: + version "1.4.2" + resolved "https://registry.yarnpkg.com/has-symbol-support-x/-/has-symbol-support-x-1.4.2.tgz#1409f98bc00247da45da67cee0a36f282ff26455" + integrity sha512-3ToOva++HaW+eCpgqZrCfN51IPB+7bJNVT6CUATzueB5Heb8o6Nam0V3HG5dlDvZU1Gn5QLcbahiKw/XVk5JJw== + has-symbols@^1.0.1, has-symbols@^1.0.2, has-symbols@^1.0.3: version "1.0.3" resolved "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz" @@ -9721,6 +9726,16 @@ range-parser@^1.2.1, range-parser@~1.2.1: resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.1.tgz#3cf37023d199e1c24d1a55b84800c2f3e6468031" integrity sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg== +raw-body@2.4.3: + version "2.4.3" + resolved "https://registry.yarnpkg.com/raw-body/-/raw-body-2.4.3.tgz#8f80305d11c2a0a545c2d9d89d7a0286fcead43c" + integrity sha512-UlTNLIcu0uzb4D2f4WltY6cVjLi+/jEN4lgEUj3E04tpMDpUlkBo/eSn6zou9hum2VMNpCCUone0O0WeJim07g== + dependencies: + bytes "3.1.2" + http-errors "1.8.1" + iconv-lite "0.4.24" + unpipe "1.0.0" + raw-body@2.5.1: version "2.5.1" resolved "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz" @@ -10418,6 +10433,11 @@ setimmediate@^1.0.4, setimmediate@^1.0.5: resolved "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz" integrity sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA== +setprototypeof@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/setprototypeof/-/setprototypeof-1.1.0.tgz#d0bd85536887b6fe7c0d818cb962d9d91c54e656" + integrity sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ== + setprototypeof@1.2.0: version "1.2.0" resolved "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz" @@ -10761,7 +10781,7 @@ statuses@2.0.1: resolved "https://registry.yarnpkg.com/statuses/-/statuses-2.0.1.tgz#55cb000ccf1d48728bd23c685a063998cf1a1b63" integrity sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ== -"statuses@>= 1.5.0 < 2", statuses@~1.5.0: +"statuses@>= 1.4.0 < 2", "statuses@>= 1.5.0 < 2", statuses@~1.5.0: version "1.5.0" resolved "https://registry.yarnpkg.com/statuses/-/statuses-1.5.0.tgz#161c7dac177659fd9811f43771fa99381478628c" integrity sha512-OpZ3zP+jT1PI7I8nemJX4AKmAX070ZkYPVWV/AaKTJl+tXCTGyVdC1a4SL8RUQYEwk/f34ZX8UTykN68FwrqAA==