@@ -6,8 +6,8 @@ CLUSTER_DIR=.local-cluster # As specified in resources/pabConfig.yaml
6
6
7
7
WALLETS=.wallets
8
8
9
- RESOURCES=resources
10
- COOP_PROTO=coop-proto
9
+ RESOURCES=resources # Symlinked by Nix env
10
+ COOP_PROTO=coop-proto # Symlinked by Nix env
11
11
12
12
function clean {
13
13
rm -fR $JS_STORE_DIR
@@ -36,7 +36,7 @@ function generate-keys {
36
36
}
37
37
38
38
# Prelude and run the FactStatementStore gRpc with a generic Json implementation
39
- function prelude -js-fs-store {
39
+ function run -js-fs-store {
40
40
mkdir $JS_STORE_DIR
41
41
sqlite3 -batch $JS_STORE_DIR /json-store.db " "
42
42
json-fs-store-cli genesis --db $JS_STORE_DIR /json-store.db
@@ -49,54 +49,39 @@ function prelude-js-fs-store {
49
49
}
50
50
51
51
# Prelude and run the Plutip Local Cluster (cardano-node and wallet creation)
52
- function prelude -cluster {
52
+ function run -cluster {
53
53
mkdir $CLUSTER_DIR
54
54
mkdir $CLUSTER_DIR /scripts
55
55
mkdir $CLUSTER_DIR /txs
56
56
mkdir $WALLETS
57
- local-cluster --wallet-dir $WALLETS -n 10 --utxos 5 --chain-index-port 9084 --slot-len 1s --epoch-size 100000
57
+ local-cluster --dump-info-json $CLUSTER_DIR /local-cluster-info.json \
58
+ --wallet-dir $WALLETS \
59
+ -n 10 --utxos 5 \
60
+ --chain-index-port 9084 \
61
+ --slot-len 1s --epoch-size 100000
58
62
}
59
63
60
- # Run manually to parse the config outputted by local-cluster
61
- function parse-cluster-config {
62
- cat > $CLUSTER_DIR /plutip-cluster-config
63
- make-exports
64
- # So BPI doesn't have access to it
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 ;
72
- }
73
-
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
64
# Export the variables used across
80
65
function make-exports {
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 )
66
+ export GOD_PKH=$( cat $CLUSTER_DIR /local -cluster-info.json | jq -r " .ciWallets[0][0] " )
67
+ export AA_PKH=$( cat $CLUSTER_DIR /local -cluster-info.json | jq -r " .ciWallets[1][0] " )
68
+ export AUTH_PKH=$( cat $CLUSTER_DIR /local -cluster-info.json | jq -r " .ciWallets[2][0] " )
69
+ export CERT_RDMR_PKH=$( cat $CLUSTER_DIR /local -cluster-info.json | jq -r " .ciWallets[3][0] " )
70
+ export FEE_PKH=$( cat $CLUSTER_DIR /local -cluster-info.json | jq -r " .ciWallets[4][0] " )
71
+ export SUBMITTER_PKH=$( cat $CLUSTER_DIR /local -cluster-info.json | jq -r " .ciWallets[5][0] " )
72
+ export CARDANO_NODE_SOCKET_PATH=$( cat $CLUSTER_DIR /local -cluster-info.json | jq -r " .ciNodeSocket " )
88
73
}
89
74
90
75
# Prelude and run the TxBuilder gRpc
91
- function prelude -tx-builder {
76
+ function run -tx-builder {
92
77
mkdir $COOP_PAB_DIR
93
78
generate-keys $COOP_PAB_DIR
94
79
make-exports
95
80
coop-genesis
96
81
coop-mint-cert-redeemers
97
82
coop-mint-authentication
98
83
coop-redist-auth
99
- coop-run-tx-builder-grpc
84
+ coop-run-tx-builder-grpc > /dev/null
100
85
}
101
86
102
87
function coop-genesis {
@@ -140,6 +125,10 @@ function coop-poll-state {
140
125
done ;
141
126
}
142
127
128
+ function fs-store-insert {
129
+ json-fs-store-cli insert-fact-statement --db $JS_STORE_DIR /json-store.db --fact_statement_id " $1 " --json " $2 "
130
+ }
131
+
143
132
function get-onchain-time {
144
133
coop-pab-cli get-state --any-wallet $GOD_PKH | grep " Current node client time range" | grep POSIXTime | grep -E -o " [0-9]+"
145
134
}
@@ -148,15 +137,26 @@ function run-grpcui {
148
137
grpcui -insecure -import-path $COOP_PROTO -proto $COOP_PROTO /publisher-service.proto localhost:5080
149
138
}
150
139
151
- function prelude -publisher {
140
+ function run -publisher {
152
141
mkdir $COOP_PUBLISHER_DIR
153
142
generate-keys $COOP_PUBLISHER_DIR
154
143
make-exports
155
144
coop-publisher-cli publisher-grpc
156
145
}
157
146
147
+ function run-all {
148
+ run-cluster &
149
+ while [ ! -f $CLUSTER_DIR /local-cluster-info.json ]; do sleep 1; done ;
150
+ make-exports
151
+ mv $WALLETS /signing-key-" $SUBMITTER_PKH " .skey $WALLETS /my-signing-key-" $SUBMITTER_PKH " .skey
152
+ run-js-fs-store &
153
+ run-tx-builder &
154
+ run-publisher &
155
+ }
156
+
158
157
function coop-mint-fs {
159
- resp=$( grpcurl -insecure -import-path $COOP_PROTO -proto $COOP_PROTO /publisher-service.proto -d @ localhost:5080 coop.publisher.Publisher/createMintFsTx << EOF
158
+ make-exports
159
+ req=$( cat << EOF
160
160
{
161
161
"fsInfos": [
162
162
{
@@ -182,36 +182,48 @@ function coop-mint-fs {
182
182
"base16": "$SUBMITTER_PKH "
183
183
}
184
184
}
185
-
186
185
EOF
187
- )
186
+ )
187
+ resp=$( echo $req | grpcurl -insecure -import-path $COOP_PROTO -proto $COOP_PROTO /publisher-service.proto -d @ localhost:5080 coop.publisher.Publisher/createMintFsTx)
188
188
rawTx=$( echo " $resp " | jq ' .mintFsTx | .cborHex = .cborBase16 | del(.cborBase16) | .description = "" | .type = "Tx BabbageEra"' )
189
189
echo " $resp " | jq ' .info'
190
190
echo " $resp " | jq ' .error'
191
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
192
+ if [ " $( echo $resp | jq " has(\" mintFsTx\" )" ) " == true ]; then
193
+ 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
194
+ cardano-cli transaction submit --tx-file $COOP_PUBLISHER_DIR /ready --mainnet
195
+ else
196
+ echo " No transaction to submit"
197
+ fi
194
198
}
195
199
196
200
function coop-gc-fs {
197
- resp=$( grpcurl -insecure -import-path $COOP_PROTO -proto $COOP_PROTO /publisher-service.proto -d @ localhost:5080 coop.publisher.Publisher/createGcFsTx << EOF
201
+ make-exports
202
+ req=$( cat << EOF
198
203
{
199
204
"fsIds": [
200
- "$( echo -ne someidA | base64) ",
201
- "$( echo -ne someidB | base64) ",
202
- "$( echo -ne someidC | base64) "
203
- ],
205
+ "$( echo -ne ' should not exist' | base64) ",
206
+ "$( echo -ne ' someidA' | base64) ",
207
+ "$( echo -ne ' someidB' | base64) ",
208
+ "$( echo -ne ' nop' | base64) ",
209
+ "$( echo -ne ' another nope' | base64) "
210
+ ],
204
211
"submitter": {
205
212
"base16": "$SUBMITTER_PKH "
206
213
}
207
214
}
208
215
209
216
EOF
210
- )
217
+ )
218
+ resp=$( echo $req | grpcurl -insecure -import-path $COOP_PROTO -proto $COOP_PROTO /publisher-service.proto -d @ localhost:5080 coop.publisher.Publisher/createGcFsTx)
211
219
rawTx=$( echo " $resp " | jq ' .gcFsTx | .cborHex = .cborBase16 | del(.cborBase16) | .description = "" | .type = "TxBodyBabbage"' )
212
220
echo " $resp " | jq ' .info'
213
221
echo " $resp " | jq ' .error'
214
222
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
223
+ if [ " $( echo $resp | jq " has(\" gcFsTx\" )" ) " == true ]; then
224
+ 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
225
+ cardano-cli transaction submit --tx-file $COOP_PUBLISHER_DIR /ready --mainnet
226
+ else
227
+ echo " No transaction to submit"
228
+ fi
217
229
}
0 commit comments