Skip to content

Commit

Permalink
Update sha3 and sha3Raw type definitions to accept Buffer (#5357)
Browse files Browse the repository at this point in the history
* Update sha3 type def to accept Buffer
  • Loading branch information
Muhammad-Altabba committed Aug 18, 2022
1 parent 9f4e7c0 commit 4524ea0
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
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
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
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
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
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

0 comments on commit 4524ea0

Please sign in to comment.