@subwallet/extension-base 1.3.77-0 → 1.3.79-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/background/KoniTypes.d.ts +5 -3
- package/cjs/core/logic-validation/index.js +1 -13
- package/cjs/core/substrate/xcm-parser.js +10 -1
- package/cjs/koni/background/handlers/Extension.js +41 -9
- package/cjs/koni/background/handlers/State.js +20 -0
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/helpers/subscribe/evm.js +85 -6
- package/cjs/services/balance-service/helpers/subscribe/index.js +2 -1
- package/cjs/services/balance-service/index.js +6 -2
- package/cjs/services/balance-service/transfer/token.js +15 -0
- package/cjs/services/balance-service/transfer/xcm/bittensorBridge/index.js +27 -0
- package/cjs/services/balance-service/transfer/xcm/bittensorBridge/nativeTokenBridge.js +58 -0
- package/cjs/services/balance-service/transfer/xcm/bittensorBridge/utils.js +36 -0
- package/cjs/services/balance-service/transfer/xcm/index.js +61 -2
- package/cjs/services/balance-service/transfer/xcm/utils.js +103 -15
- package/cjs/services/chain-service/constants.js +4 -2
- package/cjs/services/chain-service/utils/patch.js +1 -1
- package/cjs/services/earning-service/constants/chains.js +4 -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 +89 -65
- package/cjs/services/earning-service/service.js +1 -0
- 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/bittensor-handler.js +197 -0
- package/cjs/services/swap-service/handler/hydradx-handler.js +9 -5
- package/cjs/services/swap-service/index.js +12 -4
- package/cjs/services/transaction-service/index.js +1 -0
- package/cjs/types/balance/index.js +1 -0
- package/cjs/types/swap/index.js +7 -10
- package/cjs/utils/account/common.js +44 -8
- package/cjs/utils/fee/transfer.js +20 -5
- package/core/logic-validation/index.d.ts +0 -1
- package/core/logic-validation/index.js +1 -2
- package/core/substrate/xcm-parser.d.ts +2 -0
- package/core/substrate/xcm-parser.js +8 -1
- package/koni/background/handlers/Extension.d.ts +3 -0
- package/koni/background/handlers/Extension.js +42 -10
- package/koni/background/handlers/State.d.ts +1 -0
- package/koni/background/handlers/State.js +20 -0
- package/package.json +26 -11
- package/packageInfo.js +1 -1
- package/services/balance-service/helpers/subscribe/evm.d.ts +1 -0
- package/services/balance-service/helpers/subscribe/evm.js +76 -1
- package/services/balance-service/helpers/subscribe/index.js +2 -1
- package/services/balance-service/index.js +6 -2
- package/services/balance-service/transfer/token.d.ts +2 -1
- package/services/balance-service/transfer/token.js +15 -0
- package/services/balance-service/transfer/xcm/bittensorBridge/index.d.ts +2 -0
- package/services/balance-service/transfer/xcm/bittensorBridge/index.js +5 -0
- package/services/balance-service/transfer/xcm/bittensorBridge/nativeTokenBridge.d.ts +6 -0
- package/services/balance-service/transfer/xcm/bittensorBridge/nativeTokenBridge.js +50 -0
- package/services/balance-service/transfer/xcm/bittensorBridge/utils.d.ts +8 -0
- package/services/balance-service/transfer/xcm/bittensorBridge/utils.js +29 -0
- package/services/balance-service/transfer/xcm/index.d.ts +5 -0
- package/services/balance-service/transfer/xcm/index.js +57 -2
- package/services/balance-service/transfer/xcm/utils.d.ts +3 -2
- package/services/balance-service/transfer/xcm/utils.js +96 -10
- package/services/chain-service/constants.d.ts +2 -0
- package/services/chain-service/constants.js +4 -2
- package/services/chain-service/utils/patch.d.ts +1 -1
- package/services/chain-service/utils/patch.js +1 -1
- package/services/earning-service/constants/chains.d.ts +1 -0
- package/services/earning-service/constants/chains.js +2 -1
- 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.d.ts +1 -1
- package/services/earning-service/handlers/special.js +92 -68
- package/services/earning-service/service.js +1 -0
- 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/bittensor-handler.d.ts +21 -0
- package/services/swap-service/handler/bittensor-handler.js +189 -0
- package/services/swap-service/handler/hydradx-handler.js +9 -5
- package/services/swap-service/index.js +12 -4
- package/services/transaction-service/index.js +1 -0
- package/services/transaction-service/types.d.ts +4 -3
- package/types/balance/index.d.ts +3 -1
- package/types/balance/index.js +1 -0
- package/types/balance/transfer.d.ts +7 -0
- package/types/fee/base.d.ts +1 -0
- package/types/swap/index.d.ts +10 -36
- package/types/swap/index.js +6 -9
- package/types/yield/actions/join/step.d.ts +7 -0
- package/types/yield/actions/join/submit.d.ts +3 -1
- package/utils/account/common.d.ts +22 -1
- package/utils/account/common.js +44 -8
- package/utils/fee/transfer.d.ts +1 -0
- package/utils/fee/transfer.js +21 -6
- 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
|
@@ -24,6 +24,7 @@ var _subwalletServicesSdk = _interopRequireDefault(require("@subwallet-monorepos
|
|
|
24
24
|
var _bignumber = _interopRequireDefault(require("bignumber.js"));
|
|
25
25
|
var _i18next = require("i18next");
|
|
26
26
|
var _rxjs = require("rxjs");
|
|
27
|
+
var _bittensorHandler = require("./handler/bittensor-handler");
|
|
27
28
|
var _kyberHandler = require("./handler/kyber-handler");
|
|
28
29
|
var _simpleswapHandler = require("./handler/simpleswap-handler");
|
|
29
30
|
var _uniswapHandler = require("./handler/uniswap-handler");
|
|
@@ -109,8 +110,7 @@ class SwapService {
|
|
|
109
110
|
if (!params.selectedQuote) {
|
|
110
111
|
return this.getDefaultProcessV2(params);
|
|
111
112
|
} else {
|
|
112
|
-
|
|
113
|
-
const providerId = ((_params$request$curre = params.request.currentQuote) === null || _params$request$curre === void 0 ? void 0 : _params$request$curre.id) || params.selectedQuote.provider.id;
|
|
113
|
+
const providerId = params.selectedQuote.provider.id;
|
|
114
114
|
const handler = this.handlers[providerId];
|
|
115
115
|
if (handler) {
|
|
116
116
|
// todo: handle error response from generateOptimalProcess
|
|
@@ -135,6 +135,8 @@ class SwapService {
|
|
|
135
135
|
console.group('Swap Logger');
|
|
136
136
|
console.log('path', path);
|
|
137
137
|
console.log('swapQuoteResponse', swapQuoteResponse);
|
|
138
|
+
|
|
139
|
+
// Just to log routing type for Uniswap Quote
|
|
138
140
|
if (swapQuoteResponse.optimalQuote && swapQuoteResponse.optimalQuote.metadata) {
|
|
139
141
|
const routing = swapQuoteResponse.optimalQuote.metadata.routing;
|
|
140
142
|
if (routing) {
|
|
@@ -153,7 +155,7 @@ class SwapService {
|
|
|
153
155
|
}
|
|
154
156
|
|
|
155
157
|
// override fee for quote because some cases need estimate network fee on Extension (i.e. Optimex)
|
|
156
|
-
if (swapQuoteResponse.optimalQuote) {
|
|
158
|
+
if (swapQuoteResponse.optimalQuote && [_swap.SwapProviderId.OPTIMEX, _swap.SwapProviderId.OPTIMEX_TESTNET].includes(swapQuoteResponse.optimalQuote.provider.id)) {
|
|
157
159
|
const swapIndex = optimalProcess.steps.findIndex(step => step.type === _swap.SwapStepType.SWAP);
|
|
158
160
|
swapQuoteResponse.optimalQuote.feeInfo.feeComponent = optimalProcess.totalFee[swapIndex].feeComponent;
|
|
159
161
|
}
|
|
@@ -196,7 +198,7 @@ class SwapService {
|
|
|
196
198
|
const swapAction = path.find(step => step.action === _types2.DynamicSwapType.SWAP);
|
|
197
199
|
const directSwapRequest = swapAction ? {
|
|
198
200
|
...request,
|
|
199
|
-
address: (0, _utils3._reformatAddressWithChain)(request.address, this.chainService.getChainInfoByKey((0, _utils._getAssetOriginChain)(this.chainService.getAssetBySlug(swapAction.pair.from)))),
|
|
201
|
+
address: (0, _utils3._reformatAddressWithChain)(request.address, this.chainService.getChainInfoByKey((0, _utils._getAssetOriginChain)(this.chainService.getAssetBySlug(swapAction.pair.from))), request.alternativeAddress),
|
|
200
202
|
pair: swapAction.pair
|
|
201
203
|
} : undefined;
|
|
202
204
|
if (!directSwapRequest) {
|
|
@@ -296,6 +298,12 @@ class SwapService {
|
|
|
296
298
|
case _swap.SwapProviderId.OPTIMEX_TESTNET:
|
|
297
299
|
this.handlers[providerId] = new _optimexHandler.OptimexHandler(this.chainService, this.state.balanceService, this.state.feeService, true);
|
|
298
300
|
break;
|
|
301
|
+
case _swap.SwapProviderId.BITTENSOR:
|
|
302
|
+
this.handlers[providerId] = new _bittensorHandler.BittensorSwapHandler(this.chainService, this.state.balanceService, this.state.feeService, false);
|
|
303
|
+
break;
|
|
304
|
+
case _swap.SwapProviderId.BITTENSOR_TESTNET:
|
|
305
|
+
this.handlers[providerId] = new _bittensorHandler.BittensorSwapHandler(this.chainService, this.state.balanceService, this.state.feeService, true);
|
|
306
|
+
break;
|
|
299
307
|
default:
|
|
300
308
|
throw new Error('Unsupported provider');
|
|
301
309
|
}
|
|
@@ -937,6 +937,7 @@ class TransactionService {
|
|
|
937
937
|
nonce: nonce !== null && nonce !== void 0 ? nonce : 0,
|
|
938
938
|
startBlock: startBlock || 0,
|
|
939
939
|
processId: (_transaction$step3 = transaction.step) === null || _transaction$step3 === void 0 ? void 0 : _transaction$step3.processId,
|
|
940
|
+
crossChainFeeInfo: transaction === null || transaction === void 0 ? void 0 : transaction.xcmDestinationFee,
|
|
940
941
|
substrateProxyAddresses: []
|
|
941
942
|
};
|
|
942
943
|
const substrateProxyHistories = [];
|
|
@@ -23,6 +23,7 @@ exports.BalanceType = BalanceType;
|
|
|
23
23
|
BalanceType["TOTAL"] = "total";
|
|
24
24
|
BalanceType["TOTAL_MINUS_RESERVED"] = "totalMinusReserved";
|
|
25
25
|
BalanceType["KEEP_ALIVE"] = "keepAlive";
|
|
26
|
+
BalanceType["STAKING"] = "staking";
|
|
26
27
|
})(BalanceType || (exports.BalanceType = BalanceType = {}));
|
|
27
28
|
/** Balance info of all tokens on an address */
|
|
28
29
|
// Key is tokenSlug
|
package/cjs/types/swap/index.js
CHANGED
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports._SUPPORTED_SWAP_PROVIDERS = exports.SwapStepType = exports.SwapProviderId = exports.SwapFeeType = exports.SwapErrorType = exports.SIMPLE_SWAP_SLIPPAGE = exports.DynamicSwapType = exports.CHAINFLIP_SLIPPAGE =
|
|
6
|
+
exports._SUPPORTED_SWAP_PROVIDERS = exports.SwapStepType = exports.SwapProviderId = exports.SwapFeeType = exports.SwapErrorType = exports.SIMPLE_SWAP_SLIPPAGE = exports.DynamicSwapType = exports.CHAINFLIP_SLIPPAGE = void 0;
|
|
7
7
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
8
8
|
// SPDX-License-Identifier: Apache-2.0
|
|
9
|
-
// core
|
|
10
9
|
let SwapErrorType;
|
|
11
10
|
exports.SwapErrorType = SwapErrorType;
|
|
12
11
|
(function (SwapErrorType) {
|
|
@@ -45,10 +44,11 @@ exports.SwapProviderId = SwapProviderId;
|
|
|
45
44
|
SwapProviderId["KYBER"] = "KYBER";
|
|
46
45
|
SwapProviderId["OPTIMEX"] = "OPTIMEX";
|
|
47
46
|
SwapProviderId["OPTIMEX_TESTNET"] = "OPTIMEX_TESTNET";
|
|
47
|
+
SwapProviderId["BITTENSOR"] = "BITTENSOR";
|
|
48
|
+
SwapProviderId["BITTENSOR_TESTNET"] = "BITTENSOR_TESTNET";
|
|
48
49
|
})(SwapProviderId || (exports.SwapProviderId = SwapProviderId = {}));
|
|
49
|
-
const _SUPPORTED_SWAP_PROVIDERS = [SwapProviderId.CHAIN_FLIP_TESTNET, SwapProviderId.CHAIN_FLIP_MAINNET, SwapProviderId.HYDRADX_MAINNET, SwapProviderId.POLKADOT_ASSET_HUB, SwapProviderId.KUSAMA_ASSET_HUB, SwapProviderId.SIMPLE_SWAP, SwapProviderId.UNISWAP, SwapProviderId.KYBER, SwapProviderId.OPTIMEX, SwapProviderId.OPTIMEX_TESTNET];
|
|
50
|
+
const _SUPPORTED_SWAP_PROVIDERS = [SwapProviderId.CHAIN_FLIP_TESTNET, SwapProviderId.CHAIN_FLIP_MAINNET, SwapProviderId.HYDRADX_MAINNET, SwapProviderId.POLKADOT_ASSET_HUB, SwapProviderId.KUSAMA_ASSET_HUB, SwapProviderId.SIMPLE_SWAP, SwapProviderId.UNISWAP, SwapProviderId.KYBER, SwapProviderId.OPTIMEX, SwapProviderId.OPTIMEX_TESTNET, SwapProviderId.BITTENSOR, SwapProviderId.BITTENSOR_TESTNET];
|
|
50
51
|
exports._SUPPORTED_SWAP_PROVIDERS = _SUPPORTED_SWAP_PROVIDERS;
|
|
51
|
-
// process handling
|
|
52
52
|
let SwapFeeType;
|
|
53
53
|
exports.SwapFeeType = SwapFeeType;
|
|
54
54
|
(function (SwapFeeType) {
|
|
@@ -57,18 +57,15 @@ exports.SwapFeeType = SwapFeeType;
|
|
|
57
57
|
SwapFeeType["WALLET_FEE"] = "WALLET_FEE";
|
|
58
58
|
})(SwapFeeType || (exports.SwapFeeType = SwapFeeType = {})); // todo: will be more
|
|
59
59
|
// parameters & responses
|
|
60
|
+
/**
|
|
61
|
+
* @deprecated Use interface `SwapRequestV2` instead.
|
|
62
|
+
*/
|
|
60
63
|
let DynamicSwapType;
|
|
61
64
|
exports.DynamicSwapType = DynamicSwapType;
|
|
62
65
|
(function (DynamicSwapType) {
|
|
63
66
|
DynamicSwapType["SWAP"] = "SWAP";
|
|
64
67
|
DynamicSwapType["BRIDGE"] = "BRIDGE";
|
|
65
68
|
})(DynamicSwapType || (exports.DynamicSwapType = DynamicSwapType = {}));
|
|
66
|
-
let BridgeStepPosition;
|
|
67
|
-
exports.BridgeStepPosition = BridgeStepPosition;
|
|
68
|
-
(function (BridgeStepPosition) {
|
|
69
|
-
BridgeStepPosition[BridgeStepPosition["FIRST"] = 0] = "FIRST";
|
|
70
|
-
BridgeStepPosition[BridgeStepPosition["AFTER_SWAP"] = 1] = "AFTER_SWAP";
|
|
71
|
-
})(BridgeStepPosition || (exports.BridgeStepPosition = BridgeStepPosition = {}));
|
|
72
69
|
const CHAINFLIP_SLIPPAGE = 0.02; // Example: 0.01 for 1%
|
|
73
70
|
exports.CHAINFLIP_SLIPPAGE = CHAINFLIP_SLIPPAGE;
|
|
74
71
|
const SIMPLE_SWAP_SLIPPAGE = 0.05;
|
|
@@ -54,17 +54,53 @@ function reformatAddress(address) {
|
|
|
54
54
|
return address;
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* @private
|
|
60
|
+
* Reformats a wallet address based on the provided chain information.
|
|
61
|
+
*
|
|
62
|
+
* This function checks the chain type (Substrate, TON, Cardano, or others)
|
|
63
|
+
* and applies the corresponding formatting logic:
|
|
64
|
+
* 1. **Substrate**: Reformats the Substrate address using the chain's specific prefix.
|
|
65
|
+
* If the current `address` is an EVM address, it attempts to use the `alternativeAddress`
|
|
66
|
+
* (which is currently **always** expected to be the Substrate address) for Substrate
|
|
67
|
+
* formatting, as direct EVM-to-Substrate reformatting is not possible here.
|
|
68
|
+
* 2. **TON/Cardano**: Uses a simple prefix logic based on whether the chain is a testnet or a mainnet.
|
|
69
|
+
* 3. **Default (EVM/Others)**: Returns the original address without reformatting.
|
|
70
|
+
*
|
|
71
|
+
* @param address The current wallet address string.
|
|
72
|
+
* @param chainInfo An object containing chain details (e.g., chain type, testnet status, prefix).
|
|
73
|
+
* @param alternativeAddress An optional alternative address, which is currently expected to be the Substrate
|
|
74
|
+
* address associated with the account. It is used as a fallback for Substrate formatting when the main `address` is EVM.
|
|
75
|
+
* @returns The reformatted wallet address, or the original address if no reformatting is needed or possible.
|
|
76
|
+
*
|
|
77
|
+
* @todo This function currently lacks logic to reformat a Substrate address into an EVM address format.
|
|
78
|
+
*/
|
|
79
|
+
const _reformatAddressWithChain = (address, chainInfo, alternativeAddress) => {
|
|
58
80
|
const chainType = (0, _utils._chainInfoToAccountChainType)(chainInfo);
|
|
59
81
|
if (chainType === _types.AccountChainType.SUBSTRATE) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
82
|
+
const addressPrefix = (0, _utils._getChainSubstrateAddressPrefix)(chainInfo);
|
|
83
|
+
if (addressPrefix < 0) {
|
|
84
|
+
// not a valid address prefix for substrate chain type
|
|
85
|
+
return address;
|
|
86
|
+
}
|
|
87
|
+
if ((0, _utilCrypto.isEthereumAddress)(address)) {
|
|
88
|
+
if (alternativeAddress) {
|
|
89
|
+
// reformat using alternativeAddress of that account. Because can not reformat from evm address to substrate address
|
|
90
|
+
return reformatAddress(alternativeAddress, addressPrefix);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// can not reformat without substrateAddress info
|
|
94
|
+
return address;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// reformat as usual with substrate address
|
|
98
|
+
return reformatAddress(address, addressPrefix);
|
|
99
|
+
}
|
|
100
|
+
if (chainType === _types.AccountChainType.TON || chainType === _types.AccountChainType.CARDANO) {
|
|
101
|
+
return reformatAddress(address, chainInfo.isTestnet ? 0 : 1);
|
|
67
102
|
}
|
|
103
|
+
return address;
|
|
68
104
|
};
|
|
69
105
|
exports._reformatAddressWithChain = _reformatAddressWithChain;
|
|
70
106
|
const getAccountChainTypeForAddress = address => {
|
|
@@ -16,6 +16,7 @@ var _tonTransfer = require("@subwallet/extension-base/services/balance-service/t
|
|
|
16
16
|
var _xcm = require("@subwallet/extension-base/services/balance-service/transfer/xcm");
|
|
17
17
|
var _acrossBridge = require("@subwallet/extension-base/services/balance-service/transfer/xcm/acrossBridge");
|
|
18
18
|
var _availBridge = require("@subwallet/extension-base/services/balance-service/transfer/xcm/availBridge");
|
|
19
|
+
var _nativeTokenBridge = require("@subwallet/extension-base/services/balance-service/transfer/xcm/bittensorBridge/nativeTokenBridge");
|
|
19
20
|
var _polygonBridge = require("@subwallet/extension-base/services/balance-service/transfer/xcm/polygonBridge");
|
|
20
21
|
var _posBridge = require("@subwallet/extension-base/services/balance-service/transfer/xcm/posBridge");
|
|
21
22
|
var _utils = require("@subwallet/extension-base/services/balance-service/transfer/xcm/utils");
|
|
@@ -92,6 +93,7 @@ const calculateTransferMaxTransferable = async (id, request, freeBalance, fee) =
|
|
|
92
93
|
feeOption,
|
|
93
94
|
isTransferLocalTokenAndPayThatTokenAsFee,
|
|
94
95
|
isTransferNativeTokenAndPayLocalTokenAsFee,
|
|
96
|
+
metadata,
|
|
95
97
|
nativeToken,
|
|
96
98
|
srcChain,
|
|
97
99
|
srcToken,
|
|
@@ -194,7 +196,8 @@ const calculateTransferMaxTransferable = async (id, request, freeBalance, fee) =
|
|
|
194
196
|
networkKey: srcChain.slug,
|
|
195
197
|
tokenInfo: srcToken,
|
|
196
198
|
to: recipient,
|
|
197
|
-
substrateApi
|
|
199
|
+
substrateApi,
|
|
200
|
+
metadata
|
|
198
201
|
});
|
|
199
202
|
}
|
|
200
203
|
if (feeChainType === 'evm') {
|
|
@@ -348,10 +351,12 @@ const calculateXcmMaxTransferable = async (id, request, freeBalance, fee) => {
|
|
|
348
351
|
srcChain,
|
|
349
352
|
srcToken,
|
|
350
353
|
substrateApi,
|
|
354
|
+
transferAll,
|
|
351
355
|
value
|
|
352
356
|
} = request;
|
|
353
357
|
const feeChainType = fee.type;
|
|
354
358
|
let estimatedFee = '0';
|
|
359
|
+
let crossChainFee = '0';
|
|
355
360
|
let feeOptions;
|
|
356
361
|
let maxTransferable;
|
|
357
362
|
let error;
|
|
@@ -361,7 +366,9 @@ const calculateXcmMaxTransferable = async (id, request, freeBalance, fee) => {
|
|
|
361
366
|
const isPolygonBridgeTransfer = (0, _polygonBridge._isPolygonChainBridge)(srcChain.slug, destChain.slug);
|
|
362
367
|
const isPosBridgeTransfer = (0, _posBridge._isPosChainBridge)(srcChain.slug, destChain.slug);
|
|
363
368
|
const isAcrossBridgeTransfer = (0, _acrossBridge._isAcrossChainBridge)(srcChain.slug, destChain.slug);
|
|
364
|
-
const
|
|
369
|
+
const isBittensorBridgeTransfer = (0, _nativeTokenBridge._isBittensorToSubtensorBridge)(srcChain.slug, destChain.slug);
|
|
370
|
+
const isSubtensorEvmBridgeTransfer = (0, _nativeTokenBridge._isSubtensorToBittensorBridge)(srcChain.slug, destChain.slug);
|
|
371
|
+
const isSubstrateParaspellXcm = !(isAvailBridgeFromEvm || isAvailBridgeFromAvail || isSnowBridgeEvmTransfer || isPolygonBridgeTransfer || isPosBridgeTransfer || isAcrossBridgeTransfer || isBittensorBridgeTransfer || isSubtensorEvmBridgeTransfer);
|
|
365
372
|
const fakeAddress = '5DRewsYzhJqZXU3SRaWy1FSt5iDr875ao91aw5fjrJmDG4Ap'; // todo: move this
|
|
366
373
|
const substrateAddress = fakeAddress; // todo: move this
|
|
367
374
|
const evmAddress = (0, _util.u8aToHex)((0, _utilCrypto.addressToEvm)(fakeAddress)); // todo: move this
|
|
@@ -384,7 +391,8 @@ const calculateXcmMaxTransferable = async (id, request, freeBalance, fee) => {
|
|
|
384
391
|
evmApi,
|
|
385
392
|
feeCustom,
|
|
386
393
|
feeOption,
|
|
387
|
-
feeInfo: fee
|
|
394
|
+
feeInfo: fee,
|
|
395
|
+
transferAll
|
|
388
396
|
};
|
|
389
397
|
let funcCreateExtrinsic;
|
|
390
398
|
if (isPosBridgeTransfer || isPolygonBridgeTransfer) {
|
|
@@ -392,6 +400,10 @@ const calculateXcmMaxTransferable = async (id, request, freeBalance, fee) => {
|
|
|
392
400
|
} else if (isAcrossBridgeTransfer) {
|
|
393
401
|
funcCreateExtrinsic = _xcm.createAcrossBridgeExtrinsic;
|
|
394
402
|
params.sendingValue = await (0, _acrossBridge.getAcrossSendingValue)(srcChain, srcToken, destChain, (0, _acrossBridge._isAcrossTestnetBridge)(srcChain.slug));
|
|
403
|
+
} else if (isBittensorBridgeTransfer) {
|
|
404
|
+
funcCreateExtrinsic = _xcm.createBittensorToSubtensorEvmExtrinsic;
|
|
405
|
+
} else if (isSubtensorEvmBridgeTransfer) {
|
|
406
|
+
funcCreateExtrinsic = _xcm.createSubtensorEvmToBittensorExtrinsic;
|
|
395
407
|
} else if (isSnowBridgeEvmTransfer) {
|
|
396
408
|
funcCreateExtrinsic = _xcm.createSnowBridgeExtrinsic;
|
|
397
409
|
} else if (isAvailBridgeFromEvm) {
|
|
@@ -423,7 +435,8 @@ const calculateXcmMaxTransferable = async (id, request, freeBalance, fee) => {
|
|
|
423
435
|
};
|
|
424
436
|
} else if (feeChainType === 'substrate') {
|
|
425
437
|
// Calculate fee for substrate transaction
|
|
426
|
-
if (
|
|
438
|
+
if (isSubstrateParaspellXcm) {
|
|
439
|
+
var _xcmFeeInfo$destinati;
|
|
427
440
|
const xcmFeeInfo = await (0, _utils.estimateXcmFee)({
|
|
428
441
|
fromChainInfo: params.originChain,
|
|
429
442
|
fromTokenInfo: params.originTokenInfo,
|
|
@@ -433,6 +446,7 @@ const calculateXcmMaxTransferable = async (id, request, freeBalance, fee) => {
|
|
|
433
446
|
value: params.sendingValue
|
|
434
447
|
});
|
|
435
448
|
estimatedFee = (xcmFeeInfo === null || xcmFeeInfo === void 0 ? void 0 : xcmFeeInfo.origin.fee) || '0';
|
|
449
|
+
crossChainFee = (xcmFeeInfo === null || xcmFeeInfo === void 0 ? void 0 : (_xcmFeeInfo$destinati = xcmFeeInfo.destination) === null || _xcmFeeInfo$destinati === void 0 ? void 0 : _xcmFeeInfo$destinati.fee) || '0';
|
|
436
450
|
} else {
|
|
437
451
|
try {
|
|
438
452
|
var _paymentInfo$partialF2;
|
|
@@ -447,7 +461,8 @@ const calculateXcmMaxTransferable = async (id, request, freeBalance, fee) => {
|
|
|
447
461
|
estimatedFee = new _bignumber.default(estimatedFee).plus(tip).toFixed(0);
|
|
448
462
|
feeOptions = {
|
|
449
463
|
...fee,
|
|
450
|
-
estimatedFee
|
|
464
|
+
estimatedFee,
|
|
465
|
+
crossChainFee
|
|
451
466
|
};
|
|
452
467
|
} else if (feeChainType === 'bitcoin') {
|
|
453
468
|
feeOptions = {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { _ChainAsset } from '@subwallet/chain-list/types';
|
|
2
2
|
import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError';
|
|
3
3
|
import BigN from 'bignumber.js';
|
|
4
|
-
export * from './swap';
|
|
5
4
|
export * from './request';
|
|
6
5
|
export * from './earning';
|
|
7
6
|
export * from './transfer';
|
|
@@ -5,7 +5,6 @@ import { TransactionError } from '@subwallet/extension-base/background/errors/Tr
|
|
|
5
5
|
import { _getTokenMinAmount, _isNativeToken } from '@subwallet/extension-base/services/chain-service/utils';
|
|
6
6
|
import { BasicTxErrorType } from '@subwallet/extension-base/types';
|
|
7
7
|
import { t } from 'i18next';
|
|
8
|
-
export * from "./swap.js";
|
|
9
8
|
export * from "./request.js";
|
|
10
9
|
export * from "./earning.js";
|
|
11
10
|
export * from "./transfer.js";
|
|
@@ -21,7 +20,7 @@ export function validateSpendingAndFeePayment(spendingToken, feeToken, bnSpendin
|
|
|
21
20
|
}))];
|
|
22
21
|
}
|
|
23
22
|
} else {
|
|
24
|
-
if (bnFromTokenBalance.
|
|
23
|
+
if (bnFromTokenBalance.lt(bnSpendingAmount.plus(_isNativeToken(spendingToken) ? '0' : _getTokenMinAmount(spendingToken)))) {
|
|
25
24
|
return [new TransactionError(BasicTxErrorType.NOT_ENOUGH_BALANCE, t('bg.core.validation.insufficientSpendingTokenBalance', {
|
|
26
25
|
replace: {
|
|
27
26
|
spendingTokenSymbol: spendingToken.symbol
|
|
@@ -8,5 +8,7 @@ export declare function _isMythosFromHydrationToMythos(originChainInfo: _ChainIn
|
|
|
8
8
|
export declare function _isPolygonBridgeXcm(originChainInfo: _ChainInfo, destChainInfo: _ChainInfo): boolean;
|
|
9
9
|
export declare function _isPosBridgeXcm(originChainInfo: _ChainInfo, destChainInfo: _ChainInfo): boolean;
|
|
10
10
|
export declare function _isAcrossBridgeXcm(originChainInfo: _ChainInfo, destChainInfo: _ChainInfo): boolean;
|
|
11
|
+
export declare function _isBittensorToSubtensorEvmBridge(originChainInfo: _ChainInfo, destChainInfo: _ChainInfo): boolean;
|
|
12
|
+
export declare function _isSubtensorEvmtoBittensorBridge(originChainInfo: _ChainInfo, destChainInfo: _ChainInfo): boolean;
|
|
11
13
|
export declare function _isAssetHubBridgeXcm(originChainInfo: _ChainInfo, destChainInfo: _ChainInfo): boolean;
|
|
12
14
|
export declare function _adaptX1Interior(_assetIdentifier: Record<string, any>, version: number): Record<string, any>;
|
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
import { COMMON_CHAIN_SLUGS } from '@subwallet/chain-list';
|
|
5
5
|
import { _isAcrossChainBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/acrossBridge';
|
|
6
6
|
import { isAvailChainBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/availBridge';
|
|
7
|
+
import { _isBittensorToSubtensorBridge, _isSubtensorToBittensorBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/bittensorBridge/nativeTokenBridge';
|
|
7
8
|
import { _isPolygonChainBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/polygonBridge';
|
|
8
9
|
import { _isPosChainBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/posBridge';
|
|
9
10
|
import { _getSubstrateRelayParent, _isPureEvmChain } from '@subwallet/extension-base/services/chain-service/utils';
|
|
10
11
|
export function _isXcmTransferUnstable(originChainInfo, destChainInfo, assetSlug) {
|
|
11
|
-
return !_isXcmWithinSameConsensus(originChainInfo, destChainInfo) && !_isAssetHubBridgeXcm || _isMythosFromHydrationToMythos(originChainInfo, destChainInfo, assetSlug) || _isPolygonBridgeXcm(originChainInfo, destChainInfo) || _isPosBridgeXcm(originChainInfo, destChainInfo);
|
|
12
|
+
return !_isBittensorToSubtensorEvmBridge(originChainInfo, destChainInfo) && !_isSubtensorEvmtoBittensorBridge(originChainInfo, destChainInfo) && !_isXcmWithinSameConsensus(originChainInfo, destChainInfo) && !_isAssetHubBridgeXcm(originChainInfo, destChainInfo) || _isMythosFromHydrationToMythos(originChainInfo, destChainInfo, assetSlug) || _isPolygonBridgeXcm(originChainInfo, destChainInfo) || _isPosBridgeXcm(originChainInfo, destChainInfo);
|
|
12
13
|
}
|
|
13
14
|
function getDefaultUnstableWarning() {
|
|
14
15
|
return 'Cross-chain transfer of this token is not recommended as it is in beta and incurs a large transaction fee. Continue at your own risk';
|
|
@@ -81,6 +82,12 @@ export function _isPosBridgeXcm(originChainInfo, destChainInfo) {
|
|
|
81
82
|
export function _isAcrossBridgeXcm(originChainInfo, destChainInfo) {
|
|
82
83
|
return _isAcrossChainBridge(originChainInfo.slug, destChainInfo.slug);
|
|
83
84
|
}
|
|
85
|
+
export function _isBittensorToSubtensorEvmBridge(originChainInfo, destChainInfo) {
|
|
86
|
+
return _isBittensorToSubtensorBridge(originChainInfo.slug, destChainInfo.slug);
|
|
87
|
+
}
|
|
88
|
+
export function _isSubtensorEvmtoBittensorBridge(originChainInfo, destChainInfo) {
|
|
89
|
+
return _isSubtensorToBittensorBridge(originChainInfo.slug, destChainInfo.slug);
|
|
90
|
+
}
|
|
84
91
|
export function _isAssetHubBridgeXcm(originChainInfo, destChainInfo) {
|
|
85
92
|
return originChainInfo.slug === 'statemint' && destChainInfo.slug === 'statemine' || originChainInfo.slug === 'statemine' && destChainInfo.slug === 'statemint';
|
|
86
93
|
}
|
|
@@ -297,6 +297,9 @@ export default class KoniExtension {
|
|
|
297
297
|
private subscribeBuyTokens;
|
|
298
298
|
private subscribeBuyServices;
|
|
299
299
|
private subscribeSwapPairs;
|
|
300
|
+
/**
|
|
301
|
+
* @deprecated Use function `handleSwapRequestV2` instead.
|
|
302
|
+
*/
|
|
300
303
|
private handleSwapRequest;
|
|
301
304
|
private handleSwapRequestV2;
|
|
302
305
|
private getLatestSwapQuote;
|
|
@@ -32,9 +32,10 @@ import { createCardanoTransaction } from '@subwallet/extension-base/services/bal
|
|
|
32
32
|
import { getERC20TransactionObject, getERC721Transaction, getEVMTransactionObject, getPSP34TransferExtrinsic } from '@subwallet/extension-base/services/balance-service/transfer/smart-contract';
|
|
33
33
|
import { createSubstrateExtrinsic } from '@subwallet/extension-base/services/balance-service/transfer/token';
|
|
34
34
|
import { createTonTransaction } from '@subwallet/extension-base/services/balance-service/transfer/ton-transfer';
|
|
35
|
-
import { createAcrossBridgeExtrinsic, createAvailBridgeExtrinsicFromAvail, createAvailBridgeTxFromEth, createPolygonBridgeExtrinsic, createSnowBridgeExtrinsic, createXcmExtrinsicV2, dryRunXcmExtrinsicV2 } from '@subwallet/extension-base/services/balance-service/transfer/xcm';
|
|
35
|
+
import { createAcrossBridgeExtrinsic, createAvailBridgeExtrinsicFromAvail, createAvailBridgeTxFromEth, createBittensorToSubtensorEvmExtrinsic, createPolygonBridgeExtrinsic, createSnowBridgeExtrinsic, createSubtensorEvmToBittensorExtrinsic, createXcmExtrinsicV2, dryRunXcmExtrinsicV2 } from '@subwallet/extension-base/services/balance-service/transfer/xcm';
|
|
36
36
|
import { _isAcrossChainBridge, getAcrossQuote } from '@subwallet/extension-base/services/balance-service/transfer/xcm/acrossBridge';
|
|
37
37
|
import { getClaimTxOnAvail, getClaimTxOnEthereum, isAvailChainBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/availBridge';
|
|
38
|
+
import { _isBittensorToSubtensorBridge, _isSubtensorToBittensorBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/bittensorBridge/nativeTokenBridge';
|
|
38
39
|
import { _isPolygonChainBridge, getClaimPolygonBridge, isClaimedPolygonBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/polygonBridge';
|
|
39
40
|
import { _isPosChainBridge, getClaimPosBridge } from '@subwallet/extension-base/services/balance-service/transfer/xcm/posBridge';
|
|
40
41
|
import { estimateXcmFee } from '@subwallet/extension-base/services/balance-service/transfer/xcm/utils';
|
|
@@ -961,7 +962,7 @@ export default class KoniExtension {
|
|
|
961
962
|
this.#koniState.eventService.emit('asset.updateState', params.tokenSlug);
|
|
962
963
|
return true;
|
|
963
964
|
} catch (e) {
|
|
964
|
-
console.error(e);
|
|
965
|
+
console.error('[updateAssetSetting] Error:', e);
|
|
965
966
|
return false;
|
|
966
967
|
}
|
|
967
968
|
}
|
|
@@ -1259,6 +1260,7 @@ export default class KoniExtension {
|
|
|
1259
1260
|
feeCustom,
|
|
1260
1261
|
feeOption,
|
|
1261
1262
|
from,
|
|
1263
|
+
metadata,
|
|
1262
1264
|
to,
|
|
1263
1265
|
tokenPayFeeSlug,
|
|
1264
1266
|
tokenSlug,
|
|
@@ -1399,7 +1401,8 @@ export default class KoniExtension {
|
|
|
1399
1401
|
networkKey: chain,
|
|
1400
1402
|
tokenInfo: transferTokenInfo,
|
|
1401
1403
|
to: to,
|
|
1402
|
-
substrateApi
|
|
1404
|
+
substrateApi,
|
|
1405
|
+
metadata
|
|
1403
1406
|
});
|
|
1404
1407
|
if (_SUPPORT_TOKEN_PAY_FEE_GROUP.hydration.includes(chain)) {
|
|
1405
1408
|
var _this$koniState$chain, _substrateApi$api$que;
|
|
@@ -1526,11 +1529,18 @@ export default class KoniExtension {
|
|
|
1526
1529
|
const isPolygonBridgeTransfer = _isPolygonChainBridge(originNetworkKey, destinationNetworkKey);
|
|
1527
1530
|
const isPosBridgeTransfer = _isPosChainBridge(originNetworkKey, destinationNetworkKey);
|
|
1528
1531
|
const isAcrossBridgeTransfer = _isAcrossChainBridge(originNetworkKey, destinationNetworkKey);
|
|
1532
|
+
const isBittensorBridgeTransfer = _isBittensorToSubtensorBridge(originNetworkKey, destinationNetworkKey);
|
|
1533
|
+
const isSubtensorEvmBridgeTransfer = _isSubtensorToBittensorBridge(originNetworkKey, destinationNetworkKey);
|
|
1529
1534
|
const extrinsicType = ExtrinsicType.TRANSFER_XCM;
|
|
1530
|
-
const
|
|
1535
|
+
const isSubstrateParaspellXcm = !(isAvailBridgeFromEvm || isAvailBridgeFromAvail || isSnowBridgeEvmTransfer || isPolygonBridgeTransfer || isPosBridgeTransfer || isAcrossBridgeTransfer || isBittensorBridgeTransfer || isSubtensorEvmBridgeTransfer);
|
|
1531
1536
|
const isTransferNative = this.#koniState.getNativeTokenInfo(originNetworkKey).slug === tokenSlug;
|
|
1532
1537
|
const isTransferLocalTokenAndPayThatTokenAsFee = !isTransferNative && tokenSlug === tokenPayFeeSlug;
|
|
1533
1538
|
let xcmFeeDryRun;
|
|
1539
|
+
const xcmDestinationFee = {
|
|
1540
|
+
symbol: (destinationTokenInfo === null || destinationTokenInfo === void 0 ? void 0 : destinationTokenInfo.symbol) || '',
|
|
1541
|
+
decimals: (destinationTokenInfo === null || destinationTokenInfo === void 0 ? void 0 : destinationTokenInfo.decimals) || 0,
|
|
1542
|
+
value: '0'
|
|
1543
|
+
};
|
|
1534
1544
|
let additionalValidator;
|
|
1535
1545
|
let eventsHandler;
|
|
1536
1546
|
if (fromKeyPair && destinationTokenInfo) {
|
|
@@ -1541,6 +1551,9 @@ export default class KoniExtension {
|
|
|
1541
1551
|
if (isPosBridgeTransfer || isPolygonBridgeTransfer) {
|
|
1542
1552
|
funcCreateExtrinsic = createPolygonBridgeExtrinsic;
|
|
1543
1553
|
type = 'evm';
|
|
1554
|
+
} else if (isSubtensorEvmBridgeTransfer) {
|
|
1555
|
+
funcCreateExtrinsic = createSubtensorEvmToBittensorExtrinsic;
|
|
1556
|
+
type = 'evm';
|
|
1544
1557
|
} else if (isAcrossBridgeTransfer) {
|
|
1545
1558
|
funcCreateExtrinsic = createAcrossBridgeExtrinsic;
|
|
1546
1559
|
type = 'evm';
|
|
@@ -1550,6 +1563,9 @@ export default class KoniExtension {
|
|
|
1550
1563
|
} else if (isAvailBridgeFromEvm) {
|
|
1551
1564
|
funcCreateExtrinsic = createAvailBridgeTxFromEth;
|
|
1552
1565
|
type = 'evm';
|
|
1566
|
+
} else if (isBittensorBridgeTransfer) {
|
|
1567
|
+
funcCreateExtrinsic = createBittensorToSubtensorEvmExtrinsic;
|
|
1568
|
+
type = 'substrate';
|
|
1553
1569
|
} else if (isAvailBridgeFromAvail) {
|
|
1554
1570
|
funcCreateExtrinsic = createAvailBridgeExtrinsicFromAvail;
|
|
1555
1571
|
type = 'substrate';
|
|
@@ -1570,10 +1586,11 @@ export default class KoniExtension {
|
|
|
1570
1586
|
evmApi,
|
|
1571
1587
|
feeCustom,
|
|
1572
1588
|
feeOption,
|
|
1573
|
-
feeInfo
|
|
1589
|
+
feeInfo,
|
|
1590
|
+
transferAll
|
|
1574
1591
|
};
|
|
1575
1592
|
extrinsic = await funcCreateExtrinsic(params);
|
|
1576
|
-
if (
|
|
1593
|
+
if (isSubstrateParaspellXcm) {
|
|
1577
1594
|
const xcmFeeInfo = await estimateXcmFee({
|
|
1578
1595
|
fromChainInfo: params.originChain,
|
|
1579
1596
|
fromTokenInfo: params.originTokenInfo,
|
|
@@ -1582,7 +1599,11 @@ export default class KoniExtension {
|
|
|
1582
1599
|
sender: params.sender,
|
|
1583
1600
|
value: params.sendingValue
|
|
1584
1601
|
});
|
|
1602
|
+
|
|
1603
|
+
// todo: refactor name
|
|
1604
|
+
// todo: check to use full interface to has full AmountData, include symbol, decimal
|
|
1585
1605
|
xcmFeeDryRun = (xcmFeeInfo === null || xcmFeeInfo === void 0 ? void 0 : xcmFeeInfo.origin.fee) || '0';
|
|
1606
|
+
xcmDestinationFee.value = (xcmFeeInfo === null || xcmFeeInfo === void 0 ? void 0 : xcmFeeInfo.destination.fee) || '0';
|
|
1586
1607
|
}
|
|
1587
1608
|
if (isAcrossBridgeTransfer) {
|
|
1588
1609
|
const data = await getAcrossQuote(params);
|
|
@@ -1650,7 +1671,7 @@ export default class KoniExtension {
|
|
|
1650
1671
|
warning.length && inputTransaction.warnings.push(...warning);
|
|
1651
1672
|
error.length && inputTransaction.errors.push(...error);
|
|
1652
1673
|
}
|
|
1653
|
-
if (
|
|
1674
|
+
if (isSubstrateParaspellXcm) {
|
|
1654
1675
|
const isDryRunSuccess = await dryRunXcmExtrinsicV2(params, false);
|
|
1655
1676
|
if (!isDryRunSuccess) {
|
|
1656
1677
|
inputTransaction.errors.push(new TransactionError(BasicTxErrorType.UNABLE_TO_SEND, 'Unable to perform transaction. Select another token or destination chain and try again'));
|
|
@@ -1688,7 +1709,7 @@ export default class KoniExtension {
|
|
|
1688
1709
|
transaction: extrinsic,
|
|
1689
1710
|
data: inputData,
|
|
1690
1711
|
extrinsicType,
|
|
1691
|
-
chainType: !isSnowBridgeEvmTransfer && !isAvailBridgeFromEvm && !isPolygonBridgeTransfer && !isPosBridgeTransfer && !isAcrossBridgeTransfer ? ChainType.SUBSTRATE : ChainType.EVM,
|
|
1712
|
+
chainType: !isSnowBridgeEvmTransfer && !isAvailBridgeFromEvm && !isPolygonBridgeTransfer && !isPosBridgeTransfer && !isAcrossBridgeTransfer && !isSubtensorEvmBridgeTransfer ? ChainType.SUBSTRATE : ChainType.EVM,
|
|
1692
1713
|
transferNativeAmount: _isNativeToken(originTokenInfo) ? value : '0',
|
|
1693
1714
|
ignoreWarnings,
|
|
1694
1715
|
tokenPayFeeSlug,
|
|
@@ -1696,6 +1717,7 @@ export default class KoniExtension {
|
|
|
1696
1717
|
isTransferLocalTokenAndPayThatTokenAsFee,
|
|
1697
1718
|
isPassConfirmation,
|
|
1698
1719
|
xcmFeeDryRun,
|
|
1720
|
+
xcmDestinationFee,
|
|
1699
1721
|
errors,
|
|
1700
1722
|
additionalValidator: additionalValidator,
|
|
1701
1723
|
eventsHandler: eventsHandler
|
|
@@ -2159,6 +2181,7 @@ export default class KoniExtension {
|
|
|
2159
2181
|
destChain: _destChain,
|
|
2160
2182
|
feeCustom,
|
|
2161
2183
|
feeOption,
|
|
2184
|
+
metadata,
|
|
2162
2185
|
to,
|
|
2163
2186
|
token,
|
|
2164
2187
|
tokenPayFeeSlug,
|
|
@@ -2200,7 +2223,8 @@ export default class KoniExtension {
|
|
|
2200
2223
|
isTransferLocalTokenAndPayThatTokenAsFee,
|
|
2201
2224
|
isTransferNativeTokenAndPayLocalTokenAsFee,
|
|
2202
2225
|
nativeToken,
|
|
2203
|
-
transferAll
|
|
2226
|
+
transferAll,
|
|
2227
|
+
metadata
|
|
2204
2228
|
};
|
|
2205
2229
|
const subscription = combineLatest({
|
|
2206
2230
|
freeBalance: freeBalanceSubject,
|
|
@@ -4515,7 +4539,9 @@ export default class KoniExtension {
|
|
|
4515
4539
|
errorOnTimeOut,
|
|
4516
4540
|
...this.createPassConfirmationParams(isPassConfirmation),
|
|
4517
4541
|
eventsHandler,
|
|
4518
|
-
step
|
|
4542
|
+
step,
|
|
4543
|
+
xcmFeeDryRun: extrinsicType === ExtrinsicType.TRANSFER_XCM ? submitData.xcmStepFee : undefined,
|
|
4544
|
+
xcmDestinationFee: submitData.xcmDestinationFee
|
|
4519
4545
|
});
|
|
4520
4546
|
}
|
|
4521
4547
|
async handleYieldLeave(params) {
|
|
@@ -4895,6 +4921,10 @@ export default class KoniExtension {
|
|
|
4895
4921
|
ready = true;
|
|
4896
4922
|
return this.#koniState.swapService.getSwapPairs();
|
|
4897
4923
|
}
|
|
4924
|
+
|
|
4925
|
+
/**
|
|
4926
|
+
* @deprecated Use function `handleSwapRequestV2` instead.
|
|
4927
|
+
*/
|
|
4898
4928
|
async handleSwapRequest(request) {
|
|
4899
4929
|
// @ts-ignore
|
|
4900
4930
|
return Promise.resolve(null);
|
|
@@ -5817,6 +5847,8 @@ export default class KoniExtension {
|
|
|
5817
5847
|
return await this.reconnectChain(request);
|
|
5818
5848
|
case 'pri(chainService.disableChain)':
|
|
5819
5849
|
return await this.disableChain(request);
|
|
5850
|
+
case 'pri(chainService.disableAllChains)':
|
|
5851
|
+
return await this.#koniState.disableAllChains();
|
|
5820
5852
|
case 'pri(chainService.removeChain)':
|
|
5821
5853
|
return this.removeCustomChain(request);
|
|
5822
5854
|
case 'pri(chainService.validateCustomChain)':
|
|
@@ -196,6 +196,7 @@ export default class KoniState {
|
|
|
196
196
|
forceRemoveChain(networkKey: string): void;
|
|
197
197
|
private getDefaultNetworkKeys;
|
|
198
198
|
disableChain(chainSlug: string): Promise<boolean>;
|
|
199
|
+
disableAllChains(): Promise<boolean>;
|
|
199
200
|
enableChain(chainSlug: string, enableTokens?: boolean): Promise<boolean>;
|
|
200
201
|
enableChainWithPriorityAssets(chainSlug: string, enableTokens?: boolean): Promise<boolean>;
|
|
201
202
|
resetDefaultChains(): boolean;
|
|
@@ -749,6 +749,26 @@ export default class KoniState {
|
|
|
749
749
|
}
|
|
750
750
|
return this.chainService.disableChain(chainSlug);
|
|
751
751
|
}
|
|
752
|
+
async disableAllChains() {
|
|
753
|
+
const chainStateMap = this.chainService.getChainStateMap();
|
|
754
|
+
const activeChainSlugs = Object.keys(chainStateMap).filter(slug => chainStateMap[slug].active);
|
|
755
|
+
const failedChainSlugs = [];
|
|
756
|
+
for (const chainSlug of activeChainSlugs) {
|
|
757
|
+
try {
|
|
758
|
+
const isDisabled = await this.disableChain(chainSlug);
|
|
759
|
+
if (!isDisabled) {
|
|
760
|
+
failedChainSlugs.push(chainSlug);
|
|
761
|
+
}
|
|
762
|
+
} catch (error) {
|
|
763
|
+
failedChainSlugs.push(chainSlug);
|
|
764
|
+
this.logger.error(`Failed to disable chain ${chainSlug}`, error);
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
if (failedChainSlugs.length) {
|
|
768
|
+
throw new Error('Unable to turn off all networks. Please try again later');
|
|
769
|
+
}
|
|
770
|
+
return true;
|
|
771
|
+
}
|
|
752
772
|
async enableChain(chainSlug, enableTokens = true) {
|
|
753
773
|
if (enableTokens) {
|
|
754
774
|
await this.chainService.updateAssetSettingByChain(chainSlug, true);
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./cjs/detectPackage.js"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"version": "1.3.
|
|
20
|
+
"version": "1.3.79-1",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -194,11 +194,6 @@
|
|
|
194
194
|
"require": "./cjs/core/logic-validation/request.js",
|
|
195
195
|
"default": "./core/logic-validation/request.js"
|
|
196
196
|
},
|
|
197
|
-
"./core/logic-validation/swap": {
|
|
198
|
-
"types": "./core/logic-validation/swap.d.ts",
|
|
199
|
-
"require": "./cjs/core/logic-validation/swap.js",
|
|
200
|
-
"default": "./core/logic-validation/swap.js"
|
|
201
|
-
},
|
|
202
197
|
"./core/logic-validation/transfer": {
|
|
203
198
|
"types": "./core/logic-validation/transfer.d.ts",
|
|
204
199
|
"require": "./cjs/core/logic-validation/transfer.js",
|
|
@@ -804,6 +799,21 @@
|
|
|
804
799
|
"require": "./cjs/services/balance-service/transfer/xcm/availBridge.js",
|
|
805
800
|
"default": "./services/balance-service/transfer/xcm/availBridge.js"
|
|
806
801
|
},
|
|
802
|
+
"./services/balance-service/transfer/xcm/bittensorBridge": {
|
|
803
|
+
"types": "./services/balance-service/transfer/xcm/bittensorBridge/index.d.ts",
|
|
804
|
+
"require": "./cjs/services/balance-service/transfer/xcm/bittensorBridge/index.js",
|
|
805
|
+
"default": "./services/balance-service/transfer/xcm/bittensorBridge/index.js"
|
|
806
|
+
},
|
|
807
|
+
"./services/balance-service/transfer/xcm/bittensorBridge/nativeTokenBridge": {
|
|
808
|
+
"types": "./services/balance-service/transfer/xcm/bittensorBridge/nativeTokenBridge.d.ts",
|
|
809
|
+
"require": "./cjs/services/balance-service/transfer/xcm/bittensorBridge/nativeTokenBridge.js",
|
|
810
|
+
"default": "./services/balance-service/transfer/xcm/bittensorBridge/nativeTokenBridge.js"
|
|
811
|
+
},
|
|
812
|
+
"./services/balance-service/transfer/xcm/bittensorBridge/utils": {
|
|
813
|
+
"types": "./services/balance-service/transfer/xcm/bittensorBridge/utils.d.ts",
|
|
814
|
+
"require": "./cjs/services/balance-service/transfer/xcm/bittensorBridge/utils.js",
|
|
815
|
+
"default": "./services/balance-service/transfer/xcm/bittensorBridge/utils.js"
|
|
816
|
+
},
|
|
807
817
|
"./services/balance-service/transfer/xcm/polygonBridge": {
|
|
808
818
|
"types": "./services/balance-service/transfer/xcm/polygonBridge.d.ts",
|
|
809
819
|
"require": "./cjs/services/balance-service/transfer/xcm/polygonBridge.js",
|
|
@@ -2091,6 +2101,11 @@
|
|
|
2091
2101
|
"require": "./cjs/services/swap-service/handler/base-handler.js",
|
|
2092
2102
|
"default": "./services/swap-service/handler/base-handler.js"
|
|
2093
2103
|
},
|
|
2104
|
+
"./services/swap-service/handler/bittensor-handler": {
|
|
2105
|
+
"types": "./services/swap-service/handler/bittensor-handler.d.ts",
|
|
2106
|
+
"require": "./cjs/services/swap-service/handler/bittensor-handler.js",
|
|
2107
|
+
"default": "./services/swap-service/handler/bittensor-handler.js"
|
|
2108
|
+
},
|
|
2094
2109
|
"./services/swap-service/handler/chainflip-handler": {
|
|
2095
2110
|
"types": "./services/swap-service/handler/chainflip-handler.d.ts",
|
|
2096
2111
|
"require": "./cjs/services/swap-service/handler/chainflip-handler.js",
|
|
@@ -3008,11 +3023,11 @@
|
|
|
3008
3023
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
3009
3024
|
"@substrate/connect": "^0.8.9",
|
|
3010
3025
|
"@subwallet-monorepos/subwallet-services-sdk": "0.1.16",
|
|
3011
|
-
"@subwallet/chain-list": "0.2.
|
|
3012
|
-
"@subwallet/extension-base": "^1.3.
|
|
3013
|
-
"@subwallet/extension-chains": "^1.3.
|
|
3014
|
-
"@subwallet/extension-dapp": "^1.3.
|
|
3015
|
-
"@subwallet/extension-inject": "^1.3.
|
|
3026
|
+
"@subwallet/chain-list": "0.2.127",
|
|
3027
|
+
"@subwallet/extension-base": "^1.3.79-1",
|
|
3028
|
+
"@subwallet/extension-chains": "^1.3.79-1",
|
|
3029
|
+
"@subwallet/extension-dapp": "^1.3.79-1",
|
|
3030
|
+
"@subwallet/extension-inject": "^1.3.79-1",
|
|
3016
3031
|
"@subwallet/keyring": "^0.1.14",
|
|
3017
3032
|
"@subwallet/ui-keyring": "^0.1.14",
|
|
3018
3033
|
"@ton/core": "^0.56.3",
|