Skip to content

Instantly share code, notes, and snippets.

@devonwesley
Last active November 20, 2017 18:34
Show Gist options
  • Save devonwesley/1aa005d385851276957103ee13698702 to your computer and use it in GitHub Desktop.
Save devonwesley/1aa005d385851276957103ee13698702 to your computer and use it in GitHub Desktop.
This feature shows the contract details.
function renderContractDetails(name, contract) {
const modalEl = document.createElement('div')
modalEl.style.width = '700px';
modalEl.style.margin = '100px auto';
modalEl.style.padding = '50px';
modalEl.style.backgroundColor = '#fff';
modalEl.appendChild(renderContractInfo(name, contract))
mui.overlay('on', modalEl);
}
function renderContractInfo(contractName, contract) {
const contractContainer = document.createElement('div')
contractContainer.innerHTML = `
<h3>
Contract Name: <strong>${contractName.substring(1, contractName.length)}</strong>
</h3>
<h4>Bytecode:</h4>
<textarea style="width:670px; height:200px;" readonly>${contract.bytecode}</textarea>
<h4>ABI:</h4>
<textarea style="width:670px; height:150px;" readonly>${contract.interface}</textarea>
<h4>Function Hashes</h4>
<textarea style="width:670px; height:100px;" readonly>${renderFunctionWithHashes(contract.functionHashes)}</textarea>
<h4>Opcodes:</h4>
<textarea style="width:670px; height:200px;" readonly>${contract.opcodes}</textarea>
`
return contractContainer
}
function renderFunctionWithHashes(functionHashes) {
let functionHashContainer = ''
Object.keys(functionHashes)
.forEach((functionHash, index) => (
functionHashContainer += `${++index}. ${functionHashes[functionHash]}: ${functionHash} \n`
))
return functionHashContainer
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment