UNPKG

near-ca

Version:

An SDK for controlling Ethereum Accounts from a Near Account.

51 lines (50 loc) 1.9 kB
import { Signature } from "viem"; import { MPCSignature } from "../types"; import { FinalExecutionOutcome } from "near-api-js/lib/providers"; /** Basic structure of the JSON-RPC response */ export interface JSONRPCResponse<T> { /** JSON-RPC version */ jsonrpc: string; /** Request identifier */ id: number | string | null; /** Response result */ result?: T; /** Error information if request failed */ error?: { /** Error code */ code: number; /** Error message */ message: string; /** Additional error data */ data?: unknown; }; } /** * Retrieves a signature from a transaction hash * * @param nodeUrl - URL of the NEAR node * @param txHash - Transaction hash to query * @param accountId - Account ID used to determine shard for query (defaults to "non-empty") * @returns The signature from the transaction * @throws Error if HTTP request fails or response is invalid */ export declare function signatureFromTxHash(nodeUrl: string, txHash: string, accountId?: string): Promise<Signature>; /** * Transforms an MPC signature into a standard Ethereum signature * * @param mpcSig - The MPC signature to transform * @returns Standard Ethereum signature */ export declare function transformSignature(mpcSig: MPCSignature): Signature; /** * Extracts a signature from a transaction outcome * * @param outcome - Transaction outcome from NEAR API * @returns The extracted signature * @throws Error if signature is not found or is invalid * @remarks * Handles both standard and relayed signature requests. For relayed requests, * extracts signature from receipts_outcome, taking the second occurrence as * the first is nested inside `{ Ok: MPCSignature }`. */ export declare function signatureFromOutcome(outcome: FinalExecutionOutcome | Omit<FinalExecutionOutcome, "final_execution_status">): Signature;