rlp v3.0.0
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: