Skip to content

Commit

Permalink
fix: contracts with no private / public functions should not fail to …
Browse files Browse the repository at this point in the history
…generate a contract artifact (#11744)

If there were no public / private functions, the abi structs for
functions is undefined. In the previous case, with any private / public
function, unconstrained functions would just not exist in the
abistructs, and returnTypes would stay an empty array, but if there were
no private / public functions, abiStructs would be undefined and we
would throw an error. This fixes that.
  • Loading branch information
sklppy88 authored Feb 5, 2025
1 parent 8cc3f0a commit 672171c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions yarn-project/types/src/abi/contract_artifact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ function generateFunctionArtifact(
}

let returnTypes: AbiType[] = [];
if (functionType === FunctionType.UNCONSTRAINED && fn.abi.return_type) {
returnTypes = [fn.abi.return_type.abi_type];
if (functionType === FunctionType.UNCONSTRAINED) {
returnTypes = fn.abi.return_type ? [fn.abi.return_type.abi_type] : returnTypes;
} else {
const pathToFind = `${contract.name}::${fn.name}_abi`;
const abiStructs: AbiType[] = contract.outputs.structs['functions'];
Expand Down

0 comments on commit 672171c

Please sign in to comment.