UNPKG

metal-presale

Version:

SDK for Metal Presales - Client and Server utilities

92 lines (91 loc) 2.71 kB
import { g as r, c as n, a as o } from "./shared/utils-Crf4vSn8.js"; import { h as b, e as M, j as H, f as S, b as q, d as v, k as B, i as x, s as C } from "./shared/utils-Crf4vSn8.js"; import { g as c, l, c as y, b as h, t as p, q as u, a as A, d as K, s as f, e as w, f as g } from "./shared/server-Cizl23X8.js"; class t extends Error { constructor() { super("Metal Secret API Key is required for this operation."), this.name = "Missing Metal Secret Key"; } } class T { constructor({ publicApiKey: e, secretApiKey: s }) { console.warn( "MetalPresales is deprecated. Use MetalPresalesClient for client-side or MetalPresalesServer for server-side usage." ), this.publicApiKey = e, this.secretApiKey = s; } /** * ----- Client-side methods can be used with a public API key. ----- */ async getHolder(e) { return r(e, this.publicApiKey); } async getHolderWithPortfolio(e) { const s = await r(e, this.publicApiKey), a = n(s); return { holder: s, portfolio: a }; } async getPresale(e) { return o(e, this.publicApiKey); } /** * ----- Server-side only methods require a secret API key. ----- */ async getOrCreateHolder(e) { if (!this.secretApiKey) throw new t(); return c(e, this.secretApiKey); } async listPresales() { if (!this.secretApiKey) throw new t(); return l(this.secretApiKey); } async createPresale(e) { if (!this.secretApiKey) throw new t(); return y(e, this.secretApiKey); } async buyPresale(e, s) { if (!this.secretApiKey) throw new t(); return h(e, s, this.secretApiKey); } async transfer(e, s) { if (!this.secretApiKey) throw new t(); return p(e, s, this.secretApiKey); } async quoteBuyTokens(e, s) { if (!this.secretApiKey) throw new t(); return u(e, s, this.secretApiKey); } async buyTokens(e, s) { if (!this.secretApiKey) throw new t(); return A(e, s, this.secretApiKey); } async quoteSellTokens(e, s) { if (!this.secretApiKey) throw new t(); return K(e, s, this.secretApiKey); } async sellTokens(e, s) { if (!this.secretApiKey) throw new t(); return f(e, s, this.secretApiKey); } async getTokenWithHolders(e) { if (!this.secretApiKey) throw new t(); return w(e, this.secretApiKey); } async getActivePresales() { if (!this.secretApiKey) throw new t(); return g(this.secretApiKey); } } export { T as MetalPresales, n as calculatePortfolioSummary, b as calculateTotalValue, M as filterTokensByType, H as findToken, S as formatTimeRemaining, q as getPresaleProgress, v as getPresaleTimeRemaining, B as getUnlockedTokens, x as isPresaleActive, C as sortTokensByValue };