@subwallet/extension-base 1.2.8-1 → 1.2.9-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 +7 -3
- package/background/KoniTypes.js +1 -1
- package/cjs/background/KoniTypes.js +1 -1
- package/cjs/core/logic-validation/transfer.js +22 -2
- package/cjs/core/substrate/foreign-asset-pallet.js +16 -0
- package/cjs/core/substrate/xcm-parser.js +26 -4
- package/cjs/koni/api/contract-handler/evm/web3.js +58 -0
- package/cjs/{services/chain-service/helper → koni/api/contract-handler/utils}/index.js +19 -2
- package/cjs/koni/api/contract-handler/wasm/index.js +49 -0
- package/cjs/koni/api/nft/evm_nft/index.js +6 -6
- package/cjs/koni/api/nft/wasm_nft/index.js +16 -16
- package/cjs/koni/api/yield/helper/utils.js +1 -22
- package/cjs/koni/background/handlers/Extension.js +128 -64
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/helpers/index.js +11 -0
- package/cjs/services/balance-service/helpers/process.js +50 -0
- package/cjs/services/balance-service/helpers/subscribe/evm.js +11 -3
- package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +10 -24
- package/cjs/services/balance-service/index.js +20 -0
- package/cjs/{koni/api/tokens/evm/transfer.js → services/balance-service/transfer/smart-contract.js} +33 -38
- package/cjs/{koni/api/dotsama/transfer.js → services/balance-service/transfer/token.js} +3 -3
- package/cjs/{koni/api → services/balance-service/transfer}/xcm/index.js +26 -6
- package/cjs/{koni/api → services/balance-service/transfer}/xcm/polkadotXcm.js +2 -2
- package/cjs/services/balance-service/transfer/xcm/snowBridge.js +60 -0
- package/cjs/{koni/api → services/balance-service/transfer}/xcm/xTokens.js +1 -1
- package/cjs/{koni/api → services/balance-service/transfer}/xcm/xcmPallet.js +1 -1
- package/cjs/services/chain-service/handler/EvmChainHandler.js +3 -3
- package/cjs/services/chain-service/handler/SubstrateChainHandler.js +4 -4
- package/cjs/services/chain-service/health-check/utils/asset-info.js +18 -18
- package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +16 -35
- package/cjs/services/earning-service/handlers/special.js +1 -1
- package/cjs/services/swap-service/handler/base-handler.js +3 -2
- package/cjs/services/swap-service/handler/chainflip-handler.js +10 -9
- package/cjs/services/swap-service/handler/hydradx-handler.js +12 -11
- package/cjs/services/swap-service/index.js +3 -2
- package/cjs/services/swap-service/utils.js +1 -13
- package/cjs/services/transaction-service/index.js +2 -2
- package/cjs/types/service-base.js +30 -1
- package/cjs/types/swap/index.js +0 -4
- package/cjs/utils/eth/parseTransaction/index.js +10 -10
- package/core/logic-validation/transfer.d.ts +1 -1
- package/core/logic-validation/transfer.js +22 -3
- package/core/substrate/foreign-asset-pallet.d.ts +8 -0
- package/core/substrate/foreign-asset-pallet.js +9 -0
- package/core/substrate/xcm-parser.d.ts +3 -1
- package/core/substrate/xcm-parser.js +25 -5
- package/koni/api/contract-handler/evm/web3.d.ts +8 -0
- package/koni/api/contract-handler/evm/web3.js +45 -0
- package/{services/chain-service/helper → koni/api/contract-handler/utils}/index.d.ts +4 -0
- package/{services/chain-service/helper → koni/api/contract-handler/utils}/index.js +15 -1
- package/koni/api/contract-handler/utils/snowbridge_gateway_abi.json +1122 -0
- package/koni/api/{tokens → contract-handler}/wasm/index.d.ts +0 -2
- package/koni/api/{tokens → contract-handler}/wasm/index.js +1 -25
- package/koni/api/nft/evm_nft/index.js +1 -1
- package/koni/api/nft/wasm_nft/index.js +2 -2
- package/koni/api/yield/helper/utils.d.ts +1 -5
- package/koni/api/yield/helper/utils.js +0 -16
- package/koni/background/handlers/Extension.d.ts +2 -0
- package/koni/background/handlers/Extension.js +82 -18
- package/package.json +85 -79
- package/packageInfo.js +1 -1
- package/services/balance-service/helpers/index.d.ts +1 -0
- package/services/balance-service/helpers/index.js +2 -1
- package/services/balance-service/helpers/process.d.ts +13 -0
- package/services/balance-service/helpers/process.js +43 -0
- package/services/balance-service/helpers/subscribe/evm.js +11 -3
- package/services/balance-service/helpers/subscribe/substrate/index.js +11 -25
- package/services/balance-service/index.d.ts +3 -0
- package/services/balance-service/index.js +21 -1
- package/services/balance-service/transfer/smart-contract.d.ts +7 -0
- package/{koni/api/tokens/evm/transfer.js → services/balance-service/transfer/smart-contract.js} +28 -31
- package/{koni/api/dotsama/transfer.js → services/balance-service/transfer/token.js} +4 -4
- package/{koni/api → services/balance-service/transfer}/xcm/index.d.ts +9 -3
- package/{koni/api → services/balance-service/transfer}/xcm/index.js +21 -3
- package/{koni/api → services/balance-service/transfer}/xcm/polkadotXcm.js +3 -3
- package/services/balance-service/transfer/xcm/snowBridge.d.ts +4 -0
- package/services/balance-service/transfer/xcm/snowBridge.js +54 -0
- package/{koni/api → services/balance-service/transfer}/xcm/xTokens.js +1 -1
- package/{koni/api → services/balance-service/transfer}/xcm/xcmPallet.js +1 -1
- package/services/chain-service/handler/EvmChainHandler.js +1 -1
- package/services/chain-service/handler/SubstrateChainHandler.js +2 -2
- package/services/chain-service/health-check/utils/asset-info.js +3 -3
- package/services/earning-service/handlers/liquid-staking/stella-swap.js +16 -35
- package/services/earning-service/handlers/special.js +1 -1
- package/services/swap-service/handler/base-handler.d.ts +5 -5
- package/services/swap-service/handler/base-handler.js +4 -3
- package/services/swap-service/handler/chainflip-handler.d.ts +4 -4
- package/services/swap-service/handler/chainflip-handler.js +7 -6
- package/services/swap-service/handler/hydradx-handler.d.ts +6 -6
- package/services/swap-service/handler/hydradx-handler.js +12 -11
- package/services/swap-service/index.d.ts +3 -2
- package/services/swap-service/index.js +4 -3
- package/services/swap-service/utils.d.ts +1 -3
- package/services/swap-service/utils.js +1 -11
- package/services/transaction-service/index.js +2 -2
- package/types/service-base.d.ts +31 -3
- package/types/service-base.js +23 -1
- package/types/swap/index.d.ts +8 -30
- package/types/swap/index.js +0 -4
- package/types/yield/actions/join/submit.d.ts +7 -4
- package/utils/eth/parseTransaction/index.js +1 -1
- package/cjs/koni/api/tokens/evm/balance.js +0 -18
- package/cjs/koni/api/tokens/evm/web3.js +0 -17
- package/cjs/koni/api/tokens/index.js +0 -17
- package/cjs/koni/api/tokens/wasm/index.js +0 -74
- package/koni/api/tokens/evm/balance.d.ts +0 -2
- package/koni/api/tokens/evm/balance.js +0 -12
- package/koni/api/tokens/evm/transfer.d.ts +0 -17
- package/koni/api/tokens/evm/web3.d.ts +0 -3
- package/koni/api/tokens/evm/web3.js +0 -9
- package/koni/api/tokens/index.d.ts +0 -1
- package/koni/api/tokens/index.js +0 -11
- /package/cjs/koni/api/{tokens → contract-handler}/wasm/utils.js +0 -0
- /package/cjs/{koni/api → services/balance-service/transfer}/xcm/utils.js +0 -0
- /package/{services/chain-service/helper → koni/api/contract-handler/utils}/azero_domain_registry_abi.json +0 -0
- /package/{services/chain-service/helper → koni/api/contract-handler/utils}/erc20_abi.json +0 -0
- /package/{services/chain-service/helper → koni/api/contract-handler/utils}/erc721_abi.json +0 -0
- /package/{services/chain-service/helper → koni/api/contract-handler/utils}/neuroguns_psp34_abi.json +0 -0
- /package/{services/chain-service/helper → koni/api/contract-handler/utils}/pink_psp34_abi.json +0 -0
- /package/{services/chain-service/helper → koni/api/contract-handler/utils}/psp22_abi.json +0 -0
- /package/{services/chain-service/helper → koni/api/contract-handler/utils}/psp34_abi.json +0 -0
- /package/{services/chain-service/helper → koni/api/contract-handler/utils}/test_erc721_abi.json +0 -0
- /package/koni/api/{tokens → contract-handler}/wasm/utils.d.ts +0 -0
- /package/koni/api/{tokens → contract-handler}/wasm/utils.js +0 -0
- /package/{koni/api/dotsama/transfer.d.ts → services/balance-service/transfer/token.d.ts} +0 -0
- /package/{koni/api → services/balance-service/transfer}/xcm/polkadotXcm.d.ts +0 -0
- /package/{koni/api → services/balance-service/transfer}/xcm/utils.d.ts +0 -0
- /package/{koni/api → services/balance-service/transfer}/xcm/utils.js +0 -0
- /package/{koni/api → services/balance-service/transfer}/xcm/xTokens.d.ts +0 -0
- /package/{koni/api → services/balance-service/transfer}/xcm/xcmPallet.d.ts +0 -0
|
@@ -2,13 +2,13 @@ import { SwapError } from '@subwallet/extension-base/background/errors/SwapError
|
|
|
2
2
|
import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError';
|
|
3
3
|
import { BalanceService } from '@subwallet/extension-base/services/balance-service';
|
|
4
4
|
import { ChainService } from '@subwallet/extension-base/services/chain-service';
|
|
5
|
-
import { BaseStepDetail } from '@subwallet/extension-base/types/service-base';
|
|
6
|
-
import { GenSwapStepFunc,
|
|
5
|
+
import { BaseStepDetail, CommonOptimalPath, CommonStepFeeInfo } from '@subwallet/extension-base/types/service-base';
|
|
6
|
+
import { GenSwapStepFunc, OptimalSwapPathParams, SwapEarlyValidation, SwapProvider, SwapProviderId, SwapQuote, SwapRequest, SwapSubmitParams, SwapSubmitStepData, ValidateSwapProcessParams } from '@subwallet/extension-base/types/swap';
|
|
7
7
|
export interface SwapBaseInterface {
|
|
8
8
|
providerSlug: SwapProviderId;
|
|
9
9
|
getSwapQuote: (request: SwapRequest) => Promise<SwapQuote | SwapError>;
|
|
10
|
-
generateOptimalProcess: (params: OptimalSwapPathParams) => Promise<
|
|
11
|
-
getSubmitStep: (params: OptimalSwapPathParams) => Promise<[BaseStepDetail,
|
|
10
|
+
generateOptimalProcess: (params: OptimalSwapPathParams) => Promise<CommonOptimalPath>;
|
|
11
|
+
getSubmitStep: (params: OptimalSwapPathParams) => Promise<[BaseStepDetail, CommonStepFeeInfo] | undefined>;
|
|
12
12
|
validateSwapRequest: (request: SwapRequest) => Promise<SwapEarlyValidation>;
|
|
13
13
|
validateSwapProcess: (params: ValidateSwapProcessParams) => Promise<TransactionError[]>;
|
|
14
14
|
handleSwapProcess: (params: SwapSubmitParams) => Promise<SwapSubmitStepData>;
|
|
@@ -28,7 +28,7 @@ export declare class SwapBaseHandler {
|
|
|
28
28
|
chainService: ChainService;
|
|
29
29
|
balanceService: BalanceService;
|
|
30
30
|
constructor({ balanceService, chainService, providerName, providerSlug }: SwapBaseHandlerInitParams);
|
|
31
|
-
generateOptimalProcess(params: OptimalSwapPathParams, genStepFuncList: GenSwapStepFunc[]): Promise<
|
|
31
|
+
generateOptimalProcess(params: OptimalSwapPathParams, genStepFuncList: GenSwapStepFunc[]): Promise<CommonOptimalPath>;
|
|
32
32
|
validateXcmStep(params: ValidateSwapProcessParams, stepIndex: number): Promise<TransactionError[]>;
|
|
33
33
|
validateTokenApproveStep(params: ValidateSwapProcessParams, stepIndex: number): Promise<TransactionError[]>;
|
|
34
34
|
validateSetFeeTokenStep(params: ValidateSwapProcessParams, stepIndex: number): Promise<TransactionError[]>;
|
|
@@ -5,7 +5,8 @@ import { TransactionError } from '@subwallet/extension-base/background/errors/Tr
|
|
|
5
5
|
import { BasicTxErrorType } from '@subwallet/extension-base/background/KoniTypes';
|
|
6
6
|
import { _validateBalanceToSwap, _validateSwapRecipient } from '@subwallet/extension-base/core/logic-validation/swap';
|
|
7
7
|
import { _isNativeToken } from '@subwallet/extension-base/services/chain-service/utils';
|
|
8
|
-
import {
|
|
8
|
+
import { getSwapAlternativeAsset } from '@subwallet/extension-base/services/swap-service/utils';
|
|
9
|
+
import { DEFAULT_FIRST_STEP, MOCK_STEP_FEE } from '@subwallet/extension-base/types/service-base';
|
|
9
10
|
import { SwapErrorType, SwapFeeType } from '@subwallet/extension-base/types/swap';
|
|
10
11
|
import { formatNumber } from '@subwallet/extension-base/utils';
|
|
11
12
|
import BigNumber from 'bignumber.js';
|
|
@@ -26,8 +27,8 @@ export class SwapBaseHandler {
|
|
|
26
27
|
// public abstract getSwapQuote(request: SwapRequest): Promise<SwapQuote | SwapError>;
|
|
27
28
|
async generateOptimalProcess(params, genStepFuncList) {
|
|
28
29
|
const result = {
|
|
29
|
-
totalFee: [
|
|
30
|
-
steps: [
|
|
30
|
+
totalFee: [MOCK_STEP_FEE],
|
|
31
|
+
steps: [DEFAULT_FIRST_STEP]
|
|
31
32
|
};
|
|
32
33
|
try {
|
|
33
34
|
for (const genStepFunc of genStepFuncList) {
|
|
@@ -4,8 +4,8 @@ import { TransactionError } from '@subwallet/extension-base/background/errors/Tr
|
|
|
4
4
|
import { BalanceService } from '@subwallet/extension-base/services/balance-service';
|
|
5
5
|
import { ChainService } from '@subwallet/extension-base/services/chain-service';
|
|
6
6
|
import { SwapBaseInterface } from '@subwallet/extension-base/services/swap-service/handler/base-handler';
|
|
7
|
-
import { BaseStepDetail } from '@subwallet/extension-base/types/service-base';
|
|
8
|
-
import {
|
|
7
|
+
import { BaseStepDetail, CommonOptimalPath, CommonStepFeeInfo } from '@subwallet/extension-base/types/service-base';
|
|
8
|
+
import { OptimalSwapPathParams, SwapEarlyValidation, SwapProviderId, SwapQuote, SwapRequest, SwapSubmitParams, SwapSubmitStepData, ValidateSwapProcessParams } from '@subwallet/extension-base/types/swap';
|
|
9
9
|
export declare class ChainflipSwapHandler implements SwapBaseInterface {
|
|
10
10
|
private swapSdk;
|
|
11
11
|
private readonly isTestnet;
|
|
@@ -26,6 +26,6 @@ export declare class ChainflipSwapHandler implements SwapBaseInterface {
|
|
|
26
26
|
validateSwapProcess(params: ValidateSwapProcessParams): Promise<TransactionError[]>;
|
|
27
27
|
handleSubmitStep(params: SwapSubmitParams): Promise<SwapSubmitStepData>;
|
|
28
28
|
handleSwapProcess(params: SwapSubmitParams): Promise<SwapSubmitStepData>;
|
|
29
|
-
getSubmitStep(params: OptimalSwapPathParams): Promise<[BaseStepDetail,
|
|
30
|
-
generateOptimalProcess(params: OptimalSwapPathParams): Promise<
|
|
29
|
+
getSubmitStep(params: OptimalSwapPathParams): Promise<[BaseStepDetail, CommonStepFeeInfo] | undefined>;
|
|
30
|
+
generateOptimalProcess(params: OptimalSwapPathParams): Promise<CommonOptimalPath>;
|
|
31
31
|
}
|
|
@@ -7,11 +7,12 @@ import { SwapError } from '@subwallet/extension-base/background/errors/SwapError
|
|
|
7
7
|
import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError';
|
|
8
8
|
import { BasicTxErrorType, ChainType, ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
|
|
9
9
|
import { _getChainflipEarlyValidationError } from '@subwallet/extension-base/core/logic-validation/swap';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
10
|
+
import { getERC20TransactionObject, getEVMTransactionObject } from '@subwallet/extension-base/services/balance-service/transfer/smart-contract';
|
|
11
|
+
import { createTransferExtrinsic } from '@subwallet/extension-base/services/balance-service/transfer/token';
|
|
12
12
|
import { _getAssetDecimals, _getChainNativeTokenSlug, _getContractAddressOfToken, _isNativeToken, _isSubstrateChain } from '@subwallet/extension-base/services/chain-service/utils';
|
|
13
13
|
import { SwapBaseHandler } from '@subwallet/extension-base/services/swap-service/handler/base-handler';
|
|
14
14
|
import { calculateSwapRate, CHAIN_FLIP_SUPPORTED_MAINNET_ASSET_MAPPING, CHAIN_FLIP_SUPPORTED_MAINNET_MAPPING, CHAIN_FLIP_SUPPORTED_TESTNET_ASSET_MAPPING, CHAIN_FLIP_SUPPORTED_TESTNET_MAPPING, SWAP_QUOTE_TIMEOUT_MAP } from '@subwallet/extension-base/services/swap-service/utils';
|
|
15
|
+
import { CommonStepType } from '@subwallet/extension-base/types/service-base';
|
|
15
16
|
import { SwapErrorType, SwapFeeType, SwapProviderId, SwapStepType } from '@subwallet/extension-base/types/swap';
|
|
16
17
|
import BigNumber from 'bignumber.js';
|
|
17
18
|
var ChainflipFeeType;
|
|
@@ -285,9 +286,9 @@ export class ChainflipSwapHandler {
|
|
|
285
286
|
for (const [index, step] of params.process.steps.entries()) {
|
|
286
287
|
const getErrors = async () => {
|
|
287
288
|
switch (step.type) {
|
|
288
|
-
case
|
|
289
|
+
case CommonStepType.DEFAULT:
|
|
289
290
|
return Promise.resolve([]);
|
|
290
|
-
case
|
|
291
|
+
case CommonStepType.TOKEN_APPROVAL:
|
|
291
292
|
return Promise.reject(new TransactionError(BasicTxErrorType.UNSUPPORTED));
|
|
292
293
|
default:
|
|
293
294
|
return this.swapBaseHandler.validateSwapStep(params, isXcmOk, index);
|
|
@@ -296,7 +297,7 @@ export class ChainflipSwapHandler {
|
|
|
296
297
|
const errors = await getErrors();
|
|
297
298
|
if (errors.length) {
|
|
298
299
|
return errors;
|
|
299
|
-
} else if (step.type ===
|
|
300
|
+
} else if (step.type === CommonStepType.XCM) {
|
|
300
301
|
isXcmOk = true;
|
|
301
302
|
}
|
|
302
303
|
}
|
|
@@ -377,7 +378,7 @@ export class ChainflipSwapHandler {
|
|
|
377
378
|
} = params;
|
|
378
379
|
const type = process.steps[currentStep].type;
|
|
379
380
|
switch (type) {
|
|
380
|
-
case
|
|
381
|
+
case CommonStepType.DEFAULT:
|
|
381
382
|
return Promise.reject(new TransactionError(BasicTxErrorType.UNSUPPORTED));
|
|
382
383
|
case SwapStepType.SWAP:
|
|
383
384
|
return this.handleSubmitStep(params);
|
|
@@ -3,8 +3,8 @@ import { TransactionError } from '@subwallet/extension-base/background/errors/Tr
|
|
|
3
3
|
import { BalanceService } from '@subwallet/extension-base/services/balance-service';
|
|
4
4
|
import { ChainService } from '@subwallet/extension-base/services/chain-service';
|
|
5
5
|
import { SwapBaseInterface } from '@subwallet/extension-base/services/swap-service/handler/base-handler';
|
|
6
|
-
import { BaseStepDetail } from '@subwallet/extension-base/types/service-base';
|
|
7
|
-
import {
|
|
6
|
+
import { BaseStepDetail, CommonOptimalPath, CommonStepFeeInfo } from '@subwallet/extension-base/types/service-base';
|
|
7
|
+
import { OptimalSwapPathParams, SwapEarlyValidation, SwapProviderId, SwapQuote, SwapRequest, SwapSubmitParams, SwapSubmitStepData, ValidateSwapProcessParams } from '@subwallet/extension-base/types/swap';
|
|
8
8
|
export declare class HydradxHandler implements SwapBaseInterface {
|
|
9
9
|
private swapBaseHandler;
|
|
10
10
|
private tradeRouter;
|
|
@@ -19,10 +19,10 @@ export declare class HydradxHandler implements SwapBaseInterface {
|
|
|
19
19
|
get providerInfo(): import("@subwallet/extension-base/types/swap").SwapProvider;
|
|
20
20
|
get name(): string;
|
|
21
21
|
get slug(): string;
|
|
22
|
-
getXcmStep(params: OptimalSwapPathParams): Promise<[BaseStepDetail,
|
|
23
|
-
getFeeOptionStep(params: OptimalSwapPathParams): Promise<[BaseStepDetail,
|
|
24
|
-
getSubmitStep(params: OptimalSwapPathParams): Promise<[BaseStepDetail,
|
|
25
|
-
generateOptimalProcess(params: OptimalSwapPathParams): Promise<
|
|
22
|
+
getXcmStep(params: OptimalSwapPathParams): Promise<[BaseStepDetail, CommonStepFeeInfo] | undefined>;
|
|
23
|
+
getFeeOptionStep(params: OptimalSwapPathParams): Promise<[BaseStepDetail, CommonStepFeeInfo] | undefined>;
|
|
24
|
+
getSubmitStep(params: OptimalSwapPathParams): Promise<[BaseStepDetail, CommonStepFeeInfo] | undefined>;
|
|
25
|
+
generateOptimalProcess(params: OptimalSwapPathParams): Promise<CommonOptimalPath>;
|
|
26
26
|
private getSwapPathErrors;
|
|
27
27
|
private parseSwapPath;
|
|
28
28
|
getSwapQuote(request: SwapRequest): Promise<SwapQuote | SwapError>;
|
|
@@ -8,10 +8,11 @@ import { SwapError } from '@subwallet/extension-base/background/errors/SwapError
|
|
|
8
8
|
import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError';
|
|
9
9
|
import { BasicTxErrorType, ChainType, ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
|
|
10
10
|
import { _getEarlyHydradxValidationError } from '@subwallet/extension-base/core/logic-validation/swap';
|
|
11
|
-
import { createXcmExtrinsic } from '@subwallet/extension-base/
|
|
11
|
+
import { createXcmExtrinsic } from '@subwallet/extension-base/services/balance-service/transfer/xcm';
|
|
12
12
|
import { _getAssetDecimals, _getChainNativeTokenSlug, _getTokenOnChainAssetId, _isNativeToken } from '@subwallet/extension-base/services/chain-service/utils';
|
|
13
13
|
import { SwapBaseHandler } from '@subwallet/extension-base/services/swap-service/handler/base-handler';
|
|
14
14
|
import { calculateSwapRate, getSwapAlternativeAsset, SWAP_QUOTE_TIMEOUT_MAP } from '@subwallet/extension-base/services/swap-service/utils';
|
|
15
|
+
import { CommonStepType } from '@subwallet/extension-base/types/service-base';
|
|
15
16
|
import { SwapErrorType, SwapFeeType, SwapProviderId, SwapStepType } from '@subwallet/extension-base/types/swap';
|
|
16
17
|
import BigNumber from 'bignumber.js';
|
|
17
18
|
const HYDRADX_LOW_LIQUIDITY_THRESHOLD = 0.15;
|
|
@@ -94,7 +95,7 @@ export class HydradxHandler {
|
|
|
94
95
|
destinationTokenInfo: fromAsset
|
|
95
96
|
},
|
|
96
97
|
name: `Transfer ${alternativeAsset.symbol} from ${alternativeChainInfo.name}`,
|
|
97
|
-
type:
|
|
98
|
+
type: CommonStepType.XCM
|
|
98
99
|
};
|
|
99
100
|
const xcmOriginSubstrateApi = await this.chainService.getSubstrateApi(alternativeAsset.originChain).isReady;
|
|
100
101
|
const xcmTransfer = await createXcmExtrinsic({
|
|
@@ -131,7 +132,7 @@ export class HydradxHandler {
|
|
|
131
132
|
}
|
|
132
133
|
const feeStep = {
|
|
133
134
|
name: 'Set fee token',
|
|
134
|
-
type:
|
|
135
|
+
type: CommonStepType.SET_FEE_TOKEN
|
|
135
136
|
};
|
|
136
137
|
try {
|
|
137
138
|
const substrateApi = this.chainService.getSubstrateApi(this.chain());
|
|
@@ -377,7 +378,7 @@ export class HydradxHandler {
|
|
|
377
378
|
const referral = _referral === null || _referral === void 0 ? void 0 : _referral.toString();
|
|
378
379
|
const needSetReferral = !referral || referral === '';
|
|
379
380
|
const steps = params.process.steps.map(step => step.type);
|
|
380
|
-
const needSetFeeToken = steps.includes(
|
|
381
|
+
const needSetFeeToken = steps.includes(CommonStepType.SET_FEE_TOKEN);
|
|
381
382
|
if (!needSetReferral && !needSetFeeToken) {
|
|
382
383
|
extrinsic = swapTx;
|
|
383
384
|
} else {
|
|
@@ -408,11 +409,11 @@ export class HydradxHandler {
|
|
|
408
409
|
} = params;
|
|
409
410
|
const type = process.steps[currentStep].type;
|
|
410
411
|
switch (type) {
|
|
411
|
-
case
|
|
412
|
+
case CommonStepType.DEFAULT:
|
|
412
413
|
return Promise.reject(new TransactionError(BasicTxErrorType.UNSUPPORTED));
|
|
413
|
-
case
|
|
414
|
+
case CommonStepType.XCM:
|
|
414
415
|
return this.handleXcmStep(params);
|
|
415
|
-
case
|
|
416
|
+
case CommonStepType.SET_FEE_TOKEN:
|
|
416
417
|
return this.handleSetFeeStep(params);
|
|
417
418
|
case SwapStepType.SWAP:
|
|
418
419
|
return this.handleSubmitStep(params);
|
|
@@ -430,11 +431,11 @@ export class HydradxHandler {
|
|
|
430
431
|
for (const [index, step] of params.process.steps.entries()) {
|
|
431
432
|
const getErrors = async () => {
|
|
432
433
|
switch (step.type) {
|
|
433
|
-
case
|
|
434
|
+
case CommonStepType.DEFAULT:
|
|
434
435
|
return Promise.resolve([]);
|
|
435
|
-
case
|
|
436
|
+
case CommonStepType.XCM:
|
|
436
437
|
return this.swapBaseHandler.validateXcmStep(params, index);
|
|
437
|
-
case
|
|
438
|
+
case CommonStepType.SET_FEE_TOKEN:
|
|
438
439
|
return this.swapBaseHandler.validateSetFeeTokenStep(params, index);
|
|
439
440
|
default:
|
|
440
441
|
return this.swapBaseHandler.validateSwapStep(params, isXcmOk, index);
|
|
@@ -443,7 +444,7 @@ export class HydradxHandler {
|
|
|
443
444
|
const errors = await getErrors();
|
|
444
445
|
if (errors.length) {
|
|
445
446
|
return errors;
|
|
446
|
-
} else if (step.type ===
|
|
447
|
+
} else if (step.type === CommonStepType.XCM) {
|
|
447
448
|
isXcmOk = true;
|
|
448
449
|
}
|
|
449
450
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError';
|
|
2
2
|
import KoniState from '@subwallet/extension-base/koni/background/handlers/State';
|
|
3
3
|
import { ServiceStatus, ServiceWithProcessInterface, StoppableServiceInterface } from '@subwallet/extension-base/services/base/types';
|
|
4
|
-
import {
|
|
4
|
+
import { CommonOptimalPath } from '@subwallet/extension-base/types/service-base';
|
|
5
|
+
import { OptimalSwapPathParams, SwapPair, SwapQuoteResponse, SwapRequest, SwapRequestResult, SwapSubmitParams, SwapSubmitStepData, ValidateSwapProcessParams } from '@subwallet/extension-base/types/swap';
|
|
5
6
|
import { PromiseHandler } from '@subwallet/extension-base/utils';
|
|
6
7
|
export declare class SwapService implements ServiceWithProcessInterface, StoppableServiceInterface {
|
|
7
8
|
protected readonly state: KoniState;
|
|
@@ -15,7 +16,7 @@ export declare class SwapService implements ServiceWithProcessInterface, Stoppab
|
|
|
15
16
|
constructor(state: KoniState);
|
|
16
17
|
private askProvidersForQuote;
|
|
17
18
|
private getDefaultProcess;
|
|
18
|
-
generateOptimalProcess(params: OptimalSwapPathParams): Promise<
|
|
19
|
+
generateOptimalProcess(params: OptimalSwapPathParams): Promise<CommonOptimalPath>;
|
|
19
20
|
handleSwapRequest(request: SwapRequest): Promise<SwapRequestResult>;
|
|
20
21
|
getLatestQuotes(request: SwapRequest): Promise<SwapQuoteResponse>;
|
|
21
22
|
private initHandlers;
|
|
@@ -7,7 +7,8 @@ import { BasicTxErrorType } from '@subwallet/extension-base/background/KoniTypes
|
|
|
7
7
|
import { ServiceStatus } from '@subwallet/extension-base/services/base/types';
|
|
8
8
|
import { ChainflipSwapHandler } from '@subwallet/extension-base/services/swap-service/handler/chainflip-handler';
|
|
9
9
|
import { HydradxHandler } from '@subwallet/extension-base/services/swap-service/handler/hydradx-handler';
|
|
10
|
-
import { _PROVIDER_TO_SUPPORTED_PAIR_MAP,
|
|
10
|
+
import { _PROVIDER_TO_SUPPORTED_PAIR_MAP, getSwapAltToken, SWAP_QUOTE_TIMEOUT_MAP } from '@subwallet/extension-base/services/swap-service/utils';
|
|
11
|
+
import { DEFAULT_FIRST_STEP, MOCK_STEP_FEE } from '@subwallet/extension-base/types/service-base';
|
|
11
12
|
import { _SUPPORTED_SWAP_PROVIDERS, SwapErrorType, SwapProviderId, SwapStepType } from '@subwallet/extension-base/types/swap';
|
|
12
13
|
import { createPromiseHandler } from '@subwallet/extension-base/utils';
|
|
13
14
|
import { BehaviorSubject } from 'rxjs';
|
|
@@ -50,8 +51,8 @@ export class SwapService {
|
|
|
50
51
|
|
|
51
52
|
getDefaultProcess(params) {
|
|
52
53
|
const result = {
|
|
53
|
-
totalFee: [
|
|
54
|
-
steps: [
|
|
54
|
+
totalFee: [MOCK_STEP_FEE],
|
|
55
|
+
steps: [DEFAULT_FIRST_STEP]
|
|
55
56
|
};
|
|
56
57
|
result.totalFee.push({
|
|
57
58
|
feeComponent: [],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Asset, Chain } from '@chainflip/sdk/swap';
|
|
2
2
|
import { _ChainAsset } from '@subwallet/chain-list/types';
|
|
3
|
-
import {
|
|
3
|
+
import { SwapPair } from '@subwallet/extension-base/types/swap';
|
|
4
4
|
export declare const CHAIN_FLIP_TESTNET_EXPLORER = "https://blocks-perseverance.chainflip.io";
|
|
5
5
|
export declare const CHAIN_FLIP_MAINNET_EXPLORER = "https://scan.chainflip.io";
|
|
6
6
|
export declare const CHAIN_FLIP_SUPPORTED_MAINNET_MAPPING: Record<string, Chain>;
|
|
@@ -8,8 +8,6 @@ export declare const CHAIN_FLIP_SUPPORTED_TESTNET_MAPPING: Record<string, Chain>
|
|
|
8
8
|
export declare const CHAIN_FLIP_SUPPORTED_MAINNET_ASSET_MAPPING: Record<string, Asset>;
|
|
9
9
|
export declare const CHAIN_FLIP_SUPPORTED_TESTNET_ASSET_MAPPING: Record<string, Asset>;
|
|
10
10
|
export declare const SWAP_QUOTE_TIMEOUT_MAP: Record<string, number>;
|
|
11
|
-
export declare const DEFAULT_SWAP_FIRST_STEP: SwapStepDetail;
|
|
12
|
-
export declare const MOCK_SWAP_FEE: SwapFeeInfo;
|
|
13
11
|
export declare const _PROVIDER_TO_SUPPORTED_PAIR_MAP: Record<string, string[]>;
|
|
14
12
|
export declare function getSwapAlternativeAsset(swapPair: SwapPair): string | undefined;
|
|
15
13
|
export declare function getSwapAltToken(chainAsset: _ChainAsset): string | undefined;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { Assets, Chains } from '@chainflip/sdk/swap';
|
|
5
5
|
import { COMMON_ASSETS, COMMON_CHAIN_SLUGS } from '@subwallet/chain-list';
|
|
6
6
|
import { _getAssetDecimals } from '@subwallet/extension-base/services/chain-service/utils';
|
|
7
|
-
import { SwapProviderId
|
|
7
|
+
import { SwapProviderId } from '@subwallet/extension-base/types/swap';
|
|
8
8
|
import BigN from 'bignumber.js';
|
|
9
9
|
export const CHAIN_FLIP_TESTNET_EXPLORER = 'https://blocks-perseverance.chainflip.io';
|
|
10
10
|
export const CHAIN_FLIP_MAINNET_EXPLORER = 'https://scan.chainflip.io';
|
|
@@ -32,16 +32,6 @@ export const SWAP_QUOTE_TIMEOUT_MAP = {
|
|
|
32
32
|
[SwapProviderId.CHAIN_FLIP_TESTNET]: 30000,
|
|
33
33
|
[SwapProviderId.CHAIN_FLIP_MAINNET]: 30000
|
|
34
34
|
};
|
|
35
|
-
export const DEFAULT_SWAP_FIRST_STEP = {
|
|
36
|
-
id: 0,
|
|
37
|
-
name: 'Fill information',
|
|
38
|
-
type: SwapStepType.DEFAULT
|
|
39
|
-
};
|
|
40
|
-
export const MOCK_SWAP_FEE = {
|
|
41
|
-
feeComponent: [],
|
|
42
|
-
defaultFeeToken: '',
|
|
43
|
-
feeOptions: []
|
|
44
|
-
};
|
|
45
35
|
export const _PROVIDER_TO_SUPPORTED_PAIR_MAP = {
|
|
46
36
|
[SwapProviderId.HYDRADX_MAINNET]: [COMMON_CHAIN_SLUGS.HYDRADX],
|
|
47
37
|
[SwapProviderId.HYDRADX_TESTNET]: [COMMON_CHAIN_SLUGS.HYDRADX_TESTNET],
|
|
@@ -539,10 +539,10 @@ export default class TransactionService {
|
|
|
539
539
|
}
|
|
540
540
|
break;
|
|
541
541
|
}
|
|
542
|
-
case ExtrinsicType.
|
|
542
|
+
case ExtrinsicType.TOKEN_SPENDING_APPROVAL:
|
|
543
543
|
{
|
|
544
544
|
const data = parseTransactionData(transaction.data);
|
|
545
|
-
const inputAsset = this.state.chainService.getAssetBySlug(data.
|
|
545
|
+
const inputAsset = this.state.chainService.getAssetBySlug(data.contractAddress);
|
|
546
546
|
historyItem.amount = {
|
|
547
547
|
value: '0',
|
|
548
548
|
symbol: _getAssetSymbol(inputAsset),
|
package/types/service-base.d.ts
CHANGED
|
@@ -1,10 +1,38 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { OptimalSwapPathParams, SwapFeeType, SwapStepType } from '@subwallet/extension-base/types/swap';
|
|
2
2
|
import { OptimalYieldPath, OptimalYieldPathParams, YieldStepType } from '@subwallet/extension-base/types/yield';
|
|
3
3
|
export declare type OptimalProcessParams = OptimalYieldPathParams | OptimalSwapPathParams;
|
|
4
|
-
export declare type OptimalProcessResult = OptimalYieldPath |
|
|
5
|
-
export declare
|
|
4
|
+
export declare type OptimalProcessResult = OptimalYieldPath | CommonOptimalPath;
|
|
5
|
+
export declare enum CommonStepType {
|
|
6
|
+
DEFAULT = "DEFAULT",
|
|
7
|
+
XCM = "XCM",
|
|
8
|
+
TOKEN_APPROVAL = "TOKEN_APPROVAL",
|
|
9
|
+
SET_FEE_TOKEN = "SET_FEE_TOKEN",
|
|
10
|
+
TRANSFER = "TRANSFER"
|
|
11
|
+
}
|
|
12
|
+
export declare type BaseStepType = CommonStepType | SwapStepType | YieldStepType;
|
|
13
|
+
export declare type BaseFeeType = SwapFeeType;
|
|
6
14
|
export interface BaseStepDetail {
|
|
7
15
|
type: BaseStepType;
|
|
8
16
|
name: string;
|
|
9
17
|
metadata?: Record<string, unknown>;
|
|
10
18
|
}
|
|
19
|
+
export interface CommonFeeComponent {
|
|
20
|
+
feeType: BaseFeeType;
|
|
21
|
+
amount: string;
|
|
22
|
+
tokenSlug: string;
|
|
23
|
+
}
|
|
24
|
+
export interface CommonStepFeeInfo {
|
|
25
|
+
feeComponent: CommonFeeComponent[];
|
|
26
|
+
defaultFeeToken: string;
|
|
27
|
+
feeOptions: string[];
|
|
28
|
+
selectedFeeToken?: string;
|
|
29
|
+
}
|
|
30
|
+
export interface CommonStepDetail extends BaseStepDetail {
|
|
31
|
+
id: number;
|
|
32
|
+
}
|
|
33
|
+
export interface CommonOptimalPath {
|
|
34
|
+
totalFee: CommonStepFeeInfo[];
|
|
35
|
+
steps: CommonStepDetail[];
|
|
36
|
+
}
|
|
37
|
+
export declare const DEFAULT_FIRST_STEP: CommonStepDetail;
|
|
38
|
+
export declare const MOCK_STEP_FEE: CommonStepFeeInfo;
|
package/types/service-base.js
CHANGED
|
@@ -1 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-base
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
/* ServiceWithProcess */
|
|
5
|
+
|
|
6
|
+
export let CommonStepType;
|
|
7
|
+
(function (CommonStepType) {
|
|
8
|
+
CommonStepType["DEFAULT"] = "DEFAULT";
|
|
9
|
+
CommonStepType["XCM"] = "XCM";
|
|
10
|
+
CommonStepType["TOKEN_APPROVAL"] = "TOKEN_APPROVAL";
|
|
11
|
+
CommonStepType["SET_FEE_TOKEN"] = "SET_FEE_TOKEN";
|
|
12
|
+
CommonStepType["TRANSFER"] = "TRANSFER";
|
|
13
|
+
})(CommonStepType || (CommonStepType = {}));
|
|
14
|
+
export const DEFAULT_FIRST_STEP = {
|
|
15
|
+
id: 0,
|
|
16
|
+
name: 'Fill information',
|
|
17
|
+
type: CommonStepType.DEFAULT
|
|
18
|
+
};
|
|
19
|
+
export const MOCK_STEP_FEE = {
|
|
20
|
+
feeComponent: [],
|
|
21
|
+
defaultFeeToken: '',
|
|
22
|
+
feeOptions: []
|
|
23
|
+
};
|
package/types/swap/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { _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
4
|
import { TransactionData } from '@subwallet/extension-base/types';
|
|
5
|
-
import { BaseStepDetail } from '@subwallet/extension-base/types/service-base';
|
|
5
|
+
import { BaseStepDetail, CommonOptimalPath, CommonStepFeeInfo } from '@subwallet/extension-base/types/service-base';
|
|
6
6
|
import BigN from 'bignumber.js';
|
|
7
7
|
export declare type SwapRate = number;
|
|
8
8
|
export interface SwapPair {
|
|
@@ -24,7 +24,7 @@ export interface SwapQuote {
|
|
|
24
24
|
estimatedArrivalTime?: number;
|
|
25
25
|
isLowLiquidity?: boolean;
|
|
26
26
|
metadata?: any;
|
|
27
|
-
feeInfo:
|
|
27
|
+
feeInfo: CommonStepFeeInfo;
|
|
28
28
|
}
|
|
29
29
|
export interface SwapRoute {
|
|
30
30
|
path: string[];
|
|
@@ -42,11 +42,7 @@ export declare enum SwapErrorType {
|
|
|
42
42
|
AMOUNT_CANNOT_BE_ZERO = "AMOUNT_CANNOT_BE_ZERO"
|
|
43
43
|
}
|
|
44
44
|
export declare enum SwapStepType {
|
|
45
|
-
|
|
46
|
-
TOKEN_APPROVAL = "TOKEN_APPROVAL",
|
|
47
|
-
SET_FEE_TOKEN = "SET_FEE_TOKEN",
|
|
48
|
-
SWAP = "SWAP",
|
|
49
|
-
XCM = "XCM"
|
|
45
|
+
SWAP = "SWAP"
|
|
50
46
|
}
|
|
51
47
|
export declare enum SwapProviderId {
|
|
52
48
|
CHAIN_FLIP_TESTNET = "CHAIN_FLIP_TESTNET",
|
|
@@ -65,24 +61,6 @@ export declare enum SwapFeeType {
|
|
|
65
61
|
NETWORK_FEE = "NETWORK_FEE",
|
|
66
62
|
WALLET_FEE = "WALLET_FEE"
|
|
67
63
|
}
|
|
68
|
-
export interface SwapFeeComponent {
|
|
69
|
-
feeType: SwapFeeType;
|
|
70
|
-
amount: string;
|
|
71
|
-
tokenSlug: string;
|
|
72
|
-
}
|
|
73
|
-
export interface SwapFeeInfo {
|
|
74
|
-
feeComponent: SwapFeeComponent[];
|
|
75
|
-
defaultFeeToken: string;
|
|
76
|
-
feeOptions: string[];
|
|
77
|
-
selectedFeeToken?: string;
|
|
78
|
-
}
|
|
79
|
-
export interface SwapStepDetail extends BaseStepDetail {
|
|
80
|
-
id: number;
|
|
81
|
-
}
|
|
82
|
-
export interface OptimalSwapPath {
|
|
83
|
-
totalFee: SwapFeeInfo[];
|
|
84
|
-
steps: SwapStepDetail[];
|
|
85
|
-
}
|
|
86
64
|
export declare type SwapTxData = ChainflipSwapTxData | HydradxSwapTxData;
|
|
87
65
|
export interface SwapBaseTxData {
|
|
88
66
|
provider: SwapProvider;
|
|
@@ -90,7 +68,7 @@ export interface SwapBaseTxData {
|
|
|
90
68
|
address: string;
|
|
91
69
|
slippage: number;
|
|
92
70
|
recipient?: string;
|
|
93
|
-
process:
|
|
71
|
+
process: CommonOptimalPath;
|
|
94
72
|
}
|
|
95
73
|
export interface ChainflipSwapTxData extends SwapBaseTxData {
|
|
96
74
|
depositChannelId: string;
|
|
@@ -100,7 +78,7 @@ export interface ChainflipSwapTxData extends SwapBaseTxData {
|
|
|
100
78
|
export interface HydradxSwapTxData extends SwapBaseTxData {
|
|
101
79
|
txHex: string;
|
|
102
80
|
}
|
|
103
|
-
export declare type GenSwapStepFunc = (params: OptimalSwapPathParams) => Promise<[BaseStepDetail,
|
|
81
|
+
export declare type GenSwapStepFunc = (params: OptimalSwapPathParams) => Promise<[BaseStepDetail, CommonStepFeeInfo] | undefined>;
|
|
104
82
|
export interface ChainflipPreValidationMetadata {
|
|
105
83
|
minSwap: AmountData;
|
|
106
84
|
maxSwap?: AmountData;
|
|
@@ -123,7 +101,7 @@ export interface SwapRequest {
|
|
|
123
101
|
feeToken?: string;
|
|
124
102
|
}
|
|
125
103
|
export interface SwapRequestResult {
|
|
126
|
-
process:
|
|
104
|
+
process: CommonOptimalPath;
|
|
127
105
|
quote: SwapQuoteResponse;
|
|
128
106
|
}
|
|
129
107
|
export interface SwapQuoteResponse {
|
|
@@ -133,7 +111,7 @@ export interface SwapQuoteResponse {
|
|
|
133
111
|
error?: SwapError;
|
|
134
112
|
}
|
|
135
113
|
export interface SwapSubmitParams {
|
|
136
|
-
process:
|
|
114
|
+
process: CommonOptimalPath;
|
|
137
115
|
currentStep: number;
|
|
138
116
|
quote: SwapQuote;
|
|
139
117
|
address: string;
|
|
@@ -158,7 +136,7 @@ export interface SwapEarlyValidation {
|
|
|
158
136
|
}
|
|
159
137
|
export interface ValidateSwapProcessParams {
|
|
160
138
|
address: string;
|
|
161
|
-
process:
|
|
139
|
+
process: CommonOptimalPath;
|
|
162
140
|
selectedQuote: SwapQuote;
|
|
163
141
|
recipient?: string;
|
|
164
142
|
}
|
package/types/swap/index.js
CHANGED
|
@@ -18,11 +18,7 @@ export let SwapErrorType;
|
|
|
18
18
|
})(SwapErrorType || (SwapErrorType = {}));
|
|
19
19
|
export let SwapStepType;
|
|
20
20
|
(function (SwapStepType) {
|
|
21
|
-
SwapStepType["DEFAULT"] = "DEFAULT";
|
|
22
|
-
SwapStepType["TOKEN_APPROVAL"] = "TOKEN_APPROVAL";
|
|
23
|
-
SwapStepType["SET_FEE_TOKEN"] = "SET_FEE_TOKEN";
|
|
24
21
|
SwapStepType["SWAP"] = "SWAP";
|
|
25
|
-
SwapStepType["XCM"] = "XCM";
|
|
26
22
|
})(SwapStepType || (SwapStepType = {}));
|
|
27
23
|
export let SwapProviderId;
|
|
28
24
|
(function (SwapProviderId) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BaseRequestSign, ChainType, ExtrinsicType, InternalRequestSign } from '@subwallet/extension-base/background/KoniTypes';
|
|
1
|
+
import { _Address, BaseRequestSign, ChainType, ExtrinsicType, InternalRequestSign } from '@subwallet/extension-base/background/KoniTypes';
|
|
2
2
|
import { TransactionData } from '../../../transaction';
|
|
3
3
|
import { NominationPoolInfo, ValidatorInfo, YieldPositionInfo } from '../../info';
|
|
4
4
|
import { OptimalYieldPath } from './step';
|
|
@@ -34,9 +34,12 @@ export interface HandleYieldStepParams extends BaseRequestSign {
|
|
|
34
34
|
data: SubmitYieldJoinData;
|
|
35
35
|
currentStep: number;
|
|
36
36
|
}
|
|
37
|
-
export interface
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
export interface TokenSpendingApprovalParams {
|
|
38
|
+
chain: string;
|
|
39
|
+
contractAddress: _Address;
|
|
40
|
+
spenderAddress: _Address;
|
|
41
|
+
owner: _Address;
|
|
42
|
+
amount?: string;
|
|
40
43
|
}
|
|
41
44
|
export declare type RequestYieldStepSubmit = InternalRequestSign<HandleYieldStepParams>;
|
|
42
45
|
export interface StakePoolingBondingParams extends BaseRequestSign {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { _ERC20_ABI, _ERC721_ABI } from '@subwallet/extension-base/
|
|
4
|
+
import { _ERC20_ABI, _ERC721_ABI } from '@subwallet/extension-base/koni/api/contract-handler/utils';
|
|
5
5
|
import { _getEvmAbiExplorer, _getEvmChainId, _isChainEvmCompatible } from '@subwallet/extension-base/services/chain-service/utils';
|
|
6
6
|
import { fetchJson } from '@subwallet/extension-base/utils';
|
|
7
7
|
import { createTransactionFromRLP } from '@subwallet/extension-base/utils/eth';
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getEVMBalance = getEVMBalance;
|
|
7
|
-
// Copyright 2019-2022 @subwallet/extension-base
|
|
8
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
9
|
-
|
|
10
|
-
async function getEVMBalance(networkKey, addresses, web3Api) {
|
|
11
|
-
return await Promise.all(addresses.map(async address => {
|
|
12
|
-
try {
|
|
13
|
-
return await web3Api.api.eth.getBalance(address);
|
|
14
|
-
} catch (e) {
|
|
15
|
-
return '0';
|
|
16
|
-
}
|
|
17
|
-
}));
|
|
18
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getERC20Contract = void 0;
|
|
7
|
-
var _helper = require("@subwallet/extension-base/services/chain-service/helper");
|
|
8
|
-
// Copyright 2019-2022 @subwallet/extension-base
|
|
9
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
10
|
-
|
|
11
|
-
const getERC20Contract = function (assetAddress, evmApi) {
|
|
12
|
-
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
13
|
-
// @ts-ignore
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-member-access
|
|
15
|
-
return new evmApi.api.eth.Contract(_helper._ERC20_ABI, assetAddress, options);
|
|
16
|
-
};
|
|
17
|
-
exports.getERC20Contract = getERC20Contract;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isEqualContractAddress = isEqualContractAddress;
|
|
7
|
-
var _utilCrypto = require("@polkadot/util-crypto");
|
|
8
|
-
// Copyright 2019-2022 @subwallet/extension-base
|
|
9
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
10
|
-
|
|
11
|
-
function isEqualContractAddress(address1, address2) {
|
|
12
|
-
if ((0, _utilCrypto.isEthereumAddress)(address1) && (0, _utilCrypto.isEthereumAddress)(address2)) {
|
|
13
|
-
return address1.toLowerCase() === address2.toLowerCase(); // EVM address is case-insensitive
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return address2 === address1;
|
|
17
|
-
}
|