Skip to content

Commit

Permalink
Merge pull request #738 from 0xs34n/next-version
Browse files Browse the repository at this point in the history
Next version
  • Loading branch information
tabaktoni authored Aug 29, 2023
2 parents 0c15422 + f9a3e1b commit abd674b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 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
10 changes: 6 additions & 4 deletions src/utils/encode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

0 comments on commit abd674b

Please sign in to comment.