import { Field } from "o1js"; import { SimpleAsyncStateService } from "@proto-kit/protocol"; /** * Naive implementation of an in-memory variant of the StateService interface */ export class InMemoryStateService implements SimpleAsyncStateService { /** * This mapping container null values if the specific entry has been deleted. * This is used by the CachedState service to keep track of deletions */ public values: Record = {}; public async get(key: Field): Promise { return this.values[key.toString()] ?? undefined; } public async set(key: Field, value: Field[] | undefined) { if (value === undefined) { this.values[key.toString()] = null; } else { this.values[key.toString()] = value; } } }