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.
@@ -1,4 +1,4 @@
1
- export interface SymbiosisErrorResponse {
1
+ export interface SymbiosisMesonErrorRes {
2
2
  code: number;
3
3
  message: string;
4
4
  }
@@ -1,6 +1,6 @@
1
- import { XyQuoteErrorResponse } from './xy-quote-error-response';
1
+ import { XyQuoteMesonErrorRes } from './xy-quote-error-response';
2
2
  import { XyRoute } from './xy-quote-success-response';
3
- export interface XyBuildTxResponse extends XyQuoteErrorResponse {
3
+ export interface XyBuildTxResponse extends XyQuoteMesonErrorRes {
4
4
  success: boolean;
5
5
  route: XyRoute;
6
6
  tx: {
@@ -1,5 +1,5 @@
1
1
  import { XyErrorCode } from '../constants/xy-error-code';
2
- export interface XyQuoteErrorResponse {
2
+ export interface XyQuoteMesonErrorRes {
3
3
  success: boolean;
4
4
  errorCode: XyErrorCode;
5
5
  errorMsg: string;
@@ -1,4 +1,4 @@
1
- import { XyQuoteErrorResponse } from './xy-quote-error-response';
2
- import { XyQuoteSuccessResponse } from './xy-quote-success-response';
3
- export interface XyQuoteResponse extends XyQuoteSuccessResponse, XyQuoteErrorResponse {
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
  }
@@ -1,4 +1,4 @@
1
- export interface XyQuoteSuccessResponse {
1
+ export interface XyQuoteMesonSuccessRes {
2
2
  success: boolean;
3
3
  routes: XyRoute[];
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(httpErrorResponse) {
120
- if (httpErrorResponse?.error?.errorId === 'INCLUDED_GAS_FEE_NOT_COVERED_BY_INPUT_AMOUNT' ||
121
- httpErrorResponse?.error?.errorId === 'ERROR_LOW_GIVE_AMOUNT') {
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:
@@ -37,7 +37,7 @@ export interface DlnSolanaTransactionResponse extends TransactionResponse<DlnSol
37
37
  /**
38
38
  * Swap transaction error response.
39
39
  */
40
- export interface TransactionErrorResponse {
40
+ export interface TransactionMesonErrorRes {
41
41
  /**
42
42
  * Error code.
43
43
  */
@@ -1,7 +1,7 @@
1
- type ErrorResponse<T> = {
1
+ export type MesonErrorRes<T> = {
2
2
  error: T;
3
3
  };
4
- type SuccessResponse<T> = {
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
- const res = await injector_1.Injector.httpClient.post(`${this.apiUrl}/price`, {
10
- from: sourceAssetString,
11
- to: targetAssetString,
12
- amount
13
- });
14
- if ('error' in res || 'converted' in res.result) {
15
- throw new errors_1.NotSupportedTokensError();
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
- catch { }
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.error;
45
+ return res.result;
41
46
  }
42
- else {
43
- if ('converted' in res.result) {
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 res.result;
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
- const res = await injector_1.Injector.httpClient.get(`${this.apiUrl}/swap`, {
56
- params: {
57
- hash: srcTxHash
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.FAIL
81
+ status: tx_status_1.TX_STATUS.PENDING
64
82
  };
65
83
  }
66
- if (res.result.EXECUTED) {
84
+ catch {
67
85
  return {
68
- hash: res.result.EXECUTED,
69
- status: tx_status_1.TX_STATUS.SUCCESS
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,8CAA4D;AAC5D,oGAAiG;AACjG,yDAAsD;AAatD,MAAa,kBAAkB;IAGpB,MAAM,CAAC,KAAK,CAAC,aAAa,CAC7B,iBAAyB,EACzB,iBAAyB,EACzB,MAAc;QAEd,MAAM,GAAG,GAAG,MAAM,mBAAQ,CAAC,UAAU,CAAC,IAAI,CAAgB,GAAG,IAAI,CAAC,MAAM,QAAQ,EAAE;YAC9E,IAAI,EAAE,iBAAiB;YACvB,EAAE,EAAE,iBAAiB;YACrB,MAAM;SACT,CAAC,CAAC;QAEH,IAAI,OAAO,IAAI,GAAG,IAAI,WAAW,IAAI,GAAG,CAAC,MAAM,EAAE;YAC7C,MAAM,IAAI,gCAAuB,EAAE,CAAC;SACvC;QAED,OAAO,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC;IAC/B,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,iBAAiB;QACjC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,mBAAQ,CAAC,UAAU,CAAC,GAAG,CACpD,GAAG,IAAI,CAAC,MAAM,SAAS,CAC1B,CAAC;QAEF,OAAO,MAAM,CAAC;IAClB,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,cAAc,CAAC,CAA2B;QAC1D,IAAI,GAAG,GAAuB,EAAwB,CAAC;QAEvD,IAAI;YACA,GAAG,GAAG,MAAM,mBAAQ,CAAC,UAAU,CAAC,IAAI,CAAqB,GAAG,IAAI,CAAC,MAAM,OAAO,EAAE;gBAC5E,IAAI,EAAE,CAAC,CAAC,iBAAiB;gBACzB,EAAE,EAAE,CAAC,CAAC,iBAAiB;gBACvB,MAAM,EAAE,CAAC,CAAC,MAAM;gBAChB,WAAW,EAAE,CAAC,CAAC,WAAW;gBAC1B,YAAY,EAAE,CAAC,CAAC,QAAQ;gBACxB,SAAS,EAAE,CAAC,CAAC,eAAe;aAC/B,CAAC,CAAC;SACN;QAAC,MAAM,GAAE;QAEV,IAAI,OAAO,IAAI,GAAG,EAAE;YAChB,IAAI,WAAW,IAAI,GAAG,CAAC,KAAK,EAAE;gBAC1B,MAAM,IAAI,gCAAuB,EAAE,CAAC;aACvC;YACD,OAAO,GAAG,CAAC,KAAK,CAAC;SACpB;aAAM;YACH,IAAI,WAAW,IAAI,GAAG,CAAC,MAAM,EAAE;gBAC3B,MAAM,IAAI,gCAAuB,EAAE,CAAC;aACvC;YACD,OAAO,GAAG,CAAC,MAAM,CAAC;SACrB;IACL,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,SAAiB;QAC/C,MAAM,GAAG,GAAG,MAAM,mBAAQ,CAAC,UAAU,CAAC,GAAG,CAAmB,GAAG,IAAI,CAAC,MAAM,OAAO,EAAE;YAC/E,MAAM,EAAE;gBACJ,IAAI,EAAE,SAAS;aAClB;SACJ,CAAC,CAAC;QAEH,IAAI,OAAO,IAAI,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,EAAE;YACtC,OAAO;gBACH,IAAI,EAAE,IAAI;gBACV,MAAM,EAAE,qBAAS,CAAC,IAAI;aACzB,CAAC;SACL;QAED,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,EAAE;YACrB,OAAO;gBACH,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,QAAQ;gBACzB,MAAM,EAAE,qBAAS,CAAC,OAAO;aAC5B,CAAC;SACL;QAED,OAAO;YACH,IAAI,EAAE,IAAI;YACV,MAAM,EAAE,qBAAS,CAAC,OAAO;SAC5B,CAAC;IACN,CAAC;;AAtFL,gDAuFC;AAtFkB,yBAAM,GAAG,iCAAiC,CAAC"}
1
+ {"version":3,"file":"meson-cross-chain-api-service.js","sourceRoot":"","sources":["../../../../../../../src/features/cross-chain/calculation-manager/providers/meson-provider/services/meson-cross-ch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,CAAC,OAAO;aAC5B,CAAC;SACL;QAAC,MAAM;YACJ,OAAO;gBACH,IAAI,EAAE,IAAI;gBACV,MAAM,EAAE,qBAAS,CAAC,OAAO;aAC5B,CAAC;SACL;IACL,CAAC;;AA9GL,gDA+GC;AA9GkB,yBAAM,GAAG,iCAAiC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rubic-sdk",
3
- "version": "5.18.0-alpha.meson.3",
3
+ "version": "5.18.0-alpha.meson.4",
4
4
  "description": "Simplify dApp creation",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",