@subwallet/extension-base 1.3.70-2 → 1.3.72-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 +13 -2
- package/background/KoniTypes.js +68 -9
- package/cjs/background/KoniTypes.js +68 -9
- package/cjs/constants/blocked-actions.js +3 -0
- package/cjs/core/logic-validation/recipientAddress.js +1 -1
- package/cjs/core/logic-validation/swap.js +0 -3
- package/cjs/core/logic-validation/transfer.js +33 -10
- package/cjs/core/substrate/system-pallet.js +0 -2
- package/cjs/core/types.js +1 -0
- 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 +235 -166
- package/cjs/koni/background/handlers/State.js +56 -52
- 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 +48 -5
- 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 +13 -37
- package/cjs/services/balance-service/transfer/ton-transfer.js +0 -1
- package/cjs/services/balance-service/transfer/xcm/index.js +3 -8
- package/cjs/services/balance-service/transfer/xcm/snowBridge.js +0 -1
- package/cjs/services/balance-service/transfer/xcm/utils.js +1 -1
- package/cjs/services/chain-service/constants.js +6 -5
- 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 +19 -26
- package/cjs/services/chain-service/utils/index.js +21 -25
- package/cjs/services/chain-service/utils/patch.js +1 -1
- 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/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/migration-service/scripts/MigrateTransactionHistoryBySymbol20251223.js +55 -0
- package/cjs/services/migration-service/scripts/databases/MigrateAssetSetting20251223.js +41 -0
- package/cjs/services/migration-service/scripts/index.js +17 -13
- 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 +0 -2
- package/cjs/services/open-gov/interface.js +4 -1
- 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 +0 -2
- package/cjs/services/storage-service/databases/index.js +2 -0
- package/cjs/services/substrate-proxy-service/constant.js +26 -0
- package/cjs/services/substrate-proxy-service/index.js +170 -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/index.js +105 -37
- package/cjs/services/transaction-service/utils.js +8 -5
- 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/index.js +11 -0
- package/cjs/types/substrateProxyAccount/actions/index.js +1 -0
- package/cjs/types/substrateProxyAccount/index.js +16 -0
- 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 +5 -4
- package/cjs/utils/index.js +1 -2
- package/constants/blocked-actions.js +3 -0
- package/core/logic-validation/recipientAddress.js +1 -1
- package/core/logic-validation/swap.js +0 -3
- package/core/logic-validation/transfer.d.ts +3 -3
- package/core/logic-validation/transfer.js +34 -11
- package/core/substrate/system-pallet.js +0 -2
- package/core/types.d.ts +2 -1
- package/core/types.js +1 -0
- 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 +3 -0
- package/koni/background/handlers/Extension.js +89 -19
- package/koni/background/handlers/State.d.ts +2 -0
- package/koni/background/handlers/State.js +43 -38
- package/koni/background/handlers/Tabs.js +9 -3
- package/package.json +50 -21
- 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 +47 -4
- 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.d.ts +0 -4
- package/services/balance-service/transfer/token.js +12 -35
- package/services/balance-service/transfer/ton-transfer.js +0 -1
- package/services/balance-service/transfer/xcm/index.js +3 -8
- package/services/balance-service/transfer/xcm/snowBridge.js +0 -1
- package/services/balance-service/transfer/xcm/utils.d.ts +0 -2
- package/services/balance-service/transfer/xcm/utils.js +1 -1
- package/services/chain-service/constants.d.ts +1 -1
- package/services/chain-service/constants.js +4 -4
- 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 +16 -23
- package/services/chain-service/utils/index.js +22 -26
- package/services/chain-service/utils/patch.d.ts +1 -1
- package/services/chain-service/utils/patch.js +1 -1
- 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/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/migration-service/scripts/MigrateTransactionHistoryBySymbol20251223.d.ts +4 -0
- package/services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251223.js +46 -0
- package/services/migration-service/scripts/databases/MigrateAssetSetting20251223.d.ts +4 -0
- package/services/migration-service/scripts/databases/MigrateAssetSetting20251223.js +33 -0
- package/services/migration-service/scripts/index.js +8 -4
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -1
- package/services/nft-service/index.js +6 -0
- package/services/open-gov/handler.js +0 -2
- package/services/open-gov/interface.d.ts +4 -3
- package/services/open-gov/interface.js +4 -1
- 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.js +0 -2
- package/services/storage-service/databases/index.js +3 -0
- package/services/substrate-proxy-service/constant.d.ts +3 -0
- package/services/substrate-proxy-service/constant.js +19 -0
- package/services/substrate-proxy-service/index.d.ts +13 -0
- package/services/substrate-proxy-service/index.js +159 -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/index.js +79 -11
- package/services/transaction-service/types.d.ts +2 -2
- package/services/transaction-service/utils.js +8 -5
- 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/balance/transfer.d.ts +1 -0
- package/types/index.d.ts +1 -0
- package/types/index.js +1 -0
- package/types/substrateProxyAccount/actions/index.d.ts +17 -0
- package/types/substrateProxyAccount/actions/index.js +1 -0
- package/types/substrateProxyAccount/index.d.ts +23 -0
- package/types/substrateProxyAccount/index.js +8 -0
- package/types/swap/index.js +2 -1
- package/types/transaction/process.js +3 -1
- package/types/transaction/request.d.ts +1 -0
- package/types/yield/actions/join/step.js +17 -1
- package/types/yield/actions/join/submit.d.ts +1 -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/fee/transfer.js +4 -2
- package/utils/index.js +2 -5
|
@@ -259,7 +259,6 @@ function _isEqualContractAddress(address1, address2) {
|
|
|
259
259
|
if ((0, _utilCrypto.isEthereumAddress)(address1) && (0, _utilCrypto.isEthereumAddress)(address2)) {
|
|
260
260
|
return address1.toLowerCase() === address2.toLowerCase(); // EVM address is case-insensitive
|
|
261
261
|
}
|
|
262
|
-
|
|
263
262
|
return address2 === address1;
|
|
264
263
|
}
|
|
265
264
|
function _isEqualSmartContractAsset(asset1, asset2) {
|
|
@@ -399,12 +398,10 @@ function _isSmartContractToken(tokenInfo) {
|
|
|
399
398
|
function _isChainSubstrateCompatible(chainInfo) {
|
|
400
399
|
return !!chainInfo.substrateInfo; // fallback to Ethereum
|
|
401
400
|
}
|
|
402
|
-
|
|
403
401
|
function _getEvmChainId(chainInfo) {
|
|
404
402
|
var _chainInfo$evmInfo;
|
|
405
403
|
return (_chainInfo$evmInfo = chainInfo.evmInfo) === null || _chainInfo$evmInfo === void 0 ? void 0 : _chainInfo$evmInfo.evmChainId; // fallback to Ethereum
|
|
406
404
|
}
|
|
407
|
-
|
|
408
405
|
function _getSubstrateParaId(chainInfo) {
|
|
409
406
|
var _chainInfo$substrateI;
|
|
410
407
|
return ((_chainInfo$substrateI = chainInfo.substrateInfo) === null || _chainInfo$substrateI === void 0 ? void 0 : _chainInfo$substrateI.paraId) || -1;
|
|
@@ -445,8 +442,8 @@ function _isChainSupportEvmERC20(chainInfo) {
|
|
|
445
442
|
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(_types._AssetType.ERC20)) || false;
|
|
446
443
|
}
|
|
447
444
|
function _isChainSupportWasmPSP22(chainInfo) {
|
|
448
|
-
var _chainInfo$
|
|
449
|
-
return ((_chainInfo$
|
|
445
|
+
var _chainInfo$substrateI0, _chainInfo$substrateI1;
|
|
446
|
+
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(_types._AssetType.PSP22)) || false;
|
|
450
447
|
}
|
|
451
448
|
function _isAssetHubChain(chainInfo) {
|
|
452
449
|
return ['statemint', 'statemine'].includes(chainInfo.slug);
|
|
@@ -455,12 +452,12 @@ function _isAssetHubToken(token) {
|
|
|
455
452
|
return ['statemint', 'statemine'].includes(token.originChain);
|
|
456
453
|
}
|
|
457
454
|
function _isChainSupportGRC20(chainInfo) {
|
|
458
|
-
var _chainInfo$
|
|
459
|
-
return ((_chainInfo$
|
|
455
|
+
var _chainInfo$substrateI10, _chainInfo$substrateI11;
|
|
456
|
+
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(_types._AssetType.GRC20)) || false;
|
|
460
457
|
}
|
|
461
458
|
function _isChainSupportVFT(chainInfo) {
|
|
462
|
-
var _chainInfo$
|
|
463
|
-
return ((_chainInfo$
|
|
459
|
+
var _chainInfo$substrateI12, _chainInfo$substrateI13;
|
|
460
|
+
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(_types._AssetType.VFT)) || false;
|
|
464
461
|
}
|
|
465
462
|
const _isSupportOrdinal = chain => {
|
|
466
463
|
const chains = ['polkadot', 'astar', 'bifrost_dot', 'moonbeam'];
|
|
@@ -573,7 +570,6 @@ function _isTokenEvmSmartContract(tokenInfo) {
|
|
|
573
570
|
function _isTokenTonSmartContract(tokenInfo) {
|
|
574
571
|
return [_types._AssetType.TEP74].includes(tokenInfo.assetType); // add TEP-62 when supporting
|
|
575
572
|
}
|
|
576
|
-
|
|
577
573
|
function _isCIP26Token(tokenInfo) {
|
|
578
574
|
return [_types._AssetType.CIP26].includes(tokenInfo.assetType);
|
|
579
575
|
}
|
|
@@ -601,12 +597,12 @@ function _getXcmAssetType(tokenInfo) {
|
|
|
601
597
|
return ((_tokenInfo$metadata9 = tokenInfo.metadata) === null || _tokenInfo$metadata9 === void 0 ? void 0 : _tokenInfo$metadata9.assetType) || '';
|
|
602
598
|
}
|
|
603
599
|
function _getXcmAssetId(tokenInfo) {
|
|
604
|
-
var _tokenInfo$
|
|
605
|
-
return ((_tokenInfo$
|
|
600
|
+
var _tokenInfo$metadata0;
|
|
601
|
+
return ((_tokenInfo$metadata0 = tokenInfo.metadata) === null || _tokenInfo$metadata0 === void 0 ? void 0 : _tokenInfo$metadata0.assetId) || '-1';
|
|
606
602
|
}
|
|
607
603
|
function _getXcmAssetMultilocation(tokenInfo) {
|
|
608
|
-
var _tokenInfo$
|
|
609
|
-
return (_tokenInfo$
|
|
604
|
+
var _tokenInfo$metadata1;
|
|
605
|
+
return (_tokenInfo$metadata1 = tokenInfo.metadata) === null || _tokenInfo$metadata1 === void 0 ? void 0 : _tokenInfo$metadata1.multilocation;
|
|
610
606
|
}
|
|
611
607
|
function _getXcmTransferType(originChainInfo, destinationChainInfo) {
|
|
612
608
|
var _originChainInfo$subs, _destinationChainInfo;
|
|
@@ -616,12 +612,12 @@ function _isRelayChain(chainInfo) {
|
|
|
616
612
|
return _isSubstrateRelayChain(chainInfo) || _isPureEvmChain(chainInfo);
|
|
617
613
|
}
|
|
618
614
|
function _isSubstrateRelayChain(chainInfo) {
|
|
619
|
-
var _chainInfo$
|
|
620
|
-
return ((_chainInfo$
|
|
615
|
+
var _chainInfo$substrateI14;
|
|
616
|
+
return ((_chainInfo$substrateI14 = chainInfo.substrateInfo) === null || _chainInfo$substrateI14 === void 0 ? void 0 : _chainInfo$substrateI14.chainType) === _types._SubstrateChainType.RELAYCHAIN;
|
|
621
617
|
}
|
|
622
618
|
function _isSubstrateParaChain(chainInfo) {
|
|
623
|
-
var _chainInfo$
|
|
624
|
-
return chainInfo.substrateInfo !== null && chainInfo.substrateInfo.paraId !== null && ((_chainInfo$
|
|
619
|
+
var _chainInfo$substrateI15;
|
|
620
|
+
return chainInfo.substrateInfo !== null && chainInfo.substrateInfo.paraId !== null && ((_chainInfo$substrateI15 = chainInfo.substrateInfo) === null || _chainInfo$substrateI15 === void 0 ? void 0 : _chainInfo$substrateI15.chainType) === _types._SubstrateChainType.PARACHAIN;
|
|
625
621
|
}
|
|
626
622
|
function _getEvmAbiExplorer(chainInfo) {
|
|
627
623
|
var _chainInfo$evmInfo4;
|
|
@@ -675,8 +671,8 @@ function _getBlockExplorerFromChain(chainInfo) {
|
|
|
675
671
|
var _chainInfo$tonInfo;
|
|
676
672
|
blockExplorer = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$tonInfo = chainInfo.tonInfo) === null || _chainInfo$tonInfo === void 0 ? void 0 : _chainInfo$tonInfo.blockExplorer;
|
|
677
673
|
} else {
|
|
678
|
-
var _chainInfo$
|
|
679
|
-
blockExplorer = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$
|
|
674
|
+
var _chainInfo$substrateI16;
|
|
675
|
+
blockExplorer = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$substrateI16 = chainInfo.substrateInfo) === null || _chainInfo$substrateI16 === void 0 ? void 0 : _chainInfo$substrateI16.blockExplorer;
|
|
680
676
|
}
|
|
681
677
|
if (!blockExplorer) {
|
|
682
678
|
return undefined;
|
|
@@ -708,8 +704,8 @@ const _isAssetAutoEnable = chainAsset => {
|
|
|
708
704
|
};
|
|
709
705
|
exports._isAssetAutoEnable = _isAssetAutoEnable;
|
|
710
706
|
function _getCrowdloanUrlFromChain(chainInfo) {
|
|
711
|
-
var _chainInfo$
|
|
712
|
-
return (chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$
|
|
707
|
+
var _chainInfo$substrateI17;
|
|
708
|
+
return (chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$substrateI17 = chainInfo.substrateInfo) === null || _chainInfo$substrateI17 === void 0 ? void 0 : _chainInfo$substrateI17.crowdloanUrl) || '';
|
|
713
709
|
}
|
|
714
710
|
function _isCustomProvider(providerKey) {
|
|
715
711
|
return providerKey.startsWith(_types2._CUSTOM_PREFIX);
|
|
@@ -747,8 +743,8 @@ function _isMantaZkAsset(chainAsset) {
|
|
|
747
743
|
return _constants._MANTA_ZK_CHAIN_GROUP.includes(chainAsset.originChain) && chainAsset.symbol.startsWith(_constants._ZK_ASSET_PREFIX);
|
|
748
744
|
}
|
|
749
745
|
function _getChainExistentialDeposit(chainInfo) {
|
|
750
|
-
var _chainInfo$
|
|
751
|
-
return (chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$
|
|
746
|
+
var _chainInfo$substrateI18;
|
|
747
|
+
return (chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$substrateI18 = chainInfo.substrateInfo) === null || _chainInfo$substrateI18 === void 0 ? void 0 : _chainInfo$substrateI18.existentialDeposit) || '0';
|
|
752
748
|
}
|
|
753
749
|
function _getAssetExistentialDeposit(chainAsset) {
|
|
754
750
|
return (chainAsset === null || chainAsset === void 0 ? void 0 : chainAsset.minAmount) || '0';
|
|
@@ -880,7 +876,7 @@ const _isChainInfoCompatibleWithAccountInfo = (chainInfo, accountInfo) => {
|
|
|
880
876
|
type: accountType
|
|
881
877
|
} = accountInfo;
|
|
882
878
|
if (accountChainType === _types3.AccountChainType.SUBSTRATE) {
|
|
883
|
-
return _isPureSubstrateChain(chainInfo) && _types4.
|
|
879
|
+
return _isPureSubstrateChain(chainInfo) && _types4.AllSubstrateKeypairTypes.includes(accountType);
|
|
884
880
|
}
|
|
885
881
|
if (accountChainType === _types3.AccountChainType.ETHEREUM) {
|
|
886
882
|
if (accountSignMode === _types3.AccountSignMode.ECDSA_SUBSTRATE_LEDGER) {
|
|
@@ -12,7 +12,7 @@ const PRODUCTION_BRANCHES = ['master', 'webapp', 'webapp-dev'];
|
|
|
12
12
|
const branchName = process.env.BRANCH_NAME || 'subwallet-dev';
|
|
13
13
|
const fetchDomain = process.env.PATCH_CHAIN_LIST_URL || (PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'https://chain-list-assets.subwallet.app' : 'https://dev.sw-chain-list-assets.pages.dev');
|
|
14
14
|
const fetchFile = PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'list.json' : 'preview.json';
|
|
15
|
-
const ChainListVersion = '0.2.
|
|
15
|
+
const ChainListVersion = '0.2.123'; // update this when build chain-list
|
|
16
16
|
|
|
17
17
|
// todo: move this interface to chainlist
|
|
18
18
|
exports.ChainListVersion = ChainListVersion;
|
|
@@ -141,6 +141,14 @@ class BasePoolHandler {
|
|
|
141
141
|
|
|
142
142
|
/** Subscribe pool info */
|
|
143
143
|
|
|
144
|
+
/** Subscribe pool position */
|
|
145
|
+
|
|
146
|
+
/** Get pool reward */
|
|
147
|
+
|
|
148
|
+
/** Get pool reward history */
|
|
149
|
+
|
|
150
|
+
/** Get pool target */
|
|
151
|
+
|
|
144
152
|
/* Subscribe data */
|
|
145
153
|
|
|
146
154
|
/* Join action */
|
|
@@ -276,6 +284,24 @@ class BasePoolHandler {
|
|
|
276
284
|
|
|
277
285
|
/** Validate param to join the pool */
|
|
278
286
|
|
|
287
|
+
/* Validate */
|
|
288
|
+
|
|
289
|
+
/* Submit */
|
|
290
|
+
|
|
291
|
+
/** Create `transaction` to join the pool step-by-step */
|
|
292
|
+
|
|
293
|
+
/* Submit */
|
|
294
|
+
|
|
295
|
+
/* Join action */
|
|
296
|
+
|
|
297
|
+
/* Leave action */
|
|
298
|
+
|
|
299
|
+
/** Validate param to leave the pool */
|
|
300
|
+
|
|
301
|
+
/** Create `transaction` to leave the pool normal (default unstake) */
|
|
302
|
+
|
|
303
|
+
/** Create `transaction` to leave the pool fast (swap token) */
|
|
304
|
+
|
|
279
305
|
/** Create `transaction` to leave the pool */
|
|
280
306
|
async handleYieldLeave(fastLeave, amount, address, selectedTarget, netuid, slippage) {
|
|
281
307
|
if (fastLeave) {
|
|
@@ -291,6 +317,12 @@ class BasePoolHandler {
|
|
|
291
317
|
|
|
292
318
|
/** Create `transaction` to withdraw unstaked amount */
|
|
293
319
|
|
|
320
|
+
/** Create `transaction` to cancel unstake */
|
|
321
|
+
|
|
322
|
+
/** Create `transaction` to claim reward */
|
|
323
|
+
|
|
324
|
+
/** Change earning validator */
|
|
325
|
+
|
|
294
326
|
/** Check handler can handle slug */
|
|
295
327
|
canHandleSlug(slug) {
|
|
296
328
|
return this.slug === slug;
|
|
@@ -59,7 +59,6 @@ class BaseLendingPoolHandler extends _special.default {
|
|
|
59
59
|
if (!(bnRemainingStake.isZero() || bnRemainingStake.gte(minStake))) {
|
|
60
60
|
errors.push(new _TransactionError.TransactionError(_types.StakingTxErrorType.INVALID_ACTIVE_STAKE)); // TODO
|
|
61
61
|
}
|
|
62
|
-
|
|
63
62
|
if (poolPosition.unstakings.length > maxUnstakeRequest) {
|
|
64
63
|
errors.push(new _TransactionError.TransactionError(_types.StakingTxErrorType.EXCEED_MAX_UNSTAKING, (0, _i18next.t)('bg.EARNING.services.service.earning.lending.maxUnstakeTimes', {
|
|
65
64
|
replace: {
|
|
@@ -71,7 +70,6 @@ class BaseLendingPoolHandler extends _special.default {
|
|
|
71
70
|
if (bnRemainingStake.lt(0)) {
|
|
72
71
|
errors.push(new _TransactionError.TransactionError(_types.StakingTxErrorType.INVALID_ACTIVE_STAKE)); // TODO
|
|
73
72
|
}
|
|
74
|
-
|
|
75
73
|
return Promise.resolve(errors);
|
|
76
74
|
}
|
|
77
75
|
|
|
@@ -257,7 +257,6 @@ class AcalaLiquidStakingPoolHandler extends _base.default {
|
|
|
257
257
|
// Min target amount
|
|
258
258
|
weightedMinAmount // should always set a min target to prevent unexpected result
|
|
259
259
|
);
|
|
260
|
-
|
|
261
260
|
return [_KoniTypes.ExtrinsicType.REDEEM_LDOT, extrinsic];
|
|
262
261
|
}
|
|
263
262
|
async handleYieldUnstake(amount, address, selectedTarget) {
|
|
@@ -76,7 +76,6 @@ class BaseLiquidStakingPoolHandler extends _special.default {
|
|
|
76
76
|
if (!(bnRemainingStake.isZero() || bnRemainingStake.gte(minStake))) {
|
|
77
77
|
errors.push(new _TransactionError.TransactionError(_types.StakingTxErrorType.INVALID_ACTIVE_STAKE)); // TODO
|
|
78
78
|
}
|
|
79
|
-
|
|
80
79
|
if (poolPosition.unstakings.length > maxUnstakeRequest) {
|
|
81
80
|
errors.push(new _TransactionError.TransactionError(_types.StakingTxErrorType.EXCEED_MAX_UNSTAKING, (0, _i18next.t)('bg.EARNING.services.service.earning.liquidStaking.maxUnstakeTimes', {
|
|
82
81
|
replace: {
|
|
@@ -88,7 +87,6 @@ class BaseLiquidStakingPoolHandler extends _special.default {
|
|
|
88
87
|
if (bnRemainingStake.lt(_util.BN_ZERO)) {
|
|
89
88
|
errors.push(new _TransactionError.TransactionError(_types.StakingTxErrorType.INVALID_ACTIVE_STAKE)); // TODO
|
|
90
89
|
}
|
|
91
|
-
|
|
92
90
|
return Promise.resolve(errors);
|
|
93
91
|
}
|
|
94
92
|
|
|
@@ -161,7 +161,6 @@ class BifrostLiquidStakingPoolHandler extends _base.default {
|
|
|
161
161
|
|
|
162
162
|
// const bnTotalBalance = bnActiveBalance.add(bnUnstakingBalance);
|
|
163
163
|
}
|
|
164
|
-
|
|
165
164
|
const unlockingMap = {};
|
|
166
165
|
|
|
167
166
|
// TODO: review unstaking info vtokenMinting.userUnlockLedger
|
|
@@ -213,7 +212,6 @@ class BifrostLiquidStakingPoolHandler extends _base.default {
|
|
|
213
212
|
});
|
|
214
213
|
});
|
|
215
214
|
}
|
|
216
|
-
|
|
217
215
|
const activeToTotalBalance = exchangeRate.multipliedBy(bnActiveBalance.toString());
|
|
218
216
|
const totalBalance = activeToTotalBalance.plus(unlockBalance.toString());
|
|
219
217
|
const result = {
|
|
@@ -200,7 +200,6 @@ class AstarNativeStakingPoolHandler extends _basePara.default {
|
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
}
|
|
203
|
-
|
|
204
203
|
const unlockingChunks = ledger.unbondingInfo.unlockingChunks;
|
|
205
204
|
if (unlockingChunks.length > 0) {
|
|
206
205
|
for (const unlockingChunk of unlockingChunks) {
|
|
@@ -219,7 +218,6 @@ class AstarNativeStakingPoolHandler extends _basePara.default {
|
|
|
219
218
|
});
|
|
220
219
|
}
|
|
221
220
|
}
|
|
222
|
-
|
|
223
221
|
if (nominationList.length === 0 && unstakingList.length === 0) {
|
|
224
222
|
return {
|
|
225
223
|
balanceToken: this.nativeToken.slug,
|
|
@@ -12,11 +12,52 @@ var _utils = require("@subwallet/extension-base/utils");
|
|
|
12
12
|
var _bignumber = _interopRequireDefault(require("bignumber.js"));
|
|
13
13
|
var _util = require("@polkadot/util");
|
|
14
14
|
var _tao = _interopRequireWildcard(require("./tao"));
|
|
15
|
-
function
|
|
16
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
17
16
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
18
17
|
// SPDX-License-Identifier: Apache-2.0
|
|
19
18
|
|
|
19
|
+
// interface ApiResponse {
|
|
20
|
+
// data: SubnetData[];
|
|
21
|
+
// }
|
|
22
|
+
|
|
23
|
+
// interface PoolData {
|
|
24
|
+
// netuid: number;
|
|
25
|
+
// name: string;
|
|
26
|
+
// symbol: string;
|
|
27
|
+
// }
|
|
28
|
+
|
|
29
|
+
// interface PoolApiResponse {
|
|
30
|
+
// data: PoolData[];
|
|
31
|
+
// }
|
|
32
|
+
|
|
33
|
+
// const SUBNET_API_URL = 'https://dash.taostats.io/api/subnet';
|
|
34
|
+
// const POOL_API_URL = 'https://dash.taostats.io/api/dtao/pool';
|
|
35
|
+
|
|
36
|
+
// export async function fetchSubnetData () {
|
|
37
|
+
// try {
|
|
38
|
+
// const [subnetResponse, poolResponse] = await Promise.all([
|
|
39
|
+
// fetch(SUBNET_API_URL).then((res) => res.json()) as Promise<ApiResponse>,
|
|
40
|
+
// fetch(POOL_API_URL).then((res) => res.json()) as Promise<PoolApiResponse>
|
|
41
|
+
// ]);
|
|
42
|
+
|
|
43
|
+
// const poolMap = new Map(poolResponse.data.map((pool) => [pool.netuid, pool]));
|
|
44
|
+
|
|
45
|
+
// const filteredSubnets = subnetResponse.data.filter((subnet) => subnet.netuid !== 0);
|
|
46
|
+
|
|
47
|
+
// const mergedData = filteredSubnets.map((subnet) => ({
|
|
48
|
+
// ...subnet,
|
|
49
|
+
// name: poolMap.get(subnet.netuid)?.name || 'Unknown',
|
|
50
|
+
// symbol: poolMap.get(subnet.netuid)?.symbol || 'Unknown'
|
|
51
|
+
// }));
|
|
52
|
+
|
|
53
|
+
// return mergedData;
|
|
54
|
+
// } catch (err) {
|
|
55
|
+
// console.error('Error:', err);
|
|
56
|
+
|
|
57
|
+
// return [];
|
|
58
|
+
// }
|
|
59
|
+
// }
|
|
60
|
+
|
|
20
61
|
const getAlphaToTaoMapping = async substrateApi => {
|
|
21
62
|
const allSubnets = (await substrateApi.api.call.subnetInfoRuntimeApi.getAllDynamicInfo()).toJSON();
|
|
22
63
|
if (!allSubnets || allSubnets.length === 0) {
|
|
@@ -158,7 +158,6 @@ class EnergyNativeStakingPoolHandler extends _basePara.default {
|
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
|
-
|
|
162
161
|
const bnStake = new _util.BN(nomination.amount);
|
|
163
162
|
const bnUnstakeBalance = unstakingMap[nomination.owner] ? new _util.BN(unstakingMap[nomination.owner].claimable) : _util.BN_ZERO;
|
|
164
163
|
const bnActiveStake = bnStake.sub(bnUnstakeBalance);
|
|
@@ -112,7 +112,6 @@ class MythosNativeStakingPoolHandler extends _basePara.default {
|
|
|
112
112
|
// tvl: totalStake.toString(),
|
|
113
113
|
// inflation
|
|
114
114
|
},
|
|
115
|
-
|
|
116
115
|
maxPoolMembers: parseInt(maxStakers)
|
|
117
116
|
};
|
|
118
117
|
callback(data);
|
|
@@ -347,7 +346,6 @@ class MythosNativeStakingPoolHandler extends _basePara.default {
|
|
|
347
346
|
}
|
|
348
347
|
extrinsicList.push(...[substrateApi.api.tx.collatorStaking.unstakeFrom(selectedTarget), substrateApi.api.tx.collatorStaking.unlock(null) // ignore amount to unlock all
|
|
349
348
|
]);
|
|
350
|
-
|
|
351
349
|
return [_KoniTypes.ExtrinsicType.STAKING_UNBOND, substrateApi.api.tx.utility.batchAll(extrinsicList)];
|
|
352
350
|
}
|
|
353
351
|
|
|
@@ -88,7 +88,6 @@ class ParaNativeStakingPoolHandler extends _basePara.default {
|
|
|
88
88
|
if (unvestedAllocation) {
|
|
89
89
|
totalIssuance.add(unvestedAllocation); // for Turing network, read more at https://hackmd.io/@sbAqOuXkRvyiZPOB3Ryn6Q/Sypr3ZJh5
|
|
90
90
|
}
|
|
91
|
-
|
|
92
91
|
const inflationConfig = _inflation.toHuman();
|
|
93
92
|
const inflation = (0, _utils.getParaCurrentInflation)((0, _utils3.parseRawNumber)(totalStake.toString()), inflationConfig);
|
|
94
93
|
const eraTime = _constants._STAKING_ERA_LENGTH_MAP[this.chain] || _constants._STAKING_ERA_LENGTH_MAP.default; // in hours
|
|
@@ -185,7 +184,6 @@ class ParaNativeStakingPoolHandler extends _basePara.default {
|
|
|
185
184
|
}
|
|
186
185
|
}
|
|
187
186
|
}
|
|
188
|
-
|
|
189
187
|
const bnStake = new _util.BN(delegation.amount);
|
|
190
188
|
const bnUnstakeBalance = unstakingMap[delegation.owner] ? new _util.BN(unstakingMap[delegation.owner].claimable) : _util.BN_ZERO;
|
|
191
189
|
const bnActiveStake = bnStake.sub(bnUnstakeBalance);
|
|
@@ -141,9 +141,9 @@ class RelayNativeStakingPoolHandler extends _base.default {
|
|
|
141
141
|
/* Subscribe pool position */
|
|
142
142
|
|
|
143
143
|
async parseNominatorMetadata(chainInfo, address, substrateApi, ledger, currentEra, minStake) {
|
|
144
|
-
var _substrateApi$api$que7, _substrateApi$api$que8, _substrateApi$api$que9, _substrateApi$api$
|
|
144
|
+
var _substrateApi$api$que7, _substrateApi$api$que8, _substrateApi$api$que9, _substrateApi$api$que0, _substrateApi$api$que1, _substrateApi$api$que10;
|
|
145
145
|
const chain = chainInfo.slug;
|
|
146
|
-
const [_nominations, _bonded, _activeEra] = await Promise.all([(_substrateApi$api$que7 = substrateApi.api.query) === null || _substrateApi$api$que7 === void 0 ? void 0 : (_substrateApi$api$que8 = _substrateApi$api$que7.staking) === null || _substrateApi$api$que8 === void 0 ? void 0 : _substrateApi$api$que8.nominators(address), (_substrateApi$api$que9 = substrateApi.api.query) === null || _substrateApi$api$que9 === void 0 ? void 0 : (_substrateApi$api$
|
|
146
|
+
const [_nominations, _bonded, _activeEra] = await Promise.all([(_substrateApi$api$que7 = substrateApi.api.query) === null || _substrateApi$api$que7 === void 0 ? void 0 : (_substrateApi$api$que8 = _substrateApi$api$que7.staking) === null || _substrateApi$api$que8 === void 0 ? void 0 : _substrateApi$api$que8.nominators(address), (_substrateApi$api$que9 = substrateApi.api.query) === null || _substrateApi$api$que9 === void 0 ? void 0 : (_substrateApi$api$que0 = _substrateApi$api$que9.staking) === null || _substrateApi$api$que0 === void 0 ? void 0 : _substrateApi$api$que0.bonded(address), (_substrateApi$api$que1 = substrateApi.api.query) === null || _substrateApi$api$que1 === void 0 ? void 0 : (_substrateApi$api$que10 = _substrateApi$api$que1.staking) === null || _substrateApi$api$que10 === void 0 ? void 0 : _substrateApi$api$que10.activeEra()]);
|
|
147
147
|
const unlimitedNominatorRewarded = substrateApi.api.consts.staking.maxExposurePageSize !== undefined;
|
|
148
148
|
const _maxNominatorRewardedPerValidator = (substrateApi.api.consts.staking.maxNominatorRewardedPerValidator || 0).toString();
|
|
149
149
|
const maxNominatorRewardedPerValidator = unlimitedNominatorRewarded ? undefined : parseInt(_maxNominatorRewardedPerValidator);
|
|
@@ -243,23 +243,22 @@ class RelayNativeStakingPoolHandler extends _base.default {
|
|
|
243
243
|
activeStake: '0' // relaychain allocates stake accordingly
|
|
244
244
|
});
|
|
245
245
|
}));
|
|
246
|
-
|
|
247
246
|
return nominationList;
|
|
248
247
|
}
|
|
249
248
|
async subscribePoolPosition(useAddresses, resultCallback) {
|
|
250
|
-
var _substrateApi$api$
|
|
249
|
+
var _substrateApi$api$que11;
|
|
251
250
|
let cancel = false;
|
|
252
251
|
const substrateApi = await this.substrateApi.isReady;
|
|
253
252
|
const defaultInfo = this.baseInfo;
|
|
254
253
|
const chainInfo = this.chainInfo;
|
|
255
|
-
const unsub = await ((_substrateApi$api$
|
|
254
|
+
const unsub = await ((_substrateApi$api$que11 = substrateApi.api.query.staking) === null || _substrateApi$api$que11 === void 0 ? void 0 : _substrateApi$api$que11.ledger.multi(useAddresses, async ledgers => {
|
|
256
255
|
if (cancel) {
|
|
257
256
|
unsub === null || unsub === void 0 ? void 0 : unsub();
|
|
258
257
|
return;
|
|
259
258
|
}
|
|
260
259
|
if (ledgers) {
|
|
261
|
-
var _substrateApi$api$
|
|
262
|
-
const [_currentEra, _minimumActiveStake, _minNominatorBond] = await Promise.all([(_substrateApi$api$
|
|
260
|
+
var _substrateApi$api$que12, _substrateApi$api$que13, _substrateApi$api$que14, _substrateApi$api$que15, _substrateApi$api$que16, _substrateApi$api$que17, _substrateApi$api$que18, _substrateApi$api$que19, _substrateApi$api$der, _substrateApi$api$der2;
|
|
261
|
+
const [_currentEra, _minimumActiveStake, _minNominatorBond] = await Promise.all([(_substrateApi$api$que12 = substrateApi.api.query) === null || _substrateApi$api$que12 === void 0 ? void 0 : (_substrateApi$api$que13 = _substrateApi$api$que12.staking) === null || _substrateApi$api$que13 === void 0 ? void 0 : _substrateApi$api$que13.currentEra(), ((_substrateApi$api$que14 = substrateApi.api.query) === null || _substrateApi$api$que14 === void 0 ? void 0 : (_substrateApi$api$que15 = _substrateApi$api$que14.staking) === null || _substrateApi$api$que15 === void 0 ? void 0 : _substrateApi$api$que15.minimumActiveStake) && ((_substrateApi$api$que16 = substrateApi.api.query) === null || _substrateApi$api$que16 === void 0 ? void 0 : (_substrateApi$api$que17 = _substrateApi$api$que16.staking) === null || _substrateApi$api$que17 === void 0 ? void 0 : _substrateApi$api$que17.minimumActiveStake()), (_substrateApi$api$que18 = substrateApi.api.query) === null || _substrateApi$api$que18 === void 0 ? void 0 : (_substrateApi$api$que19 = _substrateApi$api$que18.staking) === null || _substrateApi$api$que19 === void 0 ? void 0 : _substrateApi$api$que19.minNominatorBond(), (_substrateApi$api$der = substrateApi.api.derive) === null || _substrateApi$api$der === void 0 ? void 0 : (_substrateApi$api$der2 = _substrateApi$api$der.session) === null || _substrateApi$api$der2 === void 0 ? void 0 : _substrateApi$api$der2.progress()]);
|
|
263
262
|
const currentEra = _currentEra.toString();
|
|
264
263
|
const minActiveStake = (_minimumActiveStake === null || _minimumActiveStake === void 0 ? void 0 : _minimumActiveStake.toString()) || '0';
|
|
265
264
|
const minNominatorBond = _minNominatorBond.toString();
|
|
@@ -301,10 +300,10 @@ class RelayNativeStakingPoolHandler extends _base.default {
|
|
|
301
300
|
};
|
|
302
301
|
}
|
|
303
302
|
async checkAccountHaveStake(useAddresses) {
|
|
304
|
-
var _substrateApi$api$
|
|
303
|
+
var _substrateApi$api$que20, _substrateApi$api$que21, _substrateApi$api$que22;
|
|
305
304
|
const result = [];
|
|
306
305
|
const substrateApi = await this.substrateApi.isReady;
|
|
307
|
-
const ledgers = await ((_substrateApi$api$
|
|
306
|
+
const ledgers = await ((_substrateApi$api$que20 = substrateApi.api.query.staking) === null || _substrateApi$api$que20 === void 0 ? void 0 : (_substrateApi$api$que21 = _substrateApi$api$que20.ledger) === null || _substrateApi$api$que21 === void 0 ? void 0 : (_substrateApi$api$que22 = _substrateApi$api$que21.multi) === null || _substrateApi$api$que22 === void 0 ? void 0 : _substrateApi$api$que22.call(_substrateApi$api$que21, useAddresses));
|
|
308
307
|
if (ledgers) {
|
|
309
308
|
for (let i = 0; i < useAddresses.length; i++) {
|
|
310
309
|
const address = useAddresses[i];
|
|
@@ -281,6 +281,13 @@ class BaseSpecialStakingPoolHandler extends _base.default {
|
|
|
281
281
|
* @return Fee of the submitting step
|
|
282
282
|
* */
|
|
283
283
|
|
|
284
|
+
/**
|
|
285
|
+
* @async
|
|
286
|
+
* @function getSubmitStepFee
|
|
287
|
+
* @description Get submit step fee
|
|
288
|
+
* @return {Promise<YieldTokenBaseInfo>} Fee of the submitting step
|
|
289
|
+
* */
|
|
290
|
+
|
|
284
291
|
async getSubmitStep(params) {
|
|
285
292
|
const fee = await this.getSubmitStepFee(params);
|
|
286
293
|
return [this.submitJoinStepInfo, fee];
|
|
@@ -47,7 +47,6 @@ exports.SubsquidTransactionType = SubsquidTransactionType;
|
|
|
47
47
|
const HISTORY_SUPPORT_TYPES = [SubsquidTransactionType.BalanceTransfer, SubsquidTransactionType.EthereumExecuted, SubsquidTransactionType.StakingBonded
|
|
48
48
|
// SubsquidTransactionType.CrowdloanContributed // Not support because data indexer not enough data
|
|
49
49
|
];
|
|
50
|
-
|
|
51
50
|
function parseData(anyData) {
|
|
52
51
|
try {
|
|
53
52
|
return JSON.parse(anyData);
|
|
@@ -15,7 +15,7 @@ var _Base = require("./Base");
|
|
|
15
15
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
16
16
|
// SPDX-License-Identifier: Apache-2.0
|
|
17
17
|
|
|
18
|
-
const validDeriveKeypairTypes = [..._types2.
|
|
18
|
+
const validDeriveKeypairTypes = [..._types2.DefaultSubstrateKeypairTypes, ..._types2.EthereumKeypairTypes, 'ton', 'cardano', ..._types2.BitcoinKeypairTypes];
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* @class AccountDeriveHandler
|
|
@@ -5,8 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.SESSION_TIMEOUT = exports.AccountMigrationHandler = void 0;
|
|
7
7
|
var _Base = require("@subwallet/extension-base/services/keyring-service/context/handlers/Base");
|
|
8
|
+
var _utils = require("@subwallet/extension-base/services/keyring-service/utils");
|
|
8
9
|
var _types = require("@subwallet/extension-base/types");
|
|
9
|
-
var
|
|
10
|
+
var _utils2 = require("@subwallet/extension-base/utils");
|
|
10
11
|
var _getId = require("@subwallet/extension-base/utils/getId");
|
|
11
12
|
var _uiKeyring = require("@subwallet/ui-keyring");
|
|
12
13
|
var _utilCrypto = require("@polkadot/util-crypto");
|
|
@@ -34,7 +35,8 @@ class AccountMigrationHandler extends _Base.AccountBaseHandler {
|
|
|
34
35
|
async migrateUnifiedAndFetchEligibleSoloAccounts(request, setMigratingModeFn) {
|
|
35
36
|
// Migrate unified -> unified
|
|
36
37
|
const password = request.password;
|
|
37
|
-
const
|
|
38
|
+
const _allAccountProxies = Object.values(this.state.accounts);
|
|
39
|
+
const allAccountProxies = _allAccountProxies.filter(acc => !(0, _utils.isTWAccount)(acc)); // Prevent migrate TrustWallet solo account
|
|
38
40
|
const UACanBeMigrated = this.getUACanBeMigrated(allAccountProxies);
|
|
39
41
|
const UACanBeMigratedSortedByParent = this.sortUAByParent(UACanBeMigrated); // master account must be migrated before derived account
|
|
40
42
|
const migratedUnifiedAccountIds = await this.migrateUnifiedToUnifiedAccount(password, UACanBeMigratedSortedByParent, setMigratingModeFn);
|
|
@@ -82,9 +84,9 @@ class AccountMigrationHandler extends _Base.AccountBaseHandler {
|
|
|
82
84
|
proxyId
|
|
83
85
|
}).result;
|
|
84
86
|
const newChainTypes = Object.values(_types.AccountChainType).filter(type => !unifiedAccount.chainTypes.includes(type) && _types.SUPPORTED_ACCOUNT_CHAIN_TYPES.includes(type));
|
|
85
|
-
const keypairTypes = newChainTypes.flatMap(chainType => (0,
|
|
87
|
+
const keypairTypes = newChainTypes.flatMap(chainType => (0, _utils2.getDefaultKeypairTypeFromAccountChainType)(chainType));
|
|
86
88
|
keypairTypes.forEach(type => {
|
|
87
|
-
const suri = (0,
|
|
89
|
+
const suri = (0, _utils2.getSuri)(mnemonic, type);
|
|
88
90
|
const pair = _uiKeyring.keyring.createFromUri(suri, {}, type);
|
|
89
91
|
const address = pair.address;
|
|
90
92
|
modifiedPairs[address] = {
|
|
@@ -94,7 +96,7 @@ class AccountMigrationHandler extends _Base.AccountBaseHandler {
|
|
|
94
96
|
};
|
|
95
97
|
});
|
|
96
98
|
keypairTypes.forEach(type => {
|
|
97
|
-
const suri = (0,
|
|
99
|
+
const suri = (0, _utils2.getSuri)(mnemonic, type);
|
|
98
100
|
const {
|
|
99
101
|
derivePath
|
|
100
102
|
} = (0, _utilCrypto.keyExtractSuri)(suri);
|
|
@@ -141,7 +143,7 @@ class AccountMigrationHandler extends _Base.AccountBaseHandler {
|
|
|
141
143
|
password,
|
|
142
144
|
proxyId: oldProxyId
|
|
143
145
|
}).result;
|
|
144
|
-
const upcomingProxyId = (0,
|
|
146
|
+
const upcomingProxyId = (0, _utils2.createAccountProxyId)(mnemonic);
|
|
145
147
|
if (!rs[upcomingProxyId]) {
|
|
146
148
|
rs[upcomingProxyId] = [];
|
|
147
149
|
}
|
|
@@ -187,9 +189,9 @@ class AccountMigrationHandler extends _Base.AccountBaseHandler {
|
|
|
187
189
|
password,
|
|
188
190
|
proxyId: firstAccountOldProxyId
|
|
189
191
|
}).result;
|
|
190
|
-
const keypairTypes = _types.SUPPORTED_ACCOUNT_CHAIN_TYPES.flatMap(chainType => (0,
|
|
192
|
+
const keypairTypes = _types.SUPPORTED_ACCOUNT_CHAIN_TYPES.flatMap(chainType => (0, _utils2.getDefaultKeypairTypeFromAccountChainType)(chainType));
|
|
191
193
|
keypairTypes.forEach(type => {
|
|
192
|
-
const suri = (0,
|
|
194
|
+
const suri = (0, _utils2.getSuri)(mnemonic, type);
|
|
193
195
|
const pair = _uiKeyring.keyring.createFromUri(suri, {}, type);
|
|
194
196
|
const address = pair.address;
|
|
195
197
|
modifiedPairs[address] = {
|
|
@@ -205,7 +207,7 @@ class AccountMigrationHandler extends _Base.AccountBaseHandler {
|
|
|
205
207
|
});
|
|
206
208
|
const soloAccountProxyIds = [];
|
|
207
209
|
keypairTypes.forEach(type => {
|
|
208
|
-
const suri = (0,
|
|
210
|
+
const suri = (0, _utils2.getSuri)(mnemonic, type);
|
|
209
211
|
const {
|
|
210
212
|
derivePath
|
|
211
213
|
} = (0, _utilCrypto.keyExtractSuri)(suri);
|
|
@@ -50,10 +50,11 @@ class AccountMnemonicHandler extends _Base.AccountBaseHandler {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
/* Validate seed */
|
|
53
|
-
mnemonicValidateV2(
|
|
54
|
-
|
|
55
|
-
mnemonic
|
|
56
|
-
|
|
53
|
+
mnemonicValidateV2(request) {
|
|
54
|
+
const {
|
|
55
|
+
mnemonic,
|
|
56
|
+
mnemonicType
|
|
57
|
+
} = request;
|
|
57
58
|
const {
|
|
58
59
|
phrase
|
|
59
60
|
} = (0, _utilCrypto.keyExtractSuri)(mnemonic);
|
|
@@ -70,8 +71,13 @@ class AccountMnemonicHandler extends _Base.AccountBaseHandler {
|
|
|
70
71
|
}));
|
|
71
72
|
try {
|
|
72
73
|
(0, _util.assert)((0, _utilCrypto.mnemonicValidate)(phrase), (0, _i18next.t)('bg.ACCOUNT.services.keyring.handler.Mnemonic.invalidSeedPhraseTryAgain'));
|
|
73
|
-
|
|
74
|
-
|
|
74
|
+
if (mnemonicType === 'trust-wallet') {
|
|
75
|
+
mnemonicTypes = 'trust-wallet';
|
|
76
|
+
pairTypes = ['ed25519-tw'];
|
|
77
|
+
} else {
|
|
78
|
+
mnemonicTypes = 'general';
|
|
79
|
+
pairTypes = ['sr25519', ..._types2.EthereumKeypairTypes, 'ton', ..._types2.CardanoKeypairTypes, ..._types2.BitcoinKeypairTypes];
|
|
80
|
+
}
|
|
75
81
|
} catch (e) {
|
|
76
82
|
(0, _util.assert)((0, _utils2.tonMnemonicValidate)(phrase), (0, _i18next.t)('bg.ACCOUNT.services.keyring.handler.Mnemonic.invalidSeedPhraseTryAgain'));
|
|
77
83
|
mnemonicTypes = 'ton';
|
|
@@ -87,10 +93,10 @@ class AccountMnemonicHandler extends _Base.AccountBaseHandler {
|
|
|
87
93
|
pairTypes.forEach(type => {
|
|
88
94
|
rs.addressMap[type] = _uiKeyring.keyring.createFromUri((0, _utils.getSuri)(mnemonic, type), {}, type).address;
|
|
89
95
|
});
|
|
90
|
-
const
|
|
91
|
-
(0, _util.assert)(!
|
|
96
|
+
const existingAccount = this.state.checkAddressExists(Object.values(rs.addressMap));
|
|
97
|
+
(0, _util.assert)(!existingAccount, (0, _i18next.t)('bg.ACCOUNT.services.keyring.handler.Mnemonic.accountAlreadyExistsWithName', {
|
|
92
98
|
replace: {
|
|
93
|
-
name: (
|
|
99
|
+
name: (existingAccount === null || existingAccount === void 0 ? void 0 : existingAccount.name) || (existingAccount === null || existingAccount === void 0 ? void 0 : existingAccount.address) || ''
|
|
94
100
|
}
|
|
95
101
|
}));
|
|
96
102
|
return rs;
|
|
@@ -103,12 +109,11 @@ class AccountMnemonicHandler extends _Base.AccountBaseHandler {
|
|
|
103
109
|
name,
|
|
104
110
|
password,
|
|
105
111
|
suri: _suri,
|
|
106
|
-
|
|
112
|
+
types
|
|
107
113
|
} = request;
|
|
108
114
|
const addressDict = {};
|
|
109
115
|
let changedAccount = false;
|
|
110
116
|
const hasMasterPassword = _uiKeyring.keyring.keyring.hasMasterPassword;
|
|
111
|
-
const types = type ? [type] : ['sr25519', ..._types2.EthereumKeypairTypes, 'ton', ..._types2.CardanoKeypairTypes, ..._types2.BitcoinKeypairTypes];
|
|
112
117
|
if (!hasMasterPassword) {
|
|
113
118
|
if (!password) {
|
|
114
119
|
throw Error((0, _i18next.t)('bg.ACCOUNT.services.keyring.handler.Mnemonic.eachAccountPasswordNeeded'));
|
|
@@ -183,11 +188,11 @@ class AccountMnemonicHandler extends _Base.AccountBaseHandler {
|
|
|
183
188
|
|
|
184
189
|
/* Export mnemonic */
|
|
185
190
|
|
|
186
|
-
exportAccountProxyMnemonic(
|
|
191
|
+
exportAccountProxyMnemonic(_ref2) {
|
|
187
192
|
let {
|
|
188
193
|
password,
|
|
189
194
|
proxyId
|
|
190
|
-
} =
|
|
195
|
+
} = _ref2;
|
|
191
196
|
const isUnified = this.state.isUnifiedAccount(proxyId);
|
|
192
197
|
if (!isUnified) {
|
|
193
198
|
const pair = _uiKeyring.keyring.getPair(proxyId);
|