@@ -13,6 +13,7 @@ import { ContractInteraction, HandlerApi, InteractionResult } from './HandlerExe
13
13
import { TagsParser } from './TagsParser' ;
14
14
import { VrfPluginFunctions } from '../../WarpPlugin' ;
15
15
import { BasicSortKeyCache } from '../../../cache/BasicSortKeyCache' ;
16
+ import { InnerWritesEvaluator } from '../../../contract/InnerWritesEvaluator' ;
16
17
17
18
type EvaluationProgressInput = {
18
19
contractTxId : string ;
@@ -239,22 +240,42 @@ export abstract class DefaultStateEvaluator implements StateEvaluator {
239
240
240
241
this . logger . debug ( `${ indent ( depth ) } Interaction evaluation` , singleInteractionBenchmark . elapsed ( ) ) ;
241
242
243
+ if ( result . type === 'exception' && ignoreExceptions !== true ) {
244
+ throw new Error ( `Exception while processing ${ JSON . stringify ( interaction ) } :\n${ result . errorMessage } ` ) ;
245
+ }
246
+
247
+ if ( internalWrites && contract . isRoot ( ) && result . type === 'ok' ) {
248
+ const innerWritesEvaluator = new InnerWritesEvaluator ( ) ;
249
+ const iwEvaluatorResult = [ ] ;
250
+ innerWritesEvaluator . evalForeignCalls ( contract . txId ( ) , interactionCall , iwEvaluatorResult , false ) ;
251
+ const tagsInnerWrites = this . tagsParser . getInteractWritesContracts ( missingInteraction ) ;
252
+ if (
253
+ iwEvaluatorResult . length == tagsInnerWrites . length &&
254
+ tagsInnerWrites . every ( ( elem ) => iwEvaluatorResult . includes ( elem ) )
255
+ ) {
256
+ validity [ missingInteraction . id ] = result . type === 'ok' ;
257
+ currentState = result . state ;
258
+ } else {
259
+ validity [ missingInteraction . id ] = false ;
260
+ errorMessage = `[SDK] Inner writes do not match - tags: ${ tagsInnerWrites } , evaluated: ${ iwEvaluatorResult } ` ;
261
+ // console.error(errorMessage);
262
+ // console.dir(interactionCall, { depth: null });
263
+ errorMessages [ missingInteraction . id ] = errorMessage ;
264
+ }
265
+ } else {
266
+ validity [ missingInteraction . id ] = result . type === 'ok' ;
267
+ currentState = result . state ;
268
+ }
269
+
242
270
interactionCall . update ( {
243
271
cacheHit : false ,
244
272
outputState : stackTrace . saveState ? currentState : undefined ,
245
273
executionTime : singleInteractionBenchmark . elapsed ( true ) as number ,
246
274
valid : validity [ missingInteraction . id ] ,
247
- errorMessage : errorMessage ,
275
+ errorMessage,
248
276
gasUsed : result . gasUsed
249
277
} ) ;
250
278
251
- if ( result . type === 'exception' && ignoreExceptions !== true ) {
252
- throw new Error ( `Exception while processing ${ JSON . stringify ( interaction ) } :\n${ result . errorMessage } ` ) ;
253
- }
254
-
255
- validity [ missingInteraction . id ] = result . type === 'ok' ;
256
- currentState = result . state ;
257
-
258
279
const toCache = new EvalStateResult ( currentState , validity , errorMessages ) ;
259
280
if ( canBeCached ( missingInteraction ) ) {
260
281
lastConfirmedTxState = {
0 commit comments