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

Update sha3 and sha3Raw type definitions to accept Buffer #5357

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -586,4 +586,7 @@ Released with 1.0.0-beta.37 code base.

## [Unreleased]

## [1.7.6]
## [1.7.6]

### Changed
- Updated `sha3` and `sha3Raw` type definition to accept `Buffer`
4 changes: 2 additions & 2 deletions docs/web3-utils.rst
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,8 @@ sha3

.. code-block:: javascript

web3.utils.sha3(string)
web3.utils.keccak256(string) // ALIAS
web3.utils.sha3(string | BN | Buffer)
web3.utils.keccak256(string | BN | Buffer) // ALIAS

Will calculate the sha3 of the input.

Expand Down
4 changes: 2 additions & 2 deletions packages/web3-utils/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ export function padLeft(value: string | number, characterAmount: number, sign?:
export function leftPad(string: string | number, characterAmount: number, sign?: string): string;
export function rightPad(string: string | number, characterAmount: number, sign?: string): string;
export function padRight(string: string | number, characterAmount: number, sign?: string): string;
export function sha3(value: string | BN): string | null;
export function sha3Raw(value: string | BN): string;
export function sha3(value: string | BN | Buffer): string | null;
export function sha3Raw(value: string | BN | Buffer): string;
export function randomHex(bytesSize: number): string;
export function utf8ToHex(string: string): string;
export function stringToHex(string: string): string;
Expand Down
2 changes: 2 additions & 0 deletions packages/web3-utils/types/tests/sha3-raw-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import {sha3Raw} from 'web3-utils';
// $ExpectType string
sha3Raw('234');
// $ExpectType string
sha3Raw(Buffer.from('123'));
// $ExpectType string
sha3Raw(new BN(3));

// $ExpectError
Expand Down
2 changes: 2 additions & 0 deletions packages/web3-utils/types/tests/sha3-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import {sha3} from 'web3-utils';
// $ExpectType string | null
sha3('234');
// $ExpectType string | null
sha3(Buffer.from('123'));
// $ExpectType string | null
sha3(new BN(3));

// $ExpectError
Expand Down