@aztec/protocol-contracts 0.0.0-test.1 → 0.0.1-commit.5daedc8

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.
Files changed (132) hide show
  1. package/README.md +2 -2
  2. package/artifacts/AuthRegistry.json +2095 -1241
  3. package/artifacts/ContractClassRegistry.json +6635 -0
  4. package/artifacts/ContractInstanceRegistry.json +3629 -0
  5. package/artifacts/FeeJuice.json +2848 -2146
  6. package/artifacts/MultiCallEntrypoint.json +1594 -855
  7. package/artifacts/Router.json +698 -3537
  8. package/dest/auth-registry/index.d.ts +3 -2
  9. package/dest/auth-registry/index.d.ts.map +1 -1
  10. package/dest/auth-registry/index.js +1 -1
  11. package/dest/auth-registry/lazy.d.ts +1 -1
  12. package/dest/auth-registry/lazy.js +4 -4
  13. package/dest/class-registry/contract_class_published_event.d.ts +17 -0
  14. package/dest/class-registry/contract_class_published_event.d.ts.map +1 -0
  15. package/dest/{class-registerer/contract_class_registered_event.js → class-registry/contract_class_published_event.js} +15 -20
  16. package/dest/class-registry/index.d.ts +8 -0
  17. package/dest/class-registry/index.d.ts.map +1 -0
  18. package/dest/class-registry/index.js +17 -0
  19. package/dest/class-registry/lazy.d.ts +9 -0
  20. package/dest/class-registry/lazy.d.ts.map +1 -0
  21. package/dest/class-registry/lazy.js +26 -0
  22. package/dest/class-registry/private_function_broadcasted_event.d.ts +40 -0
  23. package/dest/class-registry/private_function_broadcasted_event.d.ts.map +1 -0
  24. package/dest/{class-registerer → class-registry}/private_function_broadcasted_event.js +11 -11
  25. package/dest/class-registry/utility_function_broadcasted_event.d.ts +35 -0
  26. package/dest/class-registry/utility_function_broadcasted_event.d.ts.map +1 -0
  27. package/dest/{class-registerer/unconstrained_function_broadcasted_event.js → class-registry/utility_function_broadcasted_event.js} +19 -19
  28. package/dest/fee-juice/index.d.ts +1 -1
  29. package/dest/fee-juice/index.js +1 -1
  30. package/dest/fee-juice/lazy.d.ts +1 -1
  31. package/dest/fee-juice/lazy.js +4 -4
  32. package/dest/index.d.ts +1 -2
  33. package/dest/index.d.ts.map +1 -1
  34. package/dest/index.js +0 -1
  35. package/dest/instance-registry/contract_instance_published_event.d.ts +21 -0
  36. package/dest/instance-registry/contract_instance_published_event.d.ts.map +1 -0
  37. package/dest/{instance-deployer/contract_instance_deployed_event.js → instance-registry/contract_instance_published_event.js} +8 -5
  38. package/dest/instance-registry/contract_instance_updated_event.d.ts +17 -0
  39. package/dest/instance-registry/contract_instance_updated_event.d.ts.map +1 -0
  40. package/dest/instance-registry/contract_instance_updated_event.js +35 -0
  41. package/dest/instance-registry/index.d.ts +7 -0
  42. package/dest/instance-registry/index.d.ts.map +1 -0
  43. package/dest/{instance-deployer → instance-registry}/index.js +5 -5
  44. package/dest/instance-registry/lazy.d.ts +8 -0
  45. package/dest/{instance-deployer → instance-registry}/lazy.d.ts.map +1 -1
  46. package/dest/instance-registry/lazy.js +25 -0
  47. package/dest/make_protocol_contract.d.ts +1 -1
  48. package/dest/make_protocol_contract.js +2 -2
  49. package/dest/multi-call-entrypoint/index.d.ts +1 -1
  50. package/dest/multi-call-entrypoint/index.js +1 -1
  51. package/dest/multi-call-entrypoint/lazy.d.ts +1 -1
  52. package/dest/multi-call-entrypoint/lazy.js +4 -4
  53. package/dest/protocol_contract.d.ts +1 -1
  54. package/dest/protocol_contract_data.d.ts +13 -15
  55. package/dest/protocol_contract_data.d.ts.map +1 -1
  56. package/dest/protocol_contract_data.js +29 -19
  57. package/dest/provider/bundle.d.ts +1 -1
  58. package/dest/provider/bundle.d.ts.map +1 -1
  59. package/dest/provider/bundle.js +4 -4
  60. package/dest/provider/lazy.d.ts +1 -1
  61. package/dest/provider/lazy.d.ts.map +1 -1
  62. package/dest/provider/lazy.js +6 -6
  63. package/dest/provider/protocol_contracts_provider.d.ts +1 -1
  64. package/dest/router/index.d.ts +1 -1
  65. package/dest/router/index.js +1 -1
  66. package/dest/router/lazy.d.ts +1 -1
  67. package/dest/router/lazy.js +4 -4
  68. package/dest/scripts/cleanup_artifacts.js +2 -2
  69. package/dest/scripts/generate_data.js +38 -45
  70. package/dest/tests/fixtures.d.ts +4 -6
  71. package/dest/tests/fixtures.d.ts.map +1 -1
  72. package/dest/tests/fixtures.js +6 -6
  73. package/package.json +23 -20
  74. package/src/auth-registry/index.ts +3 -3
  75. package/src/auth-registry/lazy.ts +4 -4
  76. package/src/class-registry/__snapshots__/README.md +9 -0
  77. package/src/{class-registerer/contract_class_registered_event.ts → class-registry/contract_class_published_event.ts} +22 -22
  78. package/src/{class-registerer → class-registry}/index.ts +7 -9
  79. package/src/class-registry/lazy.ts +33 -0
  80. package/src/{class-registerer → class-registry}/private_function_broadcasted_event.ts +12 -8
  81. package/src/{class-registerer/unconstrained_function_broadcasted_event.ts → class-registry/utility_function_broadcasted_event.ts} +25 -21
  82. package/src/fee-juice/index.ts +1 -1
  83. package/src/fee-juice/lazy.ts +4 -4
  84. package/src/index.ts +0 -1
  85. package/src/instance-registry/__snapshots__/README.md +9 -0
  86. package/src/{instance-deployer/contract_instance_deployed_event.ts → instance-registry/contract_instance_published_event.ts} +12 -6
  87. package/src/{instance-deployer → instance-registry}/contract_instance_updated_event.ts +14 -14
  88. package/src/{instance-deployer → instance-registry}/index.ts +6 -6
  89. package/src/{instance-deployer → instance-registry}/lazy.ts +11 -11
  90. package/src/make_protocol_contract.ts +2 -2
  91. package/src/multi-call-entrypoint/index.ts +1 -1
  92. package/src/multi-call-entrypoint/lazy.ts +4 -4
  93. package/src/protocol_contract_data.ts +30 -19
  94. package/src/provider/bundle.ts +4 -4
  95. package/src/provider/lazy.ts +6 -6
  96. package/src/router/index.ts +1 -1
  97. package/src/router/lazy.ts +4 -4
  98. package/src/tests/fixtures.ts +6 -6
  99. package/artifacts/ContractClassRegisterer.json +0 -7219
  100. package/artifacts/ContractInstanceDeployer.json +0 -2984
  101. package/dest/build_protocol_contract_tree.d.ts +0 -10
  102. package/dest/build_protocol_contract_tree.d.ts.map +0 -1
  103. package/dest/build_protocol_contract_tree.js +0 -20
  104. package/dest/class-registerer/contract_class_registered_event.d.ts +0 -18
  105. package/dest/class-registerer/contract_class_registered_event.d.ts.map +0 -1
  106. package/dest/class-registerer/index.d.ts +0 -8
  107. package/dest/class-registerer/index.d.ts.map +0 -1
  108. package/dest/class-registerer/index.js +0 -17
  109. package/dest/class-registerer/lazy.d.ts +0 -9
  110. package/dest/class-registerer/lazy.d.ts.map +0 -1
  111. package/dest/class-registerer/lazy.js +0 -26
  112. package/dest/class-registerer/private_function_broadcasted_event.d.ts +0 -46
  113. package/dest/class-registerer/private_function_broadcasted_event.d.ts.map +0 -1
  114. package/dest/class-registerer/unconstrained_function_broadcasted_event.d.ts +0 -40
  115. package/dest/class-registerer/unconstrained_function_broadcasted_event.d.ts.map +0 -1
  116. package/dest/instance-deployer/contract_instance_deployed_event.d.ts +0 -20
  117. package/dest/instance-deployer/contract_instance_deployed_event.d.ts.map +0 -1
  118. package/dest/instance-deployer/contract_instance_updated_event.d.ts +0 -16
  119. package/dest/instance-deployer/contract_instance_updated_event.d.ts.map +0 -1
  120. package/dest/instance-deployer/contract_instance_updated_event.js +0 -36
  121. package/dest/instance-deployer/index.d.ts +0 -7
  122. package/dest/instance-deployer/index.d.ts.map +0 -1
  123. package/dest/instance-deployer/lazy.d.ts +0 -8
  124. package/dest/instance-deployer/lazy.js +0 -25
  125. package/dest/protocol_contract_tree.d.ts +0 -7
  126. package/dest/protocol_contract_tree.d.ts.map +0 -1
  127. package/dest/protocol_contract_tree.js +0 -34
  128. package/src/build_protocol_contract_tree.ts +0 -29
  129. package/src/class-registerer/lazy.ts +0 -33
  130. package/src/protocol_contract_tree.ts +0 -44
  131. /package/artifacts/{ContractClassRegisterer.d.json.ts → ContractClassRegistry.d.json.ts} +0 -0
  132. /package/artifacts/{ContractInstanceDeployer.d.json.ts → ContractInstanceRegistry.d.json.ts} +0 -0
@@ -1,13 +1,14 @@
1
- import { CANONICAL_AUTH_REGISTRY_ADDRESS, DEPLOYER_CONTRACT_ADDRESS, DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_MAGIC_VALUE, DEPLOYER_CONTRACT_INSTANCE_UPDATED_MAGIC_VALUE, FEE_JUICE_ADDRESS, MULTI_CALL_ENTRYPOINT_ADDRESS, REGISTERER_CONTRACT_ADDRESS, REGISTERER_CONTRACT_CLASS_REGISTERED_MAGIC_VALUE, REGISTERER_PRIVATE_FUNCTION_BROADCASTED_MAGIC_VALUE, REGISTERER_UNCONSTRAINED_FUNCTION_BROADCASTED_MAGIC_VALUE, ROUTER_ADDRESS } from '@aztec/constants';
1
+ import { CANONICAL_AUTH_REGISTRY_ADDRESS, CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS, CONTRACT_INSTANCE_PUBLISHED_MAGIC_VALUE, CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS, FEE_JUICE_ADDRESS, MAX_PROTOCOL_CONTRACTS, MULTI_CALL_ENTRYPOINT_ADDRESS, ROUTER_ADDRESS } from '@aztec/constants';
2
+ import { makeTuple } from '@aztec/foundation/array';
2
3
  import { poseidon2Hash } from '@aztec/foundation/crypto';
3
4
  import { Fr } from '@aztec/foundation/fields';
4
5
  import { createConsoleLogger } from '@aztec/foundation/log';
5
6
  import { loadContractArtifact } from '@aztec/stdlib/abi';
6
7
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
7
- import { getContractInstanceFromDeployParams } from '@aztec/stdlib/contract';
8
+ import { getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
9
+ import { ProtocolContracts } from '@aztec/stdlib/tx';
8
10
  import { promises as fs } from 'fs';
9
11
  import path from 'path';
10
- import { buildProtocolContractTree } from '../build_protocol_contract_tree.js';
11
12
  const log = createConsoleLogger('autogenerate');
12
13
  const noirContractsRoot = '../../noir-projects/noir-contracts';
13
14
  const srcPath = path.join(noirContractsRoot, './target');
@@ -16,8 +17,8 @@ const outputFilePath = './src/protocol_contract_data.ts';
16
17
  const salt = new Fr(1);
17
18
  const contractAddressMapping = {
18
19
  AuthRegistry: CANONICAL_AUTH_REGISTRY_ADDRESS,
19
- ContractInstanceDeployer: DEPLOYER_CONTRACT_ADDRESS,
20
- ContractClassRegisterer: REGISTERER_CONTRACT_ADDRESS,
20
+ ContractInstanceRegistry: CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS,
21
+ ContractClassRegistry: CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS,
21
22
  MultiCallEntrypoint: MULTI_CALL_ENTRYPOINT_ADDRESS,
22
23
  FeeJuice: FEE_JUICE_ADDRESS,
23
24
  Router: ROUTER_ADDRESS
@@ -49,20 +50,12 @@ async function copyArtifact(srcName, destName) {
49
50
  await fs.copyFile(src, dest);
50
51
  return artifact;
51
52
  }
52
- async function computeContractLeaf(artifact) {
53
- const instance = await getContractInstanceFromDeployParams(loadContractArtifact(artifact), {
53
+ async function computeAddress(artifact) {
54
+ const instance = await getContractInstanceFromInstantiationParams(loadContractArtifact(artifact), {
54
55
  salt
55
56
  });
56
57
  return instance.address;
57
58
  }
58
- async function computeRoot(names, leaves) {
59
- const data = names.map((name, i)=>({
60
- address: new AztecAddress(new Fr(contractAddressMapping[name])),
61
- leaf: leaves[i]
62
- }));
63
- const tree = await buildProtocolContractTree(data);
64
- return Fr.fromBuffer(tree.root);
65
- }
66
59
  async function generateDeclarationFile(destName) {
67
60
  const content = `
68
61
  import type { NoirCompiledContract } from '@aztec/stdlib/noir';
@@ -95,46 +88,47 @@ function generateContractAddresses(names) {
95
88
  };
96
89
  `;
97
90
  }
98
- function generateContractLeaves(names, leaves) {
91
+ function generateDerivedAddresses(names, derivedAddresses) {
99
92
  return `
100
- export const ProtocolContractLeaves = {
101
- ${leaves.map((leaf, i)=>`${names[i]}: Fr.fromHexString('${leaf.toString()}')`).join(',\n')}
93
+ export const ProtocolContractDerivedAddress = {
94
+ ${derivedAddresses.map((address, i)=>`${names[i]}: AztecAddress.fromString('${address.toString()}')`).join(',\n')}
102
95
  };
103
96
  `;
104
97
  }
105
- async function generateRoot(names, leaves) {
106
- const root = await computeRoot(names, leaves);
98
+ async function generateProtocolContractsList(names, derivedAddresses) {
99
+ const list = makeTuple(MAX_PROTOCOL_CONTRACTS, ()=>AztecAddress.zero());
100
+ for(let i = 0; i < names.length; i++){
101
+ const name = names[i];
102
+ const address = contractAddressMapping[name];
103
+ const derivedAddressIndex = address - 1;
104
+ if (!list[derivedAddressIndex].equals(AztecAddress.zero())) {
105
+ throw new Error(`Duplicate protocol contract address: ${address.toString()}`);
106
+ }
107
+ list[derivedAddressIndex] = derivedAddresses[i];
108
+ }
107
109
  return `
108
- export const protocolContractTreeRoot = Fr.fromHexString('${root.toString()}');
110
+ export const ProtocolContractsList = new ProtocolContracts([
111
+ ${list.map((address)=>`AztecAddress.fromString('${address.toString()}')`).join(',\n')}
112
+ ]);
113
+
114
+ export const protocolContractsHash = Fr.fromString('${(await new ProtocolContracts(list).hash()).toString()}');
109
115
  `;
110
116
  }
117
+ // Generate the siloed log tags for events emitted via private logs.
111
118
  async function generateLogTags() {
112
- // See silo_contract_class_log for all registerer tags
113
119
  return `
114
- export const REGISTERER_CONTRACT_CLASS_REGISTERED_TAG = Fr.fromHexString('${await poseidon2Hash([
115
- REGISTERER_CONTRACT_ADDRESS,
116
- REGISTERER_CONTRACT_CLASS_REGISTERED_MAGIC_VALUE
117
- ])}');
118
- export const REGISTERER_PRIVATE_FUNCTION_BROADCASTED_TAG = Fr.fromHexString('${await poseidon2Hash([
119
- REGISTERER_CONTRACT_ADDRESS,
120
- REGISTERER_PRIVATE_FUNCTION_BROADCASTED_MAGIC_VALUE
121
- ])}');
122
- export const REGISTERER_UNCONSTRAINED_FUNCTION_BROADCASTED_TAG = Fr.fromHexString('${await poseidon2Hash([
123
- REGISTERER_CONTRACT_ADDRESS,
124
- REGISTERER_UNCONSTRAINED_FUNCTION_BROADCASTED_MAGIC_VALUE
125
- ])}');
126
- export const DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_TAG = Fr.fromHexString('${await poseidon2Hash([
127
- DEPLOYER_CONTRACT_ADDRESS,
128
- DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_MAGIC_VALUE
120
+ export const CONTRACT_INSTANCE_PUBLISHED_EVENT_TAG = Fr.fromHexString('${await poseidon2Hash([
121
+ CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS,
122
+ CONTRACT_INSTANCE_PUBLISHED_MAGIC_VALUE
129
123
  ])}');
130
- export const DEPLOYER_CONTRACT_INSTANCE_UPDATED_TAG = new Fr(${DEPLOYER_CONTRACT_INSTANCE_UPDATED_MAGIC_VALUE}n);
131
124
  `;
132
125
  }
133
- async function generateOutputFile(names, leaves) {
126
+ async function generateOutputFile(names, derivedAddresses) {
134
127
  const content = `
135
128
  // GENERATED FILE - DO NOT EDIT. RUN \`yarn generate\` or \`yarn generate:data\`
136
129
  import { Fr } from '@aztec/foundation/fields';
137
130
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
131
+ import { ProtocolContracts } from '@aztec/stdlib/tx';
138
132
 
139
133
  ${generateNames(names)}
140
134
 
@@ -142,9 +136,9 @@ async function generateOutputFile(names, leaves) {
142
136
 
143
137
  ${generateContractAddresses(names)}
144
138
 
145
- ${generateContractLeaves(names, leaves)}
139
+ ${generateDerivedAddresses(names, derivedAddresses)}
146
140
 
147
- ${await generateRoot(names, leaves)}
141
+ ${await generateProtocolContractsList(names, derivedAddresses)}
148
142
 
149
143
  ${await generateLogTags()}
150
144
  `;
@@ -153,17 +147,16 @@ async function generateOutputFile(names, leaves) {
153
147
  async function main() {
154
148
  await clearDestDir();
155
149
  const srcNames = JSON.parse(await fs.readFile(path.join(noirContractsRoot, 'protocol_contracts.json'), 'utf8'));
156
- const leaves = [];
150
+ const derivedAddresses = [];
157
151
  const destNames = srcNames.map((n)=>n.split('-')[1]);
158
152
  for(let i = 0; i < srcNames.length; i++){
159
153
  const srcName = srcNames[i];
160
154
  const destName = destNames[i];
161
155
  const artifact = await copyArtifact(srcName, destName);
162
156
  await generateDeclarationFile(destName);
163
- const contractLeaf = await computeContractLeaf(artifact);
164
- leaves.push(contractLeaf.toField());
157
+ derivedAddresses.push(await computeAddress(artifact));
165
158
  }
166
- await generateOutputFile(destNames, leaves);
159
+ await generateOutputFile(destNames, derivedAddresses);
167
160
  }
168
161
  try {
169
162
  await main();
@@ -1,8 +1,6 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
- export declare function getSampleContractClassRegisteredEventPayload(): Buffer;
1
+ export declare function getSampleContractClassPublishedEventPayload(): Buffer;
4
2
  export declare function getSamplePrivateFunctionBroadcastedEventPayload(): Buffer;
5
- export declare function getSampleUnconstrainedFunctionBroadcastedEventPayload(): Buffer;
6
- export declare function getSampleContractInstanceDeployedEventPayload(): Buffer;
3
+ export declare function getSampleUtilityFunctionBroadcastedEventPayload(): Buffer;
4
+ export declare function getSampleContractInstancePublishedEventPayload(): Buffer;
7
5
  export declare function getPathToFixture(name: string): string;
8
- //# sourceMappingURL=fixtures.d.ts.map
6
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZml4dHVyZXMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90ZXN0cy9maXh0dXJlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFLQSx3QkFBZ0IsMkNBQTJDLElBQUksTUFBTSxDQUdwRTtBQUdELHdCQUFnQiwrQ0FBK0MsSUFBSSxNQUFNLENBR3hFO0FBR0Qsd0JBQWdCLCtDQUErQyxJQUFJLE1BQU0sQ0FHeEU7QUFHRCx3QkFBZ0IsOENBQThDLElBQUksTUFBTSxDQUd2RTtBQUVELHdCQUFnQixnQkFBZ0IsQ0FBQyxJQUFJLEVBQUUsTUFBTSxVQUU1QyJ9
@@ -1 +1 @@
1
- {"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../src/tests/fixtures.ts"],"names":[],"mappings":";;AAKA,wBAAgB,4CAA4C,IAAI,MAAM,CAGrE;AAGD,wBAAgB,+CAA+C,IAAI,MAAM,CAGxE;AAGD,wBAAgB,qDAAqD,IAAI,MAAM,CAG9E;AAGD,wBAAgB,6CAA6C,IAAI,MAAM,CAGtE;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,UAE5C"}
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"}
@@ -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 getSampleContractClassRegisteredEventPayload() {
6
- const path = getPathToFixture('ContractClassRegisteredEventData.hex');
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
@@ -12,13 +12,13 @@ export function getSamplePrivateFunctionBroadcastedEventPayload() {
12
12
  return Buffer.from(readFileSync(path).toString(), 'hex');
13
13
  }
14
14
  // Generated from end-to-end/src/e2e_deploy_contract/contract_class_registration.test.ts with AZTEC_GENERATE_TEST_DATA=1
15
- export function getSampleUnconstrainedFunctionBroadcastedEventPayload() {
16
- const path = getPathToFixture('UnconstrainedFunctionBroadcastedEventData.hex');
15
+ export function getSampleUtilityFunctionBroadcastedEventPayload() {
16
+ const path = getPathToFixture('UtilityFunctionBroadcastedEventData.hex');
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 getSampleContractInstanceDeployedEventPayload() {
21
- const path = getPathToFixture('ContractInstanceDeployedEventData.hex');
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": "0.0.0-test.1",
5
+ "version": "0.0.1-commit.5daedc8",
6
6
  "type": "module",
7
7
  "exports": {
8
8
  ".": "./dest/index.js",
@@ -14,23 +14,21 @@
14
14
  "typedocOptions": {
15
15
  "entryPoints": [
16
16
  "./src/index.ts",
17
- "./src/class-registerer/index.ts",
18
- "./src/instance-deployer/index.ts"
17
+ "./src/class-registry/index.ts",
18
+ "./src/instance-registry/index.ts"
19
19
  ],
20
20
  "name": "Protocol Contracts",
21
21
  "tsconfig": "./tsconfig.json"
22
22
  },
23
23
  "scripts": {
24
- "build": "yarn clean && yarn generate && yarn generate:cleanup-artifacts && tsc -b",
25
- "build:keep-debug-symbols": "yarn clean && yarn generate && tsc -b",
24
+ "build": "yarn clean && yarn generate && yarn generate:cleanup-artifacts && tsgo -b",
25
+ "build:keep-debug-symbols": "yarn clean && yarn generate && tsgo -b",
26
26
  "generate": "yarn generate:data",
27
27
  "generate:cleanup-artifacts": "node --no-warnings --loader @swc-node/register/esm src/scripts/cleanup_artifacts.ts",
28
28
  "generate:data": "node --no-warnings --loader @swc-node/register/esm src/scripts/generate_data.ts",
29
- "build:dev": "tsc -b --watch",
30
- "build:ts": "tsc -b",
29
+ "build:dev": "tsgo -b --watch",
30
+ "build:ts": "tsgo -b",
31
31
  "clean": "rm -rf ./dest .tsbuildinfo ./artifacts",
32
- "formatting": "run -T prettier --check ./src && run -T eslint ./src",
33
- "formatting:fix": "run -T eslint --fix ./src && run -T prettier -w ./src",
34
32
  "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
35
33
  },
36
34
  "inherits": [
@@ -68,27 +66,32 @@
68
66
  "testTimeout": 120000,
69
67
  "setupFiles": [
70
68
  "../../foundation/src/jest/setup.mjs"
69
+ ],
70
+ "testEnvironment": "../../foundation/src/jest/env.mjs",
71
+ "setupFilesAfterEnv": [
72
+ "../../foundation/src/jest/setupAfterEnv.mjs"
71
73
  ]
72
74
  },
73
75
  "dependencies": {
74
- "@aztec/constants": "0.0.0-test.1",
75
- "@aztec/foundation": "0.0.0-test.1",
76
- "@aztec/stdlib": "0.0.0-test.1",
76
+ "@aztec/constants": "0.0.1-commit.5daedc8",
77
+ "@aztec/foundation": "0.0.1-commit.5daedc8",
78
+ "@aztec/stdlib": "0.0.1-commit.5daedc8",
77
79
  "lodash.chunk": "^4.2.0",
78
80
  "lodash.omit": "^4.5.0",
79
81
  "tslib": "^2.4.0"
80
82
  },
81
83
  "devDependencies": {
82
- "@jest/globals": "^29.5.0",
83
- "@types/jest": "^29.5.0",
84
+ "@jest/globals": "^30.0.0",
85
+ "@types/jest": "^30.0.0",
84
86
  "@types/lodash.chunk": "^4.2.9",
85
87
  "@types/lodash.omit": "^4.5.9",
86
- "@types/node": "^18.7.23",
87
- "jest": "^29.5.0",
88
- "jest-mock-extended": "^3.0.3",
89
- "ts-loader": "^9.4.4",
88
+ "@types/node": "^22.15.17",
89
+ "@typescript/native-preview": "7.0.0-dev.20251126.1",
90
+ "jest": "^30.0.0",
91
+ "jest-mock-extended": "^4.0.0",
92
+ "ts-loader": "^9.5.4",
90
93
  "ts-node": "^10.9.1",
91
- "typescript": "^5.0.4"
94
+ "typescript": "^5.3.3"
92
95
  },
93
96
  "files": [
94
97
  "dest",
@@ -98,6 +101,6 @@
98
101
  "!src/scripts/*"
99
102
  ],
100
103
  "engines": {
101
- "node": ">=18"
104
+ "node": ">=20.10"
102
105
  }
103
106
  }
@@ -1,13 +1,13 @@
1
- import { loadContractArtifact } from '@aztec/stdlib/abi';
1
+ import { type ContractArtifact, loadContractArtifact } from '@aztec/stdlib/abi';
2
2
  import type { NoirCompiledContract } from '@aztec/stdlib/noir';
3
3
 
4
- import AuthRegistryJson from '../../artifacts/AuthRegistry.json' assert { type: 'json' };
4
+ import AuthRegistryJson from '../../artifacts/AuthRegistry.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
8
  let protocolContract: ProtocolContract;
9
9
 
10
- export const AuthRegistryArtifact = loadContractArtifact(AuthRegistryJson as NoirCompiledContract);
10
+ export const AuthRegistryArtifact: ContractArtifact = loadContractArtifact(AuthRegistryJson as NoirCompiledContract);
11
11
 
12
12
  /** Returns the canonical deployment of the auth registry. */
13
13
  export async function getCanonicalAuthRegistry(): Promise<ProtocolContract> {
@@ -8,10 +8,10 @@ let protocolContractArtifact: ContractArtifact;
8
8
 
9
9
  export async function getAuthRegistryArtifact(): Promise<ContractArtifact> {
10
10
  if (!protocolContractArtifact) {
11
- // Cannot assert this import as it's incompatible with browsers
12
- // https://caniuse.com/mdn-javascript_statements_import_import_assertions_type_json
13
- // Use the new "with" syntax once supported by firefox
14
- // https://caniuse.com/mdn-javascript_statements_import_import_attributes_type_json
11
+ // Cannot assert this import as it's incompatible with bundlers like vite
12
+ // https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
13
+ // Even if now supported by al major browsers, the MIME type is replaced with
14
+ // "text/javascript"
15
15
  // In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
16
16
  const { default: authRegistryJson } = await import('../../artifacts/AuthRegistry.json');
17
17
  protocolContractArtifact = loadContractArtifact(authRegistryJson);
@@ -0,0 +1,9 @@
1
+ # How to update these snapshots
2
+
3
+ (You probably need to have done a `./bootstrap.sh` at some point)
4
+
5
+ From the root:
6
+
7
+ `cd yarn-project/protocol-contracts`
8
+
9
+ `yarn test -u`
@@ -1,19 +1,18 @@
1
- import { PUBLIC_DISPATCH_SELECTOR } from '@aztec/constants';
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
- import { FunctionSelector, bufferFromFields } from '@aztec/stdlib/abi';
4
+ import { bufferFromFields } from '@aztec/stdlib/abi';
5
5
  import {
6
6
  type ContractClassPublic,
7
- type PublicFunction,
8
7
  computeContractClassId,
9
8
  computePublicBytecodeCommitment,
10
9
  } from '@aztec/stdlib/contract';
11
10
  import type { ContractClassLog } from '@aztec/stdlib/logs';
12
11
 
13
- import { REGISTERER_CONTRACT_CLASS_REGISTERED_TAG } from '../protocol_contract_data.js';
12
+ import { ProtocolContractAddress } from '../protocol_contract_data.js';
14
13
 
15
- /** Event emitted from the ContractClassRegisterer. */
16
- export class ContractClassRegisteredEvent {
14
+ /** Event emitted from the ContractClassRegistry. */
15
+ export class ContractClassPublishedEvent {
17
16
  constructor(
18
17
  public readonly contractClassId: Fr,
19
18
  public readonly version: number,
@@ -22,19 +21,24 @@ export class ContractClassRegisteredEvent {
22
21
  public readonly packedPublicBytecode: Buffer,
23
22
  ) {}
24
23
 
25
- static isContractClassRegisteredEvent(log: ContractClassLog) {
26
- return log.fields[0].equals(REGISTERER_CONTRACT_CLASS_REGISTERED_TAG);
24
+ static isContractClassPublishedEvent(log: ContractClassLog) {
25
+ return (
26
+ log.contractAddress.equals(ProtocolContractAddress.ContractClassRegistry) &&
27
+ log.fields.fields[0].toBigInt() === CONTRACT_CLASS_PUBLISHED_MAGIC_VALUE
28
+ );
27
29
  }
28
30
 
29
31
  static fromLog(log: ContractClassLog) {
30
- const reader = new FieldReader(log.fields.slice(1));
32
+ // See how the log is serialized in `noir-projects/noir-contracts/contracts/protocol/contract_class_registry/src/events/class_published.nr`.
33
+ const fieldsWithoutTag = log.fields.fields.slice(1);
34
+ const reader = new FieldReader(fieldsWithoutTag);
31
35
  const contractClassId = reader.readField();
32
36
  const version = reader.readField().toNumber();
33
37
  const artifactHash = reader.readField();
34
38
  const privateFunctionsRoot = reader.readField();
35
- const packedPublicBytecode = bufferFromFields(reader.readFieldArray(log.fields.slice(1).length - reader.cursor));
39
+ const packedPublicBytecode = bufferFromFields(reader.readFieldArray(fieldsWithoutTag.length - reader.cursor));
36
40
 
37
- return new ContractClassRegisteredEvent(
41
+ return new ContractClassPublishedEvent(
38
42
  contractClassId,
39
43
  version,
40
44
  artifactHash,
@@ -60,24 +64,20 @@ export class ContractClassRegisteredEvent {
60
64
  throw new Error(`Unexpected contract class version ${this.version}`);
61
65
  }
62
66
 
63
- // TODO(https://github.com/AztecProtocol/aztec-packages/issues/8985): Remove public functions.
64
- const publicFunctions: PublicFunction[] = [];
65
- if (this.packedPublicBytecode.length > 0) {
66
- publicFunctions.push({
67
- selector: FunctionSelector.fromField(new Fr(PUBLIC_DISPATCH_SELECTOR)),
68
- bytecode: this.packedPublicBytecode,
69
- });
70
- }
71
-
72
67
  return {
73
68
  id: this.contractClassId,
74
69
  artifactHash: this.artifactHash,
75
70
  packedBytecode: this.packedPublicBytecode,
76
71
  privateFunctionsRoot: this.privateFunctionsRoot,
77
- publicFunctions: publicFunctions,
78
72
  version: this.version,
79
73
  privateFunctions: [],
80
- unconstrainedFunctions: [],
74
+ utilityFunctions: [],
81
75
  };
82
76
  }
77
+
78
+ public static extractContractClassEvents(logs: ContractClassLog[]): ContractClassPublishedEvent[] {
79
+ return logs
80
+ .filter((log: ContractClassLog) => ContractClassPublishedEvent.isContractClassPublishedEvent(log))
81
+ .map((log: ContractClassLog) => ContractClassPublishedEvent.fromLog(log));
82
+ }
83
83
  }
@@ -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 ContractClassRegistererJson from '../../artifacts/ContractClassRegisterer.json' assert { type: 'json' };
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 './contract_class_registered_event.js';
8
+ export * from './contract_class_published_event.js';
9
9
  export * from './private_function_broadcasted_event.js';
10
- export * from './unconstrained_function_broadcasted_event.js';
10
+ export * from './utility_function_broadcasted_event.js';
11
11
 
12
- export const ContractClassRegistererArtifact = loadContractArtifact(
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 getCanonicalClassRegisterer(): Promise<ProtocolContract> {
17
+ export async function getCanonicalClassRegistry(): Promise<ProtocolContract> {
20
18
  if (!protocolContract) {
21
- const artifact = ContractClassRegistererArtifact;
22
- protocolContract = await makeProtocolContract('ContractClassRegisterer', artifact);
19
+ const artifact = ContractClassRegistryArtifact;
20
+ protocolContract = await makeProtocolContract('ContractClassRegistry', artifact);
23
21
  }
24
22
  return protocolContract;
25
23
  }
@@ -0,0 +1,33 @@
1
+ import { type ContractArtifact, loadContractArtifact } from '@aztec/stdlib/abi';
2
+
3
+ import { makeProtocolContract } from '../make_protocol_contract.js';
4
+ import type { ProtocolContract } from '../protocol_contract.js';
5
+
6
+ export * from './contract_class_published_event.js';
7
+ export * from './private_function_broadcasted_event.js';
8
+ export * from './utility_function_broadcasted_event.js';
9
+
10
+ let protocolContract: ProtocolContract;
11
+ let protocolContractArtifact: ContractArtifact;
12
+
13
+ export async function getContractClassRegistryArtifact(): Promise<ContractArtifact> {
14
+ if (!protocolContractArtifact) {
15
+ // Cannot assert this import as it's incompatible with bundlers like vite
16
+ // https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
17
+ // Even if now supported by al major browsers, the MIME type is replaced with
18
+ // "text/javascript"
19
+ // In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
20
+ const { default: contractClassRegistryJson } = await import('../../artifacts/ContractClassRegistry.json');
21
+ protocolContractArtifact = loadContractArtifact(contractClassRegistryJson);
22
+ }
23
+ return protocolContractArtifact;
24
+ }
25
+
26
+ /** Returns the canonical deployment of the auth registry. */
27
+ export async function getCanonicalClassRegistry(): Promise<ProtocolContract> {
28
+ if (!protocolContract) {
29
+ const contractClassRegistryArtifact = await getContractClassRegistryArtifact();
30
+ protocolContract = await makeProtocolContract('ContractClassRegistry', contractClassRegistryArtifact);
31
+ }
32
+ return protocolContract;
33
+ }
@@ -1,5 +1,6 @@
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
6
  } from '@aztec/constants';
@@ -10,14 +11,14 @@ import { FunctionSelector, bufferFromFields } from '@aztec/stdlib/abi';
10
11
  import type { ExecutablePrivateFunctionWithMembershipProof, PrivateFunction } from '@aztec/stdlib/contract';
11
12
  import type { ContractClassLog } from '@aztec/stdlib/logs';
12
13
 
13
- import { REGISTERER_PRIVATE_FUNCTION_BROADCASTED_TAG } from '../protocol_contract_data.js';
14
+ import { ProtocolContractAddress } from '../protocol_contract_data.js';
14
15
 
15
- /** Event emitted from the ContractClassRegisterer. */
16
+ /** Event emitted from the ContractClassRegistry. */
16
17
  export class PrivateFunctionBroadcastedEvent {
17
18
  constructor(
18
19
  public readonly contractClassId: Fr,
19
20
  public readonly artifactMetadataHash: Fr,
20
- public readonly unconstrainedFunctionsArtifactTreeRoot: Fr,
21
+ public readonly utilityFunctionsTreeRoot: Fr,
21
22
  public readonly privateFunctionTreeSiblingPath: Tuple<Fr, typeof FUNCTION_TREE_HEIGHT>,
22
23
  public readonly privateFunctionTreeLeafIndex: number,
23
24
  public readonly artifactFunctionTreeSiblingPath: Tuple<Fr, typeof ARTIFACT_FUNCTION_TREE_MAX_HEIGHT>,
@@ -26,11 +27,14 @@ export class PrivateFunctionBroadcastedEvent {
26
27
  ) {}
27
28
 
28
29
  static isPrivateFunctionBroadcastedEvent(log: ContractClassLog) {
29
- return log.fields[0].equals(REGISTERER_PRIVATE_FUNCTION_BROADCASTED_TAG);
30
+ return (
31
+ log.contractAddress.equals(ProtocolContractAddress.ContractClassRegistry) &&
32
+ log.fields.fields[0].toBigInt() === CONTRACT_CLASS_REGISTRY_PRIVATE_FUNCTION_BROADCASTED_MAGIC_VALUE
33
+ );
30
34
  }
31
35
 
32
36
  static fromLog(log: ContractClassLog) {
33
- const reader = new FieldReader(log.fields.slice(1));
37
+ const reader = new FieldReader(log.fields.fields.slice(1));
34
38
  const event = PrivateFunctionBroadcastedEvent.fromFields(reader);
35
39
  while (!reader.isFinished()) {
36
40
  const field = reader.readField();
@@ -46,7 +50,7 @@ export class PrivateFunctionBroadcastedEvent {
46
50
  const reader = FieldReader.asReader(fields);
47
51
  const contractClassId = reader.readField();
48
52
  const artifactMetadataHash = reader.readField();
49
- const unconstrainedFunctionsArtifactTreeRoot = reader.readField();
53
+ const utilityFunctionsTreeRoot = reader.readField();
50
54
  const privateFunctionTreeSiblingPath = reader.readFieldArray(FUNCTION_TREE_HEIGHT);
51
55
  const privateFunctionTreeLeafIndex = reader.readField().toNumber();
52
56
  const artifactFunctionTreeSiblingPath = reader.readFieldArray(ARTIFACT_FUNCTION_TREE_MAX_HEIGHT);
@@ -56,7 +60,7 @@ export class PrivateFunctionBroadcastedEvent {
56
60
  return new PrivateFunctionBroadcastedEvent(
57
61
  contractClassId,
58
62
  artifactMetadataHash,
59
- unconstrainedFunctionsArtifactTreeRoot,
63
+ utilityFunctionsTreeRoot,
60
64
  privateFunctionTreeSiblingPath,
61
65
  privateFunctionTreeLeafIndex,
62
66
  artifactFunctionTreeSiblingPath,
@@ -71,7 +75,7 @@ export class PrivateFunctionBroadcastedEvent {
71
75
  bytecode: this.privateFunction.bytecode,
72
76
  functionMetadataHash: this.privateFunction.metadataHash,
73
77
  artifactMetadataHash: this.artifactMetadataHash,
74
- unconstrainedFunctionsArtifactTreeRoot: this.unconstrainedFunctionsArtifactTreeRoot,
78
+ utilityFunctionsTreeRoot: this.utilityFunctionsTreeRoot,
75
79
  privateFunctionTreeSiblingPath: this.privateFunctionTreeSiblingPath,
76
80
  privateFunctionTreeLeafIndex: this.privateFunctionTreeLeafIndex,
77
81
  artifactTreeSiblingPath: this.artifactFunctionTreeSiblingPath.filter(fr => !fr.isZero()),