packageDocumentation module hidden import { ChainType , ChainID , defaultConfig } from '@harmony-js/utils' ; import { Harmony } from './harmony' ; export interface HarmonyConfig { chainUrl ? : string ; chainType : ChainType ; chainId : ChainID ; shardID ? : number ; } export function createWeb3 ( _web3 ) { const url = _web3 . currentProvider . url ; const harmony = new Harmony ( url , { chainId : defaultConfig . Default . Chain_ID , chainType : defaultConfig . Default . Chain_Type , chainUrl : defaultConfig . Default . Chain_URL , } ) ; _web3 . setProvider ( harmony . messenger . provider ) ; _web3 . messenger = harmony . messenger ; _web3 . eth . getRpcResult = harmony . blockchain . getRpcResult ; const { blockchain } = harmony ; _web3 . eth . getBlockNumber = ( ) => blockchain . getBlockByNumber ; _web3 . eth . getBalance = ( address , blockNumber ? ) => blockchain . getBalance ( { address , blockNumber } ) ; _web3 . eth . getBlockByHash = ( blockHash , returnObject ? ) => blockchain . getBlockByHash ( { blockHash , returnObject } ) ; _web3 . eth . getBlockByNumber = ( blockNumber , returnObject ? ) => blockchain . getBlockByNumber ( { blockNumber , returnObject } ) ; _web3 . eth . getBlockTransactionCountByHash = ( blockHash ) => blockchain . getBlockTransactionCountByHash ( { blockHash } ) ; _web3 . eth . getBlockTransactionCountByNumber = ( blockNumber ) => blockchain . getBlockTransactionCountByNumber ( { blockNumber } ) ; _web3 . eth . getTransactionByBlockHashAndIndex = ( blockHash , index ) => blockchain . getTransactionByBlockHashAndIndex ( { blockHash , index } ) ; _web3 . eth . getTransactionByBlockNumberAndIndex = ( blockNumber , index ) => blockchain . getTransactionByBlockNumberAndIndex ( { blockNumber , index } ) ; _web3 . eth . getTransactionByHash = ( txnHash ) => blockchain . getTransactionByHash ( { txnHash } ) ; _web3 . eth . getTransactionReceipt = ( txnHash ) => blockchain . getTransactionReceipt ( { txnHash } ) ; _web3 . eth . getCode = ( address , blockNumber ? ) => blockchain . getCode ( { address , blockNumber } ) ; _web3 . eth . net_peerCount = ( ) => blockchain . net_peerCount ( ) ; _web3 . eth . net_version = ( ) => blockchain . net_version ( ) ; _web3 . eth . getProtocolVersion = ( ) => blockchain . getProtocolVersion ( ) ; _web3 . eth . getStorageAt = ( address , position , blockNumber ) => blockchain . getStorageAt ( { address , position , blockNumber } ) ; _web3 . eth . getTransactionCount = ( address , blockNumber ) => blockchain . getTransactionCount ( { address , blockNumber } ) ; _web3 . eth . estimateGas = ( to , data ) => blockchain . estimateGas ( { to , data } ) ; _web3 . eth . gasPrice = ( ) => blockchain . gasPrice ( ) ; _web3 . eth . call = ( payload , blockNumber ) => blockchain . call ( { payload , blockNumber } ) ; _web3 . eth . newPendingTransactions = ( ) => blockchain . newPendingTransactions ( ) ; _web3 . eth . newBlockHeaders = ( ) => blockchain . newBlockHeaders ( ) ; _web3 . eth . syncing = ( ) => blockchain . syncing ( ) ; _web3 . eth . logs = ( options ) => blockchain . logs ( options ) ; _web3 . eth . subscribe = harmony . messenger . subscribe ; _web3 . accounts = harmony . wallet . accounts ; _web3 . eth . accounts . create = harmony . wallet . createAccount ; _web3 . eth . accounts . privateKeyToAccount = harmony . wallet . addByPrivateKey ; _web3 . eth . accounts . encrypt = async ( privateKey , password ) => { const newAcc = new harmony . Modules . Account ( privateKey , harmony . messenger ) ; const result = await newAcc . toFile ( password ) ; return result ; } ; _web3 . eth . accounts . decrypt = async ( keystoreJsonV3 , password ) => { const newAcc = new harmony . Modules . Account ( ) ; const result = await newAcc . fromFile ( JSON . stringify ( keystoreJsonV3 ) , password ) ; return result ; } ; _web3 . eth . accounts . signTransaction = harmony . wallet . signTransaction ; _web3 . eth . recoverTransaction = harmony . transactions . recover ; _web3 . eth . Contract = harmony . contracts . createContract ; _web3 . utils = { ... _web3 . utils , ... harmony . utils , ... harmony . crypto } ; }