@subwallet/extension-base 1.2.3-1 → 1.2.4-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 (53) hide show
  1. package/background/KoniTypes.d.ts +0 -153
  2. package/background/KoniTypes.js +0 -21
  3. package/cjs/background/KoniTypes.js +1 -22
  4. package/cjs/core/logic-validation/earning.js +2 -2
  5. package/cjs/core/logic-validation/transfer.js +0 -7
  6. package/cjs/core/substrate/nominationpools-pallet.js +11 -1
  7. package/cjs/core/substrate/system-pallet.js +2 -3
  8. package/cjs/core/substrate/xcm-parser.js +190 -0
  9. package/cjs/koni/api/dotsama/transfer.js +10 -119
  10. package/cjs/koni/api/xcm/polkadotXcm.js +12 -20
  11. package/cjs/koni/api/xcm/utils.js +8 -126
  12. package/cjs/koni/api/xcm/xTokens.js +10 -8
  13. package/cjs/koni/api/xcm/xcmPallet.js +6 -6
  14. package/cjs/koni/background/handlers/Extension.js +90 -113
  15. package/cjs/packageInfo.js +1 -1
  16. package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +6 -3
  17. package/cjs/services/chain-service/constants.js +2 -2
  18. package/cjs/services/chain-service/utils/index.js +7 -2
  19. package/cjs/services/earning-service/handlers/special.js +3 -3
  20. package/cjs/services/migration-service/scripts/MigrateTransactionHistoryBySymbol.js +2 -1
  21. package/cjs/services/migration-service/scripts/databases/MigrateAssetSetting.js +2 -1
  22. package/cjs/services/migration-service/scripts/index.js +2 -2
  23. package/cjs/services/swap-service/handler/base-handler.js +5 -3
  24. package/cjs/services/swap-service/handler/hydradx-handler.js +1 -1
  25. package/core/logic-validation/earning.d.ts +1 -1
  26. package/core/logic-validation/earning.js +2 -2
  27. package/core/logic-validation/transfer.js +0 -7
  28. package/core/substrate/nominationpools-pallet.d.ts +4 -1
  29. package/core/substrate/nominationpools-pallet.js +8 -1
  30. package/core/substrate/system-pallet.js +2 -3
  31. package/core/substrate/xcm-parser.d.ts +49 -0
  32. package/core/substrate/xcm-parser.js +181 -0
  33. package/koni/api/dotsama/transfer.d.ts +0 -3
  34. package/koni/api/dotsama/transfer.js +12 -119
  35. package/koni/api/xcm/polkadotXcm.js +14 -22
  36. package/koni/api/xcm/utils.d.ts +3 -48
  37. package/koni/api/xcm/utils.js +5 -114
  38. package/koni/api/xcm/xTokens.js +12 -10
  39. package/koni/api/xcm/xcmPallet.js +7 -7
  40. package/koni/background/handlers/Extension.d.ts +1 -3
  41. package/koni/background/handlers/Extension.js +8 -28
  42. package/package.json +11 -6
  43. package/packageInfo.js +1 -1
  44. package/services/balance-service/helpers/subscribe/substrate/index.js +8 -5
  45. package/services/chain-service/constants.js +2 -2
  46. package/services/chain-service/utils/index.d.ts +3 -2
  47. package/services/chain-service/utils/index.js +5 -2
  48. package/services/earning-service/handlers/special.js +3 -3
  49. package/services/migration-service/scripts/MigrateTransactionHistoryBySymbol.js +2 -1
  50. package/services/migration-service/scripts/databases/MigrateAssetSetting.js +2 -1
  51. package/services/migration-service/scripts/index.js +2 -2
  52. package/services/swap-service/handler/base-handler.js +5 -3
  53. package/services/swap-service/handler/hydradx-handler.js +1 -1
@@ -4,8 +4,6 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.checkReferenceCount = checkReferenceCount;
8
- exports.checkSupportTransfer = checkSupportTransfer;
9
7
  exports.getTransferMockTxFee = exports.createTransferExtrinsic = void 0;
10
8
  var _api = require("@gear-js/api");
11
9
  var _wasm = require("@subwallet/extension-base/koni/api/tokens/wasm");
@@ -20,105 +18,6 @@ var _utilCrypto = require("@polkadot/util-crypto");
20
18
  // Copyright 2019-2022 @subwallet/extension-base
21
19
  // SPDX-License-Identifier: Apache-2.0
22
20
 
23
- function isRefCount(accountInfo) {
24
- return !!accountInfo.refcount;
25
- }
26
- async function checkReferenceCount(networkKey, address, substrateApiMap, chainInfo) {
27
- const apiProps = await substrateApiMap[networkKey].isReady;
28
- const api = apiProps.api;
29
- if ((0, _utils2._isChainEvmCompatible)(chainInfo)) {
30
- return false;
31
- }
32
-
33
- // @ts-ignore
34
- const accountInfo = await api.query.system.account(address);
35
- return accountInfo ? isRefCount(accountInfo) ? !accountInfo.refcount.isZero() : !accountInfo.consumers.isZero() : false;
36
- }
37
- async function checkSupportTransfer(networkKey, tokenInfo, substrateApiMap, chainInfo) {
38
- const substrateApi = await substrateApiMap[networkKey].isReady;
39
- if (!tokenInfo) {
40
- return {
41
- supportTransfer: false,
42
- supportTransferAll: false
43
- };
44
- }
45
- if ((0, _utils2._isChainEvmCompatible)(chainInfo)) {
46
- return {
47
- supportTransfer: true,
48
- supportTransferAll: true
49
- };
50
- }
51
- if (tokenInfo.symbol.startsWith(_constants._ZK_ASSET_PREFIX) && _constants._MANTA_ZK_CHAIN_GROUP.includes(tokenInfo.originChain)) {
52
- return {
53
- supportTransfer: false,
54
- supportTransferAll: false
55
- };
56
- }
57
- if (_constants._TRANSFER_NOT_SUPPORTED_CHAINS.includes(networkKey)) {
58
- return {
59
- supportTransfer: false,
60
- supportTransferAll: false
61
- };
62
- }
63
- const api = substrateApi.api;
64
- const isTxCurrenciesSupported = !!api && !!api.tx && !!api.tx.currencies;
65
- const isTxBalancesSupported = !!api && !!api.tx && !!api.tx.balances;
66
- const isTxTokensSupported = !!api && !!api.tx && !!api.tx.tokens;
67
- const isTxEqBalancesSupported = !!api && !!api.tx && !!api.tx.eqBalances;
68
- const result = {
69
- supportTransfer: false,
70
- supportTransferAll: false
71
- };
72
- if (!(isTxCurrenciesSupported || isTxBalancesSupported || isTxTokensSupported || isTxEqBalancesSupported)) {
73
- return result;
74
- }
75
- if ((0, _utils2._isTokenWasmSmartContract)(tokenInfo) && api.query.contracts) {
76
- // for PSP tokens
77
- return {
78
- supportTransfer: true,
79
- supportTransferAll: true
80
- };
81
- }
82
-
83
- // TODO: need review
84
- if (_constants._TRANSFER_CHAIN_GROUP.acala.includes(networkKey) && !(0, _utils2._isNativeToken)(tokenInfo) && isTxCurrenciesSupported) {
85
- result.supportTransfer = true;
86
- result.supportTransferAll = true;
87
- } else if (_constants._TRANSFER_CHAIN_GROUP.kintsugi.includes(networkKey) && !(0, _utils2._isNativeToken)(tokenInfo) && isTxTokensSupported) {
88
- result.supportTransfer = true;
89
- result.supportTransferAll = true;
90
- } else if (_constants._TRANSFER_CHAIN_GROUP.genshiro.includes(networkKey)
91
- // && !_isNativeToken(tokenInfo) && isTxEqBalancesSupported
92
- ) {
93
- result.supportTransfer = false;
94
- result.supportTransferAll = false;
95
- // } else if (_TRANSFER_CHAIN_GROUP.crab.includes(networkKey) && _BALANCE_TOKEN_GROUP.crab.includes(tokenInfo.symbol)) {
96
- // result.supportTransfer = true;
97
- // result.supportTransferAll = true;
98
- } else if (isTxBalancesSupported && (0, _utils2._isNativeToken)(tokenInfo)) {
99
- result.supportTransfer = true;
100
- result.supportTransferAll = true;
101
- } else if (_constants._TRANSFER_CHAIN_GROUP.bitcountry.includes(networkKey) && !(0, _utils2._isNativeToken)(tokenInfo) && _constants._BALANCE_TOKEN_GROUP.bitcountry.includes(tokenInfo.symbol)) {
102
- result.supportTransfer = true;
103
- result.supportTransferAll = true;
104
- } else if (_constants._TRANSFER_CHAIN_GROUP.statemine.includes(networkKey) && !(0, _utils2._isNativeToken)(tokenInfo)) {
105
- result.supportTransfer = true;
106
- result.supportTransferAll = true;
107
- } else if (_constants._TRANSFER_CHAIN_GROUP.sora_substrate.includes(networkKey)) {
108
- result.supportTransfer = true;
109
- result.supportTransferAll = true;
110
- // } else if (_TRANSFER_CHAIN_GROUP.riochain.includes(networkKey) && _isNativeToken(tokenInfo)) {
111
- // result.supportTransfer = true;
112
- // result.supportTransferAll = true;
113
- } else if (_constants._TRANSFER_CHAIN_GROUP.avail.includes(networkKey)) {
114
- result.supportTransfer = true;
115
- result.supportTransferAll = true;
116
- } else if (_constants._TRANSFER_CHAIN_GROUP.centrifuge.includes(networkKey)) {
117
- result.supportTransfer = true;
118
- result.supportTransferAll = true;
119
- }
120
- return result;
121
- }
122
21
  const createTransferExtrinsic = async _ref => {
123
22
  var _tokenInfo$metadata;
124
23
  let {
@@ -141,11 +40,17 @@ const createTransferExtrinsic = async _ref => {
141
40
  const isTxCurrenciesSupported = !!api && !!api.tx && !!api.tx.currencies;
142
41
  const isTxBalancesSupported = !!api && !!api.tx && !!api.tx.balances;
143
42
  const isTxTokensSupported = !!api && !!api.tx && !!api.tx.tokens;
144
- // const isTxEqBalancesSupported = !!api && !!api.tx && !!api.tx.eqBalances;
145
43
  const isTxAssetsSupported = !!api && !!api.tx && !!api.tx.assets;
146
44
  let transferAmount; // for PSP-22 tokens, might be deprecated in the future
147
45
 
148
- if ((0, _utils2._isTokenWasmSmartContract)(tokenInfo) && api.query.contracts) {
46
+ if ((0, _utils2._isBridgedToken)(tokenInfo) && api.tx.foreignAssets) {
47
+ const onChainInfo = (0, _utils2._getTokenOnChainInfo)(tokenInfo);
48
+ if (transferAll) {
49
+ transfer = api.tx.foreignAssets.transfer(onChainInfo, to, value);
50
+ } else {
51
+ transfer = api.tx.foreignAssets.transferKeepAlive(onChainInfo, to, value);
52
+ }
53
+ } else if ((0, _utils2._isTokenWasmSmartContract)(tokenInfo) && api.query.contracts) {
149
54
  const contractPromise = (0, _wasm.getPSP22ContractPromise)(api, (0, _utils2._getContractAddressOfToken)(tokenInfo));
150
55
  // @ts-ignore
151
56
  const gasLimit = await (0, _utils.getWasmContractGasLimit)(api, from, 'psp22::transfer', contractPromise, {}, [from, value, {}]);
@@ -187,25 +92,10 @@ const createTransferExtrinsic = async _ref => {
187
92
  } else if (value) {
188
93
  transfer = api.tx.tokens.transfer(to, (0, _utils2._getTokenOnChainInfo)(tokenInfo) || (0, _utils2._getTokenOnChainAssetId)(tokenInfo), new _util.BN(value));
189
94
  }
190
- } else if (_constants._TRANSFER_CHAIN_GROUP.genshiro.includes(networkKey)
191
- // && isTxEqBalancesSupported
192
- ) {
193
- // transfer = api.tx.eqBalances.transfer(_getTokenOnChainAssetId(tokenInfo), to, value);
194
- /* empty */
195
- // } else if (!_isNativeToken(tokenInfo) && (_TRANSFER_CHAIN_GROUP.crab.includes(networkKey) || _BALANCE_TOKEN_GROUP.crab.includes(tokenInfo.symbol))) {
196
- // if (transferAll) {
197
- // transfer = api.tx.kton.transferAll(to, false);
198
- // } else if (value) {
199
- // transfer = api.tx.kton.transfer(to, new BN(value));
200
- // }
201
95
  } else if (_constants._TRANSFER_CHAIN_GROUP.bitcountry.includes(networkKey) && !(0, _utils2._isNativeToken)(tokenInfo)) {
202
96
  transfer = api.tx.currencies.transfer(to, (0, _utils2._getTokenOnChainInfo)(tokenInfo), value);
203
97
  } else if (_constants._TRANSFER_CHAIN_GROUP.statemine.includes(networkKey) && !(0, _utils2._isNativeToken)(tokenInfo)) {
204
98
  transfer = api.tx.assets.transfer((0, _utils2._getTokenOnChainAssetId)(tokenInfo), to, value);
205
- // } else if (_TRANSFER_CHAIN_GROUP.riochain.includes(networkKey)) {
206
- // if (_isNativeToken(tokenInfo)) {
207
- // transfer = api.tx.currencies.transferNativeCurrency(to, value);
208
- // }
209
99
  } else if (_constants._TRANSFER_CHAIN_GROUP.sora_substrate.includes(networkKey) && isTxAssetsSupported) {
210
100
  transfer = api.tx.assets.transfer((0, _utils2._getTokenOnChainAssetId)(tokenInfo), to, value);
211
101
  } else if (isTxBalancesSupported && (0, _utils2._isNativeToken)(tokenInfo)) {
@@ -247,10 +137,11 @@ const getTransferMockTxFee = async (address, chainInfo, tokenInfo, api) => {
247
137
  } else {
248
138
  var _paymentInfo$partialF;
249
139
  const substrateApi = api;
140
+ const chainApi = await substrateApi.isReady;
250
141
  const [mockTx] = await createTransferExtrinsic({
251
142
  from: address,
252
143
  networkKey: chainInfo.slug,
253
- substrateApi,
144
+ substrateApi: chainApi,
254
145
  to: address,
255
146
  tokenInfo,
256
147
  transferAll: true,
@@ -4,35 +4,27 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getExtrinsicByPolkadotXcmPallet = getExtrinsicByPolkadotXcmPallet;
7
+ var _xcmParser = require("@subwallet/extension-base/core/substrate/xcm-parser");
7
8
  var _utils = require("@subwallet/extension-base/koni/api/xcm/utils");
8
9
  var _utils2 = require("@subwallet/extension-base/services/chain-service/utils");
9
10
  // Copyright 2019-2022 @subwallet/extension-base
10
11
  // SPDX-License-Identifier: Apache-2.0
11
12
 
12
13
  function getExtrinsicByPolkadotXcmPallet(tokenInfo, originChainInfo, destinationChainInfo, recipientAddress, value, api) {
13
- const weightParam = (0, _utils.getDestWeight)();
14
- const version = ['statemint', 'statemine', 'shiden', 'astar'].includes(originChainInfo.slug) ? 'V3' : 'V1';
15
- const beneficiary = (0, _utils.getBeneficiary)(destinationChainInfo, recipientAddress, version);
16
- const destination = (0, _utils.getDestinationChainLocation)(originChainInfo, destinationChainInfo, version);
17
- let assetLocation = (0, _utils.getTokenLocation)(tokenInfo, value, version);
14
+ let version = _utils.STABLE_XCM_VERSION;
18
15
  let method = 'limitedReserveTransferAssets';
19
- if (['statemint', 'statemine'].includes(originChainInfo.slug) && (0, _utils2._isSubstrateRelayChain)(destinationChainInfo)) {
20
- assetLocation = {
21
- [version]: [{
22
- id: {
23
- Concrete: {
24
- parents: 1,
25
- interior: 'Here'
26
- }
27
- },
28
- fun: {
29
- Fungible: value
30
- }
31
- }]
32
- };
16
+ if ((0, _utils2._isBridgedToken)(tokenInfo)) {
17
+ version = 4;
18
+ method = 'transferAssets';
19
+ }
20
+ if ((0, _utils.isUseTeleportProtocol)(originChainInfo, destinationChainInfo)) {
33
21
  method = 'limitedTeleportAssets';
34
22
  }
35
- return api.tx.polkadotXcm[method](destination, beneficiary, assetLocation, 0,
23
+ const weightParam = (0, _xcmParser._getXcmDestWeight)(originChainInfo);
24
+ const destination = (0, _xcmParser._getXcmMultiLocation)(originChainInfo, destinationChainInfo, version);
25
+ const beneficiary = (0, _xcmParser._getXcmBeneficiary)(destinationChainInfo, recipientAddress, version);
26
+ const tokenLocation = (0, _xcmParser._getXcmMultiAssets)(tokenInfo, value, version);
27
+ return api.tx.polkadotXcm[method](destination, beneficiary, tokenLocation, 0,
36
28
  // FeeAssetItem
37
29
  weightParam);
38
30
  }
@@ -3,133 +3,15 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.FOUR_INSTRUCTIONS_WEIGHT = exports.FOUR_INSTRUCTIONS_LIMITED_WEIGHT = void 0;
7
- exports.getBeneficiary = getBeneficiary;
8
- exports.getDestMultilocation = getDestMultilocation;
9
- exports.getDestWeight = getDestWeight;
10
- exports.getDestinationChainLocation = getDestinationChainLocation;
11
- exports.getReceiverLocation = getReceiverLocation;
12
- exports.getTokenLocation = getTokenLocation;
13
- var _chainList = require("@subwallet/chain-list");
14
- var _utils = require("@subwallet/extension-base/services/chain-service/utils");
15
- var _utilCrypto = require("@polkadot/util-crypto");
6
+ exports.STABLE_XCM_VERSION = void 0;
7
+ exports.isUseTeleportProtocol = isUseTeleportProtocol;
16
8
  // Copyright 2019-2022 @subwallet/extension-base
17
9
  // SPDX-License-Identifier: Apache-2.0
18
10
 
19
- const FOUR_INSTRUCTIONS_WEIGHT = 5000000000;
20
- exports.FOUR_INSTRUCTIONS_WEIGHT = FOUR_INSTRUCTIONS_WEIGHT;
21
- const FOUR_INSTRUCTIONS_LIMITED_WEIGHT = {
22
- Limited: 5000000000
23
- };
24
-
25
- // get multilocation for destination chain from a parachain
26
- exports.FOUR_INSTRUCTIONS_LIMITED_WEIGHT = FOUR_INSTRUCTIONS_LIMITED_WEIGHT;
27
- function getReceiverLocation(destinationChainInfo, toAddress, version) {
28
- const network = version && version === 'V3' ? undefined : 'Any';
29
- if (destinationChainInfo.slug === _chainList.COMMON_CHAIN_SLUGS.ASTAR_EVM) {
30
- const ss58Address = (0, _utilCrypto.evmToAddress)(toAddress, 2006); // TODO: shouldn't pass addressPrefix directly
31
-
32
- return {
33
- AccountId32: {
34
- network,
35
- id: (0, _utilCrypto.decodeAddress)(ss58Address)
36
- }
37
- };
38
- }
39
- if ((0, _utils._isChainEvmCompatible)(destinationChainInfo)) {
40
- return {
41
- AccountKey20: {
42
- network,
43
- key: toAddress
44
- }
45
- };
46
- }
47
- return {
48
- AccountId32: {
49
- network,
50
- id: (0, _utilCrypto.decodeAddress)(toAddress)
51
- }
52
- };
53
- }
54
- function getBeneficiary(destinationChainInfo, recipientAddress) {
55
- let version = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'V1';
56
- const receiverLocation = getReceiverLocation(destinationChainInfo, recipientAddress, version);
57
- return {
58
- [version]: {
59
- parents: 0,
60
- interior: {
61
- X1: receiverLocation
62
- }
63
- }
64
- };
65
- }
66
- function getDestWeight() {
67
- return 'Unlimited';
68
- }
69
- function getTokenLocation(tokenInfo, sendingValue) {
70
- let version = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'V1';
71
- if (!(0, _utils._isNativeToken)(tokenInfo)) {
72
- const multilocation = (0, _utils._getXcmAssetMultilocation)(tokenInfo);
73
- return {
74
- [version]: [{
75
- id: multilocation,
76
- fun: {
77
- Fungible: sendingValue
78
- }
79
- }]
80
- };
81
- }
82
- return {
83
- [version]: [{
84
- id: {
85
- Concrete: {
86
- parents: 0,
87
- interior: 'Here'
88
- }
89
- },
90
- fun: {
91
- Fungible: sendingValue
92
- }
93
- }]
94
- };
95
- }
96
- function getDestMultilocation(destinationChainInfo, recipient) {
97
- let version = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'V1';
98
- const receiverLocation = getReceiverLocation(destinationChainInfo, recipient, version);
99
- if ((0, _utils._isSubstrateParaChain)(destinationChainInfo)) {
100
- const interior = {
101
- X2: [{
102
- Parachain: (0, _utils._getSubstrateParaId)(destinationChainInfo)
103
- }, receiverLocation]
104
- };
105
- return {
106
- [version]: {
107
- parents: 1,
108
- interior
109
- }
110
- };
111
- }
112
- return {
113
- [version]: {
114
- parents: 1,
115
- interior: {
116
- X1: receiverLocation
117
- }
118
- }
119
- };
120
- }
121
- function getDestinationChainLocation(originChainInfo, destinationChainInfo) {
122
- let version = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'V1';
123
- const parents = (0, _utils._isSubstrateRelayChain)(originChainInfo) ? 0 : 1;
124
- const interior = (0, _utils._isSubstrateParaChain)(destinationChainInfo) ? {
125
- X1: {
126
- Parachain: (0, _utils._getSubstrateParaId)(destinationChainInfo)
127
- }
128
- } : 'Here';
129
- return {
130
- [version]: {
131
- parents,
132
- interior
133
- }
134
- };
11
+ const STABLE_XCM_VERSION = 3;
12
+ exports.STABLE_XCM_VERSION = STABLE_XCM_VERSION;
13
+ function isUseTeleportProtocol(originChainInfo, destChainInfo) {
14
+ const relayChainToSystemChain = ['polkadot'].includes(originChainInfo.slug) && ['statemint'].includes(destChainInfo.slug) || ['kusama'].includes(originChainInfo.slug) && ['statemine'].includes(destChainInfo.slug);
15
+ const systemChainToRelayChain = ['polkadot'].includes(destChainInfo.slug) && ['statemint'].includes(originChainInfo.slug) || ['kusama'].includes(destChainInfo.slug) && ['statemine'].includes(originChainInfo.slug);
16
+ return relayChainToSystemChain || systemChainToRelayChain;
135
17
  }
@@ -4,27 +4,29 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getExtrinsicByXtokensPallet = getExtrinsicByXtokensPallet;
7
+ var _xcmParser = require("@subwallet/extension-base/core/substrate/xcm-parser");
7
8
  var _utils = require("@subwallet/extension-base/koni/api/xcm/utils");
8
9
  var _utils2 = require("@subwallet/extension-base/services/chain-service/utils");
9
10
  // Copyright 2019-2022 @subwallet/extension-base
10
11
  // SPDX-License-Identifier: Apache-2.0
11
12
 
12
13
  function getCurrencyId(tokenInfo) {
13
- if (['acala', 'karura'].includes(tokenInfo.originChain) && (0, _utils2._isNativeToken)(tokenInfo)) {
14
- return (0, _utils2._getXcmAssetMultilocation)(tokenInfo);
15
- } else if (['moonbeam', 'moonbase', 'moonriver'].includes(tokenInfo.originChain)) {
14
+ if (['moonbeam', 'moonbase', 'moonriver'].includes(tokenInfo.originChain)) {
16
15
  const tokenType = (0, _utils2._getXcmAssetType)(tokenInfo);
17
16
  const assetId = (0, _utils2._getXcmAssetId)(tokenInfo);
18
17
  return {
19
18
  [tokenType]: assetId
20
19
  };
21
- } else if (['pioneer'].includes(tokenInfo.originChain)) {
22
- return (0, _utils2._getXcmAssetMultilocation)(tokenInfo);
23
20
  }
24
21
  return (0, _utils2._getTokenOnChainInfo)(tokenInfo) || (0, _utils2._getTokenOnChainAssetId)(tokenInfo);
25
22
  }
26
23
  function getExtrinsicByXtokensPallet(tokenInfo, originChainInfo, destinationChainInfo, recipientAddress, value, api) {
27
- const weightParam = ['pioneer'].includes(originChainInfo.slug) ? _utils.FOUR_INSTRUCTIONS_WEIGHT : (0, _utils.getDestWeight)();
28
- const destVersion = ['moonbeam', 'moonriver', 'bifrost_dot', 'interlay', 'hydradx_main', 'acala', 'parallel', 'astar', 'shiden', 'centrifuge', 'manta_network'].includes(originChainInfo.slug) ? 'V3' : undefined;
29
- return api.tx.xTokens.transfer(getCurrencyId(tokenInfo), value, (0, _utils.getDestMultilocation)(destinationChainInfo, recipientAddress, destVersion), weightParam);
24
+ const version = _utils.STABLE_XCM_VERSION;
25
+ const destination = (0, _xcmParser._getXcmMultiLocation)(originChainInfo, destinationChainInfo, version, recipientAddress);
26
+ if (!(0, _utils2._getXcmAssetMultilocation)(tokenInfo)) {
27
+ const tokenCurrencyId = getCurrencyId(tokenInfo);
28
+ return api.tx.xTokens.transfer(tokenCurrencyId, value, destination, (0, _xcmParser._getXcmDestWeight)(originChainInfo));
29
+ }
30
+ const tokenMultiAsset = (0, _xcmParser._getXcmMultiAssets)(tokenInfo, value, version);
31
+ return api.tx.xTokens.transferMultiassets(tokenMultiAsset, 0, destination, (0, _xcmParser._getXcmDestWeight)(originChainInfo));
30
32
  }
@@ -4,19 +4,19 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getExtrinsicByXcmPalletPallet = getExtrinsicByXcmPalletPallet;
7
+ var _xcmParser = require("@subwallet/extension-base/core/substrate/xcm-parser");
7
8
  var _utils = require("@subwallet/extension-base/koni/api/xcm/utils");
8
9
  // Copyright 2019-2022 @subwallet/extension-base
9
10
  // SPDX-License-Identifier: Apache-2.0
10
11
 
11
12
  // this pallet is only used by Relaychains
12
13
  function getExtrinsicByXcmPalletPallet(tokenInfo, originChainInfo, destinationChainInfo, recipientAddress, value, api) {
13
- const weightParam = (0, _utils.getDestWeight)();
14
- const xcmVer = 'V3';
15
- const destination = (0, _utils.getDestinationChainLocation)(originChainInfo, destinationChainInfo, xcmVer);
16
- const beneficiary = (0, _utils.getBeneficiary)(destinationChainInfo, recipientAddress, xcmVer);
17
- const tokenLocation = (0, _utils.getTokenLocation)(tokenInfo, value, xcmVer);
14
+ const weightParam = (0, _xcmParser._getXcmDestWeight)(originChainInfo);
15
+ const destination = (0, _xcmParser._getXcmMultiLocation)(originChainInfo, destinationChainInfo, _utils.STABLE_XCM_VERSION);
16
+ const beneficiary = (0, _xcmParser._getXcmBeneficiary)(destinationChainInfo, recipientAddress, _utils.STABLE_XCM_VERSION);
17
+ const tokenLocation = (0, _xcmParser._getXcmMultiAssets)(tokenInfo, value, _utils.STABLE_XCM_VERSION);
18
18
  let method = 'limitedReserveTransferAssets';
19
- if (['statemint', 'statemine'].includes(destinationChainInfo.slug)) {
19
+ if ((0, _utils.isUseTeleportProtocol)(originChainInfo, destinationChainInfo)) {
20
20
  method = 'limitedTeleportAssets';
21
21
  }
22
22
  return api.tx.xcmPallet[method](destination, beneficiary, tokenLocation, 0, weightParam);