@subwallet/extension-base 1.3.51-0 → 1.3.52-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/cjs/constants/environment.js +3 -1
- package/cjs/koni/background/handlers/State.js +1 -5
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/index.js +3 -4
- package/cjs/services/balance-service/transfer/cardano-transfer.js +43 -11
- package/cjs/services/balance-service/transfer/xcm/acrossBridge/index.js +13 -92
- package/cjs/services/balance-service/transfer/xcm/index.js +12 -4
- package/cjs/services/chain-service/utils/patch.js +3 -2
- package/cjs/services/earning-service/handlers/native-staking/dtao.js +28 -301
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +4 -4
- package/cjs/services/earning-service/handlers/native-staking/tao.js +174 -148
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +11 -5
- package/cjs/services/earning-service/service.js +5 -2
- package/cjs/services/fee-service/utils/tokenPayFee.js +17 -13
- package/cjs/services/price-service/coingecko.js +3 -3
- package/cjs/services/swap-service/handler/hydradx-handler.js +19 -13
- package/cjs/services/swap-service/index.js +8 -5
- package/cjs/services/transaction-service/utils.js +31 -22
- package/cjs/utils/index.js +12 -0
- package/cjs/utils/setup-api-sdk.js +27 -0
- package/constants/environment.d.ts +1 -0
- package/constants/environment.js +1 -0
- package/koni/background/handlers/State.js +3 -7
- package/package.json +12 -6
- package/packageInfo.js +1 -1
- package/services/balance-service/index.js +3 -4
- package/services/balance-service/transfer/cardano-transfer.js +42 -10
- package/services/balance-service/transfer/xcm/acrossBridge/index.js +14 -93
- package/services/balance-service/transfer/xcm/index.js +12 -4
- package/services/chain-service/utils/patch.d.ts +1 -0
- package/services/chain-service/utils/patch.js +1 -1
- package/services/earning-service/handlers/native-staking/dtao.d.ts +4 -36
- package/services/earning-service/handlers/native-staking/dtao.js +24 -298
- package/services/earning-service/handlers/native-staking/relay-chain.d.ts +1 -2
- package/services/earning-service/handlers/native-staking/relay-chain.js +4 -4
- package/services/earning-service/handlers/native-staking/tao.d.ts +25 -5
- package/services/earning-service/handlers/native-staking/tao.js +169 -149
- package/services/earning-service/handlers/nomination-pool/index.d.ts +1 -2
- package/services/earning-service/handlers/nomination-pool/index.js +11 -5
- package/services/earning-service/service.d.ts +1 -0
- package/services/earning-service/service.js +4 -2
- package/services/fee-service/utils/tokenPayFee.js +17 -13
- package/services/price-service/coingecko.js +2 -3
- package/services/swap-service/handler/hydradx-handler.js +19 -13
- package/services/swap-service/index.js +8 -5
- package/services/transaction-service/utils.d.ts +0 -1
- package/services/transaction-service/utils.js +31 -21
- package/types/swap/index.d.ts +1 -1
- package/types/yield/info/chain/info.d.ts +1 -0
- package/utils/index.d.ts +1 -0
- package/utils/index.js +2 -1
- package/utils/setup-api-sdk.d.ts +1 -0
- package/utils/setup-api-sdk.js +20 -0
|
@@ -12,7 +12,7 @@ import { BasicTxErrorType, DynamicSwapType } from '@subwallet/extension-base/typ
|
|
|
12
12
|
import { CommonStepType } from '@subwallet/extension-base/types/service-base';
|
|
13
13
|
import { SwapErrorType, SwapFeeType, SwapProviderId, SwapStepType } from '@subwallet/extension-base/types/swap';
|
|
14
14
|
import { _reformatAddressWithChain } from '@subwallet/extension-base/utils';
|
|
15
|
-
import subwalletApiSdk from '@subwallet/subwallet-
|
|
15
|
+
import subwalletApiSdk from '@subwallet-monorepos/subwallet-services-sdk';
|
|
16
16
|
import BigN from 'bignumber.js';
|
|
17
17
|
import { isHex } from '@polkadot/util';
|
|
18
18
|
const HYDRADX_SUBWALLET_REFERRAL_CODE = 'WALLET';
|
|
@@ -137,21 +137,27 @@ export class HydradxHandler {
|
|
|
137
137
|
let bnSendingValue = BigN(fromAmount);
|
|
138
138
|
let bnExpectedReceive = BigN(selectedQuote.toAmount);
|
|
139
139
|
if (needModifyData) {
|
|
140
|
-
var
|
|
140
|
+
var _quotes;
|
|
141
141
|
// override info if xcm-swap-xcm
|
|
142
142
|
bnSendingValue = bnSendingValue.multipliedBy(DEFAULT_EXCESS_AMOUNT_WEIGHT);
|
|
143
143
|
bnExpectedReceive = bnExpectedReceive.multipliedBy(DEFAULT_EXCESS_AMOUNT_WEIGHT);
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
144
|
+
let quotes = []; // todo
|
|
145
|
+
|
|
146
|
+
try {
|
|
147
|
+
quotes = await subwalletApiSdk.swapApi.fetchSwapQuoteData({
|
|
148
|
+
address: sender,
|
|
149
|
+
pair: {
|
|
150
|
+
from: swapPairInfo.from,
|
|
151
|
+
to: swapPairInfo.to,
|
|
152
|
+
slug: swapPairInfo.slug
|
|
153
|
+
},
|
|
154
|
+
fromAmount: bnSendingValue.toFixed(0, 1),
|
|
155
|
+
slippage: params.request.slippage
|
|
156
|
+
});
|
|
157
|
+
} catch (error) {
|
|
158
|
+
throw new Error(`Failed to fetch swap quote: ${error.message}`);
|
|
159
|
+
}
|
|
160
|
+
const quoteAskResponse = (_quotes = quotes) === null || _quotes === void 0 ? void 0 : _quotes.find(quote => quote.provider === this.providerSlug);
|
|
155
161
|
if (!quoteAskResponse || !quoteAskResponse.quote) {
|
|
156
162
|
return Promise.resolve(undefined);
|
|
157
163
|
}
|
|
@@ -17,7 +17,7 @@ import { BasicTxErrorType, DynamicSwapType } from '@subwallet/extension-base/typ
|
|
|
17
17
|
import { DEFAULT_FIRST_STEP, MOCK_STEP_FEE } from '@subwallet/extension-base/types/service-base';
|
|
18
18
|
import { _SUPPORTED_SWAP_PROVIDERS, SwapErrorType, SwapProviderId, SwapStepType } from '@subwallet/extension-base/types/swap';
|
|
19
19
|
import { _reformatAddressWithChain, createPromiseHandler, reformatAddress } from '@subwallet/extension-base/utils';
|
|
20
|
-
import subwalletApiSdk from '@subwallet/subwallet-
|
|
20
|
+
import subwalletApiSdk from '@subwallet-monorepos/subwallet-services-sdk';
|
|
21
21
|
import BigN from 'bignumber.js';
|
|
22
22
|
import { t } from 'i18next';
|
|
23
23
|
import { BehaviorSubject } from 'rxjs';
|
|
@@ -36,7 +36,6 @@ export class SwapService {
|
|
|
36
36
|
this.chainService = state.chainService;
|
|
37
37
|
}
|
|
38
38
|
async askProvidersForQuote(_request) {
|
|
39
|
-
var _subwalletApiSdk$swap;
|
|
40
39
|
const availableQuotes = [];
|
|
41
40
|
|
|
42
41
|
// hotfix // todo: remove later
|
|
@@ -44,7 +43,7 @@ export class SwapService {
|
|
|
44
43
|
..._request,
|
|
45
44
|
isSupportKyberVersion: true
|
|
46
45
|
};
|
|
47
|
-
const quotes = await
|
|
46
|
+
const quotes = await subwalletApiSdk.swapApi.fetchSwapQuoteData(request);
|
|
48
47
|
if (Array.isArray(quotes)) {
|
|
49
48
|
quotes.forEach(quoteData => {
|
|
50
49
|
if (!_SUPPORTED_SWAP_PROVIDERS.includes(quoteData.provider)) {
|
|
@@ -265,8 +264,12 @@ export class SwapService {
|
|
|
265
264
|
return [[], undefined];
|
|
266
265
|
}
|
|
267
266
|
async getLatestQuoteFromSwapRequest(request) {
|
|
268
|
-
|
|
269
|
-
|
|
267
|
+
let availablePath;
|
|
268
|
+
try {
|
|
269
|
+
availablePath = await subwalletApiSdk.swapApi.findAvailablePath(request);
|
|
270
|
+
} catch (e) {
|
|
271
|
+
console.log('Error findAvailablePath', e);
|
|
272
|
+
}
|
|
270
273
|
if (!availablePath) {
|
|
271
274
|
return {
|
|
272
275
|
path: [],
|
|
@@ -2,7 +2,6 @@ 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>;
|
|
6
5
|
export declare function getExplorerLink(chainInfo: _ChainInfo, value: string, type: 'account' | 'tx'): string | undefined;
|
|
7
6
|
export declare function getChainflipExplorerLink(data: ChainflipSwapTxData, chainInfo: _ChainInfo): string;
|
|
8
7
|
export declare function getSimpleSwapExplorerLink(data: SimpleSwapTxData): string;
|
|
@@ -43,12 +43,18 @@ function getBlockExplorerAccountRoute(explorerLink) {
|
|
|
43
43
|
if (explorerLink.includes('devnet-explorer.mosaicchain.io')) {
|
|
44
44
|
return 'accounts';
|
|
45
45
|
}
|
|
46
|
+
if (explorerLink.includes('pdexmon.com')) {
|
|
47
|
+
return 'holders';
|
|
48
|
+
}
|
|
46
49
|
return 'address';
|
|
47
50
|
}
|
|
48
51
|
function getBlockExplorerTxRoute(chainInfo) {
|
|
49
52
|
if (_isPureEvmChain(chainInfo) || _isPureBitcoinChain(chainInfo)) {
|
|
50
53
|
return 'tx';
|
|
51
54
|
}
|
|
55
|
+
if (['moonbeam'].includes(chainInfo.slug)) {
|
|
56
|
+
return 'tx';
|
|
57
|
+
}
|
|
52
58
|
if (_isPureCardanoChain(chainInfo) || _isPureTonChain(chainInfo)) {
|
|
53
59
|
return 'transaction';
|
|
54
60
|
}
|
|
@@ -58,33 +64,38 @@ function getBlockExplorerTxRoute(chainInfo) {
|
|
|
58
64
|
if (['gen6_public'].includes(chainInfo.slug)) {
|
|
59
65
|
return '#/extrinsics';
|
|
60
66
|
}
|
|
61
|
-
if (['mosaicTest'].includes(chainInfo.slug)) {
|
|
67
|
+
if (['mosaicTest', 'polkadex'].includes(chainInfo.slug)) {
|
|
62
68
|
return 'transactions';
|
|
63
69
|
}
|
|
70
|
+
if (['autonomys'].includes(chainInfo.slug)) {
|
|
71
|
+
return 'extrinsics';
|
|
72
|
+
}
|
|
64
73
|
const explorerLink = _getBlockExplorerFromChain(chainInfo);
|
|
65
74
|
if (explorerLink && explorerLink.includes('statescan.io')) {
|
|
66
75
|
return '#/extrinsics';
|
|
67
76
|
}
|
|
68
77
|
return 'extrinsic';
|
|
69
78
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
79
|
+
|
|
80
|
+
// export function getTransactionId (value: string): Promise<string> {
|
|
81
|
+
// const query = `
|
|
82
|
+
// query ExtrinsicQuery {
|
|
83
|
+
// extrinsics(where: {hash_eq: ${value}}, limit: 1) {
|
|
84
|
+
// id
|
|
85
|
+
// }
|
|
86
|
+
// }`;
|
|
87
|
+
//
|
|
88
|
+
// const apiUrl = 'https://archive-explorer.truth-network.io/graphql';
|
|
89
|
+
//
|
|
90
|
+
// return fetch(apiUrl, {
|
|
91
|
+
// method: 'POST',
|
|
92
|
+
// headers: { 'Content-Type': 'application/json' },
|
|
93
|
+
// body: JSON.stringify({ query })
|
|
94
|
+
// })
|
|
95
|
+
// .then((response) => response.json())
|
|
96
|
+
// .then((result: SWApiResponse<ExtrinsicsDataResponse>) => result.data.extrinsics[0].id);
|
|
97
|
+
// }
|
|
98
|
+
|
|
88
99
|
export function getExplorerLink(chainInfo, value, type) {
|
|
89
100
|
const explorerLink = _getBlockExplorerFromChain(chainInfo);
|
|
90
101
|
if (explorerLink && type === 'account') {
|
|
@@ -120,6 +131,5 @@ export function getChainflipExplorerLink(data, chainInfo) {
|
|
|
120
131
|
return `${chainflipDomain}/channels/${data.depositChannelId}`;
|
|
121
132
|
}
|
|
122
133
|
export function getSimpleSwapExplorerLink(data) {
|
|
123
|
-
|
|
124
|
-
return `${simpleswapDomain}/exchange?id=${data.id}`;
|
|
134
|
+
return `${SIMPLE_SWAP_EXPLORER}/exchange?id=${data.id}`;
|
|
125
135
|
}
|
package/types/swap/index.d.ts
CHANGED
package/utils/index.d.ts
CHANGED
package/utils/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setupApiSDK(): void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { APP_VERSION, BACKEND_API_URL, BACKEND_PRICE_HISTORY_URL } from '@subwallet/extension-base/constants';
|
|
5
|
+
import { ChainListVersion } from '@subwallet/extension-base/services/chain-service/utils';
|
|
6
|
+
import subwalletApiSdk from '@subwallet-monorepos/subwallet-services-sdk';
|
|
7
|
+
import { TARGET_ENV } from "./environment.js";
|
|
8
|
+
export function setupApiSDK() {
|
|
9
|
+
subwalletApiSdk.updateConfig({
|
|
10
|
+
appVersion: APP_VERSION,
|
|
11
|
+
baseUrl: BACKEND_API_URL,
|
|
12
|
+
platform: TARGET_ENV,
|
|
13
|
+
chainListVersion: ChainListVersion
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
// Custom the price history API with other different base URL
|
|
17
|
+
subwalletApiSdk.priceHistoryApi.updateConfig({
|
|
18
|
+
baseUrl: BACKEND_PRICE_HISTORY_URL
|
|
19
|
+
});
|
|
20
|
+
}
|