import { AccountTransaction, AccountTransactionHeader, AccountTransactionInput, AccountTransactionType, ConfigureBakerPayload, ConfigureDelegationPayload, DeployModulePayload, InitContractPayload, MakeOptional, MakeRequired, RegisterDataPayload, SimpleTransferPayload, SimpleTransferWithMemoPayload, TokenUpdatePayload, UpdateContractPayload, UpdateCredentialsPayload } from '../../index.js'; import { AccountAddress, DataBlob, Energy } from '../../types/index.js'; import { Payload } from '../index.js'; import { Header, HeaderJSON } from './shared.js'; import { type Signable, SignableJSON, SignableV0, SignableV1 } from './signable.js'; type Transaction

= { /** * The transaction input header. */ readonly header: Header; /** * The transaction payload, defining the transaction type and type specific data. */ readonly payload: P; }; export type Type

= Transaction

; export type BuilderJSON = { header: HeaderJSON; payload: Payload.JSON; }; export type JSON = BuilderJSON | SignableJSON; /** * Base metadata input with optional expiry field. */ export type Metadata = MakeOptional; type Initial

= BuilderAPI

& { /** * The transaction input header of the initial transaction stage, i.e. without metadata. */ readonly header: Pick; }; type ConfiguredAPI

= { /** * Adds metadata (sender, nonce, expiry) to the transaction, making it configured and ready to be signed. * * @template T - the transaction builder type * @param metadata - transaction metadata including sender, nonce, and optionally expiry * * @returns a signable transaction with metadata attached * @throws if transaction metadata already exists. */ addMetadata>(this: T, metadata: Metadata): Configured; /** * Attempts to convert a builder to a _configured_ builder. This is useful in case type information is lost * during (de)serialization. * * @example * const tx = Transaction.transfer(...).addMetadata(...); * const json = Transaction.fromJSON(Transaction.toJSON(t)); * const rebuilt = builder(json).configured(); * * @template T - the transaction builder type * @returns a _configured transaction builder if the transaction is properly configured to be buildable. Otherwise * returns `undefined`. */ configured>(this: T): Configured | undefined; }; type Configured

= Transaction

> = Omit | 'header'> & { /** * The transaction input header of the pre-signed transaction stage, i.e. with metadata. */ readonly header: MakeRequired; }; /** * Type predicate checking if the transaction is a _configured_ transaction. * * @template P extends Payload.Type * @param transaction - the transaction to check * @returns whether the transaction is a _configured_ transaction */ export declare function isConfigured

(transaction: Transaction

): transaction is Configured

; type MultiSigAPI

= { /** * Configures the transaction for multi-signature by specifying the number of signatures required. * * @template T - the transaction builder type * @param numSignaturesSender - the number of signatures required from the `sender` to authorize this transaction * * @returns a multi-sig transaction with the signature count configured * @throws if number of sender signatures have already been added. */ addMultiSig>(this: T, numSignaturesSender: number | bigint): MultiSig; /** * Attempts to convert a builder to a multi-sig configured builder. This is useful in case type information is lost * during (de)serialization. * * @example * const tx = Transaction.transfer(...).addMultiSig(4); * const json = Transaction.fromJSON(Transaction.toJSON(t)); * const rebuilt = builder(json).multiSig(); * * @template T - the transaction builder type * @returns a multi-sig transaction builder if the transaction is properly configured for multi-sig. Otherwise * returns `undefined`. */ multiSig>(this: T): MultiSig | undefined; }; type MultiSig

= Transaction

> = Omit | 'header'> & { /** * The transaction input header of the multi-sig transaction stage, i.e. with the number of signatures * defined. */ readonly header: MakeRequired; }; /** * Type predicate checking if the transaction is a _signable_ transaction. * * @template P extends Payload.Type * @param transaction - the transaction to check * @returns whether the transaction is a _signable transaction */ export declare function isMultiSig

(transaction: Transaction

): transaction is MultiSig

; type SponsorableAPI

= { /** * Configures the transaction for sponsorring by specifying the sponsor account. * NOTE: this can be used from protocol version 10. * * @template T - the transaction builder type * @param account - the sponsor account to use for sponsorring the transaction. * @param [numSignaturesSponsor] - the number of signatures required to authorize this transaction. Defaults to `1` for if not specified. * * @returns a sponsorable transaction * @throws if sponsor details already exits. */ addSponsor>(this: T, account: AccountAddress.Type, numSignaturesSponsor?: number | bigint): Sponsorable; /** * Attempts to convert a builder to a multi-sig configured builder. This is useful in case type information is lost * during (de)serialization. * * @example * const tx = Transaction.transfer(...).addMultiSig(4); * const json = Transaction.fromJSON(Transaction.toJSON(t)); * const rebuilt = builder(json).multiSig(); * * @template T - the transaction builder type * @returns a multi-sig transaction builder if the transaction is properly configured for multi-sig. Otherwise * returns `undefined`. */ sponsorable>(this: T): Sponsorable | undefined; }; type Sponsorable

= Transaction

> = Omit | keyof MultiSigAPI

| 'header'> & { /** * The transaction input header of the sponsorable transaction stage, i.e. with the sponsor details and * the number of signatures defined. */ readonly header: MakeRequired; }; /** * Describes an account transaction in its unprocessed form, i.e. defining the input required * to create a transaction which can be signed */ type BuilderAPI

= Readonly> & ConfiguredAPI

& MultiSigAPI

& SponsorableAPI

& { /** * Build the transaction to it's pre-finalized stage. */ build(this: Sponsorable

& Configured

): SignableV1

; build(this: Configured

): Signable

; /** * Serializes the transaction to JSON format. * * @returns the JSON representation of the transaction */ toJSON(): BuilderJSON; }; /** * Type predicate checking if the transaction is a _signable_ transaction. * * @template P extends Payload.Type * @param transaction - the transaction to check * @returns whether the transaction is a _signable transaction */ export declare function isSponsorable

(transaction: Transaction

): transaction is Sponsorable

; /** * Describes an account transaction in its unprocessed form, i.e. defining the input required * to create a transaction which can be signed */ export declare class Builder

implements BuilderAPI

{ readonly header: Header; readonly payload: P; constructor(header: Header, payload: P); addMetadata>(this: T, { sender, nonce, expiry }: Metadata): Configured; configured>(this: T): Configured | undefined; addMultiSig>(this: T, numSignaturesSender: number | bigint): MultiSig; multiSig>(this: T): MultiSig | undefined; addSponsor>(this: T, account: AccountAddress.Type, numSignaturesSponsor?: number | bigint): Sponsorable; sponsorable>(this: T): Sponsorable | undefined; /** * Build the transaction to it's pre-finalized stage. */ build(this: Sponsorable

& Configured

): SignableV1

; build(this: Configured

): SignableV0

; /** * Serializes the transaction to JSON format. * * @returns the JSON representation of the transaction */ toJSON(): BuilderJSON; } /** * Dynamic `Transaction` creation based on the given transaction `type`. * * NOTE: this does _not_ check the payload structure, and thus assumes that the `type` and `payload` * given actually match. If the transaction type is known, use the specialized creation functions * per transaction type instead. * * @param type - transaction type * @param payload - a transaction payload matching the transaction type. * * @returns The corresponding transaction * * @throws if transaction type is not currently supported. * @throws if transaction cannot be created due to mismatch between `type` and `payload`. */ export declare function create(type: AccountTransactionType, payload: AccountTransactionInput): Initial; /** * Crates a {@linkcode Transaction} builder object from the legacy `AccountTransaction` format. * * @param transaction - The {@linkcode AccountTransaction} to convert. * @returns a corresonding transaction builder object. */ export declare function fromLegacyAccountTransaction({ type, header, payload }: AccountTransaction): Configured; /** * Converts a {@linkcode Transaction} to the legacy format. * * @param transaction - the transaction details to convert * @returns the legacy {@linkcode AccountTransaction} format */ export declare function toLegacyAccountTransaction(transaction: Transaction): AccountTransaction; /** * Creates a transfer transaction with memo * @param payload the transfer payload containing recipient and amount and memo * @returns a transfer with memo transaction */ export declare function transfer(payload: SimpleTransferWithMemoPayload | Payload.TransferWithMemo): Initial; /** * Creates a transfer transaction with a memo. * @param payload the transfer payload containing recipient and amount * @param memo the transfer memo to include * @returns a transfer with memo transaction */ export declare function transfer(payload: SimpleTransferPayload, memo: DataBlob): Initial; /** * Creates a transfer transaction * @param payload the transfer payload containing recipient and amount * @returns a transfer transaction */ export declare function transfer(payload: SimpleTransferPayload | Payload.Transfer): Initial; /** * Creates a transaction to update account credentials. * @param payload the credentials update payload * @returns an update credentials transaction */ export declare function updateCredentials(payload: UpdateCredentialsPayload | Payload.UpdateCredentials, currentNumberOfCredentials: bigint): Initial; /** * Creates a transaction to configure a validator (baker). * @param metadata transaction metadata including sender, nonce, and optional expiry (defaults to 5 minutes) * @param payload the validator configuration payload * @returns a configure baker transaction */ export declare function configureValidator(payload: ConfigureBakerPayload | Payload.ConfigureValidator): Initial; /** * Creates a transaction to configure account delegation. * @param metadata transaction metadata including sender, nonce, and optional expiry (defaults to 5 minutes) * @param payload the delegation configuration payload * @returns a configure delegation transaction */ export declare function configureDelegation(payload: ConfigureDelegationPayload | Payload.ConfigureDelegation): Initial; /** * Creates a transaction to update token parameters on chain. * @param payload the token update payload * @returns a token update transaction */ export declare function tokenUpdate(payload: TokenUpdatePayload | Payload.TokenUpdate): Initial; /** * Creates a transaction to deploy a smart contract module. * @param metadata transaction metadata including sender, nonce, and optional expiry (defaults to 5 minutes) * @param payload the module deployment payload containing the wasm module * @returns a deploy module transaction */ export declare function deployModule(payload: DeployModulePayload | Payload.DeployModule): Initial; /** * Creates a transaction to register arbitrary data on chain. * @param payload the data registration payload * @returns a register data transaction */ export declare function registerData(payload: RegisterDataPayload | Payload.RegisterData): Initial; /** * Creates a transaction to initialize a smart contract instance. * @param payload the contract initialization payload with specified execution energy limit * @param maxContractExecutionEnergy the maximum amount of energy to spend on initializing the contract instance * * @returns an init contract transaction */ export declare function initContract(payload: InitContractPayload | Payload.InitContract, maxContractExecutionEnergy: Energy.Type): Initial; /** * Creates a transaction to invoke an existing smart contract. * @param payload the contract update payload specifying the contract and receive function with specified execution energy limit * @param maxContractExecutionEnergy the maximum amount of energy to spend on updating the contract instance * * @returns an update contract transaction */ export declare function updateContract(payload: UpdateContractPayload | Payload.UpdateContract, maxContractExecutionEnergy: Energy.Type): Initial; /** * Calculates the total energy cost for a transaction including signature and size costs. * @param header the transaction header with execution energy and number of signatures. If the number of signatures is * `undefined`, it defaults to `1`. * @param payload the transaction payload * * @returns the total energy cost */ export declare function getEnergyCost({ header: { numSignatures, executionEnergyAmount, sponsor }, payload, }: Transaction): Energy.Type; export declare function builderFromJSON(json: unknown): BuilderAPI; /** * Converts a transaction to its intermediary JSON serializable representation. * * @param header the transaction header * @param payload the transaction payload * @returns the JSON representation */ export declare function toJSON(transaction: BuilderAPI): BuilderJSON; export declare function toJSON(transaction: Signable): SignableJSON; export declare function toJSON(transaction: Transaction): SignableJSON; /** * Converts a {@linkcode Transaction} to a JSON string. * * @param transaction - the transaction to convert * @returns the JSON string */ export declare function toJSONString(transaction: Transaction): string; /** * Converts a JSON string transaction representation to a {@linkcode Transaction}. * * @param jsonString - the json string to convert * @param fromJSON - a function to convert the intermediary value parsed. * * @returns the parsed transaction * * @example * const builder = Transaction.fromJSONString(jsonString, Transaction.builderFromJSON); */ export declare function fromJSONString(jsonString: string, fromJSON: (json: unknown) => R): R; export {};