Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🩹 get rid of bidder argument #40

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions auction/build/main.aleo
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ record Bid:


function place_bid:
input r0 as address.private;
input r1 as u64.private;
assert.eq self.caller r0;
cast aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh r0 r1 false into r2 as Bid.record;
output r2 as Bid.record;
input r0 as u64.private;
cast aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh self.caller r0 false into r1 as Bid.record;
output r1 as Bid.record;


function resolve:
Expand Down
4 changes: 0 additions & 4 deletions auction/inputs/auction.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
// The program input for auction/src/main.leo
[place_bid]
// Note that `bidder` must have the same address as the caller (refer to `program.json`).
// Swapping the below lines, will result in an error.
// bidder: address = aleo1y7065c2jxkra5yzu9jfxq55klweqev0zas89lt9nxmfrqrafmq9qw2ktdg;
bidder: address = aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh;
amount: u64 = 90u64;

[resolve]
Expand Down
4 changes: 2 additions & 2 deletions auction/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ echo "
######## ########
###############################################################################
"
leo run place_bid aleo1yzlta2q5h8t0fqe0v6dyh9mtv4aggd53fgzr068jvplqhvqsnvzq7pj2ke 10u64 || exit
leo run place_bid 10u64 || exit

# Swap in the private key and address of the second bidder to .env.
echo "
Expand All @@ -77,7 +77,7 @@ echo "
######## ########
###############################################################################
"
leo run place_bid aleo1esqchvevwn7n5p84e735w4dtwt2hdtu4dpguwgwy94tsxm2p7qpqmlrta4 90u64 || exit
leo run place_bid 90u64 || exit

# Swap in the private key and address of the auctioneer to .env.
echo "
Expand Down
8 changes: 2 additions & 6 deletions auction/src/main.leo
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,14 @@ program auction.aleo {
}

// Returns a new bid.
// - `bidder` : The address of the account that placed the bid.
// - `amount` : The amount of the bid.
// Requires that `bidder` matches the function caller.
// The owner of the record is set to the entity responsible for running the auction (auction runner).
// The address of the auction runner is aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh.
transition place_bid(bidder: address, amount: u64) -> Bid {
// Ensure the caller is the auction bidder.
assert_eq(self.caller, bidder);
transition place_bid(amount: u64) -> Bid {
// Return a new 'Bid' record for the auction bidder.
return Bid {
owner: aleo1fxs9s0w97lmkwlcmgn0z3nuxufdee5yck9wqrs0umevp7qs0sg9q5xxxzh,
bidder: bidder,
bidder: self.caller,
amount: amount,
is_winner: false,
};
Expand Down