@aztec/protocol-contracts 1.2.1 → 2.0.0-nightly.20250813
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/artifacts/AuthRegistry.json +778 -680
- package/artifacts/ContractClassRegistry.json +8374 -0
- package/artifacts/ContractInstanceRegistry.json +3636 -0
- package/artifacts/FeeJuice.json +729 -647
- package/artifacts/MultiCallEntrypoint.json +670 -544
- package/artifacts/Router.json +1204 -932
- package/dest/{class-registerer/contract_class_registered_event.d.ts → class-registry/contract_class_published_event.d.ts} +5 -5
- package/dest/class-registry/contract_class_published_event.d.ts.map +1 -0
- package/dest/{class-registerer/contract_class_registered_event.js → class-registry/contract_class_published_event.js} +5 -5
- package/dest/class-registry/index.d.ts +8 -0
- package/dest/class-registry/index.d.ts.map +1 -0
- package/dest/{class-registerer → class-registry}/index.js +6 -6
- package/dest/{class-registerer → class-registry}/lazy.d.ts +3 -3
- package/dest/class-registry/lazy.d.ts.map +1 -0
- package/dest/{class-registerer → class-registry}/lazy.js +7 -7
- package/dest/{class-registerer → class-registry}/private_function_broadcasted_event.d.ts +1 -1
- package/dest/class-registry/private_function_broadcasted_event.d.ts.map +1 -0
- package/dest/{class-registerer → class-registry}/private_function_broadcasted_event.js +3 -3
- package/dest/{class-registerer → class-registry}/utility_function_broadcasted_event.d.ts +1 -1
- package/dest/class-registry/utility_function_broadcasted_event.d.ts.map +1 -0
- package/dest/{class-registerer → class-registry}/utility_function_broadcasted_event.js +3 -3
- package/dest/{instance-deployer/contract_instance_deployed_event.d.ts → instance-registry/contract_instance_published_event.d.ts} +5 -5
- package/dest/instance-registry/contract_instance_published_event.d.ts.map +1 -0
- package/dest/{instance-deployer/contract_instance_deployed_event.js → instance-registry/contract_instance_published_event.js} +5 -5
- package/dest/{instance-deployer → instance-registry}/contract_instance_updated_event.d.ts +1 -1
- package/dest/{instance-deployer → instance-registry}/contract_instance_updated_event.d.ts.map +1 -1
- package/dest/{instance-deployer → instance-registry}/contract_instance_updated_event.js +3 -3
- package/dest/{instance-deployer → instance-registry}/index.d.ts +3 -3
- package/dest/instance-registry/index.d.ts.map +1 -0
- package/dest/{instance-deployer → instance-registry}/index.js +5 -5
- package/dest/{instance-deployer → instance-registry}/lazy.d.ts +3 -3
- package/dest/{instance-deployer → instance-registry}/lazy.d.ts.map +1 -1
- package/dest/{instance-deployer → instance-registry}/lazy.js +7 -7
- package/dest/make_protocol_contract.js +2 -2
- package/dest/protocol_contract_data.d.ts +4 -4
- package/dest/protocol_contract_data.d.ts.map +1 -1
- package/dest/protocol_contract_data.js +14 -14
- package/dest/provider/bundle.js +4 -4
- package/dest/provider/lazy.js +6 -6
- package/dest/scripts/generate_data.js +8 -8
- package/dest/tests/fixtures.d.ts +2 -2
- package/dest/tests/fixtures.d.ts.map +1 -1
- package/dest/tests/fixtures.js +4 -4
- package/package.json +6 -6
- package/src/class-registry/__snapshots__/README.md +9 -0
- package/src/{class-registerer/contract_class_registered_event.ts → class-registry/contract_class_published_event.ts} +7 -7
- package/src/{class-registerer → class-registry}/index.ts +6 -8
- package/src/{class-registerer → class-registry}/lazy.ts +7 -7
- package/src/{class-registerer → class-registry}/private_function_broadcasted_event.ts +4 -4
- package/src/{class-registerer → class-registry}/utility_function_broadcasted_event.ts +4 -4
- package/src/instance-registry/__snapshots__/README.md +9 -0
- package/src/{instance-deployer/contract_instance_deployed_event.ts → instance-registry/contract_instance_published_event.ts} +6 -6
- package/src/{instance-deployer → instance-registry}/contract_instance_updated_event.ts +4 -4
- package/src/{instance-deployer → instance-registry}/index.ts +6 -6
- package/src/{instance-deployer → instance-registry}/lazy.ts +7 -7
- package/src/make_protocol_contract.ts +2 -2
- package/src/protocol_contract_data.ts +14 -14
- package/src/provider/bundle.ts +4 -4
- package/src/provider/lazy.ts +6 -6
- package/src/tests/fixtures.ts +4 -4
- package/artifacts/ContractClassRegisterer.json +0 -7806
- package/artifacts/ContractInstanceDeployer.json +0 -3525
- package/dest/class-registerer/contract_class_registered_event.d.ts.map +0 -1
- package/dest/class-registerer/index.d.ts +0 -8
- package/dest/class-registerer/index.d.ts.map +0 -1
- package/dest/class-registerer/lazy.d.ts.map +0 -1
- package/dest/class-registerer/private_function_broadcasted_event.d.ts.map +0 -1
- package/dest/class-registerer/utility_function_broadcasted_event.d.ts.map +0 -1
- package/dest/instance-deployer/contract_instance_deployed_event.d.ts.map +0 -1
- package/dest/instance-deployer/index.d.ts.map +0 -1
- /package/artifacts/{ContractClassRegisterer.d.json.ts → ContractClassRegistry.d.json.ts} +0 -0
- /package/artifacts/{ContractInstanceDeployer.d.json.ts → ContractInstanceRegistry.d.json.ts} +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { CANONICAL_AUTH_REGISTRY_ADDRESS,
|
|
1
|
+
import { CANONICAL_AUTH_REGISTRY_ADDRESS, CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS, CONTRACT_INSTANCE_PUBLISHED_MAGIC_VALUE, CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS, FEE_JUICE_ADDRESS, MULTI_CALL_ENTRYPOINT_ADDRESS, ROUTER_ADDRESS } from '@aztec/constants';
|
|
2
2
|
import { poseidon2Hash } from '@aztec/foundation/crypto';
|
|
3
3
|
import { Fr } from '@aztec/foundation/fields';
|
|
4
4
|
import { createConsoleLogger } from '@aztec/foundation/log';
|
|
5
5
|
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
6
6
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
7
|
-
import {
|
|
7
|
+
import { getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
|
|
8
8
|
import { promises as fs } from 'fs';
|
|
9
9
|
import path from 'path';
|
|
10
10
|
import { buildProtocolContractTree } from '../build_protocol_contract_tree.js';
|
|
@@ -16,8 +16,8 @@ const outputFilePath = './src/protocol_contract_data.ts';
|
|
|
16
16
|
const salt = new Fr(1);
|
|
17
17
|
const contractAddressMapping = {
|
|
18
18
|
AuthRegistry: CANONICAL_AUTH_REGISTRY_ADDRESS,
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
ContractInstanceRegistry: CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS,
|
|
20
|
+
ContractClassRegistry: CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS,
|
|
21
21
|
MultiCallEntrypoint: MULTI_CALL_ENTRYPOINT_ADDRESS,
|
|
22
22
|
FeeJuice: FEE_JUICE_ADDRESS,
|
|
23
23
|
Router: ROUTER_ADDRESS
|
|
@@ -50,7 +50,7 @@ async function copyArtifact(srcName, destName) {
|
|
|
50
50
|
return artifact;
|
|
51
51
|
}
|
|
52
52
|
async function computeContractLeaf(artifact) {
|
|
53
|
-
const instance = await
|
|
53
|
+
const instance = await getContractInstanceFromInstantiationParams(loadContractArtifact(artifact), {
|
|
54
54
|
salt
|
|
55
55
|
});
|
|
56
56
|
return instance.address;
|
|
@@ -111,9 +111,9 @@ async function generateRoot(names, leaves) {
|
|
|
111
111
|
// Generate the siloed log tags for events emitted via private logs.
|
|
112
112
|
async function generateLogTags() {
|
|
113
113
|
return `
|
|
114
|
-
export const
|
|
115
|
-
|
|
116
|
-
|
|
114
|
+
export const CONTRACT_INSTANCE_PUBLISHED_EVENT_TAG = Fr.fromHexString('${await poseidon2Hash([
|
|
115
|
+
CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS,
|
|
116
|
+
CONTRACT_INSTANCE_PUBLISHED_MAGIC_VALUE
|
|
117
117
|
])}');
|
|
118
118
|
`;
|
|
119
119
|
}
|
package/dest/tests/fixtures.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare function
|
|
1
|
+
export declare function getSampleContractClassPublishedEventPayload(): Buffer;
|
|
2
2
|
export declare function getSamplePrivateFunctionBroadcastedEventPayload(): Buffer;
|
|
3
3
|
export declare function getSampleUtilityFunctionBroadcastedEventPayload(): Buffer;
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function getSampleContractInstancePublishedEventPayload(): Buffer;
|
|
5
5
|
export declare function getPathToFixture(name: string): string;
|
|
6
6
|
//# sourceMappingURL=fixtures.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../src/tests/fixtures.ts"],"names":[],"mappings":"AAKA,wBAAgB,
|
|
1
|
+
{"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../src/tests/fixtures.ts"],"names":[],"mappings":"AAKA,wBAAgB,2CAA2C,IAAI,MAAM,CAGpE;AAGD,wBAAgB,+CAA+C,IAAI,MAAM,CAGxE;AAGD,wBAAgB,+CAA+C,IAAI,MAAM,CAGxE;AAGD,wBAAgB,8CAA8C,IAAI,MAAM,CAGvE;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,UAE5C"}
|
package/dest/tests/fixtures.js
CHANGED
|
@@ -2,8 +2,8 @@ import { readFileSync } from 'fs';
|
|
|
2
2
|
import { dirname, resolve } from 'path';
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
// Generated from end-to-end/src/e2e_deploy_contract/contract_class_registration.test.ts with AZTEC_GENERATE_TEST_DATA=1
|
|
5
|
-
export function
|
|
6
|
-
const path = getPathToFixture('
|
|
5
|
+
export function getSampleContractClassPublishedEventPayload() {
|
|
6
|
+
const path = getPathToFixture('ContractClassPublishedEventData.hex');
|
|
7
7
|
return Buffer.from(readFileSync(path).toString(), 'hex');
|
|
8
8
|
}
|
|
9
9
|
// Generated from end-to-end/src/e2e_deploy_contract/contract_class_registration.test.ts with AZTEC_GENERATE_TEST_DATA=1
|
|
@@ -17,8 +17,8 @@ export function getSampleUtilityFunctionBroadcastedEventPayload() {
|
|
|
17
17
|
return Buffer.from(readFileSync(path).toString(), 'hex');
|
|
18
18
|
}
|
|
19
19
|
// Generated from end-to-end/src/e2e_deploy_contract/contract_class_registration.test.ts with AZTEC_GENERATE_TEST_DATA=1
|
|
20
|
-
export function
|
|
21
|
-
const path = getPathToFixture('
|
|
20
|
+
export function getSampleContractInstancePublishedEventPayload() {
|
|
21
|
+
const path = getPathToFixture('ContractInstancePublishedEventData.hex');
|
|
22
22
|
return Buffer.from(readFileSync(path).toString(), 'hex');
|
|
23
23
|
}
|
|
24
24
|
export function getPathToFixture(name) {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@aztec/protocol-contracts",
|
|
3
3
|
"homepage": "https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/protocol-contracts",
|
|
4
4
|
"description": "Canonical Noir contracts for the Aztec Network",
|
|
5
|
-
"version": "
|
|
5
|
+
"version": "2.0.0-nightly.20250813",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": "./dest/index.js",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"typedocOptions": {
|
|
15
15
|
"entryPoints": [
|
|
16
16
|
"./src/index.ts",
|
|
17
|
-
"./src/class-
|
|
18
|
-
"./src/instance-
|
|
17
|
+
"./src/class-registry/index.ts",
|
|
18
|
+
"./src/instance-registry/index.ts"
|
|
19
19
|
],
|
|
20
20
|
"name": "Protocol Contracts",
|
|
21
21
|
"tsconfig": "./tsconfig.json"
|
|
@@ -73,9 +73,9 @@
|
|
|
73
73
|
]
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
|
-
"@aztec/constants": "
|
|
77
|
-
"@aztec/foundation": "
|
|
78
|
-
"@aztec/stdlib": "
|
|
76
|
+
"@aztec/constants": "2.0.0-nightly.20250813",
|
|
77
|
+
"@aztec/foundation": "2.0.0-nightly.20250813",
|
|
78
|
+
"@aztec/stdlib": "2.0.0-nightly.20250813",
|
|
79
79
|
"lodash.chunk": "^4.2.0",
|
|
80
80
|
"lodash.omit": "^4.5.0",
|
|
81
81
|
"tslib": "^2.4.0"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CONTRACT_CLASS_PUBLISHED_MAGIC_VALUE } from '@aztec/constants';
|
|
2
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
3
|
import { FieldReader } from '@aztec/foundation/serialize';
|
|
4
4
|
import { bufferFromFields } from '@aztec/stdlib/abi';
|
|
@@ -11,8 +11,8 @@ import type { ContractClassLog } from '@aztec/stdlib/logs';
|
|
|
11
11
|
|
|
12
12
|
import { ProtocolContractAddress } from '../protocol_contract_data.js';
|
|
13
13
|
|
|
14
|
-
/** Event emitted from the
|
|
15
|
-
export class
|
|
14
|
+
/** Event emitted from the ContractClassRegistry. */
|
|
15
|
+
export class ContractClassPublishedEvent {
|
|
16
16
|
constructor(
|
|
17
17
|
public readonly contractClassId: Fr,
|
|
18
18
|
public readonly version: number,
|
|
@@ -21,10 +21,10 @@ export class ContractClassRegisteredEvent {
|
|
|
21
21
|
public readonly packedPublicBytecode: Buffer,
|
|
22
22
|
) {}
|
|
23
23
|
|
|
24
|
-
static
|
|
24
|
+
static isContractClassPublishedEvent(log: ContractClassLog) {
|
|
25
25
|
return (
|
|
26
|
-
log.contractAddress.equals(ProtocolContractAddress.
|
|
27
|
-
log.fields.fields[0].toBigInt() ===
|
|
26
|
+
log.contractAddress.equals(ProtocolContractAddress.ContractClassRegistry) &&
|
|
27
|
+
log.fields.fields[0].toBigInt() === CONTRACT_CLASS_PUBLISHED_MAGIC_VALUE
|
|
28
28
|
);
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -37,7 +37,7 @@ export class ContractClassRegisteredEvent {
|
|
|
37
37
|
const privateFunctionsRoot = reader.readField();
|
|
38
38
|
const packedPublicBytecode = bufferFromFields(reader.readFieldArray(fieldsWithoutTag.length - reader.cursor));
|
|
39
39
|
|
|
40
|
-
return new
|
|
40
|
+
return new ContractClassPublishedEvent(
|
|
41
41
|
contractClassId,
|
|
42
42
|
version,
|
|
43
43
|
artifactHash,
|
|
@@ -1,25 +1,23 @@
|
|
|
1
1
|
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
2
2
|
import type { NoirCompiledContract } from '@aztec/stdlib/noir';
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import ContractClassRegistryJson from '../../artifacts/ContractClassRegistry.json' with { type: 'json' };
|
|
5
5
|
import { makeProtocolContract } from '../make_protocol_contract.js';
|
|
6
6
|
import type { ProtocolContract } from '../protocol_contract.js';
|
|
7
7
|
|
|
8
|
-
export * from './
|
|
8
|
+
export * from './contract_class_published_event.js';
|
|
9
9
|
export * from './private_function_broadcasted_event.js';
|
|
10
10
|
export * from './utility_function_broadcasted_event.js';
|
|
11
11
|
|
|
12
|
-
export const
|
|
13
|
-
ContractClassRegistererJson as NoirCompiledContract,
|
|
14
|
-
);
|
|
12
|
+
export const ContractClassRegistryArtifact = loadContractArtifact(ContractClassRegistryJson as NoirCompiledContract);
|
|
15
13
|
|
|
16
14
|
let protocolContract: ProtocolContract;
|
|
17
15
|
|
|
18
16
|
/** Returns the canonical deployment of the contract. */
|
|
19
|
-
export async function
|
|
17
|
+
export async function getCanonicalClassRegistry(): Promise<ProtocolContract> {
|
|
20
18
|
if (!protocolContract) {
|
|
21
|
-
const artifact =
|
|
22
|
-
protocolContract = await makeProtocolContract('
|
|
19
|
+
const artifact = ContractClassRegistryArtifact;
|
|
20
|
+
protocolContract = await makeProtocolContract('ContractClassRegistry', artifact);
|
|
23
21
|
}
|
|
24
22
|
return protocolContract;
|
|
25
23
|
}
|
|
@@ -3,31 +3,31 @@ import { type ContractArtifact, loadContractArtifact } from '@aztec/stdlib/abi';
|
|
|
3
3
|
import { makeProtocolContract } from '../make_protocol_contract.js';
|
|
4
4
|
import type { ProtocolContract } from '../protocol_contract.js';
|
|
5
5
|
|
|
6
|
-
export * from './
|
|
6
|
+
export * from './contract_class_published_event.js';
|
|
7
7
|
export * from './private_function_broadcasted_event.js';
|
|
8
8
|
export * from './utility_function_broadcasted_event.js';
|
|
9
9
|
|
|
10
10
|
let protocolContract: ProtocolContract;
|
|
11
11
|
let protocolContractArtifact: ContractArtifact;
|
|
12
12
|
|
|
13
|
-
export async function
|
|
13
|
+
export async function getContractClassRegistryArtifact(): Promise<ContractArtifact> {
|
|
14
14
|
if (!protocolContractArtifact) {
|
|
15
15
|
// Cannot assert this import as it's incompatible with browsers
|
|
16
16
|
// https://caniuse.com/mdn-javascript_statements_import_import_assertions_type_json
|
|
17
17
|
// Use the new "with" syntax once supported by firefox
|
|
18
18
|
// https://caniuse.com/mdn-javascript_statements_import_import_attributes_type_json
|
|
19
19
|
// In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
|
|
20
|
-
const { default:
|
|
21
|
-
protocolContractArtifact = loadContractArtifact(
|
|
20
|
+
const { default: contractClassRegistryJson } = await import('../../artifacts/ContractClassRegistry.json');
|
|
21
|
+
protocolContractArtifact = loadContractArtifact(contractClassRegistryJson);
|
|
22
22
|
}
|
|
23
23
|
return protocolContractArtifact;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/** Returns the canonical deployment of the auth registry. */
|
|
27
|
-
export async function
|
|
27
|
+
export async function getCanonicalClassRegistry(): Promise<ProtocolContract> {
|
|
28
28
|
if (!protocolContract) {
|
|
29
|
-
const
|
|
30
|
-
protocolContract = await makeProtocolContract('
|
|
29
|
+
const contractClassRegistryArtifact = await getContractClassRegistryArtifact();
|
|
30
|
+
protocolContract = await makeProtocolContract('ContractClassRegistry', contractClassRegistryArtifact);
|
|
31
31
|
}
|
|
32
32
|
return protocolContract;
|
|
33
33
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ARTIFACT_FUNCTION_TREE_MAX_HEIGHT,
|
|
3
|
+
CONTRACT_CLASS_REGISTRY_PRIVATE_FUNCTION_BROADCASTED_MAGIC_VALUE,
|
|
3
4
|
FUNCTION_TREE_HEIGHT,
|
|
4
5
|
MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS,
|
|
5
|
-
REGISTERER_PRIVATE_FUNCTION_BROADCASTED_MAGIC_VALUE,
|
|
6
6
|
} from '@aztec/constants';
|
|
7
7
|
import { Fr } from '@aztec/foundation/fields';
|
|
8
8
|
import type { Tuple } from '@aztec/foundation/serialize';
|
|
@@ -13,7 +13,7 @@ import type { ContractClassLog } from '@aztec/stdlib/logs';
|
|
|
13
13
|
|
|
14
14
|
import { ProtocolContractAddress } from '../protocol_contract_data.js';
|
|
15
15
|
|
|
16
|
-
/** Event emitted from the
|
|
16
|
+
/** Event emitted from the ContractClassRegistry. */
|
|
17
17
|
export class PrivateFunctionBroadcastedEvent {
|
|
18
18
|
constructor(
|
|
19
19
|
public readonly contractClassId: Fr,
|
|
@@ -28,8 +28,8 @@ export class PrivateFunctionBroadcastedEvent {
|
|
|
28
28
|
|
|
29
29
|
static isPrivateFunctionBroadcastedEvent(log: ContractClassLog) {
|
|
30
30
|
return (
|
|
31
|
-
log.contractAddress.equals(ProtocolContractAddress.
|
|
32
|
-
log.fields.fields[0].toBigInt() ===
|
|
31
|
+
log.contractAddress.equals(ProtocolContractAddress.ContractClassRegistry) &&
|
|
32
|
+
log.fields.fields[0].toBigInt() === CONTRACT_CLASS_REGISTRY_PRIVATE_FUNCTION_BROADCASTED_MAGIC_VALUE
|
|
33
33
|
);
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ARTIFACT_FUNCTION_TREE_MAX_HEIGHT,
|
|
3
|
+
CONTRACT_CLASS_REGISTRY_UTILITY_FUNCTION_BROADCASTED_MAGIC_VALUE,
|
|
3
4
|
MAX_PACKED_BYTECODE_SIZE_PER_UTILITY_FUNCTION_IN_FIELDS,
|
|
4
|
-
REGISTERER_UTILITY_FUNCTION_BROADCASTED_MAGIC_VALUE,
|
|
5
5
|
} from '@aztec/constants';
|
|
6
6
|
import { removeArrayPaddingEnd } from '@aztec/foundation/collection';
|
|
7
7
|
import { Fr } from '@aztec/foundation/fields';
|
|
@@ -13,7 +13,7 @@ import type { ContractClassLog } from '@aztec/stdlib/logs';
|
|
|
13
13
|
|
|
14
14
|
import { ProtocolContractAddress } from '../protocol_contract_data.js';
|
|
15
15
|
|
|
16
|
-
/** Event emitted from the
|
|
16
|
+
/** Event emitted from the ContractClassRegistry. */
|
|
17
17
|
export class UtilityFunctionBroadcastedEvent {
|
|
18
18
|
constructor(
|
|
19
19
|
public readonly contractClassId: Fr,
|
|
@@ -26,8 +26,8 @@ export class UtilityFunctionBroadcastedEvent {
|
|
|
26
26
|
|
|
27
27
|
static isUtilityFunctionBroadcastedEvent(log: ContractClassLog) {
|
|
28
28
|
return (
|
|
29
|
-
log.contractAddress.equals(ProtocolContractAddress.
|
|
30
|
-
log.fields.fields[0].toBigInt() ===
|
|
29
|
+
log.contractAddress.equals(ProtocolContractAddress.ContractClassRegistry) &&
|
|
30
|
+
log.fields.fields[0].toBigInt() === CONTRACT_CLASS_REGISTRY_UTILITY_FUNCTION_BROADCASTED_MAGIC_VALUE
|
|
31
31
|
);
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -5,10 +5,10 @@ import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
|
5
5
|
import { PublicKeys } from '@aztec/stdlib/keys';
|
|
6
6
|
import type { PrivateLog } from '@aztec/stdlib/logs';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import { CONTRACT_INSTANCE_PUBLISHED_EVENT_TAG } from '../protocol_contract_data.js';
|
|
9
9
|
|
|
10
|
-
/** Event emitted from the
|
|
11
|
-
export class
|
|
10
|
+
/** Event emitted from the ContractInstanceRegistry. */
|
|
11
|
+
export class ContractInstancePublishedEvent {
|
|
12
12
|
constructor(
|
|
13
13
|
public readonly address: AztecAddress,
|
|
14
14
|
public readonly version: number,
|
|
@@ -19,8 +19,8 @@ export class ContractInstanceDeployedEvent {
|
|
|
19
19
|
public readonly deployer: AztecAddress,
|
|
20
20
|
) {}
|
|
21
21
|
|
|
22
|
-
static
|
|
23
|
-
return log.fields[0].equals(
|
|
22
|
+
static isContractInstancePublishedEvent(log: PrivateLog) {
|
|
23
|
+
return log.fields[0].equals(CONTRACT_INSTANCE_PUBLISHED_EVENT_TAG);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
static fromLog(log: PrivateLog) {
|
|
@@ -34,7 +34,7 @@ export class ContractInstanceDeployedEvent {
|
|
|
34
34
|
const publicKeys = reader.readObject(PublicKeys);
|
|
35
35
|
const deployer = reader.readObject(AztecAddress);
|
|
36
36
|
|
|
37
|
-
return new
|
|
37
|
+
return new ContractInstancePublishedEvent(
|
|
38
38
|
address,
|
|
39
39
|
version,
|
|
40
40
|
salt,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CONTRACT_INSTANCE_UPDATED_MAGIC_VALUE } from '@aztec/constants';
|
|
2
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
3
|
import { BufferReader } from '@aztec/foundation/serialize';
|
|
4
4
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -8,7 +8,7 @@ import type { UInt64 } from '@aztec/stdlib/types';
|
|
|
8
8
|
|
|
9
9
|
import { ProtocolContractAddress } from '../protocol_contract_data.js';
|
|
10
10
|
|
|
11
|
-
/** Event emitted from the
|
|
11
|
+
/** Event emitted from the ContractInstanceRegistry. */
|
|
12
12
|
export class ContractInstanceUpdatedEvent {
|
|
13
13
|
constructor(
|
|
14
14
|
public readonly address: AztecAddress,
|
|
@@ -19,8 +19,8 @@ export class ContractInstanceUpdatedEvent {
|
|
|
19
19
|
|
|
20
20
|
static isContractInstanceUpdatedEvent(log: PublicLog) {
|
|
21
21
|
return (
|
|
22
|
-
log.contractAddress.equals(ProtocolContractAddress.
|
|
23
|
-
log.fields[0].toBigInt() ===
|
|
22
|
+
log.contractAddress.equals(ProtocolContractAddress.ContractInstanceRegistry) &&
|
|
23
|
+
log.fields[0].toBigInt() === CONTRACT_INSTANCE_UPDATED_MAGIC_VALUE
|
|
24
24
|
);
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
2
2
|
import type { NoirCompiledContract } from '@aztec/stdlib/noir';
|
|
3
3
|
|
|
4
|
-
import
|
|
4
|
+
import ContractInstanceRegistryJson from '../../artifacts/ContractInstanceRegistry.json' with { type: 'json' };
|
|
5
5
|
import { makeProtocolContract } from '../make_protocol_contract.js';
|
|
6
6
|
import type { ProtocolContract } from '../protocol_contract.js';
|
|
7
7
|
|
|
8
|
-
export * from './
|
|
8
|
+
export * from './contract_instance_published_event.js';
|
|
9
9
|
export * from './contract_instance_updated_event.js';
|
|
10
10
|
|
|
11
|
-
export const
|
|
12
|
-
|
|
11
|
+
export const ContractInstanceRegistryArtifact = loadContractArtifact(
|
|
12
|
+
ContractInstanceRegistryJson as NoirCompiledContract,
|
|
13
13
|
);
|
|
14
14
|
|
|
15
15
|
let protocolContract: ProtocolContract;
|
|
16
16
|
|
|
17
17
|
/** Returns the canonical deployment of the contract. */
|
|
18
|
-
export async function
|
|
18
|
+
export async function getCanonicalInstanceRegistry(): Promise<ProtocolContract> {
|
|
19
19
|
if (!protocolContract) {
|
|
20
|
-
protocolContract = await makeProtocolContract('
|
|
20
|
+
protocolContract = await makeProtocolContract('ContractInstanceRegistry', ContractInstanceRegistryArtifact);
|
|
21
21
|
}
|
|
22
22
|
return protocolContract;
|
|
23
23
|
}
|
|
@@ -3,30 +3,30 @@ import { type ContractArtifact, loadContractArtifact } from '@aztec/stdlib/abi';
|
|
|
3
3
|
import { makeProtocolContract } from '../make_protocol_contract.js';
|
|
4
4
|
import type { ProtocolContract } from '../protocol_contract.js';
|
|
5
5
|
|
|
6
|
-
export * from './
|
|
6
|
+
export * from './contract_instance_published_event.js';
|
|
7
7
|
export * from './contract_instance_updated_event.js';
|
|
8
8
|
|
|
9
9
|
let protocolContract: ProtocolContract;
|
|
10
10
|
let protocolContractArtifact: ContractArtifact;
|
|
11
11
|
|
|
12
|
-
export async function
|
|
12
|
+
export async function getContractInstanceRegistryArtifact(): Promise<ContractArtifact> {
|
|
13
13
|
if (!protocolContractArtifact) {
|
|
14
14
|
// Cannot assert this import as it's incompatible with browsers
|
|
15
15
|
// https://caniuse.com/mdn-javascript_statements_import_import_assertions_type_json
|
|
16
16
|
// Use the new "with" syntax once supported by firefox
|
|
17
17
|
// https://caniuse.com/mdn-javascript_statements_import_import_attributes_type_json
|
|
18
18
|
// In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
|
|
19
|
-
const { default:
|
|
20
|
-
protocolContractArtifact = loadContractArtifact(
|
|
19
|
+
const { default: contractInstanceRegistryJson } = await import('../../artifacts/ContractInstanceRegistry.json');
|
|
20
|
+
protocolContractArtifact = loadContractArtifact(contractInstanceRegistryJson);
|
|
21
21
|
}
|
|
22
22
|
return protocolContractArtifact;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/** Returns the canonical deployment of the auth registry. */
|
|
26
|
-
export async function
|
|
26
|
+
export async function getCanonicalInstanceRegistry(): Promise<ProtocolContract> {
|
|
27
27
|
if (!protocolContract) {
|
|
28
|
-
const
|
|
29
|
-
protocolContract = await makeProtocolContract('
|
|
28
|
+
const contractInstanceRegistryArtifact = await getContractInstanceRegistryArtifact();
|
|
29
|
+
protocolContract = await makeProtocolContract('ContractInstanceRegistry', contractInstanceRegistryArtifact);
|
|
30
30
|
}
|
|
31
31
|
return protocolContract;
|
|
32
32
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
2
|
-
import { getContractClassFromArtifact,
|
|
2
|
+
import { getContractClassFromArtifact, getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
|
|
3
3
|
|
|
4
4
|
import type { ProtocolContract } from './protocol_contract.js';
|
|
5
5
|
import { ProtocolContractAddress, type ProtocolContractName, ProtocolContractSalt } from './protocol_contract_data.js';
|
|
@@ -16,7 +16,7 @@ export async function makeProtocolContract(
|
|
|
16
16
|
const salt = ProtocolContractSalt[name];
|
|
17
17
|
// TODO(@spalladino): This computes the contract class from the artifact twice.
|
|
18
18
|
const contractClass = await getContractClassFromArtifact(artifact);
|
|
19
|
-
const instance = await
|
|
19
|
+
const instance = await getContractInstanceFromInstantiationParams(artifact, { salt });
|
|
20
20
|
return {
|
|
21
21
|
instance: { ...instance, address },
|
|
22
22
|
contractClass,
|
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
export const protocolContractNames = [
|
|
8
8
|
'AuthRegistry',
|
|
9
|
-
'
|
|
10
|
-
'
|
|
9
|
+
'ContractInstanceRegistry',
|
|
10
|
+
'ContractClassRegistry',
|
|
11
11
|
'MultiCallEntrypoint',
|
|
12
12
|
'FeeJuice',
|
|
13
13
|
'Router'
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
|
|
20
20
|
export const ProtocolContractSalt: Record<ProtocolContractName, Fr> = {
|
|
21
21
|
AuthRegistry: new Fr(1),
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
ContractInstanceRegistry: new Fr(1),
|
|
23
|
+
ContractClassRegistry: new Fr(1),
|
|
24
24
|
MultiCallEntrypoint: new Fr(1),
|
|
25
25
|
FeeJuice: new Fr(1),
|
|
26
26
|
Router: new Fr(1)
|
|
@@ -30,8 +30,8 @@ Router: new Fr(1)
|
|
|
30
30
|
|
|
31
31
|
export const ProtocolContractAddress: Record<ProtocolContractName, AztecAddress> = {
|
|
32
32
|
AuthRegistry: AztecAddress.fromBigInt(1n),
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
ContractInstanceRegistry: AztecAddress.fromBigInt(2n),
|
|
34
|
+
ContractClassRegistry: AztecAddress.fromBigInt(3n),
|
|
35
35
|
MultiCallEntrypoint: AztecAddress.fromBigInt(4n),
|
|
36
36
|
FeeJuice: AztecAddress.fromBigInt(5n),
|
|
37
37
|
Router: AztecAddress.fromBigInt(6n)
|
|
@@ -40,20 +40,20 @@ Router: AztecAddress.fromBigInt(6n)
|
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
export const ProtocolContractLeaves = {
|
|
43
|
-
AuthRegistry: Fr.fromHexString('
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
MultiCallEntrypoint: Fr.fromHexString('
|
|
47
|
-
FeeJuice: Fr.fromHexString('
|
|
48
|
-
Router: Fr.fromHexString('
|
|
43
|
+
AuthRegistry: Fr.fromHexString('0x0789f6cb8356ce8d99f1173ce12232925aa61eb511e58a9b219b9548221a9147'),
|
|
44
|
+
ContractInstanceRegistry: Fr.fromHexString('0x236bb82e4b4c5ed15d7cf6d7922a865c7a894023b8d6de6c1bd9f3f26ec6a8ec'),
|
|
45
|
+
ContractClassRegistry: Fr.fromHexString('0x015e83a2205aa99d698426c8f788185df5d8a7b44020a43ab1b77f3313cd5fdc'),
|
|
46
|
+
MultiCallEntrypoint: Fr.fromHexString('0x1c6a82b9e3aa1cc8106270090201f47e43273f079271d9122b3b4563d554c40c'),
|
|
47
|
+
FeeJuice: Fr.fromHexString('0x18862ab00fb03f7e566ad42d2d79f4274cf71499a8eca648289320f529fe1293'),
|
|
48
|
+
Router: Fr.fromHexString('0x1a090e8ce78e960012ef09c2bb32d6691540b2cba5b88abfb8bdb19d6d3d894c')
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
|
|
53
|
-
export const protocolContractTreeRoot = Fr.fromHexString('
|
|
53
|
+
export const protocolContractTreeRoot = Fr.fromHexString('0x0ce924440a6c63d9f268ac8686b7c75e9cc73cb2b8a57680c9af544cb47d10d6');
|
|
54
54
|
|
|
55
55
|
|
|
56
56
|
|
|
57
|
-
export const
|
|
57
|
+
export const CONTRACT_INSTANCE_PUBLISHED_EVENT_TAG = Fr.fromHexString('0x28da3fc471387d4e20b646b77abc8cdfc02a339a7507285a73d84f9b97b13486');
|
|
58
58
|
|
|
59
59
|
|
package/src/provider/bundle.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
2
2
|
|
|
3
3
|
import { AuthRegistryArtifact } from '../auth-registry/index.js';
|
|
4
|
-
import {
|
|
4
|
+
import { ContractClassRegistryArtifact } from '../class-registry/index.js';
|
|
5
5
|
import { FeeJuiceArtifact } from '../fee-juice/index.js';
|
|
6
|
-
import {
|
|
6
|
+
import { ContractInstanceRegistryArtifact } from '../instance-registry/index.js';
|
|
7
7
|
import { makeProtocolContract } from '../make_protocol_contract.js';
|
|
8
8
|
import { MultiCallEntrypointArtifact } from '../multi-call-entrypoint/index.js';
|
|
9
9
|
import type { ProtocolContract } from '../protocol_contract.js';
|
|
@@ -13,8 +13,8 @@ import type { ProtocolContractsProvider } from './protocol_contracts_provider.js
|
|
|
13
13
|
|
|
14
14
|
export const ProtocolContractArtifact: Record<ProtocolContractName, ContractArtifact> = {
|
|
15
15
|
AuthRegistry: AuthRegistryArtifact,
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
ContractInstanceRegistry: ContractInstanceRegistryArtifact,
|
|
17
|
+
ContractClassRegistry: ContractClassRegistryArtifact,
|
|
18
18
|
MultiCallEntrypoint: MultiCallEntrypointArtifact,
|
|
19
19
|
FeeJuice: FeeJuiceArtifact,
|
|
20
20
|
Router: RouterArtifact,
|
package/src/provider/lazy.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getCanonicalAuthRegistry } from '../auth-registry/lazy.js';
|
|
2
|
-
import {
|
|
2
|
+
import { getCanonicalClassRegistry } from '../class-registry/lazy.js';
|
|
3
3
|
import { getCanonicalFeeJuice } from '../fee-juice/lazy.js';
|
|
4
|
-
import {
|
|
4
|
+
import { getCanonicalInstanceRegistry } from '../instance-registry/lazy.js';
|
|
5
5
|
import { getCanonicalMultiCallEntrypoint } from '../multi-call-entrypoint/lazy.js';
|
|
6
6
|
import type { ProtocolContract } from '../protocol_contract.js';
|
|
7
7
|
import type { ProtocolContractName } from '../protocol_contract_data.js';
|
|
@@ -13,10 +13,10 @@ export class LazyProtocolContractsProvider implements ProtocolContractsProvider
|
|
|
13
13
|
switch (name) {
|
|
14
14
|
case 'AuthRegistry':
|
|
15
15
|
return getCanonicalAuthRegistry();
|
|
16
|
-
case '
|
|
17
|
-
return
|
|
18
|
-
case '
|
|
19
|
-
return
|
|
16
|
+
case 'ContractInstanceRegistry':
|
|
17
|
+
return getCanonicalInstanceRegistry();
|
|
18
|
+
case 'ContractClassRegistry':
|
|
19
|
+
return getCanonicalClassRegistry();
|
|
20
20
|
case 'MultiCallEntrypoint':
|
|
21
21
|
return getCanonicalMultiCallEntrypoint();
|
|
22
22
|
case 'FeeJuice':
|
package/src/tests/fixtures.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { dirname, resolve } from 'path';
|
|
|
3
3
|
import { fileURLToPath } from 'url';
|
|
4
4
|
|
|
5
5
|
// Generated from end-to-end/src/e2e_deploy_contract/contract_class_registration.test.ts with AZTEC_GENERATE_TEST_DATA=1
|
|
6
|
-
export function
|
|
7
|
-
const path = getPathToFixture('
|
|
6
|
+
export function getSampleContractClassPublishedEventPayload(): Buffer {
|
|
7
|
+
const path = getPathToFixture('ContractClassPublishedEventData.hex');
|
|
8
8
|
return Buffer.from(readFileSync(path).toString(), 'hex');
|
|
9
9
|
}
|
|
10
10
|
|
|
@@ -21,8 +21,8 @@ export function getSampleUtilityFunctionBroadcastedEventPayload(): Buffer {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
// Generated from end-to-end/src/e2e_deploy_contract/contract_class_registration.test.ts with AZTEC_GENERATE_TEST_DATA=1
|
|
24
|
-
export function
|
|
25
|
-
const path = getPathToFixture('
|
|
24
|
+
export function getSampleContractInstancePublishedEventPayload(): Buffer {
|
|
25
|
+
const path = getPathToFixture('ContractInstancePublishedEventData.hex');
|
|
26
26
|
return Buffer.from(readFileSync(path).toString(), 'hex');
|
|
27
27
|
}
|
|
28
28
|
|