UNPKG

near-ca-test

Version:

An SDK for controlling Ethereum Accounts from a Near Account.

53 lines (52 loc) 2.18 kB
import { KeyPair, Account } from "near-api-js"; import { NearConfig } from "near-api-js/lib/near"; export declare const TGAS = 1000000000000n; export declare const NO_DEPOSIT = "0"; type NetworkId = "mainnet" | "testnet"; /** * Extracts the network ID from a given NEAR account ID. * If the account ID does not end with "near" or "testnet", it logs a warning. * Defaults to "mainnet" if the network ID is not "testnet". * * @param accountId - The NEAR account ID to extract the network ID from. * @returns The network ID, either "mainnet" or "testnet". */ export declare function getNetworkId(accountId: string): NetworkId; /** * Generates a NEAR configuration object based on the provided network ID. * * @param networkId - The network ID, either "mainnet" or "testnet". * @returns A NearConfig object containing the network ID and node URL. */ export declare function configFromNetworkId(networkId: NetworkId): NearConfig; /** * Loads Near Account from provided keyPair and accountId * * @param keyPair {KeyPair} * @param accountId {string} * @param network {NearConfig} network settings * @returns A Promise that resolves to a NEAR Account instance. */ export declare const nearAccountFromKeyPair: (config: { keyPair: KeyPair; accountId: string; network: NearConfig; }) => Promise<Account>; /** Minimally sufficient Account instance to construct readonly MpcContract connection. * Can't be used to change methods. * * @param accountId {string} * @param network {NearConfig} network settings * @returns A Promise that resolves to a NEAR Account instance. */ export declare const nearAccountFromAccountId: (accountId: string, network: NearConfig) => Promise<Account>; /** * Creates a NEAR account instance using the provided account ID, network configuration, and optional key pair. * * @param accountId - The NEAR account ID. * @param network - The NEAR network configuration. * @param keyPair - (Optional) The key pair for the account. * @returns A Promise that resolves to a NEAR Account instance. */ export declare const createNearAccount: (accountId: string, network: NearConfig, keyPair?: KeyPair) => Promise<Account>; export {};