Skip to content

Commit

Permalink
[GSW-323] fix: Fix ABCI Response Parser
Browse files Browse the repository at this point in the history
  • Loading branch information
jinoosss committed Oct 12, 2023
1 parent 066843b commit aa3fe85
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions packages/web/src/utils/rpc-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import BigNumber from "bignumber.js";

export function evaluateExpressionToNumber(evaluateExpression: string) {
try {
const regexp = /(.*?)/;
const result = Array.from(
evaluateExpression.matchAll(regexp),
match => `${match[0]}`,
);
if (result.length > 0) {
return BigNumber(result[0]).toNumber();
const regexp = /\((.*)\)/;
const result = evaluateExpression.match(regexp);
if (result === null || result.length < 1) {
return 0;
}

const parsedValue = result[1].split(" ")[0];
return BigNumber(parsedValue).toNumber();
} catch {
console.log("Parse Error: " + evaluateExpression);
}
Expand Down

0 comments on commit aa3fe85

Please sign in to comment.