|
|
@@ -5,34 +5,22 @@ set -x
|
|
|
# Path to `drk` binary
|
|
|
DRK="../../../drk -c drk.toml"
|
|
|
|
|
|
+# Script configuration
|
|
|
+OUTPUT_FOLDER=/tmp/darkfi
|
|
|
+mkdir -p $OUTPUT_FOLDER
|
|
|
+SLEEP_TIME=5
|
|
|
+
|
|
|
# First run the darkfid node and the miner:
|
|
|
#
|
|
|
# ./clean.sh
|
|
|
# ./init-wallet.sh
|
|
|
-# ./tmux_sessions.sh -vv
|
|
|
-#
|
|
|
-# In another term run the wallet syncing,
|
|
|
-# and wait until some blocks are mined:
|
|
|
+# ./tmux_sessions.sh
|
|
|
#
|
|
|
-# ./sync-wallet.sh
|
|
|
-#
|
|
|
-# Finally you can run this script
|
|
|
-
|
|
|
-mint_tokens() {
|
|
|
- $DRK token generate-mint
|
|
|
- $DRK token generate-mint
|
|
|
-
|
|
|
- TOKEN_ID1="$($DRK token list 2>/dev/null | awk 'NR == 3 {print $1}')"
|
|
|
- TOKEN_ID2="$($DRK token list 2>/dev/null | awk 'NR == 4 {print $1}')"
|
|
|
-
|
|
|
- $DRK alias add WCKD "$TOKEN_ID1"
|
|
|
- $DRK alias add MLDY "$TOKEN_ID2"
|
|
|
-
|
|
|
- ADDR="$($DRK wallet address)"
|
|
|
-
|
|
|
- $DRK token mint WCKD 42 "$ADDR" | tee /tmp/mint-wkcd.tx | $DRK broadcast
|
|
|
- $DRK token mint MLDY 20 "$ADDR" | tee /tmp/mint-mldy.tx | $DRK broadcast
|
|
|
+# Now you can run this script
|
|
|
|
|
|
+mint_token() {
|
|
|
+ $DRK alias add $1 "$($DRK token generate-mint | awk '{print $8}')"
|
|
|
+ $DRK token mint $1 $2 "$($DRK wallet address)" | tee $OUTPUT_FOLDER/mint-$1.tx | $DRK broadcast
|
|
|
$DRK token list
|
|
|
}
|
|
|
|
|
|
@@ -56,24 +44,26 @@ token_balance() {
|
|
|
echo "$BALANCE" | awk '{print $5}'
|
|
|
}
|
|
|
|
|
|
-wait_tokens() {
|
|
|
- while [ "$(token_balance WCKD)" = 0 ] || [ "$(token_balance MLDY)" = 0 ]; do
|
|
|
- sleep 1
|
|
|
+wait_token() {
|
|
|
+ while [ "$(token_balance $1)" = 0 ]; do
|
|
|
+ sleep $SLEEP_TIME
|
|
|
+ sh ./sync-wallet.sh > /dev/null
|
|
|
done
|
|
|
}
|
|
|
|
|
|
mint_dao() {
|
|
|
- $DRK dao create 20 10 10 0.67 MLDY > /tmp/dao.toml
|
|
|
- $DRK dao import MiladyMakerDAO < /tmp/dao.toml
|
|
|
+ $DRK dao create 20 10 10 0.67 MLDY > $OUTPUT_FOLDER/dao.toml
|
|
|
+ $DRK dao import MiladyMakerDAO < $OUTPUT_FOLDER/dao.toml
|
|
|
$DRK dao list
|
|
|
$DRK dao list MiladyMakerDAO
|
|
|
|
|
|
- $DRK dao mint MiladyMakerDAO | tee /tmp/dao-mint.tx | $DRK broadcast
|
|
|
+ $DRK dao mint MiladyMakerDAO | tee $OUTPUT_FOLDER/dao-mint.tx | $DRK broadcast
|
|
|
}
|
|
|
|
|
|
wait_dao_mint() {
|
|
|
while [ "$($DRK dao list MiladyMakerDAO | grep '^Transaction hash: ' | awk '{print $3}')" = None ]; do
|
|
|
- sleep 1
|
|
|
+ sleep $SLEEP_TIME
|
|
|
+ sh ./sync-wallet.sh > /dev/null
|
|
|
done
|
|
|
}
|
|
|
|
|
|
@@ -81,7 +71,7 @@ fill_treasury() {
|
|
|
PUBKEY="$($DRK dao list MiladyMakerDAO | grep '^Notes Public key: ' | cut -d ' ' -f4)"
|
|
|
SPEND_HOOK="$($DRK dao spend-hook)"
|
|
|
BULLA="$($DRK dao list MiladyMakerDAO | grep '^Bulla: ' | cut -d' ' -f2)"
|
|
|
- $DRK transfer 20 WCKD "$PUBKEY" "$SPEND_HOOK" "$BULLA" | tee /tmp/xfer.tx | $DRK broadcast
|
|
|
+ $DRK transfer 20 WCKD "$PUBKEY" "$SPEND_HOOK" "$BULLA" | tee $OUTPUT_FOLDER/xfer.tx | $DRK broadcast
|
|
|
}
|
|
|
|
|
|
dao_balance() {
|
|
|
@@ -105,52 +95,56 @@ dao_balance() {
|
|
|
|
|
|
wait_dao_treasury() {
|
|
|
while [ "$(dao_balance WCKD)" = 0 ]; do
|
|
|
- sleep 1
|
|
|
+ sleep $SLEEP_TIME
|
|
|
+ sh ./sync-wallet.sh > /dev/null
|
|
|
done
|
|
|
}
|
|
|
|
|
|
propose() {
|
|
|
MY_ADDR=$($DRK wallet address)
|
|
|
PROPOSAL="$($DRK dao propose-transfer MiladyMakerDAO 1 5 WCKD "$MY_ADDR" | cut -d' ' -f3)"
|
|
|
- $DRK dao proposal "$PROPOSAL" --mint-proposal > /tmp/propose.tx
|
|
|
- $DRK broadcast < /tmp/propose.tx
|
|
|
+ $DRK dao proposal "$PROPOSAL" --mint-proposal | tee $OUTPUT_FOLDER/propose.tx | $DRK broadcast
|
|
|
}
|
|
|
|
|
|
wait_proposal() {
|
|
|
PROPOSAL="$($DRK dao proposals MiladyMakerDAO | cut -d' ' -f2)"
|
|
|
while [ "$($DRK dao proposal $PROPOSAL | grep '^Proposal transaction hash: ' | awk '{print $4}')" = None ]; do
|
|
|
- sleep 1
|
|
|
+ sleep $SLEEP_TIME
|
|
|
+ sh ./sync-wallet.sh > /dev/null
|
|
|
done
|
|
|
}
|
|
|
|
|
|
vote() {
|
|
|
PROPOSAL="$($DRK dao proposals MiladyMakerDAO | cut -d' ' -f2)"
|
|
|
- $DRK dao vote "$PROPOSAL" 1 > /tmp/dao-vote.tx
|
|
|
- $DRK broadcast < /tmp/dao-vote.tx
|
|
|
+ $DRK dao vote "$PROPOSAL" 1 | tee $OUTPUT_FOLDER/dao-vote.tx | $DRK broadcast
|
|
|
}
|
|
|
|
|
|
wait_vote() {
|
|
|
PROPOSAL="$($DRK dao proposals MiladyMakerDAO | cut -d' ' -f2)"
|
|
|
while [ "$($DRK dao proposal $PROPOSAL | grep '^Current proposal outcome: ' | awk '{print $4}')" != "Approved" ]; do
|
|
|
- sleep 1
|
|
|
+ sleep $SLEEP_TIME
|
|
|
+ sh ./sync-wallet.sh > /dev/null
|
|
|
done
|
|
|
}
|
|
|
|
|
|
do_exec() {
|
|
|
PROPOSAL="$($DRK dao proposals MiladyMakerDAO | cut -d' ' -f2)"
|
|
|
- $DRK dao exec --early $PROPOSAL > /tmp/dao-exec.tx
|
|
|
- $DRK broadcast < /tmp/dao-exec.tx
|
|
|
+ $DRK dao exec --early $PROPOSAL | tee $OUTPUT_FOLDER/dao-exec.tx | $DRK broadcast
|
|
|
}
|
|
|
|
|
|
wait_exec() {
|
|
|
PROPOSAL="$($DRK dao proposals MiladyMakerDAO | cut -d' ' -f2)"
|
|
|
- while [ "$($DRK dao proposal $PROPOSAL | grep '^Proposal was executed on transaction: ' | awk '{print $6}')" = None ]; do
|
|
|
- sleep 1
|
|
|
+ while [ -z "$($DRK dao proposal $PROPOSAL | grep '^Proposal was executed on transaction: ')" ]; do
|
|
|
+ sleep $SLEEP_TIME
|
|
|
+ sh ./sync-wallet.sh > /dev/null
|
|
|
done
|
|
|
}
|
|
|
|
|
|
-mint_tokens
|
|
|
-wait_tokens
|
|
|
+wait_token DRK
|
|
|
+mint_token WCKD 42
|
|
|
+wait_token WCKD
|
|
|
+mint_token MLDY 20
|
|
|
+wait_token MLDY
|
|
|
mint_dao
|
|
|
wait_dao_mint
|
|
|
fill_treasury
|