1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-27 04:46:10 +01:00
metamask-extension/test/web3/web3.js

35 lines
796 B
JavaScript
Raw Normal View History

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