aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/helpers/transactions.util.js
diff options
context:
space:
mode:
authorAlexander Tseung <alextsg@gmail.com>2018-08-06 13:25:58 +0800
committerAlexander Tseung <alextsg@gmail.com>2018-08-24 07:45:27 +0800
commit33a94332e48b280fcf4c9fb23aa4d349eaa8a54d (patch)
treed90d6c353334211a07cd2c552e0c5a890e88e694 /ui/app/helpers/transactions.util.js
parent13c4ecd6101e57b9184b14f4e0136206843f51eb (diff)
downloadtangerine-wallet-browser-33a94332e48b280fcf4c9fb23aa4d349eaa8a54d.tar
tangerine-wallet-browser-33a94332e48b280fcf4c9fb23aa4d349eaa8a54d.tar.gz
tangerine-wallet-browser-33a94332e48b280fcf4c9fb23aa4d349eaa8a54d.tar.bz2
tangerine-wallet-browser-33a94332e48b280fcf4c9fb23aa4d349eaa8a54d.tar.lz
tangerine-wallet-browser-33a94332e48b280fcf4c9fb23aa4d349eaa8a54d.tar.xz
tangerine-wallet-browser-33a94332e48b280fcf4c9fb23aa4d349eaa8a54d.tar.zst
tangerine-wallet-browser-33a94332e48b280fcf4c9fb23aa4d349eaa8a54d.zip
Show token amounts in TransactionListItem for token transfers
Diffstat (limited to 'ui/app/helpers/transactions.util.js')
-rw-r--r--ui/app/helpers/transactions.util.js36
1 files changed, 22 insertions, 14 deletions
diff --git a/ui/app/helpers/transactions.util.js b/ui/app/helpers/transactions.util.js
index 68e935702..89d2649c9 100644
--- a/ui/app/helpers/transactions.util.js
+++ b/ui/app/helpers/transactions.util.js
@@ -1,7 +1,7 @@
import ethUtil from 'ethereumjs-util'
import MethodRegistry from 'eth-method-registry'
-const registry = new MethodRegistry({ provider: global.ethereumProvider })
-
+import abi from 'human-standard-token-abi'
+import abiDecoder from 'abi-decoder'
import { hexToDecimal } from './conversions.util'
import {
@@ -15,6 +15,26 @@ import {
TRANSFER_FROM_ACTION_KEY,
} from '../constants/transactions'
+abiDecoder.addABI(abi)
+
+export function getTokenData (data = {}) {
+ return abiDecoder.decodeMethod(data)
+}
+
+const registry = new MethodRegistry({ provider: global.ethereumProvider })
+
+export async function getMethodData (data = {}) {
+ const prefixedData = ethUtil.addHexPrefix(data)
+ const fourBytePrefix = prefixedData.slice(0, 10)
+ const sig = await registry.lookup(fourBytePrefix)
+ const parsedResult = registry.parse(sig)
+
+ return {
+ name: parsedResult.name,
+ params: parsedResult.args,
+ }
+}
+
export function isConfirmDeployContract (txData = {}) {
const { txParams = {} } = txData
return !txParams.to
@@ -46,18 +66,6 @@ export function getTransactionActionKey (transaction, methodData) {
}
}
-export async function getMethodData (data = {}) {
- const prefixedData = ethUtil.addHexPrefix(data)
- const fourBytePrefix = prefixedData.slice(0, 10)
- const sig = await registry.lookup(fourBytePrefix)
- const parsedResult = registry.parse(sig)
-
- return {
- name: parsedResult.name,
- params: parsedResult.args,
- }
-}
-
export function getLatestSubmittedTxWithEarliestNonce (transactions = []) {
if (!transactions.length) {
return {}