Skip to content

Commit

Permalink
fix: use BigNumberish for u256
Browse files Browse the repository at this point in the history
in .populate & myContract.compile
  • Loading branch information
PhilippeR26 committed Aug 26, 2023
1 parent d2cc1dd commit 3a7be10
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 3 additions & 1 deletion __tests__/cairo1v2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ describe('Cairo 1 Devnet', () => {
const myCall0 = cairo1Contract.populate('test_u256', functionParameters);
const res0 = await cairo1Contract.test_u256(myCall0.calldata);
expect(res0).toBe(16n);

const myCall0a = cairo1Contract.populate('test_u256', { p1: 15 });
const res0a = await cairo1Contract.test_u256(myCall0a.calldata);
expect(res0a).toBe(16n);
// using myCallData.compile result in meta-class
const contractCallData: CallData = new CallData(cairo1Contract.abi);
const myCalldata: Calldata = contractCallData.compile('test_u256', functionParameters);
Expand Down
10 changes: 5 additions & 5 deletions src/utils/calldata/propertyOrder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ export default function orderPropsByAbi(
if (isTypeEthAddress(abiType)) {
return unorderedItem;
}
if (isTypeStruct(abiType, structs)) {
const abiOfStruct = structs[abiType].members;
// eslint-disable-next-line @typescript-eslint/no-use-before-define
return orderStruct(unorderedItem, abiOfStruct);
}
if (isTypeUint256(abiType)) {
const u256 = unorderedItem;
if (typeof u256 !== 'object') {
Expand All @@ -63,6 +58,11 @@ export default function orderPropsByAbi(
}
return { low: u256.low, high: u256.high };
}
if (isTypeStruct(abiType, structs)) {
const abiOfStruct = structs[abiType].members;
// eslint-disable-next-line @typescript-eslint/no-use-before-define
return orderStruct(unorderedItem, abiOfStruct);
}
// litterals
return unorderedItem;
};
Expand Down

0 comments on commit 3a7be10

Please sign in to comment.