import { Box, TokenTargetAmount, FilterPredicate, OneOrMore, BoxId, SortingSelector, SortingDirection, Amount, BoxCandidate, Network, HexString, AddressType, Base58String, NonMandatoryRegisters, TokenAmount, DataInput, PlainObjectType, ContextExtension, EIP12UnsignedInput, UnsignedInput, EIP12UnsignedDataInput, EIP12UnsignedTransaction, UnsignedTransaction, BoxSummary, Collection, TokenId, CollectionAddOptions, NewToken, ErgoTreeHex } from '@fleet-sdk/common'; export { AddressType, Amount, Box, FEE_CONTRACT, Network, RECOMMENDED_MIN_FEE_VALUE, TokenAmount } from '@fleet-sdk/common'; import { SConstant as SConstant$1, SigmaByteWriter } from '@fleet-sdk/serializer'; export { SBigInt, SBool, SByte, SColl, SCollType, SGroupElement, SInt, SLong, SShort, SSigmaProp, SType, SUnit } from '@fleet-sdk/serializer'; import { ByteInput } from '@fleet-sdk/crypto'; interface ISelectionStrategy { select(inputs: Box[], target?: SelectionTarget): Box[]; } type SelectorFunction = (inputs: Box[], target?: SelectionTarget) => Box[]; /** * Custom selection strategy supports custom selections implementations. */ declare class CustomSelectionStrategy implements ISelectionStrategy { private readonly _selector; constructor(selector: SelectorFunction); select(inputs: Box[], target?: SelectionTarget): Box[]; } type SelectionTarget = { nanoErgs?: bigint; tokens?: TokenTargetAmount[]; }; declare class BoxSelector> { private readonly _inputs; private _strategy?; private _ensureFilterPredicate?; private _selector?; private _sortDirection?; private _ensureInclusionBoxIds?; constructor(inputs: T[]); defineStrategy(strategy: ISelectionStrategy | SelectorFunction): BoxSelector; select(target: SelectionTarget): T[]; private _deepCloneTarget; private _getUnreachedTargets; ensureInclusion(predicate: FilterPredicate>): BoxSelector; ensureInclusion(boxIds: OneOrMore): BoxSelector; ensureInclusion(filter: "all"): BoxSelector; orderBy(selector: SortingSelector>, direction?: SortingDirection): BoxSelector; private _isISelectionStrategyImplementation; static buildTargetFrom(boxes: Box[] | BoxCandidate[]): SelectionTarget; } /** * Accumulative selection strategy accumulates inputs until the target amounts * value is reached, skipping detrimental inputs. */ declare class AccumulativeSelectionStrategy implements ISelectionStrategy { private _inputs; select(inputs: Box[], target: SelectionTarget): Box[]; private _selectTokens; private _select; } /** * The Cherry Pick strategy accumulates inputs until the target amounts trying * to pick inputs with as less as possible unused tokens. */ declare class CherryPickSelectionStrategy extends AccumulativeSelectionStrategy { select(inputs: Box[], target: SelectionTarget): Box[]; } /** * Ergo address model * * @example * Convert address to ErgoTree hex string * ``` * const address = new Address("9eZ24iqjKywjzAti9RnWWTR3CiNnLJDAcd2MenKodcAfzc8AFTu"); * console.log(address.ergoTree); * ``` * * @example * Convert ErgoTree hex string to address string * ``` * const ergoTree = "0008cd026dc059d64a50d0dbf07755c2c4a4e557e3df8afa7141868b3ab200643d437ee7" * const address = Address.fromErgoTree(ergoTree).toString(); * ``` */ declare class ErgoAddress { #private; get network(): Network; /** * ErgoTree hex string */ get ergoTree(): HexString; get type(): AddressType; /** * New instance from ErgoTree bytes * @param ergoTree ErgoTree bytes */ constructor(ergoTree: Uint8Array, network?: Network); /** * Create a new instance from an ErgoTree * @param ergoTree ErgoTree hex string */ static fromErgoTree(ergoTree: ByteInput, network?: Network): ErgoAddress; /** * Create a new instance from a public key * @param publicKey Public key hex string */ static fromPublicKey(publicKey: ByteInput, network?: Network): ErgoAddress; static fromHash(hash: HexString | Uint8Array, network?: Network): ErgoAddress; /** * Create a new checked instance from an address string * @param encodedAddress Address encoded as base58 */ static decode(encodedAddress: Base58String): ErgoAddress; static decodeUnsafe(encodedAddress: Base58String): ErgoAddress; static fromBase58(address: Base58String, unsafe?: boolean): ErgoAddress; /** * Validate an address * @param address Address bytes or string * @deprecated Use `validateAddress()` function instead */ static validate(address: Base58String): boolean; static getNetworkType(address: Base58String): Network; static getAddressType(address: Base58String): AddressType; getPublicKeys(): Uint8Array[]; toP2SH(network?: Network): Base58String; /** * Encode address as base58 string */ encode(network?: Network): Base58String; /** * Encode address as base58 string */ toString(network?: Network): Base58String; } declare class ErgoBoxCandidate { value: bigint; ergoTree: string; creationHeight: number; assets: TokenAmount[]; additionalRegisters: R; flags?: TransactionOutputFlags; constructor(candidate: BoxCandidate, flags?: TransactionOutputFlags); toBox(transactionId: string, index: number): ErgoBox; toPlainObject(): BoxCandidate; } declare class ErgoBox { #private; get value(): bigint; get ergoTree(): string; get creationHeight(): number; get assets(): TokenAmount[]; get additionalRegisters(): R; get boxId(): string; get transactionId(): string; get index(): number; get change(): boolean; constructor(candidate: ErgoBoxCandidate, transactionId: string, index: number); constructor(candidate: BoxCandidate, transactionId: string, index: number); constructor(box: Box); constructor(box: ErgoBox); toPlainObject(type: "minimal"): DataInput; toPlainObject(type: "EIP-12"): Box; toPlainObject(type: PlainObjectType): Box | DataInput; toCandidate(): ErgoBoxCandidate; isValid(): boolean; static validate(box: Box | ErgoBox): boolean; } type InputBox = Box & { extension?: ContextExtension; }; type ContextExtensionInput = ContextExtension; declare class ErgoUnsignedInput extends ErgoBox { #private; get extension(): ContextExtension; constructor(box: InputBox); setContextExtension(extension: ContextExtensionInput): ErgoUnsignedInput; /** * @deprecated use `setContextExtension` instead. */ setContextVars(extension: ContextExtensionInput): ErgoUnsignedInput; toPlainObject(type: "EIP-12"): EIP12UnsignedInput; toPlainObject(type: "minimal"): UnsignedInput; toPlainObject(type: PlainObjectType): EIP12UnsignedInput | UnsignedInput; toDataInputPlainObject(type: "EIP-12"): EIP12UnsignedDataInput; toDataInputPlainObject(type: "minimal"): DataInput; toDataInputPlainObject(type: PlainObjectType): EIP12UnsignedDataInput | DataInput; } declare class ErgoUnsignedTransactionChain { #private; constructor(entryPoint: ErgoUnsignedTransaction); first(): ErgoUnsignedTransaction; toArray(): ErgoUnsignedTransaction[]; toEIP12Object(): EIP12UnsignedTransaction[]; toPlainObject(): UnsignedTransaction[]; } type TransactionType = T extends "default" ? UnsignedTransaction : EIP12UnsignedTransaction; type ChainCallback = (child: TransactionBuilder, parent: ErgoUnsignedTransaction) => TransactionBuilder | ErgoUnsignedTransaction | ErgoUnsignedTransactionChain; declare class ErgoUnsignedTransaction { #private; constructor(inputs: ErgoUnsignedInput[], dataInputs: ErgoUnsignedInput[], outputs: ErgoBoxCandidate[], builder?: TransactionBuilder); get id(): string; get inputs(): ErgoUnsignedInput[]; get dataInputs(): ErgoUnsignedInput[]; get outputs(): ErgoBox[]; get change(): ErgoBox[]; get burning(): BoxSummary; get child(): ErgoUnsignedTransaction | undefined; chain(callback: ChainCallback): ErgoUnsignedTransactionChain; toPlainObject(): UnsignedTransaction; toPlainObject(type: T): TransactionType; toEIP12Object(): EIP12UnsignedTransaction; toBytes(): Uint8Array; } declare const MAX_TOKENS_PER_BOX = 100; type TokenAddOptions = CollectionAddOptions & { sum?: boolean; }; type OutputToken = { tokenId?: TokenId; amount: T; }; declare class TokensCollection extends Collection, OutputToken> { #private; constructor(); constructor(token: TokenAmount); constructor(tokens: TokenAmount[]); constructor(tokens: TokenAmount[], options: TokenAddOptions); get minting(): NewToken | undefined; protected _map(token: OutputToken): OutputToken; protected _addOne(token: OutputToken, options?: TokenAddOptions): number; add(items: OneOrMore>, options?: TokenAddOptions): number; mint(token: NewToken): number; private _sum; remove(tokenId: TokenId, amount?: Amount): number; remove(index: number, amount?: Amount): number; contains(tokenId: string): boolean; toArray(): TokenAmount[]; toArray(mintingTokenId: string): TokenAmount[]; toArray(mintingTokenId?: string): TokenAmount[]; } declare class InputsCollection extends Collection> { constructor(); constructor(box: Box); constructor(boxes: Box[]); protected _map(input: Box | ErgoUnsignedInput): ErgoUnsignedInput; protected _addOne(box: Box): number; remove(boxId: BoxId): number; remove(index: number): number; } declare class OutputsCollection extends Collection { constructor(outputs?: OneOrMore); protected _map(output: OutputBuilder): OutputBuilder; remove(output: OutputBuilder): number; remove(index: number): number; clone(): OutputsCollection; sum(basis?: SelectionTarget | BoxSummary): BoxSummary; } declare class ErgoTree { #private; constructor(input: ByteInput, network?: Network); static from(input: JsonCompilerOutput, network?: Network): ErgoTree; get bytes(): Uint8Array; get header(): number; get version(): number; get hasSegregatedConstants(): boolean; get hasSize(): boolean; get constants(): ReadonlyArray; get template(): Readonly; replaceConstant(index: number | string, constant: SConstant$1): ErgoTree; toHex(): HexString; toAddress(network?: Network): ErgoAddress; encode(network?: Network): Base58String; serialize(): Uint8Array; } interface ConstantInfo { value: string; type: string; name?: string; description?: string; } interface JsonCompilerOutput { header: string; expressionTree: string; constants?: ConstantInfo[]; } /** Matches a JSON object. This type can be useful to enforce some input to be JSON-compatible or as a super-type to be extended from. Don't use this as a direct return type as the user would have to double-cast it: `jsonObject as unknown as CustomResponse`. Instead, you could extend your CustomResponse type from it to ensure your type only uses JSON-compatible types: `interface CustomResponse extends JsonObject { … }`. @category JSON */ type JsonObject = {[Key in string]: JsonValue} & {[Key in string]?: JsonValue | undefined}; /** Matches a JSON array. @category JSON */ type JsonArray = JsonValue[] | readonly JsonValue[]; /** Matches any valid JSON primitive value. @category JSON */ type JsonPrimitive = string | number | boolean | null; /** Matches any valid JSON value. @see `Jsonify` if you need to transform a type to one that is assignable to `JsonValue`. @category JSON */ type JsonValue = JsonPrimitive | JsonObject | JsonArray; declare global { // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged. interface SymbolConstructor { readonly observable: symbol; } } type NetworkOptions = { network?: Network; }; type ErgoMessageFromHashOptions = NetworkOptions & { hash: ByteInput; }; type MessageData = Uint8Array | JsonValue | JsonObject; type ErgoMessageFromDataOptions = NetworkOptions & { data: MessageData; }; type ErgoMessageOptions = ErgoMessageFromHashOptions | ErgoMessageFromDataOptions; declare const MessageType: { readonly Hash: 0; readonly Binary: 1; readonly String: 2; readonly Json: 3; }; type MessageType = (typeof MessageType)[keyof typeof MessageType]; declare class ErgoMessage { #private; constructor(options: ErgoMessageOptions); get hash(): Uint8Array; get type(): MessageType; get network(): Network; static decode(encodedHash: Base58String): ErgoMessage; static fromBase58(encodedHash: Base58String): ErgoMessage; static fromData(data: MessageData, network?: Network): ErgoMessage; encode(network?: Network): string; toString(network?: Network): string; setNetwork(network: Network): ErgoMessage; getData(): T | undefined; serialize(): SigmaByteWriter; verify(message: MessageData): boolean; } /** * Validates a Base58 encoded address. * * @param encodedAddress - The Base58 encoded address to validate. * @returns A boolean indicating whether the address is valid or not. */ declare function validateAddress(encodedAddress: Base58String): boolean; declare const BOX_VALUE_PER_BYTE: bigint; declare const SAFE_MIN_BOX_VALUE: bigint; type BoxValueEstimationCallback = (outputBuilder: OutputBuilder) => bigint; type TransactionOutputFlags = { change: boolean; }; declare function estimateMinBoxValue(valuePerByte?: bigint): BoxValueEstimationCallback; declare class OutputBuilder { #private; constructor(value: Amount | BoxValueEstimationCallback, recipient: ErgoAddress | ErgoTree | string, creationHeight?: number); get value(): bigint; get address(): ErgoAddress; get ergoTree(): ErgoTreeHex; get creationHeight(): number | undefined; get assets(): TokensCollection; get additionalRegisters(): NonMandatoryRegisters; get minting(): NewToken | undefined; get flags(): TransactionOutputFlags; static from(box: Box | ErgoBoxCandidate | ErgoBox | ErgoUnsignedInput): OutputBuilder; setValue(value: Amount | BoxValueEstimationCallback): OutputBuilder; setFlags(flags: Partial): OutputBuilder; addTokens(tokens: OneOrMore> | TokensCollection, options?: TokenAddOptions): OutputBuilder; addNfts(...tokenIds: TokenId[]): OutputBuilder; mintToken(token: NewToken): OutputBuilder; setCreationHeight(height: number, options?: { replace: boolean; }): OutputBuilder; setAdditionalRegisters(registers: NonMandatoryRegisters): OutputBuilder; eject(ejector: (context: { tokens: TokensCollection; }) => void): OutputBuilder; build(transactionInputs?: UnsignedInput[] | Box[]): ErgoBoxCandidate; estimateSize(value?: bigint): number; } type ConstantInput = SConstant$1 | HexString; type OnlyR4Register = { R4: T; } & NonMandatoryRegisters; type R4ToR5Registers = { R4: T; R5: T; } & NonMandatoryRegisters; type R4ToR6Registers = { R4: T; R5: T; R6: T; } & NonMandatoryRegisters; type R4ToR7Registers = { R4: T; R5: T; R6: T; R7: T; } & NonMandatoryRegisters; type R4ToR8Registers = { R4: T; R5: T; R6: T; R7: T; R8: T; } & NonMandatoryRegisters; type R4ToR9Registers = { R4: T; R5: T; R6: T; R7: T; R8: T; R9: T; } & NonMandatoryRegisters; type FleetPluginContext = { /** * Add and ensures selection of one or more inputs to the inputs list * @param inputs * @returns new list length */ addInputs: (inputs: OneOrMore>) => number; /** * Add one or more data inputs to the data inputs list * @param dataInputs * @returns new list length */ addDataInputs: (dataInputs: OneOrMore>, options?: CollectionAddOptions) => number; /** * Add one or more outputs to the outputs list * @param outputs * @param options * @returns new list length */ addOutputs: (outputs: OneOrMore, options?: CollectionAddOptions) => number; /** * Burn tokens * @param tokens * @throws Burning tokens thought a plugin, requires explicitly permission * from {@link TransactionBuilder.configure}, if token burning is not allowed * it will thrown a {@link NotAllowedTokenBurning} exception. */ burnTokens: (tokens: OneOrMore>) => void; /** * Set transaction fee amount * @param amount amount in nanoergs */ setFee: (amount: Amount) => void; }; declare class TransactionBuilderSettings { private _maxDistinctTokensPerChangeBox; private _allowTokenBurning; private _allowTokenBurningFromPlugins; private _isolateErgOnChange; constructor(); get maxTokensPerChangeBox(): number; get canBurnTokens(): boolean; get canBurnTokensFromPlugins(): boolean; get shouldIsolateErgOnChange(): boolean; /** * Define max number of distinct tokens per change box */ setMaxTokensPerChangeBox(max: number): TransactionBuilderSettings; /** * Allows or denies token burning from all contexts */ allowTokenBurning(allow?: boolean): TransactionBuilderSettings; /** * Allows or denies token burning **only** from plugins context. */ allowTokenBurningFromPlugins(allow?: boolean): TransactionBuilderSettings; /** * If true, it creates an exclusive change box only for ERG. * This setting is especially useful for Ledger devices to * help on avoiding to hit the max tokens limit per transaction. */ isolateErgOnChange(isolate?: boolean): TransactionBuilderSettings; } type SelectorSettings = Omit>, "select">; type ConfigureCallback = (settings: TransactionBuilderSettings) => void; type SelectorCallback = (selector: SelectorSettings) => void; type FleetPlugin = (context: FleetPluginContext) => void; type CollectionLike = { toArray(): T[]; }; type EjectorContext = { inputs: InputsCollection; dataInputs: InputsCollection; outputs: OutputsCollection; burning: TokensCollection | undefined; settings: TransactionBuilderSettings; selection: (selectorCallBack: SelectorCallback) => void; }; /** * Options for including inputs in the transaction builder */ type InputsInclusionOptions = { /** * If true, all the inputs will be included in the * transaction while preserving the original order. */ ensureInclusion?: boolean; }; declare class TransactionBuilder { #private; constructor(creationHeight: number); get inputs(): InputsCollection; get dataInputs(): InputsCollection; get outputs(): OutputsCollection; get changeAddress(): ErgoAddress | undefined; get fee(): bigint | undefined; get burning(): TokensCollection | undefined; get settings(): TransactionBuilderSettings; get creationHeight(): number; /** * Syntax sugar to be used in composition with another methods * * @example * ``` * new TransactionBuilder(height) * .from(inputs) * .and.from(otherInputs); * ``` */ get and(): TransactionBuilder; atHeight(height: number): TransactionBuilder; from(inputs: OneOrMore> | CollectionLike>, options?: InputsInclusionOptions): TransactionBuilder; to(outputs: OneOrMore, options?: CollectionAddOptions): TransactionBuilder; withDataFrom(dataInputs: OneOrMore>, options?: CollectionAddOptions): TransactionBuilder; sendChangeTo(address: ErgoAddress | Base58String | HexString): TransactionBuilder; payFee(amount: Amount): TransactionBuilder; payMinFee(): TransactionBuilder; burnTokens(tokens: OneOrMore>): TransactionBuilder; configure(callback: ConfigureCallback): TransactionBuilder; configureSelector(selectorCallback: SelectorCallback): TransactionBuilder; extend(plugins: FleetPlugin): TransactionBuilder; eject(ejector: (context: EjectorContext) => void): TransactionBuilder; build(): ErgoUnsignedTransaction; } declare class DuplicateInputError extends Error { constructor(boxId: string); } declare class DuplicateInputSelectionError extends Error { constructor(); } declare class InsufficientInputs extends Error { readonly unreached: SelectionTarget; constructor(unreached: SelectionTarget); } declare class InsufficientTokenAmount extends Error { } declare class InvalidAddress extends Error { constructor(address: string); } declare class InvalidInput extends Error { constructor(boxId: string); } declare class InvalidRegistersPacking extends Error { constructor(); } declare class MalformedTransaction extends Error { constructor(message: string); } declare class MaxTokensOverflow extends Error { constructor(); } declare class NotAllowedTokenBurning extends Error { constructor(); } declare class NotFoundError extends Error { } declare class UndefinedCreationHeight extends Error { constructor(); } declare class UndefinedMintingContext extends Error { constructor(); } /** * @deprecated Use {@link @fleet-sdk/serializer} instead. * This function will be removed from core package in v1.0.0. */ declare function SConstant(constant: SConstant$1): HexString; /** * @deprecated Use {@link @fleet-sdk/serializer} instead. * This function will be removed from core package in v1.0.0. */ declare function SParse(bytes: HexString | Uint8Array): T; export { AccumulativeSelectionStrategy, BOX_VALUE_PER_BYTE, BoxSelector, type BoxValueEstimationCallback, type ChainCallback, CherryPickSelectionStrategy, type CollectionLike, type ConfigureCallback, type ConstantInfo, type ConstantInput, CustomSelectionStrategy, DuplicateInputError, DuplicateInputSelectionError, ErgoAddress, ErgoBox, ErgoMessage, type ErgoMessageFromDataOptions, type ErgoMessageFromHashOptions, type ErgoMessageOptions, ErgoTree, ErgoUnsignedInput, ErgoUnsignedTransaction, type FleetPlugin, InputsCollection, InsufficientInputs, InsufficientTokenAmount, InvalidAddress, InvalidInput, InvalidRegistersPacking, type JsonCompilerOutput, MAX_TOKENS_PER_BOX, MalformedTransaction, MaxTokensOverflow, type MessageData, MessageType, type NetworkOptions, NotAllowedTokenBurning, NotFoundError, type OnlyR4Register, OutputBuilder, type OutputToken, OutputsCollection, type R4ToR5Registers, type R4ToR6Registers, type R4ToR7Registers, type R4ToR8Registers, type R4ToR9Registers, SAFE_MIN_BOX_VALUE, SConstant, SParse, type SelectorCallback, type TokenAddOptions, TokensCollection, TransactionBuilder, type TransactionOutputFlags, UndefinedCreationHeight, UndefinedMintingContext, estimateMinBoxValue, validateAddress };