This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (typeof web3 !== 'undefined') { | |
web3 = new Web3(web3.currentProvider) | |
} else { | |
// set the provider you want from Web3.providers | |
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545")) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getAccounts() { | |
const ethAccount = web3.eth.accounts[0] | |
return document | |
.getElementById('account-addresses') | |
.innerHTML = `<div> | |
Account: ${ethAccount} | |
<br /> | |
Balance: ${balanceInEth(ethAccount)} | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="mui-col-md-6"> | |
<div class="mui-panel"> | |
<div id="account-addresses"></div> | |
</div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function renderContractList() { | |
const contractListContainer = document.getElementById('contract-list') | |
const { contracts } = compiledContract | |
Object.keys(contracts).forEach((contract, index) => { | |
const label = `contract-id-${contract}-${Math.random()}` | |
const gas = contracts[contract].gasEstimates.creation | |
createContractInfo(gas, contract, label, function (el) { | |
contractListContainer.appendChild(el) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function deployContractEvent(name, contract) { | |
const comfirmMsg = ` | |
Contract: ${name.substring(1)} | |
Network: ${currentNetwork()} | |
Confirm to deploy with these settings. | |
` | |
if (!confirm(comfirmMsg)) return | |
const { bytecode, interface } = contract |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function renderContract(contract, contractName) { | |
status(`Contract Deployed...`) | |
const { transactionHash, address } = contract | |
web3.eth.getTransaction(transactionHash, (err, transaction) => { | |
if (!err) { | |
const props = { ...transaction, ...contract, } | |
const details = { | |
blockNumber: transaction.blockNumber, | |
contractName, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function newContractCallback(name) { | |
return (err, contract) => { | |
getAccounts() | |
if (!err) { | |
!contract.address | |
? status(`Deploying contract..`) | |
: renderContract(contract, name) | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function currentNetwork() { | |
const network = web3.eth.getBlock(0).hash | |
const main = '0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3' | |
const test = '0x41941023680923e0fe4d74a34bdac8141f2540e3ae90623718e47d66d1ca4a2d' | |
switch (network) { | |
case main: | |
return 'Main Net' | |
case test: | |
return 'Ropsten Network' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function createContractPanel(contract, callback) { | |
const div = document.createElement('DIV') | |
div.className = 'mui-panel' | |
div.innerHTML = ` | |
<h3> | |
<strong>Contract: </strong> | |
${contract.contractName} | |
</h3> | |
<p> | |
<strong>Block Number: </strong> |