From bf4d1b6e9ccf26fec0931c6a2d6d5f05b7fc40a3 Mon Sep 17 00:00:00 2001 From: robal Date: Wed, 15 Mar 2023 15:35:55 +0100 Subject: [PATCH] fix: do not modify KV store in case of view operations --- src/core/modules/impl/handler/WasmHandlerApi.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/core/modules/impl/handler/WasmHandlerApi.ts b/src/core/modules/impl/handler/WasmHandlerApi.ts index 9c1b6fc4..9e1cc69c 100644 --- a/src/core/modules/impl/handler/WasmHandlerApi.ts +++ b/src/core/modules/impl/handler/WasmHandlerApi.ts @@ -62,6 +62,10 @@ export class WasmHandlerApi extends AbstractContractHandler { }; } } finally { + if (interactionData.interaction.interactionType === 'view') { + // view calls are not allowed to perform any KV modifications + await this.swGlobal.kv.rollback(); + } await this.swGlobal.kv.close(); } }