open-libra-sdk
Version:
A minimalist Typescript library for interacting with the Open Libra blockchain.
67 lines • 3.42 kB
TypeScript
import type { AccountAddress, AccountAuthenticatorEd25519, AnyRawTransaction, CommittedTransactionResponse, Ed25519Account, Ed25519PrivateKey, InputGenerateTransactionOptions, MoveFunctionId, Network, SimpleEntryFunctionArgumentTypes, SimpleTransaction } from "@aptos-labs/ts-sdk";
import { LibraClient } from "../client/client";
/**
* CryptoWallet class provides functionalities for handling a cryptocurrency wallet.
* It allows generating an account from a mnemonic phrase, signing messages and transactions,
* verifying signatures, and submitting transactions to the blockchain.
* It has modes for using online with a client, or offline for account recovery
* and tx signing only (cold wallet).
*/
export declare class LibraWallet {
/**
* The account associated with this wallet, generated from a mnemonic phrase.
*/
readonly account: Ed25519Account;
onchainAddress?: AccountAddress;
readonly client?: LibraClient;
/**
* Transaction options that can be modified based on user preferences.
*/
txOptions: InputGenerateTransactionOptions;
private constructor();
/**
* Creates a wallet instance from a mnemonic phrase
* @param mnemonic The mnemonic phrase used to generate the account
* @param network Optional network settings (MAINNET, TESTNET etc)
* @param fullnode Optional URL of upstream node
* @param forceAddress Optional account address if key has rotated
*/
static fromMnemonic(mnemonic: string, network?: Network, fullnode?: string, forceAddress?: AccountAddress): LibraWallet;
/**
* Creates a wallet instance from an existing account address and private key
* @param address The account address
* @param privateKey The Ed25519 private key
* @param client Pre-configured LibraClient instance
*/
static fromPrivateKey(address: AccountAddress, privateKey: Ed25519PrivateKey, client?: LibraClient): LibraWallet;
/**
* Requires connection to a fullnode, will check the actual address which this
* authKey owns on chain.
*/
syncOnchain(): Promise<void>;
getAddress(): AccountAddress;
/**
* Signs a raw transaction using the account's private key.
* @param transaction - The raw transaction object that needs to be signed.
* @returns A SignerAuthenticator object containing the signed transaction data.
*/
signTransaction(transaction: AnyRawTransaction): AccountAuthenticatorEd25519;
/**
*
* @param entry_function address of the function e.g. "0x1::ol_account::transfer"
* @param args: list of simple serializable Move values e.g. [marlon_addr, 100]
*/
buildTransaction(entry_function: MoveFunctionId, args: Array<SimpleEntryFunctionArgumentTypes>): Promise<SimpleTransaction>;
/**
* Simple transfer function between ordinary accounts
* @param recipient address of recipient
* @param amount non-decimal coin amount for transfer. Open Libra uses 6 decimal places. e.g. 1 coin = 1,000,000 amount
*/
buildTransferTx(recipient: AccountAddress, amount: number): Promise<AnyRawTransaction>;
/**
* Submits a signed transaction to the blockchain network.
* @param transaction - The raw transaction object that needs to be signed.
*/
signSubmitWait(transaction: AnyRawTransaction): Promise<CommittedTransactionResponse>;
}
//# sourceMappingURL=libraWallet.d.ts.map