UNPKG

near-ca

Version:

An SDK for controlling Ethereum Accounts from a Near Account.

58 lines (57 loc) 2.16 kB
import { Hash, Hex, PublicClient, TransactionSerializable } from "viem"; import { BaseTx, TransactionWithSignature } from "../types"; /** * Converts a message hash to a payload array * * @param msgHash - The message hash to convert * @returns Array of numbers representing the payload * @throws Error if the payload length is not 32 bytes */ export declare function toPayload(msgHash: Hex | Uint8Array): number[]; /** * Converts a payload array back to a hexadecimal string * * @param payload - The payload array to convert * @returns Hexadecimal string representation * @throws Error if the payload length is not 32 bytes */ export declare function fromPayload(payload: number[]): Hex; /** * Builds a transaction payload from a serialized transaction * * @param serializedTx - The serialized transaction * @returns Array of numbers representing the transaction payload */ export declare function buildTxPayload(serializedTx: `0x${string}`): number[]; /** * Populates a transaction with necessary data * * @param tx - The base transaction data * @param from - The sender's address * @param client - Optional public client * @returns Complete transaction data * @throws Error if chain IDs don't match */ export declare function populateTx(tx: BaseTx, from: Hex, client?: PublicClient): Promise<TransactionSerializable>; /** * Adds a signature to a transaction * * @param params - Object containing transaction and signature * @returns Serialized signed transaction */ export declare function addSignature({ transaction, signature, }: TransactionWithSignature): Hex; /** * Relays a signed transaction to the Ethereum mempool * * @param serializedTransaction - The signed transaction to relay * @param wait - Whether to wait for confirmation * @returns Transaction hash */ export declare function relaySignedTransaction(serializedTransaction: Hex, wait?: boolean): Promise<Hash>; /** * Broadcasts a signed transaction to the Ethereum mempool * * @param tx - The signed transaction to broadcast * @returns Transaction hash */ export declare function broadcastSignedTransaction(tx: TransactionWithSignature): Promise<Hash>;