@heliofi/withdraw-core 0.3.0 → 0.3.2-alpha.1782827364
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/types/enums.d.ts +2 -46
- package/dist/types/index.d.ts +1 -1
- package/dist/types/responses.d.ts +5 -5
- package/dist/withdraw-core.cjs +1 -1
- package/dist/withdraw-core.js +214 -102
- package/package.json +4 -1
package/dist/index.d.ts
CHANGED
|
@@ -4,4 +4,4 @@ export { decodeJwt, isQuoteExpired } from './jwt';
|
|
|
4
4
|
export type { ApiClientConfig } from './sdk';
|
|
5
5
|
export { WithdrawalSDK } from './sdk';
|
|
6
6
|
export type { BalanceResponse, BaseBlockchain, PolymarketWalletPreparedTransaction, PreparedTransaction, PrepareWithdrawalParams, QuoteResponse, QuoteSummary, RawPreparedTransaction, RoutesResponse, SlimCurrencyWithBlockchain, StatusResponse, SubmitResponse, SubmitWithdrawalParams, UpdateQuoteParams, UserOpPreparedTransaction, WalletCurrencyBalance, WithdrawalConfig, WithdrawalCurrenciesExchangeRate, WithdrawalCustomerSwapRoute, } from './types';
|
|
7
|
-
export { BroadcastAck, SignedTransactionKind, TERMINAL_STATES, WithdrawalErrorCode, WithdrawalState,
|
|
7
|
+
export { BroadcastAck, SignedTransactionKind, TERMINAL_STATES, WithdrawalErrorCode, WithdrawalState, BlockchainSymbol, WithdrawalFeature, Platform, } from './types';
|
package/dist/types/enums.d.ts
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
SUBMITTING = "SUBMITTING",
|
|
4
|
-
SUBMITTED = "SUBMITTED",
|
|
5
|
-
BRIDGING = "BRIDGING",
|
|
6
|
-
COMPLETED = "COMPLETED",
|
|
7
|
-
FAILED = "FAILED",
|
|
8
|
-
FAILED_EXPIRED = "FAILED_EXPIRED",
|
|
9
|
-
EXPIRED = "EXPIRED",
|
|
10
|
-
REFUNDED_BY_PROVIDER = "REFUNDED_BY_PROVIDER"
|
|
11
|
-
}
|
|
1
|
+
import { BlockchainSymbol, BroadcastAck, Platform, SignedTransactionKind, WithdrawalFeature, WithdrawalState } from '@heliofi/common/withdraw';
|
|
2
|
+
export { BroadcastAck, SignedTransactionKind, WithdrawalState, BlockchainSymbol, Platform, WithdrawalFeature, };
|
|
12
3
|
export declare const TERMINAL_STATES: ReadonlySet<WithdrawalState>;
|
|
13
4
|
export declare enum WithdrawalErrorCode {
|
|
14
5
|
WITHDRAW_TX_INVALID_SIGNATURE = "WITHDRAW_TX_INVALID_SIGNATURE",
|
|
@@ -29,38 +20,3 @@ export declare enum WithdrawalErrorCode {
|
|
|
29
20
|
BALANCE_FETCH_FAILED = "BALANCE_FETCH_FAILED",
|
|
30
21
|
UNKNOWN = "UNKNOWN"
|
|
31
22
|
}
|
|
32
|
-
export declare enum BroadcastAck {
|
|
33
|
-
ACKNOWLEDGED = "acknowledged",
|
|
34
|
-
UNACKNOWLEDGED = "unacknowledged",
|
|
35
|
-
REJECTED = "rejected"
|
|
36
|
-
}
|
|
37
|
-
export declare enum SignedTransactionKind {
|
|
38
|
-
RAW = "raw",
|
|
39
|
-
USER_OP = "userop",
|
|
40
|
-
POLYMARKET_WALLET = "polymarket_wallet"
|
|
41
|
-
}
|
|
42
|
-
/** Mirror of backend `Platform` (packages/common/.../constants/platform.ts). */
|
|
43
|
-
export declare enum WithdrawPlatform {
|
|
44
|
-
HELIO = "HELIO",
|
|
45
|
-
MAGIC_EDEN = "MAGIC_EDEN"
|
|
46
|
-
}
|
|
47
|
-
/** Mirror of backend `WithdrawalFeature` (.../withdraw/constants/WithdrawalFeature.ts). */
|
|
48
|
-
export declare enum WithdrawFeature {
|
|
49
|
-
IRON = "iron",
|
|
50
|
-
MP_SELL = "mp_sell"
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Mirror of backend `BlockchainSymbol`
|
|
54
|
-
* (.../blockchain/constants/BlockchainSymbol.ts) — withdraw-supported chains.
|
|
55
|
-
*/
|
|
56
|
-
export declare enum WithdrawBlockchainSymbol {
|
|
57
|
-
SOL = "SOL",
|
|
58
|
-
ETH = "ETH",
|
|
59
|
-
POLYGON = "POLYGON",
|
|
60
|
-
BASE = "BASE",
|
|
61
|
-
BITCOIN = "BITCOIN",
|
|
62
|
-
ARBITRUM = "ARBITRUM",
|
|
63
|
-
BSC = "BSC",
|
|
64
|
-
TRON = "TRON",
|
|
65
|
-
DOGE = "DOGE"
|
|
66
|
-
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { BroadcastAck, SignedTransactionKind, TERMINAL_STATES, WithdrawalErrorCode, WithdrawalState,
|
|
1
|
+
export { BroadcastAck, SignedTransactionKind, TERMINAL_STATES, WithdrawalErrorCode, WithdrawalState, BlockchainSymbol, WithdrawalFeature, Platform, } from './enums';
|
|
2
2
|
export type { PolymarketWalletPreparedTransaction, PreparedTransaction, QuoteResponse, QuoteSummary, RawPreparedTransaction, UserOpPreparedTransaction, } from './prepared';
|
|
3
3
|
export type { PrepareWithdrawalParams, SubmitWithdrawalParams, UpdateQuoteParams, } from './requests';
|
|
4
4
|
export type { BalanceResponse, BaseBlockchain, RoutesResponse, SlimCurrencyWithBlockchain, StatusResponse, SubmitResponse, WalletCurrencyBalance, WithdrawalConfig, WithdrawalCurrenciesExchangeRate, WithdrawalCustomerSwapRoute, } from './responses';
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import type { BroadcastAck, WithdrawalState,
|
|
1
|
+
import type { BroadcastAck, WithdrawalState, BlockchainSymbol, WithdrawalFeature, Platform } from './enums';
|
|
2
2
|
export interface WithdrawalCurrenciesExchangeRate {
|
|
3
3
|
minimalUnitRate: string;
|
|
4
4
|
decimalRate: string;
|
|
5
5
|
fromCurrencyId: string;
|
|
6
6
|
fromCurrencySymbol: string;
|
|
7
|
-
fromBlockchainSymbol:
|
|
7
|
+
fromBlockchainSymbol: BlockchainSymbol;
|
|
8
8
|
toCurrencyId: string;
|
|
9
9
|
toCurrencySymbol: string;
|
|
10
10
|
}
|
|
11
11
|
export interface WithdrawalConfig {
|
|
12
12
|
id: string;
|
|
13
13
|
name: string;
|
|
14
|
-
platform:
|
|
14
|
+
platform: Platform;
|
|
15
15
|
disabled: boolean;
|
|
16
|
-
disabledBlockchainSymbols:
|
|
17
|
-
enabledFeatures:
|
|
16
|
+
disabledBlockchainSymbols: BlockchainSymbol[];
|
|
17
|
+
enabledFeatures: WithdrawalFeature[];
|
|
18
18
|
/** ISO 8601 timestamp. */
|
|
19
19
|
createdAt: string;
|
|
20
20
|
/** ISO 8601 timestamp. */
|
package/dist/withdraw-core.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var H=Object.defineProperty;var y=(t,e,r)=>e in t?H(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var s=(t,e,r)=>y(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var R={},o={},O;function b(){if(O)return o;O=1,Object.defineProperty(o,"__esModule",{value:!0}),o.DepositBlockchainSymbol=o.BlockchainSymbol=void 0;var t;(function(r){r.SOL="SOL",r.ETH="ETH",r.POLYGON="POLYGON",r.BASE="BASE",r.BITCOIN="BITCOIN",r.ARBITRUM="ARBITRUM",r.BSC="BSC",r.TRON="TRON",r.DOGE="DOGE"})(t||(o.BlockchainSymbol=t={}));var e;return(function(r){r.ABSTRACT="ABSTRACT",r.HYPERLIQUID="HYPERLIQUID",r.HYPERCORE="HYPERCORE",r.PLASMA="PLASMA",r.MEGAETH="MEGAETH"})(e||(o.DepositBlockchainSymbol=e={})),o}var c={},W;function m(){if(W)return c;W=1,Object.defineProperty(c,"__esModule",{value:!0}),c.BlockchainEngineType=void 0;var t;return(function(e){e.EVM="EVM",e.SOL="SOL",e.BTC="BTC",e.TRON="TRON",e.HYPERCORE="HYPERCORE",e.DOGE="DOGE"})(t||(c.BlockchainEngineType=t={})),c}var u={},h;function C(){if(h)return u;h=1,Object.defineProperty(u,"__esModule",{value:!0}),u.PLATFORM_HEADER_NAME=u.toPlatform=u.Platform=void 0;var t;(function(r){r.HELIO="HELIO",r.MAGIC_EDEN="MAGIC_EDEN"})(t||(u.Platform=t={}));const e=r=>{switch(r){case t.HELIO:return t.HELIO;case t.MAGIC_EDEN:return t.MAGIC_EDEN;default:throw new Error("Platform not supported")}};return u.toPlatform=e,u.PLATFORM_HEADER_NAME="x-platform",u}var T={},N;function U(){if(N)return T;N=1,Object.defineProperty(T,"__esModule",{value:!0}),T.WithdrawalFeature=void 0;var t;return(function(e){e.IRON="iron",e.MP_SELL="mp_sell"})(t||(T.WithdrawalFeature=t={})),T}var d={},S;function M(){if(S)return d;S=1,Object.defineProperty(d,"__esModule",{value:!0}),d.WithdrawalState=void 0;var t;return(function(e){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"})(t||(d.WithdrawalState=t={})),d}var _={},P;function g(){if(P)return _;P=1,Object.defineProperty(_,"__esModule",{value:!0}),_.BroadcastAck=void 0;var t;return(function(e){e.ACKNOWLEDGED="acknowledged",e.UNACKNOWLEDGED="unacknowledged",e.REJECTED="rejected"})(t||(_.BroadcastAck=t={})),_}var A={},f;function F(){if(f)return A;f=1,Object.defineProperty(A,"__esModule",{value:!0}),A.SignedTransactionKind=void 0;var t;return(function(e){e.RAW="raw",e.USER_OP="userop",e.POLYMARKET_WALLET="polymarket_wallet"})(t||(A.SignedTransactionKind=t={})),A}var w;function X(){return w||(w=1,(function(t){Object.defineProperty(t,"__esModule",{value:!0}),t.SignedTransactionKind=t.BroadcastAck=t.WithdrawalState=t.WithdrawalFeature=t.Platform=t.BlockchainEngineType=t.BlockchainSymbol=void 0;var e=b();Object.defineProperty(t,"BlockchainSymbol",{enumerable:!0,get:function(){return e.BlockchainSymbol}});var r=m();Object.defineProperty(t,"BlockchainEngineType",{enumerable:!0,get:function(){return r.BlockchainEngineType}});var a=C();Object.defineProperty(t,"Platform",{enumerable:!0,get:function(){return a.Platform}});var n=U();Object.defineProperty(t,"WithdrawalFeature",{enumerable:!0,get:function(){return n.WithdrawalFeature}});var D=M();Object.defineProperty(t,"WithdrawalState",{enumerable:!0,get:function(){return D.WithdrawalState}});var E=g();Object.defineProperty(t,"BroadcastAck",{enumerable:!0,get:function(){return E.BroadcastAck}});var B=F();Object.defineProperty(t,"SignedTransactionKind",{enumerable:!0,get:function(){return B.SignedTransactionKind}})})(R)),R}var i=X();const K=new Set([i.WithdrawalState.COMPLETED,i.WithdrawalState.FAILED,i.WithdrawalState.FAILED_EXPIRED,i.WithdrawalState.EXPIRED,i.WithdrawalState.REFUNDED_BY_PROVIDER]);var l=(t=>(t.WITHDRAW_TX_INVALID_SIGNATURE="WITHDRAW_TX_INVALID_SIGNATURE",t.WITHDRAW_TX_BLOCKHASH_EXPIRED="WITHDRAW_TX_BLOCKHASH_EXPIRED",t.WITHDRAW_TX_NONCE_TOO_LOW="WITHDRAW_TX_NONCE_TOO_LOW",t.WITHDRAW_TX_USEROP_EXPIRED="WITHDRAW_TX_USEROP_EXPIRED",t.WITHDRAW_TX_UNDERPRICED="WITHDRAW_TX_UNDERPRICED",t.WITHDRAW_BUNDLER_REJECTED="WITHDRAW_BUNDLER_REJECTED",t.WITHDRAW_TX_BROADCAST_TIMEOUT="WITHDRAW_TX_BROADCAST_TIMEOUT",t.WITHDRAW_TX_ALREADY_KNOWN="WITHDRAW_TX_ALREADY_KNOWN",t.WITHDRAW_QUOTE_EXPIRED="WITHDRAW_QUOTE_EXPIRED",t.WITHDRAW_SANCTIONS_BLOCKED="WITHDRAW_SANCTIONS_BLOCKED",t.WITHDRAW_NO_ROUTE="WITHDRAW_NO_ROUTE",t.WITHDRAW_NOT_FOUND="WITHDRAW_NOT_FOUND",t.WITHDRAW_INSUFFICIENT_BALANCE="WITHDRAW_INSUFFICIENT_BALANCE",t.WITHDRAW_DETAILS_NOT_UPDATABLE="WITHDRAW_DETAILS_NOT_UPDATABLE",t.INVALID_WALLET_ADDRESS="INVALID_WALLET_ADDRESS",t.BALANCE_FETCH_FAILED="BALANCE_FETCH_FAILED",t.UNKNOWN="UNKNOWN",t))(l||{});const k=new Set(Object.values(l));class v extends Error{constructor(r,a,n){super(n??a);s(this,"name","WithdrawalApiError");this.status=r,this.code=a,this.detail=n}}const L=t=>t&&k.has(t)?t:l.UNKNOWN,p=t=>{const e=t.split(".");if(e.length!==3)throw new Error("Invalid JWT: expected 3 parts");const r=atob(e[1].replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(r)},G=(t,e=5e3)=>{const{exp:r}=p(t);return r===void 0?!1:Date.now()>=r*1e3-e},j="0.3.2-alpha.1782827364";class q{constructor(e){s(this,"baseUrl");s(this,"headers");s(this,"fetch");var r,a;this.baseUrl=e.baseUrl.endsWith("/")?e.baseUrl.slice(0,-1):e.baseUrl,this.headers={"Content-Type":"application/json","X-MoonPay-Commerce-SDK-Version":j,...(r=e.consumer)!=null&&r.name?{"X-MoonPay-Commerce-Consumer":e.consumer.name}:{},...(a=e.consumer)!=null&&a.version?{"X-MoonPay-Commerce-Consumer-Version":e.consumer.version}:{},...e.headers},this.fetch=e.fetch??globalThis.fetch.bind(globalThis)}async get(e,r){return this.request("GET",e,void 0,r)}async post(e,r,a){return this.request("POST",e,r,a)}async patch(e,r,a){return this.request("PATCH",e,r,a)}async request(e,r,a,n){const D=`${this.baseUrl}${r}`,E=await this.fetch(D,{method:e,headers:this.headers,body:a!==void 0?JSON.stringify(a):void 0,signal:n});if(!E.ok)throw await this.buildError(E);return await E.json()}async buildError(e){let r,a;try{const n=await e.json();r=n.message??void 0,a=n.errorCode??n.errorType??void 0}catch{r=e.statusText||void 0}return new v(e.status,L(a),r)}}class I{constructor(e){this.api=e}static create(e){return new I(new q(e))}async getWithdrawalConfig(e,r){return this.api.get(`/withdrawal-configs/${e}/public`,r)}async getRoutes(e,r){return this.api.get(`/withdraw/${e}/routes`,r)}async getBalance(e,r,a){return this.api.get(`/withdraw/${e}/balances?walletAddress=${encodeURIComponent(r)}`,a)}async prepare(e,r){const{withdrawalConfigId:a,...n}=e;return this.api.post(`/withdraw/${a}/prepare`,n,r)}async updateQuote(e,r,a){throw new Error("updateQuote is not yet supported by the backend. Create a new quote via prepare() instead.")}async submitWithdrawal(e,r){const{withdrawalDetailId:a,...n}=e;return this.api.post(`/withdraw/${a}/submit`,n,r)}async getWithdrawalDetail(e,r){return this.api.get(`/withdraw-details/${e}`,r)}}exports.BlockchainSymbol=i.BlockchainSymbol;exports.BroadcastAck=i.BroadcastAck;exports.Platform=i.Platform;exports.SignedTransactionKind=i.SignedTransactionKind;exports.TERMINAL_STATES=K;exports.WithdrawalApiError=v;exports.WithdrawalErrorCode=l;exports.WithdrawalFeature=i.WithdrawalFeature;exports.WithdrawalSDK=I;exports.WithdrawalState=i.WithdrawalState;exports.decodeJwt=p;exports.isQuoteExpired=G;exports.toWithdrawalErrorCode=L;
|
package/dist/withdraw-core.js
CHANGED
|
@@ -1,108 +1,219 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
var w = Object.defineProperty;
|
|
2
|
+
var p = (t, e, r) => e in t ? w(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
|
+
var c = (t, e, r) => p(t, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
+
var l = {}, o = {}, I;
|
|
5
|
+
function B() {
|
|
6
|
+
if (I) return o;
|
|
7
|
+
I = 1, Object.defineProperty(o, "__esModule", { value: !0 }), o.DepositBlockchainSymbol = o.BlockchainSymbol = void 0;
|
|
8
|
+
var t;
|
|
9
|
+
(function(r) {
|
|
10
|
+
r.SOL = "SOL", r.ETH = "ETH", r.POLYGON = "POLYGON", r.BASE = "BASE", r.BITCOIN = "BITCOIN", r.ARBITRUM = "ARBITRUM", r.BSC = "BSC", r.TRON = "TRON", r.DOGE = "DOGE";
|
|
11
|
+
})(t || (o.BlockchainSymbol = t = {}));
|
|
12
|
+
var e;
|
|
13
|
+
return (function(r) {
|
|
14
|
+
r.ABSTRACT = "ABSTRACT", r.HYPERLIQUID = "HYPERLIQUID", r.HYPERCORE = "HYPERCORE", r.PLASMA = "PLASMA", r.MEGAETH = "MEGAETH";
|
|
15
|
+
})(e || (o.DepositBlockchainSymbol = e = {})), o;
|
|
16
|
+
}
|
|
17
|
+
var E = {}, O;
|
|
18
|
+
function H() {
|
|
19
|
+
if (O) return E;
|
|
20
|
+
O = 1, Object.defineProperty(E, "__esModule", { value: !0 }), E.BlockchainEngineType = void 0;
|
|
21
|
+
var t;
|
|
22
|
+
return (function(e) {
|
|
23
|
+
e.EVM = "EVM", e.SOL = "SOL", e.BTC = "BTC", e.TRON = "TRON", e.HYPERCORE = "HYPERCORE", e.DOGE = "DOGE";
|
|
24
|
+
})(t || (E.BlockchainEngineType = t = {})), E;
|
|
25
|
+
}
|
|
26
|
+
var u = {}, h;
|
|
27
|
+
function m() {
|
|
28
|
+
if (h) return u;
|
|
29
|
+
h = 1, Object.defineProperty(u, "__esModule", { value: !0 }), u.PLATFORM_HEADER_NAME = u.toPlatform = u.Platform = void 0;
|
|
30
|
+
var t;
|
|
31
|
+
(function(r) {
|
|
32
|
+
r.HELIO = "HELIO", r.MAGIC_EDEN = "MAGIC_EDEN";
|
|
33
|
+
})(t || (u.Platform = t = {}));
|
|
34
|
+
const e = (r) => {
|
|
35
|
+
switch (r) {
|
|
36
|
+
case t.HELIO:
|
|
37
|
+
return t.HELIO;
|
|
38
|
+
case t.MAGIC_EDEN:
|
|
39
|
+
return t.MAGIC_EDEN;
|
|
40
|
+
default:
|
|
41
|
+
throw new Error("Platform not supported");
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
return u.toPlatform = e, u.PLATFORM_HEADER_NAME = "x-platform", u;
|
|
45
|
+
}
|
|
46
|
+
var T = {}, W;
|
|
47
|
+
function y() {
|
|
48
|
+
if (W) return T;
|
|
49
|
+
W = 1, Object.defineProperty(T, "__esModule", { value: !0 }), T.WithdrawalFeature = void 0;
|
|
50
|
+
var t;
|
|
51
|
+
return (function(e) {
|
|
52
|
+
e.IRON = "iron", e.MP_SELL = "mp_sell";
|
|
53
|
+
})(t || (T.WithdrawalFeature = t = {})), T;
|
|
54
|
+
}
|
|
55
|
+
var d = {}, N;
|
|
56
|
+
function b() {
|
|
57
|
+
if (N) return d;
|
|
58
|
+
N = 1, Object.defineProperty(d, "__esModule", { value: !0 }), d.WithdrawalState = void 0;
|
|
59
|
+
var t;
|
|
60
|
+
return (function(e) {
|
|
61
|
+
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";
|
|
62
|
+
})(t || (d.WithdrawalState = t = {})), d;
|
|
63
|
+
}
|
|
64
|
+
var _ = {}, S;
|
|
65
|
+
function U() {
|
|
66
|
+
if (S) return _;
|
|
67
|
+
S = 1, Object.defineProperty(_, "__esModule", { value: !0 }), _.BroadcastAck = void 0;
|
|
68
|
+
var t;
|
|
69
|
+
return (function(e) {
|
|
70
|
+
e.ACKNOWLEDGED = "acknowledged", e.UNACKNOWLEDGED = "unacknowledged", e.REJECTED = "rejected";
|
|
71
|
+
})(t || (_.BroadcastAck = t = {})), _;
|
|
72
|
+
}
|
|
73
|
+
var A = {}, P;
|
|
74
|
+
function C() {
|
|
75
|
+
if (P) return A;
|
|
76
|
+
P = 1, Object.defineProperty(A, "__esModule", { value: !0 }), A.SignedTransactionKind = void 0;
|
|
77
|
+
var t;
|
|
78
|
+
return (function(e) {
|
|
79
|
+
e.RAW = "raw", e.USER_OP = "userop", e.POLYMARKET_WALLET = "polymarket_wallet";
|
|
80
|
+
})(t || (A.SignedTransactionKind = t = {})), A;
|
|
81
|
+
}
|
|
82
|
+
var f;
|
|
83
|
+
function M() {
|
|
84
|
+
return f || (f = 1, (function(t) {
|
|
85
|
+
Object.defineProperty(t, "__esModule", { value: !0 }), t.SignedTransactionKind = t.BroadcastAck = t.WithdrawalState = t.WithdrawalFeature = t.Platform = t.BlockchainEngineType = t.BlockchainSymbol = void 0;
|
|
86
|
+
var e = B();
|
|
87
|
+
Object.defineProperty(t, "BlockchainSymbol", { enumerable: !0, get: function() {
|
|
88
|
+
return e.BlockchainSymbol;
|
|
89
|
+
} });
|
|
90
|
+
var r = H();
|
|
91
|
+
Object.defineProperty(t, "BlockchainEngineType", { enumerable: !0, get: function() {
|
|
92
|
+
return r.BlockchainEngineType;
|
|
93
|
+
} });
|
|
94
|
+
var a = m();
|
|
95
|
+
Object.defineProperty(t, "Platform", { enumerable: !0, get: function() {
|
|
96
|
+
return a.Platform;
|
|
97
|
+
} });
|
|
98
|
+
var n = y();
|
|
99
|
+
Object.defineProperty(t, "WithdrawalFeature", { enumerable: !0, get: function() {
|
|
100
|
+
return n.WithdrawalFeature;
|
|
101
|
+
} });
|
|
102
|
+
var D = b();
|
|
103
|
+
Object.defineProperty(t, "WithdrawalState", { enumerable: !0, get: function() {
|
|
104
|
+
return D.WithdrawalState;
|
|
105
|
+
} });
|
|
106
|
+
var s = U();
|
|
107
|
+
Object.defineProperty(t, "BroadcastAck", { enumerable: !0, get: function() {
|
|
108
|
+
return s.BroadcastAck;
|
|
109
|
+
} });
|
|
110
|
+
var L = C();
|
|
111
|
+
Object.defineProperty(t, "SignedTransactionKind", { enumerable: !0, get: function() {
|
|
112
|
+
return L.SignedTransactionKind;
|
|
113
|
+
} });
|
|
114
|
+
})(l)), l;
|
|
115
|
+
}
|
|
116
|
+
var i = M();
|
|
117
|
+
const j = /* @__PURE__ */ new Set([
|
|
118
|
+
i.WithdrawalState.COMPLETED,
|
|
119
|
+
i.WithdrawalState.FAILED,
|
|
120
|
+
i.WithdrawalState.FAILED_EXPIRED,
|
|
121
|
+
i.WithdrawalState.EXPIRED,
|
|
122
|
+
i.WithdrawalState.REFUNDED_BY_PROVIDER
|
|
12
123
|
]);
|
|
13
|
-
var
|
|
14
|
-
const
|
|
15
|
-
class
|
|
16
|
-
constructor(
|
|
17
|
-
super(
|
|
18
|
-
|
|
19
|
-
this.status =
|
|
124
|
+
var R = /* @__PURE__ */ ((t) => (t.WITHDRAW_TX_INVALID_SIGNATURE = "WITHDRAW_TX_INVALID_SIGNATURE", t.WITHDRAW_TX_BLOCKHASH_EXPIRED = "WITHDRAW_TX_BLOCKHASH_EXPIRED", t.WITHDRAW_TX_NONCE_TOO_LOW = "WITHDRAW_TX_NONCE_TOO_LOW", t.WITHDRAW_TX_USEROP_EXPIRED = "WITHDRAW_TX_USEROP_EXPIRED", t.WITHDRAW_TX_UNDERPRICED = "WITHDRAW_TX_UNDERPRICED", t.WITHDRAW_BUNDLER_REJECTED = "WITHDRAW_BUNDLER_REJECTED", t.WITHDRAW_TX_BROADCAST_TIMEOUT = "WITHDRAW_TX_BROADCAST_TIMEOUT", t.WITHDRAW_TX_ALREADY_KNOWN = "WITHDRAW_TX_ALREADY_KNOWN", t.WITHDRAW_QUOTE_EXPIRED = "WITHDRAW_QUOTE_EXPIRED", t.WITHDRAW_SANCTIONS_BLOCKED = "WITHDRAW_SANCTIONS_BLOCKED", t.WITHDRAW_NO_ROUTE = "WITHDRAW_NO_ROUTE", t.WITHDRAW_NOT_FOUND = "WITHDRAW_NOT_FOUND", t.WITHDRAW_INSUFFICIENT_BALANCE = "WITHDRAW_INSUFFICIENT_BALANCE", t.WITHDRAW_DETAILS_NOT_UPDATABLE = "WITHDRAW_DETAILS_NOT_UPDATABLE", t.INVALID_WALLET_ADDRESS = "INVALID_WALLET_ADDRESS", t.BALANCE_FETCH_FAILED = "BALANCE_FETCH_FAILED", t.UNKNOWN = "UNKNOWN", t))(R || {});
|
|
125
|
+
const g = new Set(Object.values(R));
|
|
126
|
+
class F extends Error {
|
|
127
|
+
constructor(r, a, n) {
|
|
128
|
+
super(n ?? a);
|
|
129
|
+
c(this, "name", "WithdrawalApiError");
|
|
130
|
+
this.status = r, this.code = a, this.detail = n;
|
|
20
131
|
}
|
|
21
132
|
}
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
if (
|
|
133
|
+
const X = (t) => t && g.has(t) ? t : R.UNKNOWN, K = (t) => {
|
|
134
|
+
const e = t.split(".");
|
|
135
|
+
if (e.length !== 3)
|
|
25
136
|
throw new Error("Invalid JWT: expected 3 parts");
|
|
26
|
-
const
|
|
27
|
-
return JSON.parse(
|
|
28
|
-
},
|
|
29
|
-
const { exp:
|
|
30
|
-
return
|
|
31
|
-
},
|
|
32
|
-
class
|
|
33
|
-
constructor(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
var
|
|
38
|
-
this.baseUrl =
|
|
137
|
+
const r = atob(e[1].replace(/-/g, "+").replace(/_/g, "/"));
|
|
138
|
+
return JSON.parse(r);
|
|
139
|
+
}, $ = (t, e = 5e3) => {
|
|
140
|
+
const { exp: r } = K(t);
|
|
141
|
+
return r === void 0 ? !1 : Date.now() >= r * 1e3 - e;
|
|
142
|
+
}, k = "0.3.2-alpha.1782827364";
|
|
143
|
+
class G {
|
|
144
|
+
constructor(e) {
|
|
145
|
+
c(this, "baseUrl");
|
|
146
|
+
c(this, "headers");
|
|
147
|
+
c(this, "fetch");
|
|
148
|
+
var r, a;
|
|
149
|
+
this.baseUrl = e.baseUrl.endsWith("/") ? e.baseUrl.slice(0, -1) : e.baseUrl, this.headers = {
|
|
39
150
|
"Content-Type": "application/json",
|
|
40
151
|
// Every request self-identifies with the client version (always sent).
|
|
41
|
-
"X-MoonPay-Commerce-SDK-Version":
|
|
42
|
-
...(
|
|
43
|
-
...(
|
|
44
|
-
...
|
|
45
|
-
}, this.fetch =
|
|
152
|
+
"X-MoonPay-Commerce-SDK-Version": k,
|
|
153
|
+
...(r = e.consumer) != null && r.name ? { "X-MoonPay-Commerce-Consumer": e.consumer.name } : {},
|
|
154
|
+
...(a = e.consumer) != null && a.version ? { "X-MoonPay-Commerce-Consumer-Version": e.consumer.version } : {},
|
|
155
|
+
...e.headers
|
|
156
|
+
}, this.fetch = e.fetch ?? globalThis.fetch.bind(globalThis);
|
|
46
157
|
}
|
|
47
|
-
async get(
|
|
48
|
-
return this.request("GET",
|
|
158
|
+
async get(e, r) {
|
|
159
|
+
return this.request("GET", e, void 0, r);
|
|
49
160
|
}
|
|
50
|
-
async post(
|
|
51
|
-
return this.request("POST",
|
|
161
|
+
async post(e, r, a) {
|
|
162
|
+
return this.request("POST", e, r, a);
|
|
52
163
|
}
|
|
53
|
-
async patch(
|
|
54
|
-
return this.request("PATCH",
|
|
164
|
+
async patch(e, r, a) {
|
|
165
|
+
return this.request("PATCH", e, r, a);
|
|
55
166
|
}
|
|
56
|
-
async request(
|
|
57
|
-
const
|
|
58
|
-
method:
|
|
167
|
+
async request(e, r, a, n) {
|
|
168
|
+
const D = `${this.baseUrl}${r}`, s = await this.fetch(D, {
|
|
169
|
+
method: e,
|
|
59
170
|
headers: this.headers,
|
|
60
|
-
body:
|
|
61
|
-
signal:
|
|
171
|
+
body: a !== void 0 ? JSON.stringify(a) : void 0,
|
|
172
|
+
signal: n
|
|
62
173
|
});
|
|
63
|
-
if (!
|
|
64
|
-
throw await this.buildError(
|
|
65
|
-
return await
|
|
174
|
+
if (!s.ok)
|
|
175
|
+
throw await this.buildError(s);
|
|
176
|
+
return await s.json();
|
|
66
177
|
}
|
|
67
|
-
async buildError(
|
|
68
|
-
let
|
|
178
|
+
async buildError(e) {
|
|
179
|
+
let r, a;
|
|
69
180
|
try {
|
|
70
|
-
const
|
|
71
|
-
|
|
181
|
+
const n = await e.json();
|
|
182
|
+
r = n.message ?? void 0, a = n.errorCode ?? n.errorType ?? void 0;
|
|
72
183
|
} catch {
|
|
73
|
-
|
|
184
|
+
r = e.statusText || void 0;
|
|
74
185
|
}
|
|
75
|
-
return new
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
186
|
+
return new F(
|
|
187
|
+
e.status,
|
|
188
|
+
X(a),
|
|
189
|
+
r
|
|
79
190
|
);
|
|
80
191
|
}
|
|
81
192
|
}
|
|
82
|
-
class
|
|
193
|
+
class v {
|
|
83
194
|
// Takes a prebuilt ApiClient (DI). Use `WithdrawalSDK.create()` for the
|
|
84
195
|
// common case where you just have config.
|
|
85
|
-
constructor(
|
|
86
|
-
this.api =
|
|
196
|
+
constructor(e) {
|
|
197
|
+
this.api = e;
|
|
87
198
|
}
|
|
88
|
-
static create(
|
|
89
|
-
return new
|
|
199
|
+
static create(e) {
|
|
200
|
+
return new v(new G(e));
|
|
90
201
|
}
|
|
91
|
-
async getWithdrawalConfig(
|
|
202
|
+
async getWithdrawalConfig(e, r) {
|
|
92
203
|
return this.api.get(
|
|
93
|
-
`/withdrawal-configs/${
|
|
94
|
-
|
|
204
|
+
`/withdrawal-configs/${e}/public`,
|
|
205
|
+
r
|
|
95
206
|
);
|
|
96
207
|
}
|
|
97
|
-
async getRoutes(
|
|
98
|
-
return this.api.get(`/withdraw/${
|
|
208
|
+
async getRoutes(e, r) {
|
|
209
|
+
return this.api.get(`/withdraw/${e}/routes`, r);
|
|
99
210
|
}
|
|
100
|
-
async getBalance(
|
|
211
|
+
async getBalance(e, r, a) {
|
|
101
212
|
return this.api.get(
|
|
102
|
-
`/withdraw/${
|
|
103
|
-
|
|
213
|
+
`/withdraw/${e}/balances?walletAddress=${encodeURIComponent(
|
|
214
|
+
r
|
|
104
215
|
)}`,
|
|
105
|
-
|
|
216
|
+
a
|
|
106
217
|
);
|
|
107
218
|
}
|
|
108
219
|
/**
|
|
@@ -110,12 +221,12 @@ class A {
|
|
|
110
221
|
* `withdrawalConfigId` goes in the path; the remaining fields are the
|
|
111
222
|
* request body matching the backend `PreparedWithdrawalDto`.
|
|
112
223
|
*/
|
|
113
|
-
async prepare(
|
|
114
|
-
const { withdrawalConfigId:
|
|
224
|
+
async prepare(e, r) {
|
|
225
|
+
const { withdrawalConfigId: a, ...n } = e;
|
|
115
226
|
return this.api.post(
|
|
116
|
-
`/withdraw/${
|
|
117
|
-
|
|
118
|
-
|
|
227
|
+
`/withdraw/${a}/prepare`,
|
|
228
|
+
n,
|
|
229
|
+
r
|
|
119
230
|
);
|
|
120
231
|
}
|
|
121
232
|
/**
|
|
@@ -125,7 +236,7 @@ class A {
|
|
|
125
236
|
* This stub is kept for forward compatibility. It will throw until
|
|
126
237
|
* the backend ships the handler.
|
|
127
238
|
*/
|
|
128
|
-
async updateQuote(
|
|
239
|
+
async updateQuote(e, r, a) {
|
|
129
240
|
throw new Error(
|
|
130
241
|
"updateQuote is not yet supported by the backend. Create a new quote via prepare() instead."
|
|
131
242
|
);
|
|
@@ -134,30 +245,31 @@ class A {
|
|
|
134
245
|
* Body matches the backend `SubmitWithdrawalDto`:
|
|
135
246
|
* `{ token, signedTx }`, where `signedTx` is the bare signed payload string.
|
|
136
247
|
*/
|
|
137
|
-
async submitWithdrawal(
|
|
138
|
-
const { withdrawalDetailId:
|
|
248
|
+
async submitWithdrawal(e, r) {
|
|
249
|
+
const { withdrawalDetailId: a, ...n } = e;
|
|
139
250
|
return this.api.post(
|
|
140
|
-
`/withdraw/${
|
|
141
|
-
|
|
142
|
-
|
|
251
|
+
`/withdraw/${a}/submit`,
|
|
252
|
+
n,
|
|
253
|
+
r
|
|
143
254
|
);
|
|
144
255
|
}
|
|
145
|
-
async getWithdrawalDetail(
|
|
146
|
-
return this.api.get(`/withdraw-details/${
|
|
256
|
+
async getWithdrawalDetail(e, r) {
|
|
257
|
+
return this.api.get(`/withdraw-details/${e}`, r);
|
|
147
258
|
}
|
|
148
259
|
}
|
|
260
|
+
const Y = i.BlockchainSymbol, V = i.BroadcastAck, Q = i.Platform, J = i.SignedTransactionKind, z = i.WithdrawalFeature, Z = i.WithdrawalState;
|
|
149
261
|
export {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
262
|
+
Y as BlockchainSymbol,
|
|
263
|
+
V as BroadcastAck,
|
|
264
|
+
Q as Platform,
|
|
265
|
+
J as SignedTransactionKind,
|
|
266
|
+
j as TERMINAL_STATES,
|
|
267
|
+
F as WithdrawalApiError,
|
|
268
|
+
R as WithdrawalErrorCode,
|
|
269
|
+
z as WithdrawalFeature,
|
|
270
|
+
v as WithdrawalSDK,
|
|
271
|
+
Z as WithdrawalState,
|
|
272
|
+
K as decodeJwt,
|
|
273
|
+
$ as isQuoteExpired,
|
|
274
|
+
X as toWithdrawalErrorCode
|
|
163
275
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heliofi/withdraw-core",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.2-alpha.1782827364",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "vite",
|
|
@@ -39,5 +39,8 @@
|
|
|
39
39
|
"vite": "6.4.2",
|
|
40
40
|
"vite-plugin-dts": "3.7.1",
|
|
41
41
|
"vitest": "3.2.4"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@heliofi/common": "0.2.276-alpha.1782827110"
|
|
42
45
|
}
|
|
43
46
|
}
|