[CI Skip] 0.32.4
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
|
||||
@polkadot/util-rlp
|
||||
==================
|
||||
|
||||
Utility methods for encoding and decoding [Ethereum RLP structures](https://github.com/ethereum/wiki/wiki/%5BEnglish%5D-RLP). This is port adapted from the original [EthereumJS RLP](https://github.com/ethereumjs/rlp/blob/0ce09db81fc303fcee593f7cc094ba44015f9b92/index.js) implementation to cater for `Uint8Array` outputs (instead of `Buffer`) in addition to typings.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
Installation -
|
||||
|
||||
```
|
||||
yarn add @polkadot/util-rlp
|
||||
```
|
||||
|
||||
Functions can be imported as follows:
|
||||
|
||||
```js
|
||||
import { decode } from '@polkadot/util-rlp';
|
||||
import { encode } from '@polkadot/util-rlp';
|
||||
```
|
||||
|
||||
Documentation and Available Utilities
|
||||
-------------------------------------
|
||||
|
||||
No methods are exposed in the [Polkadot-JS Common Documentation Portal](https://polkadot.js.org/common/util-rlp/) because RLP will not be included in PoC-3 of Polkadot.
|
||||
|
||||
However, the key functions that are available include:
|
||||
|
||||
* util-rlp
|
||||
* Functions
|
||||
* Decoder
|
||||
* decode
|
||||
* decodeListLong
|
||||
* decodeListShort
|
||||
* decodeNumber
|
||||
* decodeSingle
|
||||
* decodeString
|
||||
* safeParseInt
|
||||
* Encoder
|
||||
* encode
|
||||
* encodeArray
|
||||
* encodeLength
|
||||
* encodeU8a
|
||||
* toU8a
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
* ["decode"](modules/_decode_.md)
|
||||
* ["decoder/decode"](modules/_decoder_decode_.md)
|
||||
* ["decoder/index"](modules/_decoder_index_.md)
|
||||
* ["decoder/listLong"](modules/_decoder_listlong_.md)
|
||||
* ["decoder/listShort"](modules/_decoder_listshort_.md)
|
||||
* ["decoder/number"](modules/_decoder_number_.md)
|
||||
* ["decoder/safeParseInt"](modules/_decoder_safeparseint_.md)
|
||||
* ["decoder/single"](modules/_decoder_single_.md)
|
||||
* ["decoder/string"](modules/_decoder_string_.md)
|
||||
* ["encode"](modules/_encode_.md)
|
||||
* ["encoder/array"](modules/_encoder_array_.md)
|
||||
* ["encoder/index"](modules/_encoder_index_.md)
|
||||
* ["encoder/length"](modules/_encoder_length_.md)
|
||||
* ["encoder/toU8a"](modules/_encoder_tou8a_.md)
|
||||
* ["encoder/u8a"](modules/_encoder_u8a_.md)
|
||||
* ["index"](modules/_index_.md)
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
|
||||
|
||||
# Functions
|
||||
|
||||
<a id="decode"></a>
|
||||
|
||||
## decode
|
||||
|
||||
▸ **decode**(input: *`Uint8Array`*): `DecodeOutput`
|
||||
|
||||
*Defined in [decoder/decode.ts:28](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/util-rlp/src/decoder/decode.ts#L28)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| input | `Uint8Array` |
|
||||
|
||||
**Returns:** `DecodeOutput`
|
||||
|
||||
___
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
|
||||
|
||||
# Functions
|
||||
|
||||
<a id="decoder"></a>
|
||||
|
||||
## decoder
|
||||
|
||||
▸ **decoder**(input?: *`Uint8Array`*): `Uint8Array` | `Array`<`any`>
|
||||
|
||||
*Defined in [decoder/index.ts:24](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/util-rlp/src/decoder/index.ts#L24)*
|
||||
|
||||
*__name__*: decoder
|
||||
|
||||
*__signature__*: decoder (input?: Uint8Array): Uint8Array | Array<*>
|
||||
|
||||
*__summary__*: Decodes the input RLP.
|
||||
|
||||
*__description__*: From an input, decode the RLP and return the result as a `Uint8Array` or `Array`.
|
||||
|
||||
*__example__*:
|
||||
```javascript
|
||||
import { decode } from '@polkadot/util-rlp';
|
||||
|
||||
decode(new Uint8Array([0x83, 0x64, 0x6f, 0x67])); // => 'dog' as Uint8Array
|
||||
```
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| `Optional` input | `Uint8Array` |
|
||||
|
||||
**Returns:** `Uint8Array` | `Array`<`any`>
|
||||
|
||||
___
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
|
||||
|
||||
# Functions
|
||||
|
||||
<a id="decodelistlong"></a>
|
||||
|
||||
## decodeListLong
|
||||
|
||||
▸ **decodeListLong**(decode: *`DecodeFunc`*, input: *`Uint8Array`*): `DecodeOutput`
|
||||
|
||||
*Defined in [decoder/listLong.ts:11](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/util-rlp/src/decoder/listLong.ts#L11)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| decode | `DecodeFunc` |
|
||||
| input | `Uint8Array` |
|
||||
|
||||
**Returns:** `DecodeOutput`
|
||||
|
||||
___
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
|
||||
|
||||
# Functions
|
||||
|
||||
<a id="decodelistshort"></a>
|
||||
|
||||
## decodeListShort
|
||||
|
||||
▸ **decodeListShort**(decode: *`DecodeFunc`*, input: *`Uint8Array`*): `DecodeOutput`
|
||||
|
||||
*Defined in [decoder/listShort.ts:7](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/util-rlp/src/decoder/listShort.ts#L7)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| decode | `DecodeFunc` |
|
||||
| input | `Uint8Array` |
|
||||
|
||||
**Returns:** `DecodeOutput`
|
||||
|
||||
___
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
|
||||
|
||||
# Functions
|
||||
|
||||
<a id="decodenumber"></a>
|
||||
|
||||
## decodeNumber
|
||||
|
||||
▸ **decodeNumber**(decode: *`DecodeFunc`*, input: *`Uint8Array`*): `DecodeOutput`
|
||||
|
||||
*Defined in [decoder/number.ts:11](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/util-rlp/src/decoder/number.ts#L11)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| decode | `DecodeFunc` |
|
||||
| input | `Uint8Array` |
|
||||
|
||||
**Returns:** `DecodeOutput`
|
||||
|
||||
___
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
|
||||
|
||||
# Functions
|
||||
|
||||
<a id="safeparseint"></a>
|
||||
|
||||
## safeParseInt
|
||||
|
||||
▸ **safeParseInt**(input: *`Uint8Array`*): `number`
|
||||
|
||||
*Defined in [decoder/safeParseInt.ts:7](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/util-rlp/src/decoder/safeParseInt.ts#L7)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| input | `Uint8Array` |
|
||||
|
||||
**Returns:** `number`
|
||||
|
||||
___
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
|
||||
|
||||
# Functions
|
||||
|
||||
<a id="decodesingle"></a>
|
||||
|
||||
## decodeSingle
|
||||
|
||||
▸ **decodeSingle**(decode: *`DecodeFunc`*, input: *`Uint8Array`*): `DecodeOutput`
|
||||
|
||||
*Defined in [decoder/single.ts:7](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/util-rlp/src/decoder/single.ts#L7)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| decode | `DecodeFunc` |
|
||||
| input | `Uint8Array` |
|
||||
|
||||
**Returns:** `DecodeOutput`
|
||||
|
||||
___
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
|
||||
|
||||
# Functions
|
||||
|
||||
<a id="decodestring"></a>
|
||||
|
||||
## decodeString
|
||||
|
||||
▸ **decodeString**(decode: *`DecodeFunc`*, input: *`Uint8Array`*): `DecodeOutput`
|
||||
|
||||
*Defined in [decoder/string.ts:9](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/util-rlp/src/decoder/string.ts#L9)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| decode | `DecodeFunc` |
|
||||
| input | `Uint8Array` |
|
||||
|
||||
**Returns:** `DecodeOutput`
|
||||
|
||||
___
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
|
||||
|
||||
# Functions
|
||||
|
||||
<a id="encodearray"></a>
|
||||
|
||||
## encodeArray
|
||||
|
||||
▸ **encodeArray**(encoder: *`EncodeFunc`*, input: *`any`*): `Uint8Array`
|
||||
|
||||
*Defined in [encoder/array.ts:11](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/util-rlp/src/encoder/array.ts#L11)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| encoder | `EncodeFunc` |
|
||||
| input | `any` |
|
||||
|
||||
**Returns:** `Uint8Array`
|
||||
|
||||
___
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
|
||||
|
||||
# Functions
|
||||
|
||||
<a id="encoder"></a>
|
||||
|
||||
## encoder
|
||||
|
||||
▸ **encoder**(input: *`any`*): `Uint8Array`
|
||||
|
||||
*Defined in [encoder/index.ts:24](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/util-rlp/src/encoder/index.ts#L24)*
|
||||
|
||||
*__name__*: encoder
|
||||
|
||||
*__signature__*: encoder (input: any): Uint8Array
|
||||
|
||||
*__summary__*: Encodes the input value into RLP.
|
||||
|
||||
*__description__*: From an input, calculate the RLP and return the result as a `Uint8Array`.
|
||||
|
||||
*__example__*:
|
||||
```javascript
|
||||
import { encode } from '@polkadot/util-rlp';
|
||||
|
||||
encode('dog'); // => [0x83, 0x64, 0x6f, 0x67]
|
||||
```
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| input | `any` |
|
||||
|
||||
**Returns:** `Uint8Array`
|
||||
|
||||
___
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
|
||||
|
||||
# Functions
|
||||
|
||||
<a id="encodelength"></a>
|
||||
|
||||
## encodeLength
|
||||
|
||||
▸ **encodeLength**(length: *`number`*, offset: *`number`*): `Uint8Array`
|
||||
|
||||
*Defined in [encoder/length.ts:7](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/util-rlp/src/encoder/length.ts#L7)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| length | `number` |
|
||||
| offset | `number` |
|
||||
|
||||
**Returns:** `Uint8Array`
|
||||
|
||||
___
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
|
||||
|
||||
# Functions
|
||||
|
||||
<a id="tou8a"></a>
|
||||
|
||||
## toU8a
|
||||
|
||||
▸ **toU8a**(value: *`any`*): `Uint8Array`
|
||||
|
||||
*Defined in [encoder/toU8a.ts:39](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/util-rlp/src/encoder/toU8a.ts#L39)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| value | `any` |
|
||||
|
||||
**Returns:** `Uint8Array`
|
||||
|
||||
___
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
|
||||
|
||||
# Functions
|
||||
|
||||
<a id="encodeu8a"></a>
|
||||
|
||||
## encodeU8a
|
||||
|
||||
▸ **encodeU8a**(encoder: *`EncodeFunc`*, input: *`Uint8Array`*): `Uint8Array`
|
||||
|
||||
*Defined in [encoder/u8a.ts:11](https://github.com/polkadot-js/common/blob/1fb1f9d/packages/util-rlp/src/encoder/u8a.ts#L11)*
|
||||
|
||||
**Parameters:**
|
||||
|
||||
| Param | Type |
|
||||
| ------ | ------ |
|
||||
| encoder | `EncodeFunc` |
|
||||
| input | `Uint8Array` |
|
||||
|
||||
**Returns:** `Uint8Array`
|
||||
|
||||
___
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
|
||||
Reference in New Issue
Block a user