@@ -434,12 +434,56 @@ func (a *AccessAdapter) GetExecutionResultByID(_ context.Context, _ flowgo.Ident
434434 return nil , nil
435435}
436436
437- func (a * AccessAdapter ) GetSystemTransaction (_ context.Context , _ flowgo.Identifier , _ flowgo.Identifier ) (* flowgo.TransactionBody , error ) {
438- return nil , nil
437+ func (a * AccessAdapter ) GetSystemTransaction (_ context.Context , txID flowgo.Identifier , blockID flowgo.Identifier ) (* flowgo.TransactionBody , error ) {
438+ tx , err := a .emulator .GetSystemTransaction (txID , blockID )
439+ if err != nil {
440+ return nil , convertError (err , codes .NotFound )
441+ }
442+
443+ return tx , nil
439444}
440445
441- func (a * AccessAdapter ) GetSystemTransactionResult (_ context.Context , _ flowgo.Identifier , _ flowgo.Identifier , _ entities.EventEncodingVersion ) (* accessmodel.TransactionResult , error ) {
442- return nil , nil
446+ func (a * AccessAdapter ) GetSystemTransactionResult (_ context.Context , txID flowgo.Identifier , blockID flowgo.Identifier , encodingVersion entities.EventEncodingVersion ) (* accessmodel.TransactionResult , error ) {
447+ result , err := a .emulator .GetSystemTransactionResult (txID , blockID )
448+ if err != nil {
449+ return nil , convertError (err , codes .NotFound )
450+ }
451+
452+ // Convert CCF events to JSON events, else return CCF encoded version
453+ if encodingVersion == entities .EventEncodingVersion_JSON_CDC_V0 {
454+ result .Events , err = ConvertCCFEventsToJsonEvents (result .Events )
455+ if err != nil {
456+ return nil , status .Error (codes .Internal , fmt .Sprintf ("failed to convert events: %v" , err ))
457+ }
458+ }
459+
460+ return result , nil
461+ }
462+
463+ func (a * AccessAdapter ) GetScheduledTransaction (_ context.Context , scheduledTxID uint64 ) (* flowgo.TransactionBody , error ) {
464+ tx , err := a .emulator .GetScheduledTransaction (scheduledTxID )
465+ if err != nil {
466+ return nil , convertError (err , codes .NotFound )
467+ }
468+
469+ return tx , nil
470+ }
471+
472+ func (a * AccessAdapter ) GetScheduledTransactionResult (_ context.Context , scheduledTxID uint64 , encodingVersion entities.EventEncodingVersion ) (* accessmodel.TransactionResult , error ) {
473+ result , err := a .emulator .GetScheduledTransactionResult (scheduledTxID )
474+ if err != nil {
475+ return nil , convertError (err , codes .NotFound )
476+ }
477+
478+ // Convert CCF events to JSON events, else return CCF encoded version
479+ if encodingVersion == entities .EventEncodingVersion_JSON_CDC_V0 {
480+ result .Events , err = ConvertCCFEventsToJsonEvents (result .Events )
481+ if err != nil {
482+ return nil , status .Error (codes .Internal , fmt .Sprintf ("failed to convert events: %v" , err ))
483+ }
484+ }
485+
486+ return result , nil
443487}
444488
445489func (a * AccessAdapter ) GetAccountBalanceAtLatestBlock (_ context.Context , address flowgo.Address ) (uint64 , error ) {
@@ -654,7 +698,7 @@ func (a *AccessAdapter) subscribeBlocksFromStartBlockID(ctx context.Context, sta
654698 if err != nil {
655699 return subscription .NewFailedSubscription (err , "could not get block by ID" )
656700 }
657-
701+
658702 emulatorBlockchain , ok := a .emulator .(* emulator.Blockchain )
659703 if ! ok {
660704 return subscription .NewFailedSubscription (fmt .Errorf ("emulator is not a Blockchain" ), "invalid emulator type" )
@@ -681,7 +725,7 @@ func (a *AccessAdapter) subscribeBlocksFromLatest(ctx context.Context, getData s
681725 if err != nil {
682726 return subscription .NewFailedSubscription (err , "could not get latest block" )
683727 }
684-
728+
685729 emulatorBlockchain , ok := a .emulator .(* emulator.Blockchain )
686730 if ! ok {
687731 return subscription .NewFailedSubscription (fmt .Errorf ("emulator is not a Blockchain" ), "invalid emulator type" )
@@ -787,7 +831,7 @@ func (a *AccessAdapter) SubscribeTransactionStatuses(ctx context.Context, txID f
787831 if err != nil {
788832 return subscription .NewFailedSubscription (err , "failed to lookup latest block" )
789833 }
790-
834+
791835 return a .createTransactionSubscription (ctx , txID , latestBlock .ID (), flowgo .ZeroID , requiredEventEncodingVersion )
792836}
793837
@@ -800,7 +844,7 @@ func (a *AccessAdapter) SubscribeTransactionStatusesFromStartHeight(ctx context.
800844 if err != nil {
801845 return subscription .NewFailedSubscription (err , "failed to get start block" )
802846 }
803-
847+
804848 return a .createTransactionSubscription (ctx , txID , block .ID (), flowgo .ZeroID , requiredEventEncodingVersion )
805849}
806850
@@ -809,7 +853,7 @@ func (a *AccessAdapter) SubscribeTransactionStatusesFromLatest(ctx context.Conte
809853 if err != nil {
810854 return subscription .NewFailedSubscription (err , "failed to lookup latest block" )
811855 }
812-
856+
813857 return a .createTransactionSubscription (ctx , txID , latestBlock .ID (), flowgo .ZeroID , requiredEventEncodingVersion )
814858}
815859
@@ -857,7 +901,7 @@ func (a *AccessAdapter) getTransactionStatusResponse(
857901 requiredEventEncodingVersion entities.EventEncodingVersion ,
858902) subscription.GetDataByHeightFunc {
859903 lastStatus := flowgo .TransactionStatusUnknown
860-
904+
861905 return func (ctx context.Context , height uint64 ) (interface {}, error ) {
862906 // Check if block is ready
863907 if err := a .validateHeight (height , flowgo .BlockStatusSealed ); err != nil {
@@ -880,7 +924,7 @@ func (a *AccessAdapter) getTransactionStatusResponse(
880924 TransactionID : txID ,
881925 }}, nil
882926 }
883-
927+
884928 // Otherwise, transaction is still pending/unknown
885929 if lastStatus == flowgo .TransactionStatusUnknown {
886930 return nil , nil // Don't send duplicate unknown status
@@ -928,14 +972,14 @@ func (a *AccessAdapter) generateTransactionStatusUpdates(
928972 Status : status ,
929973 TransactionID : txResult .TransactionID ,
930974 }
931-
975+
932976 // Add block info for finalized and later statuses
933977 if status >= flowgo .TransactionStatusFinalized {
934978 result .BlockID = txResult .BlockID
935979 result .BlockHeight = txResult .BlockHeight
936980 result .CollectionID = txResult .CollectionID
937981 }
938-
982+
939983 // Add execution details for executed and sealed statuses
940984 if status >= flowgo .TransactionStatusExecuted {
941985 result .Events = txResult .Events
@@ -961,10 +1005,3 @@ func ConvertCCFEventsToJsonEvents(events []flowgo.Event) ([]flowgo.Event, error)
9611005
9621006 return converted , nil
9631007}
964-
965- func (a * AccessAdapter ) GetScheduledTransaction (_ context.Context , _ uint64 ) (* flowgo.TransactionBody , error ) {
966- return nil , nil
967- }
968- func (a * AccessAdapter ) GetScheduledTransactionResult (_ context.Context , _ uint64 , _ entities.EventEncodingVersion ) (* accessmodel.TransactionResult , error ) {
969- return nil , nil
970- }
0 commit comments