Skip to content

Commit

Permalink
fix: cairo isCairo1Abi optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
tabaktoni committed Sep 23, 2023
1 parent 54ffca4 commit da76508
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions src/utils/calldata/cairo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,11 @@ export const getArrayType = (type: string) => {
* ```
*/
export function isCairo1Abi(abi: Abi): boolean {
const firstFunction = abi.find((entry) => entry.type === 'function');
if (!firstFunction) {
if (abi.find((it) => it.type === 'interface')) {
// Expected in Cairo1 version 2
return true;
}
throw new Error(`Error in ABI. No function in ABI.`);
const { cairo } = getAbiContractVersion(abi);
if (cairo === undefined) {
throw Error('Unable to determine Cairo version');
}
if (firstFunction.inputs.length) {
return isCairo1Type(firstFunction.inputs[0].type);
}
if (firstFunction.outputs.length) {
return isCairo1Type(firstFunction.outputs[0].type);
}
throw new Error(`Error in ABI. No input/output in function ${firstFunction.name}`);
return cairo === '1';
}

/**
Expand Down

0 comments on commit da76508

Please sign in to comment.