@heliofi/withdraw-core 1.4.1 → 1.5.1
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 +2 -2
- package/dist/index.d.ts +562 -10
- package/dist/withdraw-core.cjs +1 -1
- package/dist/withdraw-core.js +40 -34
- package/package.json +2 -2
- package/dist/errors/WithdrawalApiError.d.ts +0 -9
- package/dist/errors/index.d.ts +0 -1
- package/dist/jwt.d.ts +0 -8
- package/dist/sdk/ApiClient.d.ts +0 -27
- package/dist/sdk/WithdrawalSDK.d.ts +0 -29
- package/dist/sdk/index.d.ts +0 -3
- package/dist/types/enums.d.ts +0 -22
- package/dist/types/index.d.ts +0 -4
- package/dist/types/prepared.d.ts +0 -8
- package/dist/types/requests.d.ts +0 -34
- package/dist/types/responses.d.ts +0 -32
- package/dist/version.d.ts +0 -1
- package/dist/versionSupport/index.d.ts +0 -3
- package/dist/versionSupport/isSupported.d.ts +0 -3
- package/dist/versionSupport/semver.d.ts +0 -1
- package/dist/versionSupport/types.d.ts +0 -11
package/README.md
CHANGED
|
@@ -266,9 +266,9 @@ try {
|
|
|
266
266
|
## Helpers
|
|
267
267
|
|
|
268
268
|
```ts
|
|
269
|
-
import { decodeJwt,
|
|
269
|
+
import { decodeJwt, isQuoteValid, isSupported, isBelow, SDK_VERSION } from '@heliofi/withdraw-core';
|
|
270
270
|
|
|
271
|
-
|
|
271
|
+
isQuoteValid(quote.token); // → true while the quote's JWT is decodable and unexpired (with a small buffer); false if undecodable
|
|
272
272
|
decodeJwt(quote.token); // → { exp, iat, withdrawalDetailId, ... }
|
|
273
273
|
SDK_VERSION; // → this package's version string
|
|
274
274
|
```
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,562 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
declare class ApiClient {
|
|
2
|
+
private readonly baseUrl;
|
|
3
|
+
private readonly headers;
|
|
4
|
+
private readonly fetch;
|
|
5
|
+
readonly consumer?: {
|
|
6
|
+
name?: string;
|
|
7
|
+
version?: string;
|
|
8
|
+
};
|
|
9
|
+
constructor(config: ApiClientConfig);
|
|
10
|
+
get<T>(path: string, signal?: AbortSignal): Promise<T>;
|
|
11
|
+
post<T>(path: string, body: unknown, signal?: AbortSignal): Promise<T>;
|
|
12
|
+
patch<T>(path: string, body: unknown, signal?: AbortSignal): Promise<T>;
|
|
13
|
+
private request;
|
|
14
|
+
private buildError;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export declare interface ApiClientConfig {
|
|
18
|
+
/** API base URL. Defaults to {@link DEFAULT_BASE_URL} (`https://api.hel.io/v1`). */
|
|
19
|
+
baseUrl?: string;
|
|
20
|
+
headers?: Record<string, string>;
|
|
21
|
+
fetch?: typeof globalThis.fetch;
|
|
22
|
+
consumer?: {
|
|
23
|
+
name?: string;
|
|
24
|
+
version?: string;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export declare class BalanceResponse {
|
|
29
|
+
walletAddress: string;
|
|
30
|
+
balances: WalletCurrencyBalance[];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export declare class BaseBlockchain extends Entity {
|
|
34
|
+
id: string;
|
|
35
|
+
name: string;
|
|
36
|
+
displayName: string;
|
|
37
|
+
symbol: BlockchainSymbol;
|
|
38
|
+
iconUrl?: string;
|
|
39
|
+
iconUrlFull?: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
declare class BaseCompany extends Entity {
|
|
43
|
+
id: string;
|
|
44
|
+
name?: string;
|
|
45
|
+
email?: string;
|
|
46
|
+
logoUrl?: string;
|
|
47
|
+
defaultCheckoutImageUrl?: string;
|
|
48
|
+
websiteUrl?: string;
|
|
49
|
+
twitterUsername?: string;
|
|
50
|
+
discordUsername?: string;
|
|
51
|
+
address?: string;
|
|
52
|
+
phoneNumber?: string;
|
|
53
|
+
twitterConfirmed?: boolean;
|
|
54
|
+
escrowFunds?: boolean;
|
|
55
|
+
tradingViewDetails?: string;
|
|
56
|
+
kycVerified?: boolean;
|
|
57
|
+
kybVerified?: boolean;
|
|
58
|
+
isVerificationRequired: boolean;
|
|
59
|
+
moonpayApiKey?: string;
|
|
60
|
+
moonpayIsEnabled?: boolean;
|
|
61
|
+
onramperIsEnabled?: boolean;
|
|
62
|
+
ironIsEnabled?: boolean;
|
|
63
|
+
onrampDirectlyToMerchant?: boolean;
|
|
64
|
+
showWeb3Auth?: boolean;
|
|
65
|
+
customTheme?: CustomTheme;
|
|
66
|
+
defaultThemeId?: string;
|
|
67
|
+
allowDeposit?: boolean;
|
|
68
|
+
enabledRestrictedDepositEngines?: BlockchainEngineType[];
|
|
69
|
+
enabledBetaFeatures: BetaFeature[];
|
|
70
|
+
verifiedEntity?: {
|
|
71
|
+
entityName?: string;
|
|
72
|
+
country?: string;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
declare class BaseCurrency extends Entity {
|
|
77
|
+
id: string;
|
|
78
|
+
symbol: string;
|
|
79
|
+
name: string;
|
|
80
|
+
mintAddress: string;
|
|
81
|
+
coinMarketCapId: number;
|
|
82
|
+
decimals: number;
|
|
83
|
+
minDecimals?: number;
|
|
84
|
+
symbolPrefix?: string;
|
|
85
|
+
order: number;
|
|
86
|
+
type?: CurrencyType;
|
|
87
|
+
features?: CurrencyFeature[];
|
|
88
|
+
iconUrl?: string;
|
|
89
|
+
iconUrlFull?: string;
|
|
90
|
+
orderingType?: OrderingType;
|
|
91
|
+
isNative?: boolean;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
declare enum BetaFeature {
|
|
95
|
+
SWAP = "SWAP",
|
|
96
|
+
MOONPAY_HEADLESS_FRAMES = "MOONPAY_HEADLESS_FRAMES",
|
|
97
|
+
GLIDE_DEPOSITS = "GLIDE_DEPOSITS",
|
|
98
|
+
CHECKOUT_V2 = "checkout_v2",
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export declare class BlockchainEngine extends Entity {
|
|
102
|
+
id: string;
|
|
103
|
+
type: BlockchainEngineType;
|
|
104
|
+
addressRegex?: string;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export declare enum BlockchainEngineType {
|
|
108
|
+
EVM = "EVM",
|
|
109
|
+
SOL = "SOL",
|
|
110
|
+
BTC = "BTC",
|
|
111
|
+
TRON = "TRON",
|
|
112
|
+
HYPERCORE = "HYPERCORE",
|
|
113
|
+
DOGE = "DOGE",
|
|
114
|
+
TON = "TON",
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export declare enum BlockchainSymbol {
|
|
118
|
+
SOL = "SOL",
|
|
119
|
+
ETH = "ETH",
|
|
120
|
+
POLYGON = "POLYGON",
|
|
121
|
+
BASE = "BASE",
|
|
122
|
+
BITCOIN = "BITCOIN",
|
|
123
|
+
ARBITRUM = "ARBITRUM",
|
|
124
|
+
BSC = "BSC",
|
|
125
|
+
TRON = "TRON",
|
|
126
|
+
DOGE = "DOGE",
|
|
127
|
+
TON = "TON",
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export declare enum BroadcastAck {
|
|
131
|
+
ACKNOWLEDGED = "acknowledged",
|
|
132
|
+
UNACKNOWLEDGED = "unacknowledged",
|
|
133
|
+
REJECTED = "rejected",
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Parameters for `POST /withdraw/:withdrawalConfigId/prepare`.
|
|
138
|
+
*
|
|
139
|
+
* The request **body** is the backend `PreparedWithdrawalDto` (re-exported from
|
|
140
|
+
* `@heliofi/common-fe`, so it stays in lockstep with backend). `withdrawalConfigId`
|
|
141
|
+
* is added here because it travels in the URL path, not the body — the SDK method
|
|
142
|
+
* strips it before sending.
|
|
143
|
+
*/
|
|
144
|
+
export declare type CreateWithdrawalDetailParams = PreparedWithdrawalDto & {
|
|
145
|
+
/** Merchant withdrawal config ID — used in the URL path. */
|
|
146
|
+
withdrawalConfigId: string;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
declare class Currency extends BaseCurrency {
|
|
150
|
+
blockchain: PopulatedBlockchain;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
declare enum CurrencyFeature {
|
|
154
|
+
PAYMENT_PRICING = "PAYMENT_PRICING",
|
|
155
|
+
PAYMENT_RECIPIENT = "PAYMENT_RECIPIENT",
|
|
156
|
+
SWAP = "SWAP",
|
|
157
|
+
DEPOSIT_MERCHANT_RECIPIENT = "DEPOSIT_MERCHANT_RECIPIENT",
|
|
158
|
+
DEPOSIT_CUSTOMER_CHECKOUT = "DEPOSIT_CUSTOMER_CHECKOUT",
|
|
159
|
+
DEPOSIT_PAYLINK_CUSTOMER_CHECKOUT = "DEPOSIT_PAYLINK_CUSTOMER_CHECKOUT",
|
|
160
|
+
WITHDRAWAL_SOURCE = "WITHDRAWAL_SOURCE",
|
|
161
|
+
WITHDRAWAL_DESTINATION = "WITHDRAWAL_DESTINATION",
|
|
162
|
+
USD_RATE = "USD_RATE",
|
|
163
|
+
STABLECOIN = "STABLECOIN",
|
|
164
|
+
USD_STABLE = "USD_STABLE",
|
|
165
|
+
NATIVE_TOKEN = "NATIVE_TOKEN",
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
declare enum CurrencyType {
|
|
169
|
+
FIAT = "FIAT",
|
|
170
|
+
DIGITAL = "DIGITAL",
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
declare class CustomTheme extends Entity {
|
|
174
|
+
primaryColor: string;
|
|
175
|
+
neutralColor: string;
|
|
176
|
+
textColorOnButton: TextColor;
|
|
177
|
+
themeMode: ThemeMode;
|
|
178
|
+
backgroundColor?: string;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export declare const decodeJwt: (jwt: string) => WithdrawalJwtPayload;
|
|
182
|
+
|
|
183
|
+
/** Default MoonPay Commerce API base URL, used when `baseUrl` is omitted. */
|
|
184
|
+
export declare const DEFAULT_BASE_URL = "https://api.hel.io/v1";
|
|
185
|
+
|
|
186
|
+
declare enum DepositBlockchainSymbol {
|
|
187
|
+
ABSTRACT = "ABSTRACT",
|
|
188
|
+
HYPERLIQUID = "HYPERLIQUID",
|
|
189
|
+
HYPERCORE = "HYPERCORE",
|
|
190
|
+
PLASMA = "PLASMA",
|
|
191
|
+
MEGAETH = "MEGAETH",
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
declare class Entity {
|
|
195
|
+
static fromObject<T extends Entity>(record: T): T;
|
|
196
|
+
static fromObjects<T extends Entity>(records: T[]): T[];
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
declare enum FIATCurrencies {
|
|
200
|
+
USD = "USD",
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export declare interface HypercorePreparedTransaction {
|
|
204
|
+
kind: SignedTransactionKind.HYPERCORE;
|
|
205
|
+
chain: BlockchainSymbol | DepositBlockchainSymbol;
|
|
206
|
+
typedData: PreparedWithdrawalTypedDataDto;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export declare function isBelow(version: string, minimum: string): boolean;
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Returns whether a quote token is still usable: it decodes and has not passed
|
|
213
|
+
* its expiry (minus a safety buffer). A token with no `exp` claim is treated as
|
|
214
|
+
* non-expiring and therefore valid. An undecodable/malformed token is treated as
|
|
215
|
+
* invalid (`false`) so callers re-quote instead of crashing.
|
|
216
|
+
*
|
|
217
|
+
* Note: this only checks decodability and expiry — it does NOT verify the JWT
|
|
218
|
+
* signature.
|
|
219
|
+
*/
|
|
220
|
+
export declare const isQuoteValid: (jwt: string, bufferMs?: number) => boolean;
|
|
221
|
+
|
|
222
|
+
export declare function isSupported(input?: IsSupportedInput): boolean;
|
|
223
|
+
|
|
224
|
+
export declare interface IsSupportedInput {
|
|
225
|
+
minSupportedVersions?: MinSupportedVersions | null;
|
|
226
|
+
sdkVersion?: string;
|
|
227
|
+
consumer?: {
|
|
228
|
+
name?: string;
|
|
229
|
+
version?: string;
|
|
230
|
+
} | null;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export declare interface MinSupportedVersions {
|
|
234
|
+
packages?: Record<string, string>;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
declare enum OrderingType {
|
|
238
|
+
ALPHABETICAL = "ALPHABETICAL",
|
|
239
|
+
NUMERIC = "NUMERIC",
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export declare enum Platform {
|
|
243
|
+
HELIO = "HELIO",
|
|
244
|
+
MAGIC_EDEN = "MAGIC_EDEN",
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export declare interface PolymarketWalletPreparedTransaction {
|
|
248
|
+
kind: SignedTransactionKind.POLYMARKET_WALLET;
|
|
249
|
+
typedData: PreparedWithdrawalTypedDataDto;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export declare class PopulatedBlockchain extends BaseBlockchain {
|
|
253
|
+
engine: BlockchainEngine;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export declare type PreparedTransaction = PolymarketWalletPreparedTransaction | RawPreparedTransaction | UserOpPreparedTransaction | HypercorePreparedTransaction;
|
|
257
|
+
|
|
258
|
+
declare class PreparedWithdrawalDto {
|
|
259
|
+
ownerAddress: string;
|
|
260
|
+
recipient: string;
|
|
261
|
+
amount: string;
|
|
262
|
+
toCurrencyId: string;
|
|
263
|
+
sourceCurrencyId: string;
|
|
264
|
+
customerId?: string;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
declare class PreparedWithdrawalTypedDataDomainDto {
|
|
268
|
+
name: string;
|
|
269
|
+
version: string;
|
|
270
|
+
chainId: number;
|
|
271
|
+
verifyingContract: string;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
declare class PreparedWithdrawalTypedDataDto {
|
|
275
|
+
domain: PreparedWithdrawalTypedDataDomainDto;
|
|
276
|
+
types: Record<string, PreparedWithdrawalTypedDataFieldDto[]>;
|
|
277
|
+
primaryType: string;
|
|
278
|
+
message: Record<string, unknown>;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
declare class PreparedWithdrawalTypedDataFieldDto {
|
|
282
|
+
name: string;
|
|
283
|
+
type: string;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
export declare class QuoteResponse extends Entity {
|
|
287
|
+
withdrawalDetailId: string;
|
|
288
|
+
token: string;
|
|
289
|
+
prepared: PreparedTransaction;
|
|
290
|
+
summary: QuoteSummary;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export declare class QuoteSummary {
|
|
294
|
+
sourceToken: string;
|
|
295
|
+
sourceAmount: string;
|
|
296
|
+
destinationToken: string;
|
|
297
|
+
destinationAmount: string;
|
|
298
|
+
destinationAmountMin: string;
|
|
299
|
+
destinationAmountUsd?: string;
|
|
300
|
+
destinationAmountMinUsd?: string;
|
|
301
|
+
maxSlippageBps: number;
|
|
302
|
+
estimatedPriceImpact?: number;
|
|
303
|
+
bridgeFee: WithdrawalQuoteFee;
|
|
304
|
+
applicationFee: WithdrawalQuoteFee;
|
|
305
|
+
protocolFee: WithdrawalQuoteFee;
|
|
306
|
+
totalFee: WithdrawalQuoteFee;
|
|
307
|
+
expiresAt: string;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
export declare interface RawPreparedTransaction {
|
|
311
|
+
kind: SignedTransactionKind.RAW;
|
|
312
|
+
chain: BlockchainSymbol | DepositBlockchainSymbol;
|
|
313
|
+
unsignedTx: string;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export declare class RoutesResponse {
|
|
317
|
+
fromCurrencies: SlimCurrencyWithPopulatedBlockchain[];
|
|
318
|
+
routes: WithdrawalCustomerSwapRoute[];
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
export declare const SDK_PACKAGE_NAME = "@heliofi/withdraw-core";
|
|
322
|
+
|
|
323
|
+
export declare const SDK_VERSION: string;
|
|
324
|
+
|
|
325
|
+
export declare enum SignedTransactionKind {
|
|
326
|
+
RAW = "raw",
|
|
327
|
+
USER_OP = "userop",
|
|
328
|
+
POLYMARKET_WALLET = "polymarket_wallet",
|
|
329
|
+
HYPERCORE = "hypercore",
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
export declare type SlimCurrencyWithBlockchain = Omit<BaseCurrency, 'order' | 'orderingType' | 'features' | 'minDecimals' | 'iconUrl'> & {
|
|
333
|
+
blockchain: BaseBlockchain;
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
export declare type SlimCurrencyWithPopulatedBlockchain = Omit<SlimCurrencyWithBlockchain, 'blockchain'> & {
|
|
337
|
+
blockchain: PopulatedBlockchain;
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Status of a withdrawal detail — `GET /withdraw-details/:id`.
|
|
342
|
+
*
|
|
343
|
+
* Kept local on purpose: this is the shape produced by
|
|
344
|
+
* `WithdrawalDetailTransformer.simple`, which has **no exported backend entity**
|
|
345
|
+
* to re-export, so the SDK is the source of truth for this one type.
|
|
346
|
+
*/
|
|
347
|
+
export declare interface StatusResponse {
|
|
348
|
+
withdrawalDetailId: string;
|
|
349
|
+
state: WithdrawalState;
|
|
350
|
+
txHash: string | null;
|
|
351
|
+
broadcastAck: BroadcastAck | null;
|
|
352
|
+
errorReason: string | null;
|
|
353
|
+
/**
|
|
354
|
+
* Merchant-owned identifier supplied at prepare; `null` when none was set.
|
|
355
|
+
* Mirrors `WithdrawalDetailTransformer.simple`.
|
|
356
|
+
*/
|
|
357
|
+
customerId: string | null;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
export declare class SubmitResponse extends Entity {
|
|
361
|
+
withdrawalDetailId: string;
|
|
362
|
+
txHash: string | null;
|
|
363
|
+
state: WithdrawalState;
|
|
364
|
+
broadcastAck: BroadcastAck | null;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
declare class SubmitWithdrawalDto {
|
|
368
|
+
token: string;
|
|
369
|
+
signedTx: string;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* Parameters for `POST /withdraw/:withdrawalDetailId/submit`.
|
|
374
|
+
*
|
|
375
|
+
* The request **body** is the backend `SubmitWithdrawalDto`; `withdrawalDetailId`
|
|
376
|
+
* travels in the URL path and is stripped before sending.
|
|
377
|
+
*/
|
|
378
|
+
export declare type SubmitWithdrawalParams = SubmitWithdrawalDto & {
|
|
379
|
+
/** Per-request WithdrawalDetail ID (returned by prepare in JWT claims). */
|
|
380
|
+
withdrawalDetailId: string;
|
|
381
|
+
};
|
|
382
|
+
|
|
383
|
+
export declare const TERMINAL_STATES: ReadonlySet<WithdrawalState>;
|
|
384
|
+
|
|
385
|
+
declare enum TextColor {
|
|
386
|
+
WHITE = "WHITE",
|
|
387
|
+
BLACK = "BLACK",
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
declare enum ThemeMode {
|
|
391
|
+
LIGHT = "LIGHT",
|
|
392
|
+
DARK = "DARK",
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
export declare const toWithdrawalErrorCode: (raw: string | undefined) => WithdrawalErrorCode;
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* Parameters for `PATCH /withdraw-details/:withdrawalDetailId` (re-quote).
|
|
399
|
+
*
|
|
400
|
+
* The request **body** is the backend `PreparedWithdrawalDto` (re-exported from
|
|
401
|
+
* `@heliofi/common-fe`) — the same shape as prepare, so a re-quote stays in
|
|
402
|
+
* lockstep with backend. `withdrawalDetailId` travels in the URL path and is a
|
|
403
|
+
* separate argument on the SDK method, not part of the body.
|
|
404
|
+
*
|
|
405
|
+
* The backend handler is live: `WithdrawalDetailController.requote`
|
|
406
|
+
* (`@Patch(':id')`) maps `ownerAddress`, `recipient`, `amount`, `toCurrencyId`,
|
|
407
|
+
* `sourceCurrencyId` and `slippageBps`.
|
|
408
|
+
*/
|
|
409
|
+
export declare type UpdateWithdrawalDetailParams = PreparedWithdrawalDto;
|
|
410
|
+
|
|
411
|
+
export declare interface UserOpPreparedTransaction {
|
|
412
|
+
kind: SignedTransactionKind.USER_OP;
|
|
413
|
+
chain: BlockchainSymbol;
|
|
414
|
+
userOp: Record<string, unknown>;
|
|
415
|
+
entryPoint: string;
|
|
416
|
+
authorization?: {
|
|
417
|
+
chainId: string;
|
|
418
|
+
address: string;
|
|
419
|
+
nonce: string;
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
export declare class WalletCurrencyBalance {
|
|
424
|
+
currencyId: string;
|
|
425
|
+
symbol: string;
|
|
426
|
+
mintAddress: string;
|
|
427
|
+
balance: string | null;
|
|
428
|
+
uiBalance: string | null;
|
|
429
|
+
maxWithdrawableAmount: string | null;
|
|
430
|
+
uiMaxWithdrawableAmount: string | null;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
export declare class WithdrawalApiError extends Error {
|
|
434
|
+
readonly status: number;
|
|
435
|
+
readonly code: WithdrawalErrorCode;
|
|
436
|
+
readonly detail?: string | undefined;
|
|
437
|
+
readonly name = "WithdrawalApiError";
|
|
438
|
+
constructor(status: number, code: WithdrawalErrorCode, detail?: string | undefined);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
export declare class WithdrawalConfig extends WithdrawalConfigEntity {
|
|
442
|
+
fromCurrencies: SlimCurrencyWithPopulatedBlockchain[];
|
|
443
|
+
exchangeRates: WithdrawalCurrenciesExchangeRate[];
|
|
444
|
+
minSupportedVersions: WithdrawalMinSupportedVersions;
|
|
445
|
+
company: BaseCompany;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
declare class WithdrawalConfigEntity extends Entity {
|
|
449
|
+
id: string;
|
|
450
|
+
name: string;
|
|
451
|
+
platform: Platform;
|
|
452
|
+
disabled: boolean;
|
|
453
|
+
disabledAt: string | null;
|
|
454
|
+
disabledBlockchainSymbols: BlockchainSymbol[];
|
|
455
|
+
enabledFeatures: WithdrawalFeature[];
|
|
456
|
+
createdAt: string;
|
|
457
|
+
updatedAt: string;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
export declare class WithdrawalCurrenciesExchangeRate extends Entity {
|
|
461
|
+
minimalUnitRate: bigint;
|
|
462
|
+
decimalRate: string;
|
|
463
|
+
fromCurrencyId: string;
|
|
464
|
+
toCurrencyId: string;
|
|
465
|
+
fromCurrencySymbol: string;
|
|
466
|
+
fromBlockchainSymbol: BlockchainSymbol;
|
|
467
|
+
toCurrencySymbol: FIATCurrencies;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
export declare class WithdrawalCustomerSwapRoute {
|
|
471
|
+
id: string;
|
|
472
|
+
fromCurrencyId: string;
|
|
473
|
+
toCurrency: SlimCurrencyWithPopulatedBlockchain;
|
|
474
|
+
available: boolean;
|
|
475
|
+
minimumAmountMinimalUnit: string | null;
|
|
476
|
+
minimumAmountUsd: string;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
export declare enum WithdrawalErrorCode {
|
|
480
|
+
WITHDRAW_TX_INVALID_SIGNATURE = "WITHDRAW_TX_INVALID_SIGNATURE",
|
|
481
|
+
WITHDRAW_TX_BLOCKHASH_EXPIRED = "WITHDRAW_TX_BLOCKHASH_EXPIRED",
|
|
482
|
+
WITHDRAW_TX_NONCE_TOO_LOW = "WITHDRAW_TX_NONCE_TOO_LOW",
|
|
483
|
+
WITHDRAW_TX_USEROP_EXPIRED = "WITHDRAW_TX_USEROP_EXPIRED",
|
|
484
|
+
WITHDRAW_TX_UNDERPRICED = "WITHDRAW_TX_UNDERPRICED",
|
|
485
|
+
WITHDRAW_BUNDLER_REJECTED = "WITHDRAW_BUNDLER_REJECTED",
|
|
486
|
+
WITHDRAW_TX_BROADCAST_TIMEOUT = "WITHDRAW_TX_BROADCAST_TIMEOUT",
|
|
487
|
+
WITHDRAW_TX_ALREADY_KNOWN = "WITHDRAW_TX_ALREADY_KNOWN",
|
|
488
|
+
WITHDRAW_QUOTE_EXPIRED = "WITHDRAW_QUOTE_EXPIRED",
|
|
489
|
+
WITHDRAW_SANCTIONS_BLOCKED = "WITHDRAW_SANCTIONS_BLOCKED",
|
|
490
|
+
WITHDRAW_NO_ROUTE = "WITHDRAW_NO_ROUTE",
|
|
491
|
+
WITHDRAW_NOT_FOUND = "WITHDRAW_NOT_FOUND",
|
|
492
|
+
WITHDRAW_INSUFFICIENT_BALANCE = "WITHDRAW_INSUFFICIENT_BALANCE",
|
|
493
|
+
WITHDRAW_DETAILS_NOT_UPDATABLE = "WITHDRAW_DETAILS_NOT_UPDATABLE",
|
|
494
|
+
INVALID_WALLET_ADDRESS = "INVALID_WALLET_ADDRESS",
|
|
495
|
+
BALANCE_FETCH_FAILED = "BALANCE_FETCH_FAILED",
|
|
496
|
+
UNKNOWN = "UNKNOWN"
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
export declare enum WithdrawalFeature {
|
|
500
|
+
IRON = "iron",
|
|
501
|
+
MP_SELL = "mp_sell",
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
export declare interface WithdrawalJwtPayload {
|
|
505
|
+
exp?: number;
|
|
506
|
+
iat?: number;
|
|
507
|
+
withdrawalDetailId?: string;
|
|
508
|
+
[key: string]: unknown;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
declare class WithdrawalMinSupportedVersions extends Entity {
|
|
512
|
+
packages: Partial<Record<WithdrawalPackage, string>>;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
declare enum WithdrawalPackage {
|
|
516
|
+
HELIOFI_WITHDRAW_CORE = "@heliofi/withdraw-core",
|
|
517
|
+
HELIOFI_WITHDRAW_REACT = "@heliofi/withdraw-react",
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
export declare class WithdrawalQuoteFee extends Entity {
|
|
521
|
+
amount: string;
|
|
522
|
+
currency: Currency | null;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
export declare class WithdrawalSDK {
|
|
526
|
+
private readonly api;
|
|
527
|
+
constructor(api: ApiClient);
|
|
528
|
+
static create(config?: ApiClientConfig): WithdrawalSDK;
|
|
529
|
+
isSupported(minSupportedVersions?: MinSupportedVersions | null): boolean;
|
|
530
|
+
getWithdrawalConfig(withdrawalConfigId: string, signal?: AbortSignal): Promise<WithdrawalConfig>;
|
|
531
|
+
getRoutes(withdrawalConfigId: string, signal?: AbortSignal): Promise<RoutesResponse>;
|
|
532
|
+
getBalance(withdrawalConfigId: string, walletAddress: string, signal?: AbortSignal): Promise<BalanceResponse>;
|
|
533
|
+
/**
|
|
534
|
+
* Create a withdrawal detail (a priced quote) for a config.
|
|
535
|
+
*
|
|
536
|
+
* Calls `POST /withdraw/:withdrawalConfigId/prepare`.
|
|
537
|
+
* `withdrawalConfigId` goes in the path; the remaining fields are the
|
|
538
|
+
* request body matching the backend `PreparedWithdrawalDto`.
|
|
539
|
+
*/
|
|
540
|
+
createWithdrawalDetail(params: CreateWithdrawalDetailParams, signal?: AbortSignal): Promise<QuoteResponse>;
|
|
541
|
+
updateWithdrawalDetail(withdrawalDetailId: string, params: UpdateWithdrawalDetailParams, signal?: AbortSignal): Promise<QuoteResponse>;
|
|
542
|
+
/**
|
|
543
|
+
* Body matches the backend `SubmitWithdrawalDto`:
|
|
544
|
+
* `{ token, signedTx }`, where `signedTx` is the bare signed payload string.
|
|
545
|
+
*/
|
|
546
|
+
submitWithdrawal(params: SubmitWithdrawalParams, signal?: AbortSignal): Promise<SubmitResponse>;
|
|
547
|
+
getWithdrawalDetail(withdrawalDetailId: string, signal?: AbortSignal): Promise<StatusResponse>;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
export declare enum WithdrawalState {
|
|
551
|
+
QUOTED = "QUOTED",
|
|
552
|
+
SUBMITTING = "SUBMITTING",
|
|
553
|
+
SUBMITTED = "SUBMITTED",
|
|
554
|
+
BRIDGING = "BRIDGING",
|
|
555
|
+
COMPLETED = "COMPLETED",
|
|
556
|
+
FAILED = "FAILED",
|
|
557
|
+
FAILED_EXPIRED = "FAILED_EXPIRED",
|
|
558
|
+
EXPIRED = "EXPIRED",
|
|
559
|
+
REFUNDED_BY_PROVIDER = "REFUNDED_BY_PROVIDER",
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
export { }
|
package/dist/withdraw-core.cjs
CHANGED
|
@@ -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
|
|
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 d=(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})({}),S=(function(e){return e.HELIO="HELIO",e.MAGIC_EDEN="MAGIC_EDEN",e})({}),H=(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})({}),P=(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 A=(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))(A||{});const g=new Set(Object.values(A));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&&g.has(e)?e:A.UNKNOWN,p=e=>{const t=e.split(".");if(t.length!==3)throw new Error("Invalid JWT: expected 3 parts");let r=t[1].replace(/-/g,"+").replace(/_/g,"/");r+="=".repeat((4-r.length%4)%4);const s=Uint8Array.from(atob(r),i=>i.charCodeAt(0)),n=new TextDecoder().decode(s);return JSON.parse(n)},M=(e,t=5e3)=>{try{const{exp:r}=p(e);return r===void 0?!0:Date.now()<r*1e3-t}catch{return!1}},R="1.5.1",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 I=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 _ of E){if(!I(_))return null;o.push(Number(_))}const u=i===""?[]:i.split(".").filter(_=>_!=="");return s!==-1&&u.length===0?null:{major:o[0]??0,minor:o[1]??0,patch:o[2]??0,prerelease:u}}function c(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=I(n),o=I(i);if(E&&o){const u=c(Number(n),Number(i));if(u!==0)return u}else return E?-1:o?1:n<i?-1:1}return c(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=c(r.major,s.major)||c(r.minor,s.minor)||c(r.patch,s.patch);return n!==0?n:F(r.prerelease,s.prerelease)}function h(e,t){return G(e,t)<0}const f="@heliofi/withdraw-core";function L(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&&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 L({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=d;exports.BroadcastAck=P;exports.DEFAULT_BASE_URL=W;exports.Platform=S;exports.SDK_PACKAGE_NAME=f;exports.SDK_VERSION=R;exports.SignedTransactionKind=w;exports.TERMINAL_STATES=X;exports.WithdrawalApiError=O;exports.WithdrawalErrorCode=A;exports.WithdrawalFeature=H;exports.WithdrawalSDK=a;exports.WithdrawalState=T;exports.decodeJwt=p;exports.isBelow=h;exports.isQuoteValid=M;exports.isSupported=L;exports.toWithdrawalErrorCode=l;
|
package/dist/withdraw-core.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
var a = Object.defineProperty;
|
|
2
2
|
var l = (e, t, s) => t in e ? a(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s;
|
|
3
3
|
var T = (e, t, s) => l(e, typeof t != "symbol" ? t + "" : t, s);
|
|
4
|
-
let
|
|
4
|
+
let d = /* @__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.TON = "TON", e;
|
|
6
|
-
})({}),
|
|
6
|
+
})({}), w = /* @__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.TON = "TON", e;
|
|
8
|
-
})({}),
|
|
8
|
+
})({}), M = /* @__PURE__ */ (function(e) {
|
|
9
9
|
return e.HELIO = "HELIO", e.MAGIC_EDEN = "MAGIC_EDEN", e;
|
|
10
10
|
})({}), g = /* @__PURE__ */ (function(e) {
|
|
11
11
|
return e.IRON = "iron", e.MP_SELL = "mp_sell", e;
|
|
@@ -36,12 +36,18 @@ const f = (e) => e && p.has(e) ? e : R.UNKNOWN, L = (e) => {
|
|
|
36
36
|
const t = e.split(".");
|
|
37
37
|
if (t.length !== 3)
|
|
38
38
|
throw new Error("Invalid JWT: expected 3 parts");
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
let s = t[1].replace(/-/g, "+").replace(/_/g, "/");
|
|
40
|
+
s += "=".repeat((4 - s.length % 4) % 4);
|
|
41
|
+
const r = Uint8Array.from(atob(s), (E) => E.charCodeAt(0)), n = new TextDecoder().decode(r);
|
|
42
|
+
return JSON.parse(n);
|
|
41
43
|
}, v = (e, t = 5e3) => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
try {
|
|
45
|
+
const { exp: s } = L(e);
|
|
46
|
+
return s === void 0 ? !0 : Date.now() < s * 1e3 - t;
|
|
47
|
+
} catch {
|
|
48
|
+
return !1;
|
|
49
|
+
}
|
|
50
|
+
}, O = "1.5.1", h = "https://api.hel.io/v1";
|
|
45
51
|
class U {
|
|
46
52
|
constructor(t) {
|
|
47
53
|
T(this, "baseUrl");
|
|
@@ -69,15 +75,15 @@ class U {
|
|
|
69
75
|
return this.request("PATCH", t, s, r);
|
|
70
76
|
}
|
|
71
77
|
async request(t, s, r, n) {
|
|
72
|
-
const E = `${this.baseUrl}${s}`,
|
|
78
|
+
const E = `${this.baseUrl}${s}`, u = await this.fetch(E, {
|
|
73
79
|
method: t,
|
|
74
80
|
headers: this.headers,
|
|
75
81
|
body: r !== void 0 ? JSON.stringify(r) : void 0,
|
|
76
82
|
signal: n
|
|
77
83
|
});
|
|
78
|
-
if (!
|
|
79
|
-
throw await this.buildError(
|
|
80
|
-
return await
|
|
84
|
+
if (!u.ok)
|
|
85
|
+
throw await this.buildError(u);
|
|
86
|
+
return await u.json();
|
|
81
87
|
}
|
|
82
88
|
async buildError(t) {
|
|
83
89
|
let s, r;
|
|
@@ -94,25 +100,25 @@ class U {
|
|
|
94
100
|
);
|
|
95
101
|
}
|
|
96
102
|
}
|
|
97
|
-
const
|
|
103
|
+
const I = (e) => /^\d+$/.test(e);
|
|
98
104
|
function A(e) {
|
|
99
105
|
if (typeof e != "string") return null;
|
|
100
106
|
let t = e.trim();
|
|
101
107
|
if ((t.startsWith("v") || t.startsWith("V")) && (t = t.slice(1)), t === "") return null;
|
|
102
108
|
const s = t.indexOf("+");
|
|
103
109
|
s !== -1 && (t = t.slice(0, s));
|
|
104
|
-
const r = t.indexOf("-"), n = r === -1 ? t : t.slice(0, r), E = r === -1 ? "" : t.slice(r + 1),
|
|
105
|
-
if (
|
|
106
|
-
const
|
|
107
|
-
for (const
|
|
108
|
-
if (!c
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
const D = E === "" ? [] : E.split(".").filter((
|
|
110
|
+
const r = t.indexOf("-"), n = r === -1 ? t : t.slice(0, r), E = r === -1 ? "" : t.slice(r + 1), u = n.split(".");
|
|
111
|
+
if (u.length > 3) return null;
|
|
112
|
+
const i = [];
|
|
113
|
+
for (const c of u) {
|
|
114
|
+
if (!I(c)) return null;
|
|
115
|
+
i.push(Number(c));
|
|
116
|
+
}
|
|
117
|
+
const D = E === "" ? [] : E.split(".").filter((c) => c !== "");
|
|
112
118
|
return r !== -1 && D.length === 0 ? null : {
|
|
113
|
-
major:
|
|
114
|
-
minor:
|
|
115
|
-
patch:
|
|
119
|
+
major: i[0] ?? 0,
|
|
120
|
+
minor: i[1] ?? 0,
|
|
121
|
+
patch: i[2] ?? 0,
|
|
116
122
|
prerelease: D
|
|
117
123
|
};
|
|
118
124
|
}
|
|
@@ -127,11 +133,11 @@ function m(e, t) {
|
|
|
127
133
|
for (let r = 0; r < s; r++) {
|
|
128
134
|
const n = e[r], E = t[r];
|
|
129
135
|
if (n === E) continue;
|
|
130
|
-
const
|
|
131
|
-
if (
|
|
136
|
+
const u = I(n), i = I(E);
|
|
137
|
+
if (u && i) {
|
|
132
138
|
const D = _(Number(n), Number(E));
|
|
133
139
|
if (D !== 0) return D;
|
|
134
|
-
} else return
|
|
140
|
+
} else return u ? -1 : i ? 1 : n < E ? -1 : 1;
|
|
135
141
|
}
|
|
136
142
|
return _(e.length, t.length);
|
|
137
143
|
}
|
|
@@ -146,9 +152,9 @@ const P = "@heliofi/withdraw-core";
|
|
|
146
152
|
function S(e = {}) {
|
|
147
153
|
const { minSupportedVersions: t, consumer: s } = e, r = (t == null ? void 0 : t.packages) ?? {}, n = e.sdkVersion ?? O, E = { [P]: n };
|
|
148
154
|
s != null && s.name && s.version != null && (E[s.name] = s.version);
|
|
149
|
-
for (const [
|
|
150
|
-
const D = E[
|
|
151
|
-
if (D != null && C(D,
|
|
155
|
+
for (const [u, i] of Object.entries(r)) {
|
|
156
|
+
const D = E[u];
|
|
157
|
+
if (D != null && C(D, i)) return !1;
|
|
152
158
|
}
|
|
153
159
|
return !0;
|
|
154
160
|
}
|
|
@@ -223,11 +229,11 @@ class N {
|
|
|
223
229
|
}
|
|
224
230
|
}
|
|
225
231
|
export {
|
|
226
|
-
|
|
227
|
-
|
|
232
|
+
w as BlockchainEngineType,
|
|
233
|
+
d as BlockchainSymbol,
|
|
228
234
|
G as BroadcastAck,
|
|
229
235
|
h as DEFAULT_BASE_URL,
|
|
230
|
-
|
|
236
|
+
M as Platform,
|
|
231
237
|
P as SDK_PACKAGE_NAME,
|
|
232
238
|
O as SDK_VERSION,
|
|
233
239
|
B as SignedTransactionKind,
|
|
@@ -239,7 +245,7 @@ export {
|
|
|
239
245
|
o as WithdrawalState,
|
|
240
246
|
L as decodeJwt,
|
|
241
247
|
C as isBelow,
|
|
242
|
-
v as
|
|
248
|
+
v as isQuoteValid,
|
|
243
249
|
S as isSupported,
|
|
244
250
|
f as toWithdrawalErrorCode
|
|
245
251
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heliofi/withdraw-core",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.5.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "vite",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"engines": {
|
|
30
30
|
"node": ">=18"
|
|
31
31
|
},
|
|
32
|
-
"packageManager": "pnpm@10",
|
|
32
|
+
"packageManager": "pnpm@10.34.5+sha512.a4ee05f2f73658255bd6a89859c065a45c28a57daefae2c893a168ee2b73168c37b91e83e57ea67654ad03f03031746430e8bce38e362e042605fb8abc80192e",
|
|
33
33
|
"files": [
|
|
34
34
|
"dist"
|
|
35
35
|
],
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { WithdrawalErrorCode } from '../types/enums';
|
|
2
|
-
export declare class WithdrawalApiError extends Error {
|
|
3
|
-
readonly status: number;
|
|
4
|
-
readonly code: WithdrawalErrorCode;
|
|
5
|
-
readonly detail?: string | undefined;
|
|
6
|
-
readonly name = "WithdrawalApiError";
|
|
7
|
-
constructor(status: number, code: WithdrawalErrorCode, detail?: string | undefined);
|
|
8
|
-
}
|
|
9
|
-
export declare const toWithdrawalErrorCode: (raw: string | undefined) => WithdrawalErrorCode;
|
package/dist/errors/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { toWithdrawalErrorCode, WithdrawalApiError, } from './WithdrawalApiError';
|
package/dist/jwt.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export interface WithdrawalJwtPayload {
|
|
2
|
-
exp?: number;
|
|
3
|
-
iat?: number;
|
|
4
|
-
withdrawalDetailId?: string;
|
|
5
|
-
[key: string]: unknown;
|
|
6
|
-
}
|
|
7
|
-
export declare const decodeJwt: (jwt: string) => WithdrawalJwtPayload;
|
|
8
|
-
export declare const isQuoteExpired: (jwt: string, bufferMs?: number) => boolean;
|
package/dist/sdk/ApiClient.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/** Default MoonPay Commerce API base URL, used when `baseUrl` is omitted. */
|
|
2
|
-
export declare const DEFAULT_BASE_URL = "https://api.hel.io/v1";
|
|
3
|
-
export interface ApiClientConfig {
|
|
4
|
-
/** API base URL. Defaults to {@link DEFAULT_BASE_URL} (`https://api.hel.io/v1`). */
|
|
5
|
-
baseUrl?: string;
|
|
6
|
-
headers?: Record<string, string>;
|
|
7
|
-
fetch?: typeof globalThis.fetch;
|
|
8
|
-
consumer?: {
|
|
9
|
-
name?: string;
|
|
10
|
-
version?: string;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
export declare class ApiClient {
|
|
14
|
-
private readonly baseUrl;
|
|
15
|
-
private readonly headers;
|
|
16
|
-
private readonly fetch;
|
|
17
|
-
readonly consumer?: {
|
|
18
|
-
name?: string;
|
|
19
|
-
version?: string;
|
|
20
|
-
};
|
|
21
|
-
constructor(config: ApiClientConfig);
|
|
22
|
-
get<T>(path: string, signal?: AbortSignal): Promise<T>;
|
|
23
|
-
post<T>(path: string, body: unknown, signal?: AbortSignal): Promise<T>;
|
|
24
|
-
patch<T>(path: string, body: unknown, signal?: AbortSignal): Promise<T>;
|
|
25
|
-
private request;
|
|
26
|
-
private buildError;
|
|
27
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { QuoteResponse } from '../types/prepared';
|
|
2
|
-
import type { CreateWithdrawalDetailParams, SubmitWithdrawalParams, UpdateWithdrawalDetailParams } from '../types/requests';
|
|
3
|
-
import type { BalanceResponse, RoutesResponse, StatusResponse, SubmitResponse, WithdrawalConfig } from '../types/responses';
|
|
4
|
-
import { type MinSupportedVersions } from '../versionSupport';
|
|
5
|
-
import { ApiClient, type ApiClientConfig } from './ApiClient';
|
|
6
|
-
export declare class WithdrawalSDK {
|
|
7
|
-
private readonly api;
|
|
8
|
-
constructor(api: ApiClient);
|
|
9
|
-
static create(config?: ApiClientConfig): WithdrawalSDK;
|
|
10
|
-
isSupported(minSupportedVersions?: MinSupportedVersions | null): boolean;
|
|
11
|
-
getWithdrawalConfig(withdrawalConfigId: string, signal?: AbortSignal): Promise<WithdrawalConfig>;
|
|
12
|
-
getRoutes(withdrawalConfigId: string, signal?: AbortSignal): Promise<RoutesResponse>;
|
|
13
|
-
getBalance(withdrawalConfigId: string, walletAddress: string, signal?: AbortSignal): Promise<BalanceResponse>;
|
|
14
|
-
/**
|
|
15
|
-
* Create a withdrawal detail (a priced quote) for a config.
|
|
16
|
-
*
|
|
17
|
-
* Calls `POST /withdraw/:withdrawalConfigId/prepare`.
|
|
18
|
-
* `withdrawalConfigId` goes in the path; the remaining fields are the
|
|
19
|
-
* request body matching the backend `PreparedWithdrawalDto`.
|
|
20
|
-
*/
|
|
21
|
-
createWithdrawalDetail(params: CreateWithdrawalDetailParams, signal?: AbortSignal): Promise<QuoteResponse>;
|
|
22
|
-
updateWithdrawalDetail(withdrawalDetailId: string, params: UpdateWithdrawalDetailParams, signal?: AbortSignal): Promise<QuoteResponse>;
|
|
23
|
-
/**
|
|
24
|
-
* Body matches the backend `SubmitWithdrawalDto`:
|
|
25
|
-
* `{ token, signedTx }`, where `signedTx` is the bare signed payload string.
|
|
26
|
-
*/
|
|
27
|
-
submitWithdrawal(params: SubmitWithdrawalParams, signal?: AbortSignal): Promise<SubmitResponse>;
|
|
28
|
-
getWithdrawalDetail(withdrawalDetailId: string, signal?: AbortSignal): Promise<StatusResponse>;
|
|
29
|
-
}
|
package/dist/sdk/index.d.ts
DELETED
package/dist/types/enums.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { BlockchainEngineType, BlockchainSymbol, BroadcastAck, Platform, SignedTransactionKind, WithdrawalFeature, WithdrawalState } from '@heliofi/common-fe';
|
|
2
|
-
export { BlockchainEngineType, BlockchainSymbol, BroadcastAck, Platform, SignedTransactionKind, WithdrawalFeature, WithdrawalState, };
|
|
3
|
-
export declare const TERMINAL_STATES: ReadonlySet<WithdrawalState>;
|
|
4
|
-
export declare enum WithdrawalErrorCode {
|
|
5
|
-
WITHDRAW_TX_INVALID_SIGNATURE = "WITHDRAW_TX_INVALID_SIGNATURE",
|
|
6
|
-
WITHDRAW_TX_BLOCKHASH_EXPIRED = "WITHDRAW_TX_BLOCKHASH_EXPIRED",
|
|
7
|
-
WITHDRAW_TX_NONCE_TOO_LOW = "WITHDRAW_TX_NONCE_TOO_LOW",
|
|
8
|
-
WITHDRAW_TX_USEROP_EXPIRED = "WITHDRAW_TX_USEROP_EXPIRED",
|
|
9
|
-
WITHDRAW_TX_UNDERPRICED = "WITHDRAW_TX_UNDERPRICED",
|
|
10
|
-
WITHDRAW_BUNDLER_REJECTED = "WITHDRAW_BUNDLER_REJECTED",
|
|
11
|
-
WITHDRAW_TX_BROADCAST_TIMEOUT = "WITHDRAW_TX_BROADCAST_TIMEOUT",
|
|
12
|
-
WITHDRAW_TX_ALREADY_KNOWN = "WITHDRAW_TX_ALREADY_KNOWN",
|
|
13
|
-
WITHDRAW_QUOTE_EXPIRED = "WITHDRAW_QUOTE_EXPIRED",
|
|
14
|
-
WITHDRAW_SANCTIONS_BLOCKED = "WITHDRAW_SANCTIONS_BLOCKED",
|
|
15
|
-
WITHDRAW_NO_ROUTE = "WITHDRAW_NO_ROUTE",
|
|
16
|
-
WITHDRAW_NOT_FOUND = "WITHDRAW_NOT_FOUND",
|
|
17
|
-
WITHDRAW_INSUFFICIENT_BALANCE = "WITHDRAW_INSUFFICIENT_BALANCE",
|
|
18
|
-
WITHDRAW_DETAILS_NOT_UPDATABLE = "WITHDRAW_DETAILS_NOT_UPDATABLE",
|
|
19
|
-
INVALID_WALLET_ADDRESS = "INVALID_WALLET_ADDRESS",
|
|
20
|
-
BALANCE_FETCH_FAILED = "BALANCE_FETCH_FAILED",
|
|
21
|
-
UNKNOWN = "UNKNOWN"
|
|
22
|
-
}
|
package/dist/types/index.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export { BlockchainEngineType, BlockchainSymbol, BroadcastAck, Platform, SignedTransactionKind, TERMINAL_STATES, WithdrawalErrorCode, WithdrawalFeature, WithdrawalState, } from './enums';
|
|
2
|
-
export type { HypercorePreparedTransaction, PolymarketWalletPreparedTransaction, PreparedTransaction, QuoteResponse, QuoteSummary, RawPreparedTransaction, UserOpPreparedTransaction, WithdrawalQuoteFee, } 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
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
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`.
|
|
7
|
-
*/
|
|
8
|
-
export type { HypercorePreparedTransaction, PolymarketWalletPreparedTransaction, PreparedTransaction, PreparedWithdrawalEntity as QuoteResponse, PreparedWithdrawalSummaryDto as QuoteSummary, RawPreparedTransaction, UserOpPreparedTransaction, WithdrawalQuoteFeeEntity as WithdrawalQuoteFee, } from '@heliofi/common-fe';
|
package/dist/types/requests.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { PreparedWithdrawalDto, SubmitWithdrawalDto } from '@heliofi/common-fe';
|
|
2
|
-
/**
|
|
3
|
-
* Parameters for `POST /withdraw/:withdrawalConfigId/prepare`.
|
|
4
|
-
*
|
|
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.
|
|
9
|
-
*/
|
|
10
|
-
export type CreateWithdrawalDetailParams = PreparedWithdrawalDto & {
|
|
11
|
-
/** Merchant withdrawal config ID — used in the URL path. */
|
|
12
|
-
withdrawalConfigId: string;
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* Parameters for `POST /withdraw/:withdrawalDetailId/submit`.
|
|
16
|
-
*
|
|
17
|
-
* The request **body** is the backend `SubmitWithdrawalDto`; `withdrawalDetailId`
|
|
18
|
-
* travels in the URL path and is stripped before sending.
|
|
19
|
-
*/
|
|
20
|
-
export type SubmitWithdrawalParams = SubmitWithdrawalDto & {
|
|
21
|
-
/** Per-request WithdrawalDetail ID (returned by prepare in JWT claims). */
|
|
22
|
-
withdrawalDetailId: 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;
|
|
34
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { BroadcastAck, WithdrawalState } from './enums';
|
|
2
|
-
/**
|
|
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.
|
|
12
|
-
*/
|
|
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';
|
|
14
|
-
/**
|
|
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.
|
|
20
|
-
*/
|
|
21
|
-
export interface StatusResponse {
|
|
22
|
-
withdrawalDetailId: string;
|
|
23
|
-
state: WithdrawalState;
|
|
24
|
-
txHash: string | null;
|
|
25
|
-
broadcastAck: BroadcastAck | null;
|
|
26
|
-
errorReason: string | null;
|
|
27
|
-
/**
|
|
28
|
-
* Merchant-owned identifier supplied at prepare; `null` when none was set.
|
|
29
|
-
* Mirrors `WithdrawalDetailTransformer.simple`.
|
|
30
|
-
*/
|
|
31
|
-
customerId: string | null;
|
|
32
|
-
}
|
package/dist/version.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const SDK_VERSION: string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function isBelow(version: string, minimum: string): boolean;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export interface MinSupportedVersions {
|
|
2
|
-
packages?: Record<string, string>;
|
|
3
|
-
}
|
|
4
|
-
export interface IsSupportedInput {
|
|
5
|
-
minSupportedVersions?: MinSupportedVersions | null;
|
|
6
|
-
sdkVersion?: string;
|
|
7
|
-
consumer?: {
|
|
8
|
-
name?: string;
|
|
9
|
-
version?: string;
|
|
10
|
-
} | null;
|
|
11
|
-
}
|