@subwallet/extension-base 1.3.78-0 → 1.3.80-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 +16 -6
- package/cjs/core/logic-validation/index.js +0 -12
- package/cjs/core/substrate/system-pallet.js +3 -0
- package/cjs/koni/api/nft/index.js +0 -14
- package/cjs/koni/background/cron.js +0 -17
- package/cjs/koni/background/handlers/Extension.js +13 -7
- package/cjs/koni/background/handlers/State.js +24 -6
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/helpers/process.js +49 -21
- package/cjs/services/balance-service/index.js +2 -2
- package/cjs/services/balance-service/transfer/xcm/utils.js +9 -9
- package/cjs/services/chain-service/constants.js +6 -2
- package/cjs/services/earning-service/handlers/native-staking/dtao.js +13 -13
- package/cjs/services/earning-service/handlers/native-staking/tao.js +16 -10
- package/cjs/services/earning-service/handlers/special.js +12 -4
- package/cjs/services/nft-service/index.js +219 -150
- package/cjs/services/nft-service/multi-chain-nft-fetcher.js +145 -0
- package/cjs/services/nft-service/nft-handlers/base-nft-handler.js +28 -0
- package/cjs/services/nft-service/nft-handlers/evm/evm-nft-handler.js +179 -0
- package/cjs/services/nft-service/nft-handlers/registry.js +37 -0
- package/cjs/services/nft-service/nft-handlers/unique/unique-nft-handler.js +187 -0
- package/cjs/services/storage-service/DatabaseService.js +1 -1
- package/cjs/services/swap-service/handler/asset-hub/handler.js +7 -4
- package/cjs/services/swap-service/handler/asset-hub/router.js +2 -66
- package/cjs/services/swap-service/handler/base-handler.js +4 -3
- package/cjs/services/swap-service/handler/hydradx-handler.js +9 -5
- package/cjs/services/swap-service/index.js +5 -4
- package/cjs/types/swap/index.js +4 -9
- package/cjs/utils/account/common.js +44 -8
- package/core/logic-validation/index.d.ts +0 -1
- package/core/logic-validation/index.js +0 -1
- package/core/substrate/system-pallet.js +3 -0
- package/koni/api/nft/index.js +1 -15
- package/koni/background/cron.d.ts +0 -1
- package/koni/background/cron.js +1 -18
- package/koni/background/handlers/Extension.d.ts +4 -0
- package/koni/background/handlers/Extension.js +13 -7
- package/koni/background/handlers/State.d.ts +8 -2
- package/koni/background/handlers/State.js +24 -6
- package/package.json +31 -11
- package/packageInfo.js +1 -1
- package/services/balance-service/helpers/process.d.ts +1 -1
- package/services/balance-service/helpers/process.js +48 -21
- package/services/balance-service/index.js +2 -2
- package/services/balance-service/transfer/xcm/utils.js +9 -9
- package/services/chain-service/constants.d.ts +3 -0
- package/services/chain-service/constants.js +3 -0
- package/services/earning-service/handlers/native-staking/dtao.js +12 -13
- package/services/earning-service/handlers/native-staking/tao.d.ts +2 -1
- package/services/earning-service/handlers/native-staking/tao.js +15 -10
- package/services/earning-service/handlers/special.js +13 -5
- package/services/nft-service/index.d.ts +42 -6
- package/services/nft-service/index.js +219 -151
- package/services/nft-service/multi-chain-nft-fetcher.d.ts +13 -0
- package/services/nft-service/multi-chain-nft-fetcher.js +138 -0
- package/services/nft-service/nft-handlers/base-nft-handler.d.ts +13 -0
- package/services/nft-service/nft-handlers/base-nft-handler.js +21 -0
- package/services/nft-service/nft-handlers/evm/evm-nft-handler.d.ts +9 -0
- package/services/nft-service/nft-handlers/evm/evm-nft-handler.js +171 -0
- package/services/nft-service/nft-handlers/registry.d.ts +11 -0
- package/services/nft-service/nft-handlers/registry.js +29 -0
- package/services/nft-service/nft-handlers/unique/unique-nft-handler.d.ts +12 -0
- package/services/nft-service/nft-handlers/unique/unique-nft-handler.js +177 -0
- package/services/storage-service/DatabaseService.d.ts +1 -1
- package/services/storage-service/DatabaseService.js +1 -1
- package/services/swap-service/handler/asset-hub/handler.js +7 -4
- package/services/swap-service/handler/asset-hub/router.d.ts +0 -4
- package/services/swap-service/handler/asset-hub/router.js +1 -64
- package/services/swap-service/handler/base-handler.js +4 -3
- package/services/swap-service/handler/hydradx-handler.js +9 -5
- package/services/swap-service/index.js +5 -4
- package/types/swap/index.d.ts +7 -35
- package/types/swap/index.js +3 -8
- package/types/yield/actions/join/step.d.ts +1 -0
- package/types/yield/actions/join/submit.d.ts +2 -1
- package/utils/account/common.d.ts +22 -1
- package/utils/account/common.js +44 -8
- package/cjs/core/logic-validation/swap.js +0 -235
- package/core/logic-validation/swap.d.ts +0 -26
- package/core/logic-validation/swap.js +0 -219
|
@@ -613,10 +613,10 @@ export class BalanceService {
|
|
|
613
613
|
return getDefaultTransferProcess();
|
|
614
614
|
}
|
|
615
615
|
const destChainInfo = this.state.chainService.getChainInfoByKey(params.destChain);
|
|
616
|
+
const evmApi = this.state.chainService.getEvmApi(originChainInfo.slug);
|
|
616
617
|
|
|
617
618
|
// xcm
|
|
618
619
|
if (!_isXcmWithinSameConsensus(originChainInfo, destChainInfo) && _isPureEvmChain(originChainInfo)) {
|
|
619
|
-
const evmApi = this.state.chainService.getEvmApi(originChainInfo.slug);
|
|
620
620
|
const tokenInfo = this.state.chainService.getAssetBySlug(params.tokenSlug);
|
|
621
621
|
return getSnowbridgeTransferProcessFromEvm(params.address, evmApi, tokenInfo, params.amount);
|
|
622
622
|
}
|
|
@@ -644,7 +644,7 @@ export class BalanceService {
|
|
|
644
644
|
if (!data) {
|
|
645
645
|
throw new Error('Failed to fetch Across Bridge Data. Please try again later');
|
|
646
646
|
}
|
|
647
|
-
return getAcrossbridgeTransferProcessFromEvm(data.to);
|
|
647
|
+
return getAcrossbridgeTransferProcessFromEvm(data.to, params.address, originTokenInfo, evmApi, params.amount);
|
|
648
648
|
}
|
|
649
649
|
}
|
|
650
650
|
return getDefaultTransferProcess();
|
|
@@ -13,7 +13,7 @@ import { fetchFromProxyService } from '@subwallet/extension-base/utils';
|
|
|
13
13
|
import BigNumber from 'bignumber.js';
|
|
14
14
|
import { assert, compactToU8a, isHex, u8aConcat, u8aEq } from '@polkadot/util';
|
|
15
15
|
import { _isBittensorToSubtensorBridge, _isSubtensorToBittensorBridge } from "./bittensorBridge/index.js";
|
|
16
|
-
const version = '/
|
|
16
|
+
const version = '/v1';
|
|
17
17
|
const paraSpellApi = {
|
|
18
18
|
buildXcm: `${version}/x-transfer`,
|
|
19
19
|
feeXcm: `${version}/xcm-fee`,
|
|
@@ -93,8 +93,8 @@ export async function buildXcm(request) {
|
|
|
93
93
|
}
|
|
94
94
|
const paraSpellChainMap = await fetchParaSpellChainMap();
|
|
95
95
|
const bodyData = {
|
|
96
|
-
|
|
97
|
-
|
|
96
|
+
sender,
|
|
97
|
+
recipient,
|
|
98
98
|
from: paraSpellChainMap[originChain.slug],
|
|
99
99
|
to: paraSpellChainMap[destinationChain.slug],
|
|
100
100
|
currency: createParaSpellCurrency(paraSpellIdentifyV4, sendingValue),
|
|
@@ -134,8 +134,8 @@ export async function dryRunXcm(request) {
|
|
|
134
134
|
throw new Error('Token is not support XCM at this time');
|
|
135
135
|
}
|
|
136
136
|
const bodyData = {
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
sender,
|
|
138
|
+
recipient,
|
|
139
139
|
from: paraSpellChainMap[originChain.slug],
|
|
140
140
|
to: paraSpellChainMap[destinationChain.slug],
|
|
141
141
|
currency: createParaSpellCurrency(paraSpellIdentifyV4, sendingValue),
|
|
@@ -178,8 +178,8 @@ export async function dryRunPreviewXcm(request) {
|
|
|
178
178
|
throw new Error('Token is not support XCM at this time');
|
|
179
179
|
}
|
|
180
180
|
const bodyData = {
|
|
181
|
-
|
|
182
|
-
|
|
181
|
+
sender,
|
|
182
|
+
recipient,
|
|
183
183
|
from: paraSpellChainMap[originChain.slug],
|
|
184
184
|
to: paraSpellChainMap[destinationChain.slug],
|
|
185
185
|
currency: createParaSpellCurrency(paraSpellIdentifyV4, sendingValue),
|
|
@@ -226,8 +226,8 @@ export async function estimateXcmFee(request) {
|
|
|
226
226
|
return undefined;
|
|
227
227
|
}
|
|
228
228
|
const bodyData = {
|
|
229
|
-
|
|
230
|
-
|
|
229
|
+
sender,
|
|
230
|
+
recipient,
|
|
231
231
|
from: paraSpellChainMap[fromChainInfo.slug],
|
|
232
232
|
to: paraSpellChainMap[toChainInfo.slug],
|
|
233
233
|
currency: createParaSpellCurrency(paraSpellIdentifyV4, requestValue),
|
|
@@ -52,6 +52,9 @@ export declare const _NFT_CHAIN_GROUP: {
|
|
|
52
52
|
rari: string[];
|
|
53
53
|
story_odyssey: string[];
|
|
54
54
|
};
|
|
55
|
+
export declare const NFT_CHAIN_GROUPS_MIGRATED: {
|
|
56
|
+
unique_network: string[];
|
|
57
|
+
};
|
|
55
58
|
export declare const _STAKING_ERA_LENGTH_MAP: Record<string, number>;
|
|
56
59
|
export declare const _EXPECTED_BLOCK_TIME: Record<string, number>;
|
|
57
60
|
export declare const _PARACHAIN_INFLATION_DISTRIBUTION: Record<string, Record<string, number>>;
|
|
@@ -67,6 +67,9 @@ export const _NFT_CHAIN_GROUP = {
|
|
|
67
67
|
rari: ['rari'],
|
|
68
68
|
story_odyssey: ['storyOdyssey', 'storyOdyssey_testnet']
|
|
69
69
|
};
|
|
70
|
+
export const NFT_CHAIN_GROUPS_MIGRATED = {
|
|
71
|
+
unique_network: ['unique_network']
|
|
72
|
+
};
|
|
70
73
|
|
|
71
74
|
// Staking--------------------------------------------------------------------------------------------------------------
|
|
72
75
|
|
|
@@ -9,20 +9,19 @@ import { reformatAddress } from '@subwallet/extension-base/utils';
|
|
|
9
9
|
import BigN from 'bignumber.js';
|
|
10
10
|
import { BN_ZERO } from '@polkadot/util';
|
|
11
11
|
import TaoNativeStakingPoolHandler, { DEFAULT_DTAO_MINBOND } from "./tao.js";
|
|
12
|
-
const getAlphaToTaoRateMap = async substrateApi => {
|
|
13
|
-
const allSubnets = (await substrateApi.api.call.subnetInfoRuntimeApi.getAllDynamicInfo()).toJSON();
|
|
14
|
-
if (!allSubnets || allSubnets.length === 0) {
|
|
15
|
-
return {};
|
|
16
|
-
}
|
|
12
|
+
const getAlphaToTaoRateMap = async (substrateApi, priceScaleDecimals = 9) => {
|
|
17
13
|
const result = Object.create(null);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
const PRICE_SCALE = new BigN(10).pow(priceScaleDecimals);
|
|
15
|
+
const allSubnetPrices = (await substrateApi.api.call.swapRuntimeApi.currentAlphaPriceAll()).toJSON();
|
|
16
|
+
if (allSubnetPrices && allSubnetPrices.length > 0) {
|
|
17
|
+
for (const subnetPrice of allSubnetPrices) {
|
|
18
|
+
const netuid = subnetPrice === null || subnetPrice === void 0 ? void 0 : subnetPrice.netuid;
|
|
19
|
+
if (netuid === undefined) {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
const rawPrice = subnetPrice !== null && subnetPrice !== void 0 && subnetPrice.price ? new BigN(subnetPrice.price) : new BigN(0);
|
|
23
|
+
result[netuid] = netuid === 0 ? '1' : rawPrice.dividedBy(PRICE_SCALE).toFixed();
|
|
22
24
|
}
|
|
23
|
-
const taoIn = subnet !== null && subnet !== void 0 && subnet.taoIn ? new BigN(subnet.taoIn) : new BigN(0);
|
|
24
|
-
const alphaIn = subnet !== null && subnet !== void 0 && subnet.alphaIn ? new BigN(subnet.alphaIn) : new BigN(0);
|
|
25
|
-
result[netuid] = netuid === 0 || alphaIn.lte(0) ? '1' : taoIn.dividedBy(alphaIn).toString();
|
|
26
25
|
}
|
|
27
26
|
return result;
|
|
28
27
|
};
|
|
@@ -204,7 +203,7 @@ export default class SubnetTaoStakingPoolHandler extends TaoNativeStakingPoolHan
|
|
|
204
203
|
const getPoolPosition = async () => {
|
|
205
204
|
const rawDelegateStateInfos = await substrateApi.api.call.stakeInfoRuntimeApi.getStakeInfoForColdkeys(useAddresses);
|
|
206
205
|
const delegateStateInfos = rawDelegateStateInfos.toPrimitive();
|
|
207
|
-
const alphaToTaoRateMap = await getAlphaToTaoRateMap(this.substrateApi);
|
|
206
|
+
const alphaToTaoRateMap = await getAlphaToTaoRateMap(this.substrateApi, this.getAlphaPriceScaleDecimals());
|
|
208
207
|
if (!delegateStateInfos || delegateStateInfos.length === 0) {
|
|
209
208
|
return;
|
|
210
209
|
}
|
|
@@ -82,10 +82,11 @@ export declare class BittensorCache {
|
|
|
82
82
|
fetchApr(netuid: number): Promise<ValidatorAprResponse>;
|
|
83
83
|
fetchSubnetFeeRate(netuid: number): Promise<string>;
|
|
84
84
|
}
|
|
85
|
-
export declare const getAlphaToTaoRate: (substrateApi: _SubstrateApi, netuid: number) => Promise<string>;
|
|
85
|
+
export declare const getAlphaToTaoRate: (substrateApi: _SubstrateApi, netuid: number, priceScaleDecimals?: number) => Promise<string>;
|
|
86
86
|
export default class TaoNativeStakingPoolHandler extends BaseParaStakingPoolHandler {
|
|
87
87
|
readonly availableMethod: YieldPoolMethodInfo;
|
|
88
88
|
protected bittensorCache: BittensorCache;
|
|
89
|
+
protected getAlphaPriceScaleDecimals(): number;
|
|
89
90
|
protected getMinBond(netuid?: number): Promise<BigN>;
|
|
90
91
|
constructor(state: KoniState, chain: string);
|
|
91
92
|
get maintainBalance(): string;
|
|
@@ -113,14 +113,16 @@ export class BittensorCache {
|
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
|
-
export const getAlphaToTaoRate = async (substrateApi, netuid) => {
|
|
117
|
-
|
|
118
|
-
if (!subnetInfo) {
|
|
116
|
+
export const getAlphaToTaoRate = async (substrateApi, netuid, priceScaleDecimals = 9) => {
|
|
117
|
+
if (netuid === 0) {
|
|
119
118
|
return '1';
|
|
120
119
|
}
|
|
121
|
-
const
|
|
122
|
-
const
|
|
123
|
-
|
|
120
|
+
const [rawSubnetPrice, rawRootPrice] = await Promise.all([substrateApi.api.call.swapRuntimeApi.currentAlphaPrice(netuid), substrateApi.api.call.swapRuntimeApi.currentAlphaPrice(0)]);
|
|
121
|
+
const subnetPrice = new BigN(rawSubnetPrice.toString());
|
|
122
|
+
const defaultScale = new BigN(10).pow(priceScaleDecimals);
|
|
123
|
+
const rootPrice = new BigN(rawRootPrice.toString());
|
|
124
|
+
const priceScale = rootPrice.lte(0) ? defaultScale : rootPrice;
|
|
125
|
+
return subnetPrice.lte(0) ? '0' : subnetPrice.dividedBy(priceScale).toFixed();
|
|
124
126
|
};
|
|
125
127
|
export default class TaoNativeStakingPoolHandler extends BaseParaStakingPoolHandler {
|
|
126
128
|
availableMethod = {
|
|
@@ -132,6 +134,9 @@ export default class TaoNativeStakingPoolHandler extends BaseParaStakingPoolHand
|
|
|
132
134
|
claimReward: false,
|
|
133
135
|
changeValidator: true
|
|
134
136
|
};
|
|
137
|
+
getAlphaPriceScaleDecimals() {
|
|
138
|
+
return _getAssetDecimals(this.nativeToken);
|
|
139
|
+
}
|
|
135
140
|
async getMinBond(netuid) {
|
|
136
141
|
var _cachedPool$metadata2, _cachedPool$statistic, _cachedPool$statistic2, _onlinePool$metadata2, _onlinePool$statistic, _onlinePool$statistic2;
|
|
137
142
|
// @ts-ignore
|
|
@@ -469,7 +474,7 @@ export default class TaoNativeStakingPoolHandler extends BaseParaStakingPoolHand
|
|
|
469
474
|
const hotkey = selectedValidatorInfo.address;
|
|
470
475
|
const netuid = (_subnetData$netuid = subnetData === null || subnetData === void 0 ? void 0 : subnetData.netuid) !== null && _subnetData$netuid !== void 0 ? _subnetData$netuid : 0;
|
|
471
476
|
const slippage = (_subnetData$slippage = subnetData === null || subnetData === void 0 ? void 0 : subnetData.slippage) !== null && _subnetData$slippage !== void 0 ? _subnetData$slippage : DEFAULT_BITTENSOR_SLIPPAGE;
|
|
472
|
-
const alphaToTaoPrice = new BigN(await getAlphaToTaoRate(this.substrateApi, netuid));
|
|
477
|
+
const alphaToTaoPrice = new BigN(await getAlphaToTaoRate(this.substrateApi, netuid, this.getAlphaPriceScaleDecimals()));
|
|
473
478
|
const limitPrice = alphaToTaoPrice.multipliedBy(10 ** _getAssetDecimals(this.nativeToken)).multipliedBy(1 + slippage);
|
|
474
479
|
const BNlimitPrice = new BigN(limitPrice.integerValue(BigN.ROUND_CEIL).toFixed());
|
|
475
480
|
const extrinsic = chainApi.api.tx.subtensorModule.addStakeLimit(hotkey, netuid, binaryAmount.toFixed(), BNlimitPrice.toFixed(), false);
|
|
@@ -511,7 +516,7 @@ export default class TaoNativeStakingPoolHandler extends BaseParaStakingPoolHand
|
|
|
511
516
|
return Promise.reject(new TransactionError(BasicTxErrorType.INVALID_PARAMS));
|
|
512
517
|
}
|
|
513
518
|
const binaryAmount = new BigN(amount);
|
|
514
|
-
const alphaToTaoPrice = new BigN(await getAlphaToTaoRate(this.substrateApi, netuid));
|
|
519
|
+
const alphaToTaoPrice = new BigN(await getAlphaToTaoRate(this.substrateApi, netuid, this.getAlphaPriceScaleDecimals()));
|
|
515
520
|
const limitPrice = alphaToTaoPrice.multipliedBy(10 ** _getAssetDecimals(this.nativeToken)).multipliedBy(1 - slippage);
|
|
516
521
|
const BNlimitPrice = new BigN(limitPrice.integerValue(BigN.ROUND_CEIL).toFixed());
|
|
517
522
|
const extrinsic = apiPromise.api.tx.subtensorModule.removeStakeLimit(selectedTarget, netuid, binaryAmount.toFixed(), BNlimitPrice.toFixed(), false);
|
|
@@ -527,7 +532,7 @@ export default class TaoNativeStakingPoolHandler extends BaseParaStakingPoolHand
|
|
|
527
532
|
return [new TransactionError(BasicTxErrorType.INVALID_PARAMS)];
|
|
528
533
|
}
|
|
529
534
|
const netuid = (_poolInfo$metadata$su = poolInfo.metadata.subnetData) === null || _poolInfo$metadata$su === void 0 ? void 0 : _poolInfo$metadata$su.netuid;
|
|
530
|
-
const alphaToTaoPrice = new BigN(await getAlphaToTaoRate(this.substrateApi, netuid || 0));
|
|
535
|
+
const alphaToTaoPrice = new BigN(await getAlphaToTaoRate(this.substrateApi, netuid || 0, this.getAlphaPriceScaleDecimals()));
|
|
531
536
|
const minDelegatorStake = await this.getMinBond(netuid);
|
|
532
537
|
const minUnstake = minDelegatorStake.dividedBy(alphaToTaoPrice);
|
|
533
538
|
if (new BigN(amount).lt(minUnstake)) {
|
|
@@ -567,7 +572,7 @@ export default class TaoNativeStakingPoolHandler extends BaseParaStakingPoolHand
|
|
|
567
572
|
if (originValidator === destValidator) {
|
|
568
573
|
return Promise.reject(new TransactionError(BasicTxErrorType.INVALID_PARAMS, t('bg.EARNING.services.service.earning.nativeStaking.tao.fromValidatorSameAsTo')));
|
|
569
574
|
}
|
|
570
|
-
const alphaToTaoPrice = new BigN(await getAlphaToTaoRate(this.substrateApi, netuid));
|
|
575
|
+
const alphaToTaoPrice = new BigN(await getAlphaToTaoRate(this.substrateApi, netuid, this.getAlphaPriceScaleDecimals()));
|
|
571
576
|
const bnMinStake = await this.getMinBond(netuid);
|
|
572
577
|
const minUnstake = bnMinStake.dividedBy(alphaToTaoPrice);
|
|
573
578
|
const formattedMinUnstake = minUnstake.dividedBy(1000000).integerValue(BigN.ROUND_CEIL).dividedBy(1000);
|
|
@@ -10,7 +10,7 @@ import { estimateXcmFee } from '@subwallet/extension-base/services/balance-servi
|
|
|
10
10
|
import { _getAssetDecimals, _getAssetExistentialDeposit, _getAssetSymbol, _getChainName, _getChainNativeTokenSlug } from '@subwallet/extension-base/services/chain-service/utils';
|
|
11
11
|
import { MIN_XCM_LIQUID_STAKING_DOT } from '@subwallet/extension-base/services/earning-service/constants';
|
|
12
12
|
import { BasicTxErrorType, YieldStepType, YieldValidationStatus } from '@subwallet/extension-base/types';
|
|
13
|
-
import { createPromiseHandler, formatNumber } from '@subwallet/extension-base/utils';
|
|
13
|
+
import { _reformatAddressWithChain, createPromiseHandler, formatNumber } from '@subwallet/extension-base/utils';
|
|
14
14
|
import { getId } from '@subwallet/extension-base/utils/getId';
|
|
15
15
|
import BigN from 'bignumber.js';
|
|
16
16
|
import { t } from 'i18next';
|
|
@@ -248,6 +248,7 @@ export default class BaseSpecialStakingPoolHandler extends BasePoolHandler {
|
|
|
248
248
|
}
|
|
249
249
|
const metadata = {
|
|
250
250
|
sendingValue,
|
|
251
|
+
xcmDestinationFee,
|
|
251
252
|
originTokenInfo: altInputTokenInfo,
|
|
252
253
|
destinationTokenInfo: inputTokenInfo
|
|
253
254
|
};
|
|
@@ -459,11 +460,13 @@ export default class BaseSpecialStakingPoolHandler extends BasePoolHandler {
|
|
|
459
460
|
const {
|
|
460
461
|
destinationTokenInfo,
|
|
461
462
|
originTokenInfo,
|
|
462
|
-
sendingValue
|
|
463
|
+
sendingValue,
|
|
464
|
+
xcmDestinationFee
|
|
463
465
|
} = metadata;
|
|
464
466
|
const originChainInfo = this.state.getChainInfo(originTokenInfo.originChain);
|
|
465
467
|
const originTokenSlug = _getChainNativeTokenSlug(originChainInfo);
|
|
466
468
|
const substrateApi = this.state.getSubstrateApi(originChainInfo.slug);
|
|
469
|
+
const fromAddress = _reformatAddressWithChain(address, originChainInfo);
|
|
467
470
|
const id = getId();
|
|
468
471
|
const feeInfo = await this.state.feeService.subscribeChainFee(id, originChainInfo.slug, 'substrate');
|
|
469
472
|
const xcmRequest = {
|
|
@@ -472,7 +475,7 @@ export default class BaseSpecialStakingPoolHandler extends BasePoolHandler {
|
|
|
472
475
|
recipient: address,
|
|
473
476
|
sendingValue,
|
|
474
477
|
substrateApi,
|
|
475
|
-
sender:
|
|
478
|
+
sender: fromAddress,
|
|
476
479
|
originChain: originChainInfo,
|
|
477
480
|
destinationChain: this.chainInfo,
|
|
478
481
|
feeInfo
|
|
@@ -484,7 +487,7 @@ export default class BaseSpecialStakingPoolHandler extends BasePoolHandler {
|
|
|
484
487
|
const xcmData = {
|
|
485
488
|
originNetworkKey: originChainInfo.slug,
|
|
486
489
|
destinationNetworkKey: destinationTokenInfo.originChain,
|
|
487
|
-
from:
|
|
490
|
+
from: fromAddress,
|
|
488
491
|
to: address,
|
|
489
492
|
value: sendingValue,
|
|
490
493
|
tokenSlug: originTokenSlug,
|
|
@@ -497,7 +500,12 @@ export default class BaseSpecialStakingPoolHandler extends BasePoolHandler {
|
|
|
497
500
|
txData: xcmData,
|
|
498
501
|
transferNativeAmount: sendingValue,
|
|
499
502
|
chainType: ChainType.SUBSTRATE,
|
|
500
|
-
xcmStepFee
|
|
503
|
+
xcmStepFee,
|
|
504
|
+
xcmDestinationFee: xcmDestinationFee ? {
|
|
505
|
+
decimals: _getAssetDecimals(destinationTokenInfo),
|
|
506
|
+
symbol: _getAssetSymbol(destinationTokenInfo),
|
|
507
|
+
value: xcmDestinationFee
|
|
508
|
+
} : undefined
|
|
501
509
|
};
|
|
502
510
|
}
|
|
503
511
|
handleYieldJoin(data, path, currentStep) {
|
|
@@ -1,9 +1,45 @@
|
|
|
1
|
-
import { NftFullListRequest } from '@subwallet/extension-base/background/KoniTypes';
|
|
1
|
+
import { NftCollection, NftDetailRequest, NftFullListRequest, NftItem, NftJson } from '@subwallet/extension-base/background/KoniTypes';
|
|
2
2
|
import KoniState from '@subwallet/extension-base/koni/background/handlers/State';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import { ServiceStatus, StoppableServiceInterface } from '@subwallet/extension-base/services/base/types';
|
|
4
|
+
import { PromiseHandler } from '@subwallet/extension-base/utils';
|
|
5
|
+
export interface NftState {
|
|
6
|
+
nftData: NftJson;
|
|
7
|
+
nftCollections: NftCollection[];
|
|
8
|
+
}
|
|
9
|
+
export declare class NftService implements StoppableServiceInterface {
|
|
10
|
+
private readonly state;
|
|
11
|
+
private readonly multiChainFetcher;
|
|
12
|
+
private _intervalFetchNft;
|
|
13
|
+
private readonly NFT_INTERVAL_TIME;
|
|
14
|
+
private readonly nftStateSubject;
|
|
15
|
+
readonly nftState$: import("rxjs").Observable<NftState>;
|
|
16
|
+
private isReloading;
|
|
17
|
+
startPromiseHandler: PromiseHandler<void>;
|
|
18
|
+
stopPromiseHandler: PromiseHandler<void>;
|
|
19
|
+
status: ServiceStatus;
|
|
20
|
+
get isStarted(): boolean;
|
|
6
21
|
constructor(state: KoniState);
|
|
7
|
-
|
|
8
|
-
|
|
22
|
+
init(): Promise<void>;
|
|
23
|
+
private loadCachedData;
|
|
24
|
+
start(): Promise<void>;
|
|
25
|
+
stop(): Promise<void>;
|
|
26
|
+
waitForStarted(): Promise<void>;
|
|
27
|
+
waitForStopped(): Promise<void>;
|
|
28
|
+
private checkIfNftUpdateNeeded;
|
|
29
|
+
private extractUpdatedChains;
|
|
30
|
+
private hasNftSupportedChainUpdate;
|
|
31
|
+
private isChainNftSupported;
|
|
32
|
+
private handleImmediateRefresh;
|
|
33
|
+
private scheduleLazyRefresh;
|
|
34
|
+
private handleEvents;
|
|
35
|
+
fetchFullListNftOfACollection(request: NftFullListRequest): Promise<boolean>;
|
|
36
|
+
fetchNftDetail(request: NftDetailRequest): Promise<NftItem | null>;
|
|
37
|
+
private startScanNft;
|
|
38
|
+
private stopScanNft;
|
|
39
|
+
private persistNftData;
|
|
40
|
+
private refreshNftData;
|
|
41
|
+
/** Subscribe NFT state */
|
|
42
|
+
subscribeNftItem(): import("rxjs").Observable<NftState>;
|
|
43
|
+
subscribeNftCollection(): import("dexie").Observable<NftCollection[]>;
|
|
44
|
+
forceReload(): Promise<void>;
|
|
9
45
|
}
|