fix: additionally provide an empty object for validity if the cache returns undefined

This commit is contained in:
dtfiedler
2024-01-26 10:53:32 -07:00
committed by just_ppe
parent d08b0902f8
commit c2927a2943

View File

@@ -52,8 +52,8 @@ export class CacheableStateEvaluator extends DefaultStateEvaluator {
const isFirstEvaluation = cachedState == null;
let baseState = isFirstEvaluation ? executionContext.contractDefinition.initState : cachedState.cachedValue.state;
const baseValidity = isFirstEvaluation ? {} : cachedState.cachedValue.validity;
const baseErrorMessages = isFirstEvaluation ? {} : cachedState.cachedValue.errorMessages;
const baseValidity = isFirstEvaluation ? {} : cachedState.cachedValue.validity || {};
const baseErrorMessages = isFirstEvaluation ? {} : cachedState.cachedValue.errorMessages || {};
if (isFirstEvaluation) {
baseState = await executionContext.handler.maybeCallStateConstructor(
@@ -81,7 +81,7 @@ export class CacheableStateEvaluator extends DefaultStateEvaluator {
// eval state for the missing transactions - starting from the latest value from cache.
return await this.doReadState(
missingInteractions,
new EvalStateResult(baseState, baseValidity, baseErrorMessages || {}),
new EvalStateResult(baseState, baseValidity, baseErrorMessages),
executionContext
);
}