-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add create state Merkle tree script (#1485)
* chore: add create state Merkle tree script * fix: lint
- Loading branch information
1 parent
8b38899
commit 126575a
Showing
3 changed files
with
44 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/bin/bash | ||
|
||
# Base directory for keypairs | ||
KEYPAIR_DIR="./target/tree-keypairs" | ||
|
||
# Command template | ||
CMD_TEMPLATE="cargo xtask create-state-tree --mt-pubkey {SMT} --nfq-pubkey {NFQ} --cpi-pubkey {CPI} --index {INDEX} --network devnet" | ||
|
||
# Collect sorted key files for each type | ||
SMT_KEYS=($(ls $KEYPAIR_DIR/smt*.json | sort)) | ||
NFQ_KEYS=($(ls $KEYPAIR_DIR/nfq*.json | sort)) | ||
CPI_KEYS=($(ls $KEYPAIR_DIR/cpi*.json | sort)) | ||
|
||
# Ensure equal number of keys for each type | ||
if [[ ${#SMT_KEYS[@]} -ne ${#NFQ_KEYS[@]} || ${#NFQ_KEYS[@]} -ne ${#CPI_KEYS[@]} ]]; then | ||
echo "Error: Mismatched number of SMT, NFQ, and CPI key files." | ||
exit 1 | ||
fi | ||
|
||
# Execute the command for each triple | ||
for i in "${!SMT_KEYS[@]}"; do | ||
SMT_KEY="${SMT_KEYS[i]}" | ||
NFQ_KEY="${NFQ_KEYS[i]}" | ||
CPI_KEY="${CPI_KEYS[i]}" | ||
INDEX=$((i + 2)) | ||
|
||
# Replace placeholders in the command template | ||
CMD=${CMD_TEMPLATE//\{SMT\}/"$SMT_KEY"} | ||
CMD=${CMD//\{NFQ\}/"$NFQ_KEY"} | ||
CMD=${CMD//\{CPI\}/"$CPI_KEY"} | ||
CMD=${CMD//\{INDEX\}/"$INDEX"} | ||
|
||
echo "Executing: $CMD" | ||
eval "$CMD" | ||
|
||
done | ||
|
||
echo "All commands executed." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters