@polkadot-apps/tx 0.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/dev-signers.d.ts +34 -0
- package/dist/dev-signers.d.ts.map +1 -0
- package/dist/dev-signers.js +85 -0
- package/dist/dev-signers.js.map +1 -0
- package/dist/dry-run.d.ts +73 -0
- package/dist/dry-run.d.ts.map +1 -0
- package/dist/dry-run.js +242 -0
- package/dist/dry-run.js.map +1 -0
- package/dist/errors.d.ts +109 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +408 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/retry.d.ts +30 -0
- package/dist/retry.d.ts.map +1 -0
- package/dist/retry.js +157 -0
- package/dist/retry.js.map +1 -0
- package/dist/submit.d.ts +19 -0
- package/dist/submit.d.ts.map +1 -0
- package/dist/submit.js +413 -0
- package/dist/submit.js.map +1 -0
- package/dist/types.d.ts +110 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +32 -0
package/dist/errors.js
ADDED
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
/** Base class for all transaction errors. Use `instanceof TxError` to catch any tx-related error. */
|
|
2
|
+
export class TxError extends Error {
|
|
3
|
+
constructor(message, options) {
|
|
4
|
+
super(message, options);
|
|
5
|
+
this.name = "TxError";
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
/** The transaction did not finalize within the configured timeout. It may still be processing on-chain. */
|
|
9
|
+
export class TxTimeoutError extends TxError {
|
|
10
|
+
timeoutMs;
|
|
11
|
+
constructor(timeoutMs) {
|
|
12
|
+
super(`Transaction timed out after ${timeoutMs / 1000}s. ` +
|
|
13
|
+
"The transaction may still be processing on-chain.");
|
|
14
|
+
this.name = "TxTimeoutError";
|
|
15
|
+
this.timeoutMs = timeoutMs;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/** The transaction was included on-chain but the dispatch failed. */
|
|
19
|
+
export class TxDispatchError extends TxError {
|
|
20
|
+
/** Raw dispatch error from polkadot-api. */
|
|
21
|
+
dispatchError;
|
|
22
|
+
/** Human-readable error string (e.g., "Revive.ContractReverted"). */
|
|
23
|
+
formatted;
|
|
24
|
+
constructor(dispatchError, formatted) {
|
|
25
|
+
super(`Transaction dispatch failed: ${formatted}`);
|
|
26
|
+
this.name = "TxDispatchError";
|
|
27
|
+
this.dispatchError = dispatchError;
|
|
28
|
+
this.formatted = formatted;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/** The user rejected the signing request in their wallet. */
|
|
32
|
+
export class TxSigningRejectedError extends TxError {
|
|
33
|
+
constructor() {
|
|
34
|
+
super("Transaction signing was rejected.");
|
|
35
|
+
this.name = "TxSigningRejectedError";
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Extract a human-readable error from a transaction result's dispatch error.
|
|
40
|
+
*
|
|
41
|
+
* PAPI dispatch errors for pallet modules are nested:
|
|
42
|
+
* `{ type: "Module", value: { type: "Revive", value: { type: "ContractReverted" } } }`
|
|
43
|
+
*
|
|
44
|
+
* This walks the chain to build a string like `"Revive.ContractReverted"`.
|
|
45
|
+
*
|
|
46
|
+
* @param result - A transaction result with `ok` and optional `dispatchError`.
|
|
47
|
+
* @returns A human-readable error string, or `""` if the result is ok, or `"unknown error"` if
|
|
48
|
+
* the dispatch error cannot be decoded.
|
|
49
|
+
*/
|
|
50
|
+
export function formatDispatchError(result) {
|
|
51
|
+
if (result.ok)
|
|
52
|
+
return "";
|
|
53
|
+
try {
|
|
54
|
+
const err = result.dispatchError;
|
|
55
|
+
if (!err)
|
|
56
|
+
return "unknown error";
|
|
57
|
+
if (err.type === "Module" && err.value && typeof err.value === "object") {
|
|
58
|
+
const palletErr = err.value;
|
|
59
|
+
const palletName = palletErr.type ?? "Unknown";
|
|
60
|
+
if (palletErr.value && typeof palletErr.value === "object") {
|
|
61
|
+
const innerErr = palletErr.value;
|
|
62
|
+
if (innerErr.type) {
|
|
63
|
+
return `${palletName}.${innerErr.type}`;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return palletName;
|
|
67
|
+
}
|
|
68
|
+
return err.type ?? "unknown error";
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return "unknown error";
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* A dry-run simulation failed before the transaction was submitted on-chain.
|
|
76
|
+
*
|
|
77
|
+
* Thrown by {@link extractTransaction} when the dry-run result indicates failure.
|
|
78
|
+
* Carries structured error information so callers can distinguish revert reasons
|
|
79
|
+
* from dispatch errors programmatically.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* try {
|
|
84
|
+
* const tx = extractTransaction(await contract.query("mint", { origin, data }));
|
|
85
|
+
* } catch (e) {
|
|
86
|
+
* if (e instanceof TxDryRunError) {
|
|
87
|
+
* console.log(e.revertReason); // "InsufficientBalance" (if contract provided one)
|
|
88
|
+
* console.log(e.formatted); // "Revive.StorageDepositNotEnoughFunds"
|
|
89
|
+
* }
|
|
90
|
+
* }
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export class TxDryRunError extends TxError {
|
|
94
|
+
/** The raw dry-run result for programmatic inspection. */
|
|
95
|
+
raw;
|
|
96
|
+
/** Human-readable error string derived from the dry-run result. */
|
|
97
|
+
formatted;
|
|
98
|
+
/** Solidity revert reason, if the contract provided one. */
|
|
99
|
+
revertReason;
|
|
100
|
+
constructor(raw, formatted, revertReason) {
|
|
101
|
+
super(revertReason ? `Dry run failed: ${revertReason}` : `Dry run failed: ${formatted}`);
|
|
102
|
+
this.name = "TxDryRunError";
|
|
103
|
+
this.raw = raw;
|
|
104
|
+
this.formatted = formatted;
|
|
105
|
+
this.revertReason = revertReason;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Extract a human-readable error from a failed dry-run result.
|
|
110
|
+
*
|
|
111
|
+
* Handles every error shape found across the Polkadot contract ecosystem:
|
|
112
|
+
*
|
|
113
|
+
* 1. **Revert reason** (Ink SDK patched results / EVM contracts):
|
|
114
|
+
* `{ value: { revertReason: "InsufficientBalance" } }`
|
|
115
|
+
*
|
|
116
|
+
* 2. **Nested dispatch errors** (raw Ink SDK / pallet errors):
|
|
117
|
+
* `{ value: { type: "Module", value: { type: "Revive", value: { type: "StorageDepositNotEnoughFunds" } } } }`
|
|
118
|
+
* Delegates to {@link formatDispatchError} for the Module.Pallet.Error chain.
|
|
119
|
+
*
|
|
120
|
+
* 3. **ReviveApi runtime messages** (`eth_transact` / `ReviveApi.call`):
|
|
121
|
+
* `{ value: { type: "Message", value: "Insufficient balance for gas * price + value" } }`
|
|
122
|
+
*
|
|
123
|
+
* 4. **ReviveApi contract revert data**:
|
|
124
|
+
* `{ value: { type: "Data", value: "0x08c379a0..." } }`
|
|
125
|
+
*
|
|
126
|
+
* 5. **Wrapped raw errors** (patched SDK wrappers):
|
|
127
|
+
* `{ value: { raw: { type: "Message", value: "..." } } }`
|
|
128
|
+
*
|
|
129
|
+
* 6. **Generic error field**:
|
|
130
|
+
* `{ error: { type: "ContractTrapped" } }` or `{ error: { name: "..." } }`
|
|
131
|
+
*
|
|
132
|
+
* @param result - A dry-run result with at least `success`, and optionally `value` / `error`.
|
|
133
|
+
* @returns A human-readable error string, or `""` if the result succeeded.
|
|
134
|
+
*/
|
|
135
|
+
export function formatDryRunError(result) {
|
|
136
|
+
if (result.success)
|
|
137
|
+
return "";
|
|
138
|
+
const formatted = extractErrorFromValue(result.value);
|
|
139
|
+
if (formatted)
|
|
140
|
+
return formatted;
|
|
141
|
+
// Generic error field (Ink SDK)
|
|
142
|
+
if (result.error != null && typeof result.error === "object") {
|
|
143
|
+
const err = result.error;
|
|
144
|
+
if (typeof err.type === "string")
|
|
145
|
+
return err.type;
|
|
146
|
+
if (typeof err.name === "string")
|
|
147
|
+
return err.name;
|
|
148
|
+
}
|
|
149
|
+
return "unknown error";
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Try to extract an error string from the `value` field of a dry-run result.
|
|
153
|
+
* Returns `undefined` if no known error shape is found.
|
|
154
|
+
*/
|
|
155
|
+
function extractErrorFromValue(value) {
|
|
156
|
+
if (value == null || typeof value !== "object")
|
|
157
|
+
return undefined;
|
|
158
|
+
const v = value;
|
|
159
|
+
// Explicit revert reason — most specific, from Ink SDK / EVM wrappers
|
|
160
|
+
if (typeof v.revertReason === "string" && v.revertReason) {
|
|
161
|
+
return v.revertReason;
|
|
162
|
+
}
|
|
163
|
+
if (typeof v.type === "string") {
|
|
164
|
+
// Nested Module.Pallet.Error — reuse dispatch error formatting
|
|
165
|
+
if (v.type === "Module") {
|
|
166
|
+
const asDispatch = formatDispatchError({ ok: false, dispatchError: value });
|
|
167
|
+
if (asDispatch !== "unknown error")
|
|
168
|
+
return asDispatch;
|
|
169
|
+
}
|
|
170
|
+
// ReviveApi Message — runtime error string
|
|
171
|
+
if (v.type === "Message" && typeof v.value === "string") {
|
|
172
|
+
return v.value;
|
|
173
|
+
}
|
|
174
|
+
// ReviveApi Data — contract revert hex data
|
|
175
|
+
if (v.type === "Data") {
|
|
176
|
+
const hex = v.value != null &&
|
|
177
|
+
typeof v.value === "object" &&
|
|
178
|
+
typeof v.value.asHex === "function"
|
|
179
|
+
? String(v.value.asHex())
|
|
180
|
+
: typeof v.value === "string"
|
|
181
|
+
? v.value
|
|
182
|
+
: undefined;
|
|
183
|
+
return hex ? `contract reverted with data: ${hex}` : "contract reverted";
|
|
184
|
+
}
|
|
185
|
+
// Any other typed error (e.g., "BadOrigin", "ContractTrapped")
|
|
186
|
+
return v.type;
|
|
187
|
+
}
|
|
188
|
+
// Wrapped raw value — patched SDK nests the original error under `raw`
|
|
189
|
+
if ("raw" in v && v.raw != null && typeof v.raw === "object") {
|
|
190
|
+
return extractErrorFromValue(v.raw);
|
|
191
|
+
}
|
|
192
|
+
return undefined;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Check if an error looks like a user-rejected signing request.
|
|
196
|
+
*
|
|
197
|
+
* Different wallets use different error messages when the user rejects signing:
|
|
198
|
+
* "Cancelled", "Rejected", "User rejected", "denied". This checks for common
|
|
199
|
+
* patterns as a best-effort heuristic. Non-Error values always return false.
|
|
200
|
+
*
|
|
201
|
+
* @param error - The error to check.
|
|
202
|
+
* @returns `true` if the error message matches a known rejection pattern.
|
|
203
|
+
*/
|
|
204
|
+
export function isSigningRejection(error) {
|
|
205
|
+
if (!(error instanceof Error))
|
|
206
|
+
return false;
|
|
207
|
+
const msg = error.message.toLowerCase();
|
|
208
|
+
return (msg.includes("cancelled") ||
|
|
209
|
+
msg.includes("rejected") ||
|
|
210
|
+
msg.includes("denied") ||
|
|
211
|
+
msg.includes("user refused"));
|
|
212
|
+
}
|
|
213
|
+
if (import.meta.vitest) {
|
|
214
|
+
const { describe, test, expect } = import.meta.vitest;
|
|
215
|
+
describe("TxError hierarchy", () => {
|
|
216
|
+
test("TxTimeoutError", () => {
|
|
217
|
+
const err = new TxTimeoutError(300_000);
|
|
218
|
+
expect(err).toBeInstanceOf(TxError);
|
|
219
|
+
expect(err).toBeInstanceOf(Error);
|
|
220
|
+
expect(err.name).toBe("TxTimeoutError");
|
|
221
|
+
expect(err.timeoutMs).toBe(300_000);
|
|
222
|
+
expect(err.message).toContain("300s");
|
|
223
|
+
});
|
|
224
|
+
test("TxDispatchError", () => {
|
|
225
|
+
const raw = {
|
|
226
|
+
type: "Module",
|
|
227
|
+
value: { type: "Balances", value: { type: "InsufficientBalance" } },
|
|
228
|
+
};
|
|
229
|
+
const err = new TxDispatchError(raw, "Balances.InsufficientBalance");
|
|
230
|
+
expect(err).toBeInstanceOf(TxError);
|
|
231
|
+
expect(err.name).toBe("TxDispatchError");
|
|
232
|
+
expect(err.dispatchError).toBe(raw);
|
|
233
|
+
expect(err.formatted).toBe("Balances.InsufficientBalance");
|
|
234
|
+
expect(err.message).toContain("Balances.InsufficientBalance");
|
|
235
|
+
});
|
|
236
|
+
test("TxSigningRejectedError", () => {
|
|
237
|
+
const err = new TxSigningRejectedError();
|
|
238
|
+
expect(err).toBeInstanceOf(TxError);
|
|
239
|
+
expect(err.name).toBe("TxSigningRejectedError");
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
describe("formatDispatchError", () => {
|
|
243
|
+
test("returns empty string for ok result", () => {
|
|
244
|
+
expect(formatDispatchError({ ok: true })).toBe("");
|
|
245
|
+
});
|
|
246
|
+
test("walks Module.Pallet.Error chain", () => {
|
|
247
|
+
const result = {
|
|
248
|
+
ok: false,
|
|
249
|
+
dispatchError: {
|
|
250
|
+
type: "Module",
|
|
251
|
+
value: { type: "Revive", value: { type: "ContractReverted" } },
|
|
252
|
+
},
|
|
253
|
+
};
|
|
254
|
+
expect(formatDispatchError(result)).toBe("Revive.ContractReverted");
|
|
255
|
+
});
|
|
256
|
+
test("returns pallet name when inner error has no type", () => {
|
|
257
|
+
const result = {
|
|
258
|
+
ok: false,
|
|
259
|
+
dispatchError: {
|
|
260
|
+
type: "Module",
|
|
261
|
+
value: { type: "Balances", value: {} },
|
|
262
|
+
},
|
|
263
|
+
};
|
|
264
|
+
expect(formatDispatchError(result)).toBe("Balances");
|
|
265
|
+
});
|
|
266
|
+
test("returns error type for non-Module errors", () => {
|
|
267
|
+
const result = {
|
|
268
|
+
ok: false,
|
|
269
|
+
dispatchError: { type: "BadOrigin" },
|
|
270
|
+
};
|
|
271
|
+
expect(formatDispatchError(result)).toBe("BadOrigin");
|
|
272
|
+
});
|
|
273
|
+
test("returns unknown error when dispatchError is missing", () => {
|
|
274
|
+
expect(formatDispatchError({ ok: false })).toBe("unknown error");
|
|
275
|
+
});
|
|
276
|
+
test("returns unknown error when dispatchError has no type", () => {
|
|
277
|
+
expect(formatDispatchError({ ok: false, dispatchError: {} })).toBe("unknown error");
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
describe("TxDryRunError", () => {
|
|
281
|
+
test("with revert reason", () => {
|
|
282
|
+
const err = new TxDryRunError({ success: false }, "Module.Error", "InsufficientBalance");
|
|
283
|
+
expect(err).toBeInstanceOf(TxError);
|
|
284
|
+
expect(err.name).toBe("TxDryRunError");
|
|
285
|
+
expect(err.formatted).toBe("Module.Error");
|
|
286
|
+
expect(err.revertReason).toBe("InsufficientBalance");
|
|
287
|
+
expect(err.message).toContain("InsufficientBalance");
|
|
288
|
+
});
|
|
289
|
+
test("without revert reason uses formatted", () => {
|
|
290
|
+
const err = new TxDryRunError({ success: false }, "BadOrigin");
|
|
291
|
+
expect(err.message).toContain("BadOrigin");
|
|
292
|
+
expect(err.revertReason).toBeUndefined();
|
|
293
|
+
});
|
|
294
|
+
test("preserves raw result for inspection", () => {
|
|
295
|
+
const raw = { success: false, value: { type: "Module" } };
|
|
296
|
+
const err = new TxDryRunError(raw, "Module");
|
|
297
|
+
expect(err.raw).toBe(raw);
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
describe("formatDryRunError", () => {
|
|
301
|
+
test("returns empty string for successful result", () => {
|
|
302
|
+
expect(formatDryRunError({ success: true })).toBe("");
|
|
303
|
+
});
|
|
304
|
+
test("extracts revert reason", () => {
|
|
305
|
+
expect(formatDryRunError({
|
|
306
|
+
success: false,
|
|
307
|
+
value: { revertReason: "InsufficientBalance" },
|
|
308
|
+
})).toBe("InsufficientBalance");
|
|
309
|
+
});
|
|
310
|
+
test("walks Module.Pallet.Error chain", () => {
|
|
311
|
+
expect(formatDryRunError({
|
|
312
|
+
success: false,
|
|
313
|
+
value: {
|
|
314
|
+
type: "Module",
|
|
315
|
+
value: { type: "Revive", value: { type: "StorageDepositNotEnoughFunds" } },
|
|
316
|
+
},
|
|
317
|
+
})).toBe("Revive.StorageDepositNotEnoughFunds");
|
|
318
|
+
});
|
|
319
|
+
test("returns pallet name when inner error has no type", () => {
|
|
320
|
+
expect(formatDryRunError({
|
|
321
|
+
success: false,
|
|
322
|
+
value: { type: "Module", value: { type: "Balances", value: {} } },
|
|
323
|
+
})).toBe("Balances");
|
|
324
|
+
});
|
|
325
|
+
test("extracts ReviveApi Message string", () => {
|
|
326
|
+
expect(formatDryRunError({
|
|
327
|
+
success: false,
|
|
328
|
+
value: {
|
|
329
|
+
type: "Message",
|
|
330
|
+
value: "Insufficient balance for gas * price + value",
|
|
331
|
+
},
|
|
332
|
+
})).toBe("Insufficient balance for gas * price + value");
|
|
333
|
+
});
|
|
334
|
+
test("handles ReviveApi Data with string hex", () => {
|
|
335
|
+
expect(formatDryRunError({
|
|
336
|
+
success: false,
|
|
337
|
+
value: { type: "Data", value: "0x08c379a0" },
|
|
338
|
+
})).toBe("contract reverted with data: 0x08c379a0");
|
|
339
|
+
});
|
|
340
|
+
test("handles ReviveApi Data with Binary-like object", () => {
|
|
341
|
+
const binary = { asHex: () => "0xdeadbeef" };
|
|
342
|
+
expect(formatDryRunError({ success: false, value: { type: "Data", value: binary } })).toBe("contract reverted with data: 0xdeadbeef");
|
|
343
|
+
});
|
|
344
|
+
test("handles ReviveApi Data with no extractable hex", () => {
|
|
345
|
+
expect(formatDryRunError({ success: false, value: { type: "Data", value: 42 } })).toBe("contract reverted");
|
|
346
|
+
});
|
|
347
|
+
test("returns non-Module/Message type directly", () => {
|
|
348
|
+
expect(formatDryRunError({ success: false, value: { type: "BadOrigin" } })).toBe("BadOrigin");
|
|
349
|
+
});
|
|
350
|
+
test("extracts from nested raw field (patched SDK)", () => {
|
|
351
|
+
expect(formatDryRunError({
|
|
352
|
+
success: false,
|
|
353
|
+
value: { raw: { type: "Message", value: "out of gas" } },
|
|
354
|
+
})).toBe("out of gas");
|
|
355
|
+
});
|
|
356
|
+
test("extracts revertReason from nested raw", () => {
|
|
357
|
+
expect(formatDryRunError({
|
|
358
|
+
success: false,
|
|
359
|
+
value: { raw: { revertReason: "Unauthorized" } },
|
|
360
|
+
})).toBe("Unauthorized");
|
|
361
|
+
});
|
|
362
|
+
test("falls back to error.type", () => {
|
|
363
|
+
expect(formatDryRunError({ success: false, error: { type: "ContractTrapped" } })).toBe("ContractTrapped");
|
|
364
|
+
});
|
|
365
|
+
test("falls back to error.name", () => {
|
|
366
|
+
expect(formatDryRunError({ success: false, error: { name: "ExecutionFailed" } })).toBe("ExecutionFailed");
|
|
367
|
+
});
|
|
368
|
+
test("returns unknown error when nothing is extractable", () => {
|
|
369
|
+
expect(formatDryRunError({ success: false })).toBe("unknown error");
|
|
370
|
+
});
|
|
371
|
+
test("returns unknown error for empty value and error", () => {
|
|
372
|
+
expect(formatDryRunError({ success: false, value: {}, error: {} })).toBe("unknown error");
|
|
373
|
+
});
|
|
374
|
+
test("returns unknown error for null value", () => {
|
|
375
|
+
expect(formatDryRunError({ success: false, value: null })).toBe("unknown error");
|
|
376
|
+
});
|
|
377
|
+
test("prefers revertReason over Module error", () => {
|
|
378
|
+
// When both are present, revertReason is more specific
|
|
379
|
+
expect(formatDryRunError({
|
|
380
|
+
success: false,
|
|
381
|
+
value: {
|
|
382
|
+
revertReason: "OwnableUnauthorizedAccount",
|
|
383
|
+
type: "Module",
|
|
384
|
+
value: {},
|
|
385
|
+
},
|
|
386
|
+
})).toBe("OwnableUnauthorizedAccount");
|
|
387
|
+
});
|
|
388
|
+
});
|
|
389
|
+
describe("isSigningRejection", () => {
|
|
390
|
+
test("detects common rejection messages", () => {
|
|
391
|
+
expect(isSigningRejection(new Error("Cancelled"))).toBe(true);
|
|
392
|
+
expect(isSigningRejection(new Error("User rejected the request"))).toBe(true);
|
|
393
|
+
expect(isSigningRejection(new Error("Transaction was rejected by user"))).toBe(true);
|
|
394
|
+
expect(isSigningRejection(new Error("User denied"))).toBe(true);
|
|
395
|
+
expect(isSigningRejection(new Error("Signing was denied by user"))).toBe(true);
|
|
396
|
+
expect(isSigningRejection(new Error("User refused to sign"))).toBe(true);
|
|
397
|
+
});
|
|
398
|
+
test("returns false for non-rejection errors", () => {
|
|
399
|
+
expect(isSigningRejection(new Error("Network timeout"))).toBe(false);
|
|
400
|
+
expect(isSigningRejection(new Error("Insufficient balance"))).toBe(false);
|
|
401
|
+
});
|
|
402
|
+
test("returns false for non-Error values", () => {
|
|
403
|
+
expect(isSigningRejection("cancelled")).toBe(false);
|
|
404
|
+
expect(isSigningRejection(null)).toBe(false);
|
|
405
|
+
});
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qGAAqG;AACrG,MAAM,OAAO,OAAQ,SAAQ,KAAK;IAC9B,YAAY,OAAe,EAAE,OAAsB;QAC/C,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;IAC1B,CAAC;CACJ;AAED,2GAA2G;AAC3G,MAAM,OAAO,cAAe,SAAQ,OAAO;IAC9B,SAAS,CAAS;IAE3B,YAAY,SAAiB;QACzB,KAAK,CACD,+BAA+B,SAAS,GAAG,IAAI,KAAK;YAChD,mDAAmD,CAC1D,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC;CACJ;AAED,qEAAqE;AACrE,MAAM,OAAO,eAAgB,SAAQ,OAAO;IACxC,4CAA4C;IACnC,aAAa,CAAU;IAChC,qEAAqE;IAC5D,SAAS,CAAS;IAE3B,YAAY,aAAsB,EAAE,SAAiB;QACjD,KAAK,CAAC,gCAAgC,SAAS,EAAE,CAAC,CAAC;QACnD,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;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C;YACrF,MAAM,CAAC,kBAAkB,CAAC,IAAI,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAChE,MAAM,CAAC,kBAAkB,CAAC,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC/E,MAAM,CAAC,kBAAkB,CAAC,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC7E,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,wCAAwC,EAAE,GAAG,EAAE;YAChD,MAAM,CAAC,kBAAkB,CAAC,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACrE,MAAM,CAAC,kBAAkB,CAAC,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC9E,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,oCAAoC,EAAE,GAAG,EAAE;YAC5C,MAAM,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACpD,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { submitAndWatch } from "./submit.js";
|
|
2
|
+
export { withRetry, calculateDelay } from "./retry.js";
|
|
3
|
+
export { createDevSigner, getDevPublicKey } from "./dev-signers.js";
|
|
4
|
+
export { extractTransaction, applyWeightBuffer } from "./dry-run.js";
|
|
5
|
+
export { TxError, TxTimeoutError, TxDispatchError, TxDryRunError, TxSigningRejectedError, formatDispatchError, formatDryRunError, isSigningRejection, } from "./errors.js";
|
|
6
|
+
export type { TxStatus, WaitFor, TxResult, SubmitOptions, RetryOptions, DevAccountName, Weight, SubmittableTransaction, TxEvent, } from "./types.js";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EACH,OAAO,EACP,cAAc,EACd,eAAe,EACf,aAAa,EACb,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,GACrB,MAAM,aAAa,CAAC;AACrB,YAAY,EACR,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,cAAc,EACd,MAAM,EACN,sBAAsB,EACtB,OAAO,GACV,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { submitAndWatch } from "./submit.js";
|
|
2
|
+
export { withRetry, calculateDelay } from "./retry.js";
|
|
3
|
+
export { createDevSigner, getDevPublicKey } from "./dev-signers.js";
|
|
4
|
+
export { extractTransaction, applyWeightBuffer } from "./dry-run.js";
|
|
5
|
+
export { TxError, TxTimeoutError, TxDispatchError, TxDryRunError, TxSigningRejectedError, formatDispatchError, formatDryRunError, isSigningRejection, } from "./errors.js";
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EACH,OAAO,EACP,cAAc,EACd,eAAe,EACf,aAAa,EACb,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,GACrB,MAAM,aAAa,CAAC"}
|
package/dist/retry.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { RetryOptions } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Calculate delay with exponential backoff and jitter.
|
|
4
|
+
*
|
|
5
|
+
* Jitter prevents thundering-herd when multiple clients retry simultaneously.
|
|
6
|
+
* The delay is `min(baseDelay * 2^attempt, maxDelay) * random(0.5, 1.0)`.
|
|
7
|
+
*/
|
|
8
|
+
export declare function calculateDelay(attempt: number, baseDelayMs: number, maxDelayMs: number): number;
|
|
9
|
+
/**
|
|
10
|
+
* Wrap an async function with retry logic and exponential backoff.
|
|
11
|
+
*
|
|
12
|
+
* Only retries transient errors (network disconnects, temporary RPC failures).
|
|
13
|
+
* Deterministic errors ({@link TxDispatchError}), user rejections
|
|
14
|
+
* ({@link TxSigningRejectedError}), and timeouts ({@link TxTimeoutError}) are
|
|
15
|
+
* rethrown immediately without retry.
|
|
16
|
+
*
|
|
17
|
+
* @param fn - The async function to retry.
|
|
18
|
+
* @param options - Retry configuration.
|
|
19
|
+
* @returns The result of the first successful call.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```ts
|
|
23
|
+
* const result = await withRetry(
|
|
24
|
+
* () => submitAndWatch(tx, signer),
|
|
25
|
+
* { maxAttempts: 3, baseDelayMs: 1_000 },
|
|
26
|
+
* );
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function withRetry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
|
|
30
|
+
//# sourceMappingURL=retry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAwB/C;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAI/F;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,CAAC,CAAC,CA8B3F"}
|
package/dist/retry.js
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { createLogger } from "@polkadot-apps/logger";
|
|
2
|
+
import { TxDispatchError, TxSigningRejectedError, TxTimeoutError } from "./errors.js";
|
|
3
|
+
const log = createLogger("tx:retry");
|
|
4
|
+
function sleep(ms) {
|
|
5
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Whether an error is deterministic and should not be retried.
|
|
9
|
+
*
|
|
10
|
+
* - Dispatch errors are on-chain failures (e.g., insufficient balance) that will
|
|
11
|
+
* produce the same result on retry.
|
|
12
|
+
* - Signing rejections are explicit user intent.
|
|
13
|
+
* - Timeouts mean we already waited the full duration; retrying would double the wait.
|
|
14
|
+
*/
|
|
15
|
+
function isNonRetryable(error) {
|
|
16
|
+
return (error instanceof TxDispatchError ||
|
|
17
|
+
error instanceof TxSigningRejectedError ||
|
|
18
|
+
error instanceof TxTimeoutError);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Calculate delay with exponential backoff and jitter.
|
|
22
|
+
*
|
|
23
|
+
* Jitter prevents thundering-herd when multiple clients retry simultaneously.
|
|
24
|
+
* The delay is `min(baseDelay * 2^attempt, maxDelay) * random(0.5, 1.0)`.
|
|
25
|
+
*/
|
|
26
|
+
export function calculateDelay(attempt, baseDelayMs, maxDelayMs) {
|
|
27
|
+
const exponential = Math.min(baseDelayMs * 2 ** attempt, maxDelayMs);
|
|
28
|
+
const jitter = 0.5 + Math.random() * 0.5;
|
|
29
|
+
return Math.round(exponential * jitter);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Wrap an async function with retry logic and exponential backoff.
|
|
33
|
+
*
|
|
34
|
+
* Only retries transient errors (network disconnects, temporary RPC failures).
|
|
35
|
+
* Deterministic errors ({@link TxDispatchError}), user rejections
|
|
36
|
+
* ({@link TxSigningRejectedError}), and timeouts ({@link TxTimeoutError}) are
|
|
37
|
+
* rethrown immediately without retry.
|
|
38
|
+
*
|
|
39
|
+
* @param fn - The async function to retry.
|
|
40
|
+
* @param options - Retry configuration.
|
|
41
|
+
* @returns The result of the first successful call.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* const result = await withRetry(
|
|
46
|
+
* () => submitAndWatch(tx, signer),
|
|
47
|
+
* { maxAttempts: 3, baseDelayMs: 1_000 },
|
|
48
|
+
* );
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export async function withRetry(fn, options) {
|
|
52
|
+
const maxAttempts = options?.maxAttempts ?? 3;
|
|
53
|
+
const baseDelayMs = options?.baseDelayMs ?? 1_000;
|
|
54
|
+
const maxDelayMs = options?.maxDelayMs ?? 15_000;
|
|
55
|
+
let lastError;
|
|
56
|
+
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
57
|
+
try {
|
|
58
|
+
return await fn();
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
lastError = error;
|
|
62
|
+
if (isNonRetryable(error)) {
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
if (attempt + 1 >= maxAttempts) {
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
const delay = calculateDelay(attempt, baseDelayMs, maxDelayMs);
|
|
69
|
+
log.warn(`Attempt ${attempt + 1}/${maxAttempts} failed, retrying in ${delay}ms`, {
|
|
70
|
+
error: error instanceof Error ? error.message : String(error),
|
|
71
|
+
});
|
|
72
|
+
await sleep(delay);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
throw lastError;
|
|
76
|
+
}
|
|
77
|
+
if (import.meta.vitest) {
|
|
78
|
+
const { describe, test, expect, vi, beforeEach } = import.meta.vitest;
|
|
79
|
+
const { configure } = await import("@polkadot-apps/logger");
|
|
80
|
+
beforeEach(() => {
|
|
81
|
+
configure({ handler: () => { } });
|
|
82
|
+
vi.useRealTimers();
|
|
83
|
+
});
|
|
84
|
+
describe("withRetry", () => {
|
|
85
|
+
test("returns on first success", async () => {
|
|
86
|
+
const result = await withRetry(() => Promise.resolve("ok"));
|
|
87
|
+
expect(result).toBe("ok");
|
|
88
|
+
});
|
|
89
|
+
test("retries transient error then succeeds", async () => {
|
|
90
|
+
let calls = 0;
|
|
91
|
+
const result = await withRetry(() => {
|
|
92
|
+
calls++;
|
|
93
|
+
if (calls < 2)
|
|
94
|
+
return Promise.reject(new Error("Network error"));
|
|
95
|
+
return Promise.resolve("recovered");
|
|
96
|
+
}, { baseDelayMs: 1 });
|
|
97
|
+
expect(result).toBe("recovered");
|
|
98
|
+
expect(calls).toBe(2);
|
|
99
|
+
});
|
|
100
|
+
test("gives up after maxAttempts", async () => {
|
|
101
|
+
let calls = 0;
|
|
102
|
+
await expect(withRetry(() => {
|
|
103
|
+
calls++;
|
|
104
|
+
return Promise.reject(new Error("Persistent failure"));
|
|
105
|
+
}, { maxAttempts: 3, baseDelayMs: 1 })).rejects.toThrow("Persistent failure");
|
|
106
|
+
expect(calls).toBe(3);
|
|
107
|
+
});
|
|
108
|
+
test("does NOT retry TxDispatchError", async () => {
|
|
109
|
+
let calls = 0;
|
|
110
|
+
await expect(withRetry(() => {
|
|
111
|
+
calls++;
|
|
112
|
+
return Promise.reject(new TxDispatchError({}, "Balances.InsufficientBalance"));
|
|
113
|
+
}, { maxAttempts: 3, baseDelayMs: 1 })).rejects.toThrow(TxDispatchError);
|
|
114
|
+
expect(calls).toBe(1);
|
|
115
|
+
});
|
|
116
|
+
test("does NOT retry TxSigningRejectedError", async () => {
|
|
117
|
+
let calls = 0;
|
|
118
|
+
await expect(withRetry(() => {
|
|
119
|
+
calls++;
|
|
120
|
+
return Promise.reject(new TxSigningRejectedError());
|
|
121
|
+
}, { maxAttempts: 3, baseDelayMs: 1 })).rejects.toThrow(TxSigningRejectedError);
|
|
122
|
+
expect(calls).toBe(1);
|
|
123
|
+
});
|
|
124
|
+
test("does NOT retry TxTimeoutError", async () => {
|
|
125
|
+
let calls = 0;
|
|
126
|
+
await expect(withRetry(() => {
|
|
127
|
+
calls++;
|
|
128
|
+
return Promise.reject(new TxTimeoutError(300_000));
|
|
129
|
+
}, { maxAttempts: 3, baseDelayMs: 1 })).rejects.toThrow(TxTimeoutError);
|
|
130
|
+
expect(calls).toBe(1);
|
|
131
|
+
});
|
|
132
|
+
test("respects maxDelayMs cap", () => {
|
|
133
|
+
// attempt=10 with baseDelay=1000 would be 1024000ms uncapped
|
|
134
|
+
const delay = calculateDelay(10, 1_000, 15_000);
|
|
135
|
+
expect(delay).toBeLessThanOrEqual(15_000);
|
|
136
|
+
expect(delay).toBeGreaterThan(0);
|
|
137
|
+
});
|
|
138
|
+
test("applies jitter (delay varies between calls)", () => {
|
|
139
|
+
const delays = Array.from({ length: 20 }, () => calculateDelay(2, 1_000, 15_000));
|
|
140
|
+
const unique = new Set(delays);
|
|
141
|
+
// With jitter, we should get multiple distinct values out of 20 samples
|
|
142
|
+
expect(unique.size).toBeGreaterThan(1);
|
|
143
|
+
});
|
|
144
|
+
test("exponential backoff increases delay", () => {
|
|
145
|
+
// Use fixed random to test the exponential growth
|
|
146
|
+
const base = 1_000;
|
|
147
|
+
const max = 100_000;
|
|
148
|
+
// The minimum possible delay at each attempt (jitter factor = 0.5)
|
|
149
|
+
const minDelay0 = base * 0.5; // 500
|
|
150
|
+
const minDelay2 = base * 4 * 0.5; // 2000
|
|
151
|
+
// attempt 2 minimum should be greater than attempt 0 maximum
|
|
152
|
+
const maxDelay0 = base * 1.0; // 1000
|
|
153
|
+
expect(minDelay2).toBeGreaterThan(maxDelay0);
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=retry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry.js","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGtF,MAAM,GAAG,GAAG,YAAY,CAAC,UAAU,CAAC,CAAC;AAErC,SAAS,KAAK,CAAC,EAAU;IACrB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC7D,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,cAAc,CAAC,KAAc;IAClC,OAAO,CACH,KAAK,YAAY,eAAe;QAChC,KAAK,YAAY,sBAAsB;QACvC,KAAK,YAAY,cAAc,CAClC,CAAC;AACN,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,OAAe,EAAE,WAAmB,EAAE,UAAkB;IACnF,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,WAAW,GAAG,CAAC,IAAI,OAAO,EAAE,UAAU,CAAC,CAAC;IACrE,MAAM,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,G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