@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.
- package/artifacts/AuthRegistry.d.json.ts +5 -0
- package/artifacts/AuthRegistry.json +7838 -0
- package/artifacts/MultiCallEntrypoint.d.json.ts +5 -0
- package/artifacts/MultiCallEntrypoint.json +5994 -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 +101 -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 +4 -0
- package/dest/index.d.ts.map +1 -0
- package/dest/index.js +3 -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/multi-call-entrypoint/constants.d.ts +4 -0
- package/dest/multi-call-entrypoint/constants.d.ts.map +1 -0
- package/dest/multi-call-entrypoint/constants.js +7 -0
- package/dest/multi-call-entrypoint/index.d.ts +6 -0
- package/dest/multi-call-entrypoint/index.d.ts.map +1 -0
- package/dest/multi-call-entrypoint/index.js +14 -0
- package/dest/multi-call-entrypoint/lazy.d.ts +7 -0
- package/dest/multi-call-entrypoint/lazy.d.ts.map +1 -0
- package/dest/multi-call-entrypoint/lazy.js +24 -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 +136 -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 +61 -0
- package/package.json +102 -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 +124 -0
- package/src/drift.ts +201 -0
- package/src/index.ts +3 -0
- package/src/make_standard_contract.ts +51 -0
- package/src/multi-call-entrypoint/constants.ts +8 -0
- package/src/multi-call-entrypoint/index.ts +24 -0
- package/src/multi-call-entrypoint/lazy.ts +35 -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 +76 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const STANDARD_AUTH_REGISTRY_ADDRESS: import("@aztec/stdlib/aztec-address").AztecAddress;
|
|
2
|
+
export declare const STANDARD_AUTH_REGISTRY_CLASS_ID: import("@aztec/foundation/schemas").Fr;
|
|
3
|
+
export declare const STANDARD_AUTH_REGISTRY_SALT: import("@aztec/foundation/schemas").Fr;
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uc3RhbnRzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvYXV0aC1yZWdpc3RyeS9jb25zdGFudHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBS0EsZUFBTyxNQUFNLDhCQUE4QixvREFBdUMsQ0FBQztBQUNuRixlQUFPLE1BQU0sK0JBQStCLHdDQUF1QyxDQUFDO0FBQ3BGLGVBQU8sTUFBTSwyQkFBMkIsd0NBQW9DLENBQUMifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/auth-registry/constants.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,8BAA8B,oDAAuC,CAAC;AACnF,eAAO,MAAM,+BAA+B,wCAAuC,CAAC;AACpF,eAAO,MAAM,2BAA2B,wCAAoC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
export const STANDARD_AUTH_REGISTRY_ADDRESS = StandardContractAddress.AuthRegistry;
|
|
6
|
+
export const STANDARD_AUTH_REGISTRY_CLASS_ID = StandardContractClassId.AuthRegistry;
|
|
7
|
+
export const STANDARD_AUTH_REGISTRY_SALT = StandardContractSalt.AuthRegistry;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { StandardContract } from '../standard_contract.js';
|
|
2
|
+
export { STANDARD_AUTH_REGISTRY_ADDRESS, STANDARD_AUTH_REGISTRY_CLASS_ID, STANDARD_AUTH_REGISTRY_SALT, } from './constants.js';
|
|
3
|
+
export declare const AuthRegistryArtifact: import("@aztec/stdlib/abi").ContractArtifact;
|
|
4
|
+
/** Returns the standard deployment of the auth registry. */
|
|
5
|
+
export declare function getStandardAuthRegistry(): Promise<StandardContract>;
|
|
6
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9hdXRoLXJlZ2lzdHJ5L2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUtBLE9BQU8sS0FBSyxFQUFFLGdCQUFnQixFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFFaEUsT0FBTyxFQUNMLDhCQUE4QixFQUM5QiwrQkFBK0IsRUFDL0IsMkJBQTJCLEdBQzVCLE1BQU0sZ0JBQWdCLENBQUM7QUFFeEIsZUFBTyxNQUFNLG9CQUFvQiw4Q0FBaUUsQ0FBQztBQUluRyw0REFBNEQ7QUFDNUQsd0JBQWdCLHVCQUF1QixJQUFJLE9BQU8sQ0FBQyxnQkFBZ0IsQ0FBQyxDQUtuRSJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth-registry/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EACL,8BAA8B,EAC9B,+BAA+B,EAC/B,2BAA2B,GAC5B,MAAM,gBAAgB,CAAC;AAExB,eAAO,MAAM,oBAAoB,8CAAiE,CAAC;AAInG,4DAA4D;AAC5D,wBAAgB,uBAAuB,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAKnE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
2
|
+
import AuthRegistryJson from '../../artifacts/AuthRegistry.json' with {
|
|
3
|
+
type: 'json'
|
|
4
|
+
};
|
|
5
|
+
import { makeStandardContract } from '../make_standard_contract.js';
|
|
6
|
+
export { STANDARD_AUTH_REGISTRY_ADDRESS, STANDARD_AUTH_REGISTRY_CLASS_ID, STANDARD_AUTH_REGISTRY_SALT } from './constants.js';
|
|
7
|
+
export const AuthRegistryArtifact = loadContractArtifact(AuthRegistryJson);
|
|
8
|
+
let standardContract;
|
|
9
|
+
/** Returns the standard deployment of the auth registry. */ export function getStandardAuthRegistry() {
|
|
10
|
+
if (!standardContract) {
|
|
11
|
+
standardContract = makeStandardContract('AuthRegistry', AuthRegistryArtifact);
|
|
12
|
+
}
|
|
13
|
+
return Promise.resolve(standardContract);
|
|
14
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ContractArtifact } from '@aztec/stdlib/abi';
|
|
2
|
+
import type { StandardContract } from '../standard_contract.js';
|
|
3
|
+
export { STANDARD_AUTH_REGISTRY_ADDRESS, STANDARD_AUTH_REGISTRY_CLASS_ID, STANDARD_AUTH_REGISTRY_SALT, } from './constants.js';
|
|
4
|
+
export declare function getAuthRegistryArtifact(): Promise<ContractArtifact>;
|
|
5
|
+
/** Returns the standard deployment of the auth registry. */
|
|
6
|
+
export declare function getStandardAuthRegistry(): Promise<StandardContract>;
|
|
7
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGF6eS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2F1dGgtcmVnaXN0cnkvbGF6eS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsS0FBSyxnQkFBZ0IsRUFBd0IsTUFBTSxtQkFBbUIsQ0FBQztBQUdoRixPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLHlCQUF5QixDQUFDO0FBRWhFLE9BQU8sRUFDTCw4QkFBOEIsRUFDOUIsK0JBQStCLEVBQy9CLDJCQUEyQixHQUM1QixNQUFNLGdCQUFnQixDQUFDO0FBS3hCLHdCQUFzQix1QkFBdUIsSUFBSSxPQUFPLENBQUMsZ0JBQWdCLENBQUMsQ0FXekU7QUFFRCw0REFBNEQ7QUFDNUQsd0JBQXNCLHVCQUF1QixJQUFJLE9BQU8sQ0FBQyxnQkFBZ0IsQ0FBQyxDQU16RSJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../src/auth-registry/lazy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAwB,MAAM,mBAAmB,CAAC;AAGhF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EACL,8BAA8B,EAC9B,+BAA+B,EAC/B,2BAA2B,GAC5B,MAAM,gBAAgB,CAAC;AAKxB,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAWzE;AAED,4DAA4D;AAC5D,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAMzE"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
2
|
+
import { makeStandardContract } from '../make_standard_contract.js';
|
|
3
|
+
export { STANDARD_AUTH_REGISTRY_ADDRESS, STANDARD_AUTH_REGISTRY_CLASS_ID, STANDARD_AUTH_REGISTRY_SALT } from './constants.js';
|
|
4
|
+
let standardContract;
|
|
5
|
+
let standardContractArtifact;
|
|
6
|
+
export async function getAuthRegistryArtifact() {
|
|
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: authRegistryJson } = await import('../../artifacts/AuthRegistry.json');
|
|
14
|
+
standardContractArtifact = loadContractArtifact(authRegistryJson);
|
|
15
|
+
}
|
|
16
|
+
return standardContractArtifact;
|
|
17
|
+
}
|
|
18
|
+
/** Returns the standard deployment of the auth registry. */ export async function getStandardAuthRegistry() {
|
|
19
|
+
if (!standardContract) {
|
|
20
|
+
const artifact = await getAuthRegistryArtifact();
|
|
21
|
+
standardContract = makeStandardContract('AuthRegistry', artifact);
|
|
22
|
+
}
|
|
23
|
+
return standardContract;
|
|
24
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
3
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
import type { NoirCompiledContract } from '@aztec/stdlib/noir';
|
|
5
|
+
/** Root of the noir-contracts package relative to `yarn-project/standard-contracts`. */
|
|
6
|
+
export declare const NOIR_CONTRACTS_ROOT = "../../noir-projects/noir-contracts";
|
|
7
|
+
/** Directory holding the freshly-compiled Noir artifacts the generator reads from. */
|
|
8
|
+
export declare const NOIR_ARTIFACTS_SRC_PATH: string;
|
|
9
|
+
/** Output directory inside this package where the trimmed artifacts get copied. */
|
|
10
|
+
export declare const STANDARD_ARTIFACTS_DEST_DIR = "./artifacts";
|
|
11
|
+
/** Path of the generated TS data file (addresses, class IDs, etc.). */
|
|
12
|
+
export declare const STANDARD_CONTRACT_DATA_OUTPUT_PATH = "./src/standard_contract_data.ts";
|
|
13
|
+
export declare const NOIR_STANDARD_ADDRESSES_PATHS: string[];
|
|
14
|
+
/** The deployment salt baked into every standard contract instance. */
|
|
15
|
+
export declare const STANDARD_CONTRACT_SALT: Fr;
|
|
16
|
+
/** Every standard contract is deployed by the zero address (universal deploy). */
|
|
17
|
+
export declare const STANDARD_CONTRACT_DEPLOYER: AztecAddress;
|
|
18
|
+
/**
|
|
19
|
+
* Single source of truth for which contracts are "standard" (non-protocol, but with deterministic
|
|
20
|
+
* addresses baked into circuits via `standard_addresses.nr`).
|
|
21
|
+
*
|
|
22
|
+
* - `name`: TS-side name used as the key in the generated `StandardContractAddress` map.
|
|
23
|
+
* - `src`: artifact filename (without `.json`) inside `noir-contracts/target/`.
|
|
24
|
+
* - `nrConst`: Noir-side constant to emit in `standard_addresses.nr`, or `null` to skip the Noir
|
|
25
|
+
* stamp (used for account-side entrypoints with no Noir consumer).
|
|
26
|
+
*
|
|
27
|
+
* Adding a new standard contract is a one-row change here. The drift-detection check in the
|
|
28
|
+
* generator and the backup jest test both iterate this list, so coverage is automatic.
|
|
29
|
+
*/
|
|
30
|
+
export declare const standardContracts: {
|
|
31
|
+
name: string;
|
|
32
|
+
src: string;
|
|
33
|
+
nrConst: string | null;
|
|
34
|
+
}[];
|
|
35
|
+
/** Everything derived from a compiled standard-contract artifact that the generator emits. */
|
|
36
|
+
export type ContractData = {
|
|
37
|
+
address: AztecAddress;
|
|
38
|
+
classId: Fr;
|
|
39
|
+
artifactHash: Fr;
|
|
40
|
+
privateFunctionsRoot: Fr;
|
|
41
|
+
publicBytecodeCommitment: Fr;
|
|
42
|
+
initializationHash: Fr;
|
|
43
|
+
privateFunctions: {
|
|
44
|
+
selector: FunctionSelector;
|
|
45
|
+
vkHash: Fr;
|
|
46
|
+
}[];
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Loads a compiled Noir contract artifact from `noir-contracts/target/` by its source name.
|
|
50
|
+
* Throws with `ENOENT` if the artifact isn't built yet — callers may catch this to provide a
|
|
51
|
+
* friendlier "run the build first" message.
|
|
52
|
+
*/
|
|
53
|
+
export declare function loadArtifact(srcName: string): Promise<NoirCompiledContract>;
|
|
54
|
+
/**
|
|
55
|
+
* Derives the address, class ID, and other deployment data for a standard contract from its
|
|
56
|
+
* compiled artifact. Used by both the generator (to write `standard_contract_data.ts`) and the
|
|
57
|
+
* drift test (to verify the committed data matches).
|
|
58
|
+
*
|
|
59
|
+
* Standard contracts come from a trusted source (the build pipeline), so no class verifications
|
|
60
|
+
* are performed.
|
|
61
|
+
*/
|
|
62
|
+
export declare function computeContractData(artifact: NoirCompiledContract): Promise<ContractData>;
|
|
63
|
+
//# sourceMappingURL=data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E,eAAO,MAAM,kCAAkC,oCAAoC,CAAC;AAIpF,eAAO,MAAM,6BAA6B,UAGzC,CAAC;AAEF,uEAAuE;AACvE,eAAO,MAAM,sBAAsB,IAAY,CAAC;AAChD,kFAAkF;AAClF,eAAO,MAAM,0BAA0B,cAAsB,CAAC;AAE9D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,iBAAiB,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EAQpF,CAAC;AAEF,8FAA8F;AAC9F,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,YAAY,CAAC;IACtB,OAAO,EAAE,EAAE,CAAC;IACZ,YAAY,EAAE,EAAE,CAAC;IACjB,oBAAoB,EAAE,EAAE,CAAC;IACzB,wBAAwB,EAAE,EAAE,CAAC;IAC7B,kBAAkB,EAAE,EAAE,CAAC;IACvB,gBAAgB,EAAE;QAAE,QAAQ,EAAE,gBAAgB,CAAC;QAAC,MAAM,EAAE,EAAE,CAAA;KAAE,EAAE,CAAC;CAChE,CAAC;AAEF;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAGjF;AAED;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,oBAAoB,GAAG,OAAO,CAAC,YAAY,CAAC,CAyB/F"}
|
|
@@ -0,0 +1,101 @@
|
|
|
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 { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
15
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
16
|
+
import { computeContractAddressFromInstance, computeInitializationHash, getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
17
|
+
import { PublicKeys } from '@aztec/stdlib/keys';
|
|
18
|
+
import { promises as fs } from 'fs';
|
|
19
|
+
import path from 'path';
|
|
20
|
+
/** Root of the noir-contracts package relative to `yarn-project/standard-contracts`. */ export const NOIR_CONTRACTS_ROOT = '../../noir-projects/noir-contracts';
|
|
21
|
+
/** Directory holding the freshly-compiled Noir artifacts the generator reads from. */ export const NOIR_ARTIFACTS_SRC_PATH = path.join(NOIR_CONTRACTS_ROOT, './target');
|
|
22
|
+
/** Output directory inside this package where the trimmed artifacts get copied. */ export const STANDARD_ARTIFACTS_DEST_DIR = './artifacts';
|
|
23
|
+
/** Path of the generated TS data file (addresses, class IDs, etc.). */ export const STANDARD_CONTRACT_DATA_OUTPUT_PATH = './src/standard_contract_data.ts';
|
|
24
|
+
// Both consumers (aztec-nr's `aztec` crate and noir-contracts' `aztec_sublib`) need an identical
|
|
25
|
+
// twin of the generated addresses module. `aztec_sublib` cannot depend on `aztec`, so we stamp the
|
|
26
|
+
// same file into both locations rather than introducing a shared crate.
|
|
27
|
+
export const NOIR_STANDARD_ADDRESSES_PATHS = [
|
|
28
|
+
'../../noir-projects/aztec-nr/aztec/src/standard_addresses.nr',
|
|
29
|
+
'../../noir-projects/noir-contracts/contracts/protocol/aztec_sublib/src/standard_addresses.nr'
|
|
30
|
+
];
|
|
31
|
+
/** The deployment salt baked into every standard contract instance. */ export const STANDARD_CONTRACT_SALT = new Fr(1);
|
|
32
|
+
/** Every standard contract is deployed by the zero address (universal deploy). */ export const STANDARD_CONTRACT_DEPLOYER = AztecAddress.zero();
|
|
33
|
+
/**
|
|
34
|
+
* Single source of truth for which contracts are "standard" (non-protocol, but with deterministic
|
|
35
|
+
* addresses baked into circuits via `standard_addresses.nr`).
|
|
36
|
+
*
|
|
37
|
+
* - `name`: TS-side name used as the key in the generated `StandardContractAddress` map.
|
|
38
|
+
* - `src`: artifact filename (without `.json`) inside `noir-contracts/target/`.
|
|
39
|
+
* - `nrConst`: Noir-side constant to emit in `standard_addresses.nr`, or `null` to skip the Noir
|
|
40
|
+
* stamp (used for account-side entrypoints with no Noir consumer).
|
|
41
|
+
*
|
|
42
|
+
* Adding a new standard contract is a one-row change here. The drift-detection check in the
|
|
43
|
+
* generator and the backup jest test both iterate this list, so coverage is automatic.
|
|
44
|
+
*/ export const standardContracts = [
|
|
45
|
+
{
|
|
46
|
+
name: 'AuthRegistry',
|
|
47
|
+
src: 'auth_registry_contract-AuthRegistry',
|
|
48
|
+
nrConst: 'STANDARD_AUTH_REGISTRY_ADDRESS'
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: 'MultiCallEntrypoint',
|
|
52
|
+
src: 'multi_call_entrypoint_contract-MultiCallEntrypoint',
|
|
53
|
+
nrConst: 'STANDARD_MULTI_CALL_ENTRYPOINT_ADDRESS'
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'PublicChecks',
|
|
57
|
+
src: 'public_checks_contract-PublicChecks',
|
|
58
|
+
nrConst: 'STANDARD_PUBLIC_CHECKS_ADDRESS'
|
|
59
|
+
}
|
|
60
|
+
];
|
|
61
|
+
/**
|
|
62
|
+
* Loads a compiled Noir contract artifact from `noir-contracts/target/` by its source name.
|
|
63
|
+
* Throws with `ENOENT` if the artifact isn't built yet — callers may catch this to provide a
|
|
64
|
+
* friendlier "run the build first" message.
|
|
65
|
+
*/ export async function loadArtifact(srcName) {
|
|
66
|
+
const src = path.join(NOIR_ARTIFACTS_SRC_PATH, `${srcName}.json`);
|
|
67
|
+
return JSON.parse(await fs.readFile(src, 'utf8'));
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Derives the address, class ID, and other deployment data for a standard contract from its
|
|
71
|
+
* compiled artifact. Used by both the generator (to write `standard_contract_data.ts`) and the
|
|
72
|
+
* drift test (to verify the committed data matches).
|
|
73
|
+
*
|
|
74
|
+
* Standard contracts come from a trusted source (the build pipeline), so no class verifications
|
|
75
|
+
* are performed.
|
|
76
|
+
*/ export async function computeContractData(artifact) {
|
|
77
|
+
const loaded = loadContractArtifact(artifact);
|
|
78
|
+
const contractClass = await getContractClassFromArtifact(loaded);
|
|
79
|
+
const constructorArtifact = loaded.functions.find((f)=>f.name === 'constructor');
|
|
80
|
+
const initializationHash = await computeInitializationHash(constructorArtifact, []);
|
|
81
|
+
const instance = {
|
|
82
|
+
version: 2,
|
|
83
|
+
currentContractClassId: contractClass.id,
|
|
84
|
+
originalContractClassId: contractClass.id,
|
|
85
|
+
initializationHash,
|
|
86
|
+
immutablesHash: Fr.ZERO,
|
|
87
|
+
publicKeys: PublicKeys.default(),
|
|
88
|
+
salt: STANDARD_CONTRACT_SALT,
|
|
89
|
+
deployer: STANDARD_CONTRACT_DEPLOYER
|
|
90
|
+
};
|
|
91
|
+
const address = await computeContractAddressFromInstance(instance);
|
|
92
|
+
return {
|
|
93
|
+
address,
|
|
94
|
+
classId: contractClass.id,
|
|
95
|
+
artifactHash: contractClass.artifactHash,
|
|
96
|
+
privateFunctionsRoot: contractClass.privateFunctionsRoot,
|
|
97
|
+
publicBytecodeCommitment: contractClass.publicBytecodeCommitment,
|
|
98
|
+
initializationHash,
|
|
99
|
+
privateFunctions: contractClass.privateFunctions
|
|
100
|
+
};
|
|
101
|
+
}
|
package/dest/drift.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
2
|
+
import { type ContractData } from './contract_data.js';
|
|
3
|
+
/**
|
|
4
|
+
* Renders the unformatted TypeScript content for `standard_contract_data.ts`. Run {@link formatTs}
|
|
5
|
+
* on the result before comparing against the committed file — the committed file has been
|
|
6
|
+
* prettier-formatted, so unformatted bytes will not byte-match.
|
|
7
|
+
*/
|
|
8
|
+
export declare function renderOutputFile(names: string[], contractData: ContractData[]): string;
|
|
9
|
+
/**
|
|
10
|
+
* Renders the content for each `standard_addresses.nr` twin. Format-stable — `nargo fmt` will not
|
|
11
|
+
* rewrite the output, so the bytes returned here are byte-equal to what should be on disk.
|
|
12
|
+
*/
|
|
13
|
+
export declare function renderNoirAddresses(rows: {
|
|
14
|
+
nrConst: string;
|
|
15
|
+
address: AztecAddress;
|
|
16
|
+
}[]): string;
|
|
17
|
+
/**
|
|
18
|
+
* Formats TypeScript content with the repo's prettier config so the bytes emitted by the generator
|
|
19
|
+
* (and the expected bytes used by the drift test) match what the eventual `format` step in
|
|
20
|
+
* bootstrap.sh produces. Without this normalization the drift check would false-positive on every
|
|
21
|
+
* run since the raw template-string output differs from the prettier-formatted committed content.
|
|
22
|
+
*
|
|
23
|
+
* The typescript/estree plugins are loaded eagerly and passed explicitly: prettier 3's default
|
|
24
|
+
* lazy-loading via ESM dynamic import is unreliable under jest's `experimental-vm-modules` (the
|
|
25
|
+
* VM context can tear down before the dynamic import resolves), which causes intermittent
|
|
26
|
+
* `Cannot read properties of undefined (reading 'estree')` failures.
|
|
27
|
+
*/
|
|
28
|
+
export declare function formatTs(filePath: string, content: string): Promise<string>;
|
|
29
|
+
/** A rendered target file: the destination path and the exact bytes that should be on disk. */
|
|
30
|
+
export type RenderedTarget = {
|
|
31
|
+
path: string;
|
|
32
|
+
content: string;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Renders every generator output target (the TS data file plus each `standard_addresses.nr` twin)
|
|
36
|
+
* from a list of derived `ContractData`. The TS output is prettier-formatted so the result is
|
|
37
|
+
* byte-comparable against the committed file. Both the generator and the drift test build their
|
|
38
|
+
* comparison against this single function.
|
|
39
|
+
*/
|
|
40
|
+
export declare function renderAllTargets(names: string[], contractData: ContractData[]): Promise<RenderedTarget[]>;
|
|
41
|
+
/**
|
|
42
|
+
* Reads a file's current content, or returns `null` if it doesn't exist. Used by the generator to
|
|
43
|
+
* compare against freshly rendered output before deciding to overwrite, and by the drift test to
|
|
44
|
+
* compare the committed file's bytes against the expected bytes.
|
|
45
|
+
*/
|
|
46
|
+
export declare function readIfExists(filePath: string): Promise<string | null>;
|
|
47
|
+
/**
|
|
48
|
+
* Compares `content` against the bytes currently at `filePath`. If they differ (including the file
|
|
49
|
+
* not existing), writes the new content and returns `true`. If they match, leaves the file
|
|
50
|
+
* untouched and returns `false`. Skipping the write when the content is identical avoids mtime
|
|
51
|
+
* churn that would otherwise re-trigger downstream build steps on every generator run.
|
|
52
|
+
*/
|
|
53
|
+
export declare function writeIfChanged(filePath: string, content: string): Promise<boolean>;
|
|
54
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZHJpZnQuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9kcmlmdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFJQSxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sNkJBQTZCLENBQUM7QUFNM0QsT0FBTyxFQUNMLEtBQUssWUFBWSxFQUtsQixNQUFNLG9CQUFvQixDQUFDO0FBa0U1Qjs7OztHQUlHO0FBQ0gsd0JBQWdCLGdCQUFnQixDQUFDLEtBQUssRUFBRSxNQUFNLEVBQUUsRUFBRSxZQUFZLEVBQUUsWUFBWSxFQUFFLEdBQUcsTUFBTSxDQWV0RjtBQUVEOzs7R0FHRztBQUNILHdCQUFnQixtQkFBbUIsQ0FBQyxJQUFJLEVBQUU7SUFBRSxPQUF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AAY,EAAE,GAAG,MAAM,CAetF;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,YAAY,CAAA;CAAE,EAAE,GAAG,MAAM,CAc9F;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAYjF;AAED,+FAA+F;AAC/F,MAAM,MAAM,cAAc,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/D;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,YAAY,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAU/G;AAED;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAS3E;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAQxF"}
|
package/dest/drift.js
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
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 { promises as fs } from 'fs';
|
|
6
|
+
import path from 'path';
|
|
7
|
+
import * as prettier from 'prettier';
|
|
8
|
+
import { NOIR_STANDARD_ADDRESSES_PATHS, STANDARD_CONTRACT_DATA_OUTPUT_PATH, STANDARD_CONTRACT_SALT, standardContracts } from './contract_data.js';
|
|
9
|
+
function generateNames(names) {
|
|
10
|
+
return `
|
|
11
|
+
export const standardContractNames = [
|
|
12
|
+
${names.map((name)=>`'${name}'`).join(',\n')}
|
|
13
|
+
] as const;
|
|
14
|
+
|
|
15
|
+
export type StandardContractName = typeof standardContractNames[number];
|
|
16
|
+
`;
|
|
17
|
+
}
|
|
18
|
+
function generateSalts(names) {
|
|
19
|
+
return `
|
|
20
|
+
export const StandardContractSalt: Record<StandardContractName, Fr> = {
|
|
21
|
+
${names.map((name)=>`${name}: new Fr(${STANDARD_CONTRACT_SALT.toNumber()})`).join(',\n')}
|
|
22
|
+
};
|
|
23
|
+
`;
|
|
24
|
+
}
|
|
25
|
+
function generateAddresses(names, contractData) {
|
|
26
|
+
return `
|
|
27
|
+
export const StandardContractAddress: Record<StandardContractName, AztecAddress> = {
|
|
28
|
+
${contractData.map((d, i)=>`${names[i]}: AztecAddress.fromString('${d.address.toString()}')`).join(',\n')}
|
|
29
|
+
};
|
|
30
|
+
`;
|
|
31
|
+
}
|
|
32
|
+
function generateClassIdPreimages(names, contractData) {
|
|
33
|
+
return `
|
|
34
|
+
export const StandardContractClassId: Record<StandardContractName, Fr> = {
|
|
35
|
+
${contractData.map((d, i)=>`${names[i]}: Fr.fromString('${d.classId.toString()}')`).join(',\n')}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const StandardContractClassIdPreimage: Record<StandardContractName, { artifactHash: Fr; privateFunctionsRoot: Fr; publicBytecodeCommitment: Fr }> = {
|
|
39
|
+
${contractData.map((d, i)=>`${names[i]}: {
|
|
40
|
+
artifactHash: Fr.fromString('${d.artifactHash.toString()}'),
|
|
41
|
+
privateFunctionsRoot: Fr.fromString('${d.privateFunctionsRoot.toString()}'),
|
|
42
|
+
publicBytecodeCommitment: Fr.fromString('${d.publicBytecodeCommitment.toString()}'),
|
|
43
|
+
}`).join(',\n')}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export const StandardContractInitializationHash: Record<StandardContractName, Fr> = {
|
|
47
|
+
${contractData.map((d, i)=>`${names[i]}: Fr.fromString('${d.initializationHash.toString()}')`).join(',\n')}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const StandardContractPrivateFunctions: Record<StandardContractName, { selector: FunctionSelector; vkHash: Fr }[]> = {
|
|
51
|
+
${contractData.map((d, i)=>`${names[i]}: [${d.privateFunctions.map((fn)=>`{ selector: FunctionSelector.fromField(Fr.fromString('${fn.selector.toField().toString()}')), vkHash: Fr.fromString('${fn.vkHash.toString()}') }`).join(', ')}]`).join(',\n')}
|
|
52
|
+
};
|
|
53
|
+
`;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Renders the unformatted TypeScript content for `standard_contract_data.ts`. Run {@link formatTs}
|
|
57
|
+
* on the result before comparing against the committed file — the committed file has been
|
|
58
|
+
* prettier-formatted, so unformatted bytes will not byte-match.
|
|
59
|
+
*/ export function renderOutputFile(names, contractData) {
|
|
60
|
+
return `
|
|
61
|
+
// GENERATED FILE - DO NOT EDIT. RUN \`yarn generate\` or \`yarn generate:data\`
|
|
62
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
63
|
+
import { FunctionSelector } from '@aztec/stdlib/abi';
|
|
64
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
65
|
+
|
|
66
|
+
${generateNames(names)}
|
|
67
|
+
|
|
68
|
+
${generateSalts(names)}
|
|
69
|
+
|
|
70
|
+
${generateAddresses(names, contractData)}
|
|
71
|
+
|
|
72
|
+
${generateClassIdPreimages(names, contractData)}
|
|
73
|
+
`;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Renders the content for each `standard_addresses.nr` twin. Format-stable — `nargo fmt` will not
|
|
77
|
+
* rewrite the output, so the bytes returned here are byte-equal to what should be on disk.
|
|
78
|
+
*/ export function renderNoirAddresses(rows) {
|
|
79
|
+
// Pre-wrapped to survive `nargo fmt`'s line-width pass without diff churn.
|
|
80
|
+
const globals = rows.map((r)=>`pub global ${r.nrConst}: AztecAddress = AztecAddress::from_field(
|
|
81
|
+
${r.address.toField().toString()},
|
|
82
|
+
);`).join('\n\n');
|
|
83
|
+
return `// GENERATED FILE - DO NOT EDIT. RUN \`yarn workspace @aztec/standard-contracts run generate\`.
|
|
84
|
+
use protocol_types::{address::AztecAddress, traits::FromField};
|
|
85
|
+
|
|
86
|
+
${globals}
|
|
87
|
+
`;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Formats TypeScript content with the repo's prettier config so the bytes emitted by the generator
|
|
91
|
+
* (and the expected bytes used by the drift test) match what the eventual `format` step in
|
|
92
|
+
* bootstrap.sh produces. Without this normalization the drift check would false-positive on every
|
|
93
|
+
* run since the raw template-string output differs from the prettier-formatted committed content.
|
|
94
|
+
*
|
|
95
|
+
* The typescript/estree plugins are loaded eagerly and passed explicitly: prettier 3's default
|
|
96
|
+
* lazy-loading via ESM dynamic import is unreliable under jest's `experimental-vm-modules` (the
|
|
97
|
+
* VM context can tear down before the dynamic import resolves), which causes intermittent
|
|
98
|
+
* `Cannot read properties of undefined (reading 'estree')` failures.
|
|
99
|
+
*/ export async function formatTs(filePath, content) {
|
|
100
|
+
const [typescriptPlugin, estreePlugin] = await Promise.all([
|
|
101
|
+
import('prettier/plugins/typescript.js'),
|
|
102
|
+
import('prettier/plugins/estree.js')
|
|
103
|
+
]);
|
|
104
|
+
const config = await prettier.resolveConfig(path.resolve(filePath)) ?? {};
|
|
105
|
+
return prettier.format(content, {
|
|
106
|
+
...config,
|
|
107
|
+
filepath: filePath,
|
|
108
|
+
parser: 'typescript',
|
|
109
|
+
plugins: [
|
|
110
|
+
typescriptPlugin.default ?? typescriptPlugin,
|
|
111
|
+
estreePlugin.default ?? estreePlugin
|
|
112
|
+
]
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Renders every generator output target (the TS data file plus each `standard_addresses.nr` twin)
|
|
117
|
+
* from a list of derived `ContractData`. The TS output is prettier-formatted so the result is
|
|
118
|
+
* byte-comparable against the committed file. Both the generator and the drift test build their
|
|
119
|
+
* comparison against this single function.
|
|
120
|
+
*/ export async function renderAllTargets(names, contractData) {
|
|
121
|
+
const tsContent = await formatTs(STANDARD_CONTRACT_DATA_OUTPUT_PATH, renderOutputFile(names, contractData));
|
|
122
|
+
const noirRows = standardContracts.map((c, i)=>({
|
|
123
|
+
nrConst: c.nrConst,
|
|
124
|
+
address: contractData[i].address
|
|
125
|
+
})).filter((row)=>row.nrConst !== null);
|
|
126
|
+
const noirContent = renderNoirAddresses(noirRows);
|
|
127
|
+
return [
|
|
128
|
+
{
|
|
129
|
+
path: STANDARD_CONTRACT_DATA_OUTPUT_PATH,
|
|
130
|
+
content: tsContent
|
|
131
|
+
},
|
|
132
|
+
...NOIR_STANDARD_ADDRESSES_PATHS.map((p)=>({
|
|
133
|
+
path: p,
|
|
134
|
+
content: noirContent
|
|
135
|
+
}))
|
|
136
|
+
];
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Reads a file's current content, or returns `null` if it doesn't exist. Used by the generator to
|
|
140
|
+
* compare against freshly rendered output before deciding to overwrite, and by the drift test to
|
|
141
|
+
* compare the committed file's bytes against the expected bytes.
|
|
142
|
+
*/ export async function readIfExists(filePath) {
|
|
143
|
+
try {
|
|
144
|
+
return await fs.readFile(filePath, 'utf8');
|
|
145
|
+
} catch (err) {
|
|
146
|
+
if (err.code === 'ENOENT') {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
throw err;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Compares `content` against the bytes currently at `filePath`. If they differ (including the file
|
|
154
|
+
* not existing), writes the new content and returns `true`. If they match, leaves the file
|
|
155
|
+
* untouched and returns `false`. Skipping the write when the content is identical avoids mtime
|
|
156
|
+
* churn that would otherwise re-trigger downstream build steps on every generator run.
|
|
157
|
+
*/ export async function writeIfChanged(filePath, content) {
|
|
158
|
+
const existing = await readIfExists(filePath);
|
|
159
|
+
if (existing === content) {
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
await fs.mkdir(path.dirname(filePath), {
|
|
163
|
+
recursive: true
|
|
164
|
+
});
|
|
165
|
+
await fs.writeFile(filePath, content);
|
|
166
|
+
return true;
|
|
167
|
+
}
|
package/dest/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export * from './auth-registry/index.js';
|
|
2
|
+
export * from './multi-call-entrypoint/index.js';
|
|
3
|
+
export * from './public-checks/index.js';
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLDBCQUEwQixDQUFDO0FBQ3pDLGNBQWMsa0NBQWtDLENBQUM7QUFDakQsY0FBYywwQkFBMEIsQ0FBQyJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,0BAA0B,CAAC"}
|
package/dest/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
2
|
+
import type { StandardContract } from './standard_contract.js';
|
|
3
|
+
import { type StandardContractName } from './standard_contract_data.js';
|
|
4
|
+
/**
|
|
5
|
+
* Reconstructs a StandardContract from precomputed data without performing any hash computations.
|
|
6
|
+
* Internal to the standard-contracts package — not part of the public API.
|
|
7
|
+
*/
|
|
8
|
+
export declare function makeStandardContract(name: StandardContractName, artifact: ContractArtifact): StandardContract;
|
|
9
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWFrZV9zdGFuZGFyZF9jb250cmFjdC5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL21ha2Vfc3RhbmRhcmRfY29udHJhY3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQ0EsT0FBTyxLQUFLLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxtQkFBbUIsQ0FBQztBQUkxRCxPQUFPLEtBQUssRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBQy9ELE9BQU8sRUFLTCxLQUFLLG9CQUFvQixFQUcxQixNQUFNLDZCQUE2QixDQUFDO0FBRXJDOzs7R0FHRztBQUNILHdCQUFnQixvQkFBb0IsQ0FBQyxJQUFJLEVBQUUsb0JBQW9CLEVBQUUsUUFBUSxFQUFFLGdCQUFnQixHQUFHLGdCQUFnQixDQThCN0cifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"make_standard_contract.d.ts","sourceRoot":"","sources":["../src/make_standard_contract.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAI1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,EAKL,KAAK,oBAAoB,EAG1B,MAAM,6BAA6B,CAAC;AAErC;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,oBAAoB,EAAE,QAAQ,EAAE,gBAAgB,GAAG,gBAAgB,CA8B7G"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
import { PublicKeys } from '@aztec/stdlib/keys';
|
|
4
|
+
import { StandardContractAddress, StandardContractClassId, StandardContractClassIdPreimage, StandardContractInitializationHash, StandardContractPrivateFunctions, StandardContractSalt } from './standard_contract_data.js';
|
|
5
|
+
/**
|
|
6
|
+
* Reconstructs a StandardContract from precomputed data without performing any hash computations.
|
|
7
|
+
* Internal to the standard-contracts package — not part of the public API.
|
|
8
|
+
*/ export function makeStandardContract(name, artifact) {
|
|
9
|
+
const address = StandardContractAddress[name];
|
|
10
|
+
const salt = StandardContractSalt[name];
|
|
11
|
+
const classId = StandardContractClassId[name];
|
|
12
|
+
const { artifactHash, privateFunctionsRoot, publicBytecodeCommitment } = StandardContractClassIdPreimage[name];
|
|
13
|
+
const initializationHash = StandardContractInitializationHash[name];
|
|
14
|
+
const contractClass = {
|
|
15
|
+
id: classId,
|
|
16
|
+
version: 1,
|
|
17
|
+
artifactHash,
|
|
18
|
+
privateFunctionsRoot,
|
|
19
|
+
publicBytecodeCommitment,
|
|
20
|
+
packedBytecode: artifact.functions.find((f)=>f.name === 'public_dispatch')?.bytecode ?? Buffer.alloc(0),
|
|
21
|
+
privateFunctions: StandardContractPrivateFunctions[name]
|
|
22
|
+
};
|
|
23
|
+
const instance = {
|
|
24
|
+
version: 2,
|
|
25
|
+
currentContractClassId: classId,
|
|
26
|
+
originalContractClassId: classId,
|
|
27
|
+
initializationHash,
|
|
28
|
+
immutablesHash: Fr.ZERO,
|
|
29
|
+
publicKeys: PublicKeys.default(),
|
|
30
|
+
salt,
|
|
31
|
+
deployer: AztecAddress.ZERO,
|
|
32
|
+
address
|
|
33
|
+
};
|
|
34
|
+
return {
|
|
35
|
+
instance,
|
|
36
|
+
contractClass,
|
|
37
|
+
artifact,
|
|
38
|
+
address
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const STANDARD_MULTI_CALL_ENTRYPOINT_ADDRESS: import("@aztec/stdlib/aztec-address").AztecAddress;
|
|
2
|
+
export declare const STANDARD_MULTI_CALL_ENTRYPOINT_CLASS_ID: import("@aztec/foundation/schemas").Fr;
|
|
3
|
+
export declare const STANDARD_MULTI_CALL_ENTRYPOINT_SALT: import("@aztec/foundation/schemas").Fr;
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uc3RhbnRzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvbXVsdGktY2FsbC1lbnRyeXBvaW50L2NvbnN0YW50cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFLQSxlQUFPLE1BQU0sc0NBQXNDLG9EQUE4QyxDQUFDO0FBQ2xHLGVBQU8sTUFBTSx1Q0FBdUMsd0NBQThDLENBQUM7QUFDbkcsZUFBTyxNQUFNLG1DQUFtQyx3Q0FBMkMsQ0FBQyJ9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/multi-call-entrypoint/constants.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,sCAAsC,oDAA8C,CAAC;AAClG,eAAO,MAAM,uCAAuC,wCAA8C,CAAC;AACnG,eAAO,MAAM,mCAAmC,wCAA2C,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
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
|
+
export const STANDARD_MULTI_CALL_ENTRYPOINT_ADDRESS = StandardContractAddress.MultiCallEntrypoint;
|
|
6
|
+
export const STANDARD_MULTI_CALL_ENTRYPOINT_CLASS_ID = StandardContractClassId.MultiCallEntrypoint;
|
|
7
|
+
export const STANDARD_MULTI_CALL_ENTRYPOINT_SALT = StandardContractSalt.MultiCallEntrypoint;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { StandardContract } from '../standard_contract.js';
|
|
2
|
+
export { STANDARD_MULTI_CALL_ENTRYPOINT_ADDRESS, STANDARD_MULTI_CALL_ENTRYPOINT_CLASS_ID, STANDARD_MULTI_CALL_ENTRYPOINT_SALT, } from './constants.js';
|
|
3
|
+
export declare const MultiCallEntrypointArtifact: import("@aztec/stdlib/abi").ContractArtifact;
|
|
4
|
+
/** Returns the standard deployment of the multi-call entrypoint. */
|
|
5
|
+
export declare function getStandardMultiCallEntrypoint(): Promise<StandardContract>;
|
|
6
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9tdWx0aS1jYWxsLWVudHJ5cG9pbnQvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBS0EsT0FBTyxLQUFLLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUVoRSxPQUFPLEVBQ0wsc0NBQXNDLEVBQ3RDLHVDQUF1QyxFQUN2QyxtQ0FBbUMsR0FDcEMsTUFBTSxnQkFBZ0IsQ0FBQztBQUV4QixlQUFPLE1BQU0sMkJBQTJCLDhDQUF3RSxDQUFDO0FBSWpILG9FQUFvRTtBQUNwRSx3QkFBZ0IsOEJBQThCLElBQUksT0FBTyxDQUFDLGdCQUFnQixDQUFDLENBSzFFIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/multi-call-entrypoint/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EACL,sCAAsC,EACtC,uCAAuC,EACvC,mCAAmC,GACpC,MAAM,gBAAgB,CAAC;AAExB,eAAO,MAAM,2BAA2B,8CAAwE,CAAC;AAIjH,oEAAoE;AACpE,wBAAgB,8BAA8B,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAK1E"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { loadContractArtifact } from '@aztec/stdlib/abi';
|
|
2
|
+
import MultiCallEntrypointJson from '../../artifacts/MultiCallEntrypoint.json' with {
|
|
3
|
+
type: 'json'
|
|
4
|
+
};
|
|
5
|
+
import { makeStandardContract } from '../make_standard_contract.js';
|
|
6
|
+
export { STANDARD_MULTI_CALL_ENTRYPOINT_ADDRESS, STANDARD_MULTI_CALL_ENTRYPOINT_CLASS_ID, STANDARD_MULTI_CALL_ENTRYPOINT_SALT } from './constants.js';
|
|
7
|
+
export const MultiCallEntrypointArtifact = loadContractArtifact(MultiCallEntrypointJson);
|
|
8
|
+
let standardContract;
|
|
9
|
+
/** Returns the standard deployment of the multi-call entrypoint. */ export function getStandardMultiCallEntrypoint() {
|
|
10
|
+
if (!standardContract) {
|
|
11
|
+
standardContract = makeStandardContract('MultiCallEntrypoint', MultiCallEntrypointArtifact);
|
|
12
|
+
}
|
|
13
|
+
return Promise.resolve(standardContract);
|
|
14
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type ContractArtifact } from '@aztec/stdlib/abi';
|
|
2
|
+
import type { StandardContract } from '../standard_contract.js';
|
|
3
|
+
export { STANDARD_MULTI_CALL_ENTRYPOINT_ADDRESS, STANDARD_MULTI_CALL_ENTRYPOINT_CLASS_ID, STANDARD_MULTI_CALL_ENTRYPOINT_SALT, } from './constants.js';
|
|
4
|
+
export declare function getMultiCallEntrypointArtifact(): Promise<ContractArtifact>;
|
|
5
|
+
/** Returns the standard deployment of the multi-call entrypoint. */
|
|
6
|
+
export declare function getStandardMultiCallEntrypoint(): Promise<StandardContract>;
|
|
7
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGF6eS5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL211bHRpLWNhbGwtZW50cnlwb2ludC9sYXp5LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBRSxLQUFLLGdCQUFnQixFQUF3QixNQUFNLG1CQUFtQixDQUFDO0FBR2hGLE9BQU8sS0FBSyxFQUFFLGdCQUFnQixFQUFFLE1BQU0seUJBQXlCLENBQUM7QUFFaEUsT0FBTyxFQUNMLHNDQUFzQyxFQUN0Qyx1Q0FBdUMsRUFDdkMsbUNBQW1DLEdBQ3BDLE1BQU0sZ0JBQWdCLENBQUM7QUFLeEIsd0JBQXNCLDhCQUE4QixJQUFJLE9BQU8sQ0FBQyxnQkFBZ0IsQ0FBQyxDQVdoRjtBQUVELG9FQUFvRTtBQUNwRSx3QkFBc0IsOEJBQThCLElBQUksT0FBTyxDQUFDLGdCQUFnQixDQUFDLENBTWhGIn0=
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazy.d.ts","sourceRoot":"","sources":["../../src/multi-call-entrypoint/lazy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,gBAAgB,EAAwB,MAAM,mBAAmB,CAAC;AAGhF,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EACL,sCAAsC,EACtC,uCAAuC,EACvC,mCAAmC,GACpC,MAAM,gBAAgB,CAAC;AAKxB,wBAAsB,8BAA8B,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAWhF;AAED,oEAAoE;AACpE,wBAAsB,8BAA8B,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAMhF"}
|