Skip to content

Commit

Permalink
feat(docs): upgrade-bn (#7232)
Browse files Browse the repository at this point in the history
Add a section in "Upgrade from 1.x" for `BN` vs `BigInt`

Closes #6705
  • Loading branch information
danforbes authored Sep 9, 2024
1 parent 7a6e492 commit 75df267
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@ import web3Utils from 'web3-utils';
import * as web3Utils from 'web3-utils';
```

## No `BN` property

The `web3-utils` package no longer includes a `BN` property for using the [the `bn.js` package](https://github.com/indutny/bn.js/) for working with (big) numbers. In 4.x, [the native JavaScript `BigInt` type](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt) is used.

```ts
// 1.x
new Web3.utils.BN(1);

// 4.x
BigInt(4);
```

## Unit conversion functions

The `toWei` does not have an optional second parameter. You have to pass the source unit explicitly.
Expand Down

1 comment on commit 75df267

@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: 75df267 Previous: 7a6e492 Ratio
processingTx 22160 ops/sec (±8.48%) 22522 ops/sec (±8.59%) 1.02
processingContractDeploy 40358 ops/sec (±7.56%) 39622 ops/sec (±7.51%) 0.98
processingContractMethodSend 16223 ops/sec (±6.92%) 17407 ops/sec (±7.00%) 1.07
processingContractMethodCall 27644 ops/sec (±6.21%) 28383 ops/sec (±7.80%) 1.03
abiEncode 44173 ops/sec (±8.18%) 46331 ops/sec (±6.95%) 1.05
abiDecode 32205 ops/sec (±6.05%) 31565 ops/sec (±7.20%) 0.98
sign 1600 ops/sec (±0.98%) 1592 ops/sec (±0.56%) 0.99
verify 369 ops/sec (±0.62%) 371 ops/sec (±2.76%) 1.01

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

Please sign in to comment.