Skip to content

Commit

Permalink
[docs] add stripHexPrefix method to migration guide (#6843)
Browse files Browse the repository at this point in the history
* add stripHexPrefix method to accounts migration guide

* add stripHexPrefix method to web3-utils migration guide
  • Loading branch information
cyborgRen authored Feb 29, 2024
1 parent ab1b250 commit 0e59f28
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,14 @@ const wallet = web3.eth.accounts.wallet.create(1, 'optionalEntropy'); // entropy
const account = web3.eth.accounts.wallet.create(1, 'optionalEntropy'); // will result in an error
const account = web3.eth.accounts.wallet.create(); // correct way
```

## stripHexPrefix method

In 1.x `stripHexPrefix` method is located in the `web3-utils` package, in 4.x this has been moved to `web3-eth-accounts`

```typescript
import { stripHexPrefix } from 'web3-eth-accounts';

console.log(stripHexPrefix('0x123')); // "123"

```
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ isHex('-0x'); // in 1.x used to return `true`. But changed in 4.x to return `fal

isHexStrict('-0x'); // in 1.x used to return `true`. But changed in 4.x to return `false`
// `false`
```
## stripHexPrefix method

In 1.x `stripHexPrefix` method is located in the `web3-utils` package, in 4.x this has been moved to `web3-eth-accounts`

```typescript
import { stripHexPrefix } from 'web3-eth-accounts';

console.log(stripHexPrefix('0x123')); // "123"

```

## Other functions
Expand Down

1 comment on commit 0e59f28

@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: 0e59f28 Previous: 6c075db Ratio
processingTx 9246 ops/sec (±4.40%) 9301 ops/sec (±4.81%) 1.01
processingContractDeploy 42202 ops/sec (±7.13%) 39129 ops/sec (±7.62%) 0.93
processingContractMethodSend 20718 ops/sec (±6.87%) 19443 ops/sec (±5.19%) 0.94
processingContractMethodCall 41527 ops/sec (±5.67%) 38971 ops/sec (±6.34%) 0.94
abiEncode 46895 ops/sec (±7.00%) 44252 ops/sec (±6.92%) 0.94
abiDecode 33731 ops/sec (±6.47%) 30419 ops/sec (±8.89%) 0.90
sign 1678 ops/sec (±0.78%) 1656 ops/sec (±4.08%) 0.99
verify 376 ops/sec (±0.56%) 373 ops/sec (±0.78%) 0.99

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

Please sign in to comment.