From 50c6b30ba550d1bbd678e5fb62d704421221c9af Mon Sep 17 00:00:00 2001 From: Moritz Fuller Date: Tue, 25 Jul 2023 20:49:07 -0400 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=A9=B9=E2=80=87get=20rid=20of=20bidde?= =?UTF-8?q?r=20argument?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- auction/build/main.aleo | 8 +++----- auction/inputs/auction.in | 4 ---- auction/run.sh | 4 ++-- auction/src/main.leo | 6 ++---- 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/auction/build/main.aleo b/auction/build/main.aleo index 480fe0c..0ebd409 100644 --- a/auction/build/main.aleo +++ b/auction/build/main.aleo @@ -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: diff --git a/auction/inputs/auction.in b/auction/inputs/auction.in index c3471d4..84e79a8 100644 --- a/auction/inputs/auction.in +++ b/auction/inputs/auction.in @@ -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] diff --git a/auction/run.sh b/auction/run.sh index 560c345..a07fcfd 100755 --- a/auction/run.sh +++ b/auction/run.sh @@ -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 " @@ -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 " diff --git a/auction/src/main.leo b/auction/src/main.leo index ae94841..d1fbe48 100644 --- a/auction/src/main.leo +++ b/auction/src/main.leo @@ -20,13 +20,11 @@ program auction.aleo { // 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, }; From 857a19e80021a2ba870c0f73d7c9e9054d4dda39 Mon Sep 17 00:00:00 2001 From: Moritz Fuller Date: Tue, 25 Jul 2023 21:00:16 -0400 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=A9=B9=E2=80=87updated=20docstring?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- auction/src/main.leo | 2 -- 1 file changed, 2 deletions(-) diff --git a/auction/src/main.leo b/auction/src/main.leo index d1fbe48..0442274 100644 --- a/auction/src/main.leo +++ b/auction/src/main.leo @@ -15,9 +15,7 @@ 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(amount: u64) -> Bid {