@caatinga/core 3.0.1 → 3.1.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 +177 -59
- package/dist/index.js +167 -49
- package/package.json +1 -1
- package/dist/artifact.schema-CGCFfl0g.d.cts +0 -185
- package/dist/artifact.schema-CGCFfl0g.d.ts +0 -185
package/dist/index.cjs
CHANGED
|
@@ -1608,8 +1608,101 @@ async function deployContractGraph(options) {
|
|
|
1608
1608
|
}
|
|
1609
1609
|
|
|
1610
1610
|
// src/contracts/generate-bindings.ts
|
|
1611
|
+
var import_promises8 = require("fs/promises");
|
|
1612
|
+
var import_node_path11 = __toESM(require("path"), 1);
|
|
1613
|
+
|
|
1614
|
+
// src/bindings/patch-generated-binding-package.ts
|
|
1611
1615
|
var import_promises7 = require("fs/promises");
|
|
1612
1616
|
var import_node_path10 = __toESM(require("path"), 1);
|
|
1617
|
+
var BUNDLER_ENTRY = "./src/index.ts";
|
|
1618
|
+
var ROOT_BINDING_INDEX_CONTENT = 'export * from "./src/index.js";\n';
|
|
1619
|
+
function resolveExportEntry(exportsField) {
|
|
1620
|
+
if (!exportsField) {
|
|
1621
|
+
return void 0;
|
|
1622
|
+
}
|
|
1623
|
+
const rootExport = exportsField["."];
|
|
1624
|
+
if (typeof rootExport === "string") {
|
|
1625
|
+
return rootExport;
|
|
1626
|
+
}
|
|
1627
|
+
if (rootExport && typeof rootExport === "object" && !Array.isArray(rootExport)) {
|
|
1628
|
+
const conditions = rootExport;
|
|
1629
|
+
for (const key of ["import", "default", "types"]) {
|
|
1630
|
+
const value = conditions[key];
|
|
1631
|
+
if (typeof value === "string") {
|
|
1632
|
+
return value;
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1635
|
+
}
|
|
1636
|
+
return void 0;
|
|
1637
|
+
}
|
|
1638
|
+
function pointsToDist(main) {
|
|
1639
|
+
return typeof main === "string" && main.replace(/^\.\//, "").startsWith("dist/");
|
|
1640
|
+
}
|
|
1641
|
+
function pointsToBundlerSource(entry) {
|
|
1642
|
+
return entry === BUNDLER_ENTRY || entry === "./src/index.js";
|
|
1643
|
+
}
|
|
1644
|
+
function shouldPatchPackageJson(packageJson) {
|
|
1645
|
+
const exportEntry = resolveExportEntry(
|
|
1646
|
+
typeof packageJson.exports === "object" && packageJson.exports !== null && !Array.isArray(packageJson.exports) ? packageJson.exports : void 0
|
|
1647
|
+
);
|
|
1648
|
+
return pointsToDist(packageJson.main) || pointsToDist(packageJson.types) || !pointsToBundlerSource(exportEntry);
|
|
1649
|
+
}
|
|
1650
|
+
async function ensureRootBindingIndex(outputDir) {
|
|
1651
|
+
const rootIndexPath = import_node_path10.default.join(outputDir, "index.ts");
|
|
1652
|
+
try {
|
|
1653
|
+
const existing = await (0, import_promises7.readFile)(rootIndexPath, "utf8");
|
|
1654
|
+
if (existing === ROOT_BINDING_INDEX_CONTENT) {
|
|
1655
|
+
return;
|
|
1656
|
+
}
|
|
1657
|
+
return;
|
|
1658
|
+
} catch {
|
|
1659
|
+
await (0, import_promises7.writeFile)(rootIndexPath, ROOT_BINDING_INDEX_CONTENT, "utf8");
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
async function patchGeneratedBindingPackage(outputDir) {
|
|
1663
|
+
const packageJsonPath = import_node_path10.default.join(outputDir, "package.json");
|
|
1664
|
+
const entryPath = import_node_path10.default.join(outputDir, "src", "index.ts");
|
|
1665
|
+
try {
|
|
1666
|
+
await (0, import_promises7.access)(entryPath);
|
|
1667
|
+
} catch {
|
|
1668
|
+
throw new CaatingaError(
|
|
1669
|
+
"Generated binding package is missing src/index.ts.",
|
|
1670
|
+
CaatingaErrorCode.BINDINGS_FAILED,
|
|
1671
|
+
"Re-run caatinga generate or check @stellar/stellar-sdk generate output."
|
|
1672
|
+
);
|
|
1673
|
+
}
|
|
1674
|
+
let raw;
|
|
1675
|
+
try {
|
|
1676
|
+
raw = await (0, import_promises7.readFile)(packageJsonPath, "utf8");
|
|
1677
|
+
} catch {
|
|
1678
|
+
throw new CaatingaError(
|
|
1679
|
+
"Generated binding package is missing package.json.",
|
|
1680
|
+
CaatingaErrorCode.BINDINGS_FAILED,
|
|
1681
|
+
"Re-run caatinga generate or check @stellar/stellar-sdk generate output."
|
|
1682
|
+
);
|
|
1683
|
+
}
|
|
1684
|
+
let packageJson;
|
|
1685
|
+
try {
|
|
1686
|
+
packageJson = JSON.parse(raw);
|
|
1687
|
+
} catch {
|
|
1688
|
+
throw new CaatingaError(
|
|
1689
|
+
"Generated binding package.json is not valid JSON.",
|
|
1690
|
+
CaatingaErrorCode.BINDINGS_FAILED,
|
|
1691
|
+
"Re-run caatinga generate or check @stellar/stellar-sdk generate output."
|
|
1692
|
+
);
|
|
1693
|
+
}
|
|
1694
|
+
if (shouldPatchPackageJson(packageJson)) {
|
|
1695
|
+
packageJson.main = BUNDLER_ENTRY;
|
|
1696
|
+
packageJson.types = BUNDLER_ENTRY;
|
|
1697
|
+
packageJson.exports = {
|
|
1698
|
+
...typeof packageJson.exports === "object" && packageJson.exports !== null && !Array.isArray(packageJson.exports) ? packageJson.exports : {},
|
|
1699
|
+
".": BUNDLER_ENTRY
|
|
1700
|
+
};
|
|
1701
|
+
await (0, import_promises7.writeFile)(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}
|
|
1702
|
+
`, "utf8");
|
|
1703
|
+
}
|
|
1704
|
+
await ensureRootBindingIndex(outputDir);
|
|
1705
|
+
}
|
|
1613
1706
|
|
|
1614
1707
|
// src/contracts/build-generate-network-args.ts
|
|
1615
1708
|
function buildGenerateNetworkArgs(network) {
|
|
@@ -1621,14 +1714,14 @@ function buildGenerateNetworkArgs(network) {
|
|
|
1621
1714
|
|
|
1622
1715
|
// src/contracts/generate-bindings.ts
|
|
1623
1716
|
function toBindingImportPath(bindingsOutput, contractName) {
|
|
1624
|
-
const normalized = bindingsOutput.replace(/^\.\//, "").split(
|
|
1625
|
-
return `./${
|
|
1717
|
+
const normalized = bindingsOutput.replace(/^\.\//, "").split(import_node_path11.default.sep).join("/");
|
|
1718
|
+
return `./${import_node_path11.default.posix.join(normalized, contractName)}`;
|
|
1626
1719
|
}
|
|
1627
1720
|
async function removeLegacyBindingStub(cwd, bindingsOutput, contractName) {
|
|
1628
|
-
const legacyPath =
|
|
1721
|
+
const legacyPath = import_node_path11.default.resolve(cwd, bindingsOutput, `${contractName}.ts`);
|
|
1629
1722
|
try {
|
|
1630
|
-
await (0,
|
|
1631
|
-
await (0,
|
|
1723
|
+
await (0, import_promises8.access)(legacyPath);
|
|
1724
|
+
await (0, import_promises8.unlink)(legacyPath);
|
|
1632
1725
|
return true;
|
|
1633
1726
|
} catch {
|
|
1634
1727
|
return false;
|
|
@@ -1653,8 +1746,8 @@ async function generateBindings(options) {
|
|
|
1653
1746
|
"Run caatinga deploy for this contract and network before generating bindings."
|
|
1654
1747
|
);
|
|
1655
1748
|
}
|
|
1656
|
-
const outputDir =
|
|
1657
|
-
await (0,
|
|
1749
|
+
const outputDir = import_node_path11.default.resolve(cwd, options.config.frontend.bindingsOutput, options.contractName);
|
|
1750
|
+
await (0, import_promises8.mkdir)(outputDir, { recursive: true });
|
|
1658
1751
|
const result = await runCommand(
|
|
1659
1752
|
"npx",
|
|
1660
1753
|
[
|
|
@@ -1680,6 +1773,7 @@ async function generateBindings(options) {
|
|
|
1680
1773
|
options.config.frontend.bindingsOutput,
|
|
1681
1774
|
options.contractName
|
|
1682
1775
|
);
|
|
1776
|
+
await patchGeneratedBindingPackage(outputDir);
|
|
1683
1777
|
const marker = {
|
|
1684
1778
|
version: 1,
|
|
1685
1779
|
contractId: contractArtifact.contractId,
|
|
@@ -1879,8 +1973,8 @@ async function readContract(options) {
|
|
|
1879
1973
|
}
|
|
1880
1974
|
|
|
1881
1975
|
// src/templates/create-project-from-template.ts
|
|
1882
|
-
var
|
|
1883
|
-
var
|
|
1976
|
+
var import_promises9 = require("fs/promises");
|
|
1977
|
+
var import_node_path12 = __toESM(require("path"), 1);
|
|
1884
1978
|
var import_zod7 = require("zod");
|
|
1885
1979
|
|
|
1886
1980
|
// src/templates/template-manifest.schema.ts
|
|
@@ -1951,10 +2045,10 @@ function formatTemplateCompatibilityHint(issue) {
|
|
|
1951
2045
|
// src/templates/create-project-from-template.ts
|
|
1952
2046
|
var TEMPLATE_COPY_EXCLUDED_DIRS = /* @__PURE__ */ new Set(["target", "test_snapshots", "node_modules", ".git"]);
|
|
1953
2047
|
async function createProjectFromTemplate(options) {
|
|
1954
|
-
const targetDir =
|
|
1955
|
-
const templateDir =
|
|
2048
|
+
const targetDir = import_node_path12.default.resolve(options.targetDir);
|
|
2049
|
+
const templateDir = import_node_path12.default.resolve(options.templateDir);
|
|
1956
2050
|
try {
|
|
1957
|
-
await (0,
|
|
2051
|
+
await (0, import_promises9.stat)(templateDir);
|
|
1958
2052
|
} catch {
|
|
1959
2053
|
throw new CaatingaError(
|
|
1960
2054
|
`Template directory was not found: ${templateDir}`,
|
|
@@ -1964,11 +2058,11 @@ async function createProjectFromTemplate(options) {
|
|
|
1964
2058
|
}
|
|
1965
2059
|
const manifest = await readTemplateManifest(templateDir);
|
|
1966
2060
|
const mergeIntoExisting = Boolean(options.filter);
|
|
1967
|
-
await (0,
|
|
1968
|
-
await (0,
|
|
2061
|
+
await (0, import_promises9.mkdir)(targetDir, { recursive: true });
|
|
2062
|
+
await (0, import_promises9.cp)(templateDir, targetDir, {
|
|
1969
2063
|
recursive: true,
|
|
1970
|
-
force:
|
|
1971
|
-
errorOnExist:
|
|
2064
|
+
force: true,
|
|
2065
|
+
errorOnExist: false,
|
|
1972
2066
|
filter: (source) => shouldCopyTemplateEntry(templateDir, source, options.filter)
|
|
1973
2067
|
});
|
|
1974
2068
|
await replaceTemplateVariables(targetDir, options.projectName);
|
|
@@ -1993,9 +2087,9 @@ async function ensureArtifacts(targetDir, projectName) {
|
|
|
1993
2087
|
}
|
|
1994
2088
|
}
|
|
1995
2089
|
async function readTemplateManifest(templateDir) {
|
|
1996
|
-
const manifestPath =
|
|
2090
|
+
const manifestPath = import_node_path12.default.join(templateDir, "caatinga.template.json");
|
|
1997
2091
|
try {
|
|
1998
|
-
const rawManifest = await (0,
|
|
2092
|
+
const rawManifest = await (0, import_promises9.readFile)(manifestPath, "utf8");
|
|
1999
2093
|
const manifest = TemplateManifestSchema.parse(JSON.parse(rawManifest));
|
|
2000
2094
|
const compatibilityIssue = getTemplateCompatibilityIssue(manifest);
|
|
2001
2095
|
if (compatibilityIssue) {
|
|
@@ -2028,11 +2122,11 @@ async function readTemplateManifest(templateDir) {
|
|
|
2028
2122
|
}
|
|
2029
2123
|
}
|
|
2030
2124
|
async function replaceTemplateVariables(dir, projectName) {
|
|
2031
|
-
const entries = await (0,
|
|
2125
|
+
const entries = await (0, import_promises9.readdir)(dir);
|
|
2032
2126
|
await Promise.all(
|
|
2033
2127
|
entries.map(async (entry) => {
|
|
2034
|
-
const entryPath =
|
|
2035
|
-
const entryStat = await (0,
|
|
2128
|
+
const entryPath = import_node_path12.default.join(dir, entry);
|
|
2129
|
+
const entryStat = await (0, import_promises9.stat)(entryPath);
|
|
2036
2130
|
if (entryStat.isDirectory()) {
|
|
2037
2131
|
await replaceTemplateVariables(entryPath, projectName);
|
|
2038
2132
|
return;
|
|
@@ -2040,39 +2134,39 @@ async function replaceTemplateVariables(dir, projectName) {
|
|
|
2040
2134
|
if (!isTextTemplateFile(entryPath)) {
|
|
2041
2135
|
return;
|
|
2042
2136
|
}
|
|
2043
|
-
const content = await (0,
|
|
2044
|
-
await (0,
|
|
2137
|
+
const content = await (0, import_promises9.readFile)(entryPath, "utf8");
|
|
2138
|
+
await (0, import_promises9.writeFile)(entryPath, content.replaceAll("__PROJECT_NAME__", projectName), "utf8");
|
|
2045
2139
|
})
|
|
2046
2140
|
);
|
|
2047
2141
|
}
|
|
2048
2142
|
function shouldCopyTemplateEntry(templateDir, source, userFilter) {
|
|
2049
|
-
const relativePath =
|
|
2143
|
+
const relativePath = import_node_path12.default.relative(templateDir, source);
|
|
2050
2144
|
if (!relativePath || relativePath === ".") {
|
|
2051
2145
|
return true;
|
|
2052
2146
|
}
|
|
2053
|
-
const normalizedPath = relativePath.split(
|
|
2147
|
+
const normalizedPath = relativePath.split(import_node_path12.default.sep).join("/");
|
|
2054
2148
|
if (userFilter && !userFilter(normalizedPath)) {
|
|
2055
2149
|
return false;
|
|
2056
2150
|
}
|
|
2057
|
-
return !relativePath.split(
|
|
2151
|
+
return !relativePath.split(import_node_path12.default.sep).some((segment) => TEMPLATE_COPY_EXCLUDED_DIRS.has(segment));
|
|
2058
2152
|
}
|
|
2059
2153
|
function isTextTemplateFile(filePath) {
|
|
2060
2154
|
return [".json", ".md", ".rs", ".toml", ".ts", ".tsx", ".css", ".html"].includes(
|
|
2061
|
-
|
|
2155
|
+
import_node_path12.default.extname(filePath)
|
|
2062
2156
|
);
|
|
2063
2157
|
}
|
|
2064
2158
|
|
|
2065
2159
|
// src/scaffold/create-zk-project.ts
|
|
2066
|
-
var
|
|
2160
|
+
var import_promises10 = require("fs/promises");
|
|
2067
2161
|
var import_node_fs2 = require("fs");
|
|
2068
|
-
var
|
|
2162
|
+
var import_node_path13 = __toESM(require("path"), 1);
|
|
2069
2163
|
var import_node_url = require("url");
|
|
2070
2164
|
var import_meta3 = {};
|
|
2071
|
-
var moduleDir = typeof __dirname === "string" ? __dirname :
|
|
2165
|
+
var moduleDir = typeof __dirname === "string" ? __dirname : import_node_path13.default.dirname((0, import_node_url.fileURLToPath)(import_meta3.url));
|
|
2072
2166
|
function scaffoldRoot() {
|
|
2073
2167
|
const candidates = [
|
|
2074
|
-
|
|
2075
|
-
|
|
2168
|
+
import_node_path13.default.resolve(moduleDir, "../../scaffolds"),
|
|
2169
|
+
import_node_path13.default.resolve(moduleDir, "../scaffolds")
|
|
2076
2170
|
];
|
|
2077
2171
|
const found = candidates.find((candidate) => (0, import_node_fs2.existsSync)(candidate));
|
|
2078
2172
|
return found ?? candidates[0];
|
|
@@ -2120,7 +2214,8 @@ function packageJsonSource(projectName) {
|
|
|
2120
2214
|
"zk:prove": "caatinga zk prove main",
|
|
2121
2215
|
build: "caatinga build verifier",
|
|
2122
2216
|
deploy: "caatinga deploy verifier --network testnet --source ${CAATINGA_SOURCE:-alice}",
|
|
2123
|
-
doctor: "caatinga doctor --network testnet"
|
|
2217
|
+
doctor: "caatinga doctor --network testnet",
|
|
2218
|
+
test: "cargo test --manifest-path contracts/verifier/Cargo.toml"
|
|
2124
2219
|
},
|
|
2125
2220
|
devDependencies: {
|
|
2126
2221
|
"@caatinga/cli": `^${CAATINGA_CORE_VERSION}`,
|
|
@@ -2141,49 +2236,60 @@ Minimal Caatinga ZK project.
|
|
|
2141
2236
|
|
|
2142
2237
|
\`\`\`bash
|
|
2143
2238
|
npm install
|
|
2239
|
+
npm test
|
|
2144
2240
|
npx caatinga zk build main
|
|
2145
2241
|
npx caatinga build verifier
|
|
2146
2242
|
npx caatinga deploy verifier --network testnet --source <identity>
|
|
2147
2243
|
npx caatinga zk prove main
|
|
2148
2244
|
\`\`\`
|
|
2149
2245
|
|
|
2246
|
+
## Tests
|
|
2247
|
+
|
|
2248
|
+
Run the Rust verifier contract tests from the project root:
|
|
2249
|
+
|
|
2250
|
+
\`\`\`bash
|
|
2251
|
+
npm test
|
|
2252
|
+
# or directly:
|
|
2253
|
+
cargo test --manifest-path contracts/verifier/Cargo.toml
|
|
2254
|
+
\`\`\`
|
|
2255
|
+
|
|
2150
2256
|
Replace \`circuits/main.circom\` with your circuit. Keep the entry point named \`main\`.
|
|
2151
2257
|
`;
|
|
2152
2258
|
}
|
|
2153
2259
|
async function createZkProject(options) {
|
|
2154
|
-
const targetDir =
|
|
2260
|
+
const targetDir = import_node_path13.default.resolve(options.targetDir);
|
|
2155
2261
|
const force = options.force ?? false;
|
|
2156
2262
|
const projectFiles = options.projectFiles ?? true;
|
|
2157
|
-
await (0,
|
|
2263
|
+
await (0, import_promises10.mkdir)(targetDir, { recursive: true });
|
|
2158
2264
|
if (projectFiles) {
|
|
2159
2265
|
await Promise.all([
|
|
2160
|
-
(0,
|
|
2266
|
+
(0, import_promises10.writeFile)(import_node_path13.default.join(targetDir, "caatinga.config.ts"), configSource(options.projectName), {
|
|
2161
2267
|
encoding: "utf8",
|
|
2162
2268
|
flag: force ? "w" : "wx"
|
|
2163
2269
|
}),
|
|
2164
|
-
(0,
|
|
2270
|
+
(0, import_promises10.writeFile)(import_node_path13.default.join(targetDir, "package.json"), packageJsonSource(options.projectName), {
|
|
2165
2271
|
encoding: "utf8",
|
|
2166
2272
|
flag: force ? "w" : "wx"
|
|
2167
2273
|
}),
|
|
2168
|
-
(0,
|
|
2274
|
+
(0, import_promises10.writeFile)(import_node_path13.default.join(targetDir, ".gitignore"), "node_modules\n.artifacts\ntarget\n", {
|
|
2169
2275
|
encoding: "utf8",
|
|
2170
2276
|
flag: force ? "w" : "wx"
|
|
2171
2277
|
}),
|
|
2172
|
-
(0,
|
|
2278
|
+
(0, import_promises10.writeFile)(import_node_path13.default.join(targetDir, "README.md"), readmeSource(options.projectName), {
|
|
2173
2279
|
encoding: "utf8",
|
|
2174
2280
|
flag: force ? "w" : "wx"
|
|
2175
2281
|
})
|
|
2176
2282
|
]);
|
|
2177
2283
|
}
|
|
2178
|
-
await (0,
|
|
2179
|
-
await (0,
|
|
2284
|
+
await (0, import_promises10.mkdir)(import_node_path13.default.join(targetDir, "contracts"), { recursive: true });
|
|
2285
|
+
await (0, import_promises10.cp)(import_node_path13.default.join(scaffoldRoot(), "zk-circuit-stub"), import_node_path13.default.join(targetDir, "circuits"), {
|
|
2180
2286
|
recursive: true,
|
|
2181
2287
|
force,
|
|
2182
2288
|
errorOnExist: !force
|
|
2183
2289
|
});
|
|
2184
|
-
await (0,
|
|
2185
|
-
|
|
2186
|
-
|
|
2290
|
+
await (0, import_promises10.cp)(
|
|
2291
|
+
import_node_path13.default.join(scaffoldRoot(), "zk-verifier"),
|
|
2292
|
+
import_node_path13.default.join(targetDir, "contracts", "verifier"),
|
|
2187
2293
|
{
|
|
2188
2294
|
recursive: true,
|
|
2189
2295
|
force,
|
|
@@ -2200,16 +2306,16 @@ async function createZkProject(options) {
|
|
|
2200
2306
|
}
|
|
2201
2307
|
|
|
2202
2308
|
// src/scaffold/create-minimal-project.ts
|
|
2203
|
-
var
|
|
2309
|
+
var import_promises11 = require("fs/promises");
|
|
2204
2310
|
var import_node_fs3 = require("fs");
|
|
2205
|
-
var
|
|
2311
|
+
var import_node_path14 = __toESM(require("path"), 1);
|
|
2206
2312
|
var import_node_url2 = require("url");
|
|
2207
2313
|
var import_meta4 = {};
|
|
2208
|
-
var moduleDir2 = typeof __dirname === "string" ? __dirname :
|
|
2314
|
+
var moduleDir2 = typeof __dirname === "string" ? __dirname : import_node_path14.default.dirname((0, import_node_url2.fileURLToPath)(import_meta4.url));
|
|
2209
2315
|
function scaffoldRoot2() {
|
|
2210
2316
|
const candidates = [
|
|
2211
|
-
|
|
2212
|
-
|
|
2317
|
+
import_node_path14.default.resolve(moduleDir2, "../../scaffolds"),
|
|
2318
|
+
import_node_path14.default.resolve(moduleDir2, "../scaffolds")
|
|
2213
2319
|
];
|
|
2214
2320
|
const found = candidates.find((candidate) => (0, import_node_fs3.existsSync)(candidate));
|
|
2215
2321
|
return found ?? candidates[0];
|
|
@@ -2246,6 +2352,7 @@ function packageJsonSource2(projectName) {
|
|
|
2246
2352
|
build: "caatinga build app",
|
|
2247
2353
|
deploy: "caatinga deploy app --network testnet --source ${CAATINGA_SOURCE:-alice}",
|
|
2248
2354
|
doctor: "caatinga doctor --network testnet",
|
|
2355
|
+
test: "cargo test --manifest-path contracts/app/Cargo.toml",
|
|
2249
2356
|
"read:hello": "caatinga read app.hello --network testnet --source ${CAATINGA_SOURCE:-alice}",
|
|
2250
2357
|
"read:version": "caatinga read app.version --network testnet --source ${CAATINGA_SOURCE:-alice}"
|
|
2251
2358
|
},
|
|
@@ -2268,6 +2375,7 @@ Minimal Caatinga project with a Soroban contract stub (no frontend template).
|
|
|
2268
2375
|
|
|
2269
2376
|
\`\`\`bash
|
|
2270
2377
|
npm install
|
|
2378
|
+
npm test
|
|
2271
2379
|
npx caatinga doctor
|
|
2272
2380
|
npx caatinga build app
|
|
2273
2381
|
npx caatinga deploy app --network testnet --source <identity>
|
|
@@ -2275,6 +2383,16 @@ npx caatinga read app.version --network testnet
|
|
|
2275
2383
|
npx caatinga read app.hello --network testnet
|
|
2276
2384
|
\`\`\`
|
|
2277
2385
|
|
|
2386
|
+
## Tests
|
|
2387
|
+
|
|
2388
|
+
Run the Rust contract tests from the project root:
|
|
2389
|
+
|
|
2390
|
+
\`\`\`bash
|
|
2391
|
+
npm test
|
|
2392
|
+
# or directly:
|
|
2393
|
+
cargo test --manifest-path contracts/app/Cargo.toml
|
|
2394
|
+
\`\`\`
|
|
2395
|
+
|
|
2278
2396
|
## Contract
|
|
2279
2397
|
|
|
2280
2398
|
- \`hello()\` \u2014 read-only; returns Soroban Symbol \`hello\`
|
|
@@ -2288,31 +2406,31 @@ Edit \`contracts/app/src/lib.rs\` to customize the contract. Add a frontend late
|
|
|
2288
2406
|
`;
|
|
2289
2407
|
}
|
|
2290
2408
|
async function createMinimalProject(options) {
|
|
2291
|
-
const targetDir =
|
|
2409
|
+
const targetDir = import_node_path14.default.resolve(options.targetDir);
|
|
2292
2410
|
const force = options.force ?? false;
|
|
2293
|
-
await (0,
|
|
2411
|
+
await (0, import_promises11.mkdir)(targetDir, { recursive: true });
|
|
2294
2412
|
await Promise.all([
|
|
2295
|
-
(0,
|
|
2413
|
+
(0, import_promises11.writeFile)(import_node_path14.default.join(targetDir, "caatinga.config.ts"), configSource2(options.projectName), {
|
|
2296
2414
|
encoding: "utf8",
|
|
2297
2415
|
flag: force ? "w" : "wx"
|
|
2298
2416
|
}),
|
|
2299
|
-
(0,
|
|
2417
|
+
(0, import_promises11.writeFile)(import_node_path14.default.join(targetDir, "package.json"), packageJsonSource2(options.projectName), {
|
|
2300
2418
|
encoding: "utf8",
|
|
2301
2419
|
flag: force ? "w" : "wx"
|
|
2302
2420
|
}),
|
|
2303
|
-
(0,
|
|
2421
|
+
(0, import_promises11.writeFile)(import_node_path14.default.join(targetDir, ".gitignore"), "node_modules\n.artifacts\ntarget\n", {
|
|
2304
2422
|
encoding: "utf8",
|
|
2305
2423
|
flag: force ? "w" : "wx"
|
|
2306
2424
|
}),
|
|
2307
|
-
(0,
|
|
2425
|
+
(0, import_promises11.writeFile)(import_node_path14.default.join(targetDir, "README.md"), readmeSource2(options.projectName), {
|
|
2308
2426
|
encoding: "utf8",
|
|
2309
2427
|
flag: force ? "w" : "wx"
|
|
2310
2428
|
})
|
|
2311
2429
|
]);
|
|
2312
|
-
await (0,
|
|
2313
|
-
await (0,
|
|
2314
|
-
|
|
2315
|
-
|
|
2430
|
+
await (0, import_promises11.mkdir)(import_node_path14.default.join(targetDir, "contracts"), { recursive: true });
|
|
2431
|
+
await (0, import_promises11.cp)(
|
|
2432
|
+
import_node_path14.default.join(scaffoldRoot2(), "soroban-contract-stub"),
|
|
2433
|
+
import_node_path14.default.join(targetDir, "contracts", "app"),
|
|
2316
2434
|
{
|
|
2317
2435
|
recursive: true,
|
|
2318
2436
|
force,
|
package/dist/index.js
CHANGED
|
@@ -1517,8 +1517,101 @@ async function deployContractGraph(options) {
|
|
|
1517
1517
|
}
|
|
1518
1518
|
|
|
1519
1519
|
// src/contracts/generate-bindings.ts
|
|
1520
|
-
import { access as
|
|
1520
|
+
import { access as access4, mkdir as mkdir2, unlink } from "fs/promises";
|
|
1521
|
+
import path11 from "path";
|
|
1522
|
+
|
|
1523
|
+
// src/bindings/patch-generated-binding-package.ts
|
|
1524
|
+
import { access as access3, readFile as readFile4, writeFile as writeFile3 } from "fs/promises";
|
|
1521
1525
|
import path10 from "path";
|
|
1526
|
+
var BUNDLER_ENTRY = "./src/index.ts";
|
|
1527
|
+
var ROOT_BINDING_INDEX_CONTENT = 'export * from "./src/index.js";\n';
|
|
1528
|
+
function resolveExportEntry(exportsField) {
|
|
1529
|
+
if (!exportsField) {
|
|
1530
|
+
return void 0;
|
|
1531
|
+
}
|
|
1532
|
+
const rootExport = exportsField["."];
|
|
1533
|
+
if (typeof rootExport === "string") {
|
|
1534
|
+
return rootExport;
|
|
1535
|
+
}
|
|
1536
|
+
if (rootExport && typeof rootExport === "object" && !Array.isArray(rootExport)) {
|
|
1537
|
+
const conditions = rootExport;
|
|
1538
|
+
for (const key of ["import", "default", "types"]) {
|
|
1539
|
+
const value = conditions[key];
|
|
1540
|
+
if (typeof value === "string") {
|
|
1541
|
+
return value;
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
}
|
|
1545
|
+
return void 0;
|
|
1546
|
+
}
|
|
1547
|
+
function pointsToDist(main) {
|
|
1548
|
+
return typeof main === "string" && main.replace(/^\.\//, "").startsWith("dist/");
|
|
1549
|
+
}
|
|
1550
|
+
function pointsToBundlerSource(entry) {
|
|
1551
|
+
return entry === BUNDLER_ENTRY || entry === "./src/index.js";
|
|
1552
|
+
}
|
|
1553
|
+
function shouldPatchPackageJson(packageJson) {
|
|
1554
|
+
const exportEntry = resolveExportEntry(
|
|
1555
|
+
typeof packageJson.exports === "object" && packageJson.exports !== null && !Array.isArray(packageJson.exports) ? packageJson.exports : void 0
|
|
1556
|
+
);
|
|
1557
|
+
return pointsToDist(packageJson.main) || pointsToDist(packageJson.types) || !pointsToBundlerSource(exportEntry);
|
|
1558
|
+
}
|
|
1559
|
+
async function ensureRootBindingIndex(outputDir) {
|
|
1560
|
+
const rootIndexPath = path10.join(outputDir, "index.ts");
|
|
1561
|
+
try {
|
|
1562
|
+
const existing = await readFile4(rootIndexPath, "utf8");
|
|
1563
|
+
if (existing === ROOT_BINDING_INDEX_CONTENT) {
|
|
1564
|
+
return;
|
|
1565
|
+
}
|
|
1566
|
+
return;
|
|
1567
|
+
} catch {
|
|
1568
|
+
await writeFile3(rootIndexPath, ROOT_BINDING_INDEX_CONTENT, "utf8");
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
async function patchGeneratedBindingPackage(outputDir) {
|
|
1572
|
+
const packageJsonPath = path10.join(outputDir, "package.json");
|
|
1573
|
+
const entryPath = path10.join(outputDir, "src", "index.ts");
|
|
1574
|
+
try {
|
|
1575
|
+
await access3(entryPath);
|
|
1576
|
+
} catch {
|
|
1577
|
+
throw new CaatingaError(
|
|
1578
|
+
"Generated binding package is missing src/index.ts.",
|
|
1579
|
+
CaatingaErrorCode.BINDINGS_FAILED,
|
|
1580
|
+
"Re-run caatinga generate or check @stellar/stellar-sdk generate output."
|
|
1581
|
+
);
|
|
1582
|
+
}
|
|
1583
|
+
let raw;
|
|
1584
|
+
try {
|
|
1585
|
+
raw = await readFile4(packageJsonPath, "utf8");
|
|
1586
|
+
} catch {
|
|
1587
|
+
throw new CaatingaError(
|
|
1588
|
+
"Generated binding package is missing package.json.",
|
|
1589
|
+
CaatingaErrorCode.BINDINGS_FAILED,
|
|
1590
|
+
"Re-run caatinga generate or check @stellar/stellar-sdk generate output."
|
|
1591
|
+
);
|
|
1592
|
+
}
|
|
1593
|
+
let packageJson;
|
|
1594
|
+
try {
|
|
1595
|
+
packageJson = JSON.parse(raw);
|
|
1596
|
+
} catch {
|
|
1597
|
+
throw new CaatingaError(
|
|
1598
|
+
"Generated binding package.json is not valid JSON.",
|
|
1599
|
+
CaatingaErrorCode.BINDINGS_FAILED,
|
|
1600
|
+
"Re-run caatinga generate or check @stellar/stellar-sdk generate output."
|
|
1601
|
+
);
|
|
1602
|
+
}
|
|
1603
|
+
if (shouldPatchPackageJson(packageJson)) {
|
|
1604
|
+
packageJson.main = BUNDLER_ENTRY;
|
|
1605
|
+
packageJson.types = BUNDLER_ENTRY;
|
|
1606
|
+
packageJson.exports = {
|
|
1607
|
+
...typeof packageJson.exports === "object" && packageJson.exports !== null && !Array.isArray(packageJson.exports) ? packageJson.exports : {},
|
|
1608
|
+
".": BUNDLER_ENTRY
|
|
1609
|
+
};
|
|
1610
|
+
await writeFile3(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}
|
|
1611
|
+
`, "utf8");
|
|
1612
|
+
}
|
|
1613
|
+
await ensureRootBindingIndex(outputDir);
|
|
1614
|
+
}
|
|
1522
1615
|
|
|
1523
1616
|
// src/contracts/build-generate-network-args.ts
|
|
1524
1617
|
function buildGenerateNetworkArgs(network) {
|
|
@@ -1530,13 +1623,13 @@ function buildGenerateNetworkArgs(network) {
|
|
|
1530
1623
|
|
|
1531
1624
|
// src/contracts/generate-bindings.ts
|
|
1532
1625
|
function toBindingImportPath(bindingsOutput, contractName) {
|
|
1533
|
-
const normalized = bindingsOutput.replace(/^\.\//, "").split(
|
|
1534
|
-
return `./${
|
|
1626
|
+
const normalized = bindingsOutput.replace(/^\.\//, "").split(path11.sep).join("/");
|
|
1627
|
+
return `./${path11.posix.join(normalized, contractName)}`;
|
|
1535
1628
|
}
|
|
1536
1629
|
async function removeLegacyBindingStub(cwd, bindingsOutput, contractName) {
|
|
1537
|
-
const legacyPath =
|
|
1630
|
+
const legacyPath = path11.resolve(cwd, bindingsOutput, `${contractName}.ts`);
|
|
1538
1631
|
try {
|
|
1539
|
-
await
|
|
1632
|
+
await access4(legacyPath);
|
|
1540
1633
|
await unlink(legacyPath);
|
|
1541
1634
|
return true;
|
|
1542
1635
|
} catch {
|
|
@@ -1562,7 +1655,7 @@ async function generateBindings(options) {
|
|
|
1562
1655
|
"Run caatinga deploy for this contract and network before generating bindings."
|
|
1563
1656
|
);
|
|
1564
1657
|
}
|
|
1565
|
-
const outputDir =
|
|
1658
|
+
const outputDir = path11.resolve(cwd, options.config.frontend.bindingsOutput, options.contractName);
|
|
1566
1659
|
await mkdir2(outputDir, { recursive: true });
|
|
1567
1660
|
const result = await runCommand(
|
|
1568
1661
|
"npx",
|
|
@@ -1589,6 +1682,7 @@ async function generateBindings(options) {
|
|
|
1589
1682
|
options.config.frontend.bindingsOutput,
|
|
1590
1683
|
options.contractName
|
|
1591
1684
|
);
|
|
1685
|
+
await patchGeneratedBindingPackage(outputDir);
|
|
1592
1686
|
const marker = {
|
|
1593
1687
|
version: 1,
|
|
1594
1688
|
contractId: contractArtifact.contractId,
|
|
@@ -1788,8 +1882,8 @@ async function readContract(options) {
|
|
|
1788
1882
|
}
|
|
1789
1883
|
|
|
1790
1884
|
// src/templates/create-project-from-template.ts
|
|
1791
|
-
import { cp, mkdir as mkdir3, readFile as
|
|
1792
|
-
import
|
|
1885
|
+
import { cp, mkdir as mkdir3, readFile as readFile5, readdir as readdir3, stat as stat2, writeFile as writeFile4 } from "fs/promises";
|
|
1886
|
+
import path12 from "path";
|
|
1793
1887
|
import { z as z7 } from "zod";
|
|
1794
1888
|
|
|
1795
1889
|
// src/templates/template-manifest.schema.ts
|
|
@@ -1860,8 +1954,8 @@ function formatTemplateCompatibilityHint(issue) {
|
|
|
1860
1954
|
// src/templates/create-project-from-template.ts
|
|
1861
1955
|
var TEMPLATE_COPY_EXCLUDED_DIRS = /* @__PURE__ */ new Set(["target", "test_snapshots", "node_modules", ".git"]);
|
|
1862
1956
|
async function createProjectFromTemplate(options) {
|
|
1863
|
-
const targetDir =
|
|
1864
|
-
const templateDir =
|
|
1957
|
+
const targetDir = path12.resolve(options.targetDir);
|
|
1958
|
+
const templateDir = path12.resolve(options.templateDir);
|
|
1865
1959
|
try {
|
|
1866
1960
|
await stat2(templateDir);
|
|
1867
1961
|
} catch {
|
|
@@ -1876,8 +1970,8 @@ async function createProjectFromTemplate(options) {
|
|
|
1876
1970
|
await mkdir3(targetDir, { recursive: true });
|
|
1877
1971
|
await cp(templateDir, targetDir, {
|
|
1878
1972
|
recursive: true,
|
|
1879
|
-
force:
|
|
1880
|
-
errorOnExist:
|
|
1973
|
+
force: true,
|
|
1974
|
+
errorOnExist: false,
|
|
1881
1975
|
filter: (source) => shouldCopyTemplateEntry(templateDir, source, options.filter)
|
|
1882
1976
|
});
|
|
1883
1977
|
await replaceTemplateVariables(targetDir, options.projectName);
|
|
@@ -1902,9 +1996,9 @@ async function ensureArtifacts(targetDir, projectName) {
|
|
|
1902
1996
|
}
|
|
1903
1997
|
}
|
|
1904
1998
|
async function readTemplateManifest(templateDir) {
|
|
1905
|
-
const manifestPath =
|
|
1999
|
+
const manifestPath = path12.join(templateDir, "caatinga.template.json");
|
|
1906
2000
|
try {
|
|
1907
|
-
const rawManifest = await
|
|
2001
|
+
const rawManifest = await readFile5(manifestPath, "utf8");
|
|
1908
2002
|
const manifest = TemplateManifestSchema.parse(JSON.parse(rawManifest));
|
|
1909
2003
|
const compatibilityIssue = getTemplateCompatibilityIssue(manifest);
|
|
1910
2004
|
if (compatibilityIssue) {
|
|
@@ -1940,7 +2034,7 @@ async function replaceTemplateVariables(dir, projectName) {
|
|
|
1940
2034
|
const entries = await readdir3(dir);
|
|
1941
2035
|
await Promise.all(
|
|
1942
2036
|
entries.map(async (entry) => {
|
|
1943
|
-
const entryPath =
|
|
2037
|
+
const entryPath = path12.join(dir, entry);
|
|
1944
2038
|
const entryStat = await stat2(entryPath);
|
|
1945
2039
|
if (entryStat.isDirectory()) {
|
|
1946
2040
|
await replaceTemplateVariables(entryPath, projectName);
|
|
@@ -1949,38 +2043,38 @@ async function replaceTemplateVariables(dir, projectName) {
|
|
|
1949
2043
|
if (!isTextTemplateFile(entryPath)) {
|
|
1950
2044
|
return;
|
|
1951
2045
|
}
|
|
1952
|
-
const content = await
|
|
1953
|
-
await
|
|
2046
|
+
const content = await readFile5(entryPath, "utf8");
|
|
2047
|
+
await writeFile4(entryPath, content.replaceAll("__PROJECT_NAME__", projectName), "utf8");
|
|
1954
2048
|
})
|
|
1955
2049
|
);
|
|
1956
2050
|
}
|
|
1957
2051
|
function shouldCopyTemplateEntry(templateDir, source, userFilter) {
|
|
1958
|
-
const relativePath =
|
|
2052
|
+
const relativePath = path12.relative(templateDir, source);
|
|
1959
2053
|
if (!relativePath || relativePath === ".") {
|
|
1960
2054
|
return true;
|
|
1961
2055
|
}
|
|
1962
|
-
const normalizedPath = relativePath.split(
|
|
2056
|
+
const normalizedPath = relativePath.split(path12.sep).join("/");
|
|
1963
2057
|
if (userFilter && !userFilter(normalizedPath)) {
|
|
1964
2058
|
return false;
|
|
1965
2059
|
}
|
|
1966
|
-
return !relativePath.split(
|
|
2060
|
+
return !relativePath.split(path12.sep).some((segment) => TEMPLATE_COPY_EXCLUDED_DIRS.has(segment));
|
|
1967
2061
|
}
|
|
1968
2062
|
function isTextTemplateFile(filePath) {
|
|
1969
2063
|
return [".json", ".md", ".rs", ".toml", ".ts", ".tsx", ".css", ".html"].includes(
|
|
1970
|
-
|
|
2064
|
+
path12.extname(filePath)
|
|
1971
2065
|
);
|
|
1972
2066
|
}
|
|
1973
2067
|
|
|
1974
2068
|
// src/scaffold/create-zk-project.ts
|
|
1975
|
-
import { cp as cp2, mkdir as mkdir4, writeFile as
|
|
2069
|
+
import { cp as cp2, mkdir as mkdir4, writeFile as writeFile5 } from "fs/promises";
|
|
1976
2070
|
import { existsSync as existsSync2 } from "fs";
|
|
1977
|
-
import
|
|
2071
|
+
import path13 from "path";
|
|
1978
2072
|
import { fileURLToPath } from "url";
|
|
1979
|
-
var moduleDir = typeof __dirname === "string" ? __dirname :
|
|
2073
|
+
var moduleDir = typeof __dirname === "string" ? __dirname : path13.dirname(fileURLToPath(import.meta.url));
|
|
1980
2074
|
function scaffoldRoot() {
|
|
1981
2075
|
const candidates = [
|
|
1982
|
-
|
|
1983
|
-
|
|
2076
|
+
path13.resolve(moduleDir, "../../scaffolds"),
|
|
2077
|
+
path13.resolve(moduleDir, "../scaffolds")
|
|
1984
2078
|
];
|
|
1985
2079
|
const found = candidates.find((candidate) => existsSync2(candidate));
|
|
1986
2080
|
return found ?? candidates[0];
|
|
@@ -2028,7 +2122,8 @@ function packageJsonSource(projectName) {
|
|
|
2028
2122
|
"zk:prove": "caatinga zk prove main",
|
|
2029
2123
|
build: "caatinga build verifier",
|
|
2030
2124
|
deploy: "caatinga deploy verifier --network testnet --source ${CAATINGA_SOURCE:-alice}",
|
|
2031
|
-
doctor: "caatinga doctor --network testnet"
|
|
2125
|
+
doctor: "caatinga doctor --network testnet",
|
|
2126
|
+
test: "cargo test --manifest-path contracts/verifier/Cargo.toml"
|
|
2032
2127
|
},
|
|
2033
2128
|
devDependencies: {
|
|
2034
2129
|
"@caatinga/cli": `^${CAATINGA_CORE_VERSION}`,
|
|
@@ -2049,49 +2144,60 @@ Minimal Caatinga ZK project.
|
|
|
2049
2144
|
|
|
2050
2145
|
\`\`\`bash
|
|
2051
2146
|
npm install
|
|
2147
|
+
npm test
|
|
2052
2148
|
npx caatinga zk build main
|
|
2053
2149
|
npx caatinga build verifier
|
|
2054
2150
|
npx caatinga deploy verifier --network testnet --source <identity>
|
|
2055
2151
|
npx caatinga zk prove main
|
|
2056
2152
|
\`\`\`
|
|
2057
2153
|
|
|
2154
|
+
## Tests
|
|
2155
|
+
|
|
2156
|
+
Run the Rust verifier contract tests from the project root:
|
|
2157
|
+
|
|
2158
|
+
\`\`\`bash
|
|
2159
|
+
npm test
|
|
2160
|
+
# or directly:
|
|
2161
|
+
cargo test --manifest-path contracts/verifier/Cargo.toml
|
|
2162
|
+
\`\`\`
|
|
2163
|
+
|
|
2058
2164
|
Replace \`circuits/main.circom\` with your circuit. Keep the entry point named \`main\`.
|
|
2059
2165
|
`;
|
|
2060
2166
|
}
|
|
2061
2167
|
async function createZkProject(options) {
|
|
2062
|
-
const targetDir =
|
|
2168
|
+
const targetDir = path13.resolve(options.targetDir);
|
|
2063
2169
|
const force = options.force ?? false;
|
|
2064
2170
|
const projectFiles = options.projectFiles ?? true;
|
|
2065
2171
|
await mkdir4(targetDir, { recursive: true });
|
|
2066
2172
|
if (projectFiles) {
|
|
2067
2173
|
await Promise.all([
|
|
2068
|
-
|
|
2174
|
+
writeFile5(path13.join(targetDir, "caatinga.config.ts"), configSource(options.projectName), {
|
|
2069
2175
|
encoding: "utf8",
|
|
2070
2176
|
flag: force ? "w" : "wx"
|
|
2071
2177
|
}),
|
|
2072
|
-
|
|
2178
|
+
writeFile5(path13.join(targetDir, "package.json"), packageJsonSource(options.projectName), {
|
|
2073
2179
|
encoding: "utf8",
|
|
2074
2180
|
flag: force ? "w" : "wx"
|
|
2075
2181
|
}),
|
|
2076
|
-
|
|
2182
|
+
writeFile5(path13.join(targetDir, ".gitignore"), "node_modules\n.artifacts\ntarget\n", {
|
|
2077
2183
|
encoding: "utf8",
|
|
2078
2184
|
flag: force ? "w" : "wx"
|
|
2079
2185
|
}),
|
|
2080
|
-
|
|
2186
|
+
writeFile5(path13.join(targetDir, "README.md"), readmeSource(options.projectName), {
|
|
2081
2187
|
encoding: "utf8",
|
|
2082
2188
|
flag: force ? "w" : "wx"
|
|
2083
2189
|
})
|
|
2084
2190
|
]);
|
|
2085
2191
|
}
|
|
2086
|
-
await mkdir4(
|
|
2087
|
-
await cp2(
|
|
2192
|
+
await mkdir4(path13.join(targetDir, "contracts"), { recursive: true });
|
|
2193
|
+
await cp2(path13.join(scaffoldRoot(), "zk-circuit-stub"), path13.join(targetDir, "circuits"), {
|
|
2088
2194
|
recursive: true,
|
|
2089
2195
|
force,
|
|
2090
2196
|
errorOnExist: !force
|
|
2091
2197
|
});
|
|
2092
2198
|
await cp2(
|
|
2093
|
-
|
|
2094
|
-
|
|
2199
|
+
path13.join(scaffoldRoot(), "zk-verifier"),
|
|
2200
|
+
path13.join(targetDir, "contracts", "verifier"),
|
|
2095
2201
|
{
|
|
2096
2202
|
recursive: true,
|
|
2097
2203
|
force,
|
|
@@ -2108,15 +2214,15 @@ async function createZkProject(options) {
|
|
|
2108
2214
|
}
|
|
2109
2215
|
|
|
2110
2216
|
// src/scaffold/create-minimal-project.ts
|
|
2111
|
-
import { cp as cp3, mkdir as mkdir5, writeFile as
|
|
2217
|
+
import { cp as cp3, mkdir as mkdir5, writeFile as writeFile6 } from "fs/promises";
|
|
2112
2218
|
import { existsSync as existsSync3 } from "fs";
|
|
2113
|
-
import
|
|
2219
|
+
import path14 from "path";
|
|
2114
2220
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
2115
|
-
var moduleDir2 = typeof __dirname === "string" ? __dirname :
|
|
2221
|
+
var moduleDir2 = typeof __dirname === "string" ? __dirname : path14.dirname(fileURLToPath2(import.meta.url));
|
|
2116
2222
|
function scaffoldRoot2() {
|
|
2117
2223
|
const candidates = [
|
|
2118
|
-
|
|
2119
|
-
|
|
2224
|
+
path14.resolve(moduleDir2, "../../scaffolds"),
|
|
2225
|
+
path14.resolve(moduleDir2, "../scaffolds")
|
|
2120
2226
|
];
|
|
2121
2227
|
const found = candidates.find((candidate) => existsSync3(candidate));
|
|
2122
2228
|
return found ?? candidates[0];
|
|
@@ -2153,6 +2259,7 @@ function packageJsonSource2(projectName) {
|
|
|
2153
2259
|
build: "caatinga build app",
|
|
2154
2260
|
deploy: "caatinga deploy app --network testnet --source ${CAATINGA_SOURCE:-alice}",
|
|
2155
2261
|
doctor: "caatinga doctor --network testnet",
|
|
2262
|
+
test: "cargo test --manifest-path contracts/app/Cargo.toml",
|
|
2156
2263
|
"read:hello": "caatinga read app.hello --network testnet --source ${CAATINGA_SOURCE:-alice}",
|
|
2157
2264
|
"read:version": "caatinga read app.version --network testnet --source ${CAATINGA_SOURCE:-alice}"
|
|
2158
2265
|
},
|
|
@@ -2175,6 +2282,7 @@ Minimal Caatinga project with a Soroban contract stub (no frontend template).
|
|
|
2175
2282
|
|
|
2176
2283
|
\`\`\`bash
|
|
2177
2284
|
npm install
|
|
2285
|
+
npm test
|
|
2178
2286
|
npx caatinga doctor
|
|
2179
2287
|
npx caatinga build app
|
|
2180
2288
|
npx caatinga deploy app --network testnet --source <identity>
|
|
@@ -2182,6 +2290,16 @@ npx caatinga read app.version --network testnet
|
|
|
2182
2290
|
npx caatinga read app.hello --network testnet
|
|
2183
2291
|
\`\`\`
|
|
2184
2292
|
|
|
2293
|
+
## Tests
|
|
2294
|
+
|
|
2295
|
+
Run the Rust contract tests from the project root:
|
|
2296
|
+
|
|
2297
|
+
\`\`\`bash
|
|
2298
|
+
npm test
|
|
2299
|
+
# or directly:
|
|
2300
|
+
cargo test --manifest-path contracts/app/Cargo.toml
|
|
2301
|
+
\`\`\`
|
|
2302
|
+
|
|
2185
2303
|
## Contract
|
|
2186
2304
|
|
|
2187
2305
|
- \`hello()\` \u2014 read-only; returns Soroban Symbol \`hello\`
|
|
@@ -2195,31 +2313,31 @@ Edit \`contracts/app/src/lib.rs\` to customize the contract. Add a frontend late
|
|
|
2195
2313
|
`;
|
|
2196
2314
|
}
|
|
2197
2315
|
async function createMinimalProject(options) {
|
|
2198
|
-
const targetDir =
|
|
2316
|
+
const targetDir = path14.resolve(options.targetDir);
|
|
2199
2317
|
const force = options.force ?? false;
|
|
2200
2318
|
await mkdir5(targetDir, { recursive: true });
|
|
2201
2319
|
await Promise.all([
|
|
2202
|
-
|
|
2320
|
+
writeFile6(path14.join(targetDir, "caatinga.config.ts"), configSource2(options.projectName), {
|
|
2203
2321
|
encoding: "utf8",
|
|
2204
2322
|
flag: force ? "w" : "wx"
|
|
2205
2323
|
}),
|
|
2206
|
-
|
|
2324
|
+
writeFile6(path14.join(targetDir, "package.json"), packageJsonSource2(options.projectName), {
|
|
2207
2325
|
encoding: "utf8",
|
|
2208
2326
|
flag: force ? "w" : "wx"
|
|
2209
2327
|
}),
|
|
2210
|
-
|
|
2328
|
+
writeFile6(path14.join(targetDir, ".gitignore"), "node_modules\n.artifacts\ntarget\n", {
|
|
2211
2329
|
encoding: "utf8",
|
|
2212
2330
|
flag: force ? "w" : "wx"
|
|
2213
2331
|
}),
|
|
2214
|
-
|
|
2332
|
+
writeFile6(path14.join(targetDir, "README.md"), readmeSource2(options.projectName), {
|
|
2215
2333
|
encoding: "utf8",
|
|
2216
2334
|
flag: force ? "w" : "wx"
|
|
2217
2335
|
})
|
|
2218
2336
|
]);
|
|
2219
|
-
await mkdir5(
|
|
2337
|
+
await mkdir5(path14.join(targetDir, "contracts"), { recursive: true });
|
|
2220
2338
|
await cp3(
|
|
2221
|
-
|
|
2222
|
-
|
|
2339
|
+
path14.join(scaffoldRoot2(), "soroban-contract-stub"),
|
|
2340
|
+
path14.join(targetDir, "contracts", "app"),
|
|
2223
2341
|
{
|
|
2224
2342
|
recursive: true,
|
|
2225
2343
|
force,
|
package/package.json
CHANGED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
declare const CaatingaErrorCode: {
|
|
4
|
-
readonly CONFIG_NOT_FOUND: "CAATINGA_CONFIG_NOT_FOUND";
|
|
5
|
-
readonly DEPENDENCIES_NOT_INSTALLED: "CAATINGA_DEPENDENCIES_NOT_INSTALLED";
|
|
6
|
-
readonly INVALID_CONFIG: "CAATINGA_INVALID_CONFIG";
|
|
7
|
-
readonly COMMAND_FAILED: "CAATINGA_COMMAND_FAILED";
|
|
8
|
-
readonly UNEXPECTED_ERROR: "CAATINGA_UNEXPECTED_ERROR";
|
|
9
|
-
readonly STELLAR_CLI_NOT_FOUND: "CAATINGA_STELLAR_CLI_NOT_FOUND";
|
|
10
|
-
readonly STELLAR_CLI_VERSION_PARSE_FAILED: "CAATINGA_STELLAR_CLI_VERSION_PARSE_FAILED";
|
|
11
|
-
readonly UNSUPPORTED_CLI_VERSION: "CAATINGA_UNSUPPORTED_CLI_VERSION";
|
|
12
|
-
readonly RUST_NOT_FOUND: "CAATINGA_RUST_NOT_FOUND";
|
|
13
|
-
readonly RUST_TARGET_NOT_FOUND: "CAATINGA_RUST_TARGET_NOT_FOUND";
|
|
14
|
-
readonly DEPLOY_FAILED: "CAATINGA_DEPLOY_FAILED";
|
|
15
|
-
readonly BUILD_FAILED: "CAATINGA_BUILD_FAILED";
|
|
16
|
-
readonly BINDINGS_FAILED: "CAATINGA_BINDINGS_FAILED";
|
|
17
|
-
readonly INVOKE_FAILED: "CAATINGA_INVOKE_FAILED";
|
|
18
|
-
readonly CONTRACT_NOT_FOUND: "CAATINGA_CONTRACT_NOT_FOUND";
|
|
19
|
-
readonly NETWORK_NOT_FOUND: "CAATINGA_NETWORK_NOT_FOUND";
|
|
20
|
-
readonly ARTIFACT_NOT_FOUND: "CAATINGA_ARTIFACT_NOT_FOUND";
|
|
21
|
-
readonly ARTIFACT_INVALID: "CAATINGA_ARTIFACT_INVALID";
|
|
22
|
-
readonly CONTRACT_ID_NOT_FOUND: "CAATINGA_CONTRACT_ID_NOT_FOUND";
|
|
23
|
-
readonly CONTRACT_ARTIFACT_NOT_FOUND: "CAATINGA_CONTRACT_ARTIFACT_NOT_FOUND";
|
|
24
|
-
readonly CONTRACT_DEPENDENCY_NOT_FOUND: "CAATINGA_CONTRACT_DEPENDENCY_NOT_FOUND";
|
|
25
|
-
readonly CONTRACT_DEPENDENCY_CYCLE: "CAATINGA_CONTRACT_DEPENDENCY_CYCLE";
|
|
26
|
-
readonly CONTRACT_DEPENDENCY_ARTIFACT_NOT_FOUND: "CAATINGA_CONTRACT_DEPENDENCY_ARTIFACT_NOT_FOUND";
|
|
27
|
-
readonly DEPENDENCY_CONTRACT_NOT_FOUND: "CAATINGA_DEPENDENCY_CONTRACT_NOT_FOUND";
|
|
28
|
-
readonly DEPLOY_ARG_PLACEHOLDER_INVALID: "CAATINGA_DEPLOY_ARG_PLACEHOLDER_INVALID";
|
|
29
|
-
readonly DEPLOY_ARG_PLACEHOLDER_UNRESOLVED: "CAATINGA_DEPLOY_ARG_PLACEHOLDER_UNRESOLVED";
|
|
30
|
-
readonly BINDING_CLIENT_NOT_FOUND: "CAATINGA_BINDING_CLIENT_NOT_FOUND";
|
|
31
|
-
readonly BINDING_METHOD_NOT_FOUND: "CAATINGA_BINDING_METHOD_NOT_FOUND";
|
|
32
|
-
readonly PLACEHOLDER_BINDING: "CAATINGA_PLACEHOLDER_BINDING";
|
|
33
|
-
readonly XDR_BUILD_FAILED: "CAATINGA_XDR_BUILD_FAILED";
|
|
34
|
-
readonly XDR_PREPARE_FAILED: "CAATINGA_XDR_PREPARE_FAILED";
|
|
35
|
-
readonly XDR_SIGN_FAILED: "CAATINGA_XDR_SIGN_FAILED";
|
|
36
|
-
readonly XDR_SUBMIT_FAILED: "CAATINGA_XDR_SUBMIT_FAILED";
|
|
37
|
-
readonly XDR_RESULT_FAILED: "CAATINGA_XDR_RESULT_FAILED";
|
|
38
|
-
readonly READ_RESULT_MISSING: "CAATINGA_READ_RESULT_MISSING";
|
|
39
|
-
readonly WALLET_NOT_CONNECTED: "CAATINGA_WALLET_NOT_CONNECTED";
|
|
40
|
-
readonly WALLET_TIMEOUT: "CAATINGA_WALLET_TIMEOUT";
|
|
41
|
-
readonly SOURCE_ACCOUNT_REQUIRED: "CAATINGA_SOURCE_ACCOUNT_REQUIRED";
|
|
42
|
-
readonly SOURCE_IS_SECRET_KEY: "CAATINGA_SOURCE_IS_SECRET_KEY";
|
|
43
|
-
readonly SOURCE_IS_SEED_PHRASE: "CAATINGA_SOURCE_IS_SEED_PHRASE";
|
|
44
|
-
readonly SOURCE_IS_PUBLIC_KEY: "CAATINGA_SOURCE_IS_PUBLIC_KEY";
|
|
45
|
-
readonly UNSAFE_SOURCE_ACCOUNT: "CAATINGA_UNSAFE_SOURCE_ACCOUNT";
|
|
46
|
-
readonly INVOKE_TARGET_INVALID: "CAATINGA_INVOKE_TARGET_INVALID";
|
|
47
|
-
readonly TEMPLATE_NOT_FOUND: "CAATINGA_TEMPLATE_NOT_FOUND";
|
|
48
|
-
readonly INVALID_TEMPLATE_MANIFEST: "CAATINGA_INVALID_TEMPLATE_MANIFEST";
|
|
49
|
-
readonly TEMPLATE_MANIFEST_NOT_FOUND: "CAATINGA_TEMPLATE_MANIFEST_NOT_FOUND";
|
|
50
|
-
readonly TEMPLATE_INCOMPATIBLE: "CAATINGA_TEMPLATE_INCOMPATIBLE";
|
|
51
|
-
readonly ZK_VERIFICATION_FAILED: "CAATINGA_ZK_VERIFICATION_FAILED";
|
|
52
|
-
readonly DOCTOR_PARTIAL_DEPLOY: "CAATINGA_DOCTOR_PARTIAL_DEPLOY";
|
|
53
|
-
readonly MULTI_AUTH_REQUIRED: "CAATINGA_MULTI_AUTH_REQUIRED";
|
|
54
|
-
};
|
|
55
|
-
type CaatingaErrorCodeValue = typeof CaatingaErrorCode[keyof typeof CaatingaErrorCode];
|
|
56
|
-
|
|
57
|
-
declare class CaatingaError extends Error {
|
|
58
|
-
readonly code: CaatingaErrorCodeValue;
|
|
59
|
-
readonly hint?: string | undefined;
|
|
60
|
-
readonly cause?: unknown | undefined;
|
|
61
|
-
constructor(message: string, code: CaatingaErrorCodeValue, hint?: string | undefined, cause?: unknown | undefined);
|
|
62
|
-
}
|
|
63
|
-
declare function toCaatingaError(error: unknown): CaatingaError;
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Render an error for display. For a {@link CaatingaError} this surfaces the
|
|
67
|
-
* code, message, and hint, plus the underlying `cause` (when present) so the
|
|
68
|
-
* real reason — e.g. a wallet rejection or an XDR parse error — is never hidden
|
|
69
|
-
* behind a generic hint. Falls back to the plain message for other errors.
|
|
70
|
-
*/
|
|
71
|
-
declare function formatCaatingaError(error: unknown): string;
|
|
72
|
-
|
|
73
|
-
declare const ContractArtifactSchema: z.ZodObject<{
|
|
74
|
-
contractId: z.ZodString;
|
|
75
|
-
wasmHash: z.ZodString;
|
|
76
|
-
deployedAt: z.ZodString;
|
|
77
|
-
sourcePath: z.ZodString;
|
|
78
|
-
wasmPath: z.ZodString;
|
|
79
|
-
dependencies: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
80
|
-
resolvedDeployArgs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
81
|
-
}, "strip", z.ZodTypeAny, {
|
|
82
|
-
contractId: string;
|
|
83
|
-
wasmHash: string;
|
|
84
|
-
deployedAt: string;
|
|
85
|
-
sourcePath: string;
|
|
86
|
-
wasmPath: string;
|
|
87
|
-
dependencies: string[];
|
|
88
|
-
resolvedDeployArgs: Record<string, string | number | boolean>;
|
|
89
|
-
}, {
|
|
90
|
-
contractId: string;
|
|
91
|
-
wasmHash: string;
|
|
92
|
-
deployedAt: string;
|
|
93
|
-
sourcePath: string;
|
|
94
|
-
wasmPath: string;
|
|
95
|
-
dependencies?: string[] | undefined;
|
|
96
|
-
resolvedDeployArgs?: Record<string, string | number | boolean> | undefined;
|
|
97
|
-
}>;
|
|
98
|
-
declare const CaatingaArtifactsSchema: z.ZodObject<{
|
|
99
|
-
project: z.ZodString;
|
|
100
|
-
version: z.ZodLiteral<1>;
|
|
101
|
-
networks: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
102
|
-
contracts: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
103
|
-
contractId: z.ZodString;
|
|
104
|
-
wasmHash: z.ZodString;
|
|
105
|
-
deployedAt: z.ZodString;
|
|
106
|
-
sourcePath: z.ZodString;
|
|
107
|
-
wasmPath: z.ZodString;
|
|
108
|
-
dependencies: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
109
|
-
resolvedDeployArgs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
110
|
-
}, "strip", z.ZodTypeAny, {
|
|
111
|
-
contractId: string;
|
|
112
|
-
wasmHash: string;
|
|
113
|
-
deployedAt: string;
|
|
114
|
-
sourcePath: string;
|
|
115
|
-
wasmPath: string;
|
|
116
|
-
dependencies: string[];
|
|
117
|
-
resolvedDeployArgs: Record<string, string | number | boolean>;
|
|
118
|
-
}, {
|
|
119
|
-
contractId: string;
|
|
120
|
-
wasmHash: string;
|
|
121
|
-
deployedAt: string;
|
|
122
|
-
sourcePath: string;
|
|
123
|
-
wasmPath: string;
|
|
124
|
-
dependencies?: string[] | undefined;
|
|
125
|
-
resolvedDeployArgs?: Record<string, string | number | boolean> | undefined;
|
|
126
|
-
}>>>;
|
|
127
|
-
dependencyGraph: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
|
|
128
|
-
}, "strip", z.ZodTypeAny, {
|
|
129
|
-
contracts: Record<string, {
|
|
130
|
-
contractId: string;
|
|
131
|
-
wasmHash: string;
|
|
132
|
-
deployedAt: string;
|
|
133
|
-
sourcePath: string;
|
|
134
|
-
wasmPath: string;
|
|
135
|
-
dependencies: string[];
|
|
136
|
-
resolvedDeployArgs: Record<string, string | number | boolean>;
|
|
137
|
-
}>;
|
|
138
|
-
dependencyGraph: Record<string, string[]>;
|
|
139
|
-
}, {
|
|
140
|
-
contracts?: Record<string, {
|
|
141
|
-
contractId: string;
|
|
142
|
-
wasmHash: string;
|
|
143
|
-
deployedAt: string;
|
|
144
|
-
sourcePath: string;
|
|
145
|
-
wasmPath: string;
|
|
146
|
-
dependencies?: string[] | undefined;
|
|
147
|
-
resolvedDeployArgs?: Record<string, string | number | boolean> | undefined;
|
|
148
|
-
}> | undefined;
|
|
149
|
-
dependencyGraph?: Record<string, string[]> | undefined;
|
|
150
|
-
}>>>;
|
|
151
|
-
}, "strip", z.ZodTypeAny, {
|
|
152
|
-
project: string;
|
|
153
|
-
version: 1;
|
|
154
|
-
networks: Record<string, {
|
|
155
|
-
contracts: Record<string, {
|
|
156
|
-
contractId: string;
|
|
157
|
-
wasmHash: string;
|
|
158
|
-
deployedAt: string;
|
|
159
|
-
sourcePath: string;
|
|
160
|
-
wasmPath: string;
|
|
161
|
-
dependencies: string[];
|
|
162
|
-
resolvedDeployArgs: Record<string, string | number | boolean>;
|
|
163
|
-
}>;
|
|
164
|
-
dependencyGraph: Record<string, string[]>;
|
|
165
|
-
}>;
|
|
166
|
-
}, {
|
|
167
|
-
project: string;
|
|
168
|
-
version: 1;
|
|
169
|
-
networks?: Record<string, {
|
|
170
|
-
contracts?: Record<string, {
|
|
171
|
-
contractId: string;
|
|
172
|
-
wasmHash: string;
|
|
173
|
-
deployedAt: string;
|
|
174
|
-
sourcePath: string;
|
|
175
|
-
wasmPath: string;
|
|
176
|
-
dependencies?: string[] | undefined;
|
|
177
|
-
resolvedDeployArgs?: Record<string, string | number | boolean> | undefined;
|
|
178
|
-
}> | undefined;
|
|
179
|
-
dependencyGraph?: Record<string, string[]> | undefined;
|
|
180
|
-
}> | undefined;
|
|
181
|
-
}>;
|
|
182
|
-
type ContractArtifact = z.infer<typeof ContractArtifactSchema>;
|
|
183
|
-
type CaatingaArtifacts = z.infer<typeof CaatingaArtifactsSchema>;
|
|
184
|
-
|
|
185
|
-
export { type CaatingaArtifacts as C, CaatingaError as a, CaatingaErrorCode as b, type ContractArtifact as c, type CaatingaErrorCodeValue as d, CaatingaArtifactsSchema as e, formatCaatingaError as f, toCaatingaError as t };
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
|
|
3
|
-
declare const CaatingaErrorCode: {
|
|
4
|
-
readonly CONFIG_NOT_FOUND: "CAATINGA_CONFIG_NOT_FOUND";
|
|
5
|
-
readonly DEPENDENCIES_NOT_INSTALLED: "CAATINGA_DEPENDENCIES_NOT_INSTALLED";
|
|
6
|
-
readonly INVALID_CONFIG: "CAATINGA_INVALID_CONFIG";
|
|
7
|
-
readonly COMMAND_FAILED: "CAATINGA_COMMAND_FAILED";
|
|
8
|
-
readonly UNEXPECTED_ERROR: "CAATINGA_UNEXPECTED_ERROR";
|
|
9
|
-
readonly STELLAR_CLI_NOT_FOUND: "CAATINGA_STELLAR_CLI_NOT_FOUND";
|
|
10
|
-
readonly STELLAR_CLI_VERSION_PARSE_FAILED: "CAATINGA_STELLAR_CLI_VERSION_PARSE_FAILED";
|
|
11
|
-
readonly UNSUPPORTED_CLI_VERSION: "CAATINGA_UNSUPPORTED_CLI_VERSION";
|
|
12
|
-
readonly RUST_NOT_FOUND: "CAATINGA_RUST_NOT_FOUND";
|
|
13
|
-
readonly RUST_TARGET_NOT_FOUND: "CAATINGA_RUST_TARGET_NOT_FOUND";
|
|
14
|
-
readonly DEPLOY_FAILED: "CAATINGA_DEPLOY_FAILED";
|
|
15
|
-
readonly BUILD_FAILED: "CAATINGA_BUILD_FAILED";
|
|
16
|
-
readonly BINDINGS_FAILED: "CAATINGA_BINDINGS_FAILED";
|
|
17
|
-
readonly INVOKE_FAILED: "CAATINGA_INVOKE_FAILED";
|
|
18
|
-
readonly CONTRACT_NOT_FOUND: "CAATINGA_CONTRACT_NOT_FOUND";
|
|
19
|
-
readonly NETWORK_NOT_FOUND: "CAATINGA_NETWORK_NOT_FOUND";
|
|
20
|
-
readonly ARTIFACT_NOT_FOUND: "CAATINGA_ARTIFACT_NOT_FOUND";
|
|
21
|
-
readonly ARTIFACT_INVALID: "CAATINGA_ARTIFACT_INVALID";
|
|
22
|
-
readonly CONTRACT_ID_NOT_FOUND: "CAATINGA_CONTRACT_ID_NOT_FOUND";
|
|
23
|
-
readonly CONTRACT_ARTIFACT_NOT_FOUND: "CAATINGA_CONTRACT_ARTIFACT_NOT_FOUND";
|
|
24
|
-
readonly CONTRACT_DEPENDENCY_NOT_FOUND: "CAATINGA_CONTRACT_DEPENDENCY_NOT_FOUND";
|
|
25
|
-
readonly CONTRACT_DEPENDENCY_CYCLE: "CAATINGA_CONTRACT_DEPENDENCY_CYCLE";
|
|
26
|
-
readonly CONTRACT_DEPENDENCY_ARTIFACT_NOT_FOUND: "CAATINGA_CONTRACT_DEPENDENCY_ARTIFACT_NOT_FOUND";
|
|
27
|
-
readonly DEPENDENCY_CONTRACT_NOT_FOUND: "CAATINGA_DEPENDENCY_CONTRACT_NOT_FOUND";
|
|
28
|
-
readonly DEPLOY_ARG_PLACEHOLDER_INVALID: "CAATINGA_DEPLOY_ARG_PLACEHOLDER_INVALID";
|
|
29
|
-
readonly DEPLOY_ARG_PLACEHOLDER_UNRESOLVED: "CAATINGA_DEPLOY_ARG_PLACEHOLDER_UNRESOLVED";
|
|
30
|
-
readonly BINDING_CLIENT_NOT_FOUND: "CAATINGA_BINDING_CLIENT_NOT_FOUND";
|
|
31
|
-
readonly BINDING_METHOD_NOT_FOUND: "CAATINGA_BINDING_METHOD_NOT_FOUND";
|
|
32
|
-
readonly PLACEHOLDER_BINDING: "CAATINGA_PLACEHOLDER_BINDING";
|
|
33
|
-
readonly XDR_BUILD_FAILED: "CAATINGA_XDR_BUILD_FAILED";
|
|
34
|
-
readonly XDR_PREPARE_FAILED: "CAATINGA_XDR_PREPARE_FAILED";
|
|
35
|
-
readonly XDR_SIGN_FAILED: "CAATINGA_XDR_SIGN_FAILED";
|
|
36
|
-
readonly XDR_SUBMIT_FAILED: "CAATINGA_XDR_SUBMIT_FAILED";
|
|
37
|
-
readonly XDR_RESULT_FAILED: "CAATINGA_XDR_RESULT_FAILED";
|
|
38
|
-
readonly READ_RESULT_MISSING: "CAATINGA_READ_RESULT_MISSING";
|
|
39
|
-
readonly WALLET_NOT_CONNECTED: "CAATINGA_WALLET_NOT_CONNECTED";
|
|
40
|
-
readonly WALLET_TIMEOUT: "CAATINGA_WALLET_TIMEOUT";
|
|
41
|
-
readonly SOURCE_ACCOUNT_REQUIRED: "CAATINGA_SOURCE_ACCOUNT_REQUIRED";
|
|
42
|
-
readonly SOURCE_IS_SECRET_KEY: "CAATINGA_SOURCE_IS_SECRET_KEY";
|
|
43
|
-
readonly SOURCE_IS_SEED_PHRASE: "CAATINGA_SOURCE_IS_SEED_PHRASE";
|
|
44
|
-
readonly SOURCE_IS_PUBLIC_KEY: "CAATINGA_SOURCE_IS_PUBLIC_KEY";
|
|
45
|
-
readonly UNSAFE_SOURCE_ACCOUNT: "CAATINGA_UNSAFE_SOURCE_ACCOUNT";
|
|
46
|
-
readonly INVOKE_TARGET_INVALID: "CAATINGA_INVOKE_TARGET_INVALID";
|
|
47
|
-
readonly TEMPLATE_NOT_FOUND: "CAATINGA_TEMPLATE_NOT_FOUND";
|
|
48
|
-
readonly INVALID_TEMPLATE_MANIFEST: "CAATINGA_INVALID_TEMPLATE_MANIFEST";
|
|
49
|
-
readonly TEMPLATE_MANIFEST_NOT_FOUND: "CAATINGA_TEMPLATE_MANIFEST_NOT_FOUND";
|
|
50
|
-
readonly TEMPLATE_INCOMPATIBLE: "CAATINGA_TEMPLATE_INCOMPATIBLE";
|
|
51
|
-
readonly ZK_VERIFICATION_FAILED: "CAATINGA_ZK_VERIFICATION_FAILED";
|
|
52
|
-
readonly DOCTOR_PARTIAL_DEPLOY: "CAATINGA_DOCTOR_PARTIAL_DEPLOY";
|
|
53
|
-
readonly MULTI_AUTH_REQUIRED: "CAATINGA_MULTI_AUTH_REQUIRED";
|
|
54
|
-
};
|
|
55
|
-
type CaatingaErrorCodeValue = typeof CaatingaErrorCode[keyof typeof CaatingaErrorCode];
|
|
56
|
-
|
|
57
|
-
declare class CaatingaError extends Error {
|
|
58
|
-
readonly code: CaatingaErrorCodeValue;
|
|
59
|
-
readonly hint?: string | undefined;
|
|
60
|
-
readonly cause?: unknown | undefined;
|
|
61
|
-
constructor(message: string, code: CaatingaErrorCodeValue, hint?: string | undefined, cause?: unknown | undefined);
|
|
62
|
-
}
|
|
63
|
-
declare function toCaatingaError(error: unknown): CaatingaError;
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Render an error for display. For a {@link CaatingaError} this surfaces the
|
|
67
|
-
* code, message, and hint, plus the underlying `cause` (when present) so the
|
|
68
|
-
* real reason — e.g. a wallet rejection or an XDR parse error — is never hidden
|
|
69
|
-
* behind a generic hint. Falls back to the plain message for other errors.
|
|
70
|
-
*/
|
|
71
|
-
declare function formatCaatingaError(error: unknown): string;
|
|
72
|
-
|
|
73
|
-
declare const ContractArtifactSchema: z.ZodObject<{
|
|
74
|
-
contractId: z.ZodString;
|
|
75
|
-
wasmHash: z.ZodString;
|
|
76
|
-
deployedAt: z.ZodString;
|
|
77
|
-
sourcePath: z.ZodString;
|
|
78
|
-
wasmPath: z.ZodString;
|
|
79
|
-
dependencies: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
80
|
-
resolvedDeployArgs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
81
|
-
}, "strip", z.ZodTypeAny, {
|
|
82
|
-
contractId: string;
|
|
83
|
-
wasmHash: string;
|
|
84
|
-
deployedAt: string;
|
|
85
|
-
sourcePath: string;
|
|
86
|
-
wasmPath: string;
|
|
87
|
-
dependencies: string[];
|
|
88
|
-
resolvedDeployArgs: Record<string, string | number | boolean>;
|
|
89
|
-
}, {
|
|
90
|
-
contractId: string;
|
|
91
|
-
wasmHash: string;
|
|
92
|
-
deployedAt: string;
|
|
93
|
-
sourcePath: string;
|
|
94
|
-
wasmPath: string;
|
|
95
|
-
dependencies?: string[] | undefined;
|
|
96
|
-
resolvedDeployArgs?: Record<string, string | number | boolean> | undefined;
|
|
97
|
-
}>;
|
|
98
|
-
declare const CaatingaArtifactsSchema: z.ZodObject<{
|
|
99
|
-
project: z.ZodString;
|
|
100
|
-
version: z.ZodLiteral<1>;
|
|
101
|
-
networks: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
102
|
-
contracts: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
103
|
-
contractId: z.ZodString;
|
|
104
|
-
wasmHash: z.ZodString;
|
|
105
|
-
deployedAt: z.ZodString;
|
|
106
|
-
sourcePath: z.ZodString;
|
|
107
|
-
wasmPath: z.ZodString;
|
|
108
|
-
dependencies: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
109
|
-
resolvedDeployArgs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
110
|
-
}, "strip", z.ZodTypeAny, {
|
|
111
|
-
contractId: string;
|
|
112
|
-
wasmHash: string;
|
|
113
|
-
deployedAt: string;
|
|
114
|
-
sourcePath: string;
|
|
115
|
-
wasmPath: string;
|
|
116
|
-
dependencies: string[];
|
|
117
|
-
resolvedDeployArgs: Record<string, string | number | boolean>;
|
|
118
|
-
}, {
|
|
119
|
-
contractId: string;
|
|
120
|
-
wasmHash: string;
|
|
121
|
-
deployedAt: string;
|
|
122
|
-
sourcePath: string;
|
|
123
|
-
wasmPath: string;
|
|
124
|
-
dependencies?: string[] | undefined;
|
|
125
|
-
resolvedDeployArgs?: Record<string, string | number | boolean> | undefined;
|
|
126
|
-
}>>>;
|
|
127
|
-
dependencyGraph: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>;
|
|
128
|
-
}, "strip", z.ZodTypeAny, {
|
|
129
|
-
contracts: Record<string, {
|
|
130
|
-
contractId: string;
|
|
131
|
-
wasmHash: string;
|
|
132
|
-
deployedAt: string;
|
|
133
|
-
sourcePath: string;
|
|
134
|
-
wasmPath: string;
|
|
135
|
-
dependencies: string[];
|
|
136
|
-
resolvedDeployArgs: Record<string, string | number | boolean>;
|
|
137
|
-
}>;
|
|
138
|
-
dependencyGraph: Record<string, string[]>;
|
|
139
|
-
}, {
|
|
140
|
-
contracts?: Record<string, {
|
|
141
|
-
contractId: string;
|
|
142
|
-
wasmHash: string;
|
|
143
|
-
deployedAt: string;
|
|
144
|
-
sourcePath: string;
|
|
145
|
-
wasmPath: string;
|
|
146
|
-
dependencies?: string[] | undefined;
|
|
147
|
-
resolvedDeployArgs?: Record<string, string | number | boolean> | undefined;
|
|
148
|
-
}> | undefined;
|
|
149
|
-
dependencyGraph?: Record<string, string[]> | undefined;
|
|
150
|
-
}>>>;
|
|
151
|
-
}, "strip", z.ZodTypeAny, {
|
|
152
|
-
project: string;
|
|
153
|
-
version: 1;
|
|
154
|
-
networks: Record<string, {
|
|
155
|
-
contracts: Record<string, {
|
|
156
|
-
contractId: string;
|
|
157
|
-
wasmHash: string;
|
|
158
|
-
deployedAt: string;
|
|
159
|
-
sourcePath: string;
|
|
160
|
-
wasmPath: string;
|
|
161
|
-
dependencies: string[];
|
|
162
|
-
resolvedDeployArgs: Record<string, string | number | boolean>;
|
|
163
|
-
}>;
|
|
164
|
-
dependencyGraph: Record<string, string[]>;
|
|
165
|
-
}>;
|
|
166
|
-
}, {
|
|
167
|
-
project: string;
|
|
168
|
-
version: 1;
|
|
169
|
-
networks?: Record<string, {
|
|
170
|
-
contracts?: Record<string, {
|
|
171
|
-
contractId: string;
|
|
172
|
-
wasmHash: string;
|
|
173
|
-
deployedAt: string;
|
|
174
|
-
sourcePath: string;
|
|
175
|
-
wasmPath: string;
|
|
176
|
-
dependencies?: string[] | undefined;
|
|
177
|
-
resolvedDeployArgs?: Record<string, string | number | boolean> | undefined;
|
|
178
|
-
}> | undefined;
|
|
179
|
-
dependencyGraph?: Record<string, string[]> | undefined;
|
|
180
|
-
}> | undefined;
|
|
181
|
-
}>;
|
|
182
|
-
type ContractArtifact = z.infer<typeof ContractArtifactSchema>;
|
|
183
|
-
type CaatingaArtifacts = z.infer<typeof CaatingaArtifactsSchema>;
|
|
184
|
-
|
|
185
|
-
export { type CaatingaArtifacts as C, CaatingaError as a, CaatingaErrorCode as b, type ContractArtifact as c, type CaatingaErrorCodeValue as d, CaatingaArtifactsSchema as e, formatCaatingaError as f, toCaatingaError as t };
|