@caatinga/core 2.0.2 → 2.2.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 +328 -78
- package/dist/index.d.cts +95 -4
- package/dist/index.d.ts +95 -4
- package/dist/index.js +305 -64
- 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
|
};
|