Skip to content

Commit

Permalink
fix: Parse instance deployed event (AztecProtocol#4482)
Browse files Browse the repository at this point in the history
Fixes the `e2e_deploy` test broken in master due to the changes to
EthAddress deserialization introduced in AztecProtocol#4442.
  • Loading branch information
spalladino committed Feb 7, 2024
1 parent 7e2f283 commit d0e0801
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0000000085864497636cf755ae7bde03f267ce01a520981c21c3682aaf82a631173b1e288f0f29f945ffa7b4ec2b69393e32b78501d0f193288e4a886a9f6e18000000000000000000000000000000000000000000000000000000000000000113554cdde23fee1efdb34bb3f685929e9098b8328083970984754948007e11ea0798434d6f2adf997c4fe3d14cb8468aa3cbf7a70d8c499c3c775fc8feff67960f68e30db11bc73392acfc02600ad1177cbe0d17cbbb5d3086a592b736f414a8000000000000000000000000507a47e77fc808e31716c47865eb372b2a487b7505331ff473c938df8b7a6dba01cf45bd6b029d4aeeff7e76953b31ef2510f7b80000000000000000000000000000000000000000000000000000000000000000
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { getSampleContractInstanceDeployedEventPayload } from '../tests/fixtures.js';
import { ContractInstanceDeployedEvent } from './contract_instance_deployed_event.js';

describe('ContractInstanceDeployedEvent', () => {
it('parses an event as emitted by the ClassInstanceDeployer', () => {
const data = getSampleContractInstanceDeployedEventPayload();
const event = ContractInstanceDeployedEvent.fromLogData(data);
expect(event.address.toString()).toEqual('0x173b1e288f0f29f945ffa7b4ec2b69393e32b78501d0f193288e4a886a9f6e18');
expect(event.contractClassId.toString()).toEqual(
'0x0798434d6f2adf997c4fe3d14cb8468aa3cbf7a70d8c499c3c775fc8feff6796',
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class ContractInstanceDeployedEvent {
const salt = reader.readObject(Fr);
const contractClassId = reader.readObject(Fr);
const initializationHash = reader.readObject(Fr);
const portalContractAddress = reader.readObject(EthAddress);
const portalContractAddress = EthAddress.fromField(reader.readObject(Fr));
const publicKeysHash = reader.readObject(Fr);
const universalDeploy = reader.readObject(Fr).toBool();

Expand Down
6 changes: 6 additions & 0 deletions yarn-project/circuits.js/src/tests/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ export function getSampleContractClassRegisteredEventPayload(): Buffer {
return Buffer.from(readFileSync(path).toString(), 'hex');
}

// Copied from the test 'deploying a contract instance' in end-to-end/src/e2e_deploy_contract.test.ts
export function getSampleContractInstanceDeployedEventPayload(): Buffer {
const path = getPathToFixture('ContractInstanceDeployedEventData.hex');
return Buffer.from(readFileSync(path).toString(), 'hex');
}

function getPathToFixture(name: string) {
return resolve(dirname(fileURLToPath(import.meta.url)), `../../fixtures/${name}`);
}
3 changes: 3 additions & 0 deletions yarn-project/end-to-end/src/e2e_deploy_contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,9 @@ describe('e2e_deploy_contract', () => {
const publicKeysHash = computePublicKeysHash(publicKey);

instance = getContractInstanceFromDeployParams(artifact, initArgs, salt, publicKey, portalAddress);
logger(
`Deploying contract instance at ${instance.address.toString()} with class id ${instance.contractClassId.toString()}`,
);
const tx = await deployer.methods
.deploy(salt, contractClass.id, instance.initializationHash, portalAddress, publicKeysHash, false)
.send()
Expand Down

0 comments on commit d0e0801

Please sign in to comment.