Skip to content

Commit

Permalink
Merge branch '4.x' into 6393-web3validatorerror-error-value-at-0-must…
Browse files Browse the repository at this point in the history
…-pass-bytes-validation
  • Loading branch information
Muhammad-Altabba authored Jan 5, 2024
2 parents d2618e2 + 23d69ba commit 7ec6a95
Show file tree
Hide file tree
Showing 3 changed files with 1,888 additions and 2,009 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,24 @@ web3.utils.toWei('0.1');
web3.utils.toWei('0.1', 'ether');
```

## Conversion to Hex

The `toHex` behave exactly the same in both v1.x and 4.x, except for a string that contains only numbers. In 1.x if a number was provided inside a string like `123` it used to be treated as a number. While in 4.x it will be treated as a string, except if it was prefixed with `0x`. For more clarity, check below:

```ts
// 1.x
new Web3().utils.toHex(0x1) // returns 0x1
new Web3().utils.toHex('0x1') // returns 0x1
new Web3().utils.toHex(1) // returns 0x1
new Web3().utils.toHex('1') // returns 0x1

// 4.x
new Web3().utils.toHex(0x1) // returns 0x1
new Web3().utils.toHex('0x1') // returns 0x1
new Web3().utils.toHex(1) // returns 0x1
new Web3().utils.toHex('1') // returns 0x31
```

## Validation functions

Validation functions has been moved to the new package `web3-validator`. Actually, you can still import them from `web3-util`. But they are marked as "deprecated" and you are encouraged to import them from `web3-validator`.
Expand Down
6 changes: 3 additions & 3 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
"typecheck": "tsc"
},
"dependencies": {
"@docusaurus/core": "^3.0.0",
"@docusaurus/preset-classic": "^3.0.0",
"@docusaurus/theme-live-codeblock": "^3.0.0",
"@docusaurus/core": "^3.0.1",
"@docusaurus/preset-classic": "^3.0.1",
"@docusaurus/theme-live-codeblock": "^3.0.1",
"@mdx-js/react": "^3.0.0",
"classnames": "^2.3.2",
"clsx": "^2.0.0",
Expand Down
Loading

1 comment on commit 7ec6a95

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 7ec6a95 Previous: 6c075db Ratio
processingTx 9395 ops/sec (±4.25%) 9301 ops/sec (±4.81%) 0.99
processingContractDeploy 41272 ops/sec (±6.92%) 39129 ops/sec (±7.62%) 0.95
processingContractMethodSend 19358 ops/sec (±7.72%) 19443 ops/sec (±5.19%) 1.00
processingContractMethodCall 40015 ops/sec (±5.61%) 38971 ops/sec (±6.34%) 0.97
abiEncode 45963 ops/sec (±6.23%) 44252 ops/sec (±6.92%) 0.96
abiDecode 31664 ops/sec (±7.86%) 30419 ops/sec (±8.89%) 0.96
sign 1635 ops/sec (±3.31%) 1656 ops/sec (±4.08%) 1.01
verify 378 ops/sec (±1.38%) 373 ops/sec (±0.78%) 0.99

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.