From c5b308079135555813f39d33dd46ef3d7d201f60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enis=20Bayramo=C4=9Flu?= Date: Tue, 1 Aug 2023 16:23:22 +0200 Subject: [PATCH] Add sigs field to tx detail responses (#153) This PR is an amendment to #152, where we omitted the `sigs` field by oversight. * Add sigs field to tx detail responses * Bump CWA pin after merging API changes --- cabal.project | 4 ++-- haskell-src/exec/Chainweb/Server.hs | 8 ++++++-- haskell-src/lib/ChainwebData/Spec.hs | 9 +++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/cabal.project b/cabal.project index 560f6109..bde5753d 100644 --- a/cabal.project +++ b/cabal.project @@ -18,8 +18,8 @@ source-repository-package source-repository-package type: git location: https://github.com/kadena-io/chainweb-api.git - tag: 9a62ce26c5d71343bcad17b4ef0d7c27bb536791 - --sha256: sha256-qzS6oIJaTzeIHrUnQrV3gBvy5SvWQc8rujxpRvoXC3s= + tag: ef2bee367136e298dfb45ea118d122350e7b3bc7 + --sha256: sha256-VQ/JhpZaINeTZHNt7TZ9WaVGIXJEf9bDQ51cSG+auVI= source-repository-package type: git diff --git a/haskell-src/exec/Chainweb/Server.hs b/haskell-src/exec/Chainweb/Server.hs index d9c27ed0..e73a5c7e 100644 --- a/haskell-src/exec/Chainweb/Server.hs +++ b/haskell-src/exec/Chainweb/Server.hs @@ -60,6 +60,7 @@ import Text.Printf ------------------------------------------------------------------------------ import Chainweb.Api.Common (BlockHeight) import Chainweb.Api.StringEncoded (StringEncoded(..)) +import qualified Chainweb.Api.Sig as Api import qualified Chainweb.Api.Signer as Api import Chainweb.Coins import ChainwebDb.Database @@ -351,8 +352,9 @@ toApiTxDetail :: Block -> [Event] -> [Api.Signer] -> + [Api.Sig] -> TxDetail -toApiTxDetail tx contHist blk evs signers = TxDetail +toApiTxDetail tx contHist blk evs signers sigs = TxDetail { _txDetail_ttl = fromIntegral $ _tx_ttl tx , _txDetail_gasLimit = fromIntegral $ _tx_gasLimit tx , _txDetail_gasPrice = _tx_gasPrice tx @@ -383,6 +385,7 @@ toApiTxDetail tx contHist blk evs signers = TxDetail , _txDetail_initialCode = chCode contHist , _txDetail_previousSteps = V.toList (chSteps contHist) <$ chCode contHist , _txDetail_signers = signers + , _txDetail_sigs = sigs } where unMaybeValue = maybe Null unPgJsonb @@ -429,9 +432,10 @@ queryTxsByKey logger rk c = , Api._signer_pubKey = _signer_pubkey s , Api._signer_capList = caps } + let sigs = Api.Sig . unSignature . _signer_sig <$> dbSigners return $ (`fmap` r) $ \(tx,contHist, blk) -> - toApiTxDetail tx contHist blk evs signers + toApiTxDetail tx contHist blk evs signers sigs queryTxsByPactId :: LogFunctionIO Text -> Limit -> Text -> Connection -> IO [TxSummary] queryTxsByPactId logger limit pactid c = diff --git a/haskell-src/lib/ChainwebData/Spec.hs b/haskell-src/lib/ChainwebData/Spec.hs index 17c992e5..666a669b 100644 --- a/haskell-src/lib/ChainwebData/Spec.hs +++ b/haskell-src/lib/ChainwebData/Spec.hs @@ -24,6 +24,7 @@ import Data.OpenApi.Schema import Servant.OpenApi import ChainwebData.Pagination import Chainweb.Api.ChainId +import Chainweb.Api.Sig import Chainweb.Api.Signer import ChainwebData.TxSummary import Data.OpenApi @@ -100,6 +101,14 @@ instance ToSchema SigCapability where ] & required .~ ["name", "args"] +instance ToSchema Sig where + declareNamedSchema _ = do + textSchema <- declareSchemaRef (Proxy :: Proxy T.Text) + return $ NamedSchema (Just "Sig") $ mempty + & type_ ?~ OpenApiObject + & properties .~ [ ("sig", textSchema) ] + & required .~ ["sig"] + instance ToSchema (StringEncoded Scientific) where declareNamedSchema _ = pure $ NamedSchema (Just "StringEncodedNumber") $ mempty & type_ ?~ OpenApiString