diff --git a/marlowe-runtime-web/.golden/OpenApi/golden b/marlowe-runtime-web/.golden/OpenApi/golden index 556425768a..f7a21c081e 100644 --- a/marlowe-runtime-web/.golden/OpenApi/golden +++ b/marlowe-runtime-web/.golden/OpenApi/golden @@ -789,6 +789,9 @@ "initialContract": { "$ref": "#/components/schemas/Contract" }, + "initialState": { + "$ref": "#/components/schemas/MarloweState" + }, "metadata": { "additionalProperties": { "$ref": "#/components/schemas/Metadata" @@ -834,6 +837,7 @@ "metadata", "status", "initialContract", + "initialState", "assets", "unclaimedPayouts" ], diff --git a/marlowe-runtime-web/changelog.d/20240111_114659_jhbertra_plt_9083_initial_state_in_response.md b/marlowe-runtime-web/changelog.d/20240111_114659_jhbertra_plt_9083_initial_state_in_response.md new file mode 100644 index 0000000000..ea3a3153fb --- /dev/null +++ b/marlowe-runtime-web/changelog.d/20240111_114659_jhbertra_plt_9083_initial_state_in_response.md @@ -0,0 +1,3 @@ +### Added + +- Initial contract state to `GET /contracts/{contractId}` response. diff --git a/marlowe-runtime-web/server/Language/Marlowe/Runtime/Web/Server/DTO.hs b/marlowe-runtime-web/server/Language/Marlowe/Runtime/Web/Server/DTO.hs index 585cdfe7c9..740667bb26 100644 --- a/marlowe-runtime-web/server/Language/Marlowe/Runtime/Web/Server/DTO.hs +++ b/marlowe-runtime-web/server/Language/Marlowe/Runtime/Web/Server/DTO.hs @@ -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 @@ -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 diff --git a/marlowe-runtime-web/src/Language/Marlowe/Runtime/Web/Types.hs b/marlowe-runtime-web/src/Language/Marlowe/Runtime/Web/Types.hs index 41aaaa9d15..61a32ee2fd 100644 --- a/marlowe-runtime-web/src/Language/Marlowe/Runtime/Web/Types.hs +++ b/marlowe-runtime-web/src/Language/Marlowe/Runtime/Web/Types.hs @@ -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 diff --git a/marlowe-runtime-web/test/Spec.hs b/marlowe-runtime-web/test/Spec.hs index 6f495d59d9..1480a5604d 100644 --- a/marlowe-runtime-web/test/Spec.hs +++ b/marlowe-runtime-web/test/Spec.hs @@ -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