@subwallet/extension-base 1.3.17-0 → 1.3.18-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/background/KoniTypes.d.ts +7 -2
  2. package/cjs/constants/index.js +6 -3
  3. package/cjs/core/logic-validation/request.js +26 -19
  4. package/cjs/core/logic-validation/transfer.js +18 -17
  5. package/cjs/koni/api/contract-handler/evm/web3.js +3 -3
  6. package/cjs/koni/background/handlers/Extension.js +269 -123
  7. package/cjs/koni/background/handlers/State.js +1 -8
  8. package/cjs/packageInfo.js +1 -1
  9. package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +1 -1
  10. package/cjs/services/balance-service/index.js +13 -0
  11. package/cjs/services/balance-service/transfer/smart-contract.js +47 -33
  12. package/cjs/services/balance-service/transfer/token.js +5 -4
  13. package/cjs/services/balance-service/transfer/xcm/availBridge.js +14 -18
  14. package/cjs/services/balance-service/transfer/xcm/index.js +30 -61
  15. package/cjs/services/balance-service/transfer/xcm/polygonBridge.js +13 -17
  16. package/cjs/services/balance-service/transfer/xcm/posBridge.js +20 -21
  17. package/cjs/services/balance-service/transfer/xcm/snowBridge.js +7 -7
  18. package/cjs/services/balance-service/transfer/xcm/utils.js +2 -2
  19. package/cjs/services/chain-service/constants.js +3 -3
  20. package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +7 -12
  21. package/cjs/services/earning-service/handlers/special.js +15 -4
  22. package/cjs/services/fee-service/interfaces.js +1 -0
  23. package/cjs/services/fee-service/service.js +111 -0
  24. package/cjs/services/fee-service/utils/index.js +99 -113
  25. package/cjs/services/storage-service/db-stores/Balance.js +3 -0
  26. package/cjs/services/swap-service/handler/asset-hub/handler.js +23 -7
  27. package/cjs/services/swap-service/handler/asset-hub/router.js +1 -1
  28. package/cjs/services/swap-service/handler/asset-hub/utils.js +4 -4
  29. package/cjs/services/swap-service/handler/base-handler.js +3 -1
  30. package/cjs/services/swap-service/handler/chainflip-handler.js +26 -5
  31. package/cjs/services/swap-service/handler/hydradx-handler.js +23 -8
  32. package/cjs/services/swap-service/handler/simpleswap-handler.js +24 -4
  33. package/cjs/services/swap-service/index.js +8 -8
  34. package/cjs/services/transaction-service/index.js +23 -3
  35. package/cjs/types/balance/transfer.js +1 -0
  36. package/cjs/types/fee/base.js +1 -0
  37. package/cjs/types/fee/evm.js +16 -1
  38. package/cjs/types/fee/index.js +37 -4
  39. package/cjs/types/fee/option.js +1 -0
  40. package/cjs/types/fee/subscription.js +1 -0
  41. package/cjs/types/fee/substrate.js +1 -0
  42. package/cjs/types/fee/ton.js +1 -0
  43. package/cjs/utils/fee/combine.js +50 -0
  44. package/cjs/utils/fee/index.js +27 -0
  45. package/cjs/utils/fee/transfer.js +374 -0
  46. package/cjs/utils/index.js +12 -0
  47. package/constants/index.d.ts +1 -0
  48. package/constants/index.js +1 -0
  49. package/core/logic-validation/request.js +17 -10
  50. package/core/logic-validation/transfer.d.ts +5 -5
  51. package/core/logic-validation/transfer.js +20 -19
  52. package/core/substrate/xcm-parser.d.ts +1 -1
  53. package/koni/api/contract-handler/evm/web3.js +3 -3
  54. package/koni/background/handlers/Extension.d.ts +3 -3
  55. package/koni/background/handlers/Extension.js +253 -107
  56. package/koni/background/handlers/State.js +1 -8
  57. package/package.json +55 -5
  58. package/packageInfo.js +1 -1
  59. package/services/balance-service/helpers/subscribe/substrate/index.js +1 -1
  60. package/services/balance-service/index.d.ts +1 -0
  61. package/services/balance-service/index.js +13 -0
  62. package/services/balance-service/transfer/smart-contract.d.ts +24 -4
  63. package/services/balance-service/transfer/smart-contract.js +45 -33
  64. package/services/balance-service/transfer/token.js +6 -5
  65. package/services/balance-service/transfer/xcm/availBridge.d.ts +3 -2
  66. package/services/balance-service/transfer/xcm/availBridge.js +11 -15
  67. package/services/balance-service/transfer/xcm/index.d.ts +12 -11
  68. package/services/balance-service/transfer/xcm/index.js +29 -58
  69. package/services/balance-service/transfer/xcm/polygonBridge.d.ts +4 -3
  70. package/services/balance-service/transfer/xcm/polygonBridge.js +13 -17
  71. package/services/balance-service/transfer/xcm/posBridge.d.ts +4 -3
  72. package/services/balance-service/transfer/xcm/posBridge.js +18 -19
  73. package/services/balance-service/transfer/xcm/snowBridge.d.ts +2 -1
  74. package/services/balance-service/transfer/xcm/snowBridge.js +7 -7
  75. package/services/balance-service/transfer/xcm/utils.js +2 -2
  76. package/services/chain-service/constants.js +3 -3
  77. package/services/earning-service/handlers/liquid-staking/stella-swap.js +7 -12
  78. package/services/earning-service/handlers/special.js +15 -4
  79. package/services/fee-service/interfaces.d.ts +5 -0
  80. package/services/fee-service/interfaces.js +1 -0
  81. package/services/fee-service/service.d.ts +4 -1
  82. package/services/fee-service/service.js +111 -0
  83. package/services/fee-service/utils/index.d.ts +8 -2
  84. package/services/fee-service/utils/index.js +92 -108
  85. package/services/storage-service/db-stores/Balance.d.ts +1 -0
  86. package/services/storage-service/db-stores/Balance.js +3 -0
  87. package/services/swap-service/handler/asset-hub/handler.d.ts +2 -1
  88. package/services/swap-service/handler/asset-hub/handler.js +23 -7
  89. package/services/swap-service/handler/asset-hub/router.js +2 -2
  90. package/services/swap-service/handler/asset-hub/utils.d.ts +1 -1
  91. package/services/swap-service/handler/asset-hub/utils.js +2 -2
  92. package/services/swap-service/handler/base-handler.d.ts +4 -1
  93. package/services/swap-service/handler/base-handler.js +3 -1
  94. package/services/swap-service/handler/chainflip-handler.d.ts +2 -1
  95. package/services/swap-service/handler/chainflip-handler.js +25 -4
  96. package/services/swap-service/handler/hydradx-handler.d.ts +2 -1
  97. package/services/swap-service/handler/hydradx-handler.js +22 -7
  98. package/services/swap-service/handler/simpleswap-handler.d.ts +2 -1
  99. package/services/swap-service/handler/simpleswap-handler.js +24 -4
  100. package/services/swap-service/index.js +8 -8
  101. package/services/transaction-service/index.js +23 -3
  102. package/services/transaction-service/types.d.ts +5 -4
  103. package/types/balance/transfer.d.ts +25 -0
  104. package/types/balance/transfer.js +1 -0
  105. package/types/fee/base.d.ts +8 -0
  106. package/types/fee/base.js +1 -0
  107. package/types/fee/evm.d.ts +46 -16
  108. package/types/fee/evm.js +10 -1
  109. package/types/fee/index.d.ts +4 -1
  110. package/types/fee/index.js +4 -1
  111. package/types/fee/option.d.ts +8 -0
  112. package/types/fee/option.js +1 -0
  113. package/types/fee/subscription.d.ts +12 -0
  114. package/types/fee/subscription.js +1 -0
  115. package/types/fee/substrate.d.ts +15 -0
  116. package/types/fee/substrate.js +1 -0
  117. package/types/fee/ton.d.ts +18 -0
  118. package/types/fee/ton.js +1 -0
  119. package/types/transaction/request.d.ts +13 -3
  120. package/utils/fee/combine.d.ts +12 -0
  121. package/utils/fee/combine.js +42 -0
  122. package/utils/fee/index.d.ts +2 -0
  123. package/utils/fee/index.js +5 -0
  124. package/utils/fee/transfer.d.ts +22 -0
  125. package/utils/fee/transfer.js +363 -0
  126. package/utils/index.d.ts +1 -0
  127. package/utils/index.js +1 -0
@@ -13,9 +13,9 @@ exports.isClaimedPosBridge = isClaimedPosBridge;
13
13
  var _chainList = require("@subwallet/chain-list");
14
14
  var _web = require("@subwallet/extension-base/koni/api/contract-handler/evm/web3");
15
15
  var _utils = require("@subwallet/extension-base/koni/api/contract-handler/utils");
16
- var _utils2 = require("@subwallet/extension-base/services/fee-service/utils");
17
- var _utils3 = require("@subwallet/extension-base/services/inapp-notification-service/utils");
16
+ var _utils2 = require("@subwallet/extension-base/services/inapp-notification-service/utils");
18
17
  var _types = require("@subwallet/extension-base/types");
18
+ var _utils3 = require("@subwallet/extension-base/utils");
19
19
  // Copyright 2019-2022 @subwallet/extension-base
20
20
  // SPDX-License-Identifier: Apache-2.0
21
21
 
@@ -24,52 +24,53 @@ const POS_EXIT_PAYLOAD_INDEXER = {
24
24
  TESTNET: 'https://proof-generator.polygon.technology/api/v1/amoy/exit-payload'
25
25
  };
26
26
  exports.POS_EXIT_PAYLOAD_INDEXER = POS_EXIT_PAYLOAD_INDEXER;
27
- async function _createPosBridgeL1toL2Extrinsic(tokenInfo, originChainInfo, sender, recipientAddress, value, evmApi) {
28
- var _priority$maxFeePerGa, _priority$maxPriority;
27
+ async function _createPosBridgeL1toL2Extrinsic(tokenInfo, originChainInfo, sender, recipientAddress, value, evmApi, _feeInfo, feeCustom, feeOption) {
29
28
  const posBridgeContractAddress = (0, _utils.getPosL1BridgeContract)(originChainInfo.slug);
30
29
  const posBridgeContract = (0, _web.getWeb3Contract)(posBridgeContractAddress, evmApi, _utils._POS_BRIDGE_ABI);
30
+ const _feeCustom = feeCustom;
31
+ const feeInfo = _feeInfo;
32
+ const feeCombine = (0, _utils3.combineEthFee)(feeInfo, feeOption, _feeCustom);
31
33
 
32
34
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
33
35
  const transferCall = posBridgeContract.methods.depositEtherFor(recipientAddress);
34
36
  const transferEncodedCall = transferCall.encodeABI();
35
- const priority = await (0, _utils2.calculateGasFeeParams)(evmApi, evmApi.chainSlug);
37
+
38
+ // const priority = await calculateGasFeeParams(evmApi, evmApi.chainSlug);
39
+
36
40
  const transactionConfig = {
37
41
  from: sender,
38
42
  to: posBridgeContractAddress,
39
43
  value: value,
40
44
  data: transferEncodedCall,
41
- gasPrice: priority.gasPrice,
42
- maxFeePerGas: priority === null || priority === void 0 ? void 0 : (_priority$maxFeePerGa = priority.maxFeePerGas) === null || _priority$maxFeePerGa === void 0 ? void 0 : _priority$maxFeePerGa.toString(),
43
- maxPriorityFeePerGas: priority === null || priority === void 0 ? void 0 : (_priority$maxPriority = priority.maxPriorityFeePerGas) === null || _priority$maxPriority === void 0 ? void 0 : _priority$maxPriority.toString()
45
+ ...feeCombine
44
46
  };
45
47
  const gasLimit = await evmApi.api.eth.estimateGas(transactionConfig).catch(() => 200000);
46
48
  transactionConfig.gas = gasLimit.toString();
47
49
  return transactionConfig;
48
50
  }
49
- async function _createPosBridgeL2toL1Extrinsic(tokenInfo, originChainInfo, sender, recipientAddress, value, evmApi) {
50
- var _priority$maxFeePerGa2, _priority$maxPriority2;
51
+ async function _createPosBridgeL2toL1Extrinsic(tokenInfo, originChainInfo, sender, recipientAddress, value, evmApi, _feeInfo, feeCustom, feeOption) {
51
52
  const posBridgeContractAddress = (0, _utils.getPosL2BridgeContract)(originChainInfo.slug);
52
53
  const posBridgeContract = (0, _web.getWeb3Contract)(posBridgeContractAddress, evmApi, _utils._POS_BRIDGE_L2_ABI);
53
54
 
54
55
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
55
56
  const transferCall = posBridgeContract.methods.withdraw(value);
56
57
  const transferEncodedCall = transferCall.encodeABI();
57
- const priority = await (0, _utils2.calculateGasFeeParams)(evmApi, evmApi.chainSlug);
58
+ const _feeCustom = feeCustom;
59
+ const feeInfo = _feeInfo;
60
+ const feeCombine = (0, _utils3.combineEthFee)(feeInfo, feeOption, _feeCustom);
58
61
  const transactionConfig = {
59
62
  from: sender,
60
63
  to: posBridgeContractAddress,
61
64
  value: undefined,
62
65
  data: transferEncodedCall,
63
- gasPrice: priority.gasPrice,
64
- maxFeePerGas: priority === null || priority === void 0 ? void 0 : (_priority$maxFeePerGa2 = priority.maxFeePerGas) === null || _priority$maxFeePerGa2 === void 0 ? void 0 : _priority$maxFeePerGa2.toString(),
65
- maxPriorityFeePerGas: priority === null || priority === void 0 ? void 0 : (_priority$maxPriority2 = priority.maxPriorityFeePerGas) === null || _priority$maxPriority2 === void 0 ? void 0 : _priority$maxPriority2.toString()
66
+ ...feeCombine
66
67
  };
67
68
  const gasLimit = await evmApi.api.eth.estimateGas(transactionConfig).catch(() => 200000);
68
69
  transactionConfig.gas = gasLimit.toString();
69
70
  return transactionConfig;
70
71
  }
71
- async function getClaimPosBridge(chainSlug, notification, evmApi) {
72
- var _event$arguments, _event$arguments$, _event$arguments$$top, _priority$maxFeePerGa3, _priority$maxPriority3;
72
+ async function getClaimPosBridge(chainSlug, notification, evmApi, feeInfo) {
73
+ var _event$arguments, _event$arguments$, _event$arguments$$top;
73
74
  const posBridgeContractAddress = (0, _utils.getPosL2BridgeContract)(chainSlug);
74
75
  const posBridgeContract = (0, _web.getWeb3Contract)(posBridgeContractAddress, evmApi, _utils._POS_BRIDGE_L2_ABI);
75
76
  const metadata = notification.metadata;
@@ -96,15 +97,13 @@ async function getClaimPosBridge(chainSlug, notification, evmApi) {
96
97
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
97
98
  const transferCall = posClaimContract.methods.exit(inputData.result);
98
99
  const transferEncodedCall = transferCall.encodeABI();
99
- const priority = await (0, _utils2.calculateGasFeeParams)(evmApi, evmApi.chainSlug);
100
+ const feeCombine = (0, _utils3.combineEthFee)(feeInfo);
100
101
  const transactionConfig = {
101
102
  from: metadata.userAddress,
102
103
  to: posClaimContractAddress,
103
104
  value: '0',
104
105
  data: transferEncodedCall,
105
- gasPrice: priority.gasPrice,
106
- maxFeePerGas: (_priority$maxFeePerGa3 = priority.maxFeePerGas) === null || _priority$maxFeePerGa3 === void 0 ? void 0 : _priority$maxFeePerGa3.toString(),
107
- maxPriorityFeePerGas: (_priority$maxPriority3 = priority.maxPriorityFeePerGas) === null || _priority$maxPriority3 === void 0 ? void 0 : _priority$maxPriority3.toString()
106
+ ...feeCombine
108
107
  };
109
108
  const gasLimit = await evmApi.api.eth.estimateGas(transactionConfig).catch(() => 200000);
110
109
  transactionConfig.gas = gasLimit.toString();
@@ -112,7 +111,7 @@ async function getClaimPosBridge(chainSlug, notification, evmApi) {
112
111
  }
113
112
  async function isClaimedPosBridge(id, address, isTestnet) {
114
113
  try {
115
- const isClaimableBridge = await (0, _utils3.fetchPolygonBridgeTransactions)(address, isTestnet);
114
+ const isClaimableBridge = await (0, _utils2.fetchPolygonBridgeTransactions)(address, isTestnet);
116
115
  if (isClaimableBridge && isClaimableBridge.success) {
117
116
  const isIdClaimable = isClaimableBridge.result.some(transaction => transaction._id === id);
118
117
  return !isIdClaimable;
@@ -7,7 +7,7 @@ exports.getSnowBridgeEvmTransfer = getSnowBridgeEvmTransfer;
7
7
  var _web = require("@subwallet/extension-base/koni/api/contract-handler/evm/web3");
8
8
  var _utils = require("@subwallet/extension-base/koni/api/contract-handler/utils");
9
9
  var _utils2 = require("@subwallet/extension-base/services/chain-service/utils");
10
- var _utils3 = require("@subwallet/extension-base/services/fee-service/utils");
10
+ var _utils3 = require("@subwallet/extension-base/utils");
11
11
  var _util = require("@polkadot/util");
12
12
  var _utilCrypto = require("@polkadot/util-crypto");
13
13
  // Copyright 2019-2022 @subwallet/extension-base
@@ -20,8 +20,7 @@ async function getSendFeeToken(contract, tokenContract, destChainParaId, destina
20
20
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
21
21
  return await quoteSendTokenFee.call();
22
22
  }
23
- async function getSnowBridgeEvmTransfer(tokenInfo, originChainInfo, destinationChainInfo, sender, recipientAddress, value, evmApi) {
24
- var _priority$maxFeePerGa, _priority$maxPriority;
23
+ async function getSnowBridgeEvmTransfer(tokenInfo, originChainInfo, destinationChainInfo, sender, recipientAddress, value, evmApi, _feeInfo, feeCustom, feeOption) {
25
24
  const snowBridgeContractAddress = (0, _utils.getSnowBridgeGatewayContract)(originChainInfo.slug);
26
25
  const snowBridgeContract = (0, _web.getWeb3Contract)(snowBridgeContractAddress, evmApi, _utils._SNOWBRIDGE_GATEWAY_ABI);
27
26
  const tokenContract = (0, _utils2._getContractAddressOfToken)(tokenInfo);
@@ -36,15 +35,16 @@ async function getSnowBridgeEvmTransfer(tokenInfo, originChainInfo, destinationC
36
35
  const transferCall = snowBridgeContract.methods.sendToken(tokenContract, destinationChainParaId, recipient, destinationFee, value);
37
36
  // eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
38
37
  const transferEncodedCall = transferCall.encodeABI();
39
- const [priority, sendTokenFee] = await Promise.all([(0, _utils3.calculateGasFeeParams)(evmApi, evmApi.chainSlug), getSendFeeToken(snowBridgeContract, tokenContract, destinationChainParaId, destinationFee)]);
38
+ const feeInfo = _feeInfo;
39
+ const _feeCustom = feeCustom;
40
+ const feeCombine = (0, _utils3.combineEthFee)(feeInfo, feeOption, _feeCustom);
41
+ const sendTokenFee = await getSendFeeToken(snowBridgeContract, tokenContract, destinationChainParaId, destinationFee);
40
42
  const transactionConfig = {
41
43
  from: sender,
42
44
  to: snowBridgeContractAddress,
43
45
  value: sendTokenFee,
44
46
  data: transferEncodedCall,
45
- gasPrice: priority.gasPrice,
46
- maxFeePerGas: (_priority$maxFeePerGa = priority.maxFeePerGas) === null || _priority$maxFeePerGa === void 0 ? void 0 : _priority$maxFeePerGa.toString(),
47
- maxPriorityFeePerGas: (_priority$maxPriority = priority.maxPriorityFeePerGas) === null || _priority$maxPriority === void 0 ? void 0 : _priority$maxPriority.toString()
47
+ ...feeCombine
48
48
  };
49
49
  let gasLimit;
50
50
  try {
@@ -11,8 +11,8 @@ exports.isUseTeleportProtocol = isUseTeleportProtocol;
11
11
  const STABLE_XCM_VERSION = 3;
12
12
  exports.STABLE_XCM_VERSION = STABLE_XCM_VERSION;
13
13
  function isUseTeleportProtocol(originChainInfo, destChainInfo, tokenSlug) {
14
- const relayChainToSystemChain = ['polkadot'].includes(originChainInfo.slug) && ['statemint'].includes(destChainInfo.slug) || ['kusama'].includes(originChainInfo.slug) && ['statemine'].includes(destChainInfo.slug) || ['rococo'].includes(originChainInfo.slug) && ['rococo_assethub'].includes(destChainInfo.slug);
15
- const systemChainToRelayChain = ['polkadot'].includes(destChainInfo.slug) && ['statemint'].includes(originChainInfo.slug) || ['kusama'].includes(destChainInfo.slug) && ['statemine'].includes(originChainInfo.slug) || ['rococo'].includes(destChainInfo.slug) && ['rococo_assethub'].includes(originChainInfo.slug);
14
+ const relayChainToSystemChain = ['polkadot'].includes(originChainInfo.slug) && ['statemint'].includes(destChainInfo.slug) || ['kusama'].includes(originChainInfo.slug) && ['statemine'].includes(destChainInfo.slug) || ['rococo'].includes(originChainInfo.slug) && ['rococo_assethub'].includes(destChainInfo.slug) || ['westend'].includes(originChainInfo.slug) && ['westend_assethub'].includes(destChainInfo.slug);
15
+ const systemChainToRelayChain = ['polkadot'].includes(destChainInfo.slug) && ['statemint'].includes(originChainInfo.slug) || ['kusama'].includes(destChainInfo.slug) && ['statemine'].includes(originChainInfo.slug) || ['rococo'].includes(destChainInfo.slug) && ['rococo_assethub'].includes(originChainInfo.slug) || ['westend'].includes(destChainInfo.slug) && ['westend_assethub'].includes(originChainInfo.slug);
16
16
  const isXcmMythos = originChainInfo.slug === 'mythos' && destChainInfo.slug === 'statemint' && tokenSlug === 'mythos-NATIVE-MYTH' || originChainInfo.slug === 'statemint' && destChainInfo.slug === 'mythos' && tokenSlug === 'statemint-LOCAL-MYTH';
17
17
  return relayChainToSystemChain || systemChainToRelayChain || isXcmMythos;
18
18
  }
@@ -41,7 +41,7 @@ const _BALANCE_CHAIN_GROUP = {
41
41
  genshiro: ['genshiro_testnet', 'genshiro'],
42
42
  equilibrium_parachain: ['equilibrium_parachain'],
43
43
  bifrost: ['bifrost', 'acala', 'karura', 'acala_testnet', 'pioneer', 'bitcountry', 'bifrost_dot', 'hydradx_main', 'hydradx_rococo', 'pendulum', 'amplitude', 'continuum_network'],
44
- statemine: ['statemine', 'astar', 'shiden', 'statemint', 'moonbeam', 'moonbase', 'moonriver', 'crabParachain', 'darwinia2', 'parallel', 'calamari', 'manta_network', 'rococo_assethub', 'liberlandTest', 'liberland', 'dentnet', 'pangolin', 'crust', 'phala', 'shibuya', 'dbcchain'],
44
+ statemine: ['statemine', 'astar', 'shiden', 'statemint', 'moonbeam', 'moonbase', 'moonriver', 'crabParachain', 'darwinia2', 'parallel', 'calamari', 'manta_network', 'rococo_assethub', 'liberlandTest', 'liberland', 'dentnet', 'pangolin', 'crust', 'phala', 'shibuya', 'dbcchain', 'westend_assethub'],
45
45
  kusama: ['kusama', 'kintsugi', 'kintsugi_test', 'interlay', 'acala', 'statemint', 'karura', 'bifrost'],
46
46
  // perhaps there are some runtime updates
47
47
  centrifuge: ['centrifuge'],
@@ -288,9 +288,9 @@ const _DEFAULT_MANTA_ZK_CHAIN = 'calamari';
288
288
  // XCM------------------------------------------------------------------------------------------------------------------
289
289
  exports._DEFAULT_MANTA_ZK_CHAIN = _DEFAULT_MANTA_ZK_CHAIN;
290
290
  const _XCM_CHAIN_GROUP = {
291
- polkadotXcm: ['statemine', 'statemint', 'equilibrium_parachain', 'rococo_assethub', 'mythos'],
291
+ polkadotXcm: ['statemine', 'statemint', 'equilibrium_parachain', 'rococo_assethub', 'mythos', 'westend_assethub'],
292
292
  polkadotXcmSpecialCases: ['astar', 'shiden'],
293
- xcmPallet: ['polkadot', 'kusama', 'rococo']
293
+ xcmPallet: ['polkadot', 'kusama', 'rococo', 'westend']
294
294
  // default is xTokens pallet
295
295
  };
296
296
  exports._XCM_CHAIN_GROUP = _XCM_CHAIN_GROUP;
@@ -11,6 +11,7 @@ var _web = require("@subwallet/extension-base/koni/api/contract-handler/evm/web3
11
11
  var _utils = require("@subwallet/extension-base/services/chain-service/utils");
12
12
  var _utils2 = require("@subwallet/extension-base/services/fee-service/utils");
13
13
  var _types = require("@subwallet/extension-base/types");
14
+ var _utils3 = require("@subwallet/extension-base/utils");
14
15
  var _util = require("@polkadot/util");
15
16
  var _constants = require("../../constants");
16
17
  var _base = _interopRequireDefault(require("./base"));
@@ -280,7 +281,6 @@ class StellaSwapLiquidStakingPoolHandler extends _base.default {
280
281
  });
281
282
  }
282
283
  async handleSubmitStep(data, path) {
283
- var _priority$maxFeePerGa, _priority$maxPriority;
284
284
  const {
285
285
  address,
286
286
  amount
@@ -300,14 +300,13 @@ class StellaSwapLiquidStakingPoolHandler extends _base.default {
300
300
  from: address
301
301
  });
302
302
  const priority = await (0, _utils2.calculateGasFeeParams)(evmApi, this.chain);
303
+ const feeCombine = (0, _utils3.combineEthFee)(priority);
303
304
  const transactionObject = {
304
305
  from: address,
305
306
  to: (0, _utils._getContractAddressOfToken)(derivativeTokenInfo),
306
307
  data: depositEncodedCall,
307
308
  gas: gasLimit,
308
- gasPrice: priority.gasPrice,
309
- maxFeePerGas: (_priority$maxFeePerGa = priority.maxFeePerGas) === null || _priority$maxFeePerGa === void 0 ? void 0 : _priority$maxFeePerGa.toString(),
310
- maxPriorityFeePerGas: (_priority$maxPriority = priority.maxPriorityFeePerGas) === null || _priority$maxPriority === void 0 ? void 0 : _priority$maxPriority.toString()
309
+ ...feeCombine
311
310
  };
312
311
  return {
313
312
  txChain: this.chain,
@@ -327,7 +326,6 @@ class StellaSwapLiquidStakingPoolHandler extends _base.default {
327
326
  return Promise.reject(new _TransactionError.TransactionError(_types.BasicTxErrorType.UNSUPPORTED));
328
327
  }
329
328
  async handleYieldUnstake(amount, address, selectedTarget) {
330
- var _priority$maxFeePerGa2, _priority$maxPriority2;
331
329
  const evmApi = this.evmApi;
332
330
  const derivativeTokenSlug = this.derivativeAssets[0];
333
331
  const derivativeTokenInfo = this.state.getAssetBySlug(derivativeTokenSlug);
@@ -343,14 +341,13 @@ class StellaSwapLiquidStakingPoolHandler extends _base.default {
343
341
  from: address
344
342
  });
345
343
  const priority = await (0, _utils2.calculateGasFeeParams)(evmApi, this.chain);
344
+ const feeCombine = (0, _utils3.combineEthFee)(priority);
346
345
  const transaction = {
347
346
  from: address,
348
347
  to: (0, _utils._getContractAddressOfToken)(derivativeTokenInfo),
349
348
  data: redeemEncodedCall,
350
349
  gas: gasLimit,
351
- gasPrice: priority.gasPrice,
352
- maxFeePerGas: (_priority$maxFeePerGa2 = priority.maxFeePerGas) === null || _priority$maxFeePerGa2 === void 0 ? void 0 : _priority$maxFeePerGa2.toString(),
353
- maxPriorityFeePerGas: (_priority$maxPriority2 = priority.maxPriorityFeePerGas) === null || _priority$maxPriority2 === void 0 ? void 0 : _priority$maxPriority2.toString()
350
+ ...feeCombine
354
351
  };
355
352
  return [_KoniTypes.ExtrinsicType.UNSTAKE_STDOT, transaction];
356
353
  }
@@ -360,7 +357,6 @@ class StellaSwapLiquidStakingPoolHandler extends _base.default {
360
357
  /* Other actions */
361
358
 
362
359
  async handleYieldWithdraw(address, unstakingInfo) {
363
- var _priority$maxFeePerGa3, _priority$maxPriority3;
364
360
  const evmApi = this.evmApi;
365
361
  const derivativeTokenSlug = this.derivativeAssets[0];
366
362
  const derivativeTokenInfo = this.state.getAssetBySlug(derivativeTokenSlug);
@@ -376,14 +372,13 @@ class StellaSwapLiquidStakingPoolHandler extends _base.default {
376
372
  from: address
377
373
  });
378
374
  const priority = await (0, _utils2.calculateGasFeeParams)(evmApi, this.chain);
375
+ const feeCombine = (0, _utils3.combineEthFee)(priority);
379
376
  return {
380
377
  from: address,
381
378
  to: (0, _utils._getContractAddressOfToken)(derivativeTokenInfo),
382
379
  data: withdrawEncodedCall,
383
380
  gas: gasLimit,
384
- gasPrice: priority.gasPrice,
385
- maxFeePerGas: (_priority$maxFeePerGa3 = priority.maxFeePerGas) === null || _priority$maxFeePerGa3 === void 0 ? void 0 : _priority$maxFeePerGa3.toString(),
386
- maxPriorityFeePerGas: (_priority$maxPriority3 = priority.maxPriorityFeePerGas) === null || _priority$maxPriority3 === void 0 ? void 0 : _priority$maxPriority3.toString()
381
+ ...feeCombine
387
382
  }; // TODO: check tx history parsing
388
383
  }
389
384
 
@@ -13,6 +13,7 @@ var _xcm = require("@subwallet/extension-base/services/balance-service/transfer/
13
13
  var _utils2 = require("@subwallet/extension-base/services/chain-service/utils");
14
14
  var _types = require("@subwallet/extension-base/types");
15
15
  var _utils3 = require("@subwallet/extension-base/utils");
16
+ var _getId = require("@subwallet/extension-base/utils/getId");
16
17
  var _i18next = require("i18next");
17
18
  var _util = require("@polkadot/util");
18
19
  var _base = _interopRequireDefault(require("./base"));
@@ -232,13 +233,18 @@ class BaseSpecialStakingPoolHandler extends _base.default {
232
233
  type: _types.YieldStepType.XCM
233
234
  };
234
235
  const xcmOriginSubstrateApi = await this.state.getSubstrateApi(altInputTokenInfo.originChain).isReady;
236
+ const id = (0, _getId.getId)();
237
+ const feeInfo = await this.state.feeService.subscribeChainFee(id, altChainInfo.slug, 'substrate');
235
238
  const xcmTransfer = await (0, _xcm.createXcmExtrinsic)({
239
+ sender: address,
236
240
  originTokenInfo: altInputTokenInfo,
237
241
  destinationTokenInfo: inputTokenInfo,
238
242
  sendingValue: bnAmount.toString(),
239
243
  recipient: address,
240
- chainInfoMap: this.state.getChainInfoMap(),
241
- substrateApi: xcmOriginSubstrateApi
244
+ destinationChain: this.chainInfo,
245
+ originChain: altChainInfo,
246
+ substrateApi: xcmOriginSubstrateApi,
247
+ feeInfo
242
248
  });
243
249
  const _xcmFeeInfo = await xcmTransfer.paymentInfo(address);
244
250
  const xcmFeeInfo = _xcmFeeInfo.toPrimitive();
@@ -435,13 +441,18 @@ class BaseSpecialStakingPoolHandler extends _base.default {
435
441
  const bnXcmFee = new _util.BN(xcmFee);
436
442
  const bnAmount = new _util.BN(amount);
437
443
  const bnTotalAmount = bnAmount.sub(bnInputTokenBalance).add(bnXcmFee);
444
+ const id = (0, _getId.getId)();
445
+ const feeInfo = await this.state.feeService.subscribeChainFee(id, originChainInfo.slug, 'substrate');
438
446
  const extrinsic = await (0, _xcm.createXcmExtrinsic)({
439
- chainInfoMap: this.state.getChainInfoMap(),
440
447
  destinationTokenInfo,
441
448
  originTokenInfo,
442
449
  recipient: address,
443
450
  sendingValue: bnTotalAmount.toString(),
444
- substrateApi
451
+ substrateApi,
452
+ sender: address,
453
+ originChain: originChainInfo,
454
+ destinationChain: this.chainInfo,
455
+ feeInfo
445
456
  });
446
457
  const xcmData = {
447
458
  originNetworkKey: originChainInfo.slug,
@@ -0,0 +1 @@
1
+ "use strict";
@@ -12,6 +12,11 @@ var _rxjs = require("rxjs");
12
12
 
13
13
  class FeeService {
14
14
  evmFeeSubject = new _rxjs.BehaviorSubject({});
15
+ chainFeeSubscriptionMap = {
16
+ evm: {},
17
+ substrate: {},
18
+ ton: {}
19
+ };
15
20
  constructor(state) {
16
21
  this.state = state;
17
22
  this.useInfura = true;
@@ -66,5 +71,111 @@ class FeeService {
66
71
  clearInterval(interval);
67
72
  };
68
73
  }
74
+ subscribeChainFee(id, chain, type, callback) {
75
+ return new Promise(resolve => {
76
+ const _callback = value => {
77
+ if (value) {
78
+ callback === null || callback === void 0 ? void 0 : callback(value);
79
+ resolve(value);
80
+ }
81
+ };
82
+ const feeSubscription = this.chainFeeSubscriptionMap[type][chain];
83
+ if (feeSubscription) {
84
+ const observer = feeSubscription.observer;
85
+ _callback(observer.getValue());
86
+
87
+ // If have callback, just subscribe
88
+ if (callback) {
89
+ const subscription = observer.subscribe({
90
+ next: _callback
91
+ });
92
+ this.chainFeeSubscriptionMap[type][chain].subscription[id] = () => {
93
+ if (!subscription.closed) {
94
+ subscription.unsubscribe();
95
+ }
96
+ };
97
+ }
98
+ } else {
99
+ const observer = new _rxjs.BehaviorSubject(undefined);
100
+ const subscription = observer.subscribe({
101
+ next: _callback
102
+ });
103
+ let cancel = false;
104
+ let interval;
105
+ const update = () => {
106
+ if (cancel) {
107
+ clearInterval(interval);
108
+ } else {
109
+ const api = this.state.getEvmApi(chain);
110
+ if (api) {
111
+ (0, _utils2.calculateGasFeeParams)(api, chain).then(info => {
112
+ observer.next(info);
113
+ }).catch(e => {
114
+ console.warn(`Cannot get fee param for ${chain}`, e);
115
+ observer.next({
116
+ type: 'evm',
117
+ gasPrice: '0',
118
+ baseGasFee: undefined,
119
+ options: undefined
120
+ });
121
+ });
122
+ } else {
123
+ observer.next({
124
+ type: type,
125
+ busyNetwork: false,
126
+ options: {
127
+ slow: {
128
+ tip: '0'
129
+ },
130
+ average: {
131
+ tip: '0'
132
+ },
133
+ fast: {
134
+ tip: '0'
135
+ },
136
+ default: 'slow'
137
+ }
138
+ });
139
+ clearInterval(interval);
140
+ }
141
+ }
142
+ };
143
+ update();
144
+
145
+ // If have callback, just subscribe
146
+ if (callback) {
147
+ interval = setInterval(update, 15 * 1000);
148
+ const unsub = () => {
149
+ cancel = true;
150
+ observer.complete();
151
+ clearInterval(interval);
152
+ };
153
+ this.chainFeeSubscriptionMap[type][chain] = {
154
+ observer,
155
+ subscription: {
156
+ [id]: () => {
157
+ if (!subscription.closed) {
158
+ subscription.unsubscribe();
159
+ }
160
+ }
161
+ },
162
+ unsubscribe: unsub
163
+ };
164
+ }
165
+ }
166
+ });
167
+ }
168
+ unsubscribeChainFee(id, chain, type) {
169
+ const subscription = this.chainFeeSubscriptionMap[type][chain];
170
+ if (subscription) {
171
+ const unsub = subscription.subscription[id];
172
+ unsub && unsub();
173
+ delete subscription.subscription[id];
174
+ if (Object.keys(subscription.subscription).length === 0) {
175
+ subscription.unsubscribe();
176
+ delete this.chainFeeSubscriptionMap[type][chain];
177
+ }
178
+ }
179
+ }
69
180
  }
70
181
  exports.default = FeeService;