@caatinga/core 3.0.0 → 3.0.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.js CHANGED
@@ -121,9 +121,7 @@ function formatCause(cause) {
121
121
 
122
122
  // src/version.ts
123
123
  import { createRequire } from "module";
124
- var require2 = createRequire(
125
- typeof __filename === "string" ? __filename : import.meta.url
126
- );
124
+ var require2 = createRequire(typeof __filename === "string" ? __filename : import.meta.url);
127
125
  var CAATINGA_CORE_VERSION = require2("../package.json").version;
128
126
 
129
127
  // src/config/config.schema.ts
@@ -770,12 +768,7 @@ function matchesWellKnownNetwork(name, config) {
770
768
  return known.rpcUrl === config.rpcUrl && known.networkPassphrase === config.networkPassphrase;
771
769
  }
772
770
  function buildRpcNetworkArgs(config) {
773
- return [
774
- "--rpc-url",
775
- config.rpcUrl,
776
- "--network-passphrase",
777
- config.networkPassphrase
778
- ];
771
+ return ["--rpc-url", config.rpcUrl, "--network-passphrase", config.networkPassphrase];
779
772
  }
780
773
  function buildStellarNetworkArgsFromConfig(config) {
781
774
  for (const [name, known] of Object.entries(WELL_KNOWN_NETWORKS)) {
@@ -829,19 +822,23 @@ async function fetchCreateContractSalt(horizonUrl, transactionHash, fetchImpl =
829
822
  }
830
823
  async function resolveContractIdFromDeploySalt(options) {
831
824
  const saltHex = decimalSaltToHex(options.salt);
832
- const result = await runCommand("stellar", [
833
- "contract",
834
- "id",
835
- "wasm",
836
- "--salt",
837
- saltHex,
838
- "--source-account",
839
- options.source,
840
- ...buildStellarNetworkArgsFromConfig(options.network)
841
- ], {
842
- cwd: options.cwd,
843
- skipStellarVersionCheck: true
844
- });
825
+ const result = await runCommand(
826
+ "stellar",
827
+ [
828
+ "contract",
829
+ "id",
830
+ "wasm",
831
+ "--salt",
832
+ saltHex,
833
+ "--source-account",
834
+ options.source,
835
+ ...buildStellarNetworkArgsFromConfig(options.network)
836
+ ],
837
+ {
838
+ cwd: options.cwd,
839
+ skipStellarVersionCheck: true
840
+ }
841
+ );
845
842
  return parseContractId(result.all || `${result.stdout}
846
843
  ${result.stderr}`);
847
844
  }
@@ -989,8 +986,12 @@ function buildAlternateWasmCandidates(configuredWasmPath, options) {
989
986
  addCandidate(path8.join(cargoTargetDir, LEGACY_RUST_WASM_TARGET, "release", fileName));
990
987
  }
991
988
  if (options?.sourcePath) {
992
- addCandidate(path8.join(options.sourcePath, "target", CURRENT_RUST_WASM_TARGET, "release", fileName));
993
- addCandidate(path8.join(options.sourcePath, "target", LEGACY_RUST_WASM_TARGET, "release", fileName));
989
+ addCandidate(
990
+ path8.join(options.sourcePath, "target", CURRENT_RUST_WASM_TARGET, "release", fileName)
991
+ );
992
+ addCandidate(
993
+ path8.join(options.sourcePath, "target", LEGACY_RUST_WASM_TARGET, "release", fileName)
994
+ );
994
995
  }
995
996
  return candidates;
996
997
  }
@@ -1405,17 +1406,21 @@ function toSkippedContract(name, contractId, network) {
1405
1406
  // src/contracts/verify-dependency-contract.ts
1406
1407
  async function verifyDependencyContract(options) {
1407
1408
  try {
1408
- await runCommand("stellar", [
1409
- "contract",
1410
- "info",
1411
- "interface",
1412
- "--contract-id",
1413
- options.contractId,
1414
- ...buildStellarNetworkArgs(options.network)
1415
- ], {
1416
- cwd: options.cwd,
1417
- failureCode: CaatingaErrorCode.DEPENDENCY_CONTRACT_NOT_FOUND
1418
- });
1409
+ await runCommand(
1410
+ "stellar",
1411
+ [
1412
+ "contract",
1413
+ "info",
1414
+ "interface",
1415
+ "--contract-id",
1416
+ options.contractId,
1417
+ ...buildStellarNetworkArgs(options.network)
1418
+ ],
1419
+ {
1420
+ cwd: options.cwd,
1421
+ failureCode: CaatingaErrorCode.DEPENDENCY_CONTRACT_NOT_FOUND
1422
+ }
1423
+ );
1419
1424
  } catch (error) {
1420
1425
  if (error instanceof CaatingaError && error.code === CaatingaErrorCode.DEPENDENCY_CONTRACT_NOT_FOUND) {
1421
1426
  throw new CaatingaError(
@@ -1477,9 +1482,7 @@ async function deployContractGraph(options) {
1477
1482
  network: network.name
1478
1483
  });
1479
1484
  if (existing?.contractId && !options.force) {
1480
- skippedContracts.push(
1481
- toSkippedContract(contractName, existing.contractId, network.name)
1482
- );
1485
+ skippedContracts.push(toSkippedContract(contractName, existing.contractId, network.name));
1483
1486
  continue;
1484
1487
  }
1485
1488
  const result = await deployContract({
@@ -1500,9 +1503,7 @@ async function deployContractGraph(options) {
1500
1503
  });
1501
1504
  }
1502
1505
  if (result.skipped) {
1503
- skippedContracts.push(
1504
- toSkippedContract(contractName, result.contractId, network.name)
1505
- );
1506
+ skippedContracts.push(toSkippedContract(contractName, result.contractId, network.name));
1506
1507
  } else {
1507
1508
  deployedContracts.push({ name: contractName, contractId: result.contractId });
1508
1509
  }
@@ -1563,22 +1564,26 @@ async function generateBindings(options) {
1563
1564
  }
1564
1565
  const outputDir = path10.resolve(cwd, options.config.frontend.bindingsOutput, options.contractName);
1565
1566
  await mkdir2(outputDir, { recursive: true });
1566
- const result = await runCommand("npx", [
1567
- "--yes",
1568
- "@stellar/stellar-sdk",
1569
- "generate",
1570
- "--contract-id",
1571
- contractArtifact.contractId,
1572
- "--output-dir",
1573
- outputDir,
1574
- "--contract-name",
1575
- options.contractName,
1576
- "--overwrite",
1577
- ...buildGenerateNetworkArgs(network)
1578
- ], {
1579
- cwd,
1580
- failureCode: CaatingaErrorCode.BINDINGS_FAILED
1581
- });
1567
+ const result = await runCommand(
1568
+ "npx",
1569
+ [
1570
+ "--yes",
1571
+ "@stellar/stellar-sdk",
1572
+ "generate",
1573
+ "--contract-id",
1574
+ contractArtifact.contractId,
1575
+ "--output-dir",
1576
+ outputDir,
1577
+ "--contract-name",
1578
+ options.contractName,
1579
+ "--overwrite",
1580
+ ...buildGenerateNetworkArgs(network)
1581
+ ],
1582
+ {
1583
+ cwd,
1584
+ failureCode: CaatingaErrorCode.BINDINGS_FAILED
1585
+ }
1586
+ );
1582
1587
  const legacyStubRemoved = await removeLegacyBindingStub(
1583
1588
  cwd,
1584
1589
  options.config.frontend.bindingsOutput,
@@ -1690,21 +1695,25 @@ async function invokeContract(options) {
1690
1695
  await checkBinary("stellar", "Install Stellar CLI before running caatinga invoke.");
1691
1696
  let result;
1692
1697
  try {
1693
- result = await runCommand("stellar", [
1694
- "contract",
1695
- "invoke",
1696
- "--id",
1697
- contractArtifact.contractId,
1698
- "--source-account",
1699
- source,
1700
- ...buildStellarNetworkArgs(network),
1701
- "--",
1702
- target.method,
1703
- ...options.args ?? []
1704
- ], {
1705
- cwd,
1706
- failureCode: CaatingaErrorCode.INVOKE_FAILED
1707
- });
1698
+ result = await runCommand(
1699
+ "stellar",
1700
+ [
1701
+ "contract",
1702
+ "invoke",
1703
+ "--id",
1704
+ contractArtifact.contractId,
1705
+ "--source-account",
1706
+ source,
1707
+ ...buildStellarNetworkArgs(network),
1708
+ "--",
1709
+ target.method,
1710
+ ...options.args ?? []
1711
+ ],
1712
+ {
1713
+ cwd,
1714
+ failureCode: CaatingaErrorCode.INVOKE_FAILED
1715
+ }
1716
+ );
1708
1717
  } catch (error) {
1709
1718
  if (error instanceof CaatingaError && error.code === CaatingaErrorCode.INVOKE_FAILED && isReadCallFailure(error)) {
1710
1719
  throw new CaatingaError(
@@ -1849,12 +1858,7 @@ function formatTemplateCompatibilityHint(issue) {
1849
1858
  }
1850
1859
 
1851
1860
  // src/templates/create-project-from-template.ts
1852
- var TEMPLATE_COPY_EXCLUDED_DIRS = /* @__PURE__ */ new Set([
1853
- "target",
1854
- "test_snapshots",
1855
- "node_modules",
1856
- ".git"
1857
- ]);
1861
+ var TEMPLATE_COPY_EXCLUDED_DIRS = /* @__PURE__ */ new Set(["target", "test_snapshots", "node_modules", ".git"]);
1858
1862
  async function createProjectFromTemplate(options) {
1859
1863
  const targetDir = path11.resolve(options.targetDir);
1860
1864
  const templateDir = path11.resolve(options.templateDir);
@@ -1888,7 +1892,10 @@ async function ensureArtifacts(targetDir, projectName) {
1888
1892
  await writeArtifacts({ ...artifacts, project: projectName }, targetDir);
1889
1893
  } catch (error) {
1890
1894
  if (error instanceof CaatingaError && error.code === CaatingaErrorCode.ARTIFACT_NOT_FOUND) {
1891
- await writeArtifacts(createInitialArtifacts(projectName, { networks: ["testnet"] }), targetDir);
1895
+ await writeArtifacts(
1896
+ createInitialArtifacts(projectName, { networks: ["testnet"] }),
1897
+ targetDir
1898
+ );
1892
1899
  return;
1893
1900
  }
1894
1901
  throw error;
@@ -1931,19 +1938,21 @@ async function readTemplateManifest(templateDir) {
1931
1938
  }
1932
1939
  async function replaceTemplateVariables(dir, projectName) {
1933
1940
  const entries = await readdir3(dir);
1934
- await Promise.all(entries.map(async (entry) => {
1935
- const entryPath = path11.join(dir, entry);
1936
- const entryStat = await stat2(entryPath);
1937
- if (entryStat.isDirectory()) {
1938
- await replaceTemplateVariables(entryPath, projectName);
1939
- return;
1940
- }
1941
- if (!isTextTemplateFile(entryPath)) {
1942
- return;
1943
- }
1944
- const content = await readFile4(entryPath, "utf8");
1945
- await writeFile3(entryPath, content.replaceAll("__PROJECT_NAME__", projectName), "utf8");
1946
- }));
1941
+ await Promise.all(
1942
+ entries.map(async (entry) => {
1943
+ const entryPath = path11.join(dir, entry);
1944
+ const entryStat = await stat2(entryPath);
1945
+ if (entryStat.isDirectory()) {
1946
+ await replaceTemplateVariables(entryPath, projectName);
1947
+ return;
1948
+ }
1949
+ if (!isTextTemplateFile(entryPath)) {
1950
+ return;
1951
+ }
1952
+ const content = await readFile4(entryPath, "utf8");
1953
+ await writeFile3(entryPath, content.replaceAll("__PROJECT_NAME__", projectName), "utf8");
1954
+ })
1955
+ );
1947
1956
  }
1948
1957
  function shouldCopyTemplateEntry(templateDir, source, userFilter) {
1949
1958
  const relativePath = path11.relative(templateDir, source);
@@ -1957,16 +1966,9 @@ function shouldCopyTemplateEntry(templateDir, source, userFilter) {
1957
1966
  return !relativePath.split(path11.sep).some((segment) => TEMPLATE_COPY_EXCLUDED_DIRS.has(segment));
1958
1967
  }
1959
1968
  function isTextTemplateFile(filePath) {
1960
- return [
1961
- ".json",
1962
- ".md",
1963
- ".rs",
1964
- ".toml",
1965
- ".ts",
1966
- ".tsx",
1967
- ".css",
1968
- ".html"
1969
- ].includes(path11.extname(filePath));
1969
+ return [".json", ".md", ".rs", ".toml", ".ts", ".tsx", ".css", ".html"].includes(
1970
+ path11.extname(filePath)
1971
+ );
1970
1972
  }
1971
1973
 
1972
1974
  // src/scaffold/create-zk-project.ts
@@ -2015,23 +2017,27 @@ export default defineConfig({
2015
2017
  `;
2016
2018
  }
2017
2019
  function packageJsonSource(projectName) {
2018
- return `${JSON.stringify({
2019
- name: projectName,
2020
- version: "0.1.0",
2021
- private: true,
2022
- type: "module",
2023
- scripts: {
2024
- "zk:build": "caatinga zk build main",
2025
- "zk:prove": "caatinga zk prove main",
2026
- build: "caatinga build verifier",
2027
- deploy: "caatinga deploy verifier --network testnet --source ${CAATINGA_SOURCE:-alice}",
2028
- doctor: "caatinga doctor --network testnet"
2020
+ return `${JSON.stringify(
2021
+ {
2022
+ name: projectName,
2023
+ version: "0.1.0",
2024
+ private: true,
2025
+ type: "module",
2026
+ scripts: {
2027
+ "zk:build": "caatinga zk build main",
2028
+ "zk:prove": "caatinga zk prove main",
2029
+ build: "caatinga build verifier",
2030
+ deploy: "caatinga deploy verifier --network testnet --source ${CAATINGA_SOURCE:-alice}",
2031
+ doctor: "caatinga doctor --network testnet"
2032
+ },
2033
+ devDependencies: {
2034
+ "@caatinga/cli": `^${CAATINGA_CORE_VERSION}`,
2035
+ "@caatinga/core": `^${CAATINGA_CORE_VERSION}`
2036
+ }
2029
2037
  },
2030
- devDependencies: {
2031
- "@caatinga/cli": `^${CAATINGA_CORE_VERSION}`,
2032
- "@caatinga/core": `^${CAATINGA_CORE_VERSION}`
2033
- }
2034
- }, null, 2)}
2038
+ null,
2039
+ 2
2040
+ )}
2035
2041
  `;
2036
2042
  }
2037
2043
  function readmeSource(projectName) {
@@ -2059,10 +2065,22 @@ async function createZkProject(options) {
2059
2065
  await mkdir4(targetDir, { recursive: true });
2060
2066
  if (projectFiles) {
2061
2067
  await Promise.all([
2062
- writeFile4(path12.join(targetDir, "caatinga.config.ts"), configSource(options.projectName), { encoding: "utf8", flag: force ? "w" : "wx" }),
2063
- writeFile4(path12.join(targetDir, "package.json"), packageJsonSource(options.projectName), { encoding: "utf8", flag: force ? "w" : "wx" }),
2064
- writeFile4(path12.join(targetDir, ".gitignore"), "node_modules\n.artifacts\ntarget\n", { encoding: "utf8", flag: force ? "w" : "wx" }),
2065
- writeFile4(path12.join(targetDir, "README.md"), readmeSource(options.projectName), { encoding: "utf8", flag: force ? "w" : "wx" })
2068
+ writeFile4(path12.join(targetDir, "caatinga.config.ts"), configSource(options.projectName), {
2069
+ encoding: "utf8",
2070
+ flag: force ? "w" : "wx"
2071
+ }),
2072
+ writeFile4(path12.join(targetDir, "package.json"), packageJsonSource(options.projectName), {
2073
+ encoding: "utf8",
2074
+ flag: force ? "w" : "wx"
2075
+ }),
2076
+ writeFile4(path12.join(targetDir, ".gitignore"), "node_modules\n.artifacts\ntarget\n", {
2077
+ encoding: "utf8",
2078
+ flag: force ? "w" : "wx"
2079
+ }),
2080
+ writeFile4(path12.join(targetDir, "README.md"), readmeSource(options.projectName), {
2081
+ encoding: "utf8",
2082
+ flag: force ? "w" : "wx"
2083
+ })
2066
2084
  ]);
2067
2085
  }
2068
2086
  await mkdir4(path12.join(targetDir, "contracts"), { recursive: true });
@@ -2071,13 +2089,20 @@ async function createZkProject(options) {
2071
2089
  force,
2072
2090
  errorOnExist: !force
2073
2091
  });
2074
- await cp2(path12.join(scaffoldRoot(), "zk-verifier"), path12.join(targetDir, "contracts", "verifier"), {
2075
- recursive: true,
2076
- force,
2077
- errorOnExist: !force
2078
- });
2092
+ await cp2(
2093
+ path12.join(scaffoldRoot(), "zk-verifier"),
2094
+ path12.join(targetDir, "contracts", "verifier"),
2095
+ {
2096
+ recursive: true,
2097
+ force,
2098
+ errorOnExist: !force
2099
+ }
2100
+ );
2079
2101
  if (projectFiles) {
2080
- await writeArtifacts(createInitialArtifacts(options.projectName, { networks: ["testnet"] }), targetDir);
2102
+ await writeArtifacts(
2103
+ createInitialArtifacts(options.projectName, { networks: ["testnet"] }),
2104
+ targetDir
2105
+ );
2081
2106
  }
2082
2107
  return { targetDir };
2083
2108
  }
@@ -2118,23 +2143,27 @@ export default defineConfig({
2118
2143
  `;
2119
2144
  }
2120
2145
  function packageJsonSource2(projectName) {
2121
- return `${JSON.stringify({
2122
- name: projectName,
2123
- version: "0.1.0",
2124
- private: true,
2125
- type: "module",
2126
- scripts: {
2127
- build: "caatinga build app",
2128
- deploy: "caatinga deploy app --network testnet --source ${CAATINGA_SOURCE:-alice}",
2129
- doctor: "caatinga doctor --network testnet",
2130
- "read:hello": "caatinga read app.hello --network testnet --source ${CAATINGA_SOURCE:-alice}",
2131
- "read:version": "caatinga read app.version --network testnet --source ${CAATINGA_SOURCE:-alice}"
2146
+ return `${JSON.stringify(
2147
+ {
2148
+ name: projectName,
2149
+ version: "0.1.0",
2150
+ private: true,
2151
+ type: "module",
2152
+ scripts: {
2153
+ build: "caatinga build app",
2154
+ deploy: "caatinga deploy app --network testnet --source ${CAATINGA_SOURCE:-alice}",
2155
+ doctor: "caatinga doctor --network testnet",
2156
+ "read:hello": "caatinga read app.hello --network testnet --source ${CAATINGA_SOURCE:-alice}",
2157
+ "read:version": "caatinga read app.version --network testnet --source ${CAATINGA_SOURCE:-alice}"
2158
+ },
2159
+ devDependencies: {
2160
+ "@caatinga/cli": `^${CAATINGA_CORE_VERSION}`,
2161
+ "@caatinga/core": `^${CAATINGA_CORE_VERSION}`
2162
+ }
2132
2163
  },
2133
- devDependencies: {
2134
- "@caatinga/cli": `^${CAATINGA_CORE_VERSION}`,
2135
- "@caatinga/core": `^${CAATINGA_CORE_VERSION}`
2136
- }
2137
- }, null, 2)}
2164
+ null,
2165
+ 2
2166
+ )}
2138
2167
  `;
2139
2168
  }
2140
2169
  function readmeSource2(projectName) {
@@ -2170,18 +2199,37 @@ async function createMinimalProject(options) {
2170
2199
  const force = options.force ?? false;
2171
2200
  await mkdir5(targetDir, { recursive: true });
2172
2201
  await Promise.all([
2173
- writeFile5(path13.join(targetDir, "caatinga.config.ts"), configSource2(options.projectName), { encoding: "utf8", flag: force ? "w" : "wx" }),
2174
- writeFile5(path13.join(targetDir, "package.json"), packageJsonSource2(options.projectName), { encoding: "utf8", flag: force ? "w" : "wx" }),
2175
- writeFile5(path13.join(targetDir, ".gitignore"), "node_modules\n.artifacts\ntarget\n", { encoding: "utf8", flag: force ? "w" : "wx" }),
2176
- writeFile5(path13.join(targetDir, "README.md"), readmeSource2(options.projectName), { encoding: "utf8", flag: force ? "w" : "wx" })
2202
+ writeFile5(path13.join(targetDir, "caatinga.config.ts"), configSource2(options.projectName), {
2203
+ encoding: "utf8",
2204
+ flag: force ? "w" : "wx"
2205
+ }),
2206
+ writeFile5(path13.join(targetDir, "package.json"), packageJsonSource2(options.projectName), {
2207
+ encoding: "utf8",
2208
+ flag: force ? "w" : "wx"
2209
+ }),
2210
+ writeFile5(path13.join(targetDir, ".gitignore"), "node_modules\n.artifacts\ntarget\n", {
2211
+ encoding: "utf8",
2212
+ flag: force ? "w" : "wx"
2213
+ }),
2214
+ writeFile5(path13.join(targetDir, "README.md"), readmeSource2(options.projectName), {
2215
+ encoding: "utf8",
2216
+ flag: force ? "w" : "wx"
2217
+ })
2177
2218
  ]);
2178
2219
  await mkdir5(path13.join(targetDir, "contracts"), { recursive: true });
2179
- await cp3(path13.join(scaffoldRoot2(), "soroban-contract-stub"), path13.join(targetDir, "contracts", "app"), {
2180
- recursive: true,
2181
- force,
2182
- errorOnExist: !force
2183
- });
2184
- await writeArtifacts(createInitialArtifacts(options.projectName, { networks: ["testnet"] }), targetDir);
2220
+ await cp3(
2221
+ path13.join(scaffoldRoot2(), "soroban-contract-stub"),
2222
+ path13.join(targetDir, "contracts", "app"),
2223
+ {
2224
+ recursive: true,
2225
+ force,
2226
+ errorOnExist: !force
2227
+ }
2228
+ );
2229
+ await writeArtifacts(
2230
+ createInitialArtifacts(options.projectName, { networks: ["testnet"] }),
2231
+ targetDir
2232
+ );
2185
2233
  return { targetDir };
2186
2234
  }
2187
2235
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caatinga/core",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "Core config, artifacts, command orchestration, and error primitives for Caatinga/Soroban toolkit",
5
5
  "keywords": [
6
6
  "stellar",