type HexString = string; type ErgoTreeHex = string; type Base58String = string; type Amount = string | bigint; type OneOrMore = T | T[]; type SortingSelector = (item: T) => string | number | bigint; type SortingDirection = "asc" | "desc"; type FilterPredicate = (item: T) => boolean; type PlainObjectType = "minimal" | "EIP-12"; type NonMandatoryRegisters = { R4?: T; R5?: T; R6?: T; R7?: T; R8?: T; R9?: T; }; type TokenId = string; type TokenBase = { amount: AmountType; }; type TokenAmount = TokenBase & { tokenId: TokenId; }; type NewToken = TokenBase & { tokenId?: TokenId; name?: string; decimals?: number; description?: string; }; type TokenTargetAmount = { tokenId: TokenId; amount?: AmountType; }; type ContextExtension = { [key: number]: T | undefined; }; type ProverResult = { readonly proofBytes: HexString; readonly extension: ContextExtension; }; type SignedInput = { readonly boxId: BoxId; readonly spendingProof: ProverResult | null; }; type UnsignedInput = { boxId: BoxId; extension: ContextExtension; }; type EIP12UnsignedInput = UnsignedInput & { transactionId: TransactionId; index: number; ergoTree: ErgoTreeHex; creationHeight: number; value: string; assets: TokenAmount[]; additionalRegisters: NonMandatoryRegisters; }; type EIP12UnsignedDataInput = { boxId: BoxId; transactionId: TransactionId; index: number; ergoTree: ErgoTreeHex; creationHeight: number; value: string; assets: TokenAmount[]; additionalRegisters: NonMandatoryRegisters; }; type DataInput = { boxId: BoxId; }; type TransactionId = string; type UnsignedTransaction = { id?: TransactionId; inputs: UnsignedInput[]; dataInputs: DataInput[]; outputs: BoxCandidate[]; }; type EIP12UnsignedTransaction = { id?: TransactionId; inputs: EIP12UnsignedInput[]; dataInputs: EIP12UnsignedDataInput[]; outputs: BoxCandidate[]; }; type SignedTransaction = { readonly id: TransactionId; readonly inputs: SignedInput[]; readonly dataInputs: DataInput[]; readonly outputs: Box[]; }; type BoxId = string; type BoxBaseType = { ergoTree: ErgoTreeHex; creationHeight: number; value: T; assets: TokenAmount[]; additionalRegisters: R; }; type BoxCandidate = BoxBaseType & { boxId?: BoxId; }; type Box = BoxBaseType & { boxId: BoxId; transactionId: TransactionId; index: number; }; type PoWSolution = { pk: HexString; w: HexString; n: string; d: number; }; type BlockHeaderId = string; type BlockTransactions = { headerId: BlockHeaderId; transactions: SignedTransaction[]; }; type BlockHeader = { id: BlockHeaderId; timestamp: number; version: number; adProofsRoot: HexString; stateRoot: HexString; transactionsRoot: HexString; nBits: number; extensionHash: HexString; powSolutions: PoWSolution; height: number; difficulty: string; parentId: BlockHeaderId; votes: string; size?: number; extensionId?: HexString; transactionsId?: HexString; adProofsId?: HexString; }; type Block = { header: BlockHeader; blockTransactions: BlockTransactions; adProofs: unknown; extension: unknown; size: number; }; type EnumConst = T[keyof T]; declare enum Network { Mainnet = 0, Testnet = 16 } declare enum AddressType { P2PK = 1, P2SH = 2, P2S = 3, ADH = 4 } declare const ergoTreeHeaderFlags: { readonly sizeInclusion: 8; readonly constantSegregation: 16; }; type ErgoTreeHeaderFlag = EnumConst; type ObjectSelector = (item: T) => T[keyof T]; /** * Returns the first element of an array. * @param array * @throws an error if the array is empty. */ declare function first(array: undefined): undefined; declare function first(array: ArrayLike): T; /** * Returns the last element of an array. * @param array * @throws an error if the array is empty. */ declare function last(array: undefined): undefined; declare function last(array: ArrayLike): T; /** * Returns the element at the specified index. Negative indices are counted from the end of the array. * @param array * @param index */ declare function at(array: undefined, index: number): undefined; declare function at(array: ArrayLike, index: number): T; /** * Check for duplicate elements using the equality operator */ declare function hasDuplicates(array: T[]): boolean; /** * Check for duplicate keys in complex elements */ declare function hasDuplicatesBy(array: T[], selector: ObjectSelector): boolean; /** * Turns an array into chunks of the specified size * @param array * @param size * * @example * ``` * const array = [1, 2, 3, 4, 5]; * const chunks = chunk(array, 2); * console.log(chunks); * // [[1, 2], [3, 4], [5]] * ``` */ declare function chunk(array: T[], size: number): T[][]; /** * Sorts an array of objects by the specified property * @param array * @param iteratee * @param order * * @example * ``` * const array = [{ name: "John", age: 25 }, { name: "Jane", age: 30 }]; * const sorted = orderBy(array, (item) => item.age, "desc"); * console.log(sorted); * // [{ name: "Jane", age: 30 }, { name: "John", age: 25 }] * ``` */ declare function orderBy(array: T[], iteratee: SortingSelector, order?: SortingDirection): T[]; /** * Checks if arrays are equal * @param array1 * @param array2 * * @example * ``` * const array1 = [1, 2, 3]; * const array2 = [1, 2, 3]; * const array3 = [1, 2, 4]; * const array4 = [1, 2, 3, 4]; * areEqual(array1, array2); // true * areEqual(array1, array3); // false * areEqual(array1, array4); // false * ``` */ declare function areEqual(array1: ArrayLike, array2: ArrayLike): boolean; /** * Checks if arrays are equal by the specified property * @param array1 * @param array2 * @param selector * * @example * ``` * const array1 = [{ name: "John", age: 25 }, { name: "Jane", age: 30 }]; * const array2 = [{ name: "John", age: 25 }, { name: "Jane", age: 30 }]; * const array3 = [{ name: "John", age: 25 }, { name: "Jane", age: 31 }]; * * areEqualBy(array1, array2, (item) => item.age); // true * areEqualBy(array1, array3, (item) => item.age); // false * ``` */ declare function areEqualBy(array1: ArrayLike, array2: ArrayLike, selector: ObjectSelector): boolean; /** * Checks if the array starts with the specified target * @param array * @param target * * @example * ``` * const array = [1, 2, 3, 4, 5]; * const target1 = [1, 2]; * const target2 = [1, 3]; * * startsWith(array, target1); // true * startsWith(array, target2); // false * ``` */ declare function startsWith(array: ArrayLike, target: ArrayLike, offset?: number): boolean; /** * Checks if the array ends with the specified target * @param array * @param target * * @example * ``` * const array = [1, 2, 3, 4, 5]; * const target1 = [4, 5]; * const target2 = [3, 5]; * * endsWith(array, target1); // true * endsWith(array, target2); // false * ``` */ declare function endsWith(array: ArrayLike, target: ArrayLike): boolean; /** * Makes an array unique by removing duplicate elements * @param array * * @example * ``` * const array = [1, 2, 3, 3, 4, 5, 5]; * const unique = uniq(array); * console.log(unique); * // [1, 2, 3, 4, 5] * ``` */ declare function uniq(array: Array): Array; /** * Makes an array unique by removing duplicate elements using the specified property * @param array * @param selector * @param selection * * @example * ``` * const array = [{ name: "John", age: 25 }, { name: "Jane", age: 30 }, { name: "John", age: 30 }]; * const unique = uniqBy(array, (item) => item.name); * console.log(unique); * // [{ name: "John", age: 25 }, { name: "Jane", age: 30 }] * ``` */ declare function uniqBy(array: Array, selector: ObjectSelector, selection?: "keep-first" | "keep-last"): Array; /** * Returns the depth of an array * @param array * * @example * ``` * const array = [1, 2, 3, [4, 5, [6, 7]]]; * const depth = depthOf(array); * console.log(depth); * // 3 */ declare function depthOf(array: unknown | unknown[]): number; type NumberLike = string | number | bigint | boolean; declare const _0n: bigint; declare const _1n: bigint; declare const _2n: bigint; declare const _7n: bigint; declare const _10n: bigint; declare const _63n: bigint; declare const _127n: bigint; declare const _128n: bigint; /** * Ensure that the given value is a bigint * @param number */ declare function ensureBigInt(number: NumberLike): bigint; type ParsingOptions = { /** * Number of decimals. */ decimals?: number; /** * Thousand mark char. * Default: `.` */ decimalMark?: string; }; /** * Parse a decimal string into a bigint with options * @param input * @param options * * @example * undecimalize("129.8379183", { decimals: 9 }) // 129837918300n * undecimalize("1", { decimals: 2 }) // 100n * undecimalize("1", 2) // 100n */ declare function undecimalize(input: string, options?: ParsingOptions | number): bigint; type FormattingOptions = { /** * Number of decimals. */ decimals: number; /** * Thousand mark char. */ thousandMark?: string; /** * Decimal mark char. * Default: `.` */ decimalMark?: string; }; /** * Format a bigint into a decimal string with options * @param value * @param options * * @example * decimalize(129837918300n, { decimals: 9 }) // "129.8379183" * decimalize(100n, { decimals: 2 }) // "1" */ declare function decimalize(value: Amount, options?: FormattingOptions | number): string; /** * Calculates the percentage of a bigint value with a specified precision. * * @param value - The input value to calculate the percentage of * @param percentage - The percentage to calculate (e.g., 5n for 5%) * @param precision - The number of decimal places for the percentage (defaults to 2n) * @returns The calculated percentage of the input value * * @example * For 5% of 200 with 2 decimal places: * percent(200n, 5n) // returns 10n */ declare function percent(value: bigint, percentage: bigint, precision?: bigint): bigint; /** * Sum a collection of numbers by a given iteratee * @param collection * @param iteratee * @param condition * * @example * ``` * const values = [ * { key: 1, value: 100n }, * { key: 2, value: 200n }, * { key: 3, value: 300n }, * { key: 4, value: 400n }, * ]; * * sumBy(values, x => x.value) // 1000n * sumBy(values, x => x.value, x => x.key < 0) // 0n * sumBy(values, x => x.value, x => x.key % 2 === 0) // 600n */ declare function sumBy(collection: readonly T[], iteratee: (value: T) => bigint, condition?: (value: T) => boolean): bigint; /** * Get the minimum value from a collection of numbers * @param numbers */ declare function min(...numbers: T[]): T; /** * Get the maximum value from a collection of numbers * @param numbers */ declare function max(...numbers: T[]): T; /** * Calculates the sum of all nanoErgs and tokens in the given boxes. * @param boxes * * @example * ``` * const boxes = [ * { value: "10", assets: [{ tokenId: "test", amount: "20" }] }, * { value: 20n, assets: [{ tokenId: "test", amount: 30n }] } * ]; * * const sum = utxoSum(boxes); * console.log(sum); * // { nanoErgs: 30n, tokens: [{ tokenId: "test", amount: 50n }] } * ``` */ declare function utxoSum(boxes: readonly BoxAmounts[]): BoxSummary; declare function utxoSum(boxes: readonly BoxAmounts[], tokenId: TokenId): bigint; /** * Calculates the difference between two utxos or utxo sets. * @param minuend * @param subtrahend * * @example * ``` * const minuend = [{ nanoErgs: 30n, tokens: [{ tokenId: "test", amount: 50n }] }]; * const subtrahend = [{ nanoErgs: 10n, tokens: [{ tokenId: "test", amount: 20n }] }]; * const diff = utxoDiff(minuend, subtrahend); * console.log(diff); * // { nanoErgs: 20n, tokens: [{ tokenId: "test", amount: 30n }] } * ``` */ declare function utxoDiff(minuend: BoxSummary | Box[], subtrahend: BoxSummary | Box[], ignoreSubtrahendLeftoverTokens?: boolean): BoxSummary; /** * Checks if the given registers are densely packed. * @param registers * * @example * ``` * const registers = { * R4: "deadbeef", * R6: "cafe", * }; * const result = areRegistersDenselyPacked(registers); * console.log(result); * // false */ declare function areRegistersDenselyPacked(registers: NonMandatoryRegisters): boolean; /** * Filters the given utxos by the given filter parameters. * @param utxos * @param filterParams */ declare function utxoFilter(utxos: Box[], filterParams: UTxOFilterParams): Box[]; /** * Parameters for filtering unspent transaction outputs (UTxOs). */ type UTxOFilterParams = { /** * A function that returns a boolean indicating whether a given UTxO should be included in the filtered results. */ by?: (utxo: Box) => boolean; /** * An object specifying the maximum number of UTxOs and distinct tokens to include in the filtered results. */ max?: { /** * The maximum number of UTxOs to include in the filtered results. */ count?: number; /** * The maximum number of distinct tokens to include in the filtered results. */ aggregatedDistinctTokens?: number; }; }; type BoxSummary = { nanoErgs: bigint; tokens: TokenAmount[]; }; type BoxAmounts = { value: Amount; assets: TokenAmount[]; }; /** * Ensures that the value and asset amounts of a given box are represented as BigInts. * @returns A new box object with BigInt representation for the value and asset amounts. */ declare function ensureUTxOBigInt(box: Box): Box; declare function ensureUTxOBigInt(candidate: BoxCandidate): BoxCandidate; /** * Remove undefined values from an object * @param value * * @example * ``` * const obj = { a: 1, b: undefined }; * const result = clearUndefined(obj); * console.log(result); // { a: 1 } * ``` */ declare function clearUndefined(value: Record): Record; type EnsureDefaultsOptions = { keepUndefinedKeys: boolean; }; /** * Ensure that the options object has all the default values * @param partial * @param defaults * * @example * ``` * const options = { a: 1 }; * const defaults = { a: 2, b: 3 }; * const result = ensureDefaults(options, defaults); * console.log(result); // { a: 1, b: 3 } * ``` */ declare function ensureDefaults(partial: T | undefined, defaults: R, options?: EnsureDefaultsOptions): R & T; type ErrorMessage = string | Error | (() => string); type Constructable = Function; type JSPrimitive = "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"; declare function assert(condition: boolean, error: ErrorMessage): asserts condition; declare function assertTypeOf(obj: T, expected: JSPrimitive): asserts obj; declare function assertInstanceOf(obj: T, expected: Constructable): asserts obj; declare function isEmpty(target: T | null | undefined): target is undefined | null; declare function some(target: T | null | undefined): target is T; declare function isTruthy(value?: T): value is NonNullable; declare function isFalsy(value?: T): value is undefined; declare function isUndefined(v: unknown): v is undefined; declare function isDefined(v: T | undefined): v is T; declare function hasKey(o: unknown, key: PropertyKey): boolean; declare function concatBytes(...arrays: Uint8Array[]): Uint8Array; declare function isHex(value?: string): boolean; /** * Get hex string size in bytes * @param hex * @returns the byte size if the hex string */ declare function byteSizeOf(hex: string): number; type CollectionAddOptions = { index?: number; }; /** * Collection abstract model * * @example * Define a new collection class with internal type `number` and external type `string` * ``` * class TestCollection extends Collection { * protected _map(item: string | number): number { * return Number(item); * } * // Some other methods * } * ``` * */ declare abstract class Collection implements Iterable { protected readonly _items: InternalType[]; constructor(); protected _isIndexOutOfBounds(index: number): boolean; [Symbol.iterator](): Iterator; /** * Number of items in the collection */ get length(): number; /** * True if the collection is empty */ get isEmpty(): boolean; /** * Get item at index * @param index * @throws RangeError if index is out of bounds */ at(index: number): InternalType; /** * Add item to the collection * @param items * @param options * @returns The new length of the collection */ add(items: OneOrMore, options?: CollectionAddOptions): number; abstract remove(item: unknown): number; /** * Map external type to internal type * @param item * @protected */ protected abstract _map(item: ExternalType | InternalType): InternalType; protected _addOne(item: InternalType | ExternalType, options?: CollectionAddOptions): number; protected _addOneOrMore(items: OneOrMore, options?: CollectionAddOptions): number; /** * Get the collection as an array */ toArray(): InternalType[]; reduce(callbackFn: (accumulator: U, currentValue: InternalType, currentIndex: number, array: InternalType[]) => U, initialValue: U): U; } declare class FleetError extends Error { constructor(message?: string, options?: ErrorOptions); } declare class NotSupportedError extends FleetError { } declare class BlockchainProviderError extends FleetError { } declare const FEE_CONTRACT = "1005040004000e36100204a00b08cd0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798ea02d192a39a8cc7a701730073011001020402d19683030193a38cc7b2a57300000193c2b2a57301007473027303830108cdeeac93b1a57304"; declare const RECOMMENDED_MIN_FEE_VALUE: bigint; export { AddressType, type Amount, type Base58String, type Block, type BlockHeader, type BlockHeaderId, type BlockTransactions, BlockchainProviderError, type Box, type BoxAmounts, type BoxCandidate, type BoxId, type BoxSummary, Collection, type CollectionAddOptions, type ContextExtension, type DataInput, type EIP12UnsignedDataInput, type EIP12UnsignedInput, type EIP12UnsignedTransaction, type EnsureDefaultsOptions, type EnumConst, type ErgoTreeHeaderFlag, type ErgoTreeHex, type ErrorMessage, FEE_CONTRACT, type FilterPredicate, FleetError, type HexString, Network, type NewToken, type NonMandatoryRegisters, NotSupportedError, type OneOrMore, type PlainObjectType, type PoWSolution, type ProverResult, RECOMMENDED_MIN_FEE_VALUE, type SignedInput, type SignedTransaction, type SortingDirection, type SortingSelector, type TokenAmount, type TokenId, type TokenTargetAmount, type TransactionId, type UTxOFilterParams, type UnsignedInput, type UnsignedTransaction, _0n, _10n, _127n, _128n, _1n, _2n, _63n, _7n, areEqual, areEqualBy, areRegistersDenselyPacked, assert, assertInstanceOf, assertTypeOf, at, byteSizeOf, chunk, clearUndefined, concatBytes, decimalize, depthOf, endsWith, ensureBigInt, ensureDefaults, ensureUTxOBigInt, ergoTreeHeaderFlags, first, hasDuplicates, hasDuplicatesBy, hasKey, isDefined, isEmpty, isFalsy, isHex, isTruthy, isUndefined, last, max, min, orderBy, percent, some, startsWith, sumBy, undecimalize, uniq, uniqBy, utxoDiff, utxoFilter, utxoSum };