mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-23 23:23:50 +03:00
d31b707c4b
* improve leo example run scripts * add leo build warning message, reduce number of calls to snarkvm package open * cargo clippy * Update examples/token/run.sh Co-authored-by: Eric McCarthy <7607035+bendyarm@users.noreply.github.com> Signed-off-by: Collin Chin <16715212+collinc97@users.noreply.github.com> * Update examples/token/run.sh Co-authored-by: Eric McCarthy <7607035+bendyarm@users.noreply.github.com> Signed-off-by: Collin Chin <16715212+collinc97@users.noreply.github.com> * Update examples/token/run.sh Co-authored-by: Eric McCarthy <7607035+bendyarm@users.noreply.github.com> Signed-off-by: Collin Chin <16715212+collinc97@users.noreply.github.com> * Update examples/token/run.sh Co-authored-by: Eric McCarthy <7607035+bendyarm@users.noreply.github.com> Signed-off-by: Collin Chin <16715212+collinc97@users.noreply.github.com> * Update examples/token/run.sh Co-authored-by: Eric McCarthy <7607035+bendyarm@users.noreply.github.com> Signed-off-by: Collin Chin <16715212+collinc97@users.noreply.github.com> * fix comments * make auctioneer the starting private key in auction example --------- Signed-off-by: Collin Chin <16715212+collinc97@users.noreply.github.com> Co-authored-by: Eric McCarthy <7607035+bendyarm@users.noreply.github.com>
143 lines
7.3 KiB
Bash
Executable File
143 lines
7.3 KiB
Bash
Executable File
#!/bin/bash
|
|
# First check that Leo is installed.
|
|
if ! command -v leo &> /dev/null
|
|
then
|
|
echo "leo is not installed."
|
|
exit
|
|
fi
|
|
|
|
# The private key and address of the first bidder.
|
|
# Swap these into program.json, when running transactions as the first bidder.
|
|
# "private_key": "APrivateKey1zkpG9Af9z5Ha4ejVyMCqVFXRKknSm8L1ELEwcc4htk9YhVK"
|
|
# "address": aleo1yzlta2q5h8t0fqe0v6dyh9mtv4aggd53fgzr068jvplqhvqsnvzq7pj2ke
|
|
|
|
# The private key and address of the second bidder.
|
|
# Swap these into program.json, when running transactions as the second bidder.
|
|
# "private_key": "APrivateKey1zkpAFshdsj2EqQzXh5zHceDapFWVCwR6wMCJFfkLYRKupug"
|
|
# "address": aleo1esqchvevwn7n5p84e735w4dtwt2hdtu4dpguwgwy94tsxm2p7qpqmlrta4
|
|
|
|
# The private key and address of the auctioneer.
|
|
# Swap these into program.json, when running transactions as the auctioneer.
|
|
# "private_key": "APrivateKey1zkp5wvamYgK3WCAdpBQxZqQX8XnuN2u11Y6QprZTriVwZVc",
|
|
# "address": "aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh"
|
|
|
|
|
|
echo "
|
|
###############################################################################
|
|
######## ########
|
|
######## STEP 0: Initialize a new 2-party auction ########
|
|
######## ########
|
|
######## ------------------------------- ########
|
|
######## | OPEN | A | B | ########
|
|
######## ------------------------------- ########
|
|
######## | Bid | | | ########
|
|
######## ------------------------------- ########
|
|
######## ########
|
|
###############################################################################
|
|
"
|
|
# Swap in the private key and address of the first bidder to .env.
|
|
echo "
|
|
NETWORK=testnet3
|
|
PRIVATE_KEY=APrivateKey1zkpG9Af9z5Ha4ejVyMCqVFXRKknSm8L1ELEwcc4htk9YhVK
|
|
" > .env
|
|
|
|
# Have the first bidder place a bid of 10.
|
|
echo "
|
|
###############################################################################
|
|
######## ########
|
|
######## STEP 1: The first bidder places a bid of 10 ########
|
|
######## ########
|
|
######## ------------------------------- ########
|
|
######## | OPEN | A | B | ########
|
|
######## ------------------------------- ########
|
|
######## | Bid | 10 | | ########
|
|
######## ------------------------------- ########
|
|
######## ########
|
|
###############################################################################
|
|
"
|
|
leo run place_bid aleo1yzlta2q5h8t0fqe0v6dyh9mtv4aggd53fgzr068jvplqhvqsnvzq7pj2ke 10u64 || exit
|
|
|
|
# Swap in the private key and address of the second bidder to .env.
|
|
echo "
|
|
NETWORK=testnet3
|
|
PRIVATE_KEY=APrivateKey1zkpAFshdsj2EqQzXh5zHceDapFWVCwR6wMCJFfkLYRKupug
|
|
" > .env
|
|
|
|
# Have the second bidder place a bid of 90.
|
|
echo "
|
|
###############################################################################
|
|
######## ########
|
|
######## STEP 2: The second bidder places a bid of 90 ########
|
|
######## ########
|
|
######## ------------------------------- ########
|
|
######## | OPEN | A | B | ########
|
|
######## ------------------------------- ########
|
|
######## | Bid | 10 | 90 | ########
|
|
######## ------------------------------- ########
|
|
######## ########
|
|
###############################################################################
|
|
"
|
|
leo run place_bid aleo1esqchvevwn7n5p84e735w4dtwt2hdtu4dpguwgwy94tsxm2p7qpqmlrta4 90u64 || exit
|
|
|
|
# Swap in the private key and address of the auctioneer to .env.
|
|
echo "
|
|
NETWORK=testnet3
|
|
PRIVATE_KEY=APrivateKey1zkp5wvamYgK3WCAdpBQxZqQX8XnuN2u11Y6QprZTriVwZVc
|
|
" > .env
|
|
|
|
# Have the auctioneer select the winning bid.
|
|
echo "
|
|
###############################################################################
|
|
######## ########
|
|
######## STEP 3: The auctioneer selects the winning bidder ########
|
|
######## ########
|
|
######## ------------------------------- ########
|
|
######## | OPEN | A | → B ← | ########
|
|
######## ------------------------------- ########
|
|
######## | Bid | 10 | → 90 ← | ########
|
|
######## ------------------------------- ########
|
|
######## ########
|
|
###############################################################################
|
|
"
|
|
leo run resolve "{
|
|
owner: aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh.private,
|
|
bidder: aleo1yzlta2q5h8t0fqe0v6dyh9mtv4aggd53fgzr068jvplqhvqsnvzq7pj2ke.private,
|
|
amount: 10u64.private,
|
|
is_winner: false.private,
|
|
_nonce: 4668394794828730542675887906815309351994017139223602571716627453741502624516group.public
|
|
}" "{
|
|
owner: aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh.private,
|
|
bidder: aleo1esqchvevwn7n5p84e735w4dtwt2hdtu4dpguwgwy94tsxm2p7qpqmlrta4.private,
|
|
amount: 90u64.private,
|
|
is_winner: false.private,
|
|
_nonce: 5952811863753971450641238938606857357746712138665944763541786901326522216736group.public
|
|
}" || exit
|
|
|
|
# Have the auctioneer finish the auction.
|
|
echo "
|
|
###############################################################################
|
|
######## ########
|
|
######## STEP 3: The auctioneer completes the auction. ########
|
|
######## ########
|
|
######## ------------------------------- ########
|
|
######## | CLOSE | A | → B ← | ########
|
|
######## ------------------------------- ########
|
|
######## | Bid | 10 | → 90 ← | ########
|
|
######## ------------------------------- ########
|
|
######## ########
|
|
###############################################################################
|
|
"
|
|
leo run finish "{
|
|
owner: aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh.private,
|
|
bidder: aleo1esqchvevwn7n5p84e735w4dtwt2hdtu4dpguwgwy94tsxm2p7qpqmlrta4.private,
|
|
amount: 90u64.private,
|
|
is_winner: false.private,
|
|
_nonce: 5952811863753971450641238938606857357746712138665944763541786901326522216736group.public
|
|
}" || exit
|
|
|
|
|
|
|
|
|
|
|
|
|