@@ -11,10 +11,14 @@ import {
11
11
UInt32 ,
12
12
Transaction ,
13
13
} from "o1js" ;
14
- import { ReturnType } from "@proto-kit/protocol" ;
14
+ import {
15
+ ACTIONS_EMPTY_HASH ,
16
+ MINA_EVENT_PREFIXES ,
17
+ ReturnType ,
18
+ } from "@proto-kit/protocol" ;
15
19
import { match } from "ts-pattern" ;
16
20
import { inject , injectable } from "tsyringe" ;
17
- import { noop } from "@proto-kit/common" ;
21
+ import { hashWithPrefix , noop , range } from "@proto-kit/common" ;
18
22
19
23
import { distinctByPredicate } from "../../helpers/utils" ;
20
24
import type { MinaBaseLayer } from "../../protocol/baselayer/MinaBaseLayer" ;
@@ -277,13 +281,32 @@ export class MinaTransactionSimulator {
277
281
} ) . verificationKey = update . verificationKey . value ;
278
282
}
279
283
284
+ this . applyZkApp ( account , au . body ) ;
285
+ }
286
+
287
+ private applyZkApp (
288
+ account : Account ,
289
+ { update, actions } : AccountUpdate [ "body" ]
290
+ ) {
280
291
if ( account . zkapp !== undefined ) {
281
292
const { appState } = update ;
282
293
for ( let i = 0 ; i < 8 ; i ++ ) {
283
294
if ( appState [ i ] . isSome . toBoolean ( ) ) {
284
295
account . zkapp . appState [ i ] = appState [ i ] . value ;
285
296
}
286
297
}
298
+
299
+ if ( actions . data . length > 0 ) {
300
+ // We don't care about the correct historical array, so we just
301
+ // populate the full array with the current value
302
+ const previousActionState =
303
+ account . zkapp . actionState . at ( 0 ) ?? ACTIONS_EMPTY_HASH ;
304
+ const newActionsHash = hashWithPrefix (
305
+ MINA_EVENT_PREFIXES . sequenceEvents ,
306
+ [ previousActionState , actions . hash ]
307
+ ) ;
308
+ account . zkapp . actionState = range ( 0 , 5 ) . map ( ( ) => newActionsHash ) ;
309
+ }
287
310
}
288
311
}
289
312
}
0 commit comments