Function
Static Public Summary | ||
public |
addContract(contractName: *, abi: *, networks: *): ReduxThunk Load a contract (binding it to an web3js Contract instance), and add it to the redux store. |
|
public |
addLocalAcount(address: *): ReduxThunk Add an account to track locally. |
|
public |
Awaits a web3 call, and fires the corresponding redux events |
|
public |
* blocksSaga(web3: *, getBlocksState: ReduxStateSelector): ReduxSaga Handles ReDApp block background processing. |
|
public |
cacheCall(options: *): ReduxThunk Start a new call, but try to hit the cache for an existing call result first. |
|
public |
* callsSaga(web3: *, getCallsState: ReduxStateSelector): ReduxSaga Handles ReDApp call background processing. |
|
public |
* contractsSaga(web3: *, defaultNetworkId: *, getContractsState: ReduxStateSelector): ReduxSaga Handles ReDApp contract background processing, e.g. |
|
public |
createTransactionPromiEvent(web3: *, txID: *, txParams: *): PromiEvent<TransactionReceipt> Web3 returns a "promise combined with an event emitter": we map this to redux events. |
|
public |
Update the list of wallet accounts. |
|
public |
forceCall(options: *): ReduxThunk Start a new call, ignoring previous call data, forcing an overwrite when getting the result. |
|
public |
forgetCall(callID: *): ReduxThunk Remove a call from the tracking system. |
|
public |
forgetContract(contractName: *): ReduxThunk Removes the contract from the local redux store. |
|
public |
forgetLocalAccount(address: *): ReduxThunk Forget local account. |
|
public |
forgetTX(txID: *): ReduxThunk Remove a transaction from the tracking system. |
|
public |
Get data (like the balance) for each account in the tracker |
|
public |
getBalance(address: *): ReduxThunk To start updating the balance of an account |
|
public |
getBlock(blockHandle: *): ReduxThunk Get a specific block. |
|
public |
Force retrieval of the latest block. |
|
public |
getSingleAccount(address: *): ReduxThunk Get data for an individual account. |
|
public |
* getSpecificBlock(web3: *, action: *): ReduxSaga |
|
public |
initWeb3(fallback: *): * Initializes web3 in a fairly standard way. |
|
public |
initiateCall(web3: *, callID: *, blockNr: *, callParams: *): Promise Initiate a web3 call, it starts waiting for a promise that is mapped to our redux call system. |
|
public |
mappedreducer(mapping: *, initialState: *): Function Creates a simple reducer, based on a mapping and an initial state. |
|
public |
openTxChannel(promiEvent: *, txID: *): Channel<any> Open a TX channel: this channel maps web3 events to our redux tracking system. |
|
public |
poller(startAT: *, stopAT: *, workerInner: *, errorHandler: *, workerArgs: *): pollWatcher Simple redux saga utility for polling. |
|
public |
Forks to tracking and contracts saga. |
|
public |
sendTX(options: *): ReduxThunk Send a transaction, which will be tracked in the ReDApp tracking system. |
|
public |
startAccountPolling(interval: *): ReduxThunk Start polling for accounts. |
|
public |
Start listening for block headers, a new header will trigger the retrieval of the latest block. |
|
public |
startBlockPolling(interval: *): ReduxThunk Start polling blocks. |
|
public |
Stop polling for accounts. |
|
public |
Stop listening for block headers. |
|
public |
Stop polling blocks. |
|
public |
subber(startAT: *, stopAT: *, dataAT: *, changedAT: *, errorAT: *, openEventSub: *): subscriptionWatcher Maps an event-emitter (like web3.js uses) to a redux-saga event-channel, with support for being started/stopped/resumed. |
|
public |
* trackingSaga(web3: *, getTrackingState: ReduxStateSelector): ReduxSaga Forks to tracking and contracts saga. |
|
public |
* transactionsSaga(web3: *, getTransactionsState: ReduxStateSelector): ReduxSaga Handles ReDApp transaction background processing. |
Static Public
public addContract(contractName: *, abi: *, networks: *): ReduxThunk source
import {addContract} from 'redapp/es/contracts/actions/index.js'
Load a contract (binding it to an web3js Contract instance), and add it to the redux store. The methods of the contract are also added to the store, which can be called with their ABI arguments. This produces a thunk and an ID, the thunk can then be dispatched to execute the method, and the ID can be used to track the progress.
Params:
Name | Type | Attribute | Description |
contractName | * | The name of the contract, to use as key in the store. Any contract with the same name will be overwritten. |
|
abi | * | The ABI spec (decoded object, not encoded as string). All the methods in the spec will be loaded as call/send thunk creators. (i.e. cacheCall/forceCall/trackedSend) |
|
networks | * | The network spec, like formatted by tools like truffle. An object, with network IDs (strings) as keys, and each value being an object with an "address" property. |
public addLocalAcount(address: *): ReduxThunk source
import {addLocalAcount} from 'redapp/es/tracking/accounts/actions/index.js'
Add an account to track locally. (i.e. no interaction with the user)
Params:
Name | Type | Attribute | Description |
address | * | The address of the account to start tracking. |
public * awaitCall(callPromise: *, callID: *): Promise source
import awaitCall from 'redapp/es/tracking/calls/awaitCall.js'
Awaits a web3 call, and fires the corresponding redux events
Params:
Name | Type | Attribute | Description |
callPromise | * | The call promise, eventually completes with the call result, or fails. |
|
callID | * | The ID of the call, used in the caching system. |
public * blocksSaga(web3: *, getBlocksState: ReduxStateSelector): ReduxSaga source
import blocksSaga from 'redapp/es/tracking/blocks/blocksSaga.js'
Handles ReDApp block background processing.
Params:
Name | Type | Attribute | Description |
web3 | * | The web3js 1.0 instance to use. |
|
getBlocksState | ReduxStateSelector | Gets blocks state
(obj. incl. both |
public cacheCall(options: *): ReduxThunk source
import {cacheCall} from 'redapp/es/tracking/calls/actions/index.js'
Start a new call, but try to hit the cache for an existing call result first.
Note: the callID
is used to match with a previous call:
the callID
should be formatted consistently, based on address, calldata, and block-number,
to hit the cache properly.
The format used internally by ReDApp contract calls is:
${to}-${Web3Utils.soliditySha3(data)}-${blockNr || 'latest'}
Params:
Name | Type | Attribute | Description |
options | * | Options for this call. |
|
options.from | * | The call sender address. Optional. |
|
options.to | * | The call destination address, i.e. the contract address. |
|
options.data | * | ABI encoded call-data. E.g. a method signature + encoded arguments for a regular contract function. |
|
options.blockNr | * | The block number to use, format corresponding to web3.js formatting: a number, or special value like 'latest'. Optional, web3.js defaults to 'latest'. |
|
options.callID | * | The ID to use within the tracking system. Optional, a new ID (uuid v4) is used when not set. |
|
options.outputsABI | * | The ABI spec of the expected outputs. Optional, if set, the raw resulting value will be decoded and stored with the other data in the store. |
public * callsSaga(web3: *, getCallsState: ReduxStateSelector): ReduxSaga source
import callsSaga from 'redapp/es/tracking/calls/callsSaga.js'
Handles ReDApp call background processing.
Params:
Name | Type | Attribute | Description |
web3 | * | The web3js 1.0 instance to use. |
|
getCallsState | ReduxStateSelector | Gets calls state. |
public * contractsSaga(web3: *, defaultNetworkId: *, getContractsState: ReduxStateSelector): ReduxSaga source
import contractsSaga from 'redapp/es/contracts/contractsSaga.js'
Handles ReDApp contract background processing, e.g. loading new contracts.
Params:
Name | Type | Attribute | Description |
web3 | * | The web3js 1.0 instance to use. |
|
defaultNetworkId | * | The default network ID to use when looking up a contract address. |
|
getContractsState | ReduxStateSelector | Gets contracts state |
public createTransactionPromiEvent(web3: *, txID: *, txParams: *): PromiEvent<TransactionReceipt> source
Web3 returns a "promise combined with an event emitter": we map this to redux events.
Params:
Name | Type | Attribute | Description |
web3 | * | The web3 instance to use when sending the actual TX. |
|
txID | * | The ID of the transaction, used in the tracking system. |
|
txParams | * | The transaction parameters. |
|
txParams.from | * | Senders address, optional. (default wallet otherwise) |
|
txParams.to | * | Destination address, or undefined for contract creation. |
|
txParams.value | * | TX value in wei. |
|
txParams.gas | * | TX gas. Optional, can be determined later. |
|
txParams.gasPrice | * | TX gas price. Optional, defaults to web3.eth.gasPrice. |
|
txParams.data | * | Optional. TX data, i.e. abi encoded contract call, or contract code itself for contract creation. |
|
txParams.nonce | * | Optional, can be used to re-send a transaction (with higher gas). |
Return:
PromiEvent<TransactionReceipt> | The redux saga channel. |
public fetchAllAcounts(): ReduxThunk source
import {fetchAllAcounts} from 'redapp/es/tracking/accounts/actions/index.js'
Update the list of wallet accounts.
public forceCall(options: *): ReduxThunk source
import {forceCall} from 'redapp/es/tracking/calls/actions/index.js'
Start a new call, ignoring previous call data, forcing an overwrite when getting the result.
Params:
Name | Type | Attribute | Description |
options | * | Options for this call. |
|
options.from | * | The call sender address. Optional. |
|
options.to | * | The call destionation address, i.e. the contract address. |
|
options.data | * | ABI encoded call-data. E.g. a method signature + encoded arguments for a regular contract function. |
|
options.blockNr | * | The block number to use, format corresponding to web3.js formatting: a number, or special value like 'latest'. Optional, web3.js defaults to 'latest'. |
|
options.callID | * | The ID to use within the tracking system. Optional, a new ID (uuid v4) is used when not set. |
|
options.outputsABI | * | The ABI spec of the expected outputs. Optional, if set, the raw resulting value will be decoded and stored with the other data in the store. |
public forgetCall(callID: *): ReduxThunk source
import {forgetCall} from 'redapp/es/tracking/calls/actions/index.js'
Remove a call from the tracking system. Note: this does not cancel the call if it was already sent to the web3 instance.
Params:
Name | Type | Attribute | Description |
callID | * | The ID of the call to remove. |
public forgetContract(contractName: *): ReduxThunk source
import {forgetContract} from 'redapp/es/contracts/actions/index.js'
Removes the contract from the local redux store. Note: this does not affect the real contract in any way.
Params:
Name | Type | Attribute | Description |
contractName | * | The name of the contract (key in the state tree) |
public forgetLocalAccount(address: *): ReduxThunk source
import {forgetLocalAccount} from 'redapp/es/tracking/accounts/actions/index.js'
Forget local account.
Params:
Name | Type | Attribute | Description |
address | * | The address of the account to forget. |
public forgetTX(txID: *): ReduxThunk source
import {forgetTX} from 'redapp/es/tracking/transactions/actions/index.js'
Remove a transaction from the tracking system. Note: this does not cancel the transaction if it was already sent to the web3 instance (it may still be broadcasted, if wasn't already)
Params:
Name | Type | Attribute | Description |
txID | * | The ID of the transaction to remove. |
public getAllAccounts(): ReduxThunk source
import {getAllAccounts} from 'redapp/es/tracking/accounts/actions/index.js'
Get data (like the balance) for each account in the tracker
public getBalance(address: *): ReduxThunk source
import {getBalance} from 'redapp/es/tracking/accounts/actions/index.js'
To start updating the balance of an account
Params:
Name | Type | Attribute | Description |
address | * |
public getBlock(blockHandle: *): ReduxThunk source
import {getBlock} from 'redapp/es/tracking/blocks/actions/index.js'
Get a specific block. (Warning; block will not be inserted into the state when it's out of scope of the tracking blockDepth. However, the retrieval and events will still be executed.)
Params:
Name | Type | Attribute | Description |
blockHandle | * | The hash, number, of special name ("genesis", "latest", "pending") of the block to get. |
public getLatestBlock(): ReduxThunk source
import {getLatestBlock} from 'redapp/es/tracking/blocks/actions/index.js'
Force retrieval of the latest block.
public getSingleAccount(address: *): ReduxThunk source
import {getSingleAccount} from 'redapp/es/tracking/accounts/actions/index.js'
Get data for an individual account.
Params:
Name | Type | Attribute | Description |
address | * | The address to get the data for. |
public * getSpecificBlock(web3: *, action: *): ReduxSaga source
Params:
Name | Type | Attribute | Description |
web3 | * | Web3 handle. |
|
action | * | The action to handle. |
|
action.blockHandle | * | The hash, number, of special name ("genesis", "latest", "pending") of the block to get. |
public initWeb3(fallback: *): * source
import initWeb3 from 'redapp/es/initWeb3.js'
Initializes web3 in a fairly standard way. Utility function, for the "lazy" dev.
Params:
Name | Type | Attribute | Description |
fallback | * | An object specifying what to use when no provider was found. |
Return:
* | Web3 A new web3 instance, or throws an error if failing to instantiate. |
public initiateCall(web3: *, callID: *, blockNr: *, callParams: *): Promise source
Initiate a web3 call, it starts waiting for a promise that is mapped to our redux call system.
Params:
Name | Type | Attribute | Description |
web3 | * | The web3 instance to use when sending the actual TX. |
|
callID | * | The ID of the transaction, used in the tracking system. |
|
blockNr | * | The block number to use in the computation of the call, as call context. (Optional, web3 defaults to the "latest" block). |
|
callParams | * | The call parameters |
|
callParams.from | * | Senders address, optional. (default wallet otherwise) |
|
callParams.to | * | Destination address, or undefined for contract creation. |
|
callParams.data | * | Optional. TX data, i.e. abi encoded contract call, or contract code itself for contract creation. (99% of calls should have it though.) |
public mappedreducer(mapping: *, initialState: *): Function source
import mappedreducer from 'redapp/es/util/mapped-reducer.js'
Creates a simple reducer, based on a mapping and an initial state. Similar to redux-actions, but much less bloated.
Params:
Name | Type | Attribute | Description |
mapping | * | An object with a mapping function for each action type, actions without key in this mapping are ignored. |
|
initialState | * | The state to use when there is none available. |
public openTxChannel(promiEvent: *, txID: *): Channel<any> source
import openTxChannel from 'redapp/es/tracking/transactions/openTxChannel.js'
Open a TX channel: this channel maps web3 events to our redux tracking system.
Params:
Name | Type | Attribute | Description |
promiEvent | * | The event emitter to read transaction status updates from. |
|
txID | * | The ID of the transaction, used in the tracking system. |
Return:
Channel<any> | The redux saga channel. |
public poller(startAT: *, stopAT: *, workerInner: *, errorHandler: *, workerArgs: *): pollWatcher source
import poller from 'redapp/es/util/poller.js'
Simple redux saga utility for polling. Returns a watcher saga that listens for an action of type startAT, and then starts polling. Polling is then stopped when the watcher notices an action of type stopAT. Polling can be resumed with an action of type startAT again.
Params:
Name | Type | Attribute | Description |
startAT | * | The action type to listen for to start polling. This action should have a property 'interval', specifying the number of milliseconds to wait before executing the next poll iteration. |
|
stopAT | * | The action type to listen for to stop polling. |
|
workerInner | * | A saga that is called each poll iteration. |
|
errorHandler | * | A saga that is called on an error during a polling iteration. Optional, error is propagated otherwise. |
|
workerArgs | * | The remaining function arguments are forwarded to workerInner. |
Return:
pollWatcher | The watcher saga, controlling the inner worker saga. |
public * saga(web3: *, defaultNetworkId: *, getRootState: *): ReduxSaga source
import saga from 'redapp/es/saga.js'
Forks to tracking and contracts saga.
Params:
Name | Type | Attribute | Description |
web3 | * | The web3js 1.0 instance to use. |
|
defaultNetworkId | * | The network ID to resort to when no specific network ID is specified in an action. |
|
getRootState | * | A state selector (E.g. |
public sendTX(options: *): ReduxThunk source
import {sendTX} from 'redapp/es/tracking/transactions/actions/index.js'
Send a transaction, which will be tracked in the ReDApp tracking system.
Params:
Name | Type | Attribute | Description |
options | * | Options |
|
options.from | * | The transaction sender address. |
|
options.to | * | The transaction destination address. Optional, e.g. not used for contract deployments. |
|
options.value | * | The value, ETH. Optional, defaults to 0. |
|
options.gas | * | Gas, in wei. Optional, can be calculated on the fly by web3 provider. |
|
options.gasPrice | * | Gas price. Optional, can be set by web3 provider later on. |
|
options.data | * | ABI encoded data to send with the transaction. Used for contract deploying and contract interaction. Optional, e.g. a normal ETH transfer. |
|
options.nonce | * | The transaction nonce. Optional, can be determined automatically by the web3 provider. |
|
options.txID | * | The ID to use within the tracking system. Optional, a new ID (uuid v4) is used when not set. |
public startAccountPolling(interval: *): ReduxThunk source
import {startAccountPolling} from 'redapp/es/tracking/accounts/actions/index.js'
Start polling for accounts.
Params:
Name | Type | Attribute | Description |
interval | * | The polling interval in milliseconds. |
public startBlockListening(): ReduxThunk source
import {startBlockListening} from 'redapp/es/tracking/blocks/actions/index.js'
Start listening for block headers, a new header will trigger the retrieval of the latest block.
public startBlockPolling(interval: *): ReduxThunk source
import {startBlockPolling} from 'redapp/es/tracking/blocks/actions/index.js'
Start polling blocks.
Params:
Name | Type | Attribute | Description |
interval | * | The polling interval in milliseconds. |
public stopAccountPolling(): ReduxThunk source
import {stopAccountPolling} from 'redapp/es/tracking/accounts/actions/index.js'
Stop polling for accounts.
public stopBlockListening(): ReduxThunk source
import {stopBlockListening} from 'redapp/es/tracking/blocks/actions/index.js'
Stop listening for block headers.
public stopBlockPolling(): ReduxThunk source
import {stopBlockPolling} from 'redapp/es/tracking/blocks/actions/index.js'
Stop polling blocks. Polling can be resumed later with startPolling
again.
public subber(startAT: *, stopAT: *, dataAT: *, changedAT: *, errorAT: *, openEventSub: *): subscriptionWatcher source
import subber from 'redapp/es/util/subber.js'
Maps an event-emitter (like web3.js uses) to a redux-saga event-channel, with support for being started/stopped/resumed.
Params:
Name | Type | Attribute | Description |
startAT | * | The action type that starts/resumes it. |
|
stopAT | * | The action type that stops it. |
|
dataAT | * | The action type that will be emitted when a "data" event is received from the subscription. Payload property = 'data' |
|
changedAT | * | The action type that will be emitted when a "changed" event is received from the subscription. Payload property = 'changed' |
|
errorAT | * | The action type that will be emitted when a "error" event is received from the subscription. Payload property = 'err' |
|
openEventSub | * | A function that returns a new EventEmitter ready to subscribe to. |
Return:
subscriptionWatcher | The watcher, a redux-saga, can be shut down to stop the service completely. Controls the inner event-channel (like the worker in the poller utility). |
public * trackingSaga(web3: *, getTrackingState: ReduxStateSelector): ReduxSaga source
import trackingSaga from 'redapp/es/tracking/trackingSaga.js'
Forks to tracking and contracts saga.
Params:
Name | Type | Attribute | Description |
web3 | * | The web3js 1.0 instance to use. |
|
getTrackingState | ReduxStateSelector | Gets tracking state. |
public * transactionsSaga(web3: *, getTransactionsState: ReduxStateSelector): ReduxSaga source
import transactionsSaga from 'redapp/es/tracking/transactions/transactionsSaga.js'
Handles ReDApp transaction background processing.
Params:
Name | Type | Attribute | Description |
web3 | * | The web3js 1.0 instance to use. |
|
getTransactionsState | ReduxStateSelector | Gets transactions state. |