aboutsummaryrefslogtreecommitdiffstats
path: root/packages/subproviders
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-03-05 13:20:15 +0800
committerFabio Berger <me@fabioberger.com>2018-03-05 13:20:15 +0800
commit1817f6eaf63a5fa4302ad9ef41ad13b1555a8733 (patch)
tree1cfcfb9ba09a16890d982a61b0e7159ba97face8 /packages/subproviders
parentdf4db8fa4c19d2ef0a311d201061ba732ce0eb97 (diff)
parent699c0c3e05d3a882c8a59fec4f035ec25cb43c9e (diff)
downloaddexon-sol-tools-1817f6eaf63a5fa4302ad9ef41ad13b1555a8733.tar
dexon-sol-tools-1817f6eaf63a5fa4302ad9ef41ad13b1555a8733.tar.gz
dexon-sol-tools-1817f6eaf63a5fa4302ad9ef41ad13b1555a8733.tar.bz2
dexon-sol-tools-1817f6eaf63a5fa4302ad9ef41ad13b1555a8733.tar.lz
dexon-sol-tools-1817f6eaf63a5fa4302ad9ef41ad13b1555a8733.tar.xz
dexon-sol-tools-1817f6eaf63a5fa4302ad9ef41ad13b1555a8733.tar.zst
dexon-sol-tools-1817f6eaf63a5fa4302ad9ef41ad13b1555a8733.zip
Merge branch 'development' into extractDocs
* development: (22 commits) Fix bugs in postpublish_utils.js Update @0xproject/utils in top-level package.json Changelog tweaks Publish Updated CHANGELOGS Fix typo Add PR number to changelog entry Add changelog update to subproviders package Add `numberOfAccounts` param to `LedgerSubprovider` method `getAccountsAsync` and add tests Remove unnecessary type assertion Move web3 typings from devDeps to deps remove extrenuous comma Add PR number Add changelog entries from types and utils Add changelog entry to subproviders Remove extra comma Move web3 and ethers types to deps for utils package Make web3 typings a dep for web3Wrapper Make web3 typings a dep for subproviders reorder deps ... # Conflicts: # packages/website/package.json
Diffstat (limited to 'packages/subproviders')
-rw-r--r--packages/subproviders/CHANGELOG.md5
-rw-r--r--packages/subproviders/package.json20
-rw-r--r--packages/subproviders/src/subproviders/ledger.ts6
-rw-r--r--packages/subproviders/test/integration/ledger_subprovider_test.ts10
-rw-r--r--packages/subproviders/test/unit/ledger_subprovider_test.ts8
5 files changed, 33 insertions, 16 deletions
diff --git a/packages/subproviders/CHANGELOG.md b/packages/subproviders/CHANGELOG.md
index c2d590a35..7e1e006e3 100644
--- a/packages/subproviders/CHANGELOG.md
+++ b/packages/subproviders/CHANGELOG.md
@@ -1,5 +1,10 @@
# CHANGELOG
+## v0.6.0 - _March 4, 2018_
+
+ * Move web3 types from being a devDep to a dep since one cannot use this package without it (#429)
+ * Add `numberOfAccounts` param to `LedgerSubprovider` method `getAccountsAsync` (#432)
+
## v0.5.0 - _February 16, 2018_
* Add EmptyWalletSubprovider and FakeGasEstimateSubprovider (#392)
diff --git a/packages/subproviders/package.json b/packages/subproviders/package.json
index 5e9c2ed89..ec0642bce 100644
--- a/packages/subproviders/package.json
+++ b/packages/subproviders/package.json
@@ -1,6 +1,6 @@
{
"name": "@0xproject/subproviders",
- "version": "0.5.0",
+ "version": "0.6.0",
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
"license": "Apache-2.0",
@@ -18,9 +18,9 @@
"test:integration": "run-s clean build run_mocha_integration"
},
"dependencies": {
- "@0xproject/assert": "^0.0.20",
- "@0xproject/types": "^0.2.3",
- "@0xproject/utils": "^0.3.4",
+ "@0xproject/assert": "^0.1.0",
+ "@0xproject/types": "^0.3.0",
+ "@0xproject/utils": "^0.4.0",
"bn.js": "^4.11.8",
"es6-promisify": "^5.0.0",
"ethereumjs-tx": "^1.3.3",
@@ -30,19 +30,20 @@
"lodash": "^4.17.4",
"semaphore-async-await": "^1.5.1",
"web3": "^0.20.0",
- "web3-provider-engine": "^13.0.1"
+ "web3-provider-engine": "^13.0.1",
+ "web3-typescript-typings": "^0.10.0"
},
"devDependencies": {
- "@0xproject/tslint-config": "^0.4.9",
- "@0xproject/utils": "^0.3.4",
+ "@0xproject/tslint-config": "^0.4.10",
+ "@0xproject/utils": "^0.4.0",
"@types/lodash": "^4.14.86",
"@types/mocha": "^2.2.42",
"@types/node": "^8.0.53",
"awesome-typescript-loader": "^3.1.3",
"chai": "^4.0.1",
"chai-as-promised": "^7.1.0",
- "chai-as-promised-typescript-typings": "^0.0.9",
- "chai-typescript-typings": "^0.0.3",
+ "chai-as-promised-typescript-typings": "^0.0.10",
+ "chai-typescript-typings": "^0.0.4",
"dirty-chai": "^2.0.1",
"mocha": "^4.0.1",
"npm-run-all": "^4.1.2",
@@ -51,7 +52,6 @@
"types-bn": "^0.0.1",
"types-ethereumjs-util": "0xProject/types-ethereumjs-util",
"typescript": "2.7.1",
- "web3-typescript-typings": "^0.9.11",
"webpack": "^3.1.0"
}
}
diff --git a/packages/subproviders/src/subproviders/ledger.ts b/packages/subproviders/src/subproviders/ledger.ts
index 5966a88bb..85cdf0efc 100644
--- a/packages/subproviders/src/subproviders/ledger.ts
+++ b/packages/subproviders/src/subproviders/ledger.ts
@@ -19,7 +19,7 @@ import {
import { Subprovider } from './subprovider';
const DEFAULT_DERIVATION_PATH = `44'/60'/0'`;
-const NUM_ADDRESSES_TO_FETCH = 10;
+const DEFAULT_NUM_ADDRESSES_TO_FETCH = 10;
const ASK_FOR_ON_DEVICE_CONFIRMATION = false;
const SHOULD_GET_CHAIN_CODE = true;
@@ -129,7 +129,7 @@ export class LedgerSubprovider extends Subprovider {
return;
}
}
- public async getAccountsAsync(): Promise<string[]> {
+ public async getAccountsAsync(numberOfAccounts: number = DEFAULT_NUM_ADDRESSES_TO_FETCH): Promise<string[]> {
this._ledgerClientIfExists = await this._createLedgerClientAsync();
let ledgerResponse;
@@ -148,7 +148,7 @@ export class LedgerSubprovider extends Subprovider {
hdKey.chainCode = new Buffer(ledgerResponse.chainCode, 'hex');
const accounts = [];
- for (let i = 0; i < NUM_ADDRESSES_TO_FETCH; i++) {
+ for (let i = 0; i < numberOfAccounts; i++) {
const derivedHDNode = hdKey.derive(`m/${i + this._derivationPathIndex}`);
const derivedPublicKey = derivedHDNode.publicKey;
const shouldSanitizePublicKey = true;
diff --git a/packages/subproviders/test/integration/ledger_subprovider_test.ts b/packages/subproviders/test/integration/ledger_subprovider_test.ts
index 628b532d7..b052a76d2 100644
--- a/packages/subproviders/test/integration/ledger_subprovider_test.ts
+++ b/packages/subproviders/test/integration/ledger_subprovider_test.ts
@@ -26,11 +26,17 @@ describe('LedgerSubprovider', () => {
});
});
describe('direct method calls', () => {
- it('returns a list of accounts', async () => {
+ it('returns default number of accounts', async () => {
const accounts = await ledgerSubprovider.getAccountsAsync();
expect(accounts[0]).to.not.be.an('undefined');
expect(accounts.length).to.be.equal(10);
});
+ it('returns requested number of accounts', async () => {
+ const numberOfAccounts = 20;
+ const accounts = await ledgerSubprovider.getAccountsAsync(numberOfAccounts);
+ expect(accounts[0]).to.not.be.an('undefined');
+ expect(accounts.length).to.be.equal(numberOfAccounts);
+ });
it('signs a personal message', async () => {
const data = ethUtils.bufferToHex(ethUtils.toBuffer('hello world'));
const ecSignatureHex = await ledgerSubprovider.signPersonalMessageAsync(data);
@@ -172,7 +178,7 @@ describe('LedgerSubprovider', () => {
};
const callback = reportCallbackErrors(done)((err: Error, response: Web3.JSONRPCResponsePayload) => {
expect(err).to.be.a('null');
- const result = response.result.result;
+ const result = response.result;
expect(result.length).to.be.equal(66);
expect(result.substr(0, 2)).to.be.equal('0x');
done();
diff --git a/packages/subproviders/test/unit/ledger_subprovider_test.ts b/packages/subproviders/test/unit/ledger_subprovider_test.ts
index 1c70dd3a6..0d301bce9 100644
--- a/packages/subproviders/test/unit/ledger_subprovider_test.ts
+++ b/packages/subproviders/test/unit/ledger_subprovider_test.ts
@@ -62,11 +62,17 @@ describe('LedgerSubprovider', () => {
});
describe('direct method calls', () => {
describe('success cases', () => {
- it('returns a list of accounts', async () => {
+ it('returns default number of accounts', async () => {
const accounts = await ledgerSubprovider.getAccountsAsync();
expect(accounts[0]).to.be.equal(FAKE_ADDRESS);
expect(accounts.length).to.be.equal(10);
});
+ it('returns requested number of accounts', async () => {
+ const numberOfAccounts = 20;
+ const accounts = await ledgerSubprovider.getAccountsAsync(numberOfAccounts);
+ expect(accounts[0]).to.be.equal(FAKE_ADDRESS);
+ expect(accounts.length).to.be.equal(numberOfAccounts);
+ });
it('signs a personal message', async () => {
const data = ethUtils.bufferToHex(ethUtils.toBuffer('hello world'));
const ecSignatureHex = await ledgerSubprovider.signPersonalMessageAsync(data);