@aztec/standard-contracts 0.0.1-commit.04d373f

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 (69) hide show
  1. package/artifacts/AuthRegistry.d.json.ts +5 -0
  2. package/artifacts/AuthRegistry.json +7838 -0
  3. package/artifacts/MultiCallEntrypoint.d.json.ts +5 -0
  4. package/artifacts/MultiCallEntrypoint.json +5994 -0
  5. package/artifacts/PublicChecks.d.json.ts +5 -0
  6. package/artifacts/PublicChecks.json +4290 -0
  7. package/dest/auth-registry/constants.d.ts +4 -0
  8. package/dest/auth-registry/constants.d.ts.map +1 -0
  9. package/dest/auth-registry/constants.js +7 -0
  10. package/dest/auth-registry/index.d.ts +6 -0
  11. package/dest/auth-registry/index.d.ts.map +1 -0
  12. package/dest/auth-registry/index.js +14 -0
  13. package/dest/auth-registry/lazy.d.ts +7 -0
  14. package/dest/auth-registry/lazy.d.ts.map +1 -0
  15. package/dest/auth-registry/lazy.js +24 -0
  16. package/dest/contract_data.d.ts +63 -0
  17. package/dest/contract_data.d.ts.map +1 -0
  18. package/dest/contract_data.js +101 -0
  19. package/dest/drift.d.ts +54 -0
  20. package/dest/drift.d.ts.map +1 -0
  21. package/dest/drift.js +167 -0
  22. package/dest/index.d.ts +4 -0
  23. package/dest/index.d.ts.map +1 -0
  24. package/dest/index.js +3 -0
  25. package/dest/make_standard_contract.d.ts +9 -0
  26. package/dest/make_standard_contract.d.ts.map +1 -0
  27. package/dest/make_standard_contract.js +40 -0
  28. package/dest/multi-call-entrypoint/constants.d.ts +4 -0
  29. package/dest/multi-call-entrypoint/constants.d.ts.map +1 -0
  30. package/dest/multi-call-entrypoint/constants.js +7 -0
  31. package/dest/multi-call-entrypoint/index.d.ts +6 -0
  32. package/dest/multi-call-entrypoint/index.d.ts.map +1 -0
  33. package/dest/multi-call-entrypoint/index.js +14 -0
  34. package/dest/multi-call-entrypoint/lazy.d.ts +7 -0
  35. package/dest/multi-call-entrypoint/lazy.d.ts.map +1 -0
  36. package/dest/multi-call-entrypoint/lazy.js +24 -0
  37. package/dest/public-checks/constants.d.ts +4 -0
  38. package/dest/public-checks/constants.d.ts.map +1 -0
  39. package/dest/public-checks/constants.js +7 -0
  40. package/dest/public-checks/index.d.ts +6 -0
  41. package/dest/public-checks/index.d.ts.map +1 -0
  42. package/dest/public-checks/index.js +14 -0
  43. package/dest/public-checks/lazy.d.ts +7 -0
  44. package/dest/public-checks/lazy.d.ts.map +1 -0
  45. package/dest/public-checks/lazy.js +24 -0
  46. package/dest/scripts/cleanup_artifacts.js +16 -0
  47. package/dest/scripts/generate_data.js +136 -0
  48. package/dest/standard_contract.d.ts +15 -0
  49. package/dest/standard_contract.d.ts.map +1 -0
  50. package/dest/standard_contract.js +1 -0
  51. package/dest/standard_contract_data.d.ts +19 -0
  52. package/dest/standard_contract_data.d.ts.map +1 -0
  53. package/dest/standard_contract_data.js +61 -0
  54. package/package.json +102 -0
  55. package/src/auth-registry/constants.ts +8 -0
  56. package/src/auth-registry/index.ts +24 -0
  57. package/src/auth-registry/lazy.ts +35 -0
  58. package/src/contract_data.ts +124 -0
  59. package/src/drift.ts +201 -0
  60. package/src/index.ts +3 -0
  61. package/src/make_standard_contract.ts +51 -0
  62. package/src/multi-call-entrypoint/constants.ts +8 -0
  63. package/src/multi-call-entrypoint/index.ts +24 -0
  64. package/src/multi-call-entrypoint/lazy.ts +35 -0
  65. package/src/public-checks/constants.ts +8 -0
  66. package/src/public-checks/index.ts +24 -0
  67. package/src/public-checks/lazy.ts +35 -0
  68. package/src/standard_contract.ts +15 -0
  69. package/src/standard_contract_data.ts +76 -0
@@ -0,0 +1,124 @@
1
+ // Shared core for the standard-contracts data generator (`scripts/generate_data.ts`) and its
2
+ // drift-detection test (`standard_contract_data.test.ts`). Keeping the `standardContracts[]`
3
+ // list, paths, and the `computeContractData` derivation in one module ensures the generator
4
+ // (which writes the data) and the test (which checks the committed data is fresh) run the exact
5
+ // same code path. Adding a new standard contract is a one-row change in the array below — both
6
+ // the generator and the drift test pick it up automatically.
7
+ //
8
+ // The rendering and write-if-changed plumbing lives in `drift.ts`, a build-time-only sibling
9
+ // module — keeping `prettier` out of this module avoids pulling a formatter into the published
10
+ // package's transitive imports.
11
+ //
12
+ // Paths below are relative to `yarn-project/standard-contracts` (the cwd when scripts run).
13
+ import { Fr } from '@aztec/foundation/curves/bn254';
14
+ import { FunctionSelector, loadContractArtifact } from '@aztec/stdlib/abi';
15
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
16
+ import {
17
+ computeContractAddressFromInstance,
18
+ computeInitializationHash,
19
+ getContractClassFromArtifact,
20
+ } from '@aztec/stdlib/contract';
21
+ import { PublicKeys } from '@aztec/stdlib/keys';
22
+ import type { NoirCompiledContract } from '@aztec/stdlib/noir';
23
+
24
+ import { promises as fs } from 'fs';
25
+ import path from 'path';
26
+
27
+ /** Root of the noir-contracts package relative to `yarn-project/standard-contracts`. */
28
+ export const NOIR_CONTRACTS_ROOT = '../../noir-projects/noir-contracts';
29
+ /** Directory holding the freshly-compiled Noir artifacts the generator reads from. */
30
+ export const NOIR_ARTIFACTS_SRC_PATH = path.join(NOIR_CONTRACTS_ROOT, './target');
31
+ /** Output directory inside this package where the trimmed artifacts get copied. */
32
+ export const STANDARD_ARTIFACTS_DEST_DIR = './artifacts';
33
+ /** Path of the generated TS data file (addresses, class IDs, etc.). */
34
+ export const STANDARD_CONTRACT_DATA_OUTPUT_PATH = './src/standard_contract_data.ts';
35
+ // Both consumers (aztec-nr's `aztec` crate and noir-contracts' `aztec_sublib`) need an identical
36
+ // twin of the generated addresses module. `aztec_sublib` cannot depend on `aztec`, so we stamp the
37
+ // same file into both locations rather than introducing a shared crate.
38
+ export const NOIR_STANDARD_ADDRESSES_PATHS = [
39
+ '../../noir-projects/aztec-nr/aztec/src/standard_addresses.nr',
40
+ '../../noir-projects/noir-contracts/contracts/protocol/aztec_sublib/src/standard_addresses.nr',
41
+ ];
42
+
43
+ /** The deployment salt baked into every standard contract instance. */
44
+ export const STANDARD_CONTRACT_SALT = new Fr(1);
45
+ /** Every standard contract is deployed by the zero address (universal deploy). */
46
+ export const STANDARD_CONTRACT_DEPLOYER = AztecAddress.zero();
47
+
48
+ /**
49
+ * Single source of truth for which contracts are "standard" (non-protocol, but with deterministic
50
+ * addresses baked into circuits via `standard_addresses.nr`).
51
+ *
52
+ * - `name`: TS-side name used as the key in the generated `StandardContractAddress` map.
53
+ * - `src`: artifact filename (without `.json`) inside `noir-contracts/target/`.
54
+ * - `nrConst`: Noir-side constant to emit in `standard_addresses.nr`, or `null` to skip the Noir
55
+ * stamp (used for account-side entrypoints with no Noir consumer).
56
+ *
57
+ * Adding a new standard contract is a one-row change here. The drift-detection check in the
58
+ * generator and the backup jest test both iterate this list, so coverage is automatic.
59
+ */
60
+ export const standardContracts: { name: string; src: string; nrConst: string | null }[] = [
61
+ { name: 'AuthRegistry', src: 'auth_registry_contract-AuthRegistry', nrConst: 'STANDARD_AUTH_REGISTRY_ADDRESS' },
62
+ {
63
+ name: 'MultiCallEntrypoint',
64
+ src: 'multi_call_entrypoint_contract-MultiCallEntrypoint',
65
+ nrConst: 'STANDARD_MULTI_CALL_ENTRYPOINT_ADDRESS',
66
+ },
67
+ { name: 'PublicChecks', src: 'public_checks_contract-PublicChecks', nrConst: 'STANDARD_PUBLIC_CHECKS_ADDRESS' },
68
+ ];
69
+
70
+ /** Everything derived from a compiled standard-contract artifact that the generator emits. */
71
+ export type ContractData = {
72
+ address: AztecAddress;
73
+ classId: Fr;
74
+ artifactHash: Fr;
75
+ privateFunctionsRoot: Fr;
76
+ publicBytecodeCommitment: Fr;
77
+ initializationHash: Fr;
78
+ privateFunctions: { selector: FunctionSelector; vkHash: Fr }[];
79
+ };
80
+
81
+ /**
82
+ * Loads a compiled Noir contract artifact from `noir-contracts/target/` by its source name.
83
+ * Throws with `ENOENT` if the artifact isn't built yet — callers may catch this to provide a
84
+ * friendlier "run the build first" message.
85
+ */
86
+ export async function loadArtifact(srcName: string): Promise<NoirCompiledContract> {
87
+ const src = path.join(NOIR_ARTIFACTS_SRC_PATH, `${srcName}.json`);
88
+ return JSON.parse(await fs.readFile(src, 'utf8')) as NoirCompiledContract;
89
+ }
90
+
91
+ /**
92
+ * Derives the address, class ID, and other deployment data for a standard contract from its
93
+ * compiled artifact. Used by both the generator (to write `standard_contract_data.ts`) and the
94
+ * drift test (to verify the committed data matches).
95
+ *
96
+ * Standard contracts come from a trusted source (the build pipeline), so no class verifications
97
+ * are performed.
98
+ */
99
+ export async function computeContractData(artifact: NoirCompiledContract): Promise<ContractData> {
100
+ const loaded = loadContractArtifact(artifact);
101
+ const contractClass = await getContractClassFromArtifact(loaded);
102
+ const constructorArtifact = loaded.functions.find(f => f.name === 'constructor');
103
+ const initializationHash = await computeInitializationHash(constructorArtifact, []);
104
+ const instance = {
105
+ version: 2 as const,
106
+ currentContractClassId: contractClass.id,
107
+ originalContractClassId: contractClass.id,
108
+ initializationHash,
109
+ immutablesHash: Fr.ZERO,
110
+ publicKeys: PublicKeys.default(),
111
+ salt: STANDARD_CONTRACT_SALT,
112
+ deployer: STANDARD_CONTRACT_DEPLOYER,
113
+ };
114
+ const address = await computeContractAddressFromInstance(instance);
115
+ return {
116
+ address,
117
+ classId: contractClass.id,
118
+ artifactHash: contractClass.artifactHash,
119
+ privateFunctionsRoot: contractClass.privateFunctionsRoot,
120
+ publicBytecodeCommitment: contractClass.publicBytecodeCommitment,
121
+ initializationHash,
122
+ privateFunctions: contractClass.privateFunctions,
123
+ };
124
+ }
package/src/drift.ts ADDED
@@ -0,0 +1,201 @@
1
+ // Build-time-only rendering and drift-detection plumbing shared by the generator
2
+ // (`scripts/generate_data.ts`) and the backup jest test (`standard_contract_data.test.ts`). Lives
3
+ // outside `contract_data.ts` so that `prettier` (a devDependency used only here) does not become a
4
+ // transitive runtime import of the published package.
5
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
6
+
7
+ import { promises as fs } from 'fs';
8
+ import path from 'path';
9
+ import * as prettier from 'prettier';
10
+
11
+ import {
12
+ type ContractData,
13
+ NOIR_STANDARD_ADDRESSES_PATHS,
14
+ STANDARD_CONTRACT_DATA_OUTPUT_PATH,
15
+ STANDARD_CONTRACT_SALT,
16
+ standardContracts,
17
+ } from './contract_data.js';
18
+
19
+ function generateNames(names: string[]) {
20
+ return `
21
+ export const standardContractNames = [
22
+ ${names.map(name => `'${name}'`).join(',\n')}
23
+ ] as const;
24
+
25
+ export type StandardContractName = typeof standardContractNames[number];
26
+ `;
27
+ }
28
+
29
+ function generateSalts(names: string[]) {
30
+ return `
31
+ export const StandardContractSalt: Record<StandardContractName, Fr> = {
32
+ ${names.map(name => `${name}: new Fr(${STANDARD_CONTRACT_SALT.toNumber()})`).join(',\n')}
33
+ };
34
+ `;
35
+ }
36
+
37
+ function generateAddresses(names: string[], contractData: ContractData[]) {
38
+ return `
39
+ export const StandardContractAddress: Record<StandardContractName, AztecAddress> = {
40
+ ${contractData.map((d, i) => `${names[i]}: AztecAddress.fromString('${d.address.toString()}')`).join(',\n')}
41
+ };
42
+ `;
43
+ }
44
+
45
+ function generateClassIdPreimages(names: string[], contractData: ContractData[]) {
46
+ return `
47
+ export const StandardContractClassId: Record<StandardContractName, Fr> = {
48
+ ${contractData.map((d, i) => `${names[i]}: Fr.fromString('${d.classId.toString()}')`).join(',\n')}
49
+ };
50
+
51
+ export const StandardContractClassIdPreimage: Record<StandardContractName, { artifactHash: Fr; privateFunctionsRoot: Fr; publicBytecodeCommitment: Fr }> = {
52
+ ${contractData
53
+ .map(
54
+ (d, i) => `${names[i]}: {
55
+ artifactHash: Fr.fromString('${d.artifactHash.toString()}'),
56
+ privateFunctionsRoot: Fr.fromString('${d.privateFunctionsRoot.toString()}'),
57
+ publicBytecodeCommitment: Fr.fromString('${d.publicBytecodeCommitment.toString()}'),
58
+ }`,
59
+ )
60
+ .join(',\n')}
61
+ };
62
+
63
+ export const StandardContractInitializationHash: Record<StandardContractName, Fr> = {
64
+ ${contractData.map((d, i) => `${names[i]}: Fr.fromString('${d.initializationHash.toString()}')`).join(',\n')}
65
+ };
66
+
67
+ export const StandardContractPrivateFunctions: Record<StandardContractName, { selector: FunctionSelector; vkHash: Fr }[]> = {
68
+ ${contractData
69
+ .map(
70
+ (d, i) =>
71
+ `${names[i]}: [${d.privateFunctions
72
+ .map(
73
+ fn =>
74
+ `{ selector: FunctionSelector.fromField(Fr.fromString('${fn.selector.toField().toString()}')), vkHash: Fr.fromString('${fn.vkHash.toString()}') }`,
75
+ )
76
+ .join(', ')}]`,
77
+ )
78
+ .join(',\n')}
79
+ };
80
+ `;
81
+ }
82
+
83
+ /**
84
+ * Renders the unformatted TypeScript content for `standard_contract_data.ts`. Run {@link formatTs}
85
+ * on the result before comparing against the committed file — the committed file has been
86
+ * prettier-formatted, so unformatted bytes will not byte-match.
87
+ */
88
+ export function renderOutputFile(names: string[], contractData: ContractData[]): string {
89
+ return `
90
+ // GENERATED FILE - DO NOT EDIT. RUN \`yarn generate\` or \`yarn generate:data\`
91
+ import { Fr } from '@aztec/foundation/curves/bn254';
92
+ import { FunctionSelector } from '@aztec/stdlib/abi';
93
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
94
+
95
+ ${generateNames(names)}
96
+
97
+ ${generateSalts(names)}
98
+
99
+ ${generateAddresses(names, contractData)}
100
+
101
+ ${generateClassIdPreimages(names, contractData)}
102
+ `;
103
+ }
104
+
105
+ /**
106
+ * Renders the content for each `standard_addresses.nr` twin. Format-stable — `nargo fmt` will not
107
+ * rewrite the output, so the bytes returned here are byte-equal to what should be on disk.
108
+ */
109
+ export function renderNoirAddresses(rows: { nrConst: string; address: AztecAddress }[]): string {
110
+ // Pre-wrapped to survive `nargo fmt`'s line-width pass without diff churn.
111
+ const globals = rows
112
+ .map(
113
+ r => `pub global ${r.nrConst}: AztecAddress = AztecAddress::from_field(
114
+ ${r.address.toField().toString()},
115
+ );`,
116
+ )
117
+ .join('\n\n');
118
+ return `// GENERATED FILE - DO NOT EDIT. RUN \`yarn workspace @aztec/standard-contracts run generate\`.
119
+ use protocol_types::{address::AztecAddress, traits::FromField};
120
+
121
+ ${globals}
122
+ `;
123
+ }
124
+
125
+ /**
126
+ * Formats TypeScript content with the repo's prettier config so the bytes emitted by the generator
127
+ * (and the expected bytes used by the drift test) match what the eventual `format` step in
128
+ * bootstrap.sh produces. Without this normalization the drift check would false-positive on every
129
+ * run since the raw template-string output differs from the prettier-formatted committed content.
130
+ *
131
+ * The typescript/estree plugins are loaded eagerly and passed explicitly: prettier 3's default
132
+ * lazy-loading via ESM dynamic import is unreliable under jest's `experimental-vm-modules` (the
133
+ * VM context can tear down before the dynamic import resolves), which causes intermittent
134
+ * `Cannot read properties of undefined (reading 'estree')` failures.
135
+ */
136
+ export async function formatTs(filePath: string, content: string): Promise<string> {
137
+ const [typescriptPlugin, estreePlugin] = await Promise.all([
138
+ import('prettier/plugins/typescript.js'),
139
+ import('prettier/plugins/estree.js'),
140
+ ]);
141
+ const config = (await prettier.resolveConfig(path.resolve(filePath))) ?? {};
142
+ return prettier.format(content, {
143
+ ...config,
144
+ filepath: filePath,
145
+ parser: 'typescript',
146
+ plugins: [typescriptPlugin.default ?? typescriptPlugin, estreePlugin.default ?? estreePlugin],
147
+ });
148
+ }
149
+
150
+ /** A rendered target file: the destination path and the exact bytes that should be on disk. */
151
+ export type RenderedTarget = { path: string; content: string };
152
+
153
+ /**
154
+ * Renders every generator output target (the TS data file plus each `standard_addresses.nr` twin)
155
+ * from a list of derived `ContractData`. The TS output is prettier-formatted so the result is
156
+ * byte-comparable against the committed file. Both the generator and the drift test build their
157
+ * comparison against this single function.
158
+ */
159
+ export async function renderAllTargets(names: string[], contractData: ContractData[]): Promise<RenderedTarget[]> {
160
+ const tsContent = await formatTs(STANDARD_CONTRACT_DATA_OUTPUT_PATH, renderOutputFile(names, contractData));
161
+ const noirRows = standardContracts
162
+ .map((c, i) => ({ nrConst: c.nrConst, address: contractData[i].address }))
163
+ .filter((row): row is { nrConst: string; address: AztecAddress } => row.nrConst !== null);
164
+ const noirContent = renderNoirAddresses(noirRows);
165
+ return [
166
+ { path: STANDARD_CONTRACT_DATA_OUTPUT_PATH, content: tsContent },
167
+ ...NOIR_STANDARD_ADDRESSES_PATHS.map(p => ({ path: p, content: noirContent })),
168
+ ];
169
+ }
170
+
171
+ /**
172
+ * Reads a file's current content, or returns `null` if it doesn't exist. Used by the generator to
173
+ * compare against freshly rendered output before deciding to overwrite, and by the drift test to
174
+ * compare the committed file's bytes against the expected bytes.
175
+ */
176
+ export async function readIfExists(filePath: string): Promise<string | null> {
177
+ try {
178
+ return await fs.readFile(filePath, 'utf8');
179
+ } catch (err: any) {
180
+ if (err.code === 'ENOENT') {
181
+ return null;
182
+ }
183
+ throw err;
184
+ }
185
+ }
186
+
187
+ /**
188
+ * Compares `content` against the bytes currently at `filePath`. If they differ (including the file
189
+ * not existing), writes the new content and returns `true`. If they match, leaves the file
190
+ * untouched and returns `false`. Skipping the write when the content is identical avoids mtime
191
+ * churn that would otherwise re-trigger downstream build steps on every generator run.
192
+ */
193
+ export async function writeIfChanged(filePath: string, content: string): Promise<boolean> {
194
+ const existing = await readIfExists(filePath);
195
+ if (existing === content) {
196
+ return false;
197
+ }
198
+ await fs.mkdir(path.dirname(filePath), { recursive: true });
199
+ await fs.writeFile(filePath, content);
200
+ return true;
201
+ }
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './auth-registry/index.js';
2
+ export * from './multi-call-entrypoint/index.js';
3
+ export * from './public-checks/index.js';
@@ -0,0 +1,51 @@
1
+ import { Fr } from '@aztec/foundation/curves/bn254';
2
+ import type { ContractArtifact } from '@aztec/stdlib/abi';
3
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
4
+ import { PublicKeys } from '@aztec/stdlib/keys';
5
+
6
+ import type { StandardContract } from './standard_contract.js';
7
+ import {
8
+ StandardContractAddress,
9
+ StandardContractClassId,
10
+ StandardContractClassIdPreimage,
11
+ StandardContractInitializationHash,
12
+ type StandardContractName,
13
+ StandardContractPrivateFunctions,
14
+ StandardContractSalt,
15
+ } from './standard_contract_data.js';
16
+
17
+ /**
18
+ * Reconstructs a StandardContract from precomputed data without performing any hash computations.
19
+ * Internal to the standard-contracts package — not part of the public API.
20
+ */
21
+ export function makeStandardContract(name: StandardContractName, artifact: ContractArtifact): StandardContract {
22
+ const address = StandardContractAddress[name];
23
+ const salt = StandardContractSalt[name];
24
+ const classId = StandardContractClassId[name];
25
+ const { artifactHash, privateFunctionsRoot, publicBytecodeCommitment } = StandardContractClassIdPreimage[name];
26
+ const initializationHash = StandardContractInitializationHash[name];
27
+
28
+ const contractClass = {
29
+ id: classId,
30
+ version: 1 as const,
31
+ artifactHash,
32
+ privateFunctionsRoot,
33
+ publicBytecodeCommitment,
34
+ packedBytecode: artifact.functions.find(f => f.name === 'public_dispatch')?.bytecode ?? Buffer.alloc(0),
35
+ privateFunctions: StandardContractPrivateFunctions[name],
36
+ };
37
+
38
+ const instance = {
39
+ version: 2 as const,
40
+ currentContractClassId: classId,
41
+ originalContractClassId: classId,
42
+ initializationHash,
43
+ immutablesHash: Fr.ZERO,
44
+ publicKeys: PublicKeys.default(),
45
+ salt,
46
+ deployer: AztecAddress.ZERO,
47
+ address,
48
+ };
49
+
50
+ return { instance, contractClass, artifact, address };
51
+ }
@@ -0,0 +1,8 @@
1
+ // Lightweight metadata leaf export for browser bundles: importing from
2
+ // `@aztec/standard-contracts/multi-call-entrypoint/constants` avoids dragging in the
3
+ // `MultiCallEntrypoint.json` static import.
4
+ import { StandardContractAddress, StandardContractClassId, StandardContractSalt } from '../standard_contract_data.js';
5
+
6
+ export const STANDARD_MULTI_CALL_ENTRYPOINT_ADDRESS = StandardContractAddress.MultiCallEntrypoint;
7
+ export const STANDARD_MULTI_CALL_ENTRYPOINT_CLASS_ID = StandardContractClassId.MultiCallEntrypoint;
8
+ export const STANDARD_MULTI_CALL_ENTRYPOINT_SALT = StandardContractSalt.MultiCallEntrypoint;
@@ -0,0 +1,24 @@
1
+ import { loadContractArtifact } from '@aztec/stdlib/abi';
2
+ import type { NoirCompiledContract } from '@aztec/stdlib/noir';
3
+
4
+ import MultiCallEntrypointJson from '../../artifacts/MultiCallEntrypoint.json' with { type: 'json' };
5
+ import { makeStandardContract } from '../make_standard_contract.js';
6
+ import type { StandardContract } from '../standard_contract.js';
7
+
8
+ export {
9
+ STANDARD_MULTI_CALL_ENTRYPOINT_ADDRESS,
10
+ STANDARD_MULTI_CALL_ENTRYPOINT_CLASS_ID,
11
+ STANDARD_MULTI_CALL_ENTRYPOINT_SALT,
12
+ } from './constants.js';
13
+
14
+ export const MultiCallEntrypointArtifact = loadContractArtifact(MultiCallEntrypointJson as NoirCompiledContract);
15
+
16
+ let standardContract: StandardContract;
17
+
18
+ /** Returns the standard deployment of the multi-call entrypoint. */
19
+ export function getStandardMultiCallEntrypoint(): Promise<StandardContract> {
20
+ if (!standardContract) {
21
+ standardContract = makeStandardContract('MultiCallEntrypoint', MultiCallEntrypointArtifact);
22
+ }
23
+ return Promise.resolve(standardContract);
24
+ }
@@ -0,0 +1,35 @@
1
+ import { type ContractArtifact, loadContractArtifact } from '@aztec/stdlib/abi';
2
+
3
+ import { makeStandardContract } from '../make_standard_contract.js';
4
+ import type { StandardContract } from '../standard_contract.js';
5
+
6
+ export {
7
+ STANDARD_MULTI_CALL_ENTRYPOINT_ADDRESS,
8
+ STANDARD_MULTI_CALL_ENTRYPOINT_CLASS_ID,
9
+ STANDARD_MULTI_CALL_ENTRYPOINT_SALT,
10
+ } from './constants.js';
11
+
12
+ let standardContract: StandardContract;
13
+ let standardContractArtifact: ContractArtifact;
14
+
15
+ export async function getMultiCallEntrypointArtifact(): Promise<ContractArtifact> {
16
+ if (!standardContractArtifact) {
17
+ // Cannot assert this import as it's incompatible with bundlers like vite
18
+ // https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
19
+ // Even if now supported by all major browsers, the MIME type is replaced with
20
+ // "text/javascript"
21
+ // In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
22
+ const { default: multiCallEntrypointJson } = await import('../../artifacts/MultiCallEntrypoint.json');
23
+ standardContractArtifact = loadContractArtifact(multiCallEntrypointJson);
24
+ }
25
+ return standardContractArtifact;
26
+ }
27
+
28
+ /** Returns the standard deployment of the multi-call entrypoint. */
29
+ export async function getStandardMultiCallEntrypoint(): Promise<StandardContract> {
30
+ if (!standardContract) {
31
+ const artifact = await getMultiCallEntrypointArtifact();
32
+ standardContract = makeStandardContract('MultiCallEntrypoint', artifact);
33
+ }
34
+ return standardContract;
35
+ }
@@ -0,0 +1,8 @@
1
+ // Lightweight metadata leaf export for browser bundles: importing from
2
+ // `@aztec/standard-contracts/public-checks/constants` avoids dragging in the
3
+ // `PublicChecks.json` static import.
4
+ import { StandardContractAddress, StandardContractClassId, StandardContractSalt } from '../standard_contract_data.js';
5
+
6
+ export const STANDARD_PUBLIC_CHECKS_ADDRESS = StandardContractAddress.PublicChecks;
7
+ export const STANDARD_PUBLIC_CHECKS_CLASS_ID = StandardContractClassId.PublicChecks;
8
+ export const STANDARD_PUBLIC_CHECKS_SALT = StandardContractSalt.PublicChecks;
@@ -0,0 +1,24 @@
1
+ import { loadContractArtifact } from '@aztec/stdlib/abi';
2
+ import type { NoirCompiledContract } from '@aztec/stdlib/noir';
3
+
4
+ import PublicChecksJson from '../../artifacts/PublicChecks.json' with { type: 'json' };
5
+ import { makeStandardContract } from '../make_standard_contract.js';
6
+ import type { StandardContract } from '../standard_contract.js';
7
+
8
+ export {
9
+ STANDARD_PUBLIC_CHECKS_ADDRESS,
10
+ STANDARD_PUBLIC_CHECKS_CLASS_ID,
11
+ STANDARD_PUBLIC_CHECKS_SALT,
12
+ } from './constants.js';
13
+
14
+ export const PublicChecksArtifact = loadContractArtifact(PublicChecksJson as NoirCompiledContract);
15
+
16
+ let standardContract: StandardContract;
17
+
18
+ /** Returns the standard deployment of public_checks. */
19
+ export function getStandardPublicChecks(): Promise<StandardContract> {
20
+ if (!standardContract) {
21
+ standardContract = makeStandardContract('PublicChecks', PublicChecksArtifact);
22
+ }
23
+ return Promise.resolve(standardContract);
24
+ }
@@ -0,0 +1,35 @@
1
+ import { type ContractArtifact, loadContractArtifact } from '@aztec/stdlib/abi';
2
+
3
+ import { makeStandardContract } from '../make_standard_contract.js';
4
+ import type { StandardContract } from '../standard_contract.js';
5
+
6
+ export {
7
+ STANDARD_PUBLIC_CHECKS_ADDRESS,
8
+ STANDARD_PUBLIC_CHECKS_CLASS_ID,
9
+ STANDARD_PUBLIC_CHECKS_SALT,
10
+ } from './constants.js';
11
+
12
+ let standardContract: StandardContract;
13
+ let standardContractArtifact: ContractArtifact;
14
+
15
+ export async function getPublicChecksArtifact(): Promise<ContractArtifact> {
16
+ if (!standardContractArtifact) {
17
+ // Cannot assert this import as it's incompatible with bundlers like vite
18
+ // https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
19
+ // Even if now supported by all major browsers, the MIME type is replaced with
20
+ // "text/javascript"
21
+ // In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
22
+ const { default: publicChecksJson } = await import('../../artifacts/PublicChecks.json');
23
+ standardContractArtifact = loadContractArtifact(publicChecksJson);
24
+ }
25
+ return standardContractArtifact;
26
+ }
27
+
28
+ /** Returns the standard deployment of public_checks. */
29
+ export async function getStandardPublicChecks(): Promise<StandardContract> {
30
+ if (!standardContract) {
31
+ const artifact = await getPublicChecksArtifact();
32
+ standardContract = makeStandardContract('PublicChecks', artifact);
33
+ }
34
+ return standardContract;
35
+ }
@@ -0,0 +1,15 @@
1
+ import type { ContractArtifact } from '@aztec/stdlib/abi';
2
+ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
3
+ import type { ContractClassIdPreimage, ContractClassWithId, ContractInstanceWithAddress } from '@aztec/stdlib/contract';
4
+
5
+ /** A non-protocol contract deployed at a canonical artifact-derived address. */
6
+ export interface StandardContract {
7
+ /** Canonical deployed instance. */
8
+ instance: ContractInstanceWithAddress;
9
+ /** Contract class of this contract. */
10
+ contractClass: ContractClassWithId & ContractClassIdPreimage;
11
+ /** Complete contract artifact. */
12
+ artifact: ContractArtifact;
13
+ /** Deployment address for the canonical instance. */
14
+ address: AztecAddress;
15
+ }
@@ -0,0 +1,76 @@
1
+ // GENERATED FILE - DO NOT EDIT. RUN `yarn generate` or `yarn generate:data`
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
+ import { FunctionSelector } from '@aztec/stdlib/abi';
4
+ import { AztecAddress } from '@aztec/stdlib/aztec-address';
5
+
6
+ export const standardContractNames = ['AuthRegistry', 'MultiCallEntrypoint', 'PublicChecks'] as const;
7
+
8
+ export type StandardContractName = (typeof standardContractNames)[number];
9
+
10
+ export const StandardContractSalt: Record<StandardContractName, Fr> = {
11
+ AuthRegistry: new Fr(1),
12
+ MultiCallEntrypoint: new Fr(1),
13
+ PublicChecks: new Fr(1),
14
+ };
15
+
16
+ export const StandardContractAddress: Record<StandardContractName, AztecAddress> = {
17
+ AuthRegistry: AztecAddress.fromString('0x01de9d215d1845808cf388d3a88f9066af1e73ec280e979c3b1aec8ba6b149ea'),
18
+ MultiCallEntrypoint: AztecAddress.fromString('0x09a72c4cb473b087f59f28f913aa103c214b4f9bbf10d4157e06745169359210'),
19
+ PublicChecks: AztecAddress.fromString('0x05d900a6ed1b4ad3ff52cbe5f98d9b291b0f35c6dd5c41b1642659344d234bfe'),
20
+ };
21
+
22
+ export const StandardContractClassId: Record<StandardContractName, Fr> = {
23
+ AuthRegistry: Fr.fromString('0x2cfbdd0ce7cc31b5cc5f4eb8f680e0e245882b2208bd67828e41a8bd24a19292'),
24
+ MultiCallEntrypoint: Fr.fromString('0x188160c82cb3a9a24c6f156f270e962afa124cdd2dabce78aaa0bf04fdd799f6'),
25
+ PublicChecks: Fr.fromString('0x022bbd3c085d6a09ec500110852441419c7b1e6dc21a8d459233b72a84d03a1f'),
26
+ };
27
+
28
+ export const StandardContractClassIdPreimage: Record<
29
+ StandardContractName,
30
+ { artifactHash: Fr; privateFunctionsRoot: Fr; publicBytecodeCommitment: Fr }
31
+ > = {
32
+ AuthRegistry: {
33
+ artifactHash: Fr.fromString('0x0dd24a86cce5ff4ef33ca14f16359c5a154ce3f1ed91a9570dd5343569f5386f'),
34
+ privateFunctionsRoot: Fr.fromString('0x17b584350f4c3ccafd8f688729afb9feab8976114fb40012e9dee65022c072a4'),
35
+ publicBytecodeCommitment: Fr.fromString('0x2545f39893766508ce37bb5cea5e4dcab04c6f7f79f3089b1c076876e9d268b2'),
36
+ },
37
+ MultiCallEntrypoint: {
38
+ artifactHash: Fr.fromString('0x1f8c5717b0e478e63f462f9792969865684f8403b4608980b1a83324c03dd498'),
39
+ privateFunctionsRoot: Fr.fromString('0x0e68dfbb256e80b08b3aef47aca1f2669e97a9c6259787893c1223ac083ad5d5'),
40
+ publicBytecodeCommitment: Fr.fromString('0x0ce4c618c3ed7f3a20410e618c06bb701e150af7fe28a3e92f68e7733809f33e'),
41
+ },
42
+ PublicChecks: {
43
+ artifactHash: Fr.fromString('0x030776b58475bf6a0545eaa4f4002f5fe6701bd0d306b68065f4b40ef4fdbe60'),
44
+ privateFunctionsRoot: Fr.fromString('0x202860adb1b8975971eeaf571aaaa88a27f4035290d58532ae7d60b0dfaad54c'),
45
+ publicBytecodeCommitment: Fr.fromString('0x013c4f854a5c87c9daf86c5f9bc07a42c2a061f1d924a5b3564ec7edc8e18cb7'),
46
+ },
47
+ };
48
+
49
+ export const StandardContractInitializationHash: Record<StandardContractName, Fr> = {
50
+ AuthRegistry: Fr.fromString('0x0000000000000000000000000000000000000000000000000000000000000000'),
51
+ MultiCallEntrypoint: Fr.fromString('0x0000000000000000000000000000000000000000000000000000000000000000'),
52
+ PublicChecks: Fr.fromString('0x0000000000000000000000000000000000000000000000000000000000000000'),
53
+ };
54
+
55
+ export const StandardContractPrivateFunctions: Record<
56
+ StandardContractName,
57
+ { selector: FunctionSelector; vkHash: Fr }[]
58
+ > = {
59
+ AuthRegistry: [
60
+ {
61
+ selector: FunctionSelector.fromField(
62
+ Fr.fromString('0x0000000000000000000000000000000000000000000000000000000079a3d418'),
63
+ ),
64
+ vkHash: Fr.fromString('0x06a5c1b3a636c954a90be43cb56a4bdd9dc8aec764151a012e0018753694ff54'),
65
+ },
66
+ ],
67
+ MultiCallEntrypoint: [
68
+ {
69
+ selector: FunctionSelector.fromField(
70
+ Fr.fromString('0x00000000000000000000000000000000000000000000000000000000f04908a9'),
71
+ ),
72
+ vkHash: Fr.fromString('0x0b19b2f937f2581922c2ead5411ad9ff4ed9710efe9849bde494d9a0f94812ec'),
73
+ },
74
+ ],
75
+ PublicChecks: [],
76
+ };