@subwallet/extension-base 1.3.71-0 → 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.
Files changed (74) hide show
  1. package/background/KoniTypes.d.ts +13 -2
  2. package/background/KoniTypes.js +3 -1
  3. package/cjs/background/KoniTypes.js +3 -1
  4. package/cjs/core/logic-validation/recipientAddress.js +1 -1
  5. package/cjs/core/logic-validation/transfer.js +33 -10
  6. package/cjs/core/types.js +1 -0
  7. package/cjs/koni/background/handlers/Extension.js +81 -8
  8. package/cjs/koni/background/handlers/State.js +2 -0
  9. package/cjs/packageInfo.js +1 -1
  10. package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +46 -2
  11. package/cjs/services/balance-service/transfer/token.js +13 -35
  12. package/cjs/services/balance-service/transfer/xcm/index.js +3 -8
  13. package/cjs/services/balance-service/transfer/xcm/utils.js +1 -1
  14. package/cjs/services/chain-service/constants.js +6 -5
  15. package/cjs/services/chain-service/index.js +1 -0
  16. package/cjs/services/chain-service/utils/patch.js +1 -1
  17. package/cjs/services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251223.js +55 -0
  18. package/cjs/services/migration-service/scripts/databases/MigrateAssetSetting20251223.js +41 -0
  19. package/cjs/services/migration-service/scripts/index.js +17 -13
  20. package/cjs/services/substrate-proxy-service/constant.js +26 -0
  21. package/cjs/services/substrate-proxy-service/index.js +170 -0
  22. package/cjs/services/transaction-service/index.js +78 -10
  23. package/cjs/services/transaction-service/utils.js +8 -5
  24. package/cjs/types/index.js +11 -0
  25. package/cjs/types/substrateProxyAccount/actions/index.js +1 -0
  26. package/cjs/types/substrateProxyAccount/index.js +16 -0
  27. package/cjs/utils/account/transform.js +5 -4
  28. package/cjs/utils/fee/transfer.js +4 -2
  29. package/core/logic-validation/recipientAddress.js +1 -1
  30. package/core/logic-validation/transfer.d.ts +3 -3
  31. package/core/logic-validation/transfer.js +34 -11
  32. package/core/types.d.ts +2 -1
  33. package/core/types.js +1 -0
  34. package/koni/background/handlers/Extension.d.ts +3 -0
  35. package/koni/background/handlers/Extension.js +81 -8
  36. package/koni/background/handlers/State.d.ts +2 -0
  37. package/koni/background/handlers/State.js +2 -0
  38. package/package.json +36 -6
  39. package/packageInfo.js +1 -1
  40. package/services/balance-service/helpers/subscribe/substrate/index.js +47 -3
  41. package/services/balance-service/transfer/token.d.ts +0 -4
  42. package/services/balance-service/transfer/token.js +12 -33
  43. package/services/balance-service/transfer/xcm/index.js +3 -8
  44. package/services/balance-service/transfer/xcm/utils.d.ts +0 -2
  45. package/services/balance-service/transfer/xcm/utils.js +1 -1
  46. package/services/chain-service/constants.d.ts +1 -1
  47. package/services/chain-service/constants.js +4 -4
  48. package/services/chain-service/index.js +1 -0
  49. package/services/chain-service/utils/patch.d.ts +1 -1
  50. package/services/chain-service/utils/patch.js +1 -1
  51. package/services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251223.d.ts +4 -0
  52. package/services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251223.js +46 -0
  53. package/services/migration-service/scripts/databases/MigrateAssetSetting20251223.d.ts +4 -0
  54. package/services/migration-service/scripts/databases/MigrateAssetSetting20251223.js +33 -0
  55. package/services/migration-service/scripts/index.js +8 -4
  56. package/services/open-gov/interface.d.ts +4 -3
  57. package/services/substrate-proxy-service/constant.d.ts +3 -0
  58. package/services/substrate-proxy-service/constant.js +19 -0
  59. package/services/substrate-proxy-service/index.d.ts +13 -0
  60. package/services/substrate-proxy-service/index.js +159 -0
  61. package/services/transaction-service/index.js +79 -11
  62. package/services/transaction-service/types.d.ts +2 -2
  63. package/services/transaction-service/utils.js +8 -5
  64. package/types/balance/transfer.d.ts +1 -0
  65. package/types/index.d.ts +1 -0
  66. package/types/index.js +1 -0
  67. package/types/substrateProxyAccount/actions/index.d.ts +17 -0
  68. package/types/substrateProxyAccount/actions/index.js +1 -0
  69. package/types/substrateProxyAccount/index.d.ts +23 -0
  70. package/types/substrateProxyAccount/index.js +8 -0
  71. package/types/transaction/request.d.ts +1 -0
  72. package/types/yield/actions/join/submit.d.ts +1 -1
  73. package/utils/account/transform.js +5 -4
  74. package/utils/fee/transfer.js +4 -2
@@ -13,7 +13,7 @@ import { _getTokensPalletLocked, _getTokensPalletTransferable } from '@subwallet
13
13
  import { _adaptX1Interior } from '@subwallet/extension-base/core/substrate/xcm-parser';
14
14
  import { getPSP22ContractPromise } from '@subwallet/extension-base/koni/api/contract-handler/wasm';
15
15
  import { getDefaultWeightV2 } from '@subwallet/extension-base/koni/api/contract-handler/wasm/utils';
16
- import { _BALANCE_CHAIN_GROUP, _MANTA_ZK_CHAIN_GROUP, _ZK_ASSET_PREFIX } from '@subwallet/extension-base/services/chain-service/constants';
16
+ import { _BALANCE_CHAIN_GROUP, _MANTA_ZK_CHAIN_GROUP, _ZK_ASSET_PREFIX, USE_MULTILOCATION_INDEX } from '@subwallet/extension-base/services/chain-service/constants';
17
17
  import { _checkSmartContractSupportByChain, _getAssetExistentialDeposit, _getAssetNetuid, _getChainExistentialDeposit, _getChainNativeTokenSlug, _getContractAddressOfToken, _getTokenOnChainAssetId, _getTokenOnChainInfo, _getTokenTypesSupportedByChain, _getXcmAssetMultilocation, _isBridgedToken, _isChainEvmCompatible } from '@subwallet/extension-base/services/chain-service/utils';
18
18
  import { filterAlphaAssetsByChain, filterAssetsByChainAndType } from '@subwallet/extension-base/utils';
19
19
  import BigN from 'bignumber.js';
@@ -422,16 +422,27 @@ const subscribeAssetsAccountPallet = async ({
422
422
  }
423
423
  });
424
424
  const unsubList = await Promise.all(Object.values(tokenMap).map(tokenInfo => {
425
+ if (tokenInfo.slug === 'energy_web_x-LOCAL-stEWT') {
426
+ return timer(0, CRON_REFRESH_PRICE_INTERVAL).subscribe(() => {
427
+ const getEwtFrozenBalance = async () => {
428
+ const ewtTokenBalances = await queryEwtFrozenBalance(substrateApi, addresses, assetMap[tokenInfo.slug], extrinsicType);
429
+ callback(ewtTokenBalances);
430
+ };
431
+ getEwtFrozenBalance().catch(console.error);
432
+ });
433
+ }
425
434
  try {
426
435
  const assetIndex = _getTokenOnChainAssetId(tokenInfo);
427
- if (assetIndex === '-1') {
436
+ if (assetIndex === '-1' && !USE_MULTILOCATION_INDEX.includes(chainInfo.slug)) {
428
437
  return undefined;
429
438
  }
439
+ const version = ['statemint', 'statemine', 'westend_assethub'].includes(chainInfo.slug) ? 4 : 3;
440
+ const index = USE_MULTILOCATION_INDEX.includes(chainInfo.slug) ? _adaptX1Interior(_getXcmAssetMultilocation(tokenInfo), version) : assetIndex;
430
441
  const params = [{
431
442
  section: 'query',
432
443
  module: assetsAccountKey.split('_')[1],
433
444
  method: assetsAccountKey.split('_')[2],
434
- args: addresses.map(address => [assetIndex, address])
445
+ args: addresses.map(address => [index, address])
435
446
  }];
436
447
 
437
448
  // Get Token Balance
@@ -592,4 +603,37 @@ async function queryGigaTokenBalance(substrateApi, addresses, tokenInfo, extrins
592
603
  locked: totalLockedFromTransfer.toString()
593
604
  };
594
605
  }));
606
+ }
607
+ async function queryEwtFrozenBalance(substrateApi, addresses, tokenInfo, extrinsicType) {
608
+ const multilocation = _getXcmAssetMultilocation(tokenInfo);
609
+ return await Promise.all(addresses.map(async address => {
610
+ const [_frozenBalance, _balanceInfo] = await Promise.all([substrateApi.api.query.assetsFreezer.frozenBalances(multilocation, address), substrateApi.api.query.assets.account(multilocation, address)]);
611
+ const balanceInfo = _balanceInfo.toPrimitive();
612
+ if (!balanceInfo) {
613
+ // no balance info response
614
+ return {
615
+ address: address,
616
+ tokenSlug: tokenInfo.slug,
617
+ free: '0',
618
+ locked: '0',
619
+ state: APIItemState.READY
620
+ };
621
+ }
622
+ const transferableBalance = _getAssetsPalletTransferable(balanceInfo, _getAssetExistentialDeposit(tokenInfo), extrinsicType);
623
+ const totalLockedFromTransfer = _getAssetsPalletLocked(balanceInfo);
624
+ let freeBalance = transferableBalance;
625
+ let lockedBalance = totalLockedFromTransfer;
626
+ const frozenBalance = _frozenBalance.toPrimitive();
627
+ if (frozenBalance) {
628
+ freeBalance = transferableBalance - BigInt(frozenBalance);
629
+ lockedBalance = totalLockedFromTransfer + BigInt(frozenBalance);
630
+ }
631
+ return {
632
+ address: address,
633
+ tokenSlug: tokenInfo.slug,
634
+ free: freeBalance.toString(),
635
+ locked: lockedBalance.toString(),
636
+ state: APIItemState.READY
637
+ };
638
+ }));
595
639
  }
@@ -13,8 +13,4 @@ interface CreateTransferExtrinsicProps {
13
13
  }
14
14
  export declare const createSubstrateExtrinsic: ({ from, networkKey, substrateApi, to, tokenInfo, transferAll, value }: CreateTransferExtrinsicProps) => Promise<[SubmittableExtrinsic | null, string]>;
15
15
  export declare const getTransferMockTxFee: (address: string, chainInfo: _ChainInfo, tokenInfo: _ChainAsset, api: _SubstrateApi | _EvmApi | _TonApi) => Promise<BigN>;
16
- export declare const getAccountNetuidTokenInfo: (address: string, tokenInfo: _ChainAsset, substrateApi: _SubstrateApi) => Promise<{
17
- isEnableTransferSubnet: boolean;
18
- accountHotKey: string | undefined;
19
- }>;
20
16
  export {};
@@ -3,10 +3,11 @@
3
3
 
4
4
  import { GearApi } from '@gear-js/api';
5
5
  import { _AssetType } from '@subwallet/chain-list/types';
6
+ import { _adaptX1Interior } from '@subwallet/extension-base/core/substrate/xcm-parser';
6
7
  import { getPSP22ContractPromise } from '@subwallet/extension-base/koni/api/contract-handler/wasm';
7
8
  import { getWasmContractGasLimit } from '@subwallet/extension-base/koni/api/contract-handler/wasm/utils';
8
9
  import { estimateTonTxFee } from '@subwallet/extension-base/services/balance-service/helpers/subscribe/ton/utils';
9
- import { _TRANSFER_CHAIN_GROUP } from '@subwallet/extension-base/services/chain-service/constants';
10
+ import { _TRANSFER_CHAIN_GROUP, USE_MULTILOCATION_INDEX } from '@subwallet/extension-base/services/chain-service/constants';
10
11
  import { _getContractAddressOfToken, _getTokenOnChainAssetId, _getTokenOnChainInfo, _getXcmAssetMultilocation, _isBridgedToken, _isChainEvmCompatible, _isChainTonCompatible, _isGigaToken, _isNativeToken, _isTokenGearSmartContract, _isTokenTransferredByEvm, _isTokenTransferredByTon, _isTokenWasmSmartContract } from '@subwallet/extension-base/services/chain-service/utils';
11
12
  import { calculateGasFeeParams } from '@subwallet/extension-base/services/fee-service/utils';
12
13
  import { combineEthFee, getGRC20ContractPromise, getVFTContractPromise } from '@subwallet/extension-base/utils';
@@ -25,7 +26,7 @@ export const createSubstrateExtrinsic = async ({
25
26
  transferAll,
26
27
  value
27
28
  }) => {
28
- var _tokenInfo$metadata, _tokenInfo$metadata2;
29
+ var _tokenInfo$metadata;
29
30
  const api = substrateApi.api;
30
31
  const isDisableTransfer = (_tokenInfo$metadata = tokenInfo.metadata) === null || _tokenInfo$metadata === void 0 ? void 0 : _tokenInfo$metadata.isDisableTransfer;
31
32
  if (isDisableTransfer) {
@@ -94,7 +95,15 @@ export const createSubstrateExtrinsic = async ({
94
95
  } else if (_TRANSFER_CHAIN_GROUP.bitcountry.includes(networkKey) && !_isNativeToken(tokenInfo)) {
95
96
  transfer = api.tx.currencies.transfer(to, _getTokenOnChainInfo(tokenInfo), value);
96
97
  } else if (_TRANSFER_CHAIN_GROUP.statemine.includes(networkKey) && !_isNativeToken(tokenInfo)) {
97
- transfer = api.tx.assets.transfer(_getTokenOnChainAssetId(tokenInfo), to, value);
98
+ if (USE_MULTILOCATION_INDEX.includes(networkKey)) {
99
+ const version = ['statemint', 'statemine', 'westend_assethub'].includes(networkKey) ? 4 : 3;
100
+ const multilocationIndex = _adaptX1Interior(_getXcmAssetMultilocation(tokenInfo), version);
101
+
102
+ // @ts-ignore
103
+ transfer = api.tx.assets.transfer(multilocationIndex, to, value);
104
+ } else {
105
+ transfer = api.tx.assets.transfer(_getTokenOnChainAssetId(tokenInfo), to, value);
106
+ }
98
107
  } else if (_TRANSFER_CHAIN_GROUP.sora_substrate.includes(networkKey) && isTxAssetsSupported) {
99
108
  transfer = api.tx.assets.transfer(_getTokenOnChainAssetId(tokenInfo), to, value);
100
109
  } else if (isTxBalancesSupported && _isNativeToken(tokenInfo)) {
@@ -112,18 +121,6 @@ export const createSubstrateExtrinsic = async ({
112
121
  }
113
122
  } else if (_TRANSFER_CHAIN_GROUP.truth.includes(networkKey)) {
114
123
  transfer = api.tx.assetManager.transfer(to, _getTokenOnChainInfo(tokenInfo), value);
115
- } else if (_TRANSFER_CHAIN_GROUP.bittensor.includes(networkKey) && (_tokenInfo$metadata2 = tokenInfo.metadata) !== null && _tokenInfo$metadata2 !== void 0 && _tokenInfo$metadata2.netuid) {
116
- var _tokenInfo$metadata3;
117
- const {
118
- accountHotKey,
119
- isEnableTransferSubnet
120
- } = await getAccountNetuidTokenInfo(from, tokenInfo, substrateApi);
121
- const tokenNetuid = (_tokenInfo$metadata3 = tokenInfo.metadata) === null || _tokenInfo$metadata3 === void 0 ? void 0 : _tokenInfo$metadata3.netuid;
122
- if (isEnableTransferSubnet && accountHotKey) {
123
- transfer = api.tx.subtensorModule.transferStake(from, accountHotKey, tokenNetuid, tokenNetuid, value);
124
- } else {
125
- return [null, value];
126
- }
127
124
  }
128
125
  return [transfer, transferAmount || value];
129
126
  };
@@ -180,22 +177,4 @@ export const getTransferMockTxFee = async (address, chainInfo, tokenInfo, api) =
180
177
  console.error('error mocking tx fee', e);
181
178
  return new BigN(0);
182
179
  }
183
- };
184
- export const getAccountNetuidTokenInfo = async (address, tokenInfo, substrateApi) => {
185
- var _tokenInfo$metadata4;
186
- const tokenNetuid = (_tokenInfo$metadata4 = tokenInfo.metadata) === null || _tokenInfo$metadata4 === void 0 ? void 0 : _tokenInfo$metadata4.netuid;
187
- if (!tokenNetuid) {
188
- return {
189
- isEnableTransferSubnet: false,
190
- accountHotKey: undefined
191
- };
192
- }
193
- const [isTransferToggle, rawStakeInfoForColdKey] = await Promise.all([substrateApi.api.query.subtensorModule.transferToggle(tokenNetuid), substrateApi.api.call.stakeInfoRuntimeApi.getStakeInfoForColdkey(address)]);
194
- const isEnableTransferSubnet = isTransferToggle.toPrimitive();
195
- const taoStakeInfos = rawStakeInfoForColdKey.toPrimitive();
196
- const accountHotKey = taoStakeInfos.find(value => value.netuid === tokenNetuid);
197
- return {
198
- isEnableTransferSubnet,
199
- accountHotKey: accountHotKey === null || accountHotKey === void 0 ? void 0 : accountHotKey.hotkey
200
- };
201
180
  };
@@ -102,8 +102,6 @@ export const dryRunXcmExtrinsicV2 = async (request, isPreview = false) => {
102
102
  const originDryRunRs = dryRunResult.origin;
103
103
  if (originDryRunRs.success) {
104
104
  const {
105
- assetHub,
106
- bridgeHub,
107
105
  destination,
108
106
  hops
109
107
  } = dryRunResult;
@@ -112,12 +110,9 @@ export const dryRunXcmExtrinsicV2 = async (request, isPreview = false) => {
112
110
  return false;
113
111
  }
114
112
  }
115
- if ((assetHub === null || assetHub === void 0 ? void 0 : assetHub.success) === false || (bridgeHub === null || bridgeHub === void 0 ? void 0 : bridgeHub.success) === false || (destination === null || destination === void 0 ? void 0 : destination.success) === false) {
116
- if ((destination === null || destination === void 0 ? void 0 : destination.success) === false) {
117
- // pass dry-run in these cases
118
- return isChainNotSupportDryRun(destination.failureReason) || isChainNotSupportPolkadotApi(destination.failureReason);
119
- }
120
- return false;
113
+ if ((destination === null || destination === void 0 ? void 0 : destination.success) === false) {
114
+ // pass dry-run in these cases
115
+ return isChainNotSupportDryRun(destination.failureReason) || isChainNotSupportPolkadotApi(destination.failureReason);
121
116
  }
122
117
  return true;
123
118
  }
@@ -19,8 +19,6 @@ export declare type THopInfo = {
19
19
  export declare type DryRunResult = {
20
20
  origin: DryRunNodeResult;
21
21
  destination?: DryRunNodeResult;
22
- assetHub?: DryRunNodeResult;
23
- bridgeHub?: DryRunNodeResult;
24
22
  hops: THopInfo[];
25
23
  };
26
24
  interface GetXcmFeeRequest {
@@ -6,7 +6,7 @@ import { ProxyServiceRoute } from '@subwallet/extension-base/types/environment';
6
6
  import { fetchFromProxyService } from '@subwallet/extension-base/utils';
7
7
  import BigNumber from 'bignumber.js';
8
8
  import { assert, compactToU8a, isHex, u8aConcat, u8aEq } from '@polkadot/util';
9
- const version = '/v4';
9
+ const version = '/v5';
10
10
  const paraSpellApi = {
11
11
  buildXcm: `${version}/x-transfer`,
12
12
  feeXcm: `${version}/xcm-fee`,
@@ -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';
@@ -1421,6 +1421,7 @@ export class ChainService {
1421
1421
  relaySlug: null,
1422
1422
  hasNativeNft: false,
1423
1423
  supportStaking: params.chainSpec.paraId === null,
1424
+ supportProxy: false,
1424
1425
  supportSmartContract: null
1425
1426
  };
1426
1427
  } else if (params.chainSpec.evmChainId !== null) {
@@ -1,5 +1,5 @@
1
1
  import { _ChainAsset, _ChainInfo, _MultiChainAsset } from '@subwallet/chain-list/types';
2
- export declare const ChainListVersion = "0.2.122";
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.122'; // update this when build chain-list
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
 
@@ -0,0 +1,4 @@
1
+ import BaseMigrationJob from '@subwallet/extension-base/services/migration-service/Base';
2
+ export default class MigrateTransactionHistoryBySymbol20251223 extends BaseMigrationJob {
3
+ run(): Promise<void>;
4
+ }
@@ -0,0 +1,46 @@
1
+ // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import BaseMigrationJob from '@subwallet/extension-base/services/migration-service/Base';
5
+ export default class MigrateTransactionHistoryBySymbol20251223 extends BaseMigrationJob {
6
+ async run() {
7
+ const state = this.state;
8
+ try {
9
+ const changeSlugsMap = {
10
+ 'gnosis-NATIVE-xDAI': 'gnosis-NATIVE-XDAI',
11
+ 'stable-ERC20-USD₮0-0x779Ded0c9e1022225f8E0630b35a9b54bE713736': 'stable-ERC20-USDT0-0x779Ded0c9e1022225f8E0630b35a9b54bE713736',
12
+ 'polygon-ERC20-USD₮0-0xc2132D05D31c914a87C6611C10748AEb04B58e8F': 'polygon-ERC20-USDT0-0xc2132D05D31c914a87C6611C10748AEb04B58e8F',
13
+ 'ethereum-ERC20-TON-0x582d872A1B094FC48F5DE31D3B73F2D9bE47def1': 'ethereum-ERC20-TONCOIN-0x582d872A1B094FC48F5DE31D3B73F2D9bE47def1',
14
+ 'moonbeam-ERC20-USDC.axl-0xCa01a1D0993565291051daFF390892518ACfAD3A': 'moonbeam-ERC20-axlUSDC-0xCa01a1D0993565291051daFF390892518ACfAD3A'
15
+ };
16
+ const allTxs = [];
17
+ await Promise.all(Object.entries(changeSlugsMap).map(async ([oldSlug, newSlug], i) => {
18
+ const oldSlugSplit = oldSlug.split('-');
19
+ const oldChainSlug = oldSlugSplit[0];
20
+ const oldSymbolSlug = oldSlugSplit[2];
21
+ const newSlugSplit = newSlug.split('-');
22
+ const newSymbolSlug = newSlugSplit[2];
23
+ const filterTransactions = await state.dbService.stores.transaction.table.where({
24
+ chain: oldChainSlug
25
+ }).and(tx => {
26
+ var _tx$amount;
27
+ return ((_tx$amount = tx.amount) === null || _tx$amount === void 0 ? void 0 : _tx$amount.symbol) === oldSymbolSlug;
28
+ }).toArray();
29
+ if (filterTransactions.length > 0) {
30
+ for (const transaction of filterTransactions) {
31
+ if (transaction.amount && transaction.amount.symbol === oldSymbolSlug) {
32
+ transaction.amount.symbol = newSymbolSlug;
33
+ }
34
+ if (transaction.fee && transaction.fee.symbol === oldSymbolSlug) {
35
+ transaction.fee.symbol = newSymbolSlug;
36
+ }
37
+ }
38
+ }
39
+ allTxs.push(...filterTransactions);
40
+ }));
41
+ await state.dbService.stores.transaction.table.bulkPut(allTxs);
42
+ } catch (e) {
43
+ this.logger.error(e);
44
+ }
45
+ }
46
+ }
@@ -0,0 +1,4 @@
1
+ import BaseMigrationJob from '@subwallet/extension-base/services/migration-service/Base';
2
+ export default class MigrateAssetSetting20251223 extends BaseMigrationJob {
3
+ run(): Promise<void>;
4
+ }
@@ -0,0 +1,33 @@
1
+ // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import BaseMigrationJob from '@subwallet/extension-base/services/migration-service/Base';
5
+ export default class MigrateAssetSetting20251223 extends BaseMigrationJob {
6
+ async run() {
7
+ try {
8
+ const changeSlugsMap = {
9
+ 'gnosis-NATIVE-xDAI': 'gnosis-NATIVE-XDAI',
10
+ 'stable-ERC20-USD₮0-0x779Ded0c9e1022225f8E0630b35a9b54bE713736': 'stable-ERC20-USDT0-0x779Ded0c9e1022225f8E0630b35a9b54bE713736',
11
+ 'polygon-ERC20-USD₮0-0xc2132D05D31c914a87C6611C10748AEb04B58e8F': 'polygon-ERC20-USDT0-0xc2132D05D31c914a87C6611C10748AEb04B58e8F',
12
+ 'ethereum-ERC20-TON-0x582d872A1B094FC48F5DE31D3B73F2D9bE47def1': 'ethereum-ERC20-TONCOIN-0x582d872A1B094FC48F5DE31D3B73F2D9bE47def1',
13
+ 'moonbeam-ERC20-USDC.axl-0xCa01a1D0993565291051daFF390892518ACfAD3A': 'moonbeam-ERC20-axlUSDC-0xCa01a1D0993565291051daFF390892518ACfAD3A'
14
+ };
15
+ const assetSetting = await this.state.chainService.getAssetSettings();
16
+ const migratedAssetSetting = {};
17
+ for (const [oldSlug, newSlug] of Object.entries(changeSlugsMap)) {
18
+ if (Object.keys(assetSetting).includes(oldSlug)) {
19
+ const isVisible = assetSetting[oldSlug].visible;
20
+ migratedAssetSetting[newSlug] = {
21
+ visible: isVisible
22
+ };
23
+ }
24
+ }
25
+ this.state.chainService.setAssetSettings({
26
+ ...assetSetting,
27
+ ...migratedAssetSetting
28
+ });
29
+ } catch (e) {
30
+ console.error(e);
31
+ }
32
+ }
33
+ }
@@ -1,13 +1,12 @@
1
1
  // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import MigrateAssetSetting20251107 from '@subwallet/extension-base/services/migration-service/scripts/databases/MigrateAssetSetting20251107';
5
- import MigrateChainPatrol from '@subwallet/extension-base/services/migration-service/scripts/MigrateChainPatrol';
6
- import MigrateTransactionHistoryBySymbol20251107 from '@subwallet/extension-base/services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251107';
7
4
  import ClearMetadataDatabase from "./databases/ClearMetadataDatabase.js";
8
5
  import ClearMetadataForMythos from "./databases/ClearMetadataForMythos.js";
9
6
  import MigrateAssetSetting from "./databases/MigrateAssetSetting.js";
10
7
  import MigrateAssetSetting20251027 from "./databases/MigrateAssetSetting20251027.js";
8
+ import MigrateAssetSetting20251107 from "./databases/MigrateAssetSetting20251107.js";
9
+ import MigrateAssetSetting20251223 from "./databases/MigrateAssetSetting20251223.js";
11
10
  import MigrateEarningVersion from "./databases/MigrateEarningVersion.js";
12
11
  import ReloadMetadata from "./databases/ReloadMetadata.js";
13
12
  import MigrateLedgerAccount from "./keyring/MigrateLedgerAccount.js";
@@ -26,6 +25,7 @@ import DeleteEarningData20251105 from "./DeleteEarningData20251105.js";
26
25
  import DisableZeroBalanceTokens from "./DisableZeroBalanceTokens.js";
27
26
  import EnableVaraChain from "./EnableVaraChain.js";
28
27
  import MigrateAuthUrls from "./MigrateAuthUrls.js";
28
+ import MigrateChainPatrol from "./MigrateChainPatrol.js";
29
29
  import MigrateImportedToken from "./MigrateImportedToken.js";
30
30
  import MigrateNetworkSettings from "./MigrateNetworkSettings.js";
31
31
  import MigrateNewUnifiedAccount from "./MigrateNewUnifiedAccount.js";
@@ -34,6 +34,8 @@ import MigrateTransactionHistory from "./MigrateTransactionHistory.js";
34
34
  import MigrateTransactionHistoryBridge from "./MigrateTransactionHistoryBridge.js";
35
35
  import MigrateTransactionHistoryBySymbol from "./MigrateTransactionHistoryBySymbol.js";
36
36
  import MigrateTransactionHistoryBySymbol20251027 from "./MigrateTransactionHistoryBySymbol20251027.js";
37
+ import MigrateTransactionHistoryBySymbol20251107 from "./MigrateTransactionHistoryBySymbol20251107.js";
38
+ import MigrateTransactionHistoryBySymbol20251223 from "./MigrateTransactionHistoryBySymbol20251223.js";
37
39
  import MigrateWalletReference from "./MigrateWalletReference.js";
38
40
  import OptimizeEnableToken from "./OptimizeEnableToken.js";
39
41
  export const EVERYTIME = '__everytime__';
@@ -81,5 +83,7 @@ export default {
81
83
  '1.3.64-02': MigrateTransactionHistoryBySymbol20251027,
82
84
  '1.3.65-01': DeleteEarningData20251105,
83
85
  '1.3.66-01': MigrateAssetSetting20251107,
84
- '1.3.66-02': MigrateTransactionHistoryBySymbol20251107
86
+ '1.3.66-02': MigrateTransactionHistoryBySymbol20251107,
87
+ '1.3.72-01': MigrateAssetSetting20251223,
88
+ '1.3.72-02': MigrateTransactionHistoryBySymbol20251223
85
89
  };
@@ -1,10 +1,11 @@
1
+ import { BaseRequestSign } from '@subwallet/extension-base/types';
1
2
  export declare enum GovVoteType {
2
3
  AYE = "aye",
3
4
  NAY = "nay",
4
5
  SPLIT = "split",
5
6
  ABSTAIN = "abstain"
6
7
  }
7
- interface BaseVoteRequest {
8
+ interface BaseVoteRequest extends BaseRequestSign {
8
9
  chain: string;
9
10
  address: string;
10
11
  referendumIndex: string;
@@ -27,7 +28,7 @@ export interface SplitAbstainVoteRequest extends BaseVoteRequest {
27
28
  nayAmount: string;
28
29
  }
29
30
  export declare type GovVoteRequest = StandardVoteRequest | SplitVoteRequest | SplitAbstainVoteRequest;
30
- export interface RemoveVoteRequest {
31
+ export interface RemoveVoteRequest extends BaseRequestSign {
31
32
  address: string;
32
33
  chain: string;
33
34
  trackId: number;
@@ -131,7 +132,7 @@ export interface GovDelegationDetail {
131
132
  target: string;
132
133
  conviction: Conviction;
133
134
  }
134
- export interface UnlockVoteRequest {
135
+ export interface UnlockVoteRequest extends BaseRequestSign {
135
136
  address: string;
136
137
  chain: string;
137
138
  trackIds?: number[];
@@ -0,0 +1,3 @@
1
+ import { ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
2
+ import { SubstrateProxyType } from '@subwallet/extension-base/types/substrateProxyAccount';
3
+ export declare const txTypeToSubstrateProxyMap: Partial<Record<ExtrinsicType, SubstrateProxyType[]>>;
@@ -0,0 +1,19 @@
1
+ // Copyright 2019-2022 @subwallet/extension-base
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
5
+ const SUBSTRATE_PROXY_ACCOUNT_EXTRINSIC_GROUPS = {
6
+ STAKING: [ExtrinsicType.STAKING_BOND, ExtrinsicType.STAKING_UNBOND, ExtrinsicType.STAKING_WITHDRAW, ExtrinsicType.STAKING_JOIN_POOL, ExtrinsicType.STAKING_LEAVE_POOL, ExtrinsicType.CHANGE_EARNING_VALIDATOR, ExtrinsicType.STAKING_CANCEL_UNSTAKE, ExtrinsicType.STAKING_CLAIM_REWARD],
7
+ GOV: [ExtrinsicType.GOV_VOTE, ExtrinsicType.GOV_UNVOTE, ExtrinsicType.GOV_UNLOCK_VOTE],
8
+ PROXY: [
9
+ // only type any can add proxy
10
+ ExtrinsicType.REMOVE_SUBSTRATE_PROXY_ACCOUNT]
11
+ };
12
+
13
+ // Map extrinsic type to possible substrate proxy types that can be used
14
+ // The governance proxy type will be support later
15
+ export const txTypeToSubstrateProxyMap = {
16
+ ...Object.fromEntries(SUBSTRATE_PROXY_ACCOUNT_EXTRINSIC_GROUPS.STAKING.map(t => [t, ['Staking', 'NonTransfer']])),
17
+ ...Object.fromEntries(SUBSTRATE_PROXY_ACCOUNT_EXTRINSIC_GROUPS.GOV.map(t => [t, ['Governance', 'NonTransfer']])),
18
+ ...Object.fromEntries(SUBSTRATE_PROXY_ACCOUNT_EXTRINSIC_GROUPS.PROXY.map(t => [t, ['NonTransfer']]))
19
+ };
@@ -0,0 +1,13 @@
1
+ import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError';
2
+ import KoniState from '@subwallet/extension-base/koni/background/handlers/State';
3
+ import { TransactionData } from '@subwallet/extension-base/types';
4
+ import { AddSubstrateProxyAccountParams, RemoveSubstrateProxyAccountParams, RequestGetSubstrateProxyAccountGroup, SubstrateProxyAccountGroup } from '@subwallet/extension-base/types/substrateProxyAccount';
5
+ export default class SubstrateProxyAccountService {
6
+ protected readonly state: KoniState;
7
+ constructor(state: KoniState);
8
+ private getSubstrateApi;
9
+ getSubstrateProxyAccountGroup(request: RequestGetSubstrateProxyAccountGroup): Promise<SubstrateProxyAccountGroup>;
10
+ addSubstrateProxyAccounts(data: AddSubstrateProxyAccountParams): Promise<TransactionData>;
11
+ validateAddSubstrateProxyAccount(params: AddSubstrateProxyAccountParams, signerSubstrateProxyAddress?: string): Promise<TransactionError[]>;
12
+ removeSubstrateProxyAccounts(data: RemoveSubstrateProxyAccountParams): Promise<TransactionData>;
13
+ }