@aztec/protocol-contracts 0.0.0-test.0 → 0.0.1-commit.24de95ac

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 (111) hide show
  1. package/README.md +2 -2
  2. package/artifacts/AuthRegistry.json +1979 -1183
  3. package/artifacts/ContractClassRegistry.json +8205 -0
  4. package/artifacts/ContractInstanceRegistry.json +3587 -0
  5. package/artifacts/FeeJuice.json +2499 -1930
  6. package/artifacts/MultiCallEntrypoint.json +1527 -841
  7. package/artifacts/Router.json +709 -3531
  8. package/dest/auth-registry/index.d.ts +2 -1
  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.js +4 -4
  12. package/dest/{class-registerer/contract_class_registered_event.d.ts → class-registry/contract_class_published_event.d.ts} +5 -7
  13. package/dest/class-registry/contract_class_published_event.d.ts.map +1 -0
  14. package/dest/{class-registerer/contract_class_registered_event.js → class-registry/contract_class_published_event.js} +12 -20
  15. package/dest/class-registry/index.d.ts +8 -0
  16. package/dest/class-registry/index.d.ts.map +1 -0
  17. package/dest/class-registry/index.js +17 -0
  18. package/dest/class-registry/lazy.d.ts +9 -0
  19. package/dest/class-registry/lazy.d.ts.map +1 -0
  20. package/dest/class-registry/lazy.js +26 -0
  21. package/dest/{class-registerer → class-registry}/private_function_broadcasted_event.d.ts +3 -5
  22. package/dest/class-registry/private_function_broadcasted_event.d.ts.map +1 -0
  23. package/dest/{class-registerer → class-registry}/private_function_broadcasted_event.js +11 -11
  24. package/dest/{class-registerer/unconstrained_function_broadcasted_event.d.ts → class-registry/utility_function_broadcasted_event.d.ts} +12 -14
  25. package/dest/class-registry/utility_function_broadcasted_event.d.ts.map +1 -0
  26. package/dest/{class-registerer/unconstrained_function_broadcasted_event.js → class-registry/utility_function_broadcasted_event.js} +19 -19
  27. package/dest/fee-juice/index.js +1 -1
  28. package/dest/fee-juice/lazy.js +4 -4
  29. package/dest/index.d.ts +0 -1
  30. package/dest/index.d.ts.map +1 -1
  31. package/dest/index.js +0 -1
  32. package/dest/{instance-deployer/contract_instance_deployed_event.d.ts → instance-registry/contract_instance_published_event.d.ts} +5 -5
  33. package/dest/instance-registry/contract_instance_published_event.d.ts.map +1 -0
  34. package/dest/{instance-deployer/contract_instance_deployed_event.js → instance-registry/contract_instance_published_event.js} +5 -5
  35. package/dest/{instance-deployer → instance-registry}/contract_instance_updated_event.d.ts +4 -3
  36. package/dest/instance-registry/contract_instance_updated_event.d.ts.map +1 -0
  37. package/dest/instance-registry/contract_instance_updated_event.js +35 -0
  38. package/dest/{instance-deployer → instance-registry}/index.d.ts +3 -3
  39. package/dest/instance-registry/index.d.ts.map +1 -0
  40. package/dest/{instance-deployer → instance-registry}/index.js +5 -5
  41. package/dest/{instance-deployer → instance-registry}/lazy.d.ts +3 -3
  42. package/dest/{instance-deployer → instance-registry}/lazy.d.ts.map +1 -1
  43. package/dest/instance-registry/lazy.js +25 -0
  44. package/dest/make_protocol_contract.js +2 -2
  45. package/dest/multi-call-entrypoint/index.js +1 -1
  46. package/dest/multi-call-entrypoint/lazy.js +4 -4
  47. package/dest/protocol_contract_data.d.ts +12 -14
  48. package/dest/protocol_contract_data.d.ts.map +1 -1
  49. package/dest/protocol_contract_data.js +29 -19
  50. package/dest/provider/bundle.js +4 -4
  51. package/dest/provider/lazy.js +6 -6
  52. package/dest/router/index.js +1 -1
  53. package/dest/router/lazy.js +4 -4
  54. package/dest/scripts/cleanup_artifacts.js +2 -2
  55. package/dest/scripts/generate_data.js +38 -45
  56. package/dest/tests/fixtures.d.ts +3 -5
  57. package/dest/tests/fixtures.d.ts.map +1 -1
  58. package/dest/tests/fixtures.js +6 -6
  59. package/package.json +18 -16
  60. package/src/auth-registry/index.ts +3 -3
  61. package/src/auth-registry/lazy.ts +4 -4
  62. package/src/class-registry/__snapshots__/README.md +9 -0
  63. package/src/{class-registerer/contract_class_registered_event.ts → class-registry/contract_class_published_event.ts} +16 -22
  64. package/src/{class-registerer → class-registry}/index.ts +7 -9
  65. package/src/class-registry/lazy.ts +33 -0
  66. package/src/{class-registerer → class-registry}/private_function_broadcasted_event.ts +12 -8
  67. package/src/{class-registerer/unconstrained_function_broadcasted_event.ts → class-registry/utility_function_broadcasted_event.ts} +25 -21
  68. package/src/fee-juice/index.ts +1 -1
  69. package/src/fee-juice/lazy.ts +4 -4
  70. package/src/index.ts +0 -1
  71. package/src/instance-registry/__snapshots__/README.md +9 -0
  72. package/src/{instance-deployer/contract_instance_deployed_event.ts → instance-registry/contract_instance_published_event.ts} +6 -6
  73. package/src/{instance-deployer → instance-registry}/contract_instance_updated_event.ts +14 -14
  74. package/src/{instance-deployer → instance-registry}/index.ts +6 -6
  75. package/src/{instance-deployer → instance-registry}/lazy.ts +11 -11
  76. package/src/make_protocol_contract.ts +2 -2
  77. package/src/multi-call-entrypoint/index.ts +1 -1
  78. package/src/multi-call-entrypoint/lazy.ts +4 -4
  79. package/src/protocol_contract_data.ts +30 -19
  80. package/src/provider/bundle.ts +4 -4
  81. package/src/provider/lazy.ts +6 -6
  82. package/src/router/index.ts +1 -1
  83. package/src/router/lazy.ts +4 -4
  84. package/src/tests/fixtures.ts +6 -6
  85. package/artifacts/ContractClassRegisterer.json +0 -7219
  86. package/artifacts/ContractInstanceDeployer.json +0 -2984
  87. package/dest/build_protocol_contract_tree.d.ts +0 -10
  88. package/dest/build_protocol_contract_tree.d.ts.map +0 -1
  89. package/dest/build_protocol_contract_tree.js +0 -20
  90. package/dest/class-registerer/contract_class_registered_event.d.ts.map +0 -1
  91. package/dest/class-registerer/index.d.ts +0 -8
  92. package/dest/class-registerer/index.d.ts.map +0 -1
  93. package/dest/class-registerer/index.js +0 -17
  94. package/dest/class-registerer/lazy.d.ts +0 -9
  95. package/dest/class-registerer/lazy.d.ts.map +0 -1
  96. package/dest/class-registerer/lazy.js +0 -26
  97. package/dest/class-registerer/private_function_broadcasted_event.d.ts.map +0 -1
  98. package/dest/class-registerer/unconstrained_function_broadcasted_event.d.ts.map +0 -1
  99. package/dest/instance-deployer/contract_instance_deployed_event.d.ts.map +0 -1
  100. package/dest/instance-deployer/contract_instance_updated_event.d.ts.map +0 -1
  101. package/dest/instance-deployer/contract_instance_updated_event.js +0 -36
  102. package/dest/instance-deployer/index.d.ts.map +0 -1
  103. package/dest/instance-deployer/lazy.js +0 -25
  104. package/dest/protocol_contract_tree.d.ts +0 -7
  105. package/dest/protocol_contract_tree.d.ts.map +0 -1
  106. package/dest/protocol_contract_tree.js +0 -34
  107. package/src/build_protocol_contract_tree.ts +0 -29
  108. package/src/class-registerer/lazy.ts +0 -33
  109. package/src/protocol_contract_tree.ts +0 -44
  110. /package/artifacts/{ContractClassRegisterer.d.json.ts → ContractClassRegistry.d.json.ts} +0 -0
  111. /package/artifacts/{ContractInstanceDeployer.d.json.ts → ContractInstanceRegistry.d.json.ts} +0 -0
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.0",
5
+ "version": "0.0.1-commit.24de95ac",
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-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"
@@ -29,8 +29,6 @@
29
29
  "build:dev": "tsc -b --watch",
30
30
  "build:ts": "tsc -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,31 @@
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.0",
75
- "@aztec/foundation": "0.0.0-test.0",
76
- "@aztec/stdlib": "0.0.0-test.0",
76
+ "@aztec/constants": "0.0.1-commit.24de95ac",
77
+ "@aztec/foundation": "0.0.1-commit.24de95ac",
78
+ "@aztec/stdlib": "0.0.1-commit.24de95ac",
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
+ "jest": "^30.0.0",
90
+ "jest-mock-extended": "^4.0.0",
91
+ "ts-loader": "^9.5.4",
90
92
  "ts-node": "^10.9.1",
91
- "typescript": "^5.0.4"
93
+ "typescript": "^5.3.3"
92
94
  },
93
95
  "files": [
94
96
  "dest",
@@ -98,6 +100,6 @@
98
100
  "!src/scripts/*"
99
101
  ],
100
102
  "engines": {
101
- "node": ">=18"
103
+ "node": ">=20.10"
102
104
  }
103
105
  }
@@ -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,14 @@ 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
  }
83
77
  }
@@ -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()),
@@ -1,39 +1,43 @@
1
1
  import {
2
2
  ARTIFACT_FUNCTION_TREE_MAX_HEIGHT,
3
- MAX_PACKED_BYTECODE_SIZE_PER_UNCONSTRAINED_FUNCTION_IN_FIELDS,
3
+ CONTRACT_CLASS_REGISTRY_UTILITY_FUNCTION_BROADCASTED_MAGIC_VALUE,
4
+ MAX_PACKED_BYTECODE_SIZE_PER_UTILITY_FUNCTION_IN_FIELDS,
4
5
  } from '@aztec/constants';
5
6
  import { removeArrayPaddingEnd } from '@aztec/foundation/collection';
6
7
  import { Fr } from '@aztec/foundation/fields';
7
8
  import type { Tuple } from '@aztec/foundation/serialize';
8
9
  import { FieldReader } from '@aztec/foundation/serialize';
9
10
  import { FunctionSelector, bufferFromFields } from '@aztec/stdlib/abi';
10
- import type { UnconstrainedFunction, UnconstrainedFunctionWithMembershipProof } from '@aztec/stdlib/contract';
11
+ import type { UtilityFunction, UtilityFunctionWithMembershipProof } from '@aztec/stdlib/contract';
11
12
  import type { ContractClassLog } from '@aztec/stdlib/logs';
12
13
 
13
- import { REGISTERER_UNCONSTRAINED_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
- export class UnconstrainedFunctionBroadcastedEvent {
16
+ /** Event emitted from the ContractClassRegistry. */
17
+ export class UtilityFunctionBroadcastedEvent {
17
18
  constructor(
18
19
  public readonly contractClassId: Fr,
19
20
  public readonly artifactMetadataHash: Fr,
20
21
  public readonly privateFunctionsArtifactTreeRoot: Fr,
21
22
  public readonly artifactFunctionTreeSiblingPath: Tuple<Fr, typeof ARTIFACT_FUNCTION_TREE_MAX_HEIGHT>,
22
23
  public readonly artifactFunctionTreeLeafIndex: number,
23
- public readonly unconstrainedFunction: BroadcastedUnconstrainedFunction,
24
+ public readonly utilityFunction: BroadcastedUtilityFunction,
24
25
  ) {}
25
26
 
26
- static isUnconstrainedFunctionBroadcastedEvent(log: ContractClassLog) {
27
- return log.fields[0].equals(REGISTERER_UNCONSTRAINED_FUNCTION_BROADCASTED_TAG);
27
+ static isUtilityFunctionBroadcastedEvent(log: ContractClassLog) {
28
+ return (
29
+ log.contractAddress.equals(ProtocolContractAddress.ContractClassRegistry) &&
30
+ log.fields.fields[0].toBigInt() === CONTRACT_CLASS_REGISTRY_UTILITY_FUNCTION_BROADCASTED_MAGIC_VALUE
31
+ );
28
32
  }
29
33
 
30
34
  static fromLog(log: ContractClassLog) {
31
- const reader = new FieldReader(log.fields.slice(1));
32
- const event = UnconstrainedFunctionBroadcastedEvent.fromFields(reader);
35
+ const reader = new FieldReader(log.fields.fields.slice(1));
36
+ const event = UtilityFunctionBroadcastedEvent.fromFields(reader);
33
37
  while (!reader.isFinished()) {
34
38
  const field = reader.readField();
35
39
  if (!field.isZero()) {
36
- throw new Error(`Unexpected data after parsing UnconstrainedFunctionBroadcastedEvent: ${field.toString()}`);
40
+ throw new Error(`Unexpected data after parsing UtilityFunctionBroadcastedEvent: ${field.toString()}`);
37
41
  }
38
42
  }
39
43
 
@@ -47,28 +51,28 @@ export class UnconstrainedFunctionBroadcastedEvent {
47
51
  const privateFunctionsArtifactTreeRoot = reader.readField();
48
52
  const artifactFunctionTreeSiblingPath = reader.readFieldArray(ARTIFACT_FUNCTION_TREE_MAX_HEIGHT);
49
53
  const artifactFunctionTreeLeafIndex = reader.readField().toNumber();
50
- const unconstrainedFunction = BroadcastedUnconstrainedFunction.fromFields(reader);
54
+ const utilityFunction = BroadcastedUtilityFunction.fromFields(reader);
51
55
 
52
- return new UnconstrainedFunctionBroadcastedEvent(
56
+ return new UtilityFunctionBroadcastedEvent(
53
57
  contractClassId,
54
58
  artifactMetadataHash,
55
59
  privateFunctionsArtifactTreeRoot,
56
60
  artifactFunctionTreeSiblingPath,
57
61
  artifactFunctionTreeLeafIndex,
58
- unconstrainedFunction,
62
+ utilityFunction,
59
63
  );
60
64
  }
61
65
 
62
- toFunctionWithMembershipProof(): UnconstrainedFunctionWithMembershipProof {
66
+ toFunctionWithMembershipProof(): UtilityFunctionWithMembershipProof {
63
67
  // We should be able to safely remove the zero elements that pad the variable-length sibling path,
64
68
  // since a sibling with value zero can only occur on the tree leaves, so the sibling path will never end
65
69
  // in a zero. The only exception is a tree with depth 2 with one non-zero leaf, where the sibling path would
66
70
  // be a single zero element, but in that case the artifact tree should be just the single leaf.
67
71
  const artifactTreeSiblingPath = removeArrayPaddingEnd(this.artifactFunctionTreeSiblingPath, Fr.isZero);
68
72
  return {
69
- ...this.unconstrainedFunction,
70
- bytecode: this.unconstrainedFunction.bytecode,
71
- functionMetadataHash: this.unconstrainedFunction.metadataHash,
73
+ ...this.utilityFunction,
74
+ bytecode: this.utilityFunction.bytecode,
75
+ functionMetadataHash: this.utilityFunction.metadataHash,
72
76
  artifactMetadataHash: this.artifactMetadataHash,
73
77
  privateFunctionsArtifactTreeRoot: this.privateFunctionsArtifactTreeRoot,
74
78
  artifactTreeSiblingPath,
@@ -77,7 +81,7 @@ export class UnconstrainedFunctionBroadcastedEvent {
77
81
  }
78
82
  }
79
83
 
80
- export class BroadcastedUnconstrainedFunction implements UnconstrainedFunction {
84
+ export class BroadcastedUtilityFunction implements UtilityFunction {
81
85
  constructor(
82
86
  /** Selector of the function. Calculated as the hash of the method name and parameters. The specification of this is not enforced by the protocol. */
83
87
  public readonly selector: FunctionSelector,
@@ -92,8 +96,8 @@ export class BroadcastedUnconstrainedFunction implements UnconstrainedFunction {
92
96
  const selector = FunctionSelector.fromField(reader.readField());
93
97
  const metadataHash = reader.readField();
94
98
  // The '* 1' removes the 'Type instantiation is excessively deep and possibly infinite. ts(2589)' err
95
- const encodedBytecode = reader.readFieldArray(MAX_PACKED_BYTECODE_SIZE_PER_UNCONSTRAINED_FUNCTION_IN_FIELDS * 1);
99
+ const encodedBytecode = reader.readFieldArray(MAX_PACKED_BYTECODE_SIZE_PER_UTILITY_FUNCTION_IN_FIELDS * 1);
96
100
  const bytecode = bufferFromFields(encodedBytecode);
97
- return new BroadcastedUnconstrainedFunction(selector, metadataHash, bytecode);
101
+ return new BroadcastedUtilityFunction(selector, metadataHash, bytecode);
98
102
  }
99
103
  }
@@ -4,7 +4,7 @@ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
4
4
  import { computePublicDataTreeLeafSlot, deriveStorageSlotInMap } from '@aztec/stdlib/hash';
5
5
  import type { NoirCompiledContract } from '@aztec/stdlib/noir';
6
6
 
7
- import FeeJuiceJson from '../../artifacts/FeeJuice.json' assert { type: 'json' };
7
+ import FeeJuiceJson from '../../artifacts/FeeJuice.json' with { type: 'json' };
8
8
  import { makeProtocolContract } from '../make_protocol_contract.js';
9
9
  import type { ProtocolContract } from '../protocol_contract.js';
10
10
  import { ProtocolContractAddress } from '../protocol_contract_data.js';
@@ -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';
@@ -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`
@@ -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 { DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_TAG } from '../protocol_contract_data.js';
8
+ import { CONTRACT_INSTANCE_PUBLISHED_EVENT_TAG } from '../protocol_contract_data.js';
9
9
 
10
- /** Event emitted from the ContractInstanceDeployer. */
11
- export class ContractInstanceDeployedEvent {
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 isContractInstanceDeployedEvent(log: PrivateLog) {
23
- return log.fields[0].equals(DEPLOYER_CONTRACT_INSTANCE_DEPLOYED_TAG);
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 ContractInstanceDeployedEvent(
37
+ return new ContractInstancePublishedEvent(
38
38
  address,
39
39
  version,
40
40
  salt,
@@ -1,36 +1,36 @@
1
+ import { CONTRACT_INSTANCE_UPDATED_MAGIC_VALUE } from '@aztec/constants';
1
2
  import { Fr } from '@aztec/foundation/fields';
2
- import { BufferReader } from '@aztec/foundation/serialize';
3
+ import { FieldReader } from '@aztec/foundation/serialize';
3
4
  import { AztecAddress } from '@aztec/stdlib/aztec-address';
4
5
  import type { ContractInstanceUpdateWithAddress } from '@aztec/stdlib/contract';
5
6
  import type { PublicLog } from '@aztec/stdlib/logs';
7
+ import type { UInt64 } from '@aztec/stdlib/types';
6
8
 
7
- import { DEPLOYER_CONTRACT_INSTANCE_UPDATED_TAG, ProtocolContractAddress } from '../protocol_contract_data.js';
9
+ import { ProtocolContractAddress } from '../protocol_contract_data.js';
8
10
 
9
- /** Event emitted from the ContractInstanceDeployer. */
11
+ /** Event emitted from the ContractInstanceRegistry. */
10
12
  export class ContractInstanceUpdatedEvent {
11
13
  constructor(
12
14
  public readonly address: AztecAddress,
13
15
  public readonly prevContractClassId: Fr,
14
16
  public readonly newContractClassId: Fr,
15
- public readonly blockOfChange: number,
17
+ public readonly timestampOfChange: UInt64,
16
18
  ) {}
17
19
 
18
20
  static isContractInstanceUpdatedEvent(log: PublicLog) {
19
21
  return (
20
- log.contractAddress.equals(ProtocolContractAddress.ContractInstanceDeployer) &&
21
- log.log[0].equals(DEPLOYER_CONTRACT_INSTANCE_UPDATED_TAG)
22
+ log.contractAddress.equals(ProtocolContractAddress.ContractInstanceRegistry) &&
23
+ log.fields[0].toBigInt() === CONTRACT_INSTANCE_UPDATED_MAGIC_VALUE
22
24
  );
23
25
  }
24
26
 
25
27
  static fromLog(log: PublicLog) {
26
- const bufferWithoutAddressAndTag = log.toBuffer().subarray(64);
27
- const reader = new BufferReader(bufferWithoutAddressAndTag);
28
+ const reader = new FieldReader(log.fields.slice(1) /* remove tag */);
28
29
  const address = reader.readObject(AztecAddress);
29
- const prevContractClassId = reader.readObject(Fr);
30
- const newContractClassId = reader.readObject(Fr);
31
- const blockOfChange = reader.readObject(Fr).toNumber();
32
-
33
- return new ContractInstanceUpdatedEvent(address, prevContractClassId, newContractClassId, blockOfChange);
30
+ const prevContractClassId = reader.readField();
31
+ const newContractClassId = reader.readField();
32
+ const timestampOfChange = reader.readField().toBigInt();
33
+ return new ContractInstanceUpdatedEvent(address, prevContractClassId, newContractClassId, timestampOfChange);
34
34
  }
35
35
 
36
36
  toContractInstanceUpdate(): ContractInstanceUpdateWithAddress {
@@ -38,7 +38,7 @@ export class ContractInstanceUpdatedEvent {
38
38
  address: this.address,
39
39
  prevContractClassId: this.prevContractClassId,
40
40
  newContractClassId: this.newContractClassId,
41
- blockOfChange: this.blockOfChange,
41
+ timestampOfChange: this.timestampOfChange,
42
42
  };
43
43
  }
44
44
  }
@@ -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 ContractInstanceDeployerJson from '../../artifacts/ContractInstanceDeployer.json' assert { type: 'json' };
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 './contract_instance_deployed_event.js';
8
+ export * from './contract_instance_published_event.js';
9
9
  export * from './contract_instance_updated_event.js';
10
10
 
11
- export const ContractInstanceDeployerArtifact = loadContractArtifact(
12
- ContractInstanceDeployerJson as NoirCompiledContract,
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 getCanonicalInstanceDeployer(): Promise<ProtocolContract> {
18
+ export async function getCanonicalInstanceRegistry(): Promise<ProtocolContract> {
19
19
  if (!protocolContract) {
20
- protocolContract = await makeProtocolContract('ContractInstanceDeployer', ContractInstanceDeployerArtifact);
20
+ protocolContract = await makeProtocolContract('ContractInstanceRegistry', ContractInstanceRegistryArtifact);
21
21
  }
22
22
  return protocolContract;
23
23
  }