Skip to content

Commit

Permalink
Fix regex for parsing formula and uint256
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementWalter committed Sep 4, 2023
1 parent 63e9501 commit e38b96d
Showing 1 changed file with 4 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BigNumber, ethers } from "ethers";
import { FunctionAbi, uint256 } from "starknet";
import { FunctionAbi } from "starknet";
import { CellData, ChainType, ContractAbi } from "../../types";
import {
ARGS_SEP,
Expand Down Expand Up @@ -56,20 +56,8 @@ export function toPlainTextFormula(
while (inputIndex < abi.inputs.length) {
const _input = abi.inputs[inputIndex];
if (_input.type === "Uint256") {
if (isDependency(calldata[argsIndex])) {
displayedArgs.push(args[argsIndex]);
if (args[argsIndex + 1] !== "0")
throw new Error("Cannot parse Uint256 input");
} else {
displayedArgs.push(
uint256
.uint256ToBN({
low: args[argsIndex],
high: args[argsIndex + 1],
})
.toString()
);
}
displayedArgs.push(args[argsIndex]);
displayedArgs.push(args[argsIndex + 1]);
argsIndex += 2;
inputIndex++;
continue;
Expand Down Expand Up @@ -203,7 +191,7 @@ export function parse(
// Add global brackets if user input is just a comma separated list
`[${rawCall.args}]`
// Quote cell names before eval
.replace(/([, [(]+)([A-O]{1}[0-9]{1,2})([, \])])/gi, '$1"$2"$3')
.replace(/([, [(]?)([A-O]{1}[0-9]{1,2})([, \])]?)/gi, '$1"$2"$3')
) as any[];

// retrieve function and corresponding abi
Expand Down

0 comments on commit e38b96d

Please sign in to comment.