aboutsummaryrefslogtreecommitdiffstats
path: root/ui/app/helpers/transactions.util.js
diff options
context:
space:
mode:
authorbrunobar79 <brunobar79@gmail.com>2018-11-07 09:21:19 +0800
committerbrunobar79 <brunobar79@gmail.com>2018-11-07 09:21:19 +0800
commitc651212025ab7cd0309d96be6687c1eba35ab9fa (patch)
treefa5a6020daae332c5df47bdee3492e8a079375e3 /ui/app/helpers/transactions.util.js
parent9c1b2108f69334884473eb95758e2d1c02c984d6 (diff)
parent7f944923d170d6e7e04f6e238d2fd5f80abe3161 (diff)
downloadtangerine-wallet-browser-c651212025ab7cd0309d96be6687c1eba35ab9fa.tar.gz
tangerine-wallet-browser-c651212025ab7cd0309d96be6687c1eba35ab9fa.tar.zst
tangerine-wallet-browser-c651212025ab7cd0309d96be6687c1eba35ab9fa.zip
fix merge conflicts
Diffstat (limited to 'ui/app/helpers/transactions.util.js')
-rw-r--r--ui/app/helpers/transactions.util.js15
1 files changed, 14 insertions, 1 deletions
diff --git a/ui/app/helpers/transactions.util.js b/ui/app/helpers/transactions.util.js
index e50196196..2f4b1d095 100644
--- a/ui/app/helpers/transactions.util.js
+++ b/ui/app/helpers/transactions.util.js
@@ -27,10 +27,21 @@ export function getTokenData (data = '') {
const registry = new MethodRegistry({ provider: global.ethereumProvider })
+/**
+ * Attempts to return the method data from the MethodRegistry library, if the method exists in the
+ * registry. Otherwise, returns an empty object.
+ * @param {string} data - The hex data (@code txParams.data) of a transaction
+ * @returns {Object}
+ */
export async function getMethodData (data = '') {
const prefixedData = ethUtil.addHexPrefix(data)
const fourBytePrefix = prefixedData.slice(0, 10)
const sig = await registry.lookup(fourBytePrefix)
+
+ if (!sig) {
+ return {}
+ }
+
const parsedResult = registry.parse(sig)
return {
@@ -114,7 +125,9 @@ export function getLatestSubmittedTxWithNonce (transactions = [], nonce = '0x0')
export async function isSmartContractAddress (address) {
const code = await global.eth.getCode(address)
- return code && code !== '0x'
+ // Geth will return '0x', and ganache-core v2.2.1 will return '0x0'
+ const codeIsEmpty = !code || code === '0x' || code === '0x0'
+ return !codeIsEmpty
}
export function sumHexes (...args) {