mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 18:00:18 +01:00
e61745a821
* eslint: Enable no-var rule * yarn lint --fix
35 lines
804 B
JavaScript
35 lines
804 B
JavaScript
/* eslint no-undef: 0 */
|
|
|
|
const json = methods
|
|
|
|
web3.currentProvider.enable().then(() => {
|
|
|
|
Object.keys(json).forEach(methodGroupKey => {
|
|
|
|
console.log(methodGroupKey)
|
|
const methodGroup = json[methodGroupKey]
|
|
console.log(methodGroup)
|
|
Object.keys(methodGroup).forEach(methodKey => {
|
|
|
|
const methodButton = document.getElementById(methodKey)
|
|
methodButton.addEventListener('click', function () {
|
|
|
|
window.ethereum.sendAsync({
|
|
method: methodKey,
|
|
params: methodGroup[methodKey][1],
|
|
}, function (err, result) {
|
|
if (err) {
|
|
console.log(err)
|
|
console.log(methodKey)
|
|
} else {
|
|
document.getElementById('results').innerHTML = JSON.stringify(result)
|
|
}
|
|
})
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
})
|
|
|