import { Context } from "../context" ; import { web3 , Web3Address } from "../web3/client" ; import { fetchTransactions } from "../web3/etherscan" ; export const EthereumAddress = { display ( parent ) { return parent . display || parent . address ; } , hex ( parent ) { return parent . address ; } , balance ( parent , args , ctx ) { return ctx . loaders . web3 . balance . load ( parent ) ; } , transactionCount ( parent , args , ctx ) { return ctx . loaders . web3 . transactionCount . load ( parent ) ; } , async transactions ( parent , args , ctx ) { const txs = await fetchTransactions ( { address : parent . address , network : parent . network , ... args } ) ; return ctx . loaders . web3 . transaction . loadMany ( txs . map ( hash => ( { hash , network : parent . network } ) ) ) ; } , contract ( parent , args , ctx ) { return ctx . loaders . web3 . contract . load ( { address : parent . address , interface : args . interface , network : parent . network } ) ; } , tokenContract ( parent , args , ctx ) { const iface = args . interface || { } ; iface . standards = iface . standards || [ ] ; iface . standards . push ( "ERC_20" ) ; iface . standards . push ( "ERC_721" ) ; return ctx . loaders . web3 . contract . load ( { address : parent . address , interface : iface , network : parent . network || "MAINNET" } ) ; } , identityContract ( parent , args , ctx ) { const iface = args . interface || { } ; iface . standards = iface . standards || [ ] ; iface . standards . push ( "ERC_725" ) ; return ctx . loaders . web3 . contract . load ( { address : parent . address , interface : iface , network : parent . network || "MAINNET" } ) ; } } ;