@subwallet/extension-base 1.3.69-0 → 1.3.71-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/background/KoniTypes.d.ts +11 -0
- package/background/KoniTypes.js +68 -8
- package/cjs/background/KoniTypes.js +68 -8
- package/cjs/constants/blocked-actions.js +3 -0
- package/cjs/core/logic-validation/swap.js +0 -3
- package/cjs/core/substrate/system-pallet.js +0 -2
- package/cjs/koni/api/nft/wasm_nft/index.js +0 -1
- package/cjs/koni/api/staking/bonding/astar.js +0 -2
- package/cjs/koni/api/staking/bonding/paraChain.js +0 -3
- package/cjs/koni/api/staking/bonding/relayChain.js +2 -4
- package/cjs/koni/api/staking/bonding/utils.js +0 -4
- package/cjs/koni/background/cron.js +0 -1
- package/cjs/koni/background/handlers/Extension.js +216 -158
- package/cjs/koni/background/handlers/State.js +59 -54
- package/cjs/koni/background/handlers/Tabs.js +39 -34
- package/cjs/packageInfo.js +1 -1
- package/cjs/page/index.js +7 -0
- package/cjs/page/substrate/PostMessageProvider.js +3 -0
- package/cjs/services/balance-service/helpers/subscribe/cardano/utils.js +0 -1
- package/cjs/services/balance-service/helpers/subscribe/substrate/gear.js +0 -2
- package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +2 -3
- package/cjs/services/balance-service/helpers/subscribe/ton/utils.js +0 -3
- package/cjs/services/balance-service/index.js +103 -7
- package/cjs/services/balance-service/transfer/bitcoin-transfer.js +0 -1
- package/cjs/services/balance-service/transfer/cardano-transfer.js +1 -2
- package/cjs/services/balance-service/transfer/smart-contract.js +0 -1
- package/cjs/services/balance-service/transfer/token.js +0 -2
- package/cjs/services/balance-service/transfer/ton-transfer.js +0 -1
- package/cjs/services/balance-service/transfer/xcm/snowBridge.js +0 -1
- package/cjs/services/chain-service/constants.js +15 -4
- package/cjs/services/chain-service/handler/CardanoApi.js +3 -1
- package/cjs/services/chain-service/handler/SubstrateApi.js +0 -2
- package/cjs/services/chain-service/handler/light-client/index.js +1 -2
- package/cjs/services/chain-service/health-check/index.js +0 -1
- package/cjs/services/chain-service/health-check/utils/new-utils/chain-asset-validate.js +0 -1
- package/cjs/services/chain-service/index.js +18 -26
- package/cjs/services/chain-service/utils/index.js +34 -30
- package/cjs/services/earning-service/handlers/base.js +32 -0
- package/cjs/services/earning-service/handlers/lending/base.js +0 -2
- package/cjs/services/earning-service/handlers/liquid-staking/acala.js +0 -1
- package/cjs/services/earning-service/handlers/liquid-staking/base.js +0 -2
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +0 -2
- package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +0 -1
- package/cjs/services/earning-service/handlers/native-staking/astar.js +0 -2
- package/cjs/services/earning-service/handlers/native-staking/dtao.js +43 -2
- package/cjs/services/earning-service/handlers/native-staking/energy.js +0 -1
- package/cjs/services/earning-service/handlers/native-staking/mythos.js +0 -2
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +0 -2
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +8 -9
- package/cjs/services/earning-service/handlers/special.js +7 -0
- package/cjs/services/event-service/index.js +1 -0
- package/cjs/services/history-service/subsquid-multi-chain-history.js +0 -1
- package/cjs/services/keyring-service/context/handlers/Derive.js +1 -1
- package/cjs/services/keyring-service/context/handlers/Migration.js +11 -9
- package/cjs/services/keyring-service/context/handlers/Mnemonic.js +18 -13
- package/cjs/services/keyring-service/context/state.js +21 -3
- package/cjs/services/keyring-service/utils.js +12 -2
- package/cjs/services/migration-service/index.js +1 -2
- package/cjs/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -1
- package/cjs/services/nft-service/index.js +5 -0
- package/cjs/services/open-gov/handler.js +561 -0
- package/cjs/services/open-gov/index.js +273 -0
- package/cjs/services/open-gov/interface.js +31 -0
- package/cjs/services/open-gov/utils.js +66 -0
- package/cjs/services/request-service/handler/BitcoinRequestHandler.js +1 -2
- package/cjs/services/request-service/handler/CardanoRequestHandler.js +0 -1
- package/cjs/services/request-service/handler/EvmRequestHandler.js +0 -1
- package/cjs/services/request-service/handler/TonRequestHandler.js +0 -1
- package/cjs/services/request-service/helper/index.js +1 -2
- package/cjs/services/storage-service/DatabaseService.js +19 -3
- package/cjs/services/storage-service/databases/index.js +5 -0
- package/cjs/services/storage-service/db-stores/GovLockedInfoStore.js +35 -0
- package/cjs/services/swap-service/handler/asset-hub/handler.js +0 -1
- package/cjs/services/swap-service/handler/asset-hub/router.js +0 -1
- package/cjs/services/swap-service/handler/chainflip-handler.js +1 -4
- package/cjs/services/swap-service/handler/hydradx-handler.js +0 -1
- package/cjs/services/swap-service/handler/kyber-handler.js +0 -1
- package/cjs/services/swap-service/handler/optimex-handler.js +1 -2
- package/cjs/services/swap-service/handler/simpleswap-handler.js +1 -3
- package/cjs/services/swap-service/handler/uniswap-handler.js +0 -3
- package/cjs/services/transaction-service/event-parser/index.js +6 -6
- package/cjs/services/transaction-service/helpers/index.js +6 -0
- package/cjs/services/transaction-service/index.js +71 -28
- package/cjs/services/wallet-connect-service/index.js +21 -18
- package/cjs/services/wallet-connect-service/types.js +1 -1
- package/cjs/types/account/info/keyring.js +9 -1
- package/cjs/types/balance/index.js +5 -1
- package/cjs/types/swap/index.js +2 -1
- package/cjs/types/transaction/process.js +2 -0
- package/cjs/types/yield/actions/join/step.js +17 -1
- package/cjs/utils/account/common.js +0 -26
- package/cjs/utils/account/derive/info/solo.js +7 -4
- package/cjs/utils/account/derive/validate.js +1 -1
- package/cjs/utils/account/transform.js +10 -5
- package/cjs/utils/auth.js +1 -1
- package/cjs/utils/bitcoin/utxo-management.js +0 -1
- package/cjs/utils/environment.js +2 -1
- package/cjs/utils/fee/transfer.js +1 -2
- package/cjs/utils/index.js +1 -2
- package/constants/blocked-actions.js +3 -0
- package/core/logic-validation/swap.js +0 -3
- package/core/substrate/system-pallet.js +0 -2
- package/koni/api/nft/wasm_nft/index.js +0 -1
- package/koni/api/staking/bonding/astar.js +0 -2
- package/koni/api/staking/bonding/paraChain.js +0 -3
- package/koni/api/staking/bonding/relayChain.js +2 -4
- package/koni/api/staking/bonding/utils.js +0 -4
- package/koni/background/cron.js +0 -1
- package/koni/background/handlers/Extension.d.ts +4 -0
- package/koni/background/handlers/Extension.js +70 -11
- package/koni/background/handlers/State.d.ts +2 -0
- package/koni/background/handlers/State.js +46 -40
- package/koni/background/handlers/Tabs.js +9 -3
- package/package.json +44 -20
- package/packageInfo.js +1 -1
- package/page/substrate/PostMessageProvider.js +3 -0
- package/services/balance-service/helpers/subscribe/cardano/utils.js +0 -1
- package/services/balance-service/helpers/subscribe/substrate/gear.js +0 -2
- package/services/balance-service/helpers/subscribe/substrate/index.js +0 -1
- package/services/balance-service/helpers/subscribe/ton/utils.js +0 -3
- package/services/balance-service/index.d.ts +8 -0
- package/services/balance-service/index.js +105 -9
- package/services/balance-service/transfer/bitcoin-transfer.js +0 -1
- package/services/balance-service/transfer/smart-contract.js +0 -1
- package/services/balance-service/transfer/token.js +0 -2
- package/services/balance-service/transfer/ton-transfer.js +0 -1
- package/services/balance-service/transfer/xcm/snowBridge.js +0 -1
- package/services/chain-service/constants.d.ts +8 -0
- package/services/chain-service/constants.js +12 -2
- package/services/chain-service/handler/CardanoApi.js +3 -1
- package/services/chain-service/handler/SubstrateApi.js +0 -2
- package/services/chain-service/health-check/index.js +0 -1
- package/services/chain-service/health-check/utils/new-utils/chain-asset-validate.js +0 -1
- package/services/chain-service/index.d.ts +0 -1
- package/services/chain-service/index.js +15 -23
- package/services/chain-service/utils/index.js +35 -31
- package/services/earning-service/handlers/base.js +32 -0
- package/services/earning-service/handlers/lending/base.js +0 -2
- package/services/earning-service/handlers/liquid-staking/acala.js +0 -1
- package/services/earning-service/handlers/liquid-staking/base.js +0 -2
- package/services/earning-service/handlers/liquid-staking/bifrost.js +0 -2
- package/services/earning-service/handlers/liquid-staking/parallel.js +0 -1
- package/services/earning-service/handlers/native-staking/astar.js +0 -2
- package/services/earning-service/handlers/native-staking/dtao.js +43 -0
- package/services/earning-service/handlers/native-staking/energy.js +0 -1
- package/services/earning-service/handlers/native-staking/mythos.js +0 -2
- package/services/earning-service/handlers/native-staking/para-chain.js +0 -2
- package/services/earning-service/handlers/native-staking/relay-chain.js +8 -9
- package/services/earning-service/handlers/special.js +7 -0
- package/services/event-service/index.d.ts +1 -0
- package/services/event-service/index.js +1 -0
- package/services/event-service/types.d.ts +1 -0
- package/services/history-service/subsquid-multi-chain-history.js +0 -1
- package/services/keyring-service/context/handlers/Derive.js +2 -2
- package/services/keyring-service/context/handlers/Migration.js +3 -1
- package/services/keyring-service/context/handlers/Mnemonic.d.ts +1 -1
- package/services/keyring-service/context/handlers/Mnemonic.js +16 -10
- package/services/keyring-service/context/state.d.ts +3 -0
- package/services/keyring-service/context/state.js +21 -3
- package/services/keyring-service/utils.d.ts +1 -0
- package/services/keyring-service/utils.js +9 -0
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -1
- package/services/nft-service/index.js +6 -0
- package/services/open-gov/handler.d.ts +27 -0
- package/services/open-gov/handler.js +545 -0
- package/services/open-gov/index.d.ts +45 -0
- package/services/open-gov/index.js +265 -0
- package/services/open-gov/interface.d.ts +141 -0
- package/services/open-gov/interface.js +24 -0
- package/services/open-gov/utils.d.ts +14 -0
- package/services/open-gov/utils.js +52 -0
- package/services/request-service/handler/CardanoRequestHandler.js +0 -1
- package/services/request-service/handler/EvmRequestHandler.js +0 -1
- package/services/request-service/handler/TonRequestHandler.js +0 -1
- package/services/setting-service/constants.js +0 -1
- package/services/storage-service/DatabaseService.d.ts +7 -0
- package/services/storage-service/DatabaseService.js +19 -3
- package/services/storage-service/databases/index.d.ts +2 -0
- package/services/storage-service/databases/index.js +6 -0
- package/services/storage-service/db-stores/GovLockedInfoStore.d.ts +10 -0
- package/services/storage-service/db-stores/GovLockedInfoStore.js +27 -0
- package/services/swap-service/handler/asset-hub/handler.js +0 -1
- package/services/swap-service/handler/asset-hub/router.js +0 -1
- package/services/swap-service/handler/chainflip-handler.js +0 -2
- package/services/swap-service/handler/hydradx-handler.js +0 -1
- package/services/swap-service/handler/kyber-handler.js +0 -1
- package/services/swap-service/handler/simpleswap-handler.js +0 -1
- package/services/swap-service/handler/uniswap-handler.js +0 -3
- package/services/transaction-service/event-parser/index.js +6 -6
- package/services/transaction-service/helpers/index.js +6 -0
- package/services/transaction-service/index.js +43 -0
- package/services/wallet-connect-service/index.js +21 -18
- package/services/wallet-connect-service/types.js +1 -1
- package/types/account/action/add/mnemonic.d.ts +3 -2
- package/types/account/info/keyring.js +9 -1
- package/types/balance/index.js +5 -1
- package/types/swap/index.js +2 -1
- package/types/transaction/process.js +3 -1
- package/types/yield/actions/join/step.js +17 -1
- package/utils/account/common.d.ts +0 -3
- package/utils/account/common.js +0 -24
- package/utils/account/derive/info/solo.js +8 -5
- package/utils/account/derive/validate.d.ts +2 -2
- package/utils/account/derive/validate.js +1 -1
- package/utils/account/transform.js +10 -5
- package/utils/auth.js +2 -2
- package/utils/bitcoin/utxo-management.js +0 -1
- package/utils/index.js +2 -5
|
@@ -7,12 +7,12 @@ import { ALL_ACCOUNT_KEY } from '@subwallet/extension-base/constants';
|
|
|
7
7
|
import { _isXcmWithinSameConsensus } from '@subwallet/extension-base/core/substrate/xcm-parser';
|
|
8
8
|
import { getAcrossbridgeTransferProcessFromEvm, getDefaultTransferProcess, getSnowbridgeTransferProcessFromEvm } from '@subwallet/extension-base/services/balance-service/helpers/process';
|
|
9
9
|
import { ServiceStatus } from '@subwallet/extension-base/services/base/types';
|
|
10
|
-
import { _getChainNativeTokenSlug, _isCustomAsset, _isNativeToken, _isPureEvmChain } from '@subwallet/extension-base/services/chain-service/utils';
|
|
10
|
+
import { _getChainNativeTokenSlug, _isChainSubstrateCompatible, _isCustomAsset, _isCustomChain, _isNativeToken, _isPureEvmChain } from '@subwallet/extension-base/services/chain-service/utils';
|
|
11
11
|
import DetectAccountBalanceStore from '@subwallet/extension-base/stores/DetectAccountBalance';
|
|
12
12
|
import { BalanceType } from '@subwallet/extension-base/types';
|
|
13
13
|
import { addLazy, createPromiseHandler, isAccountAll, waitTimeout } from '@subwallet/extension-base/utils';
|
|
14
14
|
import { getKeypairTypeByAddress } from '@subwallet/keyring';
|
|
15
|
-
import {
|
|
15
|
+
import { AllSubstrateKeypairTypes, EthereumKeypairTypes } from '@subwallet/keyring/types';
|
|
16
16
|
import keyring from '@subwallet/ui-keyring';
|
|
17
17
|
import subwalletApiSdk from '@subwallet-monorepos/subwallet-services-sdk';
|
|
18
18
|
import BigN from 'bignumber.js';
|
|
@@ -458,7 +458,7 @@ export class BalanceService {
|
|
|
458
458
|
const assetMap = this.state.chainService.getAssetRegistry();
|
|
459
459
|
const promiseList = addresses.map(address => {
|
|
460
460
|
const type = getKeypairTypeByAddress(address);
|
|
461
|
-
const typeValid = [...
|
|
461
|
+
const typeValid = [...AllSubstrateKeypairTypes, ...EthereumKeypairTypes].includes(type);
|
|
462
462
|
if (typeValid) {
|
|
463
463
|
return this.state.subscanService.getMultiChainBalance(address).catch(e => {
|
|
464
464
|
console.error(e);
|
|
@@ -539,12 +539,10 @@ export class BalanceService {
|
|
|
539
539
|
var _currentAssetSettings2;
|
|
540
540
|
const chainSlug = tokenSlug.split('-')[0];
|
|
541
541
|
const chainState = this.state.chainService.getChainStateByKey(chainSlug);
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
// Cancel if chain is turned off by user
|
|
545
|
-
if (chainState && chainState.manualTurnOff) {
|
|
542
|
+
if (chainState !== null && chainState !== void 0 && chainState.manualTurnOff) {
|
|
546
543
|
continue;
|
|
547
544
|
}
|
|
545
|
+
const existedKey = Object.keys(assetMap).find(v => v.toLowerCase() === tokenSlug.toLowerCase());
|
|
548
546
|
if (existedKey && !((_currentAssetSettings2 = currentAssetSettings[existedKey]) !== null && _currentAssetSettings2 !== void 0 && _currentAssetSettings2.visible)) {
|
|
549
547
|
needEnableChains.push(chainSlug);
|
|
550
548
|
needActiveTokens.push(existedKey);
|
|
@@ -760,7 +758,7 @@ export class BalanceService {
|
|
|
760
758
|
const assetMap = this.state.chainService.getAssetRegistry();
|
|
761
759
|
const addresses = keyring.getPairs().map(account => account.address);
|
|
762
760
|
const evmAddresses = addresses.filter(address => [...EthereumKeypairTypes].includes(getKeypairTypeByAddress(address)));
|
|
763
|
-
const substrateAddresses = addresses.filter(address => [...
|
|
761
|
+
const substrateAddresses = addresses.filter(address => [...AllSubstrateKeypairTypes].includes(getKeypairTypeByAddress(address)));
|
|
764
762
|
const [nonZeroBalanceEvmToken, nonZeroBalanceSubstrateToken] = await Promise.all([this.evmDetectBalanceToken(evmAddresses), this.substrateDetectBalanceToken(substrateAddresses)]);
|
|
765
763
|
const substrateDetectChain = this.substrateDetectBalanceChain();
|
|
766
764
|
const evmDetectChain = await this.evmDetectBalanceChain();
|
|
@@ -788,5 +786,103 @@ export class BalanceService {
|
|
|
788
786
|
}
|
|
789
787
|
}
|
|
790
788
|
|
|
791
|
-
/**
|
|
789
|
+
/** Return token slugs with balance in evm chain - only work with evm addresses & pure evm chains **/
|
|
790
|
+
async getEvmTokensBalanceByChain(address, chainSlug) {
|
|
791
|
+
const tokenBalanceSlugs = await subwalletApiSdk.balanceDetectionApi.getSwEvmTokenBalanceByChain(address, chainSlug);
|
|
792
|
+
return tokenBalanceSlugs;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
/** Return token slugs with balance in substrate chain - only work with substrate chains that have subscanSlug **/
|
|
796
|
+
async getSubstrateTokensBalanceByChain(address, chainSlug, assetsByChain) {
|
|
797
|
+
const tokenBalanceSlugs = [];
|
|
798
|
+
const balanceData = await this.state.subscanService.getMultiChainBalance(address);
|
|
799
|
+
if (!balanceData) {
|
|
800
|
+
return [];
|
|
801
|
+
}
|
|
802
|
+
for (const datum of balanceData) {
|
|
803
|
+
const {
|
|
804
|
+
balance,
|
|
805
|
+
bonded,
|
|
806
|
+
category,
|
|
807
|
+
locked,
|
|
808
|
+
network,
|
|
809
|
+
symbol
|
|
810
|
+
} = datum;
|
|
811
|
+
const chain = this.state.chainService.detectBalanceChainSlugMap[network];
|
|
812
|
+
if (chain !== chainSlug) {
|
|
813
|
+
continue;
|
|
814
|
+
}
|
|
815
|
+
const isBalanceEmpty = (!balance || balance === '0') && (!locked || locked === '0') && (!bonded || bonded === '0');
|
|
816
|
+
if (isBalanceEmpty) {
|
|
817
|
+
continue;
|
|
818
|
+
}
|
|
819
|
+
const tokenKey = `${chain}-${category === 'native' ? 'NATIVE' : 'LOCAL'}-${symbol.toUpperCase()}`;
|
|
820
|
+
const existedKey = Object.keys(assetsByChain).find(v => v.toLowerCase() === tokenKey.toLowerCase());
|
|
821
|
+
if (existedKey) {
|
|
822
|
+
tokenBalanceSlugs.push(existedKey);
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
return tokenBalanceSlugs;
|
|
826
|
+
}
|
|
827
|
+
getCurrentAccountAddressByChain(chainInfo) {
|
|
828
|
+
const proxyId = this.state.keyringService.context.currentAccount.proxyId;
|
|
829
|
+
const addresses = this.state.keyringService.context.addressesByProxyId(proxyId);
|
|
830
|
+
if (_isPureEvmChain(chainInfo)) {
|
|
831
|
+
const evmAddress = addresses.find(address => {
|
|
832
|
+
const type = getKeypairTypeByAddress(address);
|
|
833
|
+
return [...EthereumKeypairTypes].includes(type);
|
|
834
|
+
});
|
|
835
|
+
if (evmAddress) {
|
|
836
|
+
return evmAddress;
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
if (_isChainSubstrateCompatible(chainInfo)) {
|
|
840
|
+
const substrateAddress = addresses.find(address => {
|
|
841
|
+
const type = getKeypairTypeByAddress(address);
|
|
842
|
+
return [...AllSubstrateKeypairTypes, ...EthereumKeypairTypes].includes(type);
|
|
843
|
+
});
|
|
844
|
+
if (substrateAddress) {
|
|
845
|
+
return substrateAddress;
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
return undefined;
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
/** re-detect balance & enable custom, priority tokens when enabling chain again **/
|
|
852
|
+
async updatePriorityAssetsByChain(chainSlug, visible) {
|
|
853
|
+
const currentAssetSettings = await this.state.chainService.getAssetSettings();
|
|
854
|
+
const assetsByChain = this.state.chainService.getFungibleTokensByChain(chainSlug);
|
|
855
|
+
const priorityTokensMap = this.state.chainService.value.priorityTokens || {};
|
|
856
|
+
const chainInfo = this.state.chainService.getChainInfoByKey(chainSlug);
|
|
857
|
+
const address = this.getCurrentAccountAddressByChain(chainInfo);
|
|
858
|
+
const tokenSlugsWithBalance = [];
|
|
859
|
+
if (address && !_isCustomChain(chainInfo.slug)) {
|
|
860
|
+
if (_isPureEvmChain(chainInfo)) {
|
|
861
|
+
tokenSlugsWithBalance.push(...(await this.getEvmTokensBalanceByChain(address, chainSlug)));
|
|
862
|
+
} else if (_isChainSubstrateCompatible(chainInfo)) {
|
|
863
|
+
tokenSlugsWithBalance.push(...(await this.getSubstrateTokensBalanceByChain(address, chainSlug, assetsByChain)));
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
tokenSlugsWithBalance.forEach(tokenSlug => {
|
|
867
|
+
currentAssetSettings[tokenSlug] = {
|
|
868
|
+
visible: true
|
|
869
|
+
};
|
|
870
|
+
});
|
|
871
|
+
const priorityTokensList = priorityTokensMap.token && typeof priorityTokensMap.token === 'object' ? Object.keys(priorityTokensMap.token) : [];
|
|
872
|
+
for (const asset of Object.values(assetsByChain)) {
|
|
873
|
+
if (visible) {
|
|
874
|
+
const isPriorityToken = priorityTokensList.includes(asset.slug) || _isCustomAsset(asset.slug);
|
|
875
|
+
if (isPriorityToken || _isNativeToken(asset)) {
|
|
876
|
+
currentAssetSettings[asset.slug] = {
|
|
877
|
+
visible: true
|
|
878
|
+
};
|
|
879
|
+
}
|
|
880
|
+
} else {
|
|
881
|
+
currentAssetSettings[asset.slug] = {
|
|
882
|
+
visible: false
|
|
883
|
+
};
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
this.state.chainService.setAssetSettings(currentAssetSettings);
|
|
887
|
+
}
|
|
792
888
|
}
|
|
@@ -158,7 +158,6 @@ export const getTransferMockTxFee = async (address, chainInfo, tokenInfo, api) =
|
|
|
158
158
|
// estimate value
|
|
159
159
|
bounce: false // anyMode
|
|
160
160
|
});
|
|
161
|
-
|
|
162
161
|
estimatedFee = new BigN((await estimateTonTxFee(tonApi, [mockMessage], mockWalletContract)).toString());
|
|
163
162
|
} else {
|
|
164
163
|
var _paymentInfo$partialF;
|
|
@@ -176,7 +175,6 @@ export const getTransferMockTxFee = async (address, chainInfo, tokenInfo, api) =
|
|
|
176
175
|
const paymentInfo = await (mockTx === null || mockTx === void 0 ? void 0 : mockTx.paymentInfo(address));
|
|
177
176
|
estimatedFee = new BigN((paymentInfo === null || paymentInfo === void 0 ? void 0 : (_paymentInfo$partialF = paymentInfo.partialFee) === null || _paymentInfo$partialF === void 0 ? void 0 : _paymentInfo$partialF.toString()) || '0'); // todo: should handle error case instead of setting fee to 0
|
|
178
177
|
}
|
|
179
|
-
|
|
180
178
|
return estimatedFee;
|
|
181
179
|
} catch (e) {
|
|
182
180
|
console.error('error mocking tx fee', e);
|
|
@@ -56,7 +56,6 @@ async function createTonNativeTransaction({
|
|
|
56
56
|
value: fromNano(value),
|
|
57
57
|
bounce: false // todo: check and update the send bounced logic
|
|
58
58
|
});
|
|
59
|
-
|
|
60
59
|
const messagePayload = cellToBase64Str(messageRelaxedToCell(messages));
|
|
61
60
|
const estimateExternalFee = await estimateTonTxFee(tonApi, [messages], walletContract);
|
|
62
61
|
const transactionObject = {
|
|
@@ -10,6 +10,14 @@ export declare const _API_OPTIONS_CHAIN_GROUP: {
|
|
|
10
10
|
};
|
|
11
11
|
export declare const _PREDEFINED_SINGLE_MODES: Record<string, SingleModeJson>;
|
|
12
12
|
export declare const _PURE_EVM_CHAINS: string[];
|
|
13
|
+
export declare const _GOVERNANCE_CHAIN_GROUP: {
|
|
14
|
+
polkadot: string[];
|
|
15
|
+
kusama: string[];
|
|
16
|
+
westend_assethub: string[];
|
|
17
|
+
paseo: string[];
|
|
18
|
+
solo: string[];
|
|
19
|
+
testnet: string[];
|
|
20
|
+
};
|
|
13
21
|
export declare const _BALANCE_CHAIN_GROUP: {
|
|
14
22
|
kintsugi: string[];
|
|
15
23
|
genshiro: string[];
|
|
@@ -20,6 +20,14 @@ export const _PREDEFINED_SINGLE_MODES = {
|
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
export const _PURE_EVM_CHAINS = ['binance', 'binance_test', 'ethereum', 'ethereum_goerli', 'astarEvm', 'shidenEvm', 'shibuyaEvm', 'crabEvm', 'pangolinEvm', 'cloverEvm', 'boba_rinkeby', 'boba', 'bobabase', 'bobabeam', 'watr_network_evm'];
|
|
23
|
+
export const _GOVERNANCE_CHAIN_GROUP = {
|
|
24
|
+
polkadot: ['statemint', 'bifrost_dot', 'hydradx_main', 'ajunaPolkadot', 'astar', 'phala', 'litentry', 'acala', 'centrifuge', 'interlay', 'laos_network'],
|
|
25
|
+
kusama: ['statemine', 'bifrost', 'basilisk', 'karura', 'kintsugi'],
|
|
26
|
+
westend_assethub: ['westend_assethub'],
|
|
27
|
+
paseo: ['paseo_assethub'],
|
|
28
|
+
solo: ['vara_network', 'zkverify'],
|
|
29
|
+
testnet: ['zkverify_testnet']
|
|
30
|
+
};
|
|
23
31
|
|
|
24
32
|
// Get balance----------------------------------------------------------------------------------------------------------
|
|
25
33
|
|
|
@@ -126,6 +134,8 @@ export const _EXPECTED_BLOCK_TIME = {
|
|
|
126
134
|
statemint: 6,
|
|
127
135
|
statemine: 6,
|
|
128
136
|
polkadex: 12,
|
|
137
|
+
westend_assethub: 6,
|
|
138
|
+
paseo_assethub: 6,
|
|
129
139
|
ternoa: 6,
|
|
130
140
|
ternoa_alphanet: 6,
|
|
131
141
|
westend: 6,
|
|
@@ -136,8 +146,8 @@ export const _EXPECTED_BLOCK_TIME = {
|
|
|
136
146
|
vara_testnet: 3,
|
|
137
147
|
goldberg_testnet: 20,
|
|
138
148
|
polimec: 12,
|
|
139
|
-
bifrost:
|
|
140
|
-
//
|
|
149
|
+
bifrost: 6,
|
|
150
|
+
// bifrost kusama
|
|
141
151
|
moonbeam: 12,
|
|
142
152
|
moonriver: 12,
|
|
143
153
|
moonbase: 6,
|
|
@@ -21,6 +21,9 @@ export class CardanoApi {
|
|
|
21
21
|
connectionStatusSubject = new BehaviorSubject(_ChainConnectionStatus.DISCONNECTED);
|
|
22
22
|
isApiReady = false;
|
|
23
23
|
isApiReadyOnce = false;
|
|
24
|
+
|
|
25
|
+
// todo: add api with interface BlockFrostAPI to remove isTestnet check
|
|
26
|
+
|
|
24
27
|
constructor(chainSlug, apiUrl, {
|
|
25
28
|
isTestnet,
|
|
26
29
|
providerName
|
|
@@ -62,7 +65,6 @@ export class CardanoApi {
|
|
|
62
65
|
this.apiUrl = apiUrl;
|
|
63
66
|
// this.api = this.createProvider();
|
|
64
67
|
}
|
|
65
|
-
|
|
66
68
|
async recoverConnect() {
|
|
67
69
|
await this.disconnect();
|
|
68
70
|
this.connect();
|
|
@@ -281,7 +281,6 @@ export class SubstrateApi {
|
|
|
281
281
|
// this.apiDefaultTx = api.tx[defaultSection][defaultMethod];
|
|
282
282
|
// this.apiDefaultTxSudo = (api.tx.system && api.tx.system.setCode) || this.apiDefaultTx;
|
|
283
283
|
}
|
|
284
|
-
|
|
285
284
|
async makeRpcQuery({
|
|
286
285
|
args,
|
|
287
286
|
method,
|
|
@@ -322,7 +321,6 @@ export class SubstrateApi {
|
|
|
322
321
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
323
322
|
return (await this.api[section][module][method]()).toPrimitive(); // todo: improve this
|
|
324
323
|
}
|
|
325
|
-
|
|
326
324
|
if (isStateQuery) {
|
|
327
325
|
if (!this.api[section][module]) {
|
|
328
326
|
return undefined;
|
|
@@ -21,7 +21,6 @@ export async function checkSubstrateEndpoint(endpoint, timeout) {
|
|
|
21
21
|
await wsProvider.disconnect(); // disconnect from the endpoint after the health check is complete
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
|
-
|
|
25
24
|
export async function checkEvmEndpoint(endpoint, timeout) {
|
|
26
25
|
try {
|
|
27
26
|
const web3 = new Web3(endpoint);
|
|
@@ -11,7 +11,6 @@ export function validateTokenHasValueByChain(chainAsset) {
|
|
|
11
11
|
}
|
|
12
12
|
return isTestnet !== chainAsset.hasValue; // todo: also check multichainAsset hasValue if has.
|
|
13
13
|
}
|
|
14
|
-
|
|
15
14
|
export function validateNativeInfoByChain(chainAsset) {
|
|
16
15
|
var _chainInfo$evmInfo, _chainInfo$substrateI, _chainInfo$bitcoinInf, _chainInfo$evmInfo2, _chainInfo$substrateI2, _chainInfo$bitcoinInf2, _chainInfo$evmInfo3, _chainInfo$substrateI3, _chainInfo$bitcoinInf3;
|
|
17
16
|
const chainInfo = ChainInfoMap[chainAsset.originChain];
|
|
@@ -170,7 +170,6 @@ export declare class ChainService {
|
|
|
170
170
|
getAssetSettings(): Promise<Record<string, AssetSetting>>;
|
|
171
171
|
updateAssetSetting(assetSlug: string, assetSetting: AssetSetting, autoEnableNativeToken?: boolean): Promise<boolean | undefined>;
|
|
172
172
|
updateAssetSettingByChain(chainSlug: string, visible: boolean): Promise<void>;
|
|
173
|
-
updatePriorityAssetsByChain(chainSlug: string, visible: boolean): Promise<void>;
|
|
174
173
|
subscribeAssetSettings(): BehaviorSubject<Record<string, AssetSetting>>;
|
|
175
174
|
getAssetLogoMap(): Record<string, string>;
|
|
176
175
|
subscribeAssetLogoMap(): BehaviorSubject<Record<string, string>>;
|
|
@@ -12,7 +12,7 @@ import { SubstrateChainHandler } from '@subwallet/extension-base/services/chain-
|
|
|
12
12
|
import { TonChainHandler } from '@subwallet/extension-base/services/chain-service/handler/TonChainHandler';
|
|
13
13
|
import { _CHAIN_VALIDATION_ERROR } from '@subwallet/extension-base/services/chain-service/handler/types';
|
|
14
14
|
import { _ChainConnectionStatus, _CUSTOM_PREFIX, _NFT_CONTRACT_STANDARDS, _SMART_CONTRACT_STANDARDS } from '@subwallet/extension-base/services/chain-service/types';
|
|
15
|
-
import { _getAssetOriginChain, _getTokenOnChainAssetId, _isAssetAutoEnable, _isAssetCanPayTxFee, _isAssetFungibleToken, _isChainBitcoinCompatible, _isChainEnabled, _isCustomAsset, _isCustomChain, _isCustomProvider, _isEqualContractAddress, _isEqualSmartContractAsset, _isLocalToken, _isMantaZkAsset,
|
|
15
|
+
import { _getAssetOriginChain, _getTokenOnChainAssetId, _isAssetAutoEnable, _isAssetCanPayTxFee, _isAssetFungibleToken, _isChainBitcoinCompatible, _isChainEnabled, _isCustomAsset, _isCustomChain, _isCustomProvider, _isEqualContractAddress, _isEqualSmartContractAsset, _isLocalToken, _isMantaZkAsset, _isPureEvmChain, _isPureSubstrateChain, _parseAssetRefKey, randomizeProvider, updateLatestChainInfo } from '@subwallet/extension-base/services/chain-service/utils';
|
|
16
16
|
import { MYTHOS_MIGRATION_KEY } from '@subwallet/extension-base/services/migration-service/scripts';
|
|
17
17
|
import { convertUtxoRawToUtxo } from '@subwallet/extension-base/services/request-service/helper';
|
|
18
18
|
import AssetSettingStore from '@subwallet/extension-base/stores/AssetSetting';
|
|
@@ -43,6 +43,9 @@ export class ChainService {
|
|
|
43
43
|
assetRegistry: {},
|
|
44
44
|
assetRefMap: {}
|
|
45
45
|
};
|
|
46
|
+
|
|
47
|
+
// to save chain, token settings from user
|
|
48
|
+
|
|
46
49
|
lockChainInfoMap = false; // prevent unwanted changes (edit, enable, disable) to chainInfoMap
|
|
47
50
|
|
|
48
51
|
get mantaPay() {
|
|
@@ -708,7 +711,6 @@ export class ChainService {
|
|
|
708
711
|
.catch(e => console.error('Error enabling popular tokens:', e)); // Log error if enabling fails
|
|
709
712
|
}
|
|
710
713
|
}
|
|
711
|
-
|
|
712
714
|
handleLatestSufficientChains(latestSufficientChains) {
|
|
713
715
|
this.sufficientChainsSubject.next(latestSufficientChains);
|
|
714
716
|
this.logger.log('Finished updating latest supported sufficient chains');
|
|
@@ -1352,7 +1354,18 @@ export class ChainService {
|
|
|
1352
1354
|
|
|
1353
1355
|
// Enable chain if not before
|
|
1354
1356
|
if (!targetChainState.active) {
|
|
1357
|
+
var _currentAssetSettings;
|
|
1355
1358
|
targetChainState.active = true;
|
|
1359
|
+
|
|
1360
|
+
// enable native token
|
|
1361
|
+
const nativeAsset = this.getNativeTokenInfo(chainSlug);
|
|
1362
|
+
const currentAssetSettings = await this.getAssetSettings();
|
|
1363
|
+
if (!((_currentAssetSettings = currentAssetSettings[nativeAsset.slug]) !== null && _currentAssetSettings !== void 0 && _currentAssetSettings.visible)) {
|
|
1364
|
+
currentAssetSettings[nativeAsset.slug] = {
|
|
1365
|
+
visible: true
|
|
1366
|
+
};
|
|
1367
|
+
this.setAssetSettings(currentAssetSettings);
|
|
1368
|
+
}
|
|
1356
1369
|
}
|
|
1357
1370
|
|
|
1358
1371
|
// It auto detects the change of api url to create new instance or reuse existed one
|
|
@@ -1855,27 +1868,6 @@ export class ChainService {
|
|
|
1855
1868
|
});
|
|
1856
1869
|
this.setAssetSettings(assetSettings);
|
|
1857
1870
|
}
|
|
1858
|
-
async updatePriorityAssetsByChain(chainSlug, visible) {
|
|
1859
|
-
const currentAssetSettings = await this.getAssetSettings();
|
|
1860
|
-
const assetsByChain = this.getFungibleTokensByChain(chainSlug);
|
|
1861
|
-
const priorityTokensMap = this.priorityTokensSubject.value || {};
|
|
1862
|
-
const priorityTokensList = priorityTokensMap.token && typeof priorityTokensMap.token === 'object' ? Object.keys(priorityTokensMap.token) : [];
|
|
1863
|
-
for (const asset of Object.values(assetsByChain)) {
|
|
1864
|
-
if (visible) {
|
|
1865
|
-
const isPriorityToken = priorityTokensList.includes(asset.slug);
|
|
1866
|
-
if (isPriorityToken || _isNativeToken(asset)) {
|
|
1867
|
-
currentAssetSettings[asset.slug] = {
|
|
1868
|
-
visible: true
|
|
1869
|
-
};
|
|
1870
|
-
}
|
|
1871
|
-
} else {
|
|
1872
|
-
currentAssetSettings[asset.slug] = {
|
|
1873
|
-
visible: false
|
|
1874
|
-
};
|
|
1875
|
-
}
|
|
1876
|
-
}
|
|
1877
|
-
this.setAssetSettings(currentAssetSettings);
|
|
1878
|
-
}
|
|
1879
1871
|
subscribeAssetSettings() {
|
|
1880
1872
|
return this.assetSettingSubject;
|
|
1881
1873
|
}
|
|
@@ -6,7 +6,7 @@ import { ChainType } from '@subwallet/extension-base/background/KoniTypes';
|
|
|
6
6
|
import { _MANTA_ZK_CHAIN_GROUP, _ZK_ASSET_PREFIX } from '@subwallet/extension-base/services/chain-service/constants';
|
|
7
7
|
import { _CUSTOM_PREFIX, _SMART_CONTRACT_STANDARDS } from '@subwallet/extension-base/services/chain-service/types';
|
|
8
8
|
import { AccountChainType, AccountSignMode } from '@subwallet/extension-base/types';
|
|
9
|
-
import { BitcoinMainnetKeypairTypes, BitcoinTestnetKeypairTypes, CardanoKeypairTypes, EthereumKeypairTypes,
|
|
9
|
+
import { AllSubstrateKeypairTypes, BitcoinMainnetKeypairTypes, BitcoinTestnetKeypairTypes, CardanoKeypairTypes, EthereumKeypairTypes, TonKeypairTypes } from '@subwallet/keyring/types';
|
|
10
10
|
import { isEthereumAddress } from '@polkadot/util-crypto';
|
|
11
11
|
export function _isCustomChain(slug) {
|
|
12
12
|
if (slug.length === 0) {
|
|
@@ -34,7 +34,6 @@ export function _isEqualContractAddress(address1, address2) {
|
|
|
34
34
|
if (isEthereumAddress(address1) && isEthereumAddress(address2)) {
|
|
35
35
|
return address1.toLowerCase() === address2.toLowerCase(); // EVM address is case-insensitive
|
|
36
36
|
}
|
|
37
|
-
|
|
38
37
|
return address2 === address1;
|
|
39
38
|
}
|
|
40
39
|
export function _isEqualSmartContractAsset(asset1, asset2) {
|
|
@@ -174,12 +173,10 @@ export function _isSmartContractToken(tokenInfo) {
|
|
|
174
173
|
export function _isChainSubstrateCompatible(chainInfo) {
|
|
175
174
|
return !!chainInfo.substrateInfo; // fallback to Ethereum
|
|
176
175
|
}
|
|
177
|
-
|
|
178
176
|
export function _getEvmChainId(chainInfo) {
|
|
179
177
|
var _chainInfo$evmInfo;
|
|
180
178
|
return (_chainInfo$evmInfo = chainInfo.evmInfo) === null || _chainInfo$evmInfo === void 0 ? void 0 : _chainInfo$evmInfo.evmChainId; // fallback to Ethereum
|
|
181
179
|
}
|
|
182
|
-
|
|
183
180
|
export function _getSubstrateParaId(chainInfo) {
|
|
184
181
|
var _chainInfo$substrateI;
|
|
185
182
|
return ((_chainInfo$substrateI = chainInfo.substrateInfo) === null || _chainInfo$substrateI === void 0 ? void 0 : _chainInfo$substrateI.paraId) || -1;
|
|
@@ -220,8 +217,8 @@ export function _isChainSupportEvmERC20(chainInfo) {
|
|
|
220
217
|
return ((_chainInfo$evmInfo3 = chainInfo.evmInfo) === null || _chainInfo$evmInfo3 === void 0 ? void 0 : (_chainInfo$evmInfo3$s = _chainInfo$evmInfo3.supportSmartContract) === null || _chainInfo$evmInfo3$s === void 0 ? void 0 : _chainInfo$evmInfo3$s.includes(_AssetType.ERC20)) || false;
|
|
221
218
|
}
|
|
222
219
|
export function _isChainSupportWasmPSP22(chainInfo) {
|
|
223
|
-
var _chainInfo$
|
|
224
|
-
return ((_chainInfo$
|
|
220
|
+
var _chainInfo$substrateI0, _chainInfo$substrateI1;
|
|
221
|
+
return ((_chainInfo$substrateI0 = chainInfo.substrateInfo) === null || _chainInfo$substrateI0 === void 0 ? void 0 : (_chainInfo$substrateI1 = _chainInfo$substrateI0.supportSmartContract) === null || _chainInfo$substrateI1 === void 0 ? void 0 : _chainInfo$substrateI1.includes(_AssetType.PSP22)) || false;
|
|
225
222
|
}
|
|
226
223
|
export function _isAssetHubChain(chainInfo) {
|
|
227
224
|
return ['statemint', 'statemine'].includes(chainInfo.slug);
|
|
@@ -230,12 +227,12 @@ export function _isAssetHubToken(token) {
|
|
|
230
227
|
return ['statemint', 'statemine'].includes(token.originChain);
|
|
231
228
|
}
|
|
232
229
|
export function _isChainSupportGRC20(chainInfo) {
|
|
233
|
-
var _chainInfo$
|
|
234
|
-
return ((_chainInfo$
|
|
230
|
+
var _chainInfo$substrateI10, _chainInfo$substrateI11;
|
|
231
|
+
return ((_chainInfo$substrateI10 = chainInfo.substrateInfo) === null || _chainInfo$substrateI10 === void 0 ? void 0 : (_chainInfo$substrateI11 = _chainInfo$substrateI10.supportSmartContract) === null || _chainInfo$substrateI11 === void 0 ? void 0 : _chainInfo$substrateI11.includes(_AssetType.GRC20)) || false;
|
|
235
232
|
}
|
|
236
233
|
export function _isChainSupportVFT(chainInfo) {
|
|
237
|
-
var _chainInfo$
|
|
238
|
-
return ((_chainInfo$
|
|
234
|
+
var _chainInfo$substrateI12, _chainInfo$substrateI13;
|
|
235
|
+
return ((_chainInfo$substrateI12 = chainInfo.substrateInfo) === null || _chainInfo$substrateI12 === void 0 ? void 0 : (_chainInfo$substrateI13 = _chainInfo$substrateI12.supportSmartContract) === null || _chainInfo$substrateI13 === void 0 ? void 0 : _chainInfo$substrateI13.includes(_AssetType.VFT)) || false;
|
|
239
236
|
}
|
|
240
237
|
export const _isSupportOrdinal = chain => {
|
|
241
238
|
const chains = ['polkadot', 'astar', 'bifrost_dot', 'moonbeam'];
|
|
@@ -289,28 +286,36 @@ export function _getChainNativeTokenBasicInfo(chainInfo) {
|
|
|
289
286
|
return defaultTokenInfo;
|
|
290
287
|
}
|
|
291
288
|
if (chainInfo.substrateInfo) {
|
|
292
|
-
// substrate by default
|
|
293
289
|
return {
|
|
290
|
+
...defaultTokenInfo,
|
|
294
291
|
symbol: chainInfo.substrateInfo.symbol,
|
|
295
292
|
decimals: chainInfo.substrateInfo.decimals
|
|
296
293
|
};
|
|
297
|
-
}
|
|
294
|
+
}
|
|
295
|
+
if (chainInfo.evmInfo) {
|
|
298
296
|
return {
|
|
297
|
+
...defaultTokenInfo,
|
|
299
298
|
symbol: chainInfo.evmInfo.symbol,
|
|
300
299
|
decimals: chainInfo.evmInfo.decimals
|
|
301
300
|
};
|
|
302
|
-
}
|
|
301
|
+
}
|
|
302
|
+
if (chainInfo.tonInfo) {
|
|
303
303
|
return {
|
|
304
|
+
...defaultTokenInfo,
|
|
304
305
|
symbol: chainInfo.tonInfo.symbol,
|
|
305
306
|
decimals: chainInfo.tonInfo.decimals
|
|
306
307
|
};
|
|
307
|
-
}
|
|
308
|
+
}
|
|
309
|
+
if (chainInfo.cardanoInfo) {
|
|
308
310
|
return {
|
|
311
|
+
...defaultTokenInfo,
|
|
309
312
|
symbol: chainInfo.cardanoInfo.symbol,
|
|
310
313
|
decimals: chainInfo.cardanoInfo.decimals
|
|
311
314
|
};
|
|
312
|
-
}
|
|
315
|
+
}
|
|
316
|
+
if (chainInfo.bitcoinInfo) {
|
|
313
317
|
return {
|
|
318
|
+
...defaultTokenInfo,
|
|
314
319
|
symbol: chainInfo.bitcoinInfo.symbol,
|
|
315
320
|
decimals: chainInfo.bitcoinInfo.decimals
|
|
316
321
|
};
|
|
@@ -339,7 +344,6 @@ export function _isTokenEvmSmartContract(tokenInfo) {
|
|
|
339
344
|
export function _isTokenTonSmartContract(tokenInfo) {
|
|
340
345
|
return [_AssetType.TEP74].includes(tokenInfo.assetType); // add TEP-62 when supporting
|
|
341
346
|
}
|
|
342
|
-
|
|
343
347
|
export function _isCIP26Token(tokenInfo) {
|
|
344
348
|
return [_AssetType.CIP26].includes(tokenInfo.assetType);
|
|
345
349
|
}
|
|
@@ -367,12 +371,12 @@ export function _getXcmAssetType(tokenInfo) {
|
|
|
367
371
|
return ((_tokenInfo$metadata9 = tokenInfo.metadata) === null || _tokenInfo$metadata9 === void 0 ? void 0 : _tokenInfo$metadata9.assetType) || '';
|
|
368
372
|
}
|
|
369
373
|
export function _getXcmAssetId(tokenInfo) {
|
|
370
|
-
var _tokenInfo$
|
|
371
|
-
return ((_tokenInfo$
|
|
374
|
+
var _tokenInfo$metadata0;
|
|
375
|
+
return ((_tokenInfo$metadata0 = tokenInfo.metadata) === null || _tokenInfo$metadata0 === void 0 ? void 0 : _tokenInfo$metadata0.assetId) || '-1';
|
|
372
376
|
}
|
|
373
377
|
export function _getXcmAssetMultilocation(tokenInfo) {
|
|
374
|
-
var _tokenInfo$
|
|
375
|
-
return (_tokenInfo$
|
|
378
|
+
var _tokenInfo$metadata1;
|
|
379
|
+
return (_tokenInfo$metadata1 = tokenInfo.metadata) === null || _tokenInfo$metadata1 === void 0 ? void 0 : _tokenInfo$metadata1.multilocation;
|
|
376
380
|
}
|
|
377
381
|
export function _getXcmTransferType(originChainInfo, destinationChainInfo) {
|
|
378
382
|
var _originChainInfo$subs, _destinationChainInfo;
|
|
@@ -382,12 +386,12 @@ export function _isRelayChain(chainInfo) {
|
|
|
382
386
|
return _isSubstrateRelayChain(chainInfo) || _isPureEvmChain(chainInfo);
|
|
383
387
|
}
|
|
384
388
|
export function _isSubstrateRelayChain(chainInfo) {
|
|
385
|
-
var _chainInfo$
|
|
386
|
-
return ((_chainInfo$
|
|
389
|
+
var _chainInfo$substrateI14;
|
|
390
|
+
return ((_chainInfo$substrateI14 = chainInfo.substrateInfo) === null || _chainInfo$substrateI14 === void 0 ? void 0 : _chainInfo$substrateI14.chainType) === _SubstrateChainType.RELAYCHAIN;
|
|
387
391
|
}
|
|
388
392
|
export function _isSubstrateParaChain(chainInfo) {
|
|
389
|
-
var _chainInfo$
|
|
390
|
-
return chainInfo.substrateInfo !== null && chainInfo.substrateInfo.paraId !== null && ((_chainInfo$
|
|
393
|
+
var _chainInfo$substrateI15;
|
|
394
|
+
return chainInfo.substrateInfo !== null && chainInfo.substrateInfo.paraId !== null && ((_chainInfo$substrateI15 = chainInfo.substrateInfo) === null || _chainInfo$substrateI15 === void 0 ? void 0 : _chainInfo$substrateI15.chainType) === _SubstrateChainType.PARACHAIN;
|
|
391
395
|
}
|
|
392
396
|
export function _getEvmAbiExplorer(chainInfo) {
|
|
393
397
|
var _chainInfo$evmInfo4;
|
|
@@ -441,8 +445,8 @@ export function _getBlockExplorerFromChain(chainInfo) {
|
|
|
441
445
|
var _chainInfo$tonInfo;
|
|
442
446
|
blockExplorer = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$tonInfo = chainInfo.tonInfo) === null || _chainInfo$tonInfo === void 0 ? void 0 : _chainInfo$tonInfo.blockExplorer;
|
|
443
447
|
} else {
|
|
444
|
-
var _chainInfo$
|
|
445
|
-
blockExplorer = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$
|
|
448
|
+
var _chainInfo$substrateI16;
|
|
449
|
+
blockExplorer = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$substrateI16 = chainInfo.substrateInfo) === null || _chainInfo$substrateI16 === void 0 ? void 0 : _chainInfo$substrateI16.blockExplorer;
|
|
446
450
|
}
|
|
447
451
|
if (!blockExplorer) {
|
|
448
452
|
return undefined;
|
|
@@ -473,8 +477,8 @@ export const _isAssetAutoEnable = chainAsset => {
|
|
|
473
477
|
return chainAsset.metadata ? !!chainAsset.metadata.autoEnable : false;
|
|
474
478
|
};
|
|
475
479
|
export function _getCrowdloanUrlFromChain(chainInfo) {
|
|
476
|
-
var _chainInfo$
|
|
477
|
-
return (chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$
|
|
480
|
+
var _chainInfo$substrateI17;
|
|
481
|
+
return (chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$substrateI17 = chainInfo.substrateInfo) === null || _chainInfo$substrateI17 === void 0 ? void 0 : _chainInfo$substrateI17.crowdloanUrl) || '';
|
|
478
482
|
}
|
|
479
483
|
export function _isCustomProvider(providerKey) {
|
|
480
484
|
return providerKey.startsWith(_CUSTOM_PREFIX);
|
|
@@ -510,8 +514,8 @@ export function _isMantaZkAsset(chainAsset) {
|
|
|
510
514
|
return _MANTA_ZK_CHAIN_GROUP.includes(chainAsset.originChain) && chainAsset.symbol.startsWith(_ZK_ASSET_PREFIX);
|
|
511
515
|
}
|
|
512
516
|
export function _getChainExistentialDeposit(chainInfo) {
|
|
513
|
-
var _chainInfo$
|
|
514
|
-
return (chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$
|
|
517
|
+
var _chainInfo$substrateI18;
|
|
518
|
+
return (chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$substrateI18 = chainInfo.substrateInfo) === null || _chainInfo$substrateI18 === void 0 ? void 0 : _chainInfo$substrateI18.existentialDeposit) || '0';
|
|
515
519
|
}
|
|
516
520
|
export function _getAssetExistentialDeposit(chainAsset) {
|
|
517
521
|
return (chainAsset === null || chainAsset === void 0 ? void 0 : chainAsset.minAmount) || '0';
|
|
@@ -640,7 +644,7 @@ export const _isChainInfoCompatibleWithAccountInfo = (chainInfo, accountInfo) =>
|
|
|
640
644
|
type: accountType
|
|
641
645
|
} = accountInfo;
|
|
642
646
|
if (accountChainType === AccountChainType.SUBSTRATE) {
|
|
643
|
-
return _isPureSubstrateChain(chainInfo) &&
|
|
647
|
+
return _isPureSubstrateChain(chainInfo) && AllSubstrateKeypairTypes.includes(accountType);
|
|
644
648
|
}
|
|
645
649
|
if (accountChainType === AccountChainType.ETHEREUM) {
|
|
646
650
|
if (accountSignMode === AccountSignMode.ECDSA_SUBSTRATE_LEDGER) {
|
|
@@ -133,6 +133,14 @@ export default class BasePoolHandler {
|
|
|
133
133
|
|
|
134
134
|
/** Subscribe pool info */
|
|
135
135
|
|
|
136
|
+
/** Subscribe pool position */
|
|
137
|
+
|
|
138
|
+
/** Get pool reward */
|
|
139
|
+
|
|
140
|
+
/** Get pool reward history */
|
|
141
|
+
|
|
142
|
+
/** Get pool target */
|
|
143
|
+
|
|
136
144
|
/* Subscribe data */
|
|
137
145
|
|
|
138
146
|
/* Join action */
|
|
@@ -268,6 +276,24 @@ export default class BasePoolHandler {
|
|
|
268
276
|
|
|
269
277
|
/** Validate param to join the pool */
|
|
270
278
|
|
|
279
|
+
/* Validate */
|
|
280
|
+
|
|
281
|
+
/* Submit */
|
|
282
|
+
|
|
283
|
+
/** Create `transaction` to join the pool step-by-step */
|
|
284
|
+
|
|
285
|
+
/* Submit */
|
|
286
|
+
|
|
287
|
+
/* Join action */
|
|
288
|
+
|
|
289
|
+
/* Leave action */
|
|
290
|
+
|
|
291
|
+
/** Validate param to leave the pool */
|
|
292
|
+
|
|
293
|
+
/** Create `transaction` to leave the pool normal (default unstake) */
|
|
294
|
+
|
|
295
|
+
/** Create `transaction` to leave the pool fast (swap token) */
|
|
296
|
+
|
|
271
297
|
/** Create `transaction` to leave the pool */
|
|
272
298
|
async handleYieldLeave(fastLeave, amount, address, selectedTarget, netuid, slippage) {
|
|
273
299
|
if (fastLeave) {
|
|
@@ -283,6 +309,12 @@ export default class BasePoolHandler {
|
|
|
283
309
|
|
|
284
310
|
/** Create `transaction` to withdraw unstaked amount */
|
|
285
311
|
|
|
312
|
+
/** Create `transaction` to cancel unstake */
|
|
313
|
+
|
|
314
|
+
/** Create `transaction` to claim reward */
|
|
315
|
+
|
|
316
|
+
/** Change earning validator */
|
|
317
|
+
|
|
286
318
|
/** Check handler can handle slug */
|
|
287
319
|
canHandleSlug(slug) {
|
|
288
320
|
return this.slug === slug;
|
|
@@ -52,7 +52,6 @@ export default class BaseLendingPoolHandler extends BaseSpecialStakingPoolHandle
|
|
|
52
52
|
if (!(bnRemainingStake.isZero() || bnRemainingStake.gte(minStake))) {
|
|
53
53
|
errors.push(new TransactionError(StakingTxErrorType.INVALID_ACTIVE_STAKE)); // TODO
|
|
54
54
|
}
|
|
55
|
-
|
|
56
55
|
if (poolPosition.unstakings.length > maxUnstakeRequest) {
|
|
57
56
|
errors.push(new TransactionError(StakingTxErrorType.EXCEED_MAX_UNSTAKING, t('bg.EARNING.services.service.earning.lending.maxUnstakeTimes', {
|
|
58
57
|
replace: {
|
|
@@ -64,7 +63,6 @@ export default class BaseLendingPoolHandler extends BaseSpecialStakingPoolHandle
|
|
|
64
63
|
if (bnRemainingStake.lt(0)) {
|
|
65
64
|
errors.push(new TransactionError(StakingTxErrorType.INVALID_ACTIVE_STAKE)); // TODO
|
|
66
65
|
}
|
|
67
|
-
|
|
68
66
|
return Promise.resolve(errors);
|
|
69
67
|
}
|
|
70
68
|
|
|
@@ -249,7 +249,6 @@ export default class AcalaLiquidStakingPoolHandler extends BaseLiquidStakingPool
|
|
|
249
249
|
// Min target amount
|
|
250
250
|
weightedMinAmount // should always set a min target to prevent unexpected result
|
|
251
251
|
);
|
|
252
|
-
|
|
253
252
|
return [ExtrinsicType.REDEEM_LDOT, extrinsic];
|
|
254
253
|
}
|
|
255
254
|
async handleYieldUnstake(amount, address, selectedTarget) {
|