Skip to content

Commit

Permalink
Merge pull request #796 from input-output-hk/plt-9083-initial-state-i…
Browse files Browse the repository at this point in the history
…n-response

PLT-9083 initial state in response
  • Loading branch information
jhbertra authored Jan 11, 2024
2 parents 38189e7 + f681328 commit cba0918
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions marlowe-runtime-web/.golden/OpenApi/golden
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,9 @@
"initialContract": {
"$ref": "#/components/schemas/Contract"
},
"initialState": {
"$ref": "#/components/schemas/MarloweState"
},
"metadata": {
"additionalProperties": {
"$ref": "#/components/schemas/Metadata"
Expand Down Expand Up @@ -834,6 +837,7 @@
"metadata",
"status",
"initialContract",
"initialState",
"assets",
"unclaimedPayouts"
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Added

- Initial contract state to `GET /contracts/{contractId}` response.
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ instance ToDTO SomeContractState where
, status = Web.Confirmed
, block = Just $ toDTO initialBlock
, initialContract = Sem.marloweContract $ datum initialOutput
, initialState = Sem.marloweState $ datum initialOutput
, currentContract = Sem.marloweContract . datum <$> latestOutput
, state = Sem.marloweState . datum <$> latestOutput
, assets = maybe emptyAssets (\Core.TransactionScriptOutput{..} -> toDTO assets) latestOutput
Expand Down Expand Up @@ -592,6 +593,8 @@ instance ToDTOWithTxStatus (Tx.ContractCreated v) where
, block = Nothing
, initialContract = case version of
MarloweV1 -> Sem.marloweContract datum
, initialState = case version of
MarloweV1 -> Sem.marloweState datum
, currentContract = case version of
MarloweV1 -> Just $ Sem.marloweContract datum
, state = case version of
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ data ContractState = ContractState
, status :: TxStatus
, block :: Maybe BlockHeader
, initialContract :: Semantics.Contract
, initialState :: Semantics.State
, currentContract :: Maybe Semantics.Contract
, state :: Maybe Semantics.State
, utxo :: Maybe TxOutRef
Expand Down
1 change: 1 addition & 0 deletions marlowe-runtime-web/test/Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ instance Arbitrary Web.ContractState where
-- size of 6 will result in a 1-layer deep contract being generated (this is
-- all we care about for the purposes of schema checking).
<*> resize 6 arbitrary
<*> arbitrary
<*> resize 6 arbitrary
<*> arbitrary
<*> arbitrary
Expand Down

0 comments on commit cba0918

Please sign in to comment.