@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
|
@@ -81,8 +81,8 @@ export declare const _TRANSFER_CHAIN_GROUP: {
|
|
|
81
81
|
centrifuge: string[];
|
|
82
82
|
disable_transfer: string[];
|
|
83
83
|
truth: string[];
|
|
84
|
-
bittensor: string[];
|
|
85
84
|
};
|
|
85
|
+
export declare const USE_MULTILOCATION_INDEX: string[];
|
|
86
86
|
export declare const _MANTA_ZK_CHAIN_GROUP: string[];
|
|
87
87
|
export declare const _ZK_ASSET_PREFIX = "zk";
|
|
88
88
|
export declare const _DEFAULT_MANTA_ZK_CHAIN = "calamari";
|
|
@@ -36,7 +36,7 @@ export const _BALANCE_CHAIN_GROUP = {
|
|
|
36
36
|
genshiro: ['genshiro_testnet', 'genshiro'],
|
|
37
37
|
equilibrium_parachain: ['equilibrium_parachain'],
|
|
38
38
|
bifrost: ['bifrost', 'acala', 'karura', 'acala_testnet', 'pioneer', 'bitcountry', 'bifrost_dot', 'hydradx_main', 'hydradx_rococo', 'pendulum', 'amplitude', 'continuum_network', 'truth_network', 'jamton', 'hydradx_hollarnet'],
|
|
39
|
-
statemine: ['statemine', 'astar', 'shiden', 'statemint', 'crabParachain', 'darwinia2', 'parallel', 'calamari', 'manta_network', 'rococo_assethub', 'liberlandTest', 'liberland', 'dentnet', 'pangolin', 'crust', 'phala', 'shibuya', 'dbcchain', 'westend_assethub', 'chainflip_assethub', 'origintrail', 'xode', 'paseo_assethub'],
|
|
39
|
+
statemine: ['statemine', 'astar', 'shiden', 'statemint', 'crabParachain', 'darwinia2', 'parallel', 'calamari', 'manta_network', 'rococo_assethub', 'liberlandTest', 'liberland', 'dentnet', 'pangolin', 'crust', 'phala', 'shibuya', 'dbcchain', 'westend_assethub', 'chainflip_assethub', 'origintrail', 'xode', 'paseo_assethub', 'energy_web_x'],
|
|
40
40
|
kusama: ['kusama', 'kintsugi', 'kintsugi_test', 'interlay', 'acala', 'statemint', 'karura', 'bifrost'],
|
|
41
41
|
// perhaps there are some runtime updates
|
|
42
42
|
centrifuge: ['centrifuge'],
|
|
@@ -289,16 +289,16 @@ export const _TRANSFER_CHAIN_GROUP = {
|
|
|
289
289
|
kintsugi: ['kintsugi', 'kintsugi_test', 'interlay', 'mangatax_para'],
|
|
290
290
|
genshiro: ['genshiro_testnet', 'genshiro', 'equilibrium_parachain'],
|
|
291
291
|
bitcountry: ['pioneer', 'bitcountry'],
|
|
292
|
-
statemine: ['statemint', 'statemine', 'darwinia2', 'astar', 'shiden', 'shibuya', 'parallel', 'liberland', 'liberlandTest', 'dentnet', 'dbcchain', 'westend_assethub', 'chainflip_assethub', 'origintrail', 'xode', 'paseo_assethub'],
|
|
292
|
+
statemine: ['statemint', 'statemine', 'darwinia2', 'astar', 'shiden', 'shibuya', 'parallel', 'liberland', 'liberlandTest', 'dentnet', 'dbcchain', 'westend_assethub', 'chainflip_assethub', 'origintrail', 'xode', 'paseo_assethub', 'energy_web_x'],
|
|
293
293
|
riochain: ['riochain'],
|
|
294
294
|
sora_substrate: ['sora_substrate'],
|
|
295
295
|
avail: ['kate', 'goldberg_testnet'],
|
|
296
296
|
pendulum: ['pendulum', 'amplitude', 'amplitude_test', 'hydradx_main', 'bifrost', 'bifrost_dot', 'jamton', 'hydradx_hollarnet'],
|
|
297
297
|
centrifuge: ['centrifuge'],
|
|
298
298
|
disable_transfer: ['crab', 'pangolin'],
|
|
299
|
-
truth: ['truth_network']
|
|
300
|
-
bittensor: ['bittensor']
|
|
299
|
+
truth: ['truth_network']
|
|
301
300
|
};
|
|
301
|
+
export const USE_MULTILOCATION_INDEX = ['energy_web_x'];
|
|
302
302
|
export const _MANTA_ZK_CHAIN_GROUP = ['calamari'];
|
|
303
303
|
export const _ZK_ASSET_PREFIX = 'zk';
|
|
304
304
|
export const _DEFAULT_MANTA_ZK_CHAIN = 'calamari';
|
|
@@ -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
|
|
@@ -1408,6 +1421,7 @@ export class ChainService {
|
|
|
1408
1421
|
relaySlug: null,
|
|
1409
1422
|
hasNativeNft: false,
|
|
1410
1423
|
supportStaking: params.chainSpec.paraId === null,
|
|
1424
|
+
supportProxy: false,
|
|
1411
1425
|
supportSmartContract: null
|
|
1412
1426
|
};
|
|
1413
1427
|
} else if (params.chainSpec.evmChainId !== null) {
|
|
@@ -1855,27 +1869,6 @@ export class ChainService {
|
|
|
1855
1869
|
});
|
|
1856
1870
|
this.setAssetSettings(assetSettings);
|
|
1857
1871
|
}
|
|
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
1872
|
subscribeAssetSettings() {
|
|
1880
1873
|
return this.assetSettingSubject;
|
|
1881
1874
|
}
|
|
@@ -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'];
|
|
@@ -347,7 +344,6 @@ export function _isTokenEvmSmartContract(tokenInfo) {
|
|
|
347
344
|
export function _isTokenTonSmartContract(tokenInfo) {
|
|
348
345
|
return [_AssetType.TEP74].includes(tokenInfo.assetType); // add TEP-62 when supporting
|
|
349
346
|
}
|
|
350
|
-
|
|
351
347
|
export function _isCIP26Token(tokenInfo) {
|
|
352
348
|
return [_AssetType.CIP26].includes(tokenInfo.assetType);
|
|
353
349
|
}
|
|
@@ -375,12 +371,12 @@ export function _getXcmAssetType(tokenInfo) {
|
|
|
375
371
|
return ((_tokenInfo$metadata9 = tokenInfo.metadata) === null || _tokenInfo$metadata9 === void 0 ? void 0 : _tokenInfo$metadata9.assetType) || '';
|
|
376
372
|
}
|
|
377
373
|
export function _getXcmAssetId(tokenInfo) {
|
|
378
|
-
var _tokenInfo$
|
|
379
|
-
return ((_tokenInfo$
|
|
374
|
+
var _tokenInfo$metadata0;
|
|
375
|
+
return ((_tokenInfo$metadata0 = tokenInfo.metadata) === null || _tokenInfo$metadata0 === void 0 ? void 0 : _tokenInfo$metadata0.assetId) || '-1';
|
|
380
376
|
}
|
|
381
377
|
export function _getXcmAssetMultilocation(tokenInfo) {
|
|
382
|
-
var _tokenInfo$
|
|
383
|
-
return (_tokenInfo$
|
|
378
|
+
var _tokenInfo$metadata1;
|
|
379
|
+
return (_tokenInfo$metadata1 = tokenInfo.metadata) === null || _tokenInfo$metadata1 === void 0 ? void 0 : _tokenInfo$metadata1.multilocation;
|
|
384
380
|
}
|
|
385
381
|
export function _getXcmTransferType(originChainInfo, destinationChainInfo) {
|
|
386
382
|
var _originChainInfo$subs, _destinationChainInfo;
|
|
@@ -390,12 +386,12 @@ export function _isRelayChain(chainInfo) {
|
|
|
390
386
|
return _isSubstrateRelayChain(chainInfo) || _isPureEvmChain(chainInfo);
|
|
391
387
|
}
|
|
392
388
|
export function _isSubstrateRelayChain(chainInfo) {
|
|
393
|
-
var _chainInfo$
|
|
394
|
-
return ((_chainInfo$
|
|
389
|
+
var _chainInfo$substrateI14;
|
|
390
|
+
return ((_chainInfo$substrateI14 = chainInfo.substrateInfo) === null || _chainInfo$substrateI14 === void 0 ? void 0 : _chainInfo$substrateI14.chainType) === _SubstrateChainType.RELAYCHAIN;
|
|
395
391
|
}
|
|
396
392
|
export function _isSubstrateParaChain(chainInfo) {
|
|
397
|
-
var _chainInfo$
|
|
398
|
-
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;
|
|
399
395
|
}
|
|
400
396
|
export function _getEvmAbiExplorer(chainInfo) {
|
|
401
397
|
var _chainInfo$evmInfo4;
|
|
@@ -449,8 +445,8 @@ export function _getBlockExplorerFromChain(chainInfo) {
|
|
|
449
445
|
var _chainInfo$tonInfo;
|
|
450
446
|
blockExplorer = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$tonInfo = chainInfo.tonInfo) === null || _chainInfo$tonInfo === void 0 ? void 0 : _chainInfo$tonInfo.blockExplorer;
|
|
451
447
|
} else {
|
|
452
|
-
var _chainInfo$
|
|
453
|
-
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;
|
|
454
450
|
}
|
|
455
451
|
if (!blockExplorer) {
|
|
456
452
|
return undefined;
|
|
@@ -481,8 +477,8 @@ export const _isAssetAutoEnable = chainAsset => {
|
|
|
481
477
|
return chainAsset.metadata ? !!chainAsset.metadata.autoEnable : false;
|
|
482
478
|
};
|
|
483
479
|
export function _getCrowdloanUrlFromChain(chainInfo) {
|
|
484
|
-
var _chainInfo$
|
|
485
|
-
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) || '';
|
|
486
482
|
}
|
|
487
483
|
export function _isCustomProvider(providerKey) {
|
|
488
484
|
return providerKey.startsWith(_CUSTOM_PREFIX);
|
|
@@ -518,8 +514,8 @@ export function _isMantaZkAsset(chainAsset) {
|
|
|
518
514
|
return _MANTA_ZK_CHAIN_GROUP.includes(chainAsset.originChain) && chainAsset.symbol.startsWith(_ZK_ASSET_PREFIX);
|
|
519
515
|
}
|
|
520
516
|
export function _getChainExistentialDeposit(chainInfo) {
|
|
521
|
-
var _chainInfo$
|
|
522
|
-
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';
|
|
523
519
|
}
|
|
524
520
|
export function _getAssetExistentialDeposit(chainAsset) {
|
|
525
521
|
return (chainAsset === null || chainAsset === void 0 ? void 0 : chainAsset.minAmount) || '0';
|
|
@@ -648,7 +644,7 @@ export const _isChainInfoCompatibleWithAccountInfo = (chainInfo, accountInfo) =>
|
|
|
648
644
|
type: accountType
|
|
649
645
|
} = accountInfo;
|
|
650
646
|
if (accountChainType === AccountChainType.SUBSTRATE) {
|
|
651
|
-
return _isPureSubstrateChain(chainInfo) &&
|
|
647
|
+
return _isPureSubstrateChain(chainInfo) && AllSubstrateKeypairTypes.includes(accountType);
|
|
652
648
|
}
|
|
653
649
|
if (accountChainType === AccountChainType.ETHEREUM) {
|
|
654
650
|
if (accountSignMode === AccountSignMode.ECDSA_SUBSTRATE_LEDGER) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _ChainAsset, _ChainInfo, _MultiChainAsset } from '@subwallet/chain-list/types';
|
|
2
|
-
export declare const ChainListVersion = "0.2.
|
|
2
|
+
export declare const ChainListVersion = "0.2.123";
|
|
3
3
|
export interface PatchInfo {
|
|
4
4
|
patchVersion: string;
|
|
5
5
|
appliedVersion: string;
|
|
@@ -5,7 +5,7 @@ const PRODUCTION_BRANCHES = ['master', 'webapp', 'webapp-dev'];
|
|
|
5
5
|
const branchName = process.env.BRANCH_NAME || 'subwallet-dev';
|
|
6
6
|
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');
|
|
7
7
|
const fetchFile = PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'list.json' : 'preview.json';
|
|
8
|
-
export const ChainListVersion = '0.2.
|
|
8
|
+
export const ChainListVersion = '0.2.123'; // update this when build chain-list
|
|
9
9
|
|
|
10
10
|
// todo: move this interface to chainlist
|
|
11
11
|
|
|
@@ -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) {
|
|
@@ -69,7 +69,6 @@ export default class BaseLiquidStakingPoolHandler extends BaseSpecialStakingPool
|
|
|
69
69
|
if (!(bnRemainingStake.isZero() || bnRemainingStake.gte(minStake))) {
|
|
70
70
|
errors.push(new TransactionError(StakingTxErrorType.INVALID_ACTIVE_STAKE)); // TODO
|
|
71
71
|
}
|
|
72
|
-
|
|
73
72
|
if (poolPosition.unstakings.length > maxUnstakeRequest) {
|
|
74
73
|
errors.push(new TransactionError(StakingTxErrorType.EXCEED_MAX_UNSTAKING, t('bg.EARNING.services.service.earning.liquidStaking.maxUnstakeTimes', {
|
|
75
74
|
replace: {
|
|
@@ -81,7 +80,6 @@ export default class BaseLiquidStakingPoolHandler extends BaseSpecialStakingPool
|
|
|
81
80
|
if (bnRemainingStake.lt(BN_ZERO)) {
|
|
82
81
|
errors.push(new TransactionError(StakingTxErrorType.INVALID_ACTIVE_STAKE)); // TODO
|
|
83
82
|
}
|
|
84
|
-
|
|
85
83
|
return Promise.resolve(errors);
|
|
86
84
|
}
|
|
87
85
|
|
|
@@ -154,7 +154,6 @@ export default class BifrostLiquidStakingPoolHandler extends BaseLiquidStakingPo
|
|
|
154
154
|
|
|
155
155
|
// const bnTotalBalance = bnActiveBalance.add(bnUnstakingBalance);
|
|
156
156
|
}
|
|
157
|
-
|
|
158
157
|
const unlockingMap = {};
|
|
159
158
|
|
|
160
159
|
// TODO: review unstaking info vtokenMinting.userUnlockLedger
|
|
@@ -203,7 +202,6 @@ export default class BifrostLiquidStakingPoolHandler extends BaseLiquidStakingPo
|
|
|
203
202
|
});
|
|
204
203
|
});
|
|
205
204
|
}
|
|
206
|
-
|
|
207
205
|
const activeToTotalBalance = exchangeRate.multipliedBy(bnActiveBalance.toString());
|
|
208
206
|
const totalBalance = activeToTotalBalance.plus(unlockBalance.toString());
|
|
209
207
|
const result = {
|
|
@@ -192,7 +192,6 @@ export default class AstarNativeStakingPoolHandler extends BaseParaNativeStaking
|
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
-
|
|
196
195
|
const unlockingChunks = ledger.unbondingInfo.unlockingChunks;
|
|
197
196
|
if (unlockingChunks.length > 0) {
|
|
198
197
|
for (const unlockingChunk of unlockingChunks) {
|
|
@@ -211,7 +210,6 @@ export default class AstarNativeStakingPoolHandler extends BaseParaNativeStaking
|
|
|
211
210
|
});
|
|
212
211
|
}
|
|
213
212
|
}
|
|
214
|
-
|
|
215
213
|
if (nominationList.length === 0 && unstakingList.length === 0) {
|
|
216
214
|
return {
|
|
217
215
|
balanceToken: this.nativeToken.slug,
|
|
@@ -8,6 +8,49 @@ import { reformatAddress } from '@subwallet/extension-base/utils';
|
|
|
8
8
|
import BigN from 'bignumber.js';
|
|
9
9
|
import { BN, BN_ZERO } from '@polkadot/util';
|
|
10
10
|
import TaoNativeStakingPoolHandler, { DEFAULT_DTAO_MINBOND } from "./tao.js";
|
|
11
|
+
|
|
12
|
+
// interface ApiResponse {
|
|
13
|
+
// data: SubnetData[];
|
|
14
|
+
// }
|
|
15
|
+
|
|
16
|
+
// interface PoolData {
|
|
17
|
+
// netuid: number;
|
|
18
|
+
// name: string;
|
|
19
|
+
// symbol: string;
|
|
20
|
+
// }
|
|
21
|
+
|
|
22
|
+
// interface PoolApiResponse {
|
|
23
|
+
// data: PoolData[];
|
|
24
|
+
// }
|
|
25
|
+
|
|
26
|
+
// const SUBNET_API_URL = 'https://dash.taostats.io/api/subnet';
|
|
27
|
+
// const POOL_API_URL = 'https://dash.taostats.io/api/dtao/pool';
|
|
28
|
+
|
|
29
|
+
// export async function fetchSubnetData () {
|
|
30
|
+
// try {
|
|
31
|
+
// const [subnetResponse, poolResponse] = await Promise.all([
|
|
32
|
+
// fetch(SUBNET_API_URL).then((res) => res.json()) as Promise<ApiResponse>,
|
|
33
|
+
// fetch(POOL_API_URL).then((res) => res.json()) as Promise<PoolApiResponse>
|
|
34
|
+
// ]);
|
|
35
|
+
|
|
36
|
+
// const poolMap = new Map(poolResponse.data.map((pool) => [pool.netuid, pool]));
|
|
37
|
+
|
|
38
|
+
// const filteredSubnets = subnetResponse.data.filter((subnet) => subnet.netuid !== 0);
|
|
39
|
+
|
|
40
|
+
// const mergedData = filteredSubnets.map((subnet) => ({
|
|
41
|
+
// ...subnet,
|
|
42
|
+
// name: poolMap.get(subnet.netuid)?.name || 'Unknown',
|
|
43
|
+
// symbol: poolMap.get(subnet.netuid)?.symbol || 'Unknown'
|
|
44
|
+
// }));
|
|
45
|
+
|
|
46
|
+
// return mergedData;
|
|
47
|
+
// } catch (err) {
|
|
48
|
+
// console.error('Error:', err);
|
|
49
|
+
|
|
50
|
+
// return [];
|
|
51
|
+
// }
|
|
52
|
+
// }
|
|
53
|
+
|
|
11
54
|
const getAlphaToTaoMapping = async substrateApi => {
|
|
12
55
|
const allSubnets = (await substrateApi.api.call.subnetInfoRuntimeApi.getAllDynamicInfo()).toJSON();
|
|
13
56
|
if (!allSubnets || allSubnets.length === 0) {
|
|
@@ -151,7 +151,6 @@ export default class EnergyNativeStakingPoolHandler extends BaseParaNativeStakin
|
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
|
-
|
|
155
154
|
const bnStake = new BN(nomination.amount);
|
|
156
155
|
const bnUnstakeBalance = unstakingMap[nomination.owner] ? new BN(unstakingMap[nomination.owner].claimable) : BN_ZERO;
|
|
157
156
|
const bnActiveStake = bnStake.sub(bnUnstakeBalance);
|
|
@@ -105,7 +105,6 @@ export default class MythosNativeStakingPoolHandler extends BaseParaStakingPoolH
|
|
|
105
105
|
// tvl: totalStake.toString(),
|
|
106
106
|
// inflation
|
|
107
107
|
},
|
|
108
|
-
|
|
109
108
|
maxPoolMembers: parseInt(maxStakers)
|
|
110
109
|
};
|
|
111
110
|
callback(data);
|
|
@@ -340,7 +339,6 @@ export default class MythosNativeStakingPoolHandler extends BaseParaStakingPoolH
|
|
|
340
339
|
}
|
|
341
340
|
extrinsicList.push(...[substrateApi.api.tx.collatorStaking.unstakeFrom(selectedTarget), substrateApi.api.tx.collatorStaking.unlock(null) // ignore amount to unlock all
|
|
342
341
|
]);
|
|
343
|
-
|
|
344
342
|
return [ExtrinsicType.STAKING_UNBOND, substrateApi.api.tx.utility.batchAll(extrinsicList)];
|
|
345
343
|
}
|
|
346
344
|
|
|
@@ -81,7 +81,6 @@ export default class ParaNativeStakingPoolHandler extends BaseParaNativeStakingP
|
|
|
81
81
|
if (unvestedAllocation) {
|
|
82
82
|
totalIssuance.add(unvestedAllocation); // for Turing network, read more at https://hackmd.io/@sbAqOuXkRvyiZPOB3Ryn6Q/Sypr3ZJh5
|
|
83
83
|
}
|
|
84
|
-
|
|
85
84
|
const inflationConfig = _inflation.toHuman();
|
|
86
85
|
const inflation = getParaCurrentInflation(parseRawNumber(totalStake.toString()), inflationConfig);
|
|
87
86
|
const eraTime = _STAKING_ERA_LENGTH_MAP[this.chain] || _STAKING_ERA_LENGTH_MAP.default; // in hours
|
|
@@ -178,7 +177,6 @@ export default class ParaNativeStakingPoolHandler extends BaseParaNativeStakingP
|
|
|
178
177
|
}
|
|
179
178
|
}
|
|
180
179
|
}
|
|
181
|
-
|
|
182
180
|
const bnStake = new BN(delegation.amount);
|
|
183
181
|
const bnUnstakeBalance = unstakingMap[delegation.owner] ? new BN(unstakingMap[delegation.owner].claimable) : BN_ZERO;
|
|
184
182
|
const bnActiveStake = bnStake.sub(bnUnstakeBalance);
|