Releases: ethereumjs/ethereumjs-util
v7.0.9 - Large ChainID Support
This release adds support for very high chainId
numbers exceeding MAX_SAFE_INTEGER
(an example is the chain ID 34180983699157880
used for the ephemeral Yolov3 testnet preparing for the berlin
hardfork, but high chain IDs might be used for things like private test networks and the like as well).
Function signatures for methods in address
and signature
are therefore expanded to allow for a BNLike
input type (BN | PrefixedHexString | number | Buffer
) for chain ID related parameters.
All function signatures are still taking in a number
input for backwards-compatibility reasons. If you use one of the following functions to implement generic use cases in your library where the chain ID is not yet known it is recommended to updated to one of the other input types (with plain Buffer
likely be the most future-proof). Note that on some functions this changes the return value as well.
account
:toChecksumAddresss(hexAddress: string, eip1191ChainId?: number): string
- ->
toChecksumAddress = function(hexAddress: string, eip1191ChainId?: BNLike): string
- ->
account
:isValidChecksumAddress(hexAddress: string, eip1191ChainId?: number)
- ->
isValidChecksumAddress(hexAddress: string, eip1191ChainId?: BNLike)
- ->
signature
:ecsign(msgHash: Buffer, privateKey: Buffer, chainId?: number): ECDSASignature
- ->
ecsign(msgHash: Buffer, privateKey: Buffer, chainId?: number): ECDSASignature
(return value stays the same onnumber
input) - ->
ecsign(msgHash: Buffer, privateKey: Buffer, chainId: BNLike): ECDSASignatureBuffer
(changed return value for other type inputs)
- ->
signature
:ecrecover(msgHash: Buffer, v: number, r: Buffer, s: Buffer, chainId?: number): Buffer
- ->
ecrecover(msgHash: Buffer, v: BNLike, r: Buffer, s: Buffer, chainId?: BNLike): Buffer
- ->
signature
:toRpcSig(v: number, r: Buffer, s: Buffer, chainId?: number): string
- ->
toRpcSig(v: BNLike, r: Buffer, s: Buffer, chainId?: BNLike): string
- ->
signature
:isValidSignature(v: number, r: Buffer, s: Buffer, homesteadOrLater: boolean = true, chainId?: number)
- ->
isValidSignature(v: BNLike, r: Buffer, s: Buffer, homesteadOrLater: boolean = true, chainId?: BNLike)
- ->
v7.0.8 - Bugfix Release
v7.0.7 - Maintenance Release
v7.0.6 - New Account Class
New Account
class
This release adds a new Account
class intended as a modern replacement for ethereumjs-account
. It has a shape of Account(nonce?: BN, balance?: BN, stateRoot?: Buffer, codeHash?: Buffer)
.
Instantiation
The static factory methods assist in creating an Account
object from varying data types: Object: fromAccountData
, RLP: fromRlpSerializedAccount
, and Array: fromValuesArray
.
Methods: isEmpty(): boolean
, isContract(): boolean
, serialize(): Buffer
Example usage:
import { Account, BN } from 'ethereumjs-util'
const account = new Account(
new BN(0), // nonce, default: 0
new BN(10).pow(new BN(18)), // balance, default: 0
undefined, // stateRoot, default: KECCAK256_RLP (hash of RLP of null)
undefined, // codeHash, default: KECCAK256_NULL (hash of null)
)
For more info see the documentation, examples of usage in test/account.spec.ts
or PR #275.
New export: TypeScript types
A new file with helpful TypeScript types has been added to the exports of this project, see PR #275.
In this release it contains BNLike
, BufferLike
, and TransformableToBuffer
.
Address.toBuffer()
The Address class has as a new method address.toBuffer()
that will give you a copy of the underlying address.buf
(PR #277).
toBuffer()
now converts TransformableToBuffer
The toBuffer()
exported function now additionally converts any object with a toBuffer()
method (PR #277).
v7.0.5 - New Address Type
This release adds a new module address
- see README - with a new Address
class and type which can be used for creating and representing Ethereum addresses.
Example usage:
import { Address } from 'ethereumjs-util'
const pubKey = Buffer.from(
'3a443d8381a6798a70c6ff9304bdc8cb0163c23211d11628fae52ef9e0dca11a001cf066d56a8156fc201cd5df8a36ef694eecd258903fca7086c1fae7441e1d',
'hex',
)
const address = Address.fromPublicKey(pubKey)
In TypeScript
the associated Address
type can be used to more strictly enforce type checks (e.g. on the length of an address) on function parameters expecting an address input. So you can declare a function like the following: myAddressRelatedFunction(address: Address)
to get more assurance that the address input is correct.
See PR #186
v7.0.4 - Bugfix Release
v6.2.1 - Crypto Update (ethereum-cryptography)
This release replaces the native secp256k1
and keccak
dependencies with ethereum-cryptopgraphy which doesn't need native compilation.
v5.2.1 - Crypto Update (ethereum-cryptography)
This release replaces the native secp256k1
and keccak
dependencies with ethereum-cryptopgraphy which doesn't need native compilation.
v4.5.1 - Crypto Update (ethereum-cryptography)
This release replaces the native secp256k1
and keccak
dependencies with ethereum-cryptopgraphy which doesn't need native compilation.
v7.0.3 - Crypto Update Release
This release replaces the keccak
and secp256k1
dependencies (PR #257) and instead uses the ethereum-cryptography package that uses native JS implementations for cryptographic primitives and makes use of modern and forward-compatible N-API implementations in Node wherever possible.
This is part of a larger initiative led by Nomic Labs to improve the developer experience within the Ethereum developer ecosystem,
see ethereum/js-team-organization#18 for context.
Other Changes: