diff options
author | Alexander Tseung <alextsg@gmail.com> | 2018-06-29 02:23:31 +0800 |
---|---|---|
committer | Alexander Tseung <alextsg@gmail.com> | 2018-07-07 07:27:08 +0800 |
commit | 9cde5ab11b0670eed7baeb2f31486cb3e253bdcb (patch) | |
tree | f31a0b631c19227cbf7a62a3be0f92a1b7b1a586 /ui/app/helpers | |
parent | 7732cd4100f3c40f35eeaec669094f63292cbe3d (diff) | |
download | tangerine-wallet-browser-9cde5ab11b0670eed7baeb2f31486cb3e253bdcb.tar tangerine-wallet-browser-9cde5ab11b0670eed7baeb2f31486cb3e253bdcb.tar.gz tangerine-wallet-browser-9cde5ab11b0670eed7baeb2f31486cb3e253bdcb.tar.bz2 tangerine-wallet-browser-9cde5ab11b0670eed7baeb2f31486cb3e253bdcb.tar.lz tangerine-wallet-browser-9cde5ab11b0670eed7baeb2f31486cb3e253bdcb.tar.xz tangerine-wallet-browser-9cde5ab11b0670eed7baeb2f31486cb3e253bdcb.tar.zst tangerine-wallet-browser-9cde5ab11b0670eed7baeb2f31486cb3e253bdcb.zip |
Use eth-method-registry to get method data
Diffstat (limited to 'ui/app/helpers')
-rw-r--r-- | ui/app/helpers/confirm-transaction/util.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/ui/app/helpers/confirm-transaction/util.js b/ui/app/helpers/confirm-transaction/util.js index fa748ca46..ad247a348 100644 --- a/ui/app/helpers/confirm-transaction/util.js +++ b/ui/app/helpers/confirm-transaction/util.js @@ -6,6 +6,9 @@ import ethUtil from 'ethereumjs-util' abiDecoder.addABI(abi) +import MethodRegistry from 'eth-method-registry' +const registry = new MethodRegistry({ provider: global.ethereumProvider }) + import { conversionUtil, addCurrencies, @@ -17,6 +20,18 @@ export function getTokenData (data = {}) { return abiDecoder.decodeMethod(data) } +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 increaseLastGasPrice (lastGasPrice) { return ethUtil.addHexPrefix(multiplyCurrencies(lastGasPrice, 1.1, { multiplicandBase: 16, |