Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function createContractElement(contractFunc, contractName, container) {
- switch (typeof contractFunc[1]) {
- case 'function':
- return createContractFunction(contractFunc, container)
- default:
- return createContractPropType(contractFunc, 'P')
- }
- }
- function createContractFunction(contractFunc, container) {
- const btn = document.createElement('BUTTON')
- btn.innerText = contractFunc[0]
- btn.className = 'mui-btn mui-btn--primary mui-col-md-2'
- btn.addEventListener('click', () => {
- const div = document.createElement('DIV')
- div.className = 'mui-col-md-3'
- div.innerHTML = `
- <strong>Return Value:</strong> "${contractFunc[1]()}"
- `
- container.appendChild(div)
- })
- return btn
- }
- function createContractPropType(contractProp, element) {
- const propName = contractProp[0]
- const hashesNames = {
- 'hash': 'hash',
- 'blockHash': 'blockHash',
- 'input': 'input',
- 'from': 'from',
- }
- if (hashesNames[propName]) {
- return renderPropType(propName, contractProp[1], 'LI', '')
- } else {
- return renderPropType(propName, contractProp[1], 'P', 'mui-col-md-2 mui-panel')
- }
- }
Add Comment
Please, Sign In to add comment