UNPKG

near-ca

Version:

An SDK for controlling Ethereum Accounts from a Near Account.

49 lines (48 loc) 1.99 kB
import { KeyPair, Account } from "near-api-js"; import { NearConfig } from "near-api-js/lib/near"; import { NearAccountConfig } from "../types"; /** Gas unit constant for NEAR transactions (1 TeraGas) */ export declare const TGAS = 1000000000000n; /** Valid NEAR network identifiers */ type NetworkId = "mainnet" | "testnet"; /** * Extracts the network ID from a given NEAR account ID * * @param accountId - The NEAR account ID to analyze * @returns The network ID ("mainnet" or "testnet") * @remarks If the account ID doesn't end with "near" or "testnet", defaults to "mainnet" */ export declare function getNetworkId(accountId: string): NetworkId; /** * Generates a NEAR configuration object for a specific network * * @param networkId - The target network identifier * @returns Configuration object for NEAR connection */ export declare function configFromNetworkId(networkId: NetworkId): NearConfig; /** * Creates a NEAR Account instance from provided credentials * * @param config - Configuration containing account ID, network, and key pair * @returns A NEAR Account instance */ export declare const nearAccountFromKeyPair: (config: NearAccountConfig) => Promise<Account>; /** * Creates a read-only NEAR Account instance from an account ID * * @param accountId - The NEAR account identifier * @param network - The NEAR network configuration * @returns A read-only NEAR Account instance * @remarks This account cannot perform write operations */ export declare const nearAccountFromAccountId: (accountId: string, network: NearConfig) => Promise<Account>; /** * Creates a NEAR Account instance with optional write capabilities * * @param accountId - The NEAR account identifier * @param network - The NEAR network configuration * @param keyPair - Optional key pair for write access * @returns A NEAR Account instance */ export declare const createNearAccount: (accountId: string, network: NearConfig, keyPair?: KeyPair) => Promise<Account>; export {};