Skip to content

Commit af4bd12

Browse files
committed
Implemented Publisher.createGcFsTx
1 parent 15bb965 commit af4bd12

File tree

4 files changed

+56
-17
lines changed

4 files changed

+56
-17
lines changed

coop-proto/publisher-service.proto

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ message CreateGcFsTxResponse {
5454
// Error encountered when servicing the request
5555
Error error = 2;
5656
}
57+
message Info {
58+
coop.tx_builder.GcFsInfo tx_builder_info = 1;
59+
}
60+
Info info = 3;
5761
}
5862

5963
message Error {

coop-publisher/app/Coop/Cli/PublisherGrpc.hs

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import Proto.PublisherService (
3737
Publisher,
3838
)
3939
import Proto.PublisherService qualified as PublisherService
40-
import Proto.PublisherService_Fields (fsId, fsIds, fsInfos, fsStoreErr, gcAfter, info, maybe'error, mintFsTx, msg, otherErr, submitter, txBuilderErr, txBuilderInfo)
40+
import Proto.PublisherService_Fields (fsId, fsIds, fsInfos, fsStoreErr, gcAfter, gcFsTx, info, maybe'error, mintFsTx, msg, otherErr, submitter, txBuilderErr, txBuilderInfo)
4141
import Proto.PublisherService_Fields qualified as PublisherService
4242
import Proto.TxBuilderService (FactStatementInfo, TxBuilder)
4343
import Proto.TxBuilderService qualified as TxBuilder
@@ -61,7 +61,7 @@ publisherService :: PublisherGrpcOpts -> IO ()
6161
publisherService opts = do
6262
let handleCreateMintFsTx :: Server.UnaryHandler IO CreateMintFsTxRequest CreateMintFsTxResponse
6363
handleCreateMintFsTx _ req = do
64-
print (show req)
64+
print ("Got from user: " <> show req)
6565
getFsRespOrErr <-
6666
call'
6767
(opts ^. fsStoreAddress)
@@ -73,7 +73,7 @@ publisherService opts = do
7373
return $ defMessage & PublisherService.error .~ err
7474
)
7575
( \(getFsResp :: GetFactStatementResponse) -> do
76-
print (show getFsResp)
76+
print ("Got from FactStatementStore: " <> show getFsResp)
7777
case getFsResp ^. maybe'error of
7878
Nothing -> do
7979
let fsIdToGcAfter = Map.fromList [(fsI ^. fsId, fsI ^. gcAfter) | fsI <- req ^. fsInfos]
@@ -100,7 +100,7 @@ publisherService opts = do
100100
either
101101
(\err -> return $ defMessage & PublisherService.error .~ err)
102102
( \(createMintFsResp :: TxBuilder.CreateMintFsTxResp) -> do
103-
print (show createMintFsResp)
103+
print ("Got from TxBuilder: " <> show getFsResp)
104104
case createMintFsResp ^. maybe'error of
105105
Nothing ->
106106
return $
@@ -119,7 +119,36 @@ publisherService opts = do
119119
getFsRespOrErr
120120

121121
handleCreateGcFsTx :: Server.UnaryHandler IO CreateGcFsTxRequest CreateGcFsTxResponse
122-
handleCreateGcFsTx _ _req = return defMessage
122+
handleCreateGcFsTx _ req = do
123+
print ("Got from user: " <> show req)
124+
let txBuilderReq :: TxBuilder.CreateGcFsTxReq
125+
txBuilderReq =
126+
defMessage
127+
& fsIds .~ req ^. fsIds
128+
& submitter .~ req ^. submitter
129+
createGcFsRespOrErr <-
130+
call'
131+
(opts ^. txBuilderAddress)
132+
(fromInteger . toInteger $ opts ^. txBuilderPort)
133+
(RPC :: RPC TxBuilder "createGcFsTx")
134+
txBuilderReq
135+
either
136+
(\err -> return $ defMessage & PublisherService.error .~ err)
137+
( \(createGcFsResp :: TxBuilder.CreateGcFsTxResp) -> do
138+
print ("Got from TxBuilder: " <> show createGcFsResp)
139+
case createGcFsResp ^. maybe'error of
140+
Nothing ->
141+
return $
142+
(defMessage :: CreateGcFsTxResponse)
143+
& gcFsTx .~ createGcFsResp ^. success . gcFsTx
144+
& info . txBuilderInfo .~ createGcFsResp ^. info
145+
Just er ->
146+
return $
147+
(defMessage :: CreateGcFsTxResponse)
148+
& PublisherService.error . txBuilderErr .~ er
149+
& info . txBuilderInfo .~ createGcFsResp ^. info
150+
)
151+
createGcFsRespOrErr
123152

124153
routes :: [ServiceHandler]
125154
routes =

coop-publisher/aux.sh

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,25 @@ EOF
3535
echo $rawTx > .coop-publisher-cli/signed
3636
}
3737

38-
function run-grpcui {
39-
make-exports
40-
grpcui -insecure -import-path ../coop-proto -proto ../coop-proto/publisher-service.proto localhost:5080
41-
}
38+
function coop-gc-fs {
39+
resp=$(grpcurl -insecure -import-path ../coop-proto -proto ../coop-proto/publisher-service.proto -d @ localhost:5080 coop.publisher.Publisher/createGcFsTx <<EOF
40+
{
41+
"fsIds": ["$(echo -ne someidB | base64)", "$(echo -ne someidA | base64)"],
42+
"submitter": {
43+
"base16": "$SUBMITTER_WALLET"
44+
}
45+
}
4246
43-
function cardano-cli-sign {
44-
cardano-cli transaction sign --tx-file .coop-pab-cli/signed --signing-key-file .wallets/no-plutip-signing-key-$SUBMITTER_WALLET.skey --out-file .coop-pab-cli/ready
47+
EOF
48+
)
49+
echo $resp
50+
rawTx=$(echo $resp | jq '.gcFsTx | .cborHex = .cborBase16 | del(.cborBase16) | .description = "" | .type = "Tx BabbageEra"')
51+
echo $resp | jq '.info'
52+
echo $resp | jq '.error'
53+
echo $rawTx > .coop-publisher-cli/signed
4554
}
4655

47-
function cardano-cli-submit {
48-
cardano-cli transaction submit --tx-file .coop-pab-cli/ready --mainnet
56+
function run-grpcui {
57+
make-exports
58+
grpcui -insecure -import-path ../coop-proto -proto ../coop-proto/publisher-service.proto localhost:5080
4959
}

coop-publisher/coop-publisher.cabal

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,7 @@ executable coop-publisher-cli
8888
other-modules: Coop.Cli.PublisherGrpc
8989
build-depends:
9090
, base
91-
, bytestring
9291
, containers
93-
, coop-cardano-proto
9492
, coop-fact-statement-store-service-proto
9593
, coop-publisher-service-proto
9694
, coop-tx-builder-service-proto
@@ -101,8 +99,6 @@ executable coop-publisher-cli
10199
, lens
102100
, optparse-applicative
103101
, proto-lens
104-
, proto-lens-protobuf-types
105-
, proto-lens-runtime
106102
, text
107103
, warp
108104
, warp-grpc

0 commit comments

Comments
 (0)