import { rpc , tx , u , wallet } from "@cityofzion/neon-core" ; import { ManagedApiBasicConfig } from "./types" ; param obj param props export function checkProperty < T extends object , K extends keyof T > ( obj , ... props ) { for ( const prop of props ) { if ( ! obj . hasOwnProperty ( prop ) || obj [ prop ] === null || obj [ prop ] === undefined ) { throw new ReferenceError ( `Property not found: ${ prop }` ) ; } } } param config return export async function modifyTransactionForEmptyTransaction < U extends tx . BaseTransaction , T extends ManagedApiBasicConfig < U > > ( config ) { if ( config . tx ! . inputs . length === 0 && config . tx ! . outputs . length === 0 ) { config . tx ! . addAttribute ( tx . TxAttrUsage . Script , u . reverseHex ( wallet . getScriptHashFromAddress ( config . account ! . address ) ) ) ; config . tx ! . addRemark ( Date . now ( ) . toString ( ) + u . ab2hexstring ( u . generateRandomArray ( 4 ) ) ) ; } return config ; } const sensitiveFields = [ "privateKey" ] ; param config return export function extractDump < T > ( config ) { const dump = Object . assign ( { } , config ) ; for ( const key of Object . keys ( config ) ) { if ( sensitiveFields . indexOf ( key ) >= 0 ) { delete ( dump as any ) [ key ] ; } } return dump ; } param url param smartContractScriptHash return export async function getVerificationSignatureForSmartContract ( url , smartContractScriptHash ) { const contractState = await rpc . Query . getContractState ( smartContractScriptHash ) . execute ( url ) ; const { parameters } = contractState . result ; const witness = new tx . Witness ( { invocationScript : "00" . repeat ( parameters . length ) , verificationScript : "" , } ) ; witness . scriptHash = smartContractScriptHash ; return witness ; }