From beb1df24425336b64e7a590f0ad960a3a89cad55 Mon Sep 17 00:00:00 2001 From: Florian Date: Mon, 15 Apr 2024 10:17:59 +0200 Subject: [PATCH] add error message for setting wrong on chain state --- src/lib/mina/state.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/lib/mina/state.ts b/src/lib/mina/state.ts index 3f16428782..2501c6dd3b 100644 --- a/src/lib/mina/state.ts +++ b/src/lib/mina/state.ts @@ -196,10 +196,13 @@ function createState(): InternalStateType { let stateAsFields = this._contract.stateType.toFields(state); let accountUpdate = this._contract.instance.self; stateAsFields.forEach((x, i) => { - AccountUpdate.setValue( - accountUpdate.body.update.appState[layout.offset + i], - x - ); + let appStateSlot = + accountUpdate.body.update.appState[layout.offset + i]; + if (!appStateSlot) + throw Error( + `Attempted to set on-chain state variable \`${this._contract?.key}\`. Currently, only a total of 8 fields elements of on-chain state are supported.` + ); + AccountUpdate.setValue(appStateSlot, x); }); },