Skip to content

Commit

Permalink
cli test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
benesjan committed Dec 11, 2023
1 parent e74dbb8 commit 6a982ab
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions yarn-project/foundation/src/abi/encoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,20 @@ class ArgumentEncoder {
// If the abi expects a struct like { address: Field } and the supplied arg does not have
// an address field in it, we try to encode it as if it were a field directly.
const isAddress = isAddressStruct(abiType);
if (isAddress && typeof arg.address === 'undefined') {
this.encodeArgument({ kind: 'field' }, arg, `${name}.address`);
if (isAddress && typeof arg.address === 'undefined' && typeof arg.inner === 'undefined') {
this.encodeArgument({ kind: 'field' }, arg, `${name}.inner`);
break;
}
if (isFunctionSelectorStruct(abiType)) {
this.encodeArgument({ kind: 'field' }, arg, `${name}.selector`);
this.encodeArgument({ kind: 'integer', sign: 'unsigned', width: 32 }, arg, `${name}.inner`);
break;
}
for (const field of abiType.fields) {
// For address we get here when a `CompleteAddress` was passed and since it has `address` property but
// in ABI it's called inner set `field.name` here to `address` instead of using `field.name`. I know
// it's hacky but using address.address in Noir looks stupid.
const fieldName = isAddress ? 'address' : field.name;
// The ugly check bellow is here because of a `CompleteAddress`. Since it has `address` property but in ABI
// it's called inner we set `field.name` here to `address` instead of using `field.name`. I know it's hacky
// but using address.address in Noir looks stupid and renaming `address` param of `CompleteAddress`
// to `inner` doesn't make sense.
const fieldName = isAddress && arg.address !== undefined ? 'address' : field.name;
this.encodeArgument(field.type, arg[fieldName], `${name}.${field.name}`);
}
break;
Expand Down

0 comments on commit 6a982ab

Please sign in to comment.