@opendatalabs/vana-sdk 3.13.4-pr.186.5162bf3 → 3.13.4-pr.186.afb5a4f
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.browser.js +24 -0
- package/dist/index.browser.js.map +2 -2
- package/dist/index.node.cjs +24 -0
- package/dist/index.node.cjs.map +2 -2
- package/dist/index.node.js +24 -0
- package/dist/index.node.js.map +2 -2
- package/dist/protocol/escrow.cjs +26 -0
- package/dist/protocol/escrow.cjs.map +1 -1
- package/dist/protocol/escrow.d.ts +21 -0
- package/dist/protocol/escrow.js +25 -0
- package/dist/protocol/escrow.js.map +1 -1
- package/package.json +1 -1
package/dist/index.browser.js
CHANGED
|
@@ -33318,6 +33318,16 @@ var EscrowWithdrawalLifecycleError = class extends Error {
|
|
|
33318
33318
|
result;
|
|
33319
33319
|
name = "EscrowWithdrawalLifecycleError";
|
|
33320
33320
|
};
|
|
33321
|
+
var EscrowWithdrawalRejectionError = class extends Error {
|
|
33322
|
+
constructor(httpStatus, result) {
|
|
33323
|
+
super(result.error);
|
|
33324
|
+
this.httpStatus = httpStatus;
|
|
33325
|
+
this.result = result;
|
|
33326
|
+
}
|
|
33327
|
+
httpStatus;
|
|
33328
|
+
result;
|
|
33329
|
+
name = "EscrowWithdrawalRejectionError";
|
|
33330
|
+
};
|
|
33321
33331
|
function createEscrowGatewayClient(baseUrl) {
|
|
33322
33332
|
const base = baseUrl.replace(/\/+$/, "");
|
|
33323
33333
|
async function throwOnError(res, context) {
|
|
@@ -33346,6 +33356,9 @@ function createEscrowGatewayClient(baseUrl) {
|
|
|
33346
33356
|
if (isEscrowWithdrawalFailureResult(body)) {
|
|
33347
33357
|
throw new EscrowWithdrawalLifecycleError(res.status, body);
|
|
33348
33358
|
}
|
|
33359
|
+
if (isEscrowWithdrawalRejectedResult(body)) {
|
|
33360
|
+
throw new EscrowWithdrawalRejectionError(res.status, body);
|
|
33361
|
+
}
|
|
33349
33362
|
const error = getGatewayErrorMessage(body);
|
|
33350
33363
|
throw new Error(
|
|
33351
33364
|
`Escrow gateway error (POST /v1/escrow/withdraw): ${res.status} ${res.statusText}${error ? `: ${error}` : ""}`
|
|
@@ -33445,6 +33458,17 @@ function isEscrowWithdrawalFailureResult(body) {
|
|
|
33445
33458
|
const value = body;
|
|
33446
33459
|
return value.success === false && (value.status === "retryable" || value.status === "reorged" || value.status === "failed") && typeof value.error === "string" && isAddressHex(value.account) && isAddressHex(value.asset) && isUint256Decimal(value.amount) && isUint256Decimal(value.withdrawNonce) && isUint256Decimal(value.deadline) && (isHash(value.txHash) || value.txHash === null) && (!("blockNumber" in value) || isBlockNumber(value.blockNumber));
|
|
33447
33460
|
}
|
|
33461
|
+
function isEscrowWithdrawalRejectedResult(body) {
|
|
33462
|
+
if (typeof body !== "object" || body === null) return false;
|
|
33463
|
+
const value = body;
|
|
33464
|
+
return value.success === false && value.status === "rejected" && isWithdrawalRejectionCode(value.code) && typeof value.error === "string" && isAddressHex(value.account) && isAddressHex(value.asset) && isUint256Decimal(value.amount) && isUint256Decimal(value.withdrawNonce) && isUint256Decimal(value.deadline) && optionalUint256Decimal(value.balance) && optionalUint256Decimal(value.authorizedAmount) && optionalUint256Decimal(value.withdrawingAmount) && optionalUint256Decimal(value.availableAmount) && optionalUint256Decimal(value.requestedAmount) && optionalUint256Decimal(value.minimumAmount);
|
|
33465
|
+
}
|
|
33466
|
+
function isWithdrawalRejectionCode(value) {
|
|
33467
|
+
return value === "below_minimum" || value === "deadline_too_far" || value === "expired" || value === "insufficient_available" || value === "stale_nonce";
|
|
33468
|
+
}
|
|
33469
|
+
function optionalUint256Decimal(value) {
|
|
33470
|
+
return value === void 0 || isUint256Decimal(value);
|
|
33471
|
+
}
|
|
33448
33472
|
function isAddressHex(value) {
|
|
33449
33473
|
return typeof value === "string" && isHex(value, { strict: true }) && value.length === 42;
|
|
33450
33474
|
}
|