From 199b2c4b629a31bf8dd05dea201cede6f467f401 Mon Sep 17 00:00:00 2001 From: Josh Stevens Date: Tue, 29 Jan 2019 11:59:13 +0000 Subject: [PATCH 01/17] fix: import buffer into types file so `node` does not need to be installed on the project --- packages/web3-bzz/types/index.d.ts | 2 ++ packages/web3-utils/types/index.d.ts | 1 + 2 files changed, 3 insertions(+) diff --git a/packages/web3-bzz/types/index.d.ts b/packages/web3-bzz/types/index.d.ts index 9d9ebb731eb..5d3d8844e10 100644 --- a/packages/web3-bzz/types/index.d.ts +++ b/packages/web3-bzz/types/index.d.ts @@ -17,6 +17,8 @@ * @date 2018 */ +import {Buffer} from 'buffer'; + export class Bzz { constructor(provider: string | {}); diff --git a/packages/web3-utils/types/index.d.ts b/packages/web3-utils/types/index.d.ts index aa8391bb3ad..8aa73dd224e 100644 --- a/packages/web3-utils/types/index.d.ts +++ b/packages/web3-utils/types/index.d.ts @@ -21,6 +21,7 @@ */ import BigNumber from 'bn.js'; +import {Buffer} from 'buffer'; export type Unit = | 'noether' From 94886981c81a99b3723f61fc4489e6f69f273874 Mon Sep 17 00:00:00 2001 From: Josh Stevens Date: Tue, 29 Jan 2019 11:59:43 +0000 Subject: [PATCH 02/17] fix: map the reference path for the `net` module so it compiles without having to install node on the project --- packages/web3-core/types/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/web3-core/types/index.d.ts b/packages/web3-core/types/index.d.ts index 85a298e2e3e..59311ab9d8b 100644 --- a/packages/web3-core/types/index.d.ts +++ b/packages/web3-core/types/index.d.ts @@ -17,6 +17,7 @@ * @date 2018 */ +/// import * as net from 'net'; import { BatchRequest, From 8e0c5fdb274e6087fb083fb6309d61a7de1597a2 Mon Sep 17 00:00:00 2001 From: Josh Stevens Date: Tue, 29 Jan 2019 12:38:25 +0000 Subject: [PATCH 03/17] fix: patch the angular `browser.js` to allow `{crypto: true, stream: true` --- packages/web3/angular-patch.js | 17 +++++++++++++++++ packages/web3/package.json | 6 +++--- 2 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 packages/web3/angular-patch.js diff --git a/packages/web3/angular-patch.js b/packages/web3/angular-patch.js new file mode 100644 index 00000000000..50544745266 --- /dev/null +++ b/packages/web3/angular-patch.js @@ -0,0 +1,17 @@ +const fs = require('fs'); +const f = '../../node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/browser.js'; + +// This is because we have to replace the `node:false` in the `/angular-cli-files/models/webpack-configs/browser.js` +// with `node: {crypto: true, stream: true}` to allow web3 to work with angular (as they enforce node: false.) +// as explained here - https://github.com/ethereum/web3.js/issues/2260#issuecomment-458519127 +if (fs.existsSync(f)) { + fs.readFile(f, 'utf8', function (err, data) { + if (err) { + return console.log(err); + } + var result = data.replace(/node: false/g, 'node: {crypto: true, stream: true}'); + fs.writeFile(f, result, 'utf8', function (err) { + if (err) return console.log(err); + }); + }); +} diff --git a/packages/web3/package.json b/packages/web3/package.json index ba2907609c7..7b9b8f944c8 100644 --- a/packages/web3/package.json +++ b/packages/web3/package.json @@ -17,8 +17,7 @@ "API" ], "author": "ethereum.org", - "authors": [ - { + "authors": [{ "name": "Samuel Furter", "email": "samuel@ethereum.org", "homepage": "https://github.com/nivida" @@ -52,7 +51,8 @@ "build": "rollup -c", "dev": "rollup -c -w", "test": "jest", - "dtslint": "dtslint types --onlyTestTsNext" + "dtslint": "dtslint types --onlyTestTsNext", + "postinstall": "node angular-patch.js" }, "types": "types", "dependencies": { From f859a24e1a5b376b89d39ebf6e96a604ee16d6b6 Mon Sep 17 00:00:00 2001 From: Leon Prouger Date: Wed, 30 Jan 2019 11:02:21 +0200 Subject: [PATCH 04/17] fixing example of whisper protocol --- docs/web3-shh.rst | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/docs/web3-shh.rst b/docs/web3-shh.rst index e80176167fd..5e7b72b08b2 100644 --- a/docs/web3-shh.rst +++ b/docs/web3-shh.rst @@ -761,8 +761,7 @@ Example .. code-block:: javascript - const identities = [], - subscription = null; + const identities = []; Promise.all([ web3.shh.newSymKey().then((id) => {identities.push(id);}), @@ -771,7 +770,7 @@ Example ]).then(() => { // will receive also its own message send, below - subscription = shh.subscribe("messages", { + const subscription = shh.subscribe("messages", { symKeyID: identities[0], topics: ['0xffaadd11'] }).on('data', console.log); @@ -785,7 +784,7 @@ Example payload: '0xffffffdddddd1122', powTime: 3, powTarget: 0.5 - }).then(hash => console.log(`Message with hash ${h} was successfuly sent`)) + }).then(hash => console.log(`Message with hash ${hash} was successfuly sent`)) .catch(err => console.log("Error: ", err)); }); @@ -1023,5 +1022,3 @@ Example "topic": "0x01020304", "ttl": 50 },{...}] - - From 85c0f0bb48124a16267117501d77560e0a7f8074 Mon Sep 17 00:00:00 2001 From: Josh Stevens Date: Thu, 31 Jan 2019 10:03:45 +0000 Subject: [PATCH 05/17] write missing typing for `web3-eth-personal` --- packages/web3-eth-personal/types/index.d.ts | 49 +++++++++++---- .../types/tests/personal-tests.ts | 59 ++++++++++++++++--- 2 files changed, 89 insertions(+), 19 deletions(-) diff --git a/packages/web3-eth-personal/types/index.d.ts b/packages/web3-eth-personal/types/index.d.ts index ca600b125d0..c8d7faea7db 100644 --- a/packages/web3-eth-personal/types/index.d.ts +++ b/packages/web3-eth-personal/types/index.d.ts @@ -13,28 +13,55 @@ */ /** * @file index.d.ts - * @author Huan Zhang + * @author Huan Zhang , + * @author Josh Stevens * @date 2018 */ -import {Accounts} from 'web3-eth-accounts' +import {Accounts} from 'web3-eth-accounts'; import {provider} from 'web3-providers'; import {AbstractWeb3Module, Providers, RLPEncodedTransaction, Transaction, Web3ModuleOptions} from 'web3-core'; export class Personal extends AbstractWeb3Module { - constructor( - provider: provider, - accounts: Accounts, - options?: Web3ModuleOptions - ); + constructor(provider: provider, accounts: Accounts, options?: Web3ModuleOptions); newAccount(password: string, callback?: (error: Error, address: string) => void): Promise; - sign(dataToSign: string, address: string, password: string, callback?: (error: Error, signature: string) => void): Promise; + sign( + dataToSign: string, + address: string, + password: string, + callback?: (error: Error, signature: string) => void + ): Promise; - ecRecover(dataThatWasSigned: string, signature: string, callback?: (error: Error, address: string) => void): Promise; + ecRecover( + dataThatWasSigned: string, + signature: string, + callback?: (error: Error, address: string) => void + ): Promise; - signTransaction(transation: Transaction, password: string, callback?: (error: Error, RLPEncodedTransaction: RLPEncodedTransaction) => void): Promise; + signTransaction( + transation: Transaction, + password: string, + callback?: (error: Error, RLPEncodedTransaction: RLPEncodedTransaction) => void + ): Promise; - unlockAccount(address: string, password: string, unlockDuration: number, callback?: (error: Error) => void): Promise; + sendTransaction( + transation: Transaction, + password: string, + callback?: (error: Error, transactionHash: string) => void + ): Promise; + + unlockAccount( + address: string, + password: string, + unlockDuration: number, + callback?: (error: Error) => void + ): Promise; + + lockAccount(address: string, callback?: (error: Error, success: boolean) => void): Promise; + + getAccounts(callback?: (error: Error, accounts: string[]) => void): Promise; + + importRawKey(privateKey: string, password: string): Promise; } diff --git a/packages/web3-eth-personal/types/tests/personal-tests.ts b/packages/web3-eth-personal/types/tests/personal-tests.ts index a582c73db42..64ad666dfd0 100644 --- a/packages/web3-eth-personal/types/tests/personal-tests.ts +++ b/packages/web3-eth-personal/types/tests/personal-tests.ts @@ -13,7 +13,9 @@ */ /** * @file personal-tests.ts - * @author Huan Zhang , Samuel Furter + * @author Huan Zhang + * @author Samuel Furter + * @author Josh Stevens * @date 2018 */ @@ -22,11 +24,7 @@ import {Personal} from 'web3-eth-personal'; import {HttpProvider} from 'web3-providers'; import {Accounts} from 'web3-eth-accounts'; -const personal = new Personal( - 'http://localhost:7545', - new Accounts('http://localhost:7545', {}), - {} -); +const personal = new Personal('http://localhost:7545', new Accounts('http://localhost:7545', {}), {}); // $ExpectType Promise personal.newAccount('test password'); @@ -36,7 +34,12 @@ personal.newAccount('test password', (error: Error, address: string) => {}); // $ExpectType Promise personal.sign('Hello world', '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', 'test password!'); // $ExpectType Promise -personal.sign('Hello world', '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', 'test password!', (error: Error, signature: string) => {}); +personal.sign( + 'Hello world', + '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', + 'test password!', + (error: Error, signature: string) => {} +); // $ExpectType Promise personal.ecRecover('Hello world', '0x30755ed65396facf86c53e6217c52b4daebe72aa'); @@ -67,9 +70,49 @@ personal.signTransaction( }, 'test password', (error: Error, RLPEncodedTransaction: RLPEncodedTransaction) => {} -) +); + +// $ExpectType Promise +personal.sendTransaction( + { + from: '0xEB014f8c8B418Db6b45774c326A0E64C78914dC0', + gasPrice: '20000000000', + gas: '21000', + to: '0x3535353535353535353535353535353535353535', + value: '1000000000000000000', + data: '' + }, + 'test password' +); + +// $ExpectType Promise +personal.sendTransaction( + { + from: '0xEB014f8c8B418Db6b45774c326A0E64C78914dC0', + gasPrice: '20000000000', + gas: '21000', + to: '0x3535353535353535353535353535353535353535', + value: '1000000000000000000', + data: '' + }, + 'test password', + (error: Error, transactionHash: string) => {} +); // $ExpectType Promise personal.unlockAccount('0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', 'test password!', 600); // $ExpectType Promise personal.unlockAccount('0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', 'test password!', 600, (error: Error) => {}); + +// $ExpectType Promise +personal.lockAccount('0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe'); +// $ExpectType Promise +personal.lockAccount('0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', (error: Error, sucess: boolean) => {}); + +// $ExpectType Promise +personal.getAccounts(); +// $ExpectType Promise +personal.getAccounts((error: Error, accounts: string[]) => {}); + +// $ExpectType Promise +personal.importRawKey('privateKey', 'blah2'); From da970728066780676f21d48d9daec2f6c0155d51 Mon Sep 17 00:00:00 2001 From: Josh Stevens Date: Thu, 31 Jan 2019 10:12:52 +0000 Subject: [PATCH 06/17] remove unused code out of the tests --- packages/web3-eth-personal/types/tests/personal-tests.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/web3-eth-personal/types/tests/personal-tests.ts b/packages/web3-eth-personal/types/tests/personal-tests.ts index 64ad666dfd0..7c9b5c4ac6c 100644 --- a/packages/web3-eth-personal/types/tests/personal-tests.ts +++ b/packages/web3-eth-personal/types/tests/personal-tests.ts @@ -21,10 +21,9 @@ import {RLPEncodedTransaction} from 'web3-core'; import {Personal} from 'web3-eth-personal'; -import {HttpProvider} from 'web3-providers'; import {Accounts} from 'web3-eth-accounts'; -const personal = new Personal('http://localhost:7545', new Accounts('http://localhost:7545', {}), {}); +const personal = new Personal('http://localhost:7545', new Accounts('http://localhost:7545')); // $ExpectType Promise personal.newAccount('test password'); From a71d8bbc7107f75093c6219c99de1d39db7b79d7 Mon Sep 17 00:00:00 2001 From: Josh Stevens Date: Thu, 31 Jan 2019 11:54:30 +0000 Subject: [PATCH 07/17] allow web3-utils to work in projects with `"noImplicitAny": true,` --- packages/web3-utils/package-lock.json | 135 ++++++++++++++++++++------ packages/web3-utils/package.json | 1 + 2 files changed, 104 insertions(+), 32 deletions(-) diff --git a/packages/web3-utils/package-lock.json b/packages/web3-utils/package-lock.json index db04929b597..31e21a0ec7c 100644 --- a/packages/web3-utils/package-lock.json +++ b/packages/web3-utils/package-lock.json @@ -1,6 +1,8 @@ { - "requires": true, + "name": "web3-utils", + "version": "1.0.0-beta.41", "lockfileVersion": 1, + "requires": true, "dependencies": { "@babel/runtime": { "version": "7.3.1", @@ -10,25 +12,42 @@ "regenerator-runtime": "^0.12.0" } }, + "@types/bn.js": { + "version": "4.11.4", + "resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-4.11.4.tgz", + "integrity": "sha512-AO8WW+aRcKWKQAYTfKLzwnpL6U+TfPqS+haRrhCy5ff04Da8WZud3ZgVjspQXaEXJDcTlsjUEVvL39wegDek5w==", + "requires": { + "@types/node": "*" + } + }, "@types/node": { "version": "10.12.18", "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.18.tgz", "integrity": "sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ==" }, + "@types/parsimmon": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@types/parsimmon/-/parsimmon-1.10.0.tgz", + "integrity": "sha512-bsTIJFVQv7jnvNiC42ld2pQW2KRI+pAG243L+iATvqzy3X6+NH1obz2itRKDZZ8VVhN3wjwYax/VBGCcXzgTqQ==", + "dev": true + }, "ansi-regex": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", - "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true }, "ansi-styles": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", - "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=" + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true }, "argparse": { "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, "requires": { "sprintf-js": "~1.0.2" } @@ -37,6 +56,7 @@ "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", + "dev": true, "requires": { "chalk": "^1.1.3", "esutils": "^2.0.2", @@ -47,6 +67,7 @@ "version": "1.1.3", "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, "requires": { "ansi-styles": "^2.2.1", "escape-string-regexp": "^1.0.2", @@ -60,7 +81,8 @@ "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true }, "bn.js": { "version": "4.11.8", @@ -71,6 +93,7 @@ "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -89,12 +112,14 @@ "builtin-modules": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", - "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=" + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", + "dev": true }, "chalk": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, "requires": { "ansi-styles": "^3.2.1", "escape-string-regexp": "^1.0.5", @@ -105,6 +130,7 @@ "version": "3.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, "requires": { "color-convert": "^1.9.0" } @@ -113,6 +139,7 @@ "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, "requires": { "has-flag": "^3.0.0" } @@ -123,6 +150,7 @@ "version": "1.9.3", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, "requires": { "color-name": "1.1.3" } @@ -130,22 +158,26 @@ "color-name": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", - "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=", + "dev": true }, "commander": { "version": "2.19.0", "resolved": "https://registry.npmjs.org/commander/-/commander-2.19.0.tgz", - "integrity": "sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==" + "integrity": "sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==", + "dev": true }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true }, "crypto-js": { "version": "3.1.9-1", "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-3.1.9-1.tgz", - "integrity": "sha1-/aGedh/Ad+Af+/3G6f38WeiAbNg=" + "integrity": "sha1-/aGedh/Ad+Af+/3G6f38WeiAbNg=", + "dev": true }, "decode-uri-component": { "version": "0.2.0", @@ -160,10 +192,20 @@ "mimic-response": "^1.0.0" } }, + "definitelytyped-header-parser": { + "version": "github:Microsoft/definitelytyped-header-parser#e0561530379dfa01324a89936b75d90b20df9bd2", + "from": "github:Microsoft/definitelytyped-header-parser#production", + "dev": true, + "requires": { + "@types/parsimmon": "^1.3.0", + "parsimmon": "^1.2.0" + } + }, "diff": { "version": "3.5.0", "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", - "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==" + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "dev": true }, "dom-walk": { "version": "0.1.1", @@ -174,17 +216,13 @@ "version": "0.4.2", "resolved": "https://registry.npmjs.org/dtslint/-/dtslint-0.4.2.tgz", "integrity": "sha512-ph4GXLw3HYzlQMJOFcpCqWHuL3MxJ/344OR7wn0wlQGchQGTIVNsSUl8iKEMatpy2geNMysgA9fQa6xVhHOkTQ==", + "dev": true, "requires": { + "definitelytyped-header-parser": "github:Microsoft/definitelytyped-header-parser#e0561530379dfa01324a89936b75d90b20df9bd2", "fs-extra": "^6.0.1", "strip-json-comments": "^2.0.1", "tslint": "^5.12.0", "typescript": "^3.3.0-dev.20190126" - }, - "dependencies": { - "definitelytyped-header-parser": { - "version": "github:Microsoft/definitelytyped-header-parser#e0561530379dfa01324a89936b75d90b20df9bd2", - "from": "github:Microsoft/definitelytyped-header-parser#e0561530379dfa01324a89936b75d90b20df9bd2" - } } }, "elliptic": { @@ -204,17 +242,20 @@ "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", - "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true }, "esprima": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", - "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true }, "esutils": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", - "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=" + "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", + "dev": true }, "eth-lib": { "version": "0.2.8", @@ -254,6 +295,7 @@ "version": "6.0.1", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-6.0.1.tgz", "integrity": "sha512-GnyIkKhhzXZUWFCaJzvyDLEEgDkPfb4/TPvJCJVuS8MWZgoSsErf++QpiAlDnKFcqhRlm+tIOcencCjyJE6ZCA==", + "dev": true, "requires": { "graceful-fs": "^4.1.2", "jsonfile": "^4.0.0", @@ -263,12 +305,14 @@ "fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true }, "glob": { "version": "7.1.3", "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "dev": true, "requires": { "fs.realpath": "^1.0.0", "inflight": "^1.0.4", @@ -290,12 +334,14 @@ "graceful-fs": { "version": "4.1.15", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz", - "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==" + "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==", + "dev": true }, "has-ansi": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "dev": true, "requires": { "ansi-regex": "^2.0.0" } @@ -303,7 +349,8 @@ "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true }, "hash.js": { "version": "1.1.7", @@ -328,6 +375,7 @@ "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, "requires": { "once": "^1.3.0", "wrappy": "1" @@ -356,12 +404,14 @@ "js-tokens": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", - "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=" + "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=", + "dev": true }, "js-yaml": { "version": "3.12.1", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.1.tgz", "integrity": "sha512-um46hB9wNOKlwkHgiuyEVAybXBjwFUV0Z/RaHJblRd9DXltue9FTYvzCr9ErQrK9Adz5MU4gHWVaNUfdmrC8qA==", + "dev": true, "requires": { "argparse": "^1.0.7", "esprima": "^4.0.0" @@ -371,6 +421,7 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", + "dev": true, "requires": { "graceful-fs": "^4.1.6" } @@ -407,6 +458,7 @@ "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, "requires": { "brace-expansion": "^1.1.7" } @@ -449,15 +501,23 @@ "trim": "0.0.1" } }, + "parsimmon": { + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/parsimmon/-/parsimmon-1.12.0.tgz", + "integrity": "sha512-uC/BjuSfb4jfaWajKCp1mVncXXq+V1twbcYChbTxN3GM7fn+8XoHwUdvUz+PTaFtDSCRQxU8+Rnh+iMhAkVwdw==", + "dev": true + }, "path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true }, "path-parse": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz", - "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==" + "integrity": "sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==", + "dev": true }, "process": { "version": "0.5.2", @@ -488,6 +548,7 @@ "version": "1.10.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.10.0.tgz", "integrity": "sha512-3sUr9aq5OfSg2S9pNtPA9hL1FVEAjvfOC4leW0SNf/mpnaakz2a9femSd6LqAww2RaFctwyf1lCqnTHuF1rxDg==", + "dev": true, "requires": { "path-parse": "^1.0.6" } @@ -495,7 +556,8 @@ "semver": { "version": "5.6.0", "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", - "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==" + "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==", + "dev": true }, "simple-concat": { "version": "1.0.0", @@ -515,7 +577,8 @@ "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true }, "strict-uri-encode": { "version": "1.1.0", @@ -526,6 +589,7 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, "requires": { "ansi-regex": "^2.0.0" } @@ -541,12 +605,14 @@ "strip-json-comments": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", - "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=" + "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=", + "dev": true }, "supports-color": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", - "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=" + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true }, "timed-out": { "version": "4.0.1", @@ -561,12 +627,14 @@ "tslib": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", - "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==" + "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==", + "dev": true }, "tslint": { "version": "5.12.1", "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.12.1.tgz", "integrity": "sha512-sfodBHOucFg6egff8d1BvuofoOQ/nOeYNfbp7LDlKBcLNrL3lmS5zoiDGyOMdT7YsEXAwWpTdAHwOGOc8eRZAw==", + "dev": true, "requires": { "babel-code-frame": "^6.22.0", "builtin-modules": "^1.1.1", @@ -586,6 +654,7 @@ "version": "2.29.0", "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", + "dev": true, "requires": { "tslib": "^1.8.1" } @@ -593,12 +662,14 @@ "typescript": { "version": "3.3.0-dev.20190126", "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.3.0-dev.20190126.tgz", - "integrity": "sha512-wx5ZIi0Dn61N/H+TDLQIyG+DPvtk46t/lHeKmu2jwk5sW7GIPjVRPUJ5AR9ohdSkV0pEUshZolWSABz5f1pTAA==" + "integrity": "sha512-wx5ZIi0Dn61N/H+TDLQIyG+DPvtk46t/lHeKmu2jwk5sW7GIPjVRPUJ5AR9ohdSkV0pEUshZolWSABz5f1pTAA==", + "dev": true }, "universalify": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", - "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==" + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "dev": true }, "url-set-query": { "version": "1.0.0", diff --git a/packages/web3-utils/package.json b/packages/web3-utils/package.json index 3b029d14eaa..615cbe4c5d6 100644 --- a/packages/web3-utils/package.json +++ b/packages/web3-utils/package.json @@ -17,6 +17,7 @@ "types": "types", "dependencies": { "@babel/runtime": "^7.3.1", + "@types/bn.js": "^4.11.4", "@types/node": "^10.12.18", "bn.js": "4.11.8", "eth-lib": "0.2.8", From 91de3a3a10a22fd4b028d65a6a6836bb1bb4e15a Mon Sep 17 00:00:00 2001 From: Josh Stevens Date: Thu, 31 Jan 2019 15:23:17 +0000 Subject: [PATCH 08/17] use `require` to make the typings work as the imports `TS` does not enjoy. --- packages/web3-utils/types/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/web3-utils/types/index.d.ts b/packages/web3-utils/types/index.d.ts index aa8391bb3ad..e96f10a22be 100644 --- a/packages/web3-utils/types/index.d.ts +++ b/packages/web3-utils/types/index.d.ts @@ -20,7 +20,7 @@ * @date 2018 */ -import BigNumber from 'bn.js'; +import BigNumber = require('bn.js'); export type Unit = | 'noether' From f3b594b29e308d927009bdf8c4c202cca1d6ae6e Mon Sep 17 00:00:00 2001 From: Josh Stevens Date: Fri, 1 Feb 2019 10:27:09 +0000 Subject: [PATCH 09/17] fix: add `status` onto `TransactionReceipt` --- packages/web3-core/types/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/web3-core/types/index.d.ts b/packages/web3-core/types/index.d.ts index 85a298e2e3e..d398dabb5a5 100644 --- a/packages/web3-core/types/index.d.ts +++ b/packages/web3-core/types/index.d.ts @@ -123,6 +123,7 @@ export interface RLPEncodedTransaction { } export interface TransactionReceipt { + status: boolean; transactionHash: string; transactionIndex: number; blockHash: string; From ed4b9884a8c05e2849066d6342776ec0a08a5867 Mon Sep 17 00:00:00 2001 From: RussMist Date: Sat, 2 Feb 2019 16:06:08 +1000 Subject: [PATCH 10/17] assign payable property to AbiItemModel --- packages/web3-eth-contract/src/models/AbiItemModel.js | 1 + packages/web3-eth-contract/tests/src/models/AbiItemModelTest.js | 1 + 2 files changed, 2 insertions(+) diff --git a/packages/web3-eth-contract/src/models/AbiItemModel.js b/packages/web3-eth-contract/src/models/AbiItemModel.js index a735518f3d6..303e5c9f549 100644 --- a/packages/web3-eth-contract/src/models/AbiItemModel.js +++ b/packages/web3-eth-contract/src/models/AbiItemModel.js @@ -32,6 +32,7 @@ export default class AbiItemModel { this.abiItem = abiItem; this.signature = this.abiItem.signature; this.name = this.abiItem.name; + this.payable = this.abiItem.payable; this.anonymous = this.abiItem.anonymous; this.contractMethodParameters = []; } diff --git a/packages/web3-eth-contract/tests/src/models/AbiItemModelTest.js b/packages/web3-eth-contract/tests/src/models/AbiItemModelTest.js index 572a1bea24f..df1b4757ee5 100644 --- a/packages/web3-eth-contract/tests/src/models/AbiItemModelTest.js +++ b/packages/web3-eth-contract/tests/src/models/AbiItemModelTest.js @@ -11,6 +11,7 @@ describe('AbiItemModelTest', () => { signature: 'signature', name: 'name', anonymous: false, + payable: true, type: 'function', constant: true }; From f246043b6989b6b12ef9b96969fab9326391ddf2 Mon Sep 17 00:00:00 2001 From: Axel Galicia Date: Sat, 2 Feb 2019 20:45:30 +0000 Subject: [PATCH 11/17] [GH-2293]-Adding clarification of how data needs to be prefix before the UTF-8 HEX --- docs/web3-eth-personal.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/web3-eth-personal.rst b/docs/web3-eth-personal.rst index ad03ac2154f..cd272a57789 100644 --- a/docs/web3-eth-personal.rst +++ b/docs/web3-eth-personal.rst @@ -84,7 +84,9 @@ sign web3.eth.personal.sign(dataToSign, address, password [, callback]) -Signs data using a specific account. +Signs data using a specific account. This data is before UTF-8 HEX decoded and enveloped as follows: ``"\x19Ethereum Signed Message:\n" + message.length + message``. + + .. note:: Sending your account password over an unsecured HTTP RPC connection is highly unsecure. From 66c67af029250c447fc6197e08af5818e8c275ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20=C5=A0?= Date: Sun, 3 Feb 2019 11:45:53 +0100 Subject: [PATCH 12/17] Add missing quotes --- docs/web3-eth-ens.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/web3-eth-ens.rst b/docs/web3-eth-ens.rst index 20e602087f0..10572f0046e 100644 --- a/docs/web3-eth-ens.rst +++ b/docs/web3-eth-ens.rst @@ -12,7 +12,7 @@ The ``web3.eth.ens`` functions let you interacting with Ens. import Web3 from 'web3'; import {Ens} from 'web3-eth-ens'; - import {Accounts} from 'web3-eth-accounts; + import {Accounts} from 'web3-eth-accounts'; // "Web3.givenProvider" will be set if in an Ethereum supported browser. const eth = new Ens( @@ -388,7 +388,7 @@ Example .. code-block:: javascript - web3.eth.ens.getText('ethereum.eth', 'key).then((result) => { + web3.eth.ens.getText('ethereum.eth', 'key').then((result) => { console.log(result); }); > "0000000000000000000000000000000000000000000000000000000000000000" From 5549f57ee2e4758fa9de006c549bdd211d1cacfd Mon Sep 17 00:00:00 2001 From: Samuel Furter Date: Mon, 4 Feb 2019 10:33:58 +0100 Subject: [PATCH 13/17] randomHex export fixed in utils module --- packages/web3-utils/src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/web3-utils/src/index.js b/packages/web3-utils/src/index.js index c825c5913ea..7865e1f80c3 100644 --- a/packages/web3-utils/src/index.js +++ b/packages/web3-utils/src/index.js @@ -28,7 +28,7 @@ import * as utils from './Utils'; import * as ethjsUnit from 'ethjs-unit'; export {soliditySha3} from './SoliditySha3'; -export {randomHex} from 'randomhex'; +export randomHex from 'randomhex'; /** * Should be used to create full function/event name from json abi From 29e25a2a50ac92aaa775c25375e889d01e2f4900 Mon Sep 17 00:00:00 2001 From: Samuel Furter Date: Mon, 4 Feb 2019 10:52:43 +0100 Subject: [PATCH 14/17] parameters amount fixed in NewAccountMethod and NewAccountMethodTest updated --- .../web3-core-method/src/methods/personal/NewAccountMethod.js | 2 +- .../tests/src/methods/personal/NewAccountMethodTest.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/web3-core-method/src/methods/personal/NewAccountMethod.js b/packages/web3-core-method/src/methods/personal/NewAccountMethod.js index 4d589512bc1..801ed78612d 100644 --- a/packages/web3-core-method/src/methods/personal/NewAccountMethod.js +++ b/packages/web3-core-method/src/methods/personal/NewAccountMethod.js @@ -30,7 +30,7 @@ export default class NewAccountMethod extends AbstractCallMethod { * @constructor */ constructor(utils, formatters) { - super('personal_newAccount', 0, utils, formatters); + super('personal_newAccount', 1, utils, formatters); } /** diff --git a/packages/web3-core-method/tests/src/methods/personal/NewAccountMethodTest.js b/packages/web3-core-method/tests/src/methods/personal/NewAccountMethodTest.js index bb22737eb18..7ef1827c15b 100644 --- a/packages/web3-core-method/tests/src/methods/personal/NewAccountMethodTest.js +++ b/packages/web3-core-method/tests/src/methods/personal/NewAccountMethodTest.js @@ -20,7 +20,7 @@ describe('NewAccountMethodTest', () => { expect(method.rpcMethod).toEqual('personal_newAccount'); - expect(method.parametersAmount).toEqual(0); + expect(method.parametersAmount).toEqual(1); expect(method.utils).toEqual(Utils); From 8e8518c53477dc56bfbd0b1ef0159e4dba56f3a1 Mon Sep 17 00:00:00 2001 From: Samuel Furter Date: Mon, 4 Feb 2019 12:28:00 +0100 Subject: [PATCH 15/17] scope fixed with binding --- packages/web3-eth-accounts/src/Accounts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/web3-eth-accounts/src/Accounts.js b/packages/web3-eth-accounts/src/Accounts.js index 3529567da1e..dc8dd904f2a 100644 --- a/packages/web3-eth-accounts/src/Accounts.js +++ b/packages/web3-eth-accounts/src/Accounts.js @@ -89,7 +89,7 @@ export default class Accounts extends AbstractWeb3Module { _addAccountFunctions(account) { // add sign functions account.signTransaction = (tx, callback) => { - return this.signTransaction(tx, account.privateKey, callback); + return this.signTransaction(tx, account.privateKey, callback).bind(this); }; account.sign = (data) => { From 70bd06e5840739700f5b6465aea3c8c74d17bb80 Mon Sep 17 00:00:00 2001 From: Samuel Furter Date: Mon, 4 Feb 2019 14:07:09 +0100 Subject: [PATCH 16/17] CallMethod updated because of the optional default block parameter --- .../src/methods/CallMethod.js | 8 +++++++ .../tests/src/methods/CallMethodTest.js | 21 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/packages/web3-core-method/src/methods/CallMethod.js b/packages/web3-core-method/src/methods/CallMethod.js index e5e85f26d4b..65283ea88da 100644 --- a/packages/web3-core-method/src/methods/CallMethod.js +++ b/packages/web3-core-method/src/methods/CallMethod.js @@ -20,6 +20,7 @@ * @date 2018 */ +import isFunction from 'lodash/isFunction'; import AbstractCallMethod from '../../lib/methods/AbstractCallMethod'; export default class CallMethod extends AbstractCallMethod { @@ -42,6 +43,13 @@ export default class CallMethod extends AbstractCallMethod { */ beforeExecution(moduleInstance) { this.parameters[0] = this.formatters.inputCallFormatter(this.parameters[0], moduleInstance); + + // Optional second parameter 'defaultBlock' could also be the callback + if (isFunction(this.parameters[1])) { + this.callback = this.parameters[1]; + this.parameters[1] = moduleInstance.defaultBlock; + } + this.parameters[1] = this.formatters.inputDefaultBlockNumberFormatter(this.parameters[1], moduleInstance); } } diff --git a/packages/web3-core-method/tests/src/methods/CallMethodTest.js b/packages/web3-core-method/tests/src/methods/CallMethodTest.js index 1367beb8a9c..129e7fa1ed9 100644 --- a/packages/web3-core-method/tests/src/methods/CallMethodTest.js +++ b/packages/web3-core-method/tests/src/methods/CallMethodTest.js @@ -44,4 +44,25 @@ describe('CallMethodTest', () => { expect(formatters.inputCallFormatter).toHaveBeenCalledWith({}, {}); }); + + it('calls beforeExecution with a callback instead of the optional paramter and it calls the inputCallFormatter and inputDefaultBlockNumberFormatter', () => { + const callback = jest.fn(); + method.parameters = [{}, callback]; + + formatters.inputCallFormatter.mockReturnValueOnce({empty: true}); + + formatters.inputDefaultBlockNumberFormatter.mockReturnValueOnce('0x0'); + + method.beforeExecution({defaultBlock: 'latest'}); + + expect(method.callback).toEqual(callback); + + expect(method.parameters[0]).toEqual({empty: true}); + + expect(method.parameters[1]).toEqual('0x0'); + + expect(formatters.inputCallFormatter).toHaveBeenCalledWith({}, {defaultBlock: 'latest'}); + + expect(formatters.inputDefaultBlockNumberFormatter).toHaveBeenCalledWith('latest', {defaultBlock: 'latest'}); + }); }); From e0a8e1176cd4f7910572010addd7d9700ed22ff0 Mon Sep 17 00:00:00 2001 From: Samuel Furter Date: Mon, 4 Feb 2019 14:22:08 +0100 Subject: [PATCH 17/17] eslint fixed --- .eslintignore | 1 + packages/web3/angular-patch.js | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.eslintignore b/.eslintignore index ef24bbc4ac4..cb12fd758ac 100644 --- a/.eslintignore +++ b/.eslintignore @@ -9,3 +9,4 @@ jest.config.js jest.preprocessor.js W3cWebsocket.js packages/**/rollup.config.js +angular-patch.js diff --git a/packages/web3/angular-patch.js b/packages/web3/angular-patch.js index 50544745266..3a76568e4cd 100644 --- a/packages/web3/angular-patch.js +++ b/packages/web3/angular-patch.js @@ -1,16 +1,16 @@ const fs = require('fs'); const f = '../../node_modules/@angular-devkit/build-angular/src/angular-cli-files/models/webpack-configs/browser.js'; -// This is because we have to replace the `node:false` in the `/angular-cli-files/models/webpack-configs/browser.js` +// This is because we have to replace the `node:false` in the `/angular-cli-files/models/webpack-configs/browser.js` // with `node: {crypto: true, stream: true}` to allow web3 to work with angular (as they enforce node: false.) // as explained here - https://github.com/ethereum/web3.js/issues/2260#issuecomment-458519127 if (fs.existsSync(f)) { - fs.readFile(f, 'utf8', function (err, data) { + fs.readFile(f, 'utf8', function(err, data) { if (err) { return console.log(err); } var result = data.replace(/node: false/g, 'node: {crypto: true, stream: true}'); - fs.writeFile(f, result, 'utf8', function (err) { + fs.writeFile(f, result, 'utf8', function(err) { if (err) return console.log(err); }); });