UNPKG

@xchainjs/xchain-evm

Version:
73 lines (72 loc) 2.88 kB
import { TxHash } from '@xchainjs/xchain-client'; import { Address } from '@xchainjs/xchain-util'; import { HDNodeWallet } from 'ethers'; import { IKeystoreSigner, SignApproveParams, SignTransferParams } from '../types'; import { Signer, SignerParams } from './signer'; /** * Keystore signer parameters */ export type KeystoreSignerParams = SignerParams & { phrase: string; }; /** * Signer which operates with an EVM account thanks to the seed phrase */ export declare class KeystoreSigner extends Signer implements IKeystoreSigner { private hdNode?; private phrase?; constructor(params: KeystoreSignerParams); /** * Validates the given Ethereum address. * * @param {Address} address - The address to validate. * @returns {boolean} `true` if the address is valid, `false` otherwise. */ setPhrase(phrase: string, walletIndex?: number): Address; /** * Purges the client, resetting it to initial state. * * @returns {void} */ purge(): void; /** * @deprecated Use getAddressAsync instead. This function will eventually be removed. */ getAddress(walletIndex?: number): Address; /** * Get the current address asynchronously. * * @param {number} walletIndex The current address. * @returns {Address} The current address. * @throws {Error} Thrown if HDNode is not defined, indicating that a phrase is needed to derive an address. * @throws {Error} Thrown if wallet index < 0. */ getAddressAsync(walletIndex?: number): Promise<Address>; /** * Retrieves the Ethereum wallet interface. * * @param {number} walletIndex - The index of the HD wallet (optional). * @returns {Wallet} The current Ethereum wallet interface. * @throws Error - Thrown if the HDNode is not defined, indicating that a phrase is needed to create a wallet and derive an address. * Note: A phrase is needed to create a wallet and to derive an address from it. */ getWallet(walletIndex?: number): HDNodeWallet; /** * Sign an EVM transaction with Ledger * * @param {SignTransferParams} params Sign transfer params * @param {string} SignTransferParams.sender Fee option (optional) * @param {ethers.Transaction} SignTransferParams.tx Fee option (optional) * @returns {string} The raw signed transaction. */ signTransfer({ walletIndex, tx }: SignTransferParams): Promise<TxHash>; /** * Sign an EVM approve transaction with Ledger * * @param {SignTransferParams} params Sign transfer params * @param {string} SignTransferParams.sender The sender address * @param {ethers.Transaction} SignTransferParams.tx Approve transaction to sign * @returns {string} The raw signed transaction. */ signApprove({ walletIndex, tx }: SignApproveParams): Promise<string>; }