Skip to content

Commit

Permalink
fix: repair CallData compilation faulty ordering
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippeR26 committed Aug 16, 2023
1 parent edbd654 commit e8cbedc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions __tests__/contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,21 @@ describe('Complex interaction', () => {
)}","10","20","48","40","1","2","10","20","22","33","1","2","3","4","22","33","1","33","1415934836","123333333","0","1","2","3","1","321","322","33","0","2","123","291","3","1","2","10","20","100","200","2","111","112","121","122","211","212","221","222"]`;
expect(json.stringify(compiled)).toBe(reference);
expect(json.stringify(doubleCompiled)).toBe(reference);

// mix of complex and litteral
const mySetArgs = {
validators: [234, 235],
powers: { a1: 562, a2: 567 },
valsetNonce: uint256(49),
};
const compiledArr = CallData.compile([mySetArgs, 456789]);
const compiledObj = CallData.compile({
currentValset: mySetArgs,
relayerRouterAddress: 456789,
});
const expectedResult = ['2', '234', '235', '562', '567', '49', '0', '456789'];
expect(compiledArr).toStrictEqual(expectedResult);
expect(compiledObj).toStrictEqual(expectedResult);
});

describe('Composed and nested data types (felt, array, struct, tuples), formatter', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/calldata/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export class CallData {
*/
static compile(rawArgs: RawArgs): Calldata {
const createTree = (obj: object) => {
const getEntries = (o: object, prefix = ''): any => {
const getEntries = (o: object, prefix = '.'): any => {
const oe = Array.isArray(o) ? [o.length.toString(), ...o] : o;
return Object.entries(oe).flatMap(([k, v]) => {
let value = v;
Expand Down

0 comments on commit e8cbedc

Please sign in to comment.