@caatinga/core 2.0.1 → 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 +91 -1
- package/dist/index.d.cts +17 -4
- package/dist/index.d.ts +17 -4
- package/dist/index.js +90 -2
- 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");
|
|
@@ -1202,6 +1237,20 @@ async function deployContractGraph(options) {
|
|
|
1202
1237
|
// src/contracts/generate-bindings.ts
|
|
1203
1238
|
var import_promises5 = require("fs/promises");
|
|
1204
1239
|
var import_node_path7 = __toESM(require("path"), 1);
|
|
1240
|
+
function toBindingImportPath(bindingsOutput, contractName) {
|
|
1241
|
+
const normalized = bindingsOutput.replace(/^\.\//, "").split(import_node_path7.default.sep).join("/");
|
|
1242
|
+
return `./${import_node_path7.default.posix.join(normalized, contractName, "src", "index.js")}`;
|
|
1243
|
+
}
|
|
1244
|
+
async function removeLegacyBindingStub(cwd, bindingsOutput, contractName) {
|
|
1245
|
+
const legacyPath = import_node_path7.default.resolve(cwd, bindingsOutput, `${contractName}.ts`);
|
|
1246
|
+
try {
|
|
1247
|
+
await (0, import_promises5.access)(legacyPath);
|
|
1248
|
+
await (0, import_promises5.unlink)(legacyPath);
|
|
1249
|
+
return true;
|
|
1250
|
+
} catch {
|
|
1251
|
+
return false;
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1205
1254
|
async function generateBindings(options) {
|
|
1206
1255
|
const cwd = options.cwd ?? process.cwd();
|
|
1207
1256
|
const network = resolveNetwork(options.config, options.networkName);
|
|
@@ -1231,14 +1280,53 @@ async function generateBindings(options) {
|
|
|
1231
1280
|
cwd,
|
|
1232
1281
|
failureCode: CaatingaErrorCode.BINDINGS_FAILED
|
|
1233
1282
|
});
|
|
1283
|
+
const legacyStubRemoved = await removeLegacyBindingStub(
|
|
1284
|
+
cwd,
|
|
1285
|
+
options.config.frontend.bindingsOutput,
|
|
1286
|
+
options.contractName
|
|
1287
|
+
);
|
|
1234
1288
|
return {
|
|
1235
1289
|
contractName: options.contractName,
|
|
1236
1290
|
network,
|
|
1237
1291
|
outputDir,
|
|
1292
|
+
importPath: toBindingImportPath(options.config.frontend.bindingsOutput, options.contractName),
|
|
1293
|
+
legacyStubRemoved,
|
|
1238
1294
|
output: result.all || result.stdout
|
|
1239
1295
|
};
|
|
1240
1296
|
}
|
|
1241
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
|
+
|
|
1242
1330
|
// src/contracts/invoke-contract.ts
|
|
1243
1331
|
var INVOKE_SIGNING_FAILURE_REGEX = /xdr processing error: xdr value invalid/i;
|
|
1244
1332
|
function parseInvokeTarget(target) {
|
|
@@ -1535,7 +1623,9 @@ function isTransientTestnetSmokeFailure(logText) {
|
|
|
1535
1623
|
deployContract,
|
|
1536
1624
|
deployContractGraph,
|
|
1537
1625
|
evaluateStellarCliCompatibility,
|
|
1626
|
+
formatCaatingaError,
|
|
1538
1627
|
generateBindings,
|
|
1628
|
+
generateBindingsGraph,
|
|
1539
1629
|
invokeContract,
|
|
1540
1630
|
isTransientTestnetSmokeFailure,
|
|
1541
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;
|
|
@@ -325,9 +325,22 @@ declare function generateBindings(options: GenerateBindingsOptions): Promise<{
|
|
|
325
325
|
contractName: string;
|
|
326
326
|
network: ResolvedNetwork;
|
|
327
327
|
outputDir: string;
|
|
328
|
+
importPath: string;
|
|
329
|
+
legacyStubRemoved: boolean;
|
|
328
330
|
output: string;
|
|
329
331
|
}>;
|
|
330
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
|
+
|
|
331
344
|
type InvokeTarget = {
|
|
332
345
|
contractName: string;
|
|
333
346
|
method: string;
|
|
@@ -466,4 +479,4 @@ type TemplateManifest = z.infer<typeof TemplateManifestSchema>;
|
|
|
466
479
|
|
|
467
480
|
declare function isTransientTestnetSmokeFailure(logText: string): boolean;
|
|
468
481
|
|
|
469
|
-
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;
|
|
@@ -325,9 +325,22 @@ declare function generateBindings(options: GenerateBindingsOptions): Promise<{
|
|
|
325
325
|
contractName: string;
|
|
326
326
|
network: ResolvedNetwork;
|
|
327
327
|
outputDir: string;
|
|
328
|
+
importPath: string;
|
|
329
|
+
legacyStubRemoved: boolean;
|
|
328
330
|
output: string;
|
|
329
331
|
}>;
|
|
330
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
|
+
|
|
331
344
|
type InvokeTarget = {
|
|
332
345
|
contractName: string;
|
|
333
346
|
method: string;
|
|
@@ -466,4 +479,4 @@ type TemplateManifest = z.infer<typeof TemplateManifestSchema>;
|
|
|
466
479
|
|
|
467
480
|
declare function isTransientTestnetSmokeFailure(logText: string): boolean;
|
|
468
481
|
|
|
469
|
-
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";
|
|
@@ -1128,8 +1161,22 @@ async function deployContractGraph(options) {
|
|
|
1128
1161
|
}
|
|
1129
1162
|
|
|
1130
1163
|
// src/contracts/generate-bindings.ts
|
|
1131
|
-
import { mkdir as mkdir2 } from "fs/promises";
|
|
1164
|
+
import { access as access3, mkdir as mkdir2, unlink } from "fs/promises";
|
|
1132
1165
|
import path7 from "path";
|
|
1166
|
+
function toBindingImportPath(bindingsOutput, contractName) {
|
|
1167
|
+
const normalized = bindingsOutput.replace(/^\.\//, "").split(path7.sep).join("/");
|
|
1168
|
+
return `./${path7.posix.join(normalized, contractName, "src", "index.js")}`;
|
|
1169
|
+
}
|
|
1170
|
+
async function removeLegacyBindingStub(cwd, bindingsOutput, contractName) {
|
|
1171
|
+
const legacyPath = path7.resolve(cwd, bindingsOutput, `${contractName}.ts`);
|
|
1172
|
+
try {
|
|
1173
|
+
await access3(legacyPath);
|
|
1174
|
+
await unlink(legacyPath);
|
|
1175
|
+
return true;
|
|
1176
|
+
} catch {
|
|
1177
|
+
return false;
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1133
1180
|
async function generateBindings(options) {
|
|
1134
1181
|
const cwd = options.cwd ?? process.cwd();
|
|
1135
1182
|
const network = resolveNetwork(options.config, options.networkName);
|
|
@@ -1159,14 +1206,53 @@ async function generateBindings(options) {
|
|
|
1159
1206
|
cwd,
|
|
1160
1207
|
failureCode: CaatingaErrorCode.BINDINGS_FAILED
|
|
1161
1208
|
});
|
|
1209
|
+
const legacyStubRemoved = await removeLegacyBindingStub(
|
|
1210
|
+
cwd,
|
|
1211
|
+
options.config.frontend.bindingsOutput,
|
|
1212
|
+
options.contractName
|
|
1213
|
+
);
|
|
1162
1214
|
return {
|
|
1163
1215
|
contractName: options.contractName,
|
|
1164
1216
|
network,
|
|
1165
1217
|
outputDir,
|
|
1218
|
+
importPath: toBindingImportPath(options.config.frontend.bindingsOutput, options.contractName),
|
|
1219
|
+
legacyStubRemoved,
|
|
1166
1220
|
output: result.all || result.stdout
|
|
1167
1221
|
};
|
|
1168
1222
|
}
|
|
1169
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
|
+
|
|
1170
1256
|
// src/contracts/invoke-contract.ts
|
|
1171
1257
|
var INVOKE_SIGNING_FAILURE_REGEX = /xdr processing error: xdr value invalid/i;
|
|
1172
1258
|
function parseInvokeTarget(target) {
|
|
@@ -1462,7 +1548,9 @@ export {
|
|
|
1462
1548
|
deployContract,
|
|
1463
1549
|
deployContractGraph,
|
|
1464
1550
|
evaluateStellarCliCompatibility,
|
|
1551
|
+
formatCaatingaError,
|
|
1465
1552
|
generateBindings,
|
|
1553
|
+
generateBindingsGraph,
|
|
1466
1554
|
invokeContract,
|
|
1467
1555
|
isTransientTestnetSmokeFailure,
|
|
1468
1556
|
loadConfig,
|