@caatinga/core 2.3.0 → 2.3.1
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/dist/index.cjs +133 -2
- package/dist/index.d.cts +19 -9
- package/dist/index.d.ts +19 -9
- package/dist/index.js +131 -2
- package/package.json +2 -1
- package/scaffolds/zk-circuit-stub/input.json +3 -0
- package/scaffolds/zk-circuit-stub/main.circom +9 -0
- package/scaffolds/zk-verifier/Cargo.lock +1880 -0
- package/scaffolds/zk-verifier/Cargo.toml +27 -0
- package/scaffolds/zk-verifier/src/lib.rs +64 -0
- package/scaffolds/zk-verifier/src/test.rs +100 -0
package/dist/index.cjs
CHANGED
|
@@ -48,6 +48,7 @@ __export(index_exports, {
|
|
|
48
48
|
collectProjectStatus: () => collectProjectStatus,
|
|
49
49
|
createInitialArtifacts: () => createInitialArtifacts,
|
|
50
50
|
createProjectFromTemplate: () => createProjectFromTemplate,
|
|
51
|
+
createZkProject: () => createZkProject,
|
|
51
52
|
defineConfig: () => defineConfig,
|
|
52
53
|
deployContract: () => deployContract,
|
|
53
54
|
deployContractGraph: () => deployContractGraph,
|
|
@@ -186,7 +187,7 @@ function formatCause(cause) {
|
|
|
186
187
|
}
|
|
187
188
|
|
|
188
189
|
// src/version.ts
|
|
189
|
-
var CAATINGA_CORE_VERSION = "2.3.
|
|
190
|
+
var CAATINGA_CORE_VERSION = "2.3.1";
|
|
190
191
|
|
|
191
192
|
// src/config/config.schema.ts
|
|
192
193
|
var import_zod = require("zod");
|
|
@@ -224,7 +225,7 @@ var CaatingaConfigSchema = import_zod.z.object({
|
|
|
224
225
|
frontend: import_zod.z.object({
|
|
225
226
|
framework: import_zod.z.enum(["vite-react", "next", "astro"]).default("vite-react"),
|
|
226
227
|
bindingsOutput: import_zod.z.string().min(1)
|
|
227
|
-
}),
|
|
228
|
+
}).optional(),
|
|
228
229
|
zk: ZkConfigSchema
|
|
229
230
|
});
|
|
230
231
|
|
|
@@ -423,6 +424,15 @@ async function listGeneratedEntries(outputDir) {
|
|
|
423
424
|
}
|
|
424
425
|
async function evaluateBindingFreshness(options) {
|
|
425
426
|
const cwd = options.cwd ?? process.cwd();
|
|
427
|
+
if (!options.config.frontend) {
|
|
428
|
+
return {
|
|
429
|
+
contractName: options.contractName,
|
|
430
|
+
status: "unknown",
|
|
431
|
+
outputDir: "",
|
|
432
|
+
marker: null,
|
|
433
|
+
reason: "frontend bindings are not configured"
|
|
434
|
+
};
|
|
435
|
+
}
|
|
426
436
|
const outputDir = import_node_path5.default.resolve(cwd, options.config.frontend.bindingsOutput, options.contractName);
|
|
427
437
|
const contractArtifact = options.artifacts.networks[options.networkName]?.contracts[options.contractName];
|
|
428
438
|
if (!contractArtifact) {
|
|
@@ -1441,6 +1451,13 @@ async function removeLegacyBindingStub(cwd, bindingsOutput, contractName) {
|
|
|
1441
1451
|
}
|
|
1442
1452
|
async function generateBindings(options) {
|
|
1443
1453
|
const cwd = options.cwd ?? process.cwd();
|
|
1454
|
+
if (!options.config.frontend) {
|
|
1455
|
+
throw new CaatingaError(
|
|
1456
|
+
"Frontend bindings are not configured.",
|
|
1457
|
+
CaatingaErrorCode.INVALID_CONFIG,
|
|
1458
|
+
"Add a frontend.bindingsOutput entry to caatinga.config.ts before running caatinga generate."
|
|
1459
|
+
);
|
|
1460
|
+
}
|
|
1444
1461
|
const network = resolveNetwork(options.config, options.networkName);
|
|
1445
1462
|
const artifacts = await readArtifacts(cwd);
|
|
1446
1463
|
const contractArtifact = artifacts.networks[network.name]?.contracts[options.contractName];
|
|
@@ -1788,6 +1805,119 @@ function isTextTemplateFile(filePath) {
|
|
|
1788
1805
|
].includes(import_node_path10.default.extname(filePath));
|
|
1789
1806
|
}
|
|
1790
1807
|
|
|
1808
|
+
// src/scaffold/create-zk-project.ts
|
|
1809
|
+
var import_promises9 = require("fs/promises");
|
|
1810
|
+
var import_node_fs = require("fs");
|
|
1811
|
+
var import_node_path11 = __toESM(require("path"), 1);
|
|
1812
|
+
var import_node_url = require("url");
|
|
1813
|
+
var import_meta2 = {};
|
|
1814
|
+
var moduleDir = typeof __dirname === "string" ? __dirname : import_node_path11.default.dirname((0, import_node_url.fileURLToPath)(import_meta2.url));
|
|
1815
|
+
function scaffoldRoot() {
|
|
1816
|
+
const candidates = [
|
|
1817
|
+
import_node_path11.default.resolve(moduleDir, "../../scaffolds"),
|
|
1818
|
+
import_node_path11.default.resolve(moduleDir, "../scaffolds")
|
|
1819
|
+
];
|
|
1820
|
+
const found = candidates.find((candidate) => (0, import_node_fs.existsSync)(candidate));
|
|
1821
|
+
return found ?? candidates[0];
|
|
1822
|
+
}
|
|
1823
|
+
function configSource(projectName) {
|
|
1824
|
+
return `import { defineConfig } from "@caatinga/core";
|
|
1825
|
+
|
|
1826
|
+
export default defineConfig({
|
|
1827
|
+
project: "${projectName}",
|
|
1828
|
+
defaultNetwork: "testnet",
|
|
1829
|
+
contracts: {
|
|
1830
|
+
verifier: {
|
|
1831
|
+
path: "./contracts/verifier",
|
|
1832
|
+
wasm: "./contracts/verifier/target/wasm32v1-none/release/verifier.wasm"
|
|
1833
|
+
}
|
|
1834
|
+
},
|
|
1835
|
+
networks: {
|
|
1836
|
+
testnet: {
|
|
1837
|
+
rpcUrl: "https://soroban-testnet.stellar.org",
|
|
1838
|
+
networkPassphrase: "Test SDF Network ; September 2015"
|
|
1839
|
+
}
|
|
1840
|
+
},
|
|
1841
|
+
zk: {
|
|
1842
|
+
circuits: {
|
|
1843
|
+
main: {
|
|
1844
|
+
path: "./circuits",
|
|
1845
|
+
protocol: "groth16",
|
|
1846
|
+
curve: "bls12381",
|
|
1847
|
+
verifierContract: "verifier"
|
|
1848
|
+
}
|
|
1849
|
+
}
|
|
1850
|
+
}
|
|
1851
|
+
});
|
|
1852
|
+
`;
|
|
1853
|
+
}
|
|
1854
|
+
function packageJsonSource(projectName) {
|
|
1855
|
+
return `${JSON.stringify({
|
|
1856
|
+
name: projectName,
|
|
1857
|
+
version: "0.1.0",
|
|
1858
|
+
private: true,
|
|
1859
|
+
type: "module",
|
|
1860
|
+
scripts: {
|
|
1861
|
+
"zk:build": "caatinga zk build main",
|
|
1862
|
+
"zk:prove": "caatinga zk prove main",
|
|
1863
|
+
build: "caatinga build verifier",
|
|
1864
|
+
deploy: "caatinga deploy verifier"
|
|
1865
|
+
},
|
|
1866
|
+
devDependencies: {
|
|
1867
|
+
"@caatinga/cli": `^${CAATINGA_CORE_VERSION}`,
|
|
1868
|
+
"@caatinga/core": `^${CAATINGA_CORE_VERSION}`
|
|
1869
|
+
}
|
|
1870
|
+
}, null, 2)}
|
|
1871
|
+
`;
|
|
1872
|
+
}
|
|
1873
|
+
function readmeSource(projectName) {
|
|
1874
|
+
return `# ${projectName}
|
|
1875
|
+
|
|
1876
|
+
Minimal Caatinga ZK project.
|
|
1877
|
+
|
|
1878
|
+
## Workflow
|
|
1879
|
+
|
|
1880
|
+
\`\`\`bash
|
|
1881
|
+
npm install
|
|
1882
|
+
npx caatinga zk build main
|
|
1883
|
+
npx caatinga build verifier
|
|
1884
|
+
npx caatinga deploy verifier --network testnet
|
|
1885
|
+
npx caatinga zk prove main
|
|
1886
|
+
\`\`\`
|
|
1887
|
+
|
|
1888
|
+
Replace \`circuits/main.circom\` with your circuit. Keep the entry point named \`main\`.
|
|
1889
|
+
`;
|
|
1890
|
+
}
|
|
1891
|
+
async function createZkProject(options) {
|
|
1892
|
+
const targetDir = import_node_path11.default.resolve(options.targetDir);
|
|
1893
|
+
const force = options.force ?? false;
|
|
1894
|
+
const projectFiles = options.projectFiles ?? true;
|
|
1895
|
+
await (0, import_promises9.mkdir)(targetDir, { recursive: true });
|
|
1896
|
+
if (projectFiles) {
|
|
1897
|
+
await Promise.all([
|
|
1898
|
+
(0, import_promises9.writeFile)(import_node_path11.default.join(targetDir, "caatinga.config.ts"), configSource(options.projectName), { encoding: "utf8", flag: force ? "w" : "wx" }),
|
|
1899
|
+
(0, import_promises9.writeFile)(import_node_path11.default.join(targetDir, "package.json"), packageJsonSource(options.projectName), { encoding: "utf8", flag: force ? "w" : "wx" }),
|
|
1900
|
+
(0, import_promises9.writeFile)(import_node_path11.default.join(targetDir, ".gitignore"), "node_modules\n.artifacts\ntarget\n", { encoding: "utf8", flag: force ? "w" : "wx" }),
|
|
1901
|
+
(0, import_promises9.writeFile)(import_node_path11.default.join(targetDir, "README.md"), readmeSource(options.projectName), { encoding: "utf8", flag: force ? "w" : "wx" })
|
|
1902
|
+
]);
|
|
1903
|
+
}
|
|
1904
|
+
await (0, import_promises9.mkdir)(import_node_path11.default.join(targetDir, "contracts"), { recursive: true });
|
|
1905
|
+
await (0, import_promises9.cp)(import_node_path11.default.join(scaffoldRoot(), "zk-circuit-stub"), import_node_path11.default.join(targetDir, "circuits"), {
|
|
1906
|
+
recursive: true,
|
|
1907
|
+
force,
|
|
1908
|
+
errorOnExist: !force
|
|
1909
|
+
});
|
|
1910
|
+
await (0, import_promises9.cp)(import_node_path11.default.join(scaffoldRoot(), "zk-verifier"), import_node_path11.default.join(targetDir, "contracts", "verifier"), {
|
|
1911
|
+
recursive: true,
|
|
1912
|
+
force,
|
|
1913
|
+
errorOnExist: !force
|
|
1914
|
+
});
|
|
1915
|
+
if (projectFiles) {
|
|
1916
|
+
await writeArtifacts(createInitialArtifacts(options.projectName, { networks: ["testnet"] }), targetDir);
|
|
1917
|
+
}
|
|
1918
|
+
return { targetDir };
|
|
1919
|
+
}
|
|
1920
|
+
|
|
1791
1921
|
// src/ci/is-transient-testnet-smoke-failure.ts
|
|
1792
1922
|
var NO_RETRY_CAATINGA_SUBSTRINGS = [
|
|
1793
1923
|
"CAATINGA_UNSUPPORTED_CLI_VERSION",
|
|
@@ -1828,6 +1958,7 @@ function isTransientTestnetSmokeFailure(logText) {
|
|
|
1828
1958
|
collectProjectStatus,
|
|
1829
1959
|
createInitialArtifacts,
|
|
1830
1960
|
createProjectFromTemplate,
|
|
1961
|
+
createZkProject,
|
|
1831
1962
|
defineConfig,
|
|
1832
1963
|
deployContract,
|
|
1833
1964
|
deployContractGraph,
|
package/dist/index.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ import { C as CaatingaArtifacts, a as ContractArtifact, b as CaatingaErrorCodeVa
|
|
|
2
2
|
export { d as CaatingaArtifactsSchema, e as CaatingaErrorCode, f as formatCaatingaError, t as toCaatingaError } from './browser-Cq4ZofIq.cjs';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
-
declare const CAATINGA_CORE_VERSION = "2.3.
|
|
5
|
+
declare const CAATINGA_CORE_VERSION = "2.3.1";
|
|
6
6
|
|
|
7
7
|
declare const ContractConfigSchema: z.ZodObject<{
|
|
8
8
|
path: z.ZodString;
|
|
@@ -75,7 +75,7 @@ declare const CaatingaConfigSchema: z.ZodObject<{
|
|
|
75
75
|
rpcUrl: string;
|
|
76
76
|
networkPassphrase: string;
|
|
77
77
|
}>>;
|
|
78
|
-
frontend: z.ZodObject<{
|
|
78
|
+
frontend: z.ZodOptional<z.ZodObject<{
|
|
79
79
|
framework: z.ZodDefault<z.ZodEnum<["vite-react", "next", "astro"]>>;
|
|
80
80
|
bindingsOutput: z.ZodString;
|
|
81
81
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -84,7 +84,7 @@ declare const CaatingaConfigSchema: z.ZodObject<{
|
|
|
84
84
|
}, {
|
|
85
85
|
bindingsOutput: string;
|
|
86
86
|
framework?: "vite-react" | "next" | "astro" | undefined;
|
|
87
|
-
}
|
|
87
|
+
}>>;
|
|
88
88
|
zk: z.ZodOptional<z.ZodObject<{
|
|
89
89
|
circuits: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
90
90
|
path: z.ZodString;
|
|
@@ -130,10 +130,10 @@ declare const CaatingaConfigSchema: z.ZodObject<{
|
|
|
130
130
|
rpcUrl: string;
|
|
131
131
|
networkPassphrase: string;
|
|
132
132
|
}>;
|
|
133
|
-
frontend
|
|
133
|
+
frontend?: {
|
|
134
134
|
framework: "vite-react" | "next" | "astro";
|
|
135
135
|
bindingsOutput: string;
|
|
136
|
-
};
|
|
136
|
+
} | undefined;
|
|
137
137
|
zk?: {
|
|
138
138
|
circuits: Record<string, {
|
|
139
139
|
path: string;
|
|
@@ -154,11 +154,11 @@ declare const CaatingaConfigSchema: z.ZodObject<{
|
|
|
154
154
|
rpcUrl: string;
|
|
155
155
|
networkPassphrase: string;
|
|
156
156
|
}>;
|
|
157
|
-
|
|
157
|
+
defaultNetwork?: string | undefined;
|
|
158
|
+
frontend?: {
|
|
158
159
|
bindingsOutput: string;
|
|
159
160
|
framework?: "vite-react" | "next" | "astro" | undefined;
|
|
160
|
-
};
|
|
161
|
-
defaultNetwork?: string | undefined;
|
|
161
|
+
} | undefined;
|
|
162
162
|
zk?: {
|
|
163
163
|
circuits: Record<string, {
|
|
164
164
|
path: string;
|
|
@@ -522,6 +522,16 @@ declare function createProjectFromTemplate(options: CreateProjectFromTemplateOpt
|
|
|
522
522
|
};
|
|
523
523
|
}>;
|
|
524
524
|
|
|
525
|
+
type CreateZkProjectOptions = {
|
|
526
|
+
projectName: string;
|
|
527
|
+
targetDir: string;
|
|
528
|
+
force?: boolean;
|
|
529
|
+
projectFiles?: boolean;
|
|
530
|
+
};
|
|
531
|
+
declare function createZkProject(options: CreateZkProjectOptions): Promise<{
|
|
532
|
+
targetDir: string;
|
|
533
|
+
}>;
|
|
534
|
+
|
|
525
535
|
declare const TemplateManifestSchema: z.ZodObject<{
|
|
526
536
|
name: z.ZodString;
|
|
527
537
|
version: z.ZodString;
|
|
@@ -611,4 +621,4 @@ type TemplateManifest = z.infer<typeof TemplateManifestSchema>;
|
|
|
611
621
|
|
|
612
622
|
declare function isTransientTestnetSmokeFailure(logText: string): boolean;
|
|
613
623
|
|
|
614
|
-
export { BINDING_MARKER_FILENAME, type BindingFreshness, type BindingFreshnessStatus, type BindingMarker, BindingMarkerSchema, type BuildContractOptions, CAATINGA_CORE_VERSION, CaatingaArtifacts, type CaatingaConfig, CaatingaConfigSchema, CaatingaError, type CheckStellarCliVersionOptions, type CollectProjectStatusOptions, type CompatibilityReport, type CompatibilityStatus, type CompatibilityWarning, type CompatibilityWarningCode, ContractArtifact, type ContractConfig, type ContractStatusEntry, type CreateInitialArtifactsOptions, type CreateProjectFromTemplateOptions, type DeployArgValue, type DeployContractGraphResult, type DeployContractOptions, type EvaluateBindingFreshnessOptions, type EvaluateStellarCliCompatibilityInput, type GenerateBindingsGraphResult, type GenerateBindingsOptions, type InvokeContractOptions, type InvokeTarget, type LoadConfigOptions, type NetworkConfig, type NetworkStatus, type ProjectStatus, type ResolvedContract, type ResolvedNetwork, type RunCommandResult, STELLAR_CLI_LAST_TESTED_VERSION, STELLAR_CLI_MIN_VERSION, type SkippedContract, type TemplateManifest, TemplateManifestSchema, WELL_KNOWN_NETWORKS, buildContract, buildDependencyGraph, checkBinary, checkStellarCliVersion, collectProjectStatus, createInitialArtifacts, createProjectFromTemplate, defineConfig, deployContract, deployContractGraph, evaluateBindingFreshness, evaluateBindingsFreshness, evaluateStellarCliCompatibility, generateBindings, generateBindingsGraph, invokeContract, isTransientTestnetSmokeFailure, loadConfig, parseContractId, parseInvokeTarget, parseStellarCliVersion, readArtifacts, readBindingMarker, resolveContract, resolveDefaultContractName, resolveDeployArgs, resolveDeployOrder, resolveNetwork, runCommand, updateArtifact, validateSourceShape, writeArtifacts, writeBindingMarker };
|
|
624
|
+
export { BINDING_MARKER_FILENAME, type BindingFreshness, type BindingFreshnessStatus, type BindingMarker, BindingMarkerSchema, type BuildContractOptions, CAATINGA_CORE_VERSION, CaatingaArtifacts, type CaatingaConfig, CaatingaConfigSchema, CaatingaError, type CheckStellarCliVersionOptions, type CollectProjectStatusOptions, type CompatibilityReport, type CompatibilityStatus, type CompatibilityWarning, type CompatibilityWarningCode, ContractArtifact, type ContractConfig, type ContractStatusEntry, type CreateInitialArtifactsOptions, type CreateProjectFromTemplateOptions, type CreateZkProjectOptions, type DeployArgValue, type DeployContractGraphResult, type DeployContractOptions, type EvaluateBindingFreshnessOptions, type EvaluateStellarCliCompatibilityInput, type GenerateBindingsGraphResult, type GenerateBindingsOptions, type InvokeContractOptions, type InvokeTarget, type LoadConfigOptions, type NetworkConfig, type NetworkStatus, type ProjectStatus, type ResolvedContract, type ResolvedNetwork, type RunCommandResult, STELLAR_CLI_LAST_TESTED_VERSION, STELLAR_CLI_MIN_VERSION, type SkippedContract, type TemplateManifest, TemplateManifestSchema, WELL_KNOWN_NETWORKS, buildContract, buildDependencyGraph, checkBinary, checkStellarCliVersion, collectProjectStatus, createInitialArtifacts, createProjectFromTemplate, createZkProject, defineConfig, deployContract, deployContractGraph, evaluateBindingFreshness, evaluateBindingsFreshness, evaluateStellarCliCompatibility, generateBindings, generateBindingsGraph, invokeContract, isTransientTestnetSmokeFailure, loadConfig, parseContractId, parseInvokeTarget, parseStellarCliVersion, readArtifacts, readBindingMarker, resolveContract, resolveDefaultContractName, resolveDeployArgs, resolveDeployOrder, resolveNetwork, runCommand, updateArtifact, validateSourceShape, writeArtifacts, writeBindingMarker };
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { C as CaatingaArtifacts, a as ContractArtifact, b as CaatingaErrorCodeVa
|
|
|
2
2
|
export { d as CaatingaArtifactsSchema, e as CaatingaErrorCode, f as formatCaatingaError, t as toCaatingaError } from './browser-Cq4ZofIq.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
-
declare const CAATINGA_CORE_VERSION = "2.3.
|
|
5
|
+
declare const CAATINGA_CORE_VERSION = "2.3.1";
|
|
6
6
|
|
|
7
7
|
declare const ContractConfigSchema: z.ZodObject<{
|
|
8
8
|
path: z.ZodString;
|
|
@@ -75,7 +75,7 @@ declare const CaatingaConfigSchema: z.ZodObject<{
|
|
|
75
75
|
rpcUrl: string;
|
|
76
76
|
networkPassphrase: string;
|
|
77
77
|
}>>;
|
|
78
|
-
frontend: z.ZodObject<{
|
|
78
|
+
frontend: z.ZodOptional<z.ZodObject<{
|
|
79
79
|
framework: z.ZodDefault<z.ZodEnum<["vite-react", "next", "astro"]>>;
|
|
80
80
|
bindingsOutput: z.ZodString;
|
|
81
81
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -84,7 +84,7 @@ declare const CaatingaConfigSchema: z.ZodObject<{
|
|
|
84
84
|
}, {
|
|
85
85
|
bindingsOutput: string;
|
|
86
86
|
framework?: "vite-react" | "next" | "astro" | undefined;
|
|
87
|
-
}
|
|
87
|
+
}>>;
|
|
88
88
|
zk: z.ZodOptional<z.ZodObject<{
|
|
89
89
|
circuits: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
90
90
|
path: z.ZodString;
|
|
@@ -130,10 +130,10 @@ declare const CaatingaConfigSchema: z.ZodObject<{
|
|
|
130
130
|
rpcUrl: string;
|
|
131
131
|
networkPassphrase: string;
|
|
132
132
|
}>;
|
|
133
|
-
frontend
|
|
133
|
+
frontend?: {
|
|
134
134
|
framework: "vite-react" | "next" | "astro";
|
|
135
135
|
bindingsOutput: string;
|
|
136
|
-
};
|
|
136
|
+
} | undefined;
|
|
137
137
|
zk?: {
|
|
138
138
|
circuits: Record<string, {
|
|
139
139
|
path: string;
|
|
@@ -154,11 +154,11 @@ declare const CaatingaConfigSchema: z.ZodObject<{
|
|
|
154
154
|
rpcUrl: string;
|
|
155
155
|
networkPassphrase: string;
|
|
156
156
|
}>;
|
|
157
|
-
|
|
157
|
+
defaultNetwork?: string | undefined;
|
|
158
|
+
frontend?: {
|
|
158
159
|
bindingsOutput: string;
|
|
159
160
|
framework?: "vite-react" | "next" | "astro" | undefined;
|
|
160
|
-
};
|
|
161
|
-
defaultNetwork?: string | undefined;
|
|
161
|
+
} | undefined;
|
|
162
162
|
zk?: {
|
|
163
163
|
circuits: Record<string, {
|
|
164
164
|
path: string;
|
|
@@ -522,6 +522,16 @@ declare function createProjectFromTemplate(options: CreateProjectFromTemplateOpt
|
|
|
522
522
|
};
|
|
523
523
|
}>;
|
|
524
524
|
|
|
525
|
+
type CreateZkProjectOptions = {
|
|
526
|
+
projectName: string;
|
|
527
|
+
targetDir: string;
|
|
528
|
+
force?: boolean;
|
|
529
|
+
projectFiles?: boolean;
|
|
530
|
+
};
|
|
531
|
+
declare function createZkProject(options: CreateZkProjectOptions): Promise<{
|
|
532
|
+
targetDir: string;
|
|
533
|
+
}>;
|
|
534
|
+
|
|
525
535
|
declare const TemplateManifestSchema: z.ZodObject<{
|
|
526
536
|
name: z.ZodString;
|
|
527
537
|
version: z.ZodString;
|
|
@@ -611,4 +621,4 @@ type TemplateManifest = z.infer<typeof TemplateManifestSchema>;
|
|
|
611
621
|
|
|
612
622
|
declare function isTransientTestnetSmokeFailure(logText: string): boolean;
|
|
613
623
|
|
|
614
|
-
export { BINDING_MARKER_FILENAME, type BindingFreshness, type BindingFreshnessStatus, type BindingMarker, BindingMarkerSchema, type BuildContractOptions, CAATINGA_CORE_VERSION, CaatingaArtifacts, type CaatingaConfig, CaatingaConfigSchema, CaatingaError, type CheckStellarCliVersionOptions, type CollectProjectStatusOptions, type CompatibilityReport, type CompatibilityStatus, type CompatibilityWarning, type CompatibilityWarningCode, ContractArtifact, type ContractConfig, type ContractStatusEntry, type CreateInitialArtifactsOptions, type CreateProjectFromTemplateOptions, type DeployArgValue, type DeployContractGraphResult, type DeployContractOptions, type EvaluateBindingFreshnessOptions, type EvaluateStellarCliCompatibilityInput, type GenerateBindingsGraphResult, type GenerateBindingsOptions, type InvokeContractOptions, type InvokeTarget, type LoadConfigOptions, type NetworkConfig, type NetworkStatus, type ProjectStatus, type ResolvedContract, type ResolvedNetwork, type RunCommandResult, STELLAR_CLI_LAST_TESTED_VERSION, STELLAR_CLI_MIN_VERSION, type SkippedContract, type TemplateManifest, TemplateManifestSchema, WELL_KNOWN_NETWORKS, buildContract, buildDependencyGraph, checkBinary, checkStellarCliVersion, collectProjectStatus, createInitialArtifacts, createProjectFromTemplate, defineConfig, deployContract, deployContractGraph, evaluateBindingFreshness, evaluateBindingsFreshness, evaluateStellarCliCompatibility, generateBindings, generateBindingsGraph, invokeContract, isTransientTestnetSmokeFailure, loadConfig, parseContractId, parseInvokeTarget, parseStellarCliVersion, readArtifacts, readBindingMarker, resolveContract, resolveDefaultContractName, resolveDeployArgs, resolveDeployOrder, resolveNetwork, runCommand, updateArtifact, validateSourceShape, writeArtifacts, writeBindingMarker };
|
|
624
|
+
export { BINDING_MARKER_FILENAME, type BindingFreshness, type BindingFreshnessStatus, type BindingMarker, BindingMarkerSchema, type BuildContractOptions, CAATINGA_CORE_VERSION, CaatingaArtifacts, type CaatingaConfig, CaatingaConfigSchema, CaatingaError, type CheckStellarCliVersionOptions, type CollectProjectStatusOptions, type CompatibilityReport, type CompatibilityStatus, type CompatibilityWarning, type CompatibilityWarningCode, ContractArtifact, type ContractConfig, type ContractStatusEntry, type CreateInitialArtifactsOptions, type CreateProjectFromTemplateOptions, type CreateZkProjectOptions, type DeployArgValue, type DeployContractGraphResult, type DeployContractOptions, type EvaluateBindingFreshnessOptions, type EvaluateStellarCliCompatibilityInput, type GenerateBindingsGraphResult, type GenerateBindingsOptions, type InvokeContractOptions, type InvokeTarget, type LoadConfigOptions, type NetworkConfig, type NetworkStatus, type ProjectStatus, type ResolvedContract, type ResolvedNetwork, type RunCommandResult, STELLAR_CLI_LAST_TESTED_VERSION, STELLAR_CLI_MIN_VERSION, type SkippedContract, type TemplateManifest, TemplateManifestSchema, WELL_KNOWN_NETWORKS, buildContract, buildDependencyGraph, checkBinary, checkStellarCliVersion, collectProjectStatus, createInitialArtifacts, createProjectFromTemplate, createZkProject, defineConfig, deployContract, deployContractGraph, evaluateBindingFreshness, evaluateBindingsFreshness, evaluateStellarCliCompatibility, generateBindings, generateBindingsGraph, invokeContract, isTransientTestnetSmokeFailure, loadConfig, parseContractId, parseInvokeTarget, parseStellarCliVersion, readArtifacts, readBindingMarker, resolveContract, resolveDefaultContractName, resolveDeployArgs, resolveDeployOrder, resolveNetwork, runCommand, updateArtifact, validateSourceShape, writeArtifacts, writeBindingMarker };
|
package/dist/index.js
CHANGED
|
@@ -105,7 +105,7 @@ function formatCause(cause) {
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
// src/version.ts
|
|
108
|
-
var CAATINGA_CORE_VERSION = "2.3.
|
|
108
|
+
var CAATINGA_CORE_VERSION = "2.3.1";
|
|
109
109
|
|
|
110
110
|
// src/config/config.schema.ts
|
|
111
111
|
import { z } from "zod";
|
|
@@ -143,7 +143,7 @@ var CaatingaConfigSchema = z.object({
|
|
|
143
143
|
frontend: z.object({
|
|
144
144
|
framework: z.enum(["vite-react", "next", "astro"]).default("vite-react"),
|
|
145
145
|
bindingsOutput: z.string().min(1)
|
|
146
|
-
}),
|
|
146
|
+
}).optional(),
|
|
147
147
|
zk: ZkConfigSchema
|
|
148
148
|
});
|
|
149
149
|
|
|
@@ -341,6 +341,15 @@ async function listGeneratedEntries(outputDir) {
|
|
|
341
341
|
}
|
|
342
342
|
async function evaluateBindingFreshness(options) {
|
|
343
343
|
const cwd = options.cwd ?? process.cwd();
|
|
344
|
+
if (!options.config.frontend) {
|
|
345
|
+
return {
|
|
346
|
+
contractName: options.contractName,
|
|
347
|
+
status: "unknown",
|
|
348
|
+
outputDir: "",
|
|
349
|
+
marker: null,
|
|
350
|
+
reason: "frontend bindings are not configured"
|
|
351
|
+
};
|
|
352
|
+
}
|
|
344
353
|
const outputDir = path5.resolve(cwd, options.config.frontend.bindingsOutput, options.contractName);
|
|
345
354
|
const contractArtifact = options.artifacts.networks[options.networkName]?.contracts[options.contractName];
|
|
346
355
|
if (!contractArtifact) {
|
|
@@ -1359,6 +1368,13 @@ async function removeLegacyBindingStub(cwd, bindingsOutput, contractName) {
|
|
|
1359
1368
|
}
|
|
1360
1369
|
async function generateBindings(options) {
|
|
1361
1370
|
const cwd = options.cwd ?? process.cwd();
|
|
1371
|
+
if (!options.config.frontend) {
|
|
1372
|
+
throw new CaatingaError(
|
|
1373
|
+
"Frontend bindings are not configured.",
|
|
1374
|
+
CaatingaErrorCode.INVALID_CONFIG,
|
|
1375
|
+
"Add a frontend.bindingsOutput entry to caatinga.config.ts before running caatinga generate."
|
|
1376
|
+
);
|
|
1377
|
+
}
|
|
1362
1378
|
const network = resolveNetwork(options.config, options.networkName);
|
|
1363
1379
|
const artifacts = await readArtifacts(cwd);
|
|
1364
1380
|
const contractArtifact = artifacts.networks[network.name]?.contracts[options.contractName];
|
|
@@ -1706,6 +1722,118 @@ function isTextTemplateFile(filePath) {
|
|
|
1706
1722
|
].includes(path10.extname(filePath));
|
|
1707
1723
|
}
|
|
1708
1724
|
|
|
1725
|
+
// src/scaffold/create-zk-project.ts
|
|
1726
|
+
import { cp as cp2, mkdir as mkdir4, writeFile as writeFile4 } from "fs/promises";
|
|
1727
|
+
import { existsSync } from "fs";
|
|
1728
|
+
import path11 from "path";
|
|
1729
|
+
import { fileURLToPath } from "url";
|
|
1730
|
+
var moduleDir = typeof __dirname === "string" ? __dirname : path11.dirname(fileURLToPath(import.meta.url));
|
|
1731
|
+
function scaffoldRoot() {
|
|
1732
|
+
const candidates = [
|
|
1733
|
+
path11.resolve(moduleDir, "../../scaffolds"),
|
|
1734
|
+
path11.resolve(moduleDir, "../scaffolds")
|
|
1735
|
+
];
|
|
1736
|
+
const found = candidates.find((candidate) => existsSync(candidate));
|
|
1737
|
+
return found ?? candidates[0];
|
|
1738
|
+
}
|
|
1739
|
+
function configSource(projectName) {
|
|
1740
|
+
return `import { defineConfig } from "@caatinga/core";
|
|
1741
|
+
|
|
1742
|
+
export default defineConfig({
|
|
1743
|
+
project: "${projectName}",
|
|
1744
|
+
defaultNetwork: "testnet",
|
|
1745
|
+
contracts: {
|
|
1746
|
+
verifier: {
|
|
1747
|
+
path: "./contracts/verifier",
|
|
1748
|
+
wasm: "./contracts/verifier/target/wasm32v1-none/release/verifier.wasm"
|
|
1749
|
+
}
|
|
1750
|
+
},
|
|
1751
|
+
networks: {
|
|
1752
|
+
testnet: {
|
|
1753
|
+
rpcUrl: "https://soroban-testnet.stellar.org",
|
|
1754
|
+
networkPassphrase: "Test SDF Network ; September 2015"
|
|
1755
|
+
}
|
|
1756
|
+
},
|
|
1757
|
+
zk: {
|
|
1758
|
+
circuits: {
|
|
1759
|
+
main: {
|
|
1760
|
+
path: "./circuits",
|
|
1761
|
+
protocol: "groth16",
|
|
1762
|
+
curve: "bls12381",
|
|
1763
|
+
verifierContract: "verifier"
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
}
|
|
1767
|
+
});
|
|
1768
|
+
`;
|
|
1769
|
+
}
|
|
1770
|
+
function packageJsonSource(projectName) {
|
|
1771
|
+
return `${JSON.stringify({
|
|
1772
|
+
name: projectName,
|
|
1773
|
+
version: "0.1.0",
|
|
1774
|
+
private: true,
|
|
1775
|
+
type: "module",
|
|
1776
|
+
scripts: {
|
|
1777
|
+
"zk:build": "caatinga zk build main",
|
|
1778
|
+
"zk:prove": "caatinga zk prove main",
|
|
1779
|
+
build: "caatinga build verifier",
|
|
1780
|
+
deploy: "caatinga deploy verifier"
|
|
1781
|
+
},
|
|
1782
|
+
devDependencies: {
|
|
1783
|
+
"@caatinga/cli": `^${CAATINGA_CORE_VERSION}`,
|
|
1784
|
+
"@caatinga/core": `^${CAATINGA_CORE_VERSION}`
|
|
1785
|
+
}
|
|
1786
|
+
}, null, 2)}
|
|
1787
|
+
`;
|
|
1788
|
+
}
|
|
1789
|
+
function readmeSource(projectName) {
|
|
1790
|
+
return `# ${projectName}
|
|
1791
|
+
|
|
1792
|
+
Minimal Caatinga ZK project.
|
|
1793
|
+
|
|
1794
|
+
## Workflow
|
|
1795
|
+
|
|
1796
|
+
\`\`\`bash
|
|
1797
|
+
npm install
|
|
1798
|
+
npx caatinga zk build main
|
|
1799
|
+
npx caatinga build verifier
|
|
1800
|
+
npx caatinga deploy verifier --network testnet
|
|
1801
|
+
npx caatinga zk prove main
|
|
1802
|
+
\`\`\`
|
|
1803
|
+
|
|
1804
|
+
Replace \`circuits/main.circom\` with your circuit. Keep the entry point named \`main\`.
|
|
1805
|
+
`;
|
|
1806
|
+
}
|
|
1807
|
+
async function createZkProject(options) {
|
|
1808
|
+
const targetDir = path11.resolve(options.targetDir);
|
|
1809
|
+
const force = options.force ?? false;
|
|
1810
|
+
const projectFiles = options.projectFiles ?? true;
|
|
1811
|
+
await mkdir4(targetDir, { recursive: true });
|
|
1812
|
+
if (projectFiles) {
|
|
1813
|
+
await Promise.all([
|
|
1814
|
+
writeFile4(path11.join(targetDir, "caatinga.config.ts"), configSource(options.projectName), { encoding: "utf8", flag: force ? "w" : "wx" }),
|
|
1815
|
+
writeFile4(path11.join(targetDir, "package.json"), packageJsonSource(options.projectName), { encoding: "utf8", flag: force ? "w" : "wx" }),
|
|
1816
|
+
writeFile4(path11.join(targetDir, ".gitignore"), "node_modules\n.artifacts\ntarget\n", { encoding: "utf8", flag: force ? "w" : "wx" }),
|
|
1817
|
+
writeFile4(path11.join(targetDir, "README.md"), readmeSource(options.projectName), { encoding: "utf8", flag: force ? "w" : "wx" })
|
|
1818
|
+
]);
|
|
1819
|
+
}
|
|
1820
|
+
await mkdir4(path11.join(targetDir, "contracts"), { recursive: true });
|
|
1821
|
+
await cp2(path11.join(scaffoldRoot(), "zk-circuit-stub"), path11.join(targetDir, "circuits"), {
|
|
1822
|
+
recursive: true,
|
|
1823
|
+
force,
|
|
1824
|
+
errorOnExist: !force
|
|
1825
|
+
});
|
|
1826
|
+
await cp2(path11.join(scaffoldRoot(), "zk-verifier"), path11.join(targetDir, "contracts", "verifier"), {
|
|
1827
|
+
recursive: true,
|
|
1828
|
+
force,
|
|
1829
|
+
errorOnExist: !force
|
|
1830
|
+
});
|
|
1831
|
+
if (projectFiles) {
|
|
1832
|
+
await writeArtifacts(createInitialArtifacts(options.projectName, { networks: ["testnet"] }), targetDir);
|
|
1833
|
+
}
|
|
1834
|
+
return { targetDir };
|
|
1835
|
+
}
|
|
1836
|
+
|
|
1709
1837
|
// src/ci/is-transient-testnet-smoke-failure.ts
|
|
1710
1838
|
var NO_RETRY_CAATINGA_SUBSTRINGS = [
|
|
1711
1839
|
"CAATINGA_UNSUPPORTED_CLI_VERSION",
|
|
@@ -1745,6 +1873,7 @@ export {
|
|
|
1745
1873
|
collectProjectStatus,
|
|
1746
1874
|
createInitialArtifacts,
|
|
1747
1875
|
createProjectFromTemplate,
|
|
1876
|
+
createZkProject,
|
|
1748
1877
|
defineConfig,
|
|
1749
1878
|
deployContract,
|
|
1750
1879
|
deployContractGraph,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caatinga/core",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "Core config, artifacts, command orchestration, and error primitives for Caatinga/Soroban toolkit",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"stellar",
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"files": [
|
|
47
47
|
"dist",
|
|
48
|
+
"scaffolds",
|
|
48
49
|
"README.md",
|
|
49
50
|
"LICENSE"
|
|
50
51
|
],
|