import { Cursor } from '../deserializationHelpers.js'; import { AccountSigner } from '../signHelpers.js'; import { type AccountInfo, type AccountTransactionSignature } from '../types.js'; import { AccountAddress, Energy } from '../types/index.js'; import { AccountTransactionV0, Payload } from './index.js'; type HeaderOptionals = { /** * An optional sponsor account for the transaction, which will pay for the transaction fee * associated with the transaction execution. */ sponsor?: AccountAddress.Type; }; /** * Describes the V1 account transaction header, which is an extension of {@linkcode AccountTransactionV0}s header * defining extra optional fields. */ export type Header = AccountTransactionV0.Header & HeaderOptionals; /** * The signatures for {@linkcode AccountTransactionV1}. */ export type Signatures = { /** * The signatures on the transaction for the sender credential(s) */ sender: AccountTransactionSignature; /** * The (optional) signatures on the transaction for the sponsor credential(s). These * _must_ be specified if the `sponsor` field on {@linkcode Header} is set. */ sponsor?: AccountTransactionSignature; }; /** * Describes the V1 account transaction format, which compared to the original account transaction format * is an extensible format defining extra optional transaction header fields. * * NOTE: this transaction format is supported from protocol version 10. */ type AccountTransactionV1 = { /** * Transaction version discriminant; */ readonly version: 1; /** * The signatures for V1 account transactions */ readonly signatures: Signatures; /** * The transaction header for the transaction which includes metadata required for execution * of any account transaction of the v1 format. */ readonly header: Header; /** * The transaction payload. */ readonly payload: Payload.Type; }; /** * Describes the V1 account transaction format, which compared to the original account transaction format * is an extensible format defining extra optional transaction header fields. */ export type Type = AccountTransactionV1; /** * Serializes the V1 account transaction header, including any optional fields. * * @param header - The V1 account transaction header to serialize, including base v0 fields and optional extensions (e.g., sponsor). * @returns The serialized header as a Uint8Array, consisting of the bitmap, v0 header, and optional field extensions. */ export declare function serializeHeader({ sponsor, ...v0 }: Header): Uint8Array; /** * Serializes the signatures for a V1 account transaction, including sender and optional sponsor signatures. * * @param signatures - The sender and optional sponsor signatures to serialize. * @returns The serialized signatures as a Uint8Array. */ export declare function serializeSignatures(signatures: Signatures): Uint8Array; /** * Serializes a complete V1 account transaction, including both header and payload. * * @param transaction - The V1 account transaction to serialize. * @returns The fully serialized transaction as a Uint8Array. */ export declare function serialize(transaction: AccountTransactionV1): Uint8Array; /** * Deserializes a V1 account transaction header from a buffer or cursor. * * @param value - The buffer or cursor containing the serialized header data. * @returns The deserialized V1 transaction header, including base fields and optional extensions. * @throws {Error} If the invoked with a buffer which is not fully consumed during deserialization. */ export declare function deserializeHeader(value: Cursor | ArrayBuffer): Header; /** * Deserializes the signatures for a V1 account transaction from a buffer or cursor. * * @param value - The buffer or cursor containing the serialized signatures data. * @returns The deserialized sender and optional sponsor signatures. * @throws {Error} If the invoked with a buffer which is not fully consumed during deserialization. */ export declare function deserializeSignatures(value: Cursor | ArrayBuffer): Signatures; /** * Deserializes a complete V1 account transaction from a buffer or cursor. * * @param value - The buffer or cursor containing the serialized transaction data. * @returns An object containing the deserialized signatures and transaction. * @throws {Error} If the invoked with a buffer which is not fully consumed during deserialization. */ export declare function deserialize(value: Cursor | ArrayBuffer): AccountTransactionV1; /** * Serializes a version 1 account transaction as a block item for submission to the chain. * * @param transaction the transaction to serialize * @returns the serialized block item as a byte array with block item kind prefix */ export declare function serializeBlockItem(transaction: AccountTransactionV1): Uint8Array; type Configuration = { [p in keyof HeaderOptionals]: boolean; }; /** * The energy cost is assigned according to the formula: * A * signatureCount + B * size + C_t, where C_t is a transaction specific cost. * * The transaction specific cost can be found at https://github.com/Concordium/concordium-base/blob/main/haskell-src/Concordium/Cost.hs. * * @param signatureCount number of signatures for the transaction, including sponsor signatures * @param payload the transaction payload * @param transactionSpecificCost a transaction specific cost * * @returns the energy cost for the transaction, to be set in the transaction header */ export declare function calculateEnergyCost(signatureCount: bigint, payload: Payload.Type, transactionSpecificCost: Energy.Type, configuration: Configuration): Energy.Type; /** * Gets the transaction hash that is used to look up the status of a transaction. * * @param transaction the transaction to hash * @returns the sha256 hash of the serialized block item kind, signatures, header and payload */ export declare function getAccountTransactionHash(transaction: AccountTransactionV1): Uint8Array; /** * An unsigned version 1 account transaction (without signatures). */ export type Unsigned = Omit; /** * Creates a v1 transaction from an unsigned transaction and the associated signature on the transaction. * * @param transaction the unsigned transaction * @param signature the signature on the transaction * * @returns a complete v1 transaction. */ export declare function create(unsigned: Unsigned, signatures: Signatures): AccountTransactionV1; /** * Returns the digest of the transaction that has to be signed. * * @param transaction the transaction to hash * @returns the sha256 hash on the serialized header and payload */ export declare function signDigest(transaction: Unsigned): Uint8Array; /** * Creates a signature on an unsigned version 1 account transaction using the provided signer. * * @param transaction the unsigned transaction to sign * @param signer the account signer to use for signing * * @returns a promise resolving to the signature */ export declare function createSignature(transaction: Unsigned, signer: AccountSigner): Promise; /** * Signs an unsigned version 1 account transaction using the provided signer. * * @param transaction the unsigned transaction to sign * @param signer the account signer to use for signing * * @returns a promise resolving to the signed transaction */ export declare function sign(transaction: Unsigned | AccountTransactionV1, signer: AccountSigner): Promise; /** * Verify an account signature on a transaction. * * @param transaction the transaction to verify the signature for. * @param signature the signature on the transaction, from a specific account. * @param accountInfo the address and credentials of the account. * * @returns whether the signature is valid. */ export declare function verifySignature(transaction: Unsigned, signature: AccountTransactionSignature, accountInfo: Pick): Promise; export {};