@heliofi/withdraw-core 1.3.5 → 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/dist/types/index.d.ts +1 -1
- package/dist/types/prepared.d.ts +6 -70
- package/dist/types/requests.d.ts +21 -37
- package/dist/types/responses.d.ts +17 -142
- package/dist/withdraw-core.cjs +1 -1
- package/dist/withdraw-core.js +1 -1
- package/package.json +2 -3
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { BlockchainEngineType, BlockchainSymbol, BroadcastAck, Platform, SignedTransactionKind, TERMINAL_STATES, WithdrawalErrorCode, WithdrawalFeature, WithdrawalState, } from './enums';
|
|
2
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,
|
|
4
|
+
export type { BalanceResponse, BaseBlockchain, BlockchainEngine, PopulatedBlockchain, RoutesResponse, SlimCurrencyWithBlockchain, SlimCurrencyWithPopulatedBlockchain, StatusResponse, SubmitResponse, WalletCurrencyBalance, WithdrawalConfig, WithdrawalCurrenciesExchangeRate, WithdrawalCustomerSwapRoute, } from './responses';
|
package/dist/types/prepared.d.ts
CHANGED
|
@@ -1,72 +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
|
-
*
|
|
29
|
-
*
|
|
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
|
|
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
|
-
/**
|
|
48
|
-
* USD value of `destinationAmount` as a decimal string. Optional — absent when
|
|
49
|
-
* the backend can't resolve a USD price for the destination token. Mirrors the
|
|
50
|
-
* backend `PreparedWithdrawalSummaryDto.destinationAmountUsd?`.
|
|
51
|
-
*/
|
|
52
|
-
destinationAmountUsd?: string;
|
|
53
|
-
/**
|
|
54
|
-
* USD value of `destinationAmountMin` as a decimal string. Optional — absent
|
|
55
|
-
* when the backend can't resolve a USD price. Mirrors the backend
|
|
56
|
-
* `PreparedWithdrawalSummaryDto.destinationAmountMinUsd?`.
|
|
57
|
-
*/
|
|
58
|
-
destinationAmountMinUsd?: string;
|
|
59
|
-
maxSlippageBps: number;
|
|
60
|
-
estimatedPriceImpact?: number;
|
|
61
|
-
bridgeFee: WithdrawalQuoteFee;
|
|
62
|
-
applicationFee: WithdrawalQuoteFee;
|
|
63
|
-
protocolFee: WithdrawalQuoteFee;
|
|
64
|
-
totalFee: WithdrawalQuoteFee;
|
|
65
|
-
expiresAt: string;
|
|
66
|
-
}
|
|
67
|
-
export interface QuoteResponse {
|
|
68
|
-
withdrawalDetailId: string;
|
|
69
|
-
token: string;
|
|
70
|
-
prepared: PreparedTransaction;
|
|
71
|
-
summary: QuoteSummary;
|
|
72
|
-
}
|
|
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
CHANGED
|
@@ -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
|
-
*
|
|
5
|
-
*
|
|
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
|
|
10
|
+
export type CreateWithdrawalDetailParams = PreparedWithdrawalDto & {
|
|
8
11
|
/** Merchant withdrawal config ID — used in the URL path. */
|
|
9
12
|
withdrawalConfigId: string;
|
|
10
|
-
|
|
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
|
-
*
|
|
17
|
+
* The request **body** is the backend `SubmitWithdrawalDto`; `withdrawalDetailId`
|
|
18
|
+
* travels in the URL path and is stripped before sending.
|
|
38
19
|
*/
|
|
39
|
-
export
|
|
20
|
+
export type SubmitWithdrawalParams = SubmitWithdrawalDto & {
|
|
40
21
|
/** Per-request WithdrawalDetail ID (returned by prepare in JWT claims). */
|
|
41
22
|
withdrawalDetailId: string;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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,147 +1,23 @@
|
|
|
1
|
-
import type {
|
|
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
|
-
}
|
|
12
|
-
/**
|
|
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.
|
|
17
|
-
*/
|
|
18
|
-
export interface CustomTheme {
|
|
19
|
-
primaryColor: string;
|
|
20
|
-
neutralColor: string;
|
|
21
|
-
textColorOnButton: 'WHITE' | 'BLACK';
|
|
22
|
-
themeMode: 'LIGHT' | 'DARK';
|
|
23
|
-
backgroundColor?: string;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
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.
|
|
30
|
-
*/
|
|
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
|
-
/**
|
|
40
|
-
* ISO 8601 timestamp of when the config was disabled; `null` when it has never
|
|
41
|
-
* been disabled. Mirrors the backend `WithdrawalConfigEntity.disabledAt`.
|
|
42
|
-
*/
|
|
43
|
-
disabledAt: string | null;
|
|
44
|
-
disabledBlockchainSymbols: BlockchainSymbol[];
|
|
45
|
-
enabledFeatures: WithdrawalFeature[];
|
|
46
|
-
/** ISO 8601 timestamp. */
|
|
47
|
-
createdAt: string;
|
|
48
|
-
/** ISO 8601 timestamp. */
|
|
49
|
-
updatedAt: string;
|
|
50
|
-
fromCurrencies: SlimCurrencyWithPopulatedBlockchain[];
|
|
51
|
-
exchangeRates: WithdrawalCurrenciesExchangeRate[];
|
|
52
|
-
minSupportedVersions?: MinSupportedVersions;
|
|
53
|
-
/**
|
|
54
|
-
* Owning company, always populated on the public endpoint. Read
|
|
55
|
-
* `company.customTheme` to theme the widget (parity with deposit/paylink).
|
|
56
|
-
*/
|
|
57
|
-
company: WithdrawalConfigCompany;
|
|
58
|
-
}
|
|
59
|
-
export interface BaseBlockchain {
|
|
60
|
-
id: string;
|
|
61
|
-
symbol: string;
|
|
62
|
-
displayName: string;
|
|
63
|
-
iconUrl?: string;
|
|
64
|
-
iconUrlFull?: string;
|
|
65
|
-
}
|
|
1
|
+
import type { BroadcastAck, WithdrawalState } from './enums';
|
|
66
2
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
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.
|
|
69
12
|
*/
|
|
70
|
-
export
|
|
71
|
-
id: string;
|
|
72
|
-
type: BlockchainEngineType;
|
|
73
|
-
/**
|
|
74
|
-
* Network-aware (testnet vs mainnet) source string for an address-validation
|
|
75
|
-
* regex, e.g. `^[1-9A-HJ-NP-Za-km-z]{32,44}$` for SOL. Present on the
|
|
76
|
-
* withdrawal `/routes` and `/public` responses; may be absent for engines
|
|
77
|
-
* without a configured regex.
|
|
78
|
-
*/
|
|
79
|
-
addressRegex?: string;
|
|
80
|
-
}
|
|
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';
|
|
81
14
|
/**
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
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.
|
|
85
20
|
*/
|
|
86
|
-
export interface PopulatedBlockchain extends BaseBlockchain {
|
|
87
|
-
engine: BlockchainEngine;
|
|
88
|
-
}
|
|
89
|
-
export interface SlimCurrencyWithBlockchain {
|
|
90
|
-
id: string;
|
|
91
|
-
symbol: string;
|
|
92
|
-
name: string;
|
|
93
|
-
mintAddress: string;
|
|
94
|
-
decimals: number;
|
|
95
|
-
iconUrlFull?: string;
|
|
96
|
-
blockchain: BaseBlockchain;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* `SlimCurrencyWithBlockchain` whose blockchain is guaranteed populated with its
|
|
100
|
-
* engine (and the engine's address regex). Mirrors the backend
|
|
101
|
-
* `SlimCurrencyWithPopulatedBlockchain` entity — the type of `fromCurrencies`
|
|
102
|
-
* on the withdrawal `/routes` and `/public` responses.
|
|
103
|
-
*/
|
|
104
|
-
export type SlimCurrencyWithPopulatedBlockchain = Omit<SlimCurrencyWithBlockchain, 'blockchain'> & {
|
|
105
|
-
blockchain: PopulatedBlockchain;
|
|
106
|
-
};
|
|
107
|
-
export interface WithdrawalCustomerSwapRoute {
|
|
108
|
-
id: string;
|
|
109
|
-
fromCurrencyId: string;
|
|
110
|
-
toCurrency: SlimCurrencyWithPopulatedBlockchain;
|
|
111
|
-
available: boolean;
|
|
112
|
-
minimumAmountMinimalUnit: string | null;
|
|
113
|
-
minimumAmountUsd: string;
|
|
114
|
-
}
|
|
115
|
-
export interface RoutesResponse {
|
|
116
|
-
/** Source currencies available under the merchant's config. */
|
|
117
|
-
fromCurrencies: SlimCurrencyWithPopulatedBlockchain[];
|
|
118
|
-
routes: WithdrawalCustomerSwapRoute[];
|
|
119
|
-
}
|
|
120
|
-
export interface WalletCurrencyBalance {
|
|
121
|
-
currencyId: string;
|
|
122
|
-
symbol: string;
|
|
123
|
-
mintAddress: string;
|
|
124
|
-
/** Minimal units. */
|
|
125
|
-
balance: string | null;
|
|
126
|
-
uiBalance: string | null;
|
|
127
|
-
maxWithdrawableAmount: string | null;
|
|
128
|
-
uiMaxWithdrawableAmount: string | null;
|
|
129
|
-
}
|
|
130
|
-
export interface BalanceResponse {
|
|
131
|
-
walletAddress: string;
|
|
132
|
-
balances: WalletCurrencyBalance[];
|
|
133
|
-
}
|
|
134
|
-
export interface SubmitResponse {
|
|
135
|
-
withdrawalDetailId: string;
|
|
136
|
-
/**
|
|
137
|
-
* Relayer/transaction hash; `null` only when the broadcast was rejected
|
|
138
|
-
* before producing a hash.
|
|
139
|
-
*/
|
|
140
|
-
txHash: string | null;
|
|
141
|
-
state: WithdrawalState;
|
|
142
|
-
/** `null` when no broadcast was attempted (defensive idempotent return). */
|
|
143
|
-
broadcastAck: BroadcastAck | null;
|
|
144
|
-
}
|
|
145
21
|
export interface StatusResponse {
|
|
146
22
|
withdrawalDetailId: string;
|
|
147
23
|
state: WithdrawalState;
|
|
@@ -150,8 +26,7 @@ export interface StatusResponse {
|
|
|
150
26
|
errorReason: string | null;
|
|
151
27
|
/**
|
|
152
28
|
* Merchant-owned identifier supplied at prepare; `null` when none was set.
|
|
153
|
-
* Mirrors `WithdrawalDetailTransformer.simple
|
|
154
|
-
* for this response).
|
|
29
|
+
* Mirrors `WithdrawalDetailTransformer.simple`.
|
|
155
30
|
*/
|
|
156
31
|
customerId: string | null;
|
|
157
32
|
}
|
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 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.
|
|
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;
|
package/dist/withdraw-core.js
CHANGED
|
@@ -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.
|
|
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
|
+
"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.
|
|
44
|
+
"@heliofi/common-fe": "0.2.295-alpha.1784813178"
|
|
46
45
|
}
|
|
47
46
|
}
|