2019-04-16 19:59:11 +02:00
|
|
|
/* eslint no-undef: 0 */
|
|
|
|
|
2019-12-03 15:52:01 +01:00
|
|
|
const json = methods
|
2019-04-16 19:59:11 +02:00
|
|
|
|
|
|
|
web3.currentProvider.enable().then(() => {
|
|
|
|
|
2020-02-15 21:34:12 +01:00
|
|
|
Object.keys(json).forEach((methodGroupKey) => {
|
2019-04-16 19:59:11 +02:00
|
|
|
|
|
|
|
console.log(methodGroupKey)
|
|
|
|
const methodGroup = json[methodGroupKey]
|
|
|
|
console.log(methodGroup)
|
2020-02-15 21:34:12 +01:00
|
|
|
Object.keys(methodGroup).forEach((methodKey) => {
|
2019-04-16 19:59:11 +02:00
|
|
|
|
|
|
|
const methodButton = document.getElementById(methodKey)
|
2020-02-11 17:51:13 +01:00
|
|
|
methodButton.addEventListener('click', () => {
|
2019-04-16 19:59:11 +02:00
|
|
|
|
|
|
|
window.ethereum.sendAsync({
|
|
|
|
method: methodKey,
|
|
|
|
params: methodGroup[methodKey][1],
|
2020-02-11 17:51:13 +01:00
|
|
|
}, (err, result) => {
|
2019-04-16 19:59:11 +02:00
|
|
|
if (err) {
|
|
|
|
console.log(err)
|
|
|
|
console.log(methodKey)
|
|
|
|
} else {
|
|
|
|
document.getElementById('results').innerHTML = JSON.stringify(result)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|
2019-07-31 22:17:11 +02:00
|
|
|
|
2019-04-16 19:59:11 +02:00
|
|
|
})
|
2019-07-31 22:17:11 +02:00
|
|
|
})
|
2019-04-16 19:59:11 +02:00
|
|
|
|