import { Address } from '../../crypto/address' ; export function sendHeartBeat ( ) { const param = { Action : 'heartbeat' , Version : 'V1.0.0' } ; return param ; } export function sendSubscribe ( subscribeEvent = false , subscribeJsonBlock = false , subscribeRawBlock = false , subscribeBlockTxHashes = false ) { const param = { Action : 'subscribe' , Version : '1.0.0' , SubscribeEvent : subscribeEvent , SubscribeJsonBlock : subscribeJsonBlock , SubscribeRawBlock : subscribeRawBlock , SubscribeBlockTxHashs : subscribeBlockTxHashes } ; return param ; } export function sendRawTransaction ( hexData , preExec = false ) { let param = { Action : 'sendrawtransaction' , Version : '1.0.0' , Data : hexData } ; if ( preExec ) { param = Object . assign ( param , { PreExec : '1' } ) ; } return param ; } export function getRawTransaction ( txHash ) { const param = { Action : 'gettransaction' , Version : '1.0.0' , Hash : txHash , Raw : '1' } ; return param ; } export function getRawTransactionJson ( txHash ) { const param = { Action : 'gettransaction' , Version : '1.0.0' , Hash : txHash , Raw : '0' } ; return param ; } export function getNodeCount ( ) { const param = { Action : 'getconnectioncount' , Version : '1.0.0' } ; return param ; } export function getBlockHeight ( ) { const param = { Action : 'getblockheight' , Version : '1.0.0' } ; return param ; } export function getBlock ( value ) { let param = { } ; if ( typeof value === 'number' ) { param = { Action : 'getblockbyheight' , Version : '1.0.0' , Height : value , Raw : '1' } ; } else if ( typeof value === 'string' ) { param = { Action : 'getblockbyhash' , Version : '1.0.0' , Hash : value , Raw : '1' } ; } return param ; } export function getBlockJson ( value ) { let param = { } ; if ( typeof value === 'number' ) { param = { Action : 'getblockbyheight' , Version : '1.0.0' , Height : value } ; } else if ( typeof value === 'string' ) { param = { Action : 'getblockbyhash' , Version : '1.0.0' , Hash : value } ; } return param ; } export function getBalance ( address ) { const param = { Action : 'getbalance' , Version : '1.0.0' , Addr : address . toBase58 ( ) } ; return param ; } export function getBalanceV2 ( address ) { const param = { Action : 'getbalancev2' , Version : '1.0.0' , Addr : address . toBase58 ( ) } ; return param ; } export function getUnboundOng ( address ) { const param = { Action : 'getunboundong' , Version : '1.0.0' , Addr : address . toBase58 ( ) } ; return param ; } export function getContract ( hash ) { const param = { Action : 'getcontract' , Version : '1.0.0' , Hash : hash , Raw : '1' } ; return param ; } export function getContractJson ( hash ) { const param = { Action : 'getcontract' , Version : '1.0.0' , Hash : hash , Raw : '0' } ; return param ; } export function getSmartCodeEvent ( value ) { let param = { } ; if ( typeof value === 'number' ) { param = { Action : 'getsmartcodeeventbyheight' , Version : '1.0.0' , Height : value } ; } else if ( typeof value === 'string' ) { param = { Action : 'getsmartcodeeventbyhash' , Version : '1.0.0' , Hash : value } ; } return param ; } export function getBlockHeightByTxHash ( hash ) { const param = { Action : 'getblockheightbytxhash' , Version : '1.0.0' , Hash : hash } ; return param ; } export function getStorage ( codeHash , key ) { const param = { Action : 'getstorage' , Version : '1.0.0' , Hash : codeHash , Key : key } ; return param ; } export function getMerkleProof ( hash ) { const param = { Action : 'getmerkleproof' , Version : '1.0.0' , Hash : hash } ; return param ; } export function getAllowance ( asset , from , to ) { const param = { Action : 'getallowance' , Version : '1.0.0' , Asset : asset , From : from . toBase58 ( ) , To : to . toBase58 ( ) } ; return param ; } export function getAllowanceV2 ( asset , from , to ) { const param = { Action : 'getallowancev2' , Version : '1.0.0' , Asset : asset , From : from . toBase58 ( ) , To : to . toBase58 ( ) } ; return param ; } export function getBlockHash ( value ) { const param = { Action : 'getblockhash' , Version : '1.0.0' , Height : value } ; return param ; } export function getBlockTxsByHeight ( value ) { const param = { Action : 'getblocktxsbyheight' , Version : '1.0.0' , Height : value } ; return param ; } export function getGasPrice ( ) { const param = { Action : 'getgasprice' , Version : '1.0.0' } ; return param ; } export function getGrantOng ( address ) { const param = { Action : 'getgrantong' , Version : '1.0.0' , Addr : address . toBase58 ( ) } ; return param ; } export function getMempoolTxCount ( ) { const param = { Action : 'getmempooltxcount' , Version : '1.0.0' } ; return param ; } export function getMempoolTxState ( txHash ) { const param = { Action : 'getmempooltxstate' , Version : '1.0.0' , Hash : txHash } ; return param ; } export function getVersion ( ) { const param = { Action : 'getversion' , Version : '1.0.0' } ; return param ; } export function getNetworkId ( ) { const param = { Action : 'getnetworkid' , Version : '1.0.0' } ; return param ; }