diff --git a/env.json b/env.json index e9abdc75e..319e9c74f 100644 --- a/env.json +++ b/env.json @@ -56,7 +56,7 @@ "KusamaSora": true, "Polkadot": true, "PolkadotSora": true, - "Liberland": true + "Liberland": false }, "EVM_NETWORKS_IDS": [56, 8217], "ETH_BRIDGE": { diff --git a/package.json b/package.json index dda77e846..7958c72d5 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ }, "dependencies": { "@metamask/detect-provider": "^2.0.0", - "@soramitsu/soraneo-wallet-web": "1.32.7", + "@soramitsu/soraneo-wallet-web": "1.32.8", "@walletconnect/ethereum-provider": "^2.11.2", "@walletconnect/modal": "^2.6.2", "core-js": "^3.36.0", diff --git a/src/App.vue b/src/App.vue index dd3bfee13..9cc9abdd7 100644 --- a/src/App.vue +++ b/src/App.vue @@ -378,13 +378,13 @@ export default class App extends Mixins(mixins.TransactionMixin, NodeErrorMixin) onReconnect: this.handleNodeConnect, }), ]); - + } catch (error) { + // we handled error using callback, do nothing + } finally { // Wallet node connection dependent logic if (!this.isWalletLoaded) { await initWallet(walletOptions); } - } catch (error) { - // we handled error using callback, do nothing } } } diff --git a/src/assets/img/networks/avalanche.svg b/src/assets/img/networks/avalanche.svg index 55473a0f2..a1b5758fd 100644 --- a/src/assets/img/networks/avalanche.svg +++ b/src/assets/img/networks/avalanche.svg @@ -1,4 +1,5 @@ - - - + + + + diff --git a/src/assets/img/networks/binance-smart-chain.svg b/src/assets/img/networks/binance-smart-chain.svg index 6013da5c7..f48307940 100644 --- a/src/assets/img/networks/binance-smart-chain.svg +++ b/src/assets/img/networks/binance-smart-chain.svg @@ -1,7 +1,8 @@ - - - - - - + + + + + + + diff --git a/src/assets/img/networks/ethereum-classic.svg b/src/assets/img/networks/ethereum-classic.svg index 789e6e223..12c434086 100644 --- a/src/assets/img/networks/ethereum-classic.svg +++ b/src/assets/img/networks/ethereum-classic.svg @@ -1 +1,13 @@ -e \ No newline at end of file + + + + + +e + + + + + + + diff --git a/src/assets/img/networks/ethereum.svg b/src/assets/img/networks/ethereum.svg index ccf8091ee..b3601a6f6 100644 --- a/src/assets/img/networks/ethereum.svg +++ b/src/assets/img/networks/ethereum.svg @@ -1,10 +1,11 @@ - - - - - - - - - + + + + + + + + + + diff --git a/src/assets/img/networks/karura.svg b/src/assets/img/networks/karura.svg index 38b9efe9f..61b0e84b3 100644 --- a/src/assets/img/networks/karura.svg +++ b/src/assets/img/networks/karura.svg @@ -1,15 +1,16 @@ - + + - - + + - - - + + + - - - + + + - \ No newline at end of file + diff --git a/src/assets/img/networks/klaytn.svg b/src/assets/img/networks/klaytn.svg index f24aa6c01..2eee14ebe 100644 --- a/src/assets/img/networks/klaytn.svg +++ b/src/assets/img/networks/klaytn.svg @@ -1,31 +1,32 @@ - - - - - - + + + + + + + - - - - - + + + + + - - - + + + - - - - - - - + + + + + + + - - - + + + diff --git a/src/assets/img/networks/kusama.svg b/src/assets/img/networks/kusama.svg index 7c5d10ccd..e6b36ef73 100644 --- a/src/assets/img/networks/kusama.svg +++ b/src/assets/img/networks/kusama.svg @@ -1,4 +1,5 @@ - - - + + + + diff --git a/src/assets/img/networks/liberland.svg b/src/assets/img/networks/liberland.svg index 9fa8aa6a8..c3a537859 100644 --- a/src/assets/img/networks/liberland.svg +++ b/src/assets/img/networks/liberland.svg @@ -1 +1,2 @@ - \ No newline at end of file + + diff --git a/src/assets/img/networks/polkadot.svg b/src/assets/img/networks/polkadot.svg index a698aaa42..6c6de81a2 100644 --- a/src/assets/img/networks/polkadot.svg +++ b/src/assets/img/networks/polkadot.svg @@ -1,9 +1,10 @@ - + + - - - - - - + + + + + + diff --git a/src/assets/img/networks/polygon.svg b/src/assets/img/networks/polygon.svg index a5bb6124f..82df3cc0a 100644 --- a/src/assets/img/networks/polygon.svg +++ b/src/assets/img/networks/polygon.svg @@ -1,16 +1,9 @@ - - - + + - - - + + + diff --git a/src/assets/img/networks/rococo.svg b/src/assets/img/networks/rococo.svg index a17e506f5..e94221bbb 100644 --- a/src/assets/img/networks/rococo.svg +++ b/src/assets/img/networks/rococo.svg @@ -1 +1,23 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/assets/img/networks/sora-kusama.svg b/src/assets/img/networks/sora-kusama.svg index 0fb4484ca..da75c1fd3 100644 --- a/src/assets/img/networks/sora-kusama.svg +++ b/src/assets/img/networks/sora-kusama.svg @@ -1,5 +1,6 @@ - - - - + + + + + diff --git a/src/assets/img/networks/sora-polkadot.svg b/src/assets/img/networks/sora-polkadot.svg index d531d5832..7e1da7af6 100644 --- a/src/assets/img/networks/sora-polkadot.svg +++ b/src/assets/img/networks/sora-polkadot.svg @@ -1,5 +1,6 @@ - - - + + + + diff --git a/src/assets/img/networks/sora.svg b/src/assets/img/networks/sora.svg index b68824c82..4773e6e88 100644 --- a/src/assets/img/networks/sora.svg +++ b/src/assets/img/networks/sora.svg @@ -1,34 +1,26 @@ - - - + + - + - - + + - - - + + + @@ -37,87 +29,31 @@ - + - + - - + + - - - - + + + + - - - - - - - - - + + + + + - - - - - - - - - + + + + + + + diff --git a/src/components/App/Menu/AppMenu.vue b/src/components/App/Menu/AppMenu.vue index 9212cf85f..5694f60ef 100644 --- a/src/components/App/Menu/AppMenu.vue +++ b/src/components/App/Menu/AppMenu.vue @@ -175,7 +175,7 @@ export default class AppMenu extends Mixins(TranslationMixin) { return StakingPageNames.Staking; } if (ExploreChildPages.includes(currentName)) { - return PageNames.ExploreFarming; + return PageNames.ExploreTokens; } return currentName as string; } diff --git a/src/components/mixins/BridgeMixin.ts b/src/components/mixins/BridgeMixin.ts index 782c0e552..3d72d17a1 100644 --- a/src/components/mixins/BridgeMixin.ts +++ b/src/components/mixins/BridgeMixin.ts @@ -6,11 +6,9 @@ import WalletConnectMixin from '@/components/mixins/WalletConnectMixin'; import { PageNames } from '@/consts'; import router from '@/router'; import { getter, state } from '@/store/decorators'; -import { subBridgeApi } from '@/utils/bridge/sub/api'; import type { CodecString } from '@sora-substrate/util'; import type { RegisteredAccountAsset } from '@sora-substrate/util/build/assets/types'; -import type { SubNetwork } from '@sora-substrate/util/build/bridgeProxy/sub/types'; @Component export default class BridgeMixin extends Mixins(mixins.LoadingMixin, WalletConnectMixin) { @@ -31,6 +29,7 @@ export default class BridgeMixin extends Mixins(mixins.LoadingMixin, WalletConne @getter.bridge.recipient recipient!: string; @getter.bridge.externalNetworkFee externalNetworkFee!: CodecString; @getter.bridge.isNativeTokenSelected isNativeTokenSelected!: boolean; + @getter.bridge.isSidechainAsset isSidechainAsset!: boolean; @getter.assets.xor xor!: RegisteredAccountAsset; get nativeTokenSymbol(): string { @@ -45,14 +44,10 @@ export default class BridgeMixin extends Mixins(mixins.LoadingMixin, WalletConne return FPNumber.fromCodecValue(this.externalTransferFee, this.asset?.externalDecimals); } - get assetLockedOnSora(): boolean { - return !subBridgeApi.isSoraParachain(this.networkSelected as SubNetwork); - } - get outgoingMaxAmount(): FPNumber | null { const locks = [this.outgoingMaxLimit]; - if (this.assetLockedOnSora) locks.push(this.assetLockedBalance); + if (this.isSidechainAsset) locks.push(this.assetLockedBalance); const filtered = locks.filter((item) => !!item) as FPNumber[]; @@ -71,7 +66,7 @@ export default class BridgeMixin extends Mixins(mixins.LoadingMixin, WalletConne } get incomingMaxAmount(): FPNumber | null { - if (this.assetLockedOnSora) return null; + if (this.isSidechainAsset) return null; return this.assetLockedBalance ?? null; } diff --git a/src/components/pages/Moonpay/BridgeInitMixin.ts b/src/components/pages/Moonpay/BridgeInitMixin.ts index 3ab8610f0..97e3bba0b 100644 --- a/src/components/pages/Moonpay/BridgeInitMixin.ts +++ b/src/components/pages/Moonpay/BridgeInitMixin.ts @@ -17,7 +17,6 @@ import { MoonpayEVMTransferAssetData, MoonpayApi } from '@/utils/moonpay'; import type { CodecString } from '@sora-substrate/util'; import type { RegisteredAccountAsset, AccountBalance } from '@sora-substrate/util/build/assets/types'; -import type { EthAssetKind } from '@sora-substrate/util/build/bridgeProxy/eth/consts'; import type { EthHistory } from '@sora-substrate/util/build/bridgeProxy/eth/types'; import type { EvmNetwork } from '@sora-substrate/util/build/bridgeProxy/evm/types'; import type { BridgeNetworkId } from '@sora-substrate/util/build/bridgeProxy/types'; @@ -157,7 +156,7 @@ export default class MoonpayBridgeInitMixin extends Mixins(BridgeHistoryMixin, W const evmNetworkFee: CodecString = await getEthNetworkFee( asset, - registeredAsset.kind as EthAssetKind, + registeredAsset.kind, this.contractAddress, ethTransferData.amount, false, diff --git a/src/components/pages/Referrals/ConfirmInviteUser.vue b/src/components/pages/Referrals/ConfirmInviteUser.vue index a57b6ef6c..8105756d5 100644 --- a/src/components/pages/Referrals/ConfirmInviteUser.vue +++ b/src/components/pages/Referrals/ConfirmInviteUser.vue @@ -47,7 +47,7 @@ export default class ReferralsConfirmInviteUser extends Mixins(mixins.Transactio } get iconName(): string { - return this.hasReferrer ? 'notifications-alert-triangle-24' : 'file-file-text-24'; + return this.hasReferrer ? 'notifications-alert-triangle-24' : 'finance-PSWAP-24'; } get iconSize(): number { diff --git a/src/consts/index.ts b/src/consts/index.ts index 453f4d00a..9ef9d52f7 100644 --- a/src/consts/index.ts +++ b/src/consts/index.ts @@ -362,7 +362,7 @@ const OtherPagesMenu: Array = [ icon: 'various-items-24', title: PageNames.ExploreContainer, href: '/#/explore', - index: PageNames.ExploreFarming, + index: PageNames.ExploreTokens, }, { icon: 'various-planet-24', @@ -380,7 +380,7 @@ const OtherPagesMenu: Array = [ href: '/#/card', }, { - icon: 'file-file-text-24', + icon: 'finance-PSWAP-24', title: PageNames.About, href: '/#/about', }, @@ -462,10 +462,10 @@ export const StakingChildPages = [ SoraStakingPageNames.SelectValidators, ]; export const ExploreChildPages = [ - PageNames.ExploreFarming, // By default + PageNames.ExploreTokens, // By default PageNames.ExploreStaking, PageNames.ExplorePools, - PageNames.ExploreTokens, + PageNames.ExploreFarming, PageNames.ExploreBooks, ]; diff --git a/src/router/index.ts b/src/router/index.ts index da112be60..940cc39ad 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -163,8 +163,13 @@ const routes: Array = [ path: '/explore', name: PageNames.ExploreContainer, component: lazyView(PageNames.ExploreContainer), - redirect: { name: PageNames.ExploreFarming }, + redirect: { name: PageNames.ExploreTokens }, children: [ + { + path: 'tokens', + name: PageNames.ExploreTokens, + component: lazyView(PageNames.ExploreTokens), + }, { path: 'demeter', component: demeterStakingLazyView(DemeterStakingPageNames.DataContainer), @@ -194,11 +199,6 @@ const routes: Array = [ }, ], }, - { - path: 'tokens', - name: PageNames.ExploreTokens, - component: lazyView(PageNames.ExploreTokens), - }, { path: 'books', name: PageNames.ExploreBooks, diff --git a/src/store/bridge/actions.ts b/src/store/bridge/actions.ts index 7695de142..d53047b90 100644 --- a/src/store/bridge/actions.ts +++ b/src/store/bridge/actions.ts @@ -3,7 +3,6 @@ import { FPNumber } from '@sora-substrate/util'; import { getAssetBalance } from '@sora-substrate/util/build/assets'; import { DAI } from '@sora-substrate/util/build/assets/consts'; import { BridgeTxStatus, BridgeTxDirection, BridgeNetworkType } from '@sora-substrate/util/build/bridgeProxy/consts'; -import { EthAssetKind } from '@sora-substrate/util/build/bridgeProxy/eth/consts'; import { DexId } from '@sora-substrate/util/build/dex/consts'; import { api, WALLET_CONSTS } from '@soramitsu/soraneo-wallet-web'; import { defineActions } from 'direct-vuex'; @@ -142,7 +141,7 @@ async function getEvmNetworkFee(context: ActionContext): Promise fee = await getEthNetworkFee( asset, - bridgeRegisteredAsset.kind as EthAssetKind, + bridgeRegisteredAsset.kind, contractAddress, value, state.isSoraToEvm, @@ -235,33 +234,28 @@ async function updateEthHistory(context: ActionContext, clearHistory = async function updateEthLockedBalance(context: ActionContext): Promise { const { commit, getters, rootGetters, rootState } = bridgeActionContext(context); - const { address, decimals, externalAddress } = getters.asset ?? {}; + const { isRegisteredAsset, isSidechainAsset, asset } = getters; + const { address, decimals, externalAddress, externalDecimals } = asset ?? {}; const { networkSelected } = rootState.web3; const { isValidNetwork, contractAddress } = rootGetters.web3; const bridgeContractAddress = contractAddress(KnownEthBridgeAsset.Other); - if (address && networkSelected && isValidNetwork && externalAddress && bridgeContractAddress) { - const registeredAsset = rootState.assets.registeredAssets[address]; - - if (registeredAsset) { - const { kind, decimals: externalDecimals } = registeredAsset; - - if (kind === EthAssetKind.Sidechain) { - const [lockedValue, bridgeValue] = await Promise.all([ - ethBridgeApi.getLockedAssets(networkSelected as number, address), - ethersUtil.getAccountAssetBalance(bridgeContractAddress, externalAddress), - ]); - const balance = FPNumber.min( - FPNumber.fromCodecValue(lockedValue, decimals), - FPNumber.fromCodecValue(bridgeValue, externalDecimals) - ); - commit.setAssetLockedBalance(balance); - return; - } - } - } + const hasNetworkData = !!networkSelected && isValidNetwork && !!bridgeContractAddress; + const hasAssetData = !!address && !!externalAddress && isRegisteredAsset; - commit.setAssetLockedBalance(); + if (hasNetworkData && hasAssetData && isSidechainAsset) { + const [lockedValue, bridgeValue] = await Promise.all([ + ethBridgeApi.getLockedAssets(networkSelected as number, address), + ethersUtil.getAccountAssetBalance(bridgeContractAddress, externalAddress), + ]); + const balance = FPNumber.min( + FPNumber.fromCodecValue(lockedValue, decimals), + FPNumber.fromCodecValue(bridgeValue, externalDecimals) + ); + commit.setAssetLockedBalance(balance); + } else { + commit.setAssetLockedBalance(); + } } async function updateBridgeProxyLockedBalance(context: ActionContext): Promise { @@ -302,11 +296,7 @@ async function updateExternalMinBalance(context: ActionContext): Promi let minBalance = ZeroStringValue; if (getters.isSubBridge && getters.asset && !state.isSoraToEvm) { - const minDepositCodec = await subBridgeConnector.network.getAssetMinDeposit(getters.asset.externalAddress); - // is greater than the minimum non-zero value - if (minDepositCodec > '1') { - minBalance = minDepositCodec; - } + minBalance = await subBridgeConnector.network.getAssetMinDeposit(getters.asset.externalAddress); } commit.setExternalMinBalance(minBalance); diff --git a/src/store/bridge/getters.ts b/src/store/bridge/getters.ts index 982fc8a6d..cb7216d26 100644 --- a/src/store/bridge/getters.ts +++ b/src/store/bridge/getters.ts @@ -1,5 +1,7 @@ import { Operation } from '@sora-substrate/util'; import { BridgeNetworkType } from '@sora-substrate/util/build/bridgeProxy/consts'; +import { EthAssetKind } from '@sora-substrate/util/build/bridgeProxy/eth/consts'; +import { SubAssetKind } from '@sora-substrate/util/build/bridgeProxy/sub/consts'; import { defineGetters } from 'direct-vuex'; import { ZeroStringValue } from '@/consts'; @@ -77,6 +79,21 @@ const getters = defineGetters()({ return !!asset?.externalAddress; }, + isSidechainAsset(...args): boolean { + const { getters, rootState } = bridgeGetterContext(args); + const { asset, isSubBridge } = getters; + const { registeredAssets } = rootState.assets; + + if (!asset) return false; + if (!(asset.address in registeredAssets)) return false; + + const registered = registeredAssets[asset.address]; + const kind = registered.kind; + const sidechainKind = isSubBridge ? SubAssetKind.Sidechain : EthAssetKind.Sidechain; + + return kind === sidechainKind; + }, + autoselectedAssetAddress(...args): Nullable { const { rootState } = bridgeGetterContext(args); const assetIds = Object.keys(rootState.assets.registeredAssets); diff --git a/src/store/web3/getters.ts b/src/store/web3/getters.ts index b8fb190fc..0a4c233ef 100644 --- a/src/store/web3/getters.ts +++ b/src/store/web3/getters.ts @@ -1,6 +1,4 @@ import { BridgeNetworkType } from '@sora-substrate/util/build/bridgeProxy/consts'; -import { SubNetworkId } from '@sora-substrate/util/build/bridgeProxy/sub/consts'; -import { WALLET_CONSTS } from '@soramitsu/soraneo-wallet-web'; import { defineGetters } from 'direct-vuex'; import { EVM_NETWORKS } from '@/consts/evm'; @@ -47,11 +45,7 @@ const getters = defineGetters()({ const data = SUB_NETWORKS[id]; if (data) { - let disabled = !(nodesOrFlag && state.supportedApps?.[BridgeNetworkType.Sub]?.includes(id as SubNetwork)); - - if (id === SubNetworkId.Liberland && rootState.wallet.settings.soraNetwork === WALLET_CONSTS.SoraNetwork.Prod) { - disabled = true; // TODO: [Liberland] Remove it when needed ready - } + const disabled = !(nodesOrFlag && state.supportedApps?.[BridgeNetworkType.Sub]?.includes(id as SubNetwork)); // override from config if (Array.isArray(nodesOrFlag)) { diff --git a/src/utils/bridge/eth/classes/history.ts b/src/utils/bridge/eth/classes/history.ts index 48392b66e..c122fa706 100644 --- a/src/utils/bridge/eth/classes/history.ts +++ b/src/utils/bridge/eth/classes/history.ts @@ -102,7 +102,8 @@ const getReceiptData = async (externalHash: string) => { }; const getEvmBlockNumber = (ethereumTx: ethers.TransactionResponse | null) => { - return ethereumTx?.blockNumber; + const blockNumber = ethereumTx?.blockNumber; // could be a string + return blockNumber ? +blockNumber : null; }; const getEvmBlockId = (ethereumTx: ethers.TransactionResponse | null) => { diff --git a/src/utils/bridge/eth/utils.ts b/src/utils/bridge/eth/utils.ts index 8fc63cb1d..a3378532f 100644 --- a/src/utils/bridge/eth/utils.ts +++ b/src/utils/bridge/eth/utils.ts @@ -246,7 +246,7 @@ const getEthBridgeIncomingGasLimit = (assetEvmAddress: string): bigint => { export async function getEthNetworkFee( asset: RegisteredAccountAsset, - assetKind: EthAssetKind, + assetKind: string, getContractAddress: (symbol: KnownEthBridgeAsset) => Nullable, value: string, isOutgoing: boolean, @@ -256,7 +256,7 @@ export async function getEthNetworkFee( let gasLimitTotal!: bigint; if (isOutgoing) { - gasLimitTotal = getEthBridgeOutgoingGasLimit(asset.externalAddress, assetKind); + gasLimitTotal = getEthBridgeOutgoingGasLimit(asset.externalAddress, assetKind as EthAssetKind); } else { const bridgeContractAddress = getContractAddress(KnownEthBridgeAsset.Other) as string; const allowance = await ethersUtil.getAllowance(evmAccount, bridgeContractAddress, asset.externalAddress); diff --git a/src/utils/bridge/sub/classes/adapters/liberland.ts b/src/utils/bridge/sub/classes/adapters/liberland.ts index cdf894e35..87cb19d8d 100644 --- a/src/utils/bridge/sub/classes/adapters/liberland.ts +++ b/src/utils/bridge/sub/classes/adapters/liberland.ts @@ -30,8 +30,9 @@ export class LiberlandAdapter extends SubAdapter { if (result.isEmpty) return ZeroStringValue; const data = result.unwrap(); + const minBalance = data.minBalance.toString(); - return data.minBalance.toString(); + return minBalance > '1' ? minBalance : ZeroStringValue; }, ZeroStringValue); } @@ -46,7 +47,7 @@ export class LiberlandAdapter extends SubAdapter { const data = result.unwrap(); - if (data.isFrozen.isTrue) return ZeroStringValue; + if (!data.status.isLiquid) return ZeroStringValue; return data.balance.toString(); }, ZeroStringValue); @@ -75,8 +76,8 @@ export class LiberlandAdapter extends SubAdapter { try { return await super.getNetworkFee(asset, sender, recipient); } catch (error) { - // Hardcoded value for Liberland - 0.011153 - return '11153000000'; + // Hardcoded value for Liberland - 0.0106 + return '10600000000'; } } } diff --git a/src/utils/bridge/sub/classes/reducers.ts b/src/utils/bridge/sub/classes/reducers.ts index 7d2a8da19..3fc4dda8a 100644 --- a/src/utils/bridge/sub/classes/reducers.ts +++ b/src/utils/bridge/sub/classes/reducers.ts @@ -14,6 +14,7 @@ import { getBridgeProxyHash, getDepositedBalance, getParachainBridgeAppMintedBalance, + getSubstrateBridgeAppMintedBalance, getMessageAcceptedNonces, isMessageDispatchedNonces, isAssetAddedToChannel, @@ -79,15 +80,17 @@ export class SubBridgeReducer extends BridgeReducer { this.updateTransactionParams(id, { payload: { ...prevPayload, ...params } }); } - async saveParachainBlock(id: string): Promise { - const adapter = this.connector.soraParachain; + async saveStartBlock(id: string): Promise { + const adapter = + this.transferType === SubTransferType.Standalone ? this.connector.network : this.connector.soraParachain; - if (!adapter) throw new Error(`[${this.constructor.name}]: Sora Parachain Adapter is not exists`); + if (!adapter) throw new Error(`[${this.constructor.name}]: Adapter is not exists`); + await adapter.connect(); // get current sora parachain block number - const parachainStartBlock = await adapter.getBlockNumber(); + const startBlock = await adapter.getBlockNumber(); // update history data - this.updateTransactionPayload(id, { parachainStartBlock }); + this.updateTransactionPayload(id, { startBlock }); } } @@ -141,11 +144,8 @@ export class SubBridgeIncomingReducer extends SubBridgeReducer { await this.connector.start(); // sign transaction await this.connector.network.transfer(asset, tx.to as string, tx.amount as string, id); - - if (this.transferType !== SubTransferType.Standalone) { - // store sora parachain block number when tx was signed - await this.saveParachainBlock(id); - } + // save start block when tx was signed + await this.saveStartBlock(id); } private async updateTxSigningData(id: string): Promise { @@ -214,7 +214,7 @@ export class SubBridgeIncomingReducer extends SubBridgeReducer { if (!adapter) throw new Error(`[${this.constructor.name}] adapter is not defined`); - const startBlockHeight: number = isStandalone ? tx.externalBlockHeight : tx.payload.parachainStartBlock; + const startBlockHeight: number = tx.payload.startBlock; if (!startBlockHeight) throw new Error(`[${this.constructor.name}] startBlockHeight is not defined`); @@ -322,6 +322,9 @@ export class SubBridgeIncomingReducer extends SubBridgeReducer { let amount!: string; let eventIndex!: number; + const isStandalone = this.transferType === SubTransferType.Standalone; + const getMintedBalance = isStandalone ? getSubstrateBridgeAppMintedBalance : getParachainBridgeAppMintedBalance; + try { await new Promise((resolve, reject) => { const eventsObservable = api.system.getEventsObservable(subBridgeApi.apiRx); @@ -338,11 +341,8 @@ export class SubBridgeIncomingReducer extends SubBridgeReducer { const foundedEvents = events.slice(substrateDispatchEventIndex); soraHash = getBridgeProxyHash(foundedEvents, subBridgeApi.api); - [amount, eventIndex] = getParachainBridgeAppMintedBalance( - foundedEvents, - tx.from as string, - subBridgeApi.api - ); + + [amount, eventIndex] = getMintedBalance(foundedEvents, tx.from as string, subBridgeApi.api); resolve(); } catch (error) { @@ -458,11 +458,8 @@ export class SubBridgeOutgoingReducer extends SubBridgeReducer { await this.connector.start(); // sign transaction await subBridgeApi.transfer(asset, tx.to as string, tx.amount as string, tx.externalNetwork as SubNetwork, id); - - if (this.transferType !== SubTransferType.Standalone) { - // store sora parachain block number when tx was signed - await this.saveParachainBlock(id); - } + // save start block when tx was signed + await this.saveStartBlock(id); } private async waitForSendingExecution(id: string): Promise { diff --git a/src/utils/bridge/sub/utils.ts b/src/utils/bridge/sub/utils.ts index 18ef1abba..a0f6d313d 100644 --- a/src/utils/bridge/sub/utils.ts +++ b/src/utils/bridge/sub/utils.ts @@ -82,6 +82,24 @@ export const getParachainBridgeAppMintedBalance = ( return [balance, index]; }; +// for SORA from Liberland +export const getSubstrateBridgeAppMintedBalance = ( + events: Array, + to: string, + api: ApiPromise +): [string, number] => { + const index = events.findIndex((e) => { + if (!api.events.substrateBridgeApp.Minted.is(e.event)) return false; + return subBridgeApi.formatAddress(e.event.data[3].toString()) === subBridgeApi.formatAddress(to); + }); + + if (index === -1) throw new Error(`Unable to find "parachainBridgeApp.Minted" event`); + + const event = events[index]; + const balance = event.event.data[4].toString(); + + return [balance, index]; +}; export const getReceivedAmount = (sendedAmount: string, receivedAmount: CodecString, decimals?: number) => { const sended = new FPNumber(sendedAmount, decimals); diff --git a/src/views/BridgeTransactionsHistory.vue b/src/views/BridgeTransactionsHistory.vue index 60eb20d1c..79f32edb3 100644 --- a/src/views/BridgeTransactionsHistory.vue +++ b/src/views/BridgeTransactionsHistory.vue @@ -12,7 +12,7 @@ ): Array { - if (this.query) { - const query = this.query.toLowerCase().trim(); - return history.filter( - (item) => - `${item.assetAddress}`.toLowerCase().includes(query) || - `${this.registeredAssets[item.assetAddress as string]?.address}`.toLowerCase().includes(query) || - `${item.symbol}`.toLowerCase().includes(query) - ); - } + if (!this.query) return history; + + const query = this.query.toLowerCase().trim(); - return history; + return history.filter((item) => { + const bridgeRegisteredAsset = this.registeredAssets[item.assetAddress as string]; + const criterias = [bridgeRegisteredAsset?.address]; + + SearchAttrs.forEach((attr) => { + if (attr in item) criterias.push(item[attr]); + }); + + return criterias.some((criteria) => String(criteria).toLowerCase().includes(query)); + }); } - formatAmount(historyItem: IBridgeTransaction, received = false): string { - const amount = received ? historyItem.amount2 ?? historyItem.amount : historyItem.amount; + formatAmount(item: IBridgeTransaction, received = false): string { + const amount = received ? item.amount2 ?? item.amount : item.amount; - if (!historyItem.assetAddress || !amount) return ''; + if (!item.assetAddress || !amount) return ''; - const decimals = this.registeredAssets?.[historyItem.assetAddress]?.decimals; + const bridgeRegisteredAsset = this.registeredAssets[item.assetAddress]; + const decimals = bridgeRegisteredAsset?.decimals; return this.formatStringValue(amount, decimals); } diff --git a/src/views/Explore/Container.vue b/src/views/Explore/Container.vue index 8ebd9270c..ada80564f 100644 --- a/src/views/Explore/Container.vue +++ b/src/views/Explore/Container.vue @@ -86,6 +86,10 @@ export default class ExploreContainer extends Mixins(mixins.LoadingMixin, Transl get tabs(): Array<{ name: string; label: string; icon: string }> { return [ + { + name: PageNames.ExploreTokens, + icon: 'finance-PSWAP-24', + }, { name: PageNames.ExploreFarming, icon: 'various-toy-horse-24', @@ -98,10 +102,6 @@ export default class ExploreContainer extends Mixins(mixins.LoadingMixin, Transl name: PageNames.ExploreStaking, icon: 'basic-layers-24', }, - { - name: PageNames.ExploreTokens, - icon: 'file-file-text-24', - }, { name: PageNames.ExploreBooks, icon: 'music-CD-24', diff --git a/yarn.lock b/yarn.lock index ab17e8329..1ac44657a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2443,10 +2443,10 @@ vue-property-decorator "^9.1.2" vuex "^3.6.2" -"@soramitsu/soraneo-wallet-web@1.32.7": - version "1.32.7" - resolved "https://nexus.iroha.tech/repository/npm-group/@soramitsu/soraneo-wallet-web/-/soraneo-wallet-web-1.32.7.tgz#5557a1900d82e2e001ff93985f8cbd593b713d5b" - integrity sha512-4maKp1nKpi10itmg748WHgUqVV4UVz/ZQukvcKCGUt8sNuP+0tNqe/BU7nD3One1cSPR4Y38WFiKH59cO810xQ== +"@soramitsu/soraneo-wallet-web@1.32.8": + version "1.32.8" + resolved "https://nexus.iroha.tech/repository/npm-group/@soramitsu/soraneo-wallet-web/-/soraneo-wallet-web-1.32.8.tgz#5c6c1e69fe77d15f7d50e6e684f2f906b9f9b27e" + integrity sha512-/AMsyybfySrI8Xg0U5OuW0dxHTg/h6yYl/A0hLtmeeoMYu9fuTISMDYqIAWZP6PKxtUlaZIEo0U+sXTcLVU5hA== dependencies: "@polkadot/vue-identicon" "2.12.1" "@sora-substrate/util" "1.33.2"