@injectivelabs/utils
Advanced tools
| const require_BigNumber = require('./BigNumber-DbDA4_xA.cjs'); | ||
| const require_BigNumberInBase = require('./BigNumberInBase-CVKbAXw6.cjs'); | ||
| exports.BigNumber = require_BigNumber.BigNumber_default; | ||
| exports.BigNumberInBase = require_BigNumberInBase.BigNumberInBase; | ||
| exports.BigNumberInWei = require_BigNumberInBase.BigNumberInWei; | ||
| exports.toBigNumber = require_BigNumber.toBigNumber; | ||
| exports.toChainFormat = require_BigNumber.toChainFormat; | ||
| exports.toHumanReadable = require_BigNumber.toHumanReadable; |
| import { i as toHumanReadable, n as toBigNumber, r as toChainFormat, t as BigNumber } from "./BigNumber-B-r__Egf.cjs"; | ||
| import { n as BigNumberInBase, t as BigNumberInWei } from "./BigNumberInWei-BMQpZg3S.cjs"; | ||
| export { BigNumber, BigNumberInBase, BigNumberInWei, toBigNumber, toChainFormat, toHumanReadable }; |
| import BigNumber from "bignumber.js"; | ||
| //#region src/classes/BigNumber.d.ts | ||
| /** | ||
| * Converts a value to BigNumber if it isn't already | ||
| */ | ||
| declare const toBigNumber: (value: BigNumber | string | number) => BigNumber; | ||
| /** | ||
| * Converts a value to Wei (multiplies by 10^decimals) default to 18 decimals | ||
| */ | ||
| declare const toChainFormat: (value: BigNumber | string | number, decimals?: number) => BigNumber; | ||
| /** | ||
| * Converts a value from Wei to Base (divides by 10^decimals) default to 18 decimals | ||
| */ | ||
| declare const toHumanReadable: (value: BigNumber | string | number, decimals?: number) => BigNumber; | ||
| //#endregion | ||
| export { toHumanReadable as i, toBigNumber as n, toChainFormat as r, BigNumber as t }; |
| const require_chunk = require('./chunk-CbDLau6x.cjs'); | ||
| let bignumber_js = require("bignumber.js"); | ||
| bignumber_js = require_chunk.__toESM(bignumber_js); | ||
| //#region src/classes/BigNumber.ts | ||
| var BigNumber_default = bignumber_js.default; | ||
| /** | ||
| * Converts a value to BigNumber if it isn't already | ||
| */ | ||
| const toBigNumber = (value) => { | ||
| if (value instanceof bignumber_js.default) return value; | ||
| return new bignumber_js.default(value); | ||
| }; | ||
| /** | ||
| * Converts a value to Wei (multiplies by 10^decimals) default to 18 decimals | ||
| */ | ||
| const toChainFormat = (value, decimals = 18) => { | ||
| return toBigNumber(value).multipliedBy(new bignumber_js.default(10).pow(decimals)); | ||
| }; | ||
| /** | ||
| * Converts a value from Wei to Base (divides by 10^decimals) default to 18 decimals | ||
| */ | ||
| const toHumanReadable = (value, decimals = 18) => { | ||
| return toBigNumber(value).dividedBy(new bignumber_js.default(10).pow(decimals)); | ||
| }; | ||
| //#endregion | ||
| Object.defineProperty(exports, 'BigNumber_default', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return BigNumber_default; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'toBigNumber', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return toBigNumber; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'toChainFormat', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return toChainFormat; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'toHumanReadable', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return toHumanReadable; | ||
| } | ||
| }); |
| const require_BigNumber = require('./BigNumber-DbDA4_xA.cjs'); | ||
| //#region src/classes/BigNumberInWei.ts | ||
| /** | ||
| * @deprecated - use toChainFormat instead | ||
| */ | ||
| var BigNumberInWei = class BigNumberInWei extends require_BigNumber.BigNumber_default { | ||
| static make(number) { | ||
| return new BigNumberInWei(number); | ||
| } | ||
| minus(n, base) { | ||
| return new BigNumberInWei(super.minus(n, base)); | ||
| } | ||
| plus(n, base) { | ||
| return new BigNumberInWei(super.plus(n, base)); | ||
| } | ||
| dividedBy(n, base) { | ||
| return new BigNumberInWei(super.dividedBy(n, base)); | ||
| } | ||
| div(n, base) { | ||
| return new BigNumberInWei(super.div(n, base)); | ||
| } | ||
| multipliedBy(n, base) { | ||
| return new BigNumberInWei(super.multipliedBy(n, base)); | ||
| } | ||
| times(n, base) { | ||
| return new BigNumberInWei(super.times(n, base)); | ||
| } | ||
| pow(n, base) { | ||
| return new BigNumberInWei(super.pow(n, base)); | ||
| } | ||
| toBase(decimals = 18) { | ||
| return new require_BigNumber.BigNumber_default(this).dividedBy(new require_BigNumber.BigNumber_default(10).pow(decimals)); | ||
| } | ||
| }; | ||
| //#endregion | ||
| //#region src/classes/BigNumberInBase.ts | ||
| /** | ||
| * @deprecated - use toHumanReadable instead | ||
| */ | ||
| var BigNumberInBase = class BigNumberInBase extends require_BigNumber.BigNumber_default { | ||
| static make(number) { | ||
| return new BigNumberInBase(number); | ||
| } | ||
| minus(n, base) { | ||
| return new BigNumberInBase(super.minus(n, base)); | ||
| } | ||
| plus(n, base) { | ||
| return new BigNumberInBase(super.plus(n, base)); | ||
| } | ||
| dividedBy(n, base) { | ||
| return new BigNumberInBase(super.dividedBy(n, base)); | ||
| } | ||
| div(n, base) { | ||
| return new BigNumberInBase(super.div(n, base)); | ||
| } | ||
| multipliedBy(n, base) { | ||
| return new BigNumberInBase(super.multipliedBy(n, base)); | ||
| } | ||
| times(n, base) { | ||
| return new BigNumberInBase(super.times(n, base)); | ||
| } | ||
| pow(n, base) { | ||
| return new BigNumberInBase(super.pow(n, base)); | ||
| } | ||
| toWei(decimals = 18) { | ||
| return new require_BigNumber.BigNumber_default(this).multipliedBy(new require_BigNumber.BigNumber_default(10).pow(decimals)); | ||
| } | ||
| }; | ||
| //#endregion | ||
| Object.defineProperty(exports, 'BigNumberInBase', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return BigNumberInBase; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'BigNumberInWei', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return BigNumberInWei; | ||
| } | ||
| }); |
| import { t as BigNumber } from "./BigNumber-B-r__Egf.cjs"; | ||
| //#region src/classes/BigNumberInBase.d.ts | ||
| /** | ||
| * @deprecated - use toHumanReadable instead | ||
| */ | ||
| declare class BigNumberInBase extends BigNumber { | ||
| static make(number: BigNumber.Value): BigNumberInBase; | ||
| minus(n: BigNumber.Value, base?: number): BigNumberInBase; | ||
| plus(n: BigNumber.Value, base?: number): BigNumberInBase; | ||
| dividedBy(n: BigNumber.Value, base?: number): BigNumberInBase; | ||
| div(n: BigNumber.Value, base?: number): BigNumberInBase; | ||
| multipliedBy(n: BigNumber.Value, base?: number): BigNumberInBase; | ||
| times(n: BigNumber.Value, base?: number): BigNumberInBase; | ||
| pow(n: BigNumber.Value, base?: number): BigNumberInBase; | ||
| toWei(decimals?: number): BigNumberInWei; | ||
| } | ||
| //#endregion | ||
| //#region src/classes/BigNumberInWei.d.ts | ||
| /** | ||
| * @deprecated - use toChainFormat instead | ||
| */ | ||
| declare class BigNumberInWei extends BigNumber { | ||
| static make(number: BigNumber.Value): BigNumberInWei; | ||
| minus(n: BigNumber.Value, base?: number): BigNumberInWei; | ||
| plus(n: BigNumber.Value, base?: number): BigNumberInWei; | ||
| dividedBy(n: BigNumber.Value, base?: number): BigNumberInWei; | ||
| div(n: BigNumber.Value, base?: number): BigNumberInWei; | ||
| multipliedBy(n: BigNumber.Value, base?: number): BigNumberInWei; | ||
| times(n: BigNumber.Value, base?: number): BigNumberInWei; | ||
| pow(n: BigNumber.Value, base?: number): BigNumberInWei; | ||
| toBase(decimals?: number): BigNumberInBase; | ||
| } | ||
| //#endregion | ||
| export { BigNumberInBase as n, BigNumberInWei as t }; |
| //#region rolldown:runtime | ||
| var __create = Object.create; | ||
| var __defProp = Object.defineProperty; | ||
| var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||
| var __getProtoOf = Object.getPrototypeOf; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __copyProps = (to, from, except, desc) => { | ||
| if (from && typeof from === "object" || typeof from === "function") { | ||
| for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) { | ||
| key = keys[i]; | ||
| if (!__hasOwnProp.call(to, key) && key !== except) { | ||
| __defProp(to, key, { | ||
| get: ((k) => from[k]).bind(null, key), | ||
| enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable | ||
| }); | ||
| } | ||
| } | ||
| } | ||
| return to; | ||
| }; | ||
| var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { | ||
| value: mod, | ||
| enumerable: true | ||
| }) : target, mod)); | ||
| //#endregion | ||
| Object.defineProperty(exports, '__toESM', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return __toESM; | ||
| } | ||
| }); |
| const require_BigNumber = require('./BigNumber-DbDA4_xA.cjs'); | ||
| //#region src/constants.ts | ||
| const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000"; | ||
| const INJ_DENOM = "inj"; | ||
| const INJECTIVE_DENOM = "inj"; | ||
| const DEFAULT_FEE_DENOM = "inj"; | ||
| const DEFAULT_GAS_LIMIT = 4e5; | ||
| const DEFAULT_IBC_GAS_LIMIT = 3e5; | ||
| const DEFAULT_GAS_PRICE = 16e7; | ||
| const DEFAULT_EXCHANGE_LIMIT = 2e5; | ||
| const DEFAULT_BRIDGE_FEE_DENOM = "inj"; | ||
| const DEFAULT_BRIDGE_FEE_PRICE = "160000000"; | ||
| const DEFAULT_BRIDGE_FEE_AMOUNT = "200000000000000"; | ||
| const DEFAULT_BLOCK_TIMEOUT_HEIGHT = 60; | ||
| const DEFAULT_BLOCK_TIME_IN_SECONDS = .7; | ||
| /** | ||
| * Default timeout for transaction block inclusion polling. | ||
| * | ||
| * Calculation: 120 blocks × 0.7 seconds/block = 84 seconds = 84,000ms | ||
| */ | ||
| const DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS = Math.floor(DEFAULT_BLOCK_TIMEOUT_HEIGHT * DEFAULT_BLOCK_TIME_IN_SECONDS * 1e3); | ||
| const DEFAULT_TX_POLL_INTERVAL_MS = 500; | ||
| const DEFAULT_TX_POLL_CALL_TIMEOUT_MS = 3e3; | ||
| const DEFAULT_TIMESTAMP_TIMEOUT_MS = 60 * 1e3 * 3; | ||
| const getDefaultStdFee = () => ({ | ||
| amount: [{ | ||
| amount: new require_BigNumber.BigNumber_default(DEFAULT_GAS_LIMIT).times(DEFAULT_GAS_PRICE).toString(), | ||
| denom: "inj" | ||
| }], | ||
| gas: DEFAULT_GAS_LIMIT.toString(), | ||
| payer: "", | ||
| granter: "", | ||
| feePayer: "" | ||
| }); | ||
| const DEFAULT_STD_FEE_BY_DENOM = (denom = "inj") => ({ | ||
| amount: [{ | ||
| denom, | ||
| amount: new require_BigNumber.BigNumber_default(DEFAULT_GAS_LIMIT).times(DEFAULT_GAS_PRICE).toString() | ||
| }], | ||
| gas: DEFAULT_GAS_LIMIT.toString() | ||
| }); | ||
| //#endregion | ||
| Object.defineProperty(exports, 'DEFAULT_BLOCK_TIMEOUT_HEIGHT', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return DEFAULT_BLOCK_TIMEOUT_HEIGHT; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'DEFAULT_BLOCK_TIME_IN_SECONDS', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return DEFAULT_BLOCK_TIME_IN_SECONDS; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'DEFAULT_BRIDGE_FEE_AMOUNT', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return DEFAULT_BRIDGE_FEE_AMOUNT; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'DEFAULT_BRIDGE_FEE_DENOM', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return DEFAULT_BRIDGE_FEE_DENOM; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'DEFAULT_BRIDGE_FEE_PRICE', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return DEFAULT_BRIDGE_FEE_PRICE; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'DEFAULT_EXCHANGE_LIMIT', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return DEFAULT_EXCHANGE_LIMIT; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'DEFAULT_FEE_DENOM', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return DEFAULT_FEE_DENOM; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'DEFAULT_GAS_LIMIT', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return DEFAULT_GAS_LIMIT; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'DEFAULT_GAS_PRICE', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return DEFAULT_GAS_PRICE; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'DEFAULT_IBC_GAS_LIMIT', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return DEFAULT_IBC_GAS_LIMIT; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'DEFAULT_STD_FEE_BY_DENOM', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return DEFAULT_STD_FEE_BY_DENOM; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'DEFAULT_TIMESTAMP_TIMEOUT_MS', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return DEFAULT_TIMESTAMP_TIMEOUT_MS; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'DEFAULT_TX_POLL_CALL_TIMEOUT_MS', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return DEFAULT_TX_POLL_CALL_TIMEOUT_MS; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'DEFAULT_TX_POLL_INTERVAL_MS', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return DEFAULT_TX_POLL_INTERVAL_MS; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'INJECTIVE_DENOM', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return INJECTIVE_DENOM; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'INJ_DENOM', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return INJ_DENOM; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'ZERO_ADDRESS', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return ZERO_ADDRESS; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'getDefaultStdFee', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return getDefaultStdFee; | ||
| } | ||
| }); |
| //#region src/constants.d.ts | ||
| declare const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000"; | ||
| declare const INJ_DENOM = "inj"; | ||
| declare const INJECTIVE_DENOM = "inj"; | ||
| declare const DEFAULT_FEE_DENOM = "inj"; | ||
| declare const DEFAULT_GAS_LIMIT = 400000; | ||
| declare const DEFAULT_IBC_GAS_LIMIT = 300000; | ||
| declare const DEFAULT_GAS_PRICE = 160000000; | ||
| declare const DEFAULT_EXCHANGE_LIMIT = 200000; | ||
| declare const DEFAULT_BRIDGE_FEE_DENOM = "inj"; | ||
| declare const DEFAULT_BRIDGE_FEE_PRICE = "160000000"; | ||
| declare const DEFAULT_BRIDGE_FEE_AMOUNT = "200000000000000"; | ||
| declare const DEFAULT_BLOCK_TIMEOUT_HEIGHT = 60; | ||
| declare const DEFAULT_BLOCK_TIME_IN_SECONDS = 0.7; | ||
| /** | ||
| * Default timeout for transaction block inclusion polling. | ||
| * | ||
| * Calculation: 120 blocks × 0.7 seconds/block = 84 seconds = 84,000ms | ||
| */ | ||
| declare const DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS: number; | ||
| declare const DEFAULT_TX_POLL_INTERVAL_MS = 500; | ||
| declare const DEFAULT_TX_POLL_CALL_TIMEOUT_MS = 3000; | ||
| declare const DEFAULT_TIMESTAMP_TIMEOUT_MS: number; | ||
| declare const getDefaultStdFee: () => { | ||
| amount: { | ||
| amount: string; | ||
| denom: string; | ||
| }[]; | ||
| gas: string; | ||
| payer: string; | ||
| granter: string; | ||
| feePayer: string; | ||
| }; | ||
| declare const DEFAULT_STD_FEE_BY_DENOM: (denom?: string) => { | ||
| amount: { | ||
| denom: string; | ||
| amount: string; | ||
| }[]; | ||
| gas: string; | ||
| }; | ||
| //#endregion | ||
| export { INJ_DENOM as _, DEFAULT_BRIDGE_FEE_PRICE as a, DEFAULT_GAS_LIMIT as c, DEFAULT_STD_FEE_BY_DENOM as d, DEFAULT_TIMESTAMP_TIMEOUT_MS as f, INJECTIVE_DENOM as g, DEFAULT_TX_POLL_INTERVAL_MS as h, DEFAULT_BRIDGE_FEE_DENOM as i, DEFAULT_GAS_PRICE as l, DEFAULT_TX_POLL_CALL_TIMEOUT_MS as m, DEFAULT_BLOCK_TIME_IN_SECONDS as n, DEFAULT_EXCHANGE_LIMIT as o, DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS as p, DEFAULT_BRIDGE_FEE_AMOUNT as r, DEFAULT_FEE_DENOM as s, DEFAULT_BLOCK_TIMEOUT_HEIGHT as t, DEFAULT_IBC_GAS_LIMIT as u, ZERO_ADDRESS as v, getDefaultStdFee as y }; |
| require('./BigNumber-DbDA4_xA.cjs'); | ||
| const require_constants = require('./constants-BdaegCnI.cjs'); | ||
| exports.DEFAULT_BLOCK_TIMEOUT_HEIGHT = require_constants.DEFAULT_BLOCK_TIMEOUT_HEIGHT; | ||
| exports.DEFAULT_BLOCK_TIME_IN_SECONDS = require_constants.DEFAULT_BLOCK_TIME_IN_SECONDS; | ||
| exports.DEFAULT_BRIDGE_FEE_AMOUNT = require_constants.DEFAULT_BRIDGE_FEE_AMOUNT; | ||
| exports.DEFAULT_BRIDGE_FEE_DENOM = require_constants.DEFAULT_BRIDGE_FEE_DENOM; | ||
| exports.DEFAULT_BRIDGE_FEE_PRICE = require_constants.DEFAULT_BRIDGE_FEE_PRICE; | ||
| exports.DEFAULT_EXCHANGE_LIMIT = require_constants.DEFAULT_EXCHANGE_LIMIT; | ||
| exports.DEFAULT_FEE_DENOM = require_constants.DEFAULT_FEE_DENOM; | ||
| exports.DEFAULT_GAS_LIMIT = require_constants.DEFAULT_GAS_LIMIT; | ||
| exports.DEFAULT_GAS_PRICE = require_constants.DEFAULT_GAS_PRICE; | ||
| exports.DEFAULT_IBC_GAS_LIMIT = require_constants.DEFAULT_IBC_GAS_LIMIT; | ||
| exports.DEFAULT_STD_FEE_BY_DENOM = require_constants.DEFAULT_STD_FEE_BY_DENOM; | ||
| exports.DEFAULT_TIMESTAMP_TIMEOUT_MS = require_constants.DEFAULT_TIMESTAMP_TIMEOUT_MS; | ||
| exports.DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS = require_constants.DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS; | ||
| exports.DEFAULT_TX_POLL_CALL_TIMEOUT_MS = require_constants.DEFAULT_TX_POLL_CALL_TIMEOUT_MS; | ||
| exports.DEFAULT_TX_POLL_INTERVAL_MS = require_constants.DEFAULT_TX_POLL_INTERVAL_MS; | ||
| exports.INJECTIVE_DENOM = require_constants.INJECTIVE_DENOM; | ||
| exports.INJ_DENOM = require_constants.INJ_DENOM; | ||
| exports.ZERO_ADDRESS = require_constants.ZERO_ADDRESS; | ||
| exports.getDefaultStdFee = require_constants.getDefaultStdFee; |
| import { _ as INJ_DENOM, a as DEFAULT_BRIDGE_FEE_PRICE, c as DEFAULT_GAS_LIMIT, d as DEFAULT_STD_FEE_BY_DENOM, f as DEFAULT_TIMESTAMP_TIMEOUT_MS, g as INJECTIVE_DENOM, h as DEFAULT_TX_POLL_INTERVAL_MS, i as DEFAULT_BRIDGE_FEE_DENOM, l as DEFAULT_GAS_PRICE, m as DEFAULT_TX_POLL_CALL_TIMEOUT_MS, n as DEFAULT_BLOCK_TIME_IN_SECONDS, o as DEFAULT_EXCHANGE_LIMIT, p as DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS, r as DEFAULT_BRIDGE_FEE_AMOUNT, s as DEFAULT_FEE_DENOM, t as DEFAULT_BLOCK_TIMEOUT_HEIGHT, u as DEFAULT_IBC_GAS_LIMIT, v as ZERO_ADDRESS, y as getDefaultStdFee } from "./constants-BRub-WIk.cjs"; | ||
| export { DEFAULT_BLOCK_TIMEOUT_HEIGHT, DEFAULT_BLOCK_TIME_IN_SECONDS, DEFAULT_BRIDGE_FEE_AMOUNT, DEFAULT_BRIDGE_FEE_DENOM, DEFAULT_BRIDGE_FEE_PRICE, DEFAULT_EXCHANGE_LIMIT, DEFAULT_FEE_DENOM, DEFAULT_GAS_LIMIT, DEFAULT_GAS_PRICE, DEFAULT_IBC_GAS_LIMIT, DEFAULT_STD_FEE_BY_DENOM, DEFAULT_TIMESTAMP_TIMEOUT_MS, DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS, DEFAULT_TX_POLL_CALL_TIMEOUT_MS, DEFAULT_TX_POLL_INTERVAL_MS, INJECTIVE_DENOM, INJ_DENOM, ZERO_ADDRESS, getDefaultStdFee }; |
| //#region \0@oxc-project+runtime@0.99.0/helpers/typeof.js | ||
| function _typeof(o) { | ||
| "@babel/helpers - typeof"; | ||
| return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) { | ||
| return typeof o$1; | ||
| } : function(o$1) { | ||
| return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1; | ||
| }, _typeof(o); | ||
| } | ||
| //#endregion | ||
| //#region \0@oxc-project+runtime@0.99.0/helpers/toPrimitive.js | ||
| function toPrimitive(t, r) { | ||
| if ("object" != _typeof(t) || !t) return t; | ||
| var e = t[Symbol.toPrimitive]; | ||
| if (void 0 !== e) { | ||
| var i = e.call(t, r || "default"); | ||
| if ("object" != _typeof(i)) return i; | ||
| throw new TypeError("@@toPrimitive must return a primitive value."); | ||
| } | ||
| return ("string" === r ? String : Number)(t); | ||
| } | ||
| //#endregion | ||
| //#region \0@oxc-project+runtime@0.99.0/helpers/toPropertyKey.js | ||
| function toPropertyKey(t) { | ||
| var i = toPrimitive(t, "string"); | ||
| return "symbol" == _typeof(i) ? i : i + ""; | ||
| } | ||
| //#endregion | ||
| //#region \0@oxc-project+runtime@0.99.0/helpers/defineProperty.js | ||
| function _defineProperty(e, r, t) { | ||
| return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, { | ||
| value: t, | ||
| enumerable: !0, | ||
| configurable: !0, | ||
| writable: !0 | ||
| }) : e[r] = t, e; | ||
| } | ||
| //#endregion | ||
| Object.defineProperty(exports, '_defineProperty', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return _defineProperty; | ||
| } | ||
| }); |
| //#region src/formatters.ts | ||
| const formatWalletAddress = (address, substrLength = 6) => { | ||
| if (address.length <= 10) return address; | ||
| return `${address.slice(0, substrLength)}...${address.slice(address.length - substrLength, address.length)}`; | ||
| }; | ||
| const toPascalCase = (str) => { | ||
| return `${str}`.toLowerCase().replace(new RegExp(/[-_]+/, "g"), " ").replace(new RegExp(/[^\w\s]/, "g"), "").replace(new RegExp(/\s+(.)(\w*)/, "g"), (_$1, $2, $3) => `${$2.toUpperCase() + $3}`).replace(/* @__PURE__ */ new RegExp(/\w/), (s) => s.toUpperCase()); | ||
| }; | ||
| const snakeToPascal = (str) => { | ||
| return str.split("/").map((snake) => snake.split("_").map((substr) => substr.charAt(0).toUpperCase() + substr.slice(1)).join("")).join("/"); | ||
| }; | ||
| const capitalize = (str) => { | ||
| if (!str) return str; | ||
| return str[0].toUpperCase() + str.slice(1); | ||
| }; | ||
| //#endregion | ||
| Object.defineProperty(exports, 'capitalize', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return capitalize; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'formatWalletAddress', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return formatWalletAddress; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'snakeToPascal', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return snakeToPascal; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'toPascalCase', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return toPascalCase; | ||
| } | ||
| }); |
| import { AccountAddress } from "@injectivelabs/ts-types"; | ||
| //#region src/formatters.d.ts | ||
| declare const formatWalletAddress: (address: AccountAddress, substrLength?: number) => string; | ||
| declare const toPascalCase: (str: string) => string; | ||
| declare const snakeToPascal: (str: string) => string; | ||
| declare const capitalize: (str: string) => string; | ||
| //#endregion | ||
| export { toPascalCase as i, formatWalletAddress as n, snakeToPascal as r, capitalize as t }; |
| const require_formatters = require('./formatters-CBhRviK1.cjs'); | ||
| exports.capitalize = require_formatters.capitalize; | ||
| exports.formatWalletAddress = require_formatters.formatWalletAddress; | ||
| exports.snakeToPascal = require_formatters.snakeToPascal; | ||
| exports.toPascalCase = require_formatters.toPascalCase; |
| import { i as toPascalCase, n as formatWalletAddress, r as snakeToPascal, t as capitalize } from "./formatters-lY6KvxzC.cjs"; | ||
| export { capitalize, formatWalletAddress, snakeToPascal, toPascalCase }; |
| //#region src/types.d.ts | ||
| type Awaited<T> = T extends null | undefined ? T : T extends object & { | ||
| then(onfulfilled: infer F, ...args: infer _): any; | ||
| } ? F extends ((value: infer V, ...args: infer _) => any) ? Awaited<V> : never : T; | ||
| //#endregion | ||
| //#region src/helpers.d.ts | ||
| declare const sleep: (timeout: number) => Promise<void>; | ||
| /** | ||
| * When we want to execute the promises in batch | ||
| */ | ||
| declare const awaitAll: <T, S>(array: Array<T>, callback: (item: T) => Promise<S>) => Promise<Awaited<S>[]>; | ||
| /** | ||
| * When we want to execute the promises one by one | ||
| * and not all in batch as with await Promise.all() | ||
| */ | ||
| declare const awaitForAll: <T, S>(array: Array<T>, callback: (item: T) => Promise<S>, onError?: (error: unknown, item: T, index: number) => void) => Promise<S[]>; | ||
| declare const splitArrayToChunksThrow: <T>({ | ||
| array, | ||
| filter, | ||
| chunkSize | ||
| }: { | ||
| array: Array<T>; | ||
| chunkSize: number; | ||
| filter?: (item: T) => boolean; | ||
| }) => T[][]; | ||
| declare const splitArrayToChunks: <T>({ | ||
| array, | ||
| filter, | ||
| chunkSize | ||
| }: { | ||
| array: Array<T>; | ||
| chunkSize: number; | ||
| filter?: (item: T) => boolean; | ||
| }) => T[][]; | ||
| declare const getStdFeeForToken: (token?: { | ||
| denom: string; | ||
| decimals: number; | ||
| }, gasPrice?: string, gasLimit?: string) => { | ||
| amount: { | ||
| denom: string; | ||
| amount: string; | ||
| }[]; | ||
| gas: string; | ||
| }; | ||
| declare const getStdFeeFromObject: (args?: { | ||
| gas?: string | number; | ||
| payer?: string; | ||
| granter?: string; | ||
| gasPrice?: string | number; | ||
| feePayer?: string; | ||
| }) => { | ||
| amount: { | ||
| denom: string; | ||
| amount: string; | ||
| }[]; | ||
| gas: string; | ||
| payer: string | undefined; /** for Web3Gateway fee delegation */ | ||
| granter: string | undefined; | ||
| feePayer: string | undefined; | ||
| }; | ||
| declare const getStdFeeFromString: (gasPrice: string) => { | ||
| amount: { | ||
| denom: string; | ||
| amount: string; | ||
| }[]; | ||
| gas: string; | ||
| payer: string | undefined; /** for Web3Gateway fee delegation */ | ||
| granter: string | undefined; | ||
| feePayer: string | undefined; | ||
| }; | ||
| declare const getStdFee: (args?: string | { | ||
| payer?: string; | ||
| granter?: string; | ||
| feePayer?: string; | ||
| gas?: string | number; | ||
| gasPrice?: string | number; | ||
| }) => { | ||
| amount: { | ||
| denom: string; | ||
| amount: string; | ||
| }[]; | ||
| gas: string; | ||
| payer: string | undefined; /** for Web3Gateway fee delegation */ | ||
| granter: string | undefined; | ||
| feePayer: string | undefined; | ||
| }; | ||
| //#endregion | ||
| export { getStdFeeFromObject as a, splitArrayToChunks as c, getStdFeeForToken as i, splitArrayToChunksThrow as l, awaitForAll as n, getStdFeeFromString as o, getStdFee as r, sleep as s, awaitAll as t }; |
| const require_BigNumber = require('./BigNumber-DbDA4_xA.cjs'); | ||
| const require_constants = require('./constants-BdaegCnI.cjs'); | ||
| //#region src/helpers.ts | ||
| const sleep = (timeout) => new Promise((resolve) => setTimeout(resolve, timeout)); | ||
| /** | ||
| * When we want to execute the promises in batch | ||
| */ | ||
| const awaitAll = async (array, callback) => await Promise.all(array.map(async (item) => await callback(item))); | ||
| /** | ||
| * When we want to execute the promises one by one | ||
| * and not all in batch as with await Promise.all() | ||
| */ | ||
| const awaitForAll = async (array, callback, onError) => { | ||
| const result = []; | ||
| for (let i = 0; i < array.length; i += 1) try { | ||
| result.push(await callback(array[i])); | ||
| } catch (e) { | ||
| if (onError) onError(e, array[i], i); | ||
| } | ||
| return result; | ||
| }; | ||
| const splitArrayToChunksThrow = ({ array, filter, chunkSize }) => { | ||
| const chunks = []; | ||
| const chunkSizeInNumber = Number(chunkSize); | ||
| if (!Number.isFinite(chunkSizeInNumber) || !Number.isInteger(chunkSizeInNumber) || chunkSizeInNumber <= 0) throw new Error("Invalid chunk size, must be a positive integer"); | ||
| for (let i = 0; i < array.length; i += chunkSizeInNumber) { | ||
| const chunk = array.slice(i, i + chunkSizeInNumber); | ||
| if (filter) chunks.push(chunk.filter(filter)); | ||
| else chunks.push(chunk); | ||
| } | ||
| return chunks; | ||
| }; | ||
| const splitArrayToChunks = ({ array, filter, chunkSize }) => { | ||
| try { | ||
| return splitArrayToChunksThrow({ | ||
| array, | ||
| chunkSize, | ||
| filter | ||
| }); | ||
| } catch (_unused) { | ||
| return [array]; | ||
| } | ||
| }; | ||
| const getStdFeeForToken = (token = { | ||
| denom: "inj", | ||
| decimals: 18 | ||
| }, gasPrice, gasLimit) => { | ||
| const gasPriceScaled = require_BigNumber.toChainFormat(gasPrice || require_BigNumber.toHumanReadable(require_constants.DEFAULT_GAS_PRICE, 18), token.decimals).toFixed(0); | ||
| const gasNormalized = new require_BigNumber.BigNumber_default(gasLimit || require_constants.DEFAULT_GAS_LIMIT).toFixed(0); | ||
| return { | ||
| amount: [{ | ||
| denom: token.denom, | ||
| amount: new require_BigNumber.BigNumber_default(gasPriceScaled).times(gasNormalized).toFixed() | ||
| }], | ||
| gas: (gasLimit || require_constants.DEFAULT_GAS_LIMIT).toString() | ||
| }; | ||
| }; | ||
| const getStdFeeFromObject = (args) => { | ||
| if (!args) return require_constants.getDefaultStdFee(); | ||
| const { payer, granter, feePayer, gasPrice = require_constants.DEFAULT_GAS_PRICE, gas = require_constants.DEFAULT_GAS_LIMIT.toString() } = args; | ||
| const gasNormalized = require_BigNumber.toBigNumber(gas).toFixed(0); | ||
| const gasPriceNormalized = require_BigNumber.toBigNumber(gasPrice).toFixed(0); | ||
| return { | ||
| amount: [{ | ||
| denom: "inj", | ||
| amount: require_BigNumber.toBigNumber(gasNormalized).times(gasPriceNormalized).toFixed() | ||
| }], | ||
| gas: require_BigNumber.toBigNumber(gasNormalized).toFixed(), | ||
| payer, | ||
| granter, | ||
| feePayer | ||
| }; | ||
| }; | ||
| const getStdFeeFromString = (gasPrice) => { | ||
| const matchResult = gasPrice.match(/^([0-9.]+)([a-zA-Z][a-zA-Z0-9/:._-]*)$/); | ||
| if (!matchResult) throw new Error("Invalid gas price string"); | ||
| const [_, amount] = matchResult; | ||
| return getStdFeeFromObject({ | ||
| gas: require_BigNumber.toChainFormat(amount, 18).dividedBy(require_constants.DEFAULT_GAS_PRICE).toFixed(0), | ||
| gasPrice: require_constants.DEFAULT_GAS_PRICE | ||
| }); | ||
| }; | ||
| const getStdFee = (args) => { | ||
| if (!args) return require_constants.getDefaultStdFee(); | ||
| if (typeof args === "string") return getStdFeeFromString(args); | ||
| return getStdFeeFromObject({ ...args }); | ||
| }; | ||
| //#endregion | ||
| Object.defineProperty(exports, 'awaitAll', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return awaitAll; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'awaitForAll', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return awaitForAll; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'getStdFee', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return getStdFee; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'getStdFeeForToken', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return getStdFeeForToken; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'getStdFeeFromObject', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return getStdFeeFromObject; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'getStdFeeFromString', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return getStdFeeFromString; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'sleep', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return sleep; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'splitArrayToChunks', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return splitArrayToChunks; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'splitArrayToChunksThrow', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return splitArrayToChunksThrow; | ||
| } | ||
| }); |
| require('./BigNumber-DbDA4_xA.cjs'); | ||
| require('./constants-BdaegCnI.cjs'); | ||
| const require_helpers = require('./helpers-BW4oKV4e.cjs'); | ||
| exports.awaitAll = require_helpers.awaitAll; | ||
| exports.awaitForAll = require_helpers.awaitForAll; | ||
| exports.getStdFee = require_helpers.getStdFee; | ||
| exports.getStdFeeForToken = require_helpers.getStdFeeForToken; | ||
| exports.getStdFeeFromObject = require_helpers.getStdFeeFromObject; | ||
| exports.getStdFeeFromString = require_helpers.getStdFeeFromString; | ||
| exports.sleep = require_helpers.sleep; | ||
| exports.splitArrayToChunks = require_helpers.splitArrayToChunks; | ||
| exports.splitArrayToChunksThrow = require_helpers.splitArrayToChunksThrow; |
| import { a as getStdFeeFromObject, c as splitArrayToChunks, i as getStdFeeForToken, l as splitArrayToChunksThrow, n as awaitForAll, o as getStdFeeFromString, r as getStdFee, s as sleep, t as awaitAll } from "./helpers-BmH3TkaY.cjs"; | ||
| export { awaitAll, awaitForAll, getStdFee, getStdFeeForToken, getStdFeeFromObject, getStdFeeFromString, sleep, splitArrayToChunks, splitArrayToChunksThrow }; |
| require('./defineProperty-CImP5zIM.cjs'); | ||
| const require_HttpRestClient = require('./HttpRestClient-C761J3nA.cjs'); | ||
| exports.HttpClient = require_HttpRestClient.HttpClient; | ||
| exports.HttpRestClient = require_HttpRestClient.HttpRestClient; |
| import { n as HttpClient, t as HttpRestClient } from "./HttpRestClient-C0p7w6ht.cjs"; | ||
| export { HttpClient, HttpRestClient }; |
| import { AxiosRequestConfig } from "axios"; | ||
| //#region src/classes/HttpClient.d.ts | ||
| declare class HttpClient { | ||
| private readonly client; | ||
| private config; | ||
| constructor(endpoint: string, options?: Record<string, any>); | ||
| setConfig(config: AxiosRequestConfig): HttpClient; | ||
| get<T, P>(endpoint: string, params?: T): Promise<P>; | ||
| post<T, P>(endpoint: string, data?: T): Promise<P>; | ||
| put<T, P>(endpoint: string, data?: T): Promise<P>; | ||
| delete<T, P>(endpoint: string, params?: T): Promise<P>; | ||
| } | ||
| //#endregion | ||
| //#region src/classes/HttpRestClient.d.ts | ||
| /** | ||
| * @hidden | ||
| */ | ||
| declare class HttpRestClient { | ||
| protected client: HttpClient; | ||
| protected endpoint: string; | ||
| constructor(endpoint: string, options?: Record<string, any>); | ||
| setConfig(config: AxiosRequestConfig): HttpRestClient; | ||
| get<T>(endpoint: string, params?: Record<string, any>): Promise<T>; | ||
| retry<TResponse>(httpCall: Function, retries?: number, delay?: number): Promise<TResponse>; | ||
| post<T>(endpoint: string, params?: Record<string, any>): Promise<T>; | ||
| } | ||
| //#endregion | ||
| export { HttpClient as n, HttpRestClient as t }; |
| const require_chunk = require('./chunk-CbDLau6x.cjs'); | ||
| const require_defineProperty = require('./defineProperty-CImP5zIM.cjs'); | ||
| let axios = require("axios"); | ||
| axios = require_chunk.__toESM(axios); | ||
| let http_status_codes = require("http-status-codes"); | ||
| let __injectivelabs_exceptions = require("@injectivelabs/exceptions"); | ||
| //#region src/classes/HttpClient.ts | ||
| var HttpClient = class { | ||
| constructor(endpoint, options = { headers: { "Content-Type": "application/json" } }) { | ||
| require_defineProperty._defineProperty(this, "client", void 0); | ||
| require_defineProperty._defineProperty(this, "config", {}); | ||
| this.client = axios.default.create({ | ||
| baseURL: endpoint, | ||
| timeout: 15e3, | ||
| ...options | ||
| }); | ||
| this.config = {}; | ||
| } | ||
| setConfig(config) { | ||
| this.config = config; | ||
| return this; | ||
| } | ||
| get(endpoint, params = {}) { | ||
| return this.client.get(endpoint, { | ||
| params, | ||
| ...this.config | ||
| }); | ||
| } | ||
| post(endpoint, data = {}) { | ||
| return this.client.post(endpoint, data, this.config); | ||
| } | ||
| put(endpoint, data = {}) { | ||
| return this.client.put(endpoint, data, this.config); | ||
| } | ||
| delete(endpoint, params = {}) { | ||
| return this.client.delete(endpoint, { | ||
| params, | ||
| ...this.config | ||
| }); | ||
| } | ||
| }; | ||
| //#endregion | ||
| //#region src/classes/HttpRestClient.ts | ||
| const getErrorMessage = (error, endpoint) => { | ||
| if (!error.response) return `The request to ${endpoint} has failed.`; | ||
| return error.response.data ? error.response.data.message || error.response.data.statusMessage || error.response.data : error.response.statusText; | ||
| }; | ||
| /** | ||
| * @hidden | ||
| */ | ||
| var HttpRestClient = class { | ||
| constructor(endpoint, options = {}) { | ||
| require_defineProperty._defineProperty(this, "client", void 0); | ||
| require_defineProperty._defineProperty(this, "endpoint", void 0); | ||
| this.client = new HttpClient(endpoint, options); | ||
| this.endpoint = endpoint; | ||
| } | ||
| setConfig(config) { | ||
| this.client.setConfig(config); | ||
| return this; | ||
| } | ||
| async get(endpoint, params = {}) { | ||
| try { | ||
| return await this.client.get(endpoint, params); | ||
| } catch (e) { | ||
| const error = e; | ||
| if (axios.default.isAxiosError(error)) { | ||
| if (error.code === "ECONNABORTED") throw new __injectivelabs_exceptions.HttpRequestException(new Error(error.message), { | ||
| code: http_status_codes.StatusCodes.REQUEST_TOO_LONG, | ||
| context: endpoint | ||
| }); | ||
| const message = getErrorMessage(error, endpoint); | ||
| throw new __injectivelabs_exceptions.HttpRequestException(new Error(message), { | ||
| context: endpoint, | ||
| code: error.response ? error.response.status : http_status_codes.StatusCodes.BAD_REQUEST | ||
| }); | ||
| } | ||
| throw new __injectivelabs_exceptions.HttpRequestException(new Error(error.message), { | ||
| code: __injectivelabs_exceptions.UnspecifiedErrorCode, | ||
| context: endpoint | ||
| }); | ||
| } | ||
| } | ||
| async retry(httpCall, retries = 3, delay = 1e3) { | ||
| const retryHttpCall = async (attempt = 1) => { | ||
| try { | ||
| return await httpCall(); | ||
| } catch (e) { | ||
| if (e instanceof __injectivelabs_exceptions.HttpRequestException) { | ||
| if (e.code === http_status_codes.StatusCodes.REQUEST_TOO_LONG) throw e; | ||
| } | ||
| if (attempt >= retries) throw e; | ||
| return new Promise((resolve) => setTimeout(() => resolve(retryHttpCall(attempt + 1)), delay * attempt)); | ||
| } | ||
| }; | ||
| return retryHttpCall(); | ||
| } | ||
| async post(endpoint, params = {}) { | ||
| try { | ||
| return await this.client.post(endpoint, params); | ||
| } catch (e) { | ||
| const error = e; | ||
| if (axios.default.isAxiosError(error)) { | ||
| if (error.code === "ECONNABORTED") throw new __injectivelabs_exceptions.HttpRequestException(new Error(error.message), { | ||
| code: http_status_codes.StatusCodes.REQUEST_TOO_LONG, | ||
| method: __injectivelabs_exceptions.HttpRequestMethod.Post | ||
| }); | ||
| const message = getErrorMessage(error, endpoint); | ||
| throw new __injectivelabs_exceptions.HttpRequestException(new Error(message), { | ||
| code: error.response ? error.response.status : http_status_codes.StatusCodes.BAD_REQUEST, | ||
| context: endpoint, | ||
| contextModule: __injectivelabs_exceptions.HttpRequestMethod.Post | ||
| }); | ||
| } | ||
| throw new __injectivelabs_exceptions.HttpRequestException(new Error(error.message), { | ||
| code: __injectivelabs_exceptions.UnspecifiedErrorCode, | ||
| context: endpoint, | ||
| contextModule: __injectivelabs_exceptions.HttpRequestMethod.Post | ||
| }); | ||
| } | ||
| } | ||
| }; | ||
| //#endregion | ||
| Object.defineProperty(exports, 'HttpClient', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return HttpClient; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'HttpRestClient', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return HttpRestClient; | ||
| } | ||
| }); |
| const require_defineProperty = require('./defineProperty-CImP5zIM.cjs'); | ||
| //#region src/light.ts | ||
| const StatusType = { | ||
| Idle: "idle", | ||
| Loading: "loading", | ||
| Completed: "completed", | ||
| Error: "error", | ||
| Confirmed: "confirmed" | ||
| }; | ||
| var Status = class { | ||
| constructor(status = StatusType.Idle) { | ||
| require_defineProperty._defineProperty(this, "status", void 0); | ||
| this.status = status; | ||
| } | ||
| get() { | ||
| return this.status; | ||
| } | ||
| set(status) { | ||
| this.status = status; | ||
| } | ||
| is(status) { | ||
| return this.status === status; | ||
| } | ||
| isLoading() { | ||
| return this.is(StatusType.Loading); | ||
| } | ||
| isNotLoading() { | ||
| return !this.is(StatusType.Loading); | ||
| } | ||
| isCompleted() { | ||
| return this.is(StatusType.Completed); | ||
| } | ||
| isConfirmed() { | ||
| return this.is(StatusType.Confirmed); | ||
| } | ||
| isIdle() { | ||
| return this.is(StatusType.Idle); | ||
| } | ||
| isError() { | ||
| return this.is(StatusType.Error); | ||
| } | ||
| setLoading() { | ||
| this.set(StatusType.Loading); | ||
| } | ||
| setCompleted() { | ||
| this.set(StatusType.Completed); | ||
| } | ||
| setConfirmed() { | ||
| this.set(StatusType.Confirmed); | ||
| } | ||
| setError() { | ||
| this.set(StatusType.Error); | ||
| } | ||
| setIdle() { | ||
| this.set(StatusType.Idle); | ||
| } | ||
| toggle() { | ||
| this.set(this.status === StatusType.Idle ? StatusType.Loading : StatusType.Idle); | ||
| } | ||
| toString() { | ||
| return this.get(); | ||
| } | ||
| valueOf() { | ||
| return this.get(); | ||
| } | ||
| }; | ||
| const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000"; | ||
| const INJ_DENOM = "inj"; | ||
| const INJECTIVE_DENOM = "inj"; | ||
| const DEFAULT_FEE_DENOM = "inj"; | ||
| const DEFAULT_GAS_LIMIT = 4e5; | ||
| const DEFAULT_IBC_GAS_LIMIT = 3e5; | ||
| const DEFAULT_GAS_PRICE = 16e7; | ||
| const DEFAULT_EXCHANGE_LIMIT = 2e5; | ||
| const DEFAULT_BRIDGE_FEE_DENOM = "inj"; | ||
| const DEFAULT_BRIDGE_FEE_PRICE = "160000000"; | ||
| const DEFAULT_BRIDGE_FEE_AMOUNT = "200000000000000"; | ||
| const DEFAULT_BLOCK_TIMEOUT_HEIGHT = 60; | ||
| const DEFAULT_BLOCK_TIME_IN_SECONDS = .7; | ||
| const DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS = Math.floor(DEFAULT_BLOCK_TIMEOUT_HEIGHT * DEFAULT_BLOCK_TIME_IN_SECONDS * 1e3); | ||
| const DEFAULT_TX_POLL_INTERVAL_MS = 500; | ||
| const DEFAULT_TX_POLL_CALL_TIMEOUT_MS = 3e3; | ||
| const DEFAULT_TIMESTAMP_TIMEOUT_MS = 60 * 1e3 * 3; | ||
| const getDefaultStdFee = () => ({ | ||
| amount: [{ | ||
| denom: "inj", | ||
| amount: String(DEFAULT_GAS_LIMIT * DEFAULT_GAS_PRICE) | ||
| }], | ||
| gas: DEFAULT_GAS_LIMIT.toString(), | ||
| payer: "", | ||
| granter: "", | ||
| feePayer: "" | ||
| }); | ||
| const DEFAULT_STD_FEE_BY_DENOM = (denom = "inj") => ({ | ||
| amount: [{ | ||
| denom, | ||
| amount: String(DEFAULT_GAS_LIMIT * DEFAULT_GAS_PRICE) | ||
| }], | ||
| gas: DEFAULT_GAS_LIMIT.toString() | ||
| }); | ||
| const formatWalletAddress = (address, substrLength = 6) => { | ||
| if (address.length <= 10) return address; | ||
| return `${address.slice(0, substrLength)}...${address.slice(address.length - substrLength, address.length)}`; | ||
| }; | ||
| const toPascalCase = (str) => { | ||
| return `${str}`.toLowerCase().replace(new RegExp(/[-_]+/, "g"), " ").replace(new RegExp(/[^\w\s]/, "g"), "").replace(new RegExp(/\s+(.)(\w*)/, "g"), (_$1, $2, $3) => `${$2.toUpperCase() + $3}`).replace(/* @__PURE__ */ new RegExp(/\w/), (s) => s.toUpperCase()); | ||
| }; | ||
| const snakeToPascal = (str) => { | ||
| return str.split("/").map((snake) => snake.split("_").map((substr) => substr.charAt(0).toUpperCase() + substr.slice(1)).join("")).join("/"); | ||
| }; | ||
| const capitalize = (str) => { | ||
| if (!str) return str; | ||
| return str[0].toUpperCase() + str.slice(1); | ||
| }; | ||
| const sleep = (timeout) => new Promise((resolve) => setTimeout(resolve, timeout)); | ||
| const awaitAll = async (array, callback) => await Promise.all(array.map(async (item) => await callback(item))); | ||
| const awaitForAll = async (array, callback, onError) => { | ||
| const result = []; | ||
| for (let index = 0; index < array.length; index += 1) try { | ||
| result.push(await callback(array[index])); | ||
| } catch (error) { | ||
| if (onError) onError(error, array[index], index); | ||
| } | ||
| return result; | ||
| }; | ||
| const splitArrayToChunksThrow = ({ array, filter, chunkSize }) => { | ||
| const chunks = []; | ||
| const chunkSizeInNumber = Number(chunkSize); | ||
| if (!Number.isFinite(chunkSizeInNumber) || !Number.isInteger(chunkSizeInNumber) || chunkSizeInNumber <= 0) throw new Error("Invalid chunk size, must be a positive integer"); | ||
| for (let index = 0; index < array.length; index += chunkSizeInNumber) { | ||
| const chunk = array.slice(index, index + chunkSizeInNumber); | ||
| if (filter) chunks.push(chunk.filter(filter)); | ||
| else chunks.push(chunk); | ||
| } | ||
| return chunks; | ||
| }; | ||
| const splitArrayToChunks = ({ array, filter, chunkSize }) => { | ||
| try { | ||
| return splitArrayToChunksThrow({ | ||
| array, | ||
| chunkSize, | ||
| filter | ||
| }); | ||
| } catch (_unused) { | ||
| return [array]; | ||
| } | ||
| }; | ||
| //#endregion | ||
| exports.DEFAULT_BLOCK_TIMEOUT_HEIGHT = DEFAULT_BLOCK_TIMEOUT_HEIGHT; | ||
| exports.DEFAULT_BLOCK_TIME_IN_SECONDS = DEFAULT_BLOCK_TIME_IN_SECONDS; | ||
| exports.DEFAULT_BRIDGE_FEE_AMOUNT = DEFAULT_BRIDGE_FEE_AMOUNT; | ||
| exports.DEFAULT_BRIDGE_FEE_DENOM = DEFAULT_BRIDGE_FEE_DENOM; | ||
| exports.DEFAULT_BRIDGE_FEE_PRICE = DEFAULT_BRIDGE_FEE_PRICE; | ||
| exports.DEFAULT_EXCHANGE_LIMIT = DEFAULT_EXCHANGE_LIMIT; | ||
| exports.DEFAULT_FEE_DENOM = DEFAULT_FEE_DENOM; | ||
| exports.DEFAULT_GAS_LIMIT = DEFAULT_GAS_LIMIT; | ||
| exports.DEFAULT_GAS_PRICE = DEFAULT_GAS_PRICE; | ||
| exports.DEFAULT_IBC_GAS_LIMIT = DEFAULT_IBC_GAS_LIMIT; | ||
| exports.DEFAULT_STD_FEE_BY_DENOM = DEFAULT_STD_FEE_BY_DENOM; | ||
| exports.DEFAULT_TIMESTAMP_TIMEOUT_MS = DEFAULT_TIMESTAMP_TIMEOUT_MS; | ||
| exports.DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS = DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS; | ||
| exports.DEFAULT_TX_POLL_CALL_TIMEOUT_MS = DEFAULT_TX_POLL_CALL_TIMEOUT_MS; | ||
| exports.DEFAULT_TX_POLL_INTERVAL_MS = DEFAULT_TX_POLL_INTERVAL_MS; | ||
| exports.INJECTIVE_DENOM = INJECTIVE_DENOM; | ||
| exports.INJ_DENOM = INJ_DENOM; | ||
| exports.Status = Status; | ||
| exports.StatusType = StatusType; | ||
| exports.ZERO_ADDRESS = ZERO_ADDRESS; | ||
| exports.awaitAll = awaitAll; | ||
| exports.awaitForAll = awaitForAll; | ||
| exports.capitalize = capitalize; | ||
| exports.formatWalletAddress = formatWalletAddress; | ||
| exports.getDefaultStdFee = getDefaultStdFee; | ||
| exports.sleep = sleep; | ||
| exports.snakeToPascal = snakeToPascal; | ||
| exports.splitArrayToChunks = splitArrayToChunks; | ||
| exports.splitArrayToChunksThrow = splitArrayToChunksThrow; | ||
| exports.toPascalCase = toPascalCase; |
| import { AccountAddress } from "@injectivelabs/ts-types"; | ||
| //#region src/light.d.ts | ||
| declare const StatusType: { | ||
| readonly Idle: "idle"; | ||
| readonly Loading: "loading"; | ||
| readonly Completed: "completed"; | ||
| readonly Error: "error"; | ||
| readonly Confirmed: "confirmed"; | ||
| }; | ||
| type StatusType = (typeof StatusType)[keyof typeof StatusType]; | ||
| declare class Status { | ||
| status: string; | ||
| constructor(status?: StatusType); | ||
| get(): string; | ||
| set(status: StatusType): void; | ||
| is(status: StatusType): boolean; | ||
| isLoading(): boolean; | ||
| isNotLoading(): boolean; | ||
| isCompleted(): boolean; | ||
| isConfirmed(): boolean; | ||
| isIdle(): boolean; | ||
| isError(): boolean; | ||
| setLoading(): void; | ||
| setCompleted(): void; | ||
| setConfirmed(): void; | ||
| setError(): void; | ||
| setIdle(): void; | ||
| toggle(): void; | ||
| toString(): string; | ||
| valueOf(): string; | ||
| } | ||
| declare const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000"; | ||
| declare const INJ_DENOM = "inj"; | ||
| declare const INJECTIVE_DENOM = "inj"; | ||
| declare const DEFAULT_FEE_DENOM = "inj"; | ||
| declare const DEFAULT_GAS_LIMIT = 400000; | ||
| declare const DEFAULT_IBC_GAS_LIMIT = 300000; | ||
| declare const DEFAULT_GAS_PRICE = 160000000; | ||
| declare const DEFAULT_EXCHANGE_LIMIT = 200000; | ||
| declare const DEFAULT_BRIDGE_FEE_DENOM = "inj"; | ||
| declare const DEFAULT_BRIDGE_FEE_PRICE = "160000000"; | ||
| declare const DEFAULT_BRIDGE_FEE_AMOUNT = "200000000000000"; | ||
| declare const DEFAULT_BLOCK_TIMEOUT_HEIGHT = 60; | ||
| declare const DEFAULT_BLOCK_TIME_IN_SECONDS = 0.7; | ||
| declare const DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS: number; | ||
| declare const DEFAULT_TX_POLL_INTERVAL_MS = 500; | ||
| declare const DEFAULT_TX_POLL_CALL_TIMEOUT_MS = 3000; | ||
| declare const DEFAULT_TIMESTAMP_TIMEOUT_MS: number; | ||
| declare const getDefaultStdFee: () => { | ||
| amount: { | ||
| denom: string; | ||
| amount: string; | ||
| }[]; | ||
| gas: string; | ||
| payer: string; | ||
| granter: string; | ||
| feePayer: string; | ||
| }; | ||
| declare const DEFAULT_STD_FEE_BY_DENOM: (denom?: string) => { | ||
| amount: { | ||
| denom: string; | ||
| amount: string; | ||
| }[]; | ||
| gas: string; | ||
| }; | ||
| declare const formatWalletAddress: (address: AccountAddress, substrLength?: number) => string; | ||
| declare const toPascalCase: (str: string) => string; | ||
| declare const snakeToPascal: (str: string) => string; | ||
| declare const capitalize: (str: string) => string; | ||
| declare const sleep: (timeout: number) => Promise<void>; | ||
| declare const awaitAll: <T, S>(array: Array<T>, callback: (item: T) => Promise<S>) => Promise<Awaited<S>[]>; | ||
| declare const awaitForAll: <T, S>(array: Array<T>, callback: (item: T) => Promise<S>, onError?: (error: unknown, item: T, index: number) => void) => Promise<S[]>; | ||
| declare const splitArrayToChunksThrow: <T>({ | ||
| array, | ||
| filter, | ||
| chunkSize | ||
| }: { | ||
| array: Array<T>; | ||
| chunkSize: number; | ||
| filter?: (item: T) => boolean; | ||
| }) => T[][]; | ||
| declare const splitArrayToChunks: <T>({ | ||
| array, | ||
| filter, | ||
| chunkSize | ||
| }: { | ||
| array: Array<T>; | ||
| chunkSize: number; | ||
| filter?: (item: T) => boolean; | ||
| }) => T[][]; | ||
| //#endregion | ||
| export { DEFAULT_BLOCK_TIMEOUT_HEIGHT, DEFAULT_BLOCK_TIME_IN_SECONDS, DEFAULT_BRIDGE_FEE_AMOUNT, DEFAULT_BRIDGE_FEE_DENOM, DEFAULT_BRIDGE_FEE_PRICE, DEFAULT_EXCHANGE_LIMIT, DEFAULT_FEE_DENOM, DEFAULT_GAS_LIMIT, DEFAULT_GAS_PRICE, DEFAULT_IBC_GAS_LIMIT, DEFAULT_STD_FEE_BY_DENOM, DEFAULT_TIMESTAMP_TIMEOUT_MS, DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS, DEFAULT_TX_POLL_CALL_TIMEOUT_MS, DEFAULT_TX_POLL_INTERVAL_MS, INJECTIVE_DENOM, INJ_DENOM, Status, StatusType, ZERO_ADDRESS, awaitAll, awaitForAll, capitalize, formatWalletAddress, getDefaultStdFee, sleep, snakeToPascal, splitArrayToChunks, splitArrayToChunksThrow, toPascalCase }; |
| //#region src/classes/LocalStorage.d.ts | ||
| declare class LocalStorage { | ||
| private storage; | ||
| constructor(namespace: string); | ||
| get(key: string, defaultValue?: unknown): unknown; | ||
| has(key: string): boolean; | ||
| set(key: string, value: unknown): void; | ||
| remove(key: string): void; | ||
| clear(): void; | ||
| } | ||
| //#endregion | ||
| export { LocalStorage as t }; |
| const require_chunk = require('./chunk-CbDLau6x.cjs'); | ||
| const require_defineProperty = require('./defineProperty-CImP5zIM.cjs'); | ||
| let store2 = require("store2"); | ||
| store2 = require_chunk.__toESM(store2); | ||
| //#region src/classes/LocalStorage.ts | ||
| var LocalStorage = class { | ||
| constructor(namespace) { | ||
| require_defineProperty._defineProperty(this, "storage", void 0); | ||
| this.storage = store2.default.namespace(namespace); | ||
| } | ||
| get(key, defaultValue = {}) { | ||
| return this.storage.get(key) || defaultValue; | ||
| } | ||
| has(key) { | ||
| return this.storage.has(key); | ||
| } | ||
| set(key, value) { | ||
| this.storage.set(key, value); | ||
| } | ||
| remove(key) { | ||
| this.storage.remove(key); | ||
| } | ||
| clear() { | ||
| this.storage.clear(); | ||
| } | ||
| }; | ||
| //#endregion | ||
| Object.defineProperty(exports, 'LocalStorage', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return LocalStorage; | ||
| } | ||
| }); |
| const require_BigNumber = require('./BigNumber-DbDA4_xA.cjs'); | ||
| //#region src/numbers.ts | ||
| const getBigNumberWithRounding = () => require_BigNumber.BigNumber_default.clone({ ROUNDING_MODE: require_BigNumber.BigNumber_default.ROUND_DOWN }); | ||
| const getSignificantDecimalsFromNumber = (number) => { | ||
| const $BigNumber = getBigNumberWithRounding(); | ||
| if (Math.floor(new $BigNumber(number).toNumber()) === number) return 0; | ||
| const [, decimals] = new $BigNumber(number).toFixed().split("."); | ||
| /** Number doesn't have decimals */ | ||
| if (!decimals) return 0; | ||
| return decimals.length; | ||
| }; | ||
| const getExactDecimalsFromNumber = (number) => { | ||
| if (!number.toString().includes(".")) return 0; | ||
| if (Number(number) % 1 === 0) return 0; | ||
| const [, decimals] = number.toString().split("."); | ||
| if (!decimals) return 0; | ||
| return decimals.length; | ||
| }; | ||
| //#endregion | ||
| Object.defineProperty(exports, 'getBigNumberWithRounding', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return getBigNumberWithRounding; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'getExactDecimalsFromNumber', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return getExactDecimalsFromNumber; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'getSignificantDecimalsFromNumber', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return getSignificantDecimalsFromNumber; | ||
| } | ||
| }); |
| import { t as BigNumber } from "./BigNumber-B-r__Egf.cjs"; | ||
| //#region src/numbers.d.ts | ||
| declare const getBigNumberWithRounding: () => typeof BigNumber; | ||
| declare const getSignificantDecimalsFromNumber: (number: BigNumber | number | string) => number; | ||
| declare const getExactDecimalsFromNumber: (number: number | string) => number; | ||
| //#endregion | ||
| export { getExactDecimalsFromNumber as n, getSignificantDecimalsFromNumber as r, getBigNumberWithRounding as t }; |
| require('./BigNumber-DbDA4_xA.cjs'); | ||
| const require_numbers = require('./numbers-BRXzNJ1I.cjs'); | ||
| exports.getBigNumberWithRounding = require_numbers.getBigNumberWithRounding; | ||
| exports.getExactDecimalsFromNumber = require_numbers.getExactDecimalsFromNumber; | ||
| exports.getSignificantDecimalsFromNumber = require_numbers.getSignificantDecimalsFromNumber; |
| import "./BigNumber-B-r__Egf.cjs"; | ||
| import { n as getExactDecimalsFromNumber, r as getSignificantDecimalsFromNumber, t as getBigNumberWithRounding } from "./numbers-CVJM893V.cjs"; | ||
| export { getBigNumberWithRounding, getExactDecimalsFromNumber, getSignificantDecimalsFromNumber }; |
| const require_defineProperty = require('./defineProperty-CImP5zIM.cjs'); | ||
| //#region src/enum.ts | ||
| const StatusType = { | ||
| Idle: "idle", | ||
| Loading: "loading", | ||
| Completed: "completed", | ||
| Error: "error", | ||
| Confirmed: "confirmed" | ||
| }; | ||
| //#endregion | ||
| //#region src/classes/Status.ts | ||
| var Status = class { | ||
| constructor(status = StatusType.Idle) { | ||
| require_defineProperty._defineProperty(this, "status", void 0); | ||
| this.status = status; | ||
| } | ||
| get() { | ||
| return this.status; | ||
| } | ||
| set(status) { | ||
| this.status = status; | ||
| } | ||
| is(status) { | ||
| return this.status === status; | ||
| } | ||
| isLoading() { | ||
| return this.is(StatusType.Loading); | ||
| } | ||
| isNotLoading() { | ||
| return !this.is(StatusType.Loading); | ||
| } | ||
| isCompleted() { | ||
| return this.is(StatusType.Completed); | ||
| } | ||
| isConfirmed() { | ||
| return this.is(StatusType.Confirmed); | ||
| } | ||
| isIdle() { | ||
| return this.is(StatusType.Idle); | ||
| } | ||
| isError() { | ||
| return this.is(StatusType.Error); | ||
| } | ||
| setLoading() { | ||
| this.set(StatusType.Loading); | ||
| } | ||
| setCompleted() { | ||
| this.set(StatusType.Completed); | ||
| } | ||
| setConfirmed() { | ||
| this.set(StatusType.Confirmed); | ||
| } | ||
| setError() { | ||
| this.set(StatusType.Error); | ||
| } | ||
| setIdle() { | ||
| this.set(StatusType.Idle); | ||
| } | ||
| toggle() { | ||
| this.set(this.status === StatusType.Idle ? StatusType.Loading : StatusType.Idle); | ||
| } | ||
| toString() { | ||
| return this.get(); | ||
| } | ||
| valueOf() { | ||
| return this.get(); | ||
| } | ||
| }; | ||
| //#endregion | ||
| Object.defineProperty(exports, 'Status', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return Status; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'StatusType', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return StatusType; | ||
| } | ||
| }); |
| //#region src/enum.d.ts | ||
| declare const StatusType: { | ||
| readonly Idle: "idle"; | ||
| readonly Loading: "loading"; | ||
| readonly Completed: "completed"; | ||
| readonly Error: "error"; | ||
| readonly Confirmed: "confirmed"; | ||
| }; | ||
| type StatusType = (typeof StatusType)[keyof typeof StatusType]; | ||
| //#endregion | ||
| //#region src/classes/Status.d.ts | ||
| declare class Status { | ||
| status: string; | ||
| constructor(status?: StatusType); | ||
| get(): string; | ||
| set(status: StatusType): void; | ||
| is(status: StatusType): boolean; | ||
| isLoading(): boolean; | ||
| isNotLoading(): boolean; | ||
| isCompleted(): boolean; | ||
| isConfirmed(): boolean; | ||
| isIdle(): boolean; | ||
| isError(): boolean; | ||
| setLoading(): void; | ||
| setCompleted(): void; | ||
| setConfirmed(): void; | ||
| setError(): void; | ||
| setIdle(): void; | ||
| toggle(): void; | ||
| toString(): string; | ||
| valueOf(): string; | ||
| } | ||
| //#endregion | ||
| export { StatusType as n, Status as t }; |
| require('./defineProperty-CImP5zIM.cjs'); | ||
| const require_Status = require('./Status-C1EkdFOa.cjs'); | ||
| exports.Status = require_Status.Status; | ||
| exports.StatusType = require_Status.StatusType; |
| import { n as StatusType, t as Status } from "./Status-lj0Wyw_3.cjs"; | ||
| export { Status, StatusType }; |
| require('./defineProperty-CImP5zIM.cjs'); | ||
| const require_LocalStorage = require('./LocalStorage-DRuofBv_.cjs'); | ||
| exports.LocalStorage = require_LocalStorage.LocalStorage; |
| import { t as LocalStorage } from "./LocalStorage-Dqm913-z.cjs"; | ||
| export { LocalStorage }; |
| const require_BigNumber = require('./BigNumber-DbDA4_xA.cjs'); | ||
| //#region src/time.ts | ||
| const getSecondsInDay = () => new require_BigNumber.BigNumber_default(3600 * 24); | ||
| const convertTimestampToMilliseconds = (timestamp) => { | ||
| const timestampInBigNumber = new require_BigNumber.BigNumber_default(timestamp); | ||
| if (timestamp.toString().length > 13) return timestampInBigNumber.precision(13, require_BigNumber.BigNumber_default.ROUND_HALF_UP).toNumber(); | ||
| if (timestamp.toString().length < 13) { | ||
| const trailingZeros = 13 - timestamp.toString().length; | ||
| return timestampInBigNumber.times(10 ** trailingZeros).toNumber(); | ||
| } | ||
| return timestampInBigNumber.toNumber(); | ||
| }; | ||
| const getUTCDateFromTimestamp = (timestamp) => { | ||
| const date = new Date(convertTimestampToMilliseconds(timestamp)); | ||
| return `${date.getUTCDate()}-${date.getUTCMonth() + 1}-${date.getUTCFullYear()}`; | ||
| }; | ||
| const tomorrow = () => new require_BigNumber.BigNumber_default(Math.floor((/* @__PURE__ */ new Date()).valueOf() / 1e3) + 3600 * 24); | ||
| const todayInSeconds = () => Math.floor(Date.now() / 1e3); | ||
| const past24Hours = () => new require_BigNumber.BigNumber_default(todayInSeconds()).minus(getSecondsInDay()).toNumber(); | ||
| const pastDays = (day = 1) => new require_BigNumber.BigNumber_default(todayInSeconds()).minus(getSecondsInDay().times(day)).toNumber(); | ||
| const getEndDateStringFromTimeInSeconds = (timeInSeconds) => { | ||
| return (/* @__PURE__ */ new Date(timeInSeconds.toNumber() * 1e3)).toLocaleString("en-us"); | ||
| }; | ||
| //#endregion | ||
| Object.defineProperty(exports, 'convertTimestampToMilliseconds', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return convertTimestampToMilliseconds; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'getEndDateStringFromTimeInSeconds', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return getEndDateStringFromTimeInSeconds; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'getSecondsInDay', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return getSecondsInDay; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'getUTCDateFromTimestamp', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return getUTCDateFromTimestamp; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'past24Hours', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return past24Hours; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'pastDays', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return pastDays; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'todayInSeconds', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return todayInSeconds; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'tomorrow', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return tomorrow; | ||
| } | ||
| }); |
| import { t as BigNumber } from "./BigNumber-B-r__Egf.cjs"; | ||
| //#region src/time.d.ts | ||
| declare const getSecondsInDay: () => BigNumber; | ||
| declare const convertTimestampToMilliseconds: (timestamp: number | string) => number; | ||
| declare const getUTCDateFromTimestamp: (timestamp: number) => string; | ||
| declare const tomorrow: () => BigNumber; | ||
| declare const todayInSeconds: () => number; | ||
| declare const past24Hours: () => number; | ||
| declare const pastDays: (day?: number) => number; | ||
| declare const getEndDateStringFromTimeInSeconds: (timeInSeconds: BigNumber) => string; | ||
| //#endregion | ||
| export { past24Hours as a, tomorrow as c, getUTCDateFromTimestamp as i, getEndDateStringFromTimeInSeconds as n, pastDays as o, getSecondsInDay as r, todayInSeconds as s, convertTimestampToMilliseconds as t }; |
| require('./BigNumber-DbDA4_xA.cjs'); | ||
| const require_time = require('./time-CPSnQ8xf.cjs'); | ||
| exports.convertTimestampToMilliseconds = require_time.convertTimestampToMilliseconds; | ||
| exports.getEndDateStringFromTimeInSeconds = require_time.getEndDateStringFromTimeInSeconds; | ||
| exports.getSecondsInDay = require_time.getSecondsInDay; | ||
| exports.getUTCDateFromTimestamp = require_time.getUTCDateFromTimestamp; | ||
| exports.past24Hours = require_time.past24Hours; | ||
| exports.pastDays = require_time.pastDays; | ||
| exports.todayInSeconds = require_time.todayInSeconds; | ||
| exports.tomorrow = require_time.tomorrow; |
| import "./BigNumber-B-r__Egf.cjs"; | ||
| import { a as past24Hours, c as tomorrow, i as getUTCDateFromTimestamp, n as getEndDateStringFromTimeInSeconds, o as pastDays, r as getSecondsInDay, s as todayInSeconds, t as convertTimestampToMilliseconds } from "./time-DQwWSv4e.cjs"; | ||
| export { convertTimestampToMilliseconds, getEndDateStringFromTimeInSeconds, getSecondsInDay, getUTCDateFromTimestamp, past24Hours, pastDays, todayInSeconds, tomorrow }; |
| import { i as toHumanReadable, n as toBigNumber, r as toChainFormat, t as BigNumber } from "./BigNumber-jKUujKpO.js"; | ||
| import { n as BigNumberInBase, t as BigNumberInWei } from "./BigNumberInWei-JtQuFET_.js"; | ||
| export { BigNumber, BigNumberInBase, BigNumberInWei, toBigNumber, toChainFormat, toHumanReadable }; |
| import { i as toHumanReadable, n as toBigNumber, r as toChainFormat, t as BigNumber_default } from "./BigNumber-DUr2WQBK.js"; | ||
| import { n as BigNumberInWei, t as BigNumberInBase } from "./BigNumberInBase-Dcx5wyxY.js"; | ||
| export { BigNumber_default as BigNumber, BigNumberInBase, BigNumberInWei, toBigNumber, toChainFormat, toHumanReadable }; |
| import BigNumber from "bignumber.js"; | ||
| //#region src/classes/BigNumber.ts | ||
| var BigNumber_default = BigNumber; | ||
| /** | ||
| * Converts a value to BigNumber if it isn't already | ||
| */ | ||
| const toBigNumber = (value) => { | ||
| if (value instanceof BigNumber) return value; | ||
| return new BigNumber(value); | ||
| }; | ||
| /** | ||
| * Converts a value to Wei (multiplies by 10^decimals) default to 18 decimals | ||
| */ | ||
| const toChainFormat = (value, decimals = 18) => { | ||
| return toBigNumber(value).multipliedBy(new BigNumber(10).pow(decimals)); | ||
| }; | ||
| /** | ||
| * Converts a value from Wei to Base (divides by 10^decimals) default to 18 decimals | ||
| */ | ||
| const toHumanReadable = (value, decimals = 18) => { | ||
| return toBigNumber(value).dividedBy(new BigNumber(10).pow(decimals)); | ||
| }; | ||
| //#endregion | ||
| export { toHumanReadable as i, toBigNumber as n, toChainFormat as r, BigNumber_default as t }; |
| import BigNumber$1 from "bignumber.js"; | ||
| //#region src/classes/BigNumber.d.ts | ||
| /** | ||
| * Converts a value to BigNumber if it isn't already | ||
| */ | ||
| declare const toBigNumber: (value: BigNumber$1 | string | number) => BigNumber$1; | ||
| /** | ||
| * Converts a value to Wei (multiplies by 10^decimals) default to 18 decimals | ||
| */ | ||
| declare const toChainFormat: (value: BigNumber$1 | string | number, decimals?: number) => BigNumber$1; | ||
| /** | ||
| * Converts a value from Wei to Base (divides by 10^decimals) default to 18 decimals | ||
| */ | ||
| declare const toHumanReadable: (value: BigNumber$1 | string | number, decimals?: number) => BigNumber$1; | ||
| //#endregion | ||
| export { toHumanReadable as i, toBigNumber as n, toChainFormat as r, BigNumber$1 as t }; |
| import { t as BigNumber_default } from "./BigNumber-DUr2WQBK.js"; | ||
| //#region src/classes/BigNumberInWei.ts | ||
| /** | ||
| * @deprecated - use toChainFormat instead | ||
| */ | ||
| var BigNumberInWei = class BigNumberInWei extends BigNumber_default { | ||
| static make(number) { | ||
| return new BigNumberInWei(number); | ||
| } | ||
| minus(n, base) { | ||
| return new BigNumberInWei(super.minus(n, base)); | ||
| } | ||
| plus(n, base) { | ||
| return new BigNumberInWei(super.plus(n, base)); | ||
| } | ||
| dividedBy(n, base) { | ||
| return new BigNumberInWei(super.dividedBy(n, base)); | ||
| } | ||
| div(n, base) { | ||
| return new BigNumberInWei(super.div(n, base)); | ||
| } | ||
| multipliedBy(n, base) { | ||
| return new BigNumberInWei(super.multipliedBy(n, base)); | ||
| } | ||
| times(n, base) { | ||
| return new BigNumberInWei(super.times(n, base)); | ||
| } | ||
| pow(n, base) { | ||
| return new BigNumberInWei(super.pow(n, base)); | ||
| } | ||
| toBase(decimals = 18) { | ||
| return new BigNumber_default(this).dividedBy(new BigNumber_default(10).pow(decimals)); | ||
| } | ||
| }; | ||
| //#endregion | ||
| //#region src/classes/BigNumberInBase.ts | ||
| /** | ||
| * @deprecated - use toHumanReadable instead | ||
| */ | ||
| var BigNumberInBase = class BigNumberInBase extends BigNumber_default { | ||
| static make(number) { | ||
| return new BigNumberInBase(number); | ||
| } | ||
| minus(n, base) { | ||
| return new BigNumberInBase(super.minus(n, base)); | ||
| } | ||
| plus(n, base) { | ||
| return new BigNumberInBase(super.plus(n, base)); | ||
| } | ||
| dividedBy(n, base) { | ||
| return new BigNumberInBase(super.dividedBy(n, base)); | ||
| } | ||
| div(n, base) { | ||
| return new BigNumberInBase(super.div(n, base)); | ||
| } | ||
| multipliedBy(n, base) { | ||
| return new BigNumberInBase(super.multipliedBy(n, base)); | ||
| } | ||
| times(n, base) { | ||
| return new BigNumberInBase(super.times(n, base)); | ||
| } | ||
| pow(n, base) { | ||
| return new BigNumberInBase(super.pow(n, base)); | ||
| } | ||
| toWei(decimals = 18) { | ||
| return new BigNumber_default(this).multipliedBy(new BigNumber_default(10).pow(decimals)); | ||
| } | ||
| }; | ||
| //#endregion | ||
| export { BigNumberInWei as n, BigNumberInBase as t }; |
| import { t as BigNumber } from "./BigNumber-jKUujKpO.js"; | ||
| //#region src/classes/BigNumberInBase.d.ts | ||
| /** | ||
| * @deprecated - use toHumanReadable instead | ||
| */ | ||
| declare class BigNumberInBase extends BigNumber { | ||
| static make(number: BigNumber.Value): BigNumberInBase; | ||
| minus(n: BigNumber.Value, base?: number): BigNumberInBase; | ||
| plus(n: BigNumber.Value, base?: number): BigNumberInBase; | ||
| dividedBy(n: BigNumber.Value, base?: number): BigNumberInBase; | ||
| div(n: BigNumber.Value, base?: number): BigNumberInBase; | ||
| multipliedBy(n: BigNumber.Value, base?: number): BigNumberInBase; | ||
| times(n: BigNumber.Value, base?: number): BigNumberInBase; | ||
| pow(n: BigNumber.Value, base?: number): BigNumberInBase; | ||
| toWei(decimals?: number): BigNumberInWei; | ||
| } | ||
| //#endregion | ||
| //#region src/classes/BigNumberInWei.d.ts | ||
| /** | ||
| * @deprecated - use toChainFormat instead | ||
| */ | ||
| declare class BigNumberInWei extends BigNumber { | ||
| static make(number: BigNumber.Value): BigNumberInWei; | ||
| minus(n: BigNumber.Value, base?: number): BigNumberInWei; | ||
| plus(n: BigNumber.Value, base?: number): BigNumberInWei; | ||
| dividedBy(n: BigNumber.Value, base?: number): BigNumberInWei; | ||
| div(n: BigNumber.Value, base?: number): BigNumberInWei; | ||
| multipliedBy(n: BigNumber.Value, base?: number): BigNumberInWei; | ||
| times(n: BigNumber.Value, base?: number): BigNumberInWei; | ||
| pow(n: BigNumber.Value, base?: number): BigNumberInWei; | ||
| toBase(decimals?: number): BigNumberInBase; | ||
| } | ||
| //#endregion | ||
| export { BigNumberInBase as n, BigNumberInWei as t }; |
| import { t as BigNumber_default } from "./BigNumber-DUr2WQBK.js"; | ||
| //#region src/constants.ts | ||
| const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000"; | ||
| const INJ_DENOM = "inj"; | ||
| const INJECTIVE_DENOM = "inj"; | ||
| const DEFAULT_FEE_DENOM = "inj"; | ||
| const DEFAULT_GAS_LIMIT = 4e5; | ||
| const DEFAULT_IBC_GAS_LIMIT = 3e5; | ||
| const DEFAULT_GAS_PRICE = 16e7; | ||
| const DEFAULT_EXCHANGE_LIMIT = 2e5; | ||
| const DEFAULT_BRIDGE_FEE_DENOM = "inj"; | ||
| const DEFAULT_BRIDGE_FEE_PRICE = "160000000"; | ||
| const DEFAULT_BRIDGE_FEE_AMOUNT = "200000000000000"; | ||
| const DEFAULT_BLOCK_TIMEOUT_HEIGHT = 60; | ||
| const DEFAULT_BLOCK_TIME_IN_SECONDS = .7; | ||
| /** | ||
| * Default timeout for transaction block inclusion polling. | ||
| * | ||
| * Calculation: 120 blocks × 0.7 seconds/block = 84 seconds = 84,000ms | ||
| */ | ||
| const DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS = Math.floor(DEFAULT_BLOCK_TIMEOUT_HEIGHT * DEFAULT_BLOCK_TIME_IN_SECONDS * 1e3); | ||
| const DEFAULT_TX_POLL_INTERVAL_MS = 500; | ||
| const DEFAULT_TX_POLL_CALL_TIMEOUT_MS = 3e3; | ||
| const DEFAULT_TIMESTAMP_TIMEOUT_MS = 60 * 1e3 * 3; | ||
| const getDefaultStdFee = () => ({ | ||
| amount: [{ | ||
| amount: new BigNumber_default(DEFAULT_GAS_LIMIT).times(DEFAULT_GAS_PRICE).toString(), | ||
| denom: "inj" | ||
| }], | ||
| gas: DEFAULT_GAS_LIMIT.toString(), | ||
| payer: "", | ||
| granter: "", | ||
| feePayer: "" | ||
| }); | ||
| const DEFAULT_STD_FEE_BY_DENOM = (denom = "inj") => ({ | ||
| amount: [{ | ||
| denom, | ||
| amount: new BigNumber_default(DEFAULT_GAS_LIMIT).times(DEFAULT_GAS_PRICE).toString() | ||
| }], | ||
| gas: DEFAULT_GAS_LIMIT.toString() | ||
| }); | ||
| //#endregion | ||
| export { INJ_DENOM as _, DEFAULT_BRIDGE_FEE_PRICE as a, DEFAULT_GAS_LIMIT as c, DEFAULT_STD_FEE_BY_DENOM as d, DEFAULT_TIMESTAMP_TIMEOUT_MS as f, INJECTIVE_DENOM as g, DEFAULT_TX_POLL_INTERVAL_MS as h, DEFAULT_BRIDGE_FEE_DENOM as i, DEFAULT_GAS_PRICE as l, DEFAULT_TX_POLL_CALL_TIMEOUT_MS as m, DEFAULT_BLOCK_TIME_IN_SECONDS as n, DEFAULT_EXCHANGE_LIMIT as o, DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS as p, DEFAULT_BRIDGE_FEE_AMOUNT as r, DEFAULT_FEE_DENOM as s, DEFAULT_BLOCK_TIMEOUT_HEIGHT as t, DEFAULT_IBC_GAS_LIMIT as u, ZERO_ADDRESS as v, getDefaultStdFee as y }; |
| //#region src/constants.d.ts | ||
| declare const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000"; | ||
| declare const INJ_DENOM = "inj"; | ||
| declare const INJECTIVE_DENOM = "inj"; | ||
| declare const DEFAULT_FEE_DENOM = "inj"; | ||
| declare const DEFAULT_GAS_LIMIT = 400000; | ||
| declare const DEFAULT_IBC_GAS_LIMIT = 300000; | ||
| declare const DEFAULT_GAS_PRICE = 160000000; | ||
| declare const DEFAULT_EXCHANGE_LIMIT = 200000; | ||
| declare const DEFAULT_BRIDGE_FEE_DENOM = "inj"; | ||
| declare const DEFAULT_BRIDGE_FEE_PRICE = "160000000"; | ||
| declare const DEFAULT_BRIDGE_FEE_AMOUNT = "200000000000000"; | ||
| declare const DEFAULT_BLOCK_TIMEOUT_HEIGHT = 60; | ||
| declare const DEFAULT_BLOCK_TIME_IN_SECONDS = 0.7; | ||
| /** | ||
| * Default timeout for transaction block inclusion polling. | ||
| * | ||
| * Calculation: 120 blocks × 0.7 seconds/block = 84 seconds = 84,000ms | ||
| */ | ||
| declare const DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS: number; | ||
| declare const DEFAULT_TX_POLL_INTERVAL_MS = 500; | ||
| declare const DEFAULT_TX_POLL_CALL_TIMEOUT_MS = 3000; | ||
| declare const DEFAULT_TIMESTAMP_TIMEOUT_MS: number; | ||
| declare const getDefaultStdFee: () => { | ||
| amount: { | ||
| amount: string; | ||
| denom: string; | ||
| }[]; | ||
| gas: string; | ||
| payer: string; | ||
| granter: string; | ||
| feePayer: string; | ||
| }; | ||
| declare const DEFAULT_STD_FEE_BY_DENOM: (denom?: string) => { | ||
| amount: { | ||
| denom: string; | ||
| amount: string; | ||
| }[]; | ||
| gas: string; | ||
| }; | ||
| //#endregion | ||
| export { INJ_DENOM as _, DEFAULT_BRIDGE_FEE_PRICE as a, DEFAULT_GAS_LIMIT as c, DEFAULT_STD_FEE_BY_DENOM as d, DEFAULT_TIMESTAMP_TIMEOUT_MS as f, INJECTIVE_DENOM as g, DEFAULT_TX_POLL_INTERVAL_MS as h, DEFAULT_BRIDGE_FEE_DENOM as i, DEFAULT_GAS_PRICE as l, DEFAULT_TX_POLL_CALL_TIMEOUT_MS as m, DEFAULT_BLOCK_TIME_IN_SECONDS as n, DEFAULT_EXCHANGE_LIMIT as o, DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS as p, DEFAULT_BRIDGE_FEE_AMOUNT as r, DEFAULT_FEE_DENOM as s, DEFAULT_BLOCK_TIMEOUT_HEIGHT as t, DEFAULT_IBC_GAS_LIMIT as u, ZERO_ADDRESS as v, getDefaultStdFee as y }; |
| import { _ as INJ_DENOM, a as DEFAULT_BRIDGE_FEE_PRICE, c as DEFAULT_GAS_LIMIT, d as DEFAULT_STD_FEE_BY_DENOM, f as DEFAULT_TIMESTAMP_TIMEOUT_MS, g as INJECTIVE_DENOM, h as DEFAULT_TX_POLL_INTERVAL_MS, i as DEFAULT_BRIDGE_FEE_DENOM, l as DEFAULT_GAS_PRICE, m as DEFAULT_TX_POLL_CALL_TIMEOUT_MS, n as DEFAULT_BLOCK_TIME_IN_SECONDS, o as DEFAULT_EXCHANGE_LIMIT, p as DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS, r as DEFAULT_BRIDGE_FEE_AMOUNT, s as DEFAULT_FEE_DENOM, t as DEFAULT_BLOCK_TIMEOUT_HEIGHT, u as DEFAULT_IBC_GAS_LIMIT, v as ZERO_ADDRESS, y as getDefaultStdFee } from "./constants-BPYHMKzA.js"; | ||
| export { DEFAULT_BLOCK_TIMEOUT_HEIGHT, DEFAULT_BLOCK_TIME_IN_SECONDS, DEFAULT_BRIDGE_FEE_AMOUNT, DEFAULT_BRIDGE_FEE_DENOM, DEFAULT_BRIDGE_FEE_PRICE, DEFAULT_EXCHANGE_LIMIT, DEFAULT_FEE_DENOM, DEFAULT_GAS_LIMIT, DEFAULT_GAS_PRICE, DEFAULT_IBC_GAS_LIMIT, DEFAULT_STD_FEE_BY_DENOM, DEFAULT_TIMESTAMP_TIMEOUT_MS, DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS, DEFAULT_TX_POLL_CALL_TIMEOUT_MS, DEFAULT_TX_POLL_INTERVAL_MS, INJECTIVE_DENOM, INJ_DENOM, ZERO_ADDRESS, getDefaultStdFee }; |
| import "./BigNumber-DUr2WQBK.js"; | ||
| import { _ as INJ_DENOM, a as DEFAULT_BRIDGE_FEE_PRICE, c as DEFAULT_GAS_LIMIT, d as DEFAULT_STD_FEE_BY_DENOM, f as DEFAULT_TIMESTAMP_TIMEOUT_MS, g as INJECTIVE_DENOM, h as DEFAULT_TX_POLL_INTERVAL_MS, i as DEFAULT_BRIDGE_FEE_DENOM, l as DEFAULT_GAS_PRICE, m as DEFAULT_TX_POLL_CALL_TIMEOUT_MS, n as DEFAULT_BLOCK_TIME_IN_SECONDS, o as DEFAULT_EXCHANGE_LIMIT, p as DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS, r as DEFAULT_BRIDGE_FEE_AMOUNT, s as DEFAULT_FEE_DENOM, t as DEFAULT_BLOCK_TIMEOUT_HEIGHT, u as DEFAULT_IBC_GAS_LIMIT, v as ZERO_ADDRESS, y as getDefaultStdFee } from "./constants-0w1sGXWU.js"; | ||
| export { DEFAULT_BLOCK_TIMEOUT_HEIGHT, DEFAULT_BLOCK_TIME_IN_SECONDS, DEFAULT_BRIDGE_FEE_AMOUNT, DEFAULT_BRIDGE_FEE_DENOM, DEFAULT_BRIDGE_FEE_PRICE, DEFAULT_EXCHANGE_LIMIT, DEFAULT_FEE_DENOM, DEFAULT_GAS_LIMIT, DEFAULT_GAS_PRICE, DEFAULT_IBC_GAS_LIMIT, DEFAULT_STD_FEE_BY_DENOM, DEFAULT_TIMESTAMP_TIMEOUT_MS, DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS, DEFAULT_TX_POLL_CALL_TIMEOUT_MS, DEFAULT_TX_POLL_INTERVAL_MS, INJECTIVE_DENOM, INJ_DENOM, ZERO_ADDRESS, getDefaultStdFee }; |
| //#region \0@oxc-project+runtime@0.99.0/helpers/typeof.js | ||
| function _typeof(o) { | ||
| "@babel/helpers - typeof"; | ||
| return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) { | ||
| return typeof o$1; | ||
| } : function(o$1) { | ||
| return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1; | ||
| }, _typeof(o); | ||
| } | ||
| //#endregion | ||
| //#region \0@oxc-project+runtime@0.99.0/helpers/toPrimitive.js | ||
| function toPrimitive(t, r) { | ||
| if ("object" != _typeof(t) || !t) return t; | ||
| var e = t[Symbol.toPrimitive]; | ||
| if (void 0 !== e) { | ||
| var i = e.call(t, r || "default"); | ||
| if ("object" != _typeof(i)) return i; | ||
| throw new TypeError("@@toPrimitive must return a primitive value."); | ||
| } | ||
| return ("string" === r ? String : Number)(t); | ||
| } | ||
| //#endregion | ||
| //#region \0@oxc-project+runtime@0.99.0/helpers/toPropertyKey.js | ||
| function toPropertyKey(t) { | ||
| var i = toPrimitive(t, "string"); | ||
| return "symbol" == _typeof(i) ? i : i + ""; | ||
| } | ||
| //#endregion | ||
| //#region \0@oxc-project+runtime@0.99.0/helpers/defineProperty.js | ||
| function _defineProperty(e, r, t) { | ||
| return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, { | ||
| value: t, | ||
| enumerable: !0, | ||
| configurable: !0, | ||
| writable: !0 | ||
| }) : e[r] = t, e; | ||
| } | ||
| //#endregion | ||
| export { _defineProperty as t }; |
| //#region src/formatters.ts | ||
| const formatWalletAddress = (address, substrLength = 6) => { | ||
| if (address.length <= 10) return address; | ||
| return `${address.slice(0, substrLength)}...${address.slice(address.length - substrLength, address.length)}`; | ||
| }; | ||
| const toPascalCase = (str) => { | ||
| return `${str}`.toLowerCase().replace(new RegExp(/[-_]+/, "g"), " ").replace(new RegExp(/[^\w\s]/, "g"), "").replace(new RegExp(/\s+(.)(\w*)/, "g"), (_$1, $2, $3) => `${$2.toUpperCase() + $3}`).replace(/* @__PURE__ */ new RegExp(/\w/), (s) => s.toUpperCase()); | ||
| }; | ||
| const snakeToPascal = (str) => { | ||
| return str.split("/").map((snake) => snake.split("_").map((substr) => substr.charAt(0).toUpperCase() + substr.slice(1)).join("")).join("/"); | ||
| }; | ||
| const capitalize = (str) => { | ||
| if (!str) return str; | ||
| return str[0].toUpperCase() + str.slice(1); | ||
| }; | ||
| //#endregion | ||
| export { toPascalCase as i, formatWalletAddress as n, snakeToPascal as r, capitalize as t }; |
| import { AccountAddress } from "@injectivelabs/ts-types"; | ||
| //#region src/formatters.d.ts | ||
| declare const formatWalletAddress: (address: AccountAddress, substrLength?: number) => string; | ||
| declare const toPascalCase: (str: string) => string; | ||
| declare const snakeToPascal: (str: string) => string; | ||
| declare const capitalize: (str: string) => string; | ||
| //#endregion | ||
| export { toPascalCase as i, formatWalletAddress as n, snakeToPascal as r, capitalize as t }; |
| import { i as toPascalCase, n as formatWalletAddress, r as snakeToPascal, t as capitalize } from "./formatters-v2reo54H.js"; | ||
| export { capitalize, formatWalletAddress, snakeToPascal, toPascalCase }; |
| import { i as toPascalCase, n as formatWalletAddress, r as snakeToPascal, t as capitalize } from "./formatters-QUaa2UZY.js"; | ||
| export { capitalize, formatWalletAddress, snakeToPascal, toPascalCase }; |
| import { i as toHumanReadable, n as toBigNumber, r as toChainFormat, t as BigNumber_default } from "./BigNumber-DUr2WQBK.js"; | ||
| import { c as DEFAULT_GAS_LIMIT, l as DEFAULT_GAS_PRICE, y as getDefaultStdFee } from "./constants-0w1sGXWU.js"; | ||
| //#region src/helpers.ts | ||
| const sleep = (timeout) => new Promise((resolve) => setTimeout(resolve, timeout)); | ||
| /** | ||
| * When we want to execute the promises in batch | ||
| */ | ||
| const awaitAll = async (array, callback) => await Promise.all(array.map(async (item) => await callback(item))); | ||
| /** | ||
| * When we want to execute the promises one by one | ||
| * and not all in batch as with await Promise.all() | ||
| */ | ||
| const awaitForAll = async (array, callback, onError) => { | ||
| const result = []; | ||
| for (let i = 0; i < array.length; i += 1) try { | ||
| result.push(await callback(array[i])); | ||
| } catch (e) { | ||
| if (onError) onError(e, array[i], i); | ||
| } | ||
| return result; | ||
| }; | ||
| const splitArrayToChunksThrow = ({ array, filter, chunkSize }) => { | ||
| const chunks = []; | ||
| const chunkSizeInNumber = Number(chunkSize); | ||
| if (!Number.isFinite(chunkSizeInNumber) || !Number.isInteger(chunkSizeInNumber) || chunkSizeInNumber <= 0) throw new Error("Invalid chunk size, must be a positive integer"); | ||
| for (let i = 0; i < array.length; i += chunkSizeInNumber) { | ||
| const chunk = array.slice(i, i + chunkSizeInNumber); | ||
| if (filter) chunks.push(chunk.filter(filter)); | ||
| else chunks.push(chunk); | ||
| } | ||
| return chunks; | ||
| }; | ||
| const splitArrayToChunks = ({ array, filter, chunkSize }) => { | ||
| try { | ||
| return splitArrayToChunksThrow({ | ||
| array, | ||
| chunkSize, | ||
| filter | ||
| }); | ||
| } catch (_unused) { | ||
| return [array]; | ||
| } | ||
| }; | ||
| const getStdFeeForToken = (token = { | ||
| denom: "inj", | ||
| decimals: 18 | ||
| }, gasPrice, gasLimit) => { | ||
| const gasPriceScaled = toChainFormat(gasPrice || toHumanReadable(DEFAULT_GAS_PRICE, 18), token.decimals).toFixed(0); | ||
| const gasNormalized = new BigNumber_default(gasLimit || DEFAULT_GAS_LIMIT).toFixed(0); | ||
| return { | ||
| amount: [{ | ||
| denom: token.denom, | ||
| amount: new BigNumber_default(gasPriceScaled).times(gasNormalized).toFixed() | ||
| }], | ||
| gas: (gasLimit || DEFAULT_GAS_LIMIT).toString() | ||
| }; | ||
| }; | ||
| const getStdFeeFromObject = (args) => { | ||
| if (!args) return getDefaultStdFee(); | ||
| const { payer, granter, feePayer, gasPrice = DEFAULT_GAS_PRICE, gas = DEFAULT_GAS_LIMIT.toString() } = args; | ||
| const gasNormalized = toBigNumber(gas).toFixed(0); | ||
| const gasPriceNormalized = toBigNumber(gasPrice).toFixed(0); | ||
| return { | ||
| amount: [{ | ||
| denom: "inj", | ||
| amount: toBigNumber(gasNormalized).times(gasPriceNormalized).toFixed() | ||
| }], | ||
| gas: toBigNumber(gasNormalized).toFixed(), | ||
| payer, | ||
| granter, | ||
| feePayer | ||
| }; | ||
| }; | ||
| const getStdFeeFromString = (gasPrice) => { | ||
| const matchResult = gasPrice.match(/^([0-9.]+)([a-zA-Z][a-zA-Z0-9/:._-]*)$/); | ||
| if (!matchResult) throw new Error("Invalid gas price string"); | ||
| const [_, amount] = matchResult; | ||
| return getStdFeeFromObject({ | ||
| gas: toChainFormat(amount, 18).dividedBy(DEFAULT_GAS_PRICE).toFixed(0), | ||
| gasPrice: DEFAULT_GAS_PRICE | ||
| }); | ||
| }; | ||
| const getStdFee = (args) => { | ||
| if (!args) return getDefaultStdFee(); | ||
| if (typeof args === "string") return getStdFeeFromString(args); | ||
| return getStdFeeFromObject({ ...args }); | ||
| }; | ||
| //#endregion | ||
| export { getStdFeeFromObject as a, splitArrayToChunks as c, getStdFeeForToken as i, splitArrayToChunksThrow as l, awaitForAll as n, getStdFeeFromString as o, getStdFee as r, sleep as s, awaitAll as t }; |
| //#region src/types.d.ts | ||
| type Awaited<T> = T extends null | undefined ? T : T extends object & { | ||
| then(onfulfilled: infer F, ...args: infer _): any; | ||
| } ? F extends ((value: infer V, ...args: infer _) => any) ? Awaited<V> : never : T; | ||
| //#endregion | ||
| //#region src/helpers.d.ts | ||
| declare const sleep: (timeout: number) => Promise<void>; | ||
| /** | ||
| * When we want to execute the promises in batch | ||
| */ | ||
| declare const awaitAll: <T, S>(array: Array<T>, callback: (item: T) => Promise<S>) => Promise<Awaited<S>[]>; | ||
| /** | ||
| * When we want to execute the promises one by one | ||
| * and not all in batch as with await Promise.all() | ||
| */ | ||
| declare const awaitForAll: <T, S>(array: Array<T>, callback: (item: T) => Promise<S>, onError?: (error: unknown, item: T, index: number) => void) => Promise<S[]>; | ||
| declare const splitArrayToChunksThrow: <T>({ | ||
| array, | ||
| filter, | ||
| chunkSize | ||
| }: { | ||
| array: Array<T>; | ||
| chunkSize: number; | ||
| filter?: (item: T) => boolean; | ||
| }) => T[][]; | ||
| declare const splitArrayToChunks: <T>({ | ||
| array, | ||
| filter, | ||
| chunkSize | ||
| }: { | ||
| array: Array<T>; | ||
| chunkSize: number; | ||
| filter?: (item: T) => boolean; | ||
| }) => T[][]; | ||
| declare const getStdFeeForToken: (token?: { | ||
| denom: string; | ||
| decimals: number; | ||
| }, gasPrice?: string, gasLimit?: string) => { | ||
| amount: { | ||
| denom: string; | ||
| amount: string; | ||
| }[]; | ||
| gas: string; | ||
| }; | ||
| declare const getStdFeeFromObject: (args?: { | ||
| gas?: string | number; | ||
| payer?: string; | ||
| granter?: string; | ||
| gasPrice?: string | number; | ||
| feePayer?: string; | ||
| }) => { | ||
| amount: { | ||
| denom: string; | ||
| amount: string; | ||
| }[]; | ||
| gas: string; | ||
| payer: string | undefined; /** for Web3Gateway fee delegation */ | ||
| granter: string | undefined; | ||
| feePayer: string | undefined; | ||
| }; | ||
| declare const getStdFeeFromString: (gasPrice: string) => { | ||
| amount: { | ||
| denom: string; | ||
| amount: string; | ||
| }[]; | ||
| gas: string; | ||
| payer: string | undefined; /** for Web3Gateway fee delegation */ | ||
| granter: string | undefined; | ||
| feePayer: string | undefined; | ||
| }; | ||
| declare const getStdFee: (args?: string | { | ||
| payer?: string; | ||
| granter?: string; | ||
| feePayer?: string; | ||
| gas?: string | number; | ||
| gasPrice?: string | number; | ||
| }) => { | ||
| amount: { | ||
| denom: string; | ||
| amount: string; | ||
| }[]; | ||
| gas: string; | ||
| payer: string | undefined; /** for Web3Gateway fee delegation */ | ||
| granter: string | undefined; | ||
| feePayer: string | undefined; | ||
| }; | ||
| //#endregion | ||
| export { getStdFeeFromObject as a, splitArrayToChunks as c, getStdFeeForToken as i, splitArrayToChunksThrow as l, awaitForAll as n, getStdFeeFromString as o, getStdFee as r, sleep as s, awaitAll as t }; |
| import { a as getStdFeeFromObject, c as splitArrayToChunks, i as getStdFeeForToken, l as splitArrayToChunksThrow, n as awaitForAll, o as getStdFeeFromString, r as getStdFee, s as sleep, t as awaitAll } from "./helpers-BZ1LFB-6.js"; | ||
| export { awaitAll, awaitForAll, getStdFee, getStdFeeForToken, getStdFeeFromObject, getStdFeeFromString, sleep, splitArrayToChunks, splitArrayToChunksThrow }; |
| import "./BigNumber-DUr2WQBK.js"; | ||
| import "./constants-0w1sGXWU.js"; | ||
| import { a as getStdFeeFromObject, c as splitArrayToChunks, i as getStdFeeForToken, l as splitArrayToChunksThrow, n as awaitForAll, o as getStdFeeFromString, r as getStdFee, s as sleep, t as awaitAll } from "./helpers-BsGkkq54.js"; | ||
| export { awaitAll, awaitForAll, getStdFee, getStdFeeForToken, getStdFeeFromObject, getStdFeeFromString, sleep, splitArrayToChunks, splitArrayToChunksThrow }; |
| import { n as HttpClient, t as HttpRestClient } from "./HttpRestClient-B-UvB9KB.js"; | ||
| export { HttpClient, HttpRestClient }; |
| import "./defineProperty-Zp25b8Cm.js"; | ||
| import { n as HttpClient, t as HttpRestClient } from "./HttpRestClient-CsKkn8lo.js"; | ||
| export { HttpClient, HttpRestClient }; |
| import { AxiosRequestConfig } from "axios"; | ||
| //#region src/classes/HttpClient.d.ts | ||
| declare class HttpClient { | ||
| private readonly client; | ||
| private config; | ||
| constructor(endpoint: string, options?: Record<string, any>); | ||
| setConfig(config: AxiosRequestConfig): HttpClient; | ||
| get<T, P>(endpoint: string, params?: T): Promise<P>; | ||
| post<T, P>(endpoint: string, data?: T): Promise<P>; | ||
| put<T, P>(endpoint: string, data?: T): Promise<P>; | ||
| delete<T, P>(endpoint: string, params?: T): Promise<P>; | ||
| } | ||
| //#endregion | ||
| //#region src/classes/HttpRestClient.d.ts | ||
| /** | ||
| * @hidden | ||
| */ | ||
| declare class HttpRestClient { | ||
| protected client: HttpClient; | ||
| protected endpoint: string; | ||
| constructor(endpoint: string, options?: Record<string, any>); | ||
| setConfig(config: AxiosRequestConfig): HttpRestClient; | ||
| get<T>(endpoint: string, params?: Record<string, any>): Promise<T>; | ||
| retry<TResponse>(httpCall: Function, retries?: number, delay?: number): Promise<TResponse>; | ||
| post<T>(endpoint: string, params?: Record<string, any>): Promise<T>; | ||
| } | ||
| //#endregion | ||
| export { HttpClient as n, HttpRestClient as t }; |
| import { t as _defineProperty } from "./defineProperty-Zp25b8Cm.js"; | ||
| import axios from "axios"; | ||
| import { StatusCodes } from "http-status-codes"; | ||
| import { HttpRequestException, HttpRequestMethod, UnspecifiedErrorCode } from "@injectivelabs/exceptions"; | ||
| //#region src/classes/HttpClient.ts | ||
| var HttpClient = class { | ||
| constructor(endpoint, options = { headers: { "Content-Type": "application/json" } }) { | ||
| _defineProperty(this, "client", void 0); | ||
| _defineProperty(this, "config", {}); | ||
| this.client = axios.create({ | ||
| baseURL: endpoint, | ||
| timeout: 15e3, | ||
| ...options | ||
| }); | ||
| this.config = {}; | ||
| } | ||
| setConfig(config) { | ||
| this.config = config; | ||
| return this; | ||
| } | ||
| get(endpoint, params = {}) { | ||
| return this.client.get(endpoint, { | ||
| params, | ||
| ...this.config | ||
| }); | ||
| } | ||
| post(endpoint, data = {}) { | ||
| return this.client.post(endpoint, data, this.config); | ||
| } | ||
| put(endpoint, data = {}) { | ||
| return this.client.put(endpoint, data, this.config); | ||
| } | ||
| delete(endpoint, params = {}) { | ||
| return this.client.delete(endpoint, { | ||
| params, | ||
| ...this.config | ||
| }); | ||
| } | ||
| }; | ||
| //#endregion | ||
| //#region src/classes/HttpRestClient.ts | ||
| const getErrorMessage = (error, endpoint) => { | ||
| if (!error.response) return `The request to ${endpoint} has failed.`; | ||
| return error.response.data ? error.response.data.message || error.response.data.statusMessage || error.response.data : error.response.statusText; | ||
| }; | ||
| /** | ||
| * @hidden | ||
| */ | ||
| var HttpRestClient = class { | ||
| constructor(endpoint, options = {}) { | ||
| _defineProperty(this, "client", void 0); | ||
| _defineProperty(this, "endpoint", void 0); | ||
| this.client = new HttpClient(endpoint, options); | ||
| this.endpoint = endpoint; | ||
| } | ||
| setConfig(config) { | ||
| this.client.setConfig(config); | ||
| return this; | ||
| } | ||
| async get(endpoint, params = {}) { | ||
| try { | ||
| return await this.client.get(endpoint, params); | ||
| } catch (e) { | ||
| const error = e; | ||
| if (axios.isAxiosError(error)) { | ||
| if (error.code === "ECONNABORTED") throw new HttpRequestException(new Error(error.message), { | ||
| code: StatusCodes.REQUEST_TOO_LONG, | ||
| context: endpoint | ||
| }); | ||
| const message = getErrorMessage(error, endpoint); | ||
| throw new HttpRequestException(new Error(message), { | ||
| context: endpoint, | ||
| code: error.response ? error.response.status : StatusCodes.BAD_REQUEST | ||
| }); | ||
| } | ||
| throw new HttpRequestException(new Error(error.message), { | ||
| code: UnspecifiedErrorCode, | ||
| context: endpoint | ||
| }); | ||
| } | ||
| } | ||
| async retry(httpCall, retries = 3, delay = 1e3) { | ||
| const retryHttpCall = async (attempt = 1) => { | ||
| try { | ||
| return await httpCall(); | ||
| } catch (e) { | ||
| if (e instanceof HttpRequestException) { | ||
| if (e.code === StatusCodes.REQUEST_TOO_LONG) throw e; | ||
| } | ||
| if (attempt >= retries) throw e; | ||
| return new Promise((resolve) => setTimeout(() => resolve(retryHttpCall(attempt + 1)), delay * attempt)); | ||
| } | ||
| }; | ||
| return retryHttpCall(); | ||
| } | ||
| async post(endpoint, params = {}) { | ||
| try { | ||
| return await this.client.post(endpoint, params); | ||
| } catch (e) { | ||
| const error = e; | ||
| if (axios.isAxiosError(error)) { | ||
| if (error.code === "ECONNABORTED") throw new HttpRequestException(new Error(error.message), { | ||
| code: StatusCodes.REQUEST_TOO_LONG, | ||
| method: HttpRequestMethod.Post | ||
| }); | ||
| const message = getErrorMessage(error, endpoint); | ||
| throw new HttpRequestException(new Error(message), { | ||
| code: error.response ? error.response.status : StatusCodes.BAD_REQUEST, | ||
| context: endpoint, | ||
| contextModule: HttpRequestMethod.Post | ||
| }); | ||
| } | ||
| throw new HttpRequestException(new Error(error.message), { | ||
| code: UnspecifiedErrorCode, | ||
| context: endpoint, | ||
| contextModule: HttpRequestMethod.Post | ||
| }); | ||
| } | ||
| } | ||
| }; | ||
| //#endregion | ||
| export { HttpClient as n, HttpRestClient as t }; |
| import { AccountAddress } from "@injectivelabs/ts-types"; | ||
| //#region src/light.d.ts | ||
| declare const StatusType: { | ||
| readonly Idle: "idle"; | ||
| readonly Loading: "loading"; | ||
| readonly Completed: "completed"; | ||
| readonly Error: "error"; | ||
| readonly Confirmed: "confirmed"; | ||
| }; | ||
| type StatusType = (typeof StatusType)[keyof typeof StatusType]; | ||
| declare class Status { | ||
| status: string; | ||
| constructor(status?: StatusType); | ||
| get(): string; | ||
| set(status: StatusType): void; | ||
| is(status: StatusType): boolean; | ||
| isLoading(): boolean; | ||
| isNotLoading(): boolean; | ||
| isCompleted(): boolean; | ||
| isConfirmed(): boolean; | ||
| isIdle(): boolean; | ||
| isError(): boolean; | ||
| setLoading(): void; | ||
| setCompleted(): void; | ||
| setConfirmed(): void; | ||
| setError(): void; | ||
| setIdle(): void; | ||
| toggle(): void; | ||
| toString(): string; | ||
| valueOf(): string; | ||
| } | ||
| declare const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000"; | ||
| declare const INJ_DENOM = "inj"; | ||
| declare const INJECTIVE_DENOM = "inj"; | ||
| declare const DEFAULT_FEE_DENOM = "inj"; | ||
| declare const DEFAULT_GAS_LIMIT = 400000; | ||
| declare const DEFAULT_IBC_GAS_LIMIT = 300000; | ||
| declare const DEFAULT_GAS_PRICE = 160000000; | ||
| declare const DEFAULT_EXCHANGE_LIMIT = 200000; | ||
| declare const DEFAULT_BRIDGE_FEE_DENOM = "inj"; | ||
| declare const DEFAULT_BRIDGE_FEE_PRICE = "160000000"; | ||
| declare const DEFAULT_BRIDGE_FEE_AMOUNT = "200000000000000"; | ||
| declare const DEFAULT_BLOCK_TIMEOUT_HEIGHT = 60; | ||
| declare const DEFAULT_BLOCK_TIME_IN_SECONDS = 0.7; | ||
| declare const DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS: number; | ||
| declare const DEFAULT_TX_POLL_INTERVAL_MS = 500; | ||
| declare const DEFAULT_TX_POLL_CALL_TIMEOUT_MS = 3000; | ||
| declare const DEFAULT_TIMESTAMP_TIMEOUT_MS: number; | ||
| declare const getDefaultStdFee: () => { | ||
| amount: { | ||
| denom: string; | ||
| amount: string; | ||
| }[]; | ||
| gas: string; | ||
| payer: string; | ||
| granter: string; | ||
| feePayer: string; | ||
| }; | ||
| declare const DEFAULT_STD_FEE_BY_DENOM: (denom?: string) => { | ||
| amount: { | ||
| denom: string; | ||
| amount: string; | ||
| }[]; | ||
| gas: string; | ||
| }; | ||
| declare const formatWalletAddress: (address: AccountAddress, substrLength?: number) => string; | ||
| declare const toPascalCase: (str: string) => string; | ||
| declare const snakeToPascal: (str: string) => string; | ||
| declare const capitalize: (str: string) => string; | ||
| declare const sleep: (timeout: number) => Promise<void>; | ||
| declare const awaitAll: <T, S>(array: Array<T>, callback: (item: T) => Promise<S>) => Promise<Awaited<S>[]>; | ||
| declare const awaitForAll: <T, S>(array: Array<T>, callback: (item: T) => Promise<S>, onError?: (error: unknown, item: T, index: number) => void) => Promise<S[]>; | ||
| declare const splitArrayToChunksThrow: <T>({ | ||
| array, | ||
| filter, | ||
| chunkSize | ||
| }: { | ||
| array: Array<T>; | ||
| chunkSize: number; | ||
| filter?: (item: T) => boolean; | ||
| }) => T[][]; | ||
| declare const splitArrayToChunks: <T>({ | ||
| array, | ||
| filter, | ||
| chunkSize | ||
| }: { | ||
| array: Array<T>; | ||
| chunkSize: number; | ||
| filter?: (item: T) => boolean; | ||
| }) => T[][]; | ||
| //#endregion | ||
| export { DEFAULT_BLOCK_TIMEOUT_HEIGHT, DEFAULT_BLOCK_TIME_IN_SECONDS, DEFAULT_BRIDGE_FEE_AMOUNT, DEFAULT_BRIDGE_FEE_DENOM, DEFAULT_BRIDGE_FEE_PRICE, DEFAULT_EXCHANGE_LIMIT, DEFAULT_FEE_DENOM, DEFAULT_GAS_LIMIT, DEFAULT_GAS_PRICE, DEFAULT_IBC_GAS_LIMIT, DEFAULT_STD_FEE_BY_DENOM, DEFAULT_TIMESTAMP_TIMEOUT_MS, DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS, DEFAULT_TX_POLL_CALL_TIMEOUT_MS, DEFAULT_TX_POLL_INTERVAL_MS, INJECTIVE_DENOM, INJ_DENOM, Status, StatusType, ZERO_ADDRESS, awaitAll, awaitForAll, capitalize, formatWalletAddress, getDefaultStdFee, sleep, snakeToPascal, splitArrayToChunks, splitArrayToChunksThrow, toPascalCase }; |
| import { t as _defineProperty } from "./defineProperty-Zp25b8Cm.js"; | ||
| //#region src/light.ts | ||
| const StatusType = { | ||
| Idle: "idle", | ||
| Loading: "loading", | ||
| Completed: "completed", | ||
| Error: "error", | ||
| Confirmed: "confirmed" | ||
| }; | ||
| var Status = class { | ||
| constructor(status = StatusType.Idle) { | ||
| _defineProperty(this, "status", void 0); | ||
| this.status = status; | ||
| } | ||
| get() { | ||
| return this.status; | ||
| } | ||
| set(status) { | ||
| this.status = status; | ||
| } | ||
| is(status) { | ||
| return this.status === status; | ||
| } | ||
| isLoading() { | ||
| return this.is(StatusType.Loading); | ||
| } | ||
| isNotLoading() { | ||
| return !this.is(StatusType.Loading); | ||
| } | ||
| isCompleted() { | ||
| return this.is(StatusType.Completed); | ||
| } | ||
| isConfirmed() { | ||
| return this.is(StatusType.Confirmed); | ||
| } | ||
| isIdle() { | ||
| return this.is(StatusType.Idle); | ||
| } | ||
| isError() { | ||
| return this.is(StatusType.Error); | ||
| } | ||
| setLoading() { | ||
| this.set(StatusType.Loading); | ||
| } | ||
| setCompleted() { | ||
| this.set(StatusType.Completed); | ||
| } | ||
| setConfirmed() { | ||
| this.set(StatusType.Confirmed); | ||
| } | ||
| setError() { | ||
| this.set(StatusType.Error); | ||
| } | ||
| setIdle() { | ||
| this.set(StatusType.Idle); | ||
| } | ||
| toggle() { | ||
| this.set(this.status === StatusType.Idle ? StatusType.Loading : StatusType.Idle); | ||
| } | ||
| toString() { | ||
| return this.get(); | ||
| } | ||
| valueOf() { | ||
| return this.get(); | ||
| } | ||
| }; | ||
| const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000"; | ||
| const INJ_DENOM = "inj"; | ||
| const INJECTIVE_DENOM = "inj"; | ||
| const DEFAULT_FEE_DENOM = "inj"; | ||
| const DEFAULT_GAS_LIMIT = 4e5; | ||
| const DEFAULT_IBC_GAS_LIMIT = 3e5; | ||
| const DEFAULT_GAS_PRICE = 16e7; | ||
| const DEFAULT_EXCHANGE_LIMIT = 2e5; | ||
| const DEFAULT_BRIDGE_FEE_DENOM = "inj"; | ||
| const DEFAULT_BRIDGE_FEE_PRICE = "160000000"; | ||
| const DEFAULT_BRIDGE_FEE_AMOUNT = "200000000000000"; | ||
| const DEFAULT_BLOCK_TIMEOUT_HEIGHT = 60; | ||
| const DEFAULT_BLOCK_TIME_IN_SECONDS = .7; | ||
| const DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS = Math.floor(DEFAULT_BLOCK_TIMEOUT_HEIGHT * DEFAULT_BLOCK_TIME_IN_SECONDS * 1e3); | ||
| const DEFAULT_TX_POLL_INTERVAL_MS = 500; | ||
| const DEFAULT_TX_POLL_CALL_TIMEOUT_MS = 3e3; | ||
| const DEFAULT_TIMESTAMP_TIMEOUT_MS = 60 * 1e3 * 3; | ||
| const getDefaultStdFee = () => ({ | ||
| amount: [{ | ||
| denom: "inj", | ||
| amount: String(DEFAULT_GAS_LIMIT * DEFAULT_GAS_PRICE) | ||
| }], | ||
| gas: DEFAULT_GAS_LIMIT.toString(), | ||
| payer: "", | ||
| granter: "", | ||
| feePayer: "" | ||
| }); | ||
| const DEFAULT_STD_FEE_BY_DENOM = (denom = "inj") => ({ | ||
| amount: [{ | ||
| denom, | ||
| amount: String(DEFAULT_GAS_LIMIT * DEFAULT_GAS_PRICE) | ||
| }], | ||
| gas: DEFAULT_GAS_LIMIT.toString() | ||
| }); | ||
| const formatWalletAddress = (address, substrLength = 6) => { | ||
| if (address.length <= 10) return address; | ||
| return `${address.slice(0, substrLength)}...${address.slice(address.length - substrLength, address.length)}`; | ||
| }; | ||
| const toPascalCase = (str) => { | ||
| return `${str}`.toLowerCase().replace(new RegExp(/[-_]+/, "g"), " ").replace(new RegExp(/[^\w\s]/, "g"), "").replace(new RegExp(/\s+(.)(\w*)/, "g"), (_$1, $2, $3) => `${$2.toUpperCase() + $3}`).replace(/* @__PURE__ */ new RegExp(/\w/), (s) => s.toUpperCase()); | ||
| }; | ||
| const snakeToPascal = (str) => { | ||
| return str.split("/").map((snake) => snake.split("_").map((substr) => substr.charAt(0).toUpperCase() + substr.slice(1)).join("")).join("/"); | ||
| }; | ||
| const capitalize = (str) => { | ||
| if (!str) return str; | ||
| return str[0].toUpperCase() + str.slice(1); | ||
| }; | ||
| const sleep = (timeout) => new Promise((resolve) => setTimeout(resolve, timeout)); | ||
| const awaitAll = async (array, callback) => await Promise.all(array.map(async (item) => await callback(item))); | ||
| const awaitForAll = async (array, callback, onError) => { | ||
| const result = []; | ||
| for (let index = 0; index < array.length; index += 1) try { | ||
| result.push(await callback(array[index])); | ||
| } catch (error) { | ||
| if (onError) onError(error, array[index], index); | ||
| } | ||
| return result; | ||
| }; | ||
| const splitArrayToChunksThrow = ({ array, filter, chunkSize }) => { | ||
| const chunks = []; | ||
| const chunkSizeInNumber = Number(chunkSize); | ||
| if (!Number.isFinite(chunkSizeInNumber) || !Number.isInteger(chunkSizeInNumber) || chunkSizeInNumber <= 0) throw new Error("Invalid chunk size, must be a positive integer"); | ||
| for (let index = 0; index < array.length; index += chunkSizeInNumber) { | ||
| const chunk = array.slice(index, index + chunkSizeInNumber); | ||
| if (filter) chunks.push(chunk.filter(filter)); | ||
| else chunks.push(chunk); | ||
| } | ||
| return chunks; | ||
| }; | ||
| const splitArrayToChunks = ({ array, filter, chunkSize }) => { | ||
| try { | ||
| return splitArrayToChunksThrow({ | ||
| array, | ||
| chunkSize, | ||
| filter | ||
| }); | ||
| } catch (_unused) { | ||
| return [array]; | ||
| } | ||
| }; | ||
| //#endregion | ||
| export { DEFAULT_BLOCK_TIMEOUT_HEIGHT, DEFAULT_BLOCK_TIME_IN_SECONDS, DEFAULT_BRIDGE_FEE_AMOUNT, DEFAULT_BRIDGE_FEE_DENOM, DEFAULT_BRIDGE_FEE_PRICE, DEFAULT_EXCHANGE_LIMIT, DEFAULT_FEE_DENOM, DEFAULT_GAS_LIMIT, DEFAULT_GAS_PRICE, DEFAULT_IBC_GAS_LIMIT, DEFAULT_STD_FEE_BY_DENOM, DEFAULT_TIMESTAMP_TIMEOUT_MS, DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS, DEFAULT_TX_POLL_CALL_TIMEOUT_MS, DEFAULT_TX_POLL_INTERVAL_MS, INJECTIVE_DENOM, INJ_DENOM, Status, StatusType, ZERO_ADDRESS, awaitAll, awaitForAll, capitalize, formatWalletAddress, getDefaultStdFee, sleep, snakeToPascal, splitArrayToChunks, splitArrayToChunksThrow, toPascalCase }; |
| import { t as _defineProperty } from "./defineProperty-Zp25b8Cm.js"; | ||
| import store from "store2"; | ||
| //#region src/classes/LocalStorage.ts | ||
| var LocalStorage = class { | ||
| constructor(namespace) { | ||
| _defineProperty(this, "storage", void 0); | ||
| this.storage = store.namespace(namespace); | ||
| } | ||
| get(key, defaultValue = {}) { | ||
| return this.storage.get(key) || defaultValue; | ||
| } | ||
| has(key) { | ||
| return this.storage.has(key); | ||
| } | ||
| set(key, value) { | ||
| this.storage.set(key, value); | ||
| } | ||
| remove(key) { | ||
| this.storage.remove(key); | ||
| } | ||
| clear() { | ||
| this.storage.clear(); | ||
| } | ||
| }; | ||
| //#endregion | ||
| export { LocalStorage as t }; |
| //#region src/classes/LocalStorage.d.ts | ||
| declare class LocalStorage { | ||
| private storage; | ||
| constructor(namespace: string); | ||
| get(key: string, defaultValue?: unknown): unknown; | ||
| has(key: string): boolean; | ||
| set(key: string, value: unknown): void; | ||
| remove(key: string): void; | ||
| clear(): void; | ||
| } | ||
| //#endregion | ||
| export { LocalStorage as t }; |
| import { t as BigNumber } from "./BigNumber-jKUujKpO.js"; | ||
| //#region src/numbers.d.ts | ||
| declare const getBigNumberWithRounding: () => typeof BigNumber; | ||
| declare const getSignificantDecimalsFromNumber: (number: BigNumber | number | string) => number; | ||
| declare const getExactDecimalsFromNumber: (number: number | string) => number; | ||
| //#endregion | ||
| export { getExactDecimalsFromNumber as n, getSignificantDecimalsFromNumber as r, getBigNumberWithRounding as t }; |
| import { t as BigNumber_default } from "./BigNumber-DUr2WQBK.js"; | ||
| //#region src/numbers.ts | ||
| const getBigNumberWithRounding = () => BigNumber_default.clone({ ROUNDING_MODE: BigNumber_default.ROUND_DOWN }); | ||
| const getSignificantDecimalsFromNumber = (number) => { | ||
| const $BigNumber = getBigNumberWithRounding(); | ||
| if (Math.floor(new $BigNumber(number).toNumber()) === number) return 0; | ||
| const [, decimals] = new $BigNumber(number).toFixed().split("."); | ||
| /** Number doesn't have decimals */ | ||
| if (!decimals) return 0; | ||
| return decimals.length; | ||
| }; | ||
| const getExactDecimalsFromNumber = (number) => { | ||
| if (!number.toString().includes(".")) return 0; | ||
| if (Number(number) % 1 === 0) return 0; | ||
| const [, decimals] = number.toString().split("."); | ||
| if (!decimals) return 0; | ||
| return decimals.length; | ||
| }; | ||
| //#endregion | ||
| export { getExactDecimalsFromNumber as n, getSignificantDecimalsFromNumber as r, getBigNumberWithRounding as t }; |
| import "./BigNumber-jKUujKpO.js"; | ||
| import { n as getExactDecimalsFromNumber, r as getSignificantDecimalsFromNumber, t as getBigNumberWithRounding } from "./numbers-Bnbd75cb.js"; | ||
| export { getBigNumberWithRounding, getExactDecimalsFromNumber, getSignificantDecimalsFromNumber }; |
| import "./BigNumber-DUr2WQBK.js"; | ||
| import { n as getExactDecimalsFromNumber, r as getSignificantDecimalsFromNumber, t as getBigNumberWithRounding } from "./numbers-Dh5x3_mA.js"; | ||
| export { getBigNumberWithRounding, getExactDecimalsFromNumber, getSignificantDecimalsFromNumber }; |
| //#region src/enum.d.ts | ||
| declare const StatusType: { | ||
| readonly Idle: "idle"; | ||
| readonly Loading: "loading"; | ||
| readonly Completed: "completed"; | ||
| readonly Error: "error"; | ||
| readonly Confirmed: "confirmed"; | ||
| }; | ||
| type StatusType = (typeof StatusType)[keyof typeof StatusType]; | ||
| //#endregion | ||
| //#region src/classes/Status.d.ts | ||
| declare class Status { | ||
| status: string; | ||
| constructor(status?: StatusType); | ||
| get(): string; | ||
| set(status: StatusType): void; | ||
| is(status: StatusType): boolean; | ||
| isLoading(): boolean; | ||
| isNotLoading(): boolean; | ||
| isCompleted(): boolean; | ||
| isConfirmed(): boolean; | ||
| isIdle(): boolean; | ||
| isError(): boolean; | ||
| setLoading(): void; | ||
| setCompleted(): void; | ||
| setConfirmed(): void; | ||
| setError(): void; | ||
| setIdle(): void; | ||
| toggle(): void; | ||
| toString(): string; | ||
| valueOf(): string; | ||
| } | ||
| //#endregion | ||
| export { StatusType as n, Status as t }; |
| import { t as _defineProperty } from "./defineProperty-Zp25b8Cm.js"; | ||
| //#region src/enum.ts | ||
| const StatusType = { | ||
| Idle: "idle", | ||
| Loading: "loading", | ||
| Completed: "completed", | ||
| Error: "error", | ||
| Confirmed: "confirmed" | ||
| }; | ||
| //#endregion | ||
| //#region src/classes/Status.ts | ||
| var Status = class { | ||
| constructor(status = StatusType.Idle) { | ||
| _defineProperty(this, "status", void 0); | ||
| this.status = status; | ||
| } | ||
| get() { | ||
| return this.status; | ||
| } | ||
| set(status) { | ||
| this.status = status; | ||
| } | ||
| is(status) { | ||
| return this.status === status; | ||
| } | ||
| isLoading() { | ||
| return this.is(StatusType.Loading); | ||
| } | ||
| isNotLoading() { | ||
| return !this.is(StatusType.Loading); | ||
| } | ||
| isCompleted() { | ||
| return this.is(StatusType.Completed); | ||
| } | ||
| isConfirmed() { | ||
| return this.is(StatusType.Confirmed); | ||
| } | ||
| isIdle() { | ||
| return this.is(StatusType.Idle); | ||
| } | ||
| isError() { | ||
| return this.is(StatusType.Error); | ||
| } | ||
| setLoading() { | ||
| this.set(StatusType.Loading); | ||
| } | ||
| setCompleted() { | ||
| this.set(StatusType.Completed); | ||
| } | ||
| setConfirmed() { | ||
| this.set(StatusType.Confirmed); | ||
| } | ||
| setError() { | ||
| this.set(StatusType.Error); | ||
| } | ||
| setIdle() { | ||
| this.set(StatusType.Idle); | ||
| } | ||
| toggle() { | ||
| this.set(this.status === StatusType.Idle ? StatusType.Loading : StatusType.Idle); | ||
| } | ||
| toString() { | ||
| return this.get(); | ||
| } | ||
| valueOf() { | ||
| return this.get(); | ||
| } | ||
| }; | ||
| //#endregion | ||
| export { StatusType as n, Status as t }; |
| import { n as StatusType, t as Status } from "./Status-C6A6ZtpL.js"; | ||
| export { Status, StatusType }; |
| import "./defineProperty-Zp25b8Cm.js"; | ||
| import { n as StatusType, t as Status } from "./Status-eHtiFREA.js"; | ||
| export { Status, StatusType }; |
| import { t as LocalStorage } from "./LocalStorage-CyTj3H1T.js"; | ||
| export { LocalStorage }; |
| import "./defineProperty-Zp25b8Cm.js"; | ||
| import { t as LocalStorage } from "./LocalStorage-Cpe5wG8z.js"; | ||
| export { LocalStorage }; |
| import { t as BigNumber_default } from "./BigNumber-DUr2WQBK.js"; | ||
| //#region src/time.ts | ||
| const getSecondsInDay = () => new BigNumber_default(3600 * 24); | ||
| const convertTimestampToMilliseconds = (timestamp) => { | ||
| const timestampInBigNumber = new BigNumber_default(timestamp); | ||
| if (timestamp.toString().length > 13) return timestampInBigNumber.precision(13, BigNumber_default.ROUND_HALF_UP).toNumber(); | ||
| if (timestamp.toString().length < 13) { | ||
| const trailingZeros = 13 - timestamp.toString().length; | ||
| return timestampInBigNumber.times(10 ** trailingZeros).toNumber(); | ||
| } | ||
| return timestampInBigNumber.toNumber(); | ||
| }; | ||
| const getUTCDateFromTimestamp = (timestamp) => { | ||
| const date = new Date(convertTimestampToMilliseconds(timestamp)); | ||
| return `${date.getUTCDate()}-${date.getUTCMonth() + 1}-${date.getUTCFullYear()}`; | ||
| }; | ||
| const tomorrow = () => new BigNumber_default(Math.floor((/* @__PURE__ */ new Date()).valueOf() / 1e3) + 3600 * 24); | ||
| const todayInSeconds = () => Math.floor(Date.now() / 1e3); | ||
| const past24Hours = () => new BigNumber_default(todayInSeconds()).minus(getSecondsInDay()).toNumber(); | ||
| const pastDays = (day = 1) => new BigNumber_default(todayInSeconds()).minus(getSecondsInDay().times(day)).toNumber(); | ||
| const getEndDateStringFromTimeInSeconds = (timeInSeconds) => { | ||
| return (/* @__PURE__ */ new Date(timeInSeconds.toNumber() * 1e3)).toLocaleString("en-us"); | ||
| }; | ||
| //#endregion | ||
| export { past24Hours as a, tomorrow as c, getUTCDateFromTimestamp as i, getEndDateStringFromTimeInSeconds as n, pastDays as o, getSecondsInDay as r, todayInSeconds as s, convertTimestampToMilliseconds as t }; |
| import { t as BigNumber } from "./BigNumber-jKUujKpO.js"; | ||
| //#region src/time.d.ts | ||
| declare const getSecondsInDay: () => BigNumber; | ||
| declare const convertTimestampToMilliseconds: (timestamp: number | string) => number; | ||
| declare const getUTCDateFromTimestamp: (timestamp: number) => string; | ||
| declare const tomorrow: () => BigNumber; | ||
| declare const todayInSeconds: () => number; | ||
| declare const past24Hours: () => number; | ||
| declare const pastDays: (day?: number) => number; | ||
| declare const getEndDateStringFromTimeInSeconds: (timeInSeconds: BigNumber) => string; | ||
| //#endregion | ||
| export { past24Hours as a, tomorrow as c, getUTCDateFromTimestamp as i, getEndDateStringFromTimeInSeconds as n, pastDays as o, getSecondsInDay as r, todayInSeconds as s, convertTimestampToMilliseconds as t }; |
| import "./BigNumber-jKUujKpO.js"; | ||
| import { a as past24Hours, c as tomorrow, i as getUTCDateFromTimestamp, n as getEndDateStringFromTimeInSeconds, o as pastDays, r as getSecondsInDay, s as todayInSeconds, t as convertTimestampToMilliseconds } from "./time-DJirA2PE.js"; | ||
| export { convertTimestampToMilliseconds, getEndDateStringFromTimeInSeconds, getSecondsInDay, getUTCDateFromTimestamp, past24Hours, pastDays, todayInSeconds, tomorrow }; |
| import "./BigNumber-DUr2WQBK.js"; | ||
| import { a as past24Hours, c as tomorrow, i as getUTCDateFromTimestamp, n as getEndDateStringFromTimeInSeconds, o as pastDays, r as getSecondsInDay, s as todayInSeconds, t as convertTimestampToMilliseconds } from "./time-BBEhFnvo.js"; | ||
| export { convertTimestampToMilliseconds, getEndDateStringFromTimeInSeconds, getSecondsInDay, getUTCDateFromTimestamp, past24Hours, pastDays, todayInSeconds, tomorrow }; |
+46
-511
@@ -1,481 +0,16 @@ | ||
| const require_constants = require('./constants-BFjeP4ow.cjs'); | ||
| let axios = require("axios"); | ||
| axios = require_constants.__toESM(axios); | ||
| let store2 = require("store2"); | ||
| store2 = require_constants.__toESM(store2); | ||
| let http_status_codes = require("http-status-codes"); | ||
| let __injectivelabs_exceptions = require("@injectivelabs/exceptions"); | ||
| require('./defineProperty-CImP5zIM.cjs'); | ||
| const require_HttpRestClient = require('./HttpRestClient-C761J3nA.cjs'); | ||
| const require_BigNumber = require('./BigNumber-DbDA4_xA.cjs'); | ||
| const require_time = require('./time-CPSnQ8xf.cjs'); | ||
| const require_constants = require('./constants-BdaegCnI.cjs'); | ||
| const require_helpers = require('./helpers-BW4oKV4e.cjs'); | ||
| const require_numbers = require('./numbers-BRXzNJ1I.cjs'); | ||
| const require_formatters = require('./formatters-CBhRviK1.cjs'); | ||
| const require_Status = require('./Status-C1EkdFOa.cjs'); | ||
| const require_LocalStorage = require('./LocalStorage-DRuofBv_.cjs'); | ||
| const require_BigNumberInBase = require('./BigNumberInBase-CVKbAXw6.cjs'); | ||
| //#region src/time.ts | ||
| const getSecondsInDay = () => new require_constants.BigNumber_default(3600 * 24); | ||
| const convertTimestampToMilliseconds = (timestamp) => { | ||
| const timestampInBigNumber = new require_constants.BigNumber_default(timestamp); | ||
| if (timestamp.toString().length > 13) return timestampInBigNumber.precision(13, require_constants.BigNumber_default.ROUND_HALF_UP).toNumber(); | ||
| if (timestamp.toString().length < 13) { | ||
| const trailingZeros = 13 - timestamp.toString().length; | ||
| return timestampInBigNumber.times(10 ** trailingZeros).toNumber(); | ||
| } | ||
| return timestampInBigNumber.toNumber(); | ||
| }; | ||
| const getUTCDateFromTimestamp = (timestamp) => { | ||
| const date = new Date(convertTimestampToMilliseconds(timestamp)); | ||
| return `${date.getUTCDate()}-${date.getUTCMonth() + 1}-${date.getUTCFullYear()}`; | ||
| }; | ||
| const tomorrow = () => new require_constants.BigNumber_default(Math.floor((/* @__PURE__ */ new Date()).valueOf() / 1e3) + 3600 * 24); | ||
| const todayInSeconds = () => Math.floor(Date.now() / 1e3); | ||
| const past24Hours = () => new require_constants.BigNumber_default(todayInSeconds()).minus(getSecondsInDay()).toNumber(); | ||
| const pastDays = (day = 1) => new require_constants.BigNumber_default(todayInSeconds()).minus(getSecondsInDay().times(day)).toNumber(); | ||
| const getEndDateStringFromTimeInSeconds = (timeInSeconds) => { | ||
| return (/* @__PURE__ */ new Date(timeInSeconds.toNumber() * 1e3)).toLocaleString("en-us"); | ||
| }; | ||
| //#endregion | ||
| //#region src/helpers.ts | ||
| const sleep = (timeout) => new Promise((resolve) => setTimeout(resolve, timeout)); | ||
| /** | ||
| * When we want to execute the promises in batch | ||
| */ | ||
| const awaitAll = async (array, callback) => await Promise.all(array.map(async (item) => await callback(item))); | ||
| /** | ||
| * When we want to execute the promises one by one | ||
| * and not all in batch as with await Promise.all() | ||
| */ | ||
| const awaitForAll = async (array, callback, onError) => { | ||
| const result = []; | ||
| for (let i = 0; i < array.length; i += 1) try { | ||
| result.push(await callback(array[i])); | ||
| } catch (e) { | ||
| if (onError) onError(e, array[i], i); | ||
| } | ||
| return result; | ||
| }; | ||
| const splitArrayToChunksThrow = ({ array, filter, chunkSize }) => { | ||
| const chunks = []; | ||
| const chunkSizeInNumber = Number(chunkSize); | ||
| if (isNaN(chunkSizeInNumber)) throw new Error("Invalid chunk size, must be a valid number"); | ||
| for (let i = 0; i < array.length; i += chunkSizeInNumber) { | ||
| const chunk = array.slice(i, i + chunkSizeInNumber); | ||
| if (filter) chunks.push(chunk.filter(filter)); | ||
| else chunks.push(chunk); | ||
| } | ||
| return chunks; | ||
| }; | ||
| const splitArrayToChunks = ({ array, filter, chunkSize }) => { | ||
| try { | ||
| return splitArrayToChunksThrow({ | ||
| array, | ||
| chunkSize, | ||
| filter | ||
| }); | ||
| } catch (_unused) { | ||
| return [array]; | ||
| } | ||
| }; | ||
| const getStdFeeForToken = (token = { | ||
| denom: "inj", | ||
| decimals: 18 | ||
| }, gasPrice, gasLimit) => { | ||
| const gasPriceScaled = require_constants.toChainFormat(gasPrice || require_constants.toHumanReadable(require_constants.DEFAULT_GAS_PRICE, 18), token.decimals).toFixed(0); | ||
| const gasNormalized = new require_constants.BigNumber_default(gasLimit || require_constants.DEFAULT_GAS_LIMIT).toFixed(0); | ||
| return { | ||
| amount: [{ | ||
| denom: token.denom, | ||
| amount: new require_constants.BigNumber_default(gasPriceScaled).times(gasNormalized).toFixed() | ||
| }], | ||
| gas: (gasLimit || require_constants.DEFAULT_GAS_LIMIT).toString() | ||
| }; | ||
| }; | ||
| const getStdFeeFromObject = (args) => { | ||
| if (!args) return require_constants.getDefaultStdFee(); | ||
| const { payer, granter, feePayer, gasPrice = require_constants.DEFAULT_GAS_PRICE, gas = require_constants.DEFAULT_GAS_LIMIT.toString() } = args; | ||
| const gasNormalized = require_constants.toBigNumber(gas).toFixed(0); | ||
| const gasPriceNormalized = require_constants.toBigNumber(gasPrice).toFixed(0); | ||
| return { | ||
| amount: [{ | ||
| denom: "inj", | ||
| amount: require_constants.toBigNumber(gasNormalized).times(gasPriceNormalized).toFixed() | ||
| }], | ||
| gas: require_constants.toBigNumber(gasNormalized).toFixed(), | ||
| payer, | ||
| granter, | ||
| feePayer | ||
| }; | ||
| }; | ||
| const getStdFeeFromString = (gasPrice) => { | ||
| const matchResult = gasPrice.match(/^([0-9.]+)([a-zA-Z][a-zA-Z0-9/:._-]*)$/); | ||
| if (!matchResult) throw new Error("Invalid gas price string"); | ||
| const [_, amount] = matchResult; | ||
| return getStdFeeFromObject({ | ||
| gas: require_constants.toChainFormat(amount, 18).dividedBy(require_constants.DEFAULT_GAS_PRICE).toFixed(0), | ||
| gasPrice: require_constants.DEFAULT_GAS_PRICE | ||
| }); | ||
| }; | ||
| const getStdFee = (args) => { | ||
| if (!args) return require_constants.getDefaultStdFee(); | ||
| if (typeof args === "string") return getStdFeeFromString(args); | ||
| return getStdFeeFromObject({ ...args }); | ||
| }; | ||
| //#endregion | ||
| //#region src/numbers.ts | ||
| const getBigNumberWithRounding = () => require_constants.BigNumber_default.clone({ ROUNDING_MODE: require_constants.BigNumber_default.ROUND_DOWN }); | ||
| const getSignificantDecimalsFromNumber = (number) => { | ||
| const $BigNumber = getBigNumberWithRounding(); | ||
| if (Math.floor(new $BigNumber(number).toNumber()) === number) return 0; | ||
| const [, decimals] = new $BigNumber(number).toFixed().split("."); | ||
| /** Number doesn't have decimals */ | ||
| if (!decimals) return 0; | ||
| return decimals.length; | ||
| }; | ||
| const getExactDecimalsFromNumber = (number) => { | ||
| if (!number.toString().includes(".")) return 0; | ||
| if (Number(number) % 1 === 0) return 0; | ||
| const [, decimals] = number.toString().split("."); | ||
| if (!decimals) return 0; | ||
| return decimals.length; | ||
| }; | ||
| //#endregion | ||
| //#region src/formatters.ts | ||
| const formatWalletAddress = (address, substrLength = 6) => { | ||
| if (address.length <= 10) return address; | ||
| return `${address.slice(0, substrLength)}...${address.slice(address.length - substrLength, address.length)}`; | ||
| }; | ||
| const toPascalCase = (str) => { | ||
| return `${str}`.toLowerCase().replace(new RegExp(/[-_]+/, "g"), " ").replace(new RegExp(/[^\w\s]/, "g"), "").replace(new RegExp(/\s+(.)(\w*)/, "g"), (_$1, $2, $3) => `${$2.toUpperCase() + $3}`).replace(/* @__PURE__ */ new RegExp(/\w/), (s) => s.toUpperCase()); | ||
| }; | ||
| const snakeToPascal = (str) => { | ||
| return str.split("/").map((snake) => snake.split("_").map((substr) => substr.charAt(0).toUpperCase() + substr.slice(1)).join("")).join("/"); | ||
| }; | ||
| const capitalize = (str) => str[0].toUpperCase() + str.slice(1); | ||
| //#endregion | ||
| //#region src/enum.ts | ||
| const StatusType = { | ||
| Idle: "idle", | ||
| Loading: "loading", | ||
| Completed: "completed", | ||
| Error: "error", | ||
| Confirmed: "confirmed" | ||
| }; | ||
| //#endregion | ||
| //#region \0@oxc-project+runtime@0.99.0/helpers/typeof.js | ||
| function _typeof(o) { | ||
| "@babel/helpers - typeof"; | ||
| return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) { | ||
| return typeof o$1; | ||
| } : function(o$1) { | ||
| return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1; | ||
| }, _typeof(o); | ||
| } | ||
| //#endregion | ||
| //#region \0@oxc-project+runtime@0.99.0/helpers/toPrimitive.js | ||
| function toPrimitive(t, r) { | ||
| if ("object" != _typeof(t) || !t) return t; | ||
| var e = t[Symbol.toPrimitive]; | ||
| if (void 0 !== e) { | ||
| var i = e.call(t, r || "default"); | ||
| if ("object" != _typeof(i)) return i; | ||
| throw new TypeError("@@toPrimitive must return a primitive value."); | ||
| } | ||
| return ("string" === r ? String : Number)(t); | ||
| } | ||
| //#endregion | ||
| //#region \0@oxc-project+runtime@0.99.0/helpers/toPropertyKey.js | ||
| function toPropertyKey(t) { | ||
| var i = toPrimitive(t, "string"); | ||
| return "symbol" == _typeof(i) ? i : i + ""; | ||
| } | ||
| //#endregion | ||
| //#region \0@oxc-project+runtime@0.99.0/helpers/defineProperty.js | ||
| function _defineProperty(e, r, t) { | ||
| return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, { | ||
| value: t, | ||
| enumerable: !0, | ||
| configurable: !0, | ||
| writable: !0 | ||
| }) : e[r] = t, e; | ||
| } | ||
| //#endregion | ||
| //#region src/classes/Status.ts | ||
| var Status = class { | ||
| constructor(status = StatusType.Idle) { | ||
| _defineProperty(this, "status", void 0); | ||
| this.status = status; | ||
| } | ||
| get() { | ||
| return this.status; | ||
| } | ||
| set(status) { | ||
| this.status = status; | ||
| } | ||
| is(status) { | ||
| return this.status === status; | ||
| } | ||
| isLoading() { | ||
| return this.is(StatusType.Loading); | ||
| } | ||
| isNotLoading() { | ||
| return !this.is(StatusType.Loading); | ||
| } | ||
| isCompleted() { | ||
| return this.is(StatusType.Completed); | ||
| } | ||
| isConfirmed() { | ||
| return this.is(StatusType.Confirmed); | ||
| } | ||
| isIdle() { | ||
| return this.is(StatusType.Idle); | ||
| } | ||
| isError() { | ||
| return this.is(StatusType.Error); | ||
| } | ||
| setLoading() { | ||
| this.set(StatusType.Loading); | ||
| } | ||
| setCompleted() { | ||
| this.set(StatusType.Completed); | ||
| } | ||
| setConfirmed() { | ||
| this.set(StatusType.Confirmed); | ||
| } | ||
| setError() { | ||
| this.set(StatusType.Error); | ||
| } | ||
| setIdle() { | ||
| this.set(StatusType.Idle); | ||
| } | ||
| toggle() { | ||
| this.set(this.status === StatusType.Idle ? StatusType.Loading : StatusType.Idle); | ||
| } | ||
| toString() { | ||
| return this.get(); | ||
| } | ||
| valueOf() { | ||
| return this.get(); | ||
| } | ||
| }; | ||
| //#endregion | ||
| //#region src/classes/HttpClient.ts | ||
| var HttpClient = class { | ||
| constructor(endpoint, options = { headers: { "Content-Type": "application/json" } }) { | ||
| _defineProperty(this, "client", void 0); | ||
| _defineProperty(this, "config", {}); | ||
| this.client = axios.default.create({ | ||
| baseURL: endpoint, | ||
| timeout: 15e3, | ||
| ...options | ||
| }); | ||
| this.config = {}; | ||
| } | ||
| setConfig(config) { | ||
| this.config = config; | ||
| return this; | ||
| } | ||
| get(endpoint, params = {}) { | ||
| return this.client.get(endpoint, { | ||
| params, | ||
| ...this.config | ||
| }); | ||
| } | ||
| post(endpoint, data = {}) { | ||
| return this.client.post(endpoint, data, this.config); | ||
| } | ||
| put(endpoint, data = {}) { | ||
| return this.client.put(endpoint, data, this.config); | ||
| } | ||
| delete(endpoint, params = {}) { | ||
| return this.client.delete(endpoint, { | ||
| params, | ||
| ...this.config | ||
| }); | ||
| } | ||
| }; | ||
| //#endregion | ||
| //#region src/classes/LocalStorage.ts | ||
| var LocalStorage = class { | ||
| constructor(namespace) { | ||
| _defineProperty(this, "storage", void 0); | ||
| this.storage = store2.default.namespace(namespace); | ||
| } | ||
| get(key, defaultValue = {}) { | ||
| return this.storage.get(key) || defaultValue; | ||
| } | ||
| has(key) { | ||
| return this.storage.has(key); | ||
| } | ||
| set(key, value) { | ||
| this.storage.set(key, value); | ||
| } | ||
| remove(key) { | ||
| this.storage.remove(key); | ||
| } | ||
| clear() { | ||
| this.storage.clear(); | ||
| } | ||
| }; | ||
| //#endregion | ||
| //#region src/classes/BigNumberInWei.ts | ||
| /** | ||
| * @deprecated - use toChainFormat instead | ||
| */ | ||
| var BigNumberInWei = class BigNumberInWei extends require_constants.BigNumber_default { | ||
| static make(number) { | ||
| return new BigNumberInWei(number); | ||
| } | ||
| minus(n, base) { | ||
| return new BigNumberInWei(super.minus(n, base)); | ||
| } | ||
| plus(n, base) { | ||
| return new BigNumberInWei(super.plus(n, base)); | ||
| } | ||
| dividedBy(n, base) { | ||
| return new BigNumberInWei(super.dividedBy(n, base)); | ||
| } | ||
| div(n, base) { | ||
| return new BigNumberInWei(super.div(n, base)); | ||
| } | ||
| multipliedBy(n, base) { | ||
| return new BigNumberInWei(super.multipliedBy(n, base)); | ||
| } | ||
| times(n, base) { | ||
| return new BigNumberInWei(super.times(n, base)); | ||
| } | ||
| pow(n, base) { | ||
| return new BigNumberInWei(super.pow(n, base)); | ||
| } | ||
| toBase(decimals = 18) { | ||
| return new require_constants.BigNumber_default(this).dividedBy(new require_constants.BigNumber_default(10).pow(decimals)); | ||
| } | ||
| }; | ||
| //#endregion | ||
| //#region src/classes/HttpRestClient.ts | ||
| const getErrorMessage = (error, endpoint) => { | ||
| if (!error.response) return `The request to ${endpoint} has failed.`; | ||
| return error.response.data ? error.response.data.message || error.response.data.statusMessage || error.response.data : error.response.statusText; | ||
| }; | ||
| /** | ||
| * @hidden | ||
| */ | ||
| var HttpRestClient = class { | ||
| constructor(endpoint, options = {}) { | ||
| _defineProperty(this, "client", void 0); | ||
| _defineProperty(this, "endpoint", void 0); | ||
| this.client = new HttpClient(endpoint, options); | ||
| this.endpoint = endpoint; | ||
| } | ||
| setConfig(config) { | ||
| this.client.setConfig(config); | ||
| return this; | ||
| } | ||
| async get(endpoint, params = {}) { | ||
| try { | ||
| return await this.client.get(endpoint, params); | ||
| } catch (e) { | ||
| const error = e; | ||
| if (axios.default.isAxiosError(error)) { | ||
| if (error.code === "ECONNABORTED") throw new __injectivelabs_exceptions.HttpRequestException(new Error(error.message), { | ||
| code: http_status_codes.StatusCodes.REQUEST_TOO_LONG, | ||
| context: endpoint | ||
| }); | ||
| const message = getErrorMessage(error, endpoint); | ||
| throw new __injectivelabs_exceptions.HttpRequestException(new Error(message), { | ||
| context: endpoint, | ||
| code: error.response ? error.response.status : http_status_codes.StatusCodes.BAD_REQUEST | ||
| }); | ||
| } | ||
| throw new __injectivelabs_exceptions.HttpRequestException(new Error(error.message), { | ||
| code: __injectivelabs_exceptions.UnspecifiedErrorCode, | ||
| context: endpoint | ||
| }); | ||
| } | ||
| } | ||
| async retry(httpCall, retries = 3, delay = 1e3) { | ||
| const retryHttpCall = async (attempt = 1) => { | ||
| try { | ||
| return await httpCall(); | ||
| } catch (e) { | ||
| if (e instanceof __injectivelabs_exceptions.HttpRequestException) { | ||
| if (e.code === http_status_codes.StatusCodes.REQUEST_TOO_LONG) throw e; | ||
| } | ||
| if (attempt >= retries) throw e; | ||
| return new Promise((resolve) => setTimeout(() => resolve(retryHttpCall(attempt + 1)), delay * attempt)); | ||
| } | ||
| }; | ||
| return retryHttpCall(); | ||
| } | ||
| async post(endpoint, params = {}) { | ||
| try { | ||
| return await this.client.post(endpoint, params); | ||
| } catch (e) { | ||
| const error = e; | ||
| if (axios.default.isAxiosError(error)) { | ||
| if (error.code === "ECONNABORTED") throw new __injectivelabs_exceptions.HttpRequestException(new Error(error.message), { | ||
| code: http_status_codes.StatusCodes.REQUEST_TOO_LONG, | ||
| method: __injectivelabs_exceptions.HttpRequestMethod.Post | ||
| }); | ||
| const message = getErrorMessage(error, endpoint); | ||
| throw new __injectivelabs_exceptions.HttpRequestException(new Error(message), { | ||
| code: error.response ? error.response.status : http_status_codes.StatusCodes.BAD_REQUEST, | ||
| context: endpoint, | ||
| contextModule: __injectivelabs_exceptions.HttpRequestMethod.Post | ||
| }); | ||
| } | ||
| throw new __injectivelabs_exceptions.HttpRequestException(new Error(error.message), { | ||
| code: __injectivelabs_exceptions.UnspecifiedErrorCode, | ||
| context: endpoint, | ||
| contextModule: __injectivelabs_exceptions.HttpRequestMethod.Post | ||
| }); | ||
| } | ||
| } | ||
| }; | ||
| //#endregion | ||
| //#region src/classes/BigNumberInBase.ts | ||
| /** | ||
| * @deprecated - use toHumanReadable instead | ||
| */ | ||
| var BigNumberInBase = class BigNumberInBase extends require_constants.BigNumber_default { | ||
| static make(number) { | ||
| return new BigNumberInBase(number); | ||
| } | ||
| minus(n, base) { | ||
| return new BigNumberInBase(super.minus(n, base)); | ||
| } | ||
| plus(n, base) { | ||
| return new BigNumberInBase(super.plus(n, base)); | ||
| } | ||
| dividedBy(n, base) { | ||
| return new BigNumberInBase(super.dividedBy(n, base)); | ||
| } | ||
| div(n, base) { | ||
| return new BigNumberInBase(super.div(n, base)); | ||
| } | ||
| multipliedBy(n, base) { | ||
| return new BigNumberInBase(super.multipliedBy(n, base)); | ||
| } | ||
| times(n, base) { | ||
| return new BigNumberInBase(super.times(n, base)); | ||
| } | ||
| pow(n, base) { | ||
| return new BigNumberInBase(super.pow(n, base)); | ||
| } | ||
| toWei(decimals = 18) { | ||
| return new require_constants.BigNumber_default(this).multipliedBy(new require_constants.BigNumber_default(10).pow(decimals)); | ||
| } | ||
| }; | ||
| //#endregion | ||
| exports.BigNumber = require_constants.BigNumber_default; | ||
| exports.BigNumberInBase = BigNumberInBase; | ||
| exports.BigNumberInWei = BigNumberInWei; | ||
| exports.BigNumber = require_BigNumber.BigNumber_default; | ||
| exports.BigNumberInBase = require_BigNumberInBase.BigNumberInBase; | ||
| exports.BigNumberInWei = require_BigNumberInBase.BigNumberInWei; | ||
| exports.DEFAULT_BLOCK_TIMEOUT_HEIGHT = require_constants.DEFAULT_BLOCK_TIMEOUT_HEIGHT; | ||
@@ -496,37 +31,37 @@ exports.DEFAULT_BLOCK_TIME_IN_SECONDS = require_constants.DEFAULT_BLOCK_TIME_IN_SECONDS; | ||
| exports.DEFAULT_TX_POLL_INTERVAL_MS = require_constants.DEFAULT_TX_POLL_INTERVAL_MS; | ||
| exports.HttpClient = HttpClient; | ||
| exports.HttpRestClient = HttpRestClient; | ||
| exports.HttpClient = require_HttpRestClient.HttpClient; | ||
| exports.HttpRestClient = require_HttpRestClient.HttpRestClient; | ||
| exports.INJECTIVE_DENOM = require_constants.INJECTIVE_DENOM; | ||
| exports.INJ_DENOM = require_constants.INJ_DENOM; | ||
| exports.LocalStorage = LocalStorage; | ||
| exports.Status = Status; | ||
| exports.StatusType = StatusType; | ||
| exports.LocalStorage = require_LocalStorage.LocalStorage; | ||
| exports.Status = require_Status.Status; | ||
| exports.StatusType = require_Status.StatusType; | ||
| exports.ZERO_ADDRESS = require_constants.ZERO_ADDRESS; | ||
| exports.awaitAll = awaitAll; | ||
| exports.awaitForAll = awaitForAll; | ||
| exports.capitalize = capitalize; | ||
| exports.convertTimestampToMilliseconds = convertTimestampToMilliseconds; | ||
| exports.formatWalletAddress = formatWalletAddress; | ||
| exports.getBigNumberWithRounding = getBigNumberWithRounding; | ||
| exports.awaitAll = require_helpers.awaitAll; | ||
| exports.awaitForAll = require_helpers.awaitForAll; | ||
| exports.capitalize = require_formatters.capitalize; | ||
| exports.convertTimestampToMilliseconds = require_time.convertTimestampToMilliseconds; | ||
| exports.formatWalletAddress = require_formatters.formatWalletAddress; | ||
| exports.getBigNumberWithRounding = require_numbers.getBigNumberWithRounding; | ||
| exports.getDefaultStdFee = require_constants.getDefaultStdFee; | ||
| exports.getEndDateStringFromTimeInSeconds = getEndDateStringFromTimeInSeconds; | ||
| exports.getExactDecimalsFromNumber = getExactDecimalsFromNumber; | ||
| exports.getSecondsInDay = getSecondsInDay; | ||
| exports.getSignificantDecimalsFromNumber = getSignificantDecimalsFromNumber; | ||
| exports.getStdFee = getStdFee; | ||
| exports.getStdFeeForToken = getStdFeeForToken; | ||
| exports.getStdFeeFromObject = getStdFeeFromObject; | ||
| exports.getStdFeeFromString = getStdFeeFromString; | ||
| exports.getUTCDateFromTimestamp = getUTCDateFromTimestamp; | ||
| exports.past24Hours = past24Hours; | ||
| exports.pastDays = pastDays; | ||
| exports.sleep = sleep; | ||
| exports.snakeToPascal = snakeToPascal; | ||
| exports.splitArrayToChunks = splitArrayToChunks; | ||
| exports.splitArrayToChunksThrow = splitArrayToChunksThrow; | ||
| exports.toBigNumber = require_constants.toBigNumber; | ||
| exports.toChainFormat = require_constants.toChainFormat; | ||
| exports.toHumanReadable = require_constants.toHumanReadable; | ||
| exports.toPascalCase = toPascalCase; | ||
| exports.todayInSeconds = todayInSeconds; | ||
| exports.tomorrow = tomorrow; | ||
| exports.getEndDateStringFromTimeInSeconds = require_time.getEndDateStringFromTimeInSeconds; | ||
| exports.getExactDecimalsFromNumber = require_numbers.getExactDecimalsFromNumber; | ||
| exports.getSecondsInDay = require_time.getSecondsInDay; | ||
| exports.getSignificantDecimalsFromNumber = require_numbers.getSignificantDecimalsFromNumber; | ||
| exports.getStdFee = require_helpers.getStdFee; | ||
| exports.getStdFeeForToken = require_helpers.getStdFeeForToken; | ||
| exports.getStdFeeFromObject = require_helpers.getStdFeeFromObject; | ||
| exports.getStdFeeFromString = require_helpers.getStdFeeFromString; | ||
| exports.getUTCDateFromTimestamp = require_time.getUTCDateFromTimestamp; | ||
| exports.past24Hours = require_time.past24Hours; | ||
| exports.pastDays = require_time.pastDays; | ||
| exports.sleep = require_helpers.sleep; | ||
| exports.snakeToPascal = require_formatters.snakeToPascal; | ||
| exports.splitArrayToChunks = require_helpers.splitArrayToChunks; | ||
| exports.splitArrayToChunksThrow = require_helpers.splitArrayToChunksThrow; | ||
| exports.toBigNumber = require_BigNumber.toBigNumber; | ||
| exports.toChainFormat = require_BigNumber.toChainFormat; | ||
| exports.toHumanReadable = require_BigNumber.toHumanReadable; | ||
| exports.toPascalCase = require_formatters.toPascalCase; | ||
| exports.todayInSeconds = require_time.todayInSeconds; | ||
| exports.tomorrow = require_time.tomorrow; |
+10
-269
@@ -1,270 +0,11 @@ | ||
| import BigNumber from "bignumber.js"; | ||
| import { AccountAddress } from "@injectivelabs/ts-types"; | ||
| import { AxiosRequestConfig } from "axios"; | ||
| //#region src/classes/BigNumber.d.ts | ||
| /** | ||
| * Converts a value to BigNumber if it isn't already | ||
| */ | ||
| declare const toBigNumber: (value: BigNumber | string | number) => BigNumber; | ||
| /** | ||
| * Converts a value to Wei (multiplies by 10^decimals) default to 18 decimals | ||
| */ | ||
| declare const toChainFormat: (value: BigNumber | string | number, decimals?: number) => BigNumber; | ||
| /** | ||
| * Converts a value from Wei to Base (divides by 10^decimals) default to 18 decimals | ||
| */ | ||
| declare const toHumanReadable: (value: BigNumber | string | number, decimals?: number) => BigNumber; | ||
| //#endregion | ||
| //#region src/time.d.ts | ||
| declare const getSecondsInDay: () => BigNumber; | ||
| declare const convertTimestampToMilliseconds: (timestamp: number | string) => number; | ||
| declare const getUTCDateFromTimestamp: (timestamp: number) => string; | ||
| declare const tomorrow: () => BigNumber; | ||
| declare const todayInSeconds: () => number; | ||
| declare const past24Hours: () => number; | ||
| declare const pastDays: (day?: number) => number; | ||
| declare const getEndDateStringFromTimeInSeconds: (timeInSeconds: BigNumber) => string; | ||
| //#endregion | ||
| //#region src/types.d.ts | ||
| type Awaited<T> = T extends null | undefined ? T : T extends object & { | ||
| then(onfulfilled: infer F, ...args: infer _): any; | ||
| } ? F extends ((value: infer V, ...args: infer _) => any) ? Awaited<V> : never : T; | ||
| //#endregion | ||
| //#region src/helpers.d.ts | ||
| declare const sleep: (timeout: number) => Promise<void>; | ||
| /** | ||
| * When we want to execute the promises in batch | ||
| */ | ||
| declare const awaitAll: <T, S>(array: Array<T>, callback: (item: T) => Promise<S>) => Promise<Awaited<S>[]>; | ||
| /** | ||
| * When we want to execute the promises one by one | ||
| * and not all in batch as with await Promise.all() | ||
| */ | ||
| declare const awaitForAll: <T, S>(array: Array<T>, callback: (item: T) => Promise<S>, onError?: (error: unknown, item: T, index: number) => void) => Promise<S[]>; | ||
| declare const splitArrayToChunksThrow: <T>({ | ||
| array, | ||
| filter, | ||
| chunkSize | ||
| }: { | ||
| array: Array<T>; | ||
| chunkSize: number; | ||
| filter?: (item: T) => boolean; | ||
| }) => T[][]; | ||
| declare const splitArrayToChunks: <T>({ | ||
| array, | ||
| filter, | ||
| chunkSize | ||
| }: { | ||
| array: Array<T>; | ||
| chunkSize: number; | ||
| filter?: (item: T) => boolean; | ||
| }) => T[][]; | ||
| declare const getStdFeeForToken: (token?: { | ||
| denom: string; | ||
| decimals: number; | ||
| }, gasPrice?: string, gasLimit?: string) => { | ||
| amount: { | ||
| denom: string; | ||
| amount: string; | ||
| }[]; | ||
| gas: string; | ||
| }; | ||
| declare const getStdFeeFromObject: (args?: { | ||
| gas?: string | number; | ||
| payer?: string; | ||
| granter?: string; | ||
| gasPrice?: string | number; | ||
| feePayer?: string; | ||
| }) => { | ||
| amount: { | ||
| denom: string; | ||
| amount: string; | ||
| }[]; | ||
| gas: string; | ||
| payer: string | undefined; /** for Web3Gateway fee delegation */ | ||
| granter: string | undefined; | ||
| feePayer: string | undefined; | ||
| }; | ||
| declare const getStdFeeFromString: (gasPrice: string) => { | ||
| amount: { | ||
| denom: string; | ||
| amount: string; | ||
| }[]; | ||
| gas: string; | ||
| payer: string | undefined; /** for Web3Gateway fee delegation */ | ||
| granter: string | undefined; | ||
| feePayer: string | undefined; | ||
| }; | ||
| declare const getStdFee: (args?: string | { | ||
| payer?: string; | ||
| granter?: string; | ||
| feePayer?: string; | ||
| gas?: string | number; | ||
| gasPrice?: string | number; | ||
| }) => { | ||
| amount: { | ||
| denom: string; | ||
| amount: string; | ||
| }[]; | ||
| gas: string; | ||
| payer: string | undefined; /** for Web3Gateway fee delegation */ | ||
| granter: string | undefined; | ||
| feePayer: string | undefined; | ||
| }; | ||
| //#endregion | ||
| //#region src/numbers.d.ts | ||
| declare const getBigNumberWithRounding: () => typeof BigNumber; | ||
| declare const getSignificantDecimalsFromNumber: (number: BigNumber | number | string) => number; | ||
| declare const getExactDecimalsFromNumber: (number: number | string) => number; | ||
| //#endregion | ||
| //#region src/constants.d.ts | ||
| declare const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000"; | ||
| declare const INJ_DENOM = "inj"; | ||
| declare const INJECTIVE_DENOM = "inj"; | ||
| declare const DEFAULT_FEE_DENOM = "inj"; | ||
| declare const DEFAULT_GAS_LIMIT = 400000; | ||
| declare const DEFAULT_IBC_GAS_LIMIT = 300000; | ||
| declare const DEFAULT_GAS_PRICE = 160000000; | ||
| declare const DEFAULT_EXCHANGE_LIMIT = 200000; | ||
| declare const DEFAULT_BRIDGE_FEE_DENOM = "inj"; | ||
| declare const DEFAULT_BRIDGE_FEE_PRICE = "160000000"; | ||
| declare const DEFAULT_BRIDGE_FEE_AMOUNT = "200000000000000"; | ||
| declare const DEFAULT_BLOCK_TIMEOUT_HEIGHT = 60; | ||
| declare const DEFAULT_BLOCK_TIME_IN_SECONDS = 0.7; | ||
| /** | ||
| * Default timeout for transaction block inclusion polling. | ||
| * | ||
| * Calculation: 120 blocks × 0.7 seconds/block = 84 seconds = 84,000ms | ||
| */ | ||
| declare const DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS: number; | ||
| declare const DEFAULT_TX_POLL_INTERVAL_MS = 500; | ||
| declare const DEFAULT_TX_POLL_CALL_TIMEOUT_MS = 3000; | ||
| declare const DEFAULT_TIMESTAMP_TIMEOUT_MS: number; | ||
| declare const getDefaultStdFee: () => { | ||
| amount: { | ||
| amount: string; | ||
| denom: string; | ||
| }[]; | ||
| gas: string; | ||
| payer: string; | ||
| granter: string; | ||
| feePayer: string; | ||
| }; | ||
| declare const DEFAULT_STD_FEE_BY_DENOM: (denom?: string) => { | ||
| amount: { | ||
| denom: string; | ||
| amount: string; | ||
| }[]; | ||
| gas: string; | ||
| }; | ||
| //#endregion | ||
| //#region src/formatters.d.ts | ||
| declare const formatWalletAddress: (address: AccountAddress, substrLength?: number) => string; | ||
| declare const toPascalCase: (str: string) => string; | ||
| declare const snakeToPascal: (str: string) => string; | ||
| declare const capitalize: (str: string) => string; | ||
| //#endregion | ||
| //#region src/enum.d.ts | ||
| declare const StatusType: { | ||
| readonly Idle: "idle"; | ||
| readonly Loading: "loading"; | ||
| readonly Completed: "completed"; | ||
| readonly Error: "error"; | ||
| readonly Confirmed: "confirmed"; | ||
| }; | ||
| type StatusType = (typeof StatusType)[keyof typeof StatusType]; | ||
| //#endregion | ||
| //#region src/classes/Status.d.ts | ||
| declare class Status { | ||
| status: string; | ||
| constructor(status?: StatusType); | ||
| get(): string; | ||
| set(status: StatusType): void; | ||
| is(status: StatusType): boolean; | ||
| isLoading(): boolean; | ||
| isNotLoading(): boolean; | ||
| isCompleted(): boolean; | ||
| isConfirmed(): boolean; | ||
| isIdle(): boolean; | ||
| isError(): boolean; | ||
| setLoading(): void; | ||
| setCompleted(): void; | ||
| setConfirmed(): void; | ||
| setError(): void; | ||
| setIdle(): void; | ||
| toggle(): void; | ||
| toString(): string; | ||
| valueOf(): string; | ||
| } | ||
| //#endregion | ||
| //#region src/classes/HttpClient.d.ts | ||
| declare class HttpClient { | ||
| private readonly client; | ||
| private config; | ||
| constructor(endpoint: string, options?: Record<string, any>); | ||
| setConfig(config: AxiosRequestConfig): HttpClient; | ||
| get<T, P>(endpoint: string, params?: T): Promise<P>; | ||
| post<T, P>(endpoint: string, data?: T): Promise<P>; | ||
| put<T, P>(endpoint: string, data?: T): Promise<P>; | ||
| delete<T, P>(endpoint: string, params?: T): Promise<P>; | ||
| } | ||
| //#endregion | ||
| //#region src/classes/LocalStorage.d.ts | ||
| declare class LocalStorage { | ||
| private storage; | ||
| constructor(namespace: string); | ||
| get(key: string, defaultValue?: unknown): unknown; | ||
| has(key: string): boolean; | ||
| set(key: string, value: unknown): void; | ||
| remove(key: string): void; | ||
| clear(): void; | ||
| } | ||
| //#endregion | ||
| //#region src/classes/BigNumberInBase.d.ts | ||
| /** | ||
| * @deprecated - use toHumanReadable instead | ||
| */ | ||
| declare class BigNumberInBase extends BigNumber { | ||
| static make(number: BigNumber.Value): BigNumberInBase; | ||
| minus(n: BigNumber.Value, base?: number): BigNumberInBase; | ||
| plus(n: BigNumber.Value, base?: number): BigNumberInBase; | ||
| dividedBy(n: BigNumber.Value, base?: number): BigNumberInBase; | ||
| div(n: BigNumber.Value, base?: number): BigNumberInBase; | ||
| multipliedBy(n: BigNumber.Value, base?: number): BigNumberInBase; | ||
| times(n: BigNumber.Value, base?: number): BigNumberInBase; | ||
| pow(n: BigNumber.Value, base?: number): BigNumberInBase; | ||
| toWei(decimals?: number): BigNumberInWei; | ||
| } | ||
| //#endregion | ||
| //#region src/classes/BigNumberInWei.d.ts | ||
| /** | ||
| * @deprecated - use toChainFormat instead | ||
| */ | ||
| declare class BigNumberInWei extends BigNumber { | ||
| static make(number: BigNumber.Value): BigNumberInWei; | ||
| minus(n: BigNumber.Value, base?: number): BigNumberInWei; | ||
| plus(n: BigNumber.Value, base?: number): BigNumberInWei; | ||
| dividedBy(n: BigNumber.Value, base?: number): BigNumberInWei; | ||
| div(n: BigNumber.Value, base?: number): BigNumberInWei; | ||
| multipliedBy(n: BigNumber.Value, base?: number): BigNumberInWei; | ||
| times(n: BigNumber.Value, base?: number): BigNumberInWei; | ||
| pow(n: BigNumber.Value, base?: number): BigNumberInWei; | ||
| toBase(decimals?: number): BigNumberInBase; | ||
| } | ||
| //#endregion | ||
| //#region src/classes/HttpRestClient.d.ts | ||
| /** | ||
| * @hidden | ||
| */ | ||
| declare class HttpRestClient { | ||
| protected client: HttpClient; | ||
| protected endpoint: string; | ||
| constructor(endpoint: string, options?: Record<string, any>); | ||
| setConfig(config: AxiosRequestConfig): HttpRestClient; | ||
| get<T>(endpoint: string, params?: Record<string, any>): Promise<T>; | ||
| retry<TResponse>(httpCall: Function, retries?: number, delay?: number): Promise<TResponse>; | ||
| post<T>(endpoint: string, params?: Record<string, any>): Promise<T>; | ||
| } | ||
| //#endregion | ||
| import { i as toHumanReadable, n as toBigNumber, r as toChainFormat, t as BigNumber } from "./BigNumber-B-r__Egf.cjs"; | ||
| import { n as BigNumberInBase, t as BigNumberInWei } from "./BigNumberInWei-BMQpZg3S.cjs"; | ||
| import { _ as INJ_DENOM, a as DEFAULT_BRIDGE_FEE_PRICE, c as DEFAULT_GAS_LIMIT, d as DEFAULT_STD_FEE_BY_DENOM, f as DEFAULT_TIMESTAMP_TIMEOUT_MS, g as INJECTIVE_DENOM, h as DEFAULT_TX_POLL_INTERVAL_MS, i as DEFAULT_BRIDGE_FEE_DENOM, l as DEFAULT_GAS_PRICE, m as DEFAULT_TX_POLL_CALL_TIMEOUT_MS, n as DEFAULT_BLOCK_TIME_IN_SECONDS, o as DEFAULT_EXCHANGE_LIMIT, p as DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS, r as DEFAULT_BRIDGE_FEE_AMOUNT, s as DEFAULT_FEE_DENOM, t as DEFAULT_BLOCK_TIMEOUT_HEIGHT, u as DEFAULT_IBC_GAS_LIMIT, v as ZERO_ADDRESS, y as getDefaultStdFee } from "./constants-BRub-WIk.cjs"; | ||
| import { i as toPascalCase, n as formatWalletAddress, r as snakeToPascal, t as capitalize } from "./formatters-lY6KvxzC.cjs"; | ||
| import { a as getStdFeeFromObject, c as splitArrayToChunks, i as getStdFeeForToken, l as splitArrayToChunksThrow, n as awaitForAll, o as getStdFeeFromString, r as getStdFee, s as sleep, t as awaitAll } from "./helpers-BmH3TkaY.cjs"; | ||
| import { n as HttpClient, t as HttpRestClient } from "./HttpRestClient-C0p7w6ht.cjs"; | ||
| import { a as past24Hours, c as tomorrow, i as getUTCDateFromTimestamp, n as getEndDateStringFromTimeInSeconds, o as pastDays, r as getSecondsInDay, s as todayInSeconds, t as convertTimestampToMilliseconds } from "./time-DQwWSv4e.cjs"; | ||
| import { n as getExactDecimalsFromNumber, r as getSignificantDecimalsFromNumber, t as getBigNumberWithRounding } from "./numbers-CVJM893V.cjs"; | ||
| import { n as StatusType, t as Status } from "./Status-lj0Wyw_3.cjs"; | ||
| import { t as LocalStorage } from "./LocalStorage-Dqm913-z.cjs"; | ||
| export { BigNumber, BigNumberInBase, BigNumberInWei, DEFAULT_BLOCK_TIMEOUT_HEIGHT, DEFAULT_BLOCK_TIME_IN_SECONDS, DEFAULT_BRIDGE_FEE_AMOUNT, DEFAULT_BRIDGE_FEE_DENOM, DEFAULT_BRIDGE_FEE_PRICE, DEFAULT_EXCHANGE_LIMIT, DEFAULT_FEE_DENOM, DEFAULT_GAS_LIMIT, DEFAULT_GAS_PRICE, DEFAULT_IBC_GAS_LIMIT, DEFAULT_STD_FEE_BY_DENOM, DEFAULT_TIMESTAMP_TIMEOUT_MS, DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS, DEFAULT_TX_POLL_CALL_TIMEOUT_MS, DEFAULT_TX_POLL_INTERVAL_MS, HttpClient, HttpRestClient, INJECTIVE_DENOM, INJ_DENOM, LocalStorage, Status, StatusType, ZERO_ADDRESS, awaitAll, awaitForAll, capitalize, convertTimestampToMilliseconds, formatWalletAddress, getBigNumberWithRounding, getDefaultStdFee, getEndDateStringFromTimeInSeconds, getExactDecimalsFromNumber, getSecondsInDay, getSignificantDecimalsFromNumber, getStdFee, getStdFeeForToken, getStdFeeFromObject, getStdFeeFromString, getUTCDateFromTimestamp, past24Hours, pastDays, sleep, snakeToPascal, splitArrayToChunks, splitArrayToChunksThrow, toBigNumber, toChainFormat, toHumanReadable, toPascalCase, todayInSeconds, tomorrow }; |
@@ -1,2 +0,4 @@ | ||
| const require_constants = require('../constants-BFjeP4ow.cjs'); | ||
| const require_chunk = require('../chunk-CbDLau6x.cjs'); | ||
| const require_BigNumber = require('../BigNumber-DbDA4_xA.cjs'); | ||
| const require_constants = require('../constants-BdaegCnI.cjs'); | ||
| let __injectivelabs_networks = require("@injectivelabs/networks"); | ||
@@ -133,3 +135,3 @@ let __injectivelabs_ts_types = require("@injectivelabs/ts-types"); | ||
| denom: "inj", | ||
| amount: new require_constants.BigNumber_default(gas.toString()).times(require_constants.DEFAULT_GAS_PRICE).toFixed() | ||
| amount: new require_BigNumber.BigNumber_default(gas.toString()).times(require_constants.DEFAULT_GAS_PRICE).toFixed() | ||
| }], | ||
@@ -136,0 +138,0 @@ gas: gas.toString(), |
+10
-269
@@ -1,270 +0,11 @@ | ||
| import BigNumber from "bignumber.js"; | ||
| import { AxiosRequestConfig } from "axios"; | ||
| import { AccountAddress } from "@injectivelabs/ts-types"; | ||
| //#region src/classes/BigNumber.d.ts | ||
| /** | ||
| * Converts a value to BigNumber if it isn't already | ||
| */ | ||
| declare const toBigNumber: (value: BigNumber | string | number) => BigNumber; | ||
| /** | ||
| * Converts a value to Wei (multiplies by 10^decimals) default to 18 decimals | ||
| */ | ||
| declare const toChainFormat: (value: BigNumber | string | number, decimals?: number) => BigNumber; | ||
| /** | ||
| * Converts a value from Wei to Base (divides by 10^decimals) default to 18 decimals | ||
| */ | ||
| declare const toHumanReadable: (value: BigNumber | string | number, decimals?: number) => BigNumber; | ||
| //#endregion | ||
| //#region src/time.d.ts | ||
| declare const getSecondsInDay: () => BigNumber; | ||
| declare const convertTimestampToMilliseconds: (timestamp: number | string) => number; | ||
| declare const getUTCDateFromTimestamp: (timestamp: number) => string; | ||
| declare const tomorrow: () => BigNumber; | ||
| declare const todayInSeconds: () => number; | ||
| declare const past24Hours: () => number; | ||
| declare const pastDays: (day?: number) => number; | ||
| declare const getEndDateStringFromTimeInSeconds: (timeInSeconds: BigNumber) => string; | ||
| //#endregion | ||
| //#region src/types.d.ts | ||
| type Awaited<T> = T extends null | undefined ? T : T extends object & { | ||
| then(onfulfilled: infer F, ...args: infer _): any; | ||
| } ? F extends ((value: infer V, ...args: infer _) => any) ? Awaited<V> : never : T; | ||
| //#endregion | ||
| //#region src/helpers.d.ts | ||
| declare const sleep: (timeout: number) => Promise<void>; | ||
| /** | ||
| * When we want to execute the promises in batch | ||
| */ | ||
| declare const awaitAll: <T, S>(array: Array<T>, callback: (item: T) => Promise<S>) => Promise<Awaited<S>[]>; | ||
| /** | ||
| * When we want to execute the promises one by one | ||
| * and not all in batch as with await Promise.all() | ||
| */ | ||
| declare const awaitForAll: <T, S>(array: Array<T>, callback: (item: T) => Promise<S>, onError?: (error: unknown, item: T, index: number) => void) => Promise<S[]>; | ||
| declare const splitArrayToChunksThrow: <T>({ | ||
| array, | ||
| filter, | ||
| chunkSize | ||
| }: { | ||
| array: Array<T>; | ||
| chunkSize: number; | ||
| filter?: (item: T) => boolean; | ||
| }) => T[][]; | ||
| declare const splitArrayToChunks: <T>({ | ||
| array, | ||
| filter, | ||
| chunkSize | ||
| }: { | ||
| array: Array<T>; | ||
| chunkSize: number; | ||
| filter?: (item: T) => boolean; | ||
| }) => T[][]; | ||
| declare const getStdFeeForToken: (token?: { | ||
| denom: string; | ||
| decimals: number; | ||
| }, gasPrice?: string, gasLimit?: string) => { | ||
| amount: { | ||
| denom: string; | ||
| amount: string; | ||
| }[]; | ||
| gas: string; | ||
| }; | ||
| declare const getStdFeeFromObject: (args?: { | ||
| gas?: string | number; | ||
| payer?: string; | ||
| granter?: string; | ||
| gasPrice?: string | number; | ||
| feePayer?: string; | ||
| }) => { | ||
| amount: { | ||
| denom: string; | ||
| amount: string; | ||
| }[]; | ||
| gas: string; | ||
| payer: string | undefined; /** for Web3Gateway fee delegation */ | ||
| granter: string | undefined; | ||
| feePayer: string | undefined; | ||
| }; | ||
| declare const getStdFeeFromString: (gasPrice: string) => { | ||
| amount: { | ||
| denom: string; | ||
| amount: string; | ||
| }[]; | ||
| gas: string; | ||
| payer: string | undefined; /** for Web3Gateway fee delegation */ | ||
| granter: string | undefined; | ||
| feePayer: string | undefined; | ||
| }; | ||
| declare const getStdFee: (args?: string | { | ||
| payer?: string; | ||
| granter?: string; | ||
| feePayer?: string; | ||
| gas?: string | number; | ||
| gasPrice?: string | number; | ||
| }) => { | ||
| amount: { | ||
| denom: string; | ||
| amount: string; | ||
| }[]; | ||
| gas: string; | ||
| payer: string | undefined; /** for Web3Gateway fee delegation */ | ||
| granter: string | undefined; | ||
| feePayer: string | undefined; | ||
| }; | ||
| //#endregion | ||
| //#region src/numbers.d.ts | ||
| declare const getBigNumberWithRounding: () => typeof BigNumber; | ||
| declare const getSignificantDecimalsFromNumber: (number: BigNumber | number | string) => number; | ||
| declare const getExactDecimalsFromNumber: (number: number | string) => number; | ||
| //#endregion | ||
| //#region src/constants.d.ts | ||
| declare const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000"; | ||
| declare const INJ_DENOM = "inj"; | ||
| declare const INJECTIVE_DENOM = "inj"; | ||
| declare const DEFAULT_FEE_DENOM = "inj"; | ||
| declare const DEFAULT_GAS_LIMIT = 400000; | ||
| declare const DEFAULT_IBC_GAS_LIMIT = 300000; | ||
| declare const DEFAULT_GAS_PRICE = 160000000; | ||
| declare const DEFAULT_EXCHANGE_LIMIT = 200000; | ||
| declare const DEFAULT_BRIDGE_FEE_DENOM = "inj"; | ||
| declare const DEFAULT_BRIDGE_FEE_PRICE = "160000000"; | ||
| declare const DEFAULT_BRIDGE_FEE_AMOUNT = "200000000000000"; | ||
| declare const DEFAULT_BLOCK_TIMEOUT_HEIGHT = 60; | ||
| declare const DEFAULT_BLOCK_TIME_IN_SECONDS = 0.7; | ||
| /** | ||
| * Default timeout for transaction block inclusion polling. | ||
| * | ||
| * Calculation: 120 blocks × 0.7 seconds/block = 84 seconds = 84,000ms | ||
| */ | ||
| declare const DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS: number; | ||
| declare const DEFAULT_TX_POLL_INTERVAL_MS = 500; | ||
| declare const DEFAULT_TX_POLL_CALL_TIMEOUT_MS = 3000; | ||
| declare const DEFAULT_TIMESTAMP_TIMEOUT_MS: number; | ||
| declare const getDefaultStdFee: () => { | ||
| amount: { | ||
| amount: string; | ||
| denom: string; | ||
| }[]; | ||
| gas: string; | ||
| payer: string; | ||
| granter: string; | ||
| feePayer: string; | ||
| }; | ||
| declare const DEFAULT_STD_FEE_BY_DENOM: (denom?: string) => { | ||
| amount: { | ||
| denom: string; | ||
| amount: string; | ||
| }[]; | ||
| gas: string; | ||
| }; | ||
| //#endregion | ||
| //#region src/formatters.d.ts | ||
| declare const formatWalletAddress: (address: AccountAddress, substrLength?: number) => string; | ||
| declare const toPascalCase: (str: string) => string; | ||
| declare const snakeToPascal: (str: string) => string; | ||
| declare const capitalize: (str: string) => string; | ||
| //#endregion | ||
| //#region src/enum.d.ts | ||
| declare const StatusType: { | ||
| readonly Idle: "idle"; | ||
| readonly Loading: "loading"; | ||
| readonly Completed: "completed"; | ||
| readonly Error: "error"; | ||
| readonly Confirmed: "confirmed"; | ||
| }; | ||
| type StatusType = (typeof StatusType)[keyof typeof StatusType]; | ||
| //#endregion | ||
| //#region src/classes/Status.d.ts | ||
| declare class Status { | ||
| status: string; | ||
| constructor(status?: StatusType); | ||
| get(): string; | ||
| set(status: StatusType): void; | ||
| is(status: StatusType): boolean; | ||
| isLoading(): boolean; | ||
| isNotLoading(): boolean; | ||
| isCompleted(): boolean; | ||
| isConfirmed(): boolean; | ||
| isIdle(): boolean; | ||
| isError(): boolean; | ||
| setLoading(): void; | ||
| setCompleted(): void; | ||
| setConfirmed(): void; | ||
| setError(): void; | ||
| setIdle(): void; | ||
| toggle(): void; | ||
| toString(): string; | ||
| valueOf(): string; | ||
| } | ||
| //#endregion | ||
| //#region src/classes/HttpClient.d.ts | ||
| declare class HttpClient { | ||
| private readonly client; | ||
| private config; | ||
| constructor(endpoint: string, options?: Record<string, any>); | ||
| setConfig(config: AxiosRequestConfig): HttpClient; | ||
| get<T, P>(endpoint: string, params?: T): Promise<P>; | ||
| post<T, P>(endpoint: string, data?: T): Promise<P>; | ||
| put<T, P>(endpoint: string, data?: T): Promise<P>; | ||
| delete<T, P>(endpoint: string, params?: T): Promise<P>; | ||
| } | ||
| //#endregion | ||
| //#region src/classes/LocalStorage.d.ts | ||
| declare class LocalStorage { | ||
| private storage; | ||
| constructor(namespace: string); | ||
| get(key: string, defaultValue?: unknown): unknown; | ||
| has(key: string): boolean; | ||
| set(key: string, value: unknown): void; | ||
| remove(key: string): void; | ||
| clear(): void; | ||
| } | ||
| //#endregion | ||
| //#region src/classes/BigNumberInBase.d.ts | ||
| /** | ||
| * @deprecated - use toHumanReadable instead | ||
| */ | ||
| declare class BigNumberInBase extends BigNumber { | ||
| static make(number: BigNumber.Value): BigNumberInBase; | ||
| minus(n: BigNumber.Value, base?: number): BigNumberInBase; | ||
| plus(n: BigNumber.Value, base?: number): BigNumberInBase; | ||
| dividedBy(n: BigNumber.Value, base?: number): BigNumberInBase; | ||
| div(n: BigNumber.Value, base?: number): BigNumberInBase; | ||
| multipliedBy(n: BigNumber.Value, base?: number): BigNumberInBase; | ||
| times(n: BigNumber.Value, base?: number): BigNumberInBase; | ||
| pow(n: BigNumber.Value, base?: number): BigNumberInBase; | ||
| toWei(decimals?: number): BigNumberInWei; | ||
| } | ||
| //#endregion | ||
| //#region src/classes/BigNumberInWei.d.ts | ||
| /** | ||
| * @deprecated - use toChainFormat instead | ||
| */ | ||
| declare class BigNumberInWei extends BigNumber { | ||
| static make(number: BigNumber.Value): BigNumberInWei; | ||
| minus(n: BigNumber.Value, base?: number): BigNumberInWei; | ||
| plus(n: BigNumber.Value, base?: number): BigNumberInWei; | ||
| dividedBy(n: BigNumber.Value, base?: number): BigNumberInWei; | ||
| div(n: BigNumber.Value, base?: number): BigNumberInWei; | ||
| multipliedBy(n: BigNumber.Value, base?: number): BigNumberInWei; | ||
| times(n: BigNumber.Value, base?: number): BigNumberInWei; | ||
| pow(n: BigNumber.Value, base?: number): BigNumberInWei; | ||
| toBase(decimals?: number): BigNumberInBase; | ||
| } | ||
| //#endregion | ||
| //#region src/classes/HttpRestClient.d.ts | ||
| /** | ||
| * @hidden | ||
| */ | ||
| declare class HttpRestClient { | ||
| protected client: HttpClient; | ||
| protected endpoint: string; | ||
| constructor(endpoint: string, options?: Record<string, any>); | ||
| setConfig(config: AxiosRequestConfig): HttpRestClient; | ||
| get<T>(endpoint: string, params?: Record<string, any>): Promise<T>; | ||
| retry<TResponse>(httpCall: Function, retries?: number, delay?: number): Promise<TResponse>; | ||
| post<T>(endpoint: string, params?: Record<string, any>): Promise<T>; | ||
| } | ||
| //#endregion | ||
| import { i as toHumanReadable, n as toBigNumber, r as toChainFormat, t as BigNumber } from "./BigNumber-jKUujKpO.js"; | ||
| import { n as BigNumberInBase, t as BigNumberInWei } from "./BigNumberInWei-JtQuFET_.js"; | ||
| import { _ as INJ_DENOM, a as DEFAULT_BRIDGE_FEE_PRICE, c as DEFAULT_GAS_LIMIT, d as DEFAULT_STD_FEE_BY_DENOM, f as DEFAULT_TIMESTAMP_TIMEOUT_MS, g as INJECTIVE_DENOM, h as DEFAULT_TX_POLL_INTERVAL_MS, i as DEFAULT_BRIDGE_FEE_DENOM, l as DEFAULT_GAS_PRICE, m as DEFAULT_TX_POLL_CALL_TIMEOUT_MS, n as DEFAULT_BLOCK_TIME_IN_SECONDS, o as DEFAULT_EXCHANGE_LIMIT, p as DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS, r as DEFAULT_BRIDGE_FEE_AMOUNT, s as DEFAULT_FEE_DENOM, t as DEFAULT_BLOCK_TIMEOUT_HEIGHT, u as DEFAULT_IBC_GAS_LIMIT, v as ZERO_ADDRESS, y as getDefaultStdFee } from "./constants-BPYHMKzA.js"; | ||
| import { i as toPascalCase, n as formatWalletAddress, r as snakeToPascal, t as capitalize } from "./formatters-v2reo54H.js"; | ||
| import { a as getStdFeeFromObject, c as splitArrayToChunks, i as getStdFeeForToken, l as splitArrayToChunksThrow, n as awaitForAll, o as getStdFeeFromString, r as getStdFee, s as sleep, t as awaitAll } from "./helpers-BZ1LFB-6.js"; | ||
| import { n as HttpClient, t as HttpRestClient } from "./HttpRestClient-B-UvB9KB.js"; | ||
| import { a as past24Hours, c as tomorrow, i as getUTCDateFromTimestamp, n as getEndDateStringFromTimeInSeconds, o as pastDays, r as getSecondsInDay, s as todayInSeconds, t as convertTimestampToMilliseconds } from "./time-DJirA2PE.js"; | ||
| import { n as getExactDecimalsFromNumber, r as getSignificantDecimalsFromNumber, t as getBigNumberWithRounding } from "./numbers-Bnbd75cb.js"; | ||
| import { n as StatusType, t as Status } from "./Status-C6A6ZtpL.js"; | ||
| import { t as LocalStorage } from "./LocalStorage-CyTj3H1T.js"; | ||
| export { BigNumber, BigNumberInBase, BigNumberInWei, DEFAULT_BLOCK_TIMEOUT_HEIGHT, DEFAULT_BLOCK_TIME_IN_SECONDS, DEFAULT_BRIDGE_FEE_AMOUNT, DEFAULT_BRIDGE_FEE_DENOM, DEFAULT_BRIDGE_FEE_PRICE, DEFAULT_EXCHANGE_LIMIT, DEFAULT_FEE_DENOM, DEFAULT_GAS_LIMIT, DEFAULT_GAS_PRICE, DEFAULT_IBC_GAS_LIMIT, DEFAULT_STD_FEE_BY_DENOM, DEFAULT_TIMESTAMP_TIMEOUT_MS, DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS, DEFAULT_TX_POLL_CALL_TIMEOUT_MS, DEFAULT_TX_POLL_INTERVAL_MS, HttpClient, HttpRestClient, INJECTIVE_DENOM, INJ_DENOM, LocalStorage, Status, StatusType, ZERO_ADDRESS, awaitAll, awaitForAll, capitalize, convertTimestampToMilliseconds, formatWalletAddress, getBigNumberWithRounding, getDefaultStdFee, getEndDateStringFromTimeInSeconds, getExactDecimalsFromNumber, getSecondsInDay, getSignificantDecimalsFromNumber, getStdFee, getStdFeeForToken, getStdFeeFromObject, getStdFeeFromString, getUTCDateFromTimestamp, past24Hours, pastDays, sleep, snakeToPascal, splitArrayToChunks, splitArrayToChunksThrow, toBigNumber, toChainFormat, toHumanReadable, toPascalCase, todayInSeconds, tomorrow }; |
+11
-474
@@ -1,476 +0,13 @@ | ||
| import { C as toHumanReadable, S as toChainFormat, _ as INJ_DENOM, a as DEFAULT_BRIDGE_FEE_PRICE, b as BigNumber_default, c as DEFAULT_GAS_LIMIT, d as DEFAULT_STD_FEE_BY_DENOM, f as DEFAULT_TIMESTAMP_TIMEOUT_MS, g as INJECTIVE_DENOM, h as DEFAULT_TX_POLL_INTERVAL_MS, i as DEFAULT_BRIDGE_FEE_DENOM, l as DEFAULT_GAS_PRICE, m as DEFAULT_TX_POLL_CALL_TIMEOUT_MS, n as DEFAULT_BLOCK_TIME_IN_SECONDS, o as DEFAULT_EXCHANGE_LIMIT, p as DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS, r as DEFAULT_BRIDGE_FEE_AMOUNT, s as DEFAULT_FEE_DENOM, t as DEFAULT_BLOCK_TIMEOUT_HEIGHT, u as DEFAULT_IBC_GAS_LIMIT, v as ZERO_ADDRESS, x as toBigNumber, y as getDefaultStdFee } from "./constants-BY74CT5-.js"; | ||
| import axios from "axios"; | ||
| import store from "store2"; | ||
| import { StatusCodes } from "http-status-codes"; | ||
| import { HttpRequestException, HttpRequestMethod, UnspecifiedErrorCode } from "@injectivelabs/exceptions"; | ||
| import "./defineProperty-Zp25b8Cm.js"; | ||
| import { n as HttpClient, t as HttpRestClient } from "./HttpRestClient-CsKkn8lo.js"; | ||
| import { i as toHumanReadable, n as toBigNumber, r as toChainFormat, t as BigNumber_default } from "./BigNumber-DUr2WQBK.js"; | ||
| import { a as past24Hours, c as tomorrow, i as getUTCDateFromTimestamp, n as getEndDateStringFromTimeInSeconds, o as pastDays, r as getSecondsInDay, s as todayInSeconds, t as convertTimestampToMilliseconds } from "./time-BBEhFnvo.js"; | ||
| import { _ as INJ_DENOM, a as DEFAULT_BRIDGE_FEE_PRICE, c as DEFAULT_GAS_LIMIT, d as DEFAULT_STD_FEE_BY_DENOM, f as DEFAULT_TIMESTAMP_TIMEOUT_MS, g as INJECTIVE_DENOM, h as DEFAULT_TX_POLL_INTERVAL_MS, i as DEFAULT_BRIDGE_FEE_DENOM, l as DEFAULT_GAS_PRICE, m as DEFAULT_TX_POLL_CALL_TIMEOUT_MS, n as DEFAULT_BLOCK_TIME_IN_SECONDS, o as DEFAULT_EXCHANGE_LIMIT, p as DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS, r as DEFAULT_BRIDGE_FEE_AMOUNT, s as DEFAULT_FEE_DENOM, t as DEFAULT_BLOCK_TIMEOUT_HEIGHT, u as DEFAULT_IBC_GAS_LIMIT, v as ZERO_ADDRESS, y as getDefaultStdFee } from "./constants-0w1sGXWU.js"; | ||
| import { a as getStdFeeFromObject, c as splitArrayToChunks, i as getStdFeeForToken, l as splitArrayToChunksThrow, n as awaitForAll, o as getStdFeeFromString, r as getStdFee, s as sleep, t as awaitAll } from "./helpers-BsGkkq54.js"; | ||
| import { n as getExactDecimalsFromNumber, r as getSignificantDecimalsFromNumber, t as getBigNumberWithRounding } from "./numbers-Dh5x3_mA.js"; | ||
| import { i as toPascalCase, n as formatWalletAddress, r as snakeToPascal, t as capitalize } from "./formatters-QUaa2UZY.js"; | ||
| import { n as StatusType, t as Status } from "./Status-eHtiFREA.js"; | ||
| import { t as LocalStorage } from "./LocalStorage-Cpe5wG8z.js"; | ||
| import { n as BigNumberInWei, t as BigNumberInBase } from "./BigNumberInBase-Dcx5wyxY.js"; | ||
| //#region src/time.ts | ||
| const getSecondsInDay = () => new BigNumber_default(3600 * 24); | ||
| const convertTimestampToMilliseconds = (timestamp) => { | ||
| const timestampInBigNumber = new BigNumber_default(timestamp); | ||
| if (timestamp.toString().length > 13) return timestampInBigNumber.precision(13, BigNumber_default.ROUND_HALF_UP).toNumber(); | ||
| if (timestamp.toString().length < 13) { | ||
| const trailingZeros = 13 - timestamp.toString().length; | ||
| return timestampInBigNumber.times(10 ** trailingZeros).toNumber(); | ||
| } | ||
| return timestampInBigNumber.toNumber(); | ||
| }; | ||
| const getUTCDateFromTimestamp = (timestamp) => { | ||
| const date = new Date(convertTimestampToMilliseconds(timestamp)); | ||
| return `${date.getUTCDate()}-${date.getUTCMonth() + 1}-${date.getUTCFullYear()}`; | ||
| }; | ||
| const tomorrow = () => new BigNumber_default(Math.floor((/* @__PURE__ */ new Date()).valueOf() / 1e3) + 3600 * 24); | ||
| const todayInSeconds = () => Math.floor(Date.now() / 1e3); | ||
| const past24Hours = () => new BigNumber_default(todayInSeconds()).minus(getSecondsInDay()).toNumber(); | ||
| const pastDays = (day = 1) => new BigNumber_default(todayInSeconds()).minus(getSecondsInDay().times(day)).toNumber(); | ||
| const getEndDateStringFromTimeInSeconds = (timeInSeconds) => { | ||
| return (/* @__PURE__ */ new Date(timeInSeconds.toNumber() * 1e3)).toLocaleString("en-us"); | ||
| }; | ||
| //#endregion | ||
| //#region src/helpers.ts | ||
| const sleep = (timeout) => new Promise((resolve) => setTimeout(resolve, timeout)); | ||
| /** | ||
| * When we want to execute the promises in batch | ||
| */ | ||
| const awaitAll = async (array, callback) => await Promise.all(array.map(async (item) => await callback(item))); | ||
| /** | ||
| * When we want to execute the promises one by one | ||
| * and not all in batch as with await Promise.all() | ||
| */ | ||
| const awaitForAll = async (array, callback, onError) => { | ||
| const result = []; | ||
| for (let i = 0; i < array.length; i += 1) try { | ||
| result.push(await callback(array[i])); | ||
| } catch (e) { | ||
| if (onError) onError(e, array[i], i); | ||
| } | ||
| return result; | ||
| }; | ||
| const splitArrayToChunksThrow = ({ array, filter, chunkSize }) => { | ||
| const chunks = []; | ||
| const chunkSizeInNumber = Number(chunkSize); | ||
| if (isNaN(chunkSizeInNumber)) throw new Error("Invalid chunk size, must be a valid number"); | ||
| for (let i = 0; i < array.length; i += chunkSizeInNumber) { | ||
| const chunk = array.slice(i, i + chunkSizeInNumber); | ||
| if (filter) chunks.push(chunk.filter(filter)); | ||
| else chunks.push(chunk); | ||
| } | ||
| return chunks; | ||
| }; | ||
| const splitArrayToChunks = ({ array, filter, chunkSize }) => { | ||
| try { | ||
| return splitArrayToChunksThrow({ | ||
| array, | ||
| chunkSize, | ||
| filter | ||
| }); | ||
| } catch (_unused) { | ||
| return [array]; | ||
| } | ||
| }; | ||
| const getStdFeeForToken = (token = { | ||
| denom: "inj", | ||
| decimals: 18 | ||
| }, gasPrice, gasLimit) => { | ||
| const gasPriceScaled = toChainFormat(gasPrice || toHumanReadable(DEFAULT_GAS_PRICE, 18), token.decimals).toFixed(0); | ||
| const gasNormalized = new BigNumber_default(gasLimit || DEFAULT_GAS_LIMIT).toFixed(0); | ||
| return { | ||
| amount: [{ | ||
| denom: token.denom, | ||
| amount: new BigNumber_default(gasPriceScaled).times(gasNormalized).toFixed() | ||
| }], | ||
| gas: (gasLimit || DEFAULT_GAS_LIMIT).toString() | ||
| }; | ||
| }; | ||
| const getStdFeeFromObject = (args) => { | ||
| if (!args) return getDefaultStdFee(); | ||
| const { payer, granter, feePayer, gasPrice = DEFAULT_GAS_PRICE, gas = DEFAULT_GAS_LIMIT.toString() } = args; | ||
| const gasNormalized = toBigNumber(gas).toFixed(0); | ||
| const gasPriceNormalized = toBigNumber(gasPrice).toFixed(0); | ||
| return { | ||
| amount: [{ | ||
| denom: "inj", | ||
| amount: toBigNumber(gasNormalized).times(gasPriceNormalized).toFixed() | ||
| }], | ||
| gas: toBigNumber(gasNormalized).toFixed(), | ||
| payer, | ||
| granter, | ||
| feePayer | ||
| }; | ||
| }; | ||
| const getStdFeeFromString = (gasPrice) => { | ||
| const matchResult = gasPrice.match(/^([0-9.]+)([a-zA-Z][a-zA-Z0-9/:._-]*)$/); | ||
| if (!matchResult) throw new Error("Invalid gas price string"); | ||
| const [_, amount] = matchResult; | ||
| return getStdFeeFromObject({ | ||
| gas: toChainFormat(amount, 18).dividedBy(DEFAULT_GAS_PRICE).toFixed(0), | ||
| gasPrice: DEFAULT_GAS_PRICE | ||
| }); | ||
| }; | ||
| const getStdFee = (args) => { | ||
| if (!args) return getDefaultStdFee(); | ||
| if (typeof args === "string") return getStdFeeFromString(args); | ||
| return getStdFeeFromObject({ ...args }); | ||
| }; | ||
| //#endregion | ||
| //#region src/numbers.ts | ||
| const getBigNumberWithRounding = () => BigNumber_default.clone({ ROUNDING_MODE: BigNumber_default.ROUND_DOWN }); | ||
| const getSignificantDecimalsFromNumber = (number) => { | ||
| const $BigNumber = getBigNumberWithRounding(); | ||
| if (Math.floor(new $BigNumber(number).toNumber()) === number) return 0; | ||
| const [, decimals] = new $BigNumber(number).toFixed().split("."); | ||
| /** Number doesn't have decimals */ | ||
| if (!decimals) return 0; | ||
| return decimals.length; | ||
| }; | ||
| const getExactDecimalsFromNumber = (number) => { | ||
| if (!number.toString().includes(".")) return 0; | ||
| if (Number(number) % 1 === 0) return 0; | ||
| const [, decimals] = number.toString().split("."); | ||
| if (!decimals) return 0; | ||
| return decimals.length; | ||
| }; | ||
| //#endregion | ||
| //#region src/formatters.ts | ||
| const formatWalletAddress = (address, substrLength = 6) => { | ||
| if (address.length <= 10) return address; | ||
| return `${address.slice(0, substrLength)}...${address.slice(address.length - substrLength, address.length)}`; | ||
| }; | ||
| const toPascalCase = (str) => { | ||
| return `${str}`.toLowerCase().replace(new RegExp(/[-_]+/, "g"), " ").replace(new RegExp(/[^\w\s]/, "g"), "").replace(new RegExp(/\s+(.)(\w*)/, "g"), (_$1, $2, $3) => `${$2.toUpperCase() + $3}`).replace(/* @__PURE__ */ new RegExp(/\w/), (s) => s.toUpperCase()); | ||
| }; | ||
| const snakeToPascal = (str) => { | ||
| return str.split("/").map((snake) => snake.split("_").map((substr) => substr.charAt(0).toUpperCase() + substr.slice(1)).join("")).join("/"); | ||
| }; | ||
| const capitalize = (str) => str[0].toUpperCase() + str.slice(1); | ||
| //#endregion | ||
| //#region src/enum.ts | ||
| const StatusType = { | ||
| Idle: "idle", | ||
| Loading: "loading", | ||
| Completed: "completed", | ||
| Error: "error", | ||
| Confirmed: "confirmed" | ||
| }; | ||
| //#endregion | ||
| //#region \0@oxc-project+runtime@0.99.0/helpers/typeof.js | ||
| function _typeof(o) { | ||
| "@babel/helpers - typeof"; | ||
| return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) { | ||
| return typeof o$1; | ||
| } : function(o$1) { | ||
| return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1; | ||
| }, _typeof(o); | ||
| } | ||
| //#endregion | ||
| //#region \0@oxc-project+runtime@0.99.0/helpers/toPrimitive.js | ||
| function toPrimitive(t, r) { | ||
| if ("object" != _typeof(t) || !t) return t; | ||
| var e = t[Symbol.toPrimitive]; | ||
| if (void 0 !== e) { | ||
| var i = e.call(t, r || "default"); | ||
| if ("object" != _typeof(i)) return i; | ||
| throw new TypeError("@@toPrimitive must return a primitive value."); | ||
| } | ||
| return ("string" === r ? String : Number)(t); | ||
| } | ||
| //#endregion | ||
| //#region \0@oxc-project+runtime@0.99.0/helpers/toPropertyKey.js | ||
| function toPropertyKey(t) { | ||
| var i = toPrimitive(t, "string"); | ||
| return "symbol" == _typeof(i) ? i : i + ""; | ||
| } | ||
| //#endregion | ||
| //#region \0@oxc-project+runtime@0.99.0/helpers/defineProperty.js | ||
| function _defineProperty(e, r, t) { | ||
| return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, { | ||
| value: t, | ||
| enumerable: !0, | ||
| configurable: !0, | ||
| writable: !0 | ||
| }) : e[r] = t, e; | ||
| } | ||
| //#endregion | ||
| //#region src/classes/Status.ts | ||
| var Status = class { | ||
| constructor(status = StatusType.Idle) { | ||
| _defineProperty(this, "status", void 0); | ||
| this.status = status; | ||
| } | ||
| get() { | ||
| return this.status; | ||
| } | ||
| set(status) { | ||
| this.status = status; | ||
| } | ||
| is(status) { | ||
| return this.status === status; | ||
| } | ||
| isLoading() { | ||
| return this.is(StatusType.Loading); | ||
| } | ||
| isNotLoading() { | ||
| return !this.is(StatusType.Loading); | ||
| } | ||
| isCompleted() { | ||
| return this.is(StatusType.Completed); | ||
| } | ||
| isConfirmed() { | ||
| return this.is(StatusType.Confirmed); | ||
| } | ||
| isIdle() { | ||
| return this.is(StatusType.Idle); | ||
| } | ||
| isError() { | ||
| return this.is(StatusType.Error); | ||
| } | ||
| setLoading() { | ||
| this.set(StatusType.Loading); | ||
| } | ||
| setCompleted() { | ||
| this.set(StatusType.Completed); | ||
| } | ||
| setConfirmed() { | ||
| this.set(StatusType.Confirmed); | ||
| } | ||
| setError() { | ||
| this.set(StatusType.Error); | ||
| } | ||
| setIdle() { | ||
| this.set(StatusType.Idle); | ||
| } | ||
| toggle() { | ||
| this.set(this.status === StatusType.Idle ? StatusType.Loading : StatusType.Idle); | ||
| } | ||
| toString() { | ||
| return this.get(); | ||
| } | ||
| valueOf() { | ||
| return this.get(); | ||
| } | ||
| }; | ||
| //#endregion | ||
| //#region src/classes/HttpClient.ts | ||
| var HttpClient = class { | ||
| constructor(endpoint, options = { headers: { "Content-Type": "application/json" } }) { | ||
| _defineProperty(this, "client", void 0); | ||
| _defineProperty(this, "config", {}); | ||
| this.client = axios.create({ | ||
| baseURL: endpoint, | ||
| timeout: 15e3, | ||
| ...options | ||
| }); | ||
| this.config = {}; | ||
| } | ||
| setConfig(config) { | ||
| this.config = config; | ||
| return this; | ||
| } | ||
| get(endpoint, params = {}) { | ||
| return this.client.get(endpoint, { | ||
| params, | ||
| ...this.config | ||
| }); | ||
| } | ||
| post(endpoint, data = {}) { | ||
| return this.client.post(endpoint, data, this.config); | ||
| } | ||
| put(endpoint, data = {}) { | ||
| return this.client.put(endpoint, data, this.config); | ||
| } | ||
| delete(endpoint, params = {}) { | ||
| return this.client.delete(endpoint, { | ||
| params, | ||
| ...this.config | ||
| }); | ||
| } | ||
| }; | ||
| //#endregion | ||
| //#region src/classes/LocalStorage.ts | ||
| var LocalStorage = class { | ||
| constructor(namespace) { | ||
| _defineProperty(this, "storage", void 0); | ||
| this.storage = store.namespace(namespace); | ||
| } | ||
| get(key, defaultValue = {}) { | ||
| return this.storage.get(key) || defaultValue; | ||
| } | ||
| has(key) { | ||
| return this.storage.has(key); | ||
| } | ||
| set(key, value) { | ||
| this.storage.set(key, value); | ||
| } | ||
| remove(key) { | ||
| this.storage.remove(key); | ||
| } | ||
| clear() { | ||
| this.storage.clear(); | ||
| } | ||
| }; | ||
| //#endregion | ||
| //#region src/classes/BigNumberInWei.ts | ||
| /** | ||
| * @deprecated - use toChainFormat instead | ||
| */ | ||
| var BigNumberInWei = class BigNumberInWei extends BigNumber_default { | ||
| static make(number) { | ||
| return new BigNumberInWei(number); | ||
| } | ||
| minus(n, base) { | ||
| return new BigNumberInWei(super.minus(n, base)); | ||
| } | ||
| plus(n, base) { | ||
| return new BigNumberInWei(super.plus(n, base)); | ||
| } | ||
| dividedBy(n, base) { | ||
| return new BigNumberInWei(super.dividedBy(n, base)); | ||
| } | ||
| div(n, base) { | ||
| return new BigNumberInWei(super.div(n, base)); | ||
| } | ||
| multipliedBy(n, base) { | ||
| return new BigNumberInWei(super.multipliedBy(n, base)); | ||
| } | ||
| times(n, base) { | ||
| return new BigNumberInWei(super.times(n, base)); | ||
| } | ||
| pow(n, base) { | ||
| return new BigNumberInWei(super.pow(n, base)); | ||
| } | ||
| toBase(decimals = 18) { | ||
| return new BigNumber_default(this).dividedBy(new BigNumber_default(10).pow(decimals)); | ||
| } | ||
| }; | ||
| //#endregion | ||
| //#region src/classes/HttpRestClient.ts | ||
| const getErrorMessage = (error, endpoint) => { | ||
| if (!error.response) return `The request to ${endpoint} has failed.`; | ||
| return error.response.data ? error.response.data.message || error.response.data.statusMessage || error.response.data : error.response.statusText; | ||
| }; | ||
| /** | ||
| * @hidden | ||
| */ | ||
| var HttpRestClient = class { | ||
| constructor(endpoint, options = {}) { | ||
| _defineProperty(this, "client", void 0); | ||
| _defineProperty(this, "endpoint", void 0); | ||
| this.client = new HttpClient(endpoint, options); | ||
| this.endpoint = endpoint; | ||
| } | ||
| setConfig(config) { | ||
| this.client.setConfig(config); | ||
| return this; | ||
| } | ||
| async get(endpoint, params = {}) { | ||
| try { | ||
| return await this.client.get(endpoint, params); | ||
| } catch (e) { | ||
| const error = e; | ||
| if (axios.isAxiosError(error)) { | ||
| if (error.code === "ECONNABORTED") throw new HttpRequestException(new Error(error.message), { | ||
| code: StatusCodes.REQUEST_TOO_LONG, | ||
| context: endpoint | ||
| }); | ||
| const message = getErrorMessage(error, endpoint); | ||
| throw new HttpRequestException(new Error(message), { | ||
| context: endpoint, | ||
| code: error.response ? error.response.status : StatusCodes.BAD_REQUEST | ||
| }); | ||
| } | ||
| throw new HttpRequestException(new Error(error.message), { | ||
| code: UnspecifiedErrorCode, | ||
| context: endpoint | ||
| }); | ||
| } | ||
| } | ||
| async retry(httpCall, retries = 3, delay = 1e3) { | ||
| const retryHttpCall = async (attempt = 1) => { | ||
| try { | ||
| return await httpCall(); | ||
| } catch (e) { | ||
| if (e instanceof HttpRequestException) { | ||
| if (e.code === StatusCodes.REQUEST_TOO_LONG) throw e; | ||
| } | ||
| if (attempt >= retries) throw e; | ||
| return new Promise((resolve) => setTimeout(() => resolve(retryHttpCall(attempt + 1)), delay * attempt)); | ||
| } | ||
| }; | ||
| return retryHttpCall(); | ||
| } | ||
| async post(endpoint, params = {}) { | ||
| try { | ||
| return await this.client.post(endpoint, params); | ||
| } catch (e) { | ||
| const error = e; | ||
| if (axios.isAxiosError(error)) { | ||
| if (error.code === "ECONNABORTED") throw new HttpRequestException(new Error(error.message), { | ||
| code: StatusCodes.REQUEST_TOO_LONG, | ||
| method: HttpRequestMethod.Post | ||
| }); | ||
| const message = getErrorMessage(error, endpoint); | ||
| throw new HttpRequestException(new Error(message), { | ||
| code: error.response ? error.response.status : StatusCodes.BAD_REQUEST, | ||
| context: endpoint, | ||
| contextModule: HttpRequestMethod.Post | ||
| }); | ||
| } | ||
| throw new HttpRequestException(new Error(error.message), { | ||
| code: UnspecifiedErrorCode, | ||
| context: endpoint, | ||
| contextModule: HttpRequestMethod.Post | ||
| }); | ||
| } | ||
| } | ||
| }; | ||
| //#endregion | ||
| //#region src/classes/BigNumberInBase.ts | ||
| /** | ||
| * @deprecated - use toHumanReadable instead | ||
| */ | ||
| var BigNumberInBase = class BigNumberInBase extends BigNumber_default { | ||
| static make(number) { | ||
| return new BigNumberInBase(number); | ||
| } | ||
| minus(n, base) { | ||
| return new BigNumberInBase(super.minus(n, base)); | ||
| } | ||
| plus(n, base) { | ||
| return new BigNumberInBase(super.plus(n, base)); | ||
| } | ||
| dividedBy(n, base) { | ||
| return new BigNumberInBase(super.dividedBy(n, base)); | ||
| } | ||
| div(n, base) { | ||
| return new BigNumberInBase(super.div(n, base)); | ||
| } | ||
| multipliedBy(n, base) { | ||
| return new BigNumberInBase(super.multipliedBy(n, base)); | ||
| } | ||
| times(n, base) { | ||
| return new BigNumberInBase(super.times(n, base)); | ||
| } | ||
| pow(n, base) { | ||
| return new BigNumberInBase(super.pow(n, base)); | ||
| } | ||
| toWei(decimals = 18) { | ||
| return new BigNumber_default(this).multipliedBy(new BigNumber_default(10).pow(decimals)); | ||
| } | ||
| }; | ||
| //#endregion | ||
| export { BigNumber_default as BigNumber, BigNumberInBase, BigNumberInWei, DEFAULT_BLOCK_TIMEOUT_HEIGHT, DEFAULT_BLOCK_TIME_IN_SECONDS, DEFAULT_BRIDGE_FEE_AMOUNT, DEFAULT_BRIDGE_FEE_DENOM, DEFAULT_BRIDGE_FEE_PRICE, DEFAULT_EXCHANGE_LIMIT, DEFAULT_FEE_DENOM, DEFAULT_GAS_LIMIT, DEFAULT_GAS_PRICE, DEFAULT_IBC_GAS_LIMIT, DEFAULT_STD_FEE_BY_DENOM, DEFAULT_TIMESTAMP_TIMEOUT_MS, DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS, DEFAULT_TX_POLL_CALL_TIMEOUT_MS, DEFAULT_TX_POLL_INTERVAL_MS, HttpClient, HttpRestClient, INJECTIVE_DENOM, INJ_DENOM, LocalStorage, Status, StatusType, ZERO_ADDRESS, awaitAll, awaitForAll, capitalize, convertTimestampToMilliseconds, formatWalletAddress, getBigNumberWithRounding, getDefaultStdFee, getEndDateStringFromTimeInSeconds, getExactDecimalsFromNumber, getSecondsInDay, getSignificantDecimalsFromNumber, getStdFee, getStdFeeForToken, getStdFeeFromObject, getStdFeeFromString, getUTCDateFromTimestamp, past24Hours, pastDays, sleep, snakeToPascal, splitArrayToChunks, splitArrayToChunksThrow, toBigNumber, toChainFormat, toHumanReadable, toPascalCase, todayInSeconds, tomorrow }; |
@@ -1,2 +0,3 @@ | ||
| import { b as BigNumber_default, c as DEFAULT_GAS_LIMIT, l as DEFAULT_GAS_PRICE } from "../constants-BY74CT5-.js"; | ||
| import { t as BigNumber_default } from "../BigNumber-DUr2WQBK.js"; | ||
| import { c as DEFAULT_GAS_LIMIT, l as DEFAULT_GAS_PRICE } from "../constants-0w1sGXWU.js"; | ||
| import { Network, getNetworkEndpoints, getNetworkInfo } from "@injectivelabs/networks"; | ||
@@ -3,0 +4,0 @@ import { ChainId, EvmChainId } from "@injectivelabs/ts-types"; |
+204
-4
| { | ||
| "name": "@injectivelabs/utils", | ||
| "version": "1.20.15", | ||
| "version": "1.20.16", | ||
| "description": "List of utils and helper functions that can be reused throughout Injective's projects.", | ||
@@ -37,2 +37,182 @@ "license": "Apache-2.0", | ||
| }, | ||
| "./big-number": { | ||
| "react-native": { | ||
| "import": "./dist/esm/big-number.js", | ||
| "require": "./dist/cjs/big-number.cjs", | ||
| "types": "./dist/cjs/big-number.d.cts", | ||
| "default": "./dist/cjs/big-number.cjs" | ||
| }, | ||
| "require": { | ||
| "types": "./dist/cjs/big-number.d.cts", | ||
| "default": "./dist/cjs/big-number.cjs" | ||
| }, | ||
| "import": { | ||
| "types": "./dist/esm/big-number.d.ts", | ||
| "default": "./dist/esm/big-number.js" | ||
| }, | ||
| "default": { | ||
| "types": "./dist/cjs/big-number.d.cts", | ||
| "default": "./dist/cjs/big-number.cjs" | ||
| } | ||
| }, | ||
| "./constants": { | ||
| "react-native": { | ||
| "import": "./dist/esm/constants.js", | ||
| "require": "./dist/cjs/constants.cjs", | ||
| "types": "./dist/cjs/constants.d.cts", | ||
| "default": "./dist/cjs/constants.cjs" | ||
| }, | ||
| "require": { | ||
| "types": "./dist/cjs/constants.d.cts", | ||
| "default": "./dist/cjs/constants.cjs" | ||
| }, | ||
| "import": { | ||
| "types": "./dist/esm/constants.d.ts", | ||
| "default": "./dist/esm/constants.js" | ||
| }, | ||
| "default": { | ||
| "types": "./dist/cjs/constants.d.cts", | ||
| "default": "./dist/cjs/constants.cjs" | ||
| } | ||
| }, | ||
| "./formatters": { | ||
| "react-native": { | ||
| "import": "./dist/esm/formatters.js", | ||
| "require": "./dist/cjs/formatters.cjs", | ||
| "types": "./dist/cjs/formatters.d.cts", | ||
| "default": "./dist/cjs/formatters.cjs" | ||
| }, | ||
| "require": { | ||
| "types": "./dist/cjs/formatters.d.cts", | ||
| "default": "./dist/cjs/formatters.cjs" | ||
| }, | ||
| "import": { | ||
| "types": "./dist/esm/formatters.d.ts", | ||
| "default": "./dist/esm/formatters.js" | ||
| }, | ||
| "default": { | ||
| "types": "./dist/cjs/formatters.d.cts", | ||
| "default": "./dist/cjs/formatters.cjs" | ||
| } | ||
| }, | ||
| "./helpers": { | ||
| "react-native": { | ||
| "import": "./dist/esm/helpers.js", | ||
| "require": "./dist/cjs/helpers.cjs", | ||
| "types": "./dist/cjs/helpers.d.cts", | ||
| "default": "./dist/cjs/helpers.cjs" | ||
| }, | ||
| "require": { | ||
| "types": "./dist/cjs/helpers.d.cts", | ||
| "default": "./dist/cjs/helpers.cjs" | ||
| }, | ||
| "import": { | ||
| "types": "./dist/esm/helpers.d.ts", | ||
| "default": "./dist/esm/helpers.js" | ||
| }, | ||
| "default": { | ||
| "types": "./dist/cjs/helpers.d.cts", | ||
| "default": "./dist/cjs/helpers.cjs" | ||
| } | ||
| }, | ||
| "./http": { | ||
| "react-native": { | ||
| "import": "./dist/esm/http.js", | ||
| "require": "./dist/cjs/http.cjs", | ||
| "types": "./dist/cjs/http.d.cts", | ||
| "default": "./dist/cjs/http.cjs" | ||
| }, | ||
| "require": { | ||
| "types": "./dist/cjs/http.d.cts", | ||
| "default": "./dist/cjs/http.cjs" | ||
| }, | ||
| "import": { | ||
| "types": "./dist/esm/http.d.ts", | ||
| "default": "./dist/esm/http.js" | ||
| }, | ||
| "default": { | ||
| "types": "./dist/cjs/http.d.cts", | ||
| "default": "./dist/cjs/http.cjs" | ||
| } | ||
| }, | ||
| "./light": { | ||
| "react-native": { | ||
| "import": "./dist/esm/light.js", | ||
| "require": "./dist/cjs/light.cjs", | ||
| "types": "./dist/cjs/light.d.cts", | ||
| "default": "./dist/cjs/light.cjs" | ||
| }, | ||
| "require": { | ||
| "types": "./dist/cjs/light.d.cts", | ||
| "default": "./dist/cjs/light.cjs" | ||
| }, | ||
| "import": { | ||
| "types": "./dist/esm/light.d.ts", | ||
| "default": "./dist/esm/light.js" | ||
| }, | ||
| "default": { | ||
| "types": "./dist/cjs/light.d.cts", | ||
| "default": "./dist/cjs/light.cjs" | ||
| } | ||
| }, | ||
| "./numbers": { | ||
| "react-native": { | ||
| "import": "./dist/esm/numbers.js", | ||
| "require": "./dist/cjs/numbers.cjs", | ||
| "types": "./dist/cjs/numbers.d.cts", | ||
| "default": "./dist/cjs/numbers.cjs" | ||
| }, | ||
| "require": { | ||
| "types": "./dist/cjs/numbers.d.cts", | ||
| "default": "./dist/cjs/numbers.cjs" | ||
| }, | ||
| "import": { | ||
| "types": "./dist/esm/numbers.d.ts", | ||
| "default": "./dist/esm/numbers.js" | ||
| }, | ||
| "default": { | ||
| "types": "./dist/cjs/numbers.d.cts", | ||
| "default": "./dist/cjs/numbers.cjs" | ||
| } | ||
| }, | ||
| "./status": { | ||
| "react-native": { | ||
| "import": "./dist/esm/status.js", | ||
| "require": "./dist/cjs/status.cjs", | ||
| "types": "./dist/cjs/status.d.cts", | ||
| "default": "./dist/cjs/status.cjs" | ||
| }, | ||
| "require": { | ||
| "types": "./dist/cjs/status.d.cts", | ||
| "default": "./dist/cjs/status.cjs" | ||
| }, | ||
| "import": { | ||
| "types": "./dist/esm/status.d.ts", | ||
| "default": "./dist/esm/status.js" | ||
| }, | ||
| "default": { | ||
| "types": "./dist/cjs/status.d.cts", | ||
| "default": "./dist/cjs/status.cjs" | ||
| } | ||
| }, | ||
| "./storage": { | ||
| "react-native": { | ||
| "import": "./dist/esm/storage.js", | ||
| "require": "./dist/cjs/storage.cjs", | ||
| "types": "./dist/cjs/storage.d.cts", | ||
| "default": "./dist/cjs/storage.cjs" | ||
| }, | ||
| "require": { | ||
| "types": "./dist/cjs/storage.d.cts", | ||
| "default": "./dist/cjs/storage.cjs" | ||
| }, | ||
| "import": { | ||
| "types": "./dist/esm/storage.d.ts", | ||
| "default": "./dist/esm/storage.js" | ||
| }, | ||
| "default": { | ||
| "types": "./dist/cjs/storage.d.cts", | ||
| "default": "./dist/cjs/storage.cjs" | ||
| } | ||
| }, | ||
| "./test-utils": { | ||
@@ -57,2 +237,22 @@ "react-native": { | ||
| } | ||
| }, | ||
| "./time": { | ||
| "react-native": { | ||
| "import": "./dist/esm/time.js", | ||
| "require": "./dist/cjs/time.cjs", | ||
| "types": "./dist/cjs/time.d.cts", | ||
| "default": "./dist/cjs/time.cjs" | ||
| }, | ||
| "require": { | ||
| "types": "./dist/cjs/time.d.cts", | ||
| "default": "./dist/cjs/time.cjs" | ||
| }, | ||
| "import": { | ||
| "types": "./dist/esm/time.d.ts", | ||
| "default": "./dist/esm/time.js" | ||
| }, | ||
| "default": { | ||
| "types": "./dist/cjs/time.d.cts", | ||
| "default": "./dist/cjs/time.cjs" | ||
| } | ||
| } | ||
@@ -71,5 +271,5 @@ }, | ||
| "store2": "^2.14.4", | ||
| "@injectivelabs/exceptions": "1.20.15", | ||
| "@injectivelabs/ts-types": "1.20.15", | ||
| "@injectivelabs/networks": "1.20.15" | ||
| "@injectivelabs/exceptions": "1.20.16", | ||
| "@injectivelabs/networks": "1.20.16", | ||
| "@injectivelabs/ts-types": "1.20.16" | ||
| }, | ||
@@ -76,0 +276,0 @@ "publishConfig": { |
| //#region rolldown:runtime | ||
| var __create = Object.create; | ||
| var __defProp = Object.defineProperty; | ||
| var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
| var __getOwnPropNames = Object.getOwnPropertyNames; | ||
| var __getProtoOf = Object.getPrototypeOf; | ||
| var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
| var __copyProps = (to, from, except, desc) => { | ||
| if (from && typeof from === "object" || typeof from === "function") { | ||
| for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) { | ||
| key = keys[i]; | ||
| if (!__hasOwnProp.call(to, key) && key !== except) { | ||
| __defProp(to, key, { | ||
| get: ((k) => from[k]).bind(null, key), | ||
| enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable | ||
| }); | ||
| } | ||
| } | ||
| } | ||
| return to; | ||
| }; | ||
| var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { | ||
| value: mod, | ||
| enumerable: true | ||
| }) : target, mod)); | ||
| //#endregion | ||
| let bignumber_js = require("bignumber.js"); | ||
| bignumber_js = __toESM(bignumber_js); | ||
| //#region src/classes/BigNumber.ts | ||
| var BigNumber_default = bignumber_js.default; | ||
| /** | ||
| * Converts a value to BigNumber if it isn't already | ||
| */ | ||
| const toBigNumber = (value) => { | ||
| if (value instanceof bignumber_js.default) return value; | ||
| return new bignumber_js.default(value); | ||
| }; | ||
| /** | ||
| * Converts a value to Wei (multiplies by 10^decimals) default to 18 decimals | ||
| */ | ||
| const toChainFormat = (value, decimals = 18) => { | ||
| return toBigNumber(value).multipliedBy(new bignumber_js.default(10).pow(decimals)); | ||
| }; | ||
| /** | ||
| * Converts a value from Wei to Base (divides by 10^decimals) default to 18 decimals | ||
| */ | ||
| const toHumanReadable = (value, decimals = 18) => { | ||
| return toBigNumber(value).dividedBy(new bignumber_js.default(10).pow(decimals)); | ||
| }; | ||
| //#endregion | ||
| //#region src/constants.ts | ||
| const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000"; | ||
| const INJ_DENOM = "inj"; | ||
| const INJECTIVE_DENOM = "inj"; | ||
| const DEFAULT_FEE_DENOM = "inj"; | ||
| const DEFAULT_GAS_LIMIT = 4e5; | ||
| const DEFAULT_IBC_GAS_LIMIT = 3e5; | ||
| const DEFAULT_GAS_PRICE = 16e7; | ||
| const DEFAULT_EXCHANGE_LIMIT = 2e5; | ||
| const DEFAULT_BRIDGE_FEE_DENOM = "inj"; | ||
| const DEFAULT_BRIDGE_FEE_PRICE = "160000000"; | ||
| const DEFAULT_BRIDGE_FEE_AMOUNT = "200000000000000"; | ||
| const DEFAULT_BLOCK_TIMEOUT_HEIGHT = 60; | ||
| const DEFAULT_BLOCK_TIME_IN_SECONDS = .7; | ||
| /** | ||
| * Default timeout for transaction block inclusion polling. | ||
| * | ||
| * Calculation: 120 blocks × 0.7 seconds/block = 84 seconds = 84,000ms | ||
| */ | ||
| const DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS = Math.floor(DEFAULT_BLOCK_TIMEOUT_HEIGHT * DEFAULT_BLOCK_TIME_IN_SECONDS * 1e3); | ||
| const DEFAULT_TX_POLL_INTERVAL_MS = 500; | ||
| const DEFAULT_TX_POLL_CALL_TIMEOUT_MS = 3e3; | ||
| const DEFAULT_TIMESTAMP_TIMEOUT_MS = 60 * 1e3 * 3; | ||
| const getDefaultStdFee = () => ({ | ||
| amount: [{ | ||
| amount: new BigNumber_default(DEFAULT_GAS_LIMIT).times(DEFAULT_GAS_PRICE).toString(), | ||
| denom: "inj" | ||
| }], | ||
| gas: DEFAULT_GAS_LIMIT.toString(), | ||
| payer: "", | ||
| granter: "", | ||
| feePayer: "" | ||
| }); | ||
| const DEFAULT_STD_FEE_BY_DENOM = (denom = "inj") => ({ | ||
| amount: [{ | ||
| denom, | ||
| amount: new BigNumber_default(DEFAULT_GAS_LIMIT).times(DEFAULT_GAS_PRICE).toString() | ||
| }], | ||
| gas: DEFAULT_GAS_LIMIT.toString() | ||
| }); | ||
| //#endregion | ||
| Object.defineProperty(exports, 'BigNumber_default', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return BigNumber_default; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'DEFAULT_BLOCK_TIMEOUT_HEIGHT', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return DEFAULT_BLOCK_TIMEOUT_HEIGHT; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'DEFAULT_BLOCK_TIME_IN_SECONDS', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return DEFAULT_BLOCK_TIME_IN_SECONDS; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'DEFAULT_BRIDGE_FEE_AMOUNT', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return DEFAULT_BRIDGE_FEE_AMOUNT; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'DEFAULT_BRIDGE_FEE_DENOM', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return DEFAULT_BRIDGE_FEE_DENOM; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'DEFAULT_BRIDGE_FEE_PRICE', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return DEFAULT_BRIDGE_FEE_PRICE; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'DEFAULT_EXCHANGE_LIMIT', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return DEFAULT_EXCHANGE_LIMIT; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'DEFAULT_FEE_DENOM', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return DEFAULT_FEE_DENOM; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'DEFAULT_GAS_LIMIT', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return DEFAULT_GAS_LIMIT; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'DEFAULT_GAS_PRICE', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return DEFAULT_GAS_PRICE; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'DEFAULT_IBC_GAS_LIMIT', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return DEFAULT_IBC_GAS_LIMIT; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'DEFAULT_STD_FEE_BY_DENOM', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return DEFAULT_STD_FEE_BY_DENOM; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'DEFAULT_TIMESTAMP_TIMEOUT_MS', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return DEFAULT_TIMESTAMP_TIMEOUT_MS; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'DEFAULT_TX_POLL_CALL_TIMEOUT_MS', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return DEFAULT_TX_POLL_CALL_TIMEOUT_MS; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'DEFAULT_TX_POLL_INTERVAL_MS', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return DEFAULT_TX_POLL_INTERVAL_MS; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'INJECTIVE_DENOM', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return INJECTIVE_DENOM; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'INJ_DENOM', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return INJ_DENOM; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'ZERO_ADDRESS', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return ZERO_ADDRESS; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, '__toESM', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return __toESM; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'getDefaultStdFee', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return getDefaultStdFee; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'toBigNumber', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return toBigNumber; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'toChainFormat', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return toChainFormat; | ||
| } | ||
| }); | ||
| Object.defineProperty(exports, 'toHumanReadable', { | ||
| enumerable: true, | ||
| get: function () { | ||
| return toHumanReadable; | ||
| } | ||
| }); |
| import BigNumber from "bignumber.js"; | ||
| //#region src/classes/BigNumber.ts | ||
| var BigNumber_default = BigNumber; | ||
| /** | ||
| * Converts a value to BigNumber if it isn't already | ||
| */ | ||
| const toBigNumber = (value) => { | ||
| if (value instanceof BigNumber) return value; | ||
| return new BigNumber(value); | ||
| }; | ||
| /** | ||
| * Converts a value to Wei (multiplies by 10^decimals) default to 18 decimals | ||
| */ | ||
| const toChainFormat = (value, decimals = 18) => { | ||
| return toBigNumber(value).multipliedBy(new BigNumber(10).pow(decimals)); | ||
| }; | ||
| /** | ||
| * Converts a value from Wei to Base (divides by 10^decimals) default to 18 decimals | ||
| */ | ||
| const toHumanReadable = (value, decimals = 18) => { | ||
| return toBigNumber(value).dividedBy(new BigNumber(10).pow(decimals)); | ||
| }; | ||
| //#endregion | ||
| //#region src/constants.ts | ||
| const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000"; | ||
| const INJ_DENOM = "inj"; | ||
| const INJECTIVE_DENOM = "inj"; | ||
| const DEFAULT_FEE_DENOM = "inj"; | ||
| const DEFAULT_GAS_LIMIT = 4e5; | ||
| const DEFAULT_IBC_GAS_LIMIT = 3e5; | ||
| const DEFAULT_GAS_PRICE = 16e7; | ||
| const DEFAULT_EXCHANGE_LIMIT = 2e5; | ||
| const DEFAULT_BRIDGE_FEE_DENOM = "inj"; | ||
| const DEFAULT_BRIDGE_FEE_PRICE = "160000000"; | ||
| const DEFAULT_BRIDGE_FEE_AMOUNT = "200000000000000"; | ||
| const DEFAULT_BLOCK_TIMEOUT_HEIGHT = 60; | ||
| const DEFAULT_BLOCK_TIME_IN_SECONDS = .7; | ||
| /** | ||
| * Default timeout for transaction block inclusion polling. | ||
| * | ||
| * Calculation: 120 blocks × 0.7 seconds/block = 84 seconds = 84,000ms | ||
| */ | ||
| const DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS = Math.floor(DEFAULT_BLOCK_TIMEOUT_HEIGHT * DEFAULT_BLOCK_TIME_IN_SECONDS * 1e3); | ||
| const DEFAULT_TX_POLL_INTERVAL_MS = 500; | ||
| const DEFAULT_TX_POLL_CALL_TIMEOUT_MS = 3e3; | ||
| const DEFAULT_TIMESTAMP_TIMEOUT_MS = 60 * 1e3 * 3; | ||
| const getDefaultStdFee = () => ({ | ||
| amount: [{ | ||
| amount: new BigNumber_default(DEFAULT_GAS_LIMIT).times(DEFAULT_GAS_PRICE).toString(), | ||
| denom: "inj" | ||
| }], | ||
| gas: DEFAULT_GAS_LIMIT.toString(), | ||
| payer: "", | ||
| granter: "", | ||
| feePayer: "" | ||
| }); | ||
| const DEFAULT_STD_FEE_BY_DENOM = (denom = "inj") => ({ | ||
| amount: [{ | ||
| denom, | ||
| amount: new BigNumber_default(DEFAULT_GAS_LIMIT).times(DEFAULT_GAS_PRICE).toString() | ||
| }], | ||
| gas: DEFAULT_GAS_LIMIT.toString() | ||
| }); | ||
| //#endregion | ||
| export { toHumanReadable as C, toChainFormat as S, INJ_DENOM as _, DEFAULT_BRIDGE_FEE_PRICE as a, BigNumber_default as b, DEFAULT_GAS_LIMIT as c, DEFAULT_STD_FEE_BY_DENOM as d, DEFAULT_TIMESTAMP_TIMEOUT_MS as f, INJECTIVE_DENOM as g, DEFAULT_TX_POLL_INTERVAL_MS as h, DEFAULT_BRIDGE_FEE_DENOM as i, DEFAULT_GAS_PRICE as l, DEFAULT_TX_POLL_CALL_TIMEOUT_MS as m, DEFAULT_BLOCK_TIME_IN_SECONDS as n, DEFAULT_EXCHANGE_LIMIT as o, DEFAULT_TX_BLOCK_INCLUSION_TIMEOUT_IN_MS as p, DEFAULT_BRIDGE_FEE_AMOUNT as r, DEFAULT_FEE_DENOM as s, DEFAULT_BLOCK_TIMEOUT_HEIGHT as t, DEFAULT_IBC_GAS_LIMIT as u, ZERO_ADDRESS as v, toBigNumber as x, getDefaultStdFee as y }; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
152915
54.18%96
540%2833
36.6%3
50%+ Added
+ Added
+ Added
- Removed
- Removed
- Removed