import { Context } from "../context" ; import { Web3Transaction } from "../web3/client" ; export const EthereumTransaction = { block ( parent , args , ctx , info ) { return ctx . loaders . web3 . block . load ( { hash : parent . blockHash , network : parent . network } ) ; } , from ( parent , args , ctx , info ) { if ( ! parent . from ) { return null ; } return ctx . loaders . web3 . address . load ( { address : parent . from , network : parent . network } ) ; } , to ( parent , args , ctx , info ) { if ( ! parent . to ) { return null ; } return ctx . loaders . web3 . address . load ( { address : parent . to , network : parent . network } ) ; } , async gasUsed ( parent , args , ctx , info ) { const receipt = await ctx . loaders . web3 . transactionReceipt . load ( { hash : parent . hash , network : parent . network } ) ; return receipt ? receipt . gasUsed : null ; } , async cumulativeGasUsed ( parent , args , ctx , info ) { const receipt = await ctx . loaders . web3 . transactionReceipt . load ( { hash : parent . hash , network : parent . network } ) ; return receipt ? receipt . cumulativeGasUsed : null ; } , async contractAddress ( parent , args , ctx , info ) { const receipt = await ctx . loaders . web3 . transactionReceipt . load ( { hash : parent . hash , network : parent . network } ) ; return receipt && receipt . contractAddress ? ctx . loaders . web3 . address . load ( { address : receipt . contractAddress , network : parent . network } ) : null ; } , async status ( parent , args , ctx , info ) { const receipt = await ctx . loaders . web3 . transactionReceipt . load ( { hash : parent . hash , network : parent . network } ) ; return receipt ? receipt . status : null ; } , async logs ( parent , args , ctx ) { const receipt = await ctx . loaders . web3 . transactionReceipt . load ( { hash : parent . hash , network : parent . network } ) ; return receipt ? receipt . logs : [ ] ; } } ;