@heliofi/withdraw-core 0.4.0 → 0.5.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 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, PreparedTransaction, PrepareWithdrawalParams, QuoteResponse, QuoteSummary, RawPreparedTransaction, RoutesResponse, SlimCurrencyWithBlockchain, StatusResponse, SubmitResponse, SubmitWithdrawalParams, UpdateQuoteParams, UserOpPreparedTransaction, WalletCurrencyBalance, WithdrawalConfig, WithdrawalCurrenciesExchangeRate, WithdrawalCustomerSwapRoute, } from './types';
6
+ export type { BalanceResponse, BaseBlockchain, CreateWithdrawalDetailParams, HypercorePreparedTransaction, PolymarketWalletPreparedTransaction, PreparedTransaction, QuoteResponse, QuoteSummary, RawPreparedTransaction, RoutesResponse, SlimCurrencyWithBlockchain, 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 { PrepareWithdrawalParams, SubmitWithdrawalParams, UpdateQuoteParams } from '../types/requests';
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
- prepare(params: PrepareWithdrawalParams, signal?: AbortSignal): Promise<QuoteResponse>;
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
- updateQuote(_withdrawalDetailId: string, _params: UpdateQuoteParams, _signal?: AbortSignal): Promise<QuoteResponse>;
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.
@@ -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 { PrepareWithdrawalParams, SubmitWithdrawalParams, UpdateQuoteParams, } from './requests';
2
+ export type { HypercorePreparedTransaction, PolymarketWalletPreparedTransaction, PreparedTransaction, QuoteResponse, QuoteSummary, RawPreparedTransaction, UserOpPreparedTransaction, } from './prepared';
3
+ export type { CreateWithdrawalDetailParams, SubmitWithdrawalParams, UpdateWithdrawalDetailParams, } from './requests';
4
4
  export type { BalanceResponse, BaseBlockchain, RoutesResponse, SlimCurrencyWithBlockchain, StatusResponse, SubmitResponse, WalletCurrencyBalance, WithdrawalConfig, WithdrawalCurrenciesExchangeRate, WithdrawalCustomerSwapRoute, } from './responses';
@@ -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
- export type PreparedTransaction = PolymarketWalletPreparedTransaction | RawPreparedTransaction | UserOpPreparedTransaction;
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;
@@ -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 PrepareWithdrawalParams {
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). */
@@ -24,7 +24,7 @@ export interface PrepareWithdrawalParams {
24
24
  * is kept as a forward-compatible stub and will throw at runtime until
25
25
  * the backend ships the PATCH handler.
26
26
  */
27
- export interface UpdateQuoteParams {
27
+ export interface UpdateWithdrawalDetailParams {
28
28
  amount: string;
29
29
  recipient?: string;
30
30
  toCurrencyId?: string;
@@ -1 +1 @@
1
- "use strict";var u=Object.defineProperty;var a=(e,t,E)=>t in e?u(e,t,{enumerable:!0,configurable:!0,writable:!0,value:E}):e[t]=E;var r=(e,t,E)=>a(e,typeof t!="symbol"?t+"":t,E);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let i=(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})({}),p=(function(e){return e.RAW="raw",e.USER_OP="userop",e.POLYMARKET_WALLET="polymarket_wallet",e.HYPERCORE="hypercore",e})({});const U=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 H=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&&H.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)},C=(e,t=5e3)=>{const{exp:E}=O(e);return E===void 0?!1:Date.now()>=E*1e3-t},P="0.4.0";class S{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 N=`${this.baseUrl}${E}`,_=await this.fetch(N,{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 S(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 prepare(t,E){const{withdrawalConfigId:s,...D}=t;return this.api.post(`/withdraw/${s}/prepare`,D,E)}async updateQuote(t,E,s){throw new Error("updateQuote is not yet supported by the backend. Create a new quote via prepare() 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=i;exports.BroadcastAck=c;exports.Platform=o;exports.SignedTransactionKind=p;exports.TERMINAL_STATES=U;exports.WithdrawalApiError=A;exports.WithdrawalErrorCode=I;exports.WithdrawalFeature=L;exports.WithdrawalSDK=R;exports.WithdrawalState=T;exports.decodeJwt=O;exports.isQuoteExpired=C;exports.toWithdrawalErrorCode=n;
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.5.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;
@@ -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 o = /* @__PURE__ */ (function(e) {
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
- })({}), a = /* @__PURE__ */ (function(e) {
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
- })({}), p = /* @__PURE__ */ (function(e) {
8
+ })({}), c = /* @__PURE__ */ (function(e) {
9
9
  return e.HELIO = "HELIO", e.MAGIC_EDEN = "MAGIC_EDEN", e;
10
- })({}), C = /* @__PURE__ */ (function(e) {
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
- })({}), c = /* @__PURE__ */ (function(e) {
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 L = (e) => e && N.has(e) ? e : R.UNKNOWN, W = (e) => {
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
- }, S = (e, t = 5e3) => {
42
- const { exp: E } = W(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.4.0";
45
- class U {
44
+ }, i = "0.5.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
- L(s),
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 U(t));
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 prepare(t, E) {
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 updateQuote(t, E, s) {
143
+ async updateWithdrawalDetail(t, E, s) {
142
144
  throw new Error(
143
- "updateQuote is not yet supported by the backend. Create a new quote via prepare() instead."
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
- a as BlockchainEngineType,
164
- o as BlockchainSymbol,
165
- c as BroadcastAck,
166
- p as Platform,
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
- C as WithdrawalFeature,
173
+ o as WithdrawalFeature,
172
174
  A as WithdrawalSDK,
173
175
  I as WithdrawalState,
174
- W as decodeJwt,
175
- S as isQuoteExpired,
176
- L as toWithdrawalErrorCode
176
+ a as decodeJwt,
177
+ l as isQuoteExpired,
178
+ W as toWithdrawalErrorCode
177
179
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@heliofi/withdraw-core",
3
3
  "private": false,
4
- "version": "0.4.0",
4
+ "version": "0.5.0",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",