Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Web3 utils full test coverage for types #2084

Merged
merged 62 commits into from
Dec 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
c5d1f87
added correct parameter types to docs for `sha3`
joshstevens19 Nov 30, 2018
cba0105
added new ts dependencies + added `dtslint`
joshstevens19 Nov 30, 2018
7dc253d
Removed `types` into folder and resolve some issues flagged
joshstevens19 Nov 30, 2018
97de83c
new package-lock.json
joshstevens19 Nov 30, 2018
0cf3eda
full type tests
joshstevens19 Nov 30, 2018
c89e469
tsconfig.json
joshstevens19 Nov 30, 2018
06fa6f1
tslint.json
joshstevens19 Nov 30, 2018
83ae913
indent imports
joshstevens19 Nov 30, 2018
5bd17f0
add a trailing line on tslint.json
joshstevens19 Nov 30, 2018
5da963f
move key dev dependencies in the root
joshstevens19 Dec 1, 2018
73c35ff
moved `ts` + `bn` into root but kept `dtslint`
joshstevens19 Dec 1, 2018
b2969f9
deleted huge test file to split in single files
joshstevens19 Dec 1, 2018
7a9d77a
remove comments
joshstevens19 Dec 1, 2018
bd75fa1
added some more rules for our test files
joshstevens19 Dec 1, 2018
b58a0fc
`asciiToHex` tests
joshstevens19 Dec 1, 2018
390f76d
`bytesToHex` tests
joshstevens19 Dec 1, 2018
494ab3b
`checkAddressChecksum` tests
joshstevens19 Dec 1, 2018
75c0c5b
`_fireError` tests
joshstevens19 Dec 1, 2018
3755e46
`_flattenTypes` tests
joshstevens19 Dec 1, 2018
f02c4a6
`fromAscii` tests
joshstevens19 Dec 1, 2018
9eeb0a5
`fromDecimal` tests
joshstevens19 Dec 1, 2018
a399954
`fromUtf8` tests
joshstevens19 Dec 1, 2018
c10a23e
`fromWei` tests
joshstevens19 Dec 1, 2018
362b66d
`getUnitValue` tests
joshstevens19 Dec 1, 2018
9d40f5b
hex tests
joshstevens19 Dec 1, 2018
c3e731e
is `type` tests
joshstevens19 Dec 1, 2018
7103a2f
to `type` tests
joshstevens19 Dec 1, 2018
1a13e74
`_jsonInterfaceMethodToString` tests
joshstevens19 Dec 1, 2018
df44740
`keccak256` tests
joshstevens19 Dec 1, 2018
b8d809c
`leftPad` tests
joshstevens19 Dec 1, 2018
8a0952a
`numberToHex` tests
joshstevens19 Dec 1, 2018
c24eb1a
`padLeft` tests
joshstevens19 Dec 1, 2018
1c2330a
`padRight` tests
joshstevens19 Dec 1, 2018
68f5165
`randomHex` tests
joshstevens19 Dec 1, 2018
eda17d2
`rightPad tests
joshstevens19 Dec 1, 2018
9d5315d
`sha3` tests
joshstevens19 Dec 1, 2018
f743420
`soliditySha3` tests
joshstevens19 Dec 1, 2018
c38fd03
`stringToHex` tests
joshstevens19 Dec 1, 2018
d1f3edd
`testAddress` tests
joshstevens19 Dec 1, 2018
4117a79
`testTopic` tests
joshstevens19 Dec 1, 2018
0d88ae3
`unitMap` tests
joshstevens19 Dec 1, 2018
ef10019
`utf8ToHex` tests
joshstevens19 Dec 1, 2018
f63e9c2
Rename `paths` to `web3-utils` to match real life
joshstevens19 Dec 1, 2018
a3b0dad
`_jsonInterfaceMethodToString` now returns `AbiItem`
joshstevens19 Dec 2, 2018
d947f66
new tests for `_jsonInterfaceMethodToString` with new `AbiItem`
joshstevens19 Dec 2, 2018
14ca4ba
`_flattenTypes` does not need `export` as its only used in this file now
joshstevens19 Dec 2, 2018
1101979
remove unneeded `_flattenTypes` tests
joshstevens19 Dec 2, 2018
cc158ff
renamed `AbiItem` > `ABIItem`
joshstevens19 Dec 2, 2018
aa53e0f
remove `s` on input as they are a single object and only `inputs` if …
joshstevens19 Dec 2, 2018
fe02d6a
remove `_fireError` as not used anymore
joshstevens19 Dec 2, 2018
373f8c0
remove `_fireError` tests
joshstevens19 Dec 2, 2018
1f8d770
remove `_fireError` types
joshstevens19 Dec 2, 2018
6020bb9
Add extra tests for some types
joshstevens19 Dec 2, 2018
42ec981
`_jsonInterfaceMethodToString` > `jsonInterfaceMethodToString` as it'…
joshstevens19 Dec 2, 2018
b752ce6
update package.json to include `types/index.d.ts`
joshstevens19 Dec 2, 2018
0888f8b
Make sure `@file` is correct in test files`
joshstevens19 Dec 2, 2018
e308d68
Update README.md
joshstevens19 Dec 2, 2018
8a4155d
add `ABIType` enum
joshstevens19 Dec 2, 2018
1c86fde
created `ABIType`
joshstevens19 Dec 2, 2018
1821c67
move generic stuff to the bottom to highlight it will need to be move…
joshstevens19 Dec 2, 2018
1f68134
fix merge conflicts
joshstevens19 Dec 3, 2018
6768764
Fix PR comments v2 :)
joshstevens19 Dec 3, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/_build/html/_sources/web3-utils.txt
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ sha3

.. code-block:: javascript

web3.utils.sha3(string)
web3.utils.keccak256(string) // ALIAS
web3.utils.sha3(mixed)
web3.utils.keccak256(mixed) // ALIAS

Will calculate the sha3 of the input.

Expand All @@ -223,7 +223,7 @@ Will calculate the sha3 of the input.
Parameters
----------

1. ``string`` - ``String``: A string to hash.
1. ``mixed`` - ``String|BN|BigNumber``: A input to hash.

-------
Returns
Expand Down
3,885 changes: 2,425 additions & 1,460 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@
"rollup-plugin-auto-external": "^2.0.0",
"rollup-plugin-babel": "^4.0.3",
"rollup-plugin-cleanup": "^3.0.0",
"rollup-plugin-json": "^3.1.0"
"rollup-plugin-json": "^3.1.0",
"@types/bn.js": "^4.11.3",
"typescript": "^3.2.1"
},
"dependencies": {
"@babel/polyfill": "^7.0.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/web3-eth-abi/src/AbiCoder.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default class AbiCoder {
*/
encodeFunctionSignature(functionName) {
if (isObject(functionName)) {
functionName = this.utils._jsonInterfaceMethodToString(functionName);
functionName = this.utils.jsonInterfaceMethodToString(functionName);
}

return this.utils.sha3(functionName).slice(0, 10);
Expand All @@ -73,7 +73,7 @@ export default class AbiCoder {
*/
encodeEventSignature(functionName) {
if (isObject(functionName)) {
functionName = this.utils._jsonInterfaceMethodToString(functionName);
functionName = this.utils.jsonInterfaceMethodToString(functionName);
}

return this.utils.sha3(functionName);
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-eth-contract/src/mappers/AbiMapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default class AbiMapper {
abiItem.payable = self.isPayable(abiItem);

if (abiItem.name) {
abiItem.funcName = self.utils._jsonInterfaceMethodToString(abiItem);
abiItem.funcName = self.utils.jsonInterfaceMethodToString(abiItem);
}

let abiItemModel;
Expand Down
13 changes: 11 additions & 2 deletions packages/web3-utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ This will expose the `Web3Utils` object on the window object.

## Usage

Import all of the utils functions

```js
import * as Utils from 'web3-utils';

Expand All @@ -39,12 +41,19 @@ console.log(Utils);
}
```

Import what you need
joshstevens19 marked this conversation as resolved.
Show resolved Hide resolved

```js
import { asciiToHex } from 'web3-utils';

console.log(asciiToHex('I have 100!'));
> "0x49206861766520313030e282ac"
```

## 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


153 changes: 0 additions & 153 deletions packages/web3-utils/index.d.ts

This file was deleted.

Loading