Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Parse instance deployed event #4482

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
@@ -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));
Copy link
Member

@Maddiaa0 Maddiaa0 Feb 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const ethAddr = reader.readObject(EthAddress);

based on this line by did this need to change? It appears to work elsewhrere

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The number of bytes read (ie how many bytes the buffer reader advances) changed from 32 to 20 in #4442.

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
Loading