@caatinga/core 2.0.2 → 2.1.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/dist/{browser-djYObNl8.d.cts → browser-Cq4ZofIq.d.cts} +10 -1
- package/dist/{browser-djYObNl8.d.ts → browser-Cq4ZofIq.d.ts} +10 -1
- package/dist/browser.cjs +35 -0
- package/dist/browser.d.cts +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +34 -0
- package/dist/index.cjs +70 -1
- package/dist/index.d.cts +15 -4
- package/dist/index.d.ts +15 -4
- package/dist/index.js +68 -1
- package/package.json +1 -1
|
@@ -28,6 +28,7 @@ declare const CaatingaErrorCode: {
|
|
|
28
28
|
readonly DEPLOY_ARG_PLACEHOLDER_UNRESOLVED: "CAATINGA_DEPLOY_ARG_PLACEHOLDER_UNRESOLVED";
|
|
29
29
|
readonly BINDING_CLIENT_NOT_FOUND: "CAATINGA_BINDING_CLIENT_NOT_FOUND";
|
|
30
30
|
readonly BINDING_METHOD_NOT_FOUND: "CAATINGA_BINDING_METHOD_NOT_FOUND";
|
|
31
|
+
readonly PLACEHOLDER_BINDING: "CAATINGA_PLACEHOLDER_BINDING";
|
|
31
32
|
readonly XDR_BUILD_FAILED: "CAATINGA_XDR_BUILD_FAILED";
|
|
32
33
|
readonly XDR_PREPARE_FAILED: "CAATINGA_XDR_PREPARE_FAILED";
|
|
33
34
|
readonly XDR_SIGN_FAILED: "CAATINGA_XDR_SIGN_FAILED";
|
|
@@ -58,6 +59,14 @@ declare class CaatingaError extends Error {
|
|
|
58
59
|
}
|
|
59
60
|
declare function toCaatingaError(error: unknown): CaatingaError;
|
|
60
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Render an error for display. For a {@link CaatingaError} this surfaces the
|
|
64
|
+
* code, message, and hint, plus the underlying `cause` (when present) so the
|
|
65
|
+
* real reason — e.g. a wallet rejection or an XDR parse error — is never hidden
|
|
66
|
+
* behind a generic hint. Falls back to the plain message for other errors.
|
|
67
|
+
*/
|
|
68
|
+
declare function formatCaatingaError(error: unknown): string;
|
|
69
|
+
|
|
61
70
|
declare const ContractArtifactSchema: z.ZodObject<{
|
|
62
71
|
contractId: z.ZodString;
|
|
63
72
|
wasmHash: z.ZodString;
|
|
@@ -170,4 +179,4 @@ declare const CaatingaArtifactsSchema: z.ZodObject<{
|
|
|
170
179
|
type ContractArtifact = z.infer<typeof ContractArtifactSchema>;
|
|
171
180
|
type CaatingaArtifacts = z.infer<typeof CaatingaArtifactsSchema>;
|
|
172
181
|
|
|
173
|
-
export { type CaatingaArtifacts as C, type ContractArtifact as a, type CaatingaErrorCodeValue as b, CaatingaError as c, CaatingaArtifactsSchema as d, CaatingaErrorCode as e, toCaatingaError as t };
|
|
182
|
+
export { type CaatingaArtifacts as C, type ContractArtifact as a, type CaatingaErrorCodeValue as b, CaatingaError as c, CaatingaArtifactsSchema as d, CaatingaErrorCode as e, formatCaatingaError as f, toCaatingaError as t };
|
|
@@ -28,6 +28,7 @@ declare const CaatingaErrorCode: {
|
|
|
28
28
|
readonly DEPLOY_ARG_PLACEHOLDER_UNRESOLVED: "CAATINGA_DEPLOY_ARG_PLACEHOLDER_UNRESOLVED";
|
|
29
29
|
readonly BINDING_CLIENT_NOT_FOUND: "CAATINGA_BINDING_CLIENT_NOT_FOUND";
|
|
30
30
|
readonly BINDING_METHOD_NOT_FOUND: "CAATINGA_BINDING_METHOD_NOT_FOUND";
|
|
31
|
+
readonly PLACEHOLDER_BINDING: "CAATINGA_PLACEHOLDER_BINDING";
|
|
31
32
|
readonly XDR_BUILD_FAILED: "CAATINGA_XDR_BUILD_FAILED";
|
|
32
33
|
readonly XDR_PREPARE_FAILED: "CAATINGA_XDR_PREPARE_FAILED";
|
|
33
34
|
readonly XDR_SIGN_FAILED: "CAATINGA_XDR_SIGN_FAILED";
|
|
@@ -58,6 +59,14 @@ declare class CaatingaError extends Error {
|
|
|
58
59
|
}
|
|
59
60
|
declare function toCaatingaError(error: unknown): CaatingaError;
|
|
60
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Render an error for display. For a {@link CaatingaError} this surfaces the
|
|
64
|
+
* code, message, and hint, plus the underlying `cause` (when present) so the
|
|
65
|
+
* real reason — e.g. a wallet rejection or an XDR parse error — is never hidden
|
|
66
|
+
* behind a generic hint. Falls back to the plain message for other errors.
|
|
67
|
+
*/
|
|
68
|
+
declare function formatCaatingaError(error: unknown): string;
|
|
69
|
+
|
|
61
70
|
declare const ContractArtifactSchema: z.ZodObject<{
|
|
62
71
|
contractId: z.ZodString;
|
|
63
72
|
wasmHash: z.ZodString;
|
|
@@ -170,4 +179,4 @@ declare const CaatingaArtifactsSchema: z.ZodObject<{
|
|
|
170
179
|
type ContractArtifact = z.infer<typeof ContractArtifactSchema>;
|
|
171
180
|
type CaatingaArtifacts = z.infer<typeof CaatingaArtifactsSchema>;
|
|
172
181
|
|
|
173
|
-
export { type CaatingaArtifacts as C, type ContractArtifact as a, type CaatingaErrorCodeValue as b, CaatingaError as c, CaatingaArtifactsSchema as d, CaatingaErrorCode as e, toCaatingaError as t };
|
|
182
|
+
export { type CaatingaArtifacts as C, type ContractArtifact as a, type CaatingaErrorCodeValue as b, CaatingaError as c, CaatingaArtifactsSchema as d, CaatingaErrorCode as e, formatCaatingaError as f, toCaatingaError as t };
|
package/dist/browser.cjs
CHANGED
|
@@ -22,6 +22,7 @@ var browser_exports = {};
|
|
|
22
22
|
__export(browser_exports, {
|
|
23
23
|
CaatingaError: () => CaatingaError,
|
|
24
24
|
CaatingaErrorCode: () => CaatingaErrorCode,
|
|
25
|
+
formatCaatingaError: () => formatCaatingaError,
|
|
25
26
|
toCaatingaError: () => toCaatingaError
|
|
26
27
|
});
|
|
27
28
|
module.exports = __toCommonJS(browser_exports);
|
|
@@ -55,6 +56,7 @@ var CaatingaErrorCode = {
|
|
|
55
56
|
DEPLOY_ARG_PLACEHOLDER_UNRESOLVED: "CAATINGA_DEPLOY_ARG_PLACEHOLDER_UNRESOLVED",
|
|
56
57
|
BINDING_CLIENT_NOT_FOUND: "CAATINGA_BINDING_CLIENT_NOT_FOUND",
|
|
57
58
|
BINDING_METHOD_NOT_FOUND: "CAATINGA_BINDING_METHOD_NOT_FOUND",
|
|
59
|
+
PLACEHOLDER_BINDING: "CAATINGA_PLACEHOLDER_BINDING",
|
|
58
60
|
XDR_BUILD_FAILED: "CAATINGA_XDR_BUILD_FAILED",
|
|
59
61
|
XDR_PREPARE_FAILED: "CAATINGA_XDR_PREPARE_FAILED",
|
|
60
62
|
XDR_SIGN_FAILED: "CAATINGA_XDR_SIGN_FAILED",
|
|
@@ -98,9 +100,42 @@ function toCaatingaError(error) {
|
|
|
98
100
|
}
|
|
99
101
|
return new CaatingaError("An unexpected error occurred.", CaatingaErrorCode.UNEXPECTED_ERROR);
|
|
100
102
|
}
|
|
103
|
+
|
|
104
|
+
// src/errors/format-caatinga-error.ts
|
|
105
|
+
function formatCaatingaError(error) {
|
|
106
|
+
if (error instanceof CaatingaError) {
|
|
107
|
+
const lines = [`[${error.code}] ${error.message}`];
|
|
108
|
+
if (error.hint) {
|
|
109
|
+
lines.push("", error.hint);
|
|
110
|
+
}
|
|
111
|
+
const detail = formatCause(error.cause);
|
|
112
|
+
if (detail) {
|
|
113
|
+
lines.push("", `Details: ${detail}`);
|
|
114
|
+
}
|
|
115
|
+
return lines.join("\n");
|
|
116
|
+
}
|
|
117
|
+
return error instanceof Error ? error.message : String(error);
|
|
118
|
+
}
|
|
119
|
+
function formatCause(cause) {
|
|
120
|
+
if (cause === void 0 || cause === null) {
|
|
121
|
+
return "";
|
|
122
|
+
}
|
|
123
|
+
if (cause instanceof Error) {
|
|
124
|
+
return cause.message;
|
|
125
|
+
}
|
|
126
|
+
if (typeof cause === "string") {
|
|
127
|
+
return cause;
|
|
128
|
+
}
|
|
129
|
+
try {
|
|
130
|
+
return JSON.stringify(cause);
|
|
131
|
+
} catch {
|
|
132
|
+
return String(cause);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
101
135
|
// Annotate the CommonJS export names for ESM import in node:
|
|
102
136
|
0 && (module.exports = {
|
|
103
137
|
CaatingaError,
|
|
104
138
|
CaatingaErrorCode,
|
|
139
|
+
formatCaatingaError,
|
|
105
140
|
toCaatingaError
|
|
106
141
|
});
|
package/dist/browser.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { C as CaatingaArtifacts, c as CaatingaError, e as CaatingaErrorCode, a as ContractArtifact, t as toCaatingaError } from './browser-
|
|
1
|
+
export { C as CaatingaArtifacts, c as CaatingaError, e as CaatingaErrorCode, a as ContractArtifact, f as formatCaatingaError, t as toCaatingaError } from './browser-Cq4ZofIq.cjs';
|
|
2
2
|
import 'zod';
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { C as CaatingaArtifacts, c as CaatingaError, e as CaatingaErrorCode, a as ContractArtifact, t as toCaatingaError } from './browser-
|
|
1
|
+
export { C as CaatingaArtifacts, c as CaatingaError, e as CaatingaErrorCode, a as ContractArtifact, f as formatCaatingaError, t as toCaatingaError } from './browser-Cq4ZofIq.js';
|
|
2
2
|
import 'zod';
|
package/dist/browser.js
CHANGED
|
@@ -27,6 +27,7 @@ var CaatingaErrorCode = {
|
|
|
27
27
|
DEPLOY_ARG_PLACEHOLDER_UNRESOLVED: "CAATINGA_DEPLOY_ARG_PLACEHOLDER_UNRESOLVED",
|
|
28
28
|
BINDING_CLIENT_NOT_FOUND: "CAATINGA_BINDING_CLIENT_NOT_FOUND",
|
|
29
29
|
BINDING_METHOD_NOT_FOUND: "CAATINGA_BINDING_METHOD_NOT_FOUND",
|
|
30
|
+
PLACEHOLDER_BINDING: "CAATINGA_PLACEHOLDER_BINDING",
|
|
30
31
|
XDR_BUILD_FAILED: "CAATINGA_XDR_BUILD_FAILED",
|
|
31
32
|
XDR_PREPARE_FAILED: "CAATINGA_XDR_PREPARE_FAILED",
|
|
32
33
|
XDR_SIGN_FAILED: "CAATINGA_XDR_SIGN_FAILED",
|
|
@@ -70,8 +71,41 @@ function toCaatingaError(error) {
|
|
|
70
71
|
}
|
|
71
72
|
return new CaatingaError("An unexpected error occurred.", CaatingaErrorCode.UNEXPECTED_ERROR);
|
|
72
73
|
}
|
|
74
|
+
|
|
75
|
+
// src/errors/format-caatinga-error.ts
|
|
76
|
+
function formatCaatingaError(error) {
|
|
77
|
+
if (error instanceof CaatingaError) {
|
|
78
|
+
const lines = [`[${error.code}] ${error.message}`];
|
|
79
|
+
if (error.hint) {
|
|
80
|
+
lines.push("", error.hint);
|
|
81
|
+
}
|
|
82
|
+
const detail = formatCause(error.cause);
|
|
83
|
+
if (detail) {
|
|
84
|
+
lines.push("", `Details: ${detail}`);
|
|
85
|
+
}
|
|
86
|
+
return lines.join("\n");
|
|
87
|
+
}
|
|
88
|
+
return error instanceof Error ? error.message : String(error);
|
|
89
|
+
}
|
|
90
|
+
function formatCause(cause) {
|
|
91
|
+
if (cause === void 0 || cause === null) {
|
|
92
|
+
return "";
|
|
93
|
+
}
|
|
94
|
+
if (cause instanceof Error) {
|
|
95
|
+
return cause.message;
|
|
96
|
+
}
|
|
97
|
+
if (typeof cause === "string") {
|
|
98
|
+
return cause;
|
|
99
|
+
}
|
|
100
|
+
try {
|
|
101
|
+
return JSON.stringify(cause);
|
|
102
|
+
} catch {
|
|
103
|
+
return String(cause);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
73
106
|
export {
|
|
74
107
|
CaatingaError,
|
|
75
108
|
CaatingaErrorCode,
|
|
109
|
+
formatCaatingaError,
|
|
76
110
|
toCaatingaError
|
|
77
111
|
};
|
package/dist/index.cjs
CHANGED
|
@@ -49,7 +49,9 @@ __export(index_exports, {
|
|
|
49
49
|
deployContract: () => deployContract,
|
|
50
50
|
deployContractGraph: () => deployContractGraph,
|
|
51
51
|
evaluateStellarCliCompatibility: () => evaluateStellarCliCompatibility,
|
|
52
|
+
formatCaatingaError: () => formatCaatingaError,
|
|
52
53
|
generateBindings: () => generateBindings,
|
|
54
|
+
generateBindingsGraph: () => generateBindingsGraph,
|
|
53
55
|
invokeContract: () => invokeContract,
|
|
54
56
|
isTransientTestnetSmokeFailure: () => isTransientTestnetSmokeFailure,
|
|
55
57
|
loadConfig: () => loadConfig,
|
|
@@ -98,6 +100,7 @@ var CaatingaErrorCode = {
|
|
|
98
100
|
DEPLOY_ARG_PLACEHOLDER_UNRESOLVED: "CAATINGA_DEPLOY_ARG_PLACEHOLDER_UNRESOLVED",
|
|
99
101
|
BINDING_CLIENT_NOT_FOUND: "CAATINGA_BINDING_CLIENT_NOT_FOUND",
|
|
100
102
|
BINDING_METHOD_NOT_FOUND: "CAATINGA_BINDING_METHOD_NOT_FOUND",
|
|
103
|
+
PLACEHOLDER_BINDING: "CAATINGA_PLACEHOLDER_BINDING",
|
|
101
104
|
XDR_BUILD_FAILED: "CAATINGA_XDR_BUILD_FAILED",
|
|
102
105
|
XDR_PREPARE_FAILED: "CAATINGA_XDR_PREPARE_FAILED",
|
|
103
106
|
XDR_SIGN_FAILED: "CAATINGA_XDR_SIGN_FAILED",
|
|
@@ -142,8 +145,40 @@ function toCaatingaError(error) {
|
|
|
142
145
|
return new CaatingaError("An unexpected error occurred.", CaatingaErrorCode.UNEXPECTED_ERROR);
|
|
143
146
|
}
|
|
144
147
|
|
|
148
|
+
// src/errors/format-caatinga-error.ts
|
|
149
|
+
function formatCaatingaError(error) {
|
|
150
|
+
if (error instanceof CaatingaError) {
|
|
151
|
+
const lines = [`[${error.code}] ${error.message}`];
|
|
152
|
+
if (error.hint) {
|
|
153
|
+
lines.push("", error.hint);
|
|
154
|
+
}
|
|
155
|
+
const detail = formatCause(error.cause);
|
|
156
|
+
if (detail) {
|
|
157
|
+
lines.push("", `Details: ${detail}`);
|
|
158
|
+
}
|
|
159
|
+
return lines.join("\n");
|
|
160
|
+
}
|
|
161
|
+
return error instanceof Error ? error.message : String(error);
|
|
162
|
+
}
|
|
163
|
+
function formatCause(cause) {
|
|
164
|
+
if (cause === void 0 || cause === null) {
|
|
165
|
+
return "";
|
|
166
|
+
}
|
|
167
|
+
if (cause instanceof Error) {
|
|
168
|
+
return cause.message;
|
|
169
|
+
}
|
|
170
|
+
if (typeof cause === "string") {
|
|
171
|
+
return cause;
|
|
172
|
+
}
|
|
173
|
+
try {
|
|
174
|
+
return JSON.stringify(cause);
|
|
175
|
+
} catch {
|
|
176
|
+
return String(cause);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
145
180
|
// src/version.ts
|
|
146
|
-
var CAATINGA_CORE_VERSION = "2.0
|
|
181
|
+
var CAATINGA_CORE_VERSION = "2.1.0";
|
|
147
182
|
|
|
148
183
|
// src/config/config.schema.ts
|
|
149
184
|
var import_zod = require("zod");
|
|
@@ -1260,6 +1295,38 @@ async function generateBindings(options) {
|
|
|
1260
1295
|
};
|
|
1261
1296
|
}
|
|
1262
1297
|
|
|
1298
|
+
// src/contracts/generate-bindings-graph.ts
|
|
1299
|
+
async function generateBindingsGraph(options) {
|
|
1300
|
+
const cwd = options.cwd ?? process.cwd();
|
|
1301
|
+
const network = resolveNetwork(options.config, options.networkName);
|
|
1302
|
+
let targets;
|
|
1303
|
+
if (options.contractName) {
|
|
1304
|
+
targets = [options.contractName];
|
|
1305
|
+
} else {
|
|
1306
|
+
const artifacts = await readArtifacts(cwd);
|
|
1307
|
+
targets = Object.keys(artifacts.networks[network.name]?.contracts ?? {});
|
|
1308
|
+
if (targets.length === 0) {
|
|
1309
|
+
throw new CaatingaError(
|
|
1310
|
+
`No deployed contracts found on "${network.name}".`,
|
|
1311
|
+
CaatingaErrorCode.ARTIFACT_NOT_FOUND,
|
|
1312
|
+
"Run caatinga deploy before generating bindings, or pass a contract name."
|
|
1313
|
+
);
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
const results = [];
|
|
1317
|
+
for (const contractName of targets) {
|
|
1318
|
+
results.push(
|
|
1319
|
+
await generateBindings({
|
|
1320
|
+
config: options.config,
|
|
1321
|
+
contractName,
|
|
1322
|
+
networkName: network.name,
|
|
1323
|
+
cwd
|
|
1324
|
+
})
|
|
1325
|
+
);
|
|
1326
|
+
}
|
|
1327
|
+
return { network, results };
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1263
1330
|
// src/contracts/invoke-contract.ts
|
|
1264
1331
|
var INVOKE_SIGNING_FAILURE_REGEX = /xdr processing error: xdr value invalid/i;
|
|
1265
1332
|
function parseInvokeTarget(target) {
|
|
@@ -1556,7 +1623,9 @@ function isTransientTestnetSmokeFailure(logText) {
|
|
|
1556
1623
|
deployContract,
|
|
1557
1624
|
deployContractGraph,
|
|
1558
1625
|
evaluateStellarCliCompatibility,
|
|
1626
|
+
formatCaatingaError,
|
|
1559
1627
|
generateBindings,
|
|
1628
|
+
generateBindingsGraph,
|
|
1560
1629
|
invokeContract,
|
|
1561
1630
|
isTransientTestnetSmokeFailure,
|
|
1562
1631
|
loadConfig,
|
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { C as CaatingaArtifacts, a as ContractArtifact, b as CaatingaErrorCodeValue, c as CaatingaError } from './browser-
|
|
2
|
-
export { d as CaatingaArtifactsSchema, e as CaatingaErrorCode, t as toCaatingaError } from './browser-
|
|
1
|
+
import { C as CaatingaArtifacts, a as ContractArtifact, b as CaatingaErrorCodeValue, c as CaatingaError } from './browser-Cq4ZofIq.cjs';
|
|
2
|
+
export { d as CaatingaArtifactsSchema, e as CaatingaErrorCode, f as formatCaatingaError, t as toCaatingaError } from './browser-Cq4ZofIq.cjs';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
-
declare const CAATINGA_CORE_VERSION = "2.0
|
|
5
|
+
declare const CAATINGA_CORE_VERSION = "2.1.0";
|
|
6
6
|
|
|
7
7
|
declare const ContractConfigSchema: z.ZodObject<{
|
|
8
8
|
path: z.ZodString;
|
|
@@ -330,6 +330,17 @@ declare function generateBindings(options: GenerateBindingsOptions): Promise<{
|
|
|
330
330
|
output: string;
|
|
331
331
|
}>;
|
|
332
332
|
|
|
333
|
+
type GenerateBindingsGraphResult = {
|
|
334
|
+
network: ResolvedNetwork;
|
|
335
|
+
results: Array<Awaited<ReturnType<typeof generateBindings>>>;
|
|
336
|
+
};
|
|
337
|
+
declare function generateBindingsGraph(options: {
|
|
338
|
+
config: CaatingaConfig;
|
|
339
|
+
contractName?: string;
|
|
340
|
+
networkName?: string;
|
|
341
|
+
cwd?: string;
|
|
342
|
+
}): Promise<GenerateBindingsGraphResult>;
|
|
343
|
+
|
|
333
344
|
type InvokeTarget = {
|
|
334
345
|
contractName: string;
|
|
335
346
|
method: string;
|
|
@@ -468,4 +479,4 @@ type TemplateManifest = z.infer<typeof TemplateManifestSchema>;
|
|
|
468
479
|
|
|
469
480
|
declare function isTransientTestnetSmokeFailure(logText: string): boolean;
|
|
470
481
|
|
|
471
|
-
export { type BuildContractOptions, CAATINGA_CORE_VERSION, CaatingaArtifacts, type CaatingaConfig, CaatingaConfigSchema, CaatingaError, type CheckStellarCliVersionOptions, type CompatibilityReport, type CompatibilityStatus, type CompatibilityWarning, type CompatibilityWarningCode, ContractArtifact, type ContractConfig, type CreateInitialArtifactsOptions, type CreateProjectFromTemplateOptions, type DeployArgValue, type DeployContractGraphResult, type DeployContractOptions, type EvaluateStellarCliCompatibilityInput, type GenerateBindingsOptions, type InvokeContractOptions, type InvokeTarget, type LoadConfigOptions, type NetworkConfig, type ResolvedContract, type ResolvedNetwork, type RunCommandResult, STELLAR_CLI_LAST_TESTED_VERSION, STELLAR_CLI_MIN_VERSION, type SkippedContract, type TemplateManifest, TemplateManifestSchema, WELL_KNOWN_NETWORKS, buildContract, buildDependencyGraph, checkBinary, checkStellarCliVersion, createInitialArtifacts, createProjectFromTemplate, defineConfig, deployContract, deployContractGraph, evaluateStellarCliCompatibility, generateBindings, invokeContract, isTransientTestnetSmokeFailure, loadConfig, parseContractId, parseInvokeTarget, parseStellarCliVersion, readArtifacts, resolveContract, resolveDeployArgs, resolveDeployOrder, resolveNetwork, runCommand, updateArtifact, validateSourceShape, writeArtifacts };
|
|
482
|
+
export { type BuildContractOptions, CAATINGA_CORE_VERSION, CaatingaArtifacts, type CaatingaConfig, CaatingaConfigSchema, CaatingaError, type CheckStellarCliVersionOptions, type CompatibilityReport, type CompatibilityStatus, type CompatibilityWarning, type CompatibilityWarningCode, ContractArtifact, type ContractConfig, type CreateInitialArtifactsOptions, type CreateProjectFromTemplateOptions, type DeployArgValue, type DeployContractGraphResult, type DeployContractOptions, type EvaluateStellarCliCompatibilityInput, type GenerateBindingsGraphResult, type GenerateBindingsOptions, type InvokeContractOptions, type InvokeTarget, type LoadConfigOptions, type NetworkConfig, type ResolvedContract, type ResolvedNetwork, type RunCommandResult, STELLAR_CLI_LAST_TESTED_VERSION, STELLAR_CLI_MIN_VERSION, type SkippedContract, type TemplateManifest, TemplateManifestSchema, WELL_KNOWN_NETWORKS, buildContract, buildDependencyGraph, checkBinary, checkStellarCliVersion, createInitialArtifacts, createProjectFromTemplate, defineConfig, deployContract, deployContractGraph, evaluateStellarCliCompatibility, generateBindings, generateBindingsGraph, invokeContract, isTransientTestnetSmokeFailure, loadConfig, parseContractId, parseInvokeTarget, parseStellarCliVersion, readArtifacts, resolveContract, resolveDeployArgs, resolveDeployOrder, resolveNetwork, runCommand, updateArtifact, validateSourceShape, writeArtifacts };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { C as CaatingaArtifacts, a as ContractArtifact, b as CaatingaErrorCodeValue, c as CaatingaError } from './browser-
|
|
2
|
-
export { d as CaatingaArtifactsSchema, e as CaatingaErrorCode, t as toCaatingaError } from './browser-
|
|
1
|
+
import { C as CaatingaArtifacts, a as ContractArtifact, b as CaatingaErrorCodeValue, c as CaatingaError } from './browser-Cq4ZofIq.js';
|
|
2
|
+
export { d as CaatingaArtifactsSchema, e as CaatingaErrorCode, f as formatCaatingaError, t as toCaatingaError } from './browser-Cq4ZofIq.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
|
|
5
|
-
declare const CAATINGA_CORE_VERSION = "2.0
|
|
5
|
+
declare const CAATINGA_CORE_VERSION = "2.1.0";
|
|
6
6
|
|
|
7
7
|
declare const ContractConfigSchema: z.ZodObject<{
|
|
8
8
|
path: z.ZodString;
|
|
@@ -330,6 +330,17 @@ declare function generateBindings(options: GenerateBindingsOptions): Promise<{
|
|
|
330
330
|
output: string;
|
|
331
331
|
}>;
|
|
332
332
|
|
|
333
|
+
type GenerateBindingsGraphResult = {
|
|
334
|
+
network: ResolvedNetwork;
|
|
335
|
+
results: Array<Awaited<ReturnType<typeof generateBindings>>>;
|
|
336
|
+
};
|
|
337
|
+
declare function generateBindingsGraph(options: {
|
|
338
|
+
config: CaatingaConfig;
|
|
339
|
+
contractName?: string;
|
|
340
|
+
networkName?: string;
|
|
341
|
+
cwd?: string;
|
|
342
|
+
}): Promise<GenerateBindingsGraphResult>;
|
|
343
|
+
|
|
333
344
|
type InvokeTarget = {
|
|
334
345
|
contractName: string;
|
|
335
346
|
method: string;
|
|
@@ -468,4 +479,4 @@ type TemplateManifest = z.infer<typeof TemplateManifestSchema>;
|
|
|
468
479
|
|
|
469
480
|
declare function isTransientTestnetSmokeFailure(logText: string): boolean;
|
|
470
481
|
|
|
471
|
-
export { type BuildContractOptions, CAATINGA_CORE_VERSION, CaatingaArtifacts, type CaatingaConfig, CaatingaConfigSchema, CaatingaError, type CheckStellarCliVersionOptions, type CompatibilityReport, type CompatibilityStatus, type CompatibilityWarning, type CompatibilityWarningCode, ContractArtifact, type ContractConfig, type CreateInitialArtifactsOptions, type CreateProjectFromTemplateOptions, type DeployArgValue, type DeployContractGraphResult, type DeployContractOptions, type EvaluateStellarCliCompatibilityInput, type GenerateBindingsOptions, type InvokeContractOptions, type InvokeTarget, type LoadConfigOptions, type NetworkConfig, type ResolvedContract, type ResolvedNetwork, type RunCommandResult, STELLAR_CLI_LAST_TESTED_VERSION, STELLAR_CLI_MIN_VERSION, type SkippedContract, type TemplateManifest, TemplateManifestSchema, WELL_KNOWN_NETWORKS, buildContract, buildDependencyGraph, checkBinary, checkStellarCliVersion, createInitialArtifacts, createProjectFromTemplate, defineConfig, deployContract, deployContractGraph, evaluateStellarCliCompatibility, generateBindings, invokeContract, isTransientTestnetSmokeFailure, loadConfig, parseContractId, parseInvokeTarget, parseStellarCliVersion, readArtifacts, resolveContract, resolveDeployArgs, resolveDeployOrder, resolveNetwork, runCommand, updateArtifact, validateSourceShape, writeArtifacts };
|
|
482
|
+
export { type BuildContractOptions, CAATINGA_CORE_VERSION, CaatingaArtifacts, type CaatingaConfig, CaatingaConfigSchema, CaatingaError, type CheckStellarCliVersionOptions, type CompatibilityReport, type CompatibilityStatus, type CompatibilityWarning, type CompatibilityWarningCode, ContractArtifact, type ContractConfig, type CreateInitialArtifactsOptions, type CreateProjectFromTemplateOptions, type DeployArgValue, type DeployContractGraphResult, type DeployContractOptions, type EvaluateStellarCliCompatibilityInput, type GenerateBindingsGraphResult, type GenerateBindingsOptions, type InvokeContractOptions, type InvokeTarget, type LoadConfigOptions, type NetworkConfig, type ResolvedContract, type ResolvedNetwork, type RunCommandResult, STELLAR_CLI_LAST_TESTED_VERSION, STELLAR_CLI_MIN_VERSION, type SkippedContract, type TemplateManifest, TemplateManifestSchema, WELL_KNOWN_NETWORKS, buildContract, buildDependencyGraph, checkBinary, checkStellarCliVersion, createInitialArtifacts, createProjectFromTemplate, defineConfig, deployContract, deployContractGraph, evaluateStellarCliCompatibility, generateBindings, generateBindingsGraph, invokeContract, isTransientTestnetSmokeFailure, loadConfig, parseContractId, parseInvokeTarget, parseStellarCliVersion, readArtifacts, resolveContract, resolveDeployArgs, resolveDeployOrder, resolveNetwork, runCommand, updateArtifact, validateSourceShape, writeArtifacts };
|
package/dist/index.js
CHANGED
|
@@ -27,6 +27,7 @@ var CaatingaErrorCode = {
|
|
|
27
27
|
DEPLOY_ARG_PLACEHOLDER_UNRESOLVED: "CAATINGA_DEPLOY_ARG_PLACEHOLDER_UNRESOLVED",
|
|
28
28
|
BINDING_CLIENT_NOT_FOUND: "CAATINGA_BINDING_CLIENT_NOT_FOUND",
|
|
29
29
|
BINDING_METHOD_NOT_FOUND: "CAATINGA_BINDING_METHOD_NOT_FOUND",
|
|
30
|
+
PLACEHOLDER_BINDING: "CAATINGA_PLACEHOLDER_BINDING",
|
|
30
31
|
XDR_BUILD_FAILED: "CAATINGA_XDR_BUILD_FAILED",
|
|
31
32
|
XDR_PREPARE_FAILED: "CAATINGA_XDR_PREPARE_FAILED",
|
|
32
33
|
XDR_SIGN_FAILED: "CAATINGA_XDR_SIGN_FAILED",
|
|
@@ -71,8 +72,40 @@ function toCaatingaError(error) {
|
|
|
71
72
|
return new CaatingaError("An unexpected error occurred.", CaatingaErrorCode.UNEXPECTED_ERROR);
|
|
72
73
|
}
|
|
73
74
|
|
|
75
|
+
// src/errors/format-caatinga-error.ts
|
|
76
|
+
function formatCaatingaError(error) {
|
|
77
|
+
if (error instanceof CaatingaError) {
|
|
78
|
+
const lines = [`[${error.code}] ${error.message}`];
|
|
79
|
+
if (error.hint) {
|
|
80
|
+
lines.push("", error.hint);
|
|
81
|
+
}
|
|
82
|
+
const detail = formatCause(error.cause);
|
|
83
|
+
if (detail) {
|
|
84
|
+
lines.push("", `Details: ${detail}`);
|
|
85
|
+
}
|
|
86
|
+
return lines.join("\n");
|
|
87
|
+
}
|
|
88
|
+
return error instanceof Error ? error.message : String(error);
|
|
89
|
+
}
|
|
90
|
+
function formatCause(cause) {
|
|
91
|
+
if (cause === void 0 || cause === null) {
|
|
92
|
+
return "";
|
|
93
|
+
}
|
|
94
|
+
if (cause instanceof Error) {
|
|
95
|
+
return cause.message;
|
|
96
|
+
}
|
|
97
|
+
if (typeof cause === "string") {
|
|
98
|
+
return cause;
|
|
99
|
+
}
|
|
100
|
+
try {
|
|
101
|
+
return JSON.stringify(cause);
|
|
102
|
+
} catch {
|
|
103
|
+
return String(cause);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
74
107
|
// src/version.ts
|
|
75
|
-
var CAATINGA_CORE_VERSION = "2.0
|
|
108
|
+
var CAATINGA_CORE_VERSION = "2.1.0";
|
|
76
109
|
|
|
77
110
|
// src/config/config.schema.ts
|
|
78
111
|
import { z } from "zod";
|
|
@@ -1188,6 +1221,38 @@ async function generateBindings(options) {
|
|
|
1188
1221
|
};
|
|
1189
1222
|
}
|
|
1190
1223
|
|
|
1224
|
+
// src/contracts/generate-bindings-graph.ts
|
|
1225
|
+
async function generateBindingsGraph(options) {
|
|
1226
|
+
const cwd = options.cwd ?? process.cwd();
|
|
1227
|
+
const network = resolveNetwork(options.config, options.networkName);
|
|
1228
|
+
let targets;
|
|
1229
|
+
if (options.contractName) {
|
|
1230
|
+
targets = [options.contractName];
|
|
1231
|
+
} else {
|
|
1232
|
+
const artifacts = await readArtifacts(cwd);
|
|
1233
|
+
targets = Object.keys(artifacts.networks[network.name]?.contracts ?? {});
|
|
1234
|
+
if (targets.length === 0) {
|
|
1235
|
+
throw new CaatingaError(
|
|
1236
|
+
`No deployed contracts found on "${network.name}".`,
|
|
1237
|
+
CaatingaErrorCode.ARTIFACT_NOT_FOUND,
|
|
1238
|
+
"Run caatinga deploy before generating bindings, or pass a contract name."
|
|
1239
|
+
);
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
const results = [];
|
|
1243
|
+
for (const contractName of targets) {
|
|
1244
|
+
results.push(
|
|
1245
|
+
await generateBindings({
|
|
1246
|
+
config: options.config,
|
|
1247
|
+
contractName,
|
|
1248
|
+
networkName: network.name,
|
|
1249
|
+
cwd
|
|
1250
|
+
})
|
|
1251
|
+
);
|
|
1252
|
+
}
|
|
1253
|
+
return { network, results };
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1191
1256
|
// src/contracts/invoke-contract.ts
|
|
1192
1257
|
var INVOKE_SIGNING_FAILURE_REGEX = /xdr processing error: xdr value invalid/i;
|
|
1193
1258
|
function parseInvokeTarget(target) {
|
|
@@ -1483,7 +1548,9 @@ export {
|
|
|
1483
1548
|
deployContract,
|
|
1484
1549
|
deployContractGraph,
|
|
1485
1550
|
evaluateStellarCliCompatibility,
|
|
1551
|
+
formatCaatingaError,
|
|
1486
1552
|
generateBindings,
|
|
1553
|
+
generateBindingsGraph,
|
|
1487
1554
|
invokeContract,
|
|
1488
1555
|
isTransientTestnetSmokeFailure,
|
|
1489
1556
|
loadConfig,
|