@heliofi/withdraw-core 0.4.0 → 0.6.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/index.d.ts +1 -1
- package/dist/sdk/WithdrawalSDK.d.ts +6 -4
- package/dist/types/index.d.ts +3 -3
- package/dist/types/prepared.d.ts +19 -1
- package/dist/types/requests.d.ts +4 -3
- package/dist/types/responses.d.ts +35 -3
- package/dist/withdraw-core.cjs +1 -1
- package/dist/withdraw-core.js +26 -24
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ export type { WithdrawalJwtPayload } from './jwt';
|
|
|
3
3
|
export { decodeJwt, isQuoteExpired } from './jwt';
|
|
4
4
|
export type { ApiClientConfig } from './sdk';
|
|
5
5
|
export { WithdrawalSDK } from './sdk';
|
|
6
|
-
export type { BalanceResponse, BaseBlockchain, PolymarketWalletPreparedTransaction,
|
|
6
|
+
export type { BalanceResponse, BaseBlockchain, BlockchainEngine, CreateWithdrawalDetailParams, HypercorePreparedTransaction, PolymarketWalletPreparedTransaction, PopulatedBlockchain, PreparedTransaction, QuoteResponse, QuoteSummary, RawPreparedTransaction, RoutesResponse, SlimCurrencyWithBlockchain, SlimCurrencyWithPopulatedBlockchain, StatusResponse, SubmitResponse, SubmitWithdrawalParams, UpdateWithdrawalDetailParams, UserOpPreparedTransaction, WalletCurrencyBalance, WithdrawalConfig, WithdrawalCurrenciesExchangeRate, WithdrawalCustomerSwapRoute, } from './types';
|
|
7
7
|
export { BlockchainEngineType, BlockchainSymbol, BroadcastAck, Platform, SignedTransactionKind, TERMINAL_STATES, WithdrawalErrorCode, WithdrawalFeature, WithdrawalState, } from './types';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { QuoteResponse } from '../types/prepared';
|
|
2
|
-
import type {
|
|
2
|
+
import type { CreateWithdrawalDetailParams, SubmitWithdrawalParams, UpdateWithdrawalDetailParams } from '../types/requests';
|
|
3
3
|
import type { BalanceResponse, RoutesResponse, StatusResponse, SubmitResponse, WithdrawalConfig } from '../types/responses';
|
|
4
4
|
import { ApiClient, type ApiClientConfig } from './ApiClient';
|
|
5
5
|
export declare class WithdrawalSDK {
|
|
@@ -10,19 +10,21 @@ export declare class WithdrawalSDK {
|
|
|
10
10
|
getRoutes(withdrawalConfigId: string, signal?: AbortSignal): Promise<RoutesResponse>;
|
|
11
11
|
getBalance(withdrawalConfigId: string, walletAddress: string, signal?: AbortSignal): Promise<BalanceResponse>;
|
|
12
12
|
/**
|
|
13
|
+
* Create a withdrawal detail (a priced quote) for a config.
|
|
14
|
+
*
|
|
13
15
|
* Calls `POST /withdraw/:withdrawalConfigId/prepare`.
|
|
14
16
|
* `withdrawalConfigId` goes in the path; the remaining fields are the
|
|
15
17
|
* request body matching the backend `PreparedWithdrawalDto`.
|
|
16
18
|
*/
|
|
17
|
-
|
|
19
|
+
createWithdrawalDetail(params: CreateWithdrawalDetailParams, signal?: AbortSignal): Promise<QuoteResponse>;
|
|
18
20
|
/**
|
|
19
|
-
* Update an existing quote.
|
|
21
|
+
* Update an existing withdrawal detail, returning a fresh quote.
|
|
20
22
|
*
|
|
21
23
|
* NOTE: The backend does not yet expose a PATCH endpoint for prepare.
|
|
22
24
|
* This stub is kept for forward compatibility. It will throw until
|
|
23
25
|
* the backend ships the handler.
|
|
24
26
|
*/
|
|
25
|
-
|
|
27
|
+
updateWithdrawalDetail(_withdrawalDetailId: string, _params: UpdateWithdrawalDetailParams, _signal?: AbortSignal): Promise<QuoteResponse>;
|
|
26
28
|
/**
|
|
27
29
|
* Body matches the backend `SubmitWithdrawalDto`:
|
|
28
30
|
* `{ token, signedTx }`, where `signedTx` is the bare signed payload string.
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { BlockchainEngineType, BlockchainSymbol, BroadcastAck, Platform, SignedTransactionKind, TERMINAL_STATES, WithdrawalErrorCode, WithdrawalFeature, WithdrawalState, } from './enums';
|
|
2
|
-
export type { PolymarketWalletPreparedTransaction, PreparedTransaction, QuoteResponse, QuoteSummary, RawPreparedTransaction, UserOpPreparedTransaction, } from './prepared';
|
|
3
|
-
export type {
|
|
4
|
-
export type { BalanceResponse, BaseBlockchain, RoutesResponse, SlimCurrencyWithBlockchain, StatusResponse, SubmitResponse, WalletCurrencyBalance, WithdrawalConfig, WithdrawalCurrenciesExchangeRate, WithdrawalCustomerSwapRoute, } from './responses';
|
|
2
|
+
export type { HypercorePreparedTransaction, PolymarketWalletPreparedTransaction, PreparedTransaction, QuoteResponse, QuoteSummary, RawPreparedTransaction, UserOpPreparedTransaction, } from './prepared';
|
|
3
|
+
export type { CreateWithdrawalDetailParams, SubmitWithdrawalParams, UpdateWithdrawalDetailParams, } from './requests';
|
|
4
|
+
export type { BalanceResponse, BaseBlockchain, BlockchainEngine, PopulatedBlockchain, RoutesResponse, SlimCurrencyWithBlockchain, SlimCurrencyWithPopulatedBlockchain, StatusResponse, SubmitResponse, WalletCurrencyBalance, WithdrawalConfig, WithdrawalCurrenciesExchangeRate, WithdrawalCustomerSwapRoute, } from './responses';
|
package/dist/types/prepared.d.ts
CHANGED
|
@@ -13,8 +13,26 @@ export interface UserOpPreparedTransaction {
|
|
|
13
13
|
chain: string;
|
|
14
14
|
userOp: Record<string, unknown>;
|
|
15
15
|
entryPoint: string;
|
|
16
|
+
/**
|
|
17
|
+
* EIP-7702 authorization tuple. Optional — present only when the userOp
|
|
18
|
+
* carries one. Mirrors the backend `UserOpPreparedTransaction.authorization?`.
|
|
19
|
+
*/
|
|
20
|
+
authorization?: {
|
|
21
|
+
chainId: string;
|
|
22
|
+
address: string;
|
|
23
|
+
nonce: string;
|
|
24
|
+
};
|
|
16
25
|
}
|
|
17
|
-
|
|
26
|
+
/**
|
|
27
|
+
* HyperCore lane: the merchant signs the EIP-712 typed data of the HyperCore
|
|
28
|
+
* action (same modality as Polymarket); submit carries back the signature.
|
|
29
|
+
*/
|
|
30
|
+
export interface HypercorePreparedTransaction {
|
|
31
|
+
kind: SignedTransactionKind.HYPERCORE;
|
|
32
|
+
chain: string;
|
|
33
|
+
typedData: Record<string, unknown>;
|
|
34
|
+
}
|
|
35
|
+
export type PreparedTransaction = PolymarketWalletPreparedTransaction | RawPreparedTransaction | UserOpPreparedTransaction | HypercorePreparedTransaction;
|
|
18
36
|
export interface QuoteSummary {
|
|
19
37
|
sourceToken: string;
|
|
20
38
|
sourceAmount: string;
|
package/dist/types/requests.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Field names mirror the backend `PreparedWithdrawalDto` exactly.
|
|
5
5
|
* `withdrawalConfigId` is sent as a URL path segment (not in the body).
|
|
6
6
|
*/
|
|
7
|
-
export interface
|
|
7
|
+
export interface CreateWithdrawalDetailParams {
|
|
8
8
|
/** Merchant withdrawal config ID — used in the URL path. */
|
|
9
9
|
withdrawalConfigId: string;
|
|
10
10
|
/** Owner address of the source wallet (lane-specific format). */
|
|
@@ -15,7 +15,8 @@ export interface PrepareWithdrawalParams {
|
|
|
15
15
|
amount: string;
|
|
16
16
|
/** Destination currency ID (MongoDB ObjectId). */
|
|
17
17
|
toCurrencyId: string;
|
|
18
|
-
|
|
18
|
+
/** Source currency ID (MongoDB ObjectId). */
|
|
19
|
+
sourceCurrencyId: string;
|
|
19
20
|
}
|
|
20
21
|
/**
|
|
21
22
|
* Parameters for `PATCH /withdraw/:withdrawalDetailId/prepare`.
|
|
@@ -24,7 +25,7 @@ export interface PrepareWithdrawalParams {
|
|
|
24
25
|
* is kept as a forward-compatible stub and will throw at runtime until
|
|
25
26
|
* the backend ships the PATCH handler.
|
|
26
27
|
*/
|
|
27
|
-
export interface
|
|
28
|
+
export interface UpdateWithdrawalDetailParams {
|
|
28
29
|
amount: string;
|
|
29
30
|
recipient?: string;
|
|
30
31
|
toCurrencyId?: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BlockchainSymbol, BroadcastAck, Platform, WithdrawalFeature, WithdrawalState } from './enums';
|
|
1
|
+
import type { BlockchainEngineType, BlockchainSymbol, BroadcastAck, Platform, WithdrawalFeature, WithdrawalState } from './enums';
|
|
2
2
|
export interface WithdrawalCurrenciesExchangeRate {
|
|
3
3
|
minimalUnitRate: string;
|
|
4
4
|
decimalRate: string;
|
|
@@ -19,7 +19,7 @@ export interface WithdrawalConfig {
|
|
|
19
19
|
createdAt: string;
|
|
20
20
|
/** ISO 8601 timestamp. */
|
|
21
21
|
updatedAt: string;
|
|
22
|
-
fromCurrencies:
|
|
22
|
+
fromCurrencies: SlimCurrencyWithPopulatedBlockchain[];
|
|
23
23
|
exchangeRates: WithdrawalCurrenciesExchangeRate[];
|
|
24
24
|
}
|
|
25
25
|
export interface BaseBlockchain {
|
|
@@ -27,6 +27,29 @@ export interface BaseBlockchain {
|
|
|
27
27
|
symbol: string;
|
|
28
28
|
displayName: string;
|
|
29
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* The blockchain engine (EVM / SOL / BTC / …) that owns the
|
|
32
|
+
* address-validation regex. Mirrors the backend `BlockchainEngine` entity.
|
|
33
|
+
*/
|
|
34
|
+
export interface BlockchainEngine {
|
|
35
|
+
id: string;
|
|
36
|
+
type: BlockchainEngineType;
|
|
37
|
+
/**
|
|
38
|
+
* Network-aware (testnet vs mainnet) source string for an address-validation
|
|
39
|
+
* regex, e.g. `^[1-9A-HJ-NP-Za-km-z]{32,44}$` for SOL. Present on the
|
|
40
|
+
* withdrawal `/routes` and `/public` responses; may be absent for engines
|
|
41
|
+
* without a configured regex.
|
|
42
|
+
*/
|
|
43
|
+
addressRegex?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* A blockchain guaranteed to have its `engine` populated (with the engine's
|
|
47
|
+
* address-validation regex). Mirrors the backend `Blockchain` entity. Used by
|
|
48
|
+
* the withdrawal `/routes` and `/public` responses.
|
|
49
|
+
*/
|
|
50
|
+
export interface PopulatedBlockchain extends BaseBlockchain {
|
|
51
|
+
engine: BlockchainEngine;
|
|
52
|
+
}
|
|
30
53
|
export interface SlimCurrencyWithBlockchain {
|
|
31
54
|
id: string;
|
|
32
55
|
symbol: string;
|
|
@@ -35,6 +58,15 @@ export interface SlimCurrencyWithBlockchain {
|
|
|
35
58
|
decimals: number;
|
|
36
59
|
blockchain: BaseBlockchain;
|
|
37
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* `SlimCurrencyWithBlockchain` whose blockchain is guaranteed populated with its
|
|
63
|
+
* engine (and the engine's address regex). Mirrors the backend
|
|
64
|
+
* `SlimCurrencyWithPopulatedBlockchain` entity — the type of `fromCurrencies`
|
|
65
|
+
* on the withdrawal `/routes` and `/public` responses.
|
|
66
|
+
*/
|
|
67
|
+
export type SlimCurrencyWithPopulatedBlockchain = Omit<SlimCurrencyWithBlockchain, 'blockchain'> & {
|
|
68
|
+
blockchain: PopulatedBlockchain;
|
|
69
|
+
};
|
|
38
70
|
export interface WithdrawalCustomerSwapRoute {
|
|
39
71
|
id: string;
|
|
40
72
|
fromCurrencyId: string;
|
|
@@ -45,7 +77,7 @@ export interface WithdrawalCustomerSwapRoute {
|
|
|
45
77
|
}
|
|
46
78
|
export interface RoutesResponse {
|
|
47
79
|
/** Source currencies available under the merchant's config. */
|
|
48
|
-
fromCurrencies:
|
|
80
|
+
fromCurrencies: SlimCurrencyWithPopulatedBlockchain[];
|
|
49
81
|
routes: WithdrawalCustomerSwapRoute[];
|
|
50
82
|
}
|
|
51
83
|
export interface WalletCurrencyBalance {
|
package/dist/withdraw-core.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var N=Object.defineProperty;var i=(e,t,E)=>t in e?N(e,t,{enumerable:!0,configurable:!0,writable:!0,value:E}):e[t]=E;var r=(e,t,E)=>i(e,typeof t!="symbol"?t+"":t,E);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let u=(function(e){return e.SOL="SOL",e.ETH="ETH",e.POLYGON="POLYGON",e.BASE="BASE",e.BITCOIN="BITCOIN",e.ARBITRUM="ARBITRUM",e.BSC="BSC",e.TRON="TRON",e.DOGE="DOGE",e})({}),W=(function(e){return e.EVM="EVM",e.SOL="SOL",e.BTC="BTC",e.TRON="TRON",e.HYPERCORE="HYPERCORE",e.DOGE="DOGE",e})({}),o=(function(e){return e.HELIO="HELIO",e.MAGIC_EDEN="MAGIC_EDEN",e})({}),L=(function(e){return e.IRON="iron",e.MP_SELL="mp_sell",e})({}),T=(function(e){return e.QUOTED="QUOTED",e.SUBMITTING="SUBMITTING",e.SUBMITTED="SUBMITTED",e.BRIDGING="BRIDGING",e.COMPLETED="COMPLETED",e.FAILED="FAILED",e.FAILED_EXPIRED="FAILED_EXPIRED",e.EXPIRED="EXPIRED",e.REFUNDED_BY_PROVIDER="REFUNDED_BY_PROVIDER",e})({}),c=(function(e){return e.ACKNOWLEDGED="acknowledged",e.UNACKNOWLEDGED="unacknowledged",e.REJECTED="rejected",e})({}),U=(function(e){return e.RAW="raw",e.USER_OP="userop",e.POLYMARKET_WALLET="polymarket_wallet",e.HYPERCORE="hypercore",e})({});const H=new Set([T.COMPLETED,T.FAILED,T.FAILED_EXPIRED,T.EXPIRED,T.REFUNDED_BY_PROVIDER]);var I=(e=>(e.WITHDRAW_TX_INVALID_SIGNATURE="WITHDRAW_TX_INVALID_SIGNATURE",e.WITHDRAW_TX_BLOCKHASH_EXPIRED="WITHDRAW_TX_BLOCKHASH_EXPIRED",e.WITHDRAW_TX_NONCE_TOO_LOW="WITHDRAW_TX_NONCE_TOO_LOW",e.WITHDRAW_TX_USEROP_EXPIRED="WITHDRAW_TX_USEROP_EXPIRED",e.WITHDRAW_TX_UNDERPRICED="WITHDRAW_TX_UNDERPRICED",e.WITHDRAW_BUNDLER_REJECTED="WITHDRAW_BUNDLER_REJECTED",e.WITHDRAW_TX_BROADCAST_TIMEOUT="WITHDRAW_TX_BROADCAST_TIMEOUT",e.WITHDRAW_TX_ALREADY_KNOWN="WITHDRAW_TX_ALREADY_KNOWN",e.WITHDRAW_QUOTE_EXPIRED="WITHDRAW_QUOTE_EXPIRED",e.WITHDRAW_SANCTIONS_BLOCKED="WITHDRAW_SANCTIONS_BLOCKED",e.WITHDRAW_NO_ROUTE="WITHDRAW_NO_ROUTE",e.WITHDRAW_NOT_FOUND="WITHDRAW_NOT_FOUND",e.WITHDRAW_INSUFFICIENT_BALANCE="WITHDRAW_INSUFFICIENT_BALANCE",e.WITHDRAW_DETAILS_NOT_UPDATABLE="WITHDRAW_DETAILS_NOT_UPDATABLE",e.INVALID_WALLET_ADDRESS="INVALID_WALLET_ADDRESS",e.BALANCE_FETCH_FAILED="BALANCE_FETCH_FAILED",e.UNKNOWN="UNKNOWN",e))(I||{});const C=new Set(Object.values(I));class A extends Error{constructor(E,s,D){super(D??s);r(this,"name","WithdrawalApiError");this.status=E,this.code=s,this.detail=D}}const n=e=>e&&C.has(e)?e:I.UNKNOWN,O=e=>{const t=e.split(".");if(t.length!==3)throw new Error("Invalid JWT: expected 3 parts");const E=atob(t[1].replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(E)},l=(e,t=5e3)=>{const{exp:E}=O(e);return E===void 0?!1:Date.now()>=E*1e3-t},p="0.6.0";class P{constructor(t){r(this,"baseUrl");r(this,"headers");r(this,"fetch");var E,s;this.baseUrl=t.baseUrl.endsWith("/")?t.baseUrl.slice(0,-1):t.baseUrl,this.headers={"Content-Type":"application/json","X-MoonPay-Commerce-SDK-Version":p,...(E=t.consumer)!=null&&E.name?{"X-MoonPay-Commerce-Consumer":t.consumer.name}:{},...(s=t.consumer)!=null&&s.version?{"X-MoonPay-Commerce-Consumer-Version":t.consumer.version}:{},...t.headers},this.fetch=t.fetch??globalThis.fetch.bind(globalThis)}async get(t,E){return this.request("GET",t,void 0,E)}async post(t,E,s){return this.request("POST",t,E,s)}async patch(t,E,s){return this.request("PATCH",t,E,s)}async request(t,E,s,D){const a=`${this.baseUrl}${E}`,_=await this.fetch(a,{method:t,headers:this.headers,body:s!==void 0?JSON.stringify(s):void 0,signal:D});if(!_.ok)throw await this.buildError(_);return await _.json()}async buildError(t){let E,s;try{const D=await t.json();E=D.message??void 0,s=D.errorCode??D.errorType??void 0}catch{E=t.statusText||void 0}return new A(t.status,n(s),E)}}class R{constructor(t){this.api=t}static create(t){return new R(new P(t))}async getWithdrawalConfig(t,E){return this.api.get(`/withdrawal-configs/${t}/public`,E)}async getRoutes(t,E){return this.api.get(`/withdraw/${t}/routes`,E)}async getBalance(t,E,s){return this.api.get(`/withdraw/${t}/balances?walletAddress=${encodeURIComponent(E)}`,s)}async createWithdrawalDetail(t,E){const{withdrawalConfigId:s,...D}=t;return this.api.post(`/withdraw/${s}/prepare`,D,E)}async updateWithdrawalDetail(t,E,s){throw new Error("updateWithdrawalDetail is not yet supported by the backend. Create a new withdrawal detail via createWithdrawalDetail() instead.")}async submitWithdrawal(t,E){const{withdrawalDetailId:s,...D}=t;return this.api.post(`/withdraw/${s}/submit`,D,E)}async getWithdrawalDetail(t,E){return this.api.get(`/withdraw-details/${t}`,E)}}exports.BlockchainEngineType=W;exports.BlockchainSymbol=u;exports.BroadcastAck=c;exports.Platform=o;exports.SignedTransactionKind=U;exports.TERMINAL_STATES=H;exports.WithdrawalApiError=A;exports.WithdrawalErrorCode=I;exports.WithdrawalFeature=L;exports.WithdrawalSDK=R;exports.WithdrawalState=T;exports.decodeJwt=O;exports.isQuoteExpired=l;exports.toWithdrawalErrorCode=n;
|
package/dist/withdraw-core.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
var O = Object.defineProperty;
|
|
2
2
|
var n = (e, t, E) => t in e ? O(e, t, { enumerable: !0, configurable: !0, writable: !0, value: E }) : e[t] = E;
|
|
3
3
|
var T = (e, t, E) => n(e, typeof t != "symbol" ? t + "" : t, E);
|
|
4
|
-
let
|
|
4
|
+
let H = /* @__PURE__ */ (function(e) {
|
|
5
5
|
return e.SOL = "SOL", e.ETH = "ETH", e.POLYGON = "POLYGON", e.BASE = "BASE", e.BITCOIN = "BITCOIN", e.ARBITRUM = "ARBITRUM", e.BSC = "BSC", e.TRON = "TRON", e.DOGE = "DOGE", e;
|
|
6
|
-
})({}),
|
|
6
|
+
})({}), C = /* @__PURE__ */ (function(e) {
|
|
7
7
|
return e.EVM = "EVM", e.SOL = "SOL", e.BTC = "BTC", e.TRON = "TRON", e.HYPERCORE = "HYPERCORE", e.DOGE = "DOGE", e;
|
|
8
|
-
})({}),
|
|
8
|
+
})({}), c = /* @__PURE__ */ (function(e) {
|
|
9
9
|
return e.HELIO = "HELIO", e.MAGIC_EDEN = "MAGIC_EDEN", e;
|
|
10
|
-
})({}),
|
|
10
|
+
})({}), o = /* @__PURE__ */ (function(e) {
|
|
11
11
|
return e.IRON = "iron", e.MP_SELL = "mp_sell", e;
|
|
12
12
|
})({}), I = /* @__PURE__ */ (function(e) {
|
|
13
13
|
return e.QUOTED = "QUOTED", e.SUBMITTING = "SUBMITTING", e.SUBMITTED = "SUBMITTED", e.BRIDGING = "BRIDGING", e.COMPLETED = "COMPLETED", e.FAILED = "FAILED", e.FAILED_EXPIRED = "FAILED_EXPIRED", e.EXPIRED = "EXPIRED", e.REFUNDED_BY_PROVIDER = "REFUNDED_BY_PROVIDER", e;
|
|
14
|
-
})({}),
|
|
14
|
+
})({}), p = /* @__PURE__ */ (function(e) {
|
|
15
15
|
return e.ACKNOWLEDGED = "acknowledged", e.UNACKNOWLEDGED = "unacknowledged", e.REJECTED = "rejected", e;
|
|
16
16
|
})({}), P = /* @__PURE__ */ (function(e) {
|
|
17
17
|
return e.RAW = "raw", e.USER_OP = "userop", e.POLYMARKET_WALLET = "polymarket_wallet", e.HYPERCORE = "hypercore", e;
|
|
@@ -32,17 +32,17 @@ class u extends Error {
|
|
|
32
32
|
this.status = E, this.code = s, this.detail = D;
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
const
|
|
35
|
+
const W = (e) => e && N.has(e) ? e : R.UNKNOWN, a = (e) => {
|
|
36
36
|
const t = e.split(".");
|
|
37
37
|
if (t.length !== 3)
|
|
38
38
|
throw new Error("Invalid JWT: expected 3 parts");
|
|
39
39
|
const E = atob(t[1].replace(/-/g, "+").replace(/_/g, "/"));
|
|
40
40
|
return JSON.parse(E);
|
|
41
|
-
},
|
|
42
|
-
const { exp: E } =
|
|
41
|
+
}, l = (e, t = 5e3) => {
|
|
42
|
+
const { exp: E } = a(e);
|
|
43
43
|
return E === void 0 ? !1 : Date.now() >= E * 1e3 - t;
|
|
44
|
-
}, i = "0.
|
|
45
|
-
class
|
|
44
|
+
}, i = "0.6.0";
|
|
45
|
+
class L {
|
|
46
46
|
constructor(t) {
|
|
47
47
|
T(this, "baseUrl");
|
|
48
48
|
T(this, "headers");
|
|
@@ -87,7 +87,7 @@ class U {
|
|
|
87
87
|
}
|
|
88
88
|
return new u(
|
|
89
89
|
t.status,
|
|
90
|
-
|
|
90
|
+
W(s),
|
|
91
91
|
E
|
|
92
92
|
);
|
|
93
93
|
}
|
|
@@ -99,7 +99,7 @@ class A {
|
|
|
99
99
|
this.api = t;
|
|
100
100
|
}
|
|
101
101
|
static create(t) {
|
|
102
|
-
return new A(new
|
|
102
|
+
return new A(new L(t));
|
|
103
103
|
}
|
|
104
104
|
async getWithdrawalConfig(t, E) {
|
|
105
105
|
return this.api.get(
|
|
@@ -119,11 +119,13 @@ class A {
|
|
|
119
119
|
);
|
|
120
120
|
}
|
|
121
121
|
/**
|
|
122
|
+
* Create a withdrawal detail (a priced quote) for a config.
|
|
123
|
+
*
|
|
122
124
|
* Calls `POST /withdraw/:withdrawalConfigId/prepare`.
|
|
123
125
|
* `withdrawalConfigId` goes in the path; the remaining fields are the
|
|
124
126
|
* request body matching the backend `PreparedWithdrawalDto`.
|
|
125
127
|
*/
|
|
126
|
-
async
|
|
128
|
+
async createWithdrawalDetail(t, E) {
|
|
127
129
|
const { withdrawalConfigId: s, ...D } = t;
|
|
128
130
|
return this.api.post(
|
|
129
131
|
`/withdraw/${s}/prepare`,
|
|
@@ -132,15 +134,15 @@ class A {
|
|
|
132
134
|
);
|
|
133
135
|
}
|
|
134
136
|
/**
|
|
135
|
-
* Update an existing quote.
|
|
137
|
+
* Update an existing withdrawal detail, returning a fresh quote.
|
|
136
138
|
*
|
|
137
139
|
* NOTE: The backend does not yet expose a PATCH endpoint for prepare.
|
|
138
140
|
* This stub is kept for forward compatibility. It will throw until
|
|
139
141
|
* the backend ships the handler.
|
|
140
142
|
*/
|
|
141
|
-
async
|
|
143
|
+
async updateWithdrawalDetail(t, E, s) {
|
|
142
144
|
throw new Error(
|
|
143
|
-
"
|
|
145
|
+
"updateWithdrawalDetail is not yet supported by the backend. Create a new withdrawal detail via createWithdrawalDetail() instead."
|
|
144
146
|
);
|
|
145
147
|
}
|
|
146
148
|
/**
|
|
@@ -160,18 +162,18 @@ class A {
|
|
|
160
162
|
}
|
|
161
163
|
}
|
|
162
164
|
export {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
165
|
+
C as BlockchainEngineType,
|
|
166
|
+
H as BlockchainSymbol,
|
|
167
|
+
p as BroadcastAck,
|
|
168
|
+
c as Platform,
|
|
167
169
|
P as SignedTransactionKind,
|
|
168
170
|
X as TERMINAL_STATES,
|
|
169
171
|
u as WithdrawalApiError,
|
|
170
172
|
R as WithdrawalErrorCode,
|
|
171
|
-
|
|
173
|
+
o as WithdrawalFeature,
|
|
172
174
|
A as WithdrawalSDK,
|
|
173
175
|
I as WithdrawalState,
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
176
|
+
a as decodeJwt,
|
|
177
|
+
l as isQuoteExpired,
|
|
178
|
+
W as toWithdrawalErrorCode
|
|
177
179
|
};
|