@@ -371,37 +371,39 @@ pub fn proposerLookahead(self: *const BeaconStateView) !js.Uint32Array {
371371
372372// pub fn BeaconStateView_getShufflingAtEpoch
373373
374- pub fn previousDecisionRoot ( self : * const BeaconStateView ) ! js.Uint8Array {
374+ fn rootToHexString ( root : * const [ 32 ] u8 ) ! js.String {
375375 const env = js .env ();
376+ var hex_buf : [66 ]u8 = undefined ;
377+ try @import ("hex" ).rootIntoHex (& hex_buf , root );
378+ return js_types .wrap (js .String , try env .createStringUtf8 (& hex_buf ));
379+ }
380+
381+ pub fn previousDecisionRoot (self : * const BeaconStateView ) ! js.String {
376382 const cached_state = try self .requireState ();
377383 const root = cached_state .previousDecisionRoot ();
378- return js_types . wrap ( js . Uint8Array , try sszValueToNapiValue ( env , ct . primitive . Root , & root ) );
384+ return rootToHexString ( & root );
379385}
380386
381- pub fn currentDecisionRoot (self : * const BeaconStateView ) ! js.Uint8Array {
382- const env = js .env ();
387+ pub fn currentDecisionRoot (self : * const BeaconStateView ) ! js.String {
383388 const cached_state = try self .requireState ();
384389 const root = cached_state .currentDecisionRoot ();
385- return js_types . wrap ( js . Uint8Array , try sszValueToNapiValue ( env , ct . primitive . Root , & root ) );
390+ return rootToHexString ( & root );
386391}
387392
388393/// Get the next decision root for the state.
389- pub fn nextDecisionRoot (self : * const BeaconStateView ) ! js.Uint8Array {
390- const env = js .env ();
394+ pub fn nextDecisionRoot (self : * const BeaconStateView ) ! js.String {
391395 const cached_state = try self .requireState ();
392396 const root = cached_state .nextDecisionRoot ();
393- return js_types . wrap ( js . Uint8Array , try sszValueToNapiValue ( env , ct . primitive . Root , & root ) );
397+ return rootToHexString ( & root );
394398}
395399
396400/// Get the shuffling decision root for a given epoch.
397- pub fn getShufflingDecisionRoot (self : * const BeaconStateView , epoch_arg : js.Number ) ! js.Uint8Array {
398- const env = js .env ();
401+ pub fn getShufflingDecisionRoot (self : * const BeaconStateView , epoch_arg : js.Number ) ! js.String {
399402 const cached_state = try self .requireState ();
400- const epoch_value : u64 = @intCast (try epoch_arg .toI64 ());
401- const root = st .calculateShufflingDecisionRoot (cached_state .state , epoch_value ) catch {
402- return throwNullAs (js .Uint8Array , "STATE_ERROR" , "Failed to calculate shuffling decision root" );
403+ const root = st .calculateShufflingDecisionRoot (cached_state .state , try epoch_arg .toU32 ()) catch {
404+ return throwNullAs (js .String , "STATE_ERROR" , "Failed to calculate shuffling decision root" );
403405 };
404- return js_types . wrap ( js . Uint8Array , try sszValueToNapiValue ( env , ct . primitive . Root , & root ) );
406+ return rootToHexString ( & root );
405407}
406408
407409pub fn previousProposers (self : * const BeaconStateView ) ! ? js.Array {
0 commit comments