import { type Address, type Hex } from "viem"; import type { Metadata } from "../types/index.js"; /** * Adds metadata to a transaction object by concatenating additional * hex-encoded data to the transaction's `data` field. The additional * data may include a timestamp and an origin identifier derived * from the metadata. * * The function ensures that the transaction data is correctly formatted * and includes optional metadata elements if provided. * * `metadata.origin` accepts either a raw hex string (`"cafe"`) or a * 0x-prefixed hex string (`"0xcafe"` / `"0Xcafe"`); both produce the same * appended 4-byte origin tag. The 0x/0X prefix is stripped case-insensitively * before length-validation, so an origin of `"0xdeadbeef"` (10 chars * including prefix, 8 raw hex chars) is accepted while `"0xdeadbeef00"` * (10 raw hex chars) is rejected and a warning is logged. Odd-length raw * fragments (e.g. `"abc"`, `"0xabc"`) are also rejected — concatenating * a non-byte-aligned fragment would corrupt the trailing analytics byte * once viem's `concatHex` pads it to a whole byte at broadcast time. * * @param {Object} tx - The original transaction object. * @param {Hex} tx.data - The existing hex-encoded data for the transaction. * @param {bigint} tx.value - The value to be sent with the transaction. * @param {Address} tx.to - The recipient address of the transaction. * @param {Metadata} metadata - An object containing optional metadata fields * such as `timestamp` and `origin`. * * @returns The same `tx` object when `data` is missing, an empty string, or * canonical empty calldata (`"0x"`); otherwise, a new transaction object * with `data` containing any appended metadata. The input is never mutated. */ export declare function addTransactionMetadata(tx: { data: Hex; value: bigint; to: Address; }, metadata: Metadata): { data: Hex; value: bigint; to: Address; };