@heliofi/withdraw-core 1.3.4 → 1.3.6-alpha.1784815902

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/README.md CHANGED
@@ -225,7 +225,7 @@ interface QuoteResponse {
225
225
  }
226
226
 
227
227
  interface SubmitResponse { withdrawalDetailId: string; txHash: string | null; state: WithdrawalState; broadcastAck: BroadcastAck | null; }
228
- interface StatusResponse { withdrawalDetailId: string; state: WithdrawalState; txHash: string | null; broadcastAck: BroadcastAck | null; errorReason: string | null; }
228
+ interface StatusResponse { withdrawalDetailId: string; state: WithdrawalState; txHash: string | null; broadcastAck: BroadcastAck | null; errorReason: string | null; customerId: string | null; }
229
229
  ```
230
230
 
231
231
  `PreparedTransaction` is a discriminated union of `HypercorePreparedTransaction`,
@@ -1,4 +1,4 @@
1
1
  export { BlockchainEngineType, BlockchainSymbol, BroadcastAck, Platform, SignedTransactionKind, TERMINAL_STATES, WithdrawalErrorCode, WithdrawalFeature, WithdrawalState, } from './enums';
2
2
  export type { HypercorePreparedTransaction, PolymarketWalletPreparedTransaction, PreparedTransaction, QuoteResponse, QuoteSummary, RawPreparedTransaction, UserOpPreparedTransaction, WithdrawalQuoteFee, } from './prepared';
3
3
  export type { CreateWithdrawalDetailParams, SubmitWithdrawalParams, UpdateWithdrawalDetailParams, } from './requests';
4
- export type { BalanceResponse, BaseBlockchain, BlockchainEngine, CustomTheme, PopulatedBlockchain, RoutesResponse, SlimCurrencyWithBlockchain, SlimCurrencyWithPopulatedBlockchain, StatusResponse, SubmitResponse, WalletCurrencyBalance, WithdrawalConfig, WithdrawalConfigCompany, WithdrawalCurrenciesExchangeRate, WithdrawalCustomerSwapRoute, } from './responses';
4
+ export type { BalanceResponse, BaseBlockchain, BlockchainEngine, PopulatedBlockchain, RoutesResponse, SlimCurrencyWithBlockchain, SlimCurrencyWithPopulatedBlockchain, StatusResponse, SubmitResponse, WalletCurrencyBalance, WithdrawalConfig, WithdrawalCurrenciesExchangeRate, WithdrawalCustomerSwapRoute, } from './responses';
@@ -1,60 +1,8 @@
1
- import type { SignedTransactionKind } from './enums';
2
- import type { SlimCurrencyWithPopulatedBlockchain } from './responses';
3
- export interface PolymarketWalletPreparedTransaction {
4
- kind: SignedTransactionKind.POLYMARKET_WALLET;
5
- typedData: Record<string, unknown>;
6
- }
7
- export interface RawPreparedTransaction {
8
- kind: SignedTransactionKind.RAW;
9
- chain: string;
10
- unsignedTx: string;
11
- }
12
- export interface UserOpPreparedTransaction {
13
- kind: SignedTransactionKind.USER_OP;
14
- chain: string;
15
- userOp: Record<string, unknown>;
16
- entryPoint: string;
17
- /**
18
- * EIP-7702 authorization tuple. Optional — present only when the userOp
19
- * carries one. Mirrors the backend `UserOpPreparedTransaction.authorization?`.
20
- */
21
- authorization?: {
22
- chainId: string;
23
- address: string;
24
- nonce: string;
25
- };
26
- }
27
1
  /**
28
- * HyperCore lane: the merchant signs the EIP-712 typed data of the HyperCore
29
- * action (same modality as Polymarket); submit carries back the signature.
2
+ * Prepare / quote types, re-exported from the backend source of truth
3
+ * (`@heliofi/common-fe`). Previously hand-copied; now imported so backend stays
4
+ * canonical. Aliased to the public names this SDK has always exposed.
5
+ *
6
+ * `export type` only — no runtime, no `reflect-metadata`.
30
7
  */
31
- export interface HypercorePreparedTransaction {
32
- kind: SignedTransactionKind.HYPERCORE;
33
- chain: string;
34
- typedData: Record<string, unknown>;
35
- }
36
- export type PreparedTransaction = PolymarketWalletPreparedTransaction | RawPreparedTransaction | UserOpPreparedTransaction | HypercorePreparedTransaction;
37
- export interface WithdrawalQuoteFee {
38
- amount: string;
39
- currency: SlimCurrencyWithPopulatedBlockchain | null;
40
- }
41
- export interface QuoteSummary {
42
- sourceToken: string;
43
- sourceAmount: string;
44
- destinationToken: string;
45
- destinationAmount: string;
46
- destinationAmountMin: string;
47
- maxSlippageBps: number;
48
- estimatedPriceImpact?: number;
49
- bridgeFee: WithdrawalQuoteFee;
50
- applicationFee: WithdrawalQuoteFee;
51
- protocolFee: WithdrawalQuoteFee;
52
- totalFee: WithdrawalQuoteFee;
53
- expiresAt: string;
54
- }
55
- export interface QuoteResponse {
56
- withdrawalDetailId: string;
57
- token: string;
58
- prepared: PreparedTransaction;
59
- summary: QuoteSummary;
60
- }
8
+ export type { HypercorePreparedTransaction, PolymarketWalletPreparedTransaction, PreparedTransaction, PreparedWithdrawalEntity as QuoteResponse, PreparedWithdrawalSummaryDto as QuoteSummary, RawPreparedTransaction, UserOpPreparedTransaction, WithdrawalQuoteFeeEntity as WithdrawalQuoteFee, } from '@heliofi/common-fe';
@@ -1,50 +1,34 @@
1
+ import type { PreparedWithdrawalDto, SubmitWithdrawalDto } from '@heliofi/common-fe';
1
2
  /**
2
3
  * Parameters for `POST /withdraw/:withdrawalConfigId/prepare`.
3
4
  *
4
- * Field names mirror the backend `PreparedWithdrawalDto` exactly.
5
- * `withdrawalConfigId` is sent as a URL path segment (not in the body).
5
+ * The request **body** is the backend `PreparedWithdrawalDto` (re-exported from
6
+ * `@heliofi/common-fe`, so it stays in lockstep with backend). `withdrawalConfigId`
7
+ * is added here because it travels in the URL path, not the body — the SDK method
8
+ * strips it before sending.
6
9
  */
7
- export interface CreateWithdrawalDetailParams {
10
+ export type CreateWithdrawalDetailParams = PreparedWithdrawalDto & {
8
11
  /** Merchant withdrawal config ID — used in the URL path. */
9
12
  withdrawalConfigId: string;
10
- /** Owner address of the source wallet (lane-specific format). */
11
- ownerAddress: string;
12
- /** Destination address to receive the withdrawn funds. */
13
- recipient: string;
14
- /** Amount in atomic units (no decimals), serialised as a string. */
15
- amount: string;
16
- /** Destination currency ID (MongoDB ObjectId). */
17
- toCurrencyId: string;
18
- /** Source currency ID (MongoDB ObjectId). */
19
- sourceCurrencyId: string;
20
- /**
21
- * Merchant-owned identifier for the customer initiating the withdrawal.
22
- * Opaque to the API — persisted on the withdrawal detail and echoed back in
23
- * withdrawal webhooks. Optional (max 255 chars server-side).
24
- */
25
- customerId?: string;
26
- }
27
- export interface UpdateWithdrawalDetailParams {
28
- ownerAddress: string;
29
- recipient: string;
30
- amount: string;
31
- toCurrencyId: string;
32
- sourceCurrencyId: string;
33
- }
13
+ };
34
14
  /**
35
15
  * Parameters for `POST /withdraw/:withdrawalDetailId/submit`.
36
16
  *
37
- * Field names mirror the backend `SubmitWithdrawalDto`.
17
+ * The request **body** is the backend `SubmitWithdrawalDto`; `withdrawalDetailId`
18
+ * travels in the URL path and is stripped before sending.
38
19
  */
39
- export interface SubmitWithdrawalParams {
20
+ export type SubmitWithdrawalParams = SubmitWithdrawalDto & {
40
21
  /** Per-request WithdrawalDetail ID (returned by prepare in JWT claims). */
41
22
  withdrawalDetailId: string;
42
- /** JWT token from the prepare response. */
43
- token: string;
44
- /**
45
- * The client's signed payload, interpreted server-side by the strategy the
46
- * WithdrawalConfig resolves: an EIP-712 signature for polymarket, a base64
47
- * signed tx for raw. Mirrors the backend `SubmitWithdrawalDto.signedTx: string`.
48
- */
49
- signedTx: string;
23
+ };
24
+ /**
25
+ * Forward-compat stub for a PATCH prepare endpoint the backend has no handler
26
+ * for yet. SDK-local — no backend DTO to re-export.
27
+ */
28
+ export interface UpdateWithdrawalDetailParams {
29
+ ownerAddress: string;
30
+ recipient: string;
31
+ amount: string;
32
+ toCurrencyId: string;
33
+ sourceCurrencyId: string;
50
34
  }
@@ -1,142 +1,23 @@
1
- import type { MinSupportedVersions } from '../versionSupport';
2
- import type { BlockchainEngineType, BlockchainSymbol, BroadcastAck, Platform, WithdrawalFeature, WithdrawalState } from './enums';
3
- export interface WithdrawalCurrenciesExchangeRate {
4
- minimalUnitRate: string;
5
- decimalRate: string;
6
- fromCurrencyId: string;
7
- fromCurrencySymbol: string;
8
- fromBlockchainSymbol: BlockchainSymbol;
9
- toCurrencyId: string;
10
- toCurrencySymbol: string;
11
- }
1
+ import type { BroadcastAck, WithdrawalState } from './enums';
12
2
  /**
13
- * Copied theming subset of the backend `CustomTheme` entity
14
- * (packages/common/.../theme/entities/CustomTheme.entity.ts). The persisted
15
- * sub-document is declared `_id: false`, so the wire shape is exactly these
16
- * fields.
3
+ * Backend source-of-truth response types, re-exported from `@heliofi/common-fe`.
4
+ *
5
+ * These were previously hand-copied into this file; they are now imported so the
6
+ * backend `@heliofi/common` stays canonical (change a DTO/entity → publish a new
7
+ * `@heliofi/common-fe` → bump it here). The re-exports are aliased to the public
8
+ * names this SDK has always exposed.
9
+ *
10
+ * `export type` keeps this dependency-light: only types cross the boundary — no
11
+ * `class-validator` / `reflect-metadata` runtime, and no heavy blockchain deps.
17
12
  */
18
- export interface CustomTheme {
19
- primaryColor: string;
20
- neutralColor: string;
21
- textColorOnButton: 'WHITE' | 'BLACK';
22
- themeMode: 'LIGHT' | 'DARK';
23
- backgroundColor?: string;
24
- }
13
+ export type { BaseBlockchain, Blockchain as PopulatedBlockchain, BlockchainEngine, PublicWithdrawalConfigEntity as WithdrawalConfig, SlimCurrencyWithBlockchain, SlimCurrencyWithPopulatedBlockchain, SubmitWithdrawalEntity as SubmitResponse, WalletCurrencyBalance, WithdrawalBalancesResponse as BalanceResponse, WithdrawalCurrenciesExchangeRate, WithdrawalCustomerSwapRoute, WithdrawalCustomerSwapRoutesResponse as RoutesResponse, } from '@heliofi/common-fe';
25
14
  /**
26
- * The owning merchant company. The backend returns a full public `BaseCompany`
27
- * (via CompanyTransformer.publicAccess), but the widget only needs `customTheme`
28
- * for theming, so this is an intentional subset — the full backend shape is a
29
- * strict superset, so adding fields later is non-breaking.
15
+ * Status of a withdrawal detail — `GET /withdraw-details/:id`.
16
+ *
17
+ * Kept local on purpose: this is the shape produced by
18
+ * `WithdrawalDetailTransformer.simple`, which has **no exported backend entity**
19
+ * to re-export, so the SDK is the source of truth for this one type.
30
20
  */
31
- export interface WithdrawalConfigCompany {
32
- customTheme?: CustomTheme;
33
- }
34
- export interface WithdrawalConfig {
35
- id: string;
36
- name: string;
37
- platform: Platform;
38
- disabled: boolean;
39
- disabledBlockchainSymbols: BlockchainSymbol[];
40
- enabledFeatures: WithdrawalFeature[];
41
- /** ISO 8601 timestamp. */
42
- createdAt: string;
43
- /** ISO 8601 timestamp. */
44
- updatedAt: string;
45
- fromCurrencies: SlimCurrencyWithPopulatedBlockchain[];
46
- exchangeRates: WithdrawalCurrenciesExchangeRate[];
47
- minSupportedVersions?: MinSupportedVersions;
48
- /**
49
- * Owning company, always populated on the public endpoint. Read
50
- * `company.customTheme` to theme the widget (parity with deposit/paylink).
51
- */
52
- company: WithdrawalConfigCompany;
53
- }
54
- export interface BaseBlockchain {
55
- id: string;
56
- symbol: string;
57
- displayName: string;
58
- iconUrl?: string;
59
- iconUrlFull?: string;
60
- }
61
- /**
62
- * The blockchain engine (EVM / SOL / BTC / …) that owns the
63
- * address-validation regex. Mirrors the backend `BlockchainEngine` entity.
64
- */
65
- export interface BlockchainEngine {
66
- id: string;
67
- type: BlockchainEngineType;
68
- /**
69
- * Network-aware (testnet vs mainnet) source string for an address-validation
70
- * regex, e.g. `^[1-9A-HJ-NP-Za-km-z]{32,44}$` for SOL. Present on the
71
- * withdrawal `/routes` and `/public` responses; may be absent for engines
72
- * without a configured regex.
73
- */
74
- addressRegex?: string;
75
- }
76
- /**
77
- * A blockchain guaranteed to have its `engine` populated (with the engine's
78
- * address-validation regex). Mirrors the backend `Blockchain` entity. Used by
79
- * the withdrawal `/routes` and `/public` responses.
80
- */
81
- export interface PopulatedBlockchain extends BaseBlockchain {
82
- engine: BlockchainEngine;
83
- }
84
- export interface SlimCurrencyWithBlockchain {
85
- id: string;
86
- symbol: string;
87
- name: string;
88
- mintAddress: string;
89
- decimals: number;
90
- iconUrlFull?: string;
91
- blockchain: BaseBlockchain;
92
- }
93
- /**
94
- * `SlimCurrencyWithBlockchain` whose blockchain is guaranteed populated with its
95
- * engine (and the engine's address regex). Mirrors the backend
96
- * `SlimCurrencyWithPopulatedBlockchain` entity — the type of `fromCurrencies`
97
- * on the withdrawal `/routes` and `/public` responses.
98
- */
99
- export type SlimCurrencyWithPopulatedBlockchain = Omit<SlimCurrencyWithBlockchain, 'blockchain'> & {
100
- blockchain: PopulatedBlockchain;
101
- };
102
- export interface WithdrawalCustomerSwapRoute {
103
- id: string;
104
- fromCurrencyId: string;
105
- toCurrency: SlimCurrencyWithPopulatedBlockchain;
106
- available: boolean;
107
- minimumAmountMinimalUnit: string | null;
108
- minimumAmountUsd: string;
109
- }
110
- export interface RoutesResponse {
111
- /** Source currencies available under the merchant's config. */
112
- fromCurrencies: SlimCurrencyWithPopulatedBlockchain[];
113
- routes: WithdrawalCustomerSwapRoute[];
114
- }
115
- export interface WalletCurrencyBalance {
116
- currencyId: string;
117
- symbol: string;
118
- mintAddress: string;
119
- /** Minimal units. */
120
- balance: string | null;
121
- uiBalance: string | null;
122
- maxWithdrawableAmount: string | null;
123
- uiMaxWithdrawableAmount: string | null;
124
- }
125
- export interface BalanceResponse {
126
- walletAddress: string;
127
- balances: WalletCurrencyBalance[];
128
- }
129
- export interface SubmitResponse {
130
- withdrawalDetailId: string;
131
- /**
132
- * Relayer/transaction hash; `null` only when the broadcast was rejected
133
- * before producing a hash.
134
- */
135
- txHash: string | null;
136
- state: WithdrawalState;
137
- /** `null` when no broadcast was attempted (defensive idempotent return). */
138
- broadcastAck: BroadcastAck | null;
139
- }
140
21
  export interface StatusResponse {
141
22
  withdrawalDetailId: string;
142
23
  state: WithdrawalState;
@@ -145,8 +26,7 @@ export interface StatusResponse {
145
26
  errorReason: string | null;
146
27
  /**
147
28
  * Merchant-owned identifier supplied at prepare; `null` when none was set.
148
- * Mirrors `WithdrawalDetailTransformer.simple` (the backend source of truth
149
- * for this response).
29
+ * Mirrors `WithdrawalDetailTransformer.simple`.
150
30
  */
151
31
  customerId: string | null;
152
32
  }
@@ -1 +1 @@
1
- "use strict";var U=Object.defineProperty;var m=(e,t,r)=>t in e?U(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var D=(e,t,r)=>m(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let S=(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.TON="TON",e})({}),C=(function(e){return e.EVM="EVM",e.SOL="SOL",e.BTC="BTC",e.TRON="TRON",e.HYPERCORE="HYPERCORE",e.DOGE="DOGE",e.TON="TON",e})({}),H=(function(e){return e.HELIO="HELIO",e.MAGIC_EDEN="MAGIC_EDEN",e})({}),P=(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})({}),d=(function(e){return e.ACKNOWLEDGED="acknowledged",e.UNACKNOWLEDGED="unacknowledged",e.REJECTED="rejected",e})({}),w=(function(e){return e.RAW="raw",e.USER_OP="userop",e.POLYMARKET_WALLET="polymarket_wallet",e.HYPERCORE="hypercore",e})({});const X=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 M=new Set(Object.values(I));class O extends Error{constructor(r,s,n){super(n??s);D(this,"name","WithdrawalApiError");this.status=r,this.code=s,this.detail=n}}const l=e=>e&&M.has(e)?e:I.UNKNOWN,p=e=>{const t=e.split(".");if(t.length!==3)throw new Error("Invalid JWT: expected 3 parts");const r=atob(t[1].replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(r)},g=(e,t=5e3)=>{const{exp:r}=p(e);return r===void 0?!1:Date.now()>=r*1e3-t},R="1.3.4",W="https://api.hel.io/v1";class B{constructor(t){D(this,"baseUrl");D(this,"headers");D(this,"fetch");D(this,"consumer");var s,n;this.consumer=t.consumer;const r=t.baseUrl??W;this.baseUrl=r.endsWith("/")?r.slice(0,-1):r,this.headers={"Content-Type":"application/json","X-MoonPay-Commerce-SDK-Version":R,...(s=this.consumer)!=null&&s.name?{"X-MoonPay-Commerce-Consumer":this.consumer.name}:{},...(n=this.consumer)!=null&&n.version?{"X-MoonPay-Commerce-Consumer-Version":this.consumer.version}:{},...t.headers},this.fetch=t.fetch??globalThis.fetch.bind(globalThis)}async get(t,r){return this.request("GET",t,void 0,r)}async post(t,r,s){return this.request("POST",t,r,s)}async patch(t,r,s){return this.request("PATCH",t,r,s)}async request(t,r,s,n){const i=`${this.baseUrl}${r}`,E=await this.fetch(i,{method:t,headers:this.headers,body:s!==void 0?JSON.stringify(s):void 0,signal:n});if(!E.ok)throw await this.buildError(E);return await E.json()}async buildError(t){let r,s;try{const n=await t.json();r=n.message??void 0,s=n.errorCode??n.errorType??void 0}catch{r=t.statusText||void 0}return new O(t.status,l(s),r)}}const A=e=>/^\d+$/.test(e);function N(e){if(typeof e!="string")return null;let t=e.trim();if((t.startsWith("v")||t.startsWith("V"))&&(t=t.slice(1)),t==="")return null;const r=t.indexOf("+");r!==-1&&(t=t.slice(0,r));const s=t.indexOf("-"),n=s===-1?t:t.slice(0,s),i=s===-1?"":t.slice(s+1),E=n.split(".");if(E.length>3)return null;const o=[];for(const c of E){if(!A(c))return null;o.push(Number(c))}const u=i===""?[]:i.split(".").filter(c=>c!=="");return s!==-1&&u.length===0?null:{major:o[0]??0,minor:o[1]??0,patch:o[2]??0,prerelease:u}}function _(e,t){return e<t?-1:e>t?1:0}function F(e,t){if(e.length===0&&t.length===0)return 0;if(e.length===0)return 1;if(t.length===0)return-1;const r=Math.min(e.length,t.length);for(let s=0;s<r;s++){const n=e[s],i=t[s];if(n===i)continue;const E=A(n),o=A(i);if(E&&o){const u=_(Number(n),Number(i));if(u!==0)return u}else return E?-1:o?1:n<i?-1:1}return _(e.length,t.length)}function G(e,t){const r=N(e)??{major:0,minor:0,patch:0,prerelease:[]},s=N(t)??{major:0,minor:0,patch:0,prerelease:[]},n=_(r.major,s.major)||_(r.minor,s.minor)||_(r.patch,s.patch);return n!==0?n:F(r.prerelease,s.prerelease)}function L(e,t){return G(e,t)<0}const f="@heliofi/withdraw-core";function h(e={}){const{minSupportedVersions:t,consumer:r}=e,s=(t==null?void 0:t.packages)??{},n=e.sdkVersion??R,i={[f]:n};r!=null&&r.name&&r.version!=null&&(i[r.name]=r.version);for(const[E,o]of Object.entries(s)){const u=i[E];if(u!=null&&L(u,o))return!1}return!0}class a{constructor(t){this.api=t}static create(t={}){return new a(new B(t))}isSupported(t){return h({minSupportedVersions:t,consumer:this.api.consumer})}async getWithdrawalConfig(t,r){return this.api.get(`/withdrawal-configs/${t}/public`,r)}async getRoutes(t,r){return this.api.get(`/withdraw/${t}/routes`,r)}async getBalance(t,r,s){return this.api.get(`/withdraw/${t}/balances?walletAddress=${encodeURIComponent(r)}`,s)}async createWithdrawalDetail(t,r){const{withdrawalConfigId:s,...n}=t;return this.api.post(`/withdraw/${s}/prepare`,n,r)}async updateWithdrawalDetail(t,r,s){return this.api.patch(`/withdraw-details/${t}`,r,s)}async submitWithdrawal(t,r){const{withdrawalDetailId:s,...n}=t;return this.api.post(`/withdraw/${s}/submit`,n,r)}async getWithdrawalDetail(t,r){return this.api.get(`/withdraw-details/${t}`,r)}}exports.BlockchainEngineType=C;exports.BlockchainSymbol=S;exports.BroadcastAck=d;exports.DEFAULT_BASE_URL=W;exports.Platform=H;exports.SDK_PACKAGE_NAME=f;exports.SDK_VERSION=R;exports.SignedTransactionKind=w;exports.TERMINAL_STATES=X;exports.WithdrawalApiError=O;exports.WithdrawalErrorCode=I;exports.WithdrawalFeature=P;exports.WithdrawalSDK=a;exports.WithdrawalState=T;exports.decodeJwt=p;exports.isBelow=L;exports.isQuoteExpired=g;exports.isSupported=h;exports.toWithdrawalErrorCode=l;
1
+ "use strict";var U=Object.defineProperty;var m=(e,t,r)=>t in e?U(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var D=(e,t,r)=>m(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let S=(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.TON="TON",e})({}),C=(function(e){return e.EVM="EVM",e.SOL="SOL",e.BTC="BTC",e.TRON="TRON",e.HYPERCORE="HYPERCORE",e.DOGE="DOGE",e.TON="TON",e})({}),H=(function(e){return e.HELIO="HELIO",e.MAGIC_EDEN="MAGIC_EDEN",e})({}),P=(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})({}),d=(function(e){return e.ACKNOWLEDGED="acknowledged",e.UNACKNOWLEDGED="unacknowledged",e.REJECTED="rejected",e})({}),w=(function(e){return e.RAW="raw",e.USER_OP="userop",e.POLYMARKET_WALLET="polymarket_wallet",e.HYPERCORE="hypercore",e})({});const X=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 M=new Set(Object.values(I));class O extends Error{constructor(r,s,n){super(n??s);D(this,"name","WithdrawalApiError");this.status=r,this.code=s,this.detail=n}}const l=e=>e&&M.has(e)?e:I.UNKNOWN,p=e=>{const t=e.split(".");if(t.length!==3)throw new Error("Invalid JWT: expected 3 parts");const r=atob(t[1].replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(r)},g=(e,t=5e3)=>{const{exp:r}=p(e);return r===void 0?!1:Date.now()>=r*1e3-t},R="1.3.6-alpha.1784815902",W="https://api.hel.io/v1";class B{constructor(t){D(this,"baseUrl");D(this,"headers");D(this,"fetch");D(this,"consumer");var s,n;this.consumer=t.consumer;const r=t.baseUrl??W;this.baseUrl=r.endsWith("/")?r.slice(0,-1):r,this.headers={"Content-Type":"application/json","X-MoonPay-Commerce-SDK-Version":R,...(s=this.consumer)!=null&&s.name?{"X-MoonPay-Commerce-Consumer":this.consumer.name}:{},...(n=this.consumer)!=null&&n.version?{"X-MoonPay-Commerce-Consumer-Version":this.consumer.version}:{},...t.headers},this.fetch=t.fetch??globalThis.fetch.bind(globalThis)}async get(t,r){return this.request("GET",t,void 0,r)}async post(t,r,s){return this.request("POST",t,r,s)}async patch(t,r,s){return this.request("PATCH",t,r,s)}async request(t,r,s,n){const i=`${this.baseUrl}${r}`,E=await this.fetch(i,{method:t,headers:this.headers,body:s!==void 0?JSON.stringify(s):void 0,signal:n});if(!E.ok)throw await this.buildError(E);return await E.json()}async buildError(t){let r,s;try{const n=await t.json();r=n.message??void 0,s=n.errorCode??n.errorType??void 0}catch{r=t.statusText||void 0}return new O(t.status,l(s),r)}}const A=e=>/^\d+$/.test(e);function N(e){if(typeof e!="string")return null;let t=e.trim();if((t.startsWith("v")||t.startsWith("V"))&&(t=t.slice(1)),t==="")return null;const r=t.indexOf("+");r!==-1&&(t=t.slice(0,r));const s=t.indexOf("-"),n=s===-1?t:t.slice(0,s),i=s===-1?"":t.slice(s+1),E=n.split(".");if(E.length>3)return null;const o=[];for(const c of E){if(!A(c))return null;o.push(Number(c))}const u=i===""?[]:i.split(".").filter(c=>c!=="");return s!==-1&&u.length===0?null:{major:o[0]??0,minor:o[1]??0,patch:o[2]??0,prerelease:u}}function _(e,t){return e<t?-1:e>t?1:0}function F(e,t){if(e.length===0&&t.length===0)return 0;if(e.length===0)return 1;if(t.length===0)return-1;const r=Math.min(e.length,t.length);for(let s=0;s<r;s++){const n=e[s],i=t[s];if(n===i)continue;const E=A(n),o=A(i);if(E&&o){const u=_(Number(n),Number(i));if(u!==0)return u}else return E?-1:o?1:n<i?-1:1}return _(e.length,t.length)}function G(e,t){const r=N(e)??{major:0,minor:0,patch:0,prerelease:[]},s=N(t)??{major:0,minor:0,patch:0,prerelease:[]},n=_(r.major,s.major)||_(r.minor,s.minor)||_(r.patch,s.patch);return n!==0?n:F(r.prerelease,s.prerelease)}function h(e,t){return G(e,t)<0}const L="@heliofi/withdraw-core";function f(e={}){const{minSupportedVersions:t,consumer:r}=e,s=(t==null?void 0:t.packages)??{},n=e.sdkVersion??R,i={[L]:n};r!=null&&r.name&&r.version!=null&&(i[r.name]=r.version);for(const[E,o]of Object.entries(s)){const u=i[E];if(u!=null&&h(u,o))return!1}return!0}class a{constructor(t){this.api=t}static create(t={}){return new a(new B(t))}isSupported(t){return f({minSupportedVersions:t,consumer:this.api.consumer})}async getWithdrawalConfig(t,r){return this.api.get(`/withdrawal-configs/${t}/public`,r)}async getRoutes(t,r){return this.api.get(`/withdraw/${t}/routes`,r)}async getBalance(t,r,s){return this.api.get(`/withdraw/${t}/balances?walletAddress=${encodeURIComponent(r)}`,s)}async createWithdrawalDetail(t,r){const{withdrawalConfigId:s,...n}=t;return this.api.post(`/withdraw/${s}/prepare`,n,r)}async updateWithdrawalDetail(t,r,s){return this.api.patch(`/withdraw-details/${t}`,r,s)}async submitWithdrawal(t,r){const{withdrawalDetailId:s,...n}=t;return this.api.post(`/withdraw/${s}/submit`,n,r)}async getWithdrawalDetail(t,r){return this.api.get(`/withdraw-details/${t}`,r)}}exports.BlockchainEngineType=C;exports.BlockchainSymbol=S;exports.BroadcastAck=d;exports.DEFAULT_BASE_URL=W;exports.Platform=H;exports.SDK_PACKAGE_NAME=L;exports.SDK_VERSION=R;exports.SignedTransactionKind=w;exports.TERMINAL_STATES=X;exports.WithdrawalApiError=O;exports.WithdrawalErrorCode=I;exports.WithdrawalFeature=P;exports.WithdrawalSDK=a;exports.WithdrawalState=T;exports.decodeJwt=p;exports.isBelow=h;exports.isQuoteExpired=g;exports.isSupported=f;exports.toWithdrawalErrorCode=l;
@@ -41,7 +41,7 @@ const f = (e) => e && p.has(e) ? e : R.UNKNOWN, L = (e) => {
41
41
  }, v = (e, t = 5e3) => {
42
42
  const { exp: s } = L(e);
43
43
  return s === void 0 ? !1 : Date.now() >= s * 1e3 - t;
44
- }, O = "1.3.4", h = "https://api.hel.io/v1";
44
+ }, O = "1.3.6-alpha.1784815902", h = "https://api.hel.io/v1";
45
45
  class U {
46
46
  constructor(t) {
47
47
  T(this, "baseUrl");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@heliofi/withdraw-core",
3
3
  "private": false,
4
- "version": "1.3.4",
4
+ "version": "1.3.6-alpha.1784815902",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",
@@ -13,7 +13,6 @@
13
13
  "prepublishOnly": "rm -rf dist && pnpm run build",
14
14
  "test": "vitest run",
15
15
  "test:watch": "vitest",
16
- "test:shape": "bash scripts/shape-check.sh",
17
16
  "typecheck": "tsc -p tsconfig.json --noEmit"
18
17
  },
19
18
  "main": "./dist/withdraw-core.cjs",
@@ -42,6 +41,6 @@
42
41
  "vitest": "3.2.4"
43
42
  },
44
43
  "dependencies": {
45
- "@heliofi/common-fe": "0.2.293"
44
+ "@heliofi/common-fe": "0.2.295-alpha.1784813178"
46
45
  }
47
46
  }