@rhea-finance/confidential-swap 0.2.6 → 0.2.7
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/index.cjs +36 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -1
- package/dist/index.d.ts +11 -1
- package/dist/index.js +32 -1
- package/dist/index.js.map +1 -1
- package/package.json +13 -12
package/dist/index.cjs
CHANGED
|
@@ -33,12 +33,15 @@ __export(index_exports, {
|
|
|
33
33
|
createConfidentialSwapClient: () => createConfidentialSwapClient,
|
|
34
34
|
createExecutionStore: () => createExecutionStore,
|
|
35
35
|
deriveConfidentialAccountId: () => deriveConfidentialAccountId,
|
|
36
|
+
failures: () => failures,
|
|
36
37
|
findCreditedBalanceChange: () => findCreditedBalanceChange,
|
|
37
38
|
identityKey: () => identityKey,
|
|
38
39
|
isRecoverableExecution: () => isRecoverableExecution,
|
|
40
|
+
isTransientPollError: () => isTransientPollError,
|
|
39
41
|
isUserRejectedError: () => isUserRejectedError,
|
|
40
42
|
needsWithdrawalReview: () => needsWithdrawalReview,
|
|
41
43
|
normalizeChain: () => normalizeChain,
|
|
44
|
+
normalizeStatus: () => normalizeStatus,
|
|
42
45
|
resolveFundingRoute: () => resolveFundingRoute,
|
|
43
46
|
resolveIntentsCreditAsset: () => resolveIntentsCreditAsset,
|
|
44
47
|
resolveLinkingWallet: () => resolveLinkingWallet,
|
|
@@ -49,6 +52,7 @@ __export(index_exports, {
|
|
|
49
52
|
snapshotBalances: () => snapshotBalances,
|
|
50
53
|
splitConfidentialRawAmount: () => splitConfidentialRawAmount,
|
|
51
54
|
standards: () => standards,
|
|
55
|
+
successes: () => successes,
|
|
52
56
|
throwIfAborted: () => throwIfAborted,
|
|
53
57
|
userRejectedError: () => userRejectedError,
|
|
54
58
|
validateRecipients: () => validateRecipients,
|
|
@@ -1302,6 +1306,22 @@ function normalizeStatus(status) {
|
|
|
1302
1306
|
}
|
|
1303
1307
|
var successes = /* @__PURE__ */ new Set(["SUCCESS", "COMPLETED", "SOURCE-CONFIRMED"]);
|
|
1304
1308
|
var failures = /* @__PURE__ */ new Set(["FAILED", "REFUNDED", "EXPIRED", "CANCELLED", "INCOMPLETE_DEPOSIT"]);
|
|
1309
|
+
function isTransientPollError(error) {
|
|
1310
|
+
if (error instanceof ConfidentialSwapError) {
|
|
1311
|
+
return error.code === "HTTP_ERROR" || error.code === "TIMEOUT" || error.code === "INVALID_RESPONSE";
|
|
1312
|
+
}
|
|
1313
|
+
if (error instanceof DOMException) {
|
|
1314
|
+
if (error.name === "AbortError") return false;
|
|
1315
|
+
if (error.name === "TimeoutError") return true;
|
|
1316
|
+
}
|
|
1317
|
+
if (error instanceof TypeError) return true;
|
|
1318
|
+
const message = String(
|
|
1319
|
+
error && typeof error === "object" && "message" in error ? error.message : error ?? ""
|
|
1320
|
+
);
|
|
1321
|
+
return /failed to fetch|networkerror|network request failed|load failed|econnreset|etimedout|socket/i.test(
|
|
1322
|
+
message
|
|
1323
|
+
);
|
|
1324
|
+
}
|
|
1305
1325
|
function polling(options) {
|
|
1306
1326
|
const result = { maxAttempts: options.maxAttempts ?? 0, intervalMs: options.intervalMs ?? 5e3 };
|
|
1307
1327
|
assert(Number.isInteger(result.maxAttempts) && result.maxAttempts >= 0 && Number.isFinite(result.intervalMs) && result.intervalMs >= 0, "Invalid polling options.");
|
|
@@ -1311,7 +1331,18 @@ async function poll(operation, options, signal) {
|
|
|
1311
1331
|
const config = polling(options);
|
|
1312
1332
|
for (let attempt = 0; ; attempt++) {
|
|
1313
1333
|
throwIfAborted(signal);
|
|
1314
|
-
|
|
1334
|
+
let result;
|
|
1335
|
+
try {
|
|
1336
|
+
result = await operation();
|
|
1337
|
+
} catch (error) {
|
|
1338
|
+
throwIfAborted(signal);
|
|
1339
|
+
if (!isTransientPollError(error)) throw error;
|
|
1340
|
+
if (config.maxAttempts > 0 && attempt + 1 >= config.maxAttempts) {
|
|
1341
|
+
throw new ConfidentialSwapError("TIMEOUT", "Status remains unconfirmed; query or resume this execution, do not resubmit.");
|
|
1342
|
+
}
|
|
1343
|
+
await delay(config.intervalMs, signal);
|
|
1344
|
+
continue;
|
|
1345
|
+
}
|
|
1315
1346
|
throwIfAborted(signal);
|
|
1316
1347
|
if (result.done) return result.value;
|
|
1317
1348
|
if (config.maxAttempts > 0 && attempt + 1 >= config.maxAttempts) {
|
|
@@ -2025,12 +2056,15 @@ function createConfidentialSwapClient(config) {
|
|
|
2025
2056
|
createConfidentialSwapClient,
|
|
2026
2057
|
createExecutionStore,
|
|
2027
2058
|
deriveConfidentialAccountId,
|
|
2059
|
+
failures,
|
|
2028
2060
|
findCreditedBalanceChange,
|
|
2029
2061
|
identityKey,
|
|
2030
2062
|
isRecoverableExecution,
|
|
2063
|
+
isTransientPollError,
|
|
2031
2064
|
isUserRejectedError,
|
|
2032
2065
|
needsWithdrawalReview,
|
|
2033
2066
|
normalizeChain,
|
|
2067
|
+
normalizeStatus,
|
|
2034
2068
|
resolveFundingRoute,
|
|
2035
2069
|
resolveIntentsCreditAsset,
|
|
2036
2070
|
resolveLinkingWallet,
|
|
@@ -2041,6 +2075,7 @@ function createConfidentialSwapClient(config) {
|
|
|
2041
2075
|
snapshotBalances,
|
|
2042
2076
|
splitConfidentialRawAmount,
|
|
2043
2077
|
standards,
|
|
2078
|
+
successes,
|
|
2044
2079
|
throwIfAborted,
|
|
2045
2080
|
userRejectedError,
|
|
2046
2081
|
validateRecipients,
|