import { logging , rpc , tx } from "@cityofzion/neon-core" ; import { checkProperty } from "./common" ; import { DoInvokeConfig , ManagedApiBasicConfig , SendAssetConfig , } from "./types" ; const log = logging . default ( "api" ) ; param { object } config return { Promise < object > } export async function sendTx < T extends ManagedApiBasicConfig < tx . BaseTransaction > > ( config ) { checkProperty ( config , "tx" , "url" ) ; const response = await rpc . Query . sendRawTransaction ( config . tx ! ) . execute ( config . url ! ) ; if ( response . result === true ) { response . txid = config . tx ! . hash ; } else { log . error ( `Transaction failed for ${ config . account . address }: ${ config . tx ! . serialize ( ) }` ) ; } return Object . assign ( config , { response } ) ; } export async function applyTxToBalance < T extends DoInvokeConfig | SendAssetConfig > ( config ) { if ( config . response && config . response . result && config . balance ) { config . balance . applyTx ( config . tx ! , false ) ; } return config ; }