You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to store the block in a DB and then serve it over an API. But when I retrieve the stored (JSON)data from the DB and send over an API I can't reconstruct the L2Block-object from the data. I know there are to/fromString and to/fromBuffer, but I want to make the data stored in DB queryable.
When trying to use fromFields with the JSON-data it works, but the object is not fully reconstructed. Also, the necessary types are not exported so that I can reconstruct the object.
import{L2Block}from"@aztec/aztec.js";// ... receiving `block`constjsonString=JSON.stringify(block,null,2);constrecreatedObj=L2Block.fromFields(JSON.parse(jsonString)asL2Block);logger.info(`Fields: ${JSON.stringify(recreatedObj,null,2)}`);// below line produces an errorlogger.info(`Fields: ${recreatedObj.hash()}`);// ...
...produces this...
TypeError: this.header.hash is not a function
at L2Block.hash (/usr/main/node_modules/@aztec/circuit-types/src/l2_block.ts:139:24)
at Object.store (/usr/main/services/explorer-api/src/database/models/block.ts:36:30)
at onBlock (/usr/main/services/explorer-api/src/event-handler/on-block.ts:6:17)
...
The text was updated successfully, but these errors were encountered:
When trying to reconstruct the obj required for fromFields I get stuck at not being able to import AppendOnlyTreeSnapshot for re-creation. It seems to be plenty of more classes that's not able to import.
Hello @FilipHarald, we've decided to just remove the function as it's non-essential. Please use toBuffer and fromBuffer methods when you need block serialization. Thank you for reporting
I'm trying to store the block in a DB and then serve it over an API. But when I retrieve the stored (JSON)data from the DB and send over an API I can't reconstruct the L2Block-object from the data. I know there are
to/fromString
andto/fromBuffer
, but I want to make the data stored in DB queryable.When trying to use
fromFields
with the JSON-data it works, but the object is not fully reconstructed. Also, the necessary types are not exported so that I can reconstruct the object.I've reproduced it here. But the gist of it is this....
...produces this...
The text was updated successfully, but these errors were encountered: