Skip to content

Commit

Permalink
expose method to rebuild internal state from fetched actions on an Of…
Browse files Browse the repository at this point in the history
…fchainStateInstance
  • Loading branch information
hattyhattington17 committed Dec 16, 2024
1 parent 86e9ee5 commit 1ab2011
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/lib/mina/actions/offchain-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ type OffchainStateInstance<
* Commitments to the offchain state, to use in your onchain state.
*/
commitments(): State<OffchainStateCommitments>;

/**
* Rebuilds the internal state map by fetching actions up to the current actionState in offchainStateCommitments
* */
fetchInternalState(): void;
};

type OffchainState<Config extends { [key: string]: OffchainStateKind }> = {
Expand Down Expand Up @@ -470,6 +475,17 @@ function OffchainState<
return result.proof;
},

async fetchInternalState() {
let actionState = await onchainActionState();
let { merkleMap, valueMap } = await fetchMerkleMap(
height,
internal.contract,
actionState
);
internal.merkleMap = merkleMap;
internal.valueMap = valueMap;
},

async settle(
proof: Proof<OffchainStateCommitments, OffchainStateCommitments>
) {
Expand Down

0 comments on commit 1ab2011

Please sign in to comment.