From 6f5004529e32c7d1979deeba04eb36f8e35d0bb2 Mon Sep 17 00:00:00 2001 From: Test Date: Thu, 17 Oct 2024 11:05:45 -0400 Subject: [PATCH 1/2] include the type OffchainStateInstance in the internal API --- .../actions/offchain-contract-tests/ExampleContract.ts | 2 +- src/lib/mina/actions/offchain-state.ts | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/lib/mina/actions/offchain-contract-tests/ExampleContract.ts b/src/lib/mina/actions/offchain-contract-tests/ExampleContract.ts index 1e4a48251..33e75b52d 100644 --- a/src/lib/mina/actions/offchain-contract-tests/ExampleContract.ts +++ b/src/lib/mina/actions/offchain-contract-tests/ExampleContract.ts @@ -27,7 +27,7 @@ class ExampleContract extends SmartContract { offchainState.emptyCommitments(); // o1js memoizes the offchain state by contract address so that this pattern works - offchainState: any = offchainState.init(this); + offchainState = offchainState.init(this); @method async createAccount(address: PublicKey, amountToMint: UInt64) { diff --git a/src/lib/mina/actions/offchain-state.ts b/src/lib/mina/actions/offchain-state.ts index af3b5829d..07b298bcf 100644 --- a/src/lib/mina/actions/offchain-state.ts +++ b/src/lib/mina/actions/offchain-state.ts @@ -33,7 +33,7 @@ import { ProvableType } from '../../provable/types/provable-intf.js'; export { OffchainState, OffchainStateCommitments }; // internal API -export { OffchainField, OffchainMap }; +export { OffchainField, OffchainMap, OffchainStateInstance }; type OffchainStateInstance< Config extends { [key: string]: OffchainStateKind } @@ -512,7 +512,10 @@ function OffchainState< const memoizedInstances = new Map>(); return { - init(contractInstance: OffchainStateContract) { + init(contractInstance: OffchainStateContract | null) { + if (contractInstance === null) { + return OffchainStateInstance(); + } let key = 'COMPILE_TIME'; let contractAddress = contractInstance.address; if (contractAddress.isConstant()) { From b4847d204777b239c4212b003c3ee3848d3ad06c Mon Sep 17 00:00:00 2001 From: Test Date: Thu, 17 Oct 2024 11:06:19 -0400 Subject: [PATCH 2/2] rm nonsense --- src/lib/mina/actions/offchain-state.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/lib/mina/actions/offchain-state.ts b/src/lib/mina/actions/offchain-state.ts index 07b298bcf..6b091df29 100644 --- a/src/lib/mina/actions/offchain-state.ts +++ b/src/lib/mina/actions/offchain-state.ts @@ -512,10 +512,7 @@ function OffchainState< const memoizedInstances = new Map>(); return { - init(contractInstance: OffchainStateContract | null) { - if (contractInstance === null) { - return OffchainStateInstance(); - } + init(contractInstance: OffchainStateContract) { let key = 'COMPILE_TIME'; let contractAddress = contractInstance.address; if (contractAddress.isConstant()) {