Constructor
new TransactionController(opts)
- Source:
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
object | opts Properties
|
Methods
_mapMethods()
maps methods for convenience
_markNonceDuplicatesDropped(txId)
Sets other txMeta statuses to dropped if the txMeta that has been confirmed has other transactions in the list have the same nonce
Parameters:
Name | Type | Description |
---|---|---|
txId |
Number | the txId of the transaction that has been confirmed in a block |
_onBootCleanUp()
If transaction controller was rebooted with transactions that are uncompleted in steps of the transaction signing or user confirmation process it will either transition txMetas to a failed state or try to redo those tasks.
_setupListeners()
is called in constructor applies the listeners for pendingTxTracker txStateManager and blockTracker
_updateMemstore()
Updates the memStore in transaction controller
addTx()
Adds a tx to the txlist
Fires:
- ${txMeta.event:id}:unapproved
(async) addTxGasDefaults(txMeta) → {Promise.<object>}
adds the tx gas defaults: gas && gasPrice
Parameters:
Name | Type | Description |
---|---|---|
txMeta |
Object | the txMeta object |
Returns:
resolves with txMeta
- Type
- Promise.<object>
(async) addUnapprovedTransaction() → {txMeta}
Validates and generates a txMeta with defaults and puts it in txStateManager store
Returns:
- Type
- txMeta
(async) approveTransaction(txId)
sets the tx status to approved auto fills the nonce signs the transaction publishes the transaction if any of these steps fails the tx status will be set to failed
Parameters:
Name | Type | Description |
---|---|---|
txId |
number | the tx's Id |
(async) cancelTransaction(txId) → {Promise.<void>}
Convenience method for the ui thats sets the transaction to rejected
Parameters:
Name | Type | Description |
---|---|---|
txId |
number | the tx's Id |
Returns:
- Type
- Promise.<void>
(async) createCancelTransaction(originalTxId, customGasPriceopt) → {txMeta}
Creates a new approved transaction to attempt to cancel a previously submitted transaction. The new transaction contains the same nonce as the previous, is a basic ETH transfer of 0x value to the sender's address, and has a higher gasPrice than that of the previous transaction.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
originalTxId |
number | the id of the txMeta that you want to attempt to cancel |
|
customGasPrice |
string |
<optional> |
the hex value to use for the cancel transaction |
Returns:
- Type
- txMeta
getChainId() → {number}
Returns:
the chainId
- Type
- number
getFilteredTxList()
see txStateManager
getNetwork()
Returns:
the network number stored in networkStore
getPendingTxCount(account)
Parameters:
Name | Type | Description |
---|---|---|
account |
String | hex prefixed account |
Returns:
a number that represents how many transactions have the status submitted
getSelectedAddress()
Returns:
the user selected address
getState()
Returns:
the state in transaction controller
getUnapprovedTxCount()
Returns an array of transactions whos status is unapproved
(async) newUnapprovedTransaction(txParams, opts) → {Promise.<string>}
add a new unapproved transaction to the pipeline
Parameters:
Name | Type | Description |
---|---|---|
txParams |
object | txParams for the transaction |
opts |
object | with the key origin to put the origin on the txMeta |
Returns:
the hash of the transaction after being submitted to the network
- Type
- Promise.<string>
(async) publishTransaction(txId, rawTx) → {Promise.<void>}
publishes the raw tx and sets the txMeta to submitted
Parameters:
Name | Type | Description |
---|---|---|
txId |
number | the tx's Id |
rawTx |
string | the hex string of the serialized signed transaction |
Returns:
- Type
- Promise.<void>
(async) retryTransaction(originalTxId) → {txMeta}
Creates a new txMeta with the same txParams as the original to allow the user to resign the transaction with a higher gas values
Parameters:
Name | Type | Description |
---|---|---|
originalTxId |
number | the id of the txMeta that you want to attempt to retry |
Returns:
- Type
- txMeta
setTxHash(txId, txHash)
Sets the txHas on the txMeta
Parameters:
Name | Type | Description |
---|---|---|
txId |
number | the tx's Id |
txHash |
string | the hash for the txMeta |
(async) signTransaction(txId) → {string}
adds the chain id and signs the transaction and set the status to signed
Parameters:
Name | Type | Description |
---|---|---|
txId |
number | the tx's Id |
Returns:
- rawTx
- Type
- string
(async) updateAndApproveTransaction(txMeta)
updates and approves the transaction
Parameters:
Name | Type | Description |
---|---|---|
txMeta |
Object |
(async) updateTransaction(txMeta)
updates the txMeta in the txStateManager
Parameters:
Name | Type | Description |
---|---|---|
txMeta |
Object | the updated txMeta |
wipeTransactions(address)
Wipes the transactions for a given account
Parameters:
Name | Type | Description |
---|---|---|
address |
string | hex string of the from address for txs being removed |