From c9e480723c6cd8355a6b629fb42e8900e2f1c159 Mon Sep 17 00:00:00 2001 From: Paolo Veronelli Date: Fri, 6 May 2022 09:02:51 +0200 Subject: [PATCH] Merge pull request #3257 from input-output-hk/jonathanknowles/ADP-1596/simple-metadata Fixes for ADP-1596 --- .gitignore | 3 - lib/cli/src/Cardano/CLI.hs | 24 +++---- .../Cardano/CLISpec/transaction get --help | 2 +- .../Cardano/CLISpec/transaction list --help | 4 +- lib/cli/test/unit/Cardano/CLISpec.hs | 19 ++--- .../src/Test/Integration/Framework/DSL.hs | 4 +- .../Scenario/API/Shelley/StakePools.hs | 4 +- .../Scenario/API/Shelley/Transactions.hs | 49 +++++++++---- .../Scenario/API/Shelley/TransactionsNew.hs | 52 +++++++------- .../Scenario/CLI/Shelley/Transactions.hs | 54 ++++++++------ lib/core/src/Cardano/Wallet/Api.hs | 4 +- lib/core/src/Cardano/Wallet/Api/Client.hs | 5 +- lib/core/src/Cardano/Wallet/Api/Link.hs | 14 ++-- lib/core/src/Cardano/Wallet/Api/Server.hs | 71 +++++++++++-------- lib/core/src/Cardano/Wallet/Api/Types.hs | 3 +- .../Wallet/Api/Types/SchemaMetadata.hs | 41 ++++++----- .../test/unit/Cardano/Wallet/Api/TypesSpec.hs | 7 +- lib/shelley/bench/latency-bench.hs | 7 +- .../stack-nix/cardano-wallet-core.nix | 1 + 19 files changed, 210 insertions(+), 158 deletions(-) diff --git a/.gitignore b/.gitignore index 936999d3853..f02fd512172 100644 --- a/.gitignore +++ b/.gitignore @@ -49,6 +49,3 @@ lib/shelley/test/data/balanceTx/**/actual ### Docs build /_build/ .vscode/settings.json - - - diff --git a/lib/cli/src/Cardano/CLI.hs b/lib/cli/src/Cardano/CLI.hs index dbbac6ec981..57108c63c31 100644 --- a/lib/cli/src/Cardano/CLI.hs +++ b/lib/cli/src/Cardano/CLI.hs @@ -162,6 +162,8 @@ import Cardano.Wallet.Api.Types , WalletPutPassphraseData (..) , fmtAllowedWords ) +import Cardano.Wallet.Api.Types.SchemaMetadata + ( TxMetadataWithSchema ) import Cardano.Wallet.Orphans () import Cardano.Wallet.Primitive.AddressDerivation @@ -324,8 +326,6 @@ import UnliftIO.Exception import qualified Cardano.BM.Configuration.Model as CM import qualified Cardano.BM.Data.BackendKind as CM import qualified Cardano.BM.Data.Observable as Obs -import Cardano.Wallet.Api.Types.SchemaMetadata - ( TxMetadataWithSchema ) import qualified Command.Key as Key import qualified Command.RecoveryPhrase as RecoveryPhrase import qualified Data.Aeson as Aeson @@ -733,9 +733,9 @@ data TransactionFeatures = NoShelleyFeatures | ShelleyFeatures -- | which json schema to use for output, True is simple metadataSchemaOption :: Parser Bool -metadataSchemaOption = switch +metadataSchemaOption = switch do long "simple-metadata" - <> help "output metadata json in no-schema encoding" + <> help "output metadata json in no-schema encoding" -- | cardano-wallet transaction cmdTransaction @@ -869,8 +869,10 @@ cmdTransactionList mkTxClient = <*> optional timeRangeStartOption <*> optional timeRangeEndOption <*> optional sortOrderOption - <*> metadataSchemaOption - exec (TransactionListArgs wPort wId mTimeRangeStart mTimeRangeEnd mOrder metadataSchema) = + <*> metadataSchemaOption + exec + (TransactionListArgs + wPort wId mTimeRangeStart mTimeRangeEnd mOrder metadataSchema) = runClient wPort Aeson.encodePretty $ listTransactions mkTxClient (ApiT wId) @@ -940,16 +942,14 @@ cmdTransactionGet mkClient = cmd = fmap exec $ TransactionGetArgs <$> portOption <*> walletIdArgument - <*> transactionIdArgument - <*> metadataSchemaOption + <*> transactionIdArgument + <*> metadataSchemaOption exec (TransactionGetArgs wPort wId txId metadataSchema ) = do runClient wPort Aeson.encodePretty $ getTransaction mkClient (ApiT wId) - metadataSchema + metadataSchema (ApiTxId $ ApiT $ getTxId txId) - - {------------------------------------------------------------------------------- Commands - 'address' -------------------------------------------------------------------------------} @@ -1455,7 +1455,7 @@ metadataOption :: Parser (Maybe TxMetadataWithSchema) metadataOption = option txMetadataReader $ mempty <> long "metadata" <> metavar "JSON" - <> value Nothing + <> value Nothing <> help ("Application-specific transaction metadata as a JSON object. " <> "The value must match the schema defined in the " <> "cardano-wallet OpenAPI specification.") diff --git a/lib/cli/test/data/Cardano/CLISpec/transaction get --help b/lib/cli/test/data/Cardano/CLISpec/transaction get --help index 36cab7120ca..d551f59bf4e 100644 --- a/lib/cli/test/data/Cardano/CLISpec/transaction get --help +++ b/lib/cli/test/data/Cardano/CLISpec/transaction get --help @@ -1,4 +1,4 @@ -Usage: transaction get [--port INT] WALLET_ID TRANSACTION_ID +Usage: transaction get [--port INT] WALLET_ID TRANSACTION_ID [--simple-metadata] Get a transaction with specified id. diff --git a/lib/cli/test/data/Cardano/CLISpec/transaction list --help b/lib/cli/test/data/Cardano/CLISpec/transaction list --help index 00775354138..033ea69b0ff 100644 --- a/lib/cli/test/data/Cardano/CLISpec/transaction list --help +++ b/lib/cli/test/data/Cardano/CLISpec/transaction list --help @@ -1,5 +1,5 @@ -Usage: transaction list [--port INT] WALLET_ID [--start TIME] - [--end TIME] [--order ORDER] +Usage: transaction list [--port INT] WALLET_ID [--start TIME] + [--end TIME] [--order ORDER] [--simple-metadata] List the transactions associated with a wallet. diff --git a/lib/cli/test/unit/Cardano/CLISpec.hs b/lib/cli/test/unit/Cardano/CLISpec.hs index a003d8b00f1..873381b474c 100644 --- a/lib/cli/test/unit/Cardano/CLISpec.hs +++ b/lib/cli/test/unit/Cardano/CLISpec.hs @@ -40,6 +40,8 @@ import Cardano.Wallet.Api.Client , transactionClient , walletClient ) +import Cardano.Wallet.Api.Types.SchemaMetadata + ( detailedMetadata, noSchemaMetadata ) import Cardano.Wallet.Primitive.Types ( PoolMetadataSource ) import Cardano.Wallet.Primitive.Types.Tx @@ -98,8 +100,6 @@ import UnliftIO.MVar import UnliftIO.Temporary ( withSystemTempDirectory ) -import Cardano.Wallet.Api.Types.SchemaMetadata - ( detailedMetadata, noSchemaMetadata ) import qualified Data.Map as Map import qualified Data.Text as T import qualified Data.Text.IO as TIO @@ -255,7 +255,8 @@ spec = do describe "Tx Metadata JSON option" $ do let parse arg = execParserPure defaultPrefs (info metadataOption mempty) ["--metadata", arg] - let md = detailedMetadata (TxMetadata (Map.singleton 42 (TxMetaText "hi"))) + let md = detailedMetadata + (TxMetadata (Map.singleton 42 (TxMetaText "hi"))) let ok ex (Success res) = ex == res ok _ _ = False let err (Failure _) = True @@ -271,8 +272,10 @@ spec = do , ("null 3", "{ }", ok (Just (detailedMetadata mempty))) ] describe "Tx No-Schema Metadata JSON option" $ do - let parse arg = execParserPure defaultPrefs (info metadataOption mempty) ["--metadata", arg] - let md = noSchemaMetadata (TxMetadata (Map.singleton 42 (TxMetaText "hi"))) + let parse arg = execParserPure + defaultPrefs (info metadataOption mempty) ["--metadata", arg] + let md = noSchemaMetadata + (TxMetadata (Map.singleton 42 (TxMetaText "hi"))) let ok ex (Success res) = ex == res ok _ _ = False let err (Failure _) = True @@ -285,10 +288,10 @@ spec = do , ("invalid", "{ \"json\": true }", err) , ("null 1", "{ \"0\": null }", err) , ("null 2", "null", ok Nothing) - , ("null 3", "{ }", ok $ Just $ detailedMetadata mempty) -- this is the default parsing success - ] + -- this is the default parsing success: + , ("null 3", "{ }", ok $ Just $ detailedMetadata mempty) - + ] describe "Tx TTL option" $ do let parse arg = execParserPure defaultPrefs diff --git a/lib/core-integration/src/Test/Integration/Framework/DSL.hs b/lib/core-integration/src/Test/Integration/Framework/DSL.hs index c9ea76225f8..b63169f19a9 100644 --- a/lib/core-integration/src/Test/Integration/Framework/DSL.hs +++ b/lib/core-integration/src/Test/Integration/Framework/DSL.hs @@ -2803,7 +2803,7 @@ postTransactionFeeViaCLI ctx args = cardanoWalletCLI $ join listTransactionsViaCLI :: forall r s m. (CmdResult r, HasType (Port "wallet") s, MonadIO m) => s - -> Bool + -> Bool -> [String] -> m r listTransactionsViaCLI ctx metadataSchema args = cardanoWalletCLI $ join @@ -2840,7 +2840,7 @@ getTransactionViaCLI => s -> String -> String - -> Bool + -> Bool -> m r getTransactionViaCLI ctx wid tid metadataSchema = cardanoWalletCLI $ join [ ["transaction", "get"] diff --git a/lib/core-integration/src/Test/Integration/Scenario/API/Shelley/StakePools.hs b/lib/core-integration/src/Test/Integration/Scenario/API/Shelley/StakePools.hs index e1c89918b5c..30f52611ef7 100644 --- a/lib/core-integration/src/Test/Integration/Scenario/API/Shelley/StakePools.hs +++ b/lib/core-integration/src/Test/Integration/Scenario/API/Shelley/StakePools.hs @@ -83,6 +83,8 @@ import Data.Text ( Text ) import Data.Text.Class ( showT, toText ) +import Data.Tuple.Extra + ( both ) import Numeric.Natural ( Natural ) import Test.Hspec @@ -154,8 +156,6 @@ import qualified Cardano.Wallet.Api.Link as Link import qualified Data.ByteString as BS import qualified Data.Set as Set import qualified Data.Text as T -import Data.Tuple.Extra - ( both ) import qualified Network.HTTP.Types.Status as HTTP spec :: forall n. diff --git a/lib/core-integration/src/Test/Integration/Scenario/API/Shelley/Transactions.hs b/lib/core-integration/src/Test/Integration/Scenario/API/Shelley/Transactions.hs index d42a5887bd3..e80cf81b6fb 100644 --- a/lib/core-integration/src/Test/Integration/Scenario/API/Shelley/Transactions.hs +++ b/lib/core-integration/src/Test/Integration/Scenario/API/Shelley/Transactions.hs @@ -40,6 +40,8 @@ import Cardano.Wallet.Api.Types , insertedAt , pendingSince ) +import Cardano.Wallet.Api.Types.SchemaMetadata + ( detailedMetadata ) import Cardano.Wallet.Primitive.AddressDerivation ( PaymentAddress ) import Cardano.Wallet.Primitive.AddressDerivation.Icarus @@ -179,7 +181,6 @@ import qualified Data.List.NonEmpty as NE import qualified Data.Map as Map import qualified Data.Text as T import qualified Network.HTTP.Types.Status as HTTP -import Cardano.Wallet.Api.Types.SchemaMetadata (detailedMetadata) data TestCase a = TestCase { query :: T.Text @@ -958,7 +959,10 @@ spec = describe "SHELLEY_TRANSACTIONS" $ do } ] - it "TRANSMETA_CREATE_02a - Transaction with invalid metadata" $ \ctx -> runResourceT $ do + it "TRANSMETA_CREATE_02a - \ + \Transaction with invalid metadata" $ + \ctx -> runResourceT $ do + (wa, wb) <- (,) <$> fixtureWallet ctx <*> fixtureWallet ctx let amt = minUTxOValue (_mainEra ctx) :: Natural @@ -972,8 +976,11 @@ spec = describe "SHELLEY_TRANSACTIONS" $ do expectResponseCode HTTP.status400 r expectErrorMessage errMsg400TxMetadataStringTooLong r - - it "TRANSMETA_CREATE_02b - Transaction with invalid no-schema metadata" $ \ctx -> runResourceT $ do + + it "TRANSMETA_CREATE_02b - \ + \Transaction with invalid no-schema metadata" $ + \ctx -> runResourceT $ do + (wa, wb) <- (,) <$> fixtureWallet ctx <*> fixtureWallet ctx let amt = minUTxOValue (_mainEra ctx) :: Natural @@ -989,7 +996,6 @@ spec = describe "SHELLEY_TRANSACTIONS" $ do Default payload - expectResponseCode HTTP.status400 r expectErrorMessage errMsg400TxMetadataStringTooLong r @@ -1013,7 +1019,10 @@ spec = describe "SHELLEY_TRANSACTIONS" $ do expectResponseCode HTTP.status403 r expectErrorMessage errMsg403TxTooBig r - it "TRANSMETA_ESTIMATE_01a - fee estimation includes metadata" $ \ctx -> runResourceT $ do + it "TRANSMETA_ESTIMATE_01a - \ + \fee estimation includes metadata" $ + \ctx -> runResourceT $ do + (wa, wb) <- (,) <$> fixtureWallet ctx <*> emptyWallet ctx let amt = minUTxOValue (_mainEra ctx) :: Natural @@ -1041,7 +1050,10 @@ spec = describe "SHELLEY_TRANSACTIONS" $ do , expectField (#estimatedMax . #getQuantity) (.< feeEstMax) ] - it "TRANSMETA_ESTIMATE_01b - fee estimation includes no-schema metadata" $ \ctx -> runResourceT $ do + it "TRANSMETA_ESTIMATE_01b - \ + \fee estimation includes no-schema metadata" $ + \ctx -> runResourceT $ do + (wa, wb) <- (,) <$> fixtureWallet ctx <*> emptyWallet ctx let amt = minUTxOValue (_mainEra ctx) :: Natural @@ -1079,7 +1091,10 @@ spec = describe "SHELLEY_TRANSACTIONS" $ do , expectField (#estimatedMax . #getQuantity) (.< feeEstMax) ] - it "TRANSMETA_ESTIMATE_02a - fee estimation with invalid metadata" $ \ctx -> runResourceT $ do + it "TRANSMETA_ESTIMATE_02a - \ + \fee estimation with invalid metadata" $ + \ctx -> runResourceT $ do + (wa, wb) <- (,) <$> fixtureWallet ctx <*> emptyWallet ctx let amt = minUTxOValue (_mainEra ctx) :: Natural @@ -1093,8 +1108,11 @@ spec = describe "SHELLEY_TRANSACTIONS" $ do expectResponseCode HTTP.status400 r expectErrorMessage errMsg400TxMetadataStringTooLong r - - it "TRANSMETA_ESTIMATE_02b - fee estimation with invalid no-schema metadata" $ \ctx -> runResourceT $ do + + it "TRANSMETA_ESTIMATE_02b - \ + \fee estimation with invalid no-schema metadata" $ + \ctx -> runResourceT $ do + (wa, wb) <- (,) <$> fixtureWallet ctx <*> emptyWallet ctx let amt = minUTxOValue (_mainEra ctx) :: Natural @@ -1685,7 +1703,8 @@ spec = describe "SHELLEY_TRANSACTIONS" $ do eventually "Transactions are available and in ledger" $ do -- Verify Tx in source wallet is Outgoing and InLedger - let linkSrc = Link.getTransaction @'Shelley wSrc (ApiTxId txid) False + let linkSrc = Link.getTransaction @'Shelley + wSrc (ApiTxId txid) False r1 <- request @(ApiTransaction n) ctx linkSrc Default Empty verify r1 [ expectResponseCode HTTP.status200 @@ -1694,7 +1713,8 @@ spec = describe "SHELLEY_TRANSACTIONS" $ do ] -- Verify Tx in destination wallet is Incoming and InLedger - let linkDest = Link.getTransaction @'Shelley wDest (ApiTxId txid) False + let linkDest = Link.getTransaction + @'Shelley wDest (ApiTxId txid) False r2 <- request @(ApiTransaction n) ctx linkDest Default Empty verify r2 [ expectResponseCode HTTP.status200 @@ -1727,7 +1747,8 @@ spec = describe "SHELLEY_TRANSACTIONS" $ do ] let txid = Hash $ BS.pack $ replicate 32 1 - let link = Link.getTransaction @'Shelley wSrc (ApiTxId $ ApiT txid) False + let link = Link.getTransaction @'Shelley + wSrc (ApiTxId $ ApiT txid) False r <- request @(ApiTransaction n) ctx link Default Empty expectResponseCode HTTP.status404 r expectErrorMessage (errMsg404CannotFindTx $ toText txid) r @@ -1908,7 +1929,7 @@ spec = describe "SHELLEY_TRANSACTIONS" $ do eventually "withdrawal transaction is listed on other" $ do rTxOther <- request @(ApiTransaction n) ctx - (Link.getTransaction @'Shelley wOther tid False) Default payload + (Link.getTransaction @'Shelley wOther tid False) Default payload verify rTxOther [ expectResponseCode HTTP.status200 diff --git a/lib/core-integration/src/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs b/lib/core-integration/src/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs index c33bac869de..b1f106d1ee1 100644 --- a/lib/core-integration/src/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs +++ b/lib/core-integration/src/Test/Integration/Scenario/API/Shelley/TransactionsNew.hs @@ -306,15 +306,13 @@ spec = describe "NEW_SHELLEY_TRANSACTIONS" $ do signedTx <- signTx ctx wa apiTx [ expectResponseCode HTTP.status202 ] -- Check for the presence of metadata on signed transaction - let - getMetadata (InAnyCardanoEra _ tx) = Cardano.getTxBody tx - & (\(Cardano.TxBody bodyContent) -> - Cardano.txMetadata bodyContent - & \case Cardano.TxMetadataNone -> - Nothing - Cardano.TxMetadataInEra _ (Cardano.TxMetadata m) -> - Just m - ) + let getMetadata (InAnyCardanoEra _ tx) = Cardano.getTxBody tx & + \(Cardano.TxBody bodyContent) -> + Cardano.txMetadata bodyContent & \case + Cardano.TxMetadataNone -> + Nothing + Cardano.TxMetadataInEra _ (Cardano.TxMetadata m) -> + Just m case getMetadata (cardanoTx $ getApiT (signedTx ^. #transaction)) of Nothing -> error "Tx doesn't include metadata" @@ -323,14 +321,17 @@ spec = describe "NEW_SHELLEY_TRANSACTIONS" $ do Just (Cardano.TxMetaText "hello") -> pure () Just _ -> error "Tx metadata incorrect" - let txCbor = getFromResponse #transaction (HTTP.status202, Right signedTx) + let txCbor = + getFromResponse #transaction (HTTP.status202, Right signedTx) let decodePayload = Json (toJSON $ ApiSerialisedTransaction txCbor) - let expMetadata = ApiT (TxMetadata (Map.fromList [(1,TxMetaText "hello")])) + let expMetadata = + ApiT (TxMetadata (Map.fromList [(1,TxMetaText "hello")])) rDecodedTx <- request @(ApiDecodedTransaction n) ctx (Link.decodeTransaction @'Shelley wa) Default decodePayload verify rDecodedTx [ expectResponseCode HTTP.status202 - , expectField #metadata (`shouldBe` (ApiTxMetadata (Just expMetadata))) + , expectField #metadata + (`shouldBe` (ApiTxMetadata (Just expMetadata))) ] -- Submit tx @@ -351,7 +352,9 @@ spec = describe "NEW_SHELLEY_TRANSACTIONS" $ do (`shouldBe` (fromIntegral oneMillionAda - expectedFee)) ] - it "TRANS_NEW_CREATE_02b - Only metadata, untyped" $ \ctx -> runResourceT $ do + it "TRANS_NEW_CREATE_02b - Only metadata, untyped" $ + \ctx -> runResourceT $ do + wa <- fixtureWallet ctx let metadata = Json [json|{ "metadata": { "1": "hello" } }|] @@ -368,15 +371,13 @@ spec = describe "NEW_SHELLEY_TRANSACTIONS" $ do signedTx <- signTx ctx wa apiTx [ expectResponseCode HTTP.status202 ] -- Check for the presence of metadata on signed transaction - let - getMetadata (InAnyCardanoEra _ tx) = Cardano.getTxBody tx - & (\(Cardano.TxBody bodyContent) -> - Cardano.txMetadata bodyContent - & \case Cardano.TxMetadataNone -> - Nothing - Cardano.TxMetadataInEra _ (Cardano.TxMetadata m) -> - Just m - ) + let getMetadata (InAnyCardanoEra _ tx) = Cardano.getTxBody tx & + \(Cardano.TxBody bodyContent) -> + Cardano.txMetadata bodyContent & \case + Cardano.TxMetadataNone -> + Nothing + Cardano.TxMetadataInEra _ (Cardano.TxMetadata m) -> + Just m case getMetadata (cardanoTx $ getApiT (signedTx ^. #transaction)) of Nothing -> error "Tx doesn't include metadata" @@ -385,7 +386,8 @@ spec = describe "NEW_SHELLEY_TRANSACTIONS" $ do Just (Cardano.TxMetaText "hello") -> pure () Just _ -> error "Tx metadata incorrect" - let txCbor = getFromResponse #transaction (HTTP.status202, Right signedTx) + let txCbor = + getFromResponse #transaction (HTTP.status202, Right signedTx) let decodePayload = Json (toJSON $ ApiSerialisedTransaction txCbor) let expMetadata = ApiT (TxMetadata (Map.fromList [(1,TxMetaText "hello")])) rDecodedTx <- request @(ApiDecodedTransaction n) ctx @@ -409,8 +411,8 @@ spec = describe "NEW_SHELLEY_TRANSACTIONS" $ do verify rWa [ expectSuccess , expectField - (#balance . #available . #getQuantity) - (`shouldBe` (fromIntegral oneMillionAda - expectedFee)) + (#balance . #available . #getQuantity) + (`shouldBe` (fromIntegral oneMillionAda - expectedFee)) ] it "TRANS_NEW_CREATE_03a - Withdrawal from self, 0 rewards" $ \ctx -> runResourceT $ do diff --git a/lib/core-integration/src/Test/Integration/Scenario/CLI/Shelley/Transactions.hs b/lib/core-integration/src/Test/Integration/Scenario/CLI/Shelley/Transactions.hs index 56a692cc1b7..67bf87774bb 100644 --- a/lib/core-integration/src/Test/Integration/Scenario/CLI/Shelley/Transactions.hs +++ b/lib/core-integration/src/Test/Integration/Scenario/CLI/Shelley/Transactions.hs @@ -25,12 +25,12 @@ import Cardano.Wallet.Api.Types , EncodeAddress (..) , getApiT ) +import Cardano.Wallet.Api.Types.SchemaMetadata + ( detailedMetadata, noSchemaMetadata ) import Cardano.Wallet.Primitive.Types ( SortOrder (..) ) import Cardano.Wallet.Primitive.Types.Tx ( Direction (..), TxMetadata (..), TxMetadataValue (..), TxStatus (..) ) -import Cardano.Wallet.Api.Types.SchemaMetadata - ( detailedMetadata, noSchemaMetadata ) import Control.Monad ( forM_, join ) import Control.Monad.IO.Class @@ -114,6 +114,7 @@ import Test.Integration.Framework.TestData ) import UnliftIO.Exception ( throwString ) + import qualified Data.Map as Map import qualified Data.Text as T @@ -318,7 +319,10 @@ spec = describe "SHELLEY_CLI_TRANSACTIONS" $ do out `shouldBe` "" c `shouldBe` ExitFailure 1 - it "TRANSMETA_CREATE_01a - Transaction with metadata via CLI" $ \ctx -> runResourceT $ do + it "TRANSMETA_CREATE_01a - \ + \Transaction with metadata via CLI" $ + \ctx -> runResourceT $ do + (wSrc, wDest) <- (,) <$> fixtureWallet ctx <*> emptyWallet ctx let amt = 10_000_000 let md = Just "{ \"1\": { \"string\": \"hello\" } }" @@ -351,10 +355,15 @@ spec = describe "SHELLEY_CLI_TRANSACTIONS" $ do verify outJson [ expectCliListField 0 #metadata (`shouldBe` expected) - , expectCliListField 0 (#status . #getApiT) (`shouldBe` InLedger) + , expectCliListField 0 + (#status . #getApiT) + (`shouldBe` InLedger) ] - it "TRANSMETA_CREATE_01b - Transaction with metadata via CLI with simple metadata" $ \ctx -> runResourceT $ do + it "TRANSMETA_CREATE_01b - \ + \Transaction with metadata via CLI with simple metadata" $ + \ctx -> runResourceT $ do + (wSrc, wDest) <- (,) <$> fixtureWallet ctx <*> emptyWallet ctx let amt = 10_000_000 let md = Just "{ \"1\": { \"string\": \"hello\" } }" @@ -365,7 +374,8 @@ spec = describe "SHELLEY_CLI_TRANSACTIONS" $ do args <- postTxArgs ctx wSrc wDest amt md Nothing Stdout feeOut <- postTransactionFeeViaCLI ctx args - ApiFee (Quantity feeMin) (Quantity feeMax) _ _ <- expectValidJSON Proxy feeOut + ApiFee (Quantity feeMin) (Quantity feeMax) _ _ <- + expectValidJSON Proxy feeOut txJson <- postTxViaCLI ctx wSrc wDest amt md Nothing verify txJson @@ -380,7 +390,8 @@ spec = describe "SHELLEY_CLI_TRANSACTIONS" $ do let wSrcId = T.unpack (wSrc ^. walletId) let txId = getTxId txJson - (Exit code, Stdout out, Stderr err) <- getTransactionViaCLI ctx wSrcId txId True + (Exit code, Stdout out, Stderr err) <- + getTransactionViaCLI ctx wSrcId txId True err `shouldBe` "Ok.\n" code `shouldBe` ExitSuccess outJson <- expectValidJSON (Proxy @(ApiTransaction n)) out @@ -408,9 +419,6 @@ spec = describe "SHELLEY_CLI_TRANSACTIONS" $ do , expectCliListField 0 (#status . #getApiT) (`shouldBe` InLedger) ] - - - it "TRANSTTL_CREATE_01 - Transaction with TTL via CLI" $ \ctx -> runResourceT $ do (wSrc, wDest) <- (,) <$> fixtureWallet ctx <*> emptyWallet ctx let amt = 10_000_000 @@ -656,7 +664,8 @@ spec = describe "SHELLEY_CLI_TRANSACTIONS" $ do describe "TRANS_LIST_04 - False wallet ids" $ do forM_ falseWalletIds $ \(title, walId) -> it title $ \ctx -> runResourceT $ do - (Exit c, Stdout o, Stderr e) <- listTransactionsViaCLI ctx False [walId] + (Exit c, Stdout o, Stderr e) <- + listTransactionsViaCLI ctx False [walId] o `shouldBe` "" c `shouldBe` ExitFailure 1 if (title == "40 chars hex") then @@ -677,13 +686,13 @@ spec = describe "SHELLEY_CLI_TRANSACTIONS" $ do [ "--start", utcIso8601ToText t1 , "--end", utcIso8601ToText t2 ] - Stdout o1 <- listTransactionsViaCLI ctx False + Stdout o1 <- listTransactionsViaCLI ctx False ( T.unpack <$> walId : (query t t) ) - Stdout o2 <- listTransactionsViaCLI ctx False + Stdout o2 <- listTransactionsViaCLI ctx False ( T.unpack <$> walId : (query te t) ) - Stdout o3 <- listTransactionsViaCLI ctx False + Stdout o3 <- listTransactionsViaCLI ctx False ( T.unpack <$> walId : (query t tl) ) - Stdout o4 <- listTransactionsViaCLI ctx False + Stdout o4 <- listTransactionsViaCLI ctx False ( T.unpack <$> walId : (query te tl) ) oJson1 <- expectValidJSON (Proxy @([ApiTransaction n])) o1 oJson2 <- expectValidJSON (Proxy @([ApiTransaction n])) o2 @@ -698,9 +707,9 @@ spec = describe "SHELLEY_CLI_TRANSACTIONS" $ do let walId = w ^. walletId t <- unsafeGetTransactionTime =<< listAllTransactions @n ctx w let tl = utcIso8601ToText $ utcTimeSucc t - Stdout o1 <- listTransactionsViaCLI ctx False + Stdout o1 <- listTransactionsViaCLI ctx False ( T.unpack <$> [walId, "--start", tl] ) - Stdout o2 <- listTransactionsViaCLI ctx False + Stdout o2 <- listTransactionsViaCLI ctx False ( T.unpack <$> [walId, "--start", tl, "--end", tl] ) oJson1 <- expectValidJSON (Proxy @([ApiTransaction n])) o1 oJson2 <- expectValidJSON (Proxy @([ApiTransaction n])) o2 @@ -713,9 +722,9 @@ spec = describe "SHELLEY_CLI_TRANSACTIONS" $ do let walId = w ^. walletId t <- unsafeGetTransactionTime =<< listAllTransactions @n ctx w let te = utcIso8601ToText $ utcTimePred t - Stdout o1 <- listTransactionsViaCLI ctx False + Stdout o1 <- listTransactionsViaCLI ctx False ( T.unpack <$> [walId, "--end", te] ) - Stdout o2 <- listTransactionsViaCLI ctx False + Stdout o2 <- listTransactionsViaCLI ctx False ( T.unpack <$> [walId, "--start", te, "--end", te] ) oJson1 <- expectValidJSON (Proxy @([ApiTransaction n])) o1 oJson2 <- expectValidJSON (Proxy @([ApiTransaction n])) o2 @@ -757,7 +766,7 @@ spec = describe "SHELLEY_CLI_TRANSACTIONS" $ do -- Verify Tx in source wallet is Outgoing and InLedger (Exit code1, Stdout out1, Stderr err1) <- - getTransactionViaCLI ctx wSrcId txId False + getTransactionViaCLI ctx wSrcId txId False err1 `shouldBe` "Ok.\n" code1 `shouldBe` ExitSuccess outJson1 <- expectValidJSON (Proxy @(ApiTransaction n)) out1 @@ -769,7 +778,7 @@ spec = describe "SHELLEY_CLI_TRANSACTIONS" $ do let wDestId = T.unpack (wDest ^. walletId) -- Verify Tx in destination wallet is Incoming and InLedger (Exit code2, Stdout out2, Stderr err2) <- - getTransactionViaCLI ctx wDestId txId False + getTransactionViaCLI ctx wDestId txId False err2 `shouldBe` "Ok.\n" code2 `shouldBe` ExitSuccess outJson2 <- expectValidJSON (Proxy @(ApiTransaction n)) out2 @@ -810,7 +819,8 @@ spec = describe "SHELLEY_CLI_TRANSACTIONS" $ do let wid = T.unpack (wSrc ^. walletId) let txId = "3e6ec12da4414aa0781ff8afa9717ae53ee8cb4aa55d622f65bc62619a4f7b12" - (Exit c2, Stdout o2, Stderr e2) <- getTransactionViaCLI ctx wid txId False + (Exit c2, Stdout o2, Stderr e2) <- + getTransactionViaCLI ctx wid txId False e2 `shouldContain` errMsg404CannotFindTx (T.pack txId) o2 `shouldBe` mempty c2 `shouldBe` ExitFailure 1 diff --git a/lib/core/src/Cardano/Wallet/Api.hs b/lib/core/src/Cardano/Wallet/Api.hs index ec77195c3e7..f7cd74bd87e 100644 --- a/lib/core/src/Cardano/Wallet/Api.hs +++ b/lib/core/src/Cardano/Wallet/Api.hs @@ -584,14 +584,14 @@ type ListTransactions n = "wallets" :> QueryParam "start" Iso8601Time :> QueryParam "end" Iso8601Time :> QueryParam "order" (ApiT SortOrder) - :> QueryFlag "simple-metadata" + :> QueryFlag "simple-metadata" :> Get '[JSON] [ApiTransactionT n] -- | https://input-output-hk.github.io/cardano-wallet/api/#operation/getTransaction type GetTransaction n = "wallets" :> Capture "walletId" (ApiT WalletId) :> "transactions" - :> QueryFlag "simple-metadata" + :> QueryFlag "simple-metadata" :> Capture "transactionId" ApiTxId :> Get '[JSON] (ApiTransactionT n) diff --git a/lib/core/src/Cardano/Wallet/Api/Client.hs b/lib/core/src/Cardano/Wallet/Api/Client.hs index 959ea140b60..020fd8bc1f9 100644 --- a/lib/core/src/Cardano/Wallet/Api/Client.hs +++ b/lib/core/src/Cardano/Wallet/Api/Client.hs @@ -163,7 +163,7 @@ data TransactionClient = TransactionClient -> Maybe Iso8601Time -> Maybe Iso8601Time -> Maybe (ApiT SortOrder) - -> Bool + -> Bool -> ClientM [ApiTransactionT Aeson.Value] , signTransaction :: ApiT WalletId @@ -363,7 +363,8 @@ byronTransactionClient = = client (Proxy @("v2" :> Proxy_)) in TransactionClient - { listTransactions = \wid start end order _ -> _listTransactions wid start end order + { listTransactions = \wid start end order _ -> + _listTransactions wid start end order , signTransaction = _signTransaction , postTransaction = _postTransaction , postTransactionFee = _postTransactionFee diff --git a/lib/core/src/Cardano/Wallet/Api/Link.hs b/lib/core/src/Cardano/Wallet/Api/Link.hs index a30d99da740..2ccc15d2298 100644 --- a/lib/core/src/Cardano/Wallet/Api/Link.hs +++ b/lib/core/src/Cardano/Wallet/Api/Link.hs @@ -627,13 +627,13 @@ listTransactions' listTransactions' w minWithdrawal inf sup order = discriminate @style (endpoint @(Api.ListTransactions Net) (\mk -> mk - wid - (MinWithdrawal <$> minWithdrawal) - inf - sup + wid + (MinWithdrawal <$> minWithdrawal) + inf + sup (ApiT <$> order) False - ) + ) ) (endpoint @(Api.ListByronTransactions Net) (\mk -> mk wid inf sup (ApiT <$> order))) @@ -696,9 +696,7 @@ getTransaction w t s = discriminate @style mkByronURL mk = mk wid tid mkShelleyURL :: (ApiT WalletId -> Bool -> ApiTxId -> Text) -> Text - mkShelleyURL mk = mk wid s tid - - + mkShelleyURL mk = mk wid s tid createUnsignedTransaction :: forall style w. diff --git a/lib/core/src/Cardano/Wallet/Api/Server.hs b/lib/core/src/Cardano/Wallet/Api/Server.hs index 5bc21ec53ce..b08e52b06cd 100644 --- a/lib/core/src/Cardano/Wallet/Api/Server.hs +++ b/lib/core/src/Cardano/Wallet/Api/Server.hs @@ -1,4 +1,5 @@ {-# LANGUAGE AllowAmbiguousTypes #-} +{-# LANGUAGE BlockArguments #-} {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} @@ -15,7 +16,6 @@ {-# LANGUAGE TypeApplications #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} -{-# LANGUAGE BlockArguments #-} -- | -- Copyright: © 2018-2020 IOHK @@ -331,6 +331,10 @@ import Cardano.Wallet.Api.Types , toApiNetworkParameters , toApiUtxoStatistics ) +import Cardano.Wallet.Api.Types.SchemaMetadata + ( TxMetadataSchema (TxMetadataDetailedSchema, TxMetadataNoSchema) + , TxMetadataWithSchema (TxMetadataWithSchema) + ) import Cardano.Wallet.CoinSelection ( SelectionBalanceError (..) , SelectionCollateralError @@ -684,7 +688,6 @@ import qualified Data.Text as T import qualified Data.Text.Encoding as T import qualified Network.Wai.Handler.Warp as Warp import qualified Network.Wai.Handler.WarpTLS as Warp -import Cardano.Wallet.Api.Types.SchemaMetadata (TxMetadataWithSchema(TxMetadataWithSchema), TxMetadataSchema (TxMetadataDetailedSchema, TxMetadataNoSchema)) -- | How the server should listen for incoming requests. data Listen @@ -2004,7 +2007,7 @@ postTransactionOld postTransactionOld ctx genChange (ApiT wid) body = do let pwd = coerce $ body ^. #passphrase . #getApiT let outs = addressAmountToTxOut <$> body ^. #payments - let md = body ^? #metadata . traverse . #txMetadataWithSchema_metadata + let md = body ^? #metadata . traverse . #txMetadataWithSchema_metadata let mTTL = body ^? #timeToLive . traverse . #getQuantity (wdrl, mkRwdAcct) <- @@ -2082,12 +2085,12 @@ deleteTransaction ctx (ApiT wid) (ApiTxId (ApiT (tid))) = do listTransactions :: forall ctx s k n. (ctx ~ ApiLayer s k) - => ctx -- ^ - -> ApiT WalletId -- ^ - -> Maybe MinWithdrawal -- ^ - -> Maybe Iso8601Time -- ^ - -> Maybe Iso8601Time -- ^ - -> Maybe (ApiT SortOrder) -- ^ + => ctx -- ^ + -> ApiT WalletId -- ^ + -> Maybe MinWithdrawal -- ^ + -> Maybe Iso8601Time -- ^ + -> Maybe Iso8601Time -- ^ + -> Maybe (ApiT SortOrder) -- ^ -> Bool -- ^ metadata json schema -> Handler [ApiTransaction n] listTransactions ctx (ApiT wid) mMinWithdrawal mStart mEnd mOrder metadataSchema = do @@ -2100,15 +2103,15 @@ listTransactions ctx (ApiT wid) mMinWithdrawal mStart mEnd mOrder metadataSchema (maybe defaultSortOrder getApiT mOrder) depo <- liftIO $ W.stakeKeyDeposit <$> NW.currentProtocolParameters (wrk ^. networkLayer) pure (txs, depo) - liftIO $ forM txs $ \tx -> - mkApiTransactionFromInfo - (timeInterpreter (ctx ^. networkLayer)) - depo - tx - if metadataSchema - then TxMetadataNoSchema + liftIO $ forM txs $ \tx -> + mkApiTransactionFromInfo + (timeInterpreter (ctx ^. networkLayer)) + depo + tx + if metadataSchema + then TxMetadataNoSchema else TxMetadataDetailedSchema - + where defaultSortOrder :: SortOrder defaultSortOrder = Descending @@ -2125,8 +2128,12 @@ getTransaction ctx (ApiT wid) mMetadataSchema (ApiTxId (ApiT (tid))) = do tx <- liftHandler $ W.getTransaction wrk wid tid depo <- liftIO $ W.stakeKeyDeposit <$> NW.currentProtocolParameters (wrk ^. networkLayer) pure (tx, depo) - liftIO $ mkApiTransactionFromInfo (timeInterpreter (ctx ^. networkLayer)) depo tx - $ if mMetadataSchema then TxMetadataNoSchema else TxMetadataDetailedSchema + liftIO + $ mkApiTransactionFromInfo + (timeInterpreter (ctx ^. networkLayer)) depo tx + $ if mMetadataSchema + then TxMetadataNoSchema + else TxMetadataDetailedSchema -- Populate an API transaction record with 'TransactionInfo' from the wallet -- layer. @@ -2135,11 +2142,11 @@ mkApiTransactionFromInfo => TimeInterpreter (ExceptT PastHorizonException IO) -> Coin -> TransactionInfo - -> TxMetadataSchema + -> TxMetadataSchema -> m (ApiTransaction n) mkApiTransactionFromInfo ti deposit info metadataSchema = do - apiTx <- liftIO $ mkApiTransaction - ti + apiTx <- liftIO $ mkApiTransaction + ti status MkApiTransactionParams { txId = info ^. #txInfoId @@ -2154,7 +2161,7 @@ mkApiTransactionFromInfo ti deposit info metadataSchema = do , txTime = info ^. #txInfoTime , txScriptValidity = info ^. #txInfoScriptValidity , txDeposit = deposit - , txMetadataSchema = metadataSchema + , txMetadataSchema = metadataSchema } return $ case info ^. (#txInfoMeta . #status) of Pending -> apiTx @@ -2185,7 +2192,10 @@ postTransactionFeeOld ctx (ApiT wid) body = do (wdrl, _) <- mkRewardAccountBuilder @_ @s @_ @n ctx wid (body ^. #withdrawal) let txCtx = defaultTransactionCtx { txWithdrawal = wdrl - , txMetadata = body ^? #metadata . traverse . #txMetadataWithSchema_metadata + , txMetadata + = body ^? #metadata + . traverse + . #txMetadataWithSchema_metadata } withWorkerCtx ctx wid liftE liftE $ \wrk -> do (utxoAvailable, wallet, pendingTxs) <- @@ -2982,7 +2992,7 @@ joinStakePool ctx knownPools getPoolStatus apiPoolId (ApiT wid) body = do , txTime , txScriptValidity = tx ^. #scriptValidity , txDeposit = W.stakeKeyDeposit pp - , txMetadataSchema = TxMetadataDetailedSchema + , txMetadataSchema = TxMetadataDetailedSchema } where ti :: TimeInterpreter (ExceptT PastHorizonException IO) @@ -3100,8 +3110,8 @@ quitStakePool ctx (ApiT wid) body = do , txTime , txScriptValidity = tx ^. #scriptValidity , txDeposit = W.stakeKeyDeposit pp - , txMetadataSchema = TxMetadataDetailedSchema - } + , txMetadataSchema = TxMetadataDetailedSchema + } where ti :: TimeInterpreter (ExceptT PastHorizonException IO) ti = timeInterpreter (ctx ^. networkLayer) @@ -3358,7 +3368,7 @@ migrateWallet ctx withdrawalType (ApiT wid) postData = do , txTime , txScriptValidity = tx ^. #scriptValidity , txDeposit = W.stakeKeyDeposit pp - , txMetadataSchema = TxMetadataDetailedSchema + , txMetadataSchema = TxMetadataDetailedSchema } where addresses = getApiT . fst <$> view #addresses postData @@ -3815,7 +3825,7 @@ data MkApiTransactionParams = MkApiTransactionParams , txTime :: UTCTime , txScriptValidity :: Maybe W.TxScriptValidity , txDeposit :: Coin - , txMetadataSchema :: TxMetadataSchema + , txMetadataSchema :: TxMetadataSchema } deriving (Eq, Generic, Show) @@ -3866,7 +3876,8 @@ mkApiTransaction timeInterpreter setTimeReference tx = do toAddressAmount @n <$> tx ^. #txCollateralOutput , withdrawals = mkApiWithdrawal @n <$> Map.toList (tx ^. #txWithdrawals) , status = ApiT (tx ^. (#txMeta . #status)) - , metadata = TxMetadataWithSchema (tx ^. #txMetadataSchema) <$> tx ^. #txMetadata + , metadata = TxMetadataWithSchema (tx ^. #txMetadataSchema) + <$> tx ^. #txMetadata , scriptValidity = ApiT <$> tx ^. #txScriptValidity } diff --git a/lib/core/src/Cardano/Wallet/Api/Types.hs b/lib/core/src/Cardano/Wallet/Api/Types.hs index b66bc95c8da..3ee6bd30295 100644 --- a/lib/core/src/Cardano/Wallet/Api/Types.hs +++ b/lib/core/src/Cardano/Wallet/Api/Types.hs @@ -270,6 +270,8 @@ import Cardano.Mnemonic , mnemonicToText , natVals ) +import Cardano.Wallet.Api.Types.SchemaMetadata + ( TxMetadataWithSchema ) import Cardano.Wallet.Primitive.AddressDerivation ( Depth (..) , DerivationIndex (..) @@ -482,7 +484,6 @@ import qualified Data.Map as Map import qualified Data.Text as T import qualified Data.Text.Encoding as T import qualified Data.Text.Read as T -import Cardano.Wallet.Api.Types.SchemaMetadata {------------------------------------------------------------------------------- Styles of Wallets diff --git a/lib/core/src/Cardano/Wallet/Api/Types/SchemaMetadata.hs b/lib/core/src/Cardano/Wallet/Api/Types/SchemaMetadata.hs index 4aca8ab4b1d..e2524809d91 100644 --- a/lib/core/src/Cardano/Wallet/Api/Types/SchemaMetadata.hs +++ b/lib/core/src/Cardano/Wallet/Api/Types/SchemaMetadata.hs @@ -23,6 +23,7 @@ import Cardano.Api , metadataToJson ) import Cardano.Wallet.Primitive.Types.Tx + ( TxMetadata ) import Control.Applicative ( liftA2, (<|>) ) import Control.DeepSeq @@ -35,20 +36,22 @@ import Prelude -- | a tag to select the json codec data TxMetadataSchema = TxMetadataNoSchema | TxMetadataDetailedSchema - deriving (Show, Eq, Generic, NFData) + deriving (Show, Eq, Generic, NFData) -- | a wrapper to drive the json codec of metadata data TxMetadataWithSchema = TxMetadataWithSchema - { -- | how to codec the metadata into json - txMetadataWithSchema_schema :: TxMetadataSchema - , -- | the metadata - txMetadataWithSchema_metadata :: TxMetadata - } - deriving (Show, Eq, Generic, NFData) + { -- | how to codec the metadata into json + txMetadataWithSchema_schema :: TxMetadataSchema + , -- | the metadata + txMetadataWithSchema_metadata :: TxMetadata + } + deriving (Show, Eq, Generic, NFData) instance ToJSON TxMetadataWithSchema where - toJSON (TxMetadataWithSchema TxMetadataDetailedSchema x) = metadataToJson TxMetadataJsonDetailedSchema x - toJSON (TxMetadataWithSchema TxMetadataNoSchema x) = metadataToJson TxMetadataJsonNoSchema x + toJSON (TxMetadataWithSchema TxMetadataDetailedSchema x) = + metadataToJson TxMetadataJsonDetailedSchema x + toJSON (TxMetadataWithSchema TxMetadataNoSchema x) = + metadataToJson TxMetadataJsonNoSchema x detailedMetadata :: TxMetadata -> TxMetadataWithSchema detailedMetadata = TxMetadataWithSchema TxMetadataDetailedSchema @@ -57,13 +60,13 @@ noSchemaMetadata :: TxMetadata -> TxMetadataWithSchema noSchemaMetadata = TxMetadataWithSchema TxMetadataNoSchema instance FromJSON TxMetadataWithSchema where - parseJSON = liftA2 - do (<|>) - do - fmap detailedMetadata - . either (fail . displayError) pure - . metadataFromJson TxMetadataJsonDetailedSchema - do - fmap noSchemaMetadata - . either (fail . displayError) pure - . metadataFromJson TxMetadataJsonNoSchema + parseJSON = liftA2 + do (<|>) + do + fmap detailedMetadata + . either (fail . displayError) pure + . metadataFromJson TxMetadataJsonDetailedSchema + do + fmap noSchemaMetadata + . either (fail . displayError) pure + . metadataFromJson TxMetadataJsonNoSchema diff --git a/lib/core/test/unit/Cardano/Wallet/Api/TypesSpec.hs b/lib/core/test/unit/Cardano/Wallet/Api/TypesSpec.hs index 8d870d93704..fea767fcedd 100644 --- a/lib/core/test/unit/Cardano/Wallet/Api/TypesSpec.hs +++ b/lib/core/test/unit/Cardano/Wallet/Api/TypesSpec.hs @@ -50,7 +50,6 @@ import Cardano.Mnemonic , entropyToMnemonic , mkEntropy ) -import Cardano.Wallet.Api.Types.SchemaMetadata import Cardano.Wallet.Api ( Api ) import Cardano.Wallet.Api.Types @@ -200,6 +199,8 @@ import Cardano.Wallet.Api.Types , WalletPutPassphraseData (..) , toApiAsset ) +import Cardano.Wallet.Api.Types.SchemaMetadata + ( TxMetadataSchema (..), TxMetadataWithSchema (..) ) import Cardano.Wallet.Gen ( genMnemonic , genNatural @@ -2158,8 +2159,8 @@ instance Arbitrary (PostTransactionOldData n) where <*> arbitrary <*> arbitrary -instance Arbitrary TxMetadataWithSchema where - arbitrary = TxMetadataWithSchema +instance Arbitrary TxMetadataWithSchema where + arbitrary = TxMetadataWithSchema <$> elements [TxMetadataNoSchema, TxMetadataDetailedSchema] <*> arbitrary diff --git a/lib/shelley/bench/latency-bench.hs b/lib/shelley/bench/latency-bench.hs index cf773661712..2eb7f94f912 100644 --- a/lib/shelley/bench/latency-bench.hs +++ b/lib/shelley/bench/latency-bench.hs @@ -311,8 +311,11 @@ walletApiBench capture ctx = do (_, txs) <- unsafeRequest @[ApiTransaction n] ctx (Link.listTransactions @'Shelley wal1) Empty let txid = (head txs) ^. #id - t5a <- measureApiLogs capture - (request @[ApiTransaction n] ctx (Link.getTransaction @'Shelley wal1 (ApiTxId txid)) Default Empty) + t5a <- measureApiLogs capture $ + request @[ApiTransaction n] + ctx (Link.getTransaction @'Shelley wal1 (ApiTxId txid) False) + Default + Empty fmtResult "getTransaction " t5a (_, addrs) <- unsafeRequest @[ApiAddress n] ctx (Link.listAddresses @'Shelley wal2) Empty diff --git a/nix/materialized/stack-nix/cardano-wallet-core.nix b/nix/materialized/stack-nix/cardano-wallet-core.nix index c3752048f0e..f87ccf674e6 100644 --- a/nix/materialized/stack-nix/cardano-wallet-core.nix +++ b/nix/materialized/stack-nix/cardano-wallet-core.nix @@ -173,6 +173,7 @@ "Cardano/Wallet/Api/Server" "Cardano/Wallet/Api/Server/Tls" "Cardano/Wallet/Api/Types" + "Cardano/Wallet/Api/Types/SchemaMetadata" "Cardano/Wallet/CoinSelection" "Cardano/Wallet/CoinSelection/Internal" "Cardano/Wallet/CoinSelection/Internal/Balance"