diff --git a/__tests__/cairo1v2.test.ts b/__tests__/cairo1v2.test.ts index e83119d2a..71fd988ee 100644 --- a/__tests__/cairo1v2.test.ts +++ b/__tests__/cairo1v2.test.ts @@ -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); diff --git a/src/utils/calldata/propertyOrder.ts b/src/utils/calldata/propertyOrder.ts index 14f19b7d0..44d88b909 100644 --- a/src/utils/calldata/propertyOrder.ts +++ b/src/utils/calldata/propertyOrder.ts @@ -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') { @@ -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; }; diff --git a/src/utils/encode.ts b/src/utils/encode.ts index e72d13fcc..cb0110c2b 100644 --- a/src/utils/encode.ts +++ b/src/utils/encode.ts @@ -80,7 +80,9 @@ export function utf8ToArray(str: string): Uint8Array { * @returns string */ export const pascalToSnake = (text: string) => - text - .split(/(?=[A-Z])/) - .join('_') - .toUpperCase(); + !/[a-z]/.test(text) + ? text + .split(/(?=[A-Z])/) + .join('_') + .toUpperCase() + : text;