UNPKG

near-ca-test

Version:

An SDK for controlling Ethereum Accounts from a Near Account.

59 lines (58 loc) 2.34 kB
import { Contract, Account } from "near-api-js"; import { Address, Signature } from "viem"; import { MPCSignature, FunctionCallTransaction, SignArgs } from "./types"; import { FinalExecutionOutcome } from "near-api-js/lib/providers"; /** * Near Contract Type for change methods. * * @template T - The type of the arguments for the change method. * @property {T} args - Change method function arguments. * @property {string} gas - Gas limit on transaction execution. * @property {Account} signerAccount - Account signing the call. * @property {string} amount - Attached deposit (i.e., payable amount) to attach to the transaction. */ export interface ChangeMethodArgs<T> { args: T; gas: string; signerAccount: Account; amount: string; } interface MpcContractInterface extends Contract { public_key: () => Promise<string>; experimental_signature_deposit: () => Promise<number>; experimantal_signature_deposit: () => Promise<number>; sign: (args: ChangeMethodArgs<{ request: SignArgs; }>) => Promise<MPCSignature>; } /** * High-level interface for the Near MPC-Recovery Contract * located in: https://github.com/near/mpc-recovery */ export declare class MpcContract implements IMpcContract { rootPublicKey: string | undefined; contract: MpcContractInterface; connectedAccount: Account; constructor(account: Account, contractId: string, rootPublicKey?: string); accountId(): string; deriveEthAddress: (derivationPath: string) => Promise<Address>; getDeposit: () => Promise<string>; requestSignature: (signArgs: SignArgs, gas?: bigint) => Promise<Signature>; encodeSignatureRequestTx(signArgs: SignArgs, gas?: bigint): Promise<FunctionCallTransaction<{ request: SignArgs; }>>; signAndSendSignRequest(transaction: FunctionCallTransaction<{ request: SignArgs; }>, blockTimeout?: number): Promise<FinalExecutionOutcome>; } export interface IMpcContract { connectedAccount: Account; accountId(): string; deriveEthAddress(derivationPath: string): Promise<Address>; getDeposit(): Promise<string>; requestSignature(signArgs: SignArgs, gas?: bigint): Promise<Signature>; encodeSignatureRequestTx(signArgs: SignArgs, gas?: bigint): Promise<FunctionCallTransaction<{ request: SignArgs; }>>; } export {};