rubic-sdk 5.18.0-alpha.meson.3 → 5.18.0-alpha.meson.4
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/lib/features/common/providers/symbiosis/models/symbiosis-api-common-types.d.ts +1 -1
- package/lib/features/common/providers/xy/models/xy-build-tx-response.d.ts +2 -2
- package/lib/features/common/providers/xy/models/xy-quote-error-response.d.ts +1 -1
- package/lib/features/common/providers/xy/models/xy-quote-response.d.ts +3 -3
- package/lib/features/common/providers/xy/models/xy-quote-success-response.d.ts +1 -1
- package/lib/features/cross-chain/calculation-manager/providers/debridge-provider/debridge-cross-chain-provider.js +3 -3
- package/lib/features/cross-chain/calculation-manager/providers/debridge-provider/models/transaction-response.d.ts +1 -1
- package/lib/features/cross-chain/calculation-manager/providers/meson-provider/models/meson-api-types.d.ts +2 -6
- package/lib/features/cross-chain/calculation-manager/providers/meson-provider/services/meson-cross-chain-api-service.js +46 -32
- package/lib/features/cross-chain/calculation-manager/providers/meson-provider/services/meson-cross-chain-api-service.js.map +1 -1
- package/package.json +1 -1
@@ -1,6 +1,6 @@
|
|
1
|
-
import {
|
1
|
+
import { XyQuoteMesonErrorRes } from './xy-quote-error-response';
|
2
2
|
import { XyRoute } from './xy-quote-success-response';
|
3
|
-
export interface XyBuildTxResponse extends
|
3
|
+
export interface XyBuildTxResponse extends XyQuoteMesonErrorRes {
|
4
4
|
success: boolean;
|
5
5
|
route: XyRoute;
|
6
6
|
tx: {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
export interface XyQuoteResponse extends
|
1
|
+
import { XyQuoteMesonErrorRes } from './xy-quote-error-response';
|
2
|
+
import { XyQuoteMesonSuccessRes } from './xy-quote-success-response';
|
3
|
+
export interface XyQuoteResponse extends XyQuoteMesonSuccessRes, XyQuoteMesonErrorRes {
|
4
4
|
}
|
@@ -116,9 +116,9 @@ class DebridgeCrossChainProvider extends cross_chain_provider_1.CrossChainProvid
|
|
116
116
|
async getFeeInfo(fromBlockchain, providerAddress, percentFeeToken, useProxy) {
|
117
117
|
return proxy_cross_chain_evm_trade_1.ProxyCrossChainEvmTrade.getFeeInfo(fromBlockchain, providerAddress, percentFeeToken, useProxy);
|
118
118
|
}
|
119
|
-
parseDebridgeApiError(
|
120
|
-
if (
|
121
|
-
|
119
|
+
parseDebridgeApiError(httpMesonErrorRes) {
|
120
|
+
if (httpMesonErrorRes?.error?.errorId === 'INCLUDED_GAS_FEE_NOT_COVERED_BY_INPUT_AMOUNT' ||
|
121
|
+
httpMesonErrorRes?.error?.errorId === 'ERROR_LOW_GIVE_AMOUNT') {
|
122
122
|
return new errors_1.TooLowAmountError();
|
123
123
|
}
|
124
124
|
// @TODO handle other debridge API error codes:
|
@@ -1,7 +1,7 @@
|
|
1
|
-
type
|
1
|
+
export type MesonErrorRes<T> = {
|
2
2
|
error: T;
|
3
3
|
};
|
4
|
-
type
|
4
|
+
export type MesonSuccessRes<T> = {
|
5
5
|
result: T;
|
6
6
|
};
|
7
7
|
export type SrcDstChainsIds = [string, string];
|
@@ -42,7 +42,6 @@ export interface FetchEncodedParamRequest {
|
|
42
42
|
receiverAddress: string;
|
43
43
|
useProxy: boolean;
|
44
44
|
}
|
45
|
-
export type EncodeSwapResponse = SuccessResponse<EncodeSwapSchema> | ErrorResponse<EncodeSwapSchema>;
|
46
45
|
export interface EncodeSwapSchema {
|
47
46
|
encoded: string;
|
48
47
|
fromAddress: string;
|
@@ -60,7 +59,6 @@ export interface EncodeSwapSchema {
|
|
60
59
|
};
|
61
60
|
initiator: string;
|
62
61
|
}
|
63
|
-
export type TxFeeResponse = SuccessResponse<TxFeeSchema> | ErrorResponse<TxFeeSchema>;
|
64
62
|
export interface TxFeeSchema {
|
65
63
|
serviceFee: string;
|
66
64
|
lpFee: string;
|
@@ -70,7 +68,6 @@ export interface TxFeeSchema {
|
|
70
68
|
token: string;
|
71
69
|
};
|
72
70
|
}
|
73
|
-
export type TxStatusResponse = SuccessResponse<TxStatusSchema> | ErrorResponse<TxStatusSchema>;
|
74
71
|
export interface TxStatusSchema {
|
75
72
|
expired?: boolean;
|
76
73
|
LOCKED: string;
|
@@ -92,4 +89,3 @@ export interface TxStatusSchema {
|
|
92
89
|
};
|
93
90
|
};
|
94
91
|
}
|
95
|
-
export {};
|
@@ -6,24 +6,32 @@ const tx_status_1 = require("../../../../../../core/blockchain/web3-public-servi
|
|
6
6
|
const injector_1 = require("../../../../../../core/injector/injector");
|
7
7
|
class MesonCcrApiService {
|
8
8
|
static async fetchMesonFee(sourceAssetString, targetAssetString, amount) {
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
try {
|
10
|
+
const res = await injector_1.Injector.httpClient.post(`${this.apiUrl}/price`, {
|
11
|
+
from: sourceAssetString,
|
12
|
+
to: targetAssetString,
|
13
|
+
amount
|
14
|
+
});
|
15
|
+
if ('converted' in res.result) {
|
16
|
+
throw new errors_1.RubicSdkError('converted');
|
17
|
+
}
|
18
|
+
return res.result.totalFee;
|
19
|
+
}
|
20
|
+
catch (e) {
|
21
|
+
const err = e;
|
22
|
+
if (e.message?.includes('converted') || 'converted' in err.error) {
|
23
|
+
throw new errors_1.NotSupportedTokensError();
|
24
|
+
}
|
25
|
+
return err.error.totalFee;
|
16
26
|
}
|
17
|
-
return res.result.totalFee;
|
18
27
|
}
|
19
28
|
static async fetchChainsLimits() {
|
20
29
|
const { result: chains } = await injector_1.Injector.httpClient.get(`${this.apiUrl}/limits`);
|
21
30
|
return chains;
|
22
31
|
}
|
23
32
|
static async fetchInfoForTx(p) {
|
24
|
-
let res = {};
|
25
33
|
try {
|
26
|
-
res = await injector_1.Injector.httpClient.post(`${this.apiUrl}/swap`, {
|
34
|
+
const res = await injector_1.Injector.httpClient.post(`${this.apiUrl}/swap`, {
|
27
35
|
from: p.sourceAssetString,
|
28
36
|
to: p.targetAssetString,
|
29
37
|
amount: p.amount,
|
@@ -31,19 +39,17 @@ class MesonCcrApiService {
|
|
31
39
|
fromContract: p.useProxy,
|
32
40
|
recipient: p.receiverAddress
|
33
41
|
});
|
34
|
-
|
35
|
-
|
36
|
-
if ('error' in res) {
|
37
|
-
if ('converted' in res.error) {
|
38
|
-
throw new errors_1.NotSupportedTokensError();
|
42
|
+
if ('converted' in res.result) {
|
43
|
+
throw new errors_1.RubicSdkError('converted');
|
39
44
|
}
|
40
|
-
return res.
|
45
|
+
return res.result;
|
41
46
|
}
|
42
|
-
|
43
|
-
|
47
|
+
catch (e) {
|
48
|
+
const err = e;
|
49
|
+
if (e.message?.includes('converted') || 'converted' in err.error) {
|
44
50
|
throw new errors_1.NotSupportedTokensError();
|
45
51
|
}
|
46
|
-
return
|
52
|
+
return err.error;
|
47
53
|
}
|
48
54
|
}
|
49
55
|
/**
|
@@ -52,27 +58,35 @@ class MesonCcrApiService {
|
|
52
58
|
* @param initiator If on proxy - rubic-multiproxy address, if direct - wallet address
|
53
59
|
*/
|
54
60
|
static async fetchTxStatus(srcTxHash) {
|
55
|
-
|
56
|
-
|
57
|
-
|
61
|
+
try {
|
62
|
+
const res = await injector_1.Injector.httpClient.get(`${this.apiUrl}/swap`, {
|
63
|
+
params: {
|
64
|
+
hash: srcTxHash
|
65
|
+
}
|
66
|
+
});
|
67
|
+
if (res.result.expired) {
|
68
|
+
return {
|
69
|
+
hash: null,
|
70
|
+
status: tx_status_1.TX_STATUS.FAIL
|
71
|
+
};
|
72
|
+
}
|
73
|
+
if (res.result.EXECUTED) {
|
74
|
+
return {
|
75
|
+
hash: res.result.EXECUTED,
|
76
|
+
status: tx_status_1.TX_STATUS.SUCCESS
|
77
|
+
};
|
58
78
|
}
|
59
|
-
});
|
60
|
-
if ('error' in res || res.result.expired) {
|
61
79
|
return {
|
62
80
|
hash: null,
|
63
|
-
status: tx_status_1.TX_STATUS.
|
81
|
+
status: tx_status_1.TX_STATUS.PENDING
|
64
82
|
};
|
65
83
|
}
|
66
|
-
|
84
|
+
catch {
|
67
85
|
return {
|
68
|
-
hash:
|
69
|
-
status: tx_status_1.TX_STATUS.
|
86
|
+
hash: null,
|
87
|
+
status: tx_status_1.TX_STATUS.PENDING
|
70
88
|
};
|
71
89
|
}
|
72
|
-
return {
|
73
|
-
hash: null,
|
74
|
-
status: tx_status_1.TX_STATUS.PENDING
|
75
|
-
};
|
76
90
|
}
|
77
91
|
}
|
78
92
|
exports.MesonCcrApiService = MesonCcrApiService;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"meson-cross-chain-api-service.js","sourceRoot":"","sources":["../../../../../../../src/features/cross-chain/calculation-manager/providers/meson-provider/services/meson-cross-chain-api-service.ts"],"names":[],"mappings":";;;AAAA,
|
1
|
+
{"version":3,"file":"meson-cross-chain-api-service.js","sourceRoot":"","sources":["../../../../../../../src/features/cross-chain/calculation-manager/providers/meson-provider/services/meson-cross-chain-api-service.ts"],"names":[],"mappings":";;;AAAA,8CAA2E;AAC3E,oGAAiG;AACjG,yDAAsD;AActD,MAAa,kBAAkB;IAGpB,MAAM,CAAC,KAAK,CAAC,aAAa,CAC7B,iBAAyB,EACzB,iBAAyB,EACzB,MAAc;QAEd,IAAI;YACA,MAAM,GAAG,GAAG,MAAM,mBAAQ,CAAC,UAAU,CAAC,IAAI,CACtC,GAAG,IAAI,CAAC,MAAM,QAAQ,EACtB;gBACI,IAAI,EAAE,iBAAiB;gBACvB,EAAE,EAAE,iBAAiB;gBACrB,MAAM;aACT,CACJ,CAAC;YAEF,IAAI,WAAW,IAAI,GAAG,CAAC,MAAM,EAAE;gBAC3B,MAAM,IAAI,sBAAa,CAAC,WAAW,CAAC,CAAC;aACxC;YAED,OAAO,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC;SAC9B;QAAC,OAAO,CAAU,EAAE;YACjB,MAAM,GAAG,GAAG,CAA+B,CAAC;YAC5C,IAAK,CAAmB,CAAC,OAAO,EAAE,QAAQ,CAAC,WAAW,CAAC,IAAI,WAAW,IAAI,GAAG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