UNPKG

@0xobelisk/rooch-client

Version:
38 lines (37 loc) 1.73 kB
import { Secp256k1Keypair, RoochAddress, BitcoinAddress } from '@roochnetwork/rooch-sdk'; import type { AccountMangerParams, DerivePathParams } from '../../types'; export declare class RoochAccountManager { private mnemonics; private secretKey; currentKeyPair: Secp256k1Keypair; currentAddress: RoochAddress; currentBitcoinAddress: BitcoinAddress; /** * Support the following ways to init the SuiToolkit: * 1. mnemonics * 2. secretKey (base64 or hex) * If none of them is provided, will generate a random mnemonics with 24 words. * * @param mnemonics, 12 or 24 mnemonics words, separated by space * @param secretKey, base64 or hex string, when mnemonics is provided, secretKey will be ignored */ constructor({ mnemonics, secretKey }?: AccountMangerParams); /** * if derivePathParams is not provided or mnemonics is empty, it will return the currentKeyPair. * else: * it will generate keyPair from the mnemonic with the given derivePathParams. */ getKeyPair(derivePathParams?: DerivePathParams): Secp256k1Keypair; /** * if derivePathParams is not provided or mnemonics is empty, it will return the currentAddress. * else: * it will generate address from the mnemonic with the given derivePathParams. */ getAddress(derivePathParams?: DerivePathParams): RoochAddress; getBitcoinAddress(derivePathParams?: DerivePathParams): BitcoinAddress; /** * Switch the current account with the given derivePathParams. * This is only useful when the mnemonics is provided. For secretKey mode, it will always use the same account. */ switchAccount(derivePathParams: DerivePathParams): void; }