@subwallet/extension-base 1.2.30-0 → 1.2.32-0

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 (33) hide show
  1. package/background/KoniTypes.d.ts +2 -2
  2. package/cjs/constants/blocked-actions-list.js +15 -0
  3. package/cjs/constants/index.js +12 -0
  4. package/cjs/core/logic-validation/transfer.js +166 -0
  5. package/cjs/koni/background/handlers/Extension.js +31 -7
  6. package/cjs/packageInfo.js +1 -1
  7. package/cjs/services/balance-service/helpers/subscribe/index.js +0 -3
  8. package/cjs/services/chain-service/handler/SubstrateApi.js +1 -0
  9. package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +6 -6
  10. package/cjs/services/swap-service/handler/chainflip-handler.js +35 -13
  11. package/cjs/services/swap-service/utils.js +5 -3
  12. package/cjs/services/transaction-service/index.js +7 -1
  13. package/cjs/utils/staticData/index.js +7 -2
  14. package/constants/blocked-actions-list.d.ts +7 -0
  15. package/constants/blocked-actions-list.js +8 -0
  16. package/constants/index.d.ts +1 -0
  17. package/constants/index.js +2 -1
  18. package/core/logic-validation/transfer.d.ts +2 -0
  19. package/core/logic-validation/transfer.js +164 -0
  20. package/koni/background/handlers/Extension.js +32 -8
  21. package/package.json +16 -10
  22. package/packageInfo.js +1 -1
  23. package/services/balance-service/helpers/subscribe/index.js +0 -3
  24. package/services/chain-service/handler/SubstrateApi.js +1 -0
  25. package/services/earning-service/handlers/liquid-staking/stella-swap.js +6 -6
  26. package/services/mkt-campaign-service/types.d.ts +4 -0
  27. package/services/swap-service/handler/chainflip-handler.d.ts +3 -2
  28. package/services/swap-service/handler/chainflip-handler.js +36 -14
  29. package/services/swap-service/utils.js +5 -3
  30. package/services/transaction-service/index.js +9 -3
  31. package/utils/staticData/blockedActionsFeatures.json +39 -0
  32. package/utils/staticData/index.d.ts +4 -1
  33. package/utils/staticData/index.js +5 -1
@@ -1652,8 +1652,8 @@ export interface KoniRequestSignatures {
1652
1652
  'pri(accounts.inject.add)': [RequestAddInjectedAccounts, boolean];
1653
1653
  'pri(accounts.inject.remove)': [RequestRemoveInjectedAccounts, boolean];
1654
1654
  'pri(derivation.createV2)': [RequestDeriveCreateV2, boolean];
1655
- 'pri(json.restoreV2)': [RequestJsonRestoreV2, void];
1656
- 'pri(json.batchRestoreV2)': [RequestBatchRestoreV2, void];
1655
+ 'pri(json.restoreV2)': [RequestJsonRestoreV2, string[]];
1656
+ 'pri(json.batchRestoreV2)': [RequestBatchRestoreV2, string[]];
1657
1657
  'pri(accounts.batchExportV2)': [RequestAccountBatchExportV2, ResponseAccountBatchExportV2];
1658
1658
  'pri(accounts.exportPrivateKey)': [RequestAccountExportPrivateKey, ResponseAccountExportPrivateKey];
1659
1659
  'pri(accounts.subscribeWithCurrentAddress)': [RequestAccountSubscribe, AccountsWithCurrentAddress, AccountsWithCurrentAddress];
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.fetchLastestBlockedActionsAndFeatures = void 0;
7
+ var _utils = require("@subwallet/extension-base/utils");
8
+ // Copyright 2019-2022 @subwallet/extension-base authors & contributors
9
+ // SPDX-License-Identifier: Apache-2.0
10
+
11
+ const BLOCKED_ACTIONS_AND_FEATURES_PROMISE = (0, _utils.fetchStaticData)('blocked-actions-features');
12
+ const fetchLastestBlockedActionsAndFeatures = async () => {
13
+ return await BLOCKED_ACTIONS_AND_FEATURES_PROMISE;
14
+ };
15
+ exports.fetchLastestBlockedActionsAndFeatures = fetchLastestBlockedActionsAndFeatures;
@@ -62,6 +62,18 @@ Object.keys(_storage).forEach(function (key) {
62
62
  }
63
63
  });
64
64
  });
65
+ var _blockedActionsList = require("./blocked-actions-list");
66
+ Object.keys(_blockedActionsList).forEach(function (key) {
67
+ if (key === "default" || key === "__esModule") return;
68
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
69
+ if (key in exports && exports[key] === _blockedActionsList[key]) return;
70
+ Object.defineProperty(exports, key, {
71
+ enumerable: true,
72
+ get: function () {
73
+ return _blockedActionsList[key];
74
+ }
75
+ });
76
+ });
65
77
  // Copyright 2019-2022 @subwallet/extension-koni authors & contributors
66
78
  // SPDX-License-Identifier: Apache-2.0
67
79
 
@@ -8,6 +8,8 @@ exports.additionalValidateTransfer = additionalValidateTransfer;
8
8
  exports.additionalValidateXcmTransfer = additionalValidateXcmTransfer;
9
9
  exports.checkBalanceWithTransactionFee = checkBalanceWithTransactionFee;
10
10
  exports.checkSigningAccountForTransaction = checkSigningAccountForTransaction;
11
+ exports.checkSupportForAction = checkSupportForAction;
12
+ exports.checkSupportForFeature = checkSupportForFeature;
11
13
  exports.checkSupportForTransaction = checkSupportForTransaction;
12
14
  exports.estimateFeeForTransaction = estimateFeeForTransaction;
13
15
  exports.validateTransferRequest = validateTransferRequest;
@@ -152,6 +154,170 @@ function additionalValidateXcmTransfer(originTokenInfo, destinationTokenInfo, se
152
154
  }
153
155
  return [warning, error];
154
156
  }
157
+ function checkSupportForFeature(validationResponse, blockedFeaturesList, chainInfo) {
158
+ const extrinsicType = validationResponse.extrinsicType;
159
+ const chain = validationResponse.chain;
160
+ const currentFeature = `${extrinsicType}___${chain}`;
161
+ if (blockedFeaturesList.includes(currentFeature)) {
162
+ validationResponse.errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.UNSUPPORTED, (0, _i18next.t)(`Feature under maintenance on ${chainInfo.name} network. Try again later`)));
163
+ }
164
+ }
165
+ function checkSupportForAction(validationResponse, blockedActionsMap) {
166
+ const extrinsicType = validationResponse.extrinsicType;
167
+ let currentAction = '';
168
+ switch (extrinsicType) {
169
+ case _KoniTypes.ExtrinsicType.TRANSFER_BALANCE:
170
+
171
+ // eslint-disable-next-line no-fallthrough
172
+ case _KoniTypes.ExtrinsicType.TRANSFER_TOKEN:
173
+ {
174
+ const data = validationResponse.data;
175
+ const tokenSlug = data.tokenSlug;
176
+ currentAction = `${extrinsicType}___${tokenSlug}`;
177
+ break;
178
+ }
179
+ case _KoniTypes.ExtrinsicType.TRANSFER_XCM:
180
+ {
181
+ const data = validationResponse.data;
182
+ const tokenSlug = data.tokenSlug;
183
+ const destinationNetworkKey = data.destinationNetworkKey;
184
+ currentAction = `${extrinsicType}___${tokenSlug}___${destinationNetworkKey}`;
185
+ break;
186
+ }
187
+ case _KoniTypes.ExtrinsicType.SEND_NFT:
188
+ {
189
+ const data = validationResponse.data;
190
+ const networkKey = data.networkKey;
191
+ const collectionId = data.nftItem.collectionId;
192
+ currentAction = `${extrinsicType}___${networkKey}___${collectionId}`;
193
+ break;
194
+ }
195
+ case _KoniTypes.ExtrinsicType.SWAP:
196
+ {
197
+ const data = validationResponse.data;
198
+ const pairSlug = data.quote.pair.slug;
199
+ const providerId = data.provider.id;
200
+ currentAction = `${extrinsicType}___${pairSlug}___${providerId}`;
201
+ break;
202
+ }
203
+ case _KoniTypes.ExtrinsicType.STAKING_BOND:
204
+ {
205
+ const data = validationResponse.data;
206
+ const chain = data.chain;
207
+ currentAction = `${extrinsicType}___${chain}`;
208
+ break;
209
+ }
210
+ case _KoniTypes.ExtrinsicType.STAKING_LEAVE_POOL:
211
+ {
212
+ const data = validationResponse.data;
213
+ const slug = data.slug;
214
+ currentAction = `${extrinsicType}___${slug}`;
215
+ break;
216
+ }
217
+ case _KoniTypes.ExtrinsicType.STAKING_UNBOND:
218
+ {
219
+ const data = validationResponse.data;
220
+ const chain = data.chain;
221
+ currentAction = `${extrinsicType}___${chain}`;
222
+ break;
223
+ }
224
+ case _KoniTypes.ExtrinsicType.STAKING_CLAIM_REWARD:
225
+ {
226
+ const data = validationResponse.data;
227
+ const slug = data.slug;
228
+ currentAction = `${extrinsicType}___${slug}`;
229
+ break;
230
+ }
231
+ case _KoniTypes.ExtrinsicType.STAKING_WITHDRAW:
232
+ {
233
+ const data = validationResponse.data;
234
+ const slug = data.slug;
235
+ currentAction = `${extrinsicType}___${slug}`;
236
+ break;
237
+ }
238
+ case _KoniTypes.ExtrinsicType.STAKING_COMPOUNDING:
239
+ {
240
+ const data = validationResponse.data;
241
+ const networkKey = data.networkKey;
242
+ currentAction = `${extrinsicType}___${networkKey}`;
243
+ break;
244
+ }
245
+ case _KoniTypes.ExtrinsicType.STAKING_CANCEL_COMPOUNDING:
246
+ {
247
+ const data = validationResponse.data;
248
+ const networkKey = data.networkKey;
249
+ currentAction = `${extrinsicType}___${networkKey}`;
250
+ break;
251
+ }
252
+ case _KoniTypes.ExtrinsicType.STAKING_CANCEL_UNSTAKE:
253
+ {
254
+ const data = validationResponse.data;
255
+ const slug = data.slug;
256
+ currentAction = `${extrinsicType}___${slug}`;
257
+ break;
258
+ }
259
+ case _KoniTypes.ExtrinsicType.JOIN_YIELD_POOL:
260
+ {
261
+ const data = validationResponse.data;
262
+ const slug = data.data.slug;
263
+ currentAction = `${extrinsicType}___${slug}`;
264
+ break;
265
+ }
266
+ case _KoniTypes.ExtrinsicType.MINT_VDOT:
267
+ case _KoniTypes.ExtrinsicType.MINT_LDOT:
268
+ case _KoniTypes.ExtrinsicType.MINT_SDOT:
269
+ case _KoniTypes.ExtrinsicType.MINT_QDOT:
270
+ case _KoniTypes.ExtrinsicType.MINT_STDOT:
271
+
272
+ // eslint-disable-next-line no-fallthrough
273
+ case _KoniTypes.ExtrinsicType.MINT_VMANTA:
274
+ {
275
+ const data = validationResponse.data;
276
+ const slug = data.slug;
277
+ currentAction = `${extrinsicType}___${slug}`;
278
+ break;
279
+ }
280
+ case _KoniTypes.ExtrinsicType.REDEEM_VDOT:
281
+ case _KoniTypes.ExtrinsicType.REDEEM_LDOT:
282
+ case _KoniTypes.ExtrinsicType.REDEEM_SDOT:
283
+ case _KoniTypes.ExtrinsicType.REDEEM_QDOT:
284
+ case _KoniTypes.ExtrinsicType.REDEEM_STDOT:
285
+
286
+ // eslint-disable-next-line no-fallthrough
287
+ case _KoniTypes.ExtrinsicType.REDEEM_VMANTA:
288
+ {
289
+ const data = validationResponse.data;
290
+ const slug = data.slug;
291
+ currentAction = `${extrinsicType}___${slug}`;
292
+ break;
293
+ }
294
+ case _KoniTypes.ExtrinsicType.UNSTAKE_VDOT:
295
+ case _KoniTypes.ExtrinsicType.UNSTAKE_LDOT:
296
+ case _KoniTypes.ExtrinsicType.UNSTAKE_SDOT:
297
+ case _KoniTypes.ExtrinsicType.UNSTAKE_QDOT:
298
+ case _KoniTypes.ExtrinsicType.UNSTAKE_STDOT:
299
+
300
+ // eslint-disable-next-line no-fallthrough
301
+ case _KoniTypes.ExtrinsicType.UNSTAKE_VMANTA:
302
+ {
303
+ const data = validationResponse.data;
304
+ const slug = data.slug;
305
+ currentAction = `${extrinsicType}___${slug}`;
306
+ break;
307
+ }
308
+ case _KoniTypes.ExtrinsicType.TOKEN_SPENDING_APPROVAL:
309
+ {
310
+ const data = validationResponse.data;
311
+ const chain = data.chain;
312
+ currentAction = `${extrinsicType}___${chain}`;
313
+ break;
314
+ }
315
+ }
316
+ const blockedActionsList = Object.values(blockedActionsMap).flat();
317
+ if (blockedActionsList.includes(currentAction)) {
318
+ validationResponse.errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.UNSUPPORTED, (0, _i18next.t)('Feature under maintenance. Try again later')));
319
+ }
320
+ }
155
321
 
156
322
  // general validations
157
323
  function checkSupportForTransaction(validationResponse, transaction) {
@@ -1431,6 +1431,10 @@ class KoniExtension {
1431
1431
  withMasterPassword
1432
1432
  } = _ref43;
1433
1433
  const isPasswordValidated = this.validatePassword(file, password);
1434
+ const {
1435
+ promise,
1436
+ resolve
1437
+ } = (0, _utils4.createPromiseHandler)();
1434
1438
  if (isPasswordValidated) {
1435
1439
  try {
1436
1440
  this._saveCurrentAccountAddress(address, () => {
@@ -1445,10 +1449,12 @@ class KoniExtension {
1445
1449
  });
1446
1450
  }
1447
1451
  this._addAddressToAuthList(address, isAllowed);
1452
+ resolve([address]);
1448
1453
  });
1449
1454
  if (this.#alwaysLock) {
1450
1455
  this.keyringLock();
1451
1456
  }
1457
+ return promise;
1452
1458
  } catch (error) {
1453
1459
  throw new Error(error.message);
1454
1460
  }
@@ -1465,17 +1471,35 @@ class KoniExtension {
1465
1471
  } = _ref44;
1466
1472
  const addressList = accountsInfo.map(acc => acc.address);
1467
1473
  const isPasswordValidated = this.validatedAccountsPassword(file, password);
1474
+ const {
1475
+ promise,
1476
+ resolve
1477
+ } = (0, _utils4.createPromiseHandler)();
1468
1478
  if (isPasswordValidated) {
1469
1479
  try {
1470
1480
  this._saveCurrentAccountAddress(_constants.ALL_ACCOUNT_KEY, () => {
1471
1481
  _uiKeyring.keyring.restoreAccounts(file, password);
1472
1482
  this.#koniState.keyringService.removeNoneHardwareGenesisHash();
1473
- this._addAddressesToAuthList(addressList, isAllowed);
1483
+ const successAddressList = addressList.reduce((addressList, address) => {
1484
+ try {
1485
+ const account = _uiKeyring.keyring.getPair(address);
1486
+ if (account) {
1487
+ addressList.push(address);
1488
+ }
1489
+ } catch (error) {
1490
+ console.log(error);
1491
+ }
1492
+ return addressList;
1493
+ }, []);
1494
+ this._addAddressesToAuthList(successAddressList, isAllowed);
1495
+ resolve(successAddressList);
1474
1496
  });
1475
1497
 
1476
1498
  // if (this.#alwaysLock) {
1477
1499
  // this.keyringLock();
1478
1500
  // }
1501
+
1502
+ return promise;
1479
1503
  } catch (error) {
1480
1504
  throw new Error(error.message);
1481
1505
  }
@@ -3051,14 +3075,14 @@ class KoniExtension {
3051
3075
  } else {
3052
3076
  metadata = await this.#koniState.chainService.getMetadataByHash(payload.genesisHash);
3053
3077
  if (metadata) {
3054
- var _chainInfo$substrateI, _chainInfo$substrateI2, _chainInfo$substrateI3;
3078
+ var _chainInfo$substrateI, _chainInfo$substrateI2, _chainInfo$substrateI3, _chainInfo$substrateI4;
3055
3079
  registry = new _types3.TypeRegistry();
3056
3080
  const _metadata = new _types3.Metadata(registry, metadata.hexValue);
3057
3081
  registry.register(metadata.types);
3058
3082
  registry.setChainProperties(registry.createType('ChainProperties', {
3059
- ss58Format: (chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$substrateI = chainInfo.substrateInfo) === null || _chainInfo$substrateI === void 0 ? void 0 : _chainInfo$substrateI.addressPrefix) || 42,
3060
- tokenDecimals: chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$substrateI2 = chainInfo.substrateInfo) === null || _chainInfo$substrateI2 === void 0 ? void 0 : _chainInfo$substrateI2.decimals,
3061
- tokenSymbol: chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$substrateI3 = chainInfo.substrateInfo) === null || _chainInfo$substrateI3 === void 0 ? void 0 : _chainInfo$substrateI3.symbol
3083
+ ss58Format: (_chainInfo$substrateI = chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$substrateI2 = chainInfo.substrateInfo) === null || _chainInfo$substrateI2 === void 0 ? void 0 : _chainInfo$substrateI2.addressPrefix) !== null && _chainInfo$substrateI !== void 0 ? _chainInfo$substrateI : 42,
3084
+ tokenDecimals: chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$substrateI3 = chainInfo.substrateInfo) === null || _chainInfo$substrateI3 === void 0 ? void 0 : _chainInfo$substrateI3.decimals,
3085
+ tokenSymbol: chainInfo === null || chainInfo === void 0 ? void 0 : (_chainInfo$substrateI4 = chainInfo.substrateInfo) === null || _chainInfo$substrateI4 === void 0 ? void 0 : _chainInfo$substrateI4.symbol
3062
3086
  }));
3063
3087
  registry.setMetadata(_metadata, payload.signedExtensions, metadata.userExtensions);
3064
3088
  } else {
@@ -4409,9 +4433,9 @@ class KoniExtension {
4409
4433
  case 'pri(accounts.batchExportV2)':
4410
4434
  return this.batchExportV2(request);
4411
4435
  case 'pri(json.restoreV2)':
4412
- return this.jsonRestoreV2(request);
4436
+ return await this.jsonRestoreV2(request);
4413
4437
  case 'pri(json.batchRestoreV2)':
4414
- return this.batchRestoreV2(request);
4438
+ return await this.batchRestoreV2(request);
4415
4439
  case 'pri(nft.getNft)':
4416
4440
  return await this.getNft();
4417
4441
  case 'pri(nft.getSubscription)':
@@ -13,6 +13,6 @@ const packageInfo = {
13
13
  name: '@subwallet/extension-base',
14
14
  path: typeof __dirname === 'string' ? __dirname : 'auto',
15
15
  type: 'cjs',
16
- version: '1.2.30-0'
16
+ version: '1.2.32-0'
17
17
  };
18
18
  exports.packageInfo = packageInfo;
@@ -124,9 +124,6 @@ function subscribeBalance(addresses, chains, tokens, _chainAssetMap, _chainInfoM
124
124
  });
125
125
  }
126
126
  const substrateApi = await substrateApiMap[chainSlug].isReady;
127
- if (!substrateApi.isApiReady) {
128
- handleUnsupportedOrPendingAddresses(useAddresses, chainSlug, chainAssetMap, _KoniTypes.APIItemState.PENDING, callback);
129
- }
130
127
  return (0, _substrate.subscribeSubstrateBalance)(useAddresses, chainInfo, chainAssetMap, substrateApi, evmApi, callback, extrinsicType);
131
128
  });
132
129
  return () => {
@@ -215,6 +215,7 @@ class SubstrateApi {
215
215
  console.log(`Connected to ${this.chainSlug || ''} at ${this.apiUrl}`);
216
216
  if (this.isApiReadyOnce) {
217
217
  this.handleApiReady.resolve(this);
218
+ this.isApiReady = true;
218
219
  }
219
220
  }
220
221
  onDisconnect() {
@@ -73,16 +73,16 @@ class StellaSwapLiquidStakingPoolHandler extends _base.default {
73
73
  const tvlCall = stakingContract.methods.fundRaisedBalance();
74
74
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
75
75
  const exchangeRateCall = stakingContract.methods.getPooledTokenByShares(sampleTokenShare);
76
-
77
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
78
- const [aprObject, tvl, equivalentTokenShare] = await Promise.all([aprPromise,
79
- // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
80
- tvlCall.call(),
81
76
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
82
- exchangeRateCall.call()]);
77
+ const equivalentTokenShare = await exchangeRateCall.call();
83
78
  const rate = equivalentTokenShare;
84
79
  const exchangeRate = rate / 10 ** (0, _utils._getAssetDecimals)(derivativeTokenInfo);
85
80
  this.updateExchangeRate(rate);
81
+
82
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
83
+ const [aprObject, tvl] = await Promise.all([aprPromise,
84
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
85
+ tvlCall.call()]);
86
86
  return {
87
87
  ...this.baseInfo,
88
88
  type: this.type,
@@ -98,11 +98,12 @@ class ChainflipSwapHandler {
98
98
  const toAsset = this.chainService.getAssetBySlug(request.pair.to);
99
99
  const srcChain = fromAsset.originChain;
100
100
  const destChain = toAsset.originChain;
101
+ const isSwapCrossChain = srcChain !== destChain;
101
102
  const srcChainInfo = this.chainService.getChainInfoByKey(srcChain);
102
103
  const srcChainId = this.chainMapping[srcChain];
103
104
  const destChainId = this.chainMapping[destChain];
104
- const fromAssetId = this.assetMapping[fromAsset.slug];
105
- const toAssetId = this.assetMapping[toAsset.slug];
105
+ const fromAssetId = (0, _utils._getAssetSymbol)(fromAsset);
106
+ const toAssetId = (0, _utils._getAssetSymbol)(toAsset);
106
107
  if (!srcChainId || !destChainId || !fromAssetId || !toAssetId) {
107
108
  return {
108
109
  error: _swap3.SwapErrorType.ASSET_NOT_SUPPORTED
@@ -110,9 +111,21 @@ class ChainflipSwapHandler {
110
111
  }
111
112
  const [supportedDestChains, srcAssets, destAssets] = await Promise.all([this.swapSdk.getChains(srcChainId), this.swapSdk.getAssets(srcChainId), this.swapSdk.getAssets(destChainId)]);
112
113
  const supportedDestChainId = supportedDestChains.find(c => c.chain === destChainId);
113
- const srcAssetData = srcAssets.find(a => a.asset === fromAssetId);
114
- const destAssetData = destAssets.find(a => a.asset === toAssetId);
115
- if (!destAssetData || !srcAssetData || !supportedDestChainId) {
114
+ const srcAssetData = srcAssets.find(a => {
115
+ if ((0, _utils._isSmartContractToken)(fromAsset)) {
116
+ var _a$contractAddress;
117
+ return (a === null || a === void 0 ? void 0 : (_a$contractAddress = a.contractAddress) === null || _a$contractAddress === void 0 ? void 0 : _a$contractAddress.toLowerCase()) === (0, _utils._getContractAddressOfToken)(fromAsset).toLowerCase() && a.asset === fromAssetId;
118
+ }
119
+ return a.asset === fromAssetId;
120
+ });
121
+ const destAssetData = destAssets.find(a => {
122
+ if ((0, _utils._isSmartContractToken)(toAsset)) {
123
+ var _a$contractAddress2;
124
+ return (a === null || a === void 0 ? void 0 : (_a$contractAddress2 = a.contractAddress) === null || _a$contractAddress2 === void 0 ? void 0 : _a$contractAddress2.toLowerCase()) === (0, _utils._getContractAddressOfToken)(toAsset).toLowerCase() && a.asset === toAssetId;
125
+ }
126
+ return a.asset === toAssetId;
127
+ });
128
+ if (!destAssetData || !srcAssetData || isSwapCrossChain && !supportedDestChainId) {
116
129
  return {
117
130
  error: _swap3.SwapErrorType.UNKNOWN
118
131
  };
@@ -208,8 +221,8 @@ class ChainflipSwapHandler {
208
221
  }
209
222
  const srcChainId = this.chainMapping[fromAsset.originChain];
210
223
  const destChainId = this.chainMapping[toAsset.originChain];
211
- const fromAssetId = this.assetMapping[fromAsset.slug];
212
- const toAssetId = this.assetMapping[toAsset.slug];
224
+ const fromAssetId = (0, _utils._getAssetSymbol)(fromAsset);
225
+ const toAssetId = (0, _utils._getAssetSymbol)(toAsset);
213
226
  try {
214
227
  var _metadata$maxSwap;
215
228
  const quoteResponse = await this.swapSdk.getQuote({
@@ -223,13 +236,22 @@ class ChainflipSwapHandler {
223
236
  quoteResponse.quote.includedFees.forEach(fee => {
224
237
  switch (fee.type) {
225
238
  case ChainflipFeeType.INGRESS:
239
+ {
240
+ console.log('ingress', fee);
241
+ feeComponent.push({
242
+ tokenSlug: fromAsset.slug,
243
+ amount: fee.amount,
244
+ feeType: _swap3.SwapFeeType.NETWORK_FEE
245
+ });
246
+ break;
247
+ }
226
248
 
227
249
  // eslint-disable-next-line no-fallthrough
228
250
  case ChainflipFeeType.EGRESS:
229
251
  {
230
- const tokenSlug = Object.keys(this.assetMapping).find(assetSlug => this.assetMapping[assetSlug] === fee.asset);
252
+ console.log('egress', fee);
231
253
  feeComponent.push({
232
- tokenSlug,
254
+ tokenSlug: toAsset.slug,
233
255
  amount: fee.amount,
234
256
  feeType: _swap3.SwapFeeType.NETWORK_FEE
235
257
  });
@@ -243,9 +265,9 @@ class ChainflipSwapHandler {
243
265
  // eslint-disable-next-line no-fallthrough
244
266
  case ChainflipFeeType.BROKER:
245
267
  {
246
- const tokenSlug = Object.keys(this.assetMapping).find(assetSlug => this.assetMapping[assetSlug] === fee.asset);
268
+ console.log('broker fee', fee);
247
269
  feeComponent.push({
248
- tokenSlug,
270
+ tokenSlug: this.intermediaryAssetSlug,
249
271
  amount: fee.amount,
250
272
  feeType: _swap3.SwapFeeType.PLATFORM_FEE
251
273
  });
@@ -330,8 +352,8 @@ class ChainflipSwapHandler {
330
352
  const receiver = recipient !== null && recipient !== void 0 ? recipient : address;
331
353
  const srcChainId = this.chainMapping[fromAsset.originChain];
332
354
  const destChainId = this.chainMapping[toAsset.originChain];
333
- const fromAssetId = this.assetMapping[fromAsset.slug];
334
- const toAssetId = this.assetMapping[toAsset.slug];
355
+ const fromAssetId = (0, _utils._getAssetSymbol)(fromAsset);
356
+ const toAssetId = (0, _utils._getAssetSymbol)(toAsset);
335
357
  const depositAddressResponse = await this.swapSdk.requestDepositAddress({
336
358
  srcChain: srcChainId,
337
359
  destChain: destChainId,
@@ -26,7 +26,8 @@ const CHAIN_FLIP_MAINNET_EXPLORER = 'https://scan.chainflip.io';
26
26
  exports.CHAIN_FLIP_MAINNET_EXPLORER = CHAIN_FLIP_MAINNET_EXPLORER;
27
27
  const CHAIN_FLIP_SUPPORTED_MAINNET_MAPPING = {
28
28
  [_chainList.COMMON_CHAIN_SLUGS.POLKADOT]: _swap.Chains.Polkadot,
29
- [_chainList.COMMON_CHAIN_SLUGS.ETHEREUM]: _swap.Chains.Ethereum
29
+ [_chainList.COMMON_CHAIN_SLUGS.ETHEREUM]: _swap.Chains.Ethereum,
30
+ [_chainList.COMMON_CHAIN_SLUGS.ARBITRUM]: _swap.Chains.Arbitrum
30
31
  };
31
32
  exports.CHAIN_FLIP_SUPPORTED_MAINNET_MAPPING = CHAIN_FLIP_SUPPORTED_MAINNET_MAPPING;
32
33
  const CHAIN_FLIP_SUPPORTED_TESTNET_MAPPING = {
@@ -37,7 +38,8 @@ exports.CHAIN_FLIP_SUPPORTED_TESTNET_MAPPING = CHAIN_FLIP_SUPPORTED_TESTNET_MAPP
37
38
  const CHAIN_FLIP_SUPPORTED_MAINNET_ASSET_MAPPING = {
38
39
  [_chainList.COMMON_ASSETS.DOT]: _swap.Assets.DOT,
39
40
  [_chainList.COMMON_ASSETS.ETH]: _swap.Assets.ETH,
40
- [_chainList.COMMON_ASSETS.USDC_ETHEREUM]: _swap.Assets.USDC
41
+ [_chainList.COMMON_ASSETS.USDC_ETHEREUM]: _swap.Assets.USDC,
42
+ [_chainList.COMMON_ASSETS.USDT_ETHEREUM]: _swap.Assets.USDT
41
43
  };
42
44
  exports.CHAIN_FLIP_SUPPORTED_MAINNET_ASSET_MAPPING = CHAIN_FLIP_SUPPORTED_MAINNET_ASSET_MAPPING;
43
45
  const CHAIN_FLIP_SUPPORTED_TESTNET_ASSET_MAPPING = {
@@ -56,7 +58,7 @@ exports.SWAP_QUOTE_TIMEOUT_MAP = SWAP_QUOTE_TIMEOUT_MAP;
56
58
  const _PROVIDER_TO_SUPPORTED_PAIR_MAP = {
57
59
  [_swap2.SwapProviderId.HYDRADX_MAINNET]: [_chainList.COMMON_CHAIN_SLUGS.HYDRADX],
58
60
  [_swap2.SwapProviderId.HYDRADX_TESTNET]: [_chainList.COMMON_CHAIN_SLUGS.HYDRADX_TESTNET],
59
- [_swap2.SwapProviderId.CHAIN_FLIP_MAINNET]: [_chainList.COMMON_CHAIN_SLUGS.POLKADOT, _chainList.COMMON_CHAIN_SLUGS.ETHEREUM],
61
+ [_swap2.SwapProviderId.CHAIN_FLIP_MAINNET]: [_chainList.COMMON_CHAIN_SLUGS.POLKADOT, _chainList.COMMON_CHAIN_SLUGS.ETHEREUM, _chainList.COMMON_CHAIN_SLUGS.ARBITRUM],
60
62
  [_swap2.SwapProviderId.CHAIN_FLIP_TESTNET]: [_chainList.COMMON_CHAIN_SLUGS.CHAINFLIP_POLKADOT, _chainList.COMMON_CHAIN_SLUGS.ETHEREUM_SEPOLIA],
61
63
  [_swap2.SwapProviderId.POLKADOT_ASSET_HUB]: [_chainList.COMMON_CHAIN_SLUGS.POLKADOT_ASSET_HUB],
62
64
  [_swap2.SwapProviderId.KUSAMA_ASSET_HUB]: [_chainList.COMMON_CHAIN_SLUGS.KUSAMA_ASSET_HUB],
@@ -75,6 +75,13 @@ class TransactionService {
75
75
  chain,
76
76
  extrinsicType
77
77
  } = validationResponse;
78
+ const chainInfo = this.state.chainService.getChainInfoByKey(chain);
79
+ const {
80
+ blockedActionsMap,
81
+ blockedFeaturesList
82
+ } = await (0, _constants.fetchLastestBlockedActionsAndFeatures)();
83
+ (0, _transfer.checkSupportForFeature)(validationResponse, blockedFeaturesList, chainInfo);
84
+ (0, _transfer.checkSupportForAction)(validationResponse, blockedActionsMap);
78
85
  const transaction = transactionInput.transaction;
79
86
 
80
87
  // Check duplicated transaction
@@ -82,7 +89,6 @@ class TransactionService {
82
89
 
83
90
  // Check support for transaction
84
91
  (0, _transfer.checkSupportForTransaction)(validationResponse, transaction);
85
- const chainInfo = this.state.chainService.getChainInfoByKey(chain);
86
92
  if (!chainInfo) {
87
93
  validationResponse.errors.push(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INTERNAL_ERROR, (0, _i18next.t)('Cannot find network')));
88
94
  }
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.termAndCondition = exports.staticData = exports.marketingCampaigns = exports.currencySymbol = exports.crowdloanFunds = exports.buyTokenConfigs = exports.buyServiceInfos = exports.StaticKey = void 0;
6
+ exports.termAndCondition = exports.staticData = exports.marketingCampaigns = exports.currencySymbol = exports.crowdloanFunds = exports.buyTokenConfigs = exports.buyServiceInfos = exports.blockedActionsFeatures = exports.StaticKey = void 0;
7
7
  var _chainList = require("@subwallet/chain-list");
8
8
  // Copyright 2019-2022 @subwallet/extension-base authors & contributors
9
9
  // SPDX-License-Identifier: Apache-2.0
@@ -27,7 +27,10 @@ const termAndCondition = require('./termAndCondition.json');
27
27
  // eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
28
28
  exports.termAndCondition = termAndCondition;
29
29
  const currencySymbol = require('./currencySymbol.json');
30
+ // eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
30
31
  exports.currencySymbol = currencySymbol;
32
+ const blockedActionsFeatures = require('./blockedActionsFeatures.json');
33
+ exports.blockedActionsFeatures = blockedActionsFeatures;
31
34
  let StaticKey;
32
35
  exports.StaticKey = StaticKey;
33
36
  (function (StaticKey) {
@@ -38,6 +41,7 @@ exports.StaticKey = StaticKey;
38
41
  StaticKey["CROWDLOAN_FUNDS"] = "crowdloan-funds";
39
42
  StaticKey["TERM_AND_CONDITION"] = "term-and-condition";
40
43
  StaticKey["BUY_TOKEN_CONFIGS"] = "buy-token-configs";
44
+ StaticKey["BLOCKED_ACTIONS_FEATURES"] = "blocked-actions-features";
41
45
  })(StaticKey || (exports.StaticKey = StaticKey = {}));
42
46
  const staticData = {
43
47
  [StaticKey.CHAINS]: Object.values(_chainList.ChainInfoMap),
@@ -46,6 +50,7 @@ const staticData = {
46
50
  [StaticKey.CROWDLOAN_FUNDS]: crowdloanFunds,
47
51
  [StaticKey.MARKETING_CAMPAINGS]: marketingCampaigns,
48
52
  [StaticKey.TERM_AND_CONDITION]: termAndCondition.default,
49
- [StaticKey.BUY_TOKEN_CONFIGS]: buyTokenConfigs
53
+ [StaticKey.BUY_TOKEN_CONFIGS]: buyTokenConfigs,
54
+ [StaticKey.BLOCKED_ACTIONS_FEATURES]: blockedActionsFeatures
50
55
  };
51
56
  exports.staticData = staticData;
@@ -0,0 +1,7 @@
1
+ import { ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
2
+ interface BlockedActionsFeaturesMap {
3
+ blockedActionsMap: Record<ExtrinsicType, string[]>;
4
+ blockedFeaturesList: string[];
5
+ }
6
+ export declare const fetchLastestBlockedActionsAndFeatures: () => Promise<BlockedActionsFeaturesMap>;
7
+ export {};
@@ -0,0 +1,8 @@
1
+ // Copyright 2019-2022 @subwallet/extension-base authors & contributors
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { fetchStaticData } from '@subwallet/extension-base/utils';
5
+ const BLOCKED_ACTIONS_AND_FEATURES_PROMISE = fetchStaticData('blocked-actions-features');
6
+ export const fetchLastestBlockedActionsAndFeatures = async () => {
7
+ return await BLOCKED_ACTIONS_AND_FEATURES_PROMISE;
8
+ };
@@ -32,3 +32,4 @@ export declare const ORDINAL_METHODS: string[];
32
32
  export declare const PERMISSIONS_TO_REVOKE: string[];
33
33
  export * from './staking';
34
34
  export * from './storage';
35
+ export * from './blocked-actions-list';
@@ -34,4 +34,5 @@ export const ORDINAL_COLLECTION = '__Ordinal__';
34
34
  export const ORDINAL_METHODS = ['drc-20', 'pol-20'];
35
35
  export const PERMISSIONS_TO_REVOKE = ['eth_accounts'];
36
36
  export * from "./staking.js";
37
- export * from "./storage.js";
37
+ export * from "./storage.js";
38
+ export * from "./blocked-actions-list.js";
@@ -10,6 +10,8 @@ export declare function validateTransferRequest(tokenInfo: _ChainAsset, from: _A
10
10
  export declare function additionalValidateTransfer(tokenInfo: _ChainAsset, nativeTokenInfo: _ChainAsset, extrinsicType: ExtrinsicType, receiverTransferTokenFreeBalance: string, transferAmount: string, senderTransferTokenTransferable?: string, receiverNativeTransferable?: string): [TransactionWarning[], TransactionError[]];
11
11
  export declare function validateXcmTransferRequest(destTokenInfo: _ChainAsset | undefined, sender: _Address, sendingValue: string): [TransactionError[], KeyringPair | undefined, BigN | undefined];
12
12
  export declare function additionalValidateXcmTransfer(originTokenInfo: _ChainAsset, destinationTokenInfo: _ChainAsset, sendingAmount: string, senderTransferable: string, receiverNativeBalance: string, destChainInfo: _ChainInfo, isSnowBridge?: boolean): [TransactionWarning | undefined, TransactionError | undefined];
13
+ export declare function checkSupportForFeature(validationResponse: SWTransactionResponse, blockedFeaturesList: string[], chainInfo: _ChainInfo): void;
14
+ export declare function checkSupportForAction(validationResponse: SWTransactionResponse, blockedActionsMap: Record<ExtrinsicType, string[]>): void;
13
15
  export declare function checkSupportForTransaction(validationResponse: SWTransactionResponse, transaction: OptionalSWTransaction): void;
14
16
  export declare function estimateFeeForTransaction(validationResponse: SWTransactionResponse, transaction: OptionalSWTransaction, chainInfo: _ChainInfo, evmApi: _EvmApi): Promise<FeeData>;
15
17
  export declare function checkSigningAccountForTransaction(validationResponse: SWTransactionResponse): void;