@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
@@ -132,19 +132,16 @@ class NftHandler {
132
132
  console.error('error setting up nft handlers', e);
133
133
  }
134
134
  }
135
- async handleNfts(nftContracts, updateItem, updateCollection) {
135
+ async handleNfts(nftContracts, updateItem, updateCollection, cleanUpNfts) {
136
136
  this.setupApi();
137
137
  this.setupNftContracts(nftContracts);
138
138
  await Promise.all(this.handlers.map(async handler => {
139
139
  await handler.fetchNfts({
140
140
  updateItem,
141
- updateCollection
141
+ updateCollection,
142
+ cleanUpNfts
142
143
  });
143
144
  }));
144
145
  }
145
- parseAssetId(id) {
146
- const numberId = parseInt(id);
147
- return numberId.toString();
148
- }
149
146
  }
150
147
  exports.NftHandler = NftHandler;
@@ -122,8 +122,11 @@ class KaruraNftApi extends _nft.BaseNftApi {
122
122
  };
123
123
  params.updateItem(this.chain, parsedNft, address);
124
124
  params.updateCollection(this.chain, parsedCollection);
125
- // params.updateReady(true);
126
125
  }));
126
+ Object.entries(collectionNftIds).forEach(_ref2 => {
127
+ let [collectionId, nftIds] = _ref2;
128
+ params.cleanUpNfts(this.chain, address, collectionId, nftIds);
129
+ });
127
130
  } catch (e) {
128
131
  console.error('Failed to fetch karura nft', e);
129
132
  }
@@ -238,8 +238,15 @@ class RmrkNftApi extends _nft.BaseNftApi {
238
238
  image: allCollectionMeta[item.collectionId] ? this.parseUrl(allCollectionMeta[item.collectionId].image) : null,
239
239
  chain: this.chain
240
240
  };
241
+ const nftIds = [];
242
+ allNfts.forEach(nft => {
243
+ const nftCollectionId = nft === null || nft === void 0 ? void 0 : nft.collectionId;
244
+ if (nftCollectionId === item.collectionId) {
245
+ nftIds.push(nft === null || nft === void 0 ? void 0 : nft.id);
246
+ }
247
+ });
241
248
  params.updateCollection(this.chain, parsedCollection);
242
- // params.updateReady(true);
249
+ params.cleanUpNfts(this.chain, address, item.collectionId, nftIds);
243
250
  });
244
251
  } catch (e) {
245
252
  console.error('Failed to fetch rmrk nft', e);
@@ -122,8 +122,11 @@ class StatemineNftApi extends _nft.BaseNftApi {
122
122
  image: collectionMeta && collectionMeta.image ? this.parseUrl(collectionMeta === null || collectionMeta === void 0 ? void 0 : collectionMeta.image) : undefined
123
123
  };
124
124
  params.updateCollection(this.chain, parsedCollection);
125
- // params.updateReady(true);
126
125
  }));
126
+ Object.entries(collectionNftIds).forEach(_ref => {
127
+ let [collectionId, nftIds] = _ref;
128
+ params.cleanUpNfts(this.chain, address, collectionId, nftIds);
129
+ });
127
130
  } catch (e) {
128
131
  console.error('Failed to fetch statemine nft', e);
129
132
  }
@@ -141,6 +141,7 @@ class UniqueNftApi extends _nft.BaseNftApi {
141
141
  }
142
142
  }
143
143
  }));
144
+ const nftCollectionMap = {};
144
145
  await Promise.all(allCollectionId.map(async collectionId => {
145
146
  const collectionIdStr = collectionId.toString();
146
147
 
@@ -148,6 +149,7 @@ class UniqueNftApi extends _nft.BaseNftApi {
148
149
  const collection = (await this.substrateApi.api.query.nft.collectionById(collectionId)).toJSON();
149
150
  collectionMap[collectionIdStr] = collection;
150
151
  const nftIds = Object.entries(nftMap).filter(item => item[1] === collectionId).map(item => item[0]);
152
+ nftCollectionMap[collectionIdStr] = nftIds;
151
153
  const parsedCollection = {
152
154
  collectionId: collectionIdStr,
153
155
  chain: this.chain
@@ -174,10 +176,13 @@ class UniqueNftApi extends _nft.BaseNftApi {
174
176
  }
175
177
  params.updateItem(this.chain, parsedItem, address);
176
178
  params.updateCollection(this.chain, parsedCollection);
177
- // params.updateReady(true);
178
179
  }
179
180
  }));
180
181
  }));
182
+ Object.entries(nftCollectionMap).forEach(_ref => {
183
+ let [collectionId, nftIds] = _ref;
184
+ params.cleanUpNfts(this.chain, address, collectionId, nftIds);
185
+ });
181
186
  } catch (e) {
182
187
  console.error('Failed to fetch unique nft', e);
183
188
  }
@@ -9,12 +9,44 @@ var _types = require("@subwallet/chain-list/types");
9
9
  var _nft = require("@subwallet/extension-base/koni/api/nft/nft");
10
10
  var _utils = require("@subwallet/extension-base/koni/api/nft/wasm_nft/utils");
11
11
  var _wasm = require("@subwallet/extension-base/koni/api/tokens/wasm");
12
- var _utils2 = require("@subwallet/extension-base/services/chain-service/utils");
12
+ var _utils2 = require("@subwallet/extension-base/koni/api/tokens/wasm/utils");
13
+ var _utils3 = require("@subwallet/extension-base/services/chain-service/utils");
14
+ var _axios = _interopRequireDefault(require("axios"));
13
15
  var _crossFetch = _interopRequireDefault(require("cross-fetch"));
14
16
  var _utilCrypto = require("@polkadot/util-crypto");
15
17
  // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
16
18
  // SPDX-License-Identifier: Apache-2.0
17
19
 
20
+ // interface CollectionAttributes {
21
+ // storedOnChain: boolean,
22
+ // attributeList: string[] // list of attribute names
23
+ // }
24
+
25
+ async function isArtZeroFeaturedCollection(networkKey, contractAddress) {
26
+ const timeout = new Promise(resolve => {
27
+ const id = setTimeout(() => {
28
+ clearTimeout(id);
29
+ resolve(null);
30
+ }, 3000);
31
+ });
32
+ const urlencoded = new URLSearchParams();
33
+ urlencoded.append('collection_address', contractAddress);
34
+ const collectionInfoPromise = new Promise(function (resolve) {
35
+ (0, _crossFetch.default)(`${networkKey === 'alephTest' ? _utils.ART_ZERO_TESTNET_COLLECTION_API : _utils.ART_ZERO_COLLECTION_API}`, {
36
+ method: 'POST',
37
+ headers: {
38
+ 'Content-Type': 'application/x-www-form-urlencoded'
39
+ },
40
+ body: urlencoded
41
+ }).then(resp => {
42
+ resolve(resp.json());
43
+ }).catch(console.error);
44
+ });
45
+ const collectionInfo = await Promise.race([timeout, collectionInfoPromise]);
46
+
47
+ // @ts-ignore
48
+ return collectionInfo !== null && (collectionInfo === null || collectionInfo === void 0 ? void 0 : collectionInfo.status) !== 'FAILED';
49
+ }
18
50
  class WasmNftApi extends _nft.BaseNftApi {
19
51
  wasmContracts = [];
20
52
  constructor(api, addresses, chain) {
@@ -27,31 +59,40 @@ class WasmNftApi extends _nft.BaseNftApi {
27
59
  if (!tokenUri || tokenUri.length === 0) {
28
60
  return undefined;
29
61
  }
62
+ if (tokenUri.startsWith('/ipfs/')) {
63
+ return tokenUri;
64
+ }
65
+ if (tokenUri.startsWith('ipfs://')) {
66
+ return `/ipfs/${tokenUri.split('ipfs://')[1]}`;
67
+ }
30
68
  if (!tokenUri.includes('ipfs://') && !tokenUri.includes('ipfs://ipfs/')) {
31
- return `ipfs://${tokenUri}`;
69
+ return `/ipfs/${tokenUri}`;
32
70
  }
33
71
  if (tokenUri.includes('ipfs://ipfs/')) {
34
- return `ipfs://${tokenUri}`;
72
+ return `/ipfs/${tokenUri.split('ipfs://ipfs/')[1]}`;
35
73
  }
36
74
  return tokenUri;
37
75
  }
38
- parseFeaturedNftImage(tokenUri) {
76
+ async parseFeaturedNftImage(tokenUri) {
39
77
  const parsedTokenUri = this.parseFeaturedTokenUri(tokenUri);
40
78
  if (!parsedTokenUri) {
41
79
  return undefined;
42
80
  }
43
- return `${_utils.ART_ZERO_IMAGE_API}?input=${parsedTokenUri}&size=500`;
81
+ const nftItemImageSrc = `${this.chain === 'alephTest' ? _utils.ART_ZERO_TESTNET_IMAGE_API : _utils.ART_ZERO_IMAGE_API}?input=${parsedTokenUri}&size=500`;
82
+ const collectionImageUrl = await (0, _axios.default)(nftItemImageSrc, {
83
+ method: 'GET'
84
+ });
85
+ return collectionImageUrl.data;
44
86
  }
45
87
  async parseFeaturedCollectionImage(smartContract) {
46
- const resp = await (0, _crossFetch.default)(_utils.ART_ZERO_COLLECTION_API, {
88
+ const urlencoded = new URLSearchParams();
89
+ urlencoded.append('collection_address', smartContract);
90
+ const resp = await (0, _crossFetch.default)(this.chain === 'alephTest' ? _utils.ART_ZERO_TESTNET_COLLECTION_API : _utils.ART_ZERO_COLLECTION_API, {
47
91
  method: 'POST',
48
92
  headers: {
49
- Accept: 'application/json',
50
- 'Content-Type': 'application/json'
93
+ 'Content-Type': 'application/x-www-form-urlencoded'
51
94
  },
52
- body: JSON.stringify({
53
- collection_address: smartContract
54
- })
95
+ body: urlencoded
55
96
  });
56
97
  const result = resp && resp.ok && (await resp.json());
57
98
  if (!result) {
@@ -65,82 +106,91 @@ class WasmNftApi extends _nft.BaseNftApi {
65
106
  if (!parsedCollectionImage) {
66
107
  return;
67
108
  }
68
- return `${_utils.ART_ZERO_IMAGE_API}?input=${parsedCollectionImage}`;
69
- }
70
- async getCollectionAttributes(contractPromise) {
71
- const _onChainAttributeCount = await contractPromise.query['psp34Traits::getAttributeCount'](this.addresses[0], {
72
- gasLimit: -1
109
+ const collectionImageSrc = `${this.chain === 'alephTest' ? _utils.ART_ZERO_TESTNET_IMAGE_API : _utils.ART_ZERO_IMAGE_API}?input=${parsedCollectionImage}&size=500`;
110
+ const collectionImageUrl = await (0, _axios.default)(collectionImageSrc, {
111
+ method: 'GET'
73
112
  });
74
- const onChainAttributeCount = _onChainAttributeCount.output ? _onChainAttributeCount.output.toString() : '0';
75
- if (parseInt(onChainAttributeCount) === 0) {
76
- return {
77
- storedOnChain: false,
78
- attributeList: []
79
- };
80
- }
81
- const attributeList = [];
82
- const attributeIndexes = [];
83
- for (let i = 0; i < parseInt(onChainAttributeCount); i++) {
84
- attributeIndexes.push(i);
85
- }
86
- await Promise.all(attributeIndexes.map(async i => {
87
- const _attributeByIndex = await contractPromise.query['psp34Traits::getAttributeName'](this.addresses[0], {
88
- gasLimit: -1
89
- }, i);
90
- if (_attributeByIndex.output) {
91
- const attributeName = _attributeByIndex.output.toString();
92
- if (attributeName !== '') {
93
- attributeList.push(attributeName);
94
- }
95
- }
96
- }));
97
- return {
98
- storedOnChain: true,
99
- attributeList
100
- };
101
- }
102
- async processOnChainMetadata(contractPromise, address, tokenIdObj, collectionAttributes, isFeatured) {
103
- const nftItem = {
104
- chain: '',
105
- collectionId: '',
106
- id: '',
107
- owner: ''
108
- };
109
- const _attributeValues = await contractPromise.query['psp34Traits::getAttributes'](address, {
110
- gasLimit: -1
111
- }, tokenIdObj, collectionAttributes);
112
- if (_attributeValues.output) {
113
- const attributeValues = _attributeValues.output.toHuman();
114
- const attributeDict = {};
115
- for (let i = 0; i < collectionAttributes.length; i++) {
116
- const attributeName = collectionAttributes[i];
117
- const attributeValue = attributeValues[i] ? attributeValues[i] : '';
118
- if (attributeName.toLowerCase() === 'nft_name') {
119
- nftItem.name = attributeValue;
120
- } else if (attributeName.toLowerCase() === 'description') {
121
- nftItem.description = attributeValue;
122
- } else if (attributeName.toLowerCase() === 'avatar') {
123
- if (isFeatured) {
124
- nftItem.image = this.parseFeaturedNftImage(attributeValue);
125
- } else {
126
- nftItem.image = this.parseUrl(attributeValue);
127
- }
128
- } else {
129
- if (attributeValue !== '') {
130
- attributeDict[attributeName] = {
131
- value: attributeValue
132
- };
133
- }
134
- }
135
- }
136
- nftItem.properties = attributeDict;
137
- }
138
- if (isFeatured) {
139
- nftItem.externalUrl = _utils.ART_ZERO_EXTERNAL_URL;
140
- }
141
- return nftItem;
113
+ return collectionImageUrl.data;
142
114
  }
115
+
116
+ // private async getCollectionAttributes (contractPromise: ContractPromise): Promise<CollectionAttributes> {
117
+ // const _onChainAttributeCount = await contractPromise.query['psp34Traits::getAttributeCount'](this.addresses[0], { gasLimit: getDefaultWeightV2(this.substrateApi?.api as ApiPromise) });
118
+ // const onChainAttributeCount = _onChainAttributeCount.output ? _onChainAttributeCount.output.toString() : '0';
119
+ //
120
+ // if (parseInt(onChainAttributeCount) === 0) {
121
+ // return {
122
+ // storedOnChain: false,
123
+ // attributeList: []
124
+ // };
125
+ // }
126
+ //
127
+ // const attributeList: string[] = [];
128
+ // const attributeIndexes: number[] = [];
129
+ //
130
+ // for (let i = 0; i < parseInt(onChainAttributeCount); i++) {
131
+ // attributeIndexes.push(i);
132
+ // }
133
+ //
134
+ // await Promise.all(attributeIndexes.map(async (i) => {
135
+ // const _attributeByIndex = await contractPromise.query['psp34Traits::getAttributeName'](this.addresses[0], { gasLimit: getDefaultWeightV2(this.substrateApi?.api as ApiPromise) }, i);
136
+ //
137
+ // if (_attributeByIndex.output) {
138
+ // const attributeName = _attributeByIndex.output.toString();
139
+ //
140
+ // if (attributeName !== '') {
141
+ // attributeList.push(attributeName);
142
+ // }
143
+ // }
144
+ // }));
145
+ //
146
+ // return {
147
+ // storedOnChain: true,
148
+ // attributeList
149
+ // };
150
+ // }
151
+
152
+ // private async processOnChainMetadata (contractPromise: ContractPromise, address: string, tokenIdObj: Record<string, string>, collectionAttributes: string[], isFeatured: boolean): Promise<NftItem> {
153
+ // const nftItem: NftItem = { chain: '', collectionId: '', id: '', owner: '' };
154
+ // const _attributeValues = await contractPromise.query['psp34Traits::getAttributes'](address, { gasLimit: getDefaultWeightV2(this.substrateApi?.api as ApiPromise) }, tokenIdObj, collectionAttributes);
155
+ //
156
+ // if (_attributeValues.output) {
157
+ // const attributeValues = _attributeValues.output.toHuman() as string[];
158
+ //
159
+ // const attributeDict: Record<string, any> = {};
160
+ //
161
+ // for (let i = 0; i < collectionAttributes.length; i++) {
162
+ // const attributeName = collectionAttributes[i];
163
+ // const attributeValue = attributeValues[i] ? attributeValues[i] : '';
164
+ //
165
+ // if (attributeName.toLowerCase() === 'nft_name') {
166
+ // nftItem.name = attributeValue;
167
+ // } else if (attributeName.toLowerCase() === 'description') {
168
+ // nftItem.description = attributeValue;
169
+ // } else if (attributeName.toLowerCase() === 'avatar') {
170
+ // if (isFeatured) {
171
+ // nftItem.image = await this.parseFeaturedNftImage(attributeValue);
172
+ // } else {
173
+ // nftItem.image = this.parseUrl(attributeValue);
174
+ // }
175
+ // } else {
176
+ // if (attributeValue !== '') {
177
+ // attributeDict[attributeName] = { value: attributeValue };
178
+ // }
179
+ // }
180
+ // }
181
+ //
182
+ // nftItem.properties = attributeDict;
183
+ // }
184
+ //
185
+ // if (isFeatured) {
186
+ // nftItem.externalUrl = ART_ZERO_EXTERNAL_URL;
187
+ // }
188
+ //
189
+ // return nftItem;
190
+ // }
191
+
143
192
  async processOffChainMetadata(contractPromise, address, tokenId, isFeatured) {
193
+ var _this$substrateApi;
144
194
  const nftItem = {
145
195
  chain: '',
146
196
  collectionId: '',
@@ -149,19 +199,23 @@ class WasmNftApi extends _nft.BaseNftApi {
149
199
  name: tokenId
150
200
  };
151
201
  const _tokenUri = await contractPromise.query['psp34Traits::tokenUri'](address, {
152
- gasLimit: -1
202
+ gasLimit: (0, _utils2.getDefaultWeightV2)((_this$substrateApi = this.substrateApi) === null || _this$substrateApi === void 0 ? void 0 : _this$substrateApi.api)
153
203
  }, tokenId);
154
204
  if (_tokenUri.output) {
155
205
  let itemDetail = false;
156
- const tokenUri = _tokenUri.output.toString();
206
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
207
+ const _tokenUriObj = _tokenUri.output.toJSON();
208
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
209
+ const tokenUri = _tokenUriObj.Ok || _tokenUriObj.ok;
157
210
  if (isFeatured) {
158
211
  const parsedTokenUri = this.parseFeaturedTokenUri(tokenUri);
159
212
  if (parsedTokenUri) {
160
- const resp = await (0, _crossFetch.default)(`${_utils.ART_ZERO_IPFS_API}?input=${parsedTokenUri}`);
213
+ const resp = await (0, _crossFetch.default)(`${this.chain === 'alephTest' ? _utils.ART_ZERO_TESTNET_IPFS_API : _utils.ART_ZERO_IPFS_API}?input=${parsedTokenUri}`);
161
214
  itemDetail = resp && resp.ok && (await resp.json());
162
215
  }
163
216
  } else {
164
- const detailUrl = this.parseUrl(tokenUri);
217
+ const parsedTokenUri = this.parseFeaturedTokenUri(tokenUri);
218
+ const detailUrl = this.parseUrl(parsedTokenUri);
165
219
  if (detailUrl) {
166
220
  const resp = await (0, _crossFetch.default)(detailUrl);
167
221
  itemDetail = resp && resp.ok && (await resp.json());
@@ -176,7 +230,7 @@ class WasmNftApi extends _nft.BaseNftApi {
176
230
  nftItem.externalUrl = itemDetail.external_url;
177
231
  const rawImageSrc = itemDetail.image ? itemDetail.image : itemDetail.image_url;
178
232
  if (isFeatured) {
179
- nftItem.image = this.parseFeaturedNftImage(rawImageSrc);
233
+ nftItem.image = await this.parseFeaturedNftImage(rawImageSrc);
180
234
  nftItem.externalUrl = _utils.ART_ZERO_EXTERNAL_URL;
181
235
  } else {
182
236
  nftItem.image = this.parseUrl(rawImageSrc);
@@ -194,20 +248,24 @@ class WasmNftApi extends _nft.BaseNftApi {
194
248
  }
195
249
  return nftItem;
196
250
  }
197
- async getItemsByCollection(contractPromise, collectionAttributes, isMetadataOnchain, tokenInfo, collectionName, nftParams) {
251
+ async getItemsByCollection(contractPromise, tokenInfo, collectionName, nftParams, isFeatured) {
198
252
  let ownItem = false;
199
253
  let collectionImage;
200
- const smartContract = (0, _utils2._getContractAddressOfToken)(tokenInfo);
201
- const isFeatured = _utils.ART_ZERO_CONTRACTS.includes(smartContract);
254
+ const smartContract = (0, _utils3._getContractAddressOfToken)(tokenInfo);
255
+ const nftOwnerMap = {};
202
256
  await Promise.all(this.addresses.map(async address => {
257
+ var _this$substrateApi2, _balance$output;
203
258
  if ((0, _utilCrypto.isEthereumAddress)(address)) {
204
259
  return;
205
260
  }
206
261
  const nftIds = [];
207
262
  const _balance = await contractPromise.query['psp34::balanceOf'](address, {
208
- gasLimit: -1
263
+ gasLimit: (0, _utils2.getDefaultWeightV2)((_this$substrateApi2 = this.substrateApi) === null || _this$substrateApi2 === void 0 ? void 0 : _this$substrateApi2.api)
209
264
  }, address);
210
- const balance = _balance.output ? _balance.output.toString() : '0';
265
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
266
+ const balanceJson = _balance === null || _balance === void 0 ? void 0 : (_balance$output = _balance.output) === null || _balance$output === void 0 ? void 0 : _balance$output.toJSON();
267
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
268
+ const balance = _balance.output ? balanceJson.ok || balanceJson.Ok : '0';
211
269
  if (parseInt(balance) === 0) {
212
270
  return;
213
271
  }
@@ -217,20 +275,17 @@ class WasmNftApi extends _nft.BaseNftApi {
217
275
  }
218
276
  try {
219
277
  await Promise.all(itemIndexes.map(async i => {
278
+ var _this$substrateApi3;
220
279
  const _tokenByIndexResp = await contractPromise.query['psp34Enumerable::ownersTokenByIndex'](address, {
221
- gasLimit: -1
280
+ gasLimit: (0, _utils2.getDefaultWeightV2)((_this$substrateApi3 = this.substrateApi) === null || _this$substrateApi3 === void 0 ? void 0 : _this$substrateApi3.api)
222
281
  }, address, i);
223
282
  if (_tokenByIndexResp.output) {
224
283
  const rawTokenId = _tokenByIndexResp.output.toHuman();
225
- const tokenIdObj = rawTokenId.Ok;
226
- const tokenId = Object.values(tokenIdObj)[0];
284
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
285
+ const tokenIdObj = rawTokenId.Ok.Ok || rawTokenId.ok.ok; // capital O, not normal o
286
+ const tokenId = Object.values(tokenIdObj)[0].replaceAll(',', '');
227
287
  nftIds.push(tokenId);
228
- let nftItem;
229
- if (isMetadataOnchain) {
230
- nftItem = await this.processOnChainMetadata(contractPromise, address, tokenIdObj, collectionAttributes, isFeatured);
231
- } else {
232
- nftItem = await this.processOffChainMetadata(contractPromise, address, tokenId, isFeatured);
233
- }
288
+ const nftItem = await this.processOffChainMetadata(contractPromise, address, tokenId, isFeatured);
234
289
  nftItem.collectionId = smartContract;
235
290
  nftItem.chain = this.chain;
236
291
  nftItem.type = _types._AssetType.PSP34;
@@ -245,6 +300,8 @@ class WasmNftApi extends _nft.BaseNftApi {
245
300
  }
246
301
  }
247
302
  }));
303
+
304
+ nftOwnerMap[address] = nftIds;
248
305
  } catch (e) {
249
306
  console.error(`error parsing item for ${this.chain} nft`, e);
250
307
  }
@@ -264,6 +321,10 @@ class WasmNftApi extends _nft.BaseNftApi {
264
321
  originAsset: tokenInfo.slug
265
322
  };
266
323
  nftParams.updateCollection(this.chain, nftCollection);
324
+ Object.entries(nftOwnerMap).forEach(_ref => {
325
+ let [owner, nftIds] = _ref;
326
+ nftParams.cleanUpNfts(this.chain, owner, smartContract, nftIds);
327
+ });
267
328
  }
268
329
  }
269
330
  async fetchNfts(params) {
@@ -275,20 +336,17 @@ class WasmNftApi extends _nft.BaseNftApi {
275
336
  return 1;
276
337
  }
277
338
  async handleNfts(params) {
278
- var _this$substrateApi;
339
+ var _this$substrateApi4;
279
340
  if (!this.wasmContracts || this.wasmContracts.length === 0) {
280
341
  return;
281
342
  }
282
343
  await this.connect(); // might not be necessary
283
344
 
284
- const apiPromise = (_this$substrateApi = this.substrateApi) === null || _this$substrateApi === void 0 ? void 0 : _this$substrateApi.api;
345
+ const apiPromise = (_this$substrateApi4 = this.substrateApi) === null || _this$substrateApi4 === void 0 ? void 0 : _this$substrateApi4.api;
285
346
  await Promise.all(this.wasmContracts.map(async tokenInfo => {
286
- const contractPromise = (0, _wasm.getPSP34ContractPromise)(apiPromise, (0, _utils2._getContractAddressOfToken)(tokenInfo));
287
- const {
288
- attributeList,
289
- storedOnChain
290
- } = await this.getCollectionAttributes(contractPromise);
291
- return await this.getItemsByCollection(contractPromise, attributeList, storedOnChain, tokenInfo, tokenInfo.name, params);
347
+ const contractPromise = (0, _wasm.getPSP34ContractPromise)(apiPromise, (0, _utils3._getContractAddressOfToken)(tokenInfo));
348
+ const isCollectionFeatured = await isArtZeroFeaturedCollection(this.chain, (0, _utils3._getContractAddressOfToken)(tokenInfo));
349
+ return await this.getItemsByCollection(contractPromise, tokenInfo, tokenInfo.name, params, isCollectionFeatured);
292
350
  }));
293
351
  }
294
352
  }
@@ -3,17 +3,21 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.ART_ZERO_IPFS_API = exports.ART_ZERO_IMAGE_API = exports.ART_ZERO_EXTERNAL_URL = exports.ART_ZERO_CONTRACTS = exports.ART_ZERO_COLLECTION_API = void 0;
6
+ exports.ART_ZERO_TESTNET_IPFS_API = exports.ART_ZERO_TESTNET_IMAGE_API = exports.ART_ZERO_TESTNET_COLLECTION_API = exports.ART_ZERO_IPFS_API = exports.ART_ZERO_IMAGE_API = exports.ART_ZERO_EXTERNAL_URL = exports.ART_ZERO_COLLECTION_API = void 0;
7
7
  // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
8
8
  // SPDX-License-Identifier: Apache-2.0
9
9
 
10
- const ART_ZERO_CONTRACTS = ['5Hg1xe6JAGZj92wxtj1ykAfQpwwRNqzAnvhZ3TuXZEmLU1Vw'];
11
- exports.ART_ZERO_CONTRACTS = ART_ZERO_CONTRACTS;
12
- const ART_ZERO_IMAGE_API = 'https://api.artzero.io/getImage';
10
+ const ART_ZERO_TESTNET_IMAGE_API = 'https://a0-test-api.artzero.io/getImage';
11
+ exports.ART_ZERO_TESTNET_IMAGE_API = ART_ZERO_TESTNET_IMAGE_API;
12
+ const ART_ZERO_TESTNET_IPFS_API = 'https://a0-test-api.artzero.io/getJSON';
13
+ exports.ART_ZERO_TESTNET_IPFS_API = ART_ZERO_TESTNET_IPFS_API;
14
+ const ART_ZERO_TESTNET_COLLECTION_API = 'https://a0-test-api.artzero.io/getCollectionByAddress';
15
+ exports.ART_ZERO_TESTNET_COLLECTION_API = ART_ZERO_TESTNET_COLLECTION_API;
16
+ const ART_ZERO_IMAGE_API = 'https://a0-api.artzero.io/getImage';
13
17
  exports.ART_ZERO_IMAGE_API = ART_ZERO_IMAGE_API;
14
- const ART_ZERO_IPFS_API = 'https://api.artzero.io/getJSON';
18
+ const ART_ZERO_IPFS_API = 'https://a0-api.artzero.io/getJSON';
15
19
  exports.ART_ZERO_IPFS_API = ART_ZERO_IPFS_API;
16
- const ART_ZERO_COLLECTION_API = 'https://api.artzero.io/getCollectionByAddress';
20
+ const ART_ZERO_COLLECTION_API = 'https://a0-api.artzero.io/getCollectionByAddress';
17
21
  exports.ART_ZERO_COLLECTION_API = ART_ZERO_COLLECTION_API;
18
- const ART_ZERO_EXTERNAL_URL = 'https://artzero.io/demotestnet/#/marketplace';
22
+ const ART_ZERO_EXTERNAL_URL = 'https://a0.artzero.io/#/marketplace';
19
23
  exports.ART_ZERO_EXTERNAL_URL = ART_ZERO_EXTERNAL_URL;
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getAmplitudeBondingExtrinsic = getAmplitudeBondingExtrinsic;
7
- exports.getAmplitudeCancelWithdrawalExtrinsic = getAmplitudeCancelWithdrawalExtrinsic;
8
7
  exports.getAmplitudeClaimRewardExtrinsic = getAmplitudeClaimRewardExtrinsic;
9
8
  exports.getAmplitudeCollatorsInfo = getAmplitudeCollatorsInfo;
10
9
  exports.getAmplitudeNominatorMetadata = getAmplitudeNominatorMetadata;
@@ -52,23 +51,31 @@ async function getAmplitudeNominatorMetadata(chainInfo, address, substrateApi) {
52
51
  const nominationList = [];
53
52
  const unstakingList = [];
54
53
  const [_delegatorState, _unstakingInfo] = await Promise.all([chainApi.api.query.parachainStaking.delegatorState(address), chainApi.api.query.parachainStaking.unstaking(address)]);
54
+ const minDelegatorStake = chainApi.api.consts.parachainStaking.minDelegatorStake.toString();
55
55
  const delegatorState = _delegatorState.toPrimitive();
56
56
  const unstakingInfo = _unstakingInfo.toPrimitive();
57
+ console.log('unstakingInfo ampe', unstakingInfo, !!unstakingInfo);
57
58
  if (!delegatorState && !unstakingInfo) {
58
59
  return;
59
60
  }
60
61
  let activeStake = '0';
61
62
  if (delegatorState) {
62
63
  // delegatorState can be null while unstaking all
63
- const identityInfo = (await chainApi.api.query.identity.identityOf(delegatorState.owner)).toPrimitive();
64
- const identity = (0, _utils.parseIdentity)(identityInfo);
64
+ const identityInfo = chainApi.api.query.identity ? (await chainApi.api.query.identity.identityOf(delegatorState.owner)).toPrimitive() : undefined;
65
+ const identity = identityInfo ? (0, _utils.parseIdentity)(identityInfo) : undefined;
65
66
  activeStake = delegatorState.amount.toString();
67
+ const bnActiveStake = new _util.BN(activeStake);
68
+ let delegationStatus = _KoniTypes.StakingStatus.NOT_EARNING;
69
+ if (bnActiveStake.gt(_util.BN_ZERO) && bnActiveStake.gte(new _util.BN(minDelegatorStake))) {
70
+ delegationStatus = _KoniTypes.StakingStatus.EARNING_REWARD;
71
+ }
66
72
  nominationList.push({
73
+ status: delegationStatus,
67
74
  chain,
68
75
  validatorAddress: delegatorState.owner,
69
76
  activeStake: delegatorState.amount.toString(),
70
77
  validatorMinStake: '0',
71
- hasUnstaking: !!unstakingInfo,
78
+ hasUnstaking: !!unstakingInfo && Object.values(unstakingInfo).length > 0,
72
79
  validatorIdentity: identity
73
80
  });
74
81
  }
@@ -96,9 +103,11 @@ async function getAmplitudeNominatorMetadata(chainInfo, address, substrateApi) {
96
103
  if (nominationList.length === 0 && unstakingList.length === 0) {
97
104
  return;
98
105
  }
106
+ const stakingStatus = (0, _utils.getStakingStatusByNominations)(new _util.BN(activeStake), nominationList);
99
107
  return {
100
108
  chain,
101
109
  type: _KoniTypes.StakingType.NOMINATED,
110
+ status: stakingStatus,
102
111
  address: address,
103
112
  activeStake: activeStake,
104
113
  nominations: nominationList,
@@ -134,13 +143,16 @@ async function getAmplitudeCollatorsInfo(chain, substrateApi) {
134
143
  }
135
144
  return allCollators;
136
145
  }
137
- async function getAmplitudeBondingExtrinsic(nominatorMetadata, substrateApi, amount, selectedValidatorInfo) {
146
+ async function getAmplitudeBondingExtrinsic(substrateApi, amount, selectedValidatorInfo, nominatorMetadata) {
138
147
  const chainApi = await substrateApi.isReady;
139
148
  const binaryAmount = new _util.BN(amount);
149
+ if (!nominatorMetadata) {
150
+ return chainApi.api.tx.parachainStaking.joinDelegators(selectedValidatorInfo.address, binaryAmount);
151
+ }
140
152
  const {
141
153
  bondedValidators
142
154
  } = (0, _utils.getBondedValidators)(nominatorMetadata.nominations);
143
- if (!bondedValidators.includes(selectedValidatorInfo.address)) {
155
+ if (!bondedValidators.includes((0, _utils2.reformatAddress)(selectedValidatorInfo.address, 0))) {
144
156
  return chainApi.api.tx.parachainStaking.joinDelegators(selectedValidatorInfo.address, binaryAmount);
145
157
  } else {
146
158
  const _params = chainApi.api.tx.parachainStaking.delegatorStakeMore.toJSON();
@@ -176,8 +188,4 @@ async function getAmplitudeWithdrawalExtrinsic(substrateApi, address) {
176
188
  async function getAmplitudeClaimRewardExtrinsic(substrateApi) {
177
189
  const chainApi = await substrateApi.isReady;
178
190
  return chainApi.api.tx.utility.batch([chainApi.api.tx.parachainStaking.incrementDelegatorRewards(), chainApi.api.tx.parachainStaking.claimRewards()]);
179
- }
180
- async function getAmplitudeCancelWithdrawalExtrinsic(substrateApi) {
181
- const chainApi = await substrateApi.isReady;
182
- return chainApi.api.tx.parachainStaking.cancelLeaveCandidates();
183
191
  }