Skip to content

Commit

Permalink
Updating docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Dec 14, 2019
1 parent 06cafe3 commit 184c459
Show file tree
Hide file tree
Showing 64 changed files with 927 additions and 666 deletions.
27 changes: 18 additions & 9 deletions docs.wrm/api/utils/address.wrm
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,27 @@ _section: Addresses

Explain addresses,formats and checksumming here.

Also see: [Constants.AddressZero](constants)
Also see: [constants.AddressZero](constants)

_heading: Functions

_property: utils.getAddress(address) => string
TODO

_property: utils.isAddress(address) => boolean
TODO
_property: utils.getAddress(address) => string @<utils-getAddress> @TS<address:>
Returns //address// as a Checksum Address.

_property: utils.getIcapAddress(address) => string
TODO
If //address// is an invalid 40-nibble [[hexstring]] or if it contains mixed case and
the checksum is invalid, an InvalidArgument Error is throw.

_property: utils.getContractAddress(transaction) => string
TODO
The value of //address// may be any supported address format.


_property: utils.isAddress(address) => boolean @<utils-isAddress> @TS<address:>
Returns true if //address// is valid (in any supported format).

_property: utils.getIcapAddress(address) => string @<utils-getIcapAddress> @TS<address:>
Returns //address// as an ICAP address. Supports the same restrictions as
[utils.getAddress](utils-getAddress).

_property: utils.getContractAddress(transaction) => string @<utils-getContractAddress> @TS<address:>
Returns the contract address that would result if //transaction// was
used to deploy a contract.
109 changes: 59 additions & 50 deletions docs.wrm/api/utils/bytes.wrm
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,27 @@ _subsection: Types

_heading: Bytes @<bytes>

A Bytes object is any object which is an
[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) or
[TypedArray](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) with
A **Bytes** is any object which is an
[Array](https:/\/developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) or
[TypedArray](https:/\/developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray) with
each value in the valid byte range (i.e. between 0 and 255 inclusive),
or is an Object with a ``length`` property where each indexed property
is in the valid byte range.

_heading: BytesLike @<byteslike>

A **BytesLike** can be either a [[bytes]] or a [[hexstring]].
A **BytesLike** can be either a [[bytes]] or a [[datahexstring]].

_heading: DataHexstring @<datahexstring>

A **DataHexstring** is identical to a [[hexstring]] except that it has
an even number of nibbles, and therefore is a valid representation of
binary data as a string.

_heading: Hexstring @<hexstring>

A **hexstring** is a string which has a ``0x`` prefix followed by
A **hexstring** is a string which has a ``0x`` prefix followed by any
number of nibbles (i.e. case-insensitive hexidecumal characters, ``0-9`` and ``a-f``).

_heading: Signature @<signature>

Expand All @@ -35,37 +42,36 @@ _heading: SignatureLike @<signaturelike>
A **SignatureLike** is similar to a [[signature]], except redundant properties
may be omitted.

For example, if *_vs* is specified, **(r, s)** and **v** can be omitted. Likewise,
if **recoverParam** is provided, **v** can be omitted (as it can be computed).
For example, if **_vs** is specified, **s** and **v** may be omitted. Likewise,
if **recoveryParam** is provided, **v** may be omitted (as in these cases the
missing values can be computed).


_subsection: Inspection

_property: utils.isBytes(object) => boolean
_property: utils.isBytes(object) => boolean @<utils-isbytes> @TS<bytes:>
Returns true if and only if //object// is a valid [[bytes]].

_property: utils.isBytesLike(object) => boolean
Returns true if and only if //object// is a [[bytes]] or an Array or TypedArray
where each value is a valid byte (i.e. between 0 and 255 inclusive).
_property: utils.isBytesLike(object) => boolean @<utils-isbyteslike> @TS<bytes:>
Returns true if and only if //object// is a [[bytes]] or [[datahexstring]].

_property: utils.isHexString(object, [ length ] ) => boolean
Returns true if and only if //object// is a valid hex string;
if //length// is specified the length (in bytes) is also verified.
_property: utils.isHexString(object, [ length ] ) => boolean @<utils-ishexstring> @TS<bytes:>
Returns true if and only if //object// is a valid hex string.
If //length// is specified and //object// is not a valid [[datahexstring]] of
//length// bytes, an InvalidArgument error is thrown.


_subsection: Converting between Arrays and Hexstrings

_property: utils.arrayify(hexstringOrArrayish [ , options ]) => Uint8Array
Converts //hexstringOrArrayish// to a Uint8Array. If a [[hexstring]]
is passed in, the length must be even.
_property: utils.arrayify(datahexstringOrArrayish [ , options ]) => Uint8Array @<utils-arrayify> @TS<bytes:>
Converts //datahexstringOrArrayish// to a Uint8Array.

_property: utils.hexlify(hexstringOrArrayish) => string
Converts //hexstringOrArrayish// to a [[hexstring]]. The result
will always be zero-padded to even length.
_property: utils.hexlify(hexstringOrArrayish) => string @<utils-hexlify> @TS<bytes:>
Converts //hexstringOrArrayish// to a [[datahexstring]].

_property: utils.hexValue(aBigNumberish) => string
Converts //aBigNumberish// to a [[hexstring]], with no unecessary leading
zeros. The result of this function can be of odd-length.
_property: utils.hexValue(aBigNumberish) => string @<utils-hexvalue> @TS<bytes:>
Converts //aBigNumberish// to a [[hexstring]], with no __unnecessary__ leading
zeros.

_heading: Examples

Expand All @@ -74,48 +80,51 @@ _code: bytes-conversion.js

_subsection: Array Manipulation

_property: utils.concat(arrayOfBytesLike) => Uint8Array
Concatenates all the [[byteslike]] in //arrayOfBytesLike//
into a single Uint8Array.
_property: utils.concat(arrayOfBytesLike) => Uint8Array @<utils-concat> @TS<bytes:>
Concatenates all the [[byteslike]] in //arrayOfBytesLike// into a single Uint8Array.

_property: utils.stripZeros(aBytesLike) => Uint8Array
Concatenates all the [[byteslike]] in //arrayOfBytesLike//
_property: utils.stripZeros(aBytesLike) => Uint8Array @<utils-stripzeros> @TS<bytes:>
Returns a Uint8Array with all leading ``0`` bytes of //aBtyesLike// removed.

_property: utils.zeroPad(aBytesLike, length) => Uint8Array
Concatenates all the [[byteslike]] in //arrayOfBytesLike//
_property: utils.zeroPad(aBytesLike, length) => Uint8Array @<utils-zeropad> @TS<bytes:>
Retutns a Uint8Array of the data in //aBytesLike// with ``0`` bytes prepended to
//length// bytes long.

If //aBytesLike// is already longer than //length// bytes long, an InvalidArgument
error will be thrown.


_subsection: Hexstring Manipulation

_property: utils.hexConcat(arrayOfBytesLike) => string
Concatenates all the [[byteslike]] in //arrayOfBytesLike//
into a single [[hexstring]]
_property: utils.hexConcat(arrayOfBytesLike) => [[datahexstring]] @<utils-hexconcat> @TS<bytes:>
Concatenates all the [[byteslike]] in //arrayOfBytesLike// into a single [[datahexstring]]

_property: utils.hexDataLength(aBytesLike) => number
_property: utils.hexDataLength(aBytesLike) => [[datahexstring]] @<utils-hexdatalength> @TS<bytes:>
Returns the length (in bytes) of //aBytesLike//.

This will **throw and error** if //aBytesLike// is a [[hexstring]]
but is of odd-length.
_property: utils.hexDataSlice(aBytesLike, offset [ , endOffset ] ) => [[datahexstring]] @<utils-hexdataslice> @TS<bytes:>
Returns a [[datahexstring]] representation of a slice of //aBytesLike//, from
//offset// (in bytes) to //endOffset// (in bytes). If //endOffset// is
omitted, the length of //aBytesLike// is used.

_property: utils.hexDataSlice(aBytesLike, offset [ , endOffset ] ) => string
Returns the length (in bytes) of //aBytesLike//.
_property: utils.hexStripZeros(aBytesLike) => [[hexstring]] @<utils-hexstripzeros> @TS<bytes:>
Returns a [[hexstring]] representation of //aBytesLike// with all
leading zeros removed.

_property: utils.hexStripZeros(aBytesLike) => string
@TODO
_property: utils.hexZeroPad(aBytesLike, length) => [[datahexstring]] @<utils-hexzeropad> @TS<bytes:>
Returns a [[datahexstring]] representation of //aBytesLike// padded to //length// bytes.

_property: utils.hexZeroPad(aBytesLike, length) => string
@TODO
If //aBytesLike// is already longer than //length// bytes long, an InvalidArgument
error will be thrown.


_subsection: Signature Conversion

_property: utils.joinSignature(aSignatureLike) => string
Return the flat-format of a [[signaturelike]], which is
65 bytes (130 nibbles) long, concatenating the **r**, **s** and **v**
of a Signature.
_property: utils.joinSignature(aSignatureLike) => [[datahexstring]] @<utils-joinsignature> @TS<bytes:>
Return the flat-format of //aSignaturelike//, which is 65 bytes (130 nibbles)
long, concatenating the **r**, **s** and (normalized) **v** of a Signature.

_property: utils.splitSignature(aSignatureLikeOrBytesLike) => Signature
Return the full expanded-format of a [[signaturelike]] or
a flat-format [[hexstring]]. Any missing properties will be
computed.
_property: utils.splitSignature(aSignatureLikeOrBytesLike) => [[signature]] @<utils-splitsignature> @TS<bytes:>
Return the full expanded-format of //aSignaturelike// or a flat-format [[datahexstring]].
Any missing properties will be computed.

18 changes: 9 additions & 9 deletions docs.wrm/api/utils/constants.wrm
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,38 @@ _code: constants-import.js

_subsection: Bytes

_property: constants.AddressZero
_property: constants.AddressZero => [[datahexstring]] @<constants-addresszero> @TS<constants:>
The Address Zero, which is 20 bytes (40 nibbles) of zero.

_property: constants.HashZero
_property: constants.HashZero => [[datahexstring]] @<constants-hashzero> @TS<constants:>
The Hash Zero, which is 32 bytes (64 nibbles) of zero.


_subsection: Strings

_property: constants.EtherSymbol
_property: constants.EtherSymbol => string @<constants-ethersymbol> @TS<constants:>
The Ether symbol, **&Xi;**.


_subsection: BigNumber

_property: constants.NegativeOne
_property: constants.NegativeOne => [[bignumber]] @<constants-negativeone> @TS<constants:>
The BigNumber value representing ``"-1"``.

_property: constants.Zero
_property: constants.Zero => [[bignumber]] @<constants-zero> @TS<constants:>
The BigNumber value representing ``"0"``.

_property: constants.One
_property: constants.One => [[bignumber]] @<constants-one> @TS<constants:>
The BigNumber value representing ``"1"``.

_property: constants.Two
_property: constants.Two => [[bignumber]] @<constants-two> @TS<constants:>
The BigNumber value representing ``"2"``.

_property: constants.WeiPerEther
_property: constants.WeiPerEther => [[bignumber]] @<constants-weiperether> @TS<constants:>
The BigNumber value representing ``"1000000000000000000"``, which is the
number of Wei per Ether.

_property: constants.MaxUint256
_property: constants.MaxUint256 => [[bignumber]] @<constants-maxuint256> @TS<constants:>
The BigNumber value representing the maximum ``uint256`` value.


Expand Down
10 changes: 5 additions & 5 deletions docs.wrm/api/utils/display-logic.wrm
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,23 @@ _subsection: Functions

_heading: Formatting

_property: utils.commify(value) => string
_property: utils.commify(value) => string @<util-commify> @TS<units:>
Returns a string with value grouped by 3 digits, separated by ``,``.


_heading: Conversion @<unit-conversion>

_property: utils.formatUnits(value [ , unit = "ether" ] ) => string
_property: utils.formatUnits(value [ , unit = "ether" ] ) => string @<util-formatunits> @TS<units:>
Returns a string representation of //value// formatted with //unit//
digits (if it is a number) or to the unit specified (if a string).

_property: utils.formatEther(value) => string
_property: utils.formatEther(value) => string @<util-formatether> @TS<units:>
The equivalent to calling ``formatUnits(value, "ether")``.

_property: utils.parseUnits(value [ , unit = "ether" ] ) => [BigNumber](bignumber)
_property: utils.parseUnits(value [ , unit = "ether" ] ) => [BigNumber](bignumber) @<util-parseunits> @TS<units:>
Returns a [BigNumber](bignumber) representation of //value//, parsed with
//unit// digits (if it is a number) or from the unit specified (if
a string).

_property: utils.parseEther(value) => [BigNumber](bignumber)
_property: utils.parseEther(value) => [BigNumber](bignumber) @<util-parseether> @TS<units:>
The equivalent to calling ``parseUnits(value, "ether")``.
26 changes: 13 additions & 13 deletions docs.wrm/api/utils/hashing.wrm
Original file line number Diff line number Diff line change
Expand Up @@ -10,43 +10,43 @@ _subsection: Cryptographic Hashing
The [Cryptographic Hash Functions](https://en.wikipedia.org/wiki/Cryptographic_hash_function)
are a specific family of hash functions.

_property: utils.keccak256(aBytesLike) => string
_property: utils.keccak256(aBytesLike) => [[datahexstring]] @<utils-keccak256> @TS<keccak256:>
Returns the [KECCAK256](https://en.wikipedia.org/wiki/SHA-3) digest //aBytesLike//.

_property: utils.ripemd160(aBytesLike) => string
_property: utils.ripemd160(aBytesLike) => [[datahexstring]] @<utils-ripemd160> @TS<sha2:>
Returns the [RIPEMD-160](https://en.m.wikipedia.org/wiki/RIPEMD) digest of //aBytesLike//.

_property: utils.sha256(aBytesLike) => string
_property: utils.sha256(aBytesLike) => [[datahexstring]] @<utils-sha256> @TS<sha2:>
Returns the [SHA2-256](https://en.wikipedia.org/wiki/SHA-2) digest of //aBytesLike//.

_property: utils.sha512(aBytesLike) => string
_property: utils.sha512(aBytesLike) => [[datahexstring]] @<utils-sha512> @TS<sha2:>
Returns the [SHA2-512](https://en.wikipedia.org/wiki/SHA-2) digest of //aBytesLike//.

_property: utils.computeHmac(algorithm, key, data) => string
_property: utils.computeHmac(algorithm, key, data) => [[datahexstring]] @<utils-computehmac> @TS<sha2:>
Returns the [HMAC](https://en.wikipedia.org/wiki/HMAC) of //data// with //key//
using the [Algorithm](supported-algorithm) //algorithm//.


_heading: HMAC Supported Algorithms @<supported-algorithm>

_property: utils.SupportedAlgorithms.sha256
_property: utils.SupportedAlgorithms.sha256 => string
Use the [SHA2-256](https://en.wikipedia.org/wiki/SHA-2) hash algorithm.

_property: utils.SupportedAlgorithms.sha512
_property: utils.SupportedAlgorithms.sha512 => string
Use the [SHA2-512](https://en.wikipedia.org/wiki/SHA-2) hash algorithm.


_subsection: Common Hashing Helpers

_property: utils.hashMessage(message) => string
_property: utils.hashMessage(message) => [[datahexstring]] @<utils-hashmessage> @TS<hash:>
Computes the Ethereum message digest of //message//. Ethereum messages are
converted to UTF-8 bytes and prefixed with ``\x19Ethereum Signed Message:``
and the length of //message//.

_property: utils.id(text) => string
_property: utils.id(text) => [[datahexstring]] @<utils-id> @TS<hash:>
The Ethereum Identity function computs the keccak256 hash of the //text// bytes.

_property: utils.namehash(name) => string
_property: utils.namehash(name) => [[datahexstring]] @<utils-namehash> @TS<hash:>
Returns the [ENS Namehash](https://docs.ens.domains/contract-api-reference/name-processing#hashing-names) of //name//.


Expand All @@ -56,15 +56,15 @@ When using the Solidity ``abi.packEncoded(...)`` function, a non-standard
//tightly packed// version of encoding is used. These functions implement
the tightly packing algorithm.

_property: utils.solidityPack(arrayOfTypes, arrayOfValues) => string
_property: utils.solidityPack(arrayOfTypes, arrayOfValues) => [[datahexstring]] @<utils-soliditypack> @TS<solidity:pack()>
Returns the non-standard encoded //arrayOfValues// packed according to
their respecive type in //arrayOfTypes//.

_property: utils.solidityKeccak256(arrayOfTypes, arrayOfValues) => string
_property: utils.solidityKeccak256(arrayOfTypes, arrayOfValues) => [[datahexstring]] @<utils-soliditykeccak256> @TS<solidity:keccak256()>
Returns the KECCAK256 of the non-standard encoded //arrayOfValues// packed
according to their respective type in //arrayOfTypes//.

_property: utils.soliditySha256(arrayOfTypes, arrayOfValues) => string
_property: utils.soliditySha256(arrayOfTypes, arrayOfValues) => [[datahexstring]] @<utils-soliditysha256> @TS<solidity:sha256()>
Returns the SHA2-256 of the non-standard encoded //arrayOfValues// packed
according to their respective type in //arrayOfTypes//.

Expand Down
Loading

0 comments on commit 184c459

Please sign in to comment.