Skip to content

Commit ea29f13

Browse files
committed
Wip on tutorial, erased pure, bump plutip
1 parent 02bbe59 commit ea29f13

File tree

14 files changed

+108
-1006
lines changed

14 files changed

+108
-1006
lines changed

coop-extras/tutorial/aux.bash

+94-129
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ CLUSTER_DIR=.local-cluster # As specified in resources/pabConfig.yaml
77
WALLETS=.wallets
88

99
RESOURCES=resources
10+
COOP_PROTO=coop-proto
1011

1112
function clean {
1213
rm -fR $JS_STORE_DIR
@@ -34,86 +35,104 @@ function generate-keys {
3435
openssl x509 -text -in $1/certificate.pem
3536
}
3637

37-
# Prelude FactStatementStore
38+
# Prelude and run the FactStatementStore gRpc with a generic Json implementation
3839
function prelude-js-fs-store {
40+
mkdir $JS_STORE_DIR
3941
sqlite3 -batch $JS_STORE_DIR/json-store.db ""
4042
json-fs-store-cli genesis --db $JS_STORE_DIR/json-store.db
4143
json-fs-store-cli insert-fact-statement --db $JS_STORE_DIR/json-store.db --fact_statement_id "someidA" --json "[1,2,3]"
4244
json-fs-store-cli insert-fact-statement --db $JS_STORE_DIR/json-store.db --fact_statement_id "someidB" --json "[4,5,6]"
4345
json-fs-store-cli insert-fact-statement --db $JS_STORE_DIR/json-store.db --fact_statement_id "someidC" --json "[7,8,9]"
4446
echo "SELECT * FROM fact_statements" | sqlite3 $JS_STORE_DIR/json-store.db
45-
}
46-
47-
# Run the FactStatementStore generic Json implementation
48-
function run-js-fs-store {
47+
generate-keys $JS_STORE_DIR
4948
json-fs-store-cli fact-statement-store-grpc --db $JS_STORE_DIR/json-store.db
5049
}
5150

52-
# Run the Plutip Local Cluster (cardano-node and wallet creation)
53-
function run-cluster {
51+
# Prelude and run the Plutip Local Cluster (cardano-node and wallet creation)
52+
function prelude-cluster {
53+
mkdir $CLUSTER_DIR
54+
mkdir $CLUSTER_DIR/scripts
55+
mkdir $CLUSTER_DIR/txs
56+
mkdir $WALLETS
5457
local-cluster --wallet-dir $WALLETS -n 10 --utxos 5 --chain-index-port 9084 --slot-len 1s --epoch-size 100000
5558
}
5659

57-
# Run manually to parse the config outputted by run-cluster
60+
# Run manually to parse the config outputted by local-cluster
5861
function parse-cluster-config {
59-
cat > $COOP_PAB_DIR/plutip-cluster-config
62+
cat > $CLUSTER_DIR/plutip-cluster-config
6063
make-exports
6164
# So BPI doesn't have access to it
62-
mv $WALLETS/signing-key-$SUBMITTER_PKH.skey $WALLETS/my-key-$SUBMITTER_PKH.skey
65+
echo $SUBMITTER_PKH
66+
if [ -f $WALLETS/my-signing-key-$SUBMITTER_PKH.skey ];
67+
then echo "My key already setup"
68+
else
69+
echo "Hiding my key from the PAB"
70+
mv $WALLETS/signing-key-$SUBMITTER_PKH.skey $WALLETS/my-signing-key-$SUBMITTER_PKH.skey
71+
fi;
6372
}
6473

74+
if [ -f $CLUSTER_DIR/plutip-cluster-config ];
75+
then make-exports;
76+
else echo "Run prelude-cluster and parse with parse-cluster-config" ;
77+
fi;
78+
79+
# Export the variables used across
6580
function make-exports {
66-
export GOD_PKH=$(cat $COOP_PAB_DIR/plutip-cluster-config | grep -E "Wallet 1 PKH" | cut -d ":" -f 2 | xargs)
67-
export AA_PKH=$(cat $COOP_PAB_DIR/plutip-cluster-config | grep -E "Wallet 2 PKH" | cut -d ":" -f 2 | xargs)
68-
export AUTH_PKH=$(cat $COOP_PAB_DIR/plutip-cluster-config | grep -E "Wallet 3 PKH" | cut -d ":" -f 2 | xargs)
69-
export CERT_RDMR_PKH=$(cat $COOP_PAB_DIR/plutip-cluster-config | grep -E "Wallet 4 PKH" | cut -d ":" -f 2 | xargs)
70-
export FEE_PKH=$(cat $COOP_PAB_DIR/plutip-cluster-config | grep -E "Wallet 5 PKH" | cut -d ":" -f 2 | xargs)
71-
export SUBMITTER_PKH=$(cat $COOP_PAB_DIR/plutip-cluster-config | grep -E "Wallet 6 PKH" | cut -d ":" -f 2 | xargs)
72-
export CARDANO_NODE_SOCKET_PATH=$(cat $COOP_PAB_DIR/plutip-cluster-config | grep CardanoNodeConn | grep -E -o '"[^"]+"' | sed s/\"//g)
81+
export GOD_PKH=$(cat $CLUSTER_DIR/plutip-cluster-config | grep -E "Wallet 1 PKH" | cut -d ":" -f 2 | xargs)
82+
export AA_PKH=$(cat $CLUSTER_DIR/plutip-cluster-config | grep -E "Wallet 2 PKH" | cut -d ":" -f 2 | xargs)
83+
export AUTH_PKH=$(cat $CLUSTER_DIR/plutip-cluster-config | grep -E "Wallet 3 PKH" | cut -d ":" -f 2 | xargs)
84+
export CERT_RDMR_PKH=$(cat $CLUSTER_DIR/plutip-cluster-config | grep -E "Wallet 4 PKH" | cut -d ":" -f 2 | xargs)
85+
export FEE_PKH=$(cat $CLUSTER_DIR/plutip-cluster-config | grep -E "Wallet 5 PKH" | cut -d ":" -f 2 | xargs)
86+
export SUBMITTER_PKH=$(cat $CLUSTER_DIR/plutip-cluster-config | grep -E "Wallet 6 PKH" | cut -d ":" -f 2 | xargs)
87+
export CARDANO_NODE_SOCKET_PATH=$(cat $CLUSTER_DIR/plutip-cluster-config | grep CardanoNodeConn | grep -E -o '"[^"]+"' | sed s/\"//g)
7388
}
7489

75-
function show-env {
76-
export | grep -E "WALLET|CARDANO_NODE_SOCKET_PATH"
90+
# Prelude and run the TxBuilder gRpc
91+
function prelude-tx-builder {
92+
mkdir $COOP_PAB_DIR
93+
generate-keys $COOP_PAB_DIR
94+
make-exports
95+
coop-genesis
96+
coop-mint-cert-redeemers
97+
coop-mint-authentication
98+
coop-redist-auth
99+
coop-run-tx-builder-grpc
77100
}
78101

79102
function coop-genesis {
80-
make-exports
81103
coop-pab-cli deploy --god-wallet $GOD_PKH --aa-wallet $AA_PKH
82104
}
83105

84106
function coop-mint-cert-redeemers {
85-
make-exports
86107
coop-pab-cli mint-cert-redeemers --cert-rdmr-wallet $CERT_RDMR_PKH --cert-rdmrs-to-mint 100
87108
}
88109

89110
function coop-mint-authentication {
90-
make-exports
91111
NOW=$(get-onchain-time) && coop-pab-cli mint-auth --aa-wallet $AA_PKH --certificate-valid-from $NOW --certificate-valid-to "$(expr $NOW + 60 \* 60 \* 1000)" --auth-wallet $AUTH_PKH
92112
}
93113

94114
function coop-redist-auth {
95-
make-exports
96115
coop-pab-cli redistribute-auth --auth-wallet $AUTH_PKH
97116
}
98117

99118
function coop-run-tx-builder-grpc {
100-
make-exports
101119
coop-pab-cli tx-builder-grpc --auth-wallet $AUTH_PKH --fee-wallet $FEE_PKH
102120
}
103121

122+
function show-env {
123+
export | grep -E "_PKH|CARDANO_NODE_SOCKET_PATH"
124+
}
125+
104126
function coop-garbage-collect {
105-
make-exports
106127
coop-pab-cli garbage-collect --cert-rdmr-wallet $CERT_RDMR_PKH
107128
}
108129

109130
function coop-get-state {
110-
make-exports
111-
coop-pab-cli get-state --any-wallet ${GOD_PKH}
131+
coop-pab-cli get-state --any-wallet $GOD_PKH
112132
cat $COOP_PAB_DIR/coop-state.json | json_pp
113133
}
114134

115135
function coop-poll-state {
116-
make-exports
117136
while true; do
118137
clear;
119138
coop-get-state;
@@ -122,131 +141,77 @@ function coop-poll-state {
122141
}
123142

124143
function get-onchain-time {
125-
make-exports
126-
coop-pab-cli get-state --any-wallet ${GOD_PKH} | grep "Current node client time range" | grep POSIXTime | grep -E -o "[0-9]+"
144+
coop-pab-cli get-state --any-wallet $GOD_PKH | grep "Current node client time range" | grep POSIXTime | grep -E -o "[0-9]+"
127145
}
128146

129147
function run-grpcui {
148+
grpcui -insecure -import-path $COOP_PROTO -proto $COOP_PROTO/publisher-service.proto localhost:5080
149+
}
150+
151+
function prelude-publisher {
152+
mkdir $COOP_PUBLISHER_DIR
153+
generate-keys $COOP_PUBLISHER_DIR
130154
make-exports
131-
grpcui -insecure -import-path $RESOURCES/coop-proto -proto $RESOURCES/coop-proto/tx-builder-service.proto localhost:5081
155+
coop-publisher-cli publisher-grpc
132156
}
133157

134158
function coop-mint-fs {
135-
make-exports
136-
resp=$(grpcurl -insecure -import-path $RESOURCES/coop-proto -proto $RESOURCES/coop-proto/tx-builder-service.proto -d @ localhost:5081 coop.tx_builder.TxBuilder/createMintFsTx <<EOF
137-
{
138-
"factStatements": [
139-
{
140-
"fsId": "$(echo -ne 'the best id1' | base64)",
141-
"gcAfter": {
142-
"extended": "NEG_INF"
143-
},
144-
"fs": {
145-
"pdint": "1337"
146-
}
147-
},
148-
{
149-
"fsId": "$(echo -ne 'the best id2' | base64)",
150-
"gcAfter": {
151-
"extended": "NEG_INF"
152-
},
153-
"fs": {
154-
"pdbytes": "$(echo -ne 'some bytes' | base64)"
155-
}
156-
},
159+
resp=$(grpcurl -insecure -import-path $COOP_PROTO -proto $COOP_PROTO/publisher-service.proto -d @ localhost:5080 coop.publisher.Publisher/createMintFsTx <<EOF
157160
{
158-
"fsId": "$(echo -ne 'the best id3' | base64)",
159-
"gcAfter": {
160-
"extended": "NEG_INF"
161-
},
162-
"fs": {
163-
"pdlist": {
164-
"elements": [
161+
"fsInfos": [
165162
{
166-
"pdint": "1337"
167-
}
168-
]
169-
}
170-
}
171-
},
172-
{
173-
"fsId": "$(echo -ne 'the best id4' | base64)",
174-
"gcAfter": {
175-
"extended": "FINITE",
176-
"finiteLedgerTime": "$(expr "$(get-onchain-time)" + 60 \* 60 \* 1000)"
177-
},
178-
"fs": {
179-
"pdlist": {
180-
"elements": [
163+
"fsId": "$(echo -ne someidA | base64)",
164+
"gcAfter": {
165+
"extended": "NEG_INF"
166+
}
167+
},
181168
{
182-
"pdint": "1337"
183-
}
184-
]
185-
}
186-
}
187-
},
188-
{
189-
"fsId": "$(echo -ne 'the best id5' | base64)",
190-
"gcAfter": {
191-
"extended": "FINITE",
192-
"finiteLedgerTime": "$(expr "$(get-onchain-time)" + 60 \* 60 \* 1000)"
193-
},
194-
"fs": {
195-
"pdlist": {
196-
"elements": [
169+
"fsId": "$(echo -ne someidB | base64)",
170+
"gcAfter": {
171+
"extended": "NEG_INF"
172+
}
173+
},
197174
{
198-
"pdint": "1337"
175+
"fsId": "$(echo -ne someidC | base64)",
176+
"gcAfter": {
177+
"extended": "NEG_INF"
178+
}
199179
}
200-
]
180+
],
181+
"submitter": {
182+
"base16": "$SUBMITTER_PKH"
201183
}
202-
}
203184
}
204-
],
205-
"submitter": {
206-
"base16": "$SUBMITTER_PKH"
207-
}
208-
}
185+
209186
EOF
210-
)
211-
rawTx=$(echo $resp | jq '.success.mintFsTx | .cborHex = .cborBase16 | del(.cborBase16) | .description = "" | .type = "Tx BabbageEra"')
212-
echo $resp | jq '.info'
213-
echo $resp | jq '.error'
214-
echo $rawTx > $COOP_PAB_DIR/signed
187+
)
188+
rawTx=$(echo "$resp" | jq '.mintFsTx | .cborHex = .cborBase16 | del(.cborBase16) | .description = "" | .type = "Tx BabbageEra"')
189+
echo "$resp" | jq '.info'
190+
echo "$resp" | jq '.error'
191+
echo "$rawTx" > $COOP_PUBLISHER_DIR/signed
192+
cardano-cli transaction sign --tx-file $COOP_PUBLISHER_DIR/signed --signing-key-file $WALLETS/my-signing-key-"$SUBMITTER_PKH".skey --out-file $COOP_PUBLISHER_DIR/ready
193+
cardano-cli transaction submit --tx-file $COOP_PUBLISHER_DIR/ready --mainnet
215194
}
216195

217196
function coop-gc-fs {
218-
make-exports
219-
resp=$(grpcurl -insecure -import-path ../coop-proto -proto ../coop-proto/tx-builder-service.proto -d @ localhost:5081 coop.tx_builder.TxBuilder/createGcFsTx <<EOF
197+
resp=$(grpcurl -insecure -import-path $COOP_PROTO -proto $COOP_PROTO/publisher-service.proto -d @ localhost:5080 coop.publisher.Publisher/createGcFsTx <<EOF
220198
{
221-
"fsIds": ["eW==", "YXNkCg=="],
199+
"fsIds": [
200+
"$(echo -ne someidA | base64)",
201+
"$(echo -ne someidB | base64)",
202+
"$(echo -ne someidC | base64)"
203+
],
222204
"submitter": {
223205
"base16": "$SUBMITTER_PKH"
224206
}
225207
}
226208
227209
EOF
228210
)
229-
rawTx=$(echo $resp | jq '.success.gcFsTx | .cborHex = .cborBase16 | del(.cborBase16) | .description = "" | .type = "Tx BabbageEra"')
230-
echo $resp | jq '.info'
231-
echo $resp | jq '.error'
232-
echo $rawTx > $COOP_PAB_DIR/signed
233-
}
234-
235-
function cardano-cli-sign {
236-
make-exports
237-
cardano-cli transaction sign --tx-file $COOP_PAB_DIR/signed --signing-key-file $WALLETS/no-plutip-signing-key-$SUBMITTER_PKH.skey --out-file $COOP_PAB_DIR/ready
238-
}
239-
240-
function cardano-cli-submit {
241-
make-exports
242-
cardano-cli transaction submit --tx-file $COOP_PAB_DIR/ready --mainnet
243-
}
244-
245-
function coop-prelude {
246-
make-exports
247-
coop-genesis
248-
coop-mint-cert-redeemers
249-
coop-mint-authentication
250-
coop-redist-auth
251-
coop-run-tx-builder-grpc
211+
rawTx=$(echo "$resp" | jq '.gcFsTx | .cborHex = .cborBase16 | del(.cborBase16) | .description = "" | .type = "TxBodyBabbage"')
212+
echo "$resp" | jq '.info'
213+
echo "$resp" | jq '.error'
214+
echo "$rawTx" > $COOP_PUBLISHER_DIR/signed
215+
cardano-cli transaction sign --tx-body-file $COOP_PUBLISHER_DIR/signed --signing-key-file $WALLETS/my-signing-key-"$SUBMITTER_PKH".skey --out-file $COOP_PUBLISHER_DIR/ready
216+
cardano-cli transaction submit --tx-file $COOP_PUBLISHER_DIR/ready --mainnet
252217
}

coop-extras/tutorial/build.nix

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
, cardanoCli
33
, cardanoNode
44
, coopPabCli
5+
, coopPlutusCli
56
, coopPublisherCli
67
, jsFsStoreCli
78
, plutipLocalCluster
@@ -22,10 +23,16 @@ pkgs.mkShell {
2223
cardanoCli
2324
cardanoNode
2425
coopPabCli
26+
coopPlutusCli
2527
coopPublisherCli
2628
jsFsStoreCli
2729
plutipLocalCluster
2830
];
2931

30-
inherit shellHook;
32+
shellHook = ''
33+
${shellHook}
34+
ln -s ${../../coop-proto} coop-proto
35+
ln -s ${../../coop-pab/resources} resources
36+
source ${./aux.bash}
37+
'';
3138
}

coop-extras/tutorial/resources/pabConfig.yaml

-25
This file was deleted.

0 commit comments

Comments
 (0)