@aztec/protocol-contracts 0.0.0-test.0 → 0.0.1-commit.21caa21

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,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,18 +0,0 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
- import { Fr } from '@aztec/foundation/fields';
4
- import { type ContractClassPublic } from '@aztec/stdlib/contract';
5
- import type { ContractClassLog } from '@aztec/stdlib/logs';
6
- /** Event emitted from the ContractClassRegisterer. */
7
- export declare class ContractClassRegisteredEvent {
8
- readonly contractClassId: Fr;
9
- readonly version: number;
10
- readonly artifactHash: Fr;
11
- readonly privateFunctionsRoot: Fr;
12
- readonly packedPublicBytecode: Buffer;
13
- constructor(contractClassId: Fr, version: number, artifactHash: Fr, privateFunctionsRoot: Fr, packedPublicBytecode: Buffer);
14
- static isContractClassRegisteredEvent(log: ContractClassLog): boolean;
15
- static fromLog(log: ContractClassLog): ContractClassRegisteredEvent;
16
- toContractClassPublic(): Promise<ContractClassPublic>;
17
- }
18
- //# sourceMappingURL=contract_class_registered_event.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"contract_class_registered_event.d.ts","sourceRoot":"","sources":["../../src/class-registerer/contract_class_registered_event.ts"],"names":[],"mappings":";;AACA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAG9C,OAAO,EACL,KAAK,mBAAmB,EAIzB,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAI3D,sDAAsD;AACtD,qBAAa,4BAA4B;aAErB,eAAe,EAAE,EAAE;aACnB,OAAO,EAAE,MAAM;aACf,YAAY,EAAE,EAAE;aAChB,oBAAoB,EAAE,EAAE;aACxB,oBAAoB,EAAE,MAAM;gBAJ5B,eAAe,EAAE,EAAE,EACnB,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,EAAE,EAChB,oBAAoB,EAAE,EAAE,EACxB,oBAAoB,EAAE,MAAM;IAG9C,MAAM,CAAC,8BAA8B,CAAC,GAAG,EAAE,gBAAgB;IAI3D,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,gBAAgB;IAiB9B,qBAAqB,IAAI,OAAO,CAAC,mBAAmB,CAAC;CAqC5D"}
@@ -1,8 +0,0 @@
1
- import type { ProtocolContract } from '../protocol_contract.js';
2
- export * from './contract_class_registered_event.js';
3
- export * from './private_function_broadcasted_event.js';
4
- export * from './unconstrained_function_broadcasted_event.js';
5
- export declare const ContractClassRegistererArtifact: import("@aztec/stdlib/abi").ContractArtifact;
6
- /** Returns the canonical deployment of the contract. */
7
- export declare function getCanonicalClassRegisterer(): Promise<ProtocolContract>;
8
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/class-registerer/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,cAAc,sCAAsC,CAAC;AACrD,cAAc,yCAAyC,CAAC;AACxD,cAAc,+CAA+C,CAAC;AAE9D,eAAO,MAAM,+BAA+B,8CAE3C,CAAC;AAIF,wDAAwD;AACxD,wBAAsB,2BAA2B,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAM7E"}
@@ -1,17 +0,0 @@
1
- import { loadContractArtifact } from '@aztec/stdlib/abi';
2
- import ContractClassRegistererJson from '../../artifacts/ContractClassRegisterer.json' assert {
3
- type: 'json'
4
- };
5
- import { makeProtocolContract } from '../make_protocol_contract.js';
6
- export * from './contract_class_registered_event.js';
7
- export * from './private_function_broadcasted_event.js';
8
- export * from './unconstrained_function_broadcasted_event.js';
9
- export const ContractClassRegistererArtifact = loadContractArtifact(ContractClassRegistererJson);
10
- let protocolContract;
11
- /** Returns the canonical deployment of the contract. */ export async function getCanonicalClassRegisterer() {
12
- if (!protocolContract) {
13
- const artifact = ContractClassRegistererArtifact;
14
- protocolContract = await makeProtocolContract('ContractClassRegisterer', artifact);
15
- }
16
- return protocolContract;
17
- }
@@ -1,9 +0,0 @@
1
- import { type ContractArtifact } from '@aztec/stdlib/abi';
2
- import type { ProtocolContract } from '../protocol_contract.js';
3
- export * from './contract_class_registered_event.js';
4
- export * from './private_function_broadcasted_event.js';
5
- export * from './unconstrained_function_broadcasted_event.js';
6
- export declare function getContractClassRegistererArtifact(): Promise<ContractArtifact>;
7
- /** Returns the canonical deployment of the auth registry. */
8
- export declare function getCanonicalClassRegisterer(): Promise<ProtocolContract>;
9
- //# sourceMappingURL=lazy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../src/class-registerer/lazy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAwB,MAAM,mBAAmB,CAAC;AAGhF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,cAAc,sCAAsC,CAAC;AACrD,cAAc,yCAAyC,CAAC;AACxD,cAAc,+CAA+C,CAAC;AAK9D,wBAAsB,kCAAkC,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAWpF;AAED,6DAA6D;AAC7D,wBAAsB,2BAA2B,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAM7E"}
@@ -1,26 +0,0 @@
1
- import { loadContractArtifact } from '@aztec/stdlib/abi';
2
- import { makeProtocolContract } from '../make_protocol_contract.js';
3
- export * from './contract_class_registered_event.js';
4
- export * from './private_function_broadcasted_event.js';
5
- export * from './unconstrained_function_broadcasted_event.js';
6
- let protocolContract;
7
- let protocolContractArtifact;
8
- export async function getContractClassRegistererArtifact() {
9
- if (!protocolContractArtifact) {
10
- // Cannot assert this import as it's incompatible with browsers
11
- // https://caniuse.com/mdn-javascript_statements_import_import_assertions_type_json
12
- // Use the new "with" syntax once supported by firefox
13
- // https://caniuse.com/mdn-javascript_statements_import_import_attributes_type_json
14
- // In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
15
- const { default: contractClassRegistererJson } = await import('../../artifacts/ContractClassRegisterer.json');
16
- protocolContractArtifact = loadContractArtifact(contractClassRegistererJson);
17
- }
18
- return protocolContractArtifact;
19
- }
20
- /** Returns the canonical deployment of the auth registry. */ export async function getCanonicalClassRegisterer() {
21
- if (!protocolContract) {
22
- const contractClassRegistererArtifact = await getContractClassRegistererArtifact();
23
- protocolContract = await makeProtocolContract('ContractClassRegisterer', contractClassRegistererArtifact);
24
- }
25
- return protocolContract;
26
- }
@@ -1,46 +0,0 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
- import { ARTIFACT_FUNCTION_TREE_MAX_HEIGHT, FUNCTION_TREE_HEIGHT } from '@aztec/constants';
4
- import { Fr } from '@aztec/foundation/fields';
5
- import type { Tuple } from '@aztec/foundation/serialize';
6
- import { FieldReader } from '@aztec/foundation/serialize';
7
- import { FunctionSelector } from '@aztec/stdlib/abi';
8
- import type { ExecutablePrivateFunctionWithMembershipProof, PrivateFunction } from '@aztec/stdlib/contract';
9
- import type { ContractClassLog } from '@aztec/stdlib/logs';
10
- /** Event emitted from the ContractClassRegisterer. */
11
- export declare class PrivateFunctionBroadcastedEvent {
12
- readonly contractClassId: Fr;
13
- readonly artifactMetadataHash: Fr;
14
- readonly unconstrainedFunctionsArtifactTreeRoot: Fr;
15
- readonly privateFunctionTreeSiblingPath: Tuple<Fr, typeof FUNCTION_TREE_HEIGHT>;
16
- readonly privateFunctionTreeLeafIndex: number;
17
- readonly artifactFunctionTreeSiblingPath: Tuple<Fr, typeof ARTIFACT_FUNCTION_TREE_MAX_HEIGHT>;
18
- readonly artifactFunctionTreeLeafIndex: number;
19
- readonly privateFunction: BroadcastedPrivateFunction;
20
- constructor(contractClassId: Fr, artifactMetadataHash: Fr, unconstrainedFunctionsArtifactTreeRoot: Fr, privateFunctionTreeSiblingPath: Tuple<Fr, typeof FUNCTION_TREE_HEIGHT>, privateFunctionTreeLeafIndex: number, artifactFunctionTreeSiblingPath: Tuple<Fr, typeof ARTIFACT_FUNCTION_TREE_MAX_HEIGHT>, artifactFunctionTreeLeafIndex: number, privateFunction: BroadcastedPrivateFunction);
21
- static isPrivateFunctionBroadcastedEvent(log: ContractClassLog): boolean;
22
- static fromLog(log: ContractClassLog): PrivateFunctionBroadcastedEvent;
23
- static fromFields(fields: Fr[] | FieldReader): PrivateFunctionBroadcastedEvent;
24
- toFunctionWithMembershipProof(): ExecutablePrivateFunctionWithMembershipProof;
25
- }
26
- export declare class BroadcastedPrivateFunction implements PrivateFunction {
27
- /** Selector of the function. Calculated as the hash of the method name and parameters. The specification of this is not enforced by the protocol. */
28
- readonly selector: FunctionSelector;
29
- /** Artifact metadata hash */
30
- readonly metadataHash: Fr;
31
- /** Hash of the verification key associated to this private function. */
32
- readonly vkHash: Fr;
33
- /** ACIR and Brillig bytecode */
34
- readonly bytecode: Buffer;
35
- constructor(
36
- /** Selector of the function. Calculated as the hash of the method name and parameters. The specification of this is not enforced by the protocol. */
37
- selector: FunctionSelector,
38
- /** Artifact metadata hash */
39
- metadataHash: Fr,
40
- /** Hash of the verification key associated to this private function. */
41
- vkHash: Fr,
42
- /** ACIR and Brillig bytecode */
43
- bytecode: Buffer);
44
- static fromFields(fields: Fr[] | FieldReader): BroadcastedPrivateFunction;
45
- }
46
- //# sourceMappingURL=private_function_broadcasted_event.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"private_function_broadcasted_event.d.ts","sourceRoot":"","sources":["../../src/class-registerer/private_function_broadcasted_event.ts"],"names":[],"mappings":";;AAAA,OAAO,EACL,iCAAiC,EACjC,oBAAoB,EAErB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAoB,MAAM,mBAAmB,CAAC;AACvE,OAAO,KAAK,EAAE,4CAA4C,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC5G,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAI3D,sDAAsD;AACtD,qBAAa,+BAA+B;aAExB,eAAe,EAAE,EAAE;aACnB,oBAAoB,EAAE,EAAE;aACxB,sCAAsC,EAAE,EAAE;aAC1C,8BAA8B,EAAE,KAAK,CAAC,EAAE,EAAE,OAAO,oBAAoB,CAAC;aACtE,4BAA4B,EAAE,MAAM;aACpC,+BAA+B,EAAE,KAAK,CAAC,EAAE,EAAE,OAAO,iCAAiC,CAAC;aACpF,6BAA6B,EAAE,MAAM;aACrC,eAAe,EAAE,0BAA0B;gBAP3C,eAAe,EAAE,EAAE,EACnB,oBAAoB,EAAE,EAAE,EACxB,sCAAsC,EAAE,EAAE,EAC1C,8BAA8B,EAAE,KAAK,CAAC,EAAE,EAAE,OAAO,oBAAoB,CAAC,EACtE,4BAA4B,EAAE,MAAM,EACpC,+BAA+B,EAAE,KAAK,CAAC,EAAE,EAAE,OAAO,iCAAiC,CAAC,EACpF,6BAA6B,EAAE,MAAM,EACrC,eAAe,EAAE,0BAA0B;IAG7D,MAAM,CAAC,iCAAiC,CAAC,GAAG,EAAE,gBAAgB;IAI9D,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,gBAAgB;IAapC,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,WAAW;IAuB5C,6BAA6B,IAAI,4CAA4C;CAa9E;AAED,qBAAa,0BAA2B,YAAW,eAAe;IAE9D,qJAAqJ;aACrI,QAAQ,EAAE,gBAAgB;IAC1C,6BAA6B;aACb,YAAY,EAAE,EAAE;IAChC,wEAAwE;aACxD,MAAM,EAAE,EAAE;IAC1B,gCAAgC;aAChB,QAAQ,EAAE,MAAM;;IAPhC,qJAAqJ;IACrI,QAAQ,EAAE,gBAAgB;IAC1C,6BAA6B;IACb,YAAY,EAAE,EAAE;IAChC,wEAAwE;IACxD,MAAM,EAAE,EAAE;IAC1B,gCAAgC;IAChB,QAAQ,EAAE,MAAM;IAGlC,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,WAAW;CAU7C"}
@@ -1,40 +0,0 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
- import { ARTIFACT_FUNCTION_TREE_MAX_HEIGHT } from '@aztec/constants';
4
- import { Fr } from '@aztec/foundation/fields';
5
- import type { Tuple } from '@aztec/foundation/serialize';
6
- import { FieldReader } from '@aztec/foundation/serialize';
7
- import { FunctionSelector } from '@aztec/stdlib/abi';
8
- import type { UnconstrainedFunction, UnconstrainedFunctionWithMembershipProof } from '@aztec/stdlib/contract';
9
- import type { ContractClassLog } from '@aztec/stdlib/logs';
10
- /** Event emitted from the ContractClassRegisterer. */
11
- export declare class UnconstrainedFunctionBroadcastedEvent {
12
- readonly contractClassId: Fr;
13
- readonly artifactMetadataHash: Fr;
14
- readonly privateFunctionsArtifactTreeRoot: Fr;
15
- readonly artifactFunctionTreeSiblingPath: Tuple<Fr, typeof ARTIFACT_FUNCTION_TREE_MAX_HEIGHT>;
16
- readonly artifactFunctionTreeLeafIndex: number;
17
- readonly unconstrainedFunction: BroadcastedUnconstrainedFunction;
18
- constructor(contractClassId: Fr, artifactMetadataHash: Fr, privateFunctionsArtifactTreeRoot: Fr, artifactFunctionTreeSiblingPath: Tuple<Fr, typeof ARTIFACT_FUNCTION_TREE_MAX_HEIGHT>, artifactFunctionTreeLeafIndex: number, unconstrainedFunction: BroadcastedUnconstrainedFunction);
19
- static isUnconstrainedFunctionBroadcastedEvent(log: ContractClassLog): boolean;
20
- static fromLog(log: ContractClassLog): UnconstrainedFunctionBroadcastedEvent;
21
- static fromFields(fields: Fr[] | FieldReader): UnconstrainedFunctionBroadcastedEvent;
22
- toFunctionWithMembershipProof(): UnconstrainedFunctionWithMembershipProof;
23
- }
24
- export declare class BroadcastedUnconstrainedFunction implements UnconstrainedFunction {
25
- /** Selector of the function. Calculated as the hash of the method name and parameters. The specification of this is not enforced by the protocol. */
26
- readonly selector: FunctionSelector;
27
- /** Artifact metadata hash */
28
- readonly metadataHash: Fr;
29
- /** Brillig bytecode */
30
- readonly bytecode: Buffer;
31
- constructor(
32
- /** Selector of the function. Calculated as the hash of the method name and parameters. The specification of this is not enforced by the protocol. */
33
- selector: FunctionSelector,
34
- /** Artifact metadata hash */
35
- metadataHash: Fr,
36
- /** Brillig bytecode */
37
- bytecode: Buffer);
38
- static fromFields(fields: Fr[] | FieldReader): BroadcastedUnconstrainedFunction;
39
- }
40
- //# sourceMappingURL=unconstrained_function_broadcasted_event.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"unconstrained_function_broadcasted_event.d.ts","sourceRoot":"","sources":["../../src/class-registerer/unconstrained_function_broadcasted_event.ts"],"names":[],"mappings":";;AAAA,OAAO,EACL,iCAAiC,EAElC,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAoB,MAAM,mBAAmB,CAAC;AACvE,OAAO,KAAK,EAAE,qBAAqB,EAAE,wCAAwC,EAAE,MAAM,wBAAwB,CAAC;AAC9G,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAI3D,sDAAsD;AACtD,qBAAa,qCAAqC;aAE9B,eAAe,EAAE,EAAE;aACnB,oBAAoB,EAAE,EAAE;aACxB,gCAAgC,EAAE,EAAE;aACpC,+BAA+B,EAAE,KAAK,CAAC,EAAE,EAAE,OAAO,iCAAiC,CAAC;aACpF,6BAA6B,EAAE,MAAM;aACrC,qBAAqB,EAAE,gCAAgC;gBALvD,eAAe,EAAE,EAAE,EACnB,oBAAoB,EAAE,EAAE,EACxB,gCAAgC,EAAE,EAAE,EACpC,+BAA+B,EAAE,KAAK,CAAC,EAAE,EAAE,OAAO,iCAAiC,CAAC,EACpF,6BAA6B,EAAE,MAAM,EACrC,qBAAqB,EAAE,gCAAgC;IAGzE,MAAM,CAAC,uCAAuC,CAAC,GAAG,EAAE,gBAAgB;IAIpE,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,gBAAgB;IAapC,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,WAAW;IAmB5C,6BAA6B,IAAI,wCAAwC;CAgB1E;AAED,qBAAa,gCAAiC,YAAW,qBAAqB;IAE1E,qJAAqJ;aACrI,QAAQ,EAAE,gBAAgB;IAC1C,6BAA6B;aACb,YAAY,EAAE,EAAE;IAChC,uBAAuB;aACP,QAAQ,EAAE,MAAM;;IALhC,qJAAqJ;IACrI,QAAQ,EAAE,gBAAgB;IAC1C,6BAA6B;IACb,YAAY,EAAE,EAAE;IAChC,uBAAuB;IACP,QAAQ,EAAE,MAAM;IAGlC,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,WAAW;CAS7C"}
@@ -1,20 +0,0 @@
1
- import { Fr } from '@aztec/foundation/fields';
2
- import { AztecAddress } from '@aztec/stdlib/aztec-address';
3
- import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
4
- import { PublicKeys } from '@aztec/stdlib/keys';
5
- import type { PrivateLog } from '@aztec/stdlib/logs';
6
- /** Event emitted from the ContractInstanceDeployer. */
7
- export declare class ContractInstanceDeployedEvent {
8
- readonly address: AztecAddress;
9
- readonly version: number;
10
- readonly salt: Fr;
11
- readonly contractClassId: Fr;
12
- readonly initializationHash: Fr;
13
- readonly publicKeys: PublicKeys;
14
- readonly deployer: AztecAddress;
15
- constructor(address: AztecAddress, version: number, salt: Fr, contractClassId: Fr, initializationHash: Fr, publicKeys: PublicKeys, deployer: AztecAddress);
16
- static isContractInstanceDeployedEvent(log: PrivateLog): boolean;
17
- static fromLog(log: PrivateLog): ContractInstanceDeployedEvent;
18
- toContractInstance(): ContractInstanceWithAddress;
19
- }
20
- //# sourceMappingURL=contract_instance_deployed_event.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"contract_instance_deployed_event.d.ts","sourceRoot":"","sources":["../../src/instance-deployer/contract_instance_deployed_event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIrD,uDAAuD;AACvD,qBAAa,6BAA6B;aAEtB,OAAO,EAAE,YAAY;aACrB,OAAO,EAAE,MAAM;aACf,IAAI,EAAE,EAAE;aACR,eAAe,EAAE,EAAE;aACnB,kBAAkB,EAAE,EAAE;aACtB,UAAU,EAAE,UAAU;aACtB,QAAQ,EAAE,YAAY;gBANtB,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,EAAE,EACR,eAAe,EAAE,EAAE,EACnB,kBAAkB,EAAE,EAAE,EACtB,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,YAAY;IAGxC,MAAM,CAAC,+BAA+B,CAAC,GAAG,EAAE,UAAU;IAItD,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,UAAU;IAsB9B,kBAAkB,IAAI,2BAA2B;CAgBlD"}
@@ -1,16 +0,0 @@
1
- import { Fr } from '@aztec/foundation/fields';
2
- import { AztecAddress } from '@aztec/stdlib/aztec-address';
3
- import type { ContractInstanceUpdateWithAddress } from '@aztec/stdlib/contract';
4
- import type { PublicLog } from '@aztec/stdlib/logs';
5
- /** Event emitted from the ContractInstanceDeployer. */
6
- export declare class ContractInstanceUpdatedEvent {
7
- readonly address: AztecAddress;
8
- readonly prevContractClassId: Fr;
9
- readonly newContractClassId: Fr;
10
- readonly blockOfChange: number;
11
- constructor(address: AztecAddress, prevContractClassId: Fr, newContractClassId: Fr, blockOfChange: number);
12
- static isContractInstanceUpdatedEvent(log: PublicLog): boolean;
13
- static fromLog(log: PublicLog): ContractInstanceUpdatedEvent;
14
- toContractInstanceUpdate(): ContractInstanceUpdateWithAddress;
15
- }
16
- //# sourceMappingURL=contract_instance_updated_event.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"contract_instance_updated_event.d.ts","sourceRoot":"","sources":["../../src/instance-deployer/contract_instance_updated_event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,wBAAwB,CAAC;AAChF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAIpD,uDAAuD;AACvD,qBAAa,4BAA4B;aAErB,OAAO,EAAE,YAAY;aACrB,mBAAmB,EAAE,EAAE;aACvB,kBAAkB,EAAE,EAAE;aACtB,aAAa,EAAE,MAAM;gBAHrB,OAAO,EAAE,YAAY,EACrB,mBAAmB,EAAE,EAAE,EACvB,kBAAkB,EAAE,EAAE,EACtB,aAAa,EAAE,MAAM;IAGvC,MAAM,CAAC,8BAA8B,CAAC,GAAG,EAAE,SAAS;IAOpD,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,SAAS;IAW7B,wBAAwB,IAAI,iCAAiC;CAQ9D"}
@@ -1,36 +0,0 @@
1
- import { Fr } from '@aztec/foundation/fields';
2
- import { BufferReader } from '@aztec/foundation/serialize';
3
- import { AztecAddress } from '@aztec/stdlib/aztec-address';
4
- import { DEPLOYER_CONTRACT_INSTANCE_UPDATED_TAG, ProtocolContractAddress } from '../protocol_contract_data.js';
5
- /** Event emitted from the ContractInstanceDeployer. */ export class ContractInstanceUpdatedEvent {
6
- address;
7
- prevContractClassId;
8
- newContractClassId;
9
- blockOfChange;
10
- constructor(address, prevContractClassId, newContractClassId, blockOfChange){
11
- this.address = address;
12
- this.prevContractClassId = prevContractClassId;
13
- this.newContractClassId = newContractClassId;
14
- this.blockOfChange = blockOfChange;
15
- }
16
- static isContractInstanceUpdatedEvent(log) {
17
- return log.contractAddress.equals(ProtocolContractAddress.ContractInstanceDeployer) && log.log[0].equals(DEPLOYER_CONTRACT_INSTANCE_UPDATED_TAG);
18
- }
19
- static fromLog(log) {
20
- const bufferWithoutAddressAndTag = log.toBuffer().subarray(64);
21
- const reader = new BufferReader(bufferWithoutAddressAndTag);
22
- const address = reader.readObject(AztecAddress);
23
- const prevContractClassId = reader.readObject(Fr);
24
- const newContractClassId = reader.readObject(Fr);
25
- const blockOfChange = reader.readObject(Fr).toNumber();
26
- return new ContractInstanceUpdatedEvent(address, prevContractClassId, newContractClassId, blockOfChange);
27
- }
28
- toContractInstanceUpdate() {
29
- return {
30
- address: this.address,
31
- prevContractClassId: this.prevContractClassId,
32
- newContractClassId: this.newContractClassId,
33
- blockOfChange: this.blockOfChange
34
- };
35
- }
36
- }
@@ -1,7 +0,0 @@
1
- import type { ProtocolContract } from '../protocol_contract.js';
2
- export * from './contract_instance_deployed_event.js';
3
- export * from './contract_instance_updated_event.js';
4
- export declare const ContractInstanceDeployerArtifact: import("@aztec/stdlib/abi").ContractArtifact;
5
- /** Returns the canonical deployment of the contract. */
6
- export declare function getCanonicalInstanceDeployer(): Promise<ProtocolContract>;
7
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/instance-deployer/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,cAAc,uCAAuC,CAAC;AACtD,cAAc,sCAAsC,CAAC;AAErD,eAAO,MAAM,gCAAgC,8CAE5C,CAAC;AAIF,wDAAwD;AACxD,wBAAsB,4BAA4B,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAK9E"}
@@ -1,8 +0,0 @@
1
- import { type ContractArtifact } from '@aztec/stdlib/abi';
2
- import type { ProtocolContract } from '../protocol_contract.js';
3
- export * from './contract_instance_deployed_event.js';
4
- export * from './contract_instance_updated_event.js';
5
- export declare function getContractInstanceDeployerArtifact(): Promise<ContractArtifact>;
6
- /** Returns the canonical deployment of the auth registry. */
7
- export declare function getCanonicalInstanceDeployer(): Promise<ProtocolContract>;
8
- //# sourceMappingURL=lazy.d.ts.map
@@ -1,25 +0,0 @@
1
- import { loadContractArtifact } from '@aztec/stdlib/abi';
2
- import { makeProtocolContract } from '../make_protocol_contract.js';
3
- export * from './contract_instance_deployed_event.js';
4
- export * from './contract_instance_updated_event.js';
5
- let protocolContract;
6
- let protocolContractArtifact;
7
- export async function getContractInstanceDeployerArtifact() {
8
- if (!protocolContractArtifact) {
9
- // Cannot assert this import as it's incompatible with browsers
10
- // https://caniuse.com/mdn-javascript_statements_import_import_assertions_type_json
11
- // Use the new "with" syntax once supported by firefox
12
- // https://caniuse.com/mdn-javascript_statements_import_import_attributes_type_json
13
- // In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
14
- const { default: contractInstanceDeployerJson } = await import('../../artifacts/ContractInstanceDeployer.json');
15
- protocolContractArtifact = loadContractArtifact(contractInstanceDeployerJson);
16
- }
17
- return protocolContractArtifact;
18
- }
19
- /** Returns the canonical deployment of the auth registry. */ export async function getCanonicalInstanceDeployer() {
20
- if (!protocolContract) {
21
- const contractInstanceDeployerArtifact = await getContractInstanceDeployerArtifact();
22
- protocolContract = await makeProtocolContract('ContractInstanceDeployer', contractInstanceDeployerArtifact);
23
- }
24
- return protocolContract;
25
- }
@@ -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
- }
@@ -1,29 +0,0 @@
1
- import { MAX_PROTOCOL_CONTRACTS, PROTOCOL_CONTRACT_TREE_HEIGHT } from '@aztec/constants';
2
- import { poseidon2Hash } from '@aztec/foundation/crypto';
3
- import type { Fr } from '@aztec/foundation/fields';
4
- import { type IndexedMerkleTree, IndexedMerkleTreeCalculator } from '@aztec/foundation/trees';
5
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
6
- import { ProtocolContractLeafPreimage } from '@aztec/stdlib/trees';
7
-
8
- export async function buildProtocolContractTree(
9
- contracts: { address: AztecAddress; leaf: Fr }[],
10
- ): Promise<IndexedMerkleTree<ProtocolContractLeafPreimage, typeof PROTOCOL_CONTRACT_TREE_HEIGHT>> {
11
- const hasher = {
12
- hash: async (l: Buffer, r: Buffer) => (await poseidon2Hash([l, r])).toBuffer(),
13
- hashInputs: async (i: Buffer[]) => (await poseidon2Hash(i)).toBuffer(),
14
- };
15
- const calculator = await IndexedMerkleTreeCalculator.create(
16
- PROTOCOL_CONTRACT_TREE_HEIGHT,
17
- hasher,
18
- ProtocolContractLeafPreimage,
19
- );
20
-
21
- const leaves = new Array(MAX_PROTOCOL_CONTRACTS).fill(Buffer.alloc(32));
22
-
23
- for (const contract of contracts) {
24
- const index = contract.address.toField().toNumber();
25
- leaves[index] = contract.leaf.toBuffer();
26
- }
27
-
28
- return calculator.computeTree(leaves);
29
- }
@@ -1,33 +0,0 @@
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_registered_event.js';
7
- export * from './private_function_broadcasted_event.js';
8
- export * from './unconstrained_function_broadcasted_event.js';
9
-
10
- let protocolContract: ProtocolContract;
11
- let protocolContractArtifact: ContractArtifact;
12
-
13
- export async function getContractClassRegistererArtifact(): Promise<ContractArtifact> {
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
19
- // In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
20
- const { default: contractClassRegistererJson } = await import('../../artifacts/ContractClassRegisterer.json');
21
- protocolContractArtifact = loadContractArtifact(contractClassRegistererJson);
22
- }
23
- return protocolContractArtifact;
24
- }
25
-
26
- /** Returns the canonical deployment of the auth registry. */
27
- export async function getCanonicalClassRegisterer(): Promise<ProtocolContract> {
28
- if (!protocolContract) {
29
- const contractClassRegistererArtifact = await getContractClassRegistererArtifact();
30
- protocolContract = await makeProtocolContract('ContractClassRegisterer', contractClassRegistererArtifact);
31
- }
32
- return protocolContract;
33
- }
@@ -1,44 +0,0 @@
1
- import type { PROTOCOL_CONTRACT_TREE_HEIGHT } from '@aztec/constants';
2
- import { poseidon2Hash } from '@aztec/foundation/crypto';
3
- import type { IndexedMerkleTree } from '@aztec/foundation/trees';
4
- import type { AztecAddress } from '@aztec/stdlib/aztec-address';
5
- import type { ProtocolContractLeafPreimage } from '@aztec/stdlib/trees';
6
-
7
- import { buildProtocolContractTree } from './build_protocol_contract_tree.js';
8
- import { isProtocolContract } from './protocol_contract.js';
9
- import { ProtocolContractAddress, ProtocolContractLeaves, protocolContractNames } from './protocol_contract_data.js';
10
-
11
- let protocolContractTree:
12
- | IndexedMerkleTree<ProtocolContractLeafPreimage, typeof PROTOCOL_CONTRACT_TREE_HEIGHT>
13
- | undefined;
14
-
15
- async function getTree() {
16
- if (!protocolContractTree) {
17
- const leaves = protocolContractNames.map(name => ({
18
- address: ProtocolContractAddress[name],
19
- leaf: ProtocolContractLeaves[name],
20
- }));
21
- protocolContractTree = await buildProtocolContractTree(leaves);
22
- }
23
- return protocolContractTree;
24
- }
25
-
26
- // Computed address can be different from contract address due to upgrades
27
- export async function getProtocolContractLeafAndMembershipWitness(
28
- contractAddress: AztecAddress,
29
- computedAddress: AztecAddress,
30
- ) {
31
- const tree = await getTree();
32
- let lowLeaf;
33
- let witness;
34
- if (isProtocolContract(contractAddress)) {
35
- const index = contractAddress.toField().toNumber();
36
- lowLeaf = tree.leafPreimages[index];
37
- witness = tree.getMembershipWitness(index);
38
- } else {
39
- lowLeaf = tree.getLowLeaf(computedAddress.toBigInt());
40
- const hashed = (await poseidon2Hash(lowLeaf.toHashInputs())).toBuffer();
41
- witness = tree.getMembershipWitness(hashed);
42
- }
43
- return { lowLeaf, witness };
44
- }