@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.
Files changed (220) hide show
  1. package/background/KoniTypes.d.ts +25 -36
  2. package/background/KoniTypes.js +12 -7
  3. package/background/errors/TransactionError.js +21 -1
  4. package/cjs/background/KoniTypes.js +14 -8
  5. package/cjs/background/errors/TransactionError.js +20 -0
  6. package/cjs/constants/index.js +13 -28
  7. package/cjs/koni/api/dotsama/balance.js +60 -224
  8. package/cjs/koni/api/dotsama/transfer.js +30 -29
  9. package/cjs/koni/api/nft/acala_nft/index.js +4 -1
  10. package/cjs/koni/api/nft/bit.country/index.js +4 -1
  11. package/cjs/koni/api/nft/evm_nft/index.js +7 -3
  12. package/cjs/koni/api/nft/index.js +3 -6
  13. package/cjs/koni/api/nft/karura_nft/index.js +4 -1
  14. package/cjs/koni/api/nft/rmrk_nft/index.js +8 -1
  15. package/cjs/koni/api/nft/statemine_nft/index.js +4 -1
  16. package/cjs/koni/api/nft/unique_nft/index.js +6 -1
  17. package/cjs/koni/api/nft/wasm_nft/index.js +169 -111
  18. package/cjs/koni/api/nft/wasm_nft/utils.js +11 -7
  19. package/cjs/koni/api/staking/bonding/amplitude.js +18 -10
  20. package/cjs/koni/api/staking/bonding/astar.js +37 -238
  21. package/cjs/koni/api/staking/bonding/index.js +26 -14
  22. package/cjs/koni/api/staking/bonding/paraChain.js +100 -11
  23. package/cjs/koni/api/staking/bonding/relayChain.js +174 -16
  24. package/cjs/koni/api/staking/bonding/utils.js +55 -10
  25. package/cjs/koni/api/tokens/wasm/index.js +5 -4
  26. package/cjs/koni/api/tokens/wasm/utils.js +63 -0
  27. package/cjs/koni/api/xcm/index.js +0 -111
  28. package/cjs/koni/api/xcm/polkadotXcm.js +2 -2
  29. package/cjs/koni/api/xcm/utils.js +18 -13
  30. package/cjs/koni/api/xcm/xTokens.js +3 -5
  31. package/cjs/koni/api/xcm/xcmPallet.js +9 -6
  32. package/cjs/koni/background/cron.js +179 -77
  33. package/cjs/koni/background/handlers/Extension.js +231 -195
  34. package/cjs/koni/background/handlers/State.js +147 -111
  35. package/cjs/koni/background/handlers/Tabs.js +48 -39
  36. package/cjs/koni/background/subscription.js +64 -56
  37. package/cjs/packageInfo.js +1 -1
  38. package/cjs/page/index.js +5 -0
  39. package/cjs/services/chain-service/constants.js +1 -11
  40. package/cjs/services/chain-service/handler/SubstrateChainHandler.js +13 -8
  41. package/cjs/services/chain-service/handler/light-client/index.js +2 -0
  42. package/cjs/services/chain-service/index.js +39 -6
  43. package/cjs/services/chain-service/utils.js +4 -0
  44. package/cjs/services/event-service/index.js +75 -0
  45. package/cjs/services/event-service/types.js +11 -0
  46. package/cjs/services/history-service/index.js +46 -21
  47. package/cjs/services/history-service/subsquid-multi-chain-history.js +19 -11
  48. package/cjs/services/keyring-service/index.js +101 -0
  49. package/cjs/services/migration-service/index.js +13 -10
  50. package/cjs/{koni/migration/scripts/RemoveWrongCrowdloan.js → services/migration-service/scripts/AutoEnableChainsTokens.js} +11 -6
  51. package/cjs/services/migration-service/scripts/MigrateNetworkSettings.js +39 -19
  52. package/cjs/services/migration-service/scripts/MigrateSettings.js +31 -0
  53. package/cjs/services/migration-service/scripts/MigrateTransactionHistory.js +72 -0
  54. package/cjs/services/migration-service/scripts/index.js +13 -4
  55. package/cjs/services/price-service/coingecko.js +15 -3
  56. package/cjs/services/price-service/index.js +15 -18
  57. package/cjs/services/request-service/constants.js +8 -2
  58. package/cjs/services/request-service/handler/AuthRequestHandler.js +43 -12
  59. package/cjs/services/request-service/index.js +3 -0
  60. package/cjs/services/storage-service/DatabaseService.js +53 -34
  61. package/cjs/services/storage-service/databases/index.js +1 -1
  62. package/cjs/services/storage-service/db-stores/BaseStoreWithAddressAndChain.js +2 -8
  63. package/cjs/services/storage-service/db-stores/Nft.js +8 -18
  64. package/cjs/services/storage-service/db-stores/Transaction.js +10 -7
  65. package/cjs/services/subscan-service/index.js +107 -0
  66. package/cjs/services/subscan-service/subscan-chain-map.js +74 -0
  67. package/cjs/services/subscan-service/types.js +1 -0
  68. package/cjs/services/transaction-service/event-parser/index.js +20 -48
  69. package/cjs/services/transaction-service/index.js +66 -22
  70. package/cjs/services/transaction-service/utils.js +4 -6
  71. package/cjs/utils/address.js +9 -1
  72. package/cjs/utils/index.js +30 -26
  73. package/constants/index.d.ts +8 -13
  74. package/constants/index.js +8 -13
  75. package/koni/api/dotsama/balance.d.ts +0 -1
  76. package/koni/api/dotsama/balance.js +33 -197
  77. package/koni/api/dotsama/transfer.js +5 -4
  78. package/koni/api/nft/acala_nft/index.js +3 -1
  79. package/koni/api/nft/bit.country/index.js +3 -1
  80. package/koni/api/nft/evm_nft/index.js +6 -3
  81. package/koni/api/nft/index.d.ts +1 -2
  82. package/koni/api/nft/index.js +3 -6
  83. package/koni/api/nft/karura_nft/index.js +3 -1
  84. package/koni/api/nft/nft.d.ts +1 -0
  85. package/koni/api/nft/rmrk_nft/index.js +8 -1
  86. package/koni/api/nft/statemine_nft/index.js +3 -1
  87. package/koni/api/nft/unique_nft/index.js +5 -1
  88. package/koni/api/nft/wasm_nft/index.d.ts +0 -2
  89. package/koni/api/nft/wasm_nft/index.js +167 -109
  90. package/koni/api/nft/wasm_nft/utils.d.ts +7 -5
  91. package/koni/api/nft/wasm_nft/utils.js +7 -5
  92. package/koni/api/staking/bonding/amplitude.d.ts +1 -2
  93. package/koni/api/staking/bonding/amplitude.js +22 -13
  94. package/koni/api/staking/bonding/astar.d.ts +2 -11
  95. package/koni/api/staking/bonding/astar.js +39 -231
  96. package/koni/api/staking/bonding/index.d.ts +5 -2
  97. package/koni/api/staking/bonding/index.js +27 -17
  98. package/koni/api/staking/bonding/paraChain.d.ts +4 -1
  99. package/koni/api/staking/bonding/paraChain.js +101 -14
  100. package/koni/api/staking/bonding/relayChain.d.ts +6 -2
  101. package/koni/api/staking/bonding/relayChain.js +172 -17
  102. package/koni/api/staking/bonding/utils.d.ts +15 -2
  103. package/koni/api/staking/bonding/utils.js +53 -11
  104. package/koni/api/tokens/wasm/index.js +5 -4
  105. package/koni/api/tokens/wasm/utils.d.ts +6 -0
  106. package/koni/api/tokens/wasm/utils.js +54 -0
  107. package/koni/api/xcm/index.js +1 -112
  108. package/koni/api/xcm/polkadotXcm.js +3 -3
  109. package/koni/api/xcm/utils.d.ts +5 -6
  110. package/koni/api/xcm/utils.js +15 -10
  111. package/koni/api/xcm/xTokens.js +5 -7
  112. package/koni/api/xcm/xcmPallet.js +10 -9
  113. package/koni/background/cron.d.ts +6 -1
  114. package/koni/background/cron.js +179 -76
  115. package/koni/background/handlers/Extension.d.ts +2 -2
  116. package/koni/background/handlers/Extension.js +161 -125
  117. package/koni/background/handlers/State.d.ts +21 -20
  118. package/koni/background/handlers/State.js +144 -111
  119. package/koni/background/handlers/Tabs.js +30 -20
  120. package/koni/background/subscription.d.ts +1 -1
  121. package/koni/background/subscription.js +64 -58
  122. package/package.json +63 -18
  123. package/packageInfo.js +1 -1
  124. package/page/index.d.ts +2 -0
  125. package/page/index.js +4 -0
  126. package/services/chain-service/constants.d.ts +0 -1
  127. package/services/chain-service/constants.js +0 -9
  128. package/services/chain-service/handler/SubstrateChainHandler.js +14 -9
  129. package/services/chain-service/handler/light-client/index.d.ts +17 -1
  130. package/services/chain-service/handler/light-client/index.js +1 -1
  131. package/services/chain-service/helper/psp22_abi.json +1041 -881
  132. package/services/chain-service/helper/psp34_abi.json +2963 -1807
  133. package/services/chain-service/index.d.ts +6 -4
  134. package/services/chain-service/index.js +40 -9
  135. package/services/chain-service/utils.d.ts +1 -0
  136. package/services/chain-service/utils.js +3 -0
  137. package/services/event-service/index.d.ts +22 -0
  138. package/services/event-service/index.js +63 -0
  139. package/services/event-service/types.d.ts +28 -0
  140. package/services/event-service/types.js +4 -0
  141. package/services/history-service/index.d.ts +5 -3
  142. package/services/history-service/index.js +46 -21
  143. package/services/history-service/subsquid-multi-chain-history.js +22 -13
  144. package/services/keyring-service/index.d.ts +19 -0
  145. package/services/keyring-service/index.js +93 -0
  146. package/services/migration-service/index.js +11 -9
  147. package/services/migration-service/scripts/AutoEnableChainsTokens.d.ts +4 -0
  148. package/services/migration-service/scripts/AutoEnableChainsTokens.js +13 -0
  149. package/services/migration-service/scripts/MigrateNetworkSettings.js +37 -18
  150. package/services/migration-service/scripts/MigrateSettings.d.ts +4 -0
  151. package/services/migration-service/scripts/MigrateSettings.js +23 -0
  152. package/services/migration-service/scripts/MigrateTransactionHistory.d.ts +4 -0
  153. package/services/migration-service/scripts/MigrateTransactionHistory.js +64 -0
  154. package/services/migration-service/scripts/index.d.ts +1 -0
  155. package/services/migration-service/scripts/index.js +10 -3
  156. package/services/price-service/coingecko.js +15 -3
  157. package/services/price-service/index.d.ts +5 -3
  158. package/services/price-service/index.js +15 -18
  159. package/services/request-service/constants.d.ts +1 -0
  160. package/services/request-service/constants.js +6 -1
  161. package/services/request-service/handler/AuthRequestHandler.d.ts +8 -1
  162. package/services/request-service/handler/AuthRequestHandler.js +44 -13
  163. package/services/request-service/index.d.ts +7 -1
  164. package/services/request-service/index.js +3 -0
  165. package/services/storage-service/DatabaseService.d.ts +1 -0
  166. package/services/storage-service/DatabaseService.js +53 -34
  167. package/services/storage-service/databases/index.js +1 -1
  168. package/services/storage-service/db-stores/BaseStoreWithAddressAndChain.d.ts +1 -1
  169. package/services/storage-service/db-stores/BaseStoreWithAddressAndChain.js +2 -8
  170. package/services/storage-service/db-stores/Nft.d.ts +3 -3
  171. package/services/storage-service/db-stores/Nft.js +8 -17
  172. package/services/storage-service/db-stores/Transaction.js +10 -7
  173. package/services/subscan-service/index.d.ts +20 -0
  174. package/services/subscan-service/index.js +99 -0
  175. package/services/subscan-service/subscan-chain-map.d.ts +5 -0
  176. package/services/subscan-service/subscan-chain-map.js +63 -0
  177. package/services/subscan-service/types.d.ts +27 -0
  178. package/services/subscan-service/types.js +1 -0
  179. package/services/transaction-service/event-parser/index.d.ts +2 -2
  180. package/services/transaction-service/event-parser/index.js +21 -49
  181. package/services/transaction-service/index.d.ts +4 -2
  182. package/services/transaction-service/index.js +66 -22
  183. package/services/transaction-service/utils.js +5 -6
  184. package/utils/address.d.ts +1 -0
  185. package/utils/address.js +9 -2
  186. package/utils/index.d.ts +2 -1
  187. package/utils/index.js +26 -23
  188. package/cjs/background/errors/EvmRpcError.js +0 -21
  189. package/cjs/background/errors/SubWalletProviderError.js +0 -17
  190. package/cjs/constants/ethereum.js +0 -19
  191. package/cjs/errors/SubWalletProviderError.js +0 -17
  192. package/cjs/koni/api/xcm/astar.js +0 -160
  193. package/cjs/koni/api/xcm/moonbeamXcm.js +0 -80
  194. package/cjs/koni/api/xcm/statemintXcm.js +0 -197
  195. package/cjs/koni/api/xcm/substrateXcm.js +0 -213
  196. package/cjs/koni/migration/Base.js +0 -20
  197. package/cjs/koni/migration/index.js +0 -45
  198. package/cjs/koni/migration/scripts/ChangeRouteToHome.js +0 -22
  199. package/cjs/koni/migration/scripts/ClearOldStorage.js +0 -24
  200. package/cjs/koni/migration/scripts/RemoveWrongTransactionHistoriesFromStore.js +0 -36
  201. package/cjs/koni/migration/scripts/ResetTransactionHistoryEventIdx.js +0 -21
  202. package/cjs/koni/migration/scripts/index.js +0 -22
  203. package/cjs/koni/page/index.js +0 -16
  204. package/cjs/services/asset-service/index.js +0 -91
  205. package/cjs/services/storage-service/db-stores/ExtraDelegationInfo.js +0 -17
  206. package/cjs/stores/Balance.js +0 -18
  207. package/cjs/stores/Crowdloan.js +0 -18
  208. package/cjs/stores/CustomEvmToken.js +0 -18
  209. package/cjs/stores/NetworkMap.js +0 -18
  210. package/cjs/stores/Nft.js +0 -18
  211. package/cjs/stores/NftCollection.js +0 -18
  212. package/cjs/stores/Price.js +0 -18
  213. package/cjs/stores/Staking.js +0 -18
  214. package/cjs/stores/StakingReward.js +0 -18
  215. package/cjs/utils/eth/parseTransactionData.js +0 -284
  216. package/koni/page/index.d.ts +0 -2
  217. package/koni/page/index.js +0 -9
  218. /package/cjs/{koni/page → page}/SubWalleEvmProvider.js +0 -0
  219. /package/{koni/page → page}/SubWalleEvmProvider.d.ts +0 -0
  220. /package/{koni/page → page}/SubWalleEvmProvider.js +0 -0
@@ -216,31 +216,34 @@ export default class KoniTabs {
216
216
  const allAccounts = accountsObservable.subject.getValue();
217
217
  const accountList = transformAccountsV2(allAccounts, false, authInfo, 'evm').map(a => a.address);
218
218
  let accounts = [];
219
- this.#koniState.getCurrentAccount(({
220
- address
221
- }) => {
222
- if (address === ALL_ACCOUNT_KEY || !accountList.includes(address) || getAll) {
223
- accounts = accountList;
224
- } else if (address && accountList.includes(address)) {
225
- accounts = [address];
226
- }
227
- resolve(accounts);
228
- });
219
+ const address = this.#koniState.keyringService.currentAccount.address;
220
+ if (address === ALL_ACCOUNT_KEY || !accountList.includes(address) || getAll) {
221
+ accounts = accountList;
222
+ } else if (address && accountList.includes(address)) {
223
+ accounts = [address];
224
+ }
225
+ resolve(accounts);
229
226
  }).catch(console.error);
230
227
  });
231
228
  }
232
229
  async getEvmState(url) {
233
- let currentEvmNetworkKey;
230
+ let currentChain;
231
+ let autoActiveChain = false;
234
232
  if (url) {
235
233
  const authInfo = await this.getAuthInfo(url);
236
- currentEvmNetworkKey = authInfo === null || authInfo === void 0 ? void 0 : authInfo.currentEvmNetworkKey;
237
- }
238
- let currentEvmNetwork = currentEvmNetworkKey ? this.#koniState.getChainInfo(currentEvmNetworkKey) : undefined;
239
- if (currentEvmNetworkKey && !this.#koniState.getChainStateByKey(currentEvmNetworkKey).active) {
240
- currentEvmNetwork = Object.values(this.#koniState.getChainInfoMap()).find(network => {
241
- return network.evmInfo !== null && this.#koniState.getChainStateByKey(network.slug).active;
242
- });
234
+ if (authInfo !== null && authInfo !== void 0 && authInfo.currentEvmNetworkKey) {
235
+ currentChain = authInfo === null || authInfo === void 0 ? void 0 : authInfo.currentEvmNetworkKey;
236
+ }
237
+ if (authInfo !== null && authInfo !== void 0 && authInfo.isAllowed) {
238
+ autoActiveChain = true;
239
+ }
243
240
  }
241
+ const currentEvmNetwork = this.#koniState.requestService.getDAppChainInfo({
242
+ autoActive: autoActiveChain,
243
+ accessType: 'evm',
244
+ defaultChain: currentChain,
245
+ url
246
+ });
244
247
  if (currentEvmNetwork) {
245
248
  const {
246
249
  evmInfo,
@@ -252,13 +255,20 @@ export default class KoniTabs {
252
255
  if (!web3.currentProvider.connected) {
253
256
  console.log(`[Web3] ${slug} is disconnected, trying to connect...`);
254
257
  this.#koniState.refreshWeb3Api(slug);
258
+ let checkingNum = 0;
255
259
  const poll = resolve => {
260
+ checkingNum += 1;
256
261
  if (web3.currentProvider.connected) {
257
262
  console.log(`Network [${slug}] is connected.`);
258
263
  resolve(true);
259
264
  } else {
260
265
  console.log(`Connecting to network [${slug}]`);
261
- setTimeout(() => poll(resolve), 400);
266
+ if (checkingNum < 10) {
267
+ setTimeout(() => poll(resolve), 900);
268
+ } else {
269
+ console.log(`Max retry, stop checking [${slug}]`);
270
+ resolve(false);
271
+ }
262
272
  }
263
273
  };
264
274
  await new Promise(poll);
@@ -437,7 +447,7 @@ export default class KoniTabs {
437
447
  currentAccountList = newAccountList;
438
448
  }
439
449
  };
440
- const accountListSubscription = this.#koniState.subscribeCurrentAccount().subscribe(() => {
450
+ const accountListSubscription = this.#koniState.keyringService.currentAccountSubject.subscribe(() => {
441
451
  onCurrentAccountChanged().catch(console.error);
442
452
  });
443
453
 
@@ -4,7 +4,7 @@ import DatabaseService from '@subwallet/extension-base/services/storage-service/
4
4
  import KoniState from './handlers/State';
5
5
  declare type SubscriptionName = 'balance' | 'crowdloan' | 'stakingOnChain';
6
6
  export declare class KoniSubscription {
7
- private serviceSubscription;
7
+ private eventHandler?;
8
8
  private subscriptionMap;
9
9
  dbService: DatabaseService;
10
10
  private state;
@@ -10,8 +10,10 @@ import { getRelayChainPoolMemberMetadata } from '@subwallet/extension-base/koni/
10
10
  import { getAmplitudeUnclaimedStakingReward } from '@subwallet/extension-base/koni/api/staking/paraChain';
11
11
  import { nftHandler } from '@subwallet/extension-base/koni/background/handlers';
12
12
  import { _STAKING_CHAIN_GROUP } from '@subwallet/extension-base/services/chain-service/constants';
13
- import { _isChainEnabled, _isChainSupportSubstrateStaking, _isSubstrateRelayChain } from '@subwallet/extension-base/services/chain-service/utils';
13
+ import { _isChainEnabled, _isChainEvmCompatible, _isChainSupportSubstrateStaking, _isSubstrateRelayChain } from '@subwallet/extension-base/services/chain-service/utils';
14
+ import { COMMON_RELOAD_EVENTS } from '@subwallet/extension-base/services/event-service/types';
14
15
  import { logger as createLogger } from '@polkadot/util';
16
+ import { isEthereumAddress } from '@polkadot/util-crypto';
15
17
  export class KoniSubscription {
16
18
  subscriptionMap = {
17
19
  crowdloan: undefined,
@@ -50,34 +52,35 @@ export class KoniSubscription {
50
52
  }
51
53
  }
52
54
  start() {
55
+ var _this$state$keyringSe;
53
56
  this.logger.log('Starting subscription');
54
- this.state.getCurrentAccount(currentAccountInfo => {
55
- if (currentAccountInfo) {
56
- const {
57
- address
58
- } = currentAccountInfo;
59
- this.subscribeBalancesAndCrowdloans(address, this.state.getChainInfoMap(), this.state.getChainStateMap(), this.state.getSubstrateApiMap(), this.state.getEvmApiMap());
60
- this.subscribeStakingOnChain(address, this.state.getSubstrateApiMap());
57
+ const currentAddress = (_this$state$keyringSe = this.state.keyringService.currentAccount) === null || _this$state$keyringSe === void 0 ? void 0 : _this$state$keyringSe.address;
58
+ if (currentAddress) {
59
+ this.subscribeBalancesAndCrowdloans(currentAddress, this.state.getChainInfoMap(), this.state.getChainStateMap(), this.state.getSubstrateApiMap(), this.state.getEvmApiMap());
60
+ this.subscribeStakingOnChain(currentAddress, this.state.getSubstrateApiMap());
61
+ }
62
+ this.eventHandler = (events, eventTypes) => {
63
+ var _serviceInfo$currentA;
64
+ const serviceInfo = this.state.getServiceInfo();
65
+ const needReload = eventTypes.some(eventType => COMMON_RELOAD_EVENTS.includes(eventType));
66
+ if (!needReload) {
67
+ return;
61
68
  }
62
- });
63
- !this.serviceSubscription && (this.serviceSubscription = this.state.subscribeServiceInfo().subscribe({
64
- next: serviceInfo => {
65
- var _serviceInfo$currentA;
66
- this.logger.log('ServiceInfo updated, restarting...');
67
- const address = (_serviceInfo$currentA = serviceInfo.currentAccountInfo) === null || _serviceInfo$currentA === void 0 ? void 0 : _serviceInfo$currentA.address;
68
- if (!address) {
69
- return;
70
- }
71
- this.subscribeBalancesAndCrowdloans(address, serviceInfo.chainInfoMap, serviceInfo.chainStateMap, serviceInfo.chainApiMap.substrate, serviceInfo.chainApiMap.evm);
72
- this.subscribeStakingOnChain(address, serviceInfo.chainApiMap.substrate);
69
+ this.logger.log('ServiceInfo updated, restarting...');
70
+ const address = (_serviceInfo$currentA = serviceInfo.currentAccountInfo) === null || _serviceInfo$currentA === void 0 ? void 0 : _serviceInfo$currentA.address;
71
+ if (!address) {
72
+ return;
73
73
  }
74
- }));
74
+ this.subscribeBalancesAndCrowdloans(address, serviceInfo.chainInfoMap, serviceInfo.chainStateMap, serviceInfo.chainApiMap.substrate, serviceInfo.chainApiMap.evm);
75
+ this.subscribeStakingOnChain(address, serviceInfo.chainApiMap.substrate);
76
+ };
77
+ this.state.eventService.onLazy(this.eventHandler);
75
78
  }
76
79
  stop() {
77
80
  this.logger.log('Stopping subscription');
78
- if (this.serviceSubscription) {
79
- this.serviceSubscription.unsubscribe();
80
- this.serviceSubscription = undefined;
81
+ if (this.eventHandler) {
82
+ this.state.eventService.offLazy(this.eventHandler);
83
+ this.eventHandler = undefined;
81
84
  }
82
85
  this.stopAllSubscription();
83
86
  }
@@ -103,25 +106,22 @@ export class KoniSubscription {
103
106
  });
104
107
  }
105
108
  subscribeBalancesAndCrowdloans(address, chainInfoMap, chainStateMap, substrateApiMap, web3ApiMap, onlyRunOnFirstTime) {
106
- this.state.switchAccount(address).then(() => {
107
- this.state.getDecodedAddresses(address).then(addresses => {
108
- if (!addresses.length) {
109
- return;
110
- }
111
- this.updateSubscription('balance', this.initBalanceSubscription(addresses, chainInfoMap, chainStateMap, substrateApiMap, web3ApiMap, onlyRunOnFirstTime));
112
- this.updateSubscription('crowdloan', this.initCrowdloanSubscription(addresses, substrateApiMap, onlyRunOnFirstTime));
113
- }).catch(this.logger.error);
109
+ this.state.handleSwitchAccount(address).then(() => {
110
+ const addresses = this.state.getDecodedAddresses(address);
111
+ if (!addresses.length) {
112
+ return;
113
+ }
114
+ this.updateSubscription('balance', this.initBalanceSubscription(addresses, chainInfoMap, chainStateMap, substrateApiMap, web3ApiMap, onlyRunOnFirstTime));
115
+ this.updateSubscription('crowdloan', this.initCrowdloanSubscription(addresses, substrateApiMap, onlyRunOnFirstTime));
114
116
  }).catch(err => this.logger.warn(err));
115
117
  }
116
118
  subscribeStakingOnChain(address, substrateApiMap, onlyRunOnFirstTime) {
117
- this.state.resetStaking(address).then(() => {
118
- this.state.getDecodedAddresses(address).then(addresses => {
119
- if (!addresses.length) {
120
- return;
121
- }
122
- this.updateSubscription('stakingOnChain', this.initStakingOnChainSubscription(addresses, substrateApiMap, onlyRunOnFirstTime));
123
- }).catch(this.logger.error);
124
- }).catch(err => this.logger.warn(err));
119
+ this.state.resetStaking(address);
120
+ const addresses = this.state.getDecodedAddresses(address);
121
+ if (!addresses.length) {
122
+ return;
123
+ }
124
+ this.updateSubscription('stakingOnChain', this.initStakingOnChainSubscription(addresses, substrateApiMap, onlyRunOnFirstTime));
125
125
  }
126
126
  initStakingOnChainSubscription(addresses, substrateApiMap, onlyRunOnFirstTime) {
127
127
  const unsub = stakingOnChainApi(addresses, substrateApiMap, (networkKey, rs) => {
@@ -137,9 +137,9 @@ export class KoniSubscription {
137
137
  }
138
138
  initBalanceSubscription(addresses, chainInfoMap, chainStateMap, substrateApiMap, evmApiMap, onlyRunOnFirstTime) {
139
139
  const filteredChainInfoMap = {};
140
- Object.values(chainInfoMap).forEach(chainInfo => {
141
- if (chainStateMap[chainInfo.slug].active) {
142
- filteredChainInfoMap[chainInfo.slug] = chainInfo;
140
+ Object.values(chainStateMap).forEach(chainState => {
141
+ if (chainState.active) {
142
+ filteredChainInfoMap[chainState.slug] = chainInfoMap[chainState.slug];
143
143
  }
144
144
  });
145
145
  const unsub = subscribeBalance(addresses, filteredChainInfoMap, substrateApiMap, evmApiMap, result => {
@@ -166,24 +166,21 @@ export class KoniSubscription {
166
166
  };
167
167
  }
168
168
  subscribeNft(address, substrateApiMap, evmApiMap, smartContractNfts, chainInfoMap) {
169
- this.state.getDecodedAddresses(address).then(addresses => {
170
- if (!addresses.length) {
171
- return;
172
- }
173
- this.initNftSubscription(addresses, substrateApiMap, evmApiMap, smartContractNfts, chainInfoMap);
174
- }).catch(this.logger.error);
169
+ const addresses = this.state.getDecodedAddresses(address);
170
+ if (!addresses.length) {
171
+ return;
172
+ }
173
+ this.initNftSubscription(addresses, substrateApiMap, evmApiMap, smartContractNfts, chainInfoMap);
175
174
  }
176
175
  initNftSubscription(addresses, substrateApiMap, evmApiMap, smartContractNfts, chainInfoMap) {
177
176
  nftHandler.setChainInfoMap(chainInfoMap);
178
177
  nftHandler.setDotSamaApiMap(substrateApiMap);
179
178
  nftHandler.setWeb3ApiMap(evmApiMap);
180
179
  nftHandler.setAddresses(addresses);
181
- nftHandler.handleNfts(smartContractNfts, (...args) => this.state.updateNftData(...args), (...args) => this.state.setNftCollection(...args)).then(() => {
182
- this.logger.log('nft state updated');
183
- }).catch(this.logger.log);
180
+ nftHandler.handleNfts(smartContractNfts, (...args) => this.state.updateNftData(...args), (...args) => this.state.setNftCollection(...args), (...args) => this.state.cleanUpNfts(...args)).catch(this.logger.log);
184
181
  }
185
182
  async subscribeStakingReward(address) {
186
- const addresses = await this.state.getDecodedAddresses(address);
183
+ const addresses = this.state.getDecodedAddresses(address);
187
184
  if (!addresses.length) {
188
185
  return;
189
186
  }
@@ -197,10 +194,9 @@ export class KoniSubscription {
197
194
  });
198
195
  const result = await getNominationStakingRewardData(addresses, targetNetworkMap);
199
196
  this.state.updateStakingReward(result, 'slowInterval');
200
- this.logger.log('Set staking reward state done', result);
201
197
  }
202
198
  async subscribeStakingRewardFastInterval(address) {
203
- const addresses = await this.state.getDecodedAddresses(address);
199
+ const addresses = this.state.getDecodedAddresses(address);
204
200
  if (!addresses.length) {
205
201
  return;
206
202
  }
@@ -226,15 +222,21 @@ export class KoniSubscription {
226
222
  const [poolingStakingRewards, amplitudeUnclaimedStakingRewards] = await Promise.all([getPoolingStakingRewardData(pooledAddresses, targetChainMap, this.state.getSubstrateApiMap()), getAmplitudeUnclaimedStakingReward(this.state.getSubstrateApiMap(), addresses, chainInfoMap, activeNetworks)]);
227
223
  const result = [...poolingStakingRewards, ...amplitudeUnclaimedStakingRewards];
228
224
  this.state.updateStakingReward(result, 'fastInterval');
229
- this.logger.log('Set staking reward state with fast interval done', result);
230
225
  }
231
226
  async fetchChainStakingMetadata(chainInfoMap, chainStateMap, substrateApiMap) {
232
- await Promise.all(Object.values(chainInfoMap).map(async chainInfo => {
227
+ const filteredChainInfoMap = {};
228
+ Object.values(chainInfoMap).forEach(chainInfo => {
233
229
  const chainState = chainStateMap[chainInfo.slug];
234
230
  if (chainState !== null && chainState !== void 0 && chainState.active && _isChainSupportSubstrateStaking(chainInfo)) {
235
- const chainStakingMetadata = await getChainStakingMetadata(chainInfo.slug, substrateApiMap[chainInfo.slug]);
236
- this.state.updateChainStakingMetadata(chainStakingMetadata);
231
+ filteredChainInfoMap[chainInfo.slug] = chainInfo;
237
232
  }
233
+ });
234
+ if (Object.values(filteredChainInfoMap).length === 0) {
235
+ return;
236
+ }
237
+ await Promise.all(Object.values(filteredChainInfoMap).map(async chainInfo => {
238
+ const chainStakingMetadata = await getChainStakingMetadata(chainInfo, substrateApiMap[chainInfo.slug]);
239
+ this.state.updateChainStakingMetadata(chainStakingMetadata);
238
240
  }));
239
241
  }
240
242
  async fetchNominatorMetadata(currentAddress, chainInfoMap, chainStateMap, substrateApiMap) {
@@ -250,7 +252,11 @@ export class KoniSubscription {
250
252
  addresses = await this.state.getStakingOwnersByChains(Object.keys(filteredChainInfoMap));
251
253
  }
252
254
  await Promise.all(addresses.map(async address => {
255
+ const isEvmAddress = isEthereumAddress(address);
253
256
  await Promise.all(Object.values(filteredChainInfoMap).map(async chainInfo => {
257
+ if (isEvmAddress && !_isChainEvmCompatible(chainInfo)) {
258
+ return;
259
+ }
254
260
  if (_isSubstrateRelayChain(chainInfo) && _STAKING_CHAIN_GROUP.nominationPool.includes(chainInfo.slug)) {
255
261
  const poolMemberMetadata = await getRelayChainPoolMemberMetadata(chainInfo, address, substrateApiMap[chainInfo.slug]);
256
262
  if (poolMemberMetadata) {
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "./cjs/detectPackage.js"
18
18
  ],
19
19
  "type": "module",
20
- "version": "1.0.1",
20
+ "version": "1.0.2-1b",
21
21
  "main": "./cjs/index.js",
22
22
  "module": "./index.js",
23
23
  "types": "./index.d.ts",
@@ -369,6 +369,11 @@
369
369
  "require": "./cjs/koni/api/tokens/wasm/index.js",
370
370
  "default": "./koni/api/tokens/wasm/index.js"
371
371
  },
372
+ "./koni/api/tokens/wasm/utils": {
373
+ "types": "./koni/api/tokens/wasm/utils.d.ts",
374
+ "require": "./cjs/koni/api/tokens/wasm/utils.js",
375
+ "default": "./koni/api/tokens/wasm/utils.js"
376
+ },
372
377
  "./koni/api/xcm": {
373
378
  "types": "./koni/api/xcm/index.d.ts",
374
379
  "require": "./cjs/koni/api/xcm/index.js",
@@ -434,16 +439,6 @@
434
439
  "require": "./cjs/koni/background/subscription.js",
435
440
  "default": "./koni/background/subscription.js"
436
441
  },
437
- "./koni/page": {
438
- "types": "./koni/page/index.d.ts",
439
- "require": "./cjs/koni/page/index.js",
440
- "default": "./koni/page/index.js"
441
- },
442
- "./koni/page/SubWalleEvmProvider": {
443
- "types": "./koni/page/SubWalleEvmProvider.d.ts",
444
- "require": "./cjs/koni/page/SubWalleEvmProvider.js",
445
- "default": "./koni/page/SubWalleEvmProvider.js"
446
- },
447
442
  "./package.json": "./package.json",
448
443
  "./packageInfo.js": {
449
444
  "types": "./packageInfo.d.ts",
@@ -485,6 +480,11 @@
485
480
  "require": "./cjs/page/Signer.js",
486
481
  "default": "./page/Signer.js"
487
482
  },
483
+ "./page/SubWalleEvmProvider": {
484
+ "types": "./page/SubWalleEvmProvider.d.ts",
485
+ "require": "./cjs/page/SubWalleEvmProvider.js",
486
+ "default": "./page/SubWalleEvmProvider.js"
487
+ },
488
488
  "./page/types": {
489
489
  "types": "./page/types.d.ts",
490
490
  "require": "./cjs/page/types.js",
@@ -1170,6 +1170,16 @@
1170
1170
  "require": "./cjs/services/chain-service/utils.js",
1171
1171
  "default": "./services/chain-service/utils.js"
1172
1172
  },
1173
+ "./services/event-service": {
1174
+ "types": "./services/event-service/index.d.ts",
1175
+ "require": "./cjs/services/event-service/index.js",
1176
+ "default": "./services/event-service/index.js"
1177
+ },
1178
+ "./services/event-service/types": {
1179
+ "types": "./services/event-service/types.d.ts",
1180
+ "require": "./cjs/services/event-service/types.js",
1181
+ "default": "./services/event-service/types.js"
1182
+ },
1173
1183
  "./services/history-service": {
1174
1184
  "types": "./services/history-service/index.d.ts",
1175
1185
  "require": "./cjs/services/history-service/index.js",
@@ -1180,6 +1190,11 @@
1180
1190
  "require": "./cjs/services/history-service/subsquid-multi-chain-history.js",
1181
1191
  "default": "./services/history-service/subsquid-multi-chain-history.js"
1182
1192
  },
1193
+ "./services/keyring-service": {
1194
+ "types": "./services/keyring-service/index.d.ts",
1195
+ "require": "./cjs/services/keyring-service/index.js",
1196
+ "default": "./services/keyring-service/index.js"
1197
+ },
1183
1198
  "./services/migration-service": {
1184
1199
  "types": "./services/migration-service/index.d.ts",
1185
1200
  "require": "./cjs/services/migration-service/index.js",
@@ -1195,6 +1210,11 @@
1195
1210
  "require": "./cjs/services/migration-service/scripts/index.js",
1196
1211
  "default": "./services/migration-service/scripts/index.js"
1197
1212
  },
1213
+ "./services/migration-service/scripts/AutoEnableChainsTokens": {
1214
+ "types": "./services/migration-service/scripts/AutoEnableChainsTokens.d.ts",
1215
+ "require": "./cjs/services/migration-service/scripts/AutoEnableChainsTokens.js",
1216
+ "default": "./services/migration-service/scripts/AutoEnableChainsTokens.js"
1217
+ },
1198
1218
  "./services/migration-service/scripts/ClearOldStorage": {
1199
1219
  "types": "./services/migration-service/scripts/ClearOldStorage.d.ts",
1200
1220
  "require": "./cjs/services/migration-service/scripts/ClearOldStorage.js",
@@ -1210,6 +1230,16 @@
1210
1230
  "require": "./cjs/services/migration-service/scripts/MigrateNetworkSettings.js",
1211
1231
  "default": "./services/migration-service/scripts/MigrateNetworkSettings.js"
1212
1232
  },
1233
+ "./services/migration-service/scripts/MigrateSettings": {
1234
+ "types": "./services/migration-service/scripts/MigrateSettings.d.ts",
1235
+ "require": "./cjs/services/migration-service/scripts/MigrateSettings.js",
1236
+ "default": "./services/migration-service/scripts/MigrateSettings.js"
1237
+ },
1238
+ "./services/migration-service/scripts/MigrateTransactionHistory": {
1239
+ "types": "./services/migration-service/scripts/MigrateTransactionHistory.d.ts",
1240
+ "require": "./cjs/services/migration-service/scripts/MigrateTransactionHistory.js",
1241
+ "default": "./services/migration-service/scripts/MigrateTransactionHistory.js"
1242
+ },
1213
1243
  "./services/notification-service/NotificationService": {
1214
1244
  "types": "./services/notification-service/NotificationService.d.ts",
1215
1245
  "require": "./cjs/services/notification-service/NotificationService.js",
@@ -1375,6 +1405,21 @@
1375
1405
  "require": "./cjs/services/storage-service/db-stores/Transaction.js",
1376
1406
  "default": "./services/storage-service/db-stores/Transaction.js"
1377
1407
  },
1408
+ "./services/subscan-service": {
1409
+ "types": "./services/subscan-service/index.d.ts",
1410
+ "require": "./cjs/services/subscan-service/index.js",
1411
+ "default": "./services/subscan-service/index.js"
1412
+ },
1413
+ "./services/subscan-service/subscan-chain-map": {
1414
+ "types": "./services/subscan-service/subscan-chain-map.d.ts",
1415
+ "require": "./cjs/services/subscan-service/subscan-chain-map.js",
1416
+ "default": "./services/subscan-service/subscan-chain-map.js"
1417
+ },
1418
+ "./services/subscan-service/types": {
1419
+ "types": "./services/subscan-service/types.d.ts",
1420
+ "require": "./cjs/services/subscan-service/types.js",
1421
+ "default": "./services/subscan-service/types.js"
1422
+ },
1378
1423
  "./services/transaction-service": {
1379
1424
  "types": "./services/transaction-service/index.d.ts",
1380
1425
  "require": "./cjs/services/transaction-service/index.js",
@@ -1611,12 +1656,12 @@
1611
1656
  "@sora-substrate/type-definitions": "^1.12.4",
1612
1657
  "@subsocial/types": "^0.6.8",
1613
1658
  "@substrate/connect": "^0.7.18",
1614
- "@subwallet/chain-list": "^0.0.21",
1615
- "@subwallet/extension-base": "^1.0.1",
1616
- "@subwallet/extension-chains": "^1.0.1",
1617
- "@subwallet/extension-dapp": "^1.0.1",
1618
- "@subwallet/extension-inject": "^1.0.1",
1619
- "@subwallet/keyring": "^0.0.4",
1659
+ "@subwallet/chain-list": "^0.0.30",
1660
+ "@subwallet/extension-base": "^1.0.2-1",
1661
+ "@subwallet/extension-chains": "^1.0.2-1",
1662
+ "@subwallet/extension-dapp": "^1.0.2-1",
1663
+ "@subwallet/extension-inject": "^1.0.2-1",
1664
+ "@subwallet/keyring": "^0.0.5",
1620
1665
  "@subwallet/ui-keyring": "^0.0.3",
1621
1666
  "@unique-nft/types": "^0.6.0-4",
1622
1667
  "@zeitgeistpm/type-defs": "^0.10.0",
@@ -1653,4 +1698,4 @@
1653
1698
  "web3-eth-contract": "^1.8.1",
1654
1699
  "web3-utils": "^1.8.1"
1655
1700
  }
1656
- }
1701
+ }
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.0.1'
10
+ version: '1.0.2-1'
11
11
  };
package/page/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { MessageTypes, MessageTypesWithNoSubscriptions, MessageTypesWithNullRequest, MessageTypesWithSubscriptions, RequestTypes, ResponseTypes, SubscriptionMessageTypes, TransportResponseMessage } from '../background/types';
2
+ import { EvmProvider } from '@subwallet/extension-inject/types';
2
3
  import Injected from './Injected';
3
4
  export interface Handler {
4
5
  resolve: (data?: any) => void;
@@ -13,3 +14,4 @@ export declare function enable(origin: string): Promise<Injected>;
13
14
  export declare function handleResponse<TMessageType extends MessageTypes>(data: TransportResponseMessage<TMessageType> & {
14
15
  subscription?: string;
15
16
  }): void;
17
+ export declare function initEvmProvider(version: string): EvmProvider;
package/page/index.js CHANGED
@@ -3,6 +3,7 @@
3
3
 
4
4
  import { ProviderError } from '@subwallet/extension-base/background/errors/ProviderError';
5
5
  import { ProviderErrorType } from '@subwallet/extension-base/background/KoniTypes';
6
+ import { SubWalletEvmProvider } from '@subwallet/extension-base/page/SubWalleEvmProvider';
6
7
  import { MESSAGE_ORIGIN_PAGE } from "../defaults.js";
7
8
  import { getId } from "../utils/getId.js";
8
9
  import Injected from "./Injected.js";
@@ -60,4 +61,7 @@ export function handleResponse(data) {
60
61
  } else {
61
62
  handler.resolve(data.response);
62
63
  }
64
+ }
65
+ export function initEvmProvider(version) {
66
+ return new SubWalletEvmProvider(sendMessage, version);
63
67
  }
@@ -69,7 +69,6 @@ export declare const _XCM_CHAIN_GROUP: {
69
69
  polkadotXcm: string[];
70
70
  xcmPallet: string[];
71
71
  };
72
- export declare const _XCM_CHAIN_USE_LIMITED_WEIGHT: string[];
73
72
  export declare const _XCM_TYPE: {
74
73
  RP: string;
75
74
  PP: string;
@@ -191,17 +191,8 @@ export const _XCM_CHAIN_GROUP = {
191
191
  polkadotXcm: ['astar', 'shiden', 'statemine', 'statemint'],
192
192
  xcmPallet: ['polkadot', 'kusama']
193
193
  // default is xTokens pallet
194
- // moonbeam: ['moonbeam', 'moonriver', 'moonbase'],
195
- // astar: ['astar', 'shiden'],
196
- // statemine: ['statemint', 'statemine'],
197
- // bifrost: ['bifrost'],
198
- // genshiro: ['genshiro_testnet', 'genshiro', 'equilibrium_parachain'],
199
- // kintsugi: ['kintsugi', 'kintsugi_test', 'interlay'],
200
- // acala: ['karura', 'acala', 'acala_testnet'],
201
- // astarEvm: ['astarEvm', 'shidenEvm']
202
194
  };
203
195
 
204
- export const _XCM_CHAIN_USE_LIMITED_WEIGHT = ['acala', 'karura', 'statemint'];
205
196
  export const _XCM_TYPE = {
206
197
  RP: `${_SubstrateChainType.RELAYCHAIN}-${_SubstrateChainType.PARACHAIN}`,
207
198
  // DMP
@@ -4,11 +4,12 @@
4
4
  import { options as acalaOptions } from '@acala-network/api';
5
5
  import { rpc as oakRpc, types as oakTypes } from '@oak-foundation/types';
6
6
  import { _AssetType } from '@subwallet/chain-list/types';
7
+ import { getDefaultWeightV2 } from '@subwallet/extension-base/koni/api/tokens/wasm/utils';
7
8
  import { getSubstrateConnectProvider } from '@subwallet/extension-base/services/chain-service/handler/light-client';
8
9
  import { ApiPromise, WsProvider } from '@polkadot/api';
9
10
  import { ContractPromise } from '@polkadot/api-contract';
10
11
  import { TypeRegistry } from '@polkadot/types/create';
11
- import { formatBalance, isTestChain, objectSpread, stringify } from '@polkadot/util';
12
+ import { BN, formatBalance, isTestChain, objectSpread, stringify } from '@polkadot/util';
12
13
  import { logger as createLogger } from '@polkadot/util/logger';
13
14
  import { defaults as addressDefaults } from '@polkadot/util-crypto/address/defaults';
14
15
  import { _API_OPTIONS_CHAIN_GROUP, API_AUTO_CONNECT_MS, API_MAX_RETRY } from "../constants.js";
@@ -87,13 +88,13 @@ export class SubstrateChainHandler {
87
88
  if (tokenType === _AssetType.PSP22) {
88
89
  tokenContract = new ContractPromise(substrateApi.api, _PSP22_ABI, contractAddress);
89
90
  const [nameResp, symbolResp, decimalsResp] = await Promise.all([tokenContract.query['psp22Metadata::tokenName'](contractCaller || contractAddress, {
90
- gasLimit: -1
91
+ gasLimit: getDefaultWeightV2(substrateApi.api)
91
92
  }),
92
93
  // read-only operation so no gas limit
93
94
  tokenContract.query['psp22Metadata::tokenSymbol'](contractCaller || contractAddress, {
94
- gasLimit: -1
95
+ gasLimit: getDefaultWeightV2(substrateApi.api)
95
96
  }), tokenContract.query['psp22Metadata::tokenDecimals'](contractCaller || contractAddress, {
96
- gasLimit: -1
97
+ gasLimit: getDefaultWeightV2(substrateApi.api)
97
98
  })]);
98
99
  if (!(nameResp.result.isOk && symbolResp.result.isOk && decimalsResp.result.isOk) || !nameResp.output || !decimalsResp.output || !symbolResp.output) {
99
100
  this.logger.error('Error response while validating WASM contract');
@@ -104,18 +105,22 @@ export class SubstrateChainHandler {
104
105
  contractError: true
105
106
  };
106
107
  } else {
107
- var _symbolResp$output, _decimalsResp$output, _symbolResp$output2;
108
- name = (_symbolResp$output = symbolResp.output) === null || _symbolResp$output === void 0 ? void 0 : _symbolResp$output.toHuman();
109
- decimals = parseInt((_decimalsResp$output = decimalsResp.output) === null || _decimalsResp$output === void 0 ? void 0 : _decimalsResp$output.toHuman());
110
- symbol = (_symbolResp$output2 = symbolResp.output) === null || _symbolResp$output2 === void 0 ? void 0 : _symbolResp$output2.toHuman();
108
+ var _symbolResp$output, _decimalsResp$output, _nameResp$output;
109
+ const symbolObj = (_symbolResp$output = symbolResp.output) === null || _symbolResp$output === void 0 ? void 0 : _symbolResp$output.toHuman();
110
+ const decimalsObj = (_decimalsResp$output = decimalsResp.output) === null || _decimalsResp$output === void 0 ? void 0 : _decimalsResp$output.toHuman();
111
+ const nameObj = (_nameResp$output = nameResp.output) === null || _nameResp$output === void 0 ? void 0 : _nameResp$output.toHuman();
112
+ name = nameResp.output ? nameObj.Ok || nameObj.ok : '';
113
+ decimals = decimalsResp.output ? new BN(decimalsObj.Ok || decimalsObj.ok).toNumber() : 0;
114
+ symbol = decimalsResp.output ? symbolObj.Ok || symbolObj.ok : '';
111
115
  if (name === '' || symbol === '') {
112
116
  contractError = true;
113
117
  }
118
+ console.log('validate PSP22', name, symbol, decimals);
114
119
  }
115
120
  } else {
116
121
  tokenContract = new ContractPromise(substrateApi.api, _PSP34_ABI, contractAddress);
117
122
  const collectionIdResp = await tokenContract.query['psp34::collectionId'](contractCaller || contractAddress, {
118
- gasLimit: -1
123
+ gasLimit: getDefaultWeightV2(substrateApi.api)
119
124
  }); // read-only operation so no gas limit
120
125
 
121
126
  if (!collectionIdResp.result.isOk || !collectionIdResp.output) {
@@ -1,4 +1,20 @@
1
- import { ProviderInterface } from '@polkadot/rpc-provider/types';
1
+ import { ScProvider } from '@polkadot/rpc-provider';
2
+ import { ProviderInterface, ProviderInterfaceCallback, ProviderInterfaceEmitCb, ProviderInterfaceEmitted } from '@polkadot/rpc-provider/types';
2
3
  export declare const relayChainSpecs: Record<string, string>;
3
4
  export declare const paraChainSpecs: Record<string, string>;
5
+ export declare class ProviderPlaceholder implements ProviderInterface {
6
+ private readonly providerPromise;
7
+ private provider?;
8
+ constructor(providerPromise: Promise<ScProvider>);
9
+ get hasSubscriptions(): boolean;
10
+ get isClonable(): boolean;
11
+ get isConnected(): boolean;
12
+ clone(): ProviderInterface;
13
+ connect(): Promise<void>;
14
+ disconnect(): Promise<void>;
15
+ on(type: ProviderInterfaceEmitted, sub: ProviderInterfaceEmitCb): () => void;
16
+ send<T = any>(method: string, params: unknown[], isCacheable?: boolean): Promise<T>;
17
+ subscribe(type: string, method: string, params: unknown[], cb: ProviderInterfaceCallback): Promise<number | string>;
18
+ unsubscribe(type: string, method: string, id: number | string): Promise<boolean>;
19
+ }
4
20
  export declare function getSubstrateConnectProvider(specLink: string): ProviderInterface;
@@ -16,7 +16,7 @@ export const paraChainSpecs = {
16
16
  'kusama/tinkernet': `${sourceFolderUrl}kusama/tinkernet.json`,
17
17
  'polkadot/astar': `${sourceFolderUrl}polkadot/astar.json`
18
18
  };
19
- class ProviderPlaceholder {
19
+ export class ProviderPlaceholder {
20
20
  constructor(providerPromise) {
21
21
  this.providerPromise = providerPromise;
22
22
  providerPromise.then(provider => {