@subwallet/extension-base 1.1.21-3 → 1.1.23-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 (59) hide show
  1. package/background/KoniTypes.d.ts +10 -1
  2. package/cjs/koni/api/dotsama/balance.js +51 -1
  3. package/cjs/koni/api/dotsama/crowdloan.js +29 -3
  4. package/cjs/koni/api/dotsama/transfer.js +10 -3
  5. package/cjs/koni/api/staking/bonding/astar.js +9 -5
  6. package/cjs/koni/api/staking/bonding/relayChain.js +2 -2
  7. package/cjs/koni/api/xcm/index.js +6 -1
  8. package/cjs/koni/api/xcm/polkadotXcm.js +1 -3
  9. package/cjs/koni/api/xcm/xTokens.js +1 -1
  10. package/cjs/koni/background/handlers/Extension.js +117 -99
  11. package/cjs/koni/background/handlers/State.js +12 -6
  12. package/cjs/koni/background/subscription.js +1 -1
  13. package/cjs/packageInfo.js +1 -1
  14. package/cjs/services/chain-service/constants.js +8 -4
  15. package/cjs/services/chain-service/handler/SubstrateApi.js +9 -0
  16. package/cjs/services/chain-service/handler/chain-spec/goldberg.js +123 -0
  17. package/cjs/services/chain-service/index.js +18 -0
  18. package/cjs/services/history-service/helpers/subscan-extrinsic-parser-helper.js +53 -0
  19. package/cjs/services/history-service/index.js +78 -21
  20. package/cjs/services/history-service/subscan-history.js +107 -0
  21. package/cjs/services/subscan-service/index.js +109 -4
  22. package/cjs/services/subscan-service/subscan-chain-map.js +82 -8
  23. package/cjs/utils/index.js +10 -1
  24. package/koni/api/dotsama/balance.js +51 -1
  25. package/koni/api/dotsama/crowdloan.d.ts +2 -2
  26. package/koni/api/dotsama/crowdloan.js +29 -2
  27. package/koni/api/dotsama/transfer.js +10 -3
  28. package/koni/api/staking/bonding/astar.js +9 -5
  29. package/koni/api/staking/bonding/relayChain.js +2 -2
  30. package/koni/api/xcm/index.js +6 -1
  31. package/koni/api/xcm/polkadotXcm.js +2 -4
  32. package/koni/api/xcm/xTokens.js +1 -1
  33. package/koni/background/handlers/Extension.d.ts +1 -0
  34. package/koni/background/handlers/Extension.js +20 -3
  35. package/koni/background/handlers/State.d.ts +1 -0
  36. package/koni/background/handlers/State.js +13 -7
  37. package/koni/background/subscription.js +1 -1
  38. package/package.json +21 -6
  39. package/packageInfo.js +1 -1
  40. package/services/chain-service/constants.d.ts +3 -0
  41. package/services/chain-service/constants.js +8 -5
  42. package/services/chain-service/handler/SubstrateApi.js +8 -0
  43. package/services/chain-service/handler/chain-spec/goldberg.d.ts +115 -0
  44. package/services/chain-service/handler/chain-spec/goldberg.js +116 -0
  45. package/services/chain-service/index.d.ts +1 -0
  46. package/services/chain-service/index.js +18 -0
  47. package/services/history-service/helpers/subscan-extrinsic-parser-helper.d.ts +6 -0
  48. package/services/history-service/helpers/subscan-extrinsic-parser-helper.js +44 -0
  49. package/services/history-service/index.d.ts +10 -6
  50. package/services/history-service/index.js +79 -22
  51. package/services/history-service/subscan-history.d.ts +5 -0
  52. package/services/history-service/subscan-history.js +100 -0
  53. package/services/subscan-service/index.d.ts +10 -2
  54. package/services/subscan-service/index.js +105 -4
  55. package/services/subscan-service/subscan-chain-map.d.ts +9 -3
  56. package/services/subscan-service/subscan-chain-map.js +78 -5
  57. package/services/subscan-service/types.d.ts +146 -0
  58. package/utils/index.d.ts +1 -0
  59. package/utils/index.js +7 -0
@@ -23,7 +23,7 @@ import RequestService from '@subwallet/extension-base/services/request-service';
23
23
  import SettingService from '@subwallet/extension-base/services/setting-service/SettingService';
24
24
  import DatabaseService from '@subwallet/extension-base/services/storage-service/DatabaseService';
25
25
  import { SubscanService } from '@subwallet/extension-base/services/subscan-service';
26
- import { SUBSCAN_CHAIN_MAP_REVERSE } from '@subwallet/extension-base/services/subscan-service/subscan-chain-map';
26
+ import { SUBSCAN_API_CHAIN_MAP, SUBSCAN_BALANCE_CHAIN_MAP_REVERSE } from '@subwallet/extension-base/services/subscan-service/subscan-chain-map';
27
27
  import TransactionService from '@subwallet/extension-base/services/transaction-service';
28
28
  import WalletConnectService from '@subwallet/extension-base/services/wallet-connect-service';
29
29
  import AccountRefStore from '@subwallet/extension-base/stores/AccountRef';
@@ -84,14 +84,14 @@ export default class KoniState {
84
84
  this.eventService = new EventService();
85
85
  this.dbService = new DatabaseService(this.eventService);
86
86
  this.keyringService = new KeyringService(this.eventService);
87
- this.subscanService = new SubscanService();
88
87
  this.notificationService = new NotificationService();
89
88
  this.chainService = new ChainService(this.dbService, this.eventService);
89
+ this.subscanService = new SubscanService(SUBSCAN_API_CHAIN_MAP);
90
90
  this.settingService = new SettingService();
91
91
  this.requestService = new RequestService(this.chainService, this.settingService, this.keyringService);
92
92
  this.priceService = new PriceService(this.dbService, this.eventService, this.chainService);
93
93
  this.balanceService = new BalanceService(this.chainService);
94
- this.historyService = new HistoryService(this.dbService, this.chainService, this.eventService, this.keyringService);
94
+ this.historyService = new HistoryService(this.dbService, this.chainService, this.eventService, this.keyringService, this.subscanService);
95
95
  this.transactionService = new TransactionService(this.chainService, this.eventService, this.requestService, this.balanceService, this.historyService, this.notificationService, this.dbService);
96
96
  this.walletConnectService = new WalletConnectService(this, this.requestService);
97
97
  this.migrationService = new MigrationService(this, this.eventService);
@@ -198,9 +198,13 @@ export default class KoniState {
198
198
  });
199
199
  return balanceMap;
200
200
  }
201
+ afterChainServiceInit() {
202
+ this.subscanService.setSubscanChainMap(this.chainService.getSubscanChainMap());
203
+ }
201
204
  async init() {
202
205
  await this.eventService.waitCryptoReady;
203
206
  await this.chainService.init();
207
+ this.afterChainServiceInit();
204
208
  await this.migrationService.run();
205
209
  this.eventService.emit('chain.ready', true);
206
210
  this.onReady();
@@ -1469,7 +1473,7 @@ export default class KoniState {
1469
1473
  symbol
1470
1474
  }) => {
1471
1475
  var _currentAssetSettings;
1472
- const chain = SUBSCAN_CHAIN_MAP_REVERSE[network];
1476
+ const chain = SUBSCAN_BALANCE_CHAIN_MAP_REVERSE[network];
1473
1477
  const chainInfo = chain ? chainMap[chain] : null;
1474
1478
  const balanceIsEmpty = (!balance || balance === '0') && (!locked || locked === '0') && (!bonded || bonded === '0');
1475
1479
 
@@ -1478,10 +1482,11 @@ export default class KoniState {
1478
1482
  return;
1479
1483
  }
1480
1484
  const tokenKey = `${chain}-${category === 'native' ? 'NATIVE' : 'LOCAL'}-${symbol.toUpperCase()}`;
1481
- if (assetMap[tokenKey] && !((_currentAssetSettings = currentAssetSettings[tokenKey]) !== null && _currentAssetSettings !== void 0 && _currentAssetSettings.visible)) {
1485
+ const existedKey = Object.keys(assetMap).find(v => v.toLowerCase() === tokenKey.toLowerCase());
1486
+ if (existedKey && !((_currentAssetSettings = currentAssetSettings[existedKey]) !== null && _currentAssetSettings !== void 0 && _currentAssetSettings.visible)) {
1482
1487
  needEnableChains.push(chain);
1483
- needActiveTokens.push(tokenKey);
1484
- currentAssetSettings[tokenKey] = {
1488
+ needActiveTokens.push(existedKey);
1489
+ currentAssetSettings[existedKey] = {
1485
1490
  visible: true
1486
1491
  };
1487
1492
  }
@@ -1553,6 +1558,7 @@ export default class KoniState {
1553
1558
  this.chainService.resetWallet(resetAll);
1554
1559
  await this.walletConnectService.resetWallet(resetAll);
1555
1560
  await this.chainService.init();
1561
+ this.afterChainServiceInit();
1556
1562
  }
1557
1563
  async enableMantaPay(updateStore, address, password, seedPhrase) {
1558
1564
  var _this$chainService3, _this$chainService3$m, _this$chainService4, _this$chainService4$m, _this$chainService4$m2, _this$chainService11, _this$chainService11$, _this$chainService11$2;
@@ -163,7 +163,7 @@ export class KoniSubscription {
163
163
  initCrowdloanSubscription(addresses, substrateApiMap, onlyRunOnFirstTime) {
164
164
  const subscriptionPromise = subscribeCrowdloan(addresses, substrateApiMap, (networkKey, rs) => {
165
165
  this.state.setCrowdloanItem(networkKey, rs);
166
- }, this.state.getChainInfoMap());
166
+ });
167
167
  if (onlyRunOnFirstTime) {
168
168
  subscriptionPromise.then(unsub => {
169
169
  unsub && unsub();
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "./cjs/detectPackage.js"
18
18
  ],
19
19
  "type": "module",
20
- "version": "1.1.21-3",
20
+ "version": "1.1.23-0",
21
21
  "main": "./cjs/index.js",
22
22
  "module": "./index.js",
23
23
  "types": "./index.d.ts",
@@ -570,6 +570,11 @@
570
570
  "require": "./cjs/services/chain-service/handler/AbstractChainHandler.js",
571
571
  "default": "./services/chain-service/handler/AbstractChainHandler.js"
572
572
  },
573
+ "./services/chain-service/handler/chain-spec/goldberg": {
574
+ "types": "./services/chain-service/handler/chain-spec/goldberg.d.ts",
575
+ "require": "./cjs/services/chain-service/handler/chain-spec/goldberg.js",
576
+ "default": "./services/chain-service/handler/chain-spec/goldberg.js"
577
+ },
573
578
  "./services/chain-service/handler/EvmApi": {
574
579
  "types": "./services/chain-service/handler/EvmApi.d.ts",
575
580
  "require": "./cjs/services/chain-service/handler/EvmApi.js",
@@ -668,6 +673,16 @@
668
673
  "require": "./cjs/services/history-service/helpers/recoverHistoryStatus.js",
669
674
  "default": "./services/history-service/helpers/recoverHistoryStatus.js"
670
675
  },
676
+ "./services/history-service/helpers/subscan-extrinsic-parser-helper": {
677
+ "types": "./services/history-service/helpers/subscan-extrinsic-parser-helper.d.ts",
678
+ "require": "./cjs/services/history-service/helpers/subscan-extrinsic-parser-helper.js",
679
+ "default": "./services/history-service/helpers/subscan-extrinsic-parser-helper.js"
680
+ },
681
+ "./services/history-service/subscan-history": {
682
+ "types": "./services/history-service/subscan-history.d.ts",
683
+ "require": "./cjs/services/history-service/subscan-history.js",
684
+ "default": "./services/history-service/subscan-history.js"
685
+ },
671
686
  "./services/history-service/subsquid-multi-chain-history": {
672
687
  "types": "./services/history-service/subsquid-multi-chain-history.d.ts",
673
688
  "require": "./cjs/services/history-service/subsquid-multi-chain-history.js",
@@ -1307,11 +1322,11 @@
1307
1322
  "@reduxjs/toolkit": "^1.9.1",
1308
1323
  "@sora-substrate/type-definitions": "^1.17.7",
1309
1324
  "@substrate/connect": "^0.7.26",
1310
- "@subwallet/chain-list": "0.2.24",
1311
- "@subwallet/extension-base": "^1.1.21-3",
1312
- "@subwallet/extension-chains": "^1.1.21-3",
1313
- "@subwallet/extension-dapp": "^1.1.21-3",
1314
- "@subwallet/extension-inject": "^1.1.21-3",
1325
+ "@subwallet/chain-list": "0.2.26",
1326
+ "@subwallet/extension-base": "^1.1.23-0",
1327
+ "@subwallet/extension-chains": "^1.1.23-0",
1328
+ "@subwallet/extension-dapp": "^1.1.23-0",
1329
+ "@subwallet/extension-inject": "^1.1.23-0",
1315
1330
  "@subwallet/keyring": "^0.1.1",
1316
1331
  "@subwallet/ui-keyring": "^0.1.1",
1317
1332
  "@walletconnect/sign-client": "^2.8.4",
package/packageInfo.js CHANGED
@@ -7,5 +7,5 @@ export const packageInfo = {
7
7
  name: '@subwallet/extension-base',
8
8
  path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
9
9
  type: 'esm',
10
- version: '1.1.21-3'
10
+ version: '1.1.23-0'
11
11
  };
@@ -6,6 +6,7 @@ export declare const _API_OPTIONS_CHAIN_GROUP: {
6
6
  acala: string[];
7
7
  turing: string[];
8
8
  avail: string[];
9
+ goldberg: string[];
9
10
  };
10
11
  export declare const _PREDEFINED_SINGLE_MODES: Record<string, SingleModeJson>;
11
12
  export declare const _PURE_EVM_CHAINS: string[];
@@ -16,6 +17,7 @@ export declare const _BALANCE_CHAIN_GROUP: {
16
17
  bifrost: string[];
17
18
  statemine: string[];
18
19
  kusama: string[];
20
+ centrifuge: string[];
19
21
  };
20
22
  export declare const _BALANCE_TOKEN_GROUP: {
21
23
  crab: string[];
@@ -70,6 +72,7 @@ export declare const _TRANSFER_CHAIN_GROUP: {
70
72
  sora_substrate: string[];
71
73
  avail: string[];
72
74
  pendulum: string[];
75
+ centrifuge: string[];
73
76
  };
74
77
  export declare const _BALANCE_PARSING_CHAIN_GROUP: {
75
78
  bobabeam: string[];
@@ -10,7 +10,8 @@ export const API_MAX_RETRY = 2;
10
10
  export const _API_OPTIONS_CHAIN_GROUP = {
11
11
  acala: ['acala', 'karura', 'origintrail', 'kintsugi'],
12
12
  turing: ['turingStaging', 'turing'],
13
- avail: ['kate']
13
+ avail: ['kate'],
14
+ goldberg: ['goldberg_testnet']
14
15
  };
15
16
  export const _PREDEFINED_SINGLE_MODES = {
16
17
  subspace: {
@@ -29,9 +30,10 @@ export const _BALANCE_CHAIN_GROUP = {
29
30
  equilibrium_parachain: ['equilibrium_parachain'],
30
31
  bifrost: ['bifrost', 'acala', 'karura', 'acala_testnet', 'pioneer', 'bitcountry', 'bifrost_dot', 'hydradx_main', 'pendulum', 'amplitude'],
31
32
  statemine: ['statemine', 'astar', 'shiden', 'statemint', 'moonbeam', 'moonbase', 'moonriver', 'crabParachain', 'darwinia2', 'parallel', 'calamari'],
32
- kusama: ['kusama', 'kintsugi', 'kintsugi_test', 'interlay', 'acala', 'statemint', 'karura', 'bifrost'] // perhaps there are some runtime updates
33
+ kusama: ['kusama', 'kintsugi', 'kintsugi_test', 'interlay', 'acala', 'statemint', 'karura', 'bifrost'],
34
+ // perhaps there are some runtime updates
35
+ centrifuge: ['centrifuge']
33
36
  };
34
-
35
37
  export const _BALANCE_TOKEN_GROUP = {
36
38
  crab: ['CKTON', 'PKTON'],
37
39
  bitcountry: ['BIT']
@@ -192,8 +194,9 @@ export const _TRANSFER_CHAIN_GROUP = {
192
194
  statemine: ['statemint', 'statemine', 'darwinia2', 'astar', 'shiden', 'shibuya', 'parallel'],
193
195
  riochain: ['riochain'],
194
196
  sora_substrate: ['sora_substrate'],
195
- avail: ['kate'],
196
- pendulum: ['pendulum', 'amplitude', 'amplitude_test']
197
+ avail: ['kate', 'goldberg_testnet'],
198
+ pendulum: ['pendulum', 'amplitude', 'amplitude_test'],
199
+ centrifuge: ['centrifuge']
197
200
  };
198
201
  export const _BALANCE_PARSING_CHAIN_GROUP = {
199
202
  bobabeam: ['bobabeam', 'bobabase']
@@ -16,6 +16,7 @@ import { typesBundle } from '@polkadot/apps-config/api';
16
16
  import { TypeRegistry } from '@polkadot/types/create';
17
17
  import { formatBalance } from '@polkadot/util';
18
18
  import { defaults as addressDefaults } from '@polkadot/util-crypto/address/defaults';
19
+ import goldbergSpec from "./chain-spec/goldberg.js";
19
20
  export class SubstrateApi {
20
21
  useLightClient = false;
21
22
  isApiReady = false;
@@ -85,6 +86,13 @@ export class SubstrateApi {
85
86
  types: availSpec.types,
86
87
  signedExtensions: availSpec.signedExtensions
87
88
  });
89
+ } else if (_API_OPTIONS_CHAIN_GROUP.goldberg.includes(this.chainSlug)) {
90
+ api = new ApiPromise({
91
+ provider,
92
+ rpc: goldbergSpec.rpc,
93
+ types: goldbergSpec.types,
94
+ signedExtensions: goldbergSpec.signedExtensions
95
+ });
88
96
  } else {
89
97
  api = new ApiPromise(apiOption);
90
98
  }
@@ -0,0 +1,115 @@
1
+ declare const chainSpec: {
2
+ types: {
3
+ AppId: string;
4
+ DataLookupIndexItem: {
5
+ appId: string;
6
+ start: string;
7
+ };
8
+ DataLookup: {
9
+ size: string;
10
+ index: string;
11
+ };
12
+ KateCommitment: {
13
+ rows: string;
14
+ cols: string;
15
+ commitment: string;
16
+ dataRoot: string;
17
+ };
18
+ V1HeaderExtension: {
19
+ appLookup: string;
20
+ commitment: string;
21
+ };
22
+ HeaderExtension: {
23
+ _enum: {
24
+ V1: string;
25
+ };
26
+ };
27
+ DaHeader: {
28
+ parentHash: string;
29
+ number: string;
30
+ stateRoot: string;
31
+ extrinsicsRoot: string;
32
+ digest: string;
33
+ extension: string;
34
+ };
35
+ Header: string;
36
+ CheckAppIdExtra: {
37
+ appId: string;
38
+ };
39
+ CheckAppIdTypes: {};
40
+ CheckAppId: {
41
+ extra: string;
42
+ types: string;
43
+ };
44
+ BlockLength: {
45
+ max: string;
46
+ cols: string;
47
+ rows: string;
48
+ chunkSize: string;
49
+ };
50
+ PerDispatchClass: {
51
+ normal: string;
52
+ operational: string;
53
+ mandatory: string;
54
+ };
55
+ DataProof: {
56
+ root: string;
57
+ proof: string;
58
+ numberOfLeaves: string;
59
+ leaf_index: string;
60
+ leaf: string;
61
+ };
62
+ Cell: {
63
+ row: string;
64
+ col: string;
65
+ };
66
+ };
67
+ rpc: {
68
+ kate: {
69
+ blockLength: {
70
+ description: string;
71
+ params: {
72
+ name: string;
73
+ type: string;
74
+ isOptional: boolean;
75
+ }[];
76
+ type: string;
77
+ };
78
+ queryProof: {
79
+ description: string;
80
+ params: ({
81
+ name: string;
82
+ type: string;
83
+ isOptional?: undefined;
84
+ } | {
85
+ name: string;
86
+ type: string;
87
+ isOptional: boolean;
88
+ })[];
89
+ type: string;
90
+ };
91
+ queryDataProof: {
92
+ description: string;
93
+ params: ({
94
+ name: string;
95
+ type: string;
96
+ isOptional?: undefined;
97
+ } | {
98
+ name: string;
99
+ type: string;
100
+ isOptional: boolean;
101
+ })[];
102
+ type: string;
103
+ };
104
+ };
105
+ };
106
+ signedExtensions: {
107
+ CheckAppId: {
108
+ extrinsic: {
109
+ appId: string;
110
+ };
111
+ payload: {};
112
+ };
113
+ };
114
+ };
115
+ export default chainSpec;
@@ -0,0 +1,116 @@
1
+ // Copyright 2019-2022 @subwallet/extension-base authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ const chainSpec = {
5
+ types: {
6
+ AppId: 'Compact<u32>',
7
+ DataLookupIndexItem: {
8
+ appId: 'AppId',
9
+ start: 'Compact<u32>'
10
+ },
11
+ DataLookup: {
12
+ size: 'Compact<u32>',
13
+ index: 'Vec<DataLookupIndexItem>'
14
+ },
15
+ KateCommitment: {
16
+ rows: 'Compact<u16>',
17
+ cols: 'Compact<u16>',
18
+ commitment: 'Vec<u8>',
19
+ dataRoot: 'H256'
20
+ },
21
+ V1HeaderExtension: {
22
+ appLookup: 'DataLookup',
23
+ commitment: 'KateCommitment'
24
+ },
25
+ HeaderExtension: {
26
+ _enum: {
27
+ V1: 'V1HeaderExtension'
28
+ }
29
+ },
30
+ DaHeader: {
31
+ parentHash: 'Hash',
32
+ number: 'Compact<BlockNumber>',
33
+ stateRoot: 'Hash',
34
+ extrinsicsRoot: 'Hash',
35
+ digest: 'Digest',
36
+ extension: 'HeaderExtension'
37
+ },
38
+ Header: 'DaHeader',
39
+ CheckAppIdExtra: {
40
+ appId: 'AppId'
41
+ },
42
+ CheckAppIdTypes: {},
43
+ CheckAppId: {
44
+ extra: 'CheckAppIdExtra',
45
+ types: 'CheckAppIdTypes'
46
+ },
47
+ BlockLength: {
48
+ max: 'PerDispatchClass',
49
+ cols: 'Compact<u32>',
50
+ rows: 'Compact<u32>',
51
+ chunkSize: 'Compact<u32>'
52
+ },
53
+ PerDispatchClass: {
54
+ normal: 'u32',
55
+ operational: 'u32',
56
+ mandatory: 'u32'
57
+ },
58
+ DataProof: {
59
+ root: 'H256',
60
+ proof: 'Vec<H256>',
61
+ numberOfLeaves: 'Compact<u32>',
62
+ leaf_index: 'Compact<u32>',
63
+ leaf: 'H256'
64
+ },
65
+ Cell: {
66
+ row: 'u32',
67
+ col: 'u32'
68
+ }
69
+ },
70
+ rpc: {
71
+ kate: {
72
+ blockLength: {
73
+ description: 'Get Block Length',
74
+ params: [{
75
+ name: 'at',
76
+ type: 'Hash',
77
+ isOptional: true
78
+ }],
79
+ type: 'BlockLength'
80
+ },
81
+ queryProof: {
82
+ description: 'Generate the kate proof for the given `cells`',
83
+ params: [{
84
+ name: 'cells',
85
+ type: 'Vec<Cell>'
86
+ }, {
87
+ name: 'at',
88
+ type: 'Hash',
89
+ isOptional: true
90
+ }],
91
+ type: 'Vec<u8>'
92
+ },
93
+ queryDataProof: {
94
+ description: 'Generate the data proof for the given `index`',
95
+ params: [{
96
+ name: 'data_index',
97
+ type: 'u32'
98
+ }, {
99
+ name: 'at',
100
+ type: 'Hash',
101
+ isOptional: true
102
+ }],
103
+ type: 'DataProof'
104
+ }
105
+ }
106
+ },
107
+ signedExtensions: {
108
+ CheckAppId: {
109
+ extrinsic: {
110
+ appId: 'AppId'
111
+ },
112
+ payload: {}
113
+ }
114
+ }
115
+ };
116
+ export default chainSpec;
@@ -113,4 +113,5 @@ export declare class ChainService {
113
113
  getMetadata(chain: string): import("dexie").PromiseExtended<IMetadataItem | undefined>;
114
114
  upsertMetadata(chain: string, metadata: IMetadataItem): import("dexie").PromiseExtended<unknown>;
115
115
  getMetadataByHash(hash: string): import("dexie").PromiseExtended<IMetadataItem | undefined>;
116
+ getSubscanChainMap(reverse?: boolean): Record<string, string>;
116
117
  }
@@ -1381,4 +1381,22 @@ export class ChainService {
1381
1381
  getMetadataByHash(hash) {
1382
1382
  return this.dbService.stores.metadata.getMetadataByGenesisHash(hash);
1383
1383
  }
1384
+ getSubscanChainMap(reverse) {
1385
+ const result = {};
1386
+ const chainInfoMap = this.getChainInfoMap();
1387
+ Object.values(chainInfoMap).forEach(i => {
1388
+ var _i$extraInfo;
1389
+ if (!((_i$extraInfo = i.extraInfo) !== null && _i$extraInfo !== void 0 && _i$extraInfo.subscanSlug)) {
1390
+ return;
1391
+ }
1392
+ if (!reverse) {
1393
+ var _i$extraInfo2;
1394
+ result[i.slug] = (_i$extraInfo2 = i.extraInfo) === null || _i$extraInfo2 === void 0 ? void 0 : _i$extraInfo2.subscanSlug;
1395
+ } else {
1396
+ var _i$extraInfo3;
1397
+ result[(_i$extraInfo3 = i.extraInfo) === null || _i$extraInfo3 === void 0 ? void 0 : _i$extraInfo3.subscanSlug] = i.slug;
1398
+ }
1399
+ });
1400
+ return result;
1401
+ }
1384
1402
  }
@@ -0,0 +1,6 @@
1
+ import { TransactionHistoryItem } from '@subwallet/extension-base/background/KoniTypes';
2
+ import { ExtrinsicItem } from '@subwallet/extension-base/services/subscan-service/types';
3
+ export declare type ExtrinsicParserFunction = (item: TransactionHistoryItem) => TransactionHistoryItem | null;
4
+ export declare function getExtrinsicParserKey(extrinsicItem: ExtrinsicItem): string;
5
+ export declare const subscanExtrinsicParserMap: Record<string, ExtrinsicParserFunction>;
6
+ export declare const supportedExtrinsicParser: string[];
@@ -0,0 +1,44 @@
1
+ // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
5
+ import { encodeAddress } from '@polkadot/util-crypto';
6
+ export function getExtrinsicParserKey(extrinsicItem) {
7
+ return `${extrinsicItem.call_module}.${extrinsicItem.call_module_function}`;
8
+ }
9
+ function paramJsonParse(item) {
10
+ try {
11
+ return JSON.parse(item.data || '[]');
12
+ } catch (e) {
13
+ return [];
14
+ }
15
+ }
16
+ function balanceTransferParserFunction(item) {
17
+ const params = paramJsonParse(item);
18
+ params.forEach(p => {
19
+ if (p.name === 'dest') {
20
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
21
+ const toPublicKey = p.value.id || p.value.Id;
22
+ if (toPublicKey) {
23
+ item.to = encodeAddress(toPublicKey, 42);
24
+ }
25
+ } else if (p.name === 'value') {
26
+ if (item.amount) {
27
+ item.amount.value = p.value;
28
+ }
29
+ }
30
+ });
31
+ item.type = ExtrinsicType.TRANSFER_BALANCE;
32
+ if (!item.to) {
33
+ return null;
34
+ }
35
+ return item;
36
+ }
37
+
38
+ // todo: will support other type later
39
+ export const subscanExtrinsicParserMap = {
40
+ 'balances.transfer': balanceTransferParserFunction,
41
+ 'balances.transfer_keep_alive': balanceTransferParserFunction,
42
+ 'balances.transfer_allow_death': balanceTransferParserFunction
43
+ };
44
+ export const supportedExtrinsicParser = Object.keys(subscanExtrinsicParserMap);
@@ -1,24 +1,30 @@
1
1
  import { TransactionHistoryItem } from '@subwallet/extension-base/background/KoniTypes';
2
- import { CronServiceInterface, PersistDataServiceInterface, ServiceStatus, StoppableServiceInterface } from '@subwallet/extension-base/services/base/types';
2
+ import { PersistDataServiceInterface, ServiceStatus, StoppableServiceInterface } from '@subwallet/extension-base/services/base/types';
3
3
  import { ChainService } from '@subwallet/extension-base/services/chain-service';
4
4
  import { EventService } from '@subwallet/extension-base/services/event-service';
5
5
  import { KeyringService } from '@subwallet/extension-base/services/keyring-service';
6
6
  import DatabaseService from '@subwallet/extension-base/services/storage-service/DatabaseService';
7
+ import { SubscanService } from '@subwallet/extension-base/services/subscan-service';
7
8
  import { BehaviorSubject } from 'rxjs';
8
- export declare class HistoryService implements StoppableServiceInterface, PersistDataServiceInterface, CronServiceInterface {
9
+ export declare class HistoryService implements StoppableServiceInterface, PersistDataServiceInterface {
9
10
  #private;
10
11
  private dbService;
11
12
  private chainService;
12
13
  private eventService;
13
14
  private keyringService;
15
+ private subscanService;
14
16
  private historySubject;
15
- constructor(dbService: DatabaseService, chainService: ChainService, eventService: EventService, keyringService: KeyringService);
17
+ constructor(dbService: DatabaseService, chainService: ChainService, eventService: EventService, keyringService: KeyringService, subscanService: SubscanService);
16
18
  private fetchPromise;
17
- private interval;
18
19
  private recoverInterval;
19
20
  private fetchAndLoadHistories;
20
21
  getHistories(): Promise<TransactionHistoryItem<import("@subwallet/extension-base/background/KoniTypes").ExtrinsicType.TRANSFER_BALANCE>[]>;
21
22
  getHistorySubject(): Promise<BehaviorSubject<TransactionHistoryItem<import("@subwallet/extension-base/background/KoniTypes").ExtrinsicType.TRANSFER_BALANCE>[]>>;
23
+ private fetchSubscanTransactionHistory;
24
+ subscribeHistories(chain: string, address: string, cb: (items: TransactionHistoryItem[]) => void): {
25
+ unsubscribe: () => void;
26
+ value: TransactionHistoryItem<import("@subwallet/extension-base/background/KoniTypes").ExtrinsicType.TRANSFER_BALANCE>[];
27
+ };
22
28
  updateHistories(chain: string, extrinsicHash: string, updateData: Partial<TransactionHistoryItem>): Promise<void>;
23
29
  updateHistoryByExtrinsicHash(extrinsicHash: string, updateData: Partial<TransactionHistoryItem>): Promise<void>;
24
30
  insertHistories(historyItems: TransactionHistoryItem[]): Promise<void>;
@@ -27,8 +33,6 @@ export declare class HistoryService implements StoppableServiceInterface, Persis
27
33
  status: ServiceStatus;
28
34
  loadData(): Promise<void>;
29
35
  persistData(): Promise<void>;
30
- startCron(): Promise<void>;
31
- stopCron(): Promise<void>;
32
36
  startRecoverHistories(): Promise<void>;
33
37
  stopRecoverHistories(): Promise<void>;
34
38
  recoverHistories(): Promise<void>;