@subwallet/extension-base 1.3.29-1 → 1.3.31-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 -4
- package/background/errors/SwapError.js +1 -1
- package/cjs/background/errors/SwapError.js +1 -1
- package/cjs/constants/blocked-actions.js +2 -2
- package/cjs/constants/paraspell-chain-map.js +13 -0
- package/cjs/constants/remind-notification-time.js +3 -3
- package/cjs/core/logic-validation/swap.js +63 -4
- package/cjs/core/logic-validation/transfer.js +13 -1
- package/cjs/core/substrate/xcm-parser.js +5 -1
- package/cjs/core/utils.js +36 -15
- package/cjs/koni/background/handlers/Extension.js +141 -172
- package/cjs/koni/background/handlers/State.js +8 -1
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/helpers/process.js +27 -0
- package/cjs/services/balance-service/index.js +9 -0
- package/cjs/services/balance-service/transfer/xcm/acrossBridge/index.js +229 -0
- package/cjs/services/balance-service/transfer/xcm/availBridge.js +6 -6
- package/cjs/services/balance-service/transfer/xcm/index.js +96 -7
- package/cjs/services/balance-service/transfer/xcm/utils.js +213 -0
- package/cjs/services/chain-service/constants.js +2 -4
- package/cjs/services/chain-service/index.js +71 -17
- package/cjs/services/chain-service/utils/patch.js +1 -1
- package/cjs/services/earning-service/handlers/base.js +6 -3
- package/cjs/services/earning-service/handlers/native-staking/base.js +4 -1
- package/cjs/services/earning-service/handlers/native-staking/dtao.js +68 -50
- package/cjs/services/earning-service/handlers/native-staking/tao.js +12 -2
- package/cjs/services/earning-service/handlers/special.js +18 -9
- package/cjs/services/earning-service/service.js +2 -1
- package/cjs/services/fee-service/utils/index.js +16 -4
- package/cjs/services/inapp-notification-service/index.js +19 -13
- package/cjs/services/keyring-service/context/handlers/Ledger.js +1 -1
- package/cjs/services/keyring-service/context/state.js +3 -0
- package/cjs/services/migration-service/scripts/DisableZeroBalanceTokens.js +60 -0
- package/cjs/services/migration-service/scripts/EnableChain.js +1 -1
- package/cjs/services/migration-service/scripts/index.js +3 -2
- package/cjs/services/swap-service/handler/asset-hub/handler.js +61 -314
- package/cjs/services/swap-service/handler/base-handler.js +406 -231
- package/cjs/services/swap-service/handler/chainflip-handler.js +18 -40
- package/cjs/services/swap-service/handler/hydradx-handler.js +77 -269
- package/cjs/services/swap-service/handler/simpleswap-handler.js +27 -48
- package/cjs/services/swap-service/handler/uniswap-handler.js +33 -54
- package/cjs/services/swap-service/index.js +154 -143
- package/cjs/services/swap-service/utils.js +107 -17
- package/cjs/services/transaction-service/index.js +1 -1
- package/cjs/services/transaction-service/utils.js +38 -14
- package/cjs/types/swap/index.js +13 -1
- package/cjs/utils/fee/transfer.js +52 -28
- package/cjs/utils/staticData/index.js +7 -2
- package/cjs/utils/swap.js +5 -1
- package/constants/blocked-actions.d.ts +1 -1
- package/constants/blocked-actions.js +1 -1
- package/constants/paraspell-chain-map.d.ts +1 -0
- package/constants/paraspell-chain-map.js +7 -0
- package/constants/remind-notification-time.d.ts +1 -1
- package/constants/remind-notification-time.js +1 -1
- package/core/logic-validation/swap.d.ts +15 -0
- package/core/logic-validation/swap.js +60 -4
- package/core/logic-validation/transfer.d.ts +1 -0
- package/core/logic-validation/transfer.js +12 -1
- package/core/substrate/xcm-parser.d.ts +1 -0
- package/core/substrate/xcm-parser.js +4 -1
- package/core/utils.d.ts +2 -2
- package/core/utils.js +36 -15
- package/koni/background/handlers/Extension.d.ts +1 -1
- package/koni/background/handlers/Extension.js +66 -98
- package/koni/background/handlers/State.d.ts +1 -0
- package/koni/background/handlers/State.js +7 -1
- package/package.json +23 -13
- package/packageInfo.js +1 -1
- package/services/balance-service/helpers/process.d.ts +2 -1
- package/services/balance-service/helpers/process.js +26 -0
- package/services/balance-service/index.js +11 -2
- package/services/balance-service/transfer/xcm/acrossBridge/index.d.ts +15 -0
- package/services/balance-service/transfer/xcm/acrossBridge/index.js +216 -0
- package/services/balance-service/transfer/xcm/availBridge.js +6 -6
- package/services/balance-service/transfer/xcm/index.d.ts +5 -1
- package/services/balance-service/transfer/xcm/index.js +85 -1
- package/services/balance-service/transfer/xcm/utils.d.ts +11 -0
- package/services/balance-service/transfer/xcm/utils.js +208 -0
- package/services/base/types.d.ts +0 -4
- package/services/chain-service/constants.d.ts +0 -1
- package/services/chain-service/constants.js +1 -2
- package/services/chain-service/index.d.ts +9 -2
- package/services/chain-service/index.js +72 -18
- package/services/chain-service/utils/patch.js +1 -1
- package/services/earning-service/handlers/base.d.ts +4 -3
- package/services/earning-service/handlers/base.js +6 -4
- package/services/earning-service/handlers/native-staking/base.js +4 -1
- package/services/earning-service/handlers/native-staking/dtao.d.ts +9 -6
- package/services/earning-service/handlers/native-staking/dtao.js +69 -48
- package/services/earning-service/handlers/native-staking/tao.js +12 -2
- package/services/earning-service/handlers/special.js +19 -10
- package/services/earning-service/service.d.ts +2 -1
- package/services/earning-service/service.js +2 -1
- package/services/fee-service/utils/index.d.ts +1 -0
- package/services/fee-service/utils/index.js +14 -4
- package/services/inapp-notification-service/index.js +13 -7
- package/services/keyring-service/context/handlers/Ledger.js +1 -1
- package/services/keyring-service/context/state.d.ts +1 -0
- package/services/keyring-service/context/state.js +3 -0
- package/services/migration-service/scripts/DisableZeroBalanceTokens.d.ts +4 -0
- package/services/migration-service/scripts/DisableZeroBalanceTokens.js +51 -0
- package/services/migration-service/scripts/EnableChain.js +1 -1
- package/services/migration-service/scripts/index.js +3 -2
- package/services/swap-service/handler/asset-hub/handler.d.ts +2 -9
- package/services/swap-service/handler/asset-hub/handler.js +64 -317
- package/services/swap-service/handler/base-handler.d.ts +6 -9
- package/services/swap-service/handler/base-handler.js +405 -230
- package/services/swap-service/handler/chainflip-handler.d.ts +2 -4
- package/services/swap-service/handler/chainflip-handler.js +15 -37
- package/services/swap-service/handler/hydradx-handler.d.ts +3 -10
- package/services/swap-service/handler/hydradx-handler.js +78 -270
- package/services/swap-service/handler/simpleswap-handler.d.ts +2 -4
- package/services/swap-service/handler/simpleswap-handler.js +24 -45
- package/services/swap-service/handler/uniswap-handler.d.ts +4 -6
- package/services/swap-service/handler/uniswap-handler.js +25 -46
- package/services/swap-service/index.d.ts +8 -14
- package/services/swap-service/index.js +141 -129
- package/services/swap-service/utils.d.ts +11 -3
- package/services/swap-service/utils.js +96 -15
- package/services/transaction-service/index.js +2 -2
- package/services/transaction-service/types.d.ts +3 -2
- package/services/transaction-service/utils.d.ts +1 -0
- package/services/transaction-service/utils.js +38 -15
- package/types/balance/transfer.d.ts +1 -0
- package/types/service-base.d.ts +2 -3
- package/types/swap/index.d.ts +25 -9
- package/types/swap/index.js +10 -0
- package/types/transaction/process.d.ts +19 -0
- package/types/transaction/request.d.ts +7 -0
- package/types/yield/actions/join/submit.d.ts +4 -1
- package/types/yield/actions/others.d.ts +2 -0
- package/utils/fee/transfer.d.ts +1 -0
- package/utils/fee/transfer.js +54 -30
- package/utils/staticData/index.d.ts +4 -1
- package/utils/staticData/index.js +5 -1
- package/utils/staticData/paraSpellChainMap.json +1 -0
- package/utils/swap.d.ts +3 -0
- package/utils/swap.js +3 -0
- package/cjs/services/swap-service/interface.js +0 -14
- package/services/swap-service/interface.d.ts +0 -9
- package/services/swap-service/interface.js +0 -8
|
@@ -20,6 +20,7 @@ export interface SWTransaction extends ValidateTransactionResponse, Partial<Pick
|
|
|
20
20
|
createdAt: number;
|
|
21
21
|
updatedAt: number;
|
|
22
22
|
estimateFee?: FeeData;
|
|
23
|
+
xcmFeeDryRun?: string;
|
|
23
24
|
transaction: SubmittableExtrinsic | TransactionConfig | TonTransactionConfig;
|
|
24
25
|
additionalValidator?: (inputTransaction: SWTransactionResponse) => Promise<void>;
|
|
25
26
|
eventsHandler?: (eventEmitter: TransactionEmitter) => void;
|
|
@@ -35,7 +36,7 @@ export interface SWTransactionResult extends Omit<SWTransaction, 'transaction' |
|
|
|
35
36
|
process?: ProcessTransactionData;
|
|
36
37
|
}
|
|
37
38
|
declare type SwInputBase = Pick<SWTransaction, 'address' | 'url' | 'data' | 'extrinsicType' | 'chain' | 'chainType' | 'ignoreWarnings' | 'transferNativeAmount'> & Partial<Pick<SWTransaction, 'additionalValidator' | 'eventsHandler'>>;
|
|
38
|
-
export interface SWTransactionInput extends SwInputBase, Partial<Pick<SWTransaction, 'estimateFee' | 'signAfterCreate' | 'isPassConfirmation' | 'step' | 'errorOnTimeOut'>>, TransactionFee {
|
|
39
|
+
export interface SWTransactionInput extends SwInputBase, Partial<Pick<SWTransaction, 'estimateFee' | 'signAfterCreate' | 'isPassConfirmation' | 'step' | 'errorOnTimeOut' | 'xcmFeeDryRun'>>, TransactionFee {
|
|
39
40
|
id?: string;
|
|
40
41
|
transaction?: SWTransaction['transaction'] | null;
|
|
41
42
|
warnings?: SWTransaction['warnings'];
|
|
@@ -49,7 +50,7 @@ export interface SWTransactionInput extends SwInputBase, Partial<Pick<SWTransact
|
|
|
49
50
|
export interface SWPermitTransactionInput extends Omit<SWTransactionInput, 'transaction'> {
|
|
50
51
|
transaction?: SWPermitTransaction['transaction'] | null;
|
|
51
52
|
}
|
|
52
|
-
export declare type SWTransactionResponse = SwInputBase & Pick<SWTransaction, 'warnings' | 'errors'> & Partial<Pick<SWTransaction, 'id' | 'extrinsicHash' | 'status' | 'estimateFee'>> & TransactionFee & {
|
|
53
|
+
export declare type SWTransactionResponse = SwInputBase & Pick<SWTransaction, 'warnings' | 'errors'> & Partial<Pick<SWTransaction, 'id' | 'extrinsicHash' | 'status' | 'estimateFee' | 'xcmFeeDryRun'>> & TransactionFee & {
|
|
53
54
|
processId?: string;
|
|
54
55
|
};
|
|
55
56
|
export declare type ValidateTransactionResponseInput = SWTransactionInput;
|
|
@@ -2,6 +2,7 @@ import { _ChainInfo } from '@subwallet/chain-list/types';
|
|
|
2
2
|
import { ExtrinsicDataTypeMap, ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
|
|
3
3
|
import { ChainflipSwapTxData, SimpleSwapTxData } from '@subwallet/extension-base/types/swap';
|
|
4
4
|
export declare function parseTransactionData<T extends ExtrinsicType>(data: unknown): ExtrinsicDataTypeMap[T];
|
|
5
|
+
export declare function getTransactionId(value: string): Promise<string>;
|
|
5
6
|
export declare function getExplorerLink(chainInfo: _ChainInfo, value: string, type: 'account' | 'tx'): string | undefined;
|
|
6
7
|
export declare function getChainflipExplorerLink(data: ChainflipSwapTxData, chainInfo: _ChainInfo): string;
|
|
7
8
|
export declare function getSimpleSwapExplorerLink(data: SimpleSwapTxData): string;
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
import { _getBlockExplorerFromChain, _isChainTestNet, _isPureCardanoChain, _isPureEvmChain } from '@subwallet/extension-base/services/chain-service/utils';
|
|
5
5
|
import { CHAIN_FLIP_MAINNET_EXPLORER, CHAIN_FLIP_TESTNET_EXPLORER, SIMPLE_SWAP_EXPLORER } from '@subwallet/extension-base/services/swap-service/utils';
|
|
6
|
-
import { hexAddPrefix, isHex } from '@polkadot/util';
|
|
6
|
+
import { hexAddPrefix, isHex, u8aToHex } from '@polkadot/util';
|
|
7
|
+
import { decodeAddress } from '@polkadot/util-crypto';
|
|
7
8
|
|
|
8
9
|
// @ts-ignore
|
|
9
10
|
export function parseTransactionData(data) {
|
|
@@ -24,19 +25,7 @@ function getBlockExplorerAccountRoute(explorerLink) {
|
|
|
24
25
|
if (explorerLink.includes('3dpscan.io')) {
|
|
25
26
|
return 'account';
|
|
26
27
|
}
|
|
27
|
-
if (explorerLink.includes('
|
|
28
|
-
return 'account';
|
|
29
|
-
}
|
|
30
|
-
if (explorerLink.includes('invarch.statescan.io')) {
|
|
31
|
-
return '#/accounts';
|
|
32
|
-
}
|
|
33
|
-
if (explorerLink.includes('tangle.statescan.io')) {
|
|
34
|
-
return '#/accounts';
|
|
35
|
-
}
|
|
36
|
-
if (explorerLink.includes('laos.statescan.io')) {
|
|
37
|
-
return '#/accounts';
|
|
38
|
-
}
|
|
39
|
-
if (explorerLink.includes('polimec.statescan.io')) {
|
|
28
|
+
if (explorerLink.includes('statescan.io')) {
|
|
40
29
|
return '#/accounts';
|
|
41
30
|
}
|
|
42
31
|
if (explorerLink.includes('explorer.zkverify.io')) {
|
|
@@ -60,15 +49,38 @@ function getBlockExplorerTxRoute(chainInfo) {
|
|
|
60
49
|
if (['aventus', 'deeper_network'].includes(chainInfo.slug)) {
|
|
61
50
|
return 'transaction';
|
|
62
51
|
}
|
|
63
|
-
|
|
52
|
+
const explorerLink = _getBlockExplorerFromChain(chainInfo);
|
|
53
|
+
if (explorerLink && explorerLink.includes('statescan.io')) {
|
|
64
54
|
return '#/extrinsics';
|
|
65
55
|
}
|
|
66
56
|
return 'extrinsic';
|
|
67
57
|
}
|
|
58
|
+
export function getTransactionId(value) {
|
|
59
|
+
const query = `
|
|
60
|
+
query ExtrinsicQuery {
|
|
61
|
+
extrinsics(where: {hash_eq: ${value}}, limit: 1) {
|
|
62
|
+
id
|
|
63
|
+
}
|
|
64
|
+
}`;
|
|
65
|
+
const apiUrl = 'https://archive-explorer.truth-network.io/graphql';
|
|
66
|
+
return fetch(apiUrl, {
|
|
67
|
+
method: 'POST',
|
|
68
|
+
headers: {
|
|
69
|
+
'Content-Type': 'application/json'
|
|
70
|
+
},
|
|
71
|
+
body: JSON.stringify({
|
|
72
|
+
query
|
|
73
|
+
})
|
|
74
|
+
}).then(response => response.json()).then(result => result.data.extrinsics[0].id);
|
|
75
|
+
}
|
|
68
76
|
export function getExplorerLink(chainInfo, value, type) {
|
|
69
77
|
const explorerLink = _getBlockExplorerFromChain(chainInfo);
|
|
70
78
|
if (explorerLink && type === 'account') {
|
|
71
79
|
const route = getBlockExplorerAccountRoute(explorerLink);
|
|
80
|
+
if (chainInfo.slug === 'truth_network') {
|
|
81
|
+
const address = u8aToHex(decodeAddress(value));
|
|
82
|
+
return `${explorerLink}${explorerLink.endsWith('/') ? '' : '/'}${route}/${address}`;
|
|
83
|
+
}
|
|
72
84
|
return `${explorerLink}${explorerLink.endsWith('/') ? '' : '/'}${route}/${value}`;
|
|
73
85
|
}
|
|
74
86
|
if (explorerLink && isHex(hexAddPrefix(value))) {
|
|
@@ -76,6 +88,17 @@ export function getExplorerLink(chainInfo, value, type) {
|
|
|
76
88
|
if (chainInfo.slug === 'tangle') {
|
|
77
89
|
return `${explorerLink}${explorerLink.endsWith('/') ? '' : '/'}extrinsic/${value}${route}/${value}`;
|
|
78
90
|
}
|
|
91
|
+
if (chainInfo.slug === 'truth_network') {
|
|
92
|
+
// getTransactionId(value)
|
|
93
|
+
// .then((transactionId) => {
|
|
94
|
+
// return (`${explorerLink}${explorerLink.endsWith('/') ? '' : '/'}${route}/${transactionId}`);
|
|
95
|
+
// })
|
|
96
|
+
// .catch((err) => {
|
|
97
|
+
// console.error(err);
|
|
98
|
+
// });
|
|
99
|
+
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
79
102
|
return `${explorerLink}${explorerLink.endsWith('/') ? '' : '/'}${route}/${value}`;
|
|
80
103
|
}
|
|
81
104
|
return undefined;
|
package/types/service-base.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { DynamicSwapAction } from '@subwallet/extension-base/
|
|
2
|
-
import { OptimalSwapPathParams, SwapFeeType, SwapStepType } from '@subwallet/extension-base/types/swap';
|
|
1
|
+
import { DynamicSwapAction, OptimalSwapPathParamsV2, SwapFeeType, SwapStepType } from '@subwallet/extension-base/types/swap';
|
|
3
2
|
import { OptimalYieldPath, OptimalYieldPathParams, YieldStepType } from '@subwallet/extension-base/types/yield';
|
|
4
|
-
export declare type OptimalProcessParams = OptimalYieldPathParams |
|
|
3
|
+
export declare type OptimalProcessParams = OptimalYieldPathParams | OptimalSwapPathParamsV2;
|
|
5
4
|
export declare type OptimalProcessResult = OptimalYieldPath | CommonOptimalSwapPath;
|
|
6
5
|
export declare enum CommonStepType {
|
|
7
6
|
DEFAULT = "DEFAULT",
|
package/types/swap/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { _ChainAsset, _ChainInfo } from '@subwallet/chain-list/types';
|
|
2
2
|
import { SwapError } from '@subwallet/extension-base/background/errors/SwapError';
|
|
3
3
|
import { AmountData, ChainType, ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
|
|
4
|
-
import { DynamicSwapAction } from '@subwallet/extension-base/services/swap-service/interface';
|
|
5
4
|
import { BaseStepDetail, BaseStepType, CommonOptimalSwapPath, CommonStepFeeInfo } from '@subwallet/extension-base/types/service-base';
|
|
6
5
|
import BigN from 'bignumber.js';
|
|
7
6
|
import { BaseProcessRequestSign, TransactionData } from '../transaction';
|
|
@@ -96,8 +95,7 @@ export interface SimpleSwapTxData extends SwapBaseTxData {
|
|
|
96
95
|
export interface HydradxSwapTxData extends SwapBaseTxData {
|
|
97
96
|
txHex: string;
|
|
98
97
|
}
|
|
99
|
-
export declare type
|
|
100
|
-
export declare type GenSwapStepFuncV2 = (params: OptimalSwapPathParamsV2) => Promise<[BaseStepDetail, CommonStepFeeInfo] | undefined>;
|
|
98
|
+
export declare type GenSwapStepFuncV2 = (params: OptimalSwapPathParamsV2, stepIndex: number) => Promise<[BaseStepDetail, CommonStepFeeInfo] | undefined>;
|
|
101
99
|
export interface ChainflipPreValidationMetadata {
|
|
102
100
|
minSwap: AmountData;
|
|
103
101
|
maxSwap?: AmountData;
|
|
@@ -131,6 +129,15 @@ export interface SwapRequest {
|
|
|
131
129
|
feeToken?: string;
|
|
132
130
|
currentQuote?: SwapProvider;
|
|
133
131
|
}
|
|
132
|
+
export interface SwapRequestV2 {
|
|
133
|
+
address: string;
|
|
134
|
+
pair: SwapPair;
|
|
135
|
+
fromAmount: string;
|
|
136
|
+
slippage: number;
|
|
137
|
+
recipient?: string;
|
|
138
|
+
feeToken?: string;
|
|
139
|
+
preferredProvider?: SwapProviderId;
|
|
140
|
+
}
|
|
134
141
|
export interface SwapRequestResult {
|
|
135
142
|
process: CommonOptimalSwapPath;
|
|
136
143
|
quote: SwapQuoteResponse;
|
|
@@ -159,9 +166,17 @@ export interface SwapSubmitStepData {
|
|
|
159
166
|
chainType: ChainType;
|
|
160
167
|
isPermit?: boolean;
|
|
161
168
|
}
|
|
162
|
-
export
|
|
163
|
-
|
|
164
|
-
|
|
169
|
+
export declare enum DynamicSwapType {
|
|
170
|
+
SWAP = "SWAP",
|
|
171
|
+
BRIDGE = "BRIDGE"
|
|
172
|
+
}
|
|
173
|
+
export interface DynamicSwapAction {
|
|
174
|
+
action: DynamicSwapType;
|
|
175
|
+
pair: ActionPair;
|
|
176
|
+
}
|
|
177
|
+
export declare const enum BridgeStepPosition {
|
|
178
|
+
FIRST = 0,
|
|
179
|
+
AFTER_SWAP = 1
|
|
165
180
|
}
|
|
166
181
|
export interface OptimalSwapPathParamsV2 {
|
|
167
182
|
request: SwapRequest;
|
|
@@ -194,11 +209,12 @@ export declare const CHAINFLIP_SLIPPAGE = 0.02;
|
|
|
194
209
|
export declare const SIMPLE_SWAP_SLIPPAGE = 0.05;
|
|
195
210
|
export interface BaseSwapStepMetadata {
|
|
196
211
|
sendingValue: string;
|
|
212
|
+
expectedReceive: string;
|
|
197
213
|
originTokenInfo: _ChainAsset;
|
|
198
214
|
destinationTokenInfo: _ChainAsset;
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
215
|
+
sender: string;
|
|
216
|
+
receiver: string;
|
|
217
|
+
version: number;
|
|
202
218
|
}
|
|
203
219
|
export interface HydrationSwapStepMetadata extends BaseSwapStepMetadata {
|
|
204
220
|
txHex: `0x${string}`;
|
package/types/swap/index.js
CHANGED
|
@@ -49,5 +49,15 @@ export let SwapFeeType;
|
|
|
49
49
|
SwapFeeType["NETWORK_FEE"] = "NETWORK_FEE";
|
|
50
50
|
SwapFeeType["WALLET_FEE"] = "WALLET_FEE";
|
|
51
51
|
})(SwapFeeType || (SwapFeeType = {}));
|
|
52
|
+
export let DynamicSwapType;
|
|
53
|
+
(function (DynamicSwapType) {
|
|
54
|
+
DynamicSwapType["SWAP"] = "SWAP";
|
|
55
|
+
DynamicSwapType["BRIDGE"] = "BRIDGE";
|
|
56
|
+
})(DynamicSwapType || (DynamicSwapType = {}));
|
|
57
|
+
export let BridgeStepPosition;
|
|
58
|
+
(function (BridgeStepPosition) {
|
|
59
|
+
BridgeStepPosition[BridgeStepPosition["FIRST"] = 0] = "FIRST";
|
|
60
|
+
BridgeStepPosition[BridgeStepPosition["AFTER_SWAP"] = 1] = "AFTER_SWAP";
|
|
61
|
+
})(BridgeStepPosition || (BridgeStepPosition = {}));
|
|
52
62
|
export const CHAINFLIP_SLIPPAGE = 0.02; // Example: 0.01 for 1%
|
|
53
63
|
export const SIMPLE_SWAP_SLIPPAGE = 0.05;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { _ChainAsset } from '@subwallet/chain-list/types';
|
|
1
2
|
import { TransactionEventResponse } from '@subwallet/extension-base/services/transaction-service/types';
|
|
2
3
|
import { CommonStepDetail, CommonStepFeeInfo } from '../service-base';
|
|
3
4
|
import { SwapPair, SwapProvider, SwapRate, SwapRoute, SwapSubmitParams } from '../swap';
|
|
@@ -51,6 +52,24 @@ export interface BriefProcessStep {
|
|
|
51
52
|
processId: string;
|
|
52
53
|
stepId: number;
|
|
53
54
|
}
|
|
55
|
+
export interface BriefXcmStep {
|
|
56
|
+
sendingValue: string;
|
|
57
|
+
originTokenInfo: _ChainAsset;
|
|
58
|
+
destinationTokenInfo: _ChainAsset;
|
|
59
|
+
}
|
|
60
|
+
export interface BriefXcmStepV2 {
|
|
61
|
+
sendingValue: string;
|
|
62
|
+
originTokenInfo: _ChainAsset;
|
|
63
|
+
destinationValue: string;
|
|
64
|
+
destinationTokenInfo: _ChainAsset;
|
|
65
|
+
}
|
|
66
|
+
export interface BriefSwapStepV2 {
|
|
67
|
+
sendingValue: string;
|
|
68
|
+
originTokenInfo: _ChainAsset;
|
|
69
|
+
destinationValue: string;
|
|
70
|
+
destinationTokenInfo: _ChainAsset;
|
|
71
|
+
}
|
|
72
|
+
export declare type BriefStepV2 = BriefXcmStepV2 | BriefSwapStepV2;
|
|
54
73
|
export interface BriefSwapStep {
|
|
55
74
|
pair: SwapPair;
|
|
56
75
|
fromAmount: string;
|
|
@@ -22,6 +22,12 @@ export interface RequestCheckCrossChainTransfer extends RequestBaseTransfer, Tra
|
|
|
22
22
|
originNetworkKey: string;
|
|
23
23
|
destinationNetworkKey: string;
|
|
24
24
|
showExtraWarning?: boolean;
|
|
25
|
+
metadata?: AcrossMetadata;
|
|
26
|
+
}
|
|
27
|
+
interface AcrossMetadata {
|
|
28
|
+
amountOut: string;
|
|
29
|
+
destChainSlug: string;
|
|
30
|
+
rate: string;
|
|
25
31
|
}
|
|
26
32
|
export declare type RequestCrossChainTransfer = InternalRequestSign<RequestCheckCrossChainTransfer>;
|
|
27
33
|
export interface RequestGetTokensCanPayFee {
|
|
@@ -34,3 +40,4 @@ export interface RequestGetAmountForPair {
|
|
|
34
40
|
nativeTokenSlug: string;
|
|
35
41
|
toTokenSlug: string;
|
|
36
42
|
}
|
|
43
|
+
export {};
|
|
@@ -20,7 +20,10 @@ export interface SubmitJoinNativeStaking extends AbstractSubmitYieldJoinData {
|
|
|
20
20
|
mindBond: string;
|
|
21
21
|
};
|
|
22
22
|
selectedValidators: ValidatorInfo[];
|
|
23
|
-
|
|
23
|
+
subnetData: {
|
|
24
|
+
netuid: number;
|
|
25
|
+
slippage: number;
|
|
26
|
+
};
|
|
24
27
|
}
|
|
25
28
|
export interface SubmitJoinNominationPool extends AbstractSubmitYieldJoinData {
|
|
26
29
|
selectedPool: NominationPoolInfo;
|
|
@@ -24,6 +24,8 @@ export interface YieldLeaveParams extends BaseRequestSign {
|
|
|
24
24
|
fastLeave: boolean;
|
|
25
25
|
/** Pool's info - use for create history */
|
|
26
26
|
poolInfo: YieldPoolInfo;
|
|
27
|
+
/** Slippage (subnet staking) */
|
|
28
|
+
slippage?: number;
|
|
27
29
|
}
|
|
28
30
|
export declare type RequestYieldLeave = InternalRequestSign<YieldLeaveParams>;
|
|
29
31
|
/**
|
package/utils/fee/transfer.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { FeeChainType, FeeInfo, TransactionFee } from '@subwallet/extension-base
|
|
|
5
5
|
import { ResponseSubscribeTransfer } from '@subwallet/extension-base/types/balance/transfer';
|
|
6
6
|
export interface CalculateMaxTransferable extends TransactionFee {
|
|
7
7
|
address: string;
|
|
8
|
+
value: string;
|
|
8
9
|
srcToken: _ChainAsset;
|
|
9
10
|
destToken?: _ChainAsset;
|
|
10
11
|
srcChain: _ChainInfo;
|
package/utils/fee/transfer.js
CHANGED
|
@@ -8,11 +8,12 @@ import { createCardanoTransaction } from '@subwallet/extension-base/services/bal
|
|
|
8
8
|
import { getERC20TransactionObject, getEVMTransactionObject } from '@subwallet/extension-base/services/balance-service/transfer/smart-contract';
|
|
9
9
|
import { createSubstrateExtrinsic } from '@subwallet/extension-base/services/balance-service/transfer/token';
|
|
10
10
|
import { createTonTransaction } from '@subwallet/extension-base/services/balance-service/transfer/ton-transfer';
|
|
11
|
-
import { createAvailBridgeExtrinsicFromAvail, createAvailBridgeTxFromEth, createPolygonBridgeExtrinsic, createSnowBridgeExtrinsic,
|
|
11
|
+
import { createAcrossBridgeExtrinsic, createAvailBridgeExtrinsicFromAvail, createAvailBridgeTxFromEth, createPolygonBridgeExtrinsic, createSnowBridgeExtrinsic, createXcmExtrinsicV2, dryRunXcmExtrinsicV2 } from '@subwallet/extension-base/services/balance-service/transfer/xcm';
|
|
12
|
+
import { _isAcrossChainBridge, _isAcrossTestnetBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/acrossBridge';
|
|
12
13
|
import { isAvailChainBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/availBridge';
|
|
13
14
|
import { _isPolygonChainBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/polygonBridge';
|
|
14
15
|
import { _isPosChainBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/posBridge';
|
|
15
|
-
import { _getContractAddressOfToken, _isChainCardanoCompatible, _isChainEvmCompatible, _isChainTonCompatible, _isLocalToken, _isNativeToken, _isPureEvmChain, _isTokenEvmSmartContract, _isTokenTransferredByCardano, _isTokenTransferredByEvm, _isTokenTransferredByTon } from '@subwallet/extension-base/services/chain-service/utils';
|
|
16
|
+
import { _getAssetDecimals, _getContractAddressOfToken, _isChainCardanoCompatible, _isChainEvmCompatible, _isChainTonCompatible, _isLocalToken, _isNativeToken, _isPureEvmChain, _isTokenEvmSmartContract, _isTokenTransferredByCardano, _isTokenTransferredByEvm, _isTokenTransferredByTon } from '@subwallet/extension-base/services/chain-service/utils';
|
|
16
17
|
import { calculateToAmountByReservePool, FEE_COVERAGE_PERCENTAGE_SPECIAL_CASE } from '@subwallet/extension-base/services/fee-service/utils';
|
|
17
18
|
import { getHydrationRate } from '@subwallet/extension-base/services/fee-service/utils/tokenPayFee';
|
|
18
19
|
import { isCardanoTransaction, isTonTransaction } from '@subwallet/extension-base/services/transaction-service/helpers';
|
|
@@ -29,7 +30,8 @@ export const detectTransferTxType = (srcToken, srcChain, destChain) => {
|
|
|
29
30
|
const isSnowBridgeEvmTransfer = _isPureEvmChain(srcChain) && _isSnowBridgeXcm(srcChain, destChain) && !isAvailBridgeFromEvm;
|
|
30
31
|
const isPolygonBridgeTransfer = _isPolygonChainBridge(srcChain.slug, destChain.slug);
|
|
31
32
|
const isPosBridgeTransfer = _isPosChainBridge(srcChain.slug, destChain.slug);
|
|
32
|
-
|
|
33
|
+
const isAcrossBridgeTransfer = _isAcrossChainBridge(srcChain.slug, destChain.slug);
|
|
34
|
+
return isAvailBridgeFromEvm || isSnowBridgeEvmTransfer || isPolygonBridgeTransfer || isPosBridgeTransfer || isAcrossBridgeTransfer ? 'evm' : 'substrate';
|
|
33
35
|
} else {
|
|
34
36
|
if (_isChainEvmCompatible(srcChain) && _isTokenTransferredByEvm(srcToken)) {
|
|
35
37
|
return 'evm';
|
|
@@ -77,7 +79,8 @@ export const calculateTransferMaxTransferable = async (id, request, freeBalance,
|
|
|
77
79
|
srcChain,
|
|
78
80
|
srcToken,
|
|
79
81
|
substrateApi,
|
|
80
|
-
tonApi
|
|
82
|
+
tonApi,
|
|
83
|
+
value
|
|
81
84
|
} = request;
|
|
82
85
|
const feeChainType = fee.type;
|
|
83
86
|
let estimatedFee;
|
|
@@ -105,7 +108,7 @@ export const calculateTransferMaxTransferable = async (id, request, freeBalance,
|
|
|
105
108
|
from: address,
|
|
106
109
|
to: recipient,
|
|
107
110
|
transferAll: false,
|
|
108
|
-
value
|
|
111
|
+
value,
|
|
109
112
|
fallbackFee: true
|
|
110
113
|
});
|
|
111
114
|
} else {
|
|
@@ -118,7 +121,7 @@ export const calculateTransferMaxTransferable = async (id, request, freeBalance,
|
|
|
118
121
|
from: address,
|
|
119
122
|
to: recipient,
|
|
120
123
|
transferAll: false,
|
|
121
|
-
value
|
|
124
|
+
value,
|
|
122
125
|
fallbackFee: true
|
|
123
126
|
});
|
|
124
127
|
}
|
|
@@ -128,19 +131,18 @@ export const calculateTransferMaxTransferable = async (id, request, freeBalance,
|
|
|
128
131
|
from: address,
|
|
129
132
|
to: address,
|
|
130
133
|
networkKey: srcChain.slug,
|
|
131
|
-
value
|
|
134
|
+
value,
|
|
132
135
|
transferAll: false,
|
|
133
136
|
// currently not used
|
|
134
137
|
tonApi
|
|
135
138
|
});
|
|
136
139
|
} else if (isCardanoAddress(address) && _isTokenTransferredByCardano(srcToken)) {
|
|
137
|
-
const isTransferNativeToken = _isNativeToken(srcToken);
|
|
138
140
|
[transaction] = await createCardanoTransaction({
|
|
139
141
|
tokenInfo: srcToken,
|
|
140
142
|
from: address,
|
|
141
143
|
to: address,
|
|
142
144
|
networkKey: srcChain.slug,
|
|
143
|
-
value
|
|
145
|
+
value,
|
|
144
146
|
cardanoTtlOffset: DEFAULT_CARDANO_TTL_OFFSET,
|
|
145
147
|
transferAll: false,
|
|
146
148
|
cardanoApi,
|
|
@@ -149,7 +151,7 @@ export const calculateTransferMaxTransferable = async (id, request, freeBalance,
|
|
|
149
151
|
} else {
|
|
150
152
|
[transaction] = await createSubstrateExtrinsic({
|
|
151
153
|
transferAll: false,
|
|
152
|
-
value
|
|
154
|
+
value,
|
|
153
155
|
from: address,
|
|
154
156
|
networkKey: srcChain.slug,
|
|
155
157
|
tokenInfo: srcToken,
|
|
@@ -285,10 +287,11 @@ export const calculateXcmMaxTransferable = async (id, request, freeBalance, fee)
|
|
|
285
287
|
nativeToken,
|
|
286
288
|
srcChain,
|
|
287
289
|
srcToken,
|
|
288
|
-
substrateApi
|
|
290
|
+
substrateApi,
|
|
291
|
+
value
|
|
289
292
|
} = request;
|
|
290
293
|
const feeChainType = fee.type;
|
|
291
|
-
let estimatedFee;
|
|
294
|
+
let estimatedFee = '0';
|
|
292
295
|
let feeOptions;
|
|
293
296
|
let maxTransferable;
|
|
294
297
|
let error;
|
|
@@ -297,20 +300,22 @@ export const calculateXcmMaxTransferable = async (id, request, freeBalance, fee)
|
|
|
297
300
|
const isSnowBridgeEvmTransfer = _isPureEvmChain(srcChain) && _isSnowBridgeXcm(srcChain, destChain) && !isAvailBridgeFromEvm;
|
|
298
301
|
const isPolygonBridgeTransfer = _isPolygonChainBridge(srcChain.slug, destChain.slug);
|
|
299
302
|
const isPosBridgeTransfer = _isPosChainBridge(srcChain.slug, destChain.slug);
|
|
303
|
+
const isAcrossBridgeTransfer = _isAcrossChainBridge(srcChain.slug, destChain.slug);
|
|
304
|
+
const isSubstrateXcm = !(isAvailBridgeFromEvm || isAvailBridgeFromAvail || isSnowBridgeEvmTransfer || isPolygonBridgeTransfer || isPosBridgeTransfer || isAcrossBridgeTransfer);
|
|
300
305
|
const fakeAddress = '5DRewsYzhJqZXU3SRaWy1FSt5iDr875ao91aw5fjrJmDG4Ap'; // todo: move this
|
|
301
306
|
const substrateAddress = fakeAddress; // todo: move this
|
|
302
307
|
const evmAddress = u8aToHex(addressToEvm(fakeAddress)); // todo: move this
|
|
303
|
-
|
|
308
|
+
const bnFreeBalance = new BigN(freeBalance.value);
|
|
304
309
|
const recipient = _isChainEvmCompatible(destChain) ? evmAddress : substrateAddress;
|
|
310
|
+
if (!destToken) {
|
|
311
|
+
throw Error('Destination token is not available');
|
|
312
|
+
}
|
|
305
313
|
try {
|
|
306
|
-
if (!destToken) {
|
|
307
|
-
throw Error('Destination token is not available');
|
|
308
|
-
}
|
|
309
314
|
const params = {
|
|
310
315
|
destinationTokenInfo: destToken,
|
|
311
316
|
originTokenInfo: srcToken,
|
|
312
317
|
// If value is 0, substrate will throw error when estimating fee
|
|
313
|
-
sendingValue:
|
|
318
|
+
sendingValue: value,
|
|
314
319
|
sender: address,
|
|
315
320
|
recipient,
|
|
316
321
|
destinationChain: destChain,
|
|
@@ -324,6 +329,13 @@ export const calculateXcmMaxTransferable = async (id, request, freeBalance, fee)
|
|
|
324
329
|
let funcCreateExtrinsic;
|
|
325
330
|
if (isPosBridgeTransfer || isPolygonBridgeTransfer) {
|
|
326
331
|
funcCreateExtrinsic = createPolygonBridgeExtrinsic;
|
|
332
|
+
} else if (isAcrossBridgeTransfer) {
|
|
333
|
+
funcCreateExtrinsic = createAcrossBridgeExtrinsic;
|
|
334
|
+
if (_isAcrossTestnetBridge(srcChain.slug)) {
|
|
335
|
+
params.sendingValue = BigN(0.0037).shiftedBy(_getAssetDecimals(srcToken)).toFixed(0, 1);
|
|
336
|
+
} else {
|
|
337
|
+
params.sendingValue = BigN(1).shiftedBy(_getAssetDecimals(srcToken)).toFixed(0, 1);
|
|
338
|
+
}
|
|
327
339
|
} else if (isSnowBridgeEvmTransfer) {
|
|
328
340
|
funcCreateExtrinsic = createSnowBridgeExtrinsic;
|
|
329
341
|
} else if (isAvailBridgeFromEvm) {
|
|
@@ -331,9 +343,12 @@ export const calculateXcmMaxTransferable = async (id, request, freeBalance, fee)
|
|
|
331
343
|
} else if (isAvailBridgeFromAvail) {
|
|
332
344
|
funcCreateExtrinsic = createAvailBridgeExtrinsicFromAvail;
|
|
333
345
|
} else {
|
|
334
|
-
funcCreateExtrinsic =
|
|
346
|
+
funcCreateExtrinsic = createXcmExtrinsicV2;
|
|
347
|
+
params.sendingValue = '1';
|
|
335
348
|
}
|
|
336
349
|
const extrinsic = await funcCreateExtrinsic(params);
|
|
350
|
+
|
|
351
|
+
// todo: refactor condition
|
|
337
352
|
if (feeChainType === 'evm') {
|
|
338
353
|
var _tx$gas2;
|
|
339
354
|
// Calculate fee for evm transaction
|
|
@@ -353,12 +368,17 @@ export const calculateXcmMaxTransferable = async (id, request, freeBalance, fee)
|
|
|
353
368
|
};
|
|
354
369
|
} else if (feeChainType === 'substrate') {
|
|
355
370
|
// Calculate fee for substrate transaction
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
371
|
+
if (isSubstrateXcm) {
|
|
372
|
+
const estimatedFeeByDryRun = await dryRunXcmExtrinsicV2(params);
|
|
373
|
+
estimatedFee = estimatedFeeByDryRun.fee || '0';
|
|
374
|
+
} else {
|
|
375
|
+
try {
|
|
376
|
+
var _paymentInfo$partialF2;
|
|
377
|
+
const paymentInfo = await extrinsic.paymentInfo(address);
|
|
378
|
+
estimatedFee = (paymentInfo === null || paymentInfo === void 0 ? void 0 : (_paymentInfo$partialF2 = paymentInfo.partialFee) === null || _paymentInfo$partialF2 === void 0 ? void 0 : _paymentInfo$partialF2.toString()) || '0';
|
|
379
|
+
} catch (e) {
|
|
380
|
+
estimatedFee = '0';
|
|
381
|
+
}
|
|
362
382
|
}
|
|
363
383
|
const _feeCustom = feeCustom;
|
|
364
384
|
const tip = combineSubstrateFee(fee, feeOption, _feeCustom).tip;
|
|
@@ -398,12 +418,12 @@ export const calculateXcmMaxTransferable = async (id, request, freeBalance, fee)
|
|
|
398
418
|
if (_SUPPORT_TOKEN_PAY_FEE_GROUP.assetHub.includes(srcChain.slug)) {
|
|
399
419
|
const estimatedFeeNative = (BigInt(estimatedFee) * BigInt(FEE_COVERAGE_PERCENTAGE_SPECIAL_CASE) / BigInt(100)).toString();
|
|
400
420
|
const estimatedFeeLocal = await calculateToAmountByReservePool(substrateApi.api, nativeToken, srcToken, estimatedFeeNative);
|
|
401
|
-
maxTransferable =
|
|
421
|
+
maxTransferable = bnFreeBalance.minus(estimatedFeeLocal);
|
|
402
422
|
} else if (_SUPPORT_TOKEN_PAY_FEE_GROUP.hydration.includes(srcChain.slug)) {
|
|
403
423
|
const rate = await getHydrationRate(address, nativeToken, srcToken);
|
|
404
424
|
if (rate) {
|
|
405
425
|
const estimatedFeeLocal = new BigN(estimatedFee).multipliedBy(rate).integerValue(BigN.ROUND_UP).toString();
|
|
406
|
-
maxTransferable =
|
|
426
|
+
maxTransferable = bnFreeBalance.minus(estimatedFeeLocal);
|
|
407
427
|
} else {
|
|
408
428
|
throw new Error(`Unable to estimate fee for ${srcChain.slug}.`);
|
|
409
429
|
}
|
|
@@ -411,16 +431,20 @@ export const calculateXcmMaxTransferable = async (id, request, freeBalance, fee)
|
|
|
411
431
|
throw new Error(`Unable to estimate fee for ${srcChain.slug}.`);
|
|
412
432
|
}
|
|
413
433
|
} else if (isTransferNativeTokenAndPayLocalTokenAsFee) {
|
|
414
|
-
maxTransferable =
|
|
434
|
+
maxTransferable = bnFreeBalance;
|
|
415
435
|
} else {
|
|
416
436
|
if (!_isNativeToken(srcToken)) {
|
|
417
|
-
maxTransferable =
|
|
437
|
+
maxTransferable = bnFreeBalance;
|
|
418
438
|
} else {
|
|
419
|
-
maxTransferable =
|
|
439
|
+
maxTransferable = bnFreeBalance.minus(BigN(estimatedFee).multipliedBy(XCM_FEE_RATIO));
|
|
420
440
|
}
|
|
421
441
|
}
|
|
442
|
+
if (isAvailBridgeFromAvail) {
|
|
443
|
+
const addedAmount = BigN(1).shiftedBy(_getAssetDecimals(srcToken));
|
|
444
|
+
maxTransferable = maxTransferable.minus(addedAmount);
|
|
445
|
+
}
|
|
422
446
|
return {
|
|
423
|
-
maxTransferable: maxTransferable.gt(BN_ZERO) ? maxTransferable.toFixed(0)
|
|
447
|
+
maxTransferable: maxTransferable.gt(BN_ZERO) ? maxTransferable.toFixed(0) : '0',
|
|
424
448
|
feeOptions: feeOptions,
|
|
425
449
|
feeType: feeChainType,
|
|
426
450
|
id: id,
|
|
@@ -10,6 +10,7 @@ export declare const blockedActionsFeatures: BlockedActionsFeaturesMap;
|
|
|
10
10
|
export declare const remindNotificationTime: Record<NotificationActionType, number>;
|
|
11
11
|
export declare const blockedActions: Record<string, EnvConfig>;
|
|
12
12
|
export declare const oldChainPrefix: Record<string, EnvConfig>;
|
|
13
|
+
export declare const paraSpellChainMap: Record<string, EnvConfig>;
|
|
13
14
|
export declare enum StaticKey {
|
|
14
15
|
BUY_SERVICE_INFOS = "buy-service-infos",
|
|
15
16
|
CHAINS = "chains",
|
|
@@ -21,7 +22,8 @@ export declare enum StaticKey {
|
|
|
21
22
|
BLOCKED_ACTIONS_FEATURES = "blocked-actions-features",
|
|
22
23
|
REMIND_NOTIFICATION_TIME = "remind-notification-time",
|
|
23
24
|
BLOCKED_ACTIONS = "blocked-actions",
|
|
24
|
-
OLD_CHAIN_PREFIX = "old-chain-prefix"
|
|
25
|
+
OLD_CHAIN_PREFIX = "old-chain-prefix",
|
|
26
|
+
PARASPELL_CHAIN_MAP = "paraspell-chain-map"
|
|
25
27
|
}
|
|
26
28
|
export declare const staticData: {
|
|
27
29
|
chains: import("@subwallet/chain-list/types")._ChainInfo[];
|
|
@@ -35,4 +37,5 @@ export declare const staticData: {
|
|
|
35
37
|
"remind-notification-time": Record<NotificationActionType, number>;
|
|
36
38
|
"blocked-actions": Record<string, EnvConfig>;
|
|
37
39
|
"old-chain-prefix": Record<string, EnvConfig>;
|
|
40
|
+
"paraspell-chain-map": Record<string, EnvConfig>;
|
|
38
41
|
};
|
|
@@ -23,6 +23,8 @@ export const remindNotificationTime = require("./remindNotificationTime.json");
|
|
|
23
23
|
export const blockedActions = require("./blockedActions.json");
|
|
24
24
|
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
|
|
25
25
|
export const oldChainPrefix = require("./oldChainPrefix.json");
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
|
|
27
|
+
export const paraSpellChainMap = require("./paraSpellChainMap.json");
|
|
26
28
|
export let StaticKey;
|
|
27
29
|
(function (StaticKey) {
|
|
28
30
|
StaticKey["BUY_SERVICE_INFOS"] = "buy-service-infos";
|
|
@@ -36,6 +38,7 @@ export let StaticKey;
|
|
|
36
38
|
StaticKey["REMIND_NOTIFICATION_TIME"] = "remind-notification-time";
|
|
37
39
|
StaticKey["BLOCKED_ACTIONS"] = "blocked-actions";
|
|
38
40
|
StaticKey["OLD_CHAIN_PREFIX"] = "old-chain-prefix";
|
|
41
|
+
StaticKey["PARASPELL_CHAIN_MAP"] = "paraspell-chain-map";
|
|
39
42
|
})(StaticKey || (StaticKey = {}));
|
|
40
43
|
export const staticData = {
|
|
41
44
|
[StaticKey.CHAINS]: Object.values(ChainInfoMap),
|
|
@@ -48,5 +51,6 @@ export const staticData = {
|
|
|
48
51
|
[StaticKey.BLOCKED_ACTIONS_FEATURES]: blockedActionsFeatures,
|
|
49
52
|
[StaticKey.REMIND_NOTIFICATION_TIME]: remindNotificationTime,
|
|
50
53
|
[StaticKey.BLOCKED_ACTIONS]: blockedActions,
|
|
51
|
-
[StaticKey.OLD_CHAIN_PREFIX]: oldChainPrefix
|
|
54
|
+
[StaticKey.OLD_CHAIN_PREFIX]: oldChainPrefix,
|
|
55
|
+
[StaticKey.PARASPELL_CHAIN_MAP]: paraSpellChainMap
|
|
52
56
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
package/utils/swap.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { NumberFormatter } from '@subwallet/extension-base/utils/number';
|
|
2
|
+
export declare const swapNumberMetadata: {
|
|
3
|
+
minNumberFormat: number;
|
|
4
|
+
};
|
|
2
5
|
export declare const swapCustomFormatter: NumberFormatter;
|
|
3
6
|
export declare const formatNumberString: (numberString: string) => string;
|
package/utils/swap.js
CHANGED
|
@@ -19,6 +19,9 @@ const NUM_1B = new BigNumber(1e9);
|
|
|
19
19
|
const BLIM = new BigNumber(1e14);
|
|
20
20
|
const NUM_1M = new BigNumber(1e6);
|
|
21
21
|
const NUM_100M = new BigNumber(1e8);
|
|
22
|
+
export const swapNumberMetadata = {
|
|
23
|
+
minNumberFormat: 4
|
|
24
|
+
};
|
|
22
25
|
export const swapCustomFormatter = (input, metadata) => {
|
|
23
26
|
const minNumberFormat = 2;
|
|
24
27
|
const maxNumberFormat = (metadata === null || metadata === void 0 ? void 0 : metadata.maxNumberFormat) || 6;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.DynamicSwapType = void 0;
|
|
7
|
-
// Copyright 2019-2022 @subwallet/extension-base
|
|
8
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
9
|
-
let DynamicSwapType;
|
|
10
|
-
exports.DynamicSwapType = DynamicSwapType;
|
|
11
|
-
(function (DynamicSwapType) {
|
|
12
|
-
DynamicSwapType["SWAP"] = "SWAP";
|
|
13
|
-
DynamicSwapType["BRIDGE"] = "BRIDGE";
|
|
14
|
-
})(DynamicSwapType || (exports.DynamicSwapType = DynamicSwapType = {}));
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
// Copyright 2019-2022 @subwallet/extension-base
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
export let DynamicSwapType;
|
|
5
|
-
(function (DynamicSwapType) {
|
|
6
|
-
DynamicSwapType["SWAP"] = "SWAP";
|
|
7
|
-
DynamicSwapType["BRIDGE"] = "BRIDGE";
|
|
8
|
-
})(DynamicSwapType || (DynamicSwapType = {}));
|