@caatinga/core 2.4.0 → 2.4.2
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 +80 -23
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +80 -23
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -195,7 +195,7 @@ function formatCause(cause) {
|
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
// src/version.ts
|
|
198
|
-
var CAATINGA_CORE_VERSION = "2.4.
|
|
198
|
+
var CAATINGA_CORE_VERSION = "2.4.1";
|
|
199
199
|
|
|
200
200
|
// src/config/config.schema.ts
|
|
201
201
|
var import_zod = require("zod");
|
|
@@ -1017,37 +1017,89 @@ function toCurrentWasmTargetPath(wasmPath) {
|
|
|
1017
1017
|
}
|
|
1018
1018
|
function wasmNotFoundError(configuredWasmPath, options) {
|
|
1019
1019
|
const migratedPath = options?.migratedPath;
|
|
1020
|
-
const
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1020
|
+
const cargoTargetDir = process.env.CARGO_TARGET_DIR;
|
|
1021
|
+
const hintParts = ["Run caatinga build before deploy or generate."];
|
|
1022
|
+
if (migratedPath !== void 0) {
|
|
1023
|
+
hintParts.push(
|
|
1024
|
+
`Soroban builds use the "${CURRENT_RUST_WASM_TARGET}" target.`,
|
|
1025
|
+
`Update wasm in caatinga.config.ts to "${toConfigRelativeWasmPath(migratedPath)}" or an equivalent path under target/${CURRENT_RUST_WASM_TARGET}/release/.`
|
|
1026
|
+
);
|
|
1027
|
+
}
|
|
1028
|
+
if (cargoTargetDir) {
|
|
1029
|
+
hintParts.push(
|
|
1030
|
+
`CARGO_TARGET_DIR is set to "${cargoTargetDir}"; the WASM may be under that directory instead of the configured path. Unset CARGO_TARGET_DIR or update wasm in caatinga.config.ts.`
|
|
1031
|
+
);
|
|
1032
|
+
}
|
|
1025
1033
|
return new CaatingaError(
|
|
1026
1034
|
`WASM output was not found at ${configuredWasmPath}.`,
|
|
1027
1035
|
CaatingaErrorCode.ARTIFACT_NOT_FOUND,
|
|
1028
|
-
|
|
1036
|
+
hintParts.join(" ")
|
|
1029
1037
|
);
|
|
1030
1038
|
}
|
|
1031
1039
|
function toConfigRelativeWasmPath(absoluteWasmPath) {
|
|
1032
1040
|
const relative = import_node_path8.default.relative(process.cwd(), absoluteWasmPath);
|
|
1033
1041
|
return relative.startsWith("..") ? absoluteWasmPath : `./${relative.split(import_node_path8.default.sep).join("/")}`;
|
|
1034
1042
|
}
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
+
function wasmFileName(configuredWasmPath) {
|
|
1044
|
+
return import_node_path8.default.basename(configuredWasmPath);
|
|
1045
|
+
}
|
|
1046
|
+
function buildAlternateWasmCandidates(configuredWasmPath, options) {
|
|
1047
|
+
const fileName = wasmFileName(configuredWasmPath);
|
|
1048
|
+
const candidates = [];
|
|
1049
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1050
|
+
function addCandidate(candidate) {
|
|
1051
|
+
const resolved = import_node_path8.default.resolve(candidate);
|
|
1052
|
+
if (seen.has(resolved)) {
|
|
1053
|
+
return;
|
|
1043
1054
|
}
|
|
1055
|
+
seen.add(resolved);
|
|
1056
|
+
candidates.push(resolved);
|
|
1057
|
+
}
|
|
1058
|
+
const cargoTargetDir = process.env.CARGO_TARGET_DIR;
|
|
1059
|
+
if (cargoTargetDir) {
|
|
1060
|
+
addCandidate(import_node_path8.default.join(cargoTargetDir, CURRENT_RUST_WASM_TARGET, "release", fileName));
|
|
1061
|
+
addCandidate(import_node_path8.default.join(cargoTargetDir, LEGACY_RUST_WASM_TARGET, "release", fileName));
|
|
1062
|
+
}
|
|
1063
|
+
if (options?.sourcePath) {
|
|
1064
|
+
addCandidate(import_node_path8.default.join(options.sourcePath, "target", CURRENT_RUST_WASM_TARGET, "release", fileName));
|
|
1065
|
+
addCandidate(import_node_path8.default.join(options.sourcePath, "target", LEGACY_RUST_WASM_TARGET, "release", fileName));
|
|
1066
|
+
}
|
|
1067
|
+
return candidates;
|
|
1068
|
+
}
|
|
1069
|
+
async function firstExistingPath(paths) {
|
|
1070
|
+
for (const candidate of paths) {
|
|
1044
1071
|
try {
|
|
1045
|
-
await (0, import_promises6.access)(
|
|
1046
|
-
return
|
|
1072
|
+
await (0, import_promises6.access)(candidate);
|
|
1073
|
+
return candidate;
|
|
1047
1074
|
} catch {
|
|
1048
|
-
|
|
1075
|
+
continue;
|
|
1049
1076
|
}
|
|
1050
1077
|
}
|
|
1078
|
+
return void 0;
|
|
1079
|
+
}
|
|
1080
|
+
async function resolveWasmArtifactPath(configuredWasmPath, options) {
|
|
1081
|
+
const resolvedConfiguredPath = import_node_path8.default.resolve(configuredWasmPath);
|
|
1082
|
+
try {
|
|
1083
|
+
await (0, import_promises6.access)(resolvedConfiguredPath);
|
|
1084
|
+
return resolvedConfiguredPath;
|
|
1085
|
+
} catch {
|
|
1086
|
+
const currentTargetPath = toCurrentWasmTargetPath(resolvedConfiguredPath);
|
|
1087
|
+
if (currentTargetPath !== resolvedConfiguredPath) {
|
|
1088
|
+
const migratedPath = await firstExistingPath([currentTargetPath]);
|
|
1089
|
+
if (migratedPath) {
|
|
1090
|
+
return migratedPath;
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
const alternatePath = await firstExistingPath(
|
|
1094
|
+
buildAlternateWasmCandidates(resolvedConfiguredPath, options)
|
|
1095
|
+
);
|
|
1096
|
+
if (alternatePath) {
|
|
1097
|
+
return alternatePath;
|
|
1098
|
+
}
|
|
1099
|
+
throw wasmNotFoundError(resolvedConfiguredPath, {
|
|
1100
|
+
migratedPath: currentTargetPath !== resolvedConfiguredPath ? currentTargetPath : void 0
|
|
1101
|
+
});
|
|
1102
|
+
}
|
|
1051
1103
|
}
|
|
1052
1104
|
async function hashWasm(wasmPath) {
|
|
1053
1105
|
const bytes = await (0, import_promises6.readFile)(wasmPath);
|
|
@@ -1141,7 +1193,9 @@ async function buildContract(options) {
|
|
|
1141
1193
|
}
|
|
1142
1194
|
throw error;
|
|
1143
1195
|
}
|
|
1144
|
-
const wasmPath = await resolveWasmArtifactPath(contract.wasmPath
|
|
1196
|
+
const wasmPath = await resolveWasmArtifactPath(contract.wasmPath, {
|
|
1197
|
+
sourcePath: contract.sourcePath
|
|
1198
|
+
});
|
|
1145
1199
|
return {
|
|
1146
1200
|
contract: {
|
|
1147
1201
|
...contract,
|
|
@@ -1234,7 +1288,9 @@ async function deployContract(options) {
|
|
|
1234
1288
|
const network = resolveNetwork(options.config, options.networkName);
|
|
1235
1289
|
const source = assertSafeSourceAccount(options.source);
|
|
1236
1290
|
await checkBinary("stellar", "Install Stellar CLI before running caatinga deploy.");
|
|
1237
|
-
const wasmPath = await resolveWasmArtifactPath(contract.wasmPath
|
|
1291
|
+
const wasmPath = await resolveWasmArtifactPath(contract.wasmPath, {
|
|
1292
|
+
sourcePath: contract.sourcePath
|
|
1293
|
+
});
|
|
1238
1294
|
const contractWithWasm = {
|
|
1239
1295
|
...contract,
|
|
1240
1296
|
wasmPath
|
|
@@ -2030,7 +2086,8 @@ function packageJsonSource(projectName) {
|
|
|
2030
2086
|
"zk:build": "caatinga zk build main",
|
|
2031
2087
|
"zk:prove": "caatinga zk prove main",
|
|
2032
2088
|
build: "caatinga build verifier",
|
|
2033
|
-
deploy: "caatinga deploy verifier"
|
|
2089
|
+
deploy: "caatinga deploy verifier --network testnet --source ${CAATINGA_SOURCE:-alice}",
|
|
2090
|
+
doctor: "caatinga doctor --network testnet"
|
|
2034
2091
|
},
|
|
2035
2092
|
devDependencies: {
|
|
2036
2093
|
"@caatinga/cli": `^${CAATINGA_CORE_VERSION}`,
|
|
@@ -2050,7 +2107,7 @@ Minimal Caatinga ZK project.
|
|
|
2050
2107
|
npm install
|
|
2051
2108
|
npx caatinga zk build main
|
|
2052
2109
|
npx caatinga build verifier
|
|
2053
|
-
npx caatinga deploy verifier --network testnet
|
|
2110
|
+
npx caatinga deploy verifier --network testnet --source <identity>
|
|
2054
2111
|
npx caatinga zk prove main
|
|
2055
2112
|
\`\`\`
|
|
2056
2113
|
|
|
@@ -2132,7 +2189,7 @@ function packageJsonSource2(projectName) {
|
|
|
2132
2189
|
scripts: {
|
|
2133
2190
|
build: "caatinga build app",
|
|
2134
2191
|
deploy: "caatinga deploy app --network testnet --source ${CAATINGA_SOURCE:-alice}",
|
|
2135
|
-
doctor: "caatinga doctor",
|
|
2192
|
+
doctor: "caatinga doctor --network testnet",
|
|
2136
2193
|
"read:hello": "caatinga read app.hello --network testnet --source ${CAATINGA_SOURCE:-alice}",
|
|
2137
2194
|
"read:version": "caatinga read app.version --network testnet --source ${CAATINGA_SOURCE:-alice}"
|
|
2138
2195
|
},
|
package/dist/index.d.cts
CHANGED
|
@@ -2,7 +2,7 @@ import { C as CaatingaArtifacts, c as ContractArtifact, d as CaatingaErrorCodeVa
|
|
|
2
2
|
export { e as CaatingaArtifactsSchema, b as CaatingaErrorCode, f as formatCaatingaError, t as toCaatingaError } from './artifact.schema-BH5K-IiZ.cjs';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
-
declare const CAATINGA_CORE_VERSION = "2.4.
|
|
5
|
+
declare const CAATINGA_CORE_VERSION = "2.4.1";
|
|
6
6
|
|
|
7
7
|
declare const ContractConfigSchema: z.ZodObject<{
|
|
8
8
|
path: z.ZodString;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { C as CaatingaArtifacts, c as ContractArtifact, d as CaatingaErrorCodeVa
|
|
|
2
2
|
export { e as CaatingaArtifactsSchema, b as CaatingaErrorCode, f as formatCaatingaError, t as toCaatingaError } from './artifact.schema-BH5K-IiZ.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
-
declare const CAATINGA_CORE_VERSION = "2.4.
|
|
5
|
+
declare const CAATINGA_CORE_VERSION = "2.4.1";
|
|
6
6
|
|
|
7
7
|
declare const ContractConfigSchema: z.ZodObject<{
|
|
8
8
|
path: z.ZodString;
|
package/dist/index.js
CHANGED
|
@@ -106,7 +106,7 @@ function formatCause(cause) {
|
|
|
106
106
|
}
|
|
107
107
|
|
|
108
108
|
// src/version.ts
|
|
109
|
-
var CAATINGA_CORE_VERSION = "2.4.
|
|
109
|
+
var CAATINGA_CORE_VERSION = "2.4.1";
|
|
110
110
|
|
|
111
111
|
// src/config/config.schema.ts
|
|
112
112
|
import { z } from "zod";
|
|
@@ -927,37 +927,89 @@ function toCurrentWasmTargetPath(wasmPath) {
|
|
|
927
927
|
}
|
|
928
928
|
function wasmNotFoundError(configuredWasmPath, options) {
|
|
929
929
|
const migratedPath = options?.migratedPath;
|
|
930
|
-
const
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
930
|
+
const cargoTargetDir = process.env.CARGO_TARGET_DIR;
|
|
931
|
+
const hintParts = ["Run caatinga build before deploy or generate."];
|
|
932
|
+
if (migratedPath !== void 0) {
|
|
933
|
+
hintParts.push(
|
|
934
|
+
`Soroban builds use the "${CURRENT_RUST_WASM_TARGET}" target.`,
|
|
935
|
+
`Update wasm in caatinga.config.ts to "${toConfigRelativeWasmPath(migratedPath)}" or an equivalent path under target/${CURRENT_RUST_WASM_TARGET}/release/.`
|
|
936
|
+
);
|
|
937
|
+
}
|
|
938
|
+
if (cargoTargetDir) {
|
|
939
|
+
hintParts.push(
|
|
940
|
+
`CARGO_TARGET_DIR is set to "${cargoTargetDir}"; the WASM may be under that directory instead of the configured path. Unset CARGO_TARGET_DIR or update wasm in caatinga.config.ts.`
|
|
941
|
+
);
|
|
942
|
+
}
|
|
935
943
|
return new CaatingaError(
|
|
936
944
|
`WASM output was not found at ${configuredWasmPath}.`,
|
|
937
945
|
CaatingaErrorCode.ARTIFACT_NOT_FOUND,
|
|
938
|
-
|
|
946
|
+
hintParts.join(" ")
|
|
939
947
|
);
|
|
940
948
|
}
|
|
941
949
|
function toConfigRelativeWasmPath(absoluteWasmPath) {
|
|
942
950
|
const relative = path8.relative(process.cwd(), absoluteWasmPath);
|
|
943
951
|
return relative.startsWith("..") ? absoluteWasmPath : `./${relative.split(path8.sep).join("/")}`;
|
|
944
952
|
}
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
+
function wasmFileName(configuredWasmPath) {
|
|
954
|
+
return path8.basename(configuredWasmPath);
|
|
955
|
+
}
|
|
956
|
+
function buildAlternateWasmCandidates(configuredWasmPath, options) {
|
|
957
|
+
const fileName = wasmFileName(configuredWasmPath);
|
|
958
|
+
const candidates = [];
|
|
959
|
+
const seen = /* @__PURE__ */ new Set();
|
|
960
|
+
function addCandidate(candidate) {
|
|
961
|
+
const resolved = path8.resolve(candidate);
|
|
962
|
+
if (seen.has(resolved)) {
|
|
963
|
+
return;
|
|
953
964
|
}
|
|
965
|
+
seen.add(resolved);
|
|
966
|
+
candidates.push(resolved);
|
|
967
|
+
}
|
|
968
|
+
const cargoTargetDir = process.env.CARGO_TARGET_DIR;
|
|
969
|
+
if (cargoTargetDir) {
|
|
970
|
+
addCandidate(path8.join(cargoTargetDir, CURRENT_RUST_WASM_TARGET, "release", fileName));
|
|
971
|
+
addCandidate(path8.join(cargoTargetDir, LEGACY_RUST_WASM_TARGET, "release", fileName));
|
|
972
|
+
}
|
|
973
|
+
if (options?.sourcePath) {
|
|
974
|
+
addCandidate(path8.join(options.sourcePath, "target", CURRENT_RUST_WASM_TARGET, "release", fileName));
|
|
975
|
+
addCandidate(path8.join(options.sourcePath, "target", LEGACY_RUST_WASM_TARGET, "release", fileName));
|
|
976
|
+
}
|
|
977
|
+
return candidates;
|
|
978
|
+
}
|
|
979
|
+
async function firstExistingPath(paths) {
|
|
980
|
+
for (const candidate of paths) {
|
|
954
981
|
try {
|
|
955
|
-
await access2(
|
|
956
|
-
return
|
|
982
|
+
await access2(candidate);
|
|
983
|
+
return candidate;
|
|
957
984
|
} catch {
|
|
958
|
-
|
|
985
|
+
continue;
|
|
959
986
|
}
|
|
960
987
|
}
|
|
988
|
+
return void 0;
|
|
989
|
+
}
|
|
990
|
+
async function resolveWasmArtifactPath(configuredWasmPath, options) {
|
|
991
|
+
const resolvedConfiguredPath = path8.resolve(configuredWasmPath);
|
|
992
|
+
try {
|
|
993
|
+
await access2(resolvedConfiguredPath);
|
|
994
|
+
return resolvedConfiguredPath;
|
|
995
|
+
} catch {
|
|
996
|
+
const currentTargetPath = toCurrentWasmTargetPath(resolvedConfiguredPath);
|
|
997
|
+
if (currentTargetPath !== resolvedConfiguredPath) {
|
|
998
|
+
const migratedPath = await firstExistingPath([currentTargetPath]);
|
|
999
|
+
if (migratedPath) {
|
|
1000
|
+
return migratedPath;
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
const alternatePath = await firstExistingPath(
|
|
1004
|
+
buildAlternateWasmCandidates(resolvedConfiguredPath, options)
|
|
1005
|
+
);
|
|
1006
|
+
if (alternatePath) {
|
|
1007
|
+
return alternatePath;
|
|
1008
|
+
}
|
|
1009
|
+
throw wasmNotFoundError(resolvedConfiguredPath, {
|
|
1010
|
+
migratedPath: currentTargetPath !== resolvedConfiguredPath ? currentTargetPath : void 0
|
|
1011
|
+
});
|
|
1012
|
+
}
|
|
961
1013
|
}
|
|
962
1014
|
async function hashWasm(wasmPath) {
|
|
963
1015
|
const bytes = await readFile3(wasmPath);
|
|
@@ -1051,7 +1103,9 @@ async function buildContract(options) {
|
|
|
1051
1103
|
}
|
|
1052
1104
|
throw error;
|
|
1053
1105
|
}
|
|
1054
|
-
const wasmPath = await resolveWasmArtifactPath(contract.wasmPath
|
|
1106
|
+
const wasmPath = await resolveWasmArtifactPath(contract.wasmPath, {
|
|
1107
|
+
sourcePath: contract.sourcePath
|
|
1108
|
+
});
|
|
1055
1109
|
return {
|
|
1056
1110
|
contract: {
|
|
1057
1111
|
...contract,
|
|
@@ -1144,7 +1198,9 @@ async function deployContract(options) {
|
|
|
1144
1198
|
const network = resolveNetwork(options.config, options.networkName);
|
|
1145
1199
|
const source = assertSafeSourceAccount(options.source);
|
|
1146
1200
|
await checkBinary("stellar", "Install Stellar CLI before running caatinga deploy.");
|
|
1147
|
-
const wasmPath = await resolveWasmArtifactPath(contract.wasmPath
|
|
1201
|
+
const wasmPath = await resolveWasmArtifactPath(contract.wasmPath, {
|
|
1202
|
+
sourcePath: contract.sourcePath
|
|
1203
|
+
});
|
|
1148
1204
|
const contractWithWasm = {
|
|
1149
1205
|
...contract,
|
|
1150
1206
|
wasmPath
|
|
@@ -1939,7 +1995,8 @@ function packageJsonSource(projectName) {
|
|
|
1939
1995
|
"zk:build": "caatinga zk build main",
|
|
1940
1996
|
"zk:prove": "caatinga zk prove main",
|
|
1941
1997
|
build: "caatinga build verifier",
|
|
1942
|
-
deploy: "caatinga deploy verifier"
|
|
1998
|
+
deploy: "caatinga deploy verifier --network testnet --source ${CAATINGA_SOURCE:-alice}",
|
|
1999
|
+
doctor: "caatinga doctor --network testnet"
|
|
1943
2000
|
},
|
|
1944
2001
|
devDependencies: {
|
|
1945
2002
|
"@caatinga/cli": `^${CAATINGA_CORE_VERSION}`,
|
|
@@ -1959,7 +2016,7 @@ Minimal Caatinga ZK project.
|
|
|
1959
2016
|
npm install
|
|
1960
2017
|
npx caatinga zk build main
|
|
1961
2018
|
npx caatinga build verifier
|
|
1962
|
-
npx caatinga deploy verifier --network testnet
|
|
2019
|
+
npx caatinga deploy verifier --network testnet --source <identity>
|
|
1963
2020
|
npx caatinga zk prove main
|
|
1964
2021
|
\`\`\`
|
|
1965
2022
|
|
|
@@ -2040,7 +2097,7 @@ function packageJsonSource2(projectName) {
|
|
|
2040
2097
|
scripts: {
|
|
2041
2098
|
build: "caatinga build app",
|
|
2042
2099
|
deploy: "caatinga deploy app --network testnet --source ${CAATINGA_SOURCE:-alice}",
|
|
2043
|
-
doctor: "caatinga doctor",
|
|
2100
|
+
doctor: "caatinga doctor --network testnet",
|
|
2044
2101
|
"read:hello": "caatinga read app.hello --network testnet --source ${CAATINGA_SOURCE:-alice}",
|
|
2045
2102
|
"read:version": "caatinga read app.version --network testnet --source ${CAATINGA_SOURCE:-alice}"
|
|
2046
2103
|
},
|