Added initial flatworm documentation stubs.
This commit is contained in:
parent
57bf997d33
commit
0333a76f4f
8
docs.wrm/api/contract.wrm
Normal file
8
docs.wrm/api/contract.wrm
Normal file
@ -0,0 +1,8 @@
|
||||
_title: Contracts
|
||||
|
||||
_null: Contract @<contract>
|
||||
_section: Contracts
|
||||
|
||||
Explain what contracts are...
|
||||
|
||||
_subsection: Buckets
|
11
docs.wrm/api/index.wrm
Normal file
11
docs.wrm/api/index.wrm
Normal file
@ -0,0 +1,11 @@
|
||||
_title: Application Programming Interface
|
||||
|
||||
_section: Application Programming Interface (API)
|
||||
|
||||
Here...
|
||||
|
||||
_toc:
|
||||
contract
|
||||
signer
|
||||
providers
|
||||
utils
|
29
docs.wrm/api/providers/api-providers.wrm
Normal file
29
docs.wrm/api/providers/api-providers.wrm
Normal file
@ -0,0 +1,29 @@
|
||||
_title: API Providers
|
||||
|
||||
_section: API Providers
|
||||
|
||||
There are many services which offer a web API for accessing
|
||||
the Ethereum Blockchain. These Providers allow connecting
|
||||
to them, which simplifies development, since you do not need
|
||||
to run your own instance or cluster of Ethereum nodes.
|
||||
|
||||
However, this reliance on third-party services can reduce
|
||||
resiliance, security and increase the amount of required trust.
|
||||
To mitigate these issues, it is recommended you use a
|
||||
[Default Provider](get-default-provider).
|
||||
|
||||
_subsection: EtherscanProvider
|
||||
|
||||
Tra la la...
|
||||
|
||||
_subsection: InfuraProvider
|
||||
|
||||
Tra la la...
|
||||
|
||||
_subsection: NodesmithProvider
|
||||
|
||||
Tra la la...
|
||||
|
||||
_subsection: AlchemyProvider
|
||||
|
||||
Tra la la...
|
29
docs.wrm/api/providers/example-account.js
Normal file
29
docs.wrm/api/providers/example-account.js
Normal file
@ -0,0 +1,29 @@
|
||||
// <hide>
|
||||
|
||||
const { ethers } = require("./packages/ethers");
|
||||
const provider = ethers.getDefaultProvider()
|
||||
|
||||
function _inspect(result) {
|
||||
if (ethers.BigNumber.isBigNumber(result)) {
|
||||
return `{ BigNumber: ${ JSON.stringify(result.toString()) } }`;
|
||||
}
|
||||
return JSON.stringify(result);
|
||||
}
|
||||
|
||||
// </hide>
|
||||
|
||||
// Get the balance for an account...
|
||||
provider.getBalance("ricmoo.firefly.eth");
|
||||
//!
|
||||
|
||||
// Get the code for a contract...
|
||||
provider.getCode("registrar.firefly.eth");
|
||||
//!
|
||||
|
||||
// Get the storage value at position 0...
|
||||
provider.getStorageAt("registrar.firefly.eth", 0)
|
||||
//!
|
||||
|
||||
// Get transaction count of an account...
|
||||
provider.getTransactionCount("ricmoo.firefly.eth");
|
||||
//!
|
15
docs.wrm/api/providers/example-ens.js
Normal file
15
docs.wrm/api/providers/example-ens.js
Normal file
@ -0,0 +1,15 @@
|
||||
// <hide>
|
||||
|
||||
const { ethers } = require("./packages/ethers");
|
||||
const provider = ethers.getDefaultProvider()
|
||||
|
||||
// </hide>
|
||||
|
||||
// Reverse lookup of an ENS by address...
|
||||
provider.lookupAddress("0x6fC21092DA55B392b045eD78F4732bff3C580e2c");
|
||||
//!
|
||||
|
||||
// Lookup an address of an ENS name...
|
||||
provider.resolveName("ricmoo.firefly.eth");
|
||||
//!
|
||||
|
46
docs.wrm/api/providers/index.wrm
Normal file
46
docs.wrm/api/providers/index.wrm
Normal file
@ -0,0 +1,46 @@
|
||||
_title: Providers
|
||||
|
||||
_section: Providers
|
||||
|
||||
A **Provider** is an abstraction of a connection to the
|
||||
Ethereum network, providing a concise, consistent interface
|
||||
to standard Ethereum node functionality.
|
||||
|
||||
The ethers.js library provides several options which should
|
||||
cover the vast majority of use-cases, but also includes the
|
||||
necessary functions and classes for sub-classing if a more
|
||||
custom configuration is necessary.
|
||||
|
||||
Most users should be able to simply use the [[get-default-provider]].
|
||||
|
||||
|
||||
_subsection: Default Provider @<get-default-provider>
|
||||
|
||||
The default provider is the safest, easiest way to begin
|
||||
developing on //Ethereum//, and it is also robust enough
|
||||
for use in production.
|
||||
|
||||
It creates a [[provider-fallback]] connected to as many backend
|
||||
services as possible. When a request is made, it is sent to
|
||||
multiple backends simulatenously. As responses from each backend
|
||||
are returned, they are checked that they agree. Once a quorum
|
||||
has been reached (i.e. enough of the backends agree), the response
|
||||
is provided to your application.
|
||||
|
||||
This ensures that if a backend has become out-of-sync, or if it
|
||||
has been compromised that its responses are dropped in favor of
|
||||
responses that match the majority.
|
||||
|
||||
_property: ethers.getDefaultProvider([ network ]) => [[provider]]
|
||||
Returns a new Provider, backed by multiple services, connected
|
||||
to //network//. Is no //network// is provided, **homestead**
|
||||
(i.e. mainnet) is used.
|
||||
|
||||
_subsection: Provider Documentation
|
||||
|
||||
_toc:
|
||||
provider
|
||||
jsonrpc-provider
|
||||
api-providers
|
||||
other
|
||||
types
|
22
docs.wrm/api/providers/jsonrpc-provider.wrm
Normal file
22
docs.wrm/api/providers/jsonrpc-provider.wrm
Normal file
@ -0,0 +1,22 @@
|
||||
_title: JSON-RPC Provider
|
||||
|
||||
_section: JSON-RPC Provider
|
||||
|
||||
Explain here...
|
||||
|
||||
_subsection: JsonRpcProvider @<jsonrpc-provider>
|
||||
|
||||
TODO...
|
||||
|
||||
_property: provider.getSigner([ addressOrIndex ]) => [[jsonrpc-signer]]
|
||||
Returns a [[jsonrpc-signer]] which is managed by this Ethereum node, at
|
||||
//addressOrIndex//. If no //addressOrIndex// is provided, the first
|
||||
account (account #0) is used.
|
||||
|
||||
_property: provider.getUncheckSigner([ addressOrIndex ]) => [[jsonrpc-uncheckedsigner]]
|
||||
|
||||
_subsection: JsonRpcSigner @<jsonrpc-signer>
|
||||
TODO... Explain
|
||||
|
||||
_subsection: JsonRpcUncheckedSigner @<jsonrpc-uncheckedsigner>
|
||||
TODO... Explain
|
27
docs.wrm/api/providers/other.wrm
Normal file
27
docs.wrm/api/providers/other.wrm
Normal file
@ -0,0 +1,27 @@
|
||||
_title: Other Providers
|
||||
|
||||
_section: Other Providers
|
||||
|
||||
Others...
|
||||
|
||||
_subsection: FallbackProvider @<provider-fallback>
|
||||
|
||||
Explain...
|
||||
|
||||
_heading: Properties
|
||||
|
||||
_property: provider.providers => Array<[[provider]]>
|
||||
The list of Providers this is connected to.
|
||||
|
||||
_property: provider.quorum => number
|
||||
The quorum the backend responses must agree upon before a result will be
|
||||
resolved. By default this is //half the sum of the weights//.
|
||||
|
||||
_property: provider.weights => Array<number>
|
||||
The weight each of the Providers adds to a results acceptance.
|
||||
|
||||
|
||||
_subsection: IpcProvider @<provider-ipc>
|
||||
|
||||
Explain...
|
||||
|
141
docs.wrm/api/providers/provider.wrm
Normal file
141
docs.wrm/api/providers/provider.wrm
Normal file
@ -0,0 +1,141 @@
|
||||
_title: Abstract Provider
|
||||
|
||||
|
||||
_section: Provider @<provider>
|
||||
|
||||
Explain what a provider is...
|
||||
|
||||
|
||||
_subsection: Accounts Methods
|
||||
|
||||
_property: provider.getBalance(address [ , blockTag = "latest" ]) => Promise<[[bignumber]]>
|
||||
Returns the balance of //address// as of the //blockTag// block height.
|
||||
|
||||
_property: provider.getCode(address [ , blockTag = "latest" ]) => Promise<[[hexstring]]>
|
||||
Returns the contract code of //address// as of the //blockTag// block height. If there is
|
||||
no contract currently deployed, the result is ``0x``.
|
||||
|
||||
_property: provider.getStorageAt(address, position [ , blockTag = "latest" ]) => Promise<[[hexstring]]>
|
||||
Returns the ``Bytes32`` value of the //position// at //address//, as of the //blockTag//.
|
||||
|
||||
_property: provider.getTransactionCount(address [ , blockTag = "latest" ]) => Promise<number>
|
||||
Returns the number of transactions //address// has ever **sent**, as of //blockTag//.
|
||||
This value is required to be the nonce for the next transaction from //address//
|
||||
sent to the network.
|
||||
|
||||
_heading: Examples
|
||||
|
||||
_code: example-account.js
|
||||
|
||||
|
||||
_subsection: Blocks Methods
|
||||
|
||||
_property: provider.getBlock(block) => Promise<[[provider-block]]>
|
||||
Get the //block// from the network, where the ``result.transactions`` is a list
|
||||
of transaction hashes.
|
||||
|
||||
_property: provider.getBlockWithTransactions(block) => Promise<[[provider-blocktxs]]>
|
||||
Get the //block// from the network, where the ``result.transactions`` is
|
||||
an Array of [[provider-transactionresponse]] objects.
|
||||
|
||||
|
||||
_subsection: Ethereum Naming Service (ENS) Methods
|
||||
|
||||
TODO: Explain ENS here...
|
||||
|
||||
_property: provider.lookupAddress(address) => Promise<string>
|
||||
Performs a reverse lookup of the //address// in ENS using the
|
||||
//Reverse Registrar//. If the name does not exist, or the
|
||||
forward lookup does not match, ``null`` is returned.
|
||||
|
||||
_property: provider.resovleName(name) => Promise<string>
|
||||
Looks up the address of //name//. If the name is not owned, or
|
||||
does not have a //Resolver// configured, or the //Resolver// does
|
||||
not have an address configured, ``null`` is returned.
|
||||
|
||||
_heading: Examples
|
||||
|
||||
_code: example-ens.js
|
||||
|
||||
_subsection: Logs Methods
|
||||
|
||||
_property: provider.getLogs(filter) => Promise<Array<[[provider-log]]>>
|
||||
Returns the Array of [[provider-log]] matching the //filter//.
|
||||
|
||||
Keep in mind that many backends will discard old events, and that requests
|
||||
which are too broad may get dropped as they require too many resources to
|
||||
execute the query.
|
||||
|
||||
|
||||
_subsection: Network Status Methods
|
||||
|
||||
_property: provider.getNetwork() => Promise<[[provider-network]]>
|
||||
Returns the [[provider-network]] this Provider is connected to.
|
||||
|
||||
_property: provider.getBlockNumber() => Promise<number>
|
||||
Returns the block number (or height) of the most recently mined block.
|
||||
|
||||
_property: provider.getGasPrice() => Promise<[[bignumber]]>
|
||||
Returns a //best guess// of the [[gas-price]] to use in a transaction.
|
||||
|
||||
|
||||
_subsection: Transactions Methods
|
||||
|
||||
_property: provider.call(transaction [ , blockTag = "latest" ]) => Promise<[[hexstring]]>
|
||||
Returns the result of executing the //transaction//, using //call//. A call
|
||||
does not require any ether, but cannot change any state. This is useful
|
||||
for calling gettings on Contracts.
|
||||
|
||||
_property: provider.estimateGas(transaction) => Promise<[[bignumber]]>
|
||||
Returns an estimate of the amount of gas that would be required to submit //transaction//
|
||||
to the network.
|
||||
|
||||
An estimate may not be accurate since there could be another transaction
|
||||
on the network that was not accounted for, but after being mined affected
|
||||
relevant state.
|
||||
|
||||
_property: provider.sendTransaction(transaction) => Promise<[[provider-transactionresponse]]>
|
||||
Submits //transaction// to the network to be mined. The //transaction// **must** be signed,
|
||||
and be valid (i.e. the nonce is correct and the account has sufficient balance to pay
|
||||
for the transaction).
|
||||
|
||||
_property: provider.waitForTransaction(transactionHash) => Promise<[[provider-transactionreceipt]]>
|
||||
Returns a Promise which will not resolve until //transactionHash// is mined.
|
||||
|
||||
|
||||
_subsection: Event Emitter Methods
|
||||
|
||||
Explain events here...
|
||||
|
||||
_property: provider.on(eventName, listener) => this
|
||||
Add a //listener// to be triggered for each //eventName//.
|
||||
|
||||
_property: provider.once(eventName, listener) => this
|
||||
Add a //listener// to be triggered for only the next //eventName//,
|
||||
at which time it be removed.
|
||||
|
||||
_property: provider.emit(eventName, ...args) => boolean
|
||||
Notify all listeners of //eventName//, passing //args// to each listener. This
|
||||
is generally only used internally.
|
||||
|
||||
_property: provider.off(eventName [ , listener ]) => this
|
||||
Remove a //listener// for //eventName//. If no //listener// is provided,
|
||||
all listeners for //eventName// are removed.
|
||||
|
||||
_property: provider.removeAllListeners([ eventName ]) => this
|
||||
Remove all the listeners for //eventName//. If no //eventName// is provided,
|
||||
**all** events are removed.
|
||||
|
||||
_property: provider.listenerCount([ eventName ]) => number
|
||||
Returns the number of listeners for //eventName//. If no //eventName// is
|
||||
provided, the total number of listeners is returned.
|
||||
|
||||
_property: provider.listeners(eventName) => Array<Listener>
|
||||
Returns the list of Listeners for //eventName//.
|
||||
|
||||
|
||||
_subsection: Inspection Methods
|
||||
|
||||
_property: Provider.isProvider(object) => boolean
|
||||
Returns true if and only if object is a Provider.
|
||||
|
75
docs.wrm/api/providers/types.wrm
Normal file
75
docs.wrm/api/providers/types.wrm
Normal file
@ -0,0 +1,75 @@
|
||||
_title: Types
|
||||
|
||||
_section: Types
|
||||
|
||||
_heading: BlockTag @<provider-blocktag>
|
||||
A **BlockTag** specifies a specific location in the Blockchain.
|
||||
|
||||
- **``"latest"``** -- The most recently mined block
|
||||
- **``"earliest"``** -- Block #0
|
||||
- **``"pending"``** -- The block currently being prepared for mining; not all
|
||||
operations support this BlockTag
|
||||
- **//number//** -- The block at this height
|
||||
- **//a negative number//** -- The block this many blocks ago
|
||||
|
||||
_heading: Network @<provider-network>
|
||||
A **Network** represents an Etherem network.
|
||||
|
||||
- **name** -- The human-readable name of the network
|
||||
- **chainId** -- The Chain ID of the network
|
||||
- **ensAddress** -- The address at which the ENS registry is deployed
|
||||
|
||||
|
||||
_subsection: Blocks
|
||||
|
||||
_heading: Block @<provider-block>
|
||||
TODO
|
||||
|
||||
_heading: BlockWithTransactions @<provider-blocktxs>
|
||||
TODO
|
||||
|
||||
|
||||
_subsection: Events and Logs
|
||||
|
||||
_heading: EventFilter
|
||||
TODO
|
||||
|
||||
_heading: EventType
|
||||
TODO
|
||||
|
||||
_heading: Filter
|
||||
TODO
|
||||
|
||||
_heading: FilterByBlockHash
|
||||
TODO
|
||||
|
||||
_heading: Log @<provider-log>
|
||||
A network...
|
||||
|
||||
|
||||
_subsection: Transactions
|
||||
|
||||
_heading: TransactionRequest @<provider-transactionrequest>
|
||||
|
||||
A transaction request describes a transaction that is to
|
||||
be sent to the network or otherwise processed.
|
||||
|
||||
It contains the fields:
|
||||
- **to** --- target address
|
||||
- **from** --- target address
|
||||
- **nonce** --- target address
|
||||
- **gasLimit** --- target address
|
||||
- **gasPrice** --- target address
|
||||
- **data** --- target address
|
||||
- **value** --- target address
|
||||
- **chainId** --- target address
|
||||
|
||||
All fields are optional and may be a promise which resolves
|
||||
to the required type.
|
||||
|
||||
_heading: TransactionResponse @<provider-transactionresponse>
|
||||
|
||||
A **TransactionResponse** ..
|
||||
|
||||
_heading: TransactionReceipt @<provider-transactionreceipt>
|
||||
TODO
|
32
docs.wrm/api/signer.wrm
Normal file
32
docs.wrm/api/signer.wrm
Normal file
@ -0,0 +1,32 @@
|
||||
_title: Signer
|
||||
|
||||
_section: Signers
|
||||
|
||||
Tra la la...
|
||||
|
||||
_subsection: Signer
|
||||
|
||||
_property: signer.connect(provider) => Signer
|
||||
TODO
|
||||
|
||||
_heading: Blockchain Methods
|
||||
|
||||
_property: signer.getBalance([ blockTag = "latest" ]) => Promise(BigNumber)
|
||||
TODO
|
||||
|
||||
_property: signer.getTransactionCount([ blockTag = "latest" ]) => Promise(number)
|
||||
TODO
|
||||
|
||||
|
||||
_subsection: Wallet inherits Signer
|
||||
|
||||
Wallet is...
|
||||
|
||||
_heading: Creating an Instance
|
||||
|
||||
_property: new ethers.Wallet(privateKey [ , provider ])
|
||||
TODO
|
||||
|
||||
_property: Wallet.fromEncryptedJson(json, password)
|
||||
TODO
|
||||
|
21
docs.wrm/api/utils/address.wrm
Normal file
21
docs.wrm/api/utils/address.wrm
Normal file
@ -0,0 +1,21 @@
|
||||
_title: Addresses
|
||||
|
||||
_section: Addresses
|
||||
|
||||
Explain addresses,formats and checksumming here.
|
||||
|
||||
Also see: [Constants.AddressZero](constants)
|
||||
|
||||
_heading: Functions
|
||||
|
||||
_property: utils.getAddress(address) => string
|
||||
TODO
|
||||
|
||||
_property: utils.isAddress(address) => boolean
|
||||
TODO
|
||||
|
||||
_property: utils.getIcapAddress(address) => string
|
||||
TODO
|
||||
|
||||
_property: utils.getContractAddress(transaction) => string
|
||||
TODO
|
50
docs.wrm/api/utils/bignumber-create.js
Normal file
50
docs.wrm/api/utils/bignumber-create.js
Normal file
@ -0,0 +1,50 @@
|
||||
// <hide>
|
||||
const { BigNumber } = require("./packages/ethers");
|
||||
const { constants } = require("./packages/ethers");
|
||||
|
||||
function _inspect(result) {
|
||||
if (BigNumber.isBigNumber(result)) {
|
||||
return `{ BigNumber: ${ JSON.stringify(result.toString()) } }`;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// </hide>
|
||||
|
||||
// From a decimal string...
|
||||
BigNumber.from("42")
|
||||
//!
|
||||
|
||||
// From a hexstring...
|
||||
BigNumber.from("0x2a")
|
||||
//!
|
||||
|
||||
// From a negative hexstring...
|
||||
BigNumber.from("-0x2a")
|
||||
//!
|
||||
|
||||
// From an Array (or Uint8Array)...
|
||||
BigNumber.from([ 42 ])
|
||||
//!
|
||||
|
||||
// From an existing BigNumber...
|
||||
let one1 = constants.One;
|
||||
let one2 = BigNumber.from(one1)
|
||||
|
||||
one2
|
||||
//!
|
||||
|
||||
// ...which returns the same instance
|
||||
one1 === one2
|
||||
//!
|
||||
|
||||
// From a (safe) number...
|
||||
BigNumber.from(42)
|
||||
//!
|
||||
|
||||
// From a ES2015 BigInt... (only on platforms with BigInt support)
|
||||
BigNumber.from(42n)
|
||||
//!
|
||||
|
||||
// Numbers outside the safe range fail:
|
||||
BigNumber.from(Number.MAX_SAFE_INTEGER);
|
||||
//! error
|
16
docs.wrm/api/utils/bignumber-examples.js
Normal file
16
docs.wrm/api/utils/bignumber-examples.js
Normal file
@ -0,0 +1,16 @@
|
||||
// <hide>
|
||||
const { BigNumber } = require("./packages/ethers");
|
||||
|
||||
function _inspect(result) {
|
||||
if (BigNumber.isBigNumber(result)) {
|
||||
return `{ BigNumber: ${ JSON.stringify(result.toString()) } }`;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// </hide>
|
||||
|
||||
let a = BigNumber.from(42);
|
||||
let b = BigNumber.from("91");
|
||||
|
||||
a.mul(b);
|
||||
//!
|
2
docs.wrm/api/utils/bignumber-ieee754.js
Normal file
2
docs.wrm/api/utils/bignumber-ieee754.js
Normal file
@ -0,0 +1,2 @@
|
||||
(Number.MAX_SAFE_INTEGER + 2 - 2) == (Number.MAX_SAFE_INTEGER)
|
||||
//!
|
18
docs.wrm/api/utils/bignumber-import.source
Normal file
18
docs.wrm/api/utils/bignumber-import.source
Normal file
@ -0,0 +1,18 @@
|
||||
/////
|
||||
// CommonJS:
|
||||
|
||||
// From the Umbrella ethers package...
|
||||
const { BigNumber } = require("ethers");
|
||||
|
||||
// From the bignumber pacakge...
|
||||
const { BigNumber } = require("@ethersproject/bignumber");
|
||||
|
||||
|
||||
/////
|
||||
// ES6 and TypeScript:
|
||||
|
||||
// From the Umbrella ethers package...
|
||||
import { BigNumber } from "ethers";
|
||||
|
||||
// From the bignumber pacakge...
|
||||
import { BigNumber } from "@ethersproject/bignumber";
|
175
docs.wrm/api/utils/bignumber.wrm
Normal file
175
docs.wrm/api/utils/bignumber.wrm
Normal file
@ -0,0 +1,175 @@
|
||||
_title: Big Number
|
||||
|
||||
|
||||
_section: BigNumber @<bignumber>
|
||||
|
||||
Explain about BigNumber here...
|
||||
|
||||
_heading: Importing
|
||||
|
||||
_code: bignumber-import.source
|
||||
|
||||
_subsection: Types
|
||||
|
||||
_heading: BigNumberish @<bignumberish>
|
||||
|
||||
Many functions and methods in this library take in values which
|
||||
can be non-ambiguously and safely converted to a BigNumber. These
|
||||
values can be sepcified as:
|
||||
|
||||
_definition: **//string//**
|
||||
A [hexstring](hexstring) or a decimal string, either of which may
|
||||
be negative.
|
||||
|
||||
_definition: **//BytesLike//**
|
||||
A [BytesLike](byteslike) Object, such as an Array or Uint8Array.
|
||||
|
||||
_definition: **//BigNumber//**
|
||||
An existing BigNumber instance.
|
||||
|
||||
_definition: **//number//**
|
||||
A number that is within the safe range for JavaScript numbers.
|
||||
|
||||
_definition: **//BigInt//**
|
||||
A JavaScript [BigInt](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt)
|
||||
object, on environments that support BigInt.
|
||||
|
||||
|
||||
_subsection: Creating Instances
|
||||
|
||||
The constructor of BigNumber cannot be called directly. Instead, Use the static ``BigNumber.from``.
|
||||
|
||||
_property: BigNumber.from(aBigNumberish) => [[bignumber]]
|
||||
Returns an instance of a **BigNumber** for //aBigNumberish//.
|
||||
|
||||
_heading: Examples:
|
||||
|
||||
_code: bignumber-create.js
|
||||
|
||||
|
||||
_subsection: Methods
|
||||
|
||||
The BigNumber class is immutable, so no operations can change the value
|
||||
it represents.
|
||||
|
||||
|
||||
_heading: Math Operations
|
||||
|
||||
_property: bignumber.add(otherValue) => [[bignumber]]
|
||||
Returns a BigNumber with the value of //bignumber// **+** //otherValue//.
|
||||
|
||||
_property: bignumber.sub(otherValue) => [[bignumber]]
|
||||
Returns a BigNumber with the value of //bignumber// **–** //otherValue//.
|
||||
|
||||
_property: bignumber.mul(otherValue) => [[bignumber]]
|
||||
Returns a BigNumber with the value of //bignumber// **×** //otherValue//.
|
||||
|
||||
_property: bignumber.div(divisor) => [[bignumber]]
|
||||
Returns a BigNumber with the value of //bignumber// **÷** //divisor//.
|
||||
|
||||
_property: bignumber.mod(divisor) => [[bignumber]]
|
||||
Returns a BigNumber with the value of the **remainder** of //bignumber// ÷ //divisor//.
|
||||
|
||||
_property: bignumber.pow(exponent) => [[bignumber]]
|
||||
Returns a BigNumber with the value of //bignumber// to the power of //exponent//.
|
||||
|
||||
_property: bignumber.abs() => [[bignumber]]
|
||||
Returns a BigNumber with the absolute value of //bignumber//.
|
||||
|
||||
_property: bignumber.maskn(bitcount) => [[bignumber]]
|
||||
Returns a BigNumber with the value of //bignumber// with bits beyond
|
||||
the //bitcount// least significant bits set to zero.
|
||||
|
||||
|
||||
_heading: Two's Compliment
|
||||
|
||||
[Two's Complicment](https://en.wikipedia.org/wiki/Two%27s_complement)
|
||||
is a method used to encode and decode fixed-width values which can be
|
||||
positive or negative, without requiring a separate sign bit. Most users
|
||||
will not need to interact with these.
|
||||
|
||||
_property: bignumber.fromTwos(bitwidth) => [[bignumber]]
|
||||
Returns a BigNumber with the value of //bignumber// converted from twos-compliment with //bitwidth//.
|
||||
|
||||
_property: bignumber.toTwos(bitwidth) => [[bignumber]]
|
||||
Returns a BigNumber with the value of //bignumber// converted to twos-compliment with //bitwidth//.
|
||||
|
||||
|
||||
_heading: Comparison and Equivalence
|
||||
|
||||
_property: bignumber.eq(otherValue) => boolean
|
||||
Returns true if and only if the value of //bignumber// is equal to //otherValue//.
|
||||
|
||||
_property: bignumber.lt(otherValue) => boolean
|
||||
Returns true if and only if the value of //bignumber// **<** //otherValue//.
|
||||
|
||||
_property: bignumber.lte(otherValue) => boolean
|
||||
Returns true if and only if the value of //bignumber// **≤** //otherValue//.
|
||||
|
||||
_property: bignumber.gt(otherValue) => boolean
|
||||
Returns true if and only if the value of //bignumber// **>** //otherValue//.
|
||||
|
||||
_property: bignumber.gte(otherValue) => boolean
|
||||
Returns true if and only if the value of //bignumber// **≥** //otherValue//.
|
||||
|
||||
_property: bignumber.isZero() => boolean
|
||||
Returns true if and only if the value of //bignumber// is zero.
|
||||
|
||||
|
||||
_heading: Conversion
|
||||
|
||||
_property: bignumber.toNumber() => number
|
||||
Returns the value of //bignumber// as a JavaScript value.
|
||||
|
||||
This will **throw an error**
|
||||
if the value is greater than or equal to //Number.MAX_SAFE_INTEGER// or less than or
|
||||
equal to //Number.MIN_SAFE_INTEGER//.
|
||||
|
||||
_property: bignumber.toString() => string
|
||||
Returns the value of //bignumber// as a base-10 string.
|
||||
|
||||
_property: bignumber.toHexString() => string
|
||||
Returns the value of //bignumber// as a base-16, `0x`-prefixed [hexstring](hexstring).
|
||||
|
||||
|
||||
_heading: Inspection
|
||||
|
||||
_property: BigNumnber.isBigNumber(object) => boolean
|
||||
Returns true if and only if the //object// is a BigNumber object.
|
||||
|
||||
|
||||
_heading: Examples
|
||||
|
||||
_code: bignumber-examples.js
|
||||
|
||||
_subsection: Notes
|
||||
|
||||
A few short notes on numbers...
|
||||
|
||||
_heading: Why can't I just use numbers?
|
||||
|
||||
The first problem many encounter when dealing with Ethereum is
|
||||
the concept of numbers. Most common currencies are broken down
|
||||
with very little granularity. For example, there are only 100
|
||||
cents in a single dollar. However, there are 10^^18^^ **wei** in a
|
||||
single **ether**.
|
||||
|
||||
JavaScript uses [IEEE 754 double-precision binary floating point](https://en.wikipedia.org/wiki/Double-precision_floating-point_format)
|
||||
numbers to represent numeric values. As a result, there are //holes//
|
||||
in the integer set after 9,007,199,254,740,991; which is
|
||||
problematic for //Ethereum// because that is only around 0.009
|
||||
ether (in wei), which means any value over that will begin to
|
||||
experience rounding errors.
|
||||
|
||||
To demonstrate how this may be an issue in your code, consider:
|
||||
|
||||
_code: bignumber-ieee754.js
|
||||
|
||||
To remedy this, all numbers (which can be large) are stored
|
||||
and manipulated as [Big Numbers](bignumber).
|
||||
|
||||
The functions [parseEther( etherString )](http://linkto) and
|
||||
[formatEther( wei )](http://linkto) can be used to convert
|
||||
between string representations, which are displayed to or entered
|
||||
by the user and Big Number representations which can have
|
||||
mathematical operations handled safely.
|
37
docs.wrm/api/utils/bytes-conversion.js
Normal file
37
docs.wrm/api/utils/bytes-conversion.js
Normal file
@ -0,0 +1,37 @@
|
||||
// <hide>
|
||||
|
||||
const { ethers } = require("./packages/ethers");
|
||||
const { arrayify, hexlify, hexValue } = ethers.utils;
|
||||
|
||||
function _inspect(result) {
|
||||
if (result && typeof(result.length) === "number" && typeof(result) !== "string") {
|
||||
return "[ " + Array.prototype.map.call(result, (i) => _inspect(i)).join(", ") + " ]";
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// </hide>
|
||||
|
||||
// Convert a hexstring to a Uint8Array
|
||||
arrayify("0x1234")
|
||||
//!
|
||||
|
||||
// Convert an Array to a hexstring
|
||||
hexlify([1, 2, 3, 4])
|
||||
//!
|
||||
|
||||
// Convert an Object to a hexstring
|
||||
hexlify({ length: 2, "0": 1, "1": 2 })
|
||||
//!
|
||||
|
||||
// Convert an Array to a hexstring
|
||||
hexlify([ 1 ])
|
||||
//!
|
||||
|
||||
// Convert a number to a stripped hex value
|
||||
hexValue(1)
|
||||
//!
|
||||
|
||||
// Convert an Array to a stripped hex value
|
||||
hexValue([ 1, 2 ])
|
||||
//!
|
121
docs.wrm/api/utils/bytes.wrm
Normal file
121
docs.wrm/api/utils/bytes.wrm
Normal file
@ -0,0 +1,121 @@
|
||||
_title: Byte Manipulation
|
||||
|
||||
_section: Byte Manipulation
|
||||
|
||||
Tra la la...
|
||||
|
||||
_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
|
||||
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]].
|
||||
|
||||
_heading: Hexstring @<hexstring>
|
||||
|
||||
A **hexstring** is a string which has a ``0x`` prefix followed by
|
||||
|
||||
_heading: Signature @<signature>
|
||||
|
||||
- **r** and **s** --- The x co-ordinate of **r** and the **s** value of the signature
|
||||
- **v** --- The parity of the y co-ordinate of **r**
|
||||
- **_vs** --- The [compact representation](https://link_here) of the **(r, s)** and **v**
|
||||
- **recoveryParam** --- The normalized (i.e. 0 or 1) value of **v**
|
||||
|
||||
_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).
|
||||
|
||||
|
||||
_subsection: Inspection
|
||||
|
||||
_property: utils.isBytes(object) => boolean
|
||||
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.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.
|
||||
|
||||
|
||||
_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.hexlify(hexstringOrArrayish) => string
|
||||
Converts //hexstringOrArrayish// to a [[hexstring]]. The result
|
||||
will always be zero-padded to even length.
|
||||
|
||||
_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.
|
||||
|
||||
_heading: Examples
|
||||
|
||||
_code: bytes-conversion.js
|
||||
|
||||
|
||||
_subsection: Array Manipulation
|
||||
|
||||
_property: utils.concat(arrayOfBytesLike) => Uint8Array
|
||||
Concatenates all the [[byteslike]] in //arrayOfBytesLike//
|
||||
into a single Uint8Array.
|
||||
|
||||
_property: utils.stripZeros(aBytesLike) => Uint8Array
|
||||
Concatenates all the [[byteslike]] in //arrayOfBytesLike//
|
||||
|
||||
_property: utils.zeroPad(aBytesLike, length) => Uint8Array
|
||||
Concatenates all the [[byteslike]] in //arrayOfBytesLike//
|
||||
|
||||
|
||||
_subsection: Hexstring Manipulation
|
||||
|
||||
_property: utils.hexConcat(arrayOfBytesLike) => string
|
||||
Concatenates all the [[byteslike]] in //arrayOfBytesLike//
|
||||
into a single [[hexstring]]
|
||||
|
||||
_property: utils.hexDataLength(aBytesLike) => number
|
||||
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 ] ) => string
|
||||
Returns the length (in bytes) of //aBytesLike//.
|
||||
|
||||
_property: utils.hexStripZeros(aBytesLike) => string
|
||||
@TODO
|
||||
|
||||
_property: utils.hexZeroPad(aBytesLike, length) => string
|
||||
@TODO
|
||||
|
||||
|
||||
_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.splitSignature(aSignatureLikeOrBytesLike) => Signature
|
||||
Return the full expanded-format of a [[signaturelike]] or
|
||||
a flat-format [[hexstring]]. Any missing properties will be
|
||||
computed.
|
||||
|
3
docs.wrm/api/utils/constants-import.js
Normal file
3
docs.wrm/api/utils/constants-import.js
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
//const { constants } = require("ethers");
|
||||
// const { constants } = require("@ethersproject/constants");
|
49
docs.wrm/api/utils/constants.wrm
Normal file
49
docs.wrm/api/utils/constants.wrm
Normal file
@ -0,0 +1,49 @@
|
||||
_title: Constants
|
||||
|
||||
_section: Constants @<constants>
|
||||
|
||||
The **ethers.contants** Object contains commonly used values.
|
||||
|
||||
_heading: Importing
|
||||
|
||||
_code: constants-import.js
|
||||
|
||||
|
||||
_subsection: Bytes
|
||||
|
||||
_property: constants.AddressZero
|
||||
The Address Zero, which is 20 bytes (40 nibbles) of zero.
|
||||
|
||||
_property: constants.HashZero
|
||||
The Hash Zero, which is 32 bytes (64 nibbles) of zero.
|
||||
|
||||
|
||||
_subsection: Strings
|
||||
|
||||
_property: constants.EtherSymbol
|
||||
The Ether symbol, **Ξ**.
|
||||
|
||||
|
||||
_subsection: BigNumber
|
||||
|
||||
_property: constants.NegativeOne
|
||||
The BigNumber value representing ``"-1"``.
|
||||
|
||||
_property: constants.Zero
|
||||
The BigNumber value representing ``"0"``.
|
||||
|
||||
_property: constants.One
|
||||
The BigNumber value representing ``"1"``.
|
||||
|
||||
_property: constants.Two
|
||||
The BigNumber value representing ``"2"``.
|
||||
|
||||
_property: constants.WeiPerEther
|
||||
The BigNumber value representing ``"1000000000000000000"``, which is the
|
||||
number of Wei per Ether.
|
||||
|
||||
_property: constants.MaxUint256
|
||||
The BigNumber value representing the maximum ``uint256`` value.
|
||||
|
||||
|
||||
|
68
docs.wrm/api/utils/display-logic.wrm
Normal file
68
docs.wrm/api/utils/display-logic.wrm
Normal file
@ -0,0 +1,68 @@
|
||||
_title: Display Logic and Input
|
||||
|
||||
_section: Display Logic and Input
|
||||
|
||||
When creating an Application, it is useful to convert between
|
||||
user-friendly strings (usually displaying **ether**) and the
|
||||
machine-readable values that contracts and maths depend on
|
||||
(usually in **wei**).
|
||||
|
||||
For example, a Wallet may specify the balance in ether, and
|
||||
gas prices in gwei for the User Interface, but when sending
|
||||
a transaction, both must be specified in wei.
|
||||
|
||||
The [parseUnits](unit-conversion) will parse a string representing
|
||||
ether, such as ``1.1`` into a [BigNumber](bignumber) in wei, and is
|
||||
useful when a user types in a value, such as sending 1.1 ether.
|
||||
|
||||
The [formatUnits](unit-conversion) will format a [BigNumberish](bignumberish)
|
||||
into a string, which is useful when displaying a balance.
|
||||
|
||||
|
||||
_subsection: Units
|
||||
|
||||
_heading: Decimal Count
|
||||
|
||||
The //unit// specified may be an integer, which indicates how
|
||||
many decimal place the unit has. For example, 1 ether has 18 decimal
|
||||
places for wei, and if this library were used with Bitcoin, 1 BTC
|
||||
has 8 decimal places for satoshis.
|
||||
|
||||
_heading: Named Units
|
||||
|
||||
In addition to specifying //unit// as a number of decimals, there
|
||||
are several common units, which can be passed in as a string:
|
||||
|
||||
- **wei** --- 0
|
||||
- **kwei** --- 3
|
||||
- **mwei** --- 6
|
||||
- **gwei** --- 9
|
||||
- **szabo** --- 12
|
||||
- **finney** --- 15
|
||||
- **ether** --- 18
|
||||
|
||||
|
||||
_subsection: Functions
|
||||
|
||||
_heading: Formatting
|
||||
|
||||
_property: utils.commify(value) => string
|
||||
Returns a string with value grouped by 3 digits, separated by ``,``.
|
||||
|
||||
|
||||
_heading: Conversion @<unit-conversion>
|
||||
|
||||
_property: utils.formatUnits(value [ , unit = "ether" ] ) => string
|
||||
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
|
||||
The equivalent to calling ``formatUnits(value, "ether")``.
|
||||
|
||||
_property: utils.parseUnits(value [ , unit = "ether" ] ) => [BigNumber](bignumber)
|
||||
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)
|
||||
The equivalent to calling ``parseUnits(value, "ether")``.
|
80
docs.wrm/api/utils/fixednumber.wrm
Normal file
80
docs.wrm/api/utils/fixednumber.wrm
Normal file
@ -0,0 +1,80 @@
|
||||
_title: Fixed Number
|
||||
|
||||
_section: FixedNumber @<fixednumber>
|
||||
|
||||
|
||||
_subsection: Types
|
||||
|
||||
|
||||
_heading: FixedFormat @<fixedformat>
|
||||
TODO
|
||||
|
||||
_definition: **//"fixed"//**
|
||||
A shorthand for ``fixed128x80``.
|
||||
|
||||
_subsection: Creating Instances
|
||||
|
||||
The FixedNumber constructor cannot be called directly. There are several
|
||||
static methods for creating a FixedNumber.
|
||||
|
||||
_property: BigNumber.from(value [ , format = "fixed" ] ) => [[fixednumber]]
|
||||
Returns an instance of a **FixedNumber** for //value// as a //format//.
|
||||
|
||||
_property: BigNumber.fromBytes(aBytesLike [ , format = "fixed" ] ) => [[fixednumber]]
|
||||
Returns an instance of a **FixedNumber** for //value// as a //format//.
|
||||
|
||||
_property: BigNumber.fromString(value [ , format = "fixed" ] ) => [[fixednumber]]
|
||||
Returns an instance of a **FixedNumber** for //value// as a //format//. The //value// must
|
||||
not contain more decimals than the //format// permits.
|
||||
|
||||
_property: BigNumber.fromValue(value [ , decimals = 0 [ , format = "fixed" ] ] ) => [[fixednumber]]
|
||||
Returns an instance of a **FixedNumber** for //value// with //decimals// as a //format//.
|
||||
|
||||
|
||||
_subsection: Properties
|
||||
|
||||
_property: fixednumber.format
|
||||
The [FixedFormat](fixedformat) of //fixednumber//.
|
||||
|
||||
|
||||
_subsection: Methods
|
||||
|
||||
_heading: Math Operations
|
||||
|
||||
_property: fixednumber.addUnsafe(otherValue) => [[fixednumber]]
|
||||
Returns a new FixedNumber with the value of //fixedvalue// **+** //otherValue//.
|
||||
|
||||
_property: fixednumber.subUnsafe(otherValue) => [[fixednumber]]
|
||||
Returns a new FixedNumber with the value of //fixedvalue// **–** //otherValue//.
|
||||
|
||||
_property: fixednumber.mulUnsafe(otherValue) => [[fixednumber]]
|
||||
Returns a new FixedNumber with the value of //fixedvalue// **×** //otherValue//.
|
||||
|
||||
_property: fixednumber.divUnsafe(otherValue) => [[fixednumber]]
|
||||
Returns a new FixedNumber with the value of //fixedvalue// **÷** //otherValue//.
|
||||
|
||||
_property: fixednumber.round([ decimals = 0 ]) => [[fixednumber]]
|
||||
Returns a new FixedNumber with the value of //fixedvalue// rounded to //decimals//.
|
||||
|
||||
|
||||
_heading: Conversion
|
||||
|
||||
_property: fixednumber.toFormat(format) => [[fixednumber]]
|
||||
Returns a new FixedNumber with the value of //fixedvalue// with //format//.
|
||||
|
||||
_property: fixednumber.toHexString() => string
|
||||
Returns a [Hexstring](hexstring) representation of //fixednumber//.
|
||||
|
||||
_property: fixednumber.toString() => string
|
||||
Returns a string representation of //fixednumber//.
|
||||
|
||||
_property: fixednumber.toUnsafeFloat() => float
|
||||
Returns a floating-point JavaScript number value of //fixednumber//.
|
||||
Due to rounding in JavaScript numbers, the value is only approximate.
|
||||
|
||||
|
||||
_heading: Inspection
|
||||
|
||||
_property: BigNumber.isFixedNumber(value) => boolean
|
||||
Returns true if and only if //value// is a **FixedNumber**.
|
||||
|
71
docs.wrm/api/utils/hashing.wrm
Normal file
71
docs.wrm/api/utils/hashing.wrm
Normal file
@ -0,0 +1,71 @@
|
||||
_title: Hashing
|
||||
|
||||
_section: Hashing Algorithms
|
||||
|
||||
Explain what hash functions are?
|
||||
|
||||
|
||||
_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
|
||||
Returns the [KECCAK256](https://en.wikipedia.org/wiki/SHA-3) digest //aBytesLike//.
|
||||
|
||||
_property: utils.ripemd160(aBytesLike) => string
|
||||
Returns the [RIPEMD-160](https://en.m.wikipedia.org/wiki/RIPEMD) digest of //aBytesLike//.
|
||||
|
||||
_property: utils.sha256(aBytesLike) => string
|
||||
Returns the [SHA2-256](https://en.wikipedia.org/wiki/SHA-2) digest of //aBytesLike//.
|
||||
|
||||
_property: utils.sha512(aBytesLike) => string
|
||||
Returns the [SHA2-512](https://en.wikipedia.org/wiki/SHA-2) digest of //aBytesLike//.
|
||||
|
||||
_property: utils.computeHmac(algorithm, key, data) => string
|
||||
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
|
||||
Use the [SHA2-256](https://en.wikipedia.org/wiki/SHA-2) hash algorithm.
|
||||
|
||||
_property: utils.SupportedAlgorithms.sha512
|
||||
Use the [SHA2-512](https://en.wikipedia.org/wiki/SHA-2) hash algorithm.
|
||||
|
||||
|
||||
_subsection: Common Hashing Helpers
|
||||
|
||||
_property: utils.hashMessage(message) => string
|
||||
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
|
||||
The Ethereum Identity function computs the keccak256 hash of the //text// bytes.
|
||||
|
||||
_property: utils.namehash(name) => string
|
||||
Returns the [ENS Namehash](https://docs.ens.domains/contract-api-reference/name-processing#hashing-names) of //name//.
|
||||
|
||||
|
||||
_subsection: Solidity Hashing Algorithms
|
||||
|
||||
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
|
||||
Returns the non-standard encoded //arrayOfValues// packed according to
|
||||
their respecive type in //arrayOfTypes//.
|
||||
|
||||
_property: utils.solidityKeccak256(arrayOfTypes, arrayOfValues) => string
|
||||
Returns the KECCAK256 of the non-standard encoded //arrayOfValues// packed
|
||||
according to their respective type in //arrayOfTypes//.
|
||||
|
||||
_property: utils.soliditySha256(arrayOfTypes, arrayOfValues) => string
|
||||
Returns the SHA2-256 of the non-standard encoded //arrayOfValues// packed
|
||||
according to their respective type in //arrayOfTypes//.
|
||||
|
||||
|
16
docs.wrm/api/utils/index.wrm
Normal file
16
docs.wrm/api/utils/index.wrm
Normal file
@ -0,0 +1,16 @@
|
||||
_title: Utilities
|
||||
|
||||
_section: Utilities
|
||||
|
||||
These utilities are used extensively within the library, but
|
||||
are also quite useful for application developers.
|
||||
|
||||
_toc:
|
||||
address
|
||||
bignumber
|
||||
bytes
|
||||
constants
|
||||
display-logic
|
||||
fixednumber
|
||||
hashing
|
||||
strings
|
92
docs.wrm/api/utils/strings.wrm
Normal file
92
docs.wrm/api/utils/strings.wrm
Normal file
@ -0,0 +1,92 @@
|
||||
_title: Strings
|
||||
|
||||
_section: Strings
|
||||
|
||||
Tra la la
|
||||
|
||||
|
||||
_subsection: Bytes32String @<bytes32-string>
|
||||
|
||||
A string in Solidity is length prefixed with its 256-bit (32 byte)
|
||||
length, which means that even short strings require 2 words (64 bytes)
|
||||
of storage.
|
||||
|
||||
In many cases, we deal with short strings, so instead of prefixing
|
||||
the string with its length, we can null-terminate it and fit it in a
|
||||
single word (32 bytes). Since we need only a single byte for the
|
||||
null termination, we can store strings up to 31 bytes long in a
|
||||
word.
|
||||
|
||||
_definition: **Note:**
|
||||
Strings that are 31 __//bytes//__ long may contain fewer than 31 __//characters//__,
|
||||
since UTF-8 requires multiple bytes to encode international characters.
|
||||
|
||||
_property: utils.parseBytes32String(aBytesLike) => string
|
||||
Returns the decoded string represented by the ``Bytes32`` encoded data.
|
||||
|
||||
_property: utils.formatBytes32String(text) => string
|
||||
Returns a ``bytes32`` string representation of //text//. If the
|
||||
length of //text// exceeds 31 bytes, it will throw an error.
|
||||
|
||||
|
||||
_subsection: UTF-8 Strings @<utf8-string>
|
||||
|
||||
_property: utils.toUtf8Bytes(text [ , form = current ] ) => Uint8Array
|
||||
Returns the UTF-8 bytes of //text//, optionally normalizing it using the
|
||||
[[unicode-normalization-form]] //form//.
|
||||
|
||||
_property: utils.toUtf8CodePoints(aBytesLike [ , form = current ] ) => Array<number>
|
||||
Returns the Array of codepoints of //aBytesLike//, optionally normalizing it using the
|
||||
[[unicode-normalization-form]] //form//.
|
||||
|
||||
**Note:** This function correctly splits each user-perceived character into
|
||||
its codepoint, accounting for surrogate pairs. This should not be confused with
|
||||
``string.split("")``, which destroys surrogate pairs, spliting between each UTF-16
|
||||
codeunit instead.
|
||||
|
||||
_property: utils.toUtf8String(aBytesLike [ , ignoreErrors = false ] ) => string
|
||||
Returns the string represented by the UTF-8 bytes of //aBytesLike//. This will
|
||||
throw an error for invalid surrogates, overlong sequences or other UTF-8 issues,
|
||||
unless //ignoreErrors// is specified.
|
||||
|
||||
|
||||
_heading: UnicodeNormalizationForm @<unicode-normalization-form>
|
||||
|
||||
There are several [commonly used forms](https://en.wikipedia.org/wiki/Unicode_equivalence)
|
||||
when normalizing UTF-8 data, which allow strings to be compared or hashed in a stable
|
||||
way.
|
||||
|
||||
_property: utils.UnicodeNormalizationForm.current
|
||||
Maintain the current normalization form.
|
||||
|
||||
_property: utils.UnicodeNormalizationForm.NFC
|
||||
The Composed Normalization Form. This form uses single codepoints
|
||||
which represent the fully composed character.
|
||||
|
||||
For example, the **é** is a single codepoint, ``0x00e9``.
|
||||
|
||||
_property: utils.UnicodeNormalizationForm.NFD
|
||||
The Decomposed Normalization Form. This form uses multiple codepoints
|
||||
(when necessary) to compose a character.
|
||||
|
||||
For example, the **é**
|
||||
is made up of two codepoints, ``"0x0065"`` (which is the letter ``"e"``)
|
||||
and ``"0x0301"`` which is a special diacritic UTF-8 codepoint which
|
||||
indicates the previous character should have an acute accent.
|
||||
|
||||
_property: utils.UnicodeNormalizationForm.NFKC
|
||||
The Composed Normalization Form with Canonical Equivalence. The Canonical
|
||||
representation folds characters which have the same syntactic representation
|
||||
but different semantic meaning.
|
||||
|
||||
For example, the Roman Numeral **I**, which has a UTF-8
|
||||
codepoint ``"0x2160"``, is folded into the capital letter I, ``"0x0049"``.
|
||||
|
||||
_property: utils.UnicodeNormalizationForm.NFKD
|
||||
The Decomposed Normalization Form with Canonical Equivalence.
|
||||
See NFKC for more an example.
|
||||
|
||||
_definition: **Note:**
|
||||
Only certain specified characters are folded in Canonical Equivalence, and thus
|
||||
it should not be considered a method to acheive //any// level of security from
|
||||
[homoglyph attacks](https://en.wikipedia.org/wiki/IDN_homograph_attack).
|
5
docs.wrm/concepts/events.wrm
Normal file
5
docs.wrm/concepts/events.wrm
Normal file
@ -0,0 +1,5 @@
|
||||
_title: Events
|
||||
|
||||
_section: Events
|
||||
|
||||
Explain how topics and such work
|
13
docs.wrm/concepts/gas.wrm
Normal file
13
docs.wrm/concepts/gas.wrm
Normal file
@ -0,0 +1,13 @@
|
||||
_title: Gas
|
||||
|
||||
_section: Gas
|
||||
|
||||
_subsection: Gas Price @<gas-price>
|
||||
|
||||
The gas price is used somewhat like a bid, indicating an amount
|
||||
you are willing to pay (per unit of execution) to have your transaction
|
||||
processed.
|
||||
|
||||
_subsection: Gas Limit @<gas-limit>
|
||||
|
||||
|
10
docs.wrm/concepts/index.wrm
Normal file
10
docs.wrm/concepts/index.wrm
Normal file
@ -0,0 +1,10 @@
|
||||
_title: Concepts
|
||||
|
||||
_section: Concepts
|
||||
|
||||
This is a very breif overview of some aspects of //Ethereum//
|
||||
which developers can make use of or should be aware of.
|
||||
|
||||
_toc:
|
||||
events
|
||||
gas
|
35
docs.wrm/contributing.wrm
Normal file
35
docs.wrm/contributing.wrm
Normal file
@ -0,0 +1,35 @@
|
||||
_title: Contributing and Hacking
|
||||
|
||||
_section: Contributing and Hacking
|
||||
|
||||
The ethers.js library is something that I've written out of necessity,
|
||||
and has grown somewhat organically over time.
|
||||
|
||||
Many things are the way they are for good (at the time, at least) reasons,
|
||||
but I always welcome criticism, and am completely willing to have my mind
|
||||
changed on things.
|
||||
|
||||
So, pull requests are always welcome, but please keep a few points in mind:
|
||||
|
||||
- Backwards-compatibility-breaking changes will not be accepted; they may be
|
||||
considered for the next major version
|
||||
- Security is important; adding dependencies require fairly convincing
|
||||
arguments as to why
|
||||
- The library aims to be lean, so keep an eye on the dist/ethers.min.js
|
||||
file size before and after your changes
|
||||
- Add test cases for both expected and unexpected input
|
||||
- Any new features need to be supported by me (future issues, documentation,
|
||||
testing, migration), so anything that is overly complicated or specific
|
||||
may not be accepted
|
||||
|
||||
In general, **please start an issue //before// beginning a pull request**, so we can
|
||||
have a public discussion and figure out the best way to address to problem/feature.
|
||||
**:)**
|
||||
|
||||
|
||||
_subsection: Building
|
||||
|
||||
use npm run auto-build
|
||||
|
||||
use npm run update-version
|
||||
|
7
docs.wrm/cookbook/index.wrm
Normal file
7
docs.wrm/cookbook/index.wrm
Normal file
@ -0,0 +1,7 @@
|
||||
_title: Cookbook
|
||||
|
||||
_section: Cookbook
|
||||
|
||||
Cooking...
|
||||
|
||||
|
23
docs.wrm/documentation/examples.txt
Normal file
23
docs.wrm/documentation/examples.txt
Normal file
@ -0,0 +1,23 @@
|
||||
_section: Hello World @<link-to-this-section>
|
||||
|
||||
_subsection: Some Example @<link-to-this-subsection>
|
||||
|
||||
_heading: Large Bold Text @<link-to-this-heading>
|
||||
|
||||
_definition: Flatworm
|
||||
A phylum of relatively **simple** bilaterian, unsegmented,
|
||||
soft-bodied invertebrates.
|
||||
|
||||
_property: String.fromCharCode(code) => string
|
||||
Returns a string created from //code//, a sequence of
|
||||
UTF-16 code units.
|
||||
|
||||
_code: filename.js
|
||||
|
||||
_toc:
|
||||
some-file
|
||||
some-directory
|
||||
|
||||
_null:
|
||||
This breaks out of a directive. For example, to end a
|
||||
_definition and reset the indentation.
|
7
docs.wrm/documentation/fragment.txt
Normal file
7
docs.wrm/documentation/fragment.txt
Normal file
@ -0,0 +1,7 @@
|
||||
_DIRECTIVE: VALUE @<LINK>
|
||||
BODY
|
||||
|
||||
DIRECTIVE: The directive name
|
||||
VALUE: Optional; the value to pass to the directive
|
||||
LINK: Optional; a name for internal linking
|
||||
BODY: Optional; the directive body (certain directives only)
|
85
docs.wrm/documentation/index.wrm
Normal file
85
docs.wrm/documentation/index.wrm
Normal file
@ -0,0 +1,85 @@
|
||||
_title: Flatworm Docs
|
||||
|
||||
_section: Flatworm Docs
|
||||
|
||||
The //Flatworm Docs// rendering script is designed to be **very**
|
||||
simple, but provide enough formatting necessary for documenting
|
||||
JavaScript libraries.
|
||||
|
||||
A lot of its inspiration came from [Read the Docs](https://github.com/readthedocs/sphinx_rtd_theme) and
|
||||
the [Sphinx](https://www.sphinx-doc.org/) project.
|
||||
|
||||
|
||||
_subsection: Fragments
|
||||
|
||||
Flatworm Docs are made up of fragments. A fragment is either a lone
|
||||
body of [markdown](flatworm-markdown) text, or a
|
||||
[directive](flatworm-directive) for specialized formatting, which may
|
||||
itself have body.
|
||||
|
||||
|
||||
_heading: Directive Format
|
||||
|
||||
_code: fragment.txt
|
||||
|
||||
|
||||
_heading: Flatworm Directives @<flatworm-directive>
|
||||
|
||||
_definition: **_section:** //TITLE//
|
||||
A //section// has its **TITLE** in an H1 font. Sections are linked
|
||||
to in //Table of Contents// and have a dividing line drawn above
|
||||
them. If an option is specified, it is avaialble as a name for
|
||||
intern linking. There should only be one ``_section:`` per page.
|
||||
|
||||
_definition: **_subsection:** //TITLE//
|
||||
A //subsection// has its **TITLE** in an H2 font. Subsections are linked
|
||||
to in //Table of Contents// and have a dividing line drawn above
|
||||
them. If an option is specified, it is avaialble as a name for
|
||||
internal linking.
|
||||
|
||||
_definition: **_heading:** //TITLE//
|
||||
A //heading// has its **TITLE** in an H3 font. If an option is specified,
|
||||
it is available as a name for internal linking.
|
||||
|
||||
_definition: **_definition:** //TERM//
|
||||
A //definition// has its **TERM** bolded and the markdown body is
|
||||
indented.
|
||||
|
||||
_definition: **_property:** //SIGNATURE//
|
||||
A //property// has its JavaScript **SIGNATURE** formatted and the
|
||||
markdown body is indented.
|
||||
|
||||
_definition: **_code:** //FILENAME//
|
||||
A //code// reads the **FILENAME** and depending on the extension
|
||||
adjusts it.
|
||||
|
||||
For JavaScript files, the file is executed, with ``\/\/!`` replaced
|
||||
with the result of the last statement and ``\/\/!error`` is replaced
|
||||
with the throw error. If the error state does not agree, rendering
|
||||
fails.
|
||||
|
||||
_definition: **_toc:**
|
||||
A //toc// injects a Table of Contents, loading each line of the
|
||||
body as a filename and recursively loads the //toc// if present,
|
||||
otherwise all the //sections// and //subsections//.
|
||||
|
||||
_definition: **_null:**
|
||||
A //null// is used to terminated a directive. For example, after
|
||||
a //definition//, the bodies are indented, so a //null// can be
|
||||
used to reset the indentation.
|
||||
|
||||
|
||||
_heading: Examples
|
||||
|
||||
_code: examples.txt
|
||||
|
||||
|
||||
_subsection: Markdown @<flatworm-markdown>
|
||||
|
||||
The markdown is simple and does not have the flexibility of
|
||||
other dialects, but allows for **bold**, //italic//,
|
||||
__underlined__, ``monospaced``, ^^super-scripted^^ text,
|
||||
supporting [links](flatworm-markdown) and lists.
|
||||
|
||||
_code: markdown.txt
|
||||
|
23
docs.wrm/documentation/markdown.txt
Normal file
23
docs.wrm/documentation/markdown.txt
Normal file
@ -0,0 +1,23 @@
|
||||
**bold text**
|
||||
|
||||
//italic text//
|
||||
|
||||
__underlined text__
|
||||
|
||||
``monospace code``
|
||||
|
||||
^^superscript text^^
|
||||
|
||||
- This is a list
|
||||
- With bullet points
|
||||
- With a total of three items
|
||||
|
||||
This is separated by -- an en-dash.
|
||||
|
||||
This is separated by --- an em-dash.
|
||||
|
||||
This is a [Link to Ethereum](https://ethereum.org) and this
|
||||
is an [Internal Link](some-link).
|
||||
|
||||
This is a self-titled link [[https://ethereumorg]] and this
|
||||
[[some-link]] will use the title from its directives value.
|
32
docs.wrm/getting-started.wrm
Normal file
32
docs.wrm/getting-started.wrm
Normal file
@ -0,0 +1,32 @@
|
||||
_title: Getting Started
|
||||
|
||||
_section: Getting Started
|
||||
|
||||
|
||||
_subsection: Installing
|
||||
|
||||
The various Classes and Functions are available to be imported
|
||||
manually from sub-packages under the
|
||||
[@ethersproject](https://www.npmjs.com/search?q=%40ethersproject%2F)
|
||||
but for most projects, the umbrella package is the easiest way to
|
||||
get started.
|
||||
|
||||
_code: installing.txt
|
||||
|
||||
|
||||
_subsection: Importing
|
||||
|
||||
_heading: Node.js
|
||||
|
||||
_code: importing-node.source
|
||||
|
||||
_heading: Web Browser
|
||||
|
||||
It is generally better practice (for security reasons) to copy the
|
||||
[ethers library](https://cdn.ethers.io/lib/ethers-5.0.min.js) to
|
||||
your own webserver and serve it yourself.
|
||||
|
||||
For quick demos or prototyping though, it can be loaded in your
|
||||
Web Applications from our CDN.
|
||||
|
||||
_code: importing-browser.txt
|
2
docs.wrm/importing-browser.txt
Normal file
2
docs.wrm/importing-browser.txt
Normal file
@ -0,0 +1,2 @@
|
||||
<script src="https://cdn.ethers.io/lib/ethers-5.0.min.js"
|
||||
type="application/javascipt"></script>
|
5
docs.wrm/importing-node.source
Normal file
5
docs.wrm/importing-node.source
Normal file
@ -0,0 +1,5 @@
|
||||
// CommonJS
|
||||
const { ethers } = require("ethers");
|
||||
|
||||
// ES6 or TypeScript
|
||||
const { ethers } = require("ethers");
|
59
docs.wrm/index.wrm
Normal file
59
docs.wrm/index.wrm
Normal file
@ -0,0 +1,59 @@
|
||||
_title: Documentation
|
||||
|
||||
_section: What is ethers?
|
||||
|
||||
The ethers.js library aims to be a complete and compact library for
|
||||
interacting with the Ethereum Blockchain and its ecosystem. It was
|
||||
originally designed for use with [ethers.io](https://ethers.io/) and
|
||||
has since expanded into a much more general-purpose library.
|
||||
|
||||
_subsection: Features
|
||||
|
||||
- Keep your private keys in your client, **safe** and sound
|
||||
- Import and export **JSON wallets** (Geth, Parity and crowdsale)
|
||||
- Import and export BIP 39 **mnemonic phrases** (12 word backup
|
||||
phrases) and HD Wallets (English, Italian, Japanese, Korean,
|
||||
Simplified Chinese, Traditional Chinese; more coming soon)
|
||||
- Meta-classes create JavaScript objects from any contract ABI,
|
||||
including **ABIv2** and **Human-Readable ABI**
|
||||
- Connect to Ethereum nodes over
|
||||
[JSON-RPC](https://github.com/ethereum/wiki/wiki/JSON-RPC),
|
||||
[INFURA](https://infura.io/),
|
||||
[Etherscan](https://etherscan.io/),
|
||||
[Nodesmith](https://nodesmith.io),
|
||||
[Alchemy](https://alchemyapi.io),
|
||||
or [MetaMask](https://metamask.io/).
|
||||
- **ENS names** are first-class citizens; they can be used
|
||||
anywhere an Ethereum addresses can be used
|
||||
- **Tiny** (~88kb compressed; 284kb uncompressed)
|
||||
- **Complete** functionality for all your Ethereum needs
|
||||
- Extensive [documentation](https://docs.ethers.io/)
|
||||
- Large collection of **test cases** which are maintained and added to
|
||||
- Fully **TypeScript** ready, with definition files and full
|
||||
TypeScript source
|
||||
- **MIT License** (including //ALL// dependencies); completely open
|
||||
source to do with as you please
|
||||
|
||||
|
||||
_subsection: Developer Documentation
|
||||
|
||||
_toc:
|
||||
|
||||
getting-started
|
||||
concepts
|
||||
api
|
||||
cookbook
|
||||
migration
|
||||
testing
|
||||
contributing
|
||||
documentation
|
||||
license
|
||||
|
||||
|
||||
_subsection: Legacy Documentation
|
||||
|
||||
This section will be kept up to date, linking to documentation of
|
||||
older versions of the library.
|
||||
|
||||
- [version 4.0](https://docs.ethers.io/ethers.js)
|
||||
- [version 3.0](https://docs.ethers.io/ethers.js/v3.0/html/)
|
1
docs.wrm/installing.txt
Normal file
1
docs.wrm/installing.txt
Normal file
@ -0,0 +1 @@
|
||||
/home/ricmoo> npm install --save ethers@next
|
32
docs.wrm/license.wrm
Normal file
32
docs.wrm/license.wrm
Normal file
@ -0,0 +1,32 @@
|
||||
_title: License and Copyright
|
||||
|
||||
|
||||
_section: License and Copyright
|
||||
|
||||
The ethers library (including all dependencies) are available
|
||||
under the [MIT License](https://en.m.wikipedia.org/wiki/MIT_License),
|
||||
which permits a wide variety of uses.
|
||||
|
||||
|
||||
_heading: MIT License
|
||||
|
||||
//Copyright © 2019 [Richard Moore](mailto:me@ricmoo.com).//
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
13
docs.wrm/migration/index.wrm
Normal file
13
docs.wrm/migration/index.wrm
Normal file
@ -0,0 +1,13 @@
|
||||
_title: Migration Guide
|
||||
|
||||
_section: Migration Guide
|
||||
|
||||
Migratimg...
|
||||
|
||||
_subsection: From Web3
|
||||
|
||||
test
|
||||
|
||||
_subsection: From ethers v4
|
||||
|
||||
test
|
5
docs.wrm/testing/index.wrm
Normal file
5
docs.wrm/testing/index.wrm
Normal file
@ -0,0 +1,5 @@
|
||||
_title: Testing
|
||||
|
||||
_section: Testing
|
||||
|
||||
Here goes info about testing
|
143
docs/README.md
Normal file
143
docs/README.md
Normal file
@ -0,0 +1,143 @@
|
||||
-----
|
||||
|
||||
test
|
||||
|
||||
-----
|
||||
|
||||
What is ethers?
|
||||
===============
|
||||
|
||||
|
||||
The ethers.js library aims to be a complete and compact library for
|
||||
interacting with the Ethereum Blockchain and its ecosystem. It was
|
||||
originally designed for use with [ethers.io](https://ethers.io/) and
|
||||
has since expanded into a much more general-purpose library.
|
||||
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
|
||||
|
||||
|
||||
* Keep your private keys in your client, **safe** and sound
|
||||
* Import and export **JSON wallets** (Geth, Parity and crowdsale)
|
||||
* Import and export BIP 39 **mnemonic phrases** (12 word backup phrases) and HD Wallets (English, Italian, Japanese, Korean, Simplified Chinese, Traditional Chinese; more coming soon)
|
||||
* Meta-classes create JavaScript objects from any contract ABI, including **ABIv2** and **Human-Readable ABI**
|
||||
* Connect to Ethereum nodes over [JSON-RPC](https://github.com/ethereum/wiki/wiki/JSON-RPC), [INFURA](https://infura.io/), [Etherscan](https://etherscan.io/), [Nodesmith](https://nodesmith.io), [Alchemy](https://alchemyapi.io), or [MetaMask](https://metamask.io/).
|
||||
* **ENS names** are first-class citizens; they can be used anywhere an Ethereum addresses can be used
|
||||
* **Tiny** (~88kb compressed; 284kb uncompressed)
|
||||
* **Complete** functionality for all your Ethereum needs
|
||||
* Extensive [documentation](https://docs.ethers.io/)
|
||||
* Large collection of **test cases** which are maintained and added to
|
||||
* Fully **TypeScript** ready, with definition files and full TypeScript source
|
||||
* **MIT License** (including *ALL* dependencies); completely open source to do with as you please
|
||||
|
||||
|
||||
Developer Documentation
|
||||
-----------------------
|
||||
|
||||
|
||||
|
||||
* [Getting Started](getting-started)
|
||||
* [Installing](getting-started)
|
||||
* [Importing](getting-started)
|
||||
* [Concepts](concepts)
|
||||
* [Events](concepts/events)
|
||||
* [Gas](concepts/gas)
|
||||
* [Gas Price](concepts/gas)
|
||||
* [Gas Limit](concepts/gas)
|
||||
* [Application Programming Interface](api)
|
||||
* [Contracts](api/contract)
|
||||
* [Buckets](api/contract)
|
||||
* [Signers](api/signer)
|
||||
* [Signer](api/signer)
|
||||
* [Wallet inherits Signer](api/signer)
|
||||
* [Providers](api/providers)
|
||||
* [Provider](api/providers/provider)
|
||||
* [Accounts Methods](api/providers/provider)
|
||||
* [Blocks Methods](api/providers/provider)
|
||||
* [Ethereum Naming Service (ENS) Methods](api/providers/provider)
|
||||
* [Logs Methods](api/providers/provider)
|
||||
* [Network Status Methods](api/providers/provider)
|
||||
* [Transactions Methods](api/providers/provider)
|
||||
* [Event Emitter Methods](api/providers/provider)
|
||||
* [Inspection Methods](api/providers/provider)
|
||||
* [JSON-RPC Provider](api/providers/jsonrpc-provider)
|
||||
* [JsonRpcProvider](api/providers/jsonrpc-provider)
|
||||
* [JsonRpcSigner](api/providers/jsonrpc-provider)
|
||||
* [JsonRpcUncheckedSigner](api/providers/jsonrpc-provider)
|
||||
* [API Providers](api/providers/api-providers)
|
||||
* [EtherscanProvider](api/providers/api-providers)
|
||||
* [InfuraProvider](api/providers/api-providers)
|
||||
* [NodesmithProvider](api/providers/api-providers)
|
||||
* [AlchemyProvider](api/providers/api-providers)
|
||||
* [Other Providers](api/providers/other)
|
||||
* [FallbackProvider](api/providers/other)
|
||||
* [IpcProvider](api/providers/other)
|
||||
* [Types](api/providers/types)
|
||||
* [Blocks](api/providers/types)
|
||||
* [Events and Logs](api/providers/types)
|
||||
* [Transactions](api/providers/types)
|
||||
* [Utilities](api/utils)
|
||||
* [Addresses](api/utils/address)
|
||||
* [BigNumber](api/utils/bignumber)
|
||||
* [Types](api/utils/bignumber)
|
||||
* [Creating Instances](api/utils/bignumber)
|
||||
* [Methods](api/utils/bignumber)
|
||||
* [Notes](api/utils/bignumber)
|
||||
* [Byte Manipulation](api/utils/bytes)
|
||||
* [Types](api/utils/bytes)
|
||||
* [Inspection](api/utils/bytes)
|
||||
* [Converting between Arrays and Hexstrings](api/utils/bytes)
|
||||
* [Array Manipulation](api/utils/bytes)
|
||||
* [Hexstring Manipulation](api/utils/bytes)
|
||||
* [Signature Conversion](api/utils/bytes)
|
||||
* [Constants](api/utils/constants)
|
||||
* [Bytes](api/utils/constants)
|
||||
* [Strings](api/utils/constants)
|
||||
* [BigNumber](api/utils/constants)
|
||||
* [Display Logic and Input](api/utils/display-logic)
|
||||
* [Units](api/utils/display-logic)
|
||||
* [Functions](api/utils/display-logic)
|
||||
* [FixedNumber](api/utils/fixednumber)
|
||||
* [Types](api/utils/fixednumber)
|
||||
* [Creating Instances](api/utils/fixednumber)
|
||||
* [Properties](api/utils/fixednumber)
|
||||
* [Methods](api/utils/fixednumber)
|
||||
* [Hashing Algorithms](api/utils/hashing)
|
||||
* [Cryptographic Hashing](api/utils/hashing)
|
||||
* [Common Hashing Helpers](api/utils/hashing)
|
||||
* [Solidity Hashing Algorithms](api/utils/hashing)
|
||||
* [Strings](api/utils/strings)
|
||||
* [Bytes32String](api/utils/strings)
|
||||
* [UTF-8 Strings](api/utils/strings)
|
||||
* [Cookbook](cookbook)
|
||||
* [Migration Guide](migration)
|
||||
* [From Web3](migration)
|
||||
* [From ethers v4](migration)
|
||||
* [Testing](testing)
|
||||
* [Contributing and Hacking](contributing)
|
||||
* [Building](contributing)
|
||||
* [Flatworm Docs](documentation)
|
||||
* [Fragments](documentation)
|
||||
* [Markdown](documentation)
|
||||
* [License and Copyright](license)
|
||||
|
||||
|
||||
Legacy Documentation
|
||||
--------------------
|
||||
|
||||
|
||||
This section will be kept up to date, linking to documentation of
|
||||
older versions of the library.
|
||||
|
||||
|
||||
|
||||
* [version 4.0](https://docs.ethers.io/ethers.js)
|
||||
* [version 3.0](https://docs.ethers.io/ethers.js/v3.0/html/)
|
||||
|
||||
|
||||
|
||||
-----
|
||||
**Content Hash:** 488687b8320fc7da1517bdf2b1ac582250593622aca6b0b3244f61fc14973e42
|
77
docs/api/README.md
Normal file
77
docs/api/README.md
Normal file
@ -0,0 +1,77 @@
|
||||
|
||||
Application Programming Interface (API)
|
||||
=======================================
|
||||
|
||||
|
||||
Here...
|
||||
|
||||
|
||||
* [Contracts](contract)
|
||||
* [Buckets](contract)
|
||||
* [Signers](signer)
|
||||
* [Signer](signer)
|
||||
* [Wallet inherits Signer](signer)
|
||||
* [Providers](providers)
|
||||
* [Provider](providers/provider)
|
||||
* [Accounts Methods](providers/provider)
|
||||
* [Blocks Methods](providers/provider)
|
||||
* [Ethereum Naming Service (ENS) Methods](providers/provider)
|
||||
* [Logs Methods](providers/provider)
|
||||
* [Network Status Methods](providers/provider)
|
||||
* [Transactions Methods](providers/provider)
|
||||
* [Event Emitter Methods](providers/provider)
|
||||
* [Inspection Methods](providers/provider)
|
||||
* [JSON-RPC Provider](providers/jsonrpc-provider)
|
||||
* [JsonRpcProvider](providers/jsonrpc-provider)
|
||||
* [JsonRpcSigner](providers/jsonrpc-provider)
|
||||
* [JsonRpcUncheckedSigner](providers/jsonrpc-provider)
|
||||
* [API Providers](providers/api-providers)
|
||||
* [EtherscanProvider](providers/api-providers)
|
||||
* [InfuraProvider](providers/api-providers)
|
||||
* [NodesmithProvider](providers/api-providers)
|
||||
* [AlchemyProvider](providers/api-providers)
|
||||
* [Other Providers](providers/other)
|
||||
* [FallbackProvider](providers/other)
|
||||
* [IpcProvider](providers/other)
|
||||
* [Types](providers/types)
|
||||
* [Blocks](providers/types)
|
||||
* [Events and Logs](providers/types)
|
||||
* [Transactions](providers/types)
|
||||
* [Utilities](utils)
|
||||
* [Addresses](utils/address)
|
||||
* [BigNumber](utils/bignumber)
|
||||
* [Types](utils/bignumber)
|
||||
* [Creating Instances](utils/bignumber)
|
||||
* [Methods](utils/bignumber)
|
||||
* [Notes](utils/bignumber)
|
||||
* [Byte Manipulation](utils/bytes)
|
||||
* [Types](utils/bytes)
|
||||
* [Inspection](utils/bytes)
|
||||
* [Converting between Arrays and Hexstrings](utils/bytes)
|
||||
* [Array Manipulation](utils/bytes)
|
||||
* [Hexstring Manipulation](utils/bytes)
|
||||
* [Signature Conversion](utils/bytes)
|
||||
* [Constants](utils/constants)
|
||||
* [Bytes](utils/constants)
|
||||
* [Strings](utils/constants)
|
||||
* [BigNumber](utils/constants)
|
||||
* [Display Logic and Input](utils/display-logic)
|
||||
* [Units](utils/display-logic)
|
||||
* [Functions](utils/display-logic)
|
||||
* [FixedNumber](utils/fixednumber)
|
||||
* [Types](utils/fixednumber)
|
||||
* [Creating Instances](utils/fixednumber)
|
||||
* [Properties](utils/fixednumber)
|
||||
* [Methods](utils/fixednumber)
|
||||
* [Hashing Algorithms](utils/hashing)
|
||||
* [Cryptographic Hashing](utils/hashing)
|
||||
* [Common Hashing Helpers](utils/hashing)
|
||||
* [Solidity Hashing Algorithms](utils/hashing)
|
||||
* [Strings](utils/strings)
|
||||
* [Bytes32String](utils/strings)
|
||||
* [UTF-8 Strings](utils/strings)
|
||||
|
||||
|
||||
|
||||
-----
|
||||
**Content Hash:** 3b51f44082b56d5b7fd9be77c92e6871df8642a3307b24d478ee625dbe1d8585
|
17
docs/api/contract/README.md
Normal file
17
docs/api/contract/README.md
Normal file
@ -0,0 +1,17 @@
|
||||
|
||||
|
||||
Contracts
|
||||
=========
|
||||
|
||||
|
||||
Explain what contracts are...
|
||||
|
||||
|
||||
Buckets
|
||||
-------
|
||||
|
||||
|
||||
|
||||
|
||||
-----
|
||||
**Content Hash:** c703f8cc79e5372fb818572209c72eaa54c68385c2021e6fc412594379d834e0
|
6
docs/api/contract/index.html
Normal file
6
docs/api/contract/index.html
Normal file
File diff suppressed because one or more lines are too long
4
docs/api/index.html
Normal file
4
docs/api/index.html
Normal file
File diff suppressed because one or more lines are too long
81
docs/api/providers/README.md
Normal file
81
docs/api/providers/README.md
Normal file
@ -0,0 +1,81 @@
|
||||
|
||||
Providers
|
||||
=========
|
||||
|
||||
|
||||
A **Provider** is an abstraction of a connection to the
|
||||
Ethereum network, providing a concise, consistent interface
|
||||
to standard Ethereum node functionality.
|
||||
|
||||
The ethers.js library provides several options which should
|
||||
cover the vast majority of use-cases, but also includes the
|
||||
necessary functions and classes for sub-classing if a more
|
||||
custom configuration is necessary.
|
||||
|
||||
Most users should be able to simply use the [Default Provider](./).
|
||||
|
||||
|
||||
Default Provider
|
||||
----------------
|
||||
|
||||
|
||||
The default provider is the safest, easiest way to begin
|
||||
developing on *Ethereum*, and it is also robust enough
|
||||
for use in production.
|
||||
|
||||
It creates a [FallbackProvider](other) connected to as many backend
|
||||
services as possible. When a request is made, it is sent to
|
||||
multiple backends simulatenously. As responses from each backend
|
||||
are returned, they are checked that they agree. Once a quorum
|
||||
has been reached (i.e. enough of the backends agree), the response
|
||||
is provided to your application.
|
||||
|
||||
This ensures that if a backend has become out-of-sync, or if it
|
||||
has been compromised that its responses are dropped in favor of
|
||||
responses that match the majority.
|
||||
|
||||
|
||||
#### *ethers* . **getDefaultProvider** ( [ network ] ) **=>** *[Provider](provider)*
|
||||
|
||||
Returns a new Provider, backed by multiple services, connected
|
||||
to *network*. Is no *network* is provided, **homestead**
|
||||
(i.e. mainnet) is used.
|
||||
|
||||
|
||||
|
||||
|
||||
Provider Documentation
|
||||
----------------------
|
||||
|
||||
|
||||
|
||||
* [Provider](provider)
|
||||
* [Accounts Methods](provider)
|
||||
* [Blocks Methods](provider)
|
||||
* [Ethereum Naming Service (ENS) Methods](provider)
|
||||
* [Logs Methods](provider)
|
||||
* [Network Status Methods](provider)
|
||||
* [Transactions Methods](provider)
|
||||
* [Event Emitter Methods](provider)
|
||||
* [Inspection Methods](provider)
|
||||
* [JSON-RPC Provider](jsonrpc-provider)
|
||||
* [JsonRpcProvider](jsonrpc-provider)
|
||||
* [JsonRpcSigner](jsonrpc-provider)
|
||||
* [JsonRpcUncheckedSigner](jsonrpc-provider)
|
||||
* [API Providers](api-providers)
|
||||
* [EtherscanProvider](api-providers)
|
||||
* [InfuraProvider](api-providers)
|
||||
* [NodesmithProvider](api-providers)
|
||||
* [AlchemyProvider](api-providers)
|
||||
* [Other Providers](other)
|
||||
* [FallbackProvider](other)
|
||||
* [IpcProvider](other)
|
||||
* [Types](types)
|
||||
* [Blocks](types)
|
||||
* [Events and Logs](types)
|
||||
* [Transactions](types)
|
||||
|
||||
|
||||
|
||||
-----
|
||||
**Content Hash:** 7c81bceed28adc2b3e892a999c49c14f0d63d29be28d44587c6c2bc63ecd0204
|
47
docs/api/providers/api-providers/README.md
Normal file
47
docs/api/providers/api-providers/README.md
Normal file
@ -0,0 +1,47 @@
|
||||
|
||||
API Providers
|
||||
=============
|
||||
|
||||
|
||||
There are many services which offer a web API for accessing
|
||||
the Ethereum Blockchain. These Providers allow connecting
|
||||
to them, which simplifies development, since you do not need
|
||||
to run your own instance or cluster of Ethereum nodes.
|
||||
|
||||
However, this reliance on third-party services can reduce
|
||||
resiliance, security and increase the amount of required trust.
|
||||
To mitigate these issues, it is recommended you use a
|
||||
[Default Provider](..).
|
||||
|
||||
|
||||
EtherscanProvider
|
||||
-----------------
|
||||
|
||||
|
||||
Tra la la...
|
||||
|
||||
|
||||
InfuraProvider
|
||||
--------------
|
||||
|
||||
|
||||
Tra la la...
|
||||
|
||||
|
||||
NodesmithProvider
|
||||
-----------------
|
||||
|
||||
|
||||
Tra la la...
|
||||
|
||||
|
||||
AlchemyProvider
|
||||
---------------
|
||||
|
||||
|
||||
Tra la la...
|
||||
|
||||
|
||||
|
||||
-----
|
||||
**Content Hash:** cc4a4f172bf2c52a4c2876b44408d293e57ff92b1607ece82192adada290b93a
|
11
docs/api/providers/api-providers/index.html
Normal file
11
docs/api/providers/api-providers/index.html
Normal file
File diff suppressed because one or more lines are too long
9
docs/api/providers/index.html
Normal file
9
docs/api/providers/index.html
Normal file
File diff suppressed because one or more lines are too long
48
docs/api/providers/jsonrpc-provider/README.md
Normal file
48
docs/api/providers/jsonrpc-provider/README.md
Normal file
@ -0,0 +1,48 @@
|
||||
|
||||
JSON-RPC Provider
|
||||
=================
|
||||
|
||||
|
||||
Explain here...
|
||||
|
||||
|
||||
JsonRpcProvider
|
||||
---------------
|
||||
|
||||
|
||||
TODO...
|
||||
|
||||
|
||||
#### *provider* . **getSigner** ( [ addressOrIndex ] ) **=>** *[JsonRpcSigner](./)*
|
||||
|
||||
Returns a [JsonRpcSigner](./) which is managed by this Ethereum node, at
|
||||
*addressOrIndex*. If no *addressOrIndex* is provided, the first
|
||||
account (account #0) is used.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *provider* . **getUncheckSigner** ( [ addressOrIndex ] ) **=>** *[JsonRpcUncheckedSigner](./)*
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
JsonRpcSigner
|
||||
-------------
|
||||
|
||||
|
||||
TODO... Explain
|
||||
|
||||
|
||||
JsonRpcUncheckedSigner
|
||||
----------------------
|
||||
|
||||
|
||||
TODO... Explain
|
||||
|
||||
|
||||
|
||||
-----
|
||||
**Content Hash:** 497729952599bd12a48198ea62e259c24bb3ec8de38d594f346695f34753a2c2
|
11
docs/api/providers/jsonrpc-provider/index.html
Normal file
11
docs/api/providers/jsonrpc-provider/index.html
Normal file
File diff suppressed because one or more lines are too long
51
docs/api/providers/other/README.md
Normal file
51
docs/api/providers/other/README.md
Normal file
@ -0,0 +1,51 @@
|
||||
|
||||
Other Providers
|
||||
===============
|
||||
|
||||
|
||||
Others...
|
||||
|
||||
|
||||
FallbackProvider
|
||||
----------------
|
||||
|
||||
|
||||
Explain...
|
||||
|
||||
|
||||
### Properties
|
||||
|
||||
|
||||
|
||||
#### *provider* . **providers** **=>** *Array< [Provider](../provider) >*
|
||||
|
||||
The list of Providers this is connected to.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *provider* . **quorum** **=>** *number*
|
||||
|
||||
The quorum the backend responses must agree upon before a result will be
|
||||
resolved. By default this is *half the sum of the weights*.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *provider* . **weights** **=>** *Array< number >*
|
||||
|
||||
The weight each of the Providers adds to a results acceptance.
|
||||
|
||||
|
||||
|
||||
|
||||
IpcProvider
|
||||
-----------
|
||||
|
||||
|
||||
Explain...
|
||||
|
||||
|
||||
|
||||
-----
|
||||
**Content Hash:** 5718f5431014c04862ff69aa2ff77548301446272c4ad92724b443850c10a117
|
12
docs/api/providers/other/index.html
Normal file
12
docs/api/providers/other/index.html
Normal file
File diff suppressed because one or more lines are too long
290
docs/api/providers/provider/README.md
Normal file
290
docs/api/providers/provider/README.md
Normal file
File diff suppressed because one or more lines are too long
51
docs/api/providers/provider/index.html
Normal file
51
docs/api/providers/provider/index.html
Normal file
File diff suppressed because one or more lines are too long
125
docs/api/providers/types/README.md
Normal file
125
docs/api/providers/types/README.md
Normal file
@ -0,0 +1,125 @@
|
||||
|
||||
Types
|
||||
=====
|
||||
|
||||
|
||||
|
||||
### BlockTag
|
||||
|
||||
|
||||
A **BlockTag** specifies a specific location in the Blockchain.
|
||||
|
||||
|
||||
|
||||
* **`"latest"`** -- The most recently mined block
|
||||
* **`"earliest"`** -- Block #0
|
||||
* **`"pending"`** -- The block currently being prepared for mining; not all operations support this BlockTag
|
||||
* ***number*** -- The block at this height
|
||||
* ***a negative number*** -- The block this many blocks ago
|
||||
|
||||
|
||||
### Network
|
||||
|
||||
|
||||
A **Network** represents an Etherem network.
|
||||
|
||||
|
||||
|
||||
* **name** -- The human-readable name of the network
|
||||
* **chainId** -- The Chain ID of the network
|
||||
* **ensAddress** -- The address at which the ENS registry is deployed
|
||||
|
||||
|
||||
Blocks
|
||||
------
|
||||
|
||||
|
||||
|
||||
### Block
|
||||
|
||||
|
||||
TODO
|
||||
|
||||
|
||||
### BlockWithTransactions
|
||||
|
||||
|
||||
TODO
|
||||
|
||||
|
||||
Events and Logs
|
||||
---------------
|
||||
|
||||
|
||||
|
||||
### EventFilter
|
||||
|
||||
|
||||
TODO
|
||||
|
||||
|
||||
### EventType
|
||||
|
||||
|
||||
TODO
|
||||
|
||||
|
||||
### Filter
|
||||
|
||||
|
||||
TODO
|
||||
|
||||
|
||||
### FilterByBlockHash
|
||||
|
||||
|
||||
TODO
|
||||
|
||||
|
||||
### Log
|
||||
|
||||
|
||||
A network...
|
||||
|
||||
|
||||
Transactions
|
||||
------------
|
||||
|
||||
|
||||
|
||||
### TransactionRequest
|
||||
|
||||
|
||||
A transaction request describes a transaction that is to
|
||||
be sent to the network or otherwise processed.
|
||||
|
||||
It contains the fields:
|
||||
|
||||
* **to** --- target address
|
||||
* **from** --- target address
|
||||
* **nonce** --- target address
|
||||
* **gasLimit** --- target address
|
||||
* **gasPrice** --- target address
|
||||
* **data** --- target address
|
||||
* **value** --- target address
|
||||
* **chainId** --- target address
|
||||
|
||||
All fields are optional and may be a promise which resolves
|
||||
to the required type.
|
||||
|
||||
|
||||
### TransactionResponse
|
||||
|
||||
|
||||
A **TransactionResponse** ..
|
||||
|
||||
|
||||
### TransactionReceipt
|
||||
|
||||
|
||||
TODO
|
||||
|
||||
|
||||
|
||||
-----
|
||||
**Content Hash:** 9b08b2e4c2db679ae2fc80deb4ce59ec288da11c40730d7e1a045a2538436b17
|
33
docs/api/providers/types/index.html
Normal file
33
docs/api/providers/types/index.html
Normal file
File diff suppressed because one or more lines are too long
66
docs/api/signer/README.md
Normal file
66
docs/api/signer/README.md
Normal file
@ -0,0 +1,66 @@
|
||||
|
||||
Signers
|
||||
=======
|
||||
|
||||
|
||||
Tra la la...
|
||||
|
||||
|
||||
Signer
|
||||
------
|
||||
|
||||
|
||||
|
||||
#### *signer* . **connect** ( provider ) **=>** *Signer*
|
||||
|
||||
TODO
|
||||
|
||||
|
||||
|
||||
|
||||
### Blockchain Methods
|
||||
|
||||
|
||||
|
||||
#### *signer* . **getBalance** ( [ blockTag="latest" ] ) **=>** *Promise(BigNumber)*
|
||||
|
||||
TODO
|
||||
|
||||
|
||||
|
||||
|
||||
#### *signer* . **getTransactionCount** ( [ blockTag="latest" ] ) **=>** *Promise(number)*
|
||||
|
||||
TODO
|
||||
|
||||
|
||||
|
||||
|
||||
Wallet inherits Signer
|
||||
----------------------
|
||||
|
||||
|
||||
Wallet is...
|
||||
|
||||
|
||||
### Creating an Instance
|
||||
|
||||
|
||||
|
||||
#### **new** *ethers* . **Wallet** ( privateKey [ , provider ] )
|
||||
|
||||
TODO
|
||||
|
||||
|
||||
|
||||
|
||||
#### *Wallet* . **fromEncryptedJson** ( json , password )
|
||||
|
||||
TODO
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-----
|
||||
**Content Hash:** abb9583fce7bfb330648881c6855cebac07174afa724901ba883e2b33dcb0a07
|
16
docs/api/signer/index.html
Normal file
16
docs/api/signer/index.html
Normal file
File diff suppressed because one or more lines are too long
46
docs/api/utils/README.md
Normal file
46
docs/api/utils/README.md
Normal file
@ -0,0 +1,46 @@
|
||||
|
||||
Utilities
|
||||
=========
|
||||
|
||||
|
||||
These utilities are used extensively within the library, but
|
||||
are also quite useful for application developers.
|
||||
|
||||
|
||||
* [Addresses](address)
|
||||
* [BigNumber](bignumber)
|
||||
* [Types](bignumber)
|
||||
* [Creating Instances](bignumber)
|
||||
* [Methods](bignumber)
|
||||
* [Notes](bignumber)
|
||||
* [Byte Manipulation](bytes)
|
||||
* [Types](bytes)
|
||||
* [Inspection](bytes)
|
||||
* [Converting between Arrays and Hexstrings](bytes)
|
||||
* [Array Manipulation](bytes)
|
||||
* [Hexstring Manipulation](bytes)
|
||||
* [Signature Conversion](bytes)
|
||||
* [Constants](constants)
|
||||
* [Bytes](constants)
|
||||
* [Strings](constants)
|
||||
* [BigNumber](constants)
|
||||
* [Display Logic and Input](display-logic)
|
||||
* [Units](display-logic)
|
||||
* [Functions](display-logic)
|
||||
* [FixedNumber](fixednumber)
|
||||
* [Types](fixednumber)
|
||||
* [Creating Instances](fixednumber)
|
||||
* [Properties](fixednumber)
|
||||
* [Methods](fixednumber)
|
||||
* [Hashing Algorithms](hashing)
|
||||
* [Cryptographic Hashing](hashing)
|
||||
* [Common Hashing Helpers](hashing)
|
||||
* [Solidity Hashing Algorithms](hashing)
|
||||
* [Strings](strings)
|
||||
* [Bytes32String](strings)
|
||||
* [UTF-8 Strings](strings)
|
||||
|
||||
|
||||
|
||||
-----
|
||||
**Content Hash:** 2ad729e67eb1303dcd0749dafe8b681b0e71d5511e3921ffdb45b81b2561755a
|
45
docs/api/utils/address/README.md
Normal file
45
docs/api/utils/address/README.md
Normal file
@ -0,0 +1,45 @@
|
||||
|
||||
Addresses
|
||||
=========
|
||||
|
||||
|
||||
Explain addresses,formats and checksumming here.
|
||||
|
||||
Also see: [Constants.AddressZero](../constants)
|
||||
|
||||
|
||||
### Functions
|
||||
|
||||
|
||||
|
||||
#### *utils* . **getAddress** ( address ) **=>** *string*
|
||||
|
||||
TODO
|
||||
|
||||
|
||||
|
||||
|
||||
#### *utils* . **isAddress** ( address ) **=>** *boolean*
|
||||
|
||||
TODO
|
||||
|
||||
|
||||
|
||||
|
||||
#### *utils* . **getIcapAddress** ( address ) **=>** *string*
|
||||
|
||||
TODO
|
||||
|
||||
|
||||
|
||||
|
||||
#### *utils* . **getContractAddress** ( transaction ) **=>** *string*
|
||||
|
||||
TODO
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-----
|
||||
**Content Hash:** 85968aa9edabc277425171a51527f26b845070f5e2cc44ea573bae6b06a8b952
|
9
docs/api/utils/address/index.html
Normal file
9
docs/api/utils/address/index.html
Normal file
File diff suppressed because one or more lines are too long
383
docs/api/utils/bignumber/README.md
Normal file
383
docs/api/utils/bignumber/README.md
Normal file
@ -0,0 +1,383 @@
|
||||
|
||||
BigNumber
|
||||
=========
|
||||
|
||||
|
||||
Explain about BigNumber here...
|
||||
|
||||
|
||||
### Importing
|
||||
|
||||
|
||||
|
||||
```
|
||||
/////
|
||||
// CommonJS:
|
||||
|
||||
// From the Umbrella ethers package...
|
||||
const { BigNumber } = require("ethers");
|
||||
|
||||
// From the bignumber pacakge...
|
||||
const { BigNumber } = require("@ethersproject/bignumber");
|
||||
|
||||
|
||||
/////
|
||||
// ES6 and TypeScript:
|
||||
|
||||
// From the Umbrella ethers package...
|
||||
import { BigNumber } from "ethers";
|
||||
|
||||
// From the bignumber pacakge...
|
||||
import { BigNumber } from "@ethersproject/bignumber";
|
||||
```
|
||||
|
||||
|
||||
|
||||
Types
|
||||
-----
|
||||
|
||||
|
||||
|
||||
### BigNumberish
|
||||
|
||||
|
||||
Many functions and methods in this library take in values which
|
||||
can be non-ambiguously and safely converted to a BigNumber. These
|
||||
values can be sepcified as:
|
||||
|
||||
|
||||
#### ***string***
|
||||
|
||||
A [hexstring](../bytes) or a decimal string, either of which may
|
||||
be negative.
|
||||
|
||||
|
||||
|
||||
|
||||
#### ***BytesLike***
|
||||
|
||||
A [BytesLike](../bytes) Object, such as an Array or Uint8Array.
|
||||
|
||||
|
||||
|
||||
|
||||
#### ***BigNumber***
|
||||
|
||||
An existing BigNumber instance.
|
||||
|
||||
|
||||
|
||||
|
||||
#### ***number***
|
||||
|
||||
A number that is within the safe range for JavaScript numbers.
|
||||
|
||||
|
||||
|
||||
|
||||
#### ***BigInt***
|
||||
|
||||
A JavaScript [BigInt](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt)
|
||||
object, on environments that support BigInt.
|
||||
|
||||
|
||||
|
||||
|
||||
Creating Instances
|
||||
------------------
|
||||
|
||||
|
||||
The constructor of BigNumber cannot be called directly. Instead, Use the static `BigNumber.from`.
|
||||
|
||||
|
||||
#### *BigNumber* . **from** ( aBigNumberish ) **=>** *[BigNumber](./)*
|
||||
|
||||
Returns an instance of a **BigNumber** for *aBigNumberish*.
|
||||
|
||||
|
||||
|
||||
|
||||
### Examples:
|
||||
|
||||
|
||||
|
||||
```javascript
|
||||
// From a decimal string...
|
||||
BigNumber.from("42")
|
||||
// { BigNumber: "42" }</span>
|
||||
|
||||
// From a hexstring...
|
||||
BigNumber.from("0x2a")
|
||||
// { BigNumber: "42" }</span>
|
||||
|
||||
// From a negative hexstring...
|
||||
BigNumber.from("-0x2a")
|
||||
// { BigNumber: "-42" }</span>
|
||||
|
||||
// From an Array (or Uint8Array)...
|
||||
BigNumber.from([ 42 ])
|
||||
// { BigNumber: "42" }</span>
|
||||
|
||||
// From an existing BigNumber...
|
||||
let one1 = constants.One;
|
||||
let one2 = BigNumber.from(one1)
|
||||
|
||||
one2
|
||||
// { BigNumber: "1" }</span>
|
||||
|
||||
// ...which returns the same instance
|
||||
one1 === one2
|
||||
// true</span>
|
||||
|
||||
// From a (safe) number...
|
||||
BigNumber.from(42)
|
||||
// { BigNumber: "42" }</span>
|
||||
|
||||
// From a ES2015 BigInt... (only on platforms with BigInt support)
|
||||
BigNumber.from(42n)
|
||||
// { BigNumber: "42" }</span>
|
||||
|
||||
// Numbers outside the safe range fail:
|
||||
BigNumber.from(Number.MAX_SAFE_INTEGER);
|
||||
// Error: overflow (fault="overflow", operation="BigNumber.from", value=9007199254740991, version=bignumber/5.0.0-beta.129)</span>
|
||||
```
|
||||
|
||||
|
||||
|
||||
Methods
|
||||
-------
|
||||
|
||||
|
||||
The BigNumber class is immutable, so no operations can change the value
|
||||
it represents.
|
||||
|
||||
|
||||
### Math Operations
|
||||
|
||||
|
||||
|
||||
#### *bignumber* . **add** ( otherValue ) **=>** *[BigNumber](./)*
|
||||
|
||||
Returns a BigNumber with the value of *bignumber* **+** *otherValue*.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *bignumber* . **sub** ( otherValue ) **=>** *[BigNumber](./)*
|
||||
|
||||
Returns a BigNumber with the value of *bignumber* **–** *otherValue*.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *bignumber* . **mul** ( otherValue ) **=>** *[BigNumber](./)*
|
||||
|
||||
Returns a BigNumber with the value of *bignumber* **×** *otherValue*.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *bignumber* . **div** ( divisor ) **=>** *[BigNumber](./)*
|
||||
|
||||
Returns a BigNumber with the value of *bignumber* **÷** *divisor*.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *bignumber* . **mod** ( divisor ) **=>** *[BigNumber](./)*
|
||||
|
||||
Returns a BigNumber with the value of the **remainder** of *bignumber* ÷ *divisor*.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *bignumber* . **pow** ( exponent ) **=>** *[BigNumber](./)*
|
||||
|
||||
Returns a BigNumber with the value of *bignumber* to the power of *exponent*.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *bignumber* . **abs** ( ) **=>** *[BigNumber](./)*
|
||||
|
||||
Returns a BigNumber with the absolute value of *bignumber*.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *bignumber* . **maskn** ( bitcount ) **=>** *[BigNumber](./)*
|
||||
|
||||
Returns a BigNumber with the value of *bignumber* with bits beyond
|
||||
the *bitcount* least significant bits set to zero.
|
||||
|
||||
|
||||
|
||||
|
||||
### Two's Compliment
|
||||
|
||||
|
||||
[Two's Complicment](https://en.wikipedia.org/wiki/Two%27s_complement)
|
||||
is a method used to encode and decode fixed-width values which can be
|
||||
positive or negative, without requiring a separate sign bit. Most users
|
||||
will not need to interact with these.
|
||||
|
||||
|
||||
#### *bignumber* . **fromTwos** ( bitwidth ) **=>** *[BigNumber](./)*
|
||||
|
||||
Returns a BigNumber with the value of *bignumber* converted from twos-compliment with *bitwidth*.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *bignumber* . **toTwos** ( bitwidth ) **=>** *[BigNumber](./)*
|
||||
|
||||
Returns a BigNumber with the value of *bignumber* converted to twos-compliment with *bitwidth*.
|
||||
|
||||
|
||||
|
||||
|
||||
### Comparison and Equivalence
|
||||
|
||||
|
||||
|
||||
#### *bignumber* . **eq** ( otherValue ) **=>** *boolean*
|
||||
|
||||
Returns true if and only if the value of *bignumber* is equal to *otherValue*.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *bignumber* . **lt** ( otherValue ) **=>** *boolean*
|
||||
|
||||
Returns true if and only if the value of *bignumber* **<** *otherValue*.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *bignumber* . **lte** ( otherValue ) **=>** *boolean*
|
||||
|
||||
Returns true if and only if the value of *bignumber* **≤** *otherValue*.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *bignumber* . **gt** ( otherValue ) **=>** *boolean*
|
||||
|
||||
Returns true if and only if the value of *bignumber* **>** *otherValue*.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *bignumber* . **gte** ( otherValue ) **=>** *boolean*
|
||||
|
||||
Returns true if and only if the value of *bignumber* **≥** *otherValue*.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *bignumber* . **isZero** ( ) **=>** *boolean*
|
||||
|
||||
Returns true if and only if the value of *bignumber* is zero.
|
||||
|
||||
|
||||
|
||||
|
||||
### Conversion
|
||||
|
||||
|
||||
|
||||
#### *bignumber* . **toNumber** ( ) **=>** *number*
|
||||
|
||||
Returns the value of *bignumber* as a JavaScript value.
|
||||
|
||||
This will **throw an error**
|
||||
if the value is greater than or equal to *Number.MAX_SAFE_INTEGER* or less than or
|
||||
equal to *Number.MIN_SAFE_INTEGER*.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *bignumber* . **toString** ( ) **=>** *string*
|
||||
|
||||
Returns the value of *bignumber* as a base-10 string.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *bignumber* . **toHexString** ( ) **=>** *string*
|
||||
|
||||
Returns the value of *bignumber* as a base-16, `0x`-prefixed [hexstring](../bytes).
|
||||
|
||||
|
||||
|
||||
|
||||
### Inspection
|
||||
|
||||
|
||||
|
||||
#### *BigNumnber* . **isBigNumber** ( object ) **=>** *boolean*
|
||||
|
||||
Returns true if and only if the *object* is a BigNumber object.
|
||||
|
||||
|
||||
|
||||
|
||||
### Examples
|
||||
|
||||
|
||||
|
||||
```javascript
|
||||
let a = BigNumber.from(42);
|
||||
let b = BigNumber.from("91");
|
||||
|
||||
a.mul(b);
|
||||
// { BigNumber: "3822" }</span>
|
||||
```
|
||||
|
||||
|
||||
|
||||
Notes
|
||||
-----
|
||||
|
||||
|
||||
A few short notes on numbers...
|
||||
|
||||
|
||||
### Why can't I just use numbers?
|
||||
|
||||
|
||||
The first problem many encounter when dealing with Ethereum is
|
||||
the concept of numbers. Most common currencies are broken down
|
||||
with very little granularity. For example, there are only 100
|
||||
cents in a single dollar. However, there are 10*18* **wei** in a
|
||||
single **ether**.
|
||||
|
||||
JavaScript uses [IEEE 754 double-precision binary floating point](https://en.wikipedia.org/wiki/Double-precision_floating-point_format)
|
||||
numbers to represent numeric values. As a result, there are *holes*
|
||||
in the integer set after 9,007,199,254,740,991; which is
|
||||
problematic for *Ethereum* because that is only around 0.009
|
||||
ether (in wei), which means any value over that will begin to
|
||||
experience rounding errors.
|
||||
|
||||
To demonstrate how this may be an issue in your code, consider:
|
||||
|
||||
|
||||
```javascript
|
||||
(Number.MAX_SAFE_INTEGER + 2 - 2) == (Number.MAX_SAFE_INTEGER)
|
||||
// false</span>
|
||||
```
|
||||
|
||||
|
||||
To remedy this, all numbers (which can be large) are stored
|
||||
and manipulated as [Big Numbers](./).
|
||||
|
||||
The functions [parseEther( etherString )](http://linkto) and
|
||||
[formatEther( wei )](http://linkto) can be used to convert
|
||||
between string representations, which are displayed to or entered
|
||||
by the user and Big Number representations which can have
|
||||
mathematical operations handled safely.
|
||||
|
||||
|
||||
|
||||
-----
|
||||
**Content Hash:** 2bd4504f910c0e79b352ebb19083a36d6ee0ed263c279aa64a4921a28874c2e9
|
65
docs/api/utils/bignumber/index.html
Normal file
65
docs/api/utils/bignumber/index.html
Normal file
File diff suppressed because one or more lines are too long
243
docs/api/utils/bytes/README.md
Normal file
243
docs/api/utils/bytes/README.md
Normal file
@ -0,0 +1,243 @@
|
||||
|
||||
Byte Manipulation
|
||||
=================
|
||||
|
||||
|
||||
Tra la la...
|
||||
|
||||
|
||||
Types
|
||||
-----
|
||||
|
||||
|
||||
|
||||
### 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
|
||||
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.
|
||||
|
||||
|
||||
### BytesLike
|
||||
|
||||
|
||||
A **BytesLike** can be either a [Bytes](./) or a [Hexstring](./).
|
||||
|
||||
|
||||
### Hexstring
|
||||
|
||||
|
||||
A **hexstring** is a string which has a `0x` prefix followed by
|
||||
|
||||
|
||||
### Signature
|
||||
|
||||
|
||||
|
||||
|
||||
* **r** and **s** --- The x co-ordinate of **r** and the **s** value of the signature
|
||||
* **v** --- The parity of the y co-ordinate of **r**
|
||||
* **_vs** --- The [compact representation](https://link_here) of the **(r, s)** and **v**
|
||||
* **recoveryParam** --- The normalized (i.e. 0 or 1) value of **v**
|
||||
|
||||
|
||||
### 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).
|
||||
|
||||
|
||||
Inspection
|
||||
----------
|
||||
|
||||
|
||||
|
||||
#### *utils* . **isBytes** ( object ) **=>** *boolean*
|
||||
|
||||
Returns true if and only if *object* is a valid [Bytes](./).
|
||||
|
||||
|
||||
|
||||
|
||||
#### *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).
|
||||
|
||||
|
||||
|
||||
|
||||
#### *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.
|
||||
|
||||
|
||||
|
||||
|
||||
Converting between Arrays and Hexstrings
|
||||
----------------------------------------
|
||||
|
||||
|
||||
|
||||
#### *utils* . **arrayify** ( hexstringOrArrayish [ , options ] ) **=>** *Uint8Array*
|
||||
|
||||
Converts *hexstringOrArrayish* to a Uint8Array. If a [Hexstring](./)
|
||||
is passed in, the length must be even.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *utils* . **hexlify** ( hexstringOrArrayish ) **=>** *string*
|
||||
|
||||
Converts *hexstringOrArrayish* to a [Hexstring](./). The result
|
||||
will always be zero-padded to even length.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *utils* . **hexValue** ( aBigNumberish ) **=>** *string*
|
||||
|
||||
Converts *aBigNumberish* to a [Hexstring](./), with no unecessary leading
|
||||
zeros. The result of this function can be of odd-length.
|
||||
|
||||
|
||||
|
||||
|
||||
### Examples
|
||||
|
||||
|
||||
|
||||
```javascript
|
||||
// Convert a hexstring to a Uint8Array
|
||||
arrayify("0x1234")
|
||||
// [ 18, 52 ]</span>
|
||||
|
||||
// Convert an Array to a hexstring
|
||||
hexlify([1, 2, 3, 4])
|
||||
// 0x01020304</span>
|
||||
|
||||
// Convert an Object to a hexstring
|
||||
hexlify({ length: 2, "0": 1, "1": 2 })
|
||||
// 0x0102</span>
|
||||
|
||||
// Convert an Array to a hexstring
|
||||
hexlify([ 1 ])
|
||||
// 0x01</span>
|
||||
|
||||
// Convert a number to a stripped hex value
|
||||
hexValue(1)
|
||||
// 0x1</span>
|
||||
|
||||
// Convert an Array to a stripped hex value
|
||||
hexValue([ 1, 2 ])
|
||||
// 0x102</span>
|
||||
```
|
||||
|
||||
|
||||
|
||||
Array Manipulation
|
||||
------------------
|
||||
|
||||
|
||||
|
||||
#### *utils* . **concat** ( arrayOfBytesLike ) **=>** *Uint8Array*
|
||||
|
||||
Concatenates all the [BytesLike](./) in *arrayOfBytesLike*
|
||||
into a single Uint8Array.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *utils* . **stripZeros** ( aBytesLike ) **=>** *Uint8Array*
|
||||
|
||||
Concatenates all the [BytesLike](./) in *arrayOfBytesLike*
|
||||
|
||||
|
||||
|
||||
|
||||
#### *utils* . **zeroPad** ( aBytesLike , length ) **=>** *Uint8Array*
|
||||
|
||||
Concatenates all the [BytesLike](./) in *arrayOfBytesLike*
|
||||
|
||||
|
||||
|
||||
|
||||
Hexstring Manipulation
|
||||
----------------------
|
||||
|
||||
|
||||
|
||||
#### *utils* . **hexConcat** ( arrayOfBytesLike ) **=>** *string*
|
||||
|
||||
Concatenates all the [BytesLike](./) in *arrayOfBytesLike*
|
||||
into a single [Hexstring](./)
|
||||
|
||||
|
||||
|
||||
|
||||
#### *utils* . **hexDataLength** ( aBytesLike ) **=>** *number*
|
||||
|
||||
Returns the length (in bytes) of *aBytesLike*.
|
||||
|
||||
This will **throw and error** if *aBytesLike* is a [Hexstring](./)
|
||||
but is of odd-length.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *utils* . **hexDataSlice** ( aBytesLike , offset [ , endOffset ] ) **=>** *string*
|
||||
|
||||
Returns the length (in bytes) of *aBytesLike*.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *utils* . **hexStripZeros** ( aBytesLike ) **=>** *string*
|
||||
|
||||
@TODO
|
||||
|
||||
|
||||
|
||||
|
||||
#### *utils* . **hexZeroPad** ( aBytesLike , length ) **=>** *string*
|
||||
|
||||
@TODO
|
||||
|
||||
|
||||
|
||||
|
||||
Signature Conversion
|
||||
--------------------
|
||||
|
||||
|
||||
|
||||
#### *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.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *utils* . **splitSignature** ( aSignatureLikeOrBytesLike ) **=>** *Signature*
|
||||
|
||||
Return the full expanded-format of a [SignatureLike](./) or
|
||||
a flat-format [Hexstring](./). Any missing properties will be
|
||||
computed.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-----
|
||||
**Content Hash:** 6c6608cb249ff3e352417e8c99e1965500c19a3ae9b33d0397d7f8b84e78e20b
|
45
docs/api/utils/bytes/index.html
Normal file
45
docs/api/utils/bytes/index.html
Normal file
File diff suppressed because one or more lines are too long
101
docs/api/utils/constants/README.md
Normal file
101
docs/api/utils/constants/README.md
Normal file
@ -0,0 +1,101 @@
|
||||
|
||||
Constants
|
||||
=========
|
||||
|
||||
|
||||
The **ethers.contants** Object contains commonly used values.
|
||||
|
||||
|
||||
### Importing
|
||||
|
||||
|
||||
|
||||
```javascript
|
||||
//const { constants } = require("ethers");
|
||||
// const { constants } = require("@ethersproject/constants");
|
||||
```
|
||||
|
||||
|
||||
|
||||
Bytes
|
||||
-----
|
||||
|
||||
|
||||
|
||||
#### *constants* . **AddressZero**
|
||||
|
||||
The Address Zero, which is 20 bytes (40 nibbles) of zero.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *constants* . **HashZero**
|
||||
|
||||
The Hash Zero, which is 32 bytes (64 nibbles) of zero.
|
||||
|
||||
|
||||
|
||||
|
||||
Strings
|
||||
-------
|
||||
|
||||
|
||||
|
||||
#### *constants* . **EtherSymbol**
|
||||
|
||||
The Ether symbol, **Ξ**.
|
||||
|
||||
|
||||
|
||||
|
||||
BigNumber
|
||||
---------
|
||||
|
||||
|
||||
|
||||
#### *constants* . **NegativeOne**
|
||||
|
||||
The BigNumber value representing `"-1"`.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *constants* . **Zero**
|
||||
|
||||
The BigNumber value representing `"0"`.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *constants* . **One**
|
||||
|
||||
The BigNumber value representing `"1"`.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *constants* . **Two**
|
||||
|
||||
The BigNumber value representing `"2"`.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *constants* . **WeiPerEther**
|
||||
|
||||
The BigNumber value representing `"1000000000000000000"`, which is the
|
||||
number of Wei per Ether.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *constants* . **MaxUint256**
|
||||
|
||||
The BigNumber value representing the maximum `uint256` value.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-----
|
||||
**Content Hash:** 36d1996cf9909e8654bc8eef0c760bf3022681482bc88ebc553c79f0b224c9af
|
22
docs/api/utils/constants/index.html
Normal file
22
docs/api/utils/constants/index.html
Normal file
File diff suppressed because one or more lines are too long
107
docs/api/utils/display-logic/README.md
Normal file
107
docs/api/utils/display-logic/README.md
Normal file
@ -0,0 +1,107 @@
|
||||
|
||||
Display Logic and Input
|
||||
=======================
|
||||
|
||||
|
||||
When creating an Application, it is useful to convert between
|
||||
user-friendly strings (usually displaying **ether**) and the
|
||||
machine-readable values that contracts and maths depend on
|
||||
(usually in **wei**).
|
||||
|
||||
For example, a Wallet may specify the balance in ether, and
|
||||
gas prices in gwei for the User Interface, but when sending
|
||||
a transaction, both must be specified in wei.
|
||||
|
||||
The [parseUnits](./) will parse a string representing
|
||||
ether, such as `1.1` into a [BigNumber](../bignumber) in wei, and is
|
||||
useful when a user types in a value, such as sending 1.1 ether.
|
||||
|
||||
The [formatUnits](./) will format a [BigNumberish](../bignumber)
|
||||
into a string, which is useful when displaying a balance.
|
||||
|
||||
|
||||
Units
|
||||
-----
|
||||
|
||||
|
||||
|
||||
### Decimal Count
|
||||
|
||||
|
||||
The *unit* specified may be an integer, which indicates how
|
||||
many decimal place the unit has. For example, 1 ether has 18 decimal
|
||||
places for wei, and if this library were used with Bitcoin, 1 BTC
|
||||
has 8 decimal places for satoshis.
|
||||
|
||||
|
||||
### Named Units
|
||||
|
||||
|
||||
In addition to specifying *unit* as a number of decimals, there
|
||||
are several common units, which can be passed in as a string:
|
||||
|
||||
|
||||
|
||||
* **wei** --- 0
|
||||
* **kwei** --- 3
|
||||
* **mwei** --- 6
|
||||
* **gwei** --- 9
|
||||
* **szabo** --- 12
|
||||
* **finney** --- 15
|
||||
* **ether** --- 18
|
||||
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
|
||||
|
||||
### Formatting
|
||||
|
||||
|
||||
|
||||
#### *utils* . **commify** ( value ) **=>** *string*
|
||||
|
||||
Returns a string with value grouped by 3 digits, separated by `,`.
|
||||
|
||||
|
||||
|
||||
|
||||
### Conversion
|
||||
|
||||
|
||||
|
||||
#### *utils* . **formatUnits** ( value [ , unit="ether" ] ) **=>** *string*
|
||||
|
||||
Returns a string representation of *value* formatted with *unit*
|
||||
digits (if it is a number) or to the unit specified (if a string).
|
||||
|
||||
|
||||
|
||||
|
||||
#### *utils* . **formatEther** ( value ) **=>** *string*
|
||||
|
||||
The equivalent to calling `formatUnits(value, "ether")`.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *utils* . **parseUnits** ( value [ , unit="ether" ] ) **=>** *[BigNumber](../bignumber)*
|
||||
|
||||
Returns a [BigNumber](../bignumber) representation of *value*, parsed with
|
||||
*unit* digits (if it is a number) or from the unit specified (if
|
||||
a string).
|
||||
|
||||
|
||||
|
||||
|
||||
#### *utils* . **parseEther** ( value ) **=>** *[BigNumber](../bignumber)*
|
||||
|
||||
The equivalent to calling `parseUnits(value, "ether")`.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-----
|
||||
**Content Hash:** a0fd257cd92fcf3ae0659a22281fe10e7b68d632443cdf65556445a34365fcf1
|
20
docs/api/utils/display-logic/index.html
Normal file
20
docs/api/utils/display-logic/index.html
Normal file
File diff suppressed because one or more lines are too long
164
docs/api/utils/fixednumber/README.md
Normal file
164
docs/api/utils/fixednumber/README.md
Normal file
@ -0,0 +1,164 @@
|
||||
|
||||
FixedNumber
|
||||
===========
|
||||
|
||||
|
||||
|
||||
Types
|
||||
-----
|
||||
|
||||
|
||||
|
||||
### FixedFormat
|
||||
|
||||
|
||||
TODO
|
||||
|
||||
|
||||
#### ***"fixed"***
|
||||
|
||||
A shorthand for `fixed128x80`.
|
||||
|
||||
|
||||
|
||||
|
||||
Creating Instances
|
||||
------------------
|
||||
|
||||
|
||||
The FixedNumber constructor cannot be called directly. There are several
|
||||
static methods for creating a FixedNumber.
|
||||
|
||||
|
||||
#### *BigNumber* . **from** ( value [ , format="fixed" ] ) **=>** *[FixedNumber](./)*
|
||||
|
||||
Returns an instance of a **FixedNumber** for *value* as a *format*.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *BigNumber* . **fromBytes** ( aBytesLike [ , format="fixed" ] ) **=>** *[FixedNumber](./)*
|
||||
|
||||
Returns an instance of a **FixedNumber** for *value* as a *format*.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *BigNumber* . **fromString** ( value [ , format="fixed" ] ) **=>** *[FixedNumber](./)*
|
||||
|
||||
Returns an instance of a **FixedNumber** for *value* as a *format*. The *value* must
|
||||
not contain more decimals than the *format* permits.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *BigNumber* . **fromValue** ( value [ , decimals=0 [ , format="fixed" ] ] ) **=>** *[FixedNumber](./)*
|
||||
|
||||
Returns an instance of a **FixedNumber** for *value* with *decimals* as a *format*.
|
||||
|
||||
|
||||
|
||||
|
||||
Properties
|
||||
----------
|
||||
|
||||
|
||||
|
||||
#### *fixednumber* . **format**
|
||||
|
||||
The [FixedFormat](./) of *fixednumber*.
|
||||
|
||||
|
||||
|
||||
|
||||
Methods
|
||||
-------
|
||||
|
||||
|
||||
|
||||
### Math Operations
|
||||
|
||||
|
||||
|
||||
#### *fixednumber* . **addUnsafe** ( otherValue ) **=>** *[FixedNumber](./)*
|
||||
|
||||
Returns a new FixedNumber with the value of *fixedvalue* **+** *otherValue*.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *fixednumber* . **subUnsafe** ( otherValue ) **=>** *[FixedNumber](./)*
|
||||
|
||||
Returns a new FixedNumber with the value of *fixedvalue* **–** *otherValue*.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *fixednumber* . **mulUnsafe** ( otherValue ) **=>** *[FixedNumber](./)*
|
||||
|
||||
Returns a new FixedNumber with the value of *fixedvalue* **×** *otherValue*.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *fixednumber* . **divUnsafe** ( otherValue ) **=>** *[FixedNumber](./)*
|
||||
|
||||
Returns a new FixedNumber with the value of *fixedvalue* **÷** *otherValue*.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *fixednumber* . **round** ( [ decimals=0 ] ) **=>** *[FixedNumber](./)*
|
||||
|
||||
Returns a new FixedNumber with the value of *fixedvalue* rounded to *decimals*.
|
||||
|
||||
|
||||
|
||||
|
||||
### Conversion
|
||||
|
||||
|
||||
|
||||
#### *fixednumber* . **toFormat** ( format ) **=>** *[FixedNumber](./)*
|
||||
|
||||
Returns a new FixedNumber with the value of *fixedvalue* with *format*.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *fixednumber* . **toHexString** ( ) **=>** *string*
|
||||
|
||||
Returns a [Hexstring](../bytes) representation of *fixednumber*.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *fixednumber* . **toString** ( ) **=>** *string*
|
||||
|
||||
Returns a string representation of *fixednumber*.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *fixednumber* . **toUnsafeFloat** ( ) **=>** *float*
|
||||
|
||||
Returns a floating-point JavaScript number value of *fixednumber*.
|
||||
Due to rounding in JavaScript numbers, the value is only approximate.
|
||||
|
||||
|
||||
|
||||
|
||||
### Inspection
|
||||
|
||||
|
||||
|
||||
#### *BigNumber* . **isFixedNumber** ( value ) **=>** *boolean*
|
||||
|
||||
Returns true if and only if *value* is a **FixedNumber**.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-----
|
||||
**Content Hash:** ddffbdca7bc7b54726596bd79a88e5df5dc947ff48bd2f93d516bb5b084aa4db
|
35
docs/api/utils/fixednumber/index.html
Normal file
35
docs/api/utils/fixednumber/index.html
Normal file
File diff suppressed because one or more lines are too long
134
docs/api/utils/hashing/README.md
Normal file
134
docs/api/utils/hashing/README.md
Normal file
@ -0,0 +1,134 @@
|
||||
|
||||
Hashing Algorithms
|
||||
==================
|
||||
|
||||
|
||||
Explain what hash functions are?
|
||||
|
||||
|
||||
Cryptographic Hashing
|
||||
---------------------
|
||||
|
||||
|
||||
The [Cryptographic Hash Functions](https://en.wikipedia.org/wiki/Cryptographic_hash_function)
|
||||
are a specific family of hash functions.
|
||||
|
||||
|
||||
#### *utils* . **keccak256** ( aBytesLike ) **=>** *string*
|
||||
|
||||
Returns the [KECCAK256](https://en.wikipedia.org/wiki/SHA-3) digest *aBytesLike*.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *utils* . **ripemd160** ( aBytesLike ) **=>** *string*
|
||||
|
||||
Returns the [RIPEMD-160](https://en.m.wikipedia.org/wiki/RIPEMD) digest of *aBytesLike*.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *utils* . **sha256** ( aBytesLike ) **=>** *string*
|
||||
|
||||
Returns the [SHA2-256](https://en.wikipedia.org/wiki/SHA-2) digest of *aBytesLike*.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *utils* . **sha512** ( aBytesLike ) **=>** *string*
|
||||
|
||||
Returns the [SHA2-512](https://en.wikipedia.org/wiki/SHA-2) digest of *aBytesLike*.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *utils* . **computeHmac** ( algorithm , key , data ) **=>** *string*
|
||||
|
||||
Returns the [HMAC](https://en.wikipedia.org/wiki/HMAC) of *data* with *key*
|
||||
using the [Algorithm](./) *algorithm*.
|
||||
|
||||
|
||||
|
||||
|
||||
### HMAC Supported Algorithms
|
||||
|
||||
|
||||
|
||||
#### *utils* . *SupportedAlgorithms* . **sha256**
|
||||
|
||||
Use the [SHA2-256](https://en.wikipedia.org/wiki/SHA-2) hash algorithm.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *utils* . *SupportedAlgorithms* . **sha512**
|
||||
|
||||
Use the [SHA2-512](https://en.wikipedia.org/wiki/SHA-2) hash algorithm.
|
||||
|
||||
|
||||
|
||||
|
||||
Common Hashing Helpers
|
||||
----------------------
|
||||
|
||||
|
||||
|
||||
#### *utils* . **hashMessage** ( message ) **=>** *string*
|
||||
|
||||
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*.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *utils* . **id** ( text ) **=>** *string*
|
||||
|
||||
The Ethereum Identity function computs the keccak256 hash of the *text* bytes.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *utils* . **namehash** ( name ) **=>** *string*
|
||||
|
||||
Returns the [ENS Namehash](https://docs.ens.domains/contract-api-reference/name-processing#hashing-names) of *name*.
|
||||
|
||||
|
||||
|
||||
|
||||
Solidity Hashing Algorithms
|
||||
---------------------------
|
||||
|
||||
|
||||
When using the Solidity `abi.packEncoded(...)` function, a non-standard
|
||||
*tightly packed* version of encoding is used. These functions implement
|
||||
the tightly packing algorithm.
|
||||
|
||||
|
||||
#### *utils* . **solidityPack** ( arrayOfTypes , arrayOfValues ) **=>** *string*
|
||||
|
||||
Returns the non-standard encoded *arrayOfValues* packed according to
|
||||
their respecive type in *arrayOfTypes*.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *utils* . **solidityKeccak256** ( arrayOfTypes , arrayOfValues ) **=>** *string*
|
||||
|
||||
Returns the KECCAK256 of the non-standard encoded *arrayOfValues* packed
|
||||
according to their respective type in *arrayOfTypes*.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *utils* . **soliditySha256** ( arrayOfTypes , arrayOfValues ) **=>** *string*
|
||||
|
||||
Returns the SHA2-256 of the non-standard encoded *arrayOfValues* packed
|
||||
according to their respective type in *arrayOfTypes*.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-----
|
||||
**Content Hash:** d67fa58e91e9358b895d2c6dbb0ab2f6b1ce71b85c7c0d9bc1a93b4ae2eb4b23
|
24
docs/api/utils/hashing/index.html
Normal file
24
docs/api/utils/hashing/index.html
Normal file
File diff suppressed because one or more lines are too long
4
docs/api/utils/index.html
Normal file
4
docs/api/utils/index.html
Normal file
File diff suppressed because one or more lines are too long
151
docs/api/utils/strings/README.md
Normal file
151
docs/api/utils/strings/README.md
Normal file
@ -0,0 +1,151 @@
|
||||
|
||||
Strings
|
||||
=======
|
||||
|
||||
|
||||
Tra la la
|
||||
|
||||
|
||||
Bytes32String
|
||||
-------------
|
||||
|
||||
|
||||
A string in Solidity is length prefixed with its 256-bit (32 byte)
|
||||
length, which means that even short strings require 2 words (64 bytes)
|
||||
of storage.
|
||||
|
||||
In many cases, we deal with short strings, so instead of prefixing
|
||||
the string with its length, we can null-terminate it and fit it in a
|
||||
single word (32 bytes). Since we need only a single byte for the
|
||||
null termination, we can store strings up to 31 bytes long in a
|
||||
word.
|
||||
|
||||
|
||||
#### **Note:**
|
||||
|
||||
Strings that are 31 **bytes** long may contain fewer than 31 **characters**,
|
||||
since UTF-8 requires multiple bytes to encode international characters.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *utils* . **parseBytes32String** ( aBytesLike ) **=>** *string*
|
||||
|
||||
Returns the decoded string represented by the `Bytes32` encoded data.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *utils* . **formatBytes32String** ( text ) **=>** *string*
|
||||
|
||||
Returns a `bytes32` string representation of *text*. If the
|
||||
length of *text* exceeds 31 bytes, it will throw an error.
|
||||
|
||||
|
||||
|
||||
|
||||
UTF-8 Strings
|
||||
-------------
|
||||
|
||||
|
||||
|
||||
#### *utils* . **toUtf8Bytes** ( text [ , form=current ] ) **=>** *Uint8Array*
|
||||
|
||||
Returns the UTF-8 bytes of *text*, optionally normalizing it using the
|
||||
[UnicodeNormalizationForm](./) *form*.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *utils* . **toUtf8CodePoints** ( aBytesLike [ , form=current ] ) **=>** *Array< number >*
|
||||
|
||||
Returns the Array of codepoints of *aBytesLike*, optionally normalizing it using the
|
||||
[UnicodeNormalizationForm](./) *form*.
|
||||
|
||||
**Note:** This function correctly splits each user-perceived character into
|
||||
its codepoint, accounting for surrogate pairs. This should not be confused with
|
||||
`string.split("")`, which destroys surrogate pairs, spliting between each UTF-16
|
||||
codeunit instead.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *utils* . **toUtf8String** ( aBytesLike [ , ignoreErrors=false ] ) **=>** *string*
|
||||
|
||||
Returns the string represented by the UTF-8 bytes of *aBytesLike*. This will
|
||||
throw an error for invalid surrogates, overlong sequences or other UTF-8 issues,
|
||||
unless *ignoreErrors* is specified.
|
||||
|
||||
|
||||
|
||||
|
||||
### UnicodeNormalizationForm
|
||||
|
||||
|
||||
There are several [commonly used forms](https://en.wikipedia.org/wiki/Unicode_equivalence)
|
||||
when normalizing UTF-8 data, which allow strings to be compared or hashed in a stable
|
||||
way.
|
||||
|
||||
|
||||
#### *utils* . *UnicodeNormalizationForm* . **current**
|
||||
|
||||
Maintain the current normalization form.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *utils* . *UnicodeNormalizationForm* . **NFC**
|
||||
|
||||
The Composed Normalization Form. This form uses single codepoints
|
||||
which represent the fully composed character.
|
||||
|
||||
For example, the **é** is a single codepoint, `0x00e9`.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *utils* . *UnicodeNormalizationForm* . **NFD**
|
||||
|
||||
The Decomposed Normalization Form. This form uses multiple codepoints
|
||||
(when necessary) to compose a character.
|
||||
|
||||
For example, the **é**
|
||||
is made up of two codepoints, `"0x0065"` (which is the letter `"e"`)
|
||||
and `"0x0301"` which is a special diacritic UTF-8 codepoint which
|
||||
indicates the previous character should have an acute accent.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *utils* . *UnicodeNormalizationForm* . **NFKC**
|
||||
|
||||
The Composed Normalization Form with Canonical Equivalence. The Canonical
|
||||
representation folds characters which have the same syntactic representation
|
||||
but different semantic meaning.
|
||||
|
||||
For example, the Roman Numeral **I**, which has a UTF-8
|
||||
codepoint `"0x2160"`, is folded into the capital letter I, `"0x0049"`.
|
||||
|
||||
|
||||
|
||||
|
||||
#### *utils* . *UnicodeNormalizationForm* . **NFKD**
|
||||
|
||||
The Decomposed Normalization Form with Canonical Equivalence.
|
||||
See NFKC for more an example.
|
||||
|
||||
|
||||
|
||||
|
||||
#### **Note:**
|
||||
|
||||
Only certain specified characters are folded in Canonical Equivalence, and thus
|
||||
it should not be considered a method to acheive *any* level of security from
|
||||
[homoglyph attacks](https://en.wikipedia.org/wiki/IDN_homograph_attack).
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
-----
|
||||
**Content Hash:** f6a51816edca0ae4b74c16012629f26108f16204ff9d3aa3879fd44adb8d0d7f
|
21
docs/api/utils/strings/index.html
Normal file
21
docs/api/utils/strings/index.html
Normal file
File diff suppressed because one or more lines are too long
18
docs/concepts/README.md
Normal file
18
docs/concepts/README.md
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
Concepts
|
||||
========
|
||||
|
||||
|
||||
This is a very breif overview of some aspects of *Ethereum*
|
||||
which developers can make use of or should be aware of.
|
||||
|
||||
|
||||
* [Events](events)
|
||||
* [Gas](gas)
|
||||
* [Gas Price](gas)
|
||||
* [Gas Limit](gas)
|
||||
|
||||
|
||||
|
||||
-----
|
||||
**Content Hash:** 1a99161696ee94f8320ce5b63367cfc1245dadb9dc5f52819e5a547b3f44c509
|
11
docs/concepts/events/README.md
Normal file
11
docs/concepts/events/README.md
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
Events
|
||||
======
|
||||
|
||||
|
||||
Explain how topics and such work
|
||||
|
||||
|
||||
|
||||
-----
|
||||
**Content Hash:** 1b85be44f478836054f7efb2aa093d82c399ddd636153815991b334dc1c1b4b3
|
3
docs/concepts/events/index.html
Normal file
3
docs/concepts/events/index.html
Normal file
File diff suppressed because one or more lines are too long
23
docs/concepts/gas/README.md
Normal file
23
docs/concepts/gas/README.md
Normal file
@ -0,0 +1,23 @@
|
||||
|
||||
Gas
|
||||
===
|
||||
|
||||
|
||||
|
||||
Gas Price
|
||||
---------
|
||||
|
||||
|
||||
The gas price is used somewhat like a bid, indicating an amount
|
||||
you are willing to pay (per unit of execution) to have your transaction
|
||||
processed.
|
||||
|
||||
|
||||
Gas Limit
|
||||
---------
|
||||
|
||||
|
||||
|
||||
|
||||
-----
|
||||
**Content Hash:** 0e5b9d2e12fbc359899548a8f3d7a0951ee96cc3dec2b4b64be0e4dbfa1371eb
|
7
docs/concepts/gas/index.html
Normal file
7
docs/concepts/gas/index.html
Normal file
File diff suppressed because one or more lines are too long
4
docs/concepts/index.html
Normal file
4
docs/concepts/index.html
Normal file
File diff suppressed because one or more lines are too long
39
docs/contributing/README.md
Normal file
39
docs/contributing/README.md
Normal file
@ -0,0 +1,39 @@
|
||||
|
||||
Contributing and Hacking
|
||||
========================
|
||||
|
||||
|
||||
The ethers.js library is something that I've written out of necessity,
|
||||
and has grown somewhat organically over time.
|
||||
|
||||
Many things are the way they are for good (at the time, at least) reasons,
|
||||
but I always welcome criticism, and am completely willing to have my mind
|
||||
changed on things.
|
||||
|
||||
So, pull requests are always welcome, but please keep a few points in mind:
|
||||
|
||||
|
||||
|
||||
* Backwards-compatibility-breaking changes will not be accepted; they may be considered for the next major version
|
||||
* Security is important; adding dependencies require fairly convincing arguments as to why
|
||||
* The library aims to be lean, so keep an eye on the dist/ethers.min.js file size before and after your changes
|
||||
* Add test cases for both expected and unexpected input
|
||||
* Any new features need to be supported by me (future issues, documentation, testing, migration), so anything that is overly complicated or specific may not be accepted
|
||||
|
||||
In general, **please start an issue *before* beginning a pull request**, so we can
|
||||
have a public discussion and figure out the best way to address to problem/feature.
|
||||
**:)**
|
||||
|
||||
|
||||
Building
|
||||
--------
|
||||
|
||||
|
||||
use npm run auto-build
|
||||
|
||||
use npm run update-version
|
||||
|
||||
|
||||
|
||||
-----
|
||||
**Content Hash:** a9c6c700043f9b18ddd10b4b914603231c63c6adb95e26d3630fb39709b35eb6
|
5
docs/contributing/index.html
Normal file
5
docs/contributing/index.html
Normal file
File diff suppressed because one or more lines are too long
11
docs/cookbook/README.md
Normal file
11
docs/cookbook/README.md
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
Cookbook
|
||||
========
|
||||
|
||||
|
||||
Cooking...
|
||||
|
||||
|
||||
|
||||
-----
|
||||
**Content Hash:** 19de63e3df2d64c5982c1625034ee40032aee1bd349eacf1cd8cf00c336548aa
|
3
docs/cookbook/index.html
Normal file
3
docs/cookbook/index.html
Normal file
File diff suppressed because one or more lines are too long
191
docs/documentation/README.md
Normal file
191
docs/documentation/README.md
Normal file
@ -0,0 +1,191 @@
|
||||
|
||||
Flatworm Docs
|
||||
=============
|
||||
|
||||
|
||||
The *Flatworm Docs* rendering script is designed to be **very**
|
||||
simple, but provide enough formatting necessary for documenting
|
||||
JavaScript libraries.
|
||||
|
||||
A lot of its inspiration came from [Read the Docs](https://github.com/readthedocs/sphinx_rtd_theme) and
|
||||
the [Sphinx](https://www.sphinx-doc.org/) project.
|
||||
|
||||
|
||||
Fragments
|
||||
---------
|
||||
|
||||
|
||||
Flatworm Docs are made up of fragments. A fragment is either a lone
|
||||
body of [markdown](./) text, or a
|
||||
[directive](./) for specialized formatting, which may
|
||||
itself have body.
|
||||
|
||||
|
||||
### Directive Format
|
||||
|
||||
|
||||
|
||||
```
|
||||
_DIRECTIVE: VALUE @<LINK>
|
||||
BODY
|
||||
|
||||
DIRECTIVE: The directive name
|
||||
VALUE: Optional; the value to pass to the directive
|
||||
LINK: Optional; a name for internal linking
|
||||
BODY: Optional; the directive body (certain directives only)
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Flatworm Directives
|
||||
|
||||
|
||||
|
||||
#### **_section:** *TITLE*
|
||||
|
||||
A *section* has its **TITLE** in an H1 font. Sections are linked
|
||||
to in *Table of Contents* and have a dividing line drawn above
|
||||
them. If an option is specified, it is avaialble as a name for
|
||||
intern linking. There should only be one `_section:` per page.
|
||||
|
||||
|
||||
|
||||
|
||||
#### **_subsection:** *TITLE*
|
||||
|
||||
A *subsection* has its **TITLE** in an H2 font. Subsections are linked
|
||||
to in *Table of Contents* and have a dividing line drawn above
|
||||
them. If an option is specified, it is avaialble as a name for
|
||||
internal linking.
|
||||
|
||||
|
||||
|
||||
|
||||
#### **_heading:** *TITLE*
|
||||
|
||||
A *heading* has its **TITLE** in an H3 font. If an option is specified,
|
||||
it is available as a name for internal linking.
|
||||
|
||||
|
||||
|
||||
|
||||
#### **_definition:** *TERM*
|
||||
|
||||
A *definition* has its **TERM** bolded and the markdown body is
|
||||
indented.
|
||||
|
||||
|
||||
|
||||
|
||||
#### **_property:** *SIGNATURE*
|
||||
|
||||
A *property* has its JavaScript **SIGNATURE** formatted and the
|
||||
markdown body is indented.
|
||||
|
||||
|
||||
|
||||
|
||||
#### **_code:** *FILENAME*
|
||||
|
||||
A *code* reads the **FILENAME** and depending on the extension
|
||||
adjusts it.
|
||||
|
||||
For JavaScript files, the file is executed, with `//!` replaced
|
||||
with the result of the last statement and `//!error` is replaced
|
||||
with the throw error. If the error state does not agree, rendering
|
||||
fails.
|
||||
|
||||
|
||||
|
||||
|
||||
#### **_toc:**
|
||||
|
||||
A *toc* injects a Table of Contents, loading each line of the
|
||||
body as a filename and recursively loads the *toc* if present,
|
||||
otherwise all the *sections* and *subsections*.
|
||||
|
||||
|
||||
|
||||
|
||||
#### **_null:**
|
||||
|
||||
A *null* is used to terminated a directive. For example, after
|
||||
a *definition*, the bodies are indented, so a *null* can be
|
||||
used to reset the indentation.
|
||||
|
||||
|
||||
|
||||
|
||||
### Examples
|
||||
|
||||
|
||||
|
||||
```
|
||||
_section: Hello World @<link-to-this-section>
|
||||
|
||||
_subsection: Some Example @<link-to-this-subsection>
|
||||
|
||||
_heading: Large Bold Text @<link-to-this-heading>
|
||||
|
||||
_definition: Flatworm
|
||||
A phylum of relatively **simple** bilaterian, unsegmented,
|
||||
soft-bodied invertebrates.
|
||||
|
||||
_property: String.fromCharCode(code) => string
|
||||
Returns a string created from //code//, a sequence of
|
||||
UTF-16 code units.
|
||||
|
||||
_code: filename.js
|
||||
|
||||
_toc:
|
||||
some-file
|
||||
some-directory
|
||||
|
||||
_null:
|
||||
This breaks out of a directive. For example, to end a
|
||||
_definition and reset the indentation.
|
||||
```
|
||||
|
||||
|
||||
|
||||
Markdown
|
||||
--------
|
||||
|
||||
|
||||
The markdown is simple and does not have the flexibility of
|
||||
other dialects, but allows for **bold**, *italic*,
|
||||
*underlined*, `monospaced`, *super-scripted* text,
|
||||
supporting [links](./) and lists.
|
||||
|
||||
|
||||
```
|
||||
**bold text**
|
||||
|
||||
//italic text//
|
||||
|
||||
__underlined text__
|
||||
|
||||
``monospace code``
|
||||
|
||||
^^superscript text^^
|
||||
|
||||
- This is a list
|
||||
- With bullet points
|
||||
- With a total of three items
|
||||
|
||||
This is separated by -- an en-dash.
|
||||
|
||||
This is separated by --- an em-dash.
|
||||
|
||||
This is a [Link to Ethereum](https://ethereum.org) and this
|
||||
is an [Internal Link](some-link).
|
||||
|
||||
This is a self-titled link [[https://ethereumorg]] and this
|
||||
[[some-link]] will use the title from its directives value.
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
-----
|
||||
**Content Hash:** 74aa879d77ec6a068c9233aefbf85188a6a18cacf24f5ba9c83cd3602c15e9ae
|
27
docs/documentation/index.html
Normal file
27
docs/documentation/index.html
Normal file
File diff suppressed because one or more lines are too long
63
docs/getting-started/README.md
Normal file
63
docs/getting-started/README.md
Normal file
@ -0,0 +1,63 @@
|
||||
|
||||
Getting Started
|
||||
===============
|
||||
|
||||
|
||||
|
||||
Installing
|
||||
----------
|
||||
|
||||
|
||||
The various Classes and Functions are available to be imported
|
||||
manually from sub-packages under the
|
||||
[@ethersproject](https://www.npmjs.com/search?q=%40ethersproject%2F)
|
||||
but for most projects, the umbrella package is the easiest way to
|
||||
get started.
|
||||
|
||||
|
||||
```
|
||||
/home/ricmoo> npm install --save ethers@next
|
||||
```
|
||||
|
||||
|
||||
|
||||
Importing
|
||||
---------
|
||||
|
||||
|
||||
|
||||
### Node.js
|
||||
|
||||
|
||||
|
||||
```
|
||||
// CommonJS
|
||||
const { ethers } = require("ethers");
|
||||
|
||||
// ES6 or TypeScript
|
||||
const { ethers } = require("ethers");
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Web Browser
|
||||
|
||||
|
||||
It is generally better practice (for security reasons) to copy the
|
||||
[ethers library](https://cdn.ethers.io/lib/ethers-5.0.min.js) to
|
||||
your own webserver and serve it yourself.
|
||||
|
||||
For quick demos or prototyping though, it can be loaded in your
|
||||
Web Applications from our CDN.
|
||||
|
||||
|
||||
```
|
||||
<script src="https://cdn.ethers.io/lib/ethers-5.0.min.js"
|
||||
type="application/javascipt"></script>
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
-----
|
||||
**Content Hash:** 5550edc55238e573fa55ca0421c610304a1c12cfa1281db2ddba44f36b1a3409
|
17
docs/getting-started/index.html
Normal file
17
docs/getting-started/index.html
Normal file
File diff suppressed because one or more lines are too long
10
docs/index.html
Normal file
10
docs/index.html
Normal file
File diff suppressed because one or more lines are too long
37
docs/license/README.md
Normal file
37
docs/license/README.md
Normal file
@ -0,0 +1,37 @@
|
||||
|
||||
License and Copyright
|
||||
=====================
|
||||
|
||||
|
||||
The ethers library (including all dependencies) are available
|
||||
under the [MIT License](https://en.m.wikipedia.org/wiki/MIT_License),
|
||||
which permits a wide variety of uses.
|
||||
|
||||
|
||||
### MIT License
|
||||
|
||||
|
||||
*Copyright © 2019 [Richard Moore](mailto:me@ricmoo.com).*
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
|
||||
|
||||
-----
|
||||
**Content Hash:** 33d04a7c1199b1f7bee1b864f1610c01fde9a928993a6ffb5816b7268183e9d0
|
5
docs/license/index.html
Normal file
5
docs/license/index.html
Normal file
File diff suppressed because one or more lines are too long
25
docs/migration/README.md
Normal file
25
docs/migration/README.md
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
Migration Guide
|
||||
===============
|
||||
|
||||
|
||||
Migratimg...
|
||||
|
||||
|
||||
From Web3
|
||||
---------
|
||||
|
||||
|
||||
test
|
||||
|
||||
|
||||
From ethers v4
|
||||
--------------
|
||||
|
||||
|
||||
test
|
||||
|
||||
|
||||
|
||||
-----
|
||||
**Content Hash:** 9b0d95b05f5e8941f7984f2f5141af4c4b17eef142c924bea54c446f11a367f4
|
7
docs/migration/index.html
Normal file
7
docs/migration/index.html
Normal file
File diff suppressed because one or more lines are too long
BIN
docs/static/lato/Lato-Black.ttf
vendored
Normal file
BIN
docs/static/lato/Lato-Black.ttf
vendored
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user