From 913b4c33a37e75776f35753eed56660398ad09cc Mon Sep 17 00:00:00 2001 From: Huan Zhang Date: Sat, 15 Dec 2018 23:55:22 +0000 Subject: [PATCH 01/13] all eth-personal types and tests --- packages/web3-eth-personal/README.md | 4 + packages/web3-eth-personal/package-lock.json | 406 +++++++++++++++++- packages/web3-eth-personal/package.json | 14 +- packages/web3-eth-personal/src/Personal.js | 2 +- packages/web3-eth-personal/types/index.d.ts | 60 +++ .../types/tests/personal-tests.ts | 130 ++++++ .../web3-eth-personal/types/tsconfig.json | 17 + packages/web3-eth-personal/types/tslint.json | 10 + 8 files changed, 630 insertions(+), 13 deletions(-) create mode 100644 packages/web3-eth-personal/types/index.d.ts create mode 100644 packages/web3-eth-personal/types/tests/personal-tests.ts create mode 100644 packages/web3-eth-personal/types/tsconfig.json create mode 100644 packages/web3-eth-personal/types/tslint.json diff --git a/packages/web3-eth-personal/README.md b/packages/web3-eth-personal/README.md index 79baf062636..1874e61a87e 100644 --- a/packages/web3-eth-personal/README.md +++ b/packages/web3-eth-personal/README.md @@ -37,6 +37,10 @@ const personal = new Personal( ); ``` +## Types + +If you are using TypeScript all the types are defined in the `index.d.ts` file. + [docs]: http://web3js.readthedocs.io/en/1.0/ [repo]: https://github.com/ethereum/web3.js diff --git a/packages/web3-eth-personal/package-lock.json b/packages/web3-eth-personal/package-lock.json index 3276e649339..1a85dc0b69b 100644 --- a/packages/web3-eth-personal/package-lock.json +++ b/packages/web3-eth-personal/package-lock.json @@ -2,18 +2,406 @@ "requires": true, "lockfileVersion": 1, "dependencies": { - "@babel/runtime": { - "version": "7.1.5", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.1.5.tgz", - "integrity": "sha512-xKnPpXG/pvK1B90JkwwxSGii90rQGKtzcMt2gI5G6+M0REXaq6rOHsGC2ay6/d0Uje7zzvSzjEzfR3ENhFlrfA==", + "@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==" + }, + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=" + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=" + }, + "any-promise": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", + "integrity": "sha1-q8av7tzqUugJzcA3au0845Y10X8=" + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "babel-code-frame": { + "version": "6.26.0", + "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", + "integrity": "sha1-Y/1D99weO7fONZR9uP42mj9Yx0s=", + "requires": { + "chalk": "^1.1.3", + "esutils": "^2.0.2", + "js-tokens": "^3.0.2" + }, + "dependencies": { + "chalk": { + "version": "1.1.3", + "resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "requires": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + } + } + } + }, + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "builtin-modules": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=" + }, + "chalk": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", + "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "dependencies": { + "ansi-styles": { + "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==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, + "commander": { + "version": "2.19.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.19.0.tgz", + "integrity": "sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==" + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "definitelytyped-header-parser": { + "version": "github:Microsoft/definitelytyped-header-parser#e0561530379dfa01324a89936b75d90b20df9bd2", + "from": "github:Microsoft/definitelytyped-header-parser#production", + "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==" + }, + "dtslint": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/dtslint/-/dtslint-0.3.0.tgz", + "integrity": "sha512-3oWL8MD+2nKaxmNzrt8EAissP63hNSJ4OLr/itvNnPdAAl+7vxnjQ8p2Zdk0MNgdenqwk7GcaUDz7fQHaPgCyA==", + "requires": { + "definitelytyped-header-parser": "github:Microsoft/definitelytyped-header-parser#e0561530379dfa01324a89936b75d90b20df9bd2", + "fs-promise": "^2.0.0", + "strip-json-comments": "^2.0.1", + "tslint": "^5.9.1", + "typescript": "^3.3.0-dev.20181214" + }, + "dependencies": { + "typescript": { + "version": "3.3.0-dev.20181214", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.3.0-dev.20181214.tgz", + "integrity": "sha512-dy3hilVp3gHsKEqj837gzo6YLn5IuX+5obTkdLJuvceYQ1B/fBnj4Y+FB44IQdmZ4oaeQd5+7u+uI6vDvp5FhQ==" + } + } + }, + "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=" + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==" + }, + "esutils": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", + "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=" + }, + "fs-extra": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-2.1.2.tgz", + "integrity": "sha1-BGxwFjzvmq1GsOSn+kZ/si1x3jU=", + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^2.1.0" + } + }, + "fs-promise": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/fs-promise/-/fs-promise-2.0.3.tgz", + "integrity": "sha1-9k5PhUvPaJqovdy6JokW2z20aFQ=", + "requires": { + "any-promise": "^1.3.0", + "fs-extra": "^2.0.0", + "mz": "^2.6.0", + "thenify-all": "^1.6.0" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "glob": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.3.tgz", + "integrity": "sha512-vcfuiIxogLV4DlGBHIUOwI0IbrJ8HWPc4MU7HzviGeNho/UJDfi6B5p3sHeWIQ0KGIU0Jpxi5ZHxemQfLkkAwQ==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "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==" + }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "js-tokens": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", + "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=" + }, + "js-yaml": { + "version": "3.12.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz", + "integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==", + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "jsonfile": { + "version": "2.4.0", + "resolved": "http://registry.npmjs.org/jsonfile/-/jsonfile-2.4.0.tgz", + "integrity": "sha1-NzaitCi4e72gzIO1P6PWM6NcKug=", + "requires": { + "graceful-fs": "^4.1.6" + } + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "mz": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz", + "integrity": "sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==", + "requires": { + "any-promise": "^1.0.0", + "object-assign": "^4.0.1", + "thenify-all": "^1.0.0" + } + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "requires": { - "regenerator-runtime": "^0.12.0" + "wrappy": "1" } }, - "regenerator-runtime": { - "version": "0.12.1", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.12.1.tgz", - "integrity": "sha512-odxIc1/vDlo4iZcfXqRYFj0vpXFNoGdKMAUieAlFYO6m/nl5e9KR/beGf41z4a1FI+aQgtjhuaSlDxQ0hmkrHg==" + "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==" + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "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==" + }, + "resolve": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.8.1.tgz", + "integrity": "sha512-AicPrAC7Qu1JxPCZ9ZgCZlY35QgFnNqc+0LtbRNxnVw4TXvjQ72wnuL9JQcEBgXkI9JM8MsT9kaQoHcpCRJOYA==", + "requires": { + "path-parse": "^1.0.5" + } + }, + "semver": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.6.0.tgz", + "integrity": "sha512-RS9R6R35NYgQn++fkDWaOmqGoj4Ek9gGs+DPxNUZKuwE183xjJroKvyo1IzVFeXvUrvmALy6FWD5xrdJT25gMg==" + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "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=" + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=" + }, + "thenify": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.0.tgz", + "integrity": "sha1-5p44obq+lpsBCCB5eLn2K4hgSDk=", + "requires": { + "any-promise": "^1.0.0" + } + }, + "thenify-all": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/thenify-all/-/thenify-all-1.6.0.tgz", + "integrity": "sha1-GhkY1ALY/D+Y+/I02wvMjMEOlyY=", + "requires": { + "thenify": ">= 3.1.0 < 4" + } + }, + "tslib": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", + "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==" + }, + "tslint": { + "version": "5.11.0", + "resolved": "https://registry.npmjs.org/tslint/-/tslint-5.11.0.tgz", + "integrity": "sha1-mPMMAurjzecAYgHkwzywi0hYHu0=", + "requires": { + "babel-code-frame": "^6.22.0", + "builtin-modules": "^1.1.1", + "chalk": "^2.3.0", + "commander": "^2.12.1", + "diff": "^3.2.0", + "glob": "^7.1.1", + "js-yaml": "^3.7.0", + "minimatch": "^3.0.4", + "resolve": "^1.3.2", + "semver": "^5.3.0", + "tslib": "^1.8.0", + "tsutils": "^2.27.2" + } + }, + "tsutils": { + "version": "2.29.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.29.0.tgz", + "integrity": "sha512-g5JVHCIJwzfISaXpXE1qvNalca5Jwob6FjI4AoPlqMusJ6ftFE7IkkFoMhVLRgK+4Kx3gkzb8UZK5t5yTTvEmA==", + "requires": { + "tslib": "^1.8.1" + } + }, + "typescript": { + "version": "3.3.0-dev.20181213", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.3.0-dev.20181213.tgz", + "integrity": "sha512-r5RkOJsu5zMQ3K0OMhX/w/kA8m0moO5lZg0SAjuiLGZ/LPQo+Q/ysuICqVK5B5vq/mYov0cTlJu0vEP2b7vQ+Q==" + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" } } } diff --git a/packages/web3-eth-personal/package.json b/packages/web3-eth-personal/package.json index d4bd61e7157..d0d2d414a71 100644 --- a/packages/web3-eth-personal/package.json +++ b/packages/web3-eth-personal/package.json @@ -11,17 +11,25 @@ "scripts": { "build": "rollup -c", "dev": "rollup -c -w", - "test": "jest" + "test": "jest", + "dtslint": "dtslint types --onlyTestTsNext" }, + "types": "types", "dependencies": { + "typescript": "^3.3.0-dev.20181213", "web3-core": "1.0.0-beta.36", "web3-core-helpers": "1.0.0-beta.36", "web3-core-method": "1.0.0-beta.36", + "web3-eth": "1.0.0-beta.36", "web3-net": "1.0.0-beta.36", "web3-providers": "1.0.0-beta.36", "web3-utils": "1.0.0-beta.36" }, "files": [ - "dist" - ] + "dist", + "types/index.d.ts" + ], + "devDependencies": { + "dtslint": "^0.3.0" + } } diff --git a/packages/web3-eth-personal/src/Personal.js b/packages/web3-eth-personal/src/Personal.js index 6885585c1d1..e945cc4411b 100644 --- a/packages/web3-eth-personal/src/Personal.js +++ b/packages/web3-eth-personal/src/Personal.js @@ -26,7 +26,7 @@ import {AbstractWeb3Module} from 'web3-core'; export default class Personal extends AbstractWeb3Module { /** * TODO: Add missing documentation for getAccounts, lockAccount and sendTransaction! - * @param {AbstractProviderAdapter|EthereumProvider} provider + * @param {AbstractProviderAdapter|EthereumProvider|HttpProvider|WebsocketProvider|IpcProvider|String} provider * @param {ProvidersModuleFactory} providersModuleFactory * @param {Object} providers * @param {MethodModuleFactory} methodModuleFactory diff --git a/packages/web3-eth-personal/types/index.d.ts b/packages/web3-eth-personal/types/index.d.ts new file mode 100644 index 00000000000..79b9c3d44f0 --- /dev/null +++ b/packages/web3-eth-personal/types/index.d.ts @@ -0,0 +1,60 @@ +/* + This file is part of web3.js. + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file index.d.ts + * @author Huan Zhang + * @date 2018 + */ + +import * as net from 'net'; +import {AbstractProviderAdapter, ProvidersModuleFactory, provider, BatchRequest} from 'web3-providers'; +import {AbstractWeb3Module, Web3ModuleOptions, Providers} from 'web3-core'; +import { Transaction, SignedTransaction } from 'web3-eth' +import { Network } from 'web3-net'; +export class Personal extends AbstractWeb3Module { + constructor( + provider: AbstractProviderAdapter | provider, + providersModuleFactory: ProvidersModuleFactory, + providers: Providers, + // dont have type yet + // as this is in web3-core-helpers + // can be sorted later once dependencies + // are cleaned up + methodModuleFactory: any, + // dont have type yet + // as this is in web3-core-method + // can be sorted later once dependencies + // are cleaned up + methodFactory: any, + net: Network, + formatters?: any, + utils?: any, + options?: Web3ModuleOptions + ) + + setProvider(provider: AbstractProviderAdapter | provider, net?: net.Server): boolean; + givenProvider: AbstractProviderAdapter; + BatchRequest: new() => BatchRequest; + providers: Providers; + newAccount(password: string, callback?: (error: Error, address: 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; + signTransaction(transation: Transaction, password: string, callback?: (error: Error, RLPEncodedTransaction: RLPEncodedTransaction) => void): Promise; + unlockAccount(address: string, password: string, unlockDuration: number, callback?: (error: Error) => void): void; +} + +export interface RLPEncodedTransaction { + raw: string, + tx: SignedTransaction +} diff --git a/packages/web3-eth-personal/types/tests/personal-tests.ts b/packages/web3-eth-personal/types/tests/personal-tests.ts new file mode 100644 index 00000000000..f22eef8645a --- /dev/null +++ b/packages/web3-eth-personal/types/tests/personal-tests.ts @@ -0,0 +1,130 @@ +/* + This file is part of web3.js. + web3.js is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + web3.js is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public License + along with web3.js. If not, see . +*/ +/** + * @file personal-tests.ts + * @author Huan Zhang + * @date 2018 + */ + +import * as net from 'net'; +import { Personal } from 'web3-eth-personal'; +import {ProvidersModuleFactory, HttpProvider, IpcProvider, WebsocketProvider, BatchRequest, JsonRpcMapper, JsonRpcResponseValidator} from 'web3-providers'; +import {Network} from 'web3-net'; + +const options = { + timeout: 20000, + headers: [ + { + name: 'Access-Control-Allow-Origin', value: '*' + } + ] +}; + +const networkOptions = { + defaultAccount: '0x5680b9a5b3f1614c5b8edf1c4e7aba991394bf6d', + defaultBlock: 600123, + transactionBlockTimeout: 50, + transactionConfirmationBlocks: 24, + transactionPollingTimeout: 15, + defaultGasPrice: '2', + defaultGas: 50000 +} + +const providersModuleFactory = new ProvidersModuleFactory(); +const httpProvider = new HttpProvider('http://localhost:8545', options); +const ipcProvider = new IpcProvider('/Users/myuser/Library/Ethereum/geth.ipc', new net.Server()); +const websocketProvider = new WebsocketProvider('ws://localhost:8546'); + +const batchRequest = new BatchRequest(httpProvider, JsonRpcMapper, JsonRpcResponseValidator); + +const PersonalClass = new Personal( + httpProvider, + providersModuleFactory, + { + HttpProvider: httpProvider, + WebsocketProvider: websocketProvider, + IpcProvider: ipcProvider + }, + {}, + {}, + new Network(httpProvider, networkOptions) +) + +// $ExpectType boolean +PersonalClass.setProvider(httpProvider) + +// $ExpectType Providers +PersonalClass.providers; + +// $ExpectType AbstractProviderAdapter +PersonalClass.givenProvider; + +// $ExpectType AbstractProviderAdapter +PersonalClass.currentProvider; + +// $ExpectType BatchRequest +new PersonalClass.BatchRequest(); + +// $ExpectType void +batchRequest.add({}) + +// $ExpectType void +batchRequest.execute(); + +// $ExpectType boolean +batchRequest.hasOutputFormatter({}); + +// $ExpectType Promise +PersonalClass.newAccount('test password'); + +// $ExpectType Promise +PersonalClass.newAccount('test password', (error: Error, address: string) => {}); + +// $ExpectType Promise +PersonalClass.sign('Hello world', '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', 'test password!'); + +// $ExpectType Promise +PersonalClass.sign('Hello world', '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', 'test password!', (error: Error, signature: string) => {}); + +// $ExpectType Promise +PersonalClass.ecRecover( + 'Hello world', + '0x30755ed65396facf86c53e6217c52b4daebe72aa4941d89635409de4c9c7f9466d4e9aaec7977f05e923889b33c0d0dd27d7226b6e6f56ce737465c5cfd04be400' +); + +// $ExpectType Promise +PersonalClass.ecRecover( + 'Hello world', + '0x30755ed65396facf86c53e6217c52b4daebe72aa4941d89635409de4c9c7f9466d4e9aaec7977f05e923889b33c0d0dd27d7226b6e6f56ce737465c5cfd04be400', + (error: Error, address: string) => {} +); + +// $ExpectType Promise +PersonalClass.signTransaction( + { + from: "0xEB014f8c8B418Db6b45774c326A0E64C78914dC0", + gasPrice: "20000000000", + gas: "21000", + to: '0x3535353535353535353535353535353535353535', + value: "1000000000000000000", + data: "" + }, + 'test password' +); + +// $ExpectType void +PersonalClass.unlockAccount("0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe", "test password!", 600); + +// $ExpectType void +PersonalClass.unlockAccount("0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe", "test password!", 600, (error: Error) => {}); diff --git a/packages/web3-eth-personal/types/tsconfig.json b/packages/web3-eth-personal/types/tsconfig.json new file mode 100644 index 00000000000..95216e0b19d --- /dev/null +++ b/packages/web3-eth-personal/types/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6"], + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "noEmit": true, + "allowSyntheticDefaultImports": true, + "baseUrl": ".", + "paths": { + "web3-eth-personal": ["."] + } + } +} diff --git a/packages/web3-eth-personal/types/tslint.json b/packages/web3-eth-personal/types/tslint.json new file mode 100644 index 00000000000..6429b0c446e --- /dev/null +++ b/packages/web3-eth-personal/types/tslint.json @@ -0,0 +1,10 @@ +{ + "extends": "dtslint/dtslint.json", + "rules": { + "semicolon": false, + "no-import-default-of-export-equals": false, + "file-name-casing": [true, "kebab-case"], + "whitespace": false, + "no-unnecessary-class": false + } +} From d97578fbe48b1bdc16e653d5c7ac76427a12ad85 Mon Sep 17 00:00:00 2001 From: Huan Zhang Date: Sun, 16 Dec 2018 00:10:51 +0000 Subject: [PATCH 02/13] remove TS from package dependency --- packages/web3-eth-personal/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/web3-eth-personal/package.json b/packages/web3-eth-personal/package.json index d0d2d414a71..a8c3389d4b8 100644 --- a/packages/web3-eth-personal/package.json +++ b/packages/web3-eth-personal/package.json @@ -16,7 +16,6 @@ }, "types": "types", "dependencies": { - "typescript": "^3.3.0-dev.20181213", "web3-core": "1.0.0-beta.36", "web3-core-helpers": "1.0.0-beta.36", "web3-core-method": "1.0.0-beta.36", From 8acc968e5d6b127352a3d6fa2e582bcf4641c0a5 Mon Sep 17 00:00:00 2001 From: Huan Zhang Date: Sun, 16 Dec 2018 00:24:58 +0000 Subject: [PATCH 03/13] fix personal constructor and update PersonalClass in test --- packages/web3-eth-personal/package.json | 1 - packages/web3-eth-personal/types/index.d.ts | 45 +++++++++++-------- .../types/tests/personal-tests.ts | 27 +---------- 3 files changed, 28 insertions(+), 45 deletions(-) diff --git a/packages/web3-eth-personal/package.json b/packages/web3-eth-personal/package.json index a8c3389d4b8..f3662c51e9a 100644 --- a/packages/web3-eth-personal/package.json +++ b/packages/web3-eth-personal/package.json @@ -19,7 +19,6 @@ "web3-core": "1.0.0-beta.36", "web3-core-helpers": "1.0.0-beta.36", "web3-core-method": "1.0.0-beta.36", - "web3-eth": "1.0.0-beta.36", "web3-net": "1.0.0-beta.36", "web3-providers": "1.0.0-beta.36", "web3-utils": "1.0.0-beta.36" diff --git a/packages/web3-eth-personal/types/index.d.ts b/packages/web3-eth-personal/types/index.d.ts index 79b9c3d44f0..a2f0b100c87 100644 --- a/packages/web3-eth-personal/types/index.d.ts +++ b/packages/web3-eth-personal/types/index.d.ts @@ -20,29 +20,12 @@ import * as net from 'net'; import {AbstractProviderAdapter, ProvidersModuleFactory, provider, BatchRequest} from 'web3-providers'; import {AbstractWeb3Module, Web3ModuleOptions, Providers} from 'web3-core'; -import { Transaction, SignedTransaction } from 'web3-eth' -import { Network } from 'web3-net'; +import {Network} from 'web3-net'; export class Personal extends AbstractWeb3Module { constructor( provider: AbstractProviderAdapter | provider, - providersModuleFactory: ProvidersModuleFactory, - providers: Providers, - // dont have type yet - // as this is in web3-core-helpers - // can be sorted later once dependencies - // are cleaned up - methodModuleFactory: any, - // dont have type yet - // as this is in web3-core-method - // can be sorted later once dependencies - // are cleaned up - methodFactory: any, - net: Network, - formatters?: any, - utils?: any, options?: Web3ModuleOptions - ) - + ); setProvider(provider: AbstractProviderAdapter | provider, net?: net.Server): boolean; givenProvider: AbstractProviderAdapter; BatchRequest: new() => BatchRequest; @@ -54,6 +37,30 @@ export class Personal extends AbstractWeb3Module { unlockAccount(address: string, password: string, unlockDuration: number, callback?: (error: Error) => void): void; } +// Josh to move to web3-core +export interface Transaction { + from?: string | number; + to?: string; + gasPrice?: string; + gas?: number | string; + value?: number | string; + chainId?: number; + data?: string; + nonce?: number; + v?: string; + r?: string; + s?: string; + hash?: string; +} + +export interface SignedTransaction { + messageHash?: string; + r: string; + s: string; + v: string; + rawTransaction?: string; +} + export interface RLPEncodedTransaction { raw: string, tx: SignedTransaction diff --git a/packages/web3-eth-personal/types/tests/personal-tests.ts b/packages/web3-eth-personal/types/tests/personal-tests.ts index f22eef8645a..8cb0022fed2 100644 --- a/packages/web3-eth-personal/types/tests/personal-tests.ts +++ b/packages/web3-eth-personal/types/tests/personal-tests.ts @@ -17,9 +17,8 @@ * @date 2018 */ -import * as net from 'net'; -import { Personal } from 'web3-eth-personal'; -import {ProvidersModuleFactory, HttpProvider, IpcProvider, WebsocketProvider, BatchRequest, JsonRpcMapper, JsonRpcResponseValidator} from 'web3-providers'; +import {Personal} from 'web3-eth-personal'; +import {HttpProvider, BatchRequest, JsonRpcMapper, JsonRpcResponseValidator} from 'web3-providers'; import {Network} from 'web3-net'; const options = { @@ -31,34 +30,12 @@ const options = { ] }; -const networkOptions = { - defaultAccount: '0x5680b9a5b3f1614c5b8edf1c4e7aba991394bf6d', - defaultBlock: 600123, - transactionBlockTimeout: 50, - transactionConfirmationBlocks: 24, - transactionPollingTimeout: 15, - defaultGasPrice: '2', - defaultGas: 50000 -} - -const providersModuleFactory = new ProvidersModuleFactory(); const httpProvider = new HttpProvider('http://localhost:8545', options); -const ipcProvider = new IpcProvider('/Users/myuser/Library/Ethereum/geth.ipc', new net.Server()); -const websocketProvider = new WebsocketProvider('ws://localhost:8546'); const batchRequest = new BatchRequest(httpProvider, JsonRpcMapper, JsonRpcResponseValidator); const PersonalClass = new Personal( httpProvider, - providersModuleFactory, - { - HttpProvider: httpProvider, - WebsocketProvider: websocketProvider, - IpcProvider: ipcProvider - }, - {}, - {}, - new Network(httpProvider, networkOptions) ) // $ExpectType boolean From b19e21de58a0bd19f4b7d7266be973040805ac5d Mon Sep 17 00:00:00 2001 From: Huan Zhang Date: Sun, 16 Dec 2018 18:06:12 +0000 Subject: [PATCH 04/13] remove SignedTransaction interface and switch to Transaction --- packages/web3-eth-personal/types/index.d.ts | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/packages/web3-eth-personal/types/index.d.ts b/packages/web3-eth-personal/types/index.d.ts index a2f0b100c87..caf9dae1047 100644 --- a/packages/web3-eth-personal/types/index.d.ts +++ b/packages/web3-eth-personal/types/index.d.ts @@ -53,15 +53,7 @@ export interface Transaction { hash?: string; } -export interface SignedTransaction { - messageHash?: string; - r: string; - s: string; - v: string; - rawTransaction?: string; -} - export interface RLPEncodedTransaction { raw: string, - tx: SignedTransaction + tx: Transaction } From b8f6fc490a14794aa7c3660cb8bff62f35b0ad0f Mon Sep 17 00:00:00 2001 From: Huan Zhang Date: Sun, 16 Dec 2018 18:08:40 +0000 Subject: [PATCH 05/13] remove unused imports and also BatchRequest, change PersonalClass to personal --- packages/web3-eth-personal/types/index.d.ts | 2 +- .../types/tests/personal-tests.ts | 43 +++++++------------ 2 files changed, 17 insertions(+), 28 deletions(-) diff --git a/packages/web3-eth-personal/types/index.d.ts b/packages/web3-eth-personal/types/index.d.ts index caf9dae1047..edf27ec0b2a 100644 --- a/packages/web3-eth-personal/types/index.d.ts +++ b/packages/web3-eth-personal/types/index.d.ts @@ -18,7 +18,7 @@ */ import * as net from 'net'; -import {AbstractProviderAdapter, ProvidersModuleFactory, provider, BatchRequest} from 'web3-providers'; +import {AbstractProviderAdapter, provider, BatchRequest} from 'web3-providers'; import {AbstractWeb3Module, Web3ModuleOptions, Providers} from 'web3-core'; import {Network} from 'web3-net'; export class Personal extends AbstractWeb3Module { diff --git a/packages/web3-eth-personal/types/tests/personal-tests.ts b/packages/web3-eth-personal/types/tests/personal-tests.ts index 8cb0022fed2..48e3f2378e3 100644 --- a/packages/web3-eth-personal/types/tests/personal-tests.ts +++ b/packages/web3-eth-personal/types/tests/personal-tests.ts @@ -18,7 +18,7 @@ */ import {Personal} from 'web3-eth-personal'; -import {HttpProvider, BatchRequest, JsonRpcMapper, JsonRpcResponseValidator} from 'web3-providers'; +import {HttpProvider} from 'web3-providers'; import {Network} from 'web3-net'; const options = { @@ -32,63 +32,52 @@ const options = { const httpProvider = new HttpProvider('http://localhost:8545', options); -const batchRequest = new BatchRequest(httpProvider, JsonRpcMapper, JsonRpcResponseValidator); - -const PersonalClass = new Personal( +const personal = new Personal( httpProvider, ) // $ExpectType boolean -PersonalClass.setProvider(httpProvider) +personal.setProvider(httpProvider) // $ExpectType Providers -PersonalClass.providers; +personal.providers; // $ExpectType AbstractProviderAdapter -PersonalClass.givenProvider; +personal.givenProvider; // $ExpectType AbstractProviderAdapter -PersonalClass.currentProvider; +personal.currentProvider; // $ExpectType BatchRequest -new PersonalClass.BatchRequest(); - -// $ExpectType void -batchRequest.add({}) - -// $ExpectType void -batchRequest.execute(); - -// $ExpectType boolean -batchRequest.hasOutputFormatter({}); +new personal.BatchRequest(); // $ExpectType Promise -PersonalClass.newAccount('test password'); +personal.newAccount('test password'); // $ExpectType Promise -PersonalClass.newAccount('test password', (error: Error, address: string) => {}); +personal.newAccount('test password', (error: Error, address: string) => {}); // $ExpectType Promise -PersonalClass.sign('Hello world', '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', 'test password!'); +personal.sign('Hello world', '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', 'test password!'); // $ExpectType Promise -PersonalClass.sign('Hello world', '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', 'test password!', (error: Error, signature: string) => {}); +personal.sign('Hello world', '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', 'test password!', (error: Error, signature: string) => {}); // $ExpectType Promise -PersonalClass.ecRecover( +personal.ecRecover( 'Hello world', '0x30755ed65396facf86c53e6217c52b4daebe72aa4941d89635409de4c9c7f9466d4e9aaec7977f05e923889b33c0d0dd27d7226b6e6f56ce737465c5cfd04be400' ); // $ExpectType Promise -PersonalClass.ecRecover( +personal.ecRecover( 'Hello world', '0x30755ed65396facf86c53e6217c52b4daebe72aa4941d89635409de4c9c7f9466d4e9aaec7977f05e923889b33c0d0dd27d7226b6e6f56ce737465c5cfd04be400', (error: Error, address: string) => {} ); // $ExpectType Promise -PersonalClass.signTransaction( +personal.signTransaction( { from: "0xEB014f8c8B418Db6b45774c326A0E64C78914dC0", gasPrice: "20000000000", @@ -101,7 +90,7 @@ PersonalClass.signTransaction( ); // $ExpectType void -PersonalClass.unlockAccount("0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe", "test password!", 600); +personal.unlockAccount("0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe", "test password!", 600); // $ExpectType void -PersonalClass.unlockAccount("0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe", "test password!", 600, (error: Error) => {}); +personal.unlockAccount("0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe", "test password!", 600, (error: Error) => {}); From e82424e8f57627f05f70630e872184a62f9f005c Mon Sep 17 00:00:00 2001 From: Huan Zhang Date: Sun, 16 Dec 2018 18:11:43 +0000 Subject: [PATCH 06/13] fix formatting --- .../types/tests/personal-tests.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/web3-eth-personal/types/tests/personal-tests.ts b/packages/web3-eth-personal/types/tests/personal-tests.ts index 48e3f2378e3..0ed2b7ae206 100644 --- a/packages/web3-eth-personal/types/tests/personal-tests.ts +++ b/packages/web3-eth-personal/types/tests/personal-tests.ts @@ -66,31 +66,31 @@ personal.sign('Hello world', '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', 'test // $ExpectType Promise personal.ecRecover( 'Hello world', - '0x30755ed65396facf86c53e6217c52b4daebe72aa4941d89635409de4c9c7f9466d4e9aaec7977f05e923889b33c0d0dd27d7226b6e6f56ce737465c5cfd04be400' + '0x30755ed65396facf86c53e6217c52b4daebe72aa' ); // $ExpectType Promise personal.ecRecover( 'Hello world', - '0x30755ed65396facf86c53e6217c52b4daebe72aa4941d89635409de4c9c7f9466d4e9aaec7977f05e923889b33c0d0dd27d7226b6e6f56ce737465c5cfd04be400', + '0x30755ed65396facf86c53e6217c52b4daebe72aa', (error: Error, address: string) => {} ); // $ExpectType Promise personal.signTransaction( { - from: "0xEB014f8c8B418Db6b45774c326A0E64C78914dC0", - gasPrice: "20000000000", - gas: "21000", + from: '0xEB014f8c8B418Db6b45774c326A0E64C78914dC0', + gasPrice: '20000000000', + gas: '21000', to: '0x3535353535353535353535353535353535353535', - value: "1000000000000000000", - data: "" + value: '1000000000000000000', + data: '' }, 'test password' ); // $ExpectType void -personal.unlockAccount("0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe", "test password!", 600); +personal.unlockAccount('0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', 'test password!', 600); // $ExpectType void -personal.unlockAccount("0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe", "test password!", 600, (error: Error) => {}); +personal.unlockAccount('0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', 'test password!', 600, (error: Error) => {}); From 69273310464fedb997ce97735bbb98ad9ba0e8ec Mon Sep 17 00:00:00 2001 From: Huan Zhang Date: Sun, 16 Dec 2018 18:17:44 +0000 Subject: [PATCH 07/13] add test for signTransaction callback and remove linebreaks between same method tests --- .../types/tests/personal-tests.ts | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/packages/web3-eth-personal/types/tests/personal-tests.ts b/packages/web3-eth-personal/types/tests/personal-tests.ts index 0ed2b7ae206..d420c806be3 100644 --- a/packages/web3-eth-personal/types/tests/personal-tests.ts +++ b/packages/web3-eth-personal/types/tests/personal-tests.ts @@ -17,7 +17,7 @@ * @date 2018 */ -import {Personal} from 'web3-eth-personal'; +import {Personal, RLPEncodedTransaction} from 'web3-eth-personal'; import {HttpProvider} from 'web3-providers'; import {Network} from 'web3-net'; @@ -53,13 +53,11 @@ new personal.BatchRequest(); // $ExpectType Promise personal.newAccount('test password'); - // $ExpectType Promise 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) => {}); @@ -68,7 +66,6 @@ personal.ecRecover( 'Hello world', '0x30755ed65396facf86c53e6217c52b4daebe72aa' ); - // $ExpectType Promise personal.ecRecover( 'Hello world', @@ -88,9 +85,21 @@ personal.signTransaction( }, 'test password' ); +// $ExpectType Promise +personal.signTransaction( + { + from: '0xEB014f8c8B418Db6b45774c326A0E64C78914dC0', + gasPrice: '20000000000', + gas: '21000', + to: '0x3535353535353535353535353535353535353535', + value: '1000000000000000000', + data: '' + }, + 'test password', + (error: Error, RLPEncodedTransaction: RLPEncodedTransaction) => {} +) -// $ExpectType void +// $ExpectType Promise personal.unlockAccount('0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', 'test password!', 600); - -// $ExpectType void +// $ExpectType Promise personal.unlockAccount('0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', 'test password!', 600, (error: Error) => {}); From 896320ba43ad697693aa78295e1550d47228c046 Mon Sep 17 00:00:00 2001 From: Huan Zhang Date: Sun, 16 Dec 2018 18:23:53 +0000 Subject: [PATCH 08/13] fix return type for unlockAccount and update documentation --- docs/web3-eth-personal.rst | 7 +++++++ packages/web3-eth-personal/types/index.d.ts | 4 ++-- packages/web3-eth-personal/types/tests/personal-tests.ts | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/web3-eth-personal.rst b/docs/web3-eth-personal.rst index a2c51305971..c7029e04741 100644 --- a/docs/web3-eth-personal.rst +++ b/docs/web3-eth-personal.rst @@ -247,6 +247,13 @@ Parameters 2. ``password`` - ``String`` - The password of the account. 3. ``unlockDuration`` - ``Number`` - The duration for the account to remain unlocked. +------- +Returns +------- + + +``Promise`` returns ``void`` + ------- Example ------- diff --git a/packages/web3-eth-personal/types/index.d.ts b/packages/web3-eth-personal/types/index.d.ts index edf27ec0b2a..82a03131763 100644 --- a/packages/web3-eth-personal/types/index.d.ts +++ b/packages/web3-eth-personal/types/index.d.ts @@ -27,14 +27,14 @@ export class Personal extends AbstractWeb3Module { options?: Web3ModuleOptions ); setProvider(provider: AbstractProviderAdapter | provider, net?: net.Server): boolean; - givenProvider: AbstractProviderAdapter; + givenProvider: AbstractProviderAdapter | null; BatchRequest: new() => BatchRequest; providers: Providers; newAccount(password: string, callback?: (error: Error, address: 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; signTransaction(transation: Transaction, password: string, callback?: (error: Error, RLPEncodedTransaction: RLPEncodedTransaction) => void): Promise; - unlockAccount(address: string, password: string, unlockDuration: number, callback?: (error: Error) => void): void; + unlockAccount(address: string, password: string, unlockDuration: number, callback?: (error: Error) => void): Promise; } // Josh to move to web3-core diff --git a/packages/web3-eth-personal/types/tests/personal-tests.ts b/packages/web3-eth-personal/types/tests/personal-tests.ts index d420c806be3..424425d12cf 100644 --- a/packages/web3-eth-personal/types/tests/personal-tests.ts +++ b/packages/web3-eth-personal/types/tests/personal-tests.ts @@ -42,7 +42,7 @@ personal.setProvider(httpProvider) // $ExpectType Providers personal.providers; -// $ExpectType AbstractProviderAdapter +// $ExpectType AbstractProviderAdapter | null personal.givenProvider; // $ExpectType AbstractProviderAdapter From ab29c7da82e4aadd0ac76477f12d6f75990c285e Mon Sep 17 00:00:00 2001 From: Huan Zhang Date: Sun, 16 Dec 2018 18:26:01 +0000 Subject: [PATCH 09/13] remove linebreaks for ecRecover --- .../web3-eth-personal/types/tests/personal-tests.ts | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/packages/web3-eth-personal/types/tests/personal-tests.ts b/packages/web3-eth-personal/types/tests/personal-tests.ts index 424425d12cf..b4a38451f35 100644 --- a/packages/web3-eth-personal/types/tests/personal-tests.ts +++ b/packages/web3-eth-personal/types/tests/personal-tests.ts @@ -62,16 +62,9 @@ personal.sign('Hello world', '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', 'test personal.sign('Hello world', '0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', 'test password!', (error: Error, signature: string) => {}); // $ExpectType Promise -personal.ecRecover( - 'Hello world', - '0x30755ed65396facf86c53e6217c52b4daebe72aa' -); +personal.ecRecover('Hello world', '0x30755ed65396facf86c53e6217c52b4daebe72aa'); // $ExpectType Promise -personal.ecRecover( - 'Hello world', - '0x30755ed65396facf86c53e6217c52b4daebe72aa', - (error: Error, address: string) => {} -); +personal.ecRecover('Hello world', '0x30755ed65396facf86c53e6217c52b4daebe72aa', (error: Error, address: string) => {}); // $ExpectType Promise personal.signTransaction( From f78649d376359d5418eb6a4d3206460819924643 Mon Sep 17 00:00:00 2001 From: Huan Zhang Date: Sun, 16 Dec 2018 23:22:06 +0000 Subject: [PATCH 10/13] remove unused import --- packages/web3-eth-personal/types/index.d.ts | 1 - packages/web3-eth-personal/types/tests/personal-tests.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/packages/web3-eth-personal/types/index.d.ts b/packages/web3-eth-personal/types/index.d.ts index 82a03131763..d3ee28b7941 100644 --- a/packages/web3-eth-personal/types/index.d.ts +++ b/packages/web3-eth-personal/types/index.d.ts @@ -20,7 +20,6 @@ import * as net from 'net'; import {AbstractProviderAdapter, provider, BatchRequest} from 'web3-providers'; import {AbstractWeb3Module, Web3ModuleOptions, Providers} from 'web3-core'; -import {Network} from 'web3-net'; export class Personal extends AbstractWeb3Module { constructor( provider: AbstractProviderAdapter | provider, diff --git a/packages/web3-eth-personal/types/tests/personal-tests.ts b/packages/web3-eth-personal/types/tests/personal-tests.ts index b4a38451f35..a0f96811737 100644 --- a/packages/web3-eth-personal/types/tests/personal-tests.ts +++ b/packages/web3-eth-personal/types/tests/personal-tests.ts @@ -19,7 +19,6 @@ import {Personal, RLPEncodedTransaction} from 'web3-eth-personal'; import {HttpProvider} from 'web3-providers'; -import {Network} from 'web3-net'; const options = { timeout: 20000, From 9881f1df323f17aba50f55f742c4d37e48fcb04d Mon Sep 17 00:00:00 2001 From: Josh Stevens Date: Mon, 17 Dec 2018 08:40:31 +0000 Subject: [PATCH 11/13] Update unlock duration docs --- docs/web3-eth-personal.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/web3-eth-personal.rst b/docs/web3-eth-personal.rst index c7029e04741..c8f199cbcd3 100644 --- a/docs/web3-eth-personal.rst +++ b/docs/web3-eth-personal.rst @@ -252,7 +252,7 @@ Returns ------- -``Promise`` returns ``void`` +``Promise`` returns ``Boolean`` ------- Example From 28a011fc53d6b84708183b8bbb241c50938c9726 Mon Sep 17 00:00:00 2001 From: Josh Stevens Date: Mon, 17 Dec 2018 08:41:04 +0000 Subject: [PATCH 12/13] Update `unlockAccount` to return `Promise` --- packages/web3-eth-personal/types/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/web3-eth-personal/types/index.d.ts b/packages/web3-eth-personal/types/index.d.ts index d3ee28b7941..a3999e1172d 100644 --- a/packages/web3-eth-personal/types/index.d.ts +++ b/packages/web3-eth-personal/types/index.d.ts @@ -33,7 +33,7 @@ export class Personal extends AbstractWeb3Module { 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; signTransaction(transation: Transaction, password: string, callback?: (error: Error, RLPEncodedTransaction: RLPEncodedTransaction) => void): Promise; - unlockAccount(address: string, password: string, unlockDuration: number, callback?: (error: Error) => void): Promise; + unlockAccount(address: string, password: string, unlockDuration: number, callback?: (error: Error) => void): Promise; } // Josh to move to web3-core From 5f7c02ed9f614a7ae2cdf7461bf5a0645b2d8a32 Mon Sep 17 00:00:00 2001 From: Josh Stevens Date: Mon, 17 Dec 2018 08:41:37 +0000 Subject: [PATCH 13/13] Fix `unlockAccount` tests --- packages/web3-eth-personal/types/tests/personal-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 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 a0f96811737..7565789935b 100644 --- a/packages/web3-eth-personal/types/tests/personal-tests.ts +++ b/packages/web3-eth-personal/types/tests/personal-tests.ts @@ -91,7 +91,7 @@ personal.signTransaction( (error: Error, RLPEncodedTransaction: RLPEncodedTransaction) => {} ) -// $ExpectType Promise +// $ExpectType Promise personal.unlockAccount('0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', 'test password!', 600); -// $ExpectType Promise +// $ExpectType Promise personal.unlockAccount('0x11f4d0A3c12e86B4b5F39B213F7E19D048276DAe', 'test password!', 600, (error: Error) => {});