@caatinga/core 0.2.4 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/{browser-CuET2GqM.d.cts → browser-djYObNl8.d.cts} +0 -1
- package/dist/{browser-CuET2GqM.d.ts → browser-djYObNl8.d.ts} +0 -1
- package/dist/browser.cjs +0 -1
- package/dist/browser.d.cts +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +72 -5
- package/dist/index.cjs +142 -79
- package/dist/index.d.cts +37 -16
- package/dist/index.d.ts +37 -16
- package/dist/index.js +211 -81
- package/dist/runtime/requirements.cjs +50 -0
- package/dist/runtime/requirements.d.cts +5 -0
- package/dist/runtime/requirements.d.ts +5 -0
- package/dist/runtime/requirements.js +12 -0
- package/package.json +7 -2
- package/dist/browser-DUcSR5D3.d.cts +0 -173
- package/dist/browser-DUcSR5D3.d.ts +0 -173
- package/dist/chunk-EKHNKCJV.js +0 -79
- package/dist/chunk-GMABXVEY.js +0 -78
package/dist/index.js
CHANGED
|
@@ -1,11 +1,78 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
// src/errors/CaatingaErrorCode.ts
|
|
2
|
+
var CaatingaErrorCode = {
|
|
3
|
+
CONFIG_NOT_FOUND: "CAATINGA_CONFIG_NOT_FOUND",
|
|
4
|
+
INVALID_CONFIG: "CAATINGA_INVALID_CONFIG",
|
|
5
|
+
COMMAND_FAILED: "CAATINGA_COMMAND_FAILED",
|
|
6
|
+
UNEXPECTED_ERROR: "CAATINGA_UNEXPECTED_ERROR",
|
|
7
|
+
STELLAR_CLI_NOT_FOUND: "CAATINGA_STELLAR_CLI_NOT_FOUND",
|
|
8
|
+
STELLAR_CLI_VERSION_PARSE_FAILED: "CAATINGA_STELLAR_CLI_VERSION_PARSE_FAILED",
|
|
9
|
+
UNSUPPORTED_CLI_VERSION: "CAATINGA_UNSUPPORTED_CLI_VERSION",
|
|
10
|
+
RUST_NOT_FOUND: "CAATINGA_RUST_NOT_FOUND",
|
|
11
|
+
RUST_TARGET_NOT_FOUND: "CAATINGA_RUST_TARGET_NOT_FOUND",
|
|
12
|
+
DEPLOY_FAILED: "CAATINGA_DEPLOY_FAILED",
|
|
13
|
+
BUILD_FAILED: "CAATINGA_BUILD_FAILED",
|
|
14
|
+
BINDINGS_FAILED: "CAATINGA_BINDINGS_FAILED",
|
|
15
|
+
INVOKE_FAILED: "CAATINGA_INVOKE_FAILED",
|
|
16
|
+
CONTRACT_NOT_FOUND: "CAATINGA_CONTRACT_NOT_FOUND",
|
|
17
|
+
NETWORK_NOT_FOUND: "CAATINGA_NETWORK_NOT_FOUND",
|
|
18
|
+
ARTIFACT_NOT_FOUND: "CAATINGA_ARTIFACT_NOT_FOUND",
|
|
19
|
+
ARTIFACT_INVALID: "CAATINGA_ARTIFACT_INVALID",
|
|
20
|
+
CONTRACT_ID_NOT_FOUND: "CAATINGA_CONTRACT_ID_NOT_FOUND",
|
|
21
|
+
CONTRACT_ARTIFACT_NOT_FOUND: "CAATINGA_CONTRACT_ARTIFACT_NOT_FOUND",
|
|
22
|
+
CONTRACT_DEPENDENCY_NOT_FOUND: "CAATINGA_CONTRACT_DEPENDENCY_NOT_FOUND",
|
|
23
|
+
CONTRACT_DEPENDENCY_CYCLE: "CAATINGA_CONTRACT_DEPENDENCY_CYCLE",
|
|
24
|
+
CONTRACT_DEPENDENCY_ARTIFACT_NOT_FOUND: "CAATINGA_CONTRACT_DEPENDENCY_ARTIFACT_NOT_FOUND",
|
|
25
|
+
DEPENDENCY_CONTRACT_NOT_FOUND: "CAATINGA_DEPENDENCY_CONTRACT_NOT_FOUND",
|
|
26
|
+
DEPLOY_ARG_PLACEHOLDER_INVALID: "CAATINGA_DEPLOY_ARG_PLACEHOLDER_INVALID",
|
|
27
|
+
DEPLOY_ARG_PLACEHOLDER_UNRESOLVED: "CAATINGA_DEPLOY_ARG_PLACEHOLDER_UNRESOLVED",
|
|
28
|
+
BINDING_CLIENT_NOT_FOUND: "CAATINGA_BINDING_CLIENT_NOT_FOUND",
|
|
29
|
+
BINDING_METHOD_NOT_FOUND: "CAATINGA_BINDING_METHOD_NOT_FOUND",
|
|
30
|
+
XDR_BUILD_FAILED: "CAATINGA_XDR_BUILD_FAILED",
|
|
31
|
+
XDR_PREPARE_FAILED: "CAATINGA_XDR_PREPARE_FAILED",
|
|
32
|
+
XDR_SIGN_FAILED: "CAATINGA_XDR_SIGN_FAILED",
|
|
33
|
+
XDR_SUBMIT_FAILED: "CAATINGA_XDR_SUBMIT_FAILED",
|
|
34
|
+
XDR_RESULT_FAILED: "CAATINGA_XDR_RESULT_FAILED",
|
|
35
|
+
READ_RESULT_MISSING: "CAATINGA_READ_RESULT_MISSING",
|
|
36
|
+
WALLET_NOT_CONNECTED: "CAATINGA_WALLET_NOT_CONNECTED",
|
|
37
|
+
WALLET_TIMEOUT: "CAATINGA_WALLET_TIMEOUT",
|
|
38
|
+
SOURCE_ACCOUNT_REQUIRED: "CAATINGA_SOURCE_ACCOUNT_REQUIRED",
|
|
39
|
+
SOURCE_IS_SECRET_KEY: "CAATINGA_SOURCE_IS_SECRET_KEY",
|
|
40
|
+
SOURCE_IS_SEED_PHRASE: "CAATINGA_SOURCE_IS_SEED_PHRASE",
|
|
41
|
+
SOURCE_IS_PUBLIC_KEY: "CAATINGA_SOURCE_IS_PUBLIC_KEY",
|
|
42
|
+
UNSAFE_SOURCE_ACCOUNT: "CAATINGA_UNSAFE_SOURCE_ACCOUNT",
|
|
43
|
+
INVOKE_TARGET_INVALID: "CAATINGA_INVOKE_TARGET_INVALID",
|
|
44
|
+
TEMPLATE_NOT_FOUND: "CAATINGA_TEMPLATE_NOT_FOUND",
|
|
45
|
+
INVALID_TEMPLATE_MANIFEST: "CAATINGA_INVALID_TEMPLATE_MANIFEST",
|
|
46
|
+
TEMPLATE_MANIFEST_NOT_FOUND: "CAATINGA_TEMPLATE_MANIFEST_NOT_FOUND",
|
|
47
|
+
TEMPLATE_INCOMPATIBLE: "CAATINGA_TEMPLATE_INCOMPATIBLE",
|
|
48
|
+
DOCTOR_PARTIAL_DEPLOY: "CAATINGA_DOCTOR_PARTIAL_DEPLOY"
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
// src/errors/CaatingaError.ts
|
|
52
|
+
var CaatingaError = class extends Error {
|
|
53
|
+
constructor(message, code, hint, cause) {
|
|
54
|
+
super(message);
|
|
55
|
+
this.code = code;
|
|
56
|
+
this.hint = hint;
|
|
57
|
+
this.cause = cause;
|
|
58
|
+
this.name = "CaatingaError";
|
|
59
|
+
}
|
|
60
|
+
code;
|
|
61
|
+
hint;
|
|
62
|
+
cause;
|
|
63
|
+
};
|
|
64
|
+
function toCaatingaError(error) {
|
|
65
|
+
if (error instanceof CaatingaError) {
|
|
66
|
+
return error;
|
|
67
|
+
}
|
|
68
|
+
if (error instanceof Error) {
|
|
69
|
+
return new CaatingaError(error.message, CaatingaErrorCode.UNEXPECTED_ERROR, void 0, error);
|
|
70
|
+
}
|
|
71
|
+
return new CaatingaError("An unexpected error occurred.", CaatingaErrorCode.UNEXPECTED_ERROR);
|
|
72
|
+
}
|
|
6
73
|
|
|
7
74
|
// src/version.ts
|
|
8
|
-
var CAATINGA_CORE_VERSION = "0.
|
|
75
|
+
var CAATINGA_CORE_VERSION = "2.0.0";
|
|
9
76
|
|
|
10
77
|
// src/config/config.schema.ts
|
|
11
78
|
import { z } from "zod";
|
|
@@ -134,11 +201,20 @@ async function writeArtifacts(artifacts, cwd = process.cwd()) {
|
|
|
134
201
|
`, "utf8");
|
|
135
202
|
return artifactsPath;
|
|
136
203
|
}
|
|
137
|
-
function createInitialArtifacts(project) {
|
|
204
|
+
function createInitialArtifacts(project, options = {}) {
|
|
205
|
+
const networks = Object.fromEntries(
|
|
206
|
+
Array.from(new Set(options.networks ?? [])).map((network) => [
|
|
207
|
+
network,
|
|
208
|
+
{
|
|
209
|
+
contracts: {},
|
|
210
|
+
dependencyGraph: {}
|
|
211
|
+
}
|
|
212
|
+
])
|
|
213
|
+
);
|
|
138
214
|
return {
|
|
139
215
|
project,
|
|
140
216
|
version: 1,
|
|
141
|
-
networks
|
|
217
|
+
networks
|
|
142
218
|
};
|
|
143
219
|
}
|
|
144
220
|
|
|
@@ -190,10 +266,12 @@ function resolveNetwork(config, networkName) {
|
|
|
190
266
|
// src/shell/run-command.ts
|
|
191
267
|
import { execa } from "execa";
|
|
192
268
|
|
|
269
|
+
// src/stellar-cli/compat.ts
|
|
270
|
+
import semver2 from "semver";
|
|
271
|
+
|
|
193
272
|
// src/stellar-cli/version.ts
|
|
194
273
|
import semver from "semver";
|
|
195
274
|
var STELLAR_CLI_MIN_VERSION = "23.0.0";
|
|
196
|
-
var STELLAR_CLI_TESTED_MAX_VERSION = "25.2.0";
|
|
197
275
|
var STELLAR_CLI_SEMVER_REGEX = /\b(\d+\.\d+\.\d+(?:-[0-9A-Za-z-.]+)?(?:\+[0-9A-Za-z-.]+)?)\b/;
|
|
198
276
|
function parseStellarCliVersion(output) {
|
|
199
277
|
const match = output.match(STELLAR_CLI_SEMVER_REGEX);
|
|
@@ -207,43 +285,66 @@ function parseStellarCliVersion(output) {
|
|
|
207
285
|
}
|
|
208
286
|
return version;
|
|
209
287
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
288
|
+
|
|
289
|
+
// src/stellar-cli/compat.ts
|
|
290
|
+
var STELLAR_CLI_LAST_TESTED_VERSION = "25.2.0";
|
|
291
|
+
function evaluateStellarCliCompatibility(input) {
|
|
292
|
+
const parsed = semver2.parse(input.version);
|
|
293
|
+
if (!parsed || !semver2.valid(input.version)) {
|
|
213
294
|
throw new CaatingaError(
|
|
214
295
|
"Could not parse Stellar CLI version.",
|
|
215
296
|
CaatingaErrorCode.STELLAR_CLI_VERSION_PARSE_FAILED,
|
|
216
297
|
"Use a semantic version such as 22.0.1."
|
|
217
298
|
);
|
|
218
299
|
}
|
|
219
|
-
|
|
300
|
+
const lastTestedVersion = semver2.valid(input.lastTestedVersion ?? STELLAR_CLI_LAST_TESTED_VERSION) ?? STELLAR_CLI_LAST_TESTED_VERSION;
|
|
301
|
+
const warnings = [];
|
|
302
|
+
let status = "supported";
|
|
303
|
+
if (semver2.lt(parsed, STELLAR_CLI_MIN_VERSION)) {
|
|
220
304
|
throw new CaatingaError(
|
|
221
|
-
`Stellar CLI ${
|
|
305
|
+
`Stellar CLI ${input.version} is below the supported minimum ${STELLAR_CLI_MIN_VERSION}.`,
|
|
222
306
|
CaatingaErrorCode.UNSUPPORTED_CLI_VERSION,
|
|
223
307
|
`Install Stellar CLI ${STELLAR_CLI_MIN_VERSION} or newer.`
|
|
224
308
|
);
|
|
225
309
|
}
|
|
226
|
-
if (
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
310
|
+
if (semver2.gt(parsed, lastTestedVersion)) {
|
|
311
|
+
status = "untested";
|
|
312
|
+
warnings.push({
|
|
313
|
+
code: "STELLAR_CLI_UNTESTED_VERSION",
|
|
314
|
+
message: `Stellar CLI ${input.version} is newer than the last-tested ${lastTestedVersion}; proceeding without compatibility guarantees.`,
|
|
315
|
+
remediation: "Pin Stellar CLI to the last-tested version, or update Caatinga after re-running the parser fixtures."
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
if (input.features) {
|
|
319
|
+
for (const feature of input.features) {
|
|
320
|
+
if (!feature) {
|
|
321
|
+
continue;
|
|
322
|
+
}
|
|
323
|
+
status = "untested";
|
|
324
|
+
warnings.push({
|
|
325
|
+
code: "STELLAR_CLI_MISSING_FEATURE",
|
|
326
|
+
message: `Stellar CLI ${input.version} did not advertise the required feature "${feature}".`,
|
|
327
|
+
remediation: "Upgrade Stellar CLI or run `caatinga doctor` for diagnostics."
|
|
328
|
+
});
|
|
329
|
+
}
|
|
232
330
|
}
|
|
233
|
-
return
|
|
331
|
+
return {
|
|
332
|
+
version: input.version,
|
|
333
|
+
status,
|
|
334
|
+
minVersion: STELLAR_CLI_MIN_VERSION,
|
|
335
|
+
lastTestedVersion,
|
|
336
|
+
warnings
|
|
337
|
+
};
|
|
234
338
|
}
|
|
235
339
|
|
|
236
340
|
// src/stellar-cli/check-stellar-cli-version.ts
|
|
237
|
-
async function checkStellarCliVersion(input) {
|
|
341
|
+
async function checkStellarCliVersion(input = {}) {
|
|
342
|
+
let rawOutput;
|
|
238
343
|
try {
|
|
239
344
|
const result = await runCommand("stellar", ["--version"], {
|
|
240
345
|
skipStellarVersionCheck: true
|
|
241
346
|
});
|
|
242
|
-
|
|
243
|
-
return assertSupportedStellarCliVersion({
|
|
244
|
-
version: parseStellarCliVersion(output),
|
|
245
|
-
allowUntested: input.allowUntested
|
|
246
|
-
});
|
|
347
|
+
rawOutput = result.all || result.stdout || result.stderr;
|
|
247
348
|
} catch (error) {
|
|
248
349
|
if (typeof error === "object" && error && "code" in error && error.code === "ENOENT") {
|
|
249
350
|
throw new CaatingaError(
|
|
@@ -255,15 +356,34 @@ async function checkStellarCliVersion(input) {
|
|
|
255
356
|
}
|
|
256
357
|
throw error;
|
|
257
358
|
}
|
|
359
|
+
const report = evaluateStellarCliCompatibility({
|
|
360
|
+
version: parseStellarCliVersion(rawOutput),
|
|
361
|
+
features: input.features,
|
|
362
|
+
lastTestedVersion: input.lastTestedVersion
|
|
363
|
+
});
|
|
364
|
+
for (const warning of report.warnings) {
|
|
365
|
+
if (input.onWarning) {
|
|
366
|
+
input.onWarning(warning);
|
|
367
|
+
} else {
|
|
368
|
+
defaultEmitWarning(warning);
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
return report;
|
|
372
|
+
}
|
|
373
|
+
function defaultEmitWarning(warning) {
|
|
374
|
+
const lines = [
|
|
375
|
+
`Warning: ${warning.message}`,
|
|
376
|
+
warning.remediation ? ` ${warning.remediation}` : void 0
|
|
377
|
+
].filter((line) => Boolean(line));
|
|
378
|
+
process.stderr.write(`${lines.join("\n")}
|
|
379
|
+
`);
|
|
258
380
|
}
|
|
259
381
|
|
|
260
382
|
// src/shell/run-command.ts
|
|
261
383
|
async function runCommand(command, args, options = {}) {
|
|
262
384
|
try {
|
|
263
385
|
if (command === "stellar" && !options.skipStellarVersionCheck) {
|
|
264
|
-
await checkStellarCliVersion(
|
|
265
|
-
allowUntested: options.allowUntestedStellarCli === true
|
|
266
|
-
});
|
|
386
|
+
await checkStellarCliVersion();
|
|
267
387
|
}
|
|
268
388
|
const result = await execa(command, args, {
|
|
269
389
|
cwd: options.cwd,
|
|
@@ -404,7 +524,6 @@ async function resolveContractIdFromDeploySalt(options) {
|
|
|
404
524
|
...buildStellarNetworkArgsFromConfig(options.network)
|
|
405
525
|
], {
|
|
406
526
|
cwd: options.cwd,
|
|
407
|
-
allowUntestedStellarCli: options.allowUntestedStellarCli,
|
|
408
527
|
skipStellarVersionCheck: true
|
|
409
528
|
});
|
|
410
529
|
return parseContractId(result.all || `${result.stdout}
|
|
@@ -427,8 +546,7 @@ async function tryRecoverContractIdFromDeployFailure(options) {
|
|
|
427
546
|
salt,
|
|
428
547
|
source: options.source,
|
|
429
548
|
network: options.network,
|
|
430
|
-
cwd: options.cwd
|
|
431
|
-
allowUntestedStellarCli: options.allowUntestedStellarCli
|
|
549
|
+
cwd: options.cwd
|
|
432
550
|
});
|
|
433
551
|
}
|
|
434
552
|
|
|
@@ -578,7 +696,6 @@ function formatStaleWasmWarning(contractName) {
|
|
|
578
696
|
}
|
|
579
697
|
|
|
580
698
|
// src/contracts/build-contract.ts
|
|
581
|
-
var RUST_WASM_TARGET = "wasm32v1-none";
|
|
582
699
|
var MISSING_WASM_TARGET_HINT_SUBSTRINGS = [
|
|
583
700
|
"not installed",
|
|
584
701
|
"not found",
|
|
@@ -596,7 +713,7 @@ function isMissingRustWasmTargetError(error) {
|
|
|
596
713
|
error.cause === void 0 ? "" : String(error.cause)
|
|
597
714
|
];
|
|
598
715
|
const haystack = parts.join("\n").toLowerCase();
|
|
599
|
-
if (!haystack.includes(
|
|
716
|
+
if (!haystack.includes(CURRENT_RUST_WASM_TARGET)) {
|
|
600
717
|
return false;
|
|
601
718
|
}
|
|
602
719
|
return MISSING_WASM_TARGET_HINT_SUBSTRINGS.some((needle) => haystack.includes(needle));
|
|
@@ -605,22 +722,19 @@ async function buildContract(options) {
|
|
|
605
722
|
const cwd = options.cwd ?? process.cwd();
|
|
606
723
|
const contract = resolveContract(options.config, options.contractName, cwd);
|
|
607
724
|
await checkBinary("rustc", "Install Rust before running caatinga build.");
|
|
608
|
-
await checkBinary("stellar", "Install Stellar CLI before running caatinga build."
|
|
609
|
-
allowUntestedStellarCli: options.allowUntestedStellarCli
|
|
610
|
-
});
|
|
725
|
+
await checkBinary("stellar", "Install Stellar CLI before running caatinga build.");
|
|
611
726
|
let result;
|
|
612
727
|
try {
|
|
613
728
|
result = await runCommand("stellar", ["contract", "build"], {
|
|
614
729
|
cwd: contract.sourcePath,
|
|
615
|
-
allowUntestedStellarCli: options.allowUntestedStellarCli,
|
|
616
730
|
failureCode: CaatingaErrorCode.BUILD_FAILED
|
|
617
731
|
});
|
|
618
732
|
} catch (error) {
|
|
619
733
|
if (error instanceof CaatingaError && error.code === CaatingaErrorCode.BUILD_FAILED && isMissingRustWasmTargetError(error)) {
|
|
620
734
|
throw new CaatingaError(
|
|
621
|
-
`Required Rust wasm target "${
|
|
735
|
+
`Required Rust wasm target "${CURRENT_RUST_WASM_TARGET}" is missing.`,
|
|
622
736
|
CaatingaErrorCode.RUST_TARGET_NOT_FOUND,
|
|
623
|
-
`Run \`rustup target add ${
|
|
737
|
+
`Run \`rustup target add ${CURRENT_RUST_WASM_TARGET}\` and retry.`,
|
|
624
738
|
error
|
|
625
739
|
);
|
|
626
740
|
}
|
|
@@ -715,9 +829,7 @@ async function deployContract(options) {
|
|
|
715
829
|
const contract = resolveContract(options.config, options.contractName, cwd);
|
|
716
830
|
const network = resolveNetwork(options.config, options.networkName);
|
|
717
831
|
const source = assertSafeSourceAccount(options.source);
|
|
718
|
-
await checkBinary("stellar", "Install Stellar CLI before running caatinga deploy."
|
|
719
|
-
allowUntestedStellarCli: options.allowUntestedStellarCli
|
|
720
|
-
});
|
|
832
|
+
await checkBinary("stellar", "Install Stellar CLI before running caatinga deploy.");
|
|
721
833
|
const wasmPath = await resolveWasmArtifactPath(contract.wasmPath);
|
|
722
834
|
const contractWithWasm = {
|
|
723
835
|
...contract,
|
|
@@ -785,7 +897,6 @@ async function deployContract(options) {
|
|
|
785
897
|
try {
|
|
786
898
|
const result = await runCommand("stellar", stellarArgs, {
|
|
787
899
|
cwd,
|
|
788
|
-
allowUntestedStellarCli: options.allowUntestedStellarCli,
|
|
789
900
|
failureCode: CaatingaErrorCode.DEPLOY_FAILED
|
|
790
901
|
});
|
|
791
902
|
output = result.all || `${result.stdout}
|
|
@@ -800,8 +911,7 @@ ${result.stderr}`;
|
|
|
800
911
|
${error.hint ?? ""}`,
|
|
801
912
|
source,
|
|
802
913
|
network: network.config,
|
|
803
|
-
cwd
|
|
804
|
-
allowUntestedStellarCli: options.allowUntestedStellarCli
|
|
914
|
+
cwd
|
|
805
915
|
});
|
|
806
916
|
if (!recoveredContractId) {
|
|
807
917
|
throw error;
|
|
@@ -894,6 +1004,16 @@ function resolveDeployOrder(input) {
|
|
|
894
1004
|
}
|
|
895
1005
|
}
|
|
896
1006
|
|
|
1007
|
+
// src/contracts/deploy-skip.ts
|
|
1008
|
+
function toSkippedContract(name, contractId, network) {
|
|
1009
|
+
return {
|
|
1010
|
+
name,
|
|
1011
|
+
contractId,
|
|
1012
|
+
network,
|
|
1013
|
+
reason: "already-deployed"
|
|
1014
|
+
};
|
|
1015
|
+
}
|
|
1016
|
+
|
|
897
1017
|
// src/contracts/verify-dependency-contract.ts
|
|
898
1018
|
async function verifyDependencyContract(options) {
|
|
899
1019
|
try {
|
|
@@ -906,7 +1026,6 @@ async function verifyDependencyContract(options) {
|
|
|
906
1026
|
...buildStellarNetworkArgs(options.network)
|
|
907
1027
|
], {
|
|
908
1028
|
cwd: options.cwd,
|
|
909
|
-
allowUntestedStellarCli: options.allowUntestedStellarCli,
|
|
910
1029
|
failureCode: CaatingaErrorCode.DEPENDENCY_CONTRACT_NOT_FOUND
|
|
911
1030
|
});
|
|
912
1031
|
} catch (error) {
|
|
@@ -935,8 +1054,7 @@ async function verifyDependencyContracts(options) {
|
|
|
935
1054
|
dependencyName,
|
|
936
1055
|
contractId: contractArtifact.contractId,
|
|
937
1056
|
network: options.network,
|
|
938
|
-
cwd: options.cwd
|
|
939
|
-
allowUntestedStellarCli: options.allowUntestedStellarCli
|
|
1057
|
+
cwd: options.cwd
|
|
940
1058
|
});
|
|
941
1059
|
}
|
|
942
1060
|
}
|
|
@@ -962,8 +1080,7 @@ async function deployContractGraph(options) {
|
|
|
962
1080
|
dependencies: contractConfig.dependsOn,
|
|
963
1081
|
artifacts,
|
|
964
1082
|
network,
|
|
965
|
-
cwd
|
|
966
|
-
allowUntestedStellarCli: options.allowUntestedStellarCli
|
|
1083
|
+
cwd
|
|
967
1084
|
});
|
|
968
1085
|
}
|
|
969
1086
|
const resolvedDeployArgs = resolveDeployArgs({
|
|
@@ -972,12 +1089,9 @@ async function deployContractGraph(options) {
|
|
|
972
1089
|
network: network.name
|
|
973
1090
|
});
|
|
974
1091
|
if (existing?.contractId && !options.force) {
|
|
975
|
-
skippedContracts.push(
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
network: network.name,
|
|
979
|
-
reason: "already-deployed"
|
|
980
|
-
});
|
|
1092
|
+
skippedContracts.push(
|
|
1093
|
+
toSkippedContract(contractName, existing.contractId, network.name)
|
|
1094
|
+
);
|
|
981
1095
|
continue;
|
|
982
1096
|
}
|
|
983
1097
|
const result = await deployContract({
|
|
@@ -986,7 +1100,6 @@ async function deployContractGraph(options) {
|
|
|
986
1100
|
networkName: network.name,
|
|
987
1101
|
source: options.source,
|
|
988
1102
|
cwd,
|
|
989
|
-
allowUntestedStellarCli: options.allowUntestedStellarCli,
|
|
990
1103
|
force: options.force,
|
|
991
1104
|
checkStaleWasm: options.checkStaleWasm,
|
|
992
1105
|
resolvedDeployArgs,
|
|
@@ -999,12 +1112,9 @@ async function deployContractGraph(options) {
|
|
|
999
1112
|
});
|
|
1000
1113
|
}
|
|
1001
1114
|
if (result.skipped) {
|
|
1002
|
-
skippedContracts.push(
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
network: network.name,
|
|
1006
|
-
reason: "already-deployed"
|
|
1007
|
-
});
|
|
1115
|
+
skippedContracts.push(
|
|
1116
|
+
toSkippedContract(contractName, result.contractId, network.name)
|
|
1117
|
+
);
|
|
1008
1118
|
} else {
|
|
1009
1119
|
deployedContracts.push({ name: contractName, contractId: result.contractId });
|
|
1010
1120
|
}
|
|
@@ -1032,9 +1142,7 @@ async function generateBindings(options) {
|
|
|
1032
1142
|
"Run caatinga deploy for this contract and network before generating bindings."
|
|
1033
1143
|
);
|
|
1034
1144
|
}
|
|
1035
|
-
await checkBinary("stellar", "Install Stellar CLI before running caatinga generate."
|
|
1036
|
-
allowUntestedStellarCli: options.allowUntestedStellarCli
|
|
1037
|
-
});
|
|
1145
|
+
await checkBinary("stellar", "Install Stellar CLI before running caatinga generate.");
|
|
1038
1146
|
const outputDir = path7.resolve(cwd, options.config.frontend.bindingsOutput, options.contractName);
|
|
1039
1147
|
await mkdir2(outputDir, { recursive: true });
|
|
1040
1148
|
const result = await runCommand("stellar", [
|
|
@@ -1049,7 +1157,6 @@ async function generateBindings(options) {
|
|
|
1049
1157
|
...buildStellarNetworkArgs(network)
|
|
1050
1158
|
], {
|
|
1051
1159
|
cwd,
|
|
1052
|
-
allowUntestedStellarCli: options.allowUntestedStellarCli,
|
|
1053
1160
|
failureCode: CaatingaErrorCode.BINDINGS_FAILED
|
|
1054
1161
|
});
|
|
1055
1162
|
return {
|
|
@@ -1087,9 +1194,7 @@ async function invokeContract(options) {
|
|
|
1087
1194
|
"Run caatinga deploy for this contract and network before invoking it."
|
|
1088
1195
|
);
|
|
1089
1196
|
}
|
|
1090
|
-
await checkBinary("stellar", "Install Stellar CLI before running caatinga invoke."
|
|
1091
|
-
allowUntestedStellarCli: options.allowUntestedStellarCli
|
|
1092
|
-
});
|
|
1197
|
+
await checkBinary("stellar", "Install Stellar CLI before running caatinga invoke.");
|
|
1093
1198
|
let result;
|
|
1094
1199
|
try {
|
|
1095
1200
|
result = await runCommand("stellar", [
|
|
@@ -1105,7 +1210,6 @@ async function invokeContract(options) {
|
|
|
1105
1210
|
...options.args ?? []
|
|
1106
1211
|
], {
|
|
1107
1212
|
cwd,
|
|
1108
|
-
allowUntestedStellarCli: options.allowUntestedStellarCli,
|
|
1109
1213
|
failureCode: CaatingaErrorCode.INVOKE_FAILED
|
|
1110
1214
|
});
|
|
1111
1215
|
} catch (error) {
|
|
@@ -1141,7 +1245,7 @@ import { z as z6 } from "zod";
|
|
|
1141
1245
|
|
|
1142
1246
|
// src/templates/template-manifest.schema.ts
|
|
1143
1247
|
import { z as z5 } from "zod";
|
|
1144
|
-
import
|
|
1248
|
+
import semver3 from "semver";
|
|
1145
1249
|
var CURRENT_TEMPLATE_VERSION = 1;
|
|
1146
1250
|
var TemplateManifestSchema = z5.object({
|
|
1147
1251
|
name: z5.string().min(1),
|
|
@@ -1165,14 +1269,14 @@ var TemplateManifestSchema = z5.object({
|
|
|
1165
1269
|
})
|
|
1166
1270
|
});
|
|
1167
1271
|
function defaultCompatibleCoreRange(coreVersion = CAATINGA_CORE_VERSION) {
|
|
1168
|
-
const version =
|
|
1272
|
+
const version = semver3.valid(semver3.coerce(coreVersion));
|
|
1169
1273
|
if (!version) {
|
|
1170
1274
|
throw new Error(`Invalid core version: ${coreVersion}`);
|
|
1171
1275
|
}
|
|
1172
1276
|
return `^${version}`;
|
|
1173
1277
|
}
|
|
1174
1278
|
function isCoreVersionCompatible(range, coreVersion = CAATINGA_CORE_VERSION) {
|
|
1175
|
-
return
|
|
1279
|
+
return semver3.satisfies(coreVersion, range);
|
|
1176
1280
|
}
|
|
1177
1281
|
function getTemplateCompatibilityIssue(manifest, coreVersion = CAATINGA_CORE_VERSION) {
|
|
1178
1282
|
if (manifest.caatinga.templateVersion !== CURRENT_TEMPLATE_VERSION) {
|
|
@@ -1205,6 +1309,12 @@ function formatTemplateCompatibilityHint(issue) {
|
|
|
1205
1309
|
}
|
|
1206
1310
|
|
|
1207
1311
|
// src/templates/create-project-from-template.ts
|
|
1312
|
+
var TEMPLATE_COPY_EXCLUDED_DIRS = /* @__PURE__ */ new Set([
|
|
1313
|
+
"target",
|
|
1314
|
+
"test_snapshots",
|
|
1315
|
+
"node_modules",
|
|
1316
|
+
".git"
|
|
1317
|
+
]);
|
|
1208
1318
|
async function createProjectFromTemplate(options) {
|
|
1209
1319
|
const targetDir = path8.resolve(options.targetDir);
|
|
1210
1320
|
const templateDir = path8.resolve(options.templateDir);
|
|
@@ -1222,12 +1332,25 @@ async function createProjectFromTemplate(options) {
|
|
|
1222
1332
|
await cp(templateDir, targetDir, {
|
|
1223
1333
|
recursive: true,
|
|
1224
1334
|
force: false,
|
|
1225
|
-
errorOnExist: true
|
|
1335
|
+
errorOnExist: true,
|
|
1336
|
+
filter: (source) => shouldCopyTemplateEntry(templateDir, source)
|
|
1226
1337
|
});
|
|
1227
1338
|
await replaceTemplateVariables(targetDir, options.projectName);
|
|
1228
|
-
await
|
|
1339
|
+
await ensureArtifacts(targetDir, options.projectName);
|
|
1229
1340
|
return { targetDir, template: manifest };
|
|
1230
1341
|
}
|
|
1342
|
+
async function ensureArtifacts(targetDir, projectName) {
|
|
1343
|
+
try {
|
|
1344
|
+
const artifacts = await readArtifacts(targetDir);
|
|
1345
|
+
await writeArtifacts({ ...artifacts, project: projectName }, targetDir);
|
|
1346
|
+
} catch (error) {
|
|
1347
|
+
if (error instanceof CaatingaError && error.code === CaatingaErrorCode.ARTIFACT_NOT_FOUND) {
|
|
1348
|
+
await writeArtifacts(createInitialArtifacts(projectName, { networks: ["testnet"] }), targetDir);
|
|
1349
|
+
return;
|
|
1350
|
+
}
|
|
1351
|
+
throw error;
|
|
1352
|
+
}
|
|
1353
|
+
}
|
|
1231
1354
|
async function readTemplateManifest(templateDir) {
|
|
1232
1355
|
const manifestPath = path8.join(templateDir, "caatinga.template.json");
|
|
1233
1356
|
try {
|
|
@@ -1279,6 +1402,13 @@ async function replaceTemplateVariables(dir, projectName) {
|
|
|
1279
1402
|
await writeFile2(entryPath, content.replaceAll("__PROJECT_NAME__", projectName), "utf8");
|
|
1280
1403
|
}));
|
|
1281
1404
|
}
|
|
1405
|
+
function shouldCopyTemplateEntry(templateDir, source) {
|
|
1406
|
+
const relativePath = path8.relative(templateDir, source);
|
|
1407
|
+
if (!relativePath || relativePath === ".") {
|
|
1408
|
+
return true;
|
|
1409
|
+
}
|
|
1410
|
+
return !relativePath.split(path8.sep).some((segment) => TEMPLATE_COPY_EXCLUDED_DIRS.has(segment));
|
|
1411
|
+
}
|
|
1282
1412
|
function isTextTemplateFile(filePath) {
|
|
1283
1413
|
return [
|
|
1284
1414
|
".json",
|
|
@@ -1295,7 +1425,6 @@ function isTextTemplateFile(filePath) {
|
|
|
1295
1425
|
// src/ci/is-transient-testnet-smoke-failure.ts
|
|
1296
1426
|
var NO_RETRY_CAATINGA_SUBSTRINGS = [
|
|
1297
1427
|
"CAATINGA_UNSUPPORTED_CLI_VERSION",
|
|
1298
|
-
"CAATINGA_UNTESTED_CLI_VERSION",
|
|
1299
1428
|
"CAATINGA_STELLAR_CLI_VERSION_PARSE_FAILED",
|
|
1300
1429
|
"CAATINGA_STELLAR_CLI_NOT_FOUND",
|
|
1301
1430
|
"CAATINGA_INVALID_CONFIG",
|
|
@@ -1319,19 +1448,20 @@ export {
|
|
|
1319
1448
|
CaatingaConfigSchema,
|
|
1320
1449
|
CaatingaError,
|
|
1321
1450
|
CaatingaErrorCode,
|
|
1451
|
+
STELLAR_CLI_LAST_TESTED_VERSION,
|
|
1322
1452
|
STELLAR_CLI_MIN_VERSION,
|
|
1323
|
-
STELLAR_CLI_TESTED_MAX_VERSION,
|
|
1324
1453
|
TemplateManifestSchema,
|
|
1325
1454
|
WELL_KNOWN_NETWORKS,
|
|
1326
|
-
assertSupportedStellarCliVersion,
|
|
1327
1455
|
buildContract,
|
|
1328
1456
|
buildDependencyGraph,
|
|
1329
1457
|
checkBinary,
|
|
1458
|
+
checkStellarCliVersion,
|
|
1330
1459
|
createInitialArtifacts,
|
|
1331
1460
|
createProjectFromTemplate,
|
|
1332
1461
|
defineConfig,
|
|
1333
1462
|
deployContract,
|
|
1334
1463
|
deployContractGraph,
|
|
1464
|
+
evaluateStellarCliCompatibility,
|
|
1335
1465
|
generateBindings,
|
|
1336
1466
|
invokeContract,
|
|
1337
1467
|
isTransientTestnetSmokeFailure,
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/runtime/requirements.ts
|
|
31
|
+
var requirements_exports = {};
|
|
32
|
+
__export(requirements_exports, {
|
|
33
|
+
CURRENT_RUST_WASM_TARGET: () => CURRENT_RUST_WASM_TARGET,
|
|
34
|
+
NODE_MIN_MAJOR: () => NODE_MIN_MAJOR
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(requirements_exports);
|
|
37
|
+
|
|
38
|
+
// src/contracts/wasm.ts
|
|
39
|
+
var import_node_crypto = require("crypto");
|
|
40
|
+
var import_promises = require("fs/promises");
|
|
41
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
42
|
+
var CURRENT_RUST_WASM_TARGET = "wasm32v1-none";
|
|
43
|
+
|
|
44
|
+
// src/runtime/requirements.ts
|
|
45
|
+
var NODE_MIN_MAJOR = 20;
|
|
46
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
47
|
+
0 && (module.exports = {
|
|
48
|
+
CURRENT_RUST_WASM_TARGET,
|
|
49
|
+
NODE_MIN_MAJOR
|
|
50
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// src/contracts/wasm.ts
|
|
2
|
+
import { createHash } from "crypto";
|
|
3
|
+
import { access, readdir, readFile, stat } from "fs/promises";
|
|
4
|
+
import path from "path";
|
|
5
|
+
var CURRENT_RUST_WASM_TARGET = "wasm32v1-none";
|
|
6
|
+
|
|
7
|
+
// src/runtime/requirements.ts
|
|
8
|
+
var NODE_MIN_MAJOR = 20;
|
|
9
|
+
export {
|
|
10
|
+
CURRENT_RUST_WASM_TARGET,
|
|
11
|
+
NODE_MIN_MAJOR
|
|
12
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caatinga/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Core config, artifacts, command orchestration, and error primitives for Caatinga/Soroban toolkit",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"stellar",
|
|
@@ -36,6 +36,11 @@
|
|
|
36
36
|
"types": "./dist/browser.d.ts",
|
|
37
37
|
"import": "./dist/browser.js",
|
|
38
38
|
"require": "./dist/browser.cjs"
|
|
39
|
+
},
|
|
40
|
+
"./runtime/requirements": {
|
|
41
|
+
"types": "./dist/runtime/requirements.d.ts",
|
|
42
|
+
"import": "./dist/runtime/requirements.js",
|
|
43
|
+
"require": "./dist/runtime/requirements.cjs"
|
|
39
44
|
}
|
|
40
45
|
},
|
|
41
46
|
"files": [
|
|
@@ -56,7 +61,7 @@
|
|
|
56
61
|
"vitest": "^2.1.8"
|
|
57
62
|
},
|
|
58
63
|
"scripts": {
|
|
59
|
-
"build": "tsup
|
|
64
|
+
"build": "tsup",
|
|
60
65
|
"test": "vitest run --pool=threads",
|
|
61
66
|
"typecheck": "tsc --noEmit"
|
|
62
67
|
}
|