web3.js
web3.js copied to clipboard
web3.utils.padRight cannot pad hex strings that begin with 0x8 or higher
Expected behavior
web3.utils.padRight('0x05e2e7de3cd95eb48fa9ff77e7860cf249fe05f726abea45a0a44e62b4bf52b2', 64)
should return 0x05e2e7de3cd95eb48fa9ff77e7860cf249fe05f726abea45a0a44e62b4bf52b2
.
web3.utils.padRight('0xb5e2e7de3cd95eb48fa9ff77e7860cf249fe05f726abea45a0a44e62b4bf52b2', 64)
should return 0xb5e2e7de3cd95eb48fa9ff77e7860cf249fe05f726abea45a0a44e62b4bf52b2
.
Actual behavior
web3.utils.padRight('0x05e2e7de3cd95eb48fa9ff77e7860cf249fe05f726abea45a0a44e62b4bf52b2', 64)
returns 0x05e2e7de3cd95eb48fa9ff77e7860cf249fe05f726abea45a0a44e62b4bf52b2
.
web3.utils.padRight('0xb5e2e7de3cd95eb48fa9ff77e7860cf249fe05f726abea45a0a44e62b4bf52b2', 64)
throws an exception:
Web3ValidatorError: Web3 validator found 1 error[s]:
value "0xb5e2e7de3cd95eb48fa9ff77e7860cf249fe05f726abea45a0a44e62b4bf52b2" at "/0" must pass "int" validation
Steps to reproduce the behavior
Call the functions above.
Logs
Uncaught Web3ValidatorError
at Validator.validate (validator.js:101:23)
at Web3Validator.validate (web3_validator.js:39:32)
at Module.padRight (string_manipulation.js:78:59)
at eval (page.tsx:184:18)
Environment
- npm 10.8.1
- Node 22.3.0
- web3 4.11.0