-
Notifications
You must be signed in to change notification settings - Fork 162
Open
Labels
Description
Reimplement the functionality of the OCaml local ledge (local_ledger.ml) TypeScript directly in o1js
The new TS implementation should match the behavior of the old OCaml version. Include tests to ensure parity with the original implementation.
For reference, we already have a good chunk of this implemented in TypeScript for the V2 API - feel free to reference this implementation and use parts of it
- pick up and finish the local transaction application logic from V2 https://github.com/o1-labs/o1js/blob/main/src/lib/mina/v2/zkapp-logic.ts
- make it compatible with the old account update API
- use the new local transaction logic in
Mina.LocalBlockchain
viaapplyJsonTransaction
instead of the old ocamlapply_zkapp_command
- the API of https://github.com/o1-labs/o1js-bindings/blob/30106d23ffd707a7e6af4093b9af442cabef1d93/ocaml/lib/local_ledger.ml will be re-implemented in TS see
Lines 499 to 526 in ee74d2d
declare class Ledger { /** * Creates a fresh ledger. */ static create(): Ledger; /** * Adds an account and its balance to the ledger. */ addAccount(publicKey: MlPublicKey, balance: string): void; /** * Applies a JSON transaction to the ledger. */ applyJsonTransaction( txJson: string, accountCreationFee: string, networkState: string ): void; /** * Returns an account. */ getAccount( publicKey: MlPublicKey, tokenId: FieldConst ): JsonAccount | undefined; } - the transaction application logic will have an extensive test suite to ensure its behaviour is the same as https://github.com/o1-labs/o1js-bindings/blob/30106d23ffd707a7e6af4093b9af442cabef1d93/ocaml/lib/local_ledger.ml - this will be tested in CI
- the API to https://github.com/o1-labs/o1js-bindings/blob/30106d23ffd707a7e6af4093b9af442cabef1d93/ocaml/lib/local_ledger.ml will be removed
- When done,
Mina.LocalBlockchain
will be implemented using TypeScript-only functions