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 createContractHash(name, hash, tag, className) { | |
| const el = document.createElement(tag) | |
| const value = name === 'input' | |
| ? `<br/><textarea style="width: 100%;">${hash}</textarea>` | |
| : hash | |
| el.className = className | |
| el.innerHTML = `<br/><strong>${name}</strong>: ${value}` | |
| return 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 createContractElement(contractProp, container) { | |
| return typeof contractProp[1] === 'function' | |
| ? createContractFunction(contractProp, container) | |
| : createContractProp(contractProp, 'P') | |
| } | |
| function createContractFunction(contractFunc, container) { | |
| const name = contractFunc[0] | |
| const func = contractFunc[1] | |
| const btn = document.createElement('BUTTON') |
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 filterProps(prop) { | |
| const excludes = { | |
| '_eth': '_eth', | |
| 'abi': 'abi', | |
| 'allEvents': 'allEvents', | |
| 'to': 'to', | |
| 'value': 'value', | |
| 'blockNumber': 'blockNumber', | |
| 'address': 'address', | |
| 'transactionHash': 'transactionHash', |
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 categorizeContractProps(params) { | |
| const hashNames = { | |
| 'hash': 'hash', | |
| 'blockHash': 'blockHash', | |
| 'input': 'input', | |
| 'from': 'from', | |
| } | |
| if (hashNames[params.key]) { | |
| return params.hashList |
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 createPropsContainers(panel, callback) { | |
| document.getElementById('contractFunction').appendChild(panel) | |
| const propsList = createPanelContainer('props') | |
| const hashList = createPanelContainer('hashes') | |
| const functionList = createPanelContainer() | |
| const banner = '<H3><strong>Contract Functions: </strong></H3>' | |
| functionList.innerHTML = banner | |
| panel.append(propsList) | |
| panel.append(hashList) |
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 createContract(contract, panel) { | |
| const propHandler = lists => props => { | |
| if(!filterProps(props[0])) { | |
| const container = categorizeContractProps({ | |
| key: props[0], | |
| value: props[1], | |
| ...lists | |
| }) | |
| container.append(createContractElement(props, container)) |
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> |
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 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 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, |