Created
July 22, 2018 18:30
-
-
Save sogoiii/245ed18ae8ed1213afaf0d2cdef21ed9 to your computer and use it in GitHub Desktop.
Ethereum-to-graphQL source function
This file contains 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
const sourceFn = ({ contract, method, outputMapper, isCall = true, options }) => { | |
return async function () { | |
try { | |
const instance = await contract.deployed() | |
const fn = (isCall) | |
? instance[method].call(...Object.values(arguments)) | |
: instance[method](...Object.values(arguments), options) | |
const data = await fn | |
return outputMapper(data) | |
} catch (e) { | |
console.log('Inside sourceFN error ------------------------ ') | |
console.log(e) | |
return new Error(e) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment