Constructor
new TransactionStateManager(opts)
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
opts |
object |
Properties
|
Methods
_saveTxList(transactions)
Saves the new/updated txList.
Parameters:
Name | Type | Description |
---|---|---|
transactions |
array | the list of transactions to save |
_setTxStatus(txId, status)
Parameters:
Name | Type | Description |
---|---|---|
txId |
number | the txMeta Id |
status |
string | the status to set on the txMeta |
Fires:
- tx:status-update - passes txId and status
- ${txMeta.id}:finished - if it is a finished state.event: Passes the txMeta
- update:badge
addTx(txMeta) → {object}
Adds the txMeta to the list of transactions in the store.
if the list is over txHistoryLimit it will remove a transaction that
is in its final state
it will allso add the key history
to the txMeta with the snap shot of the original
object
Parameters:
Name | Type | Description |
---|---|---|
txMeta |
Object |
Returns:
the txMeta
- Type
- object
generateTxMeta(opts) → {txMeta}
Parameters:
Name | Type | Description |
---|---|---|
opts |
object | the object to use when overwriting defaults |
Returns:
the default txMeta object
- Type
- txMeta
getConfirmedTransactions(addressopt) → {array}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
address |
string |
<optional> |
hex prefixed address to sort the txMetas for [optional] |
Returns:
the tx list whos status is confirmed if no address is provide returns all txMetas who's status is confirmed for the current network
- Type
- array
getFullTxList() → {array}
Returns:
of all the txMetas in store
- Type
- array
getPendingTransactions(addressopt) → {array}
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
address |
string |
<optional> |
hex prefixed address to sort the txMetas for [optional] |
Returns:
the tx list whos status is submitted if no address is provide returns all txMetas who's status is submitted for the current network
- Type
- array
getTx(txId) → {object}
Parameters:
Name | Type | Description |
---|---|---|
txId |
number |
Returns:
the txMeta who matches the given id if none found for the network returns undefined
- Type
- object
getTxList() → {array}
Returns:
of txMetas that have been filtered for only the current network
- Type
- array
getTxsByMetaData(key, value, txListopt) → {array}
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
key |
string | the key to check |
||
value |
the value your looking for |
|||
txList |
array |
<optional> |
this.getTxList()
|
the list to search. default is the txList from txStateManager#getTxList |
Returns:
a list of txMetas who matches the search params
- Type
- array
getTxStatus(txId) → {string}
Parameters:
Name | Type | Description |
---|---|---|
txId |
number | the txMeta Id |
Returns:
the status of the tx.
- Type
- string
getUnapprovedTxList() → {array}
Returns:
the tx list whos status is unapproved
- Type
- array
setTxStatusApproved(txId)
should update the status of the tx to 'approved'.
Parameters:
Name | Type | Description |
---|---|---|
txId |
number | the txMeta Id |
setTxStatusConfirmed(txId)
should update the status of the tx to 'confirmed'.
Parameters:
Name | Type | Description |
---|---|---|
txId |
number | the txMeta Id |
setTxStatusDropped(txId)
should update the status of the tx to 'dropped'.
Parameters:
Name | Type | Description |
---|---|---|
txId |
number | the txMeta Id |
setTxStatusFailed(txId, err)
should update the status of the tx to 'failed'. and put the error on the txMeta
Parameters:
Name | Type | Description |
---|---|---|
txId |
number | the txMeta Id |
err |
erroObject | error object |
setTxStatusRejected(txId)
should update the status of the tx to 'rejected'.
Parameters:
Name | Type | Description |
---|---|---|
txId |
number | the txMeta Id |
setTxStatusSigned(txId)
should update the status of the tx to 'signed'.
Parameters:
Name | Type | Description |
---|---|---|
txId |
number | the txMeta Id |
setTxStatusSubmitted(txId)
should update the status of the tx to 'submitted'. and add a time stamp for when it was called
Parameters:
Name | Type | Description |
---|---|---|
txId |
number | the txMeta Id |
setTxStatusUnapproved(txId)
should update the status of the tx to 'unapproved'.
Parameters:
Name | Type | Description |
---|---|---|
txId |
number | the txMeta Id |
updateTx(txMeta, noteopt)
updates the txMeta in the list and adds a history entry
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
txMeta |
Object | the txMeta to update |
|
note |
string |
<optional> |
a note about the update for history |
updateTxParams(txId, txParams)
merges txParams obj onto txMeta.txParams use extend to ensure that all fields are filled
Parameters:
Name | Type | Description |
---|---|---|
txId |
number | the id of the txMeta |
txParams |
object | the updated txParams |
validateTxParams(txParams)
validates txParams members by type
Parameters:
Name | Type | Description |
---|---|---|
txParams |
object | txParams to validate |
wipeTransactions(address)
Removes transaction from the given address for the current network from the txList
Parameters:
Name | Type | Description |
---|---|---|
address |
string | hex string of the from address on the txParams to remove |