From 08a7cb1f2b8ae68cfc89e79d0b6768103a005b7c Mon Sep 17 00:00:00 2001 From: HenryNguyen5 Date: Fri, 6 Apr 2018 17:34:43 -0400 Subject: [PATCH] Check for buffer type and decode to hex instead of utf8 (#1469) * Check for buffer type and decode to hex instead of utf8 * Fix typo --- .../Interact/components/InteractExplorer/index.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/common/containers/Tabs/Contracts/components/Interact/components/InteractExplorer/index.tsx b/common/containers/Tabs/Contracts/components/Interact/components/InteractExplorer/index.tsx index ec455719..1ab39872 100644 --- a/common/containers/Tabs/Contracts/components/Interact/components/InteractExplorer/index.tsx +++ b/common/containers/Tabs/Contracts/components/Interact/components/InteractExplorer/index.tsx @@ -12,6 +12,7 @@ import { setDataField, TSetDataField } from 'actions/transaction'; import { Data } from 'libs/units'; import { Input, Dropdown } from 'components/ui'; import { INode } from 'libs/nodes'; +import { bufferToHex } from 'ethereumjs-util'; interface StateProps { nodeLib: INode; @@ -126,6 +127,10 @@ class InteractExplorerClass extends Component { {selectedFunction.contract.outputs.map((output: any, index: number) => { const { type, name } = output; const parsedName = name === '' ? index : name; + const rawFieldValue = outputs[parsedName] || ''; + const decodedFieldValue = Buffer.isBuffer(rawFieldValue) + ? bufferToHex(rawFieldValue) + : rawFieldValue; return (
@@ -133,7 +138,7 @@ class InteractExplorerClass extends Component {
↳ {name + ' ' + type}
@@ -187,6 +192,7 @@ class InteractExplorerClass extends Component { const results = await nodeLib.sendCallRequest(callData); const parsedResult = selectedFunction!.contract.decodeOutput(results); + this.setState({ outputs: parsedResult }); } catch (e) { this.props.showNotification(