Skip to content

Commit c5b3080

Browse files
authored
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
1 parent e2f78cf commit c5b3080

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

cabal.project

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ source-repository-package
1818
source-repository-package
1919
type: git
2020
location: https://github.com/kadena-io/chainweb-api.git
21-
tag: 9a62ce26c5d71343bcad17b4ef0d7c27bb536791
22-
--sha256: sha256-qzS6oIJaTzeIHrUnQrV3gBvy5SvWQc8rujxpRvoXC3s=
21+
tag: ef2bee367136e298dfb45ea118d122350e7b3bc7
22+
--sha256: sha256-VQ/JhpZaINeTZHNt7TZ9WaVGIXJEf9bDQ51cSG+auVI=
2323

2424
source-repository-package
2525
type: git

haskell-src/exec/Chainweb/Server.hs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ import Text.Printf
6060
------------------------------------------------------------------------------
6161
import Chainweb.Api.Common (BlockHeight)
6262
import Chainweb.Api.StringEncoded (StringEncoded(..))
63+
import qualified Chainweb.Api.Sig as Api
6364
import qualified Chainweb.Api.Signer as Api
6465
import Chainweb.Coins
6566
import ChainwebDb.Database
@@ -351,8 +352,9 @@ toApiTxDetail ::
351352
Block ->
352353
[Event] ->
353354
[Api.Signer] ->
355+
[Api.Sig] ->
354356
TxDetail
355-
toApiTxDetail tx contHist blk evs signers = TxDetail
357+
toApiTxDetail tx contHist blk evs signers sigs = TxDetail
356358
{ _txDetail_ttl = fromIntegral $ _tx_ttl tx
357359
, _txDetail_gasLimit = fromIntegral $ _tx_gasLimit tx
358360
, _txDetail_gasPrice = _tx_gasPrice tx
@@ -383,6 +385,7 @@ toApiTxDetail tx contHist blk evs signers = TxDetail
383385
, _txDetail_initialCode = chCode contHist
384386
, _txDetail_previousSteps = V.toList (chSteps contHist) <$ chCode contHist
385387
, _txDetail_signers = signers
388+
, _txDetail_sigs = sigs
386389
}
387390
where
388391
unMaybeValue = maybe Null unPgJsonb
@@ -429,9 +432,10 @@ queryTxsByKey logger rk c =
429432
, Api._signer_pubKey = _signer_pubkey s
430433
, Api._signer_capList = caps
431434
}
435+
let sigs = Api.Sig . unSignature . _signer_sig <$> dbSigners
432436

433437
return $ (`fmap` r) $ \(tx,contHist, blk) ->
434-
toApiTxDetail tx contHist blk evs signers
438+
toApiTxDetail tx contHist blk evs signers sigs
435439

436440
queryTxsByPactId :: LogFunctionIO Text -> Limit -> Text -> Connection -> IO [TxSummary]
437441
queryTxsByPactId logger limit pactid c =

haskell-src/lib/ChainwebData/Spec.hs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import Data.OpenApi.Schema
2424
import Servant.OpenApi
2525
import ChainwebData.Pagination
2626
import Chainweb.Api.ChainId
27+
import Chainweb.Api.Sig
2728
import Chainweb.Api.Signer
2829
import ChainwebData.TxSummary
2930
import Data.OpenApi
@@ -100,6 +101,14 @@ instance ToSchema SigCapability where
100101
]
101102
& required .~ ["name", "args"]
102103

104+
instance ToSchema Sig where
105+
declareNamedSchema _ = do
106+
textSchema <- declareSchemaRef (Proxy :: Proxy T.Text)
107+
return $ NamedSchema (Just "Sig") $ mempty
108+
& type_ ?~ OpenApiObject
109+
& properties .~ [ ("sig", textSchema) ]
110+
& required .~ ["sig"]
111+
103112
instance ToSchema (StringEncoded Scientific) where
104113
declareNamedSchema _ = pure $ NamedSchema (Just "StringEncodedNumber") $ mempty
105114
& type_ ?~ OpenApiString

0 commit comments

Comments
 (0)