@aztec/standard-contracts 5.0.0-nightly.20260530
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.
- package/artifacts/AuthRegistry.d.json.ts +5 -0
- package/artifacts/AuthRegistry.json +7838 -0
- package/artifacts/PublicChecks.d.json.ts +5 -0
- package/artifacts/PublicChecks.json +4290 -0
- package/dest/auth-registry/constants.d.ts +4 -0
- package/dest/auth-registry/constants.d.ts.map +1 -0
- package/dest/auth-registry/constants.js +7 -0
- package/dest/auth-registry/index.d.ts +6 -0
- package/dest/auth-registry/index.d.ts.map +1 -0
- package/dest/auth-registry/index.js +14 -0
- package/dest/auth-registry/lazy.d.ts +7 -0
- package/dest/auth-registry/lazy.d.ts.map +1 -0
- package/dest/auth-registry/lazy.js +24 -0
- package/dest/contract_data.d.ts +63 -0
- package/dest/contract_data.d.ts.map +1 -0
- package/dest/contract_data.js +96 -0
- package/dest/drift.d.ts +54 -0
- package/dest/drift.d.ts.map +1 -0
- package/dest/drift.js +167 -0
- package/dest/index.d.ts +3 -0
- package/dest/index.d.ts.map +1 -0
- package/dest/index.js +2 -0
- package/dest/make_standard_contract.d.ts +9 -0
- package/dest/make_standard_contract.d.ts.map +1 -0
- package/dest/make_standard_contract.js +40 -0
- package/dest/public-checks/constants.d.ts +4 -0
- package/dest/public-checks/constants.d.ts.map +1 -0
- package/dest/public-checks/constants.js +7 -0
- package/dest/public-checks/index.d.ts +6 -0
- package/dest/public-checks/index.d.ts.map +1 -0
- package/dest/public-checks/index.js +14 -0
- package/dest/public-checks/lazy.d.ts +7 -0
- package/dest/public-checks/lazy.d.ts.map +1 -0
- package/dest/public-checks/lazy.js +24 -0
- package/dest/scripts/cleanup_artifacts.js +16 -0
- package/dest/scripts/generate_data.js +79 -0
- package/dest/standard_contract.d.ts +15 -0
- package/dest/standard_contract.d.ts.map +1 -0
- package/dest/standard_contract.js +1 -0
- package/dest/standard_contract_data.d.ts +19 -0
- package/dest/standard_contract_data.d.ts.map +1 -0
- package/dest/standard_contract_data.js +45 -0
- package/package.json +101 -0
- package/src/auth-registry/constants.ts +8 -0
- package/src/auth-registry/index.ts +24 -0
- package/src/auth-registry/lazy.ts +35 -0
- package/src/contract_data.ts +119 -0
- package/src/drift.ts +201 -0
- package/src/index.ts +2 -0
- package/src/make_standard_contract.ts +51 -0
- package/src/public-checks/constants.ts +8 -0
- package/src/public-checks/index.ts +24 -0
- package/src/public-checks/lazy.ts +35 -0
- package/src/standard_contract.ts +15 -0
- package/src/standard_contract_data.ts +59 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
2
|
+
import { makeStandardContract } from '../make_standard_contract.js';
|
|
3
|
+
export { STANDARD_PUBLIC_CHECKS_ADDRESS, STANDARD_PUBLIC_CHECKS_CLASS_ID, STANDARD_PUBLIC_CHECKS_SALT } from './constants.js';
|
|
4
|
+
let standardContract;
|
|
5
|
+
let standardContractArtifact;
|
|
6
|
+
export async function getPublicChecksArtifact() {
|
|
7
|
+
if (!standardContractArtifact) {
|
|
8
|
+
// Cannot assert this import as it's incompatible with bundlers like vite
|
|
9
|
+
// https://github.com/vitejs/vite/issues/19095#issuecomment-2566074352
|
|
10
|
+
// Even if now supported by all major browsers, the MIME type is replaced with
|
|
11
|
+
// "text/javascript"
|
|
12
|
+
// In the meantime, this lazy import is INCOMPATIBLE WITH NODEJS
|
|
13
|
+
const { default: publicChecksJson } = await import('../../artifacts/PublicChecks.json');
|
|
14
|
+
standardContractArtifact = loadContractArtifact(publicChecksJson);
|
|
15
|
+
}
|
|
16
|
+
return standardContractArtifact;
|
|
17
|
+
}
|
|
18
|
+
/** Returns the standard deployment of public_checks. */ export async function getStandardPublicChecks() {
|
|
19
|
+
if (!standardContract) {
|
|
20
|
+
const artifact = await getPublicChecksArtifact();
|
|
21
|
+
standardContract = makeStandardContract('PublicChecks', artifact);
|
|
22
|
+
}
|
|
23
|
+
return standardContract;
|
|
24
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { fileURLToPath } from '@aztec/foundation/url';
|
|
2
|
+
import { readFile, readdir, writeFile } from 'fs/promises';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
async function cleanupArtifacts(target) {
|
|
5
|
+
const files = await readdir(target);
|
|
6
|
+
for (const file of files){
|
|
7
|
+
if (!file.endsWith('.json')) {
|
|
8
|
+
continue;
|
|
9
|
+
}
|
|
10
|
+
const fileData = JSON.parse((await readFile(join(target, file), 'utf8')).toString());
|
|
11
|
+
/* eslint-disable camelcase */ fileData.file_map = {};
|
|
12
|
+
fileData.debug_symbols = {};
|
|
13
|
+
/* eslint-enable camelcase */ await writeFile(join(target, file), JSON.stringify(fileData));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
await cleanupArtifacts(fileURLToPath(new URL('../../artifacts', import.meta.url).href));
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// Reads compiled Noir artifacts for each standard contract and derives their addresses, class IDs,
|
|
2
|
+
// bytecode commitments, and initialization hashes — emitting everything as precomputed constants
|
|
3
|
+
// into `standard_contract_data.ts` and as Noir address stamps into the `standard_addresses.nr`
|
|
4
|
+
// modules of `aztec-nr/aztec` and `noir-contracts/.../aztec_sublib`. This avoids clients repeating
|
|
5
|
+
// the expensive hashing at runtime and keeps the Noir-side address aligned with the TS-side.
|
|
6
|
+
//
|
|
7
|
+
// Drift detection: every invocation renders the expected output in memory and compares against the
|
|
8
|
+
// existing on-disk content. Files that match are left untouched (no mtime churn). Files that
|
|
9
|
+
// differ are overwritten with the fresh content and the generator exits non-zero with a clear
|
|
10
|
+
// error — so the developer gets the regeneration for free, and a second `./bootstrap.sh` pass
|
|
11
|
+
// recompiles dependent Noir contracts against the now-correct values.
|
|
12
|
+
import { createConsoleLogger } from '@aztec/foundation/log';
|
|
13
|
+
import { promises as fs } from 'fs';
|
|
14
|
+
import path from 'path';
|
|
15
|
+
import { NOIR_ARTIFACTS_SRC_PATH, STANDARD_ARTIFACTS_DEST_DIR, computeContractData, loadArtifact, standardContracts } from '../contract_data.js';
|
|
16
|
+
import { renderAllTargets, writeIfChanged } from '../drift.js';
|
|
17
|
+
const log = createConsoleLogger('autogenerate');
|
|
18
|
+
async function clearDestDir() {
|
|
19
|
+
try {
|
|
20
|
+
await fs.access(STANDARD_ARTIFACTS_DEST_DIR);
|
|
21
|
+
// If the directory exists, remove it recursively.
|
|
22
|
+
await fs.rm(STANDARD_ARTIFACTS_DEST_DIR, {
|
|
23
|
+
recursive: true,
|
|
24
|
+
force: true,
|
|
25
|
+
maxRetries: 3
|
|
26
|
+
});
|
|
27
|
+
} catch (err) {
|
|
28
|
+
if (err.code === 'ENOENT') {
|
|
29
|
+
// If the directory does not exist, do nothing.
|
|
30
|
+
} else {
|
|
31
|
+
log(`Error removing dest directory: ${err}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
await fs.mkdir(STANDARD_ARTIFACTS_DEST_DIR, {
|
|
35
|
+
recursive: true
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
async function copyArtifact(srcName, destName) {
|
|
39
|
+
const artifact = await loadArtifact(srcName);
|
|
40
|
+
const src = path.join(NOIR_ARTIFACTS_SRC_PATH, `${srcName}.json`);
|
|
41
|
+
const dest = path.join(STANDARD_ARTIFACTS_DEST_DIR, `${destName}.json`);
|
|
42
|
+
await fs.copyFile(src, dest);
|
|
43
|
+
return artifact;
|
|
44
|
+
}
|
|
45
|
+
async function generateDeclarationFile(destName) {
|
|
46
|
+
const content = `
|
|
47
|
+
import type { NoirCompiledContract } from '@aztec/stdlib/noir';
|
|
48
|
+
const circuit: NoirCompiledContract;
|
|
49
|
+
export = circuit;
|
|
50
|
+
`;
|
|
51
|
+
await fs.writeFile(path.join(STANDARD_ARTIFACTS_DEST_DIR, `${destName}.d.json.ts`), content);
|
|
52
|
+
}
|
|
53
|
+
async function main() {
|
|
54
|
+
await clearDestDir();
|
|
55
|
+
const names = standardContracts.map((c)=>c.name);
|
|
56
|
+
const contractDataList = [];
|
|
57
|
+
for (const { name, src } of standardContracts){
|
|
58
|
+
const artifact = await copyArtifact(src, name);
|
|
59
|
+
await generateDeclarationFile(name);
|
|
60
|
+
contractDataList.push(await computeContractData(artifact));
|
|
61
|
+
}
|
|
62
|
+
const targets = await renderAllTargets(names, contractDataList);
|
|
63
|
+
const driftedFiles = [];
|
|
64
|
+
for (const { path: filePath, content } of targets){
|
|
65
|
+
if (await writeIfChanged(filePath, content)) {
|
|
66
|
+
driftedFiles.push(filePath);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (driftedFiles.length > 0) {
|
|
70
|
+
const list = driftedFiles.map((f)=>` - ${f}`).join('\n');
|
|
71
|
+
throw new Error(`Standard contract addresses have changed. The following generated files were out of date and have been rewritten in-place with the freshly-derived values:\n${list}\n\n` + `Any noir-contract that imports the stale addresses (via aztec-nr or aztec_sublib) now has stale bytecode and must be rebuilt.\n\n` + `To recover, the simplest option is to re-run \`./bootstrap.sh\` from the repo root: the second pass picks up the now-correct values.\n\n` + `For a faster targeted recovery without rebuilding everything, run from the repo root:\n` + ` 1. \`./bootstrap.sh build noir-contracts\` (rebuilds contracts against the now-stamped addresses; equivalent to \`make noir-contracts\`)\n` + ` 2. \`./bootstrap.sh build yarn-project\` (the generator re-runs, sees no drift, and the build proceeds)\n\n` + `Commit the rewritten files alongside whatever source change triggered the drift.`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
await main();
|
|
76
|
+
} catch (err) {
|
|
77
|
+
log(`Error generating standard contract data: ${err}`);
|
|
78
|
+
process.exit(1);
|
|
79
|
+
}
|
|
@@ -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
|
+
/** A non-protocol contract deployed at a canonical artifact-derived address. */
|
|
5
|
+
export interface StandardContract {
|
|
6
|
+
/** Canonical deployed instance. */
|
|
7
|
+
instance: ContractInstanceWithAddress;
|
|
8
|
+
/** Contract class of this contract. */
|
|
9
|
+
contractClass: ContractClassWithId & ContractClassIdPreimage;
|
|
10
|
+
/** Complete contract artifact. */
|
|
11
|
+
artifact: ContractArtifact;
|
|
12
|
+
/** Deployment address for the canonical instance. */
|
|
13
|
+
address: AztecAddress;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3RhbmRhcmRfY29udHJhY3QuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9zdGFuZGFyZF9jb250cmFjdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBQzFELE9BQU8sS0FBSyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBQ2hFLE9BQU8sS0FBSyxFQUFFLHVCQUF1QixFQUFFLG1CQUFtQixFQUFFLDJCQUEyQixFQUFFLE1BQU0sd0JBQXdCLENBQUM7QUFFeEgsZ0ZBQWdGO0FBQ2hGLE1BQU0sV0FBVyxnQkFBZ0I7SUFDL0IsbUNBQW1DO0lBQ25DLFFBQVEsRUFBRSwyQkFBMkIsQ0FBQztJQUN0Qyx1Q0FBdUM7SUFDdkMsYUFBYSxFQUFFLG1CQUFtQixHQUFHLHVCQUF1QixDQUFDO0lBQzdELGtDQUFrQztJQUNsQyxRQUFRLEVBQUUsZ0JBQWdCLENBQUM7SUFDM0IscURBQXFEO0lBQ3JELE9BQU8sRUFBRSxZQUFZLENBQUM7Q0FDdkIifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"standard_contract.d.ts","sourceRoot":"","sources":["../src/standard_contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAExH,gFAAgF;AAChF,MAAM,WAAW,gBAAgB;IAC/B,mCAAmC;IACnC,QAAQ,EAAE,2BAA2B,CAAC;IACtC,uCAAuC;IACvC,aAAa,EAAE,mBAAmB,GAAG,uBAAuB,CAAC;IAC7D,kCAAkC;IAClC,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,qDAAqD;IACrD,OAAO,EAAE,YAAY,CAAC;CACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/** A non-protocol contract deployed at a canonical artifact-derived address. */ export { };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
3
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
export declare const standardContractNames: readonly ["AuthRegistry", "PublicChecks"];
|
|
5
|
+
export type StandardContractName = (typeof standardContractNames)[number];
|
|
6
|
+
export declare const StandardContractSalt: Record<StandardContractName, Fr>;
|
|
7
|
+
export declare const StandardContractAddress: Record<StandardContractName, AztecAddress>;
|
|
8
|
+
export declare const StandardContractClassId: Record<StandardContractName, Fr>;
|
|
9
|
+
export declare const StandardContractClassIdPreimage: Record<StandardContractName, {
|
|
10
|
+
artifactHash: Fr;
|
|
11
|
+
privateFunctionsRoot: Fr;
|
|
12
|
+
publicBytecodeCommitment: Fr;
|
|
13
|
+
}>;
|
|
14
|
+
export declare const StandardContractInitializationHash: Record<StandardContractName, Fr>;
|
|
15
|
+
export declare const StandardContractPrivateFunctions: Record<StandardContractName, {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,oBAAoB,EACpB;IAAE,QAAQ,EAAE,gBAAgB,CAAC;IAAC,MAAM,EAAE,EAAE,CAAA;CAAE,EAAE,CAW7C,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
export const standardContractNames = [
|
|
6
|
+
'AuthRegistry',
|
|
7
|
+
'PublicChecks'
|
|
8
|
+
];
|
|
9
|
+
export const StandardContractSalt = {
|
|
10
|
+
AuthRegistry: new Fr(1),
|
|
11
|
+
PublicChecks: new Fr(1)
|
|
12
|
+
};
|
|
13
|
+
export const StandardContractAddress = {
|
|
14
|
+
AuthRegistry: AztecAddress.fromString('0x27ced680dd8c176230127b42131054bce7fcd00623650eb695b5588bac81430b'),
|
|
15
|
+
PublicChecks: AztecAddress.fromString('0x05d900a6ed1b4ad3ff52cbe5f98d9b291b0f35c6dd5c41b1642659344d234bfe')
|
|
16
|
+
};
|
|
17
|
+
export const StandardContractClassId = {
|
|
18
|
+
AuthRegistry: Fr.fromString('0x2a2197818ebc248f6933c0364e50de7b4dcee6a4e53cfadcebae98d77ec0ca4a'),
|
|
19
|
+
PublicChecks: Fr.fromString('0x022bbd3c085d6a09ec500110852441419c7b1e6dc21a8d459233b72a84d03a1f')
|
|
20
|
+
};
|
|
21
|
+
export const StandardContractClassIdPreimage = {
|
|
22
|
+
AuthRegistry: {
|
|
23
|
+
artifactHash: Fr.fromString('0x1bf78e923b58f3e083093a39ccfc37576b9089c439797365cc7fe3b73a000dbc'),
|
|
24
|
+
privateFunctionsRoot: Fr.fromString('0x17b584350f4c3ccafd8f688729afb9feab8976114fb40012e9dee65022c072a4'),
|
|
25
|
+
publicBytecodeCommitment: Fr.fromString('0x2545f39893766508ce37bb5cea5e4dcab04c6f7f79f3089b1c076876e9d268b2')
|
|
26
|
+
},
|
|
27
|
+
PublicChecks: {
|
|
28
|
+
artifactHash: Fr.fromString('0x030776b58475bf6a0545eaa4f4002f5fe6701bd0d306b68065f4b40ef4fdbe60'),
|
|
29
|
+
privateFunctionsRoot: Fr.fromString('0x202860adb1b8975971eeaf571aaaa88a27f4035290d58532ae7d60b0dfaad54c'),
|
|
30
|
+
publicBytecodeCommitment: Fr.fromString('0x013c4f854a5c87c9daf86c5f9bc07a42c2a061f1d924a5b3564ec7edc8e18cb7')
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
export const StandardContractInitializationHash = {
|
|
34
|
+
AuthRegistry: Fr.fromString('0x0000000000000000000000000000000000000000000000000000000000000000'),
|
|
35
|
+
PublicChecks: Fr.fromString('0x0000000000000000000000000000000000000000000000000000000000000000')
|
|
36
|
+
};
|
|
37
|
+
export const StandardContractPrivateFunctions = {
|
|
38
|
+
AuthRegistry: [
|
|
39
|
+
{
|
|
40
|
+
selector: FunctionSelector.fromField(Fr.fromString('0x0000000000000000000000000000000000000000000000000000000079a3d418')),
|
|
41
|
+
vkHash: Fr.fromString('0x06a5c1b3a636c954a90be43cb56a4bdd9dc8aec764151a012e0018753694ff54')
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
PublicChecks: []
|
|
45
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aztec/standard-contracts",
|
|
3
|
+
"homepage": "https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/standard-contracts",
|
|
4
|
+
"description": "Standard non-protocol contracts for the Aztec Network",
|
|
5
|
+
"version": "5.0.0-nightly.20260530",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./dest/index.js",
|
|
9
|
+
"./*": "./dest/*/index.js",
|
|
10
|
+
"./*/lazy": "./dest/*/lazy.js",
|
|
11
|
+
"./auth-registry/constants": "./dest/auth-registry/constants.js",
|
|
12
|
+
"./public-checks/constants": "./dest/public-checks/constants.js"
|
|
13
|
+
},
|
|
14
|
+
"typedocOptions": {
|
|
15
|
+
"entryPoints": [
|
|
16
|
+
"./src/index.ts",
|
|
17
|
+
"./src/auth-registry/index.ts"
|
|
18
|
+
],
|
|
19
|
+
"name": "Standard Contracts",
|
|
20
|
+
"tsconfig": "./tsconfig.json"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "yarn clean && yarn generate && yarn generate:cleanup-artifacts && ../scripts/tsc.sh",
|
|
24
|
+
"build:keep-debug-symbols": "yarn clean && yarn generate && ../scripts/tsc.sh",
|
|
25
|
+
"generate": "yarn generate:data",
|
|
26
|
+
"generate:cleanup-artifacts": "node --no-warnings --loader @swc-node/register/esm src/scripts/cleanup_artifacts.ts",
|
|
27
|
+
"generate:data": "node --no-warnings --loader @swc-node/register/esm src/scripts/generate_data.ts",
|
|
28
|
+
"build:dev": "../scripts/tsc.sh --watch",
|
|
29
|
+
"build:ts": "../scripts/tsc.sh",
|
|
30
|
+
"clean": "rm -rf ./dest .tsbuildinfo ./artifacts",
|
|
31
|
+
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
|
|
32
|
+
},
|
|
33
|
+
"inherits": [
|
|
34
|
+
"../package.common.json",
|
|
35
|
+
"./package.local.json"
|
|
36
|
+
],
|
|
37
|
+
"jest": {
|
|
38
|
+
"moduleNameMapper": {
|
|
39
|
+
"^(\\.{1,2}/.*)\\.[cm]?js$": "$1"
|
|
40
|
+
},
|
|
41
|
+
"testRegex": "./src/.*\\.test\\.(js|mjs|ts)$",
|
|
42
|
+
"rootDir": "./src",
|
|
43
|
+
"transform": {
|
|
44
|
+
"^.+\\.tsx?$": [
|
|
45
|
+
"@swc/jest",
|
|
46
|
+
{
|
|
47
|
+
"jsc": {
|
|
48
|
+
"parser": {
|
|
49
|
+
"syntax": "typescript",
|
|
50
|
+
"decorators": true
|
|
51
|
+
},
|
|
52
|
+
"transform": {
|
|
53
|
+
"decoratorVersion": "2022-03"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
"extensionsToTreatAsEsm": [
|
|
60
|
+
".ts"
|
|
61
|
+
],
|
|
62
|
+
"reporters": [
|
|
63
|
+
"default"
|
|
64
|
+
],
|
|
65
|
+
"testTimeout": 120000,
|
|
66
|
+
"setupFiles": [
|
|
67
|
+
"../../foundation/src/jest/setup.mjs"
|
|
68
|
+
],
|
|
69
|
+
"testEnvironment": "../../foundation/src/jest/env.mjs",
|
|
70
|
+
"setupFilesAfterEnv": [
|
|
71
|
+
"../../foundation/src/jest/setupAfterEnv.mjs"
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
"dependencies": {
|
|
75
|
+
"@aztec/foundation": "5.0.0-nightly.20260530",
|
|
76
|
+
"@aztec/stdlib": "5.0.0-nightly.20260530",
|
|
77
|
+
"tslib": "^2.4.0"
|
|
78
|
+
},
|
|
79
|
+
"devDependencies": {
|
|
80
|
+
"@jest/globals": "^30.0.0",
|
|
81
|
+
"@types/jest": "^30.0.0",
|
|
82
|
+
"@types/node": "^22.15.17",
|
|
83
|
+
"@typescript/native-preview": "7.0.0-dev.20260113.1",
|
|
84
|
+
"jest": "^30.0.0",
|
|
85
|
+
"jest-mock-extended": "^4.0.0",
|
|
86
|
+
"prettier": "^3.5.3",
|
|
87
|
+
"ts-loader": "^9.5.4",
|
|
88
|
+
"ts-node": "^10.9.1",
|
|
89
|
+
"typescript": "^5.3.3"
|
|
90
|
+
},
|
|
91
|
+
"files": [
|
|
92
|
+
"dest",
|
|
93
|
+
"src",
|
|
94
|
+
"!*.test.*",
|
|
95
|
+
"artifacts",
|
|
96
|
+
"!src/scripts/*"
|
|
97
|
+
],
|
|
98
|
+
"engines": {
|
|
99
|
+
"node": ">=20.10"
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Address-only leaf export for browser bundles: importing from
|
|
2
|
+
// `@aztec/standard-contracts/auth-registry/constants` avoids dragging in the
|
|
3
|
+
// `AuthRegistry.json` static import.
|
|
4
|
+
import { StandardContractAddress, StandardContractClassId, StandardContractSalt } from '../standard_contract_data.js';
|
|
5
|
+
|
|
6
|
+
export const STANDARD_AUTH_REGISTRY_ADDRESS = StandardContractAddress.AuthRegistry;
|
|
7
|
+
export const STANDARD_AUTH_REGISTRY_CLASS_ID = StandardContractClassId.AuthRegistry;
|
|
8
|
+
export const STANDARD_AUTH_REGISTRY_SALT = StandardContractSalt.AuthRegistry;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
2
|
+
import type { NoirCompiledContract } from '@aztec/stdlib/noir';
|
|
3
|
+
|
|
4
|
+
import AuthRegistryJson from '../../artifacts/AuthRegistry.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_AUTH_REGISTRY_ADDRESS,
|
|
10
|
+
STANDARD_AUTH_REGISTRY_CLASS_ID,
|
|
11
|
+
STANDARD_AUTH_REGISTRY_SALT,
|
|
12
|
+
} from './constants.js';
|
|
13
|
+
|
|
14
|
+
export const AuthRegistryArtifact = loadContractArtifact(AuthRegistryJson as NoirCompiledContract);
|
|
15
|
+
|
|
16
|
+
let standardContract: StandardContract;
|
|
17
|
+
|
|
18
|
+
/** Returns the standard deployment of the auth registry. */
|
|
19
|
+
export function getStandardAuthRegistry(): Promise<StandardContract> {
|
|
20
|
+
if (!standardContract) {
|
|
21
|
+
standardContract = makeStandardContract('AuthRegistry', AuthRegistryArtifact);
|
|
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_AUTH_REGISTRY_ADDRESS,
|
|
8
|
+
STANDARD_AUTH_REGISTRY_CLASS_ID,
|
|
9
|
+
STANDARD_AUTH_REGISTRY_SALT,
|
|
10
|
+
} from './constants.js';
|
|
11
|
+
|
|
12
|
+
let standardContract: StandardContract;
|
|
13
|
+
let standardContractArtifact: ContractArtifact;
|
|
14
|
+
|
|
15
|
+
export async function getAuthRegistryArtifact(): 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: authRegistryJson } = await import('../../artifacts/AuthRegistry.json');
|
|
23
|
+
standardContractArtifact = loadContractArtifact(authRegistryJson);
|
|
24
|
+
}
|
|
25
|
+
return standardContractArtifact;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Returns the standard deployment of the auth registry. */
|
|
29
|
+
export async function getStandardAuthRegistry(): Promise<StandardContract> {
|
|
30
|
+
if (!standardContract) {
|
|
31
|
+
const artifact = await getAuthRegistryArtifact();
|
|
32
|
+
standardContract = makeStandardContract('AuthRegistry', artifact);
|
|
33
|
+
}
|
|
34
|
+
return standardContract;
|
|
35
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
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
|
+
{ name: 'PublicChecks', src: 'public_checks_contract-PublicChecks', nrConst: 'STANDARD_PUBLIC_CHECKS_ADDRESS' },
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
/** Everything derived from a compiled standard-contract artifact that the generator emits. */
|
|
66
|
+
export type ContractData = {
|
|
67
|
+
address: AztecAddress;
|
|
68
|
+
classId: Fr;
|
|
69
|
+
artifactHash: Fr;
|
|
70
|
+
privateFunctionsRoot: Fr;
|
|
71
|
+
publicBytecodeCommitment: Fr;
|
|
72
|
+
initializationHash: Fr;
|
|
73
|
+
privateFunctions: { selector: FunctionSelector; vkHash: Fr }[];
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Loads a compiled Noir contract artifact from `noir-contracts/target/` by its source name.
|
|
78
|
+
* Throws with `ENOENT` if the artifact isn't built yet — callers may catch this to provide a
|
|
79
|
+
* friendlier "run the build first" message.
|
|
80
|
+
*/
|
|
81
|
+
export async function loadArtifact(srcName: string): Promise<NoirCompiledContract> {
|
|
82
|
+
const src = path.join(NOIR_ARTIFACTS_SRC_PATH, `${srcName}.json`);
|
|
83
|
+
return JSON.parse(await fs.readFile(src, 'utf8')) as NoirCompiledContract;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Derives the address, class ID, and other deployment data for a standard contract from its
|
|
88
|
+
* compiled artifact. Used by both the generator (to write `standard_contract_data.ts`) and the
|
|
89
|
+
* drift test (to verify the committed data matches).
|
|
90
|
+
*
|
|
91
|
+
* Standard contracts come from a trusted source (the build pipeline), so no class verifications
|
|
92
|
+
* are performed.
|
|
93
|
+
*/
|
|
94
|
+
export async function computeContractData(artifact: NoirCompiledContract): Promise<ContractData> {
|
|
95
|
+
const loaded = loadContractArtifact(artifact);
|
|
96
|
+
const contractClass = await getContractClassFromArtifact(loaded);
|
|
97
|
+
const constructorArtifact = loaded.functions.find(f => f.name === 'constructor');
|
|
98
|
+
const initializationHash = await computeInitializationHash(constructorArtifact, []);
|
|
99
|
+
const instance = {
|
|
100
|
+
version: 2 as const,
|
|
101
|
+
currentContractClassId: contractClass.id,
|
|
102
|
+
originalContractClassId: contractClass.id,
|
|
103
|
+
initializationHash,
|
|
104
|
+
immutablesHash: Fr.ZERO,
|
|
105
|
+
publicKeys: PublicKeys.default(),
|
|
106
|
+
salt: STANDARD_CONTRACT_SALT,
|
|
107
|
+
deployer: STANDARD_CONTRACT_DEPLOYER,
|
|
108
|
+
};
|
|
109
|
+
const address = await computeContractAddressFromInstance(instance);
|
|
110
|
+
return {
|
|
111
|
+
address,
|
|
112
|
+
classId: contractClass.id,
|
|
113
|
+
artifactHash: contractClass.artifactHash,
|
|
114
|
+
privateFunctionsRoot: contractClass.privateFunctionsRoot,
|
|
115
|
+
publicBytecodeCommitment: contractClass.publicBytecodeCommitment,
|
|
116
|
+
initializationHash,
|
|
117
|
+
privateFunctions: contractClass.privateFunctions,
|
|
118
|
+
};
|
|
119
|
+
}
|