Skip to content

rlp v3.0.0

Compare
Choose a tag to compare
@ryanio ryanio released this 25 Jan 17:38
· 1589 commits to master since this release
4d087b4

rlp v3 is a breaking release with several important updates. Special thanks to @paulmillr for the majority of this work in PR #90.

Dependencies

bn.js was removed in favor of BigInt support so the package now contains zero dependencies.

Default export

A new default export RLP now contains encode and decode.

You can now import and use RLP like this:

import RLP from 'rlp'
RLP.encode(1)

Uint8Array

Buffers were replaced in favor of using Uint8Arrays for improved performance and greater compatibility with browsers.

When upgrading from rlp v2 to v3, you must convert your Buffers to Uint8Arrays before passing in. To help, two new utility methods were added to ethereumjs-util v7.1.4: arrToBufArr and bufArrToArr. These will recursively step through your arrays to replace Buffers with Uint8Arrays, or vise versa.

Example:

// Old, rlp v2
import * as rlp from 'rlp'
const bufArr = [Buffer.from('123', 'hex'), Buffer.from('456', 'hex')]
const encoded = rlp.encode(bufArr)
const decoded = rlp.decode(encoded)

// New, rlp v3
import RLP from 'rlp'
const encoded: Uint8Array = RLP.encode(bufArrToArr(bufArr))
const encodedAsBuffer = Buffer.from(encoded)
const decoded: Uint8Array[] = RLP.decode(encoded)
const decodedAsBuffers = arrToBufArr(decoded)

Invalid RLPs

Increased strictness has been added to ensure invalid RLPs are not decoded, see PR #101.


PRs included in this release:

  • Fix karma, readme updates, combine source to one file, PR #109
  • Add browser support, remove dependencies, PR #90
  • Readme and typedoc updates, normalize source error messages to capital RLP, PR #108
  • Improve cli interface, PR #95
  • Ensure we do not decode invalid RLPs, PR #101