@openzeppelin/compact-deployer 0.2.0
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/CHANGELOG.md +33 -0
- package/README.md +304 -0
- package/dist/config/compact-config.d.ts +31 -0
- package/dist/config/compact-config.js +123 -0
- package/dist/config/compact-config.js.map +1 -0
- package/dist/config/schema.d.ts +688 -0
- package/dist/config/schema.js +90 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/deployer.d.ts +154 -0
- package/dist/deployer.js +916 -0
- package/dist/deployer.js.map +1 -0
- package/dist/deployments.d.ts +119 -0
- package/dist/deployments.js +144 -0
- package/dist/deployments.js.map +1 -0
- package/dist/errors.d.ts +94 -0
- package/dist/errors.js +124 -0
- package/dist/errors.js.map +1 -0
- package/dist/loaders/args.d.ts +22 -0
- package/dist/loaders/args.js +72 -0
- package/dist/loaders/args.js.map +1 -0
- package/dist/loaders/argv.d.ts +36 -0
- package/dist/loaders/argv.js +101 -0
- package/dist/loaders/argv.js.map +1 -0
- package/dist/loaders/artifact-path.d.ts +16 -0
- package/dist/loaders/artifact-path.js +35 -0
- package/dist/loaders/artifact-path.js.map +1 -0
- package/dist/loaders/artifact.d.ts +43 -0
- package/dist/loaders/artifact.js +115 -0
- package/dist/loaders/artifact.js.map +1 -0
- package/dist/loaders/constructor-meta.d.ts +17 -0
- package/dist/loaders/constructor-meta.js +99 -0
- package/dist/loaders/constructor-meta.js.map +1 -0
- package/dist/loaders/context.d.ts +14 -0
- package/dist/loaders/context.js +43 -0
- package/dist/loaders/context.js.map +1 -0
- package/dist/loaders/contract-resolve.d.ts +15 -0
- package/dist/loaders/contract-resolve.js +53 -0
- package/dist/loaders/contract-resolve.js.map +1 -0
- package/dist/loaders/init-state.d.ts +8 -0
- package/dist/loaders/init-state.js +37 -0
- package/dist/loaders/init-state.js.map +1 -0
- package/dist/loaders/ref-resolver.d.ts +8 -0
- package/dist/loaders/ref-resolver.js +27 -0
- package/dist/loaders/ref-resolver.js.map +1 -0
- package/dist/loaders/signing-key.d.ts +10 -0
- package/dist/loaders/signing-key.js +23 -0
- package/dist/loaders/signing-key.js.map +1 -0
- package/dist/providers/build.d.ts +20 -0
- package/dist/providers/build.js +41 -0
- package/dist/providers/build.js.map +1 -0
- package/dist/providers/network.d.ts +6 -0
- package/dist/providers/network.js +36 -0
- package/dist/providers/network.js.map +1 -0
- package/dist/providers/private-state-password.d.ts +12 -0
- package/dist/providers/private-state-password.js +27 -0
- package/dist/providers/private-state-password.js.map +1 -0
- package/dist/providers/proof-server.d.ts +29 -0
- package/dist/providers/proof-server.js +97 -0
- package/dist/providers/proof-server.js.map +1 -0
- package/dist/runDeploy.d.ts +167 -0
- package/dist/runDeploy.js +228 -0
- package/dist/runDeploy.js.map +1 -0
- package/dist/services/atomic-json.d.ts +7 -0
- package/dist/services/atomic-json.js +34 -0
- package/dist/services/atomic-json.js.map +1 -0
- package/dist/services/chain-state.d.ts +75 -0
- package/dist/services/chain-state.js +151 -0
- package/dist/services/chain-state.js.map +1 -0
- package/dist/services/contract-state.d.ts +29 -0
- package/dist/services/contract-state.js +54 -0
- package/dist/services/contract-state.js.map +1 -0
- package/dist/services/deploy-plan.d.ts +36 -0
- package/dist/services/deploy-plan.js +45 -0
- package/dist/services/deploy-plan.js.map +1 -0
- package/dist/services/deploy-tx.d.ts +189 -0
- package/dist/services/deploy-tx.js +297 -0
- package/dist/services/deploy-tx.js.map +1 -0
- package/dist/services/error-format.d.ts +10 -0
- package/dist/services/error-format.js +91 -0
- package/dist/services/error-format.js.map +1 -0
- package/dist/services/file-lock.d.ts +23 -0
- package/dist/services/file-lock.js +90 -0
- package/dist/services/file-lock.js.map +1 -0
- package/dist/services/maintenance-tx.d.ts +49 -0
- package/dist/services/maintenance-tx.js +43 -0
- package/dist/services/maintenance-tx.js.map +1 -0
- package/dist/services/wallet-cache.d.ts +99 -0
- package/dist/services/wallet-cache.js +239 -0
- package/dist/services/wallet-cache.js.map +1 -0
- package/dist/services/wallet-sync.d.ts +89 -0
- package/dist/services/wallet-sync.js +249 -0
- package/dist/services/wallet-sync.js.map +1 -0
- package/dist/wallet/handler.d.ts +64 -0
- package/dist/wallet/handler.js +151 -0
- package/dist/wallet/handler.js.map +1 -0
- package/dist/wallet/keystore.d.ts +55 -0
- package/dist/wallet/keystore.js +213 -0
- package/dist/wallet/keystore.js.map +1 -0
- package/dist/wallet/seeds.d.ts +41 -0
- package/dist/wallet/seeds.js +84 -0
- package/dist/wallet/seeds.js.map +1 -0
- package/package.json +133 -0
- package/proof-server.yml +16 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deploy-flag parser shared by the library entrypoint (`runDeploy`) and the
|
|
3
|
+
* `compact-deploy` CLI, so the two can't drift on flag names or validation.
|
|
4
|
+
*/
|
|
5
|
+
/** Flags recognised by both front-ends. */
|
|
6
|
+
export interface ParsedDeployArgv {
|
|
7
|
+
network?: string;
|
|
8
|
+
configPath?: string;
|
|
9
|
+
seedFile?: string;
|
|
10
|
+
proofServer?: string;
|
|
11
|
+
syncTimeoutSec?: number;
|
|
12
|
+
txTimeoutSec?: number;
|
|
13
|
+
syncBatchSize?: number;
|
|
14
|
+
circuitsPerTx?: number;
|
|
15
|
+
seedCacheFromDust?: string;
|
|
16
|
+
seedCacheFromShielded?: string;
|
|
17
|
+
seedCacheFromUnshielded?: string;
|
|
18
|
+
noCache: boolean;
|
|
19
|
+
force: boolean;
|
|
20
|
+
dryRun: boolean;
|
|
21
|
+
json: boolean;
|
|
22
|
+
verbose: boolean;
|
|
23
|
+
help: boolean;
|
|
24
|
+
version: boolean;
|
|
25
|
+
/** Non-flag arguments, in order. The CLI reads the contract name from slot 0. */
|
|
26
|
+
positional: string[];
|
|
27
|
+
}
|
|
28
|
+
export interface ParseDeployArgvOptions {
|
|
29
|
+
/**
|
|
30
|
+
* Throw on an unrecognised `--flag`. The CLI sets this; the library leaves
|
|
31
|
+
* it off so it coexists with extra argv a caller's wrapper script injects.
|
|
32
|
+
* Unrecognised single-dash args are positional under either setting.
|
|
33
|
+
*/
|
|
34
|
+
rejectUnknownFlags?: boolean;
|
|
35
|
+
}
|
|
36
|
+
export declare function parseDeployArgv(argv: string[], opts?: ParseDeployArgvOptions): ParsedDeployArgv;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deploy-flag parser shared by the library entrypoint (`runDeploy`) and the
|
|
3
|
+
* `compact-deploy` CLI, so the two can't drift on flag names or validation.
|
|
4
|
+
*/
|
|
5
|
+
export function parseDeployArgv(argv, opts = {}) {
|
|
6
|
+
const out = {
|
|
7
|
+
noCache: false,
|
|
8
|
+
force: false,
|
|
9
|
+
dryRun: false,
|
|
10
|
+
json: false,
|
|
11
|
+
verbose: false,
|
|
12
|
+
help: false,
|
|
13
|
+
version: false,
|
|
14
|
+
positional: [],
|
|
15
|
+
};
|
|
16
|
+
for (let i = 0; i < argv.length; i++) {
|
|
17
|
+
const arg = argv[i];
|
|
18
|
+
switch (arg) {
|
|
19
|
+
case '-h':
|
|
20
|
+
case '--help':
|
|
21
|
+
out.help = true;
|
|
22
|
+
break;
|
|
23
|
+
case '--version':
|
|
24
|
+
out.version = true;
|
|
25
|
+
break;
|
|
26
|
+
case '-v':
|
|
27
|
+
case '--verbose':
|
|
28
|
+
out.verbose = true;
|
|
29
|
+
break;
|
|
30
|
+
case '--json':
|
|
31
|
+
out.json = true;
|
|
32
|
+
break;
|
|
33
|
+
case '--dry-run':
|
|
34
|
+
out.dryRun = true;
|
|
35
|
+
break;
|
|
36
|
+
case '--no-cache':
|
|
37
|
+
out.noCache = true;
|
|
38
|
+
break;
|
|
39
|
+
case '--force':
|
|
40
|
+
out.force = true;
|
|
41
|
+
break;
|
|
42
|
+
case '--seed-cache-from-dust':
|
|
43
|
+
out.seedCacheFromDust = expectValue(argv, ++i, '--seed-cache-from-dust');
|
|
44
|
+
break;
|
|
45
|
+
case '--seed-cache-from-shielded':
|
|
46
|
+
out.seedCacheFromShielded = expectValue(argv, ++i, '--seed-cache-from-shielded');
|
|
47
|
+
break;
|
|
48
|
+
case '--seed-cache-from-unshielded':
|
|
49
|
+
out.seedCacheFromUnshielded = expectValue(argv, ++i, '--seed-cache-from-unshielded');
|
|
50
|
+
break;
|
|
51
|
+
case '--network':
|
|
52
|
+
out.network = expectValue(argv, ++i, '--network');
|
|
53
|
+
break;
|
|
54
|
+
case '--config':
|
|
55
|
+
out.configPath = expectValue(argv, ++i, '--config');
|
|
56
|
+
break;
|
|
57
|
+
case '--seed-file':
|
|
58
|
+
out.seedFile = expectValue(argv, ++i, '--seed-file');
|
|
59
|
+
break;
|
|
60
|
+
case '--proof-server':
|
|
61
|
+
out.proofServer = expectValue(argv, ++i, '--proof-server');
|
|
62
|
+
break;
|
|
63
|
+
case '--sync-timeout':
|
|
64
|
+
out.syncTimeoutSec = expectPositiveInt(expectValue(argv, ++i, '--sync-timeout'), '--sync-timeout', ' (seconds)');
|
|
65
|
+
break;
|
|
66
|
+
case '--tx-timeout':
|
|
67
|
+
out.txTimeoutSec = expectPositiveInt(expectValue(argv, ++i, '--tx-timeout'), '--tx-timeout', ' (seconds)');
|
|
68
|
+
break;
|
|
69
|
+
case '--sync-batch-size':
|
|
70
|
+
out.syncBatchSize = expectPositiveInt(expectValue(argv, ++i, '--sync-batch-size'), '--sync-batch-size');
|
|
71
|
+
break;
|
|
72
|
+
case '--circuits-per-tx':
|
|
73
|
+
out.circuitsPerTx = expectPositiveInt(expectValue(argv, ++i, '--circuits-per-tx'), '--circuits-per-tx');
|
|
74
|
+
break;
|
|
75
|
+
default:
|
|
76
|
+
if (opts.rejectUnknownFlags === true && arg.startsWith('--')) {
|
|
77
|
+
throw new Error(`Unknown flag: ${arg}`);
|
|
78
|
+
}
|
|
79
|
+
if (!arg.startsWith('--'))
|
|
80
|
+
out.positional.push(arg);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return out;
|
|
84
|
+
}
|
|
85
|
+
function expectValue(argv, i, flag) {
|
|
86
|
+
const v = argv[i];
|
|
87
|
+
if (v === undefined || v.startsWith('-')) {
|
|
88
|
+
throw new Error(`${flag} requires a value`);
|
|
89
|
+
}
|
|
90
|
+
return v;
|
|
91
|
+
}
|
|
92
|
+
function expectPositiveInt(raw, flag, unit = '') {
|
|
93
|
+
const n = Number(raw);
|
|
94
|
+
// `parseInt` would read "1.5" as 1 and "3abc" as 3, both of which the user
|
|
95
|
+
// did not ask for.
|
|
96
|
+
if (!Number.isInteger(n) || n <= 0) {
|
|
97
|
+
throw new Error(`${flag} requires a positive integer${unit}; got "${raw}"`);
|
|
98
|
+
}
|
|
99
|
+
return n;
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=argv.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"argv.js","sourceRoot":"","sources":["../../src/loaders/argv.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAmCH,MAAM,UAAU,eAAe,CAC7B,IAAc,EACd,OAA+B,EAAE;IAEjC,MAAM,GAAG,GAAqB;QAC5B,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,KAAK;QACZ,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,KAAK;QACX,OAAO,EAAE,KAAK;QACd,IAAI,EAAE,KAAK;QACX,OAAO,EAAE,KAAK;QACd,UAAU,EAAE,EAAE;KACf,CAAC;IACF,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAW,CAAC;QAC9B,QAAQ,GAAG,EAAE,CAAC;YACZ,KAAK,IAAI,CAAC;YACV,KAAK,QAAQ;gBACX,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC;gBAChB,MAAM;YACR,KAAK,WAAW;gBACd,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC;gBACnB,MAAM;YACR,KAAK,IAAI,CAAC;YACV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AC,GAAG,IAAI,mBAAmB,CAAC,CAAC;IAC9C,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAED,SAAS,iBAAiB,CAAC,GAAW,EAAE,IAAY,EAAE,IAAI,GAAG,EAAE;IAC7D,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IACtB,2EAA2E;IAC3E,mBAAmB;IACnB,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,+BAA+B,IAAI,UAAU,GAAG,GAAG,CAAC,CAAC;IAC9E,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Artifact-directory resolution shared by the artifact loader and the
|
|
3
|
+
* `Contract`-class resolver, so the two agree on which directory a TOML
|
|
4
|
+
* `artifact` string names and which file is its entry point.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Resolve a TOML `artifact` value to a directory. Relative values are tried
|
|
8
|
+
* against `rootDir` first so a path that already includes the artifacts
|
|
9
|
+
* directory works, then under `artifactsDir`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolveUnderRoot(rootDir: string, artifact: string, artifactsDir: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* First existing `index.{cjs,js}` under `<artifactDir>/contract` then
|
|
14
|
+
* `<artifactDir>`. `.cjs` wins because compactc emits CommonJS.
|
|
15
|
+
*/
|
|
16
|
+
export declare function findArtifactEntry(artifactDir: string): string | undefined;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { isAbsolute, resolve } from 'node:path';
|
|
3
|
+
/**
|
|
4
|
+
* Artifact-directory resolution shared by the artifact loader and the
|
|
5
|
+
* `Contract`-class resolver, so the two agree on which directory a TOML
|
|
6
|
+
* `artifact` string names and which file is its entry point.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Resolve a TOML `artifact` value to a directory. Relative values are tried
|
|
10
|
+
* against `rootDir` first so a path that already includes the artifacts
|
|
11
|
+
* directory works, then under `artifactsDir`.
|
|
12
|
+
*/
|
|
13
|
+
export function resolveUnderRoot(rootDir, artifact, artifactsDir) {
|
|
14
|
+
if (isAbsolute(artifact))
|
|
15
|
+
return artifact;
|
|
16
|
+
const direct = resolve(rootDir, artifact);
|
|
17
|
+
if (existsSync(direct))
|
|
18
|
+
return direct;
|
|
19
|
+
return resolve(rootDir, artifactsDir, artifact);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* First existing `index.{cjs,js}` under `<artifactDir>/contract` then
|
|
23
|
+
* `<artifactDir>`. `.cjs` wins because compactc emits CommonJS.
|
|
24
|
+
*/
|
|
25
|
+
export function findArtifactEntry(artifactDir) {
|
|
26
|
+
const contractDir = resolve(artifactDir, 'contract');
|
|
27
|
+
const candidates = [
|
|
28
|
+
resolve(contractDir, 'index.cjs'),
|
|
29
|
+
resolve(contractDir, 'index.js'),
|
|
30
|
+
resolve(artifactDir, 'index.cjs'),
|
|
31
|
+
resolve(artifactDir, 'index.js'),
|
|
32
|
+
];
|
|
33
|
+
return candidates.find(existsSync);
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=artifact-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact-path.js","sourceRoot":"","sources":["../../src/loaders/artifact-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEhD;;;;GAIG;AAEH;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAC9B,OAAe,EACf,QAAgB,EAChB,YAAoB;IAEpB,IAAI,UAAU,CAAC,QAAQ,CAAC;QAAE,OAAO,QAAQ,CAAC;IAC1C,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC1C,IAAI,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,MAAM,CAAC;IACtC,OAAO,OAAO,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,CAAC,CAAC;AAClD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,WAAmB;IACnD,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IACrD,MAAM,UAAU,GAAG;QACjB,OAAO,CAAC,WAAW,EAAE,WAAW,CAAC;QACjC,OAAO,CAAC,WAAW,EAAE,UAAU,CAAC;QAChC,OAAO,CAAC,WAAW,EAAE,WAAW,CAAC;QACjC,OAAO,CAAC,WAAW,EAAE,UAAU,CAAC;KACjC,CAAC;IACF,OAAO,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AACrC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { CompiledContract, type Contract } from '@midnight-ntwrk/compact-js';
|
|
2
|
+
import type { ZKConfigProvider } from '@midnight-ntwrk/midnight-js-types';
|
|
3
|
+
import { type FileOrModuleRef } from '../config/schema.ts';
|
|
4
|
+
/**
|
|
5
|
+
* A compactc artifact bundle on disk:
|
|
6
|
+
* <artifact>/contract/index.{cjs,js} — Contract class
|
|
7
|
+
* <artifact>/keys/<circuit>.{prover,verifier}
|
|
8
|
+
* <artifact>/zkir/<circuit>.bzkir
|
|
9
|
+
* Witnesses live outside the bundle, referenced via `[contracts.X].witnesses`.
|
|
10
|
+
*/
|
|
11
|
+
type AnyContract = Contract.Any;
|
|
12
|
+
/**
|
|
13
|
+
* `unknown` private state would not satisfy either SDK entry point that takes
|
|
14
|
+
* this value, and the artifact's real private-state type is only known to the
|
|
15
|
+
* dApp. `any` is the one place that gap is bridged, so no consumer casts.
|
|
16
|
+
*/
|
|
17
|
+
type AnyCompiledContract = CompiledContract.CompiledContract<AnyContract, any>;
|
|
18
|
+
export interface LoadArtifactOptions {
|
|
19
|
+
rootDir: string;
|
|
20
|
+
artifactsDir: string;
|
|
21
|
+
artifact: string;
|
|
22
|
+
contractName: string;
|
|
23
|
+
witnesses?: FileOrModuleRef;
|
|
24
|
+
}
|
|
25
|
+
/** Verifier key bytes per circuit, as read from `keys/<circuit>.verifier`. */
|
|
26
|
+
export type ArtifactKeys = ReadonlyMap<string, Uint8Array>;
|
|
27
|
+
export declare class Artifact {
|
|
28
|
+
readonly compiledContract: AnyCompiledContract;
|
|
29
|
+
readonly artifactPath: string;
|
|
30
|
+
readonly zkConfigPath: string;
|
|
31
|
+
readonly circuitNames: readonly string[];
|
|
32
|
+
private constructor();
|
|
33
|
+
/**
|
|
34
|
+
* Verifier key bytes for every circuit this artifact declares.
|
|
35
|
+
*
|
|
36
|
+
* Read before fragment 0, so a bundle missing a key fails before any
|
|
37
|
+
* transaction rather than mid-way through the inserts.
|
|
38
|
+
*/
|
|
39
|
+
verifierKeys(zkConfigProvider: ZKConfigProvider<string>): Promise<ArtifactKeys>;
|
|
40
|
+
/** Resolve, validate, and import the bundle. Throws {@link ArtifactNotFoundError} on missing dir/entry/keys/zkir. */
|
|
41
|
+
static load(opts: LoadArtifactOptions): Promise<Artifact>;
|
|
42
|
+
}
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { existsSync, readdirSync } from 'node:fs';
|
|
2
|
+
import { dirname, resolve } from 'node:path';
|
|
3
|
+
import { CompiledContract } from '@midnight-ntwrk/compact-js';
|
|
4
|
+
import { isFileRef, isModuleRef, } from "../config/schema.js";
|
|
5
|
+
import { ArtifactNotFoundError, ConfigError } from "../errors.js";
|
|
6
|
+
import { findArtifactEntry, resolveUnderRoot } from "./artifact-path.js";
|
|
7
|
+
import { LoaderContext } from "./context.js";
|
|
8
|
+
export class Artifact {
|
|
9
|
+
compiledContract;
|
|
10
|
+
artifactPath;
|
|
11
|
+
zkConfigPath;
|
|
12
|
+
circuitNames;
|
|
13
|
+
constructor(input) {
|
|
14
|
+
this.compiledContract = input.compiledContract;
|
|
15
|
+
this.artifactPath = input.artifactPath;
|
|
16
|
+
this.zkConfigPath = input.zkConfigPath;
|
|
17
|
+
this.circuitNames = input.circuitNames;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Verifier key bytes for every circuit this artifact declares.
|
|
21
|
+
*
|
|
22
|
+
* Read before fragment 0, so a bundle missing a key fails before any
|
|
23
|
+
* transaction rather than mid-way through the inserts.
|
|
24
|
+
*/
|
|
25
|
+
async verifierKeys(zkConfigProvider) {
|
|
26
|
+
const pairs = await zkConfigProvider.getVerifierKeys([
|
|
27
|
+
...this.circuitNames,
|
|
28
|
+
]);
|
|
29
|
+
const keys = new Map(pairs);
|
|
30
|
+
const missing = this.circuitNames.filter((name) => !keys.has(name));
|
|
31
|
+
if (missing.length > 0) {
|
|
32
|
+
throw new ConfigError(`Artifact at ${this.artifactPath} has no verifier key for: ${missing.join(', ')}.`);
|
|
33
|
+
}
|
|
34
|
+
return keys;
|
|
35
|
+
}
|
|
36
|
+
/** Resolve, validate, and import the bundle. Throws {@link ArtifactNotFoundError} on missing dir/entry/keys/zkir. */
|
|
37
|
+
static async load(opts) {
|
|
38
|
+
const { rootDir, artifactsDir, artifact, contractName, witnesses } = opts;
|
|
39
|
+
const ctx = new LoaderContext(rootDir);
|
|
40
|
+
const artifactPath = resolveUnderRoot(rootDir, artifact, artifactsDir);
|
|
41
|
+
if (!existsSync(artifactPath)) {
|
|
42
|
+
throw new ArtifactNotFoundError(artifactPath);
|
|
43
|
+
}
|
|
44
|
+
const entry = findArtifactEntry(artifactPath);
|
|
45
|
+
if (!entry) {
|
|
46
|
+
throw new ArtifactNotFoundError(`${artifactPath} (no contract/index.{cjs,js} or index.{cjs,js} found)`);
|
|
47
|
+
}
|
|
48
|
+
// Bind compiled assets to the directory the entry actually lives in:
|
|
49
|
+
// `findArtifactEntry` may resolve a top-level `index.{cjs,js}` rather than the
|
|
50
|
+
// `contract/` subdir, in which case the hardcoded path would be wrong.
|
|
51
|
+
const contractDir = dirname(entry);
|
|
52
|
+
const keysDir = resolve(artifactPath, 'keys');
|
|
53
|
+
const zkirDir = resolve(artifactPath, 'zkir');
|
|
54
|
+
if (!existsSync(keysDir) || !existsSync(zkirDir)) {
|
|
55
|
+
throw new ArtifactNotFoundError(`${artifactPath} (missing keys/ or zkir/ subdirectory)`);
|
|
56
|
+
}
|
|
57
|
+
const circuitNames = collectCircuitNames(zkirDir);
|
|
58
|
+
const Ctor = await importContractCtor(ctx, entry);
|
|
59
|
+
const witnessImpls = witnesses
|
|
60
|
+
? await importWitnesses(ctx, witnesses)
|
|
61
|
+
: undefined;
|
|
62
|
+
const compiledContract = buildCompiledContract({
|
|
63
|
+
contractName,
|
|
64
|
+
Ctor,
|
|
65
|
+
witnessImpls,
|
|
66
|
+
contractDir,
|
|
67
|
+
});
|
|
68
|
+
return new Artifact({
|
|
69
|
+
compiledContract,
|
|
70
|
+
artifactPath,
|
|
71
|
+
zkConfigPath: artifactPath,
|
|
72
|
+
circuitNames,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
async function importContractCtor(ctx, entry) {
|
|
77
|
+
const { mod, path } = await ctx.importModule(entry, 'artifact');
|
|
78
|
+
const m = mod;
|
|
79
|
+
const Ctor = m.Contract ?? m.default?.Contract;
|
|
80
|
+
if (!Ctor) {
|
|
81
|
+
throw new ConfigError(`Artifact at ${path} does not export a \`Contract\` class (got keys: ${Object.keys(m).join(', ')})`);
|
|
82
|
+
}
|
|
83
|
+
return Ctor;
|
|
84
|
+
}
|
|
85
|
+
async function importWitnesses(ctx, ref) {
|
|
86
|
+
if (isFileRef(ref)) {
|
|
87
|
+
throw new ConfigError('witnesses must be a { module, export } reference; JSON file refs are not supported (witnesses are functions)');
|
|
88
|
+
}
|
|
89
|
+
if (!isModuleRef(ref)) {
|
|
90
|
+
throw new ConfigError('witnesses must be { module, export }');
|
|
91
|
+
}
|
|
92
|
+
const { mod, path } = await ctx.importModule(ref.module, 'witnesses');
|
|
93
|
+
const exported = mod[ref.export];
|
|
94
|
+
const resolved = typeof exported === 'function'
|
|
95
|
+
? await exported()
|
|
96
|
+
: exported;
|
|
97
|
+
if (typeof resolved !== 'object' || resolved === null) {
|
|
98
|
+
throw new ConfigError(`witnesses: module ${path} export "${ref.export}" must resolve to an object`);
|
|
99
|
+
}
|
|
100
|
+
return resolved;
|
|
101
|
+
}
|
|
102
|
+
function buildCompiledContract(input) {
|
|
103
|
+
const base = CompiledContract.make(input.contractName, input.Ctor);
|
|
104
|
+
const withWit = input.witnessImpls
|
|
105
|
+
? CompiledContract.withWitnesses(base, input.witnessImpls)
|
|
106
|
+
: CompiledContract.withVacantWitnesses(base);
|
|
107
|
+
return CompiledContract.withCompiledFileAssets(withWit, input.contractDir);
|
|
108
|
+
}
|
|
109
|
+
function collectCircuitNames(zkirDir) {
|
|
110
|
+
return readdirSync(zkirDir)
|
|
111
|
+
.filter((f) => f.endsWith('.bzkir'))
|
|
112
|
+
.map((f) => f.slice(0, -'.bzkir'.length))
|
|
113
|
+
.sort();
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=artifact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact.js","sourceRoot":"","sources":["../../src/loaders/artifact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAiB,MAAM,4BAA4B,CAAC;AAG7E,OAAO,EAEL,SAAS,EACT,WAAW,GACZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MA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,GAAG,CAAC,MAAM,6BAA6B,CAC7E,CAAC;IACJ,CAAC;IACD,OAAO,QAAwB,CAAC;AAClC,CAAC;AAED,SAAS,qBAAqB,CAAC,KAK9B;IACC,MAAM,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IACnE,MAAM,OAAO,GAAG,KAAK,CAAC,YAAY;QAChC,CAAC,CAAC,gBAAgB,CAAC,aAAa,CAAC,IAAI,EAAE,KAAK,CAAC,YAAY,CAAC;QAC1D,CAAC,CAAC,gBAAgB,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;IAC/C,OAAO,gBAAgB,CAAC,sBAAsB,CAAC,OAAO,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;AAC7E,CAAC;AAOD,SAAS,mBAAmB,CAAC,OAAe;IAC1C,OAAO,WAAW,CAAC,OAAO,CAAC;SACxB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;SACnC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;SACxC,IAAI,EAAE,CAAC;AACZ,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses an artifact's `contract/index.d.ts` and returns the ordered
|
|
3
|
+
* constructor parameter names (with the trailing `_<digits>` SSA
|
|
4
|
+
* suffix the Compact compiler appends stripped — `_name_2` → `_name`).
|
|
5
|
+
* Used to reorder a named-object `args: { ... }` into the positional
|
|
6
|
+
* tuple the contract's `initialState` expects.
|
|
7
|
+
*/
|
|
8
|
+
export declare function loadConstructorParamNames(artifactPath: string): string[];
|
|
9
|
+
/** Reorders a named-object args record into a positional tuple. */
|
|
10
|
+
export declare function reorderNamedArgs(named: Record<string, unknown>, paramNames: readonly string[]): unknown[];
|
|
11
|
+
/**
|
|
12
|
+
* Pulls the constructor parameter names out of a Compact artifact's
|
|
13
|
+
* `index.d.ts`. The trailing `_<digits>` SSA suffix is stripped; if
|
|
14
|
+
* stripping causes a collision in the same constructor, the original
|
|
15
|
+
* names are kept.
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseConstructorParamNames(dtsSource: string): string[];
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { ArtifactNotFoundError, ConfigError } from "../errors.js";
|
|
4
|
+
/**
|
|
5
|
+
* Parses an artifact's `contract/index.d.ts` and returns the ordered
|
|
6
|
+
* constructor parameter names (with the trailing `_<digits>` SSA
|
|
7
|
+
* suffix the Compact compiler appends stripped — `_name_2` → `_name`).
|
|
8
|
+
* Used to reorder a named-object `args: { ... }` into the positional
|
|
9
|
+
* tuple the contract's `initialState` expects.
|
|
10
|
+
*/
|
|
11
|
+
export function loadConstructorParamNames(artifactPath) {
|
|
12
|
+
const dtsPath = join(artifactPath, 'contract', 'index.d.ts');
|
|
13
|
+
if (!existsSync(dtsPath)) {
|
|
14
|
+
throw new ArtifactNotFoundError(`${artifactPath} (no contract/index.d.ts — cannot reorder named args)`);
|
|
15
|
+
}
|
|
16
|
+
const source = readFileSync(dtsPath, 'utf8');
|
|
17
|
+
// A no-arg constructor yields `[]`. `reorderNamedArgs` then accepts an
|
|
18
|
+
// empty named-args object and rejects any unexpected keys, so we don't
|
|
19
|
+
// need to special-case the empty result here.
|
|
20
|
+
return parseConstructorParamNames(source);
|
|
21
|
+
}
|
|
22
|
+
/** Reorders a named-object args record into a positional tuple. */
|
|
23
|
+
export function reorderNamedArgs(named, paramNames) {
|
|
24
|
+
const missing = paramNames.filter((n) => !(n in named));
|
|
25
|
+
if (missing.length > 0) {
|
|
26
|
+
throw new ConfigError(`args object is missing constructor parameter(s): ${missing.join(', ')}`);
|
|
27
|
+
}
|
|
28
|
+
const extra = Object.keys(named).filter((k) => !paramNames.includes(k));
|
|
29
|
+
if (extra.length > 0) {
|
|
30
|
+
throw new ConfigError(`args object has unknown constructor parameter(s): ${extra.join(', ')}. Expected: ${paramNames.join(', ')}`);
|
|
31
|
+
}
|
|
32
|
+
return paramNames.map((n) => named[n]);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Pulls the constructor parameter names out of a Compact artifact's
|
|
36
|
+
* `index.d.ts`. The trailing `_<digits>` SSA suffix is stripped; if
|
|
37
|
+
* stripping causes a collision in the same constructor, the original
|
|
38
|
+
* names are kept.
|
|
39
|
+
*/
|
|
40
|
+
export function parseConstructorParamNames(dtsSource) {
|
|
41
|
+
const block = sliceInitialStateParams(dtsSource);
|
|
42
|
+
if (block === null)
|
|
43
|
+
return [];
|
|
44
|
+
const params = splitTopLevelParams(block).slice(1); // drop `context: ...`
|
|
45
|
+
if (params.length === 0)
|
|
46
|
+
return [];
|
|
47
|
+
const names = params.map(extractParamName);
|
|
48
|
+
const stripped = names.map(stripSsaSuffix);
|
|
49
|
+
return new Set(stripped).size === stripped.length ? stripped : names;
|
|
50
|
+
}
|
|
51
|
+
function sliceInitialStateParams(source) {
|
|
52
|
+
const head = source.indexOf('initialState(');
|
|
53
|
+
if (head === -1)
|
|
54
|
+
return null;
|
|
55
|
+
const open = head + 'initialState('.length;
|
|
56
|
+
let depth = 1;
|
|
57
|
+
for (let i = open; i < source.length; i++) {
|
|
58
|
+
const ch = source[i];
|
|
59
|
+
if (ch === '(')
|
|
60
|
+
depth++;
|
|
61
|
+
else if (ch === ')') {
|
|
62
|
+
depth--;
|
|
63
|
+
if (depth === 0)
|
|
64
|
+
return source.slice(open, i);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
function splitTopLevelParams(block) {
|
|
70
|
+
const out = [];
|
|
71
|
+
let depth = 0;
|
|
72
|
+
let start = 0;
|
|
73
|
+
for (let i = 0; i < block.length; i++) {
|
|
74
|
+
const ch = block[i];
|
|
75
|
+
if (ch === '<' || ch === '(' || ch === '[' || ch === '{')
|
|
76
|
+
depth++;
|
|
77
|
+
else if (ch === '>' || ch === ')' || ch === ']' || ch === '}')
|
|
78
|
+
depth--;
|
|
79
|
+
else if (ch === ',' && depth === 0) {
|
|
80
|
+
out.push(block.slice(start, i).trim());
|
|
81
|
+
start = i + 1;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const tail = block.slice(start).trim();
|
|
85
|
+
if (tail.length > 0)
|
|
86
|
+
out.push(tail);
|
|
87
|
+
return out;
|
|
88
|
+
}
|
|
89
|
+
function extractParamName(raw) {
|
|
90
|
+
const colon = raw.indexOf(':');
|
|
91
|
+
if (colon === -1) {
|
|
92
|
+
throw new ConfigError(`Cannot parse constructor param: "${raw}"`);
|
|
93
|
+
}
|
|
94
|
+
return raw.slice(0, colon).trim();
|
|
95
|
+
}
|
|
96
|
+
function stripSsaSuffix(name) {
|
|
97
|
+
return name.replace(/_\d+$/, '');
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=constructor-meta.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constructor-meta.js","sourceRoot":"","sources":["../../src/loaders/constructor-meta.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAElE;;;;;;GAMG;AACH,MAAM,UAAU,yBAAyB,CAAC,YAAoB;IAC5D,MAAM,OAAO,GAAG,IAAI,CAAC,YAAY,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;IAC7D,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,qBAAqB,CAC7B,GAAG,YAAY,uDAAu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CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Per-call I/O bundle for loaders. Centralises the `ConfigError`-wrapping boilerplate. */
|
|
2
|
+
export declare class LoaderContext {
|
|
3
|
+
readonly rootDir: string;
|
|
4
|
+
constructor(rootDir: string);
|
|
5
|
+
abs(p: string): string;
|
|
6
|
+
readText(p: string, label: string): Promise<{
|
|
7
|
+
text: string;
|
|
8
|
+
path: string;
|
|
9
|
+
}>;
|
|
10
|
+
importModule(p: string, label: string): Promise<{
|
|
11
|
+
mod: Record<string, unknown>;
|
|
12
|
+
path: string;
|
|
13
|
+
}>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExtension) || function (path, preserveJsx) {
|
|
2
|
+
if (typeof path === "string" && /^\.\.?\//.test(path)) {
|
|
3
|
+
return path.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i, function (m, tsx, d, ext, cm) {
|
|
4
|
+
return tsx ? preserveJsx ? ".jsx" : ".js" : d && (!ext || !cm) ? m : (d + ext + "." + cm.toLowerCase() + "js");
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
return path;
|
|
8
|
+
};
|
|
9
|
+
import { readFile } from 'node:fs/promises';
|
|
10
|
+
import { isAbsolute, resolve } from 'node:path';
|
|
11
|
+
import { pathToFileURL } from 'node:url';
|
|
12
|
+
import { ConfigError } from "../errors.js";
|
|
13
|
+
/** Per-call I/O bundle for loaders. Centralises the `ConfigError`-wrapping boilerplate. */
|
|
14
|
+
export class LoaderContext {
|
|
15
|
+
rootDir;
|
|
16
|
+
constructor(rootDir) {
|
|
17
|
+
this.rootDir = rootDir;
|
|
18
|
+
}
|
|
19
|
+
abs(p) {
|
|
20
|
+
return isAbsolute(p) ? p : resolve(this.rootDir, p);
|
|
21
|
+
}
|
|
22
|
+
async readText(p, label) {
|
|
23
|
+
const path = this.abs(p);
|
|
24
|
+
try {
|
|
25
|
+
const text = await readFile(path, 'utf8');
|
|
26
|
+
return { text, path };
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
throw new ConfigError(`${label}: failed to read ${path}: ${e.message}`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async importModule(p, label) {
|
|
33
|
+
const path = this.abs(p);
|
|
34
|
+
try {
|
|
35
|
+
const mod = (await import(__rewriteRelativeImportExtension(pathToFileURL(path).href)));
|
|
36
|
+
return { mod, path };
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
throw new ConfigError(`${label}: failed to import ${path}: ${e.message}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/loaders/context.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,2FAA2F;AAC3F,MAAM,OAAO,aAAa;IACf,OAAO,CAAS;IAEzB,YAAY,OAAe;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,GAAG,CAAC,CAAS;QACX,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,QAAQ,CACZ,CAAS,EACT,KAAa;QAEb,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACzB,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAC1C,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;QACxB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,IAAI,WAAW,CACnB,GAAG,KAAK,oBAAoB,IAAI,KAAM,CAAW,CAAC,OAAO,EAAE,CAC5D,CAAC;QACJ,CAAC;IACH,CAAC;IAED,KAAK,CAAC,YAAY,CAChB,CAAS,EACT,KAAa;QAEb,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACzB,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,CAAC,MAAM,MAAM,kCAAC,aAAa,CAAC,IAAI,CAAC,CAAC,IAAI,EAAC,CAGlD,CAAC;YACF,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;QACvB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,IAAI,WAAW,CACnB,GAAG,KAAK,sBAAsB,IAAI,KAAM,CAAW,CAAC,OAAO,EAAE,CAC9D,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CompactConfig } from '../config/compact-config.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Walks `compact.toml`'s `[contracts.X]` entries and returns the name
|
|
4
|
+
* whose compiled `Contract` class is identity-equal to the one
|
|
5
|
+
* imported by the caller's deploy script. Used by the curried
|
|
6
|
+
* `runDeploy(Contract)(...)` form so the deploy script names the
|
|
7
|
+
* contract once.
|
|
8
|
+
*
|
|
9
|
+
* Throws when:
|
|
10
|
+
* - no entry resolves to the same Contract class (the script likely
|
|
11
|
+
* imported from a path that isn't referenced by `compact.toml`)
|
|
12
|
+
* - two entries match (ambiguous — likely two TOML entries pointing
|
|
13
|
+
* at the same artifact directory).
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolveContractName(Contract: unknown, config: CompactConfig, rootDir: string): Promise<string>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { ConfigError } from "../errors.js";
|
|
2
|
+
import { findArtifactEntry, resolveUnderRoot } from "./artifact-path.js";
|
|
3
|
+
import { LoaderContext } from "./context.js";
|
|
4
|
+
/**
|
|
5
|
+
* Walks `compact.toml`'s `[contracts.X]` entries and returns the name
|
|
6
|
+
* whose compiled `Contract` class is identity-equal to the one
|
|
7
|
+
* imported by the caller's deploy script. Used by the curried
|
|
8
|
+
* `runDeploy(Contract)(...)` form so the deploy script names the
|
|
9
|
+
* contract once.
|
|
10
|
+
*
|
|
11
|
+
* Throws when:
|
|
12
|
+
* - no entry resolves to the same Contract class (the script likely
|
|
13
|
+
* imported from a path that isn't referenced by `compact.toml`)
|
|
14
|
+
* - two entries match (ambiguous — likely two TOML entries pointing
|
|
15
|
+
* at the same artifact directory).
|
|
16
|
+
*/
|
|
17
|
+
export async function resolveContractName(Contract, config, rootDir) {
|
|
18
|
+
const ctx = new LoaderContext(rootDir);
|
|
19
|
+
const matches = [];
|
|
20
|
+
const tried = [];
|
|
21
|
+
for (const name of config.listContracts()) {
|
|
22
|
+
const cfg = config.contract(name);
|
|
23
|
+
const entry = findArtifactEntry(resolveUnderRoot(rootDir, cfg.artifact, config.artifactsDir));
|
|
24
|
+
if (!entry) {
|
|
25
|
+
tried.push({
|
|
26
|
+
name,
|
|
27
|
+
reason: `no contract/index.{cjs,js} or index.{cjs,js} under ${cfg.artifact}`,
|
|
28
|
+
});
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
const { mod } = await ctx.importModule(entry, 'artifact');
|
|
33
|
+
const Loaded = mod.Contract ??
|
|
34
|
+
mod.default?.Contract;
|
|
35
|
+
if (Loaded === Contract) {
|
|
36
|
+
matches.push(name);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
tried.push({ name, reason: e.message });
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (matches.length === 1)
|
|
44
|
+
return matches[0];
|
|
45
|
+
if (matches.length > 1) {
|
|
46
|
+
throw new ConfigError(`Ambiguous Contract: matches ${matches.length} entries in compact.toml (${matches.join(', ')}). Use the string form: runDeploy({ contract: 'X' }).`);
|
|
47
|
+
}
|
|
48
|
+
const tail = tried.length > 0
|
|
49
|
+
? `\nSkipped: ${tried.map((t) => `${t.name} (${t.reason})`).join('; ')}`
|
|
50
|
+
: '';
|
|
51
|
+
throw new ConfigError(`Contract class did not match any [contracts.X] entry in compact.toml. Make sure the import path resolves to the same artifact directory referenced by the TOML.${tail}`);
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=contract-resolve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contract-resolve.js","sourceRoot":"","sources":["../../src/loaders/contract-resolve.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,QAAiB,EACjB,MAAqB,EACrB,OAAe;IAEf,MAAM,GAAG,GAAG,IAAI,aAAa,CAAC,OAAO,CAAC,CAAC;IACvC,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,MAAM,KAAK,GAA4C,EAAE,CAAC;IAE1D,KAAK,MAAM,IAAI,IAAI,MAAM,CAAC,aAAa,EAAE,EAAE,CAAC;QAC1C,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAClC,MAAM,KAAK,GAAG,iBAAiB,CAC7B,gBAAgB,CAAC,OAAO,EAAE,GAAG,CAAC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AAW,CACnB,kKAAkK,IAAI,EAAE,CACzK,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { FileOrModuleRef } from '../config/schema.ts';
|
|
2
|
+
/** Initial private state for the contract constructor. `load` returns `undefined` when omitted in TOML. */
|
|
3
|
+
export declare class InitialPrivateState {
|
|
4
|
+
readonly value: unknown;
|
|
5
|
+
private constructor();
|
|
6
|
+
/** Source: `{ file }` (JSON with `"123n"` bigint strings) or `{ module, export }` (value or zero-arg function). */
|
|
7
|
+
static load(ref: FileOrModuleRef | undefined, rootDir: string): Promise<InitialPrivateState | undefined>;
|
|
8
|
+
}
|