@heliofi/withdraw-core 1.2.0 → 1.2.1-alpha.1784107550

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.
@@ -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, PopulatedBlockchain, RoutesResponse, SlimCurrencyWithBlockchain, SlimCurrencyWithPopulatedBlockchain, StatusResponse, SubmitResponse, WalletCurrencyBalance, WithdrawalConfig, WithdrawalCurrenciesExchangeRate, WithdrawalCustomerSwapRoute, } from './responses';
4
+ export type { BalanceResponse, BaseBlockchain, BlockchainEngine, CustomTheme, PopulatedBlockchain, RoutesResponse, SlimCurrencyWithBlockchain, SlimCurrencyWithPopulatedBlockchain, StatusResponse, SubmitResponse, WalletCurrencyBalance, WithdrawalConfig, WithdrawalConfigCompany, WithdrawalCurrenciesExchangeRate, WithdrawalCustomerSwapRoute, } from './responses';
@@ -9,6 +9,28 @@ export interface WithdrawalCurrenciesExchangeRate {
9
9
  toCurrencyId: string;
10
10
  toCurrencySymbol: string;
11
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
+ }
12
34
  export interface WithdrawalConfig {
13
35
  id: string;
14
36
  name: string;
@@ -23,6 +45,11 @@ export interface WithdrawalConfig {
23
45
  fromCurrencies: SlimCurrencyWithPopulatedBlockchain[];
24
46
  exchangeRates: WithdrawalCurrenciesExchangeRate[];
25
47
  minSupportedVersions?: MinSupportedVersions;
48
+ /**
49
+ * Owning company, always populated on the public endpoint. Read
50
+ * `company.customTheme` to theme the widget (parity with deposit/paylink).
51
+ */
52
+ company: WithdrawalConfigCompany;
26
53
  }
27
54
  export interface BaseBlockchain {
28
55
  id: string;
@@ -1 +1 @@
1
- "use strict";var L=Object.defineProperty;var m=(e,t,r)=>t in e?L(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 U=(function(e){return e.SOL="SOL",e.ETH="ETH",e.POLYGON="POLYGON",e.BASE="BASE",e.BITCOIN="BITCOIN",e.ARBITRUM="ARBITRUM",e.BSC="BSC",e.TRON="TRON",e.DOGE="DOGE",e})({}),C=(function(e){return e.EVM="EVM",e.SOL="SOL",e.BTC="BTC",e.TRON="TRON",e.HYPERCORE="HYPERCORE",e.DOGE="DOGE",e})({}),H=(function(e){return e.HELIO="HELIO",e.MAGIC_EDEN="MAGIC_EDEN",e})({}),S=(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})({}),d=(function(e){return e.RAW="raw",e.USER_OP="userop",e.POLYMARKET_WALLET="polymarket_wallet",e.HYPERCORE="hypercore",e})({});const w=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 X=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&&X.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)},M=(e,t=5e3)=>{const{exp:r}=p(e);return r===void 0?!1:Date.now()>=r*1e3-t},R="1.2.0",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 u=[];for(const _ of E){if(!A(_))return null;u.push(Number(_))}const o=i===""?[]:i.split(".").filter(_=>_!=="");return s!==-1&&o.length===0?null:{major:u[0]??0,minor:u[1]??0,patch:u[2]??0,prerelease:o}}function c(e,t){return e<t?-1:e>t?1:0}function g(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),u=A(i);if(E&&u){const o=c(Number(n),Number(i));if(o!==0)return o}else return E?-1:u?1:n<i?-1:1}return c(e.length,t.length)}function B(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:g(r.prerelease,s.prerelease)}function W(e,t){return B(e,t)<0}const h="@heliofi/withdraw-core";function f(e={}){const{minSupportedVersions:t,consumer:r}=e,s=(t==null?void 0:t.packages)??{},n=e.sdkVersion??R,i={[h]:n};r!=null&&r.name&&r.version!=null&&(i[r.name]=r.version);for(const[E,u]of Object.entries(s)){const o=i[E];if(o!=null&&W(o,u))return!1}return!0}class G{constructor(t){D(this,"baseUrl");D(this,"headers");D(this,"fetch");D(this,"consumer");var r,s;this.consumer=t.consumer,this.baseUrl=t.baseUrl.endsWith("/")?t.baseUrl.slice(0,-1):t.baseUrl,this.headers={"Content-Type":"application/json","X-MoonPay-Commerce-SDK-Version":R,...(r=this.consumer)!=null&&r.name?{"X-MoonPay-Commerce-Consumer":this.consumer.name}:{},...(s=this.consumer)!=null&&s.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)}}class a{constructor(t){this.api=t}static create(t){return new a(new G(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=U;exports.BroadcastAck=P;exports.Platform=H;exports.SDK_PACKAGE_NAME=h;exports.SDK_VERSION=R;exports.SignedTransactionKind=d;exports.TERMINAL_STATES=w;exports.WithdrawalApiError=O;exports.WithdrawalErrorCode=I;exports.WithdrawalFeature=S;exports.WithdrawalSDK=a;exports.WithdrawalState=T;exports.decodeJwt=p;exports.isBelow=W;exports.isQuoteExpired=M;exports.isSupported=f;exports.toWithdrawalErrorCode=l;
1
+ "use strict";var L=Object.defineProperty;var m=(e,t,r)=>t in e?L(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 U=(function(e){return e.SOL="SOL",e.ETH="ETH",e.POLYGON="POLYGON",e.BASE="BASE",e.BITCOIN="BITCOIN",e.ARBITRUM="ARBITRUM",e.BSC="BSC",e.TRON="TRON",e.DOGE="DOGE",e})({}),C=(function(e){return e.EVM="EVM",e.SOL="SOL",e.BTC="BTC",e.TRON="TRON",e.HYPERCORE="HYPERCORE",e.DOGE="DOGE",e})({}),H=(function(e){return e.HELIO="HELIO",e.MAGIC_EDEN="MAGIC_EDEN",e})({}),S=(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})({}),d=(function(e){return e.RAW="raw",e.USER_OP="userop",e.POLYMARKET_WALLET="polymarket_wallet",e.HYPERCORE="hypercore",e})({});const w=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 X=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&&X.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)},M=(e,t=5e3)=>{const{exp:r}=p(e);return r===void 0?!1:Date.now()>=r*1e3-t},R="1.2.1-alpha.1784107550",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 u=[];for(const _ of E){if(!A(_))return null;u.push(Number(_))}const o=i===""?[]:i.split(".").filter(_=>_!=="");return s!==-1&&o.length===0?null:{major:u[0]??0,minor:u[1]??0,patch:u[2]??0,prerelease:o}}function c(e,t){return e<t?-1:e>t?1:0}function g(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),u=A(i);if(E&&u){const o=c(Number(n),Number(i));if(o!==0)return o}else return E?-1:u?1:n<i?-1:1}return c(e.length,t.length)}function B(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:g(r.prerelease,s.prerelease)}function W(e,t){return B(e,t)<0}const h="@heliofi/withdraw-core";function f(e={}){const{minSupportedVersions:t,consumer:r}=e,s=(t==null?void 0:t.packages)??{},n=e.sdkVersion??R,i={[h]:n};r!=null&&r.name&&r.version!=null&&(i[r.name]=r.version);for(const[E,u]of Object.entries(s)){const o=i[E];if(o!=null&&W(o,u))return!1}return!0}class G{constructor(t){D(this,"baseUrl");D(this,"headers");D(this,"fetch");D(this,"consumer");var r,s;this.consumer=t.consumer,this.baseUrl=t.baseUrl.endsWith("/")?t.baseUrl.slice(0,-1):t.baseUrl,this.headers={"Content-Type":"application/json","X-MoonPay-Commerce-SDK-Version":R,...(r=this.consumer)!=null&&r.name?{"X-MoonPay-Commerce-Consumer":this.consumer.name}:{},...(s=this.consumer)!=null&&s.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)}}class a{constructor(t){this.api=t}static create(t){return new a(new G(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=U;exports.BroadcastAck=P;exports.Platform=H;exports.SDK_PACKAGE_NAME=h;exports.SDK_VERSION=R;exports.SignedTransactionKind=d;exports.TERMINAL_STATES=w;exports.WithdrawalApiError=O;exports.WithdrawalErrorCode=I;exports.WithdrawalFeature=S;exports.WithdrawalSDK=a;exports.WithdrawalState=T;exports.decodeJwt=p;exports.isBelow=W;exports.isQuoteExpired=M;exports.isSupported=f;exports.toWithdrawalErrorCode=l;
@@ -41,7 +41,7 @@ const f = (e) => e && p.has(e) ? e : R.UNKNOWN, L = (e) => {
41
41
  }, F = (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.2.0", c = (e) => /^\d+$/.test(e);
44
+ }, O = "1.2.1-alpha.1784107550", c = (e) => /^\d+$/.test(e);
45
45
  function A(e) {
46
46
  if (typeof e != "string") return null;
47
47
  let t = e.trim();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@heliofi/withdraw-core",
3
3
  "private": false,
4
- "version": "1.2.0",
4
+ "version": "1.2.1-alpha.1784107550",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",