@subwallet/extension-base 1.0.2-1b → 1.0.2-2
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 +34 -16
- package/background/KoniTypes.js +7 -6
- package/background/errors/TransactionError.js +1 -21
- package/cjs/background/KoniTypes.js +7 -6
- package/cjs/background/errors/TransactionError.js +0 -20
- package/cjs/constants/index.js +26 -8
- package/cjs/koni/api/dotsama/balance.js +224 -49
- package/cjs/koni/api/dotsama/transfer.js +29 -30
- package/cjs/koni/api/nft/acala_nft/index.js +1 -4
- package/cjs/koni/api/nft/bit.country/index.js +1 -4
- package/cjs/koni/api/nft/evm_nft/index.js +3 -7
- package/cjs/koni/api/nft/index.js +6 -3
- package/cjs/koni/api/nft/karura_nft/index.js +1 -4
- package/cjs/koni/api/nft/rmrk_nft/index.js +1 -8
- package/cjs/koni/api/nft/statemine_nft/index.js +1 -4
- package/cjs/koni/api/nft/unique_nft/index.js +1 -6
- package/cjs/koni/api/nft/wasm_nft/index.js +111 -169
- package/cjs/koni/api/nft/wasm_nft/utils.js +7 -11
- package/cjs/koni/api/staking/bonding/amplitude.js +9 -13
- package/cjs/koni/api/staking/bonding/astar.js +13 -15
- package/cjs/koni/api/staking/bonding/index.js +10 -22
- package/cjs/koni/api/staking/bonding/paraChain.js +2 -85
- package/cjs/koni/api/staking/bonding/relayChain.js +16 -119
- package/cjs/koni/api/staking/bonding/utils.js +8 -27
- package/cjs/koni/api/tokens/wasm/index.js +4 -5
- package/cjs/koni/api/xcm/polkadotXcm.js +1 -1
- package/cjs/koni/api/xcm/utils.js +13 -18
- package/cjs/koni/api/xcm/xTokens.js +1 -1
- package/cjs/koni/api/xcm/xcmPallet.js +6 -9
- package/cjs/koni/background/cron.js +47 -150
- package/cjs/koni/background/handlers/Extension.js +64 -106
- package/cjs/koni/background/handlers/State.js +21 -19
- package/cjs/koni/background/handlers/Tabs.js +1 -8
- package/cjs/koni/background/subscription.js +29 -32
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/chain-service/handler/SubstrateChainHandler.js +8 -13
- package/cjs/services/chain-service/handler/light-client/index.js +0 -2
- package/cjs/services/chain-service/index.js +7 -6
- package/cjs/services/event-service/index.js +1 -5
- package/cjs/services/event-service/types.js +1 -11
- package/cjs/services/history-service/index.js +10 -16
- package/cjs/services/history-service/subsquid-multi-chain-history.js +9 -12
- package/cjs/services/price-service/coingecko.js +1 -0
- package/cjs/services/price-service/index.js +3 -2
- package/cjs/services/request-service/handler/AuthRequestHandler.js +2 -6
- package/cjs/services/storage-service/DatabaseService.js +33 -52
- package/cjs/services/storage-service/db-stores/Nft.js +17 -4
- package/cjs/services/transaction-service/event-parser/index.js +48 -20
- package/cjs/services/transaction-service/index.js +14 -23
- package/cjs/utils/index.js +14 -7
- package/constants/index.d.ts +13 -7
- package/constants/index.js +13 -7
- package/koni/api/dotsama/balance.d.ts +1 -0
- package/koni/api/dotsama/balance.js +197 -22
- package/koni/api/dotsama/transfer.js +4 -5
- package/koni/api/nft/acala_nft/index.js +1 -3
- package/koni/api/nft/bit.country/index.js +1 -3
- package/koni/api/nft/evm_nft/index.js +3 -6
- package/koni/api/nft/index.d.ts +2 -1
- package/koni/api/nft/index.js +6 -3
- package/koni/api/nft/karura_nft/index.js +1 -3
- package/koni/api/nft/nft.d.ts +0 -1
- package/koni/api/nft/rmrk_nft/index.js +1 -8
- package/koni/api/nft/statemine_nft/index.js +1 -3
- package/koni/api/nft/unique_nft/index.js +1 -5
- package/koni/api/nft/wasm_nft/index.d.ts +2 -0
- package/koni/api/nft/wasm_nft/index.js +109 -167
- package/koni/api/nft/wasm_nft/utils.d.ts +5 -7
- package/koni/api/nft/wasm_nft/utils.js +5 -7
- package/koni/api/staking/bonding/amplitude.d.ts +1 -0
- package/koni/api/staking/bonding/amplitude.js +10 -15
- package/koni/api/staking/bonding/astar.js +6 -8
- package/koni/api/staking/bonding/index.d.ts +1 -4
- package/koni/api/staking/bonding/index.js +13 -23
- package/koni/api/staking/bonding/paraChain.d.ts +0 -3
- package/koni/api/staking/bonding/paraChain.js +5 -86
- package/koni/api/staking/bonding/relayChain.d.ts +1 -5
- package/koni/api/staking/bonding/relayChain.js +18 -118
- package/koni/api/staking/bonding/utils.d.ts +2 -3
- package/koni/api/staking/bonding/utils.js +9 -27
- package/koni/api/tokens/wasm/index.js +4 -5
- package/koni/api/xcm/polkadotXcm.js +2 -2
- package/koni/api/xcm/utils.d.ts +6 -5
- package/koni/api/xcm/utils.js +10 -15
- package/koni/api/xcm/xTokens.js +2 -2
- package/koni/api/xcm/xcmPallet.js +9 -10
- package/koni/background/cron.d.ts +1 -6
- package/koni/background/cron.js +48 -151
- package/koni/background/handlers/Extension.d.ts +2 -2
- package/koni/background/handlers/Extension.js +67 -108
- package/koni/background/handlers/State.d.ts +6 -5
- package/koni/background/handlers/State.js +21 -19
- package/koni/background/handlers/Tabs.js +1 -8
- package/koni/background/subscription.js +30 -31
- package/package.json +8 -13
- package/packageInfo.js +1 -1
- package/services/chain-service/handler/SubstrateChainHandler.js +9 -14
- package/services/chain-service/handler/light-client/index.d.ts +1 -17
- package/services/chain-service/handler/light-client/index.js +1 -1
- package/services/chain-service/helper/psp22_abi.json +881 -1041
- package/services/chain-service/helper/psp34_abi.json +1808 -2964
- package/services/chain-service/index.js +7 -6
- package/services/event-service/index.js +1 -5
- package/services/event-service/types.d.ts +9 -5
- package/services/event-service/types.js +1 -4
- package/services/history-service/index.d.ts +1 -1
- package/services/history-service/index.js +10 -16
- package/services/history-service/subsquid-multi-chain-history.js +11 -15
- package/services/price-service/coingecko.js +1 -0
- package/services/price-service/index.js +3 -2
- package/services/request-service/handler/AuthRequestHandler.js +2 -6
- package/services/storage-service/DatabaseService.d.ts +0 -1
- package/services/storage-service/DatabaseService.js +33 -52
- package/services/storage-service/db-stores/Nft.d.ts +2 -1
- package/services/storage-service/db-stores/Nft.js +16 -4
- package/services/transaction-service/event-parser/index.js +49 -21
- package/services/transaction-service/index.js +14 -23
- package/utils/index.d.ts +1 -1
- package/utils/index.js +12 -6
- package/cjs/koni/api/tokens/wasm/utils.js +0 -63
- package/koni/api/tokens/wasm/utils.d.ts +0 -6
- package/koni/api/tokens/wasm/utils.js +0 -54
|
@@ -15,16 +15,15 @@ export declare class KoniCron {
|
|
|
15
15
|
constructor(state: KoniState, subscriptions: KoniSubscription, dbService: DatabaseService);
|
|
16
16
|
private cronMap;
|
|
17
17
|
private subjectMap;
|
|
18
|
-
private eventHandler?;
|
|
19
18
|
getCron: (name: string) => any;
|
|
20
19
|
getSubjectMap: (name: string) => any;
|
|
21
20
|
addCron: (name: string, callback: (param?: any) => void, interval: number, runFirst?: boolean) => void;
|
|
22
21
|
addSubscribeCron: <T>(name: string, callback: (subject: Subject<T>) => void, interval: number) => void;
|
|
23
22
|
removeCron: (name: string) => void;
|
|
24
23
|
removeAllCrons: () => void;
|
|
24
|
+
init: () => void;
|
|
25
25
|
start: () => void;
|
|
26
26
|
stop: () => void;
|
|
27
|
-
updateApiMapStatus: () => void;
|
|
28
27
|
recoverApiMap: () => void;
|
|
29
28
|
refreshNft: (address: string, apiMap: ApiMap, smartContractNfts: _ChainAsset[], chainInfoMap: Record<string, _ChainInfo>) => () => void;
|
|
30
29
|
resetNft: (newAddress: string) => void;
|
|
@@ -35,8 +34,4 @@ export declare class KoniCron {
|
|
|
35
34
|
checkNetworkAvailable: (serviceInfo: ServiceInfo) => boolean;
|
|
36
35
|
updateChainStakingMetadata: (chainInfoMap: Record<string, _ChainInfo>, chainStateMap: Record<string, _ChainState>, substrateApiMap: Record<string, _SubstrateApi>) => () => void;
|
|
37
36
|
updateNominatorMetadata: (address: string, chainInfoMap: Record<string, _ChainInfo>, chainStateMap: Record<string, _ChainState>, substrateApiMap: Record<string, _SubstrateApi>) => () => void;
|
|
38
|
-
reloadNft(): Promise<boolean>;
|
|
39
|
-
reloadStaking(): Promise<boolean>;
|
|
40
|
-
private needUpdateNft;
|
|
41
|
-
private needUpdateStaking;
|
|
42
37
|
}
|
package/koni/background/cron.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { CRON_AUTO_RECOVER_DOTSAMA_INTERVAL,
|
|
5
|
-
import { _ChainConnectionStatus } from '@subwallet/extension-base/services/chain-service/types';
|
|
6
|
-
import { _isChainSupportEvmNft, _isChainSupportNativeNft, _isChainSupportSubstrateStaking, _isChainSupportWasmNft } from '@subwallet/extension-base/services/chain-service/utils';
|
|
7
|
-
import { waitTimeout } from '@subwallet/extension-base/utils';
|
|
4
|
+
import { CRON_AUTO_RECOVER_DOTSAMA_INTERVAL, CRON_REFRESH_CHAIN_NOMINATOR_METADATA, CRON_REFRESH_CHAIN_STAKING_METADATA, CRON_REFRESH_NFT_INTERVAL, CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL, CRON_REFRESH_STAKING_REWARD_INTERVAL } from '@subwallet/extension-base/constants';
|
|
8
5
|
import { Subject } from 'rxjs';
|
|
9
6
|
import { logger as createLogger } from '@polkadot/util';
|
|
10
7
|
export class KoniCron {
|
|
@@ -50,26 +47,21 @@ export class KoniCron {
|
|
|
50
47
|
delete this.cronMap[key];
|
|
51
48
|
});
|
|
52
49
|
};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
// } else {
|
|
69
|
-
// this.setStakingRewardReady();
|
|
70
|
-
// }
|
|
71
|
-
// };
|
|
72
|
-
|
|
50
|
+
init = () => {
|
|
51
|
+
const currentAccountInfo = this.state.keyringService.currentAccount;
|
|
52
|
+
if (!(currentAccountInfo !== null && currentAccountInfo !== void 0 && currentAccountInfo.address)) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (Object.keys(this.state.getSubstrateApiMap()).length !== 0 || Object.keys(this.state.getEvmApiMap()).length !== 0) {
|
|
56
|
+
this.refreshNft(currentAccountInfo.address, this.state.getApiMap(), this.state.getSmartContractNfts(), this.state.getActiveChainInfoMap());
|
|
57
|
+
this.refreshStakingReward(currentAccountInfo.address);
|
|
58
|
+
this.refreshStakingRewardFastInterval(currentAccountInfo.address);
|
|
59
|
+
this.updateChainStakingMetadata(this.state.getChainInfoMap(), this.state.getChainStateMap(), this.state.getSubstrateApiMap());
|
|
60
|
+
this.updateNominatorMetadata(currentAccountInfo.address, this.state.getChainInfoMap(), this.state.getChainStateMap(), this.state.getSubstrateApiMap());
|
|
61
|
+
} else {
|
|
62
|
+
this.setStakingRewardReady();
|
|
63
|
+
}
|
|
64
|
+
};
|
|
73
65
|
start = () => {
|
|
74
66
|
if (this.status === 'running') {
|
|
75
67
|
return;
|
|
@@ -82,7 +74,6 @@ export class KoniCron {
|
|
|
82
74
|
if (Object.keys(this.state.getSubstrateApiMap()).length !== 0 || Object.keys(this.state.getEvmApiMap()).length !== 0) {
|
|
83
75
|
this.resetNft(currentAccountInfo.address);
|
|
84
76
|
this.addCron('refreshNft', this.refreshNft(currentAccountInfo.address, this.state.getApiMap(), this.state.getSmartContractNfts(), this.state.getActiveChainInfoMap()), CRON_REFRESH_NFT_INTERVAL);
|
|
85
|
-
this.addCron('checkStatusApiMap', this.updateApiMapStatus, CRON_GET_API_MAP_STATUS);
|
|
86
77
|
this.addCron('recoverApiMap', this.recoverApiMap, CRON_AUTO_RECOVER_DOTSAMA_INTERVAL, false);
|
|
87
78
|
this.addCron('refreshStakingReward', this.refreshStakingReward(currentAccountInfo.address), CRON_REFRESH_STAKING_REWARD_INTERVAL);
|
|
88
79
|
this.addCron('refreshPoolingStakingReward', this.refreshStakingRewardFastInterval(currentAccountInfo.address), CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL);
|
|
@@ -91,74 +82,46 @@ export class KoniCron {
|
|
|
91
82
|
} else {
|
|
92
83
|
this.setStakingRewardReady();
|
|
93
84
|
}
|
|
94
|
-
const
|
|
95
|
-
this.
|
|
85
|
+
const reloadEvents = ['account.add', 'account.remove', 'account.updateCurrent', 'chain.add', 'chain.update', 'chain.enable', 'asset.update', 'asset.enable', 'transaction.done', 'transaction.failed'];
|
|
86
|
+
this.state.eventService.onLazy((events, eventTypes) => {
|
|
96
87
|
var _serviceInfo$currentA;
|
|
97
88
|
const serviceInfo = this.state.getServiceInfo();
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
const stakingSubmitted = eventTypes.includes('transaction.submitStaking');
|
|
101
|
-
const updatedChains = [];
|
|
102
|
-
if (chainUpdated) {
|
|
103
|
-
events.forEach(event => {
|
|
104
|
-
if (event.type === 'chain.updateState') {
|
|
105
|
-
const updatedData = event.data;
|
|
106
|
-
updatedChains.push(updatedData[0]);
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
if (!commonReload && !chainUpdated && !stakingSubmitted) {
|
|
89
|
+
const needReload = eventTypes.some(eT => reloadEvents.includes(eT));
|
|
90
|
+
if (!needReload) {
|
|
111
91
|
return;
|
|
112
92
|
}
|
|
113
|
-
this.logger.log('ServiceInfo updated,
|
|
93
|
+
this.logger.log('ServiceInfo updated, restarting...');
|
|
114
94
|
const address = (_serviceInfo$currentA = serviceInfo.currentAccountInfo) === null || _serviceInfo$currentA === void 0 ? void 0 : _serviceInfo$currentA.address;
|
|
115
95
|
if (!address) {
|
|
116
96
|
return;
|
|
117
97
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
(commonReload || needUpdateStaking || stakingSubmitted) && this.resetStakingReward();
|
|
128
|
-
(commonReload || needUpdateStaking || stakingSubmitted) && this.removeCron('refreshStakingReward');
|
|
129
|
-
(commonReload || needUpdateStaking || stakingSubmitted) && this.removeCron('refreshPoolingStakingReward');
|
|
130
|
-
(commonReload || needUpdateStaking || stakingSubmitted) && this.removeCron('updateNominatorMetadata');
|
|
131
|
-
needUpdateStaking && this.removeCron('updateChainStakingMetadata');
|
|
132
|
-
|
|
133
|
-
// Chains
|
|
134
|
-
chainUpdated && this.removeCron('checkStatusApiMap');
|
|
135
|
-
chainUpdated && this.removeCron('recoverApiMap');
|
|
98
|
+
this.resetStakingReward();
|
|
99
|
+
this.resetNft(address);
|
|
100
|
+
this.removeCron('refreshNft');
|
|
101
|
+
this.removeCron('refreshStakingReward');
|
|
102
|
+
this.removeCron('refreshPoolingStakingReward');
|
|
103
|
+
this.removeCron('checkStatusApiMap');
|
|
104
|
+
this.removeCron('recoverApiMap');
|
|
105
|
+
this.removeCron('updateChainStakingMetadata');
|
|
106
|
+
this.removeCron('updateNominatorMetadata');
|
|
136
107
|
if (this.checkNetworkAvailable(serviceInfo)) {
|
|
137
108
|
// only add cron job if there's at least 1 active network
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
needUpdateStaking && this.addCron('updateChainStakingMetadata', this.updateChainStakingMetadata(serviceInfo.chainInfoMap, serviceInfo.chainStateMap, serviceInfo.chainApiMap.substrate), CRON_REFRESH_CHAIN_STAKING_METADATA);
|
|
109
|
+
this.addCron('refreshNft', this.refreshNft(address, serviceInfo.chainApiMap, this.state.getSmartContractNfts(), this.state.getActiveChainInfoMap()), CRON_REFRESH_NFT_INTERVAL);
|
|
110
|
+
this.addCron('recoverApiMap', this.recoverApiMap, CRON_AUTO_RECOVER_DOTSAMA_INTERVAL, false);
|
|
111
|
+
this.addCron('refreshStakingReward', this.refreshStakingReward(address), CRON_REFRESH_STAKING_REWARD_INTERVAL);
|
|
112
|
+
this.addCron('refreshPoolingStakingReward', this.refreshStakingRewardFastInterval(address), CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL);
|
|
113
|
+
this.addCron('updateChainStakingMetadata', this.updateChainStakingMetadata(serviceInfo.chainInfoMap, serviceInfo.chainStateMap, serviceInfo.chainApiMap.substrate), CRON_REFRESH_CHAIN_STAKING_METADATA);
|
|
114
|
+
this.addCron('updateNominatorMetadata', this.updateNominatorMetadata(address, serviceInfo.chainInfoMap, serviceInfo.chainStateMap, serviceInfo.chainApiMap.substrate), CRON_REFRESH_CHAIN_NOMINATOR_METADATA);
|
|
145
115
|
} else {
|
|
146
116
|
this.setStakingRewardReady();
|
|
147
117
|
}
|
|
148
|
-
};
|
|
149
|
-
this.state.eventService.onLazy(this.eventHandler);
|
|
118
|
+
});
|
|
150
119
|
this.status = 'running';
|
|
151
120
|
};
|
|
152
121
|
stop = () => {
|
|
153
122
|
if (this.status === 'stopped') {
|
|
154
123
|
return;
|
|
155
124
|
}
|
|
156
|
-
|
|
157
|
-
// Unsubscribe events
|
|
158
|
-
if (this.eventHandler) {
|
|
159
|
-
this.state.eventService.offLazy(this.eventHandler);
|
|
160
|
-
this.eventHandler = undefined;
|
|
161
|
-
}
|
|
162
125
|
if (this.serviceSubscription) {
|
|
163
126
|
this.serviceSubscription.unsubscribe();
|
|
164
127
|
this.serviceSubscription = undefined;
|
|
@@ -167,36 +130,6 @@ export class KoniCron {
|
|
|
167
130
|
this.removeAllCrons();
|
|
168
131
|
this.status = 'stopped';
|
|
169
132
|
};
|
|
170
|
-
updateApiMapStatus = () => {
|
|
171
|
-
const apiMap = this.state.getApiMap();
|
|
172
|
-
const networkMap = this.state.getChainStateMap();
|
|
173
|
-
for (const [key, substrateApi] of Object.entries(apiMap.substrate)) {
|
|
174
|
-
let status = _ChainConnectionStatus.CONNECTING;
|
|
175
|
-
if (substrateApi.isApiConnected) {
|
|
176
|
-
status = _ChainConnectionStatus.CONNECTED;
|
|
177
|
-
}
|
|
178
|
-
if (!networkMap[key].connectionStatus) {
|
|
179
|
-
this.state.updateChainConnectionStatus(key, status);
|
|
180
|
-
} else if (networkMap[key].connectionStatus && networkMap[key].connectionStatus !== status) {
|
|
181
|
-
this.state.updateChainConnectionStatus(key, status);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
for (const [key, evmApi] of Object.entries(apiMap.evm)) {
|
|
185
|
-
evmApi.api.eth.net.isListening().then(() => {
|
|
186
|
-
if (!networkMap[key].connectionStatus) {
|
|
187
|
-
this.state.updateChainConnectionStatus(key, _ChainConnectionStatus.CONNECTED);
|
|
188
|
-
} else if (networkMap[key].connectionStatus && networkMap[key].connectionStatus !== _ChainConnectionStatus.CONNECTED) {
|
|
189
|
-
this.state.updateChainConnectionStatus(key, _ChainConnectionStatus.CONNECTED);
|
|
190
|
-
}
|
|
191
|
-
}).catch(() => {
|
|
192
|
-
if (!networkMap[key].connectionStatus) {
|
|
193
|
-
this.state.updateChainConnectionStatus(key, _ChainConnectionStatus.CONNECTING);
|
|
194
|
-
} else if (networkMap[key].connectionStatus && networkMap[key].connectionStatus !== _ChainConnectionStatus.CONNECTING) {
|
|
195
|
-
this.state.updateChainConnectionStatus(key, _ChainConnectionStatus.CONNECTING);
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
133
|
recoverApiMap = () => {
|
|
201
134
|
var _this$subscriptions;
|
|
202
135
|
const apiMap = this.state.getApiMap();
|
|
@@ -217,26 +150,28 @@ export class KoniCron {
|
|
|
217
150
|
};
|
|
218
151
|
refreshNft = (address, apiMap, smartContractNfts, chainInfoMap) => {
|
|
219
152
|
return () => {
|
|
220
|
-
|
|
153
|
+
this.logger.log('Refresh Nft state');
|
|
221
154
|
this.subscriptions.subscribeNft(address, apiMap.substrate, apiMap.evm, smartContractNfts, chainInfoMap);
|
|
222
155
|
};
|
|
223
156
|
};
|
|
224
157
|
resetNft = newAddress => {
|
|
158
|
+
this.logger.log('Reset Nft state');
|
|
225
159
|
this.state.resetNft(newAddress);
|
|
226
160
|
};
|
|
227
161
|
resetStakingReward = () => {
|
|
162
|
+
this.logger.log('Reset Staking Reward State');
|
|
228
163
|
this.state.resetStakingReward();
|
|
229
164
|
};
|
|
230
165
|
refreshStakingReward = address => {
|
|
231
166
|
return () => {
|
|
232
|
-
|
|
233
|
-
this.subscriptions.subscribeStakingReward(address).catch(this.logger.error);
|
|
167
|
+
this.logger.log('Fetching staking reward data');
|
|
168
|
+
this.subscriptions.subscribeStakingReward(address).then(() => this.logger.log('Refresh staking reward state')).catch(this.logger.error);
|
|
234
169
|
};
|
|
235
170
|
};
|
|
236
171
|
refreshStakingRewardFastInterval = address => {
|
|
237
172
|
return () => {
|
|
238
|
-
|
|
239
|
-
this.subscriptions.subscribeStakingRewardFastInterval(address).catch(this.logger.error);
|
|
173
|
+
this.logger.log('Fetching staking reward data with fast interval');
|
|
174
|
+
this.subscriptions.subscribeStakingRewardFastInterval(address).then(() => this.logger.log('Refresh staking reward state with fast interval')).catch(this.logger.error);
|
|
240
175
|
};
|
|
241
176
|
};
|
|
242
177
|
setStakingRewardReady = () => {
|
|
@@ -247,52 +182,14 @@ export class KoniCron {
|
|
|
247
182
|
};
|
|
248
183
|
updateChainStakingMetadata = (chainInfoMap, chainStateMap, substrateApiMap) => {
|
|
249
184
|
return () => {
|
|
250
|
-
|
|
251
|
-
this.subscriptions.fetchChainStakingMetadata(chainInfoMap, chainStateMap, substrateApiMap).catch(this.logger.error);
|
|
185
|
+
this.logger.log('Fetching chain staking metadata');
|
|
186
|
+
this.subscriptions.fetchChainStakingMetadata(chainInfoMap, chainStateMap, substrateApiMap).then(() => this.logger.log('Updated chain staking metadata')).catch(this.logger.error);
|
|
252
187
|
};
|
|
253
188
|
};
|
|
254
189
|
updateNominatorMetadata = (address, chainInfoMap, chainStateMap, substrateApiMap) => {
|
|
255
190
|
return () => {
|
|
256
|
-
|
|
257
|
-
this.subscriptions.fetchNominatorMetadata(address, chainInfoMap, chainStateMap, substrateApiMap).catch(this.logger.error);
|
|
191
|
+
this.logger.log('Fetching nominator data', address);
|
|
192
|
+
this.subscriptions.fetchNominatorMetadata(address, chainInfoMap, chainStateMap, substrateApiMap).then(() => this.logger.log('Updated nominator data', address)).catch(this.logger.error);
|
|
258
193
|
};
|
|
259
194
|
};
|
|
260
|
-
async reloadNft() {
|
|
261
|
-
const address = this.state.keyringService.currentAccount.address;
|
|
262
|
-
const serviceInfo = this.state.getServiceInfo();
|
|
263
|
-
console.debug('Hard refresh NFT for', address);
|
|
264
|
-
this.resetNft(address);
|
|
265
|
-
this.removeCron('refreshNft');
|
|
266
|
-
this.addCron('refreshNft', this.refreshNft(address, serviceInfo.chainApiMap, this.state.getSmartContractNfts(), this.state.getActiveChainInfoMap()), CRON_REFRESH_NFT_INTERVAL);
|
|
267
|
-
await waitTimeout(1800);
|
|
268
|
-
return true;
|
|
269
|
-
}
|
|
270
|
-
async reloadStaking() {
|
|
271
|
-
const address = this.state.keyringService.currentAccount.address;
|
|
272
|
-
console.debug('Hard refresh staking meta for', address);
|
|
273
|
-
this.resetStakingReward();
|
|
274
|
-
this.removeCron('refreshStakingReward');
|
|
275
|
-
this.removeCron('refreshPoolingStakingReward');
|
|
276
|
-
this.removeCron('updateNominatorMetadata');
|
|
277
|
-
this.addCron('refreshStakingReward', this.refreshStakingReward(address), CRON_REFRESH_STAKING_REWARD_INTERVAL);
|
|
278
|
-
this.addCron('refreshPoolingStakingReward', this.refreshStakingRewardFastInterval(address), CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL);
|
|
279
|
-
this.addCron('updateNominatorMetadata', this.updateNominatorMetadata(address, this.state.getChainInfoMap(), this.state.getChainStateMap(), this.state.getSubstrateApiMap()), CRON_REFRESH_CHAIN_NOMINATOR_METADATA);
|
|
280
|
-
await waitTimeout(1800);
|
|
281
|
-
return true;
|
|
282
|
-
}
|
|
283
|
-
needUpdateNft(chainInfoMap, updatedChains) {
|
|
284
|
-
if (updatedChains && updatedChains.length > 0) {
|
|
285
|
-
return updatedChains.some(updatedChain => {
|
|
286
|
-
const chainInfo = chainInfoMap[updatedChain];
|
|
287
|
-
return _isChainSupportNativeNft(chainInfo) || _isChainSupportEvmNft(chainInfo) || _isChainSupportWasmNft(chainInfo);
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
return false;
|
|
291
|
-
}
|
|
292
|
-
needUpdateStaking(chainInfoMap, updatedChains) {
|
|
293
|
-
if (updatedChains && updatedChains.length > 0) {
|
|
294
|
-
return updatedChains.some(updatedChain => _isChainSupportSubstrateStaking(chainInfoMap[updatedChain]));
|
|
295
|
-
}
|
|
296
|
-
return false;
|
|
297
|
-
}
|
|
298
195
|
}
|
|
@@ -40,6 +40,7 @@ export default class KoniExtension {
|
|
|
40
40
|
private accountsGetAllWithCurrentAddress;
|
|
41
41
|
private accountsGetAll;
|
|
42
42
|
private saveRecentAccountId;
|
|
43
|
+
private triggerAccountsSubscription;
|
|
43
44
|
private _getAuthListV2;
|
|
44
45
|
private authorizeSubscribeV2;
|
|
45
46
|
private getAuthListV2;
|
|
@@ -153,7 +154,7 @@ export default class KoniExtension {
|
|
|
153
154
|
private submitStakeWithdrawal;
|
|
154
155
|
private submitStakeClaimReward;
|
|
155
156
|
private submitCancelStakeWithdrawal;
|
|
156
|
-
private
|
|
157
|
+
private submitPoolingBonding;
|
|
157
158
|
private submitPoolingUnbonding;
|
|
158
159
|
private parseContractInput;
|
|
159
160
|
private submitTuringStakeCompounding;
|
|
@@ -178,6 +179,5 @@ export default class KoniExtension {
|
|
|
178
179
|
private getTransaction;
|
|
179
180
|
private subscribeTransactions;
|
|
180
181
|
private subscribeNotifications;
|
|
181
|
-
private reloadCron;
|
|
182
182
|
handle<TMessageType extends MessageTypes>(id: string, type: TMessageType, request: RequestTypes[TMessageType], port: chrome.runtime.Port): Promise<ResponseType<TMessageType>>;
|
|
183
183
|
}
|