Home Reference Source Test
public class | source

LocalWallet

Extends:

Wallet → LocalWallet

libsimba-js Local Wallet implementation Stores the wallet as encrypted json within the browsers localstorage Wraps the [ethersjs]https://docs.ethers.io/ethers.js/html/ library.

Constructor Summary

Public Constructor
public

constructor(signingConfirmation: function)

Use a wallet stored in the browsers local storage

Member Summary

Public Members
public

wallet: *

public

window: *

Method Summary

Public Methods
public
public

generateWallet(passkey: string, progressCB: function): Promise

public

Generate a wallet from a encrypted json (see [ethers docs]{@link https://docs.ethers.io/ethers.js/html/api-wallet.html?highlight=fromencryptedjson})

public

generateWalletFromMnemonic(mnemonic: string, passkey: string, progressCB: function): Promise

Generate a wallet from a mnemonic

public

Generate a wallet from an existing private key

public
public

getEncryptedJson(passkey: string, progressCB: function): Promise<string>

public

The mnemonic phrase for this wallet, or null if the mnemonic is unknown.

public

unlockWallet(passkey: string, progressCB: function): Promise

public
Protected Methods
protected

sign(payload: Object): Promise<string>

Private Methods
private

Inherited Summary

From class Wallet
public
public abstract
public abstract
public abstract
public abstract
public abstract
protected abstract

sign(payload: Object): Promise<string>

Public Constructors

public constructor(signingConfirmation: function) source

Use a wallet stored in the browsers local storage

Override:

Wallet#constructor

Params:

NameTypeAttributeDescription
signingConfirmation function
  • optional
  • an optional callback for requesting user permission to sign a transaction. Should resolve a promise with true for accept, and false (or reject) for reject.

Public Members

public wallet: * source

public window: * source

Public Methods

public deleteWallet() source

Override:

Wallet#deleteWallet

public generateWallet(passkey: string, progressCB: function): Promise source

Override:

Wallet#generateWallet

Params:

NameTypeAttributeDescription
passkey string

The pass key to lock the wallet

progressCB function
  • optional

A callback, accepting a number between 0-1, indicating decryption progress

Return:

Promise

Returns a promise resolving when the wallet is created

public generateWalletFromEncryptedJson(json: string, passkey: string, progressCB: function): Promise source

Generate a wallet from a encrypted json (see [ethers docs]{@link https://docs.ethers.io/ethers.js/html/api-wallet.html?highlight=fromencryptedjson})

Params:

NameTypeAttributeDescription
json string

The json

passkey string

The pass key to lock the wallet

progressCB function
  • optional

A callback, accepting a number between 0-1, indicating decryption progress

Return:

Promise

Returns a promise resolving when the wallet is created

public generateWalletFromMnemonic(mnemonic: string, passkey: string, progressCB: function): Promise source

Generate a wallet from a mnemonic

Params:

NameTypeAttributeDescription
mnemonic string

The mnemonic

passkey string

The pass key to lock the wallet

progressCB function
  • optional

A callback, accepting a number between 0-1, indicating decryption progress

Return:

Promise

Returns a promise resolving when the wallet is created

public generateWalletFromPrivateKey(key: string, passkey: string, progressCB: function): Promise source

Generate a wallet from an existing private key

Params:

NameTypeAttributeDescription
key string

The existing private key

passkey string

The pass key to lock the wallet

progressCB function
  • optional

A callback, accepting a number between 0-1, indicating decryption progress

Return:

Promise

Returns a promise resolving when the wallet is created

public getAddress(): Promise<string> source

Override:

Wallet#getAddress

Return:

Promise<string>

Returns a promise resolving to the wallets address

public getEncryptedJson(passkey: string, progressCB: function): Promise<string> source

Params:

NameTypeAttributeDescription
passkey string

Passkey to encrypt the wallet

progressCB function
  • optional

An optional callback to monitor progress of encryption, calls with a value between 0-1

Return:

Promise<string>

A promise that resolves with the JSON wallet

public getMnemonic(): string source

The mnemonic phrase for this wallet, or null if the mnemonic is unknown.

Return:

string

The mnemonic phrase for this wallet, or null if the mnemonic is unknown.

public unlockWallet(passkey: string, progressCB: function): Promise source

Override:

Wallet#unlockWallet

Params:

NameTypeAttributeDescription
passkey string

The pass key to unlock the wallet

progressCB function
  • optional

A callback, accepting a number between 0-1, indicating decryption progress

Return:

Promise

Returns a promise resolving when the wallet is unlocked

public walletExists(): boolean source

Override:

Wallet#walletExists

Return:

boolean

does the wallet exist

Protected Methods

protected sign(payload: Object): Promise<string> source

Override:

Wallet#sign

Params:

NameTypeAttributeDescription
payload Object

The transaction to sign

Return:

Promise<string>

Returns a promise resolving to the signed transaction

Private Methods

private cleanPayload(payload: Object): string source

Params:

NameTypeAttributeDescription
payload Object

The transaction to clean

Return:

string

The cleaned transaction