@@ -6,13 +6,15 @@ import {
66import {
77 Transaction as DBTransaction ,
88 TransactionExecutionResult as DBTransactionExecutionResult ,
9+ StateTransition as DBStateTransition ,
10+ StateTransitionBatch as DBStateTransitionBatch ,
911} from "@prisma/client" ;
1012import { Bool } from "o1js" ;
1113
1214import { ObjectMapper } from "../../../ObjectMapper" ;
1315
14- import { StateTransitionBatchArrayMapper } from "./StateTransitionMapper" ;
1516import { EventArrayMapper } from "./EventMapper" ;
17+ import { StateTransitionBatchArrayMapper } from "./StateTransitionMapper" ;
1618
1719@singleton ( )
1820@injectable ( )
@@ -50,41 +52,73 @@ export class TransactionExecutionResultMapper
5052 implements
5153 ObjectMapper <
5254 TransactionExecutionResult ,
53- [ Omit < DBTransactionExecutionResult , "blockHash" > , DBTransaction ]
55+ [
56+ Omit < DBTransactionExecutionResult , "blockHash" > ,
57+ DBTransaction ,
58+ [
59+ Omit <
60+ DBStateTransitionBatch ,
61+ "txExecutionResultId" | "id" | "blockId" | "blockResultId"
62+ > ,
63+ Omit < DBStateTransition , "batchId" | "id" > [ ] ,
64+ ] [ ] ,
65+ ]
5466 >
5567{
5668 public constructor (
5769 private readonly transactionMapper : TransactionMapper ,
58- private readonly stBatchMapper : StateTransitionBatchArrayMapper ,
59- private readonly eventArrayMapper : EventArrayMapper
70+ private readonly eventArrayMapper : EventArrayMapper ,
71+ private readonly stBatchArrayMapper : StateTransitionBatchArrayMapper
6072 ) { }
6173
6274 public mapIn (
63- input : [ Omit < DBTransactionExecutionResult , "blockHash" > , DBTransaction ]
75+ input : [
76+ Omit < DBTransactionExecutionResult , "blockHash" > ,
77+ DBTransaction ,
78+ [
79+ Omit <
80+ DBStateTransitionBatch ,
81+ "txExecutionResultId" | "id" | "blockId" | "blockResultId"
82+ > ,
83+ Omit < DBStateTransition , "batchId" | "id" > [ ] ,
84+ ] [ ] ,
85+ ]
6486 ) : TransactionExecutionResult {
6587 const executionResult = input [ 0 ] ;
88+ const stateTransitions = input [ 2 ] ;
6689 return {
6790 tx : this . transactionMapper . mapIn ( input [ 1 ] ) ,
6891 status : Bool ( executionResult . status ) ,
6992 statusMessage : executionResult . statusMessage ?? undefined ,
70- stateTransitions : this . stBatchMapper . mapIn (
71- executionResult . stateTransitions
72- ) ,
7393 events : this . eventArrayMapper . mapIn ( executionResult . events ) ,
94+ stateTransitions : this . stBatchArrayMapper . mapIn ( stateTransitions ) ,
7495 } ;
7596 }
7697
7798 mapOut (
7899 input : TransactionExecutionResult
79- ) : [ Omit < DBTransactionExecutionResult , "blockHash" > , DBTransaction ] {
100+ ) : [
101+ Omit < DBTransactionExecutionResult , "blockHash" > ,
102+ DBTransaction ,
103+ [
104+ Omit <
105+ DBStateTransitionBatch ,
106+ "txExecutionResultId" | "id" | "blockId" | "blockResultId"
107+ > ,
108+ Omit < DBStateTransition , "batchId" | "id" > [ ] ,
109+ ] [ ] ,
110+ ] {
80111 const tx = this . transactionMapper . mapOut ( input . tx ) ;
81112 const executionResult = {
82113 status : input . status . toBoolean ( ) ,
83114 statusMessage : input . statusMessage ?? null ,
84- stateTransitions : this . stBatchMapper . mapOut ( input . stateTransitions ) ,
85115 events : this . eventArrayMapper . mapOut ( input . events ) ,
86116 txHash : tx . hash ,
87117 } ;
88- return [ executionResult , tx ] ;
118+ const stateTransitions = this . stBatchArrayMapper . mapOut (
119+ input . stateTransitions
120+ ) ;
121+
122+ return [ executionResult , tx , stateTransitions ] ;
89123 }
90124}
0 commit comments