@aztec/protocol-contracts 4.0.0-nightly.20250907 → 4.0.0-nightly.20260108

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 (77) hide show
  1. package/artifacts/AuthRegistry.json +1526 -1612
  2. package/artifacts/ContractClassRegistry.json +3568 -5272
  3. package/artifacts/ContractInstanceRegistry.json +1509 -1484
  4. package/artifacts/FeeJuice.json +3157 -1202
  5. package/artifacts/MultiCallEntrypoint.json +1161 -1117
  6. package/artifacts/Router.json +347 -4001
  7. package/dest/auth-registry/index.d.ts +1 -1
  8. package/dest/auth-registry/lazy.d.ts +1 -1
  9. package/dest/auth-registry/lazy.js +4 -4
  10. package/dest/class-registry/contract_class_published_event.d.ts +3 -2
  11. package/dest/class-registry/contract_class_published_event.d.ts.map +1 -1
  12. package/dest/class-registry/contract_class_published_event.js +4 -0
  13. package/dest/class-registry/index.d.ts +1 -1
  14. package/dest/class-registry/lazy.d.ts +1 -1
  15. package/dest/class-registry/lazy.js +4 -4
  16. package/dest/class-registry/private_function_broadcasted_event.d.ts +2 -6
  17. package/dest/class-registry/private_function_broadcasted_event.d.ts.map +1 -1
  18. package/dest/class-registry/utility_function_broadcasted_event.d.ts +2 -5
  19. package/dest/class-registry/utility_function_broadcasted_event.d.ts.map +1 -1
  20. package/dest/class-registry/utility_function_broadcasted_event.js +1 -1
  21. package/dest/fee-juice/index.d.ts +2 -2
  22. package/dest/fee-juice/index.d.ts.map +1 -1
  23. package/dest/fee-juice/lazy.d.ts +1 -1
  24. package/dest/fee-juice/lazy.js +4 -4
  25. package/dest/index.d.ts +1 -2
  26. package/dest/index.d.ts.map +1 -1
  27. package/dest/index.js +0 -1
  28. package/dest/instance-registry/contract_instance_published_event.d.ts +3 -2
  29. package/dest/instance-registry/contract_instance_published_event.d.ts.map +1 -1
  30. package/dest/instance-registry/contract_instance_published_event.js +4 -1
  31. package/dest/instance-registry/contract_instance_updated_event.d.ts +2 -2
  32. package/dest/instance-registry/contract_instance_updated_event.d.ts.map +1 -1
  33. package/dest/instance-registry/contract_instance_updated_event.js +5 -7
  34. package/dest/instance-registry/index.d.ts +1 -1
  35. package/dest/instance-registry/lazy.d.ts +1 -1
  36. package/dest/instance-registry/lazy.js +4 -4
  37. package/dest/make_protocol_contract.d.ts +1 -1
  38. package/dest/multi-call-entrypoint/index.d.ts +1 -1
  39. package/dest/multi-call-entrypoint/lazy.d.ts +1 -1
  40. package/dest/multi-call-entrypoint/lazy.js +4 -4
  41. package/dest/protocol_contract.d.ts +1 -1
  42. package/dest/protocol_contract_data.d.ts +12 -10
  43. package/dest/protocol_contract_data.d.ts.map +1 -1
  44. package/dest/protocol_contract_data.js +23 -9
  45. package/dest/provider/bundle.d.ts +1 -1
  46. package/dest/provider/bundle.d.ts.map +1 -1
  47. package/dest/provider/lazy.d.ts +1 -1
  48. package/dest/provider/lazy.d.ts.map +1 -1
  49. package/dest/provider/protocol_contracts_provider.d.ts +1 -1
  50. package/dest/router/index.d.ts +1 -1
  51. package/dest/router/lazy.d.ts +1 -1
  52. package/dest/router/lazy.js +4 -4
  53. package/dest/scripts/generate_data.js +33 -76
  54. package/dest/tests/fixtures.d.ts +1 -1
  55. package/package.json +10 -9
  56. package/src/auth-registry/lazy.ts +4 -4
  57. package/src/class-registry/contract_class_published_event.ts +8 -1
  58. package/src/class-registry/lazy.ts +4 -4
  59. package/src/class-registry/private_function_broadcasted_event.ts +1 -1
  60. package/src/class-registry/utility_function_broadcasted_event.ts +1 -1
  61. package/src/fee-juice/index.ts +1 -1
  62. package/src/fee-juice/lazy.ts +4 -4
  63. package/src/index.ts +0 -1
  64. package/src/instance-registry/contract_instance_published_event.ts +7 -1
  65. package/src/instance-registry/contract_instance_updated_event.ts +6 -8
  66. package/src/instance-registry/lazy.ts +4 -4
  67. package/src/multi-call-entrypoint/lazy.ts +4 -4
  68. package/src/protocol_contract_data.ts +24 -9
  69. package/src/router/lazy.ts +4 -4
  70. package/dest/build_protocol_contract_tree.d.ts +0 -10
  71. package/dest/build_protocol_contract_tree.d.ts.map +0 -1
  72. package/dest/build_protocol_contract_tree.js +0 -20
  73. package/dest/protocol_contract_tree.d.ts +0 -7
  74. package/dest/protocol_contract_tree.d.ts.map +0 -1
  75. package/dest/protocol_contract_tree.js +0 -34
  76. package/src/build_protocol_contract_tree.ts +0 -29
  77. package/src/protocol_contract_tree.ts +0 -44
@@ -4,10 +4,10 @@ let protocolContract;
4
4
  let protocolContractArtifact;
5
5
  export async function getRouterArtifact() {
6
6
  if (!protocolContractArtifact) {
7
- // Cannot assert this import as it's incompatible with browsers
8
- // https://caniuse.com/mdn-javascript_statements_import_import_assertions_type_json
9
- // Use the new "with" syntax once supported by firefox
10
- // https://caniuse.com/mdn-javascript_statements_import_import_attributes_type_json
7
+ // Cannot assert this import as it's incompatible with bundlers like vite
8
+ // https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
9
+ // Even if now supported by al major browsers, the MIME type is replaced with
10
+ // "text/javascript"
11
11
  // In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
12
12
  const { default: routerJson } = await import('../../artifacts/Router.json');
13
13
  protocolContractArtifact = loadContractArtifact(routerJson);
@@ -1,19 +1,19 @@
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
- import { poseidon2Hash } from '@aztec/foundation/crypto';
3
- import { Fr } from '@aztec/foundation/fields';
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';
3
+ import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
4
+ import { Fr } from '@aztec/foundation/curves/bn254';
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
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');
14
15
  const destArtifactsDir = './artifacts';
15
16
  const outputFilePath = './src/protocol_contract_data.ts';
16
- const cppOutputFilePath = '../../barretenberg/cpp/src/barretenberg/vm2/common/protocol_contract_data.hpp';
17
17
  const salt = new Fr(1);
18
18
  const contractAddressMapping = {
19
19
  AuthRegistry: CANONICAL_AUTH_REGISTRY_ADDRESS,
@@ -23,14 +23,6 @@ const contractAddressMapping = {
23
23
  FeeJuice: FEE_JUICE_ADDRESS,
24
24
  Router: ROUTER_ADDRESS
25
25
  };
26
- const contractAddressNameMapping = {
27
- AuthRegistry: 'CANONICAL_AUTH_REGISTRY_ADDRESS',
28
- ContractInstanceRegistry: 'CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS',
29
- ContractClassRegistry: 'CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS',
30
- MultiCallEntrypoint: 'MULTI_CALL_ENTRYPOINT_ADDRESS',
31
- FeeJuice: 'FEE_JUICE_ADDRESS',
32
- Router: 'ROUTER_ADDRESS'
33
- };
34
26
  async function clearDestDir() {
35
27
  try {
36
28
  await fs.access(destArtifactsDir);
@@ -58,20 +50,12 @@ async function copyArtifact(srcName, destName) {
58
50
  await fs.copyFile(src, dest);
59
51
  return artifact;
60
52
  }
61
- async function computeContractLeaf(artifact) {
53
+ async function computeAddress(artifact) {
62
54
  const instance = await getContractInstanceFromInstantiationParams(loadContractArtifact(artifact), {
63
55
  salt
64
56
  });
65
57
  return instance.address;
66
58
  }
67
- async function computeRoot(names, leaves) {
68
- const data = names.map((name, i)=>({
69
- address: new AztecAddress(new Fr(contractAddressMapping[name])),
70
- leaf: leaves[i]
71
- }));
72
- const tree = await buildProtocolContractTree(data);
73
- return Fr.fromBuffer(tree.root);
74
- }
75
59
  async function generateDeclarationFile(destName) {
76
60
  const content = `
77
61
  import type { NoirCompiledContract } from '@aztec/stdlib/noir';
@@ -104,17 +88,30 @@ function generateContractAddresses(names) {
104
88
  };
105
89
  `;
106
90
  }
107
- function generateContractLeaves(names, leaves) {
91
+ function generateDerivedAddresses(names, derivedAddresses) {
108
92
  return `
109
- export const ProtocolContractLeaves = {
110
- ${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')}
111
95
  };
112
96
  `;
113
97
  }
114
- async function generateRoot(names, leaves) {
115
- 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
+ }
116
109
  return `
117
- 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()}');
118
115
  `;
119
116
  }
120
117
  // Generate the siloed log tags for events emitted via private logs.
@@ -126,11 +123,12 @@ async function generateLogTags() {
126
123
  ])}');
127
124
  `;
128
125
  }
129
- async function generateOutputFile(names, leaves) {
126
+ async function generateOutputFile(names, derivedAddresses) {
130
127
  const content = `
131
128
  // GENERATED FILE - DO NOT EDIT. RUN \`yarn generate\` or \`yarn generate:data\`
132
- import { Fr } from '@aztec/foundation/fields';
129
+ import { Fr } from '@aztec/foundation/curves/bn254';
133
130
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
131
+ import { ProtocolContracts } from '@aztec/stdlib/tx';
134
132
 
135
133
  ${generateNames(names)}
136
134
 
@@ -138,68 +136,27 @@ async function generateOutputFile(names, leaves) {
138
136
 
139
137
  ${generateContractAddresses(names)}
140
138
 
141
- ${generateContractLeaves(names, leaves)}
139
+ ${generateDerivedAddresses(names, derivedAddresses)}
142
140
 
143
- ${await generateRoot(names, leaves)}
141
+ ${await generateProtocolContractsList(names, derivedAddresses)}
144
142
 
145
143
  ${await generateLogTags()}
146
144
  `;
147
145
  await fs.writeFile(outputFilePath, content);
148
146
  }
149
- async function generateHppOutputFile() {
150
- const content = `// GENERATED FILE - DO NOT EDIT, RUN yarn generate in yarn-project/protocol-contracts
151
- #pragma once
152
-
153
- #include "barretenberg/vm2/common/aztec_constants.hpp"
154
- #include "barretenberg/vm2/common/aztec_types.hpp"
155
-
156
- #include <unordered_map>
157
-
158
- namespace bb::avm2 {
159
-
160
- using CanonicalAddress = AztecAddress;
161
- using DerivedAddress = AztecAddress;
162
-
163
- extern const std::unordered_map<CanonicalAddress, DerivedAddress> derived_addresses;
164
-
165
- } // namespace bb::avm2
166
- `;
167
- await fs.writeFile(cppOutputFilePath, content);
168
- }
169
- async function generateCppOutputFile(names, leaves) {
170
- await generateHppOutputFile();
171
- const data = names.map((name, i)=>({
172
- name: contractAddressNameMapping[name],
173
- addr: leaves[i].toString()
174
- }));
175
- const content = `// GENERATED FILE - DO NOT EDIT, RUN yarn generate in yarn-project/protocol-contracts
176
- #include "protocol_contract_data.hpp"
177
-
178
- namespace bb::avm2 {
179
-
180
- const std::unordered_map<CanonicalAddress, DerivedAddress> derived_addresses = {
181
- ${data.map(({ name, addr })=>`{ ${name}, AztecAddress("${addr}") }`).join(',\n\t')}
182
- };
183
-
184
- } // namespace bb::avm2
185
- `;
186
- await fs.writeFile(cppOutputFilePath.replace('.hpp', '.cpp'), content);
187
- }
188
147
  async function main() {
189
148
  await clearDestDir();
190
149
  const srcNames = JSON.parse(await fs.readFile(path.join(noirContractsRoot, 'protocol_contracts.json'), 'utf8'));
191
- const leaves = [];
150
+ const derivedAddresses = [];
192
151
  const destNames = srcNames.map((n)=>n.split('-')[1]);
193
152
  for(let i = 0; i < srcNames.length; i++){
194
153
  const srcName = srcNames[i];
195
154
  const destName = destNames[i];
196
155
  const artifact = await copyArtifact(srcName, destName);
197
156
  await generateDeclarationFile(destName);
198
- const contractLeaf = await computeContractLeaf(artifact);
199
- leaves.push(contractLeaf.toField());
157
+ derivedAddresses.push(await computeAddress(artifact));
200
158
  }
201
- await generateCppOutputFile(destNames, leaves);
202
- await generateOutputFile(destNames, leaves);
159
+ await generateOutputFile(destNames, derivedAddresses);
203
160
  }
204
161
  try {
205
162
  await main();
@@ -3,4 +3,4 @@ export declare function getSamplePrivateFunctionBroadcastedEventPayload(): Buffe
3
3
  export declare function getSampleUtilityFunctionBroadcastedEventPayload(): Buffer;
4
4
  export declare function getSampleContractInstancePublishedEventPayload(): Buffer;
5
5
  export declare function getPathToFixture(name: string): string;
6
- //# sourceMappingURL=fixtures.d.ts.map
6
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZml4dHVyZXMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy90ZXN0cy9maXh0dXJlcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFLQSx3QkFBZ0IsMkNBQTJDLElBQUksTUFBTSxDQUdwRTtBQUdELHdCQUFnQiwrQ0FBK0MsSUFBSSxNQUFNLENBR3hFO0FBR0Qsd0JBQWdCLCtDQUErQyxJQUFJLE1BQU0sQ0FHeEU7QUFHRCx3QkFBZ0IsOENBQThDLElBQUksTUFBTSxDQUd2RTtBQUVELHdCQUFnQixnQkFBZ0IsQ0FBQyxJQUFJLEVBQUUsTUFBTSxVQUU1QyJ9
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": "4.0.0-nightly.20250907",
5
+ "version": "4.0.0-nightly.20260108",
6
6
  "type": "module",
7
7
  "exports": {
8
8
  ".": "./dest/index.js",
@@ -21,13 +21,13 @@
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 && ../scripts/tsc.sh",
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": "../scripts/tsc.sh --watch",
30
+ "build:ts": "tsgo -b",
31
31
  "clean": "rm -rf ./dest .tsbuildinfo ./artifacts",
32
32
  "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
33
33
  },
@@ -73,9 +73,9 @@
73
73
  ]
74
74
  },
75
75
  "dependencies": {
76
- "@aztec/constants": "4.0.0-nightly.20250907",
77
- "@aztec/foundation": "4.0.0-nightly.20250907",
78
- "@aztec/stdlib": "4.0.0-nightly.20250907",
76
+ "@aztec/constants": "4.0.0-nightly.20260108",
77
+ "@aztec/foundation": "4.0.0-nightly.20260108",
78
+ "@aztec/stdlib": "4.0.0-nightly.20260108",
79
79
  "lodash.chunk": "^4.2.0",
80
80
  "lodash.omit": "^4.5.0",
81
81
  "tslib": "^2.4.0"
@@ -86,9 +86,10 @@
86
86
  "@types/lodash.chunk": "^4.2.9",
87
87
  "@types/lodash.omit": "^4.5.9",
88
88
  "@types/node": "^22.15.17",
89
+ "@typescript/native-preview": "7.0.0-dev.20251126.1",
89
90
  "jest": "^30.0.0",
90
91
  "jest-mock-extended": "^4.0.0",
91
- "ts-loader": "^9.4.4",
92
+ "ts-loader": "^9.5.4",
92
93
  "ts-node": "^10.9.1",
93
94
  "typescript": "^5.3.3"
94
95
  },
@@ -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);
@@ -1,5 +1,5 @@
1
1
  import { CONTRACT_CLASS_PUBLISHED_MAGIC_VALUE } from '@aztec/constants';
2
- import { Fr } from '@aztec/foundation/fields';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
3
  import { FieldReader } from '@aztec/foundation/serialize';
4
4
  import { bufferFromFields } from '@aztec/stdlib/abi';
5
5
  import {
@@ -29,6 +29,7 @@ export class ContractClassPublishedEvent {
29
29
  }
30
30
 
31
31
  static fromLog(log: ContractClassLog) {
32
+ // See how the log is serialized in `noir-projects/noir-contracts/contracts/protocol/contract_class_registry/src/events/class_published.nr`.
32
33
  const fieldsWithoutTag = log.fields.fields.slice(1);
33
34
  const reader = new FieldReader(fieldsWithoutTag);
34
35
  const contractClassId = reader.readField();
@@ -73,4 +74,10 @@ export class ContractClassPublishedEvent {
73
74
  utilityFunctions: [],
74
75
  };
75
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
+ }
76
83
  }
@@ -12,10 +12,10 @@ let protocolContractArtifact: ContractArtifact;
12
12
 
13
13
  export async function getContractClassRegistryArtifact(): Promise<ContractArtifact> {
14
14
  if (!protocolContractArtifact) {
15
- // Cannot assert this import as it's incompatible with browsers
16
- // https://caniuse.com/mdn-javascript_statements_import_import_assertions_type_json
17
- // Use the new "with" syntax once supported by firefox
18
- // https://caniuse.com/mdn-javascript_statements_import_import_attributes_type_json
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
19
  // In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
20
20
  const { default: contractClassRegistryJson } = await import('../../artifacts/ContractClassRegistry.json');
21
21
  protocolContractArtifact = loadContractArtifact(contractClassRegistryJson);
@@ -4,7 +4,7 @@ import {
4
4
  FUNCTION_TREE_HEIGHT,
5
5
  MAX_PACKED_BYTECODE_SIZE_PER_PRIVATE_FUNCTION_IN_FIELDS,
6
6
  } from '@aztec/constants';
7
- import { Fr } from '@aztec/foundation/fields';
7
+ import { Fr } from '@aztec/foundation/curves/bn254';
8
8
  import type { Tuple } from '@aztec/foundation/serialize';
9
9
  import { FieldReader } from '@aztec/foundation/serialize';
10
10
  import { FunctionSelector, bufferFromFields } from '@aztec/stdlib/abi';
@@ -4,7 +4,7 @@ import {
4
4
  MAX_PACKED_BYTECODE_SIZE_PER_UTILITY_FUNCTION_IN_FIELDS,
5
5
  } from '@aztec/constants';
6
6
  import { removeArrayPaddingEnd } from '@aztec/foundation/collection';
7
- import { Fr } from '@aztec/foundation/fields';
7
+ import { Fr } from '@aztec/foundation/curves/bn254';
8
8
  import type { Tuple } from '@aztec/foundation/serialize';
9
9
  import { FieldReader } from '@aztec/foundation/serialize';
10
10
  import { FunctionSelector, bufferFromFields } from '@aztec/stdlib/abi';
@@ -1,4 +1,4 @@
1
- import type { Fr } from '@aztec/foundation/fields';
1
+ import type { Fr } from '@aztec/foundation/curves/bn254';
2
2
  import { loadContractArtifact } from '@aztec/stdlib/abi';
3
3
  import type { AztecAddress } from '@aztec/stdlib/aztec-address';
4
4
  import { computePublicDataTreeLeafSlot, deriveStorageSlotInMap } from '@aztec/stdlib/hash';
@@ -8,10 +8,10 @@ let protocolContractArtifact: ContractArtifact;
8
8
 
9
9
  export async function getFeeJuiceArtifact(): 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: feeJuiceJson } = await import('../../artifacts/FeeJuice.json');
17
17
  protocolContractArtifact = loadContractArtifact(feeJuiceJson);
package/src/index.ts CHANGED
@@ -1,3 +1,2 @@
1
1
  export * from './protocol_contract.js';
2
2
  export * from './protocol_contract_data.js';
3
- export * from './protocol_contract_tree.js';
@@ -1,4 +1,4 @@
1
- import { Fr } from '@aztec/foundation/fields';
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
2
  import { BufferReader } from '@aztec/foundation/serialize';
3
3
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
4
4
  import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
@@ -61,4 +61,10 @@ export class ContractInstancePublishedEvent {
61
61
  deployer: this.deployer,
62
62
  };
63
63
  }
64
+
65
+ public static extractContractInstanceEvents(logs: PrivateLog[]): ContractInstancePublishedEvent[] {
66
+ return logs
67
+ .filter(log => ContractInstancePublishedEvent.isContractInstancePublishedEvent(log))
68
+ .map(log => ContractInstancePublishedEvent.fromLog(log));
69
+ }
64
70
  }
@@ -1,6 +1,6 @@
1
1
  import { CONTRACT_INSTANCE_UPDATED_MAGIC_VALUE } from '@aztec/constants';
2
- import { Fr } from '@aztec/foundation/fields';
3
- import { BufferReader } from '@aztec/foundation/serialize';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
+ import { FieldReader } from '@aztec/foundation/serialize';
4
4
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
5
5
  import type { ContractInstanceUpdateWithAddress } from '@aztec/stdlib/contract';
6
6
  import type { PublicLog } from '@aztec/stdlib/logs';
@@ -25,13 +25,11 @@ export class ContractInstanceUpdatedEvent {
25
25
  }
26
26
 
27
27
  static fromLog(log: PublicLog) {
28
- const bufferWithoutAddressAndTag = log.toBuffer().subarray(64);
29
- const reader = new BufferReader(bufferWithoutAddressAndTag);
28
+ const reader = new FieldReader(log.fields.slice(1) /* remove tag */);
30
29
  const address = reader.readObject(AztecAddress);
31
- const prevContractClassId = reader.readObject(Fr);
32
- const newContractClassId = reader.readObject(Fr);
33
- const timestampOfChange = reader.readObject(Fr).toBigInt();
34
-
30
+ const prevContractClassId = reader.readField();
31
+ const newContractClassId = reader.readField();
32
+ const timestampOfChange = reader.readField().toBigInt();
35
33
  return new ContractInstanceUpdatedEvent(address, prevContractClassId, newContractClassId, timestampOfChange);
36
34
  }
37
35
 
@@ -11,10 +11,10 @@ let protocolContractArtifact: ContractArtifact;
11
11
 
12
12
  export async function getContractInstanceRegistryArtifact(): Promise<ContractArtifact> {
13
13
  if (!protocolContractArtifact) {
14
- // Cannot assert this import as it's incompatible with browsers
15
- // https://caniuse.com/mdn-javascript_statements_import_import_assertions_type_json
16
- // Use the new "with" syntax once supported by firefox
17
- // https://caniuse.com/mdn-javascript_statements_import_import_attributes_type_json
14
+ // Cannot assert this import as it's incompatible with bundlers like vite
15
+ // https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
16
+ // Even if now supported by al major browsers, the MIME type is replaced with
17
+ // "text/javascript"
18
18
  // In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
19
19
  const { default: contractInstanceRegistryJson } = await import('../../artifacts/ContractInstanceRegistry.json');
20
20
  protocolContractArtifact = loadContractArtifact(contractInstanceRegistryJson);
@@ -8,10 +8,10 @@ let protocolContractArtifact: ContractArtifact;
8
8
 
9
9
  export async function getMultiCallEntrypointArtifact(): 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: multiCallEntrypointJson } = await import('../../artifacts/MultiCallEntrypoint.json');
17
17
  protocolContractArtifact = loadContractArtifact(multiCallEntrypointJson);
@@ -1,7 +1,8 @@
1
1
 
2
2
  // GENERATED FILE - DO NOT EDIT. RUN `yarn generate` or `yarn generate:data`
3
- import { Fr } from '@aztec/foundation/fields';
3
+ import { Fr } from '@aztec/foundation/curves/bn254';
4
4
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
5
+ import { ProtocolContracts } from '@aztec/stdlib/tx';
5
6
 
6
7
 
7
8
  export const protocolContractNames = [
@@ -39,18 +40,32 @@ Router: AztecAddress.fromBigInt(6n)
39
40
 
40
41
 
41
42
 
42
- export const ProtocolContractLeaves = {
43
- AuthRegistry: Fr.fromHexString('0x1c2474a77af3c756895867fa7622e5e9295121b35849e965f4614d51f00c62e2'),
44
- ContractInstanceRegistry: Fr.fromHexString('0x001e627e78063a4944f1331b4c59544f8ad6d6d478f2fc79b025e8240b94b816'),
45
- ContractClassRegistry: Fr.fromHexString('0x1bd2e13b35e2745e638132262e6642a86ac4219f1b7a95086bebe250f5d557ea'),
46
- MultiCallEntrypoint: Fr.fromHexString('0x27b35c8e0851d28c56846ce8977155ffbb5725c4e6b47a67f5d5c6639d1c1a1c'),
47
- FeeJuice: Fr.fromHexString('0x2ee34a2d304636f81114dffc8a2357e03e08345a008262eb36112f95aaa58eb1'),
48
- Router: Fr.fromHexString('0x180b58198cce7c0866a828841df6eca6369a71a6e884ca5cf08938301d7ad0ca')
43
+ export const ProtocolContractDerivedAddress = {
44
+ AuthRegistry: AztecAddress.fromString('0x0dc6fe49180dc87e51469381cb4f730cf1e21c38b24d9aea432fd2b03a423d84'),
45
+ ContractInstanceRegistry: AztecAddress.fromString('0x2a507595606743f79982188757771a64afd3a36a7394f79dffa5d79eda52e5c9'),
46
+ ContractClassRegistry: AztecAddress.fromString('0x2c58e13582be993f8c8ecf14098fbedc934d0a70e38f6099ae4bff3dc6d83698'),
47
+ MultiCallEntrypoint: AztecAddress.fromString('0x1fc028a3c35509cdc71172a38fc5216dea66d8fb8e0b87393c7d72b0144d7af1'),
48
+ FeeJuice: AztecAddress.fromString('0x2eba553c14705e3b010b2429d1de26fd991d36b5c4526b0bdbcfd7327a9702f4'),
49
+ Router: AztecAddress.fromString('0x2ec996f044d85cd763f4ada686763f443a4db0103c1fd6eb64bef7d7b95bcf80')
49
50
  };
50
51
 
51
52
 
52
53
 
53
- export const protocolContractTreeRoot = Fr.fromHexString('0x227802391f582e49922178a4d4de61384eda4ee4ba69708f0349b76dd04db461');
54
+ export const ProtocolContractsList = new ProtocolContracts([
55
+ AztecAddress.fromString('0x0dc6fe49180dc87e51469381cb4f730cf1e21c38b24d9aea432fd2b03a423d84'),
56
+ AztecAddress.fromString('0x2a507595606743f79982188757771a64afd3a36a7394f79dffa5d79eda52e5c9'),
57
+ AztecAddress.fromString('0x2c58e13582be993f8c8ecf14098fbedc934d0a70e38f6099ae4bff3dc6d83698'),
58
+ AztecAddress.fromString('0x1fc028a3c35509cdc71172a38fc5216dea66d8fb8e0b87393c7d72b0144d7af1'),
59
+ AztecAddress.fromString('0x2eba553c14705e3b010b2429d1de26fd991d36b5c4526b0bdbcfd7327a9702f4'),
60
+ AztecAddress.fromString('0x2ec996f044d85cd763f4ada686763f443a4db0103c1fd6eb64bef7d7b95bcf80'),
61
+ AztecAddress.fromString('0x0000000000000000000000000000000000000000000000000000000000000000'),
62
+ AztecAddress.fromString('0x0000000000000000000000000000000000000000000000000000000000000000'),
63
+ AztecAddress.fromString('0x0000000000000000000000000000000000000000000000000000000000000000'),
64
+ AztecAddress.fromString('0x0000000000000000000000000000000000000000000000000000000000000000'),
65
+ AztecAddress.fromString('0x0000000000000000000000000000000000000000000000000000000000000000')
66
+ ]);
67
+
68
+ export const protocolContractsHash = Fr.fromString('0x03b32c37e16ca005980ee1539fda7736b2ba88b8bade7e882134e1faba4c23db');
54
69
 
55
70
 
56
71
 
@@ -8,10 +8,10 @@ let protocolContractArtifact: ContractArtifact;
8
8
 
9
9
  export async function getRouterArtifact(): 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: routerJson } = await import('../../artifacts/Router.json');
17
17
  protocolContractArtifact = loadContractArtifact(routerJson);
@@ -1,10 +0,0 @@
1
- import { PROTOCOL_CONTRACT_TREE_HEIGHT } from '@aztec/constants';
2
- import type { Fr } from '@aztec/foundation/fields';
3
- import { type IndexedMerkleTree } from '@aztec/foundation/trees';
4
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
5
- import { ProtocolContractLeafPreimage } from '@aztec/stdlib/trees';
6
- export declare function buildProtocolContractTree(contracts: {
7
- address: AztecAddress;
8
- leaf: Fr;
9
- }[]): Promise<IndexedMerkleTree<ProtocolContractLeafPreimage, typeof PROTOCOL_CONTRACT_TREE_HEIGHT>>;
10
- //# sourceMappingURL=build_protocol_contract_tree.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build_protocol_contract_tree.d.ts","sourceRoot":"","sources":["../src/build_protocol_contract_tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,6BAA6B,EAAE,MAAM,kBAAkB,CAAC;AAEzF,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,KAAK,iBAAiB,EAA+B,MAAM,yBAAyB,CAAC;AAC9F,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAEnE,wBAAsB,yBAAyB,CAC7C,SAAS,EAAE;IAAE,OAAO,EAAE,YAAY,CAAC;IAAC,IAAI,EAAE,EAAE,CAAA;CAAE,EAAE,GAC/C,OAAO,CAAC,iBAAiB,CAAC,4BAA4B,EAAE,OAAO,6BAA6B,CAAC,CAAC,CAmBhG"}
@@ -1,20 +0,0 @@
1
- import { MAX_PROTOCOL_CONTRACTS, PROTOCOL_CONTRACT_TREE_HEIGHT } from '@aztec/constants';
2
- import { poseidon2Hash } from '@aztec/foundation/crypto';
3
- import { IndexedMerkleTreeCalculator } from '@aztec/foundation/trees';
4
- import { ProtocolContractLeafPreimage } from '@aztec/stdlib/trees';
5
- export async function buildProtocolContractTree(contracts) {
6
- const hasher = {
7
- hash: async (l, r)=>(await poseidon2Hash([
8
- l,
9
- r
10
- ])).toBuffer(),
11
- hashInputs: async (i)=>(await poseidon2Hash(i)).toBuffer()
12
- };
13
- const calculator = await IndexedMerkleTreeCalculator.create(PROTOCOL_CONTRACT_TREE_HEIGHT, hasher, ProtocolContractLeafPreimage);
14
- const leaves = new Array(MAX_PROTOCOL_CONTRACTS).fill(Buffer.alloc(32));
15
- for (const contract of contracts){
16
- const index = contract.address.toField().toNumber();
17
- leaves[index] = contract.leaf.toBuffer();
18
- }
19
- return calculator.computeTree(leaves);
20
- }
@@ -1,7 +0,0 @@
1
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
2
- import type { ProtocolContractLeafPreimage } from '@aztec/stdlib/trees';
3
- export declare function getProtocolContractLeafAndMembershipWitness(contractAddress: AztecAddress, computedAddress: AztecAddress): Promise<{
4
- lowLeaf: ProtocolContractLeafPreimage;
5
- witness: import("@aztec/foundation/trees").MembershipWitness<3>;
6
- }>;
7
- //# sourceMappingURL=protocol_contract_tree.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"protocol_contract_tree.d.ts","sourceRoot":"","sources":["../src/protocol_contract_tree.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAsBxE,wBAAsB,2CAA2C,CAC/D,eAAe,EAAE,YAAY,EAC7B,eAAe,EAAE,YAAY;;;GAe9B"}
@@ -1,34 +0,0 @@
1
- import { poseidon2Hash } from '@aztec/foundation/crypto';
2
- import { buildProtocolContractTree } from './build_protocol_contract_tree.js';
3
- import { isProtocolContract } from './protocol_contract.js';
4
- import { ProtocolContractAddress, ProtocolContractLeaves, protocolContractNames } from './protocol_contract_data.js';
5
- let protocolContractTree;
6
- async function getTree() {
7
- if (!protocolContractTree) {
8
- const leaves = protocolContractNames.map((name)=>({
9
- address: ProtocolContractAddress[name],
10
- leaf: ProtocolContractLeaves[name]
11
- }));
12
- protocolContractTree = await buildProtocolContractTree(leaves);
13
- }
14
- return protocolContractTree;
15
- }
16
- // Computed address can be different from contract address due to upgrades
17
- export async function getProtocolContractLeafAndMembershipWitness(contractAddress, computedAddress) {
18
- const tree = await getTree();
19
- let lowLeaf;
20
- let witness;
21
- if (isProtocolContract(contractAddress)) {
22
- const index = contractAddress.toField().toNumber();
23
- lowLeaf = tree.leafPreimages[index];
24
- witness = tree.getMembershipWitness(index);
25
- } else {
26
- lowLeaf = tree.getLowLeaf(computedAddress.toBigInt());
27
- const hashed = (await poseidon2Hash(lowLeaf.toHashInputs())).toBuffer();
28
- witness = tree.getMembershipWitness(hashed);
29
- }
30
- return {
31
- lowLeaf,
32
- witness
33
- };
34
- }