UNPKG

@celo/wallet-local

Version:

Local wallet implementation

30 lines 1.16 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.LocalWallet = void 0; const address_1 = require("@celo/utils/lib/address"); const wallet_base_1 = require("@celo/wallet-base"); const local_signer_1 = require("./local-signer"); class LocalWallet extends wallet_base_1.WalletBase { /** * Register the private key as signer account * @param privateKey account private key */ addAccount(privateKey) { // Prefix 0x here or else the signed transaction produces dramatically different signer!!! privateKey = (0, address_1.normalizeAddressWith0x)(privateKey); const accountAddress = (0, address_1.normalizeAddressWith0x)((0, address_1.privateKeyToAddress)(privateKey)); if (this.hasAccount(accountAddress)) { return; } this.addSigner(accountAddress, new local_signer_1.LocalSigner(privateKey)); } /** * Remove the account * @param address Adddress of the account to remove */ removeAccount(address) { this.removeSigner(address); } } exports.LocalWallet = LocalWallet; //# sourceMappingURL=local-wallet.js.map