Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit 62ed500

Browse files
Update sha3 type def to accept Buffer
1 parent 276a72b commit 62ed500

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

docs/web3-utils.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ sha3
218218

219219
.. code-block:: javascript
220220
221-
web3.utils.sha3(string)
222-
web3.utils.keccak256(string) // ALIAS
221+
web3.utils.sha3(string | BN | Buffer)
222+
web3.utils.keccak256(string | BN | Buffer) // ALIAS
223223
224224
Will calculate the sha3 of the input.
225225

packages/web3-utils/types/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ export function padLeft(value: string | number, characterAmount: number, sign?:
9595
export function leftPad(string: string | number, characterAmount: number, sign?: string): string;
9696
export function rightPad(string: string | number, characterAmount: number, sign?: string): string;
9797
export function padRight(string: string | number, characterAmount: number, sign?: string): string;
98-
export function sha3(value: string | BN): string | null;
99-
export function sha3Raw(value: string | BN): string;
98+
export function sha3(value: string | BN | Buffer): string | null;
99+
export function sha3Raw(value: string | BN | Buffer): string;
100100
export function randomHex(bytesSize: number): string;
101101
export function utf8ToHex(string: string): string;
102102
export function stringToHex(string: string): string;

packages/web3-utils/types/tests/sha3-raw-test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import {sha3Raw} from 'web3-utils';
2525

2626
// $ExpectType string
2727
sha3Raw('234');
28+
// $ExpectType string | null
29+
sha3Raw(Buffer.from('123'));
2830
// $ExpectType string
2931
sha3Raw(new BN(3));
3032

packages/web3-utils/types/tests/sha3-test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import {sha3} from 'web3-utils';
2626
// $ExpectType string | null
2727
sha3('234');
2828
// $ExpectType string | null
29+
sha3(Buffer.from('123'));
30+
// $ExpectType string | null
2931
sha3(new BN(3));
3032

3133
// $ExpectError

0 commit comments

Comments
 (0)