feat(proto): implement ProtoAdapters — 15/15 integration tests pass#100
Closed
ottobot-ai wants to merge 1 commit into
Closed
Conversation
…ass) Implements full bidirectional serialization between Scala fiber types and proto binary format (on-chain storage). Wire format boundary maintained: DL1 JSON API stays Circe, proto binary for on-chain storage only. ## ProtoAdapters.scala (new) - FiberStatus ↔ ProtoFiberStatus (bidirectional, Left on UNSPECIFIED) - SnapshotOrdinal / FiberOrdinal / Hash / Address / StateId converters - Circe Json ↔ com.google.protobuf.struct.Value bridge (via fold) - JsonLogicValue / JsonLogicExpression ↔ Protobuf Value (via Circe) - StateMachineDefinition ↔ ProtoStateMachineDefinition (JSON Struct) - AccessControlPolicy ↔ ProtoAccessControlPolicy (3 variants) - EmittedEvent / EventReceipt / OracleInvocation converters - StateMachineFiberRecord toProto + fromProto (Either[String, T]) - ScriptFiberRecord toProto + fromProto (Either[String, T]) ## ProtoAdaptersIntegrationTest.scala (fixed) - Fixed import paths: xyz.kd5ujc.schema.* (was xyz.kd5ujc.ottochain.*) - Fixed State constructor: State(id = StateId(...), isFinal = false) - Fixed StateMachineDefinition.states: Map[StateId, State] - Fixed Transition: guard/effect are required JsonLogicExpression - Fixed StateMachineFiberRecord: added previousUpdateOrdinal field - Fixed ScriptFiberRecord: added creationOrdinal/latestUpdateOrdinal - Fixed EventReceipt: all required fields (ordinal, fromState, toState, etc.) - Fixed Address construction: refineV[DAGAddressRefined].unsafeFrom() - Replaced EitherValues (ScalaTest) with IO-based getRight/getLeft helpers - All 15 tests now compile and pass Closes card 699621e4 (Integration Tests: Verify generated types with fiber engine)
Collaborator
Author
|
Moving to feature branch |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements
ProtoAdapters.scala— full bidirectional serialization between Scala fiber types and proto binary format for on-chain storage.Wire format boundary maintained: DL1 JSON API continues using Circe JSON. Proto binary is for on-chain storage only (no breaking change to external APIs).
Changes
ProtoAdapters.scala(new — 400 lines)FiberStatus↔ProtoFiberStatus— bidirectional; returnsLeftonUNSPECIFIEDSnapshotOrdinal / FiberOrdinal / Hash / Address / StateIdconvertersJson↔com.google.protobuf.struct.Valuebridge (complete fold)JsonLogicValue/JsonLogicExpression↔ proto Value (via Circe round-trip)StateMachineDefinition↔ProtoStateMachineDefinition(encoded as JSON Struct)AccessControlPolicy↔ProtoAccessControlPolicy(all 3 variants: Public / Whitelist / FiberOwned)EmittedEvent/EventReceipt/OracleInvocationconvertersStateMachineFiberRecord.toProto+fromProtoreturningEither[String, T]ScriptFiberRecord.toProto+fromProtoreturningEither[String, T]ProtoAdaptersIntegrationTest.scala(fixed)The spec tests from @code (PR #98) were written with hallucinated import paths and type constructors. Fixed all 15 tests to use correct Scala types:
xyz.kd5ujc.schema.*)State(id = StateId(...), isFinal = false)constructorStateMachineDefinition.states: Map[StateId, State]Transitionwith requiredguard/effectfieldsStateMachineFiberRecordwithpreviousUpdateOrdinalEventReceiptwith all required fieldsrefineV[DAGAddressRefined].unsafeFrom()EitherValueswith IO-basedgetRight/getLefthelpers (weaver-compatible)Test Results
Closes Trello card: Integration Tests: Verify generated types with fiber engine