aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/components/transaction-activity-log/transaction-activity-log.util.js
diff options
context:
space:
mode:
authorAlexander Tseung <alextsg@gmail.com>2018-09-01 03:34:22 +0800
committerAlexander Tseung <alextsg@gmail.com>2018-09-13 10:48:52 +0800
commit084158f1a2af9d117c054420e895f4ae76a94df0 (patch)
tree1f822718e3ee315bf1d8f8f0c3aec4ec7242dbef /ui/app/components/transaction-activity-log/transaction-activity-log.util.js
parent8143f7725a21aa48c00b59402a79a3d3918ae601 (diff)
downloadtangerine-wallet-browser-084158f1a2af9d117c054420e895f4ae76a94df0.tar.gz
tangerine-wallet-browser-084158f1a2af9d117c054420e895f4ae76a94df0.tar.zst
tangerine-wallet-browser-084158f1a2af9d117c054420e895f4ae76a94df0.zip
Add tests for TransactionActivityLog. Make changes to rendering events
Diffstat (limited to 'ui/app/components/transaction-activity-log/transaction-activity-log.util.js')
-rw-r--r--ui/app/components/transaction-activity-log/transaction-activity-log.util.js32
1 files changed, 19 insertions, 13 deletions
diff --git a/ui/app/components/transaction-activity-log/transaction-activity-log.util.js b/ui/app/components/transaction-activity-log/transaction-activity-log.util.js
index fe780788a..fff0b68dc 100644
--- a/ui/app/components/transaction-activity-log/transaction-activity-log.util.js
+++ b/ui/app/components/transaction-activity-log/transaction-activity-log.util.js
@@ -3,31 +3,37 @@ const STATUS_PATH = '/status'
const GAS_PRICE_PATH = '/txParams/gasPrice'
// status constants
-const STATUS_UNAPPROVED = 'unapproved'
-const STATUS_SUBMITTED = 'submitted'
-const STATUS_CONFIRMED = 'confirmed'
-const STATUS_DROPPED = 'dropped'
+const UNAPPROVED_STATUS = 'unapproved'
+const SUBMITTED_STATUS = 'submitted'
+const CONFIRMED_STATUS = 'confirmed'
+const DROPPED_STATUS = 'dropped'
// op constants
const REPLACE_OP = 'replace'
+// event constants
+const TRANSACTION_CREATED_EVENT = 'transactionCreated'
+const TRANSACTION_UPDATED_GAS_EVENT = 'transactionUpdatedGas'
+const TRANSACTION_SUBMITTED_EVENT = 'transactionSubmitted'
+const TRANSACTION_CONFIRMED_EVENT = 'transactionConfirmed'
+const TRANSACTION_DROPPED_EVENT = 'transactionDropped'
+
const eventPathsHash = {
[STATUS_PATH]: true,
[GAS_PRICE_PATH]: true,
}
const statusHash = {
- [STATUS_SUBMITTED]: true,
- [STATUS_CONFIRMED]: true,
- [STATUS_DROPPED]: true,
+ [SUBMITTED_STATUS]: TRANSACTION_SUBMITTED_EVENT,
+ [CONFIRMED_STATUS]: TRANSACTION_CONFIRMED_EVENT,
+ [DROPPED_STATUS]: TRANSACTION_DROPPED_EVENT,
}
-function eventCreator (eventKey, timestamp, value, valueDescriptionKey) {
+function eventCreator (eventKey, timestamp, value) {
return {
eventKey,
timestamp,
value,
- valueDescriptionKey,
}
}
@@ -36,9 +42,9 @@ export function getActivities (transaction) {
return history.reduce((acc, base) => {
// First history item should be transaction creation
- if (!Array.isArray(base) && base.status === STATUS_UNAPPROVED && base.txParams) {
+ if (!Array.isArray(base) && base.status === UNAPPROVED_STATUS && base.txParams) {
const { time, txParams: { value } = {} } = base
- return acc.concat(eventCreator('created', time, value, 'value'))
+ return acc.concat(eventCreator(TRANSACTION_CREATED_EVENT, time, value))
} else if (Array.isArray(base)) {
const events = []
@@ -49,14 +55,14 @@ export function getActivities (transaction) {
switch (path) {
case STATUS_PATH: {
if (value in statusHash) {
- events.push(eventCreator(value, timestamp))
+ events.push(eventCreator(statusHash[value], timestamp))
}
break
}
case GAS_PRICE_PATH: {
- events.push(eventCreator('updated', timestamp, value, 'gasPrice'))
+ events.push(eventCreator(TRANSACTION_UPDATED_GAS_EVENT, timestamp, value))
break
}