@subwallet/extension-base 1.1.22-0 → 1.1.24-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.
- package/background/KoniTypes.d.ts +21 -2
- package/cjs/koni/api/dotsama/balance.js +49 -0
- package/cjs/koni/api/dotsama/crowdloan.js +29 -3
- package/cjs/koni/api/dotsama/transfer.js +10 -3
- package/cjs/koni/api/staking/bonding/astar.js +9 -5
- package/cjs/koni/api/xcm/index.js +6 -1
- package/cjs/koni/api/xcm/polkadotXcm.js +1 -3
- package/cjs/koni/api/xcm/xTokens.js +1 -1
- package/cjs/koni/background/handlers/Extension.js +123 -96
- package/cjs/koni/background/handlers/Mobile.js +32 -0
- package/cjs/koni/background/handlers/State.js +15 -7
- package/cjs/koni/background/subscription.js +1 -1
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/chain-service/constants.js +5 -2
- package/cjs/services/chain-service/index.js +18 -0
- package/cjs/services/history-service/helpers/subscan-extrinsic-parser-helper.js +53 -0
- package/cjs/services/history-service/index.js +78 -21
- package/cjs/services/history-service/subscan-history.js +107 -0
- package/cjs/services/storage-service/DatabaseService.js +40 -0
- package/cjs/services/subscan-service/index.js +109 -4
- package/cjs/services/subscan-service/subscan-chain-map.js +82 -8
- package/cjs/utils/index.js +10 -1
- package/koni/api/dotsama/balance.js +49 -0
- package/koni/api/dotsama/crowdloan.d.ts +2 -2
- package/koni/api/dotsama/crowdloan.js +29 -2
- package/koni/api/dotsama/transfer.js +10 -3
- package/koni/api/staking/bonding/astar.js +9 -5
- package/koni/api/xcm/index.js +6 -1
- package/koni/api/xcm/polkadotXcm.js +2 -4
- package/koni/api/xcm/xTokens.js +1 -1
- package/koni/background/handlers/Extension.d.ts +1 -0
- package/koni/background/handlers/Extension.js +26 -0
- package/koni/background/handlers/Mobile.d.ts +5 -1
- package/koni/background/handlers/Mobile.js +31 -0
- package/koni/background/handlers/State.d.ts +1 -0
- package/koni/background/handlers/State.js +17 -9
- package/koni/background/subscription.js +1 -1
- package/package.json +17 -6
- package/packageInfo.js +1 -1
- package/services/chain-service/constants.d.ts +2 -0
- package/services/chain-service/constants.js +5 -3
- package/services/chain-service/index.d.ts +1 -0
- package/services/chain-service/index.js +18 -0
- package/services/history-service/helpers/subscan-extrinsic-parser-helper.d.ts +6 -0
- package/services/history-service/helpers/subscan-extrinsic-parser-helper.js +44 -0
- package/services/history-service/index.d.ts +10 -6
- package/services/history-service/index.js +79 -22
- package/services/history-service/subscan-history.d.ts +5 -0
- package/services/history-service/subscan-history.js +100 -0
- package/services/storage-service/DatabaseService.d.ts +3 -0
- package/services/storage-service/DatabaseService.js +40 -0
- package/services/subscan-service/index.d.ts +10 -2
- package/services/subscan-service/index.js +105 -4
- package/services/subscan-service/subscan-chain-map.d.ts +9 -3
- package/services/subscan-service/subscan-chain-map.js +78 -5
- package/services/subscan-service/types.d.ts +146 -0
- package/utils/index.d.ts +1 -0
- package/utils/index.js +7 -0
|
@@ -13,6 +13,7 @@ import { KeyringPair$Json, KeyringPair$Meta } from '@subwallet/keyring/types';
|
|
|
13
13
|
import { KeyringOptions } from '@subwallet/ui-keyring/options/types';
|
|
14
14
|
import { KeyringAddress, KeyringPairs$Json } from '@subwallet/ui-keyring/types';
|
|
15
15
|
import { SessionTypes } from '@walletconnect/types/dist/types/sign-client/session';
|
|
16
|
+
import { DexieExportJsonMeta } from 'dexie-export-import';
|
|
16
17
|
import Web3 from 'web3';
|
|
17
18
|
import { RequestArguments, TransactionConfig } from 'web3-core';
|
|
18
19
|
import { JsonRpcPayload, JsonRpcResponse } from 'web3-core-helpers';
|
|
@@ -36,7 +37,7 @@ export interface RuntimeEnvironmentInfo {
|
|
|
36
37
|
host?: string;
|
|
37
38
|
protocol?: string;
|
|
38
39
|
}
|
|
39
|
-
export declare type TargetEnvironment = 'extension' | 'webapp' | '
|
|
40
|
+
export declare type TargetEnvironment = 'extension' | 'webapp' | 'mobile';
|
|
40
41
|
export interface EnvironmentSupport {
|
|
41
42
|
MANTA_ZK: boolean;
|
|
42
43
|
}
|
|
@@ -450,7 +451,7 @@ export interface NFTTransactionAdditionalInfo {
|
|
|
450
451
|
}
|
|
451
452
|
export declare type TransactionAdditionalInfo<T extends ExtrinsicType> = T extends ExtrinsicType.TRANSFER_XCM ? XCMTransactionAdditionalInfo : T extends ExtrinsicType.SEND_NFT ? NFTTransactionAdditionalInfo : undefined;
|
|
452
453
|
export interface TransactionHistoryItem<ET extends ExtrinsicType = ExtrinsicType.TRANSFER_BALANCE> {
|
|
453
|
-
origin?: 'app' | 'migration' | 'subsquid';
|
|
454
|
+
origin?: 'app' | 'migration' | 'subsquid' | 'subscan';
|
|
454
455
|
callhash?: string;
|
|
455
456
|
signature?: string;
|
|
456
457
|
chain: string;
|
|
@@ -1419,6 +1420,10 @@ export interface RequestGetTransaction {
|
|
|
1419
1420
|
id: string;
|
|
1420
1421
|
}
|
|
1421
1422
|
export declare type SubscriptionServiceType = 'chainRegistry' | 'balance' | 'crowdloan' | 'staking';
|
|
1423
|
+
export interface MobileData {
|
|
1424
|
+
storage: string;
|
|
1425
|
+
indexedDB: string;
|
|
1426
|
+
}
|
|
1422
1427
|
export declare type CronServiceType = 'price' | 'nft' | 'staking' | 'history' | 'recoverApi' | 'checkApiStatus';
|
|
1423
1428
|
export declare type CronType = 'recoverApiMap' | 'checkApiMapStatus' | 'refreshHistory' | 'refreshNft' | 'refreshPrice' | 'refreshStakeUnlockingInfo' | 'refreshStakingReward' | 'refreshPoolingStakingReward';
|
|
1424
1429
|
export interface RequestInitCronAndSubscription {
|
|
@@ -1603,6 +1608,14 @@ export declare type CampaignData = CampaignBanner | CampaignNotification;
|
|
|
1603
1608
|
export interface RequestCampaignBannerComplete {
|
|
1604
1609
|
slug: string;
|
|
1605
1610
|
}
|
|
1611
|
+
export interface RequestSubscribeHistory {
|
|
1612
|
+
address: string;
|
|
1613
|
+
chain: string;
|
|
1614
|
+
}
|
|
1615
|
+
export interface ResponseSubscribeHistory {
|
|
1616
|
+
id: string;
|
|
1617
|
+
items: TransactionHistoryItem[];
|
|
1618
|
+
}
|
|
1606
1619
|
export interface KoniRequestSignatures {
|
|
1607
1620
|
'pri(staking.submitTuringCancelCompound)': [RequestTuringCancelStakeCompound, SWTransactionResponse];
|
|
1608
1621
|
'pri(staking.submitTuringCompound)': [RequestTuringStakeCompound, SWTransactionResponse];
|
|
@@ -1716,6 +1729,7 @@ export interface KoniRequestSignatures {
|
|
|
1716
1729
|
'pri(settings.saveShowZeroBalance)': [RequestChangeShowZeroBalance, boolean];
|
|
1717
1730
|
'pri(settings.saveShowBalance)': [RequestChangeShowBalance, boolean];
|
|
1718
1731
|
'pri(transaction.history.getSubscription)': [null, TransactionHistoryItem[], TransactionHistoryItem[]];
|
|
1732
|
+
'pri(transaction.history.subscribe)': [RequestSubscribeHistory, ResponseSubscribeHistory, TransactionHistoryItem[]];
|
|
1719
1733
|
'pri(transfer.checkReferenceCount)': [RequestTransferCheckReferenceCount, boolean];
|
|
1720
1734
|
'pri(transfer.checkSupporting)': [RequestTransferCheckSupporting, SupportTransferResponse];
|
|
1721
1735
|
'pri(transfer.getExistentialDeposit)': [RequestTransferExistentialDeposit, string];
|
|
@@ -1773,6 +1787,8 @@ export interface KoniRequestSignatures {
|
|
|
1773
1787
|
'mobile(subscription.start)': [SubscriptionServiceType[], void];
|
|
1774
1788
|
'mobile(subscription.stop)': [SubscriptionServiceType[], void];
|
|
1775
1789
|
'mobile(subscription.restart)': [SubscriptionServiceType[], void];
|
|
1790
|
+
'mobile(storage.backup)': [null, MobileData];
|
|
1791
|
+
'mobile(storage.restore)': [Partial<MobileData>, null];
|
|
1776
1792
|
'pub(token.add)': [RequestAddPspToken, boolean];
|
|
1777
1793
|
'pri(walletConnect.connect)': [RequestConnectWalletConnect, boolean];
|
|
1778
1794
|
'pri(walletConnect.requests.connect.subscribe)': [null, WalletConnectSessionRequest[], WalletConnectSessionRequest[]];
|
|
@@ -1789,6 +1805,9 @@ export interface KoniRequestSignatures {
|
|
|
1789
1805
|
'pri(campaign.banner.complete)': [RequestCampaignBannerComplete, boolean];
|
|
1790
1806
|
'pri(buyService.tokens.subscribe)': [null, Record<string, BuyTokenInfo>, Record<string, BuyTokenInfo>];
|
|
1791
1807
|
'pri(buyService.services.subscribe)': [null, Record<string, BuyServiceInfo>, Record<string, BuyServiceInfo>];
|
|
1808
|
+
'pri(database.export)': [null, string];
|
|
1809
|
+
'pri(database.import)': [string, boolean];
|
|
1810
|
+
'pri(database.checkMetadata)': [string, DexieExportJsonMeta];
|
|
1792
1811
|
}
|
|
1793
1812
|
export interface ApplicationMetadataType {
|
|
1794
1813
|
version: string;
|
|
@@ -79,6 +79,8 @@ async function subscribeSubstrateBalance(addresses, chainInfo, chain, networkAPI
|
|
|
79
79
|
unsubLocalToken = await subscribeEqBalanceAccountPallet(addresses, chain, networkAPI.api, callBack, true);
|
|
80
80
|
} else if (_constants2._BALANCE_CHAIN_GROUP.equilibrium_parachain.includes(chain)) {
|
|
81
81
|
unsubLocalToken = await subscribeEquilibriumTokenBalance(addresses, chain, networkAPI.api, callBack, true);
|
|
82
|
+
} else if (_constants2._BALANCE_CHAIN_GROUP.centrifuge.includes(chain)) {
|
|
83
|
+
unsubLocalToken = await subscribeOrmlTokensPallet(addresses, chain, networkAPI.api, callBack);
|
|
82
84
|
}
|
|
83
85
|
if ((0, _utils2._isChainEvmCompatible)(chainInfo)) {
|
|
84
86
|
unsubEvmContractToken = subscribeERC20Interval(addresses, chain, evmApiMap, callBack);
|
|
@@ -293,6 +295,53 @@ async function subscribeEqBalanceAccountPallet(addresses, chain, api, callBack,
|
|
|
293
295
|
});
|
|
294
296
|
};
|
|
295
297
|
}
|
|
298
|
+
|
|
299
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
300
|
+
async function subscribeOrmlTokensPallet(addresses, chain, api, callBack) {
|
|
301
|
+
const tokenTypes = [_types._AssetType.LOCAL];
|
|
302
|
+
const tokenMap = _handlers.state.getAssetByChainAndAsset(chain, tokenTypes);
|
|
303
|
+
const unsubList = Object.values(tokenMap).map(async tokenInfo => {
|
|
304
|
+
try {
|
|
305
|
+
const onChainInfo = (0, _utils2._getTokenOnChainInfo)(tokenInfo);
|
|
306
|
+
|
|
307
|
+
// Get Token Balance
|
|
308
|
+
// @ts-ignore
|
|
309
|
+
const unsub = await api.query.ormlTokens.accounts.multi(addresses.map(address => [address, onChainInfo]), balances => {
|
|
310
|
+
const tokenBalance = {
|
|
311
|
+
reserved: (0, _utils3.sumBN)(balances.map(b => b.reserved || new _util.BN(0))),
|
|
312
|
+
frozen: (0, _utils3.sumBN)(balances.map(b => b.frozen || new _util.BN(0))),
|
|
313
|
+
free: (0, _utils3.sumBN)(balances.map(b => b.free || new _util.BN(0))) // free is actually total balance
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
// free balance = total balance - frozen misc
|
|
317
|
+
// locked balance = reserved + frozen misc
|
|
318
|
+
const freeBalance = tokenBalance.free.sub(tokenBalance.frozen);
|
|
319
|
+
const lockedBalance = tokenBalance.frozen.add(tokenBalance.reserved);
|
|
320
|
+
callBack({
|
|
321
|
+
tokenSlug: tokenInfo.slug,
|
|
322
|
+
state: _KoniTypes.APIItemState.READY,
|
|
323
|
+
free: freeBalance.toString(),
|
|
324
|
+
locked: lockedBalance.toString(),
|
|
325
|
+
substrateInfo: {
|
|
326
|
+
reserved: tokenBalance.reserved.toString(),
|
|
327
|
+
miscFrozen: tokenBalance.frozen.toString()
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
});
|
|
331
|
+
return unsub;
|
|
332
|
+
} catch (err) {
|
|
333
|
+
console.warn(err);
|
|
334
|
+
return undefined;
|
|
335
|
+
}
|
|
336
|
+
});
|
|
337
|
+
return () => {
|
|
338
|
+
unsubList.forEach(subProm => {
|
|
339
|
+
subProm.then(unsub => {
|
|
340
|
+
unsub && unsub();
|
|
341
|
+
}).catch(console.error);
|
|
342
|
+
});
|
|
343
|
+
};
|
|
344
|
+
}
|
|
296
345
|
async function subscribeTokensAccountsPallet(addresses, chain, api, callBack, includeNativeToken) {
|
|
297
346
|
const tokenTypes = includeNativeToken ? [_types._AssetType.NATIVE, _types._AssetType.LOCAL] : [_types._AssetType.LOCAL];
|
|
298
347
|
const tokenMap = _handlers.state.getAssetByChainAndAsset(chain, tokenTypes);
|
|
@@ -24,7 +24,20 @@ const STATUS_MAP = {
|
|
|
24
24
|
[_types._FundStatus.FAILED]: _KoniTypes.CrowdloanParaState.FAILED,
|
|
25
25
|
[_types._FundStatus.WON]: _KoniTypes.CrowdloanParaState.COMPLETED
|
|
26
26
|
};
|
|
27
|
+
function getChainInfoMap(chainInfoList) {
|
|
28
|
+
const result = {};
|
|
29
|
+
chainInfoList.forEach(ci => {
|
|
30
|
+
if (ci.slug) {
|
|
31
|
+
result[ci.slug] = ci;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
27
36
|
const getOnlineFundList = (0, _fetchStaticData.fetchStaticData)('crowdloan-funds');
|
|
37
|
+
const getOnlineChainInfoMap = (async () => {
|
|
38
|
+
const chainInfoList = await (0, _fetchStaticData.fetchStaticData)('chains');
|
|
39
|
+
return getChainInfoMap(chainInfoList);
|
|
40
|
+
})();
|
|
28
41
|
function getRPCCrowdloan(parentAPI, fundInfo, hexAddresses, callback) {
|
|
29
42
|
const {
|
|
30
43
|
auctionIndex,
|
|
@@ -130,16 +143,29 @@ const subscribeAcalaContributeInterval = (polkadotAddresses, fundInfo, callback)
|
|
|
130
143
|
// return stateMap;
|
|
131
144
|
// }, {} as Record<string, CrowdloanParaState>);
|
|
132
145
|
// }
|
|
146
|
+
exports.subscribeAcalaContributeInterval = subscribeAcalaContributeInterval;
|
|
147
|
+
function isNeedToUpdateLatestFundInfoMap(latestMap, chainSlug, fundInfo) {
|
|
148
|
+
if (!latestMap[chainSlug]) {
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
if (!fundInfo.auctionIndex && fundInfo.status === _types._FundStatus.IN_AUCTION) {
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
if (fundInfo.auctionIndex > latestMap[chainSlug].auctionIndex) {
|
|
155
|
+
return true;
|
|
156
|
+
}
|
|
157
|
+
return false;
|
|
158
|
+
}
|
|
133
159
|
|
|
134
160
|
// Get All crowdloan
|
|
135
|
-
|
|
136
|
-
async function subscribeCrowdloan(addresses, substrateApiMap, callback, chainInfoMap) {
|
|
161
|
+
async function subscribeCrowdloan(addresses, substrateApiMap, callback) {
|
|
137
162
|
const unsubMap = {};
|
|
138
163
|
const latestMap = {};
|
|
139
164
|
const rawFundList = await getOnlineFundList;
|
|
165
|
+
const chainInfoMap = await getOnlineChainInfoMap;
|
|
140
166
|
rawFundList.forEach(fundInfo => {
|
|
141
167
|
const chainSlug = fundInfo.chain;
|
|
142
|
-
if (
|
|
168
|
+
if (isNeedToUpdateLatestFundInfoMap(latestMap, chainSlug, fundInfo)) {
|
|
143
169
|
latestMap[chainSlug] = fundInfo;
|
|
144
170
|
}
|
|
145
171
|
});
|
|
@@ -105,8 +105,11 @@ async function checkSupportTransfer(networkKey, tokenInfo, substrateApiMap, chai
|
|
|
105
105
|
// result.supportTransfer = true;
|
|
106
106
|
// result.supportTransferAll = true;
|
|
107
107
|
} else if (_constants._TRANSFER_CHAIN_GROUP.avail.includes(networkKey)) {
|
|
108
|
-
result.supportTransfer =
|
|
109
|
-
result.supportTransferAll =
|
|
108
|
+
result.supportTransfer = true;
|
|
109
|
+
result.supportTransferAll = true;
|
|
110
|
+
} else if (_constants._TRANSFER_CHAIN_GROUP.centrifuge.includes(networkKey)) {
|
|
111
|
+
result.supportTransfer = true;
|
|
112
|
+
result.supportTransferAll = true;
|
|
110
113
|
}
|
|
111
114
|
return result;
|
|
112
115
|
}
|
|
@@ -190,7 +193,11 @@ const createTransferExtrinsic = async _ref => {
|
|
|
190
193
|
if (transferAll) {
|
|
191
194
|
transfer = api.tx.balances.transferAll(to, false);
|
|
192
195
|
} else if (value) {
|
|
193
|
-
|
|
196
|
+
if (api.tx.balances.transferKeepAlive) {
|
|
197
|
+
transfer = api.tx.balances.transferKeepAlive(to, new _util.BN(value));
|
|
198
|
+
} else {
|
|
199
|
+
transfer = api.tx.balances.transfer(to, new _util.BN(value));
|
|
200
|
+
}
|
|
194
201
|
}
|
|
195
202
|
}
|
|
196
203
|
return [transfer, transferAmount || value];
|
|
@@ -79,6 +79,9 @@ async function getAstarStakingMetadata(chain, substrateApi) {
|
|
|
79
79
|
unstakingPeriod
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
|
+
const convertAddress = address => {
|
|
83
|
+
return (0, _utilCrypto.isEthereumAddress)(address) ? address.toLowerCase() : address;
|
|
84
|
+
};
|
|
82
85
|
async function subscribeAstarNominatorMetadata(chainInfo, address, substrateApi, ledger) {
|
|
83
86
|
const nominationList = [];
|
|
84
87
|
const unstakingList = [];
|
|
@@ -97,14 +100,15 @@ async function subscribeAstarNominatorMetadata(chainInfo, address, substrateApi,
|
|
|
97
100
|
if (_stakerInfo.length > 0) {
|
|
98
101
|
const dAppInfoMap = {};
|
|
99
102
|
allDapps.forEach(dappInfo => {
|
|
100
|
-
dAppInfoMap[dappInfo.address
|
|
103
|
+
dAppInfoMap[convertAddress(dappInfo.address)] = dappInfo;
|
|
101
104
|
});
|
|
102
105
|
for (const item of _stakerInfo) {
|
|
103
106
|
const data = item[0].toHuman();
|
|
104
107
|
const stakedDapp = data[1];
|
|
105
108
|
const stakeData = item[1].toPrimitive();
|
|
106
109
|
const stakeList = stakeData.stakes;
|
|
107
|
-
const
|
|
110
|
+
const _dappAddress = stakedDapp.Evm ? stakedDapp.Evm.toLowerCase() : stakedDapp.Wasm;
|
|
111
|
+
const dappAddress = convertAddress(_dappAddress);
|
|
108
112
|
const currentStake = stakeList.slice(-1)[0].staked.toString() || '0';
|
|
109
113
|
const bnCurrentStake = new _util.BN(currentStake);
|
|
110
114
|
if (bnCurrentStake.gt(_util.BN_ZERO)) {
|
|
@@ -114,7 +118,7 @@ async function subscribeAstarNominatorMetadata(chainInfo, address, substrateApi,
|
|
|
114
118
|
nominationList.push({
|
|
115
119
|
status: dappStakingStatus,
|
|
116
120
|
chain: chainInfo.slug,
|
|
117
|
-
validatorAddress:
|
|
121
|
+
validatorAddress: dappAddress,
|
|
118
122
|
activeStake: currentStake,
|
|
119
123
|
validatorMinStake: '0',
|
|
120
124
|
validatorIdentity: dappInfo === null || dappInfo === void 0 ? void 0 : dappInfo.name,
|
|
@@ -192,7 +196,7 @@ async function getAstarNominatorMetadata(chainInfo, address, substrateApi) {
|
|
|
192
196
|
const stakedDapp = data[1];
|
|
193
197
|
const stakeData = item[1].toPrimitive();
|
|
194
198
|
const stakeList = stakeData.stakes;
|
|
195
|
-
const dappAddress = (
|
|
199
|
+
const dappAddress = convertAddress(stakedDapp.Evm);
|
|
196
200
|
const currentStake = stakeList.slice(-1)[0].staked.toString() || '0';
|
|
197
201
|
const bnCurrentStake = new _util.BN(currentStake);
|
|
198
202
|
if (bnCurrentStake.gt(_util.BN_ZERO)) {
|
|
@@ -285,7 +289,7 @@ async function getAstarDappsInfo(networkKey, substrateApi) {
|
|
|
285
289
|
allDappsInfo.push({
|
|
286
290
|
commission: 0,
|
|
287
291
|
expectedReturn: 0,
|
|
288
|
-
address: (
|
|
292
|
+
address: convertAddress(dappAddress),
|
|
289
293
|
totalStake: totalStake,
|
|
290
294
|
ownStake: '0',
|
|
291
295
|
otherStake: totalStake.toString(),
|
|
@@ -8,6 +8,7 @@ var _polkadotXcm = require("@subwallet/extension-base/koni/api/xcm/polkadotXcm")
|
|
|
8
8
|
var _xcmPallet = require("@subwallet/extension-base/koni/api/xcm/xcmPallet");
|
|
9
9
|
var _xTokens = require("@subwallet/extension-base/koni/api/xcm/xTokens");
|
|
10
10
|
var _constants = require("@subwallet/extension-base/services/chain-service/constants");
|
|
11
|
+
var _utils = require("@subwallet/extension-base/services/chain-service/utils");
|
|
11
12
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
12
13
|
// SPDX-License-Identifier: Apache-2.0
|
|
13
14
|
|
|
@@ -26,7 +27,11 @@ const createXcmExtrinsic = async _ref => {
|
|
|
26
27
|
const api = chainApi.api;
|
|
27
28
|
let extrinsic;
|
|
28
29
|
if (_constants._XCM_CHAIN_GROUP.polkadotXcm.includes(originTokenInfo.originChain)) {
|
|
29
|
-
|
|
30
|
+
if (['astar', 'shiden'].includes(originChainInfo.slug) && !(0, _utils._isNativeToken)(originTokenInfo)) {
|
|
31
|
+
extrinsic = (0, _xTokens.getExtrinsicByXtokensPallet)(originTokenInfo, originChainInfo, destinationChainInfo, recipient, sendingValue, api);
|
|
32
|
+
} else {
|
|
33
|
+
extrinsic = (0, _polkadotXcm.getExtrinsicByPolkadotXcmPallet)(originTokenInfo, originChainInfo, destinationChainInfo, recipient, sendingValue, api);
|
|
34
|
+
}
|
|
30
35
|
} else if (_constants._XCM_CHAIN_GROUP.xcmPallet.includes(originTokenInfo.originChain)) {
|
|
31
36
|
extrinsic = (0, _xcmPallet.getExtrinsicByXcmPalletPallet)(originTokenInfo, originChainInfo, destinationChainInfo, recipient, sendingValue, api);
|
|
32
37
|
} else {
|
|
@@ -16,9 +16,7 @@ function getExtrinsicByPolkadotXcmPallet(tokenInfo, originChainInfo, destination
|
|
|
16
16
|
const destination = (0, _utils.getDestinationChainLocation)(originChainInfo, destinationChainInfo, version);
|
|
17
17
|
let assetLocation = (0, _utils.getTokenLocation)(tokenInfo, value, version);
|
|
18
18
|
let method = 'limitedReserveTransferAssets';
|
|
19
|
-
if (['
|
|
20
|
-
method = 'limitedReserveWithdrawAssets';
|
|
21
|
-
} else if (['statemint', 'statemine'].includes(originChainInfo.slug) && (0, _utils2._isSubstrateRelayChain)(destinationChainInfo)) {
|
|
19
|
+
if (['statemint', 'statemine'].includes(originChainInfo.slug) && (0, _utils2._isSubstrateRelayChain)(destinationChainInfo)) {
|
|
22
20
|
assetLocation = {
|
|
23
21
|
[version]: [{
|
|
24
22
|
id: {
|
|
@@ -25,6 +25,6 @@ function getCurrencyId(tokenInfo) {
|
|
|
25
25
|
}
|
|
26
26
|
function getExtrinsicByXtokensPallet(tokenInfo, originChainInfo, destinationChainInfo, recipientAddress, value, api) {
|
|
27
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'].includes(originChainInfo.slug) ? 'V3' : undefined;
|
|
28
|
+
const destVersion = ['moonbeam', 'moonriver', 'bifrost_dot', 'interlay', 'hydradx_main', 'acala', 'parallel', 'astar', 'shiden'].includes(originChainInfo.slug) ? 'V3' : undefined;
|
|
29
29
|
return api.tx.xTokens.transfer(getCurrencyId(tokenInfo), value, (0, _utils.getDestMultilocation)(destinationChainInfo, recipientAddress, destVersion), weightParam);
|
|
30
30
|
}
|