@@ -30,13 +30,21 @@ process.on('SIGINT', _ => {
3030if ( ! fs . existsSync ( PROTOCOL_VERSIONS ) ) {
3131 throw Error ( 'Missing protocol versions file: ' + PROTOCOL_VERSIONS ) ;
3232}
33+ if ( ! semver . valid ( CURRENT_PROTOCOL_VERSION ) ) {
34+ throw Error ( "Wrong version format is specified in package.json" ) ;
35+ }
3336const VERSION_LIST = JSON . parse ( fs . readFileSync ( PROTOCOL_VERSIONS ) ) ;
34- if ( ! VERSION_LIST [ CURRENT_PROTOCOL_VERSION ] ) {
37+ const MAJOR_MINOR_VERSION =
38+ `${ semver . major ( CURRENT_PROTOCOL_VERSION ) } .${ semver . minor ( CURRENT_PROTOCOL_VERSION ) } ` ;
39+ if ( ! semver . valid ( semver . coerce ( MAJOR_MINOR_VERSION ) ) ) {
40+ throw Error ( "Given major and minor version does not correctly setup" ) ;
41+ }
42+ if ( ! VERSION_LIST [ MAJOR_MINOR_VERSION ] ) {
3543 throw Error ( "Current protocol version doesn't exist in the protocol versions file" ) ;
3644}
3745const minProtocolVersion =
38- VERSION_LIST [ CURRENT_PROTOCOL_VERSION ] . min || CURRENT_PROTOCOL_VERSION ;
39- const maxProtocolVersion = VERSION_LIST [ CURRENT_PROTOCOL_VERSION ] . max ;
46+ VERSION_LIST [ MAJOR_MINOR_VERSION ] . min || CURRENT_PROTOCOL_VERSION ;
47+ const maxProtocolVersion = VERSION_LIST [ MAJOR_MINOR_VERSION ] . max ;
4048
4149const app = express ( ) ;
4250app . use ( express . json ( ) ) ; // support json encoded bodies
@@ -293,21 +301,20 @@ app.get('/pending_nonce_tracker', (req, res, next) => {
293301
294302app . get ( '/get_transaction' , ( req , res , next ) => {
295303 const transactionInfo = node . tp . transactionTracker [ req . query . hash ] ;
296- let result = { } ;
297304 if ( transactionInfo ) {
298305 if ( transactionInfo . status === TransactionStatus . BLOCK_STATUS ) {
299306 const block = node . bc . getBlockByNumber ( transactionInfo . number ) ;
300307 const index = transactionInfo . index ;
301- Object . assign ( result , block . transactions [ index ] , { is_confirmed : true } ) ;
308+ transactionInfo . transaction = block . transactions [ index ] ;
302309 } else if ( transactionInfo . status === TransactionStatus . POOL_STATUS ) {
303310 const address = transactionInfo . address ;
304311 const index = transactionInfo . index ;
305- Object . assign ( result , node . tp . transactions [ address ] [ index ] , { is_confirmed : false } ) ;
312+ transactionInfo . transaction = node . tp . transactions [ address ] [ index ] ;
306313 }
307314 }
308315 res . status ( 200 )
309316 . set ( 'Content-Type' , 'application/json' )
310- . send ( { code : 0 , result} )
317+ . send ( { code : 0 , result : transactionInfo } )
311318 . end ( ) ;
312319} ) ;
313320
0 commit comments