@subwallet/extension-base 1.0.1 → 1.0.2-1b
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 +25 -36
- package/background/KoniTypes.js +12 -7
- package/background/errors/TransactionError.js +21 -1
- package/cjs/background/KoniTypes.js +14 -8
- package/cjs/background/errors/TransactionError.js +20 -0
- package/cjs/constants/index.js +13 -28
- package/cjs/koni/api/dotsama/balance.js +60 -224
- package/cjs/koni/api/dotsama/transfer.js +30 -29
- package/cjs/koni/api/nft/acala_nft/index.js +4 -1
- package/cjs/koni/api/nft/bit.country/index.js +4 -1
- package/cjs/koni/api/nft/evm_nft/index.js +7 -3
- package/cjs/koni/api/nft/index.js +3 -6
- package/cjs/koni/api/nft/karura_nft/index.js +4 -1
- package/cjs/koni/api/nft/rmrk_nft/index.js +8 -1
- package/cjs/koni/api/nft/statemine_nft/index.js +4 -1
- package/cjs/koni/api/nft/unique_nft/index.js +6 -1
- package/cjs/koni/api/nft/wasm_nft/index.js +169 -111
- package/cjs/koni/api/nft/wasm_nft/utils.js +11 -7
- package/cjs/koni/api/staking/bonding/amplitude.js +18 -10
- package/cjs/koni/api/staking/bonding/astar.js +37 -238
- package/cjs/koni/api/staking/bonding/index.js +26 -14
- package/cjs/koni/api/staking/bonding/paraChain.js +100 -11
- package/cjs/koni/api/staking/bonding/relayChain.js +174 -16
- package/cjs/koni/api/staking/bonding/utils.js +55 -10
- package/cjs/koni/api/tokens/wasm/index.js +5 -4
- package/cjs/koni/api/tokens/wasm/utils.js +63 -0
- package/cjs/koni/api/xcm/index.js +0 -111
- package/cjs/koni/api/xcm/polkadotXcm.js +2 -2
- package/cjs/koni/api/xcm/utils.js +18 -13
- package/cjs/koni/api/xcm/xTokens.js +3 -5
- package/cjs/koni/api/xcm/xcmPallet.js +9 -6
- package/cjs/koni/background/cron.js +179 -77
- package/cjs/koni/background/handlers/Extension.js +231 -195
- package/cjs/koni/background/handlers/State.js +147 -111
- package/cjs/koni/background/handlers/Tabs.js +48 -39
- package/cjs/koni/background/subscription.js +64 -56
- package/cjs/packageInfo.js +1 -1
- package/cjs/page/index.js +5 -0
- package/cjs/services/chain-service/constants.js +1 -11
- package/cjs/services/chain-service/handler/SubstrateChainHandler.js +13 -8
- package/cjs/services/chain-service/handler/light-client/index.js +2 -0
- package/cjs/services/chain-service/index.js +39 -6
- package/cjs/services/chain-service/utils.js +4 -0
- package/cjs/services/event-service/index.js +75 -0
- package/cjs/services/event-service/types.js +11 -0
- package/cjs/services/history-service/index.js +46 -21
- package/cjs/services/history-service/subsquid-multi-chain-history.js +19 -11
- package/cjs/services/keyring-service/index.js +101 -0
- package/cjs/services/migration-service/index.js +13 -10
- package/cjs/{koni/migration/scripts/RemoveWrongCrowdloan.js → services/migration-service/scripts/AutoEnableChainsTokens.js} +11 -6
- package/cjs/services/migration-service/scripts/MigrateNetworkSettings.js +39 -19
- package/cjs/services/migration-service/scripts/MigrateSettings.js +31 -0
- package/cjs/services/migration-service/scripts/MigrateTransactionHistory.js +72 -0
- package/cjs/services/migration-service/scripts/index.js +13 -4
- package/cjs/services/price-service/coingecko.js +15 -3
- package/cjs/services/price-service/index.js +15 -18
- package/cjs/services/request-service/constants.js +8 -2
- package/cjs/services/request-service/handler/AuthRequestHandler.js +43 -12
- package/cjs/services/request-service/index.js +3 -0
- package/cjs/services/storage-service/DatabaseService.js +53 -34
- package/cjs/services/storage-service/databases/index.js +1 -1
- package/cjs/services/storage-service/db-stores/BaseStoreWithAddressAndChain.js +2 -8
- package/cjs/services/storage-service/db-stores/Nft.js +8 -18
- package/cjs/services/storage-service/db-stores/Transaction.js +10 -7
- package/cjs/services/subscan-service/index.js +107 -0
- package/cjs/services/subscan-service/subscan-chain-map.js +74 -0
- package/cjs/services/subscan-service/types.js +1 -0
- package/cjs/services/transaction-service/event-parser/index.js +20 -48
- package/cjs/services/transaction-service/index.js +66 -22
- package/cjs/services/transaction-service/utils.js +4 -6
- package/cjs/utils/address.js +9 -1
- package/cjs/utils/index.js +30 -26
- package/constants/index.d.ts +8 -13
- package/constants/index.js +8 -13
- package/koni/api/dotsama/balance.d.ts +0 -1
- package/koni/api/dotsama/balance.js +33 -197
- package/koni/api/dotsama/transfer.js +5 -4
- package/koni/api/nft/acala_nft/index.js +3 -1
- package/koni/api/nft/bit.country/index.js +3 -1
- package/koni/api/nft/evm_nft/index.js +6 -3
- package/koni/api/nft/index.d.ts +1 -2
- package/koni/api/nft/index.js +3 -6
- package/koni/api/nft/karura_nft/index.js +3 -1
- package/koni/api/nft/nft.d.ts +1 -0
- package/koni/api/nft/rmrk_nft/index.js +8 -1
- package/koni/api/nft/statemine_nft/index.js +3 -1
- package/koni/api/nft/unique_nft/index.js +5 -1
- package/koni/api/nft/wasm_nft/index.d.ts +0 -2
- package/koni/api/nft/wasm_nft/index.js +167 -109
- package/koni/api/nft/wasm_nft/utils.d.ts +7 -5
- package/koni/api/nft/wasm_nft/utils.js +7 -5
- package/koni/api/staking/bonding/amplitude.d.ts +1 -2
- package/koni/api/staking/bonding/amplitude.js +22 -13
- package/koni/api/staking/bonding/astar.d.ts +2 -11
- package/koni/api/staking/bonding/astar.js +39 -231
- package/koni/api/staking/bonding/index.d.ts +5 -2
- package/koni/api/staking/bonding/index.js +27 -17
- package/koni/api/staking/bonding/paraChain.d.ts +4 -1
- package/koni/api/staking/bonding/paraChain.js +101 -14
- package/koni/api/staking/bonding/relayChain.d.ts +6 -2
- package/koni/api/staking/bonding/relayChain.js +172 -17
- package/koni/api/staking/bonding/utils.d.ts +15 -2
- package/koni/api/staking/bonding/utils.js +53 -11
- package/koni/api/tokens/wasm/index.js +5 -4
- package/koni/api/tokens/wasm/utils.d.ts +6 -0
- package/koni/api/tokens/wasm/utils.js +54 -0
- package/koni/api/xcm/index.js +1 -112
- package/koni/api/xcm/polkadotXcm.js +3 -3
- package/koni/api/xcm/utils.d.ts +5 -6
- package/koni/api/xcm/utils.js +15 -10
- package/koni/api/xcm/xTokens.js +5 -7
- package/koni/api/xcm/xcmPallet.js +10 -9
- package/koni/background/cron.d.ts +6 -1
- package/koni/background/cron.js +179 -76
- package/koni/background/handlers/Extension.d.ts +2 -2
- package/koni/background/handlers/Extension.js +161 -125
- package/koni/background/handlers/State.d.ts +21 -20
- package/koni/background/handlers/State.js +144 -111
- package/koni/background/handlers/Tabs.js +30 -20
- package/koni/background/subscription.d.ts +1 -1
- package/koni/background/subscription.js +64 -58
- package/package.json +63 -18
- package/packageInfo.js +1 -1
- package/page/index.d.ts +2 -0
- package/page/index.js +4 -0
- package/services/chain-service/constants.d.ts +0 -1
- package/services/chain-service/constants.js +0 -9
- package/services/chain-service/handler/SubstrateChainHandler.js +14 -9
- package/services/chain-service/handler/light-client/index.d.ts +17 -1
- package/services/chain-service/handler/light-client/index.js +1 -1
- package/services/chain-service/helper/psp22_abi.json +1041 -881
- package/services/chain-service/helper/psp34_abi.json +2963 -1807
- package/services/chain-service/index.d.ts +6 -4
- package/services/chain-service/index.js +40 -9
- package/services/chain-service/utils.d.ts +1 -0
- package/services/chain-service/utils.js +3 -0
- package/services/event-service/index.d.ts +22 -0
- package/services/event-service/index.js +63 -0
- package/services/event-service/types.d.ts +28 -0
- package/services/event-service/types.js +4 -0
- package/services/history-service/index.d.ts +5 -3
- package/services/history-service/index.js +46 -21
- package/services/history-service/subsquid-multi-chain-history.js +22 -13
- package/services/keyring-service/index.d.ts +19 -0
- package/services/keyring-service/index.js +93 -0
- package/services/migration-service/index.js +11 -9
- package/services/migration-service/scripts/AutoEnableChainsTokens.d.ts +4 -0
- package/services/migration-service/scripts/AutoEnableChainsTokens.js +13 -0
- package/services/migration-service/scripts/MigrateNetworkSettings.js +37 -18
- package/services/migration-service/scripts/MigrateSettings.d.ts +4 -0
- package/services/migration-service/scripts/MigrateSettings.js +23 -0
- package/services/migration-service/scripts/MigrateTransactionHistory.d.ts +4 -0
- package/services/migration-service/scripts/MigrateTransactionHistory.js +64 -0
- package/services/migration-service/scripts/index.d.ts +1 -0
- package/services/migration-service/scripts/index.js +10 -3
- package/services/price-service/coingecko.js +15 -3
- package/services/price-service/index.d.ts +5 -3
- package/services/price-service/index.js +15 -18
- package/services/request-service/constants.d.ts +1 -0
- package/services/request-service/constants.js +6 -1
- package/services/request-service/handler/AuthRequestHandler.d.ts +8 -1
- package/services/request-service/handler/AuthRequestHandler.js +44 -13
- package/services/request-service/index.d.ts +7 -1
- package/services/request-service/index.js +3 -0
- package/services/storage-service/DatabaseService.d.ts +1 -0
- package/services/storage-service/DatabaseService.js +53 -34
- package/services/storage-service/databases/index.js +1 -1
- package/services/storage-service/db-stores/BaseStoreWithAddressAndChain.d.ts +1 -1
- package/services/storage-service/db-stores/BaseStoreWithAddressAndChain.js +2 -8
- package/services/storage-service/db-stores/Nft.d.ts +3 -3
- package/services/storage-service/db-stores/Nft.js +8 -17
- package/services/storage-service/db-stores/Transaction.js +10 -7
- package/services/subscan-service/index.d.ts +20 -0
- package/services/subscan-service/index.js +99 -0
- package/services/subscan-service/subscan-chain-map.d.ts +5 -0
- package/services/subscan-service/subscan-chain-map.js +63 -0
- package/services/subscan-service/types.d.ts +27 -0
- package/services/subscan-service/types.js +1 -0
- package/services/transaction-service/event-parser/index.d.ts +2 -2
- package/services/transaction-service/event-parser/index.js +21 -49
- package/services/transaction-service/index.d.ts +4 -2
- package/services/transaction-service/index.js +66 -22
- package/services/transaction-service/utils.js +5 -6
- package/utils/address.d.ts +1 -0
- package/utils/address.js +9 -2
- package/utils/index.d.ts +2 -1
- package/utils/index.js +26 -23
- package/cjs/background/errors/EvmRpcError.js +0 -21
- package/cjs/background/errors/SubWalletProviderError.js +0 -17
- package/cjs/constants/ethereum.js +0 -19
- package/cjs/errors/SubWalletProviderError.js +0 -17
- package/cjs/koni/api/xcm/astar.js +0 -160
- package/cjs/koni/api/xcm/moonbeamXcm.js +0 -80
- package/cjs/koni/api/xcm/statemintXcm.js +0 -197
- package/cjs/koni/api/xcm/substrateXcm.js +0 -213
- package/cjs/koni/migration/Base.js +0 -20
- package/cjs/koni/migration/index.js +0 -45
- package/cjs/koni/migration/scripts/ChangeRouteToHome.js +0 -22
- package/cjs/koni/migration/scripts/ClearOldStorage.js +0 -24
- package/cjs/koni/migration/scripts/RemoveWrongTransactionHistoriesFromStore.js +0 -36
- package/cjs/koni/migration/scripts/ResetTransactionHistoryEventIdx.js +0 -21
- package/cjs/koni/migration/scripts/index.js +0 -22
- package/cjs/koni/page/index.js +0 -16
- package/cjs/services/asset-service/index.js +0 -91
- package/cjs/services/storage-service/db-stores/ExtraDelegationInfo.js +0 -17
- package/cjs/stores/Balance.js +0 -18
- package/cjs/stores/Crowdloan.js +0 -18
- package/cjs/stores/CustomEvmToken.js +0 -18
- package/cjs/stores/NetworkMap.js +0 -18
- package/cjs/stores/Nft.js +0 -18
- package/cjs/stores/NftCollection.js +0 -18
- package/cjs/stores/Price.js +0 -18
- package/cjs/stores/Staking.js +0 -18
- package/cjs/stores/StakingReward.js +0 -18
- package/cjs/utils/eth/parseTransactionData.js +0 -284
- package/koni/page/index.d.ts +0 -2
- package/koni/page/index.js +0 -9
- /package/cjs/{koni/page → page}/SubWalleEvmProvider.js +0 -0
- /package/{koni/page → page}/SubWalleEvmProvider.d.ts +0 -0
- /package/{koni/page → page}/SubWalleEvmProvider.js +0 -0
|
@@ -15,15 +15,18 @@ var _balanceService = require("@subwallet/extension-base/services/balance-servic
|
|
|
15
15
|
var _chainService = require("@subwallet/extension-base/services/chain-service");
|
|
16
16
|
var _constants2 = require("@subwallet/extension-base/services/chain-service/constants");
|
|
17
17
|
var _utils = require("@subwallet/extension-base/services/chain-service/utils");
|
|
18
|
+
var _eventService = require("@subwallet/extension-base/services/event-service");
|
|
18
19
|
var _historyService = require("@subwallet/extension-base/services/history-service");
|
|
20
|
+
var _keyringService = require("@subwallet/extension-base/services/keyring-service");
|
|
19
21
|
var _migrationService = _interopRequireDefault(require("@subwallet/extension-base/services/migration-service"));
|
|
20
22
|
var _NotificationService = _interopRequireDefault(require("@subwallet/extension-base/services/notification-service/NotificationService"));
|
|
21
23
|
var _priceService = require("@subwallet/extension-base/services/price-service");
|
|
22
24
|
var _requestService = _interopRequireDefault(require("@subwallet/extension-base/services/request-service"));
|
|
23
25
|
var _SettingService = _interopRequireDefault(require("@subwallet/extension-base/services/setting-service/SettingService"));
|
|
24
26
|
var _DatabaseService = _interopRequireDefault(require("@subwallet/extension-base/services/storage-service/DatabaseService"));
|
|
27
|
+
var _subscanService = require("@subwallet/extension-base/services/subscan-service");
|
|
28
|
+
var _subscanChainMap = require("@subwallet/extension-base/services/subscan-service/subscan-chain-map");
|
|
25
29
|
var _transactionService = _interopRequireDefault(require("@subwallet/extension-base/services/transaction-service"));
|
|
26
|
-
var _stores = require("@subwallet/extension-base/stores");
|
|
27
30
|
var _AccountRef = _interopRequireDefault(require("@subwallet/extension-base/stores/AccountRef"));
|
|
28
31
|
var _parseTransaction = require("@subwallet/extension-base/utils/eth/parseTransaction");
|
|
29
32
|
var _decode = require("@subwallet/keyring/pair/decode");
|
|
@@ -62,16 +65,8 @@ const generateDefaultCrowdloanMap = () => {
|
|
|
62
65
|
class KoniState {
|
|
63
66
|
injectedProviders = new Map();
|
|
64
67
|
unsubscriptionMap = {};
|
|
65
|
-
currentAccountStore = new _stores.CurrentAccountStore();
|
|
66
68
|
accountRefStore = new _AccountRef.default();
|
|
67
|
-
keyringStateSubject = new _rxjs.Subject();
|
|
68
69
|
externalRequest = {};
|
|
69
|
-
keyringState = {
|
|
70
|
-
isReady: false,
|
|
71
|
-
isLocked: true,
|
|
72
|
-
hasMasterPassword: false
|
|
73
|
-
};
|
|
74
|
-
serviceInfoSubject = new _rxjs.Subject();
|
|
75
70
|
balanceMap = {};
|
|
76
71
|
balanceSubject = new _rxjs.Subject();
|
|
77
72
|
crowdloanMap = generateDefaultCrowdloanMap();
|
|
@@ -88,19 +83,21 @@ class KoniState {
|
|
|
88
83
|
};
|
|
89
84
|
lazyMap = {};
|
|
90
85
|
ready = false;
|
|
91
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
92
86
|
constructor() {
|
|
93
87
|
let providers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
94
88
|
this.providers = providers;
|
|
95
89
|
this.dbService = new _DatabaseService.default();
|
|
90
|
+
this.eventService = new _eventService.EventService();
|
|
91
|
+
this.subscanService = new _subscanService.SubscanService();
|
|
92
|
+
this.keyringService = new _keyringService.KeyringService(this.eventService);
|
|
96
93
|
this.notificationService = new _NotificationService.default();
|
|
97
|
-
this.chainService = new _chainService.ChainService(this.dbService);
|
|
94
|
+
this.chainService = new _chainService.ChainService(this.dbService, this.eventService);
|
|
98
95
|
this.settingService = new _SettingService.default();
|
|
99
96
|
this.requestService = new _requestService.default(this.chainService, this.settingService);
|
|
100
|
-
this.priceService = new _priceService.PriceService(this.
|
|
97
|
+
this.priceService = new _priceService.PriceService(this.dbService, this.eventService, this.chainService);
|
|
101
98
|
this.balanceService = new _balanceService.BalanceService(this.chainService);
|
|
102
|
-
this.historyService = new _historyService.HistoryService(this.dbService, this.chainService);
|
|
103
|
-
this.transactionService = new _transactionService.default(this.chainService, this.requestService, this.balanceService, this.historyService, this.notificationService, this.dbService);
|
|
99
|
+
this.historyService = new _historyService.HistoryService(this.dbService, this.chainService, this.eventService);
|
|
100
|
+
this.transactionService = new _transactionService.default(this.chainService, this.eventService, this.requestService, this.balanceService, this.historyService, this.notificationService, this.dbService);
|
|
104
101
|
this.migrationService = new _migrationService.default(this);
|
|
105
102
|
this.subscription = new _subscription.KoniSubscription(this, this.dbService);
|
|
106
103
|
this.cron = new _cron.KoniCron(this, this.subscription, this.dbService);
|
|
@@ -208,8 +205,10 @@ class KoniState {
|
|
|
208
205
|
await this.chainService.init();
|
|
209
206
|
await this.migrationService.run();
|
|
210
207
|
this.startSubscription();
|
|
211
|
-
this.
|
|
208
|
+
this.eventService.emit('chain.ready', true);
|
|
212
209
|
this.onReady();
|
|
210
|
+
this.onAccountAdd();
|
|
211
|
+
this.onAccountRemove();
|
|
213
212
|
this.logger.log('Done init state');
|
|
214
213
|
}
|
|
215
214
|
startSubscription() {
|
|
@@ -229,15 +228,10 @@ class KoniState {
|
|
|
229
228
|
isReady() {
|
|
230
229
|
return this.ready;
|
|
231
230
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
return this.keyringStateSubject;
|
|
237
|
-
}
|
|
238
|
-
setKeyringState(data, callback) {
|
|
239
|
-
this.keyringStateSubject.next(data);
|
|
240
|
-
this.keyringState = data;
|
|
231
|
+
updateKeyringState() {
|
|
232
|
+
let isReady = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
233
|
+
let callback = arguments.length > 1 ? arguments[1] : undefined;
|
|
234
|
+
this.keyringService.updateKeyringState(isReady);
|
|
241
235
|
callback && callback();
|
|
242
236
|
}
|
|
243
237
|
lazyNext = (key, callback) => {
|
|
@@ -296,7 +290,7 @@ class KoniState {
|
|
|
296
290
|
return this.dbService.getNominatorMetadata();
|
|
297
291
|
}
|
|
298
292
|
async getStaking() {
|
|
299
|
-
const addresses =
|
|
293
|
+
const addresses = this.getDecodedAddresses();
|
|
300
294
|
const stakings = await this.dbService.getStakings(addresses, this.activeChainSlugs);
|
|
301
295
|
return {
|
|
302
296
|
ready: true,
|
|
@@ -314,7 +308,7 @@ class KoniState {
|
|
|
314
308
|
return addresses;
|
|
315
309
|
}
|
|
316
310
|
async getPooledStakingRecordsByAddress(addresses) {
|
|
317
|
-
return
|
|
311
|
+
return this.dbService.getPooledStakings(addresses, this.activeChainSlugs);
|
|
318
312
|
}
|
|
319
313
|
|
|
320
314
|
// TODO: delete later
|
|
@@ -355,12 +349,12 @@ class KoniState {
|
|
|
355
349
|
subscribeNftCollection() {
|
|
356
350
|
return this.dbService.stores.nftCollection.subscribeNftCollection(this.activeChainSlugs);
|
|
357
351
|
}
|
|
358
|
-
|
|
352
|
+
resetNft(newAddress) {
|
|
359
353
|
this.getNft().then(data => this.nftSubject.next(data || {
|
|
360
354
|
nftList: [],
|
|
361
355
|
total: 0
|
|
362
356
|
})).catch(e => this.logger.warn(e));
|
|
363
|
-
const addresses =
|
|
357
|
+
const addresses = this.getDecodedAddresses(newAddress);
|
|
364
358
|
this.dbService.subscribeNft(addresses, this.activeChainSlugs, nfts => {
|
|
365
359
|
this.nftSubject.next({
|
|
366
360
|
nftList: nfts,
|
|
@@ -372,14 +366,14 @@ class KoniState {
|
|
|
372
366
|
this.dbService.addNft(address, nftData).catch(e => this.logger.warn(e));
|
|
373
367
|
callback && callback(nftData);
|
|
374
368
|
}
|
|
375
|
-
removeNfts(chain, address, collectionId, nftIds) {
|
|
376
|
-
return this.dbService.removeNfts(chain, address, collectionId, nftIds);
|
|
377
|
-
}
|
|
378
369
|
deleteNftCollection(chain, collectionId) {
|
|
379
370
|
return this.dbService.deleteNftCollection(chain, collectionId);
|
|
380
371
|
}
|
|
372
|
+
cleanUpNfts(chain, owner, collectionId, nftIds) {
|
|
373
|
+
this.dbService.cleanUpNft(chain, owner, collectionId, nftIds).catch(e => this.logger.warn(e));
|
|
374
|
+
}
|
|
381
375
|
async getNft() {
|
|
382
|
-
const addresses =
|
|
376
|
+
const addresses = this.getDecodedAddresses();
|
|
383
377
|
if (!addresses.length) {
|
|
384
378
|
return;
|
|
385
379
|
}
|
|
@@ -453,9 +447,6 @@ class KoniState {
|
|
|
453
447
|
subscribeStakingReward() {
|
|
454
448
|
return this.stakingRewardSubject;
|
|
455
449
|
}
|
|
456
|
-
getCurrentAccount(update) {
|
|
457
|
-
this.currentAccountStore.get('CurrentAccountInfo', update);
|
|
458
|
-
}
|
|
459
450
|
setCurrentAccount(data, callback) {
|
|
460
451
|
const {
|
|
461
452
|
address,
|
|
@@ -465,9 +456,9 @@ class KoniState {
|
|
|
465
456
|
...data
|
|
466
457
|
};
|
|
467
458
|
if (address === _constants.ALL_ACCOUNT_KEY) {
|
|
468
|
-
const pairs = _uiKeyring.keyring.
|
|
459
|
+
const pairs = _uiKeyring.keyring.getAccounts();
|
|
469
460
|
const pair = pairs[0];
|
|
470
|
-
const pairGenesisHash = pair.meta.genesisHash;
|
|
461
|
+
const pairGenesisHash = (pair === null || pair === void 0 ? void 0 : pair.meta.genesisHash) || '';
|
|
471
462
|
if (pairs.length > 1 || !pair) {
|
|
472
463
|
result.allGenesisHash = currentGenesisHash || undefined;
|
|
473
464
|
} else {
|
|
@@ -476,10 +467,8 @@ class KoniState {
|
|
|
476
467
|
result.allGenesisHash = pairGenesisHash || undefined;
|
|
477
468
|
}
|
|
478
469
|
}
|
|
479
|
-
this.
|
|
480
|
-
|
|
481
|
-
callback && callback();
|
|
482
|
-
});
|
|
470
|
+
this.keyringService.setCurrentAccount(result);
|
|
471
|
+
callback && callback();
|
|
483
472
|
}
|
|
484
473
|
setAccountTie(address, genesisHash) {
|
|
485
474
|
if (address !== _constants.ALL_ACCOUNT_KEY) {
|
|
@@ -490,12 +479,11 @@ class KoniState {
|
|
|
490
479
|
genesisHash
|
|
491
480
|
});
|
|
492
481
|
}
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
});
|
|
482
|
+
const accountInfo = this.keyringService.currentAccount;
|
|
483
|
+
if (address === accountInfo.address) {
|
|
484
|
+
accountInfo.currentGenesisHash = genesisHash || _constants.ALL_GENESIS_HASH;
|
|
485
|
+
this.setCurrentAccount(accountInfo);
|
|
486
|
+
}
|
|
499
487
|
return true;
|
|
500
488
|
}
|
|
501
489
|
async switchEvmNetworkByUrl(shortenUrl, networkKey) {
|
|
@@ -518,9 +506,7 @@ class KoniState {
|
|
|
518
506
|
const {
|
|
519
507
|
address,
|
|
520
508
|
currentGenesisHash
|
|
521
|
-
} =
|
|
522
|
-
this.getCurrentAccount(resolve);
|
|
523
|
-
});
|
|
509
|
+
} = this.keyringService.currentAccount;
|
|
524
510
|
return this.requestService.addConfirmation(id, url, 'switchNetworkRequest', {
|
|
525
511
|
networkKey,
|
|
526
512
|
address: changeAddress
|
|
@@ -638,35 +624,28 @@ class KoniState {
|
|
|
638
624
|
subscribeSettingsSubject() {
|
|
639
625
|
return this.settingService.getSubject();
|
|
640
626
|
}
|
|
641
|
-
subscribeCurrentAccount() {
|
|
642
|
-
return this.currentAccountStore.getSubject();
|
|
643
|
-
}
|
|
644
627
|
getAccountAddress() {
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
resolve(null);
|
|
651
|
-
}
|
|
652
|
-
});
|
|
653
|
-
});
|
|
628
|
+
const address = this.keyringService.currentAccount.address;
|
|
629
|
+
if (address === '') {
|
|
630
|
+
return null;
|
|
631
|
+
}
|
|
632
|
+
return address;
|
|
654
633
|
}
|
|
655
|
-
|
|
634
|
+
getDecodedAddresses(address) {
|
|
656
635
|
let checkingAddress = address;
|
|
657
636
|
if (!address) {
|
|
658
|
-
checkingAddress =
|
|
637
|
+
checkingAddress = this.getAccountAddress();
|
|
659
638
|
}
|
|
660
639
|
if (!checkingAddress) {
|
|
661
640
|
return [];
|
|
662
641
|
}
|
|
663
642
|
if (checkingAddress === _constants.ALL_ACCOUNT_KEY) {
|
|
664
|
-
return
|
|
643
|
+
return this.getAllAddresses();
|
|
665
644
|
}
|
|
666
645
|
return [checkingAddress];
|
|
667
646
|
}
|
|
668
647
|
getAllAddresses() {
|
|
669
|
-
return
|
|
648
|
+
return _uiKeyring.keyring.getAccounts().map(account => account.address);
|
|
670
649
|
}
|
|
671
650
|
removeInactiveChainBalances(balanceMap) {
|
|
672
651
|
const activeBalanceMap = {};
|
|
@@ -693,7 +672,7 @@ class KoniState {
|
|
|
693
672
|
const items = await this.dbService.stores.balance.getBalanceMapByAddress(address);
|
|
694
673
|
return items || {};
|
|
695
674
|
}
|
|
696
|
-
async
|
|
675
|
+
async handleSwitchAccount(newAddress) {
|
|
697
676
|
await Promise.all([this.resetBalanceMap(newAddress), this.resetCrowdloanMap(newAddress)]);
|
|
698
677
|
}
|
|
699
678
|
async resetBalanceMap(newAddress) {
|
|
@@ -715,11 +694,11 @@ class KoniState {
|
|
|
715
694
|
};
|
|
716
695
|
this.publishCrowdloan(true);
|
|
717
696
|
}
|
|
718
|
-
|
|
697
|
+
resetStaking(newAddress) {
|
|
719
698
|
this.getStaking().then(data => {
|
|
720
699
|
this.stakingSubject.next(data);
|
|
721
700
|
}).catch(e => this.logger.warn(e));
|
|
722
|
-
const addresses =
|
|
701
|
+
const addresses = this.getDecodedAddresses(newAddress);
|
|
723
702
|
this.dbService.subscribeStaking(addresses, this.activeChainSlugs, stakings => {
|
|
724
703
|
this.stakingSubject.next({
|
|
725
704
|
ready: true,
|
|
@@ -738,9 +717,8 @@ class KoniState {
|
|
|
738
717
|
});
|
|
739
718
|
}
|
|
740
719
|
updateBalanceStore(item) {
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
});
|
|
720
|
+
const currentAccountInfo = this.keyringService.currentAccount;
|
|
721
|
+
this.dbService.updateBalanceStore(currentAccountInfo.address, item).catch(e => this.logger.warn(e));
|
|
744
722
|
}
|
|
745
723
|
subscribeBalance() {
|
|
746
724
|
return this.balanceSubject;
|
|
@@ -769,16 +747,12 @@ class KoniState {
|
|
|
769
747
|
});
|
|
770
748
|
}
|
|
771
749
|
updateCrowdloanStore(networkKey, item) {
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
});
|
|
750
|
+
const currentAccountInfo = this.keyringService.currentAccount;
|
|
751
|
+
this.dbService.updateCrowdloanStore(networkKey, currentAccountInfo.address, item).catch(e => this.logger.warn(e));
|
|
775
752
|
}
|
|
776
753
|
subscribeCrowdloan() {
|
|
777
754
|
return this.crowdloanSubject;
|
|
778
755
|
}
|
|
779
|
-
getAllPriceIds() {
|
|
780
|
-
return this.chainService.getAllPriceIds();
|
|
781
|
-
}
|
|
782
756
|
getSmartContractNfts() {
|
|
783
757
|
return this.chainService.getSmartContractNfts();
|
|
784
758
|
}
|
|
@@ -836,12 +810,13 @@ class KoniState {
|
|
|
836
810
|
await this.chainService.updateAssetSetting(tokenSlug, {
|
|
837
811
|
visible: true
|
|
838
812
|
});
|
|
813
|
+
this.eventService.emit('asset.updateState', tokenSlug);
|
|
814
|
+
} else {
|
|
815
|
+
this.eventService.emit('asset.updateState', tokenSlug);
|
|
839
816
|
}
|
|
840
|
-
this.updateServiceInfo();
|
|
841
817
|
}
|
|
842
818
|
deleteCustomAssets(targetTokens) {
|
|
843
819
|
this.chainService.deleteCustomAssets(targetTokens);
|
|
844
|
-
this.updateServiceInfo();
|
|
845
820
|
}
|
|
846
821
|
async validateCustomChain(provider, existedChainSlug) {
|
|
847
822
|
return await this.chainService.validateCustomChain(provider, existedChainSlug);
|
|
@@ -864,14 +839,12 @@ class KoniState {
|
|
|
864
839
|
await this.chainService.updateAssetSetting(newNativeTokenSlug, {
|
|
865
840
|
visible: true
|
|
866
841
|
});
|
|
842
|
+
this.eventService.emit('asset.updateState', newNativeTokenSlug);
|
|
867
843
|
}
|
|
868
|
-
this.updateServiceInfo();
|
|
869
844
|
return true;
|
|
870
845
|
}
|
|
871
846
|
removeCustomChain(networkKey) {
|
|
872
|
-
|
|
873
|
-
this.updateServiceInfo();
|
|
874
|
-
return result;
|
|
847
|
+
return this.chainService.removeCustomChain(networkKey);
|
|
875
848
|
}
|
|
876
849
|
|
|
877
850
|
// TODO: avoids turning off chains related to ledger account
|
|
@@ -897,30 +870,19 @@ class KoniState {
|
|
|
897
870
|
async disableChain(chainSlug) {
|
|
898
871
|
// const defaultChains = this.getDefaultNetworkKeys();
|
|
899
872
|
await this.chainService.updateAssetSettingByChain(chainSlug, false);
|
|
900
|
-
|
|
901
|
-
this.updateServiceInfo();
|
|
902
|
-
return result;
|
|
873
|
+
return this.chainService.disableChain(chainSlug);
|
|
903
874
|
}
|
|
904
875
|
async enableChain(chainSlug) {
|
|
905
876
|
let enableTokens = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
906
877
|
if (enableTokens) {
|
|
907
878
|
await this.chainService.updateAssetSettingByChain(chainSlug, true);
|
|
908
879
|
}
|
|
909
|
-
|
|
910
|
-
this.updateServiceInfo();
|
|
911
|
-
return result;
|
|
880
|
+
return this.chainService.enableChain(chainSlug);
|
|
912
881
|
}
|
|
913
882
|
resetDefaultChains() {
|
|
914
883
|
const defaultChains = this.getDefaultNetworkKeys();
|
|
915
884
|
return this.chainService.resetChainInfoMap(defaultChains);
|
|
916
885
|
}
|
|
917
|
-
updateNetworkStatus(networkKey, status) {
|
|
918
|
-
const chainState = this.chainService.getChainStateByKey(networkKey);
|
|
919
|
-
if (chainState.connectionStatus === status) {
|
|
920
|
-
return;
|
|
921
|
-
}
|
|
922
|
-
this.chainService.setChainConnectionStatus(networkKey, status);
|
|
923
|
-
}
|
|
924
886
|
getSubstrateApiMap() {
|
|
925
887
|
return this.chainService.getSubstrateApiMap();
|
|
926
888
|
}
|
|
@@ -946,20 +908,14 @@ class KoniState {
|
|
|
946
908
|
refreshWeb3Api(key) {
|
|
947
909
|
this.chainService.refreshEvmApi(key);
|
|
948
910
|
}
|
|
949
|
-
|
|
950
|
-
return
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
this.
|
|
956
|
-
|
|
957
|
-
chainApiMap: this.getApiMap(),
|
|
958
|
-
currentAccountInfo: value,
|
|
959
|
-
assetRegistry: this.chainService.getAssetRegistry(),
|
|
960
|
-
chainStateMap: this.chainService.getChainStateMap()
|
|
961
|
-
});
|
|
962
|
-
});
|
|
911
|
+
getServiceInfo() {
|
|
912
|
+
return {
|
|
913
|
+
chainInfoMap: this.chainService.getChainInfoMap(),
|
|
914
|
+
chainApiMap: this.getApiMap(),
|
|
915
|
+
currentAccountInfo: this.keyringService.currentAccount,
|
|
916
|
+
assetRegistry: this.chainService.getAssetRegistry(),
|
|
917
|
+
chainStateMap: this.chainService.getChainStateMap()
|
|
918
|
+
};
|
|
963
919
|
}
|
|
964
920
|
getExternalRequestMap() {
|
|
965
921
|
return this.externalRequest;
|
|
@@ -1401,5 +1357,85 @@ class KoniState {
|
|
|
1401
1357
|
createUnsubscriptionHandle(id, unsubscribe) {
|
|
1402
1358
|
this.unsubscriptionMap[id] = unsubscribe;
|
|
1403
1359
|
}
|
|
1360
|
+
updateChainConnectionStatus(chain, status) {
|
|
1361
|
+
this.chainService.setChainConnectionStatus(chain, status);
|
|
1362
|
+
}
|
|
1363
|
+
async autoEnableChains(addresses) {
|
|
1364
|
+
const assetMap = this.chainService.getAssetRegistry();
|
|
1365
|
+
const promiseList = addresses.map(address => {
|
|
1366
|
+
return this.subscanService.getMultiChainBalance(address).catch(e => {
|
|
1367
|
+
console.error(e);
|
|
1368
|
+
return null;
|
|
1369
|
+
});
|
|
1370
|
+
});
|
|
1371
|
+
const needEnableChains = [];
|
|
1372
|
+
const needActiveTokens = [];
|
|
1373
|
+
const currentAssetSettings = await this.chainService.getAssetSettings();
|
|
1374
|
+
const chainMap = this.chainService.getChainInfoMap();
|
|
1375
|
+
const balanceDataList = await Promise.all(promiseList);
|
|
1376
|
+
balanceDataList.forEach(balanceData => {
|
|
1377
|
+
balanceData && balanceData.forEach(_ref14 => {
|
|
1378
|
+
var _currentAssetSettings;
|
|
1379
|
+
let {
|
|
1380
|
+
balance,
|
|
1381
|
+
bonded,
|
|
1382
|
+
category,
|
|
1383
|
+
locked,
|
|
1384
|
+
network,
|
|
1385
|
+
symbol
|
|
1386
|
+
} = _ref14;
|
|
1387
|
+
const chain = _subscanChainMap.SUBSCAN_CHAIN_MAP_REVERSE[network];
|
|
1388
|
+
const chainInfo = chain ? chainMap[chain] : null;
|
|
1389
|
+
const balanceIsEmpty = (!balance || balance === '0') && !locked && locked === '0' && (!bonded || bonded === '0');
|
|
1390
|
+
|
|
1391
|
+
// Cancel if chain is not supported or is testnet or balance is 0
|
|
1392
|
+
if (!chainInfo || chainInfo.isTestnet || balanceIsEmpty) {
|
|
1393
|
+
return;
|
|
1394
|
+
}
|
|
1395
|
+
const tokenKey = `${chain}-${category === 'native' ? 'NATIVE' : 'LOCAL'}-${symbol.toUpperCase()}`;
|
|
1396
|
+
if (assetMap[tokenKey] && !((_currentAssetSettings = currentAssetSettings[tokenKey]) !== null && _currentAssetSettings !== void 0 && _currentAssetSettings.visible)) {
|
|
1397
|
+
needEnableChains.push(chain);
|
|
1398
|
+
needActiveTokens.push(tokenKey);
|
|
1399
|
+
currentAssetSettings[tokenKey] = {
|
|
1400
|
+
visible: true
|
|
1401
|
+
};
|
|
1402
|
+
}
|
|
1403
|
+
});
|
|
1404
|
+
});
|
|
1405
|
+
if (needActiveTokens.length) {
|
|
1406
|
+
this.chainService.enableChains(needEnableChains);
|
|
1407
|
+
this.chainService.setAssetSettings({
|
|
1408
|
+
...currentAssetSettings
|
|
1409
|
+
});
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
onAccountAdd() {
|
|
1413
|
+
this.eventService.on('account.add', address => {
|
|
1414
|
+
this.autoEnableChains([address]).catch(this.logger.error);
|
|
1415
|
+
});
|
|
1416
|
+
}
|
|
1417
|
+
onAccountRemove() {
|
|
1418
|
+
this.eventService.on('account.remove', address => {
|
|
1419
|
+
// Some separate service like historyService will listen to this event and remove inside that service
|
|
1420
|
+
|
|
1421
|
+
const stores = this.dbService.stores;
|
|
1422
|
+
|
|
1423
|
+
// Remove Balance
|
|
1424
|
+
stores.balance.removeAllByAddress(address).catch(console.error);
|
|
1425
|
+
stores.balance.removeAllByAddress(_constants.ALL_ACCOUNT_KEY).catch(console.error);
|
|
1426
|
+
|
|
1427
|
+
// Remove NFT
|
|
1428
|
+
stores.nft.deleteNftByAddress([address]).catch(console.error);
|
|
1429
|
+
|
|
1430
|
+
// Remove Staking Data
|
|
1431
|
+
stores.staking.removeAllByAddress(address).catch(console.error);
|
|
1432
|
+
});
|
|
1433
|
+
}
|
|
1434
|
+
async reloadNft() {
|
|
1435
|
+
return await this.cron.reloadNft();
|
|
1436
|
+
}
|
|
1437
|
+
async reloadStaking() {
|
|
1438
|
+
return await this.cron.reloadStaking();
|
|
1439
|
+
}
|
|
1404
1440
|
}
|
|
1405
1441
|
exports.default = KoniState;
|
|
@@ -256,32 +256,34 @@ class KoniTabs {
|
|
|
256
256
|
const allAccounts = _accounts.accounts.subject.getValue();
|
|
257
257
|
const accountList = transformAccountsV2(allAccounts, false, authInfo, 'evm').map(a => a.address);
|
|
258
258
|
let accounts = [];
|
|
259
|
-
this.#koniState.
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
accounts = [address];
|
|
267
|
-
}
|
|
268
|
-
resolve(accounts);
|
|
269
|
-
});
|
|
259
|
+
const address = this.#koniState.keyringService.currentAccount.address;
|
|
260
|
+
if (address === _constants.ALL_ACCOUNT_KEY || !accountList.includes(address) || getAll) {
|
|
261
|
+
accounts = accountList;
|
|
262
|
+
} else if (address && accountList.includes(address)) {
|
|
263
|
+
accounts = [address];
|
|
264
|
+
}
|
|
265
|
+
resolve(accounts);
|
|
270
266
|
}).catch(console.error);
|
|
271
267
|
});
|
|
272
268
|
}
|
|
273
269
|
async getEvmState(url) {
|
|
274
|
-
let
|
|
270
|
+
let currentChain;
|
|
271
|
+
let autoActiveChain = false;
|
|
275
272
|
if (url) {
|
|
276
273
|
const authInfo = await this.getAuthInfo(url);
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
});
|
|
274
|
+
if (authInfo !== null && authInfo !== void 0 && authInfo.currentEvmNetworkKey) {
|
|
275
|
+
currentChain = authInfo === null || authInfo === void 0 ? void 0 : authInfo.currentEvmNetworkKey;
|
|
276
|
+
}
|
|
277
|
+
if (authInfo !== null && authInfo !== void 0 && authInfo.isAllowed) {
|
|
278
|
+
autoActiveChain = true;
|
|
279
|
+
}
|
|
284
280
|
}
|
|
281
|
+
const currentEvmNetwork = this.#koniState.requestService.getDAppChainInfo({
|
|
282
|
+
autoActive: autoActiveChain,
|
|
283
|
+
accessType: 'evm',
|
|
284
|
+
defaultChain: currentChain,
|
|
285
|
+
url
|
|
286
|
+
});
|
|
285
287
|
if (currentEvmNetwork) {
|
|
286
288
|
const {
|
|
287
289
|
evmInfo,
|
|
@@ -293,13 +295,20 @@ class KoniTabs {
|
|
|
293
295
|
if (!web3.currentProvider.connected) {
|
|
294
296
|
console.log(`[Web3] ${slug} is disconnected, trying to connect...`);
|
|
295
297
|
this.#koniState.refreshWeb3Api(slug);
|
|
298
|
+
let checkingNum = 0;
|
|
296
299
|
const poll = resolve => {
|
|
300
|
+
checkingNum += 1;
|
|
297
301
|
if (web3.currentProvider.connected) {
|
|
298
302
|
console.log(`Network [${slug}] is connected.`);
|
|
299
303
|
resolve(true);
|
|
300
304
|
} else {
|
|
301
305
|
console.log(`Connecting to network [${slug}]`);
|
|
302
|
-
|
|
306
|
+
if (checkingNum < 10) {
|
|
307
|
+
setTimeout(() => poll(resolve), 900);
|
|
308
|
+
} else {
|
|
309
|
+
console.log(`Max retry, stop checking [${slug}]`);
|
|
310
|
+
resolve(false);
|
|
311
|
+
}
|
|
303
312
|
}
|
|
304
313
|
};
|
|
305
314
|
await new Promise(poll);
|
|
@@ -327,10 +336,10 @@ class KoniTabs {
|
|
|
327
336
|
date: new Date().getTime()
|
|
328
337
|
}];
|
|
329
338
|
}
|
|
330
|
-
async switchEvmChain(id, url,
|
|
339
|
+
async switchEvmChain(id, url, _ref12) {
|
|
331
340
|
let {
|
|
332
341
|
params
|
|
333
|
-
} =
|
|
342
|
+
} = _ref12;
|
|
334
343
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
335
344
|
const chainId = params[0].chainId;
|
|
336
345
|
const evmState = await this.getEvmState(url);
|
|
@@ -345,11 +354,11 @@ class KoniTabs {
|
|
|
345
354
|
}
|
|
346
355
|
return null;
|
|
347
356
|
}
|
|
348
|
-
async addEvmToken(id, url,
|
|
357
|
+
async addEvmToken(id, url, _ref13) {
|
|
349
358
|
var _input$type, _input$options, _input$options2;
|
|
350
359
|
let {
|
|
351
360
|
params
|
|
352
|
-
} =
|
|
361
|
+
} = _ref13;
|
|
353
362
|
const input = params;
|
|
354
363
|
const _tokenType = (input === null || input === void 0 ? void 0 : (_input$type = input.type) === null || _input$type === void 0 ? void 0 : _input$type.toLowerCase()) || '';
|
|
355
364
|
if (_tokenType !== 'erc20' && _tokenType !== 'erc721') {
|
|
@@ -384,10 +393,10 @@ class KoniTabs {
|
|
|
384
393
|
};
|
|
385
394
|
return await this.#koniState.addTokenConfirm(id, url, tokenInfo);
|
|
386
395
|
}
|
|
387
|
-
async addEvmChain(id, url,
|
|
396
|
+
async addEvmChain(id, url, _ref14) {
|
|
388
397
|
let {
|
|
389
398
|
params
|
|
390
|
-
} =
|
|
399
|
+
} = _ref14;
|
|
391
400
|
const input = params;
|
|
392
401
|
if (input && input.length > 0) {
|
|
393
402
|
const {
|
|
@@ -481,7 +490,7 @@ class KoniTabs {
|
|
|
481
490
|
currentAccountList = newAccountList;
|
|
482
491
|
}
|
|
483
492
|
};
|
|
484
|
-
const accountListSubscription = this.#koniState.
|
|
493
|
+
const accountListSubscription = this.#koniState.keyringService.currentAccountSubject.subscribe(() => {
|
|
485
494
|
onCurrentAccountChanged().catch(console.error);
|
|
486
495
|
});
|
|
487
496
|
|
|
@@ -531,11 +540,11 @@ class KoniTabs {
|
|
|
531
540
|
const networkCheckInterval = setInterval(networkCheck, _constants.CRON_GET_API_MAP_STATUS);
|
|
532
541
|
const provider = await this.getEvmProvider(url);
|
|
533
542
|
const eventMap = {};
|
|
534
|
-
eventMap.data =
|
|
543
|
+
eventMap.data = _ref15 => {
|
|
535
544
|
let {
|
|
536
545
|
method,
|
|
537
546
|
params
|
|
538
|
-
} =
|
|
547
|
+
} = _ref15;
|
|
539
548
|
emitEvent('message', {
|
|
540
549
|
type: method,
|
|
541
550
|
data: params
|
|
@@ -544,8 +553,8 @@ class KoniTabs {
|
|
|
544
553
|
eventMap.error = rs => {
|
|
545
554
|
emitEvent('error', rs);
|
|
546
555
|
};
|
|
547
|
-
Object.entries(eventMap).forEach(
|
|
548
|
-
let [event, callback] =
|
|
556
|
+
Object.entries(eventMap).forEach(_ref16 => {
|
|
557
|
+
let [event, callback] = _ref16;
|
|
549
558
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
550
559
|
(provider === null || provider === void 0 ? void 0 : provider.on) && (provider === null || provider === void 0 ? void 0 : provider.on(event, callback));
|
|
551
560
|
});
|
|
@@ -559,8 +568,8 @@ class KoniTabs {
|
|
|
559
568
|
if (this.evmEventEmitterMap[url][id]) {
|
|
560
569
|
delete this.evmEventEmitterMap[url][id];
|
|
561
570
|
}
|
|
562
|
-
Object.entries(eventMap).forEach(
|
|
563
|
-
let [event, callback] =
|
|
571
|
+
Object.entries(eventMap).forEach(_ref17 => {
|
|
572
|
+
let [event, callback] = _ref17;
|
|
564
573
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
565
574
|
(provider === null || provider === void 0 ? void 0 : provider.removeListener) && (provider === null || provider === void 0 ? void 0 : provider.removeListener(event, callback));
|
|
566
575
|
});
|
|
@@ -595,11 +604,11 @@ class KoniTabs {
|
|
|
595
604
|
}
|
|
596
605
|
return provider;
|
|
597
606
|
}
|
|
598
|
-
async performWeb3Method(id, url,
|
|
607
|
+
async performWeb3Method(id, url, _ref18, callback) {
|
|
599
608
|
let {
|
|
600
609
|
method,
|
|
601
610
|
params
|
|
602
|
-
} =
|
|
611
|
+
} = _ref18;
|
|
603
612
|
const provider = await this.getEvmProvider(url);
|
|
604
613
|
this.checkAndHandleProviderStatus(provider);
|
|
605
614
|
return new Promise((resolve, reject) => {
|
|
@@ -624,11 +633,11 @@ class KoniTabs {
|
|
|
624
633
|
const allowedAccounts = await this.getEvmCurrentAccount(url, true);
|
|
625
634
|
return !!allowedAccounts.find(acc => acc.toLowerCase() === address.toLowerCase());
|
|
626
635
|
}
|
|
627
|
-
async evmSign(id, url,
|
|
636
|
+
async evmSign(id, url, _ref19) {
|
|
628
637
|
let {
|
|
629
638
|
method,
|
|
630
639
|
params
|
|
631
|
-
} =
|
|
640
|
+
} = _ref19;
|
|
632
641
|
const allowedAccounts = await this.getEvmCurrentAccount(url, true);
|
|
633
642
|
const signResult = await this.#koniState.evmSign(id, url, method, params, allowedAccounts);
|
|
634
643
|
if (signResult) {
|
|
@@ -637,10 +646,10 @@ class KoniTabs {
|
|
|
637
646
|
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, 'Have something wrong to sign message');
|
|
638
647
|
}
|
|
639
648
|
}
|
|
640
|
-
async evmSendTransaction(id, url,
|
|
649
|
+
async evmSendTransaction(id, url, _ref20) {
|
|
641
650
|
let {
|
|
642
651
|
params
|
|
643
|
-
} =
|
|
652
|
+
} = _ref20;
|
|
644
653
|
const transactionParams = params[0];
|
|
645
654
|
const canUseAccount = transactionParams.from && this.canUseAccount(transactionParams.from, url);
|
|
646
655
|
const evmState = await this.getEvmState(url);
|