@@ -271,12 +271,120 @@ oracle
271271 const receipt = await tx . wait ( ) ;
272272
273273 if ( receipt . status === 1 ) {
274- logger . log ( '✅ Hash submitted successfully!' ) ;
274+ logger . log ( 'Hash submitted successfully!' ) ;
275275 logger . log ( 'Transaction confirmed in block:' , receipt . blockNumber ) ;
276276 } else {
277- logger . error ( '❌ Transaction failed' ) ;
277+ logger . error ( 'Transaction failed' ) ;
278278 }
279279 } catch ( error ) {
280280 logger . error ( 'Failed to submit hash:' , error ) ;
281281 }
282282 } ) ;
283+
284+ oracle
285+ . command ( 'submit-data' )
286+ . description ( 'Submit Exit Request Data' )
287+ . option (
288+ '--data <data>' ,
289+ 'Exit requests data in format: moduleId,nodeOpId,valIndex,pubkey;moduleId,nodeOpId,valIndex,pubkey' ,
290+ )
291+ . option ( '--format <format>' , 'Data format specifier' , '1' )
292+ . action ( async ( options ) => {
293+ const { data, format } = options ;
294+
295+ if ( ! data ) {
296+ logger . error ( '--data parameter is required' ) ;
297+ logger . log ( 'Expected format: moduleId,nodeOpId,valIndex,pubkey;moduleId,nodeOpId,valIndex,pubkey' ) ;
298+ logger . log ( 'Example: 1,15,12345,0x...pubkey1;2,22,54321,0x...pubkey2' ) ;
299+ return ;
300+ }
301+
302+ try {
303+ const requests = data
304+ . split ( ';' )
305+ . filter ( ( req : string ) => req . trim ( ) )
306+ . map ( ( request : string ) => {
307+ const parts = request . trim ( ) . split ( ',' ) ;
308+ if ( parts . length !== 4 ) {
309+ throw new Error ( `Invalid request format: ${ request } . Expected: moduleId,nodeOpId,valIndex,pubkey` ) ;
310+ }
311+
312+ const [ moduleId , nodeOpId , valIndex , pubkey ] = parts ;
313+
314+ if ( ! moduleId || ! nodeOpId || ! valIndex || ! pubkey ) {
315+ throw new Error ( `Invalid request format: ${ request } . All fields are required` ) ;
316+ }
317+
318+ if ( ! pubkey . startsWith ( '0x' ) || pubkey . length !== 98 ) {
319+ throw new Error ( `Invalid pubkey format: ${ pubkey } . Expected 0x-prefixed 48-byte hex string` ) ;
320+ }
321+
322+ return {
323+ moduleId : parseInt ( moduleId , 10 ) ,
324+ nodeOpId : parseInt ( nodeOpId , 10 ) ,
325+ valIndex : parseInt ( valIndex , 10 ) ,
326+ pubkey : pubkey . toLowerCase ( ) ,
327+ } ;
328+ } ) ;
329+
330+ if ( requests . length === 0 ) {
331+ logger . error ( 'No valid exit requests found in data' ) ;
332+ return ;
333+ }
334+
335+ logger . log ( `Parsed ${ requests . length } exit request(s):` ) ;
336+ requests . forEach ( ( req : { moduleId : number ; nodeOpId : number ; valIndex : number ; pubkey : string } , i : number ) => {
337+ logger . log (
338+ ` ${ i + 1 } . Module ${ req . moduleId } , Operator ${ req . nodeOpId } , Index ${ req . valIndex } , Pubkey ${ req . pubkey } ` ,
339+ ) ;
340+ } ) ;
341+
342+ const encodeExitRequestHex = ( {
343+ moduleId,
344+ nodeOpId,
345+ valIndex,
346+ pubkey,
347+ } : {
348+ moduleId : number ;
349+ nodeOpId : number ;
350+ valIndex : number ;
351+ pubkey : string ;
352+ } ) => {
353+ const pubkeyHex = pubkey . slice ( 2 ) ;
354+
355+ const moduleIdHex = moduleId . toString ( 16 ) . padStart ( 6 , '0' ) ; // 3 bytes
356+ const nodeOpIdHex = nodeOpId . toString ( 16 ) . padStart ( 10 , '0' ) ; // 5 bytes
357+ const valIndexHex = valIndex . toString ( 16 ) . padStart ( 16 , '0' ) ; // 8 bytes
358+
359+ return moduleIdHex + nodeOpIdHex + valIndexHex + pubkeyHex ;
360+ } ;
361+
362+ const encodedData = '0x' + requests . map ( encodeExitRequestHex ) . join ( '' ) ;
363+
364+ logger . log ( 'Encoded data:' , encodedData ) ;
365+ logger . log ( 'Data format:' , format ) ;
366+
367+ const exitRequest = {
368+ dataFormat : parseInt ( format , 10 ) ,
369+ data : encodedData ,
370+ } ;
371+
372+ logger . log ( 'Submitting exit requests data to VEB contract...' ) ;
373+ logger . log ( 'Contract address:' , exitBusOracleContract . target ) ;
374+
375+ const tx = await exitBusOracleContract . submitExitRequestsData ( exitRequest ) ;
376+ logger . log ( 'Transaction hash:' , tx . hash ) ;
377+
378+ logger . log ( 'Waiting for transaction confirmation...' ) ;
379+ const receipt = await tx . wait ( ) ;
380+
381+ if ( receipt . status === 1 ) {
382+ logger . log ( 'Exit requests data submitted successfully!' ) ;
383+ logger . log ( 'Transaction confirmed in block:' , receipt . blockNumber ) ;
384+ } else {
385+ logger . error ( 'Transaction failed' ) ;
386+ }
387+ } catch ( error ) {
388+ logger . error ( 'Failed to submit exit requests data:' , error ) ;
389+ }
390+ } ) ;
0 commit comments