Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ export async function deployAndInitializeTokenAndBridgeContracts(
throw new Error(`Token admin is not ${owner}`);
}

// TODO(#3641) - Fix deserialization and compare AztecAddress directly
if ((await bridge.methods.token().view()).inner !== token.address.toBigInt()) {
if (!(await bridge.methods.token().view()).equals(token.address)) {
throw new Error(`Bridge token is not ${token.address}`);
}

Expand Down
8 changes: 7 additions & 1 deletion yarn-project/foundation/src/abi/decoder.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { AztecAddress } from '../aztec-address/index.js';
import { Fr } from '../fields/index.js';
import { ABIParameter, type ABIType, ABIVariable, FunctionArtifact } from './abi.js';
import { isAztecAddressStruct } from './utils.js';

/**
* The type of our decoded ABI.
*/
export type DecodedReturn = bigint | boolean | DecodedReturn[] | { [key: string]: DecodedReturn };
export type DecodedReturn = bigint | boolean | AztecAddress | DecodedReturn[] | { [key: string]: DecodedReturn };

/**
* Decodes return values from a function call.
Expand Down Expand Up @@ -38,6 +40,10 @@ class ReturnValuesDecoder {
}
case 'struct': {
const struct: { [key: string]: DecodedReturn } = {};
if (isAztecAddressStruct(abiType)) {
return new AztecAddress(this.getNextField().toBuffer());
}

for (const field of abiType.fields) {
struct[field.name] = this.decodeReturn(field.type);
}
Expand Down