Skip to content

Commit

Permalink
802-150, fix Meson (#772)
Browse files Browse the repository at this point in the history
  • Loading branch information
IDIDOS authored Dec 28, 2024
2 parents b18d273 + 9ad79a1 commit 638e206
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rubic-sdk",
"version": "5.49.9",
"version": "5.49.10",
"description": "Simplify dApp creation",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,15 @@ export class MesonCrossChainProvider extends CrossChainProvider {
sourceToken.tokenAmount.toFixed()
);

const min = Math.max(Number(sourceTokenInfo.min), Number(targetTokenInfo.min));
const max = Math.min(Number(sourceTokenInfo.max), Number(targetTokenInfo.max));

return {
mesonFee,
sourceAssetString,
targetAssetString,
min: new BigNumber(sourceTokenInfo.min),
max: new BigNumber(sourceTokenInfo.max)
min: new BigNumber(min),
max: new BigNumber(max)
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ export type MesonErrorRes<T> = {
error: {
error: {
code: number;
data: {
swapData: T;
};
data: T;
message: string;
};
};
Expand Down Expand Up @@ -89,6 +87,10 @@ export interface TxFeeSchema {
converted?: { amount: string; token: string };
}

export interface ErrorFeeResp {
fee: string;
}

export interface TxStatusSchema {
expired?: boolean;
LOCKED: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { TxStatusData } from 'src/features/common/status-manager/models/tx-statu

import {
EncodeSwapSchema,
ErrorFeeResp,
FetchEncodedParamRequest,
MesonErrorRes,
MesonLimitsChain,
Expand Down Expand Up @@ -38,9 +39,9 @@ export class MesonCcrApiService {

return res.result.totalFee;
} catch (e: unknown) {
const res = this.parseMesonError<TxFeeSchema>(e);
const res = this.parseMesonError<ErrorFeeResp>(e);

return res.totalFee;
return res.fee;
}
}

Expand Down Expand Up @@ -127,16 +128,12 @@ export class MesonCcrApiService {

const {
error: {
error: {
data: { swapData }
}
error: { data }
}
} = err as MesonErrorRes<T>;

if ('converted' in swapData) {
throw new NotSupportedTokensError();
}
if (!data || 'converted' in data) throw new NotSupportedTokensError();

return swapData;
return data;
}
}

0 comments on commit 638e206

Please sign in to comment.