Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix storage loading #132

Merged
merged 2 commits into from
Oct 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions solarkraft/src/fetcher/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export interface ContractCallEntry {
* deletes some fields from the storage. Also, fields may be cleared from `storage`
* when the storage goes over TTL.
*/
storage: FieldsMap
storage: MultiContractStorage

/**
* Flag which tracks whether this particular entry has already been verified, and, if it has been, the verification result.
Expand Down Expand Up @@ -207,6 +207,18 @@ export function saveContractCallEntry(home: string, entry: ContractCallEntry) {
return filename
}

function contractStorageFromJs(js: any): ContractStorage {
return {
instance: OrderedMap<string, any>(js.instance),
persistent: OrderedMap<string, any>(js.persistent),
temporary: OrderedMap<string, any>(js.temporary),
}
}

function storageFromJS(js: any): MultiContractStorage {
return Immutable.Seq(js).map(contractStorageFromJs).toOrderedMap()
}

/**
* Load a contract call entry in the file storage.
* @param root the storage root directory
Expand All @@ -220,8 +232,8 @@ export function loadContractCallEntry(filename: string): ContractCallEntry {
...loaded,
fields: OrderedMap<string, any>(loaded.fields),
oldFields: OrderedMap<string, any>(loaded.oldFields),
oldStorage: Immutable.fromJS(loaded.oldStorage),
storage: Immutable.fromJS(loaded.storage),
oldStorage: storageFromJS(loaded.oldStorage),
storage: storageFromJS(loaded.storage),
verificationStatus:
loaded.verificationStatus ?? VerificationStatus.Unknown,
typeHints: loaded.typeHints ?? {},
Expand Down
Loading