Skip to content

Instantly share code, notes, and snippets.

@sogoiii
Created July 22, 2018 18:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sogoiii/245ed18ae8ed1213afaf0d2cdef21ed9 to your computer and use it in GitHub Desktop.
Save sogoiii/245ed18ae8ed1213afaf0d2cdef21ed9 to your computer and use it in GitHub Desktop.
Ethereum-to-graphQL source function
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