Skip to content

Commit

Permalink
add error message for setting wrong on chain state
Browse files Browse the repository at this point in the history
  • Loading branch information
Trivo25 committed Apr 15, 2024
1 parent c427142 commit beb1df2
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/lib/mina/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,13 @@ function createState<T>(): InternalStateType<T> {
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);
});
},

Expand Down

0 comments on commit beb1df2

Please sign in to comment.