Skip to content

Commit

Permalink
start working on cip-25 compliant metadata type
Browse files Browse the repository at this point in the history
  • Loading branch information
bjornkihlberg committed Mar 27, 2023
1 parent f9fe213 commit 9bfbe2f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
1 change: 1 addition & 0 deletions marlowe-integration-tests/marlowe-integration-tests.cabal
Expand Up @@ -98,4 +98,5 @@ executable marlowe-integration-tests
, transformers
, transformers-base
, lifted-async
, logict
build-tool-depends: hspec-discover:hspec-discover
34 changes: 32 additions & 2 deletions marlowe-integration-tests/test/Language/Marlowe/Runtime/CliSpec.hs
Expand Up @@ -6,10 +6,15 @@ module Language.Marlowe.Runtime.CliSpec
where

import Cardano.Api (AsType(AsTxBody), BabbageEra, CardanoEra(BabbageEra), TxBody, readFileTextEnvelope)
import Control.Applicative (Alternative(empty, (<|>)))
import Control.Concurrent.Async.Lifted (concurrently)
import Control.Monad ((>=>))
import qualified Control.Monad.Base as Trans
import Control.Monad.Logic (MonadLogic)
import qualified Control.Monad.Logic as Logic
import qualified Control.Monad.Reader as Reader
import qualified Data.Either as Either
import qualified Data.Foldable as Foldable
import qualified Data.Maybe as Maybe
import qualified Data.Set as Set
import qualified Data.Text as Text
Expand All @@ -26,7 +31,8 @@ import Language.Marlowe.Runtime.Transaction.Api
(ContractCreated(..), CreateError, MarloweTxCommand(..), RoleTokensConfig(RoleTokensNone), WalletAddresses(..))
import qualified Network.Protocol.Job.Client as JobClient
import Test.Hspec (Spec, describe, fdescribe, it, shouldBe)
import Test.Integration.Marlowe (LocalTestnet(..), resolveWorkspacePath, testnet, withLocalMarloweRuntime, writeWorkspaceFileJSON)
import Test.Integration.Marlowe
(LocalTestnet(..), resolveWorkspacePath, testnet, withLocalMarloweRuntime, writeWorkspaceFileJSON)

serializeAddress :: Address -> String
serializeAddress = Text.unpack . Maybe.fromJust . toBech32
Expand All @@ -42,15 +48,39 @@ marloweRuntimeJobClient cmd = do
(Either.fromRight (error "Some JobClient creation error!") -> ContractCreated {txBody}) <- runMarloweTxClient $ JobClient.liftCommand cmd
pure txBody

{-
data RoleTokensConfig
= RoleTokensNone
| RoleTokensUsePolicy PolicyId
| RoleTokensMint Mint
PolicyId ~ ByteString
Mint ~ Map TokenName (Address, Either Natural (Maybe NFTMetadata))
https://cips.cardano.org/cips/cip25/
-}

{-
TODO make PR and go home
DOING take an extra look at all the JSON instances to make sure it's done correctly
TODO find out if zerging will work for this suite
TODO find out what exactly takes long time for this test
DONE take an extra look at all the JSON instances to make sure it's done correctly
DOING implement fromJSON for NFTMetadata based on CIP-25
DONE Load role tokens config file and parse it in module Language.Marlowe.Runtime.CLI.Command.Create
DONE Implement FromJSON and FromJSONKey instances where they're needed
DONE reference role tokens config in cliEffect :: Integration ()
DONE Create role tokens config file from RoleTokensConfig
-}

fromFoldable :: (Foldable t, MonadLogic m) => t a -> m a
fromFoldable = Foldable.foldl (\acc x -> acc <|> pure x) empty

mcons :: MonadLogic m => m a -> m (a, m a)
mcons =
Logic.msplit >=> \case
Just ama@(_, ma) -> pure ama <|> mcons ma
Nothing -> empty

spec :: Spec
spec = fdescribe "Marlowe runtime CLI" do
describe "create" do
Expand Down

0 comments on commit 9bfbe2f

Please sign in to comment.