@subwallet/extension-base 1.1.2-0 → 1.1.2-1

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 (77) hide show
  1. package/background/KoniTypes.d.ts +14 -4
  2. package/cjs/constants/i18n.js +10 -2
  3. package/cjs/koni/api/dotsama/transfer.js +6 -0
  4. package/cjs/koni/api/nft/acala_nft/index.js +0 -2
  5. package/cjs/koni/api/nft/bit.country/index.js +49 -18
  6. package/cjs/koni/api/nft/config.js +5 -3
  7. package/cjs/koni/api/nft/evm_nft/index.js +0 -5
  8. package/cjs/koni/api/nft/index.js +2 -3
  9. package/cjs/koni/api/nft/karura_nft/index.js +0 -2
  10. package/cjs/koni/api/nft/rmrk_nft/index.js +0 -4
  11. package/cjs/koni/api/nft/statemine_nft/index.js +0 -2
  12. package/cjs/koni/api/nft/unique_nft/index.js +0 -5
  13. package/cjs/koni/api/nft/wasm_nft/index.js +0 -5
  14. package/cjs/koni/api/staking/bonding/amplitude.js +6 -6
  15. package/cjs/koni/api/staking/bonding/astar.js +6 -6
  16. package/cjs/koni/api/staking/bonding/paraChain.js +5 -5
  17. package/cjs/koni/api/staking/bonding/relayChain.js +24 -14
  18. package/cjs/koni/api/staking/bonding/utils.js +1 -7
  19. package/cjs/koni/api/xcm/xTokens.js +1 -1
  20. package/cjs/koni/background/cron.js +2 -37
  21. package/cjs/koni/background/handlers/Extension.js +133 -123
  22. package/cjs/koni/background/handlers/State.js +6 -43
  23. package/cjs/koni/background/subscription.js +6 -88
  24. package/cjs/packageInfo.js +1 -1
  25. package/cjs/services/chain-service/constants.js +6 -4
  26. package/cjs/services/setting-service/constants.js +16 -6
  27. package/cjs/services/storage-service/DatabaseService.js +3 -0
  28. package/cjs/services/storage-service/db-stores/Nft.js +3 -0
  29. package/cjs/services/storage-service/db-stores/NominatorMetadata.js +3 -2
  30. package/cjs/utils/index.js +12 -0
  31. package/cjs/utils/translate.js +11 -0
  32. package/constants/i18n.d.ts +2 -1
  33. package/constants/i18n.js +8 -1
  34. package/koni/api/dotsama/transfer.js +6 -0
  35. package/koni/api/nft/acala_nft/index.js +0 -2
  36. package/koni/api/nft/bit.country/index.d.ts +1 -0
  37. package/koni/api/nft/bit.country/index.js +50 -19
  38. package/koni/api/nft/config.d.ts +2 -1
  39. package/koni/api/nft/config.js +2 -1
  40. package/koni/api/nft/evm_nft/index.js +0 -4
  41. package/koni/api/nft/index.d.ts +1 -1
  42. package/koni/api/nft/index.js +2 -3
  43. package/koni/api/nft/karura_nft/index.js +0 -2
  44. package/koni/api/nft/nft.d.ts +0 -1
  45. package/koni/api/nft/rmrk_nft/index.js +0 -4
  46. package/koni/api/nft/statemine_nft/index.js +0 -2
  47. package/koni/api/nft/unique_nft/index.js +0 -5
  48. package/koni/api/nft/wasm_nft/index.js +0 -4
  49. package/koni/api/staking/bonding/amplitude.js +6 -6
  50. package/koni/api/staking/bonding/astar.js +6 -6
  51. package/koni/api/staking/bonding/paraChain.js +5 -5
  52. package/koni/api/staking/bonding/relayChain.js +24 -14
  53. package/koni/api/staking/bonding/utils.js +1 -7
  54. package/koni/api/xcm/xTokens.js +1 -1
  55. package/koni/background/cron.d.ts +0 -5
  56. package/koni/background/cron.js +4 -39
  57. package/koni/background/handlers/Extension.d.ts +2 -0
  58. package/koni/background/handlers/Extension.js +25 -17
  59. package/koni/background/handlers/State.d.ts +2 -6
  60. package/koni/background/handlers/State.js +6 -43
  61. package/koni/background/subscription.d.ts +1 -4
  62. package/koni/background/subscription.js +9 -88
  63. package/package.json +11 -6
  64. package/packageInfo.js +1 -1
  65. package/services/chain-service/constants.d.ts +1 -0
  66. package/services/chain-service/constants.js +6 -4
  67. package/services/setting-service/constants.d.ts +6 -1
  68. package/services/setting-service/constants.js +10 -5
  69. package/services/storage-service/DatabaseService.d.ts +1 -0
  70. package/services/storage-service/DatabaseService.js +3 -0
  71. package/services/storage-service/db-stores/Nft.d.ts +1 -0
  72. package/services/storage-service/db-stores/Nft.js +3 -0
  73. package/services/storage-service/db-stores/NominatorMetadata.js +3 -2
  74. package/utils/index.d.ts +1 -0
  75. package/utils/index.js +2 -1
  76. package/utils/translate.d.ts +1 -0
  77. package/utils/translate.js +4 -0
@@ -72,7 +72,6 @@ class KoniCron {
72
72
  const serviceInfo = this.state.getServiceInfo();
73
73
  const commonReload = eventTypes.some(eventType => commonReloadEvents.includes(eventType));
74
74
  const chainUpdated = eventTypes.includes('chain.updateState');
75
- const stakingSubmitted = eventTypes.includes('transaction.submitStaking');
76
75
  const reloadMantaPay = eventTypes.includes('mantaPay.submitTransaction') || eventTypes.includes('mantaPay.enable');
77
76
  const updatedChains = [];
78
77
  if (chainUpdated) {
@@ -83,7 +82,7 @@ class KoniCron {
83
82
  }
84
83
  });
85
84
  }
86
- if (!commonReload && !chainUpdated && !stakingSubmitted && !reloadMantaPay) {
85
+ if (!commonReload && !chainUpdated && !reloadMantaPay) {
87
86
  return;
88
87
  }
89
88
  const address = (_serviceInfo$currentA = serviceInfo.currentAccountInfo) === null || _serviceInfo$currentA === void 0 ? void 0 : _serviceInfo$currentA.address;
@@ -92,7 +91,6 @@ class KoniCron {
92
91
  }
93
92
  const chainInfoMap = serviceInfo.chainInfoMap;
94
93
  const needUpdateNft = this.needUpdateNft(chainInfoMap, updatedChains);
95
- const needUpdateStaking = this.needUpdateStaking(chainInfoMap, updatedChains);
96
94
 
97
95
  // MantaPay
98
96
  reloadMantaPay && this.removeCron('syncMantaPay');
@@ -101,19 +99,10 @@ class KoniCron {
101
99
  (commonReload || needUpdateNft) && this.resetNft(address);
102
100
  (commonReload || needUpdateNft) && this.removeCron('refreshNft');
103
101
 
104
- // Staking
105
- (commonReload || needUpdateStaking || stakingSubmitted) && this.resetStakingReward();
106
- (commonReload || needUpdateStaking || stakingSubmitted) && this.removeCron('refreshStakingReward');
107
- (commonReload || needUpdateStaking || stakingSubmitted) && this.removeCron('refreshPoolingStakingReward');
108
- needUpdateStaking && this.removeCron('updateChainStakingMetadata');
109
-
110
102
  // Chains
111
103
  if (this.checkNetworkAvailable(serviceInfo)) {
112
104
  // only add cron job if there's at least 1 active network
113
105
  (commonReload || needUpdateNft) && this.addCron('refreshNft', this.refreshNft(address, serviceInfo.chainApiMap, this.state.getSmartContractNfts(), this.state.getActiveChainInfoMap()), _constants.CRON_REFRESH_NFT_INTERVAL);
114
- (commonReload || needUpdateStaking || stakingSubmitted) && this.addCron('refreshStakingReward', this.refreshStakingReward(address), _constants.CRON_REFRESH_STAKING_REWARD_INTERVAL);
115
- (commonReload || needUpdateStaking || stakingSubmitted) && this.addCron('refreshPoolingStakingReward', this.refreshStakingRewardFastInterval(address), _constants.CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL);
116
- needUpdateStaking && this.addCron('updateChainStakingMetadata', this.updateChainStakingMetadata(serviceInfo.chainInfoMap, serviceInfo.chainStateMap, serviceInfo.chainApiMap.substrate), _constants.CRON_REFRESH_CHAIN_STAKING_METADATA);
117
106
  reloadMantaPay && this.addCron('syncMantaPay', this.syncMantaPay, _constants.CRON_SYNC_MANTA_PAY);
118
107
  } else {
119
108
  this.setStakingRewardReady();
@@ -128,7 +117,6 @@ class KoniCron {
128
117
  this.addCron('refreshNft', this.refreshNft(currentAccountInfo.address, this.state.getApiMap(), this.state.getSmartContractNfts(), this.state.getActiveChainInfoMap()), _constants.CRON_REFRESH_NFT_INTERVAL);
129
118
  this.addCron('refreshStakingReward', this.refreshStakingReward(currentAccountInfo.address), _constants.CRON_REFRESH_STAKING_REWARD_INTERVAL);
130
119
  this.addCron('refreshPoolingStakingReward', this.refreshStakingRewardFastInterval(currentAccountInfo.address), _constants.CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL);
131
- this.addCron('updateChainStakingMetadata', this.updateChainStakingMetadata(this.state.getChainInfoMap(), this.state.getChainStateMap(), this.state.getSubstrateApiMap()), _constants.CRON_REFRESH_CHAIN_STAKING_METADATA);
132
120
  this.addCron('syncMantaPay', this.syncMantaPay, _constants.CRON_SYNC_MANTA_PAY);
133
121
  } else {
134
122
  this.setStakingRewardReady();
@@ -166,9 +154,6 @@ class KoniCron {
166
154
  resetNft = newAddress => {
167
155
  this.state.resetNft(newAddress);
168
156
  };
169
- resetStakingReward = () => {
170
- this.state.resetStakingReward();
171
- };
172
157
  refreshStakingReward = address => {
173
158
  return () => {
174
159
  this.subscriptions.subscribeStakingReward(address).catch(this.logger.error);
@@ -185,16 +170,6 @@ class KoniCron {
185
170
  checkNetworkAvailable = serviceInfo => {
186
171
  return Object.keys(serviceInfo.chainApiMap.substrate).length > 0 || Object.keys(serviceInfo.chainApiMap.evm).length > 0;
187
172
  };
188
- updateChainStakingMetadata = (chainInfoMap, chainStateMap, substrateApiMap) => {
189
- return () => {
190
- this.subscriptions.fetchChainStakingMetadata(chainInfoMap, chainStateMap, substrateApiMap).catch(this.logger.error);
191
- };
192
- };
193
- updateNominatorMetadata = (address, chainInfoMap, chainStateMap, substrateApiMap) => {
194
- return () => {
195
- this.subscriptions.fetchNominatorMetadata(address, chainInfoMap, chainStateMap, substrateApiMap).catch(this.logger.error);
196
- };
197
- };
198
173
  async reloadNft() {
199
174
  const address = this.state.keyringService.currentAccount.address;
200
175
  const serviceInfo = this.state.getServiceInfo();
@@ -206,11 +181,7 @@ class KoniCron {
206
181
  }
207
182
  async reloadStaking() {
208
183
  const address = this.state.keyringService.currentAccount.address;
209
- this.resetStakingReward();
210
- this.removeCron('refreshStakingReward');
211
- this.removeCron('refreshPoolingStakingReward');
212
- this.addCron('refreshStakingReward', this.refreshStakingReward(address), _constants.CRON_REFRESH_STAKING_REWARD_INTERVAL);
213
- this.addCron('refreshPoolingStakingReward', this.refreshStakingRewardFastInterval(address), _constants.CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL);
184
+ console.log('reload staking', address);
214
185
  await (0, _utils2.waitTimeout)(1800);
215
186
  return true;
216
187
  }
@@ -223,11 +194,5 @@ class KoniCron {
223
194
  }
224
195
  return false;
225
196
  }
226
- needUpdateStaking(chainInfoMap, updatedChains) {
227
- if (updatedChains && updatedChains.length > 0) {
228
- return updatedChains.some(updatedChain => (0, _utils._isChainSupportSubstrateStaking)(chainInfoMap[updatedChain]));
229
- }
230
- return false;
231
- }
232
197
  }
233
198
  exports.KoniCron = KoniCron;