Skip to content

Commit

Permalink
Add sigs field to tx detail responses (#153)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
enobayram authored Aug 1, 2023
1 parent e2f78cf commit c5b3080
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions haskell-src/exec/Chainweb/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 =
Expand Down
9 changes: 9 additions & 0 deletions haskell-src/lib/ChainwebData/Spec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c5b3080

Please sign in to comment.