import { Coin, OfflineAminoSigner, StdFee } from '@cosmjs/amino'; import BigNumber from 'bignumber.js'; import { AppCurrency } from '@keplr-wallet/types'; import * as defu from 'defu'; import { createDefu } from 'defu'; import _ from 'lodash'; import { createWasmAminoConverters } from '@cosmjs/cosmwasm-stargate'; import { AminoTypes, createDefaultAminoConverters, SignerData } from '@cosmjs/stargate'; import { SigningArchwayClient } from '@archwayhq/arch3.js'; import { EncodeObject } from '@cosmjs/proto-signing'; import { TxRaw } from 'cosmjs-types/cosmos/tx/v1beta1/tx.js'; type FiatCurrency = { currencyCode: string; currencySymbol?: string; }; declare const DEFAULT_FIAT_CURRENCY: FiatCurrency; declare const FIAT_CURRENCIES_MAP: Record; type Optional = Pick, K> & Omit; type DeviceType = 'desktop' | 'mobile'; type OS = 'android' | 'ios' | 'windows' | 'macos'; type UserAgentConfig = { os: OS; device: DeviceType; browser: string; isMobile: boolean; }; type MaybeArray = T | T[]; type MaybePromise = T | Promise; type TokenDenom = AppCurrency; declare enum SortDirection { ASC = "ASC", DESC = "DESC" } declare enum TooltipPosition { TOP = "TOP", TOP_LEFT = "TOP_LEFT", TOP_RIGHT = "TOP_RIGHT", RIGHT = "RIGHT", BOTTOM = "BOTTOM", BOTTOM_LEFT = "BOTTOM_LEFT", BOTTOM_RIGHT = "BOTTOM_RIGHT", LEFT = "LEFT" } type Filter = { id: string | number | boolean; label: string; }; declare enum Status { SUCCESS = "success", ERROR = "error", WARNING = "warning", INFO = "info" } declare enum ProgressStatus { DONE = "done", ERROR = "error", WARNING = "warning", DEFAULT = "default" } type NumberSymbolMap = Record; type FormatNumberParams = { removeTrailingZeroes?: boolean; roundingMode?: BigNumber.RoundingMode; compact?: boolean; compactThousandSymbol?: string; compactMillionSymbol?: string; compactSymbolMap?: NumberSymbolMap; compactThreshold?: BigNumber.Value; prefix?: string; suffix?: string; }; type CwExpiration = { /** Timestamp in nanoseconds */ at_time: string; } | { never: {}; }; declare class TokenAmount$1 { amount: BigNumber; denom: TokenDenom; static DEFAULT_DECIMALS: number | undefined; constructor(amount: BigNumber, denom: TokenDenom); static makeFromAmount(amount: BigNumber.Value, tokenDenom: TokenDenom): TokenAmount$1; static makeFromDenom(amount: BigNumber.Value, tokenDenom: TokenDenom): TokenAmount$1; static zero(tokenDenom: TokenDenom): TokenAmount$1; format(decimals?: number, params?: FormatNumberParams): string; formatWithCoin(formatDecimals?: number, params?: FormatNumberParams): string; formatWithMinCoin(params?: FormatNumberParams): string; plus(otherAmount: TokenAmount$1): TokenAmount$1; minus(otherAmount: TokenAmount$1): TokenAmount$1; toBigNumber(): BigNumber; toCosmjsCoin(): Coin; } type ITokenPrice = { coinGeckoId: string; price: BigNumber.Value; priceChange: BigNumber.Value; fiatCurrency: FiatCurrency; }; declare class TokenPrice { coinGeckoId: string; price: number; priceChange: number; fiatCurrency: FiatCurrency; constructor(coinGeckoId: string, price: number, priceChange: number, fiatCurrency: FiatCurrency); static make(coinGeckoId: string, price: BigNumber.Value, priceChange?: BigNumber.Value, fiatCurrency?: FiatCurrency): TokenPrice; } const compactNumberSymbolMap$1 = { "1000": "K", "1000000": "M", "1000000000": "B" }; function formatNumber$1(val, decimals, params) { const { removeTrailingZeroes = true, roundingMode = BigNumber.ROUND_DOWN, compact, compactThousandSymbol, compactMillionSymbol, compactThreshold = 1e5, compactSymbolMap = compactNumberSymbolMap$1, prefix = "", suffix = "" } = params ?? {}; let bigNum = BigNumber(val); let compactSuffix = ""; if (compact && bigNum.gte(compactThreshold)) { if (compactThousandSymbol) { compactSymbolMap["1000"] = compactThousandSymbol; } if (compactMillionSymbol) { compactSymbolMap["1000000"] = compactMillionSymbol; } const symbolsEntries = Object.entries(compactSymbolMap).sort(([a, _asymbol], [b, _bsymbol]) => { const bna = BigNumber(a); const bnb = BigNumber(b); return bna < bnb ? 1 : bna === bnb ? 0 : -1; }); for (const [amount, symbol] of symbolsEntries) { const quotient = bigNum.div(amount); if (quotient.gte(1)) { bigNum = quotient; compactSuffix = symbol; break; } } } let result = decimals === void 0 ? bigNum.toFormat() : bigNum.toFormat(decimals, roundingMode); if (removeTrailingZeroes) { result = result.replace(/(\.\d*?)0*$/, "$1").replace(/\.$/, ""); } return `${prefix}${result}${compactSuffix}${suffix}`; } var __defProp = Object.defineProperty; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __publicField = (obj, key, value) => { __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); return value; }; BigNumber.config({ EXPONENTIAL_AT: 1e9 }); const _TokenAmount = class _TokenAmount { constructor(amount, denom) { this.amount = amount; this.denom = denom; } static makeFromAmount(amount, tokenDenom) { return new _TokenAmount(BigNumber(amount || 0), tokenDenom); } static makeFromDenom(amount, tokenDenom) { const converted = BigNumber(amount || 0).shiftedBy(tokenDenom.coinDecimals); return new _TokenAmount(converted, tokenDenom); } static zero(tokenDenom) { return new _TokenAmount(BigNumber(0), tokenDenom); } format(decimals, params) { const converted = this.toBigNumber(); return formatNumber$1(converted, decimals ?? _TokenAmount.DEFAULT_DECIMALS ?? this.denom.coinDecimals, params); } formatWithCoin(formatDecimals, params) { return `${this.format(formatDecimals, params)} ${this.denom.coinDenom}`; } formatWithMinCoin(params) { return `${formatNumber$1(this.amount, 0, params)} ${this.denom.coinMinimalDenom}`; } plus(otherAmount) { return _TokenAmount.makeFromAmount(this.amount.plus(otherAmount.amount), this.denom); } minus(otherAmount) { return _TokenAmount.makeFromAmount(this.amount.minus(otherAmount.amount), this.denom); } toBigNumber() { return BigNumber(this.amount || 0).shiftedBy(-this.denom.coinDecimals); } toCosmjsCoin() { return { amount: this.amount.toFixed(), denom: this.denom.coinMinimalDenom }; } }; __publicField(_TokenAmount, "DEFAULT_DECIMALS"); let TokenAmount = _TokenAmount; createDefu((obj, key, value) => { if (_.isArray(obj[key])) { if (JSON.stringify(obj[key]) !== JSON.stringify(value)) { obj[key] = value; } return true; } }); new AminoTypes({ ...createDefaultAminoConverters(), ...createWasmAminoConverters() }); declare class TokenTotalPrice { tokenAmount: TokenAmount; tokenPrice?: TokenPrice | undefined; constructor(tokenAmount: TokenAmount, tokenPrice?: TokenPrice | undefined); get totalPrice(): any; } declare class LocalStorage { static get(key: string, encoded?: boolean): any; static set(key: string, value: any, encoded?: boolean): void; static remove(key: string): void; } declare const DEFAULT_PAGINATION_LIMIT = 12; declare function convertAddress(address: string, newPrefix: string): string | undefined; declare const toSHA256String: (input: string) => string; /** * * @param expiration Stringified number with timestamp in nanoseconds * @returns CosmWasm compatible Expiration structure, i.e. `{ at_time } | { never }` */ declare const toCwExpiration: (expiration: string | null) => CwExpiration; /** * Takes a number of seconds, and add them on top of the current timestamp, * with a result in nanoseconds * * @param futureInSeconds Number of seconds to add * @returns Timestamp in the future, represented in nanoseconds, or null if no expiration */ declare const futureExpirationTimestamp: (futureInSeconds?: number) => `${number}` | null; declare function formatShortDate(date: Date | number): string; declare function formatShortTime(date: Date | number): string; declare function formatShortDateTime(date: Date): string; declare function formatDate(date: Date | number): string; declare function formatTime(date: Date | number): string; declare function formatDateTime(date: Date): string; declare const compactNumberSymbolMap: NumberSymbolMap; declare function formatNumber(val: BigNumber.Value, decimals?: number, params?: FormatNumberParams): string; declare function formatPercent(val: BigNumber.Value, decimals?: number, params?: FormatNumberParams): string; declare const formatPrice: (price?: BigNumber.Value, decimals?: number, params?: FormatNumberParams) => string | undefined; declare function formatCosmjsErrorMessage(errorMessage?: string): string; declare function truncateAddress(address: string, params?: { prefix?: string; charsStart?: number; charsEnd?: number; hidePrefix?: boolean; uppercase?: boolean; lowercase?: boolean; }): string; declare const truncateTransaction: (transactionId: string) => string; /** * Truncate a string if its length is higher than a number, and add an ellipsis as the last char. * @param value String to truncate * @param maxLength Max number of characters that it can have * @returns Truncated string if too long, otherwise return same string */ declare const truncateString: (value: string, maxLength: number, placeholder?: string) => string; declare const listRepresentation: (list: string[], options?: { max?: number; }) => string; /** * Parse denom value into units * @param amount BigNumber's input value - string, number or another BN instance * @param decimals Number of decimal places to shift by * @returns BigNumber's stringified representation parsed to units * @example ```js * toAmountUnits('100', 3); // '100000' * ``` */ declare const toAmountUnits: (amount: BigNumber.Value, decimals?: number) => string; /** * Format units as denom value * @param amount BigNumber's input value - string, number or another BN instance * @param decimals Number of decimal places to shift by * @returns BigNumber's stringified representation formatted from units * @example ```js * fromAmountUnits('100', 3); // '0.1' * ``` */ declare const fromAmountUnits: (amount: BigNumber.Value, decimals?: number) => string; /** * Format the time distance between the given date and now in words * @param dateToCompare Date object that will be compared to Date.now() * @returns String containing the distance in words */ declare const formatTimeDistanceToNow: (dateToCompare: Date) => string | undefined; declare const formatSkipUrl: (baseUrl: string, params?: { srcChain?: string; srcAsset?: string; destChain?: string; destAsset?: string; }) => string; declare const numberToRoman: (value: number) => string | undefined; /** * Convert a contract address into a Cw20 denom * * @param address Contract address to convert * @returns Cw20 denom string */ declare const addressToCw20Denom: (address: string) => string; /** * Convert a Cw20 denom into a contract address, returns undefined if it can't be converted * * @param cw20Denom Cw20 denom to convert * @returns Contract address string, or undefined if failed to convert */ declare const cw20DenomToAddress: (cw20Denom: string) => string | undefined; /** * Checks if a TokenDenom is a CW20 token * * @param tokenDenom Token Denom to check * @returns Boolean */ declare const isCw20TokenDenom: (tokenDenom?: TokenDenom) => boolean | undefined; /** * Creates a Date from ns input * @param ns Date in nanoseconds * @returns Date instance */ declare const nanosecondsToDate: (ns: BigNumber.Value) => Date; /** * Creates a Date from seconds input * @param s Date in seconds * @returns Date instance */ declare const secondsToDate: (s: BigNumber.Value) => Date; declare const buildQueryString: (input?: Record) => string; /** * Returns current timestamp in nanoseconds as a BigInt, optionally allows to add seconds to the timestamp * @param secondsAdded Optional, Number of seconds to add * @returns BigInt containing the timestamp in nanoseconds */ declare const nanoTimestampToBigInt: (secondsAdded?: string | number | bigint) => bigint; declare function omit & {}>(object: T, keysToOmit?: string[]): {} & T; declare function delayFor(timeout?: number): Promise; declare function retryFor(cb: () => void, maxTries?: number): Promise; declare function uniqueId(): number; declare const capitalize: (value: string) => string; declare const toArray: (value?: T | T[] | undefined) => T[]; declare const isUint8Array: (value: unknown) => boolean; declare const openLink: (uri: string, target?: '_self' | '_blank') => Window | null; declare const transformKeys: (input: Record, transformer: (v: string) => string) => any; declare const transformValues: (input: unknown, transformer: (v: unknown, key?: string) => any, key?: string) => any; declare const mergeObjects: | null | undefined))[]>(source: Source, ...defaults: Defaults) => defu.Defu; /** * Removes from an array the first element with value 'undefined', and all the elements that come after. * * @param items An array * @returns Array with only the first group of defined values */ declare const sliceDefined: (items: T[]) => T[]; declare const filterAlphaNumeric: (input: string) => string; /** * Get percentage the new value increased by compared to the old value. * It's positive if the value has increased and negative otherwise. * * @param oldValue Previous value to compare to * @param newValue Current value * * @example * ``` * getTrend(0, 4); * // 0 -> 4: (4 - 0) / 4 = 4/4 = 100% * // > 100 * * getTrend(1, 4); * // 1 -> 4: (4 - 1) / 4 = 3/4 = 75% * // > 75 * * getTrend(4, 1); * // 4 -> 1: (1 - 4) / 1 = -3/1 = -300% * // > -300 * ``` * * @returns Trend percentage */ declare const getTrend: (oldValue: BigNumber.Value | undefined, newValue: BigNumber.Value) => number | undefined; declare enum ArchwayLinks { ABOUT_DOCS = "https://docs.archway.io/overview/about", ARCH3JS_DOCS = "https://docs.archway.io/developers/developer-tools/arch3js/introduction", ARCH3JS_REPO = "https://github.com/archway-network/arch3.js", ARCHITECTS_ALLIANCE = "https://phi-labs.notion.site/phi-labs/Archway-Architects-Alliance-8a375c760f3e4d53bc697defba56dcbe", AREA_52 = "https://area-52.io", BLOCK_EXPLORERS_DOCS = "https://docs.archway.io/resources/blockexplorers", BLOG = "https://blog.archway.io", BRAND_KIT_ZIP = "https://archway.io/assets/04-archway-brand-kit.zip", BRIDGES_DOCS = "https://docs.archway.io/resources/inc-channels", CLI_DOCS = "https://docs.archway.io/developers/developer-tools/developer-cli", CLI_REPO = "https://github.com/archway-network/archway-cli", COMMUNITY = "https://archway.io/community", CONNECT = "https://connect.archway.io", COSMWASM_DOCS = "https://docs.archway.io/developers/cosmwasm-documentation/introduction", DAPP_SUPPORT_FORM = "https://forms.gle/r4eCaFvUz3iNpeDD6", DESIGN_GUIDELINES_PDF = "https://archway.io/assets/03-archway-design-guidelines.pdf", DEVELOPERS_DOCS = "https://docs.archway.io/developers", DOCS = "https://docs.archway.io", DOCS_REPO = "https://github.com/archway-network/archway-docs", ECOSYSTEM = "https://archway.io/ecosystem", ECONOMICS_PDF = "https://archway.io/assets/archway-economics.pdf", FAQ = "https://docs.archway.io/overview/faq", GETTING_STARTED_DOCS = "https://docs.archway.io/getting-started", GOVERNANCE_FORUM = "https://gov.archway.io", GOVERNANCE_PDF = "https://archway.io/assets/archway-governance.pdf", GRANTS = "https://archway.io/grants", LOGO_PACK_ZIP = "https://archway.io/assets/01-archway-logo-pack.zip", MEDIA_KIT_PDF = "https://archway.io/assets/05-archway-media-kit.pdf", NETWORKS_DOCS = "https://docs.archway.io/resources/networks", PARTNERSHIP_FORM = "https://forms.gle/nCz6Dazdm8ZS9wPf8", REWARDS = "https://rewards.archway.io", REWARDS_DOCS = "https://docs.archway.io/overview/rewards", STATUS = "https://status.archway.io", TECHNICAL_PAPER_PDF = "https://archway.io/assets/archway-technical-paper.pdf", TECHNOLOGY = "https://archway.io/technology", TOKEN_ALLOCATION_PDF = "https://archway.io/assets/archway-token-allocation.pdf", VALIDATORS_DOCS = "https://docs.archway.io/validators", VISUAL_ASSETS_ZIP = "https://archway.io/assets/02-archway-visual-assets.zip", WHITEPAPERS = "https://archway.io/whitepapers", WHITEPAPER_PDF = "https://archway.io/assets/archway-whitepaper.pdf" } declare enum SocialLinks { DISCORD = "https://discord.gg/5FVvx3WGfa", GITHUB = "https://github.com/archway-network", REDDIT = "https://www.reddit.com/r/Archway", TELEGRAM = "https://t.me/archway_hq", X = "https://twitter.com/archwayhq", YOUTUBE = "https://www.youtube.com/@ArchwayNetwork" } declare function patchSignAmino(client: SigningArchwayClient, offlineSigner: OfflineAminoSigner, signerAddress: string, messages: readonly EncodeObject[], fee: StdFee, memo: string, { accountNumber, sequence, chainId }: SignerData): Promise; declare const getUserAgent: () => Partial; declare function isEmail(str: string): boolean; declare function isValidAddress(address: string, prefix?: string, type?: 'contract' | 'wallet'): boolean; declare function isValidArchwayAddress(address: string, type?: 'contract' | 'wallet'): boolean; export { ArchwayLinks, CwExpiration, DEFAULT_FIAT_CURRENCY, DEFAULT_PAGINATION_LIMIT, DeviceType, FIAT_CURRENCIES_MAP, FiatCurrency, Filter, FormatNumberParams, ITokenPrice, LocalStorage, MaybeArray, MaybePromise, NumberSymbolMap, OS, Optional, ProgressStatus, SocialLinks, SortDirection, Status, TokenAmount$1 as TokenAmount, TokenDenom, TokenPrice, TokenTotalPrice, TooltipPosition, UserAgentConfig, addressToCw20Denom, buildQueryString, capitalize, compactNumberSymbolMap, convertAddress, cw20DenomToAddress, delayFor, filterAlphaNumeric, formatCosmjsErrorMessage, formatDate, formatDateTime, formatNumber, formatPercent, formatPrice, formatShortDate, formatShortDateTime, formatShortTime, formatSkipUrl, formatTime, formatTimeDistanceToNow, fromAmountUnits, futureExpirationTimestamp, getTrend, getUserAgent, isCw20TokenDenom, isEmail, isUint8Array, isValidAddress, isValidArchwayAddress, listRepresentation, mergeObjects, nanoTimestampToBigInt, nanosecondsToDate, numberToRoman, omit, openLink, patchSignAmino, retryFor, secondsToDate, sliceDefined, toAmountUnits, toArray, toCwExpiration, toSHA256String, transformKeys, transformValues, truncateAddress, truncateString, truncateTransaction, uniqueId };