@@ -7,6 +7,7 @@ CLUSTER_DIR=.local-cluster # As specified in resources/pabConfig.yaml
7
7
WALLETS=.wallets
8
8
9
9
RESOURCES=resources
10
+ COOP_PROTO=coop-proto
10
11
11
12
function clean {
12
13
rm -fR $JS_STORE_DIR
@@ -34,86 +35,104 @@ function generate-keys {
34
35
openssl x509 -text -in $1 /certificate.pem
35
36
}
36
37
37
- # Prelude FactStatementStore
38
+ # Prelude and run the FactStatementStore gRpc with a generic Json implementation
38
39
function prelude-js-fs-store {
40
+ mkdir $JS_STORE_DIR
39
41
sqlite3 -batch $JS_STORE_DIR /json-store.db " "
40
42
json-fs-store-cli genesis --db $JS_STORE_DIR /json-store.db
41
43
json-fs-store-cli insert-fact-statement --db $JS_STORE_DIR /json-store.db --fact_statement_id " someidA" --json " [1,2,3]"
42
44
json-fs-store-cli insert-fact-statement --db $JS_STORE_DIR /json-store.db --fact_statement_id " someidB" --json " [4,5,6]"
43
45
json-fs-store-cli insert-fact-statement --db $JS_STORE_DIR /json-store.db --fact_statement_id " someidC" --json " [7,8,9]"
44
46
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
49
48
json-fs-store-cli fact-statement-store-grpc --db $JS_STORE_DIR /json-store.db
50
49
}
51
50
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
54
57
local-cluster --wallet-dir $WALLETS -n 10 --utxos 5 --chain-index-port 9084 --slot-len 1s --epoch-size 100000
55
58
}
56
59
57
- # Run manually to parse the config outputted by run -cluster
60
+ # Run manually to parse the config outputted by local -cluster
58
61
function parse-cluster-config {
59
- cat > $COOP_PAB_DIR /plutip-cluster-config
62
+ cat > $CLUSTER_DIR /plutip-cluster-config
60
63
make-exports
61
64
# 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 ;
63
72
}
64
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
+ # Export the variables used across
65
80
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)
73
88
}
74
89
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
77
100
}
78
101
79
102
function coop-genesis {
80
- make-exports
81
103
coop-pab-cli deploy --god-wallet $GOD_PKH --aa-wallet $AA_PKH
82
104
}
83
105
84
106
function coop-mint-cert-redeemers {
85
- make-exports
86
107
coop-pab-cli mint-cert-redeemers --cert-rdmr-wallet $CERT_RDMR_PKH --cert-rdmrs-to-mint 100
87
108
}
88
109
89
110
function coop-mint-authentication {
90
- make-exports
91
111
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
92
112
}
93
113
94
114
function coop-redist-auth {
95
- make-exports
96
115
coop-pab-cli redistribute-auth --auth-wallet $AUTH_PKH
97
116
}
98
117
99
118
function coop-run-tx-builder-grpc {
100
- make-exports
101
119
coop-pab-cli tx-builder-grpc --auth-wallet $AUTH_PKH --fee-wallet $FEE_PKH
102
120
}
103
121
122
+ function show-env {
123
+ export | grep -E " _PKH|CARDANO_NODE_SOCKET_PATH"
124
+ }
125
+
104
126
function coop-garbage-collect {
105
- make-exports
106
127
coop-pab-cli garbage-collect --cert-rdmr-wallet $CERT_RDMR_PKH
107
128
}
108
129
109
130
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
112
132
cat $COOP_PAB_DIR /coop-state.json | json_pp
113
133
}
114
134
115
135
function coop-poll-state {
116
- make-exports
117
136
while true ; do
118
137
clear;
119
138
coop-get-state;
@@ -122,131 +141,77 @@ function coop-poll-state {
122
141
}
123
142
124
143
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]+"
127
145
}
128
146
129
147
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
130
154
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
132
156
}
133
157
134
158
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
157
160
{
158
- "fsId": "$( echo -ne ' the best id3' | base64) ",
159
- "gcAfter": {
160
- "extended": "NEG_INF"
161
- },
162
- "fs": {
163
- "pdlist": {
164
- "elements": [
161
+ "fsInfos": [
165
162
{
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
+ },
181
168
{
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
+ },
197
174
{
198
- "pdint": "1337"
175
+ "fsId": "$( echo -ne someidC | base64) ",
176
+ "gcAfter": {
177
+ "extended": "NEG_INF"
178
+ }
199
179
}
200
- ]
180
+ ],
181
+ "submitter": {
182
+ "base16": "$SUBMITTER_PKH "
201
183
}
202
- }
203
184
}
204
- ],
205
- "submitter": {
206
- "base16": "$SUBMITTER_PKH "
207
- }
208
- }
185
+
209
186
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
215
194
}
216
195
217
196
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
220
198
{
221
- "fsIds": ["eW==", "YXNkCg=="],
199
+ "fsIds": [
200
+ "$( echo -ne someidA | base64) ",
201
+ "$( echo -ne someidB | base64) ",
202
+ "$( echo -ne someidC | base64) "
203
+ ],
222
204
"submitter": {
223
205
"base16": "$SUBMITTER_PKH "
224
206
}
225
207
}
226
208
227
209
EOF
228
210
)
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
252
217
}
0 commit comments