Small stylistic tweaks
This commit is contained in:
@@ -17,14 +17,11 @@ import { BaseWalletSubprovider } from './base_wallet_subprovider';
|
|||||||
export class EthLightwalletSubprovider extends BaseWalletSubprovider {
|
export class EthLightwalletSubprovider extends BaseWalletSubprovider {
|
||||||
private _keystore: lightwallet.keystore;
|
private _keystore: lightwallet.keystore;
|
||||||
private _pwDerivedKey: Uint8Array;
|
private _pwDerivedKey: Uint8Array;
|
||||||
|
|
||||||
constructor(keystore: lightwallet.keystore, pwDerivedKey: Uint8Array) {
|
constructor(keystore: lightwallet.keystore, pwDerivedKey: Uint8Array) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
this._keystore = keystore;
|
this._keystore = keystore;
|
||||||
this._pwDerivedKey = pwDerivedKey;
|
this._pwDerivedKey = pwDerivedKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the accounts associated with the eth-lightwallet instance.
|
* Retrieve the accounts associated with the eth-lightwallet instance.
|
||||||
* This method is implicitly called when issuing a `eth_accounts` JSON RPC request
|
* This method is implicitly called when issuing a `eth_accounts` JSON RPC request
|
||||||
@@ -36,7 +33,6 @@ export class EthLightwalletSubprovider extends BaseWalletSubprovider {
|
|||||||
const accounts = this._keystore.getAddresses();
|
const accounts = this._keystore.getAddresses();
|
||||||
return accounts;
|
return accounts;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Signs a transaction with the account specificed by the `from` field in txParams.
|
* Signs a transaction with the account specificed by the `from` field in txParams.
|
||||||
* If you've added this Subprovider to your app's provider, you can simply send
|
* If you've added this Subprovider to your app's provider, you can simply send
|
||||||
@@ -58,7 +54,6 @@ export class EthLightwalletSubprovider extends BaseWalletSubprovider {
|
|||||||
|
|
||||||
return signedTxHex;
|
return signedTxHex;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sign a personal Ethereum signed message. The signing account will be the account
|
* Sign a personal Ethereum signed message. The signing account will be the account
|
||||||
* associated with the provided address.
|
* associated with the provided address.
|
||||||
@@ -83,7 +78,6 @@ export class EthLightwalletSubprovider extends BaseWalletSubprovider {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const signature = lightwallet.signing.concatSig(result);
|
const signature = lightwallet.signing.concatSig(result);
|
||||||
|
|
||||||
return signature;
|
return signature;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import { reportCallbackErrors } from '../utils/report_callback_errors';
|
|||||||
|
|
||||||
chaiSetup.configure();
|
chaiSetup.configure();
|
||||||
const expect = chai.expect;
|
const expect = chai.expect;
|
||||||
|
|
||||||
const FAKE_ADDRESS = '0x44be42fd88e22387c43ba9b75941aa3e680dae25';
|
const FAKE_ADDRESS = '0x44be42fd88e22387c43ba9b75941aa3e680dae25';
|
||||||
const NUM_GENERATED_ADDRESSES = 10;
|
const NUM_GENERATED_ADDRESSES = 10;
|
||||||
const PASSWORD = 'supersecretpassword99';
|
const PASSWORD = 'supersecretpassword99';
|
||||||
@@ -30,7 +31,6 @@ describe('EthLightwalletSubprovider', () => {
|
|||||||
|
|
||||||
const createVaultAsync = async (vaultOptions: lightwallet.VaultOptions) => {
|
const createVaultAsync = async (vaultOptions: lightwallet.VaultOptions) => {
|
||||||
return new Promise<lightwallet.keystore>(resolve => {
|
return new Promise<lightwallet.keystore>(resolve => {
|
||||||
// Create Vault
|
|
||||||
lightwallet.keystore.createVault(vaultOptions, (err: Error, vaultKeystore) => {
|
lightwallet.keystore.createVault(vaultOptions, (err: Error, vaultKeystore) => {
|
||||||
if (err) {
|
if (err) {
|
||||||
throw new Error(`Failed to createVault: ${err}`);
|
throw new Error(`Failed to createVault: ${err}`);
|
||||||
@@ -39,7 +39,6 @@ describe('EthLightwalletSubprovider', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const deriveKeyFromPasswordAsync = async (vaultKeystore: lightwallet.keystore) => {
|
const deriveKeyFromPasswordAsync = async (vaultKeystore: lightwallet.keystore) => {
|
||||||
return new Promise<Uint8Array>(resolve => {
|
return new Promise<Uint8Array>(resolve => {
|
||||||
vaultKeystore.keyFromPassword(PASSWORD, (err: Error, passwordDerivedKey: Uint8Array) => {
|
vaultKeystore.keyFromPassword(PASSWORD, (err: Error, passwordDerivedKey: Uint8Array) => {
|
||||||
@@ -50,14 +49,12 @@ describe('EthLightwalletSubprovider', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const keystore: lightwallet.keystore = await createVaultAsync(options);
|
const keystore: lightwallet.keystore = await createVaultAsync(options);
|
||||||
const pwDerivedKey: Uint8Array = await deriveKeyFromPasswordAsync(keystore);
|
const pwDerivedKey: Uint8Array = await deriveKeyFromPasswordAsync(keystore);
|
||||||
|
|
||||||
// Generate 10 addresses
|
// Generate 10 addresses
|
||||||
keystore.generateNewAddress(pwDerivedKey, NUM_GENERATED_ADDRESSES);
|
keystore.generateNewAddress(pwDerivedKey, NUM_GENERATED_ADDRESSES);
|
||||||
|
|
||||||
// Initialize Subprovider
|
|
||||||
ethLightwalletSubprovider = new EthLightwalletSubprovider(keystore, pwDerivedKey);
|
ethLightwalletSubprovider = new EthLightwalletSubprovider(keystore, pwDerivedKey);
|
||||||
});
|
});
|
||||||
describe('direct method calls', () => {
|
describe('direct method calls', () => {
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ declare module 'eth-lightwallet' {
|
|||||||
public exportPrivateKey(address: string, pwDerivedKey: Uint8Array): string;
|
public exportPrivateKey(address: string, pwDerivedKey: Uint8Array): string;
|
||||||
public getAddresses(): string[];
|
public getAddresses(): string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
interface VaultOptions {
|
interface VaultOptions {
|
||||||
password: string;
|
password: string;
|
||||||
seedPhrase: string;
|
seedPhrase: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user