@subwallet/extension-base 1.2.8-0 → 1.2.9-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 (130) hide show
  1. package/background/KoniTypes.d.ts +7 -3
  2. package/background/KoniTypes.js +1 -1
  3. package/cjs/background/KoniTypes.js +1 -1
  4. package/cjs/core/logic-validation/transfer.js +22 -2
  5. package/cjs/core/substrate/foreign-asset-pallet.js +16 -0
  6. package/cjs/core/substrate/xcm-parser.js +26 -4
  7. package/cjs/koni/api/contract-handler/evm/web3.js +58 -0
  8. package/cjs/{services/chain-service/helper → koni/api/contract-handler/utils}/index.js +19 -2
  9. package/cjs/koni/api/contract-handler/wasm/index.js +49 -0
  10. package/cjs/koni/api/nft/evm_nft/index.js +6 -6
  11. package/cjs/koni/api/nft/wasm_nft/index.js +16 -16
  12. package/cjs/koni/api/yield/helper/utils.js +1 -22
  13. package/cjs/koni/background/handlers/Extension.js +128 -64
  14. package/cjs/packageInfo.js +1 -1
  15. package/cjs/services/balance-service/helpers/index.js +11 -0
  16. package/cjs/services/balance-service/helpers/process.js +50 -0
  17. package/cjs/services/balance-service/helpers/subscribe/evm.js +11 -3
  18. package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +10 -24
  19. package/cjs/services/balance-service/index.js +20 -0
  20. package/cjs/{koni/api/tokens/evm/transfer.js → services/balance-service/transfer/smart-contract.js} +33 -38
  21. package/cjs/{koni/api/dotsama/transfer.js → services/balance-service/transfer/token.js} +3 -3
  22. package/cjs/{koni/api → services/balance-service/transfer}/xcm/index.js +26 -6
  23. package/cjs/{koni/api → services/balance-service/transfer}/xcm/polkadotXcm.js +2 -2
  24. package/cjs/services/balance-service/transfer/xcm/snowBridge.js +60 -0
  25. package/cjs/{koni/api → services/balance-service/transfer}/xcm/xTokens.js +1 -1
  26. package/cjs/{koni/api → services/balance-service/transfer}/xcm/xcmPallet.js +1 -1
  27. package/cjs/services/chain-service/handler/EvmChainHandler.js +3 -3
  28. package/cjs/services/chain-service/handler/SubstrateChainHandler.js +4 -4
  29. package/cjs/services/chain-service/health-check/utils/asset-info.js +18 -18
  30. package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +16 -35
  31. package/cjs/services/earning-service/handlers/special.js +1 -1
  32. package/cjs/services/swap-service/handler/base-handler.js +3 -2
  33. package/cjs/services/swap-service/handler/chainflip-handler.js +10 -9
  34. package/cjs/services/swap-service/handler/hydradx-handler.js +12 -11
  35. package/cjs/services/swap-service/index.js +3 -2
  36. package/cjs/services/swap-service/utils.js +1 -13
  37. package/cjs/services/transaction-service/index.js +2 -2
  38. package/cjs/types/service-base.js +30 -1
  39. package/cjs/types/swap/index.js +0 -4
  40. package/cjs/utils/eth/parseTransaction/index.js +10 -10
  41. package/core/logic-validation/transfer.d.ts +1 -1
  42. package/core/logic-validation/transfer.js +22 -3
  43. package/core/substrate/foreign-asset-pallet.d.ts +8 -0
  44. package/core/substrate/foreign-asset-pallet.js +9 -0
  45. package/core/substrate/xcm-parser.d.ts +3 -1
  46. package/core/substrate/xcm-parser.js +25 -5
  47. package/koni/api/contract-handler/evm/web3.d.ts +8 -0
  48. package/koni/api/contract-handler/evm/web3.js +45 -0
  49. package/{services/chain-service/helper → koni/api/contract-handler/utils}/index.d.ts +4 -0
  50. package/{services/chain-service/helper → koni/api/contract-handler/utils}/index.js +15 -1
  51. package/koni/api/contract-handler/utils/snowbridge_gateway_abi.json +1122 -0
  52. package/koni/api/{tokens → contract-handler}/wasm/index.d.ts +0 -2
  53. package/koni/api/{tokens → contract-handler}/wasm/index.js +1 -25
  54. package/koni/api/nft/evm_nft/index.js +1 -1
  55. package/koni/api/nft/wasm_nft/index.js +2 -2
  56. package/koni/api/yield/helper/utils.d.ts +1 -5
  57. package/koni/api/yield/helper/utils.js +0 -16
  58. package/koni/background/handlers/Extension.d.ts +2 -0
  59. package/koni/background/handlers/Extension.js +82 -18
  60. package/package.json +85 -79
  61. package/packageInfo.js +1 -1
  62. package/services/balance-service/helpers/index.d.ts +1 -0
  63. package/services/balance-service/helpers/index.js +2 -1
  64. package/services/balance-service/helpers/process.d.ts +13 -0
  65. package/services/balance-service/helpers/process.js +43 -0
  66. package/services/balance-service/helpers/subscribe/evm.js +11 -3
  67. package/services/balance-service/helpers/subscribe/substrate/index.js +11 -25
  68. package/services/balance-service/index.d.ts +3 -0
  69. package/services/balance-service/index.js +21 -1
  70. package/services/balance-service/transfer/smart-contract.d.ts +7 -0
  71. package/{koni/api/tokens/evm/transfer.js → services/balance-service/transfer/smart-contract.js} +28 -31
  72. package/{koni/api/dotsama/transfer.js → services/balance-service/transfer/token.js} +4 -4
  73. package/{koni/api → services/balance-service/transfer}/xcm/index.d.ts +9 -3
  74. package/{koni/api → services/balance-service/transfer}/xcm/index.js +21 -3
  75. package/{koni/api → services/balance-service/transfer}/xcm/polkadotXcm.js +3 -3
  76. package/services/balance-service/transfer/xcm/snowBridge.d.ts +4 -0
  77. package/services/balance-service/transfer/xcm/snowBridge.js +54 -0
  78. package/{koni/api → services/balance-service/transfer}/xcm/xTokens.js +1 -1
  79. package/{koni/api → services/balance-service/transfer}/xcm/xcmPallet.js +1 -1
  80. package/services/chain-service/handler/EvmChainHandler.js +1 -1
  81. package/services/chain-service/handler/SubstrateChainHandler.js +2 -2
  82. package/services/chain-service/health-check/utils/asset-info.js +3 -3
  83. package/services/earning-service/handlers/liquid-staking/stella-swap.js +16 -35
  84. package/services/earning-service/handlers/special.js +1 -1
  85. package/services/swap-service/handler/base-handler.d.ts +5 -5
  86. package/services/swap-service/handler/base-handler.js +4 -3
  87. package/services/swap-service/handler/chainflip-handler.d.ts +4 -4
  88. package/services/swap-service/handler/chainflip-handler.js +7 -6
  89. package/services/swap-service/handler/hydradx-handler.d.ts +6 -6
  90. package/services/swap-service/handler/hydradx-handler.js +12 -11
  91. package/services/swap-service/index.d.ts +3 -2
  92. package/services/swap-service/index.js +4 -3
  93. package/services/swap-service/utils.d.ts +1 -3
  94. package/services/swap-service/utils.js +1 -11
  95. package/services/transaction-service/index.js +2 -2
  96. package/types/service-base.d.ts +31 -3
  97. package/types/service-base.js +23 -1
  98. package/types/swap/index.d.ts +8 -30
  99. package/types/swap/index.js +0 -4
  100. package/types/yield/actions/join/submit.d.ts +7 -4
  101. package/utils/eth/parseTransaction/index.js +1 -1
  102. package/cjs/koni/api/tokens/evm/balance.js +0 -18
  103. package/cjs/koni/api/tokens/evm/web3.js +0 -17
  104. package/cjs/koni/api/tokens/index.js +0 -17
  105. package/cjs/koni/api/tokens/wasm/index.js +0 -74
  106. package/koni/api/tokens/evm/balance.d.ts +0 -2
  107. package/koni/api/tokens/evm/balance.js +0 -12
  108. package/koni/api/tokens/evm/transfer.d.ts +0 -17
  109. package/koni/api/tokens/evm/web3.d.ts +0 -3
  110. package/koni/api/tokens/evm/web3.js +0 -9
  111. package/koni/api/tokens/index.d.ts +0 -1
  112. package/koni/api/tokens/index.js +0 -11
  113. /package/cjs/koni/api/{tokens → contract-handler}/wasm/utils.js +0 -0
  114. /package/cjs/{koni/api → services/balance-service/transfer}/xcm/utils.js +0 -0
  115. /package/{services/chain-service/helper → koni/api/contract-handler/utils}/azero_domain_registry_abi.json +0 -0
  116. /package/{services/chain-service/helper → koni/api/contract-handler/utils}/erc20_abi.json +0 -0
  117. /package/{services/chain-service/helper → koni/api/contract-handler/utils}/erc721_abi.json +0 -0
  118. /package/{services/chain-service/helper → koni/api/contract-handler/utils}/neuroguns_psp34_abi.json +0 -0
  119. /package/{services/chain-service/helper → koni/api/contract-handler/utils}/pink_psp34_abi.json +0 -0
  120. /package/{services/chain-service/helper → koni/api/contract-handler/utils}/psp22_abi.json +0 -0
  121. /package/{services/chain-service/helper → koni/api/contract-handler/utils}/psp34_abi.json +0 -0
  122. /package/{services/chain-service/helper → koni/api/contract-handler/utils}/test_erc721_abi.json +0 -0
  123. /package/koni/api/{tokens → contract-handler}/wasm/utils.d.ts +0 -0
  124. /package/koni/api/{tokens → contract-handler}/wasm/utils.js +0 -0
  125. /package/{koni/api/dotsama/transfer.d.ts → services/balance-service/transfer/token.d.ts} +0 -0
  126. /package/{koni/api → services/balance-service/transfer}/xcm/polkadotXcm.d.ts +0 -0
  127. /package/{koni/api → services/balance-service/transfer}/xcm/utils.d.ts +0 -0
  128. /package/{koni/api → services/balance-service/transfer}/xcm/utils.js +0 -0
  129. /package/{koni/api → services/balance-service/transfer}/xcm/xTokens.d.ts +0 -0
  130. /package/{koni/api → services/balance-service/transfer}/xcm/xcmPallet.d.ts +0 -0
@@ -10,6 +10,7 @@ var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
10
10
  var _swap = require("@subwallet/extension-base/core/logic-validation/swap");
11
11
  var _utils = require("@subwallet/extension-base/services/chain-service/utils");
12
12
  var _utils2 = require("@subwallet/extension-base/services/swap-service/utils");
13
+ var _serviceBase = require("@subwallet/extension-base/types/service-base");
13
14
  var _swap2 = require("@subwallet/extension-base/types/swap");
14
15
  var _utils3 = require("@subwallet/extension-base/utils");
15
16
  var _bignumber = _interopRequireDefault(require("bignumber.js"));
@@ -34,8 +35,8 @@ class SwapBaseHandler {
34
35
  // public abstract getSwapQuote(request: SwapRequest): Promise<SwapQuote | SwapError>;
35
36
  async generateOptimalProcess(params, genStepFuncList) {
36
37
  const result = {
37
- totalFee: [_utils2.MOCK_SWAP_FEE],
38
- steps: [_utils2.DEFAULT_SWAP_FIRST_STEP]
38
+ totalFee: [_serviceBase.MOCK_STEP_FEE],
39
+ steps: [_serviceBase.DEFAULT_FIRST_STEP]
39
40
  };
40
41
  try {
41
42
  for (const genStepFunc of genStepFuncList) {
@@ -11,11 +11,12 @@ var _SwapError = require("@subwallet/extension-base/background/errors/SwapError"
11
11
  var _TransactionError = require("@subwallet/extension-base/background/errors/TransactionError");
12
12
  var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
13
13
  var _swap2 = require("@subwallet/extension-base/core/logic-validation/swap");
14
- var _transfer = require("@subwallet/extension-base/koni/api/dotsama/transfer");
15
- var _transfer2 = require("@subwallet/extension-base/koni/api/tokens/evm/transfer");
14
+ var _smartContract = require("@subwallet/extension-base/services/balance-service/transfer/smart-contract");
15
+ var _token = require("@subwallet/extension-base/services/balance-service/transfer/token");
16
16
  var _utils = require("@subwallet/extension-base/services/chain-service/utils");
17
17
  var _baseHandler = require("@subwallet/extension-base/services/swap-service/handler/base-handler");
18
18
  var _utils2 = require("@subwallet/extension-base/services/swap-service/utils");
19
+ var _serviceBase = require("@subwallet/extension-base/types/service-base");
19
20
  var _swap3 = require("@subwallet/extension-base/types/swap");
20
21
  var _bignumber = _interopRequireDefault(require("bignumber.js"));
21
22
  // Copyright 2019-2022 @subwallet/extension-base
@@ -292,9 +293,9 @@ class ChainflipSwapHandler {
292
293
  for (const [index, step] of params.process.steps.entries()) {
293
294
  const getErrors = async () => {
294
295
  switch (step.type) {
295
- case _swap3.SwapStepType.DEFAULT:
296
+ case _serviceBase.CommonStepType.DEFAULT:
296
297
  return Promise.resolve([]);
297
- case _swap3.SwapStepType.TOKEN_APPROVAL:
298
+ case _serviceBase.CommonStepType.TOKEN_APPROVAL:
298
299
  return Promise.reject(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.UNSUPPORTED));
299
300
  default:
300
301
  return this.swapBaseHandler.validateSwapStep(params, isXcmOk, index);
@@ -303,7 +304,7 @@ class ChainflipSwapHandler {
303
304
  const errors = await getErrors();
304
305
  if (errors.length) {
305
306
  return errors;
306
- } else if (step.type === _swap3.SwapStepType.XCM) {
307
+ } else if (step.type === _serviceBase.CommonStepType.XCM) {
307
308
  isXcmOk = true;
308
309
  }
309
310
  }
@@ -347,7 +348,7 @@ class ChainflipSwapHandler {
347
348
  if (chainType === _KoniTypes.ChainType.SUBSTRATE) {
348
349
  const chainApi = this.chainService.getSubstrateApi(chainInfo.slug);
349
350
  const substrateApi = await chainApi.isReady;
350
- const [submittableExtrinsic] = await (0, _transfer.createTransferExtrinsic)({
351
+ const [submittableExtrinsic] = await (0, _token.createTransferExtrinsic)({
351
352
  from: address,
352
353
  networkKey: chainInfo.slug,
353
354
  substrateApi,
@@ -360,10 +361,10 @@ class ChainflipSwapHandler {
360
361
  extrinsic = submittableExtrinsic;
361
362
  } else {
362
363
  if ((0, _utils._isNativeToken)(fromAsset)) {
363
- const [transactionConfig] = await (0, _transfer2.getEVMTransactionObject)(chainInfo, address, depositAddressResponse.depositAddress, quote.fromAmount, false, this.chainService.getEvmApi(chainInfo.slug));
364
+ const [transactionConfig] = await (0, _smartContract.getEVMTransactionObject)(chainInfo, address, depositAddressResponse.depositAddress, quote.fromAmount, false, this.chainService.getEvmApi(chainInfo.slug));
364
365
  extrinsic = transactionConfig;
365
366
  } else {
366
- const [transactionConfig] = await (0, _transfer2.getERC20TransactionObject)((0, _utils._getContractAddressOfToken)(fromAsset), chainInfo, address, depositAddressResponse.depositAddress, quote.fromAmount, false, this.chainService.getEvmApi(chainInfo.slug));
367
+ const [transactionConfig] = await (0, _smartContract.getERC20TransactionObject)((0, _utils._getContractAddressOfToken)(fromAsset), chainInfo, address, depositAddressResponse.depositAddress, quote.fromAmount, false, this.chainService.getEvmApi(chainInfo.slug));
367
368
  extrinsic = transactionConfig;
368
369
  }
369
370
  }
@@ -384,7 +385,7 @@ class ChainflipSwapHandler {
384
385
  } = params;
385
386
  const type = process.steps[currentStep].type;
386
387
  switch (type) {
387
- case _swap3.SwapStepType.DEFAULT:
388
+ case _serviceBase.CommonStepType.DEFAULT:
388
389
  return Promise.reject(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.UNSUPPORTED));
389
390
  case _swap3.SwapStepType.SWAP:
390
391
  return this.handleSubmitStep(params);
@@ -12,10 +12,11 @@ var _SwapError = require("@subwallet/extension-base/background/errors/SwapError"
12
12
  var _TransactionError = require("@subwallet/extension-base/background/errors/TransactionError");
13
13
  var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
14
14
  var _swap = require("@subwallet/extension-base/core/logic-validation/swap");
15
- var _xcm = require("@subwallet/extension-base/koni/api/xcm");
15
+ var _xcm = require("@subwallet/extension-base/services/balance-service/transfer/xcm");
16
16
  var _utils = require("@subwallet/extension-base/services/chain-service/utils");
17
17
  var _baseHandler = require("@subwallet/extension-base/services/swap-service/handler/base-handler");
18
18
  var _utils2 = require("@subwallet/extension-base/services/swap-service/utils");
19
+ var _serviceBase = require("@subwallet/extension-base/types/service-base");
19
20
  var _swap2 = require("@subwallet/extension-base/types/swap");
20
21
  var _bignumber = _interopRequireDefault(require("bignumber.js"));
21
22
  // Copyright 2019-2022 @subwallet/extension-base
@@ -102,7 +103,7 @@ class HydradxHandler {
102
103
  destinationTokenInfo: fromAsset
103
104
  },
104
105
  name: `Transfer ${alternativeAsset.symbol} from ${alternativeChainInfo.name}`,
105
- type: _swap2.SwapStepType.XCM
106
+ type: _serviceBase.CommonStepType.XCM
106
107
  };
107
108
  const xcmOriginSubstrateApi = await this.chainService.getSubstrateApi(alternativeAsset.originChain).isReady;
108
109
  const xcmTransfer = await (0, _xcm.createXcmExtrinsic)({
@@ -139,7 +140,7 @@ class HydradxHandler {
139
140
  }
140
141
  const feeStep = {
141
142
  name: 'Set fee token',
142
- type: _swap2.SwapStepType.SET_FEE_TOKEN
143
+ type: _serviceBase.CommonStepType.SET_FEE_TOKEN
143
144
  };
144
145
  try {
145
146
  const substrateApi = this.chainService.getSubstrateApi(this.chain());
@@ -385,7 +386,7 @@ class HydradxHandler {
385
386
  const referral = _referral === null || _referral === void 0 ? void 0 : _referral.toString();
386
387
  const needSetReferral = !referral || referral === '';
387
388
  const steps = params.process.steps.map(step => step.type);
388
- const needSetFeeToken = steps.includes(_swap2.SwapStepType.SET_FEE_TOKEN);
389
+ const needSetFeeToken = steps.includes(_serviceBase.CommonStepType.SET_FEE_TOKEN);
389
390
  if (!needSetReferral && !needSetFeeToken) {
390
391
  extrinsic = swapTx;
391
392
  } else {
@@ -416,11 +417,11 @@ class HydradxHandler {
416
417
  } = params;
417
418
  const type = process.steps[currentStep].type;
418
419
  switch (type) {
419
- case _swap2.SwapStepType.DEFAULT:
420
+ case _serviceBase.CommonStepType.DEFAULT:
420
421
  return Promise.reject(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.UNSUPPORTED));
421
- case _swap2.SwapStepType.XCM:
422
+ case _serviceBase.CommonStepType.XCM:
422
423
  return this.handleXcmStep(params);
423
- case _swap2.SwapStepType.SET_FEE_TOKEN:
424
+ case _serviceBase.CommonStepType.SET_FEE_TOKEN:
424
425
  return this.handleSetFeeStep(params);
425
426
  case _swap2.SwapStepType.SWAP:
426
427
  return this.handleSubmitStep(params);
@@ -438,11 +439,11 @@ class HydradxHandler {
438
439
  for (const [index, step] of params.process.steps.entries()) {
439
440
  const getErrors = async () => {
440
441
  switch (step.type) {
441
- case _swap2.SwapStepType.DEFAULT:
442
+ case _serviceBase.CommonStepType.DEFAULT:
442
443
  return Promise.resolve([]);
443
- case _swap2.SwapStepType.XCM:
444
+ case _serviceBase.CommonStepType.XCM:
444
445
  return this.swapBaseHandler.validateXcmStep(params, index);
445
- case _swap2.SwapStepType.SET_FEE_TOKEN:
446
+ case _serviceBase.CommonStepType.SET_FEE_TOKEN:
446
447
  return this.swapBaseHandler.validateSetFeeTokenStep(params, index);
447
448
  default:
448
449
  return this.swapBaseHandler.validateSwapStep(params, isXcmOk, index);
@@ -451,7 +452,7 @@ class HydradxHandler {
451
452
  const errors = await getErrors();
452
453
  if (errors.length) {
453
454
  return errors;
454
- } else if (step.type === _swap2.SwapStepType.XCM) {
455
+ } else if (step.type === _serviceBase.CommonStepType.XCM) {
455
456
  isXcmOk = true;
456
457
  }
457
458
  }
@@ -11,6 +11,7 @@ var _types = require("@subwallet/extension-base/services/base/types");
11
11
  var _chainflipHandler = require("@subwallet/extension-base/services/swap-service/handler/chainflip-handler");
12
12
  var _hydradxHandler = require("@subwallet/extension-base/services/swap-service/handler/hydradx-handler");
13
13
  var _utils = require("@subwallet/extension-base/services/swap-service/utils");
14
+ var _serviceBase = require("@subwallet/extension-base/types/service-base");
14
15
  var _swap = require("@subwallet/extension-base/types/swap");
15
16
  var _utils2 = require("@subwallet/extension-base/utils");
16
17
  var _rxjs = require("rxjs");
@@ -56,8 +57,8 @@ class SwapService {
56
57
 
57
58
  getDefaultProcess(params) {
58
59
  const result = {
59
- totalFee: [_utils.MOCK_SWAP_FEE],
60
- steps: [_utils.DEFAULT_SWAP_FIRST_STEP]
60
+ totalFee: [_serviceBase.MOCK_STEP_FEE],
61
+ steps: [_serviceBase.DEFAULT_FIRST_STEP]
61
62
  };
62
63
  result.totalFee.push({
63
64
  feeComponent: [],
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports._PROVIDER_TO_SUPPORTED_PAIR_MAP = exports.SWAP_QUOTE_TIMEOUT_MAP = exports.MOCK_SWAP_FEE = exports.DEFAULT_SWAP_FIRST_STEP = exports.CHAIN_FLIP_TESTNET_EXPLORER = exports.CHAIN_FLIP_SUPPORTED_TESTNET_MAPPING = exports.CHAIN_FLIP_SUPPORTED_TESTNET_ASSET_MAPPING = exports.CHAIN_FLIP_SUPPORTED_MAINNET_MAPPING = exports.CHAIN_FLIP_SUPPORTED_MAINNET_ASSET_MAPPING = exports.CHAIN_FLIP_MAINNET_EXPLORER = void 0;
7
+ exports._PROVIDER_TO_SUPPORTED_PAIR_MAP = exports.SWAP_QUOTE_TIMEOUT_MAP = exports.CHAIN_FLIP_TESTNET_EXPLORER = exports.CHAIN_FLIP_SUPPORTED_TESTNET_MAPPING = exports.CHAIN_FLIP_SUPPORTED_TESTNET_ASSET_MAPPING = exports.CHAIN_FLIP_SUPPORTED_MAINNET_MAPPING = exports.CHAIN_FLIP_SUPPORTED_MAINNET_ASSET_MAPPING = exports.CHAIN_FLIP_MAINNET_EXPLORER = void 0;
8
8
  exports.calculateSwapRate = calculateSwapRate;
9
9
  exports.getSwapAltToken = getSwapAltToken;
10
10
  exports.getSwapAlternativeAsset = getSwapAlternativeAsset;
@@ -49,18 +49,6 @@ const SWAP_QUOTE_TIMEOUT_MAP = {
49
49
  [_swap2.SwapProviderId.CHAIN_FLIP_MAINNET]: 30000
50
50
  };
51
51
  exports.SWAP_QUOTE_TIMEOUT_MAP = SWAP_QUOTE_TIMEOUT_MAP;
52
- const DEFAULT_SWAP_FIRST_STEP = {
53
- id: 0,
54
- name: 'Fill information',
55
- type: _swap2.SwapStepType.DEFAULT
56
- };
57
- exports.DEFAULT_SWAP_FIRST_STEP = DEFAULT_SWAP_FIRST_STEP;
58
- const MOCK_SWAP_FEE = {
59
- feeComponent: [],
60
- defaultFeeToken: '',
61
- feeOptions: []
62
- };
63
- exports.MOCK_SWAP_FEE = MOCK_SWAP_FEE;
64
52
  const _PROVIDER_TO_SUPPORTED_PAIR_MAP = {
65
53
  [_swap2.SwapProviderId.HYDRADX_MAINNET]: [_chainList.COMMON_CHAIN_SLUGS.HYDRADX],
66
54
  [_swap2.SwapProviderId.HYDRADX_TESTNET]: [_chainList.COMMON_CHAIN_SLUGS.HYDRADX_TESTNET],
@@ -546,10 +546,10 @@ class TransactionService {
546
546
  }
547
547
  break;
548
548
  }
549
- case _KoniTypes.ExtrinsicType.TOKEN_APPROVE:
549
+ case _KoniTypes.ExtrinsicType.TOKEN_SPENDING_APPROVAL:
550
550
  {
551
551
  const data = (0, _utils2.parseTransactionData)(transaction.data);
552
- const inputAsset = this.state.chainService.getAssetBySlug(data.inputTokenSlug);
552
+ const inputAsset = this.state.chainService.getAssetBySlug(data.contractAddress);
553
553
  historyItem.amount = {
554
554
  value: '0',
555
555
  symbol: (0, _utils._getAssetSymbol)(inputAsset),
@@ -1 +1,30 @@
1
- "use strict";
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.MOCK_STEP_FEE = exports.DEFAULT_FIRST_STEP = exports.CommonStepType = void 0;
7
+ // Copyright 2019-2022 @subwallet/extension-base
8
+ // SPDX-License-Identifier: Apache-2.0
9
+ /* ServiceWithProcess */
10
+ let CommonStepType;
11
+ exports.CommonStepType = CommonStepType;
12
+ (function (CommonStepType) {
13
+ CommonStepType["DEFAULT"] = "DEFAULT";
14
+ CommonStepType["XCM"] = "XCM";
15
+ CommonStepType["TOKEN_APPROVAL"] = "TOKEN_APPROVAL";
16
+ CommonStepType["SET_FEE_TOKEN"] = "SET_FEE_TOKEN";
17
+ CommonStepType["TRANSFER"] = "TRANSFER";
18
+ })(CommonStepType || (exports.CommonStepType = CommonStepType = {}));
19
+ const DEFAULT_FIRST_STEP = {
20
+ id: 0,
21
+ name: 'Fill information',
22
+ type: CommonStepType.DEFAULT
23
+ };
24
+ exports.DEFAULT_FIRST_STEP = DEFAULT_FIRST_STEP;
25
+ const MOCK_STEP_FEE = {
26
+ feeComponent: [],
27
+ defaultFeeToken: '',
28
+ feeOptions: []
29
+ };
30
+ exports.MOCK_STEP_FEE = MOCK_STEP_FEE;
@@ -24,11 +24,7 @@ exports.SwapErrorType = SwapErrorType;
24
24
  let SwapStepType;
25
25
  exports.SwapStepType = SwapStepType;
26
26
  (function (SwapStepType) {
27
- SwapStepType["DEFAULT"] = "DEFAULT";
28
- SwapStepType["TOKEN_APPROVAL"] = "TOKEN_APPROVAL";
29
- SwapStepType["SET_FEE_TOKEN"] = "SET_FEE_TOKEN";
30
27
  SwapStepType["SWAP"] = "SWAP";
31
- SwapStepType["XCM"] = "XCM";
32
28
  })(SwapStepType || (exports.SwapStepType = SwapStepType = {}));
33
29
  let SwapProviderId;
34
30
  exports.SwapProviderId = SwapProviderId;
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.parseEvmRlp = exports.parseContractInput = exports.isContractAddress = void 0;
8
- var _helper = require("@subwallet/extension-base/services/chain-service/helper");
9
- var _utils = require("@subwallet/extension-base/services/chain-service/utils");
10
- var _utils2 = require("@subwallet/extension-base/utils");
8
+ var _utils = require("@subwallet/extension-base/koni/api/contract-handler/utils");
9
+ var _utils2 = require("@subwallet/extension-base/services/chain-service/utils");
10
+ var _utils3 = require("@subwallet/extension-base/utils");
11
11
  var _eth = require("@subwallet/extension-base/utils/eth");
12
12
  var _base = require("@subwallet/extension-base/utils/eth/parseTransaction/base");
13
13
  var _bignumber = _interopRequireDefault(require("bignumber.js"));
@@ -16,7 +16,7 @@ var _i18next = require("i18next");
16
16
  // SPDX-License-Identifier: Apache-2.0
17
17
 
18
18
  // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
19
- const ABIs = [_helper._ERC20_ABI, _helper._ERC721_ABI];
19
+ const ABIs = [_utils._ERC20_ABI, _utils._ERC721_ABI];
20
20
  const genName = name => {
21
21
  if (typeof name === 'string') {
22
22
  return name;
@@ -135,9 +135,9 @@ const parseContractInput = async (input, contractAddress, network) => {
135
135
  }
136
136
  }
137
137
  if (contractAddress && network) {
138
- if ((0, _utils._getEvmAbiExplorer)(network)) {
138
+ if ((0, _utils2._getEvmAbiExplorer)(network)) {
139
139
  try {
140
- const data = await (0, _utils2.fetchJson)((0, _utils._getEvmAbiExplorer)(network), {
140
+ const data = await (0, _utils3.fetchJson)((0, _utils2._getEvmAbiExplorer)(network), {
141
141
  params: {
142
142
  address: contractAddress
143
143
  },
@@ -168,7 +168,7 @@ const getChainInfoByChainId = (networkMap, chainId) => {
168
168
  continue;
169
169
  }
170
170
  const networkInfo = networkMap[n];
171
- if ((0, _utils._isChainEvmCompatible)(networkInfo)) {
171
+ if ((0, _utils2._isChainEvmCompatible)(networkInfo)) {
172
172
  return networkInfo;
173
173
  }
174
174
  }
@@ -179,7 +179,7 @@ const getChainInfoByChainId = (networkMap, chainId) => {
179
179
  continue;
180
180
  }
181
181
  const networkInfo = networkMap[n];
182
- if ((0, _utils._getEvmChainId)(networkInfo) === chainId) {
182
+ if ((0, _utils2._getEvmChainId)(networkInfo) === chainId) {
183
183
  return networkInfo;
184
184
  }
185
185
  }
@@ -209,9 +209,9 @@ const parseEvmRlp = async (data, networkMap, evmApiMap) => {
209
209
  }
210
210
  if (tx.to && network) {
211
211
  if (await isContractAddress(tx.to, evmApiMap[network.slug])) {
212
- if ((0, _utils._getEvmAbiExplorer)(network) !== '') {
212
+ if ((0, _utils2._getEvmAbiExplorer)(network) !== '') {
213
213
  try {
214
- const data = await (0, _utils2.fetchJson)((0, _utils._getEvmAbiExplorer)(network), {
214
+ const data = await (0, _utils3.fetchJson)((0, _utils2._getEvmAbiExplorer)(network), {
215
215
  params: {
216
216
  address: tx.to
217
217
  },
@@ -9,7 +9,7 @@ import BigN from 'bignumber.js';
9
9
  export declare function validateTransferRequest(tokenInfo: _ChainAsset, from: _Address, to: _Address, value: string | undefined, transferAll: boolean | undefined): [TransactionError[], KeyringPair | undefined, BigN | undefined];
10
10
  export declare function additionalValidateTransfer(tokenInfo: _ChainAsset, extrinsicType: ExtrinsicType, receiverTransferTokenFreeBalance: string, transferAmount: string, senderTransferTokenTransferable?: string): [TransactionWarning | undefined, TransactionError | undefined];
11
11
  export declare function validateXcmTransferRequest(destTokenInfo: _ChainAsset | undefined, sender: _Address, sendingValue: string): [TransactionError[], KeyringPair | undefined, BigN | undefined];
12
- export declare function additionalValidateXcmTransfer(originTokenInfo: _ChainAsset, destinationTokenInfo: _ChainAsset, sendingAmount: string, senderTransferable: string): [TransactionWarning | undefined, TransactionError | undefined];
12
+ export declare function additionalValidateXcmTransfer(originTokenInfo: _ChainAsset, destinationTokenInfo: _ChainAsset, sendingAmount: string, senderTransferable: string, receiverNativeBalance: string, destChainInfo: _ChainInfo, isSnowBridge?: boolean): [TransactionWarning | undefined, TransactionError | undefined];
13
13
  export declare function checkSupportForTransaction(validationResponse: SWTransactionResponse, transaction: OptionalSWTransaction): void;
14
14
  export declare function estimateFeeForTransaction(validationResponse: SWTransactionResponse, transaction: OptionalSWTransaction, chainInfo: _ChainInfo, evmApi: _EvmApi): Promise<FeeData>;
15
15
  export declare function checkSigningAccountForTransaction(validationResponse: SWTransactionResponse): void;
@@ -7,7 +7,7 @@ import { TransactionWarning } from '@subwallet/extension-base/background/warning
7
7
  import { XCM_MIN_AMOUNT_RATIO } from '@subwallet/extension-base/constants';
8
8
  import { _canAccountBeReaped } from '@subwallet/extension-base/core/substrate/system-pallet';
9
9
  import { _TRANSFER_CHAIN_GROUP } from '@subwallet/extension-base/services/chain-service/constants';
10
- import { _getChainNativeTokenBasicInfo, _getContractAddressOfToken, _getTokenMinAmount, _isNativeToken, _isTokenEvmSmartContract } from '@subwallet/extension-base/services/chain-service/utils';
10
+ import { _getChainExistentialDeposit, _getChainNativeTokenBasicInfo, _getContractAddressOfToken, _getTokenMinAmount, _isNativeToken, _isTokenEvmSmartContract } from '@subwallet/extension-base/services/chain-service/utils';
11
11
  import { calculateGasFeeParams } from '@subwallet/extension-base/services/fee-service/utils';
12
12
  import { isSubstrateTransaction } from '@subwallet/extension-base/services/transaction-service/helpers';
13
13
  import { balanceFormatter, formatNumber } from '@subwallet/extension-base/utils';
@@ -75,13 +75,13 @@ export function validateXcmTransferRequest(destTokenInfo, sender, sendingValue)
75
75
  }
76
76
  return [errors, keypair, transferValue];
77
77
  }
78
- export function additionalValidateXcmTransfer(originTokenInfo, destinationTokenInfo, sendingAmount, senderTransferable) {
78
+ export function additionalValidateXcmTransfer(originTokenInfo, destinationTokenInfo, sendingAmount, senderTransferable, receiverNativeBalance, destChainInfo, isSnowBridge = false) {
79
79
  const destMinAmount = _getTokenMinAmount(destinationTokenInfo);
80
80
  const minSendingRequired = new BigN(destMinAmount).multipliedBy(XCM_MIN_AMOUNT_RATIO);
81
81
  let error;
82
82
  let warning;
83
83
 
84
- // Check ed for receiver
84
+ // Check sending token ED for receiver
85
85
  if (new BigN(sendingAmount).lt(minSendingRequired)) {
86
86
  const atLeastStr = formatNumber(minSendingRequired, destinationTokenInfo.decimals || 0, balanceFormatter, {
87
87
  maxNumberFormat: destinationTokenInfo.decimals || 6
@@ -94,6 +94,25 @@ export function additionalValidateXcmTransfer(originTokenInfo, destinationTokenI
94
94
  }));
95
95
  }
96
96
 
97
+ // check native token ED on dest chain for receiver
98
+ const bnKeepAliveBalance = _isNativeToken(destinationTokenInfo) ? new BigN(receiverNativeBalance).plus(sendingAmount) : new BigN(receiverNativeBalance);
99
+ if (isSnowBridge && bnKeepAliveBalance.lt(_getChainExistentialDeposit(destChainInfo))) {
100
+ const {
101
+ decimals,
102
+ symbol
103
+ } = _getChainNativeTokenBasicInfo(destChainInfo);
104
+ const atLeastStr = formatNumber(_getChainExistentialDeposit(destChainInfo), decimals || 0, balanceFormatter, {
105
+ maxNumberFormat: 6
106
+ });
107
+ error = new TransactionError(TransferTxErrorType.RECEIVER_NOT_ENOUGH_EXISTENTIAL_DEPOSIT, t(' Insufficient {{symbol}} on {{chain}} to cover min balance ({{amount}} {{symbol}})', {
108
+ replace: {
109
+ amount: atLeastStr,
110
+ symbol,
111
+ chain: destChainInfo.name
112
+ }
113
+ }));
114
+ }
115
+
97
116
  // Check ed for sender
98
117
  if (!_isNativeToken(originTokenInfo)) {
99
118
  if (new BigN(senderTransferable).minus(sendingAmount).lt(_getTokenMinAmount(originTokenInfo))) {
@@ -0,0 +1,8 @@
1
+ export declare type PalletAssetsAssetAccount = {
2
+ balance: number | string;
3
+ status: 'Frozen' | 'Liquid' | 'Blocked';
4
+ reason: Record<string, unknown>;
5
+ extra: unknown;
6
+ };
7
+ export declare function _getForeignAssetPalletTransferable(accountInfo: PalletAssetsAssetAccount): bigint;
8
+ export declare function _getForeignAssetPalletLockedBalance(accountInfo: PalletAssetsAssetAccount): bigint;
@@ -0,0 +1,9 @@
1
+ // Copyright 2019-2022 @subwallet/extension-base
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export function _getForeignAssetPalletTransferable(accountInfo) {
5
+ return accountInfo.status !== 'Liquid' ? BigInt(0) : BigInt(accountInfo.balance);
6
+ }
7
+ export function _getForeignAssetPalletLockedBalance(accountInfo) {
8
+ return accountInfo.status === 'Liquid' ? BigInt(0) : BigInt(accountInfo.balance);
9
+ }
@@ -48,4 +48,6 @@ export declare function _getXcmMultiLocation(originChainInfo: _ChainInfo, destCh
48
48
  };
49
49
  };
50
50
  export declare function _isXcmTransferUnstable(originChainInfo: _ChainInfo, destChainInfo: _ChainInfo): boolean;
51
- export declare function _getXcmUnstableWarning(originChainInfo: _ChainInfo): string;
51
+ export declare function _getXcmUnstableWarning(originChainInfo: _ChainInfo, destChainInfo: _ChainInfo): string;
52
+ export declare function _isXcmWithinSameConsensus(originChainInfo: _ChainInfo, destChainInfo: _ChainInfo): boolean;
53
+ export declare function _isSnowBridgeXcm(originChainInfo: _ChainInfo, destChainInfo: _ChainInfo): boolean;
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import { COMMON_CHAIN_SLUGS } from '@subwallet/chain-list';
5
- import { _getChainSubstrateAddressPrefix, _getEvmChainId, _getSubstrateParaId, _getSubstrateRelayParent, _getXcmAssetMultilocation, _isChainEvmCompatible, _isSubstrateParaChain } from '@subwallet/extension-base/services/chain-service/utils';
5
+ import { _getChainSubstrateAddressPrefix, _getEvmChainId, _getSubstrateParaId, _getSubstrateRelayParent, _getXcmAssetMultilocation, _isChainEvmCompatible, _isPureEvmChain, _isSubstrateParaChain } from '@subwallet/extension-base/services/chain-service/utils';
6
6
  import { decodeAddress, evmToAddress } from '@polkadot/util-crypto';
7
7
  const FOUR_INSTRUCTIONS_WEIGHT = 5000000000;
8
8
  const UNLIMITED_WEIGHT = 'Unlimited';
@@ -49,7 +49,7 @@ export function _getXcmMultiLocation(originChainInfo, destChainInfo, version, re
49
49
  export function _isXcmTransferUnstable(originChainInfo, destChainInfo) {
50
50
  return !_isXcmWithinSameConsensus(originChainInfo, destChainInfo);
51
51
  }
52
- export function _getXcmUnstableWarning(originChainInfo) {
52
+ function getAssetHubBridgeUnstableWarning(originChainInfo) {
53
53
  switch (originChainInfo.slug) {
54
54
  case COMMON_CHAIN_SLUGS.POLKADOT_ASSET_HUB:
55
55
  return 'Cross-chain transfer of this token is not recommended as it is in beta and incurs a transaction fee of 2 DOT. Continue at your own risk';
@@ -59,12 +59,32 @@ export function _getXcmUnstableWarning(originChainInfo) {
59
59
  return 'Cross-chain transfer of this token is not recommended as it is in beta and incurs a large transaction fee. Continue at your own risk';
60
60
  }
61
61
  }
62
+ function getSnowBridgeUnstableWarning(originChainInfo) {
63
+ switch (originChainInfo.slug) {
64
+ case COMMON_CHAIN_SLUGS.POLKADOT_ASSET_HUB:
65
+ return 'Cross-chain transfer of this token is not recommended as it is in beta, incurs a fee of 70$ and takes up to 1 hour to complete. Continue at your own risk';
66
+ case COMMON_CHAIN_SLUGS.ETHEREUM:
67
+ return 'Cross-chain transfer of this token is not recommended as it is in beta, incurs a fee of 5$ and takes up to 1 hour to complete. Continue at your own risk';
68
+ default:
69
+ return 'Cross-chain transfer of this token is not recommended as it is in beta, incurs a high fee and takes up to 1 hour to complete. Continue at your own risk';
70
+ }
71
+ }
72
+ export function _getXcmUnstableWarning(originChainInfo, destChainInfo) {
73
+ if (_isSnowBridgeXcm(originChainInfo, destChainInfo)) {
74
+ return getSnowBridgeUnstableWarning(originChainInfo);
75
+ } else {
76
+ return getAssetHubBridgeUnstableWarning(originChainInfo);
77
+ }
78
+ }
79
+ export function _isXcmWithinSameConsensus(originChainInfo, destChainInfo) {
80
+ return _getSubstrateRelayParent(originChainInfo) === destChainInfo.slug || _getSubstrateRelayParent(destChainInfo) === originChainInfo.slug || _getSubstrateRelayParent(originChainInfo) === _getSubstrateRelayParent(destChainInfo);
81
+ }
82
+ export function _isSnowBridgeXcm(originChainInfo, destChainInfo) {
83
+ return !_isXcmWithinSameConsensus(originChainInfo, destChainInfo) && (_isPureEvmChain(originChainInfo) || _isPureEvmChain(destChainInfo));
84
+ }
62
85
 
63
86
  // ---------------------------------------------------------------------------------------------------------------------
64
87
 
65
- function _isXcmWithinSameConsensus(originChainInfo, destChainInfo) {
66
- return _getSubstrateRelayParent(originChainInfo) === destChainInfo.slug || _getSubstrateRelayParent(destChainInfo) === originChainInfo.slug || _getSubstrateRelayParent(originChainInfo) === _getSubstrateRelayParent(destChainInfo);
67
- }
68
88
  function _getMultiLocationParent(originChainInfo, isWithinSameConsensus) {
69
89
  let parent = 0; // how many hops up the hierarchy
70
90
 
@@ -0,0 +1,8 @@
1
+ import { _Address } from '@subwallet/extension-base/background/KoniTypes';
2
+ import { _EvmApi } from '@subwallet/extension-base/services/chain-service/types';
3
+ import { TransactionConfig } from 'web3-core';
4
+ import { Contract } from 'web3-eth-contract';
5
+ export declare const getERC20Contract: (assetAddress: string, evmApi: _EvmApi, options?: {}) => Contract;
6
+ export declare function getWeb3Contract(contractAddress: _Address, evmApi: _EvmApi, contractAbi: Record<string, any>, options?: {}): Contract;
7
+ export declare function getERC20Allowance(spender: _Address, owner: _Address, contractAddress: _Address, evmApi: _EvmApi): Promise<string>;
8
+ export declare function getERC20SpendingApprovalTx(spender: _Address, owner: _Address, contractAddress: _Address, evmApi: _EvmApi, amount?: string): Promise<TransactionConfig>;
@@ -0,0 +1,45 @@
1
+ // Copyright 2019-2022 @subwallet/extension-base
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { _ERC20_ABI } from '@subwallet/extension-base/koni/api/contract-handler/utils';
5
+ import { calculateGasFeeParams } from '@subwallet/extension-base/services/fee-service/utils';
6
+ export const getERC20Contract = (assetAddress, evmApi, options = {}) => {
7
+ // @ts-ignore
8
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-member-access
9
+ return new evmApi.api.eth.Contract(_ERC20_ABI, assetAddress, options);
10
+ };
11
+ export function getWeb3Contract(contractAddress, evmApi, contractAbi, options = {}) {
12
+ // @ts-ignore
13
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-member-access
14
+ return new evmApi.api.eth.Contract(contractAbi, contractAddress, options);
15
+ }
16
+ export async function getERC20Allowance(spender, owner, contractAddress, evmApi) {
17
+ const tokenContract = getERC20Contract(contractAddress, evmApi);
18
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
19
+ const allowanceCall = tokenContract.methods.allowance(owner, spender);
20
+
21
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
22
+ return await allowanceCall.call();
23
+ }
24
+ export async function getERC20SpendingApprovalTx(spender, owner, contractAddress, evmApi, amount = '115792089237316195423570985008687907853269984665640564039457584007913129639935') {
25
+ var _priority$maxFeePerGa, _priority$maxPriority;
26
+ const tokenContract = getERC20Contract(contractAddress, evmApi);
27
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
28
+ const approveCall = tokenContract.methods.approve(spender, amount); // TODO: need test
29
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
30
+ const approveEncodedCall = approveCall.encodeABI();
31
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
32
+ const gasLimit = await approveCall.estimateGas({
33
+ from: owner
34
+ });
35
+ const priority = await calculateGasFeeParams(evmApi, evmApi.chainSlug);
36
+ return {
37
+ from: owner,
38
+ to: contractAddress,
39
+ data: approveEncodedCall,
40
+ gas: gasLimit,
41
+ gasPrice: priority.gasPrice,
42
+ maxFeePerGas: (_priority$maxFeePerGa = priority.maxFeePerGas) === null || _priority$maxFeePerGa === void 0 ? void 0 : _priority$maxFeePerGa.toString(),
43
+ maxPriorityFeePerGas: (_priority$maxPriority = priority.maxPriorityFeePerGas) === null || _priority$maxPriority === void 0 ? void 0 : _priority$maxPriority.toString()
44
+ };
45
+ }
@@ -1,3 +1,4 @@
1
+ import { _Address } from '@subwallet/extension-base/background/KoniTypes';
1
2
  export declare const _ERC20_ABI: any;
2
3
  export declare const _ERC721_ABI: any;
3
4
  export declare const _TEST_ERC721_ABI: any;
@@ -6,3 +7,6 @@ export declare const _PSP34_ABI: Record<string, any>;
6
7
  export declare const _PINK_PSP34_ABI: Record<string, any>;
7
8
  export declare const _NEUROGUNS_PSP34_ABI: Record<string, any>;
8
9
  export declare const _AZERO_DOMAIN_REGISTRY_ABI: Record<string, any>;
10
+ export declare const _SNOWBRIDGE_GATEWAY_ABI: Record<string, any>;
11
+ export declare function getSnowBridgeGatewayContract(chain: string): "0x27ca963C279c93801941e1eB8799c23f407d68e7" | "0x5B4909cE6Ca82d2CE23BD46738953c7959E710Cd";
12
+ export declare function isSnowBridgeGatewayContract(contractAddress: _Address): boolean;
@@ -1,6 +1,7 @@
1
1
  // Copyright 2019-2022 @subwallet/extension-base
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
+ import { COMMON_CHAIN_SLUGS } from '@subwallet/chain-list';
4
5
  // eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
5
6
  export const _ERC20_ABI = require("./erc20_abi.json");
6
7
  // eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
@@ -16,4 +17,17 @@ export const _PINK_PSP34_ABI = require("./pink_psp34_abi.json");
16
17
  // eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
17
18
  export const _NEUROGUNS_PSP34_ABI = require("./neuroguns_psp34_abi.json");
18
19
  // eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
19
- export const _AZERO_DOMAIN_REGISTRY_ABI = require("./azero_domain_registry_abi.json");
20
+ export const _AZERO_DOMAIN_REGISTRY_ABI = require("./azero_domain_registry_abi.json");
21
+ // eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
22
+ export const _SNOWBRIDGE_GATEWAY_ABI = require("./snowbridge_gateway_abi.json");
23
+ const SNOWBRIDGE_GATEWAY_ETHEREUM_CONTRACT_ADDRESS = '0x27ca963C279c93801941e1eB8799c23f407d68e7';
24
+ const SNOWBRIDGE_GATEWAY_SEPOLIA_CONTRACT_ADDRESS = '0x5B4909cE6Ca82d2CE23BD46738953c7959E710Cd';
25
+ export function getSnowBridgeGatewayContract(chain) {
26
+ if (chain === COMMON_CHAIN_SLUGS.ETHEREUM_SEPOLIA) {
27
+ return SNOWBRIDGE_GATEWAY_SEPOLIA_CONTRACT_ADDRESS;
28
+ }
29
+ return SNOWBRIDGE_GATEWAY_ETHEREUM_CONTRACT_ADDRESS;
30
+ }
31
+ export function isSnowBridgeGatewayContract(contractAddress) {
32
+ return [SNOWBRIDGE_GATEWAY_ETHEREUM_CONTRACT_ADDRESS, SNOWBRIDGE_GATEWAY_SEPOLIA_CONTRACT_ADDRESS].includes(contractAddress);
33
+ }