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

fix: unnecessary array copy when pack encoding #6553

Merged
merged 5 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 5 additions & 1 deletion packages/web3-utils/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,8 @@ Documentation:
- Fix issue with default config with babel (and React): "TypeError: Cannot convert a BigInt value to a number #6187" (#6506)
- Fixed bug in chunks processing logic (#6496)

## [Unreleased]
## [Unreleased]

### Fixed

- Fix unecessary array copy when pack encoding
5 changes: 4 additions & 1 deletion packages/web3-utils/src/hash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,10 @@ export const processSolidityEncodePackedArgs = (arg: Sha3Input): string => {
* Encode packed arguments to a hexstring
*/
export const encodePacked = (...values: Sha3Input[]): string => {
const args = Array.prototype.slice.call(values);
let args = values;
if(!Array.isArray(values)) {
args = [values]
mpetrunic marked this conversation as resolved.
Show resolved Hide resolved
}
const hexArgs = args.map(processSolidityEncodePackedArgs);
return `0x${hexArgs.join('').toLowerCase()}`;
};
Expand Down
Loading