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

Commit 9606f73

Browse files
committed
fix: unnecessary array copy when pack encoding
Signed-off-by: Marin Petrunic <marin.petrunic@gmail.com>
1 parent f860b04 commit 9606f73

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

packages/web3-utils/CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,4 +169,8 @@ Documentation:
169169
- Fix issue with default config with babel (and React): "TypeError: Cannot convert a BigInt value to a number #6187" (#6506)
170170
- Fixed bug in chunks processing logic (#6496)
171171

172-
## [Unreleased]
172+
## [Unreleased]
173+
174+
### Fixed
175+
176+
- Fix unecessary array copy when pack encoding

packages/web3-utils/src/hash.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,10 @@ export const processSolidityEncodePackedArgs = (arg: Sha3Input): string => {
325325
* Encode packed arguments to a hexstring
326326
*/
327327
export const encodePacked = (...values: Sha3Input[]): string => {
328-
const args = Array.prototype.slice.call(values);
328+
let args = values;
329+
if(!Array.isArray(values)) {
330+
args = [values]
331+
}
329332
const hexArgs = args.map(processSolidityEncodePackedArgs);
330333
return `0x${hexArgs.join('').toLowerCase()}`;
331334
};

0 commit comments

Comments
 (0)