From ff9105c3f2cd15cacbe9fc408e0d3d36b9aad45f Mon Sep 17 00:00:00 2001 From: Luke Newman <5315645+lukenewman@users.noreply.github.com> Date: Tue, 17 Dec 2024 10:25:12 -0500 Subject: [PATCH 1/5] add MAX_ENTRIES assertion to entry functions --- arcade/raffle/build/main.aleo | 246 +++++++++++++++++-------------- arcade/raffle/build/program.json | 10 +- arcade/raffle/leo.lock | 2 +- arcade/raffle/src/main.leo | 12 ++ 4 files changed, 147 insertions(+), 123 deletions(-) diff --git a/arcade/raffle/build/main.aleo b/arcade/raffle/build/main.aleo index 027bbb0..b5c3c15 100644 --- a/arcade/raffle/build/main.aleo +++ b/arcade/raffle/build/main.aleo @@ -60,12 +60,14 @@ function buy_one_entry: finalize buy_one_entry: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; + lt r1 20_000u64 into r2; + assert.eq r2 true; set r0 into entries[r1]; - add r1 1u64 into r2; - set r2 into total_entries[0u64]; - get.or_use user_entries[r0] 0u16 into r3; - add r3 1u16 into r4; - set r4 into user_entries[r0]; + add r1 1u64 into r3; + set r3 into total_entries[0u64]; + get.or_use user_entries[r0] 0u16 into r4; + add r4 1u16 into r5; + set r5 into user_entries[r0]; function buy_two_entries: input r0 as puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket.record; @@ -77,15 +79,17 @@ function buy_two_entries: finalize buy_two_entries: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - add r1 0u64 into r2; - set r0 into entries[r2]; - add r1 1u64 into r3; + lt r1 20_000u64 into r2; + assert.eq r2 true; + add r1 0u64 into r3; set r0 into entries[r3]; - add r1 2u64 into r4; - set r4 into total_entries[0u64]; - get.or_use user_entries[r0] 0u16 into r5; - add r5 2u16 into r6; - set r6 into user_entries[r0]; + add r1 1u64 into r4; + set r0 into entries[r4]; + add r1 2u64 into r5; + set r5 into total_entries[0u64]; + get.or_use user_entries[r0] 0u16 into r6; + add r6 2u16 into r7; + set r7 into user_entries[r0]; function buy_three_entries: input r0 as puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket.record; @@ -97,17 +101,19 @@ function buy_three_entries: finalize buy_three_entries: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - add r1 0u64 into r2; - set r0 into entries[r2]; - add r1 1u64 into r3; + lt r1 20_000u64 into r2; + assert.eq r2 true; + add r1 0u64 into r3; set r0 into entries[r3]; - add r1 2u64 into r4; + add r1 1u64 into r4; set r0 into entries[r4]; - add r1 3u64 into r5; - set r5 into total_entries[0u64]; - get.or_use user_entries[r0] 0u16 into r6; - add r6 3u16 into r7; - set r7 into user_entries[r0]; + add r1 2u64 into r5; + set r0 into entries[r5]; + add r1 3u64 into r6; + set r6 into total_entries[0u64]; + get.or_use user_entries[r0] 0u16 into r7; + add r7 3u16 into r8; + set r8 into user_entries[r0]; function buy_four_entries: input r0 as puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket.record; @@ -119,19 +125,21 @@ function buy_four_entries: finalize buy_four_entries: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - add r1 0u64 into r2; - set r0 into entries[r2]; - add r1 1u64 into r3; + lt r1 20_000u64 into r2; + assert.eq r2 true; + add r1 0u64 into r3; set r0 into entries[r3]; - add r1 2u64 into r4; + add r1 1u64 into r4; set r0 into entries[r4]; - add r1 3u64 into r5; + add r1 2u64 into r5; set r0 into entries[r5]; - add r1 4u64 into r6; - set r6 into total_entries[0u64]; - get.or_use user_entries[r0] 0u16 into r7; - add r7 4u16 into r8; - set r8 into user_entries[r0]; + add r1 3u64 into r6; + set r0 into entries[r6]; + add r1 4u64 into r7; + set r7 into total_entries[0u64]; + get.or_use user_entries[r0] 0u16 into r8; + add r8 4u16 into r9; + set r9 into user_entries[r0]; function buy_five_entries: input r0 as puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket.record; @@ -143,21 +151,23 @@ function buy_five_entries: finalize buy_five_entries: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - add r1 0u64 into r2; - set r0 into entries[r2]; - add r1 1u64 into r3; + lt r1 20_000u64 into r2; + assert.eq r2 true; + add r1 0u64 into r3; set r0 into entries[r3]; - add r1 2u64 into r4; + add r1 1u64 into r4; set r0 into entries[r4]; - add r1 3u64 into r5; + add r1 2u64 into r5; set r0 into entries[r5]; - add r1 4u64 into r6; + add r1 3u64 into r6; set r0 into entries[r6]; - add r1 5u64 into r7; - set r7 into total_entries[0u64]; - get.or_use user_entries[r0] 0u16 into r8; - add r8 5u16 into r9; - set r9 into user_entries[r0]; + add r1 4u64 into r7; + set r0 into entries[r7]; + add r1 5u64 into r8; + set r8 into total_entries[0u64]; + get.or_use user_entries[r0] 0u16 into r9; + add r9 5u16 into r10; + set r10 into user_entries[r0]; function buy_six_entries: input r0 as puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket.record; @@ -169,23 +179,25 @@ function buy_six_entries: finalize buy_six_entries: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - add r1 0u64 into r2; - set r0 into entries[r2]; - add r1 1u64 into r3; + lt r1 20_000u64 into r2; + assert.eq r2 true; + add r1 0u64 into r3; set r0 into entries[r3]; - add r1 2u64 into r4; + add r1 1u64 into r4; set r0 into entries[r4]; - add r1 3u64 into r5; + add r1 2u64 into r5; set r0 into entries[r5]; - add r1 4u64 into r6; + add r1 3u64 into r6; set r0 into entries[r6]; - add r1 5u64 into r7; + add r1 4u64 into r7; set r0 into entries[r7]; - add r1 6u64 into r8; - set r8 into total_entries[0u64]; - get.or_use user_entries[r0] 0u16 into r9; - add r9 6u16 into r10; - set r10 into user_entries[r0]; + add r1 5u64 into r8; + set r0 into entries[r8]; + add r1 6u64 into r9; + set r9 into total_entries[0u64]; + get.or_use user_entries[r0] 0u16 into r10; + add r10 6u16 into r11; + set r11 into user_entries[r0]; function buy_seven_entries: input r0 as puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket.record; @@ -197,25 +209,27 @@ function buy_seven_entries: finalize buy_seven_entries: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - add r1 0u64 into r2; - set r0 into entries[r2]; - add r1 1u64 into r3; + lt r1 20_000u64 into r2; + assert.eq r2 true; + add r1 0u64 into r3; set r0 into entries[r3]; - add r1 2u64 into r4; + add r1 1u64 into r4; set r0 into entries[r4]; - add r1 3u64 into r5; + add r1 2u64 into r5; set r0 into entries[r5]; - add r1 4u64 into r6; + add r1 3u64 into r6; set r0 into entries[r6]; - add r1 5u64 into r7; + add r1 4u64 into r7; set r0 into entries[r7]; - add r1 6u64 into r8; + add r1 5u64 into r8; set r0 into entries[r8]; - add r1 7u64 into r9; - set r9 into total_entries[0u64]; - get.or_use user_entries[r0] 0u16 into r10; - add r10 7u16 into r11; - set r11 into user_entries[r0]; + add r1 6u64 into r9; + set r0 into entries[r9]; + add r1 7u64 into r10; + set r10 into total_entries[0u64]; + get.or_use user_entries[r0] 0u16 into r11; + add r11 7u16 into r12; + set r12 into user_entries[r0]; function buy_eight_entries: input r0 as puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket.record; @@ -227,27 +241,29 @@ function buy_eight_entries: finalize buy_eight_entries: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - add r1 0u64 into r2; - set r0 into entries[r2]; - add r1 1u64 into r3; + lt r1 20_000u64 into r2; + assert.eq r2 true; + add r1 0u64 into r3; set r0 into entries[r3]; - add r1 2u64 into r4; + add r1 1u64 into r4; set r0 into entries[r4]; - add r1 3u64 into r5; + add r1 2u64 into r5; set r0 into entries[r5]; - add r1 4u64 into r6; + add r1 3u64 into r6; set r0 into entries[r6]; - add r1 5u64 into r7; + add r1 4u64 into r7; set r0 into entries[r7]; - add r1 6u64 into r8; + add r1 5u64 into r8; set r0 into entries[r8]; - add r1 7u64 into r9; + add r1 6u64 into r9; set r0 into entries[r9]; - add r1 8u64 into r10; - set r10 into total_entries[0u64]; - get.or_use user_entries[r0] 0u16 into r11; - add r11 8u16 into r12; - set r12 into user_entries[r0]; + add r1 7u64 into r10; + set r0 into entries[r10]; + add r1 8u64 into r11; + set r11 into total_entries[0u64]; + get.or_use user_entries[r0] 0u16 into r12; + add r12 8u16 into r13; + set r13 into user_entries[r0]; function buy_nine_entries: input r0 as puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket.record; @@ -259,29 +275,31 @@ function buy_nine_entries: finalize buy_nine_entries: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - add r1 0u64 into r2; - set r0 into entries[r2]; - add r1 1u64 into r3; + lt r1 20_000u64 into r2; + assert.eq r2 true; + add r1 0u64 into r3; set r0 into entries[r3]; - add r1 2u64 into r4; + add r1 1u64 into r4; set r0 into entries[r4]; - add r1 3u64 into r5; + add r1 2u64 into r5; set r0 into entries[r5]; - add r1 4u64 into r6; + add r1 3u64 into r6; set r0 into entries[r6]; - add r1 5u64 into r7; + add r1 4u64 into r7; set r0 into entries[r7]; - add r1 6u64 into r8; + add r1 5u64 into r8; set r0 into entries[r8]; - add r1 7u64 into r9; + add r1 6u64 into r9; set r0 into entries[r9]; - add r1 8u64 into r10; + add r1 7u64 into r10; set r0 into entries[r10]; - add r1 9u64 into r11; - set r11 into total_entries[0u64]; - get.or_use user_entries[r0] 0u16 into r12; - add r12 9u16 into r13; - set r13 into user_entries[r0]; + add r1 8u64 into r11; + set r0 into entries[r11]; + add r1 9u64 into r12; + set r12 into total_entries[0u64]; + get.or_use user_entries[r0] 0u16 into r13; + add r13 9u16 into r14; + set r14 into user_entries[r0]; function buy_ten_entries: input r0 as puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket.record; @@ -293,31 +311,33 @@ function buy_ten_entries: finalize buy_ten_entries: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - add r1 0u64 into r2; - set r0 into entries[r2]; - add r1 1u64 into r3; + lt r1 20_000u64 into r2; + assert.eq r2 true; + add r1 0u64 into r3; set r0 into entries[r3]; - add r1 2u64 into r4; + add r1 1u64 into r4; set r0 into entries[r4]; - add r1 3u64 into r5; + add r1 2u64 into r5; set r0 into entries[r5]; - add r1 4u64 into r6; + add r1 3u64 into r6; set r0 into entries[r6]; - add r1 5u64 into r7; + add r1 4u64 into r7; set r0 into entries[r7]; - add r1 6u64 into r8; + add r1 5u64 into r8; set r0 into entries[r8]; - add r1 7u64 into r9; + add r1 6u64 into r9; set r0 into entries[r9]; - add r1 8u64 into r10; + add r1 7u64 into r10; set r0 into entries[r10]; - add r1 9u64 into r11; + add r1 8u64 into r11; set r0 into entries[r11]; - add r1 10u64 into r12; - set r12 into total_entries[0u64]; - get.or_use user_entries[r0] 0u16 into r13; - add r13 10u16 into r14; - set r14 into user_entries[r0]; + add r1 9u64 into r12; + set r0 into entries[r12]; + add r1 10u64 into r13; + set r13 into total_entries[0u64]; + get.or_use user_entries[r0] 0u16 into r14; + add r14 10u16 into r15; + set r15 into user_entries[r0]; function draw_winner: assert.eq self.caller self.signer; diff --git a/arcade/raffle/build/program.json b/arcade/raffle/build/program.json index c4a2b6f..1274791 100644 --- a/arcade/raffle/build/program.json +++ b/arcade/raffle/build/program.json @@ -2,13 +2,5 @@ "program": "puzzle_giveaway_112724.aleo", "version": "0.0.0", "description": "", - "license": "MIT", - "dependencies": [ - { - "name": "puzzle_arcade_ticket_v002.aleo", - "location": "local", - "network": null, - "path": "../ticket" - } - ] + "license": "MIT" } diff --git a/arcade/raffle/leo.lock b/arcade/raffle/leo.lock index 2b711e5..187dc7f 100644 --- a/arcade/raffle/leo.lock +++ b/arcade/raffle/leo.lock @@ -1,6 +1,6 @@ [[package]] name = "puzzle_arcade_ticket_v002.aleo" location = "local" -path = "/Users/jonathan/Desktop/serengeti/arcade/raffle/../ticket" +path = "/Users/lucas/code/puzzle/serengeti/arcade/raffle/../ticket" checksum = "62705078d06ab0ce2dfb7244b958735e1c8272e7be51db8adf80386df51a938c" dependencies = [] diff --git a/arcade/raffle/src/main.leo b/arcade/raffle/src/main.leo index 3a654b3..bdd5a87 100644 --- a/arcade/raffle/src/main.leo +++ b/arcade/raffle/src/main.leo @@ -2,6 +2,7 @@ import puzzle_arcade_ticket_v002.aleo; program puzzle_giveaway_112724.aleo { const OPERATOR: address = aleo196a39wq9q8ea779cmlmff0c9pj2gl4f5e8fhjpvmufe5utuq7y8snz4h2l; + const MAX_ENTRIES: u64 = 20_000u64; // used for storing the raffle entries (multiple entries per address) // i.e. 0 -> aleo1...asdf, 1 -> aleo1...ghjk @@ -69,6 +70,8 @@ program puzzle_giveaway_112724.aleo { async function add_one_entry (public participant: address) { // get current raffle count, if first entry, choose default of 0u64 let current_raffle_count: u64 = Mapping::get_or_use(total_entries, 0u64, 0u64); + assert(current_raffle_count < MAX_ENTRIES); + // add address to entry mapping Mapping::set(entries, current_raffle_count, participant); // increment raffle total entries by 1 @@ -87,6 +90,7 @@ program puzzle_giveaway_112724.aleo { } async function add_two_entries (public participant: address) { let current_raffle_count: u64 = Mapping::get_or_use(total_entries, 0u64, 0u64); + assert(current_raffle_count < MAX_ENTRIES); for i: u64 in 0u64..2u64 { Mapping::set(entries, current_raffle_count + i, participant); @@ -107,6 +111,7 @@ program puzzle_giveaway_112724.aleo { } async function add_three_entries (public participant: address) { let current_raffle_count: u64 = Mapping::get_or_use(total_entries, 0u64, 0u64); + assert(current_raffle_count < MAX_ENTRIES); for i: u64 in 0u64..3u64 { Mapping::set(entries, current_raffle_count + i, participant); @@ -127,6 +132,7 @@ program puzzle_giveaway_112724.aleo { } async function add_four_entries(public participant: address) { let current_raffle_count: u64 = Mapping::get_or_use(total_entries, 0u64, 0u64); + assert(current_raffle_count < MAX_ENTRIES); for i: u64 in 0u64..4u64 { Mapping::set(entries, current_raffle_count + i, participant); @@ -147,6 +153,7 @@ program puzzle_giveaway_112724.aleo { } async function add_five_entries(public participant: address) { let current_raffle_count: u64 = Mapping::get_or_use(total_entries, 0u64, 0u64); + assert(current_raffle_count < MAX_ENTRIES); for i: u64 in 0u64..5u64 { Mapping::set(entries, current_raffle_count + i, participant); @@ -167,6 +174,7 @@ program puzzle_giveaway_112724.aleo { } async function add_six_entries(public participant: address) { let current_raffle_count: u64 = Mapping::get_or_use(total_entries, 0u64, 0u64); + assert(current_raffle_count < MAX_ENTRIES); for i: u64 in 0u64..6u64 { Mapping::set(entries, current_raffle_count + i, participant); @@ -187,6 +195,7 @@ program puzzle_giveaway_112724.aleo { } async function add_seven_entries(public participant: address) { let current_raffle_count: u64 = Mapping::get_or_use(total_entries, 0u64, 0u64); + assert(current_raffle_count < MAX_ENTRIES); for i: u64 in 0u64..7u64 { Mapping::set(entries, current_raffle_count + i, participant); @@ -207,6 +216,7 @@ program puzzle_giveaway_112724.aleo { } async function add_eight_entries(public participant: address) { let current_raffle_count: u64 = Mapping::get_or_use(total_entries, 0u64, 0u64); + assert(current_raffle_count < MAX_ENTRIES); for i: u64 in 0u64..8u64 { Mapping::set(entries, current_raffle_count + i, participant); @@ -227,6 +237,7 @@ program puzzle_giveaway_112724.aleo { } async function add_nine_entries(public participant: address) { let current_raffle_count: u64 = Mapping::get_or_use(total_entries, 0u64, 0u64); + assert(current_raffle_count < MAX_ENTRIES); for i: u64 in 0u64..9u64 { Mapping::set(entries, current_raffle_count + i, participant); @@ -247,6 +258,7 @@ program puzzle_giveaway_112724.aleo { } async function add_ten_entries(public participant: address) { let current_raffle_count: u64 = Mapping::get_or_use(total_entries, 0u64, 0u64); + assert(current_raffle_count < MAX_ENTRIES); for i: u64 in 0u64..10u64 { Mapping::set(entries, current_raffle_count + i, participant); From d7d1253ec5bb9b70991073dd845eb7feca9bc975 Mon Sep 17 00:00:00 2001 From: Luke Newman <5315645+lukenewman@users.noreply.github.com> Date: Tue, 17 Dec 2024 11:26:55 -0500 Subject: [PATCH 2/5] testing version --- arcade/raffle/build/README.md | 2 +- ...02.aleo => puzzle_arcade_ticket_v001.aleo} | 42 +++---- arcade/raffle/build/main.aleo | 106 +++++++++--------- arcade/raffle/build/program.json | 2 +- arcade/raffle/leo.lock | 8 +- arcade/raffle/program.json | 9 +- arcade/raffle/src/main.leo | 66 +++++------ 7 files changed, 117 insertions(+), 118 deletions(-) rename arcade/raffle/build/imports/{puzzle_arcade_ticket_v002.aleo => puzzle_arcade_ticket_v001.aleo} (80%) diff --git a/arcade/raffle/build/README.md b/arcade/raffle/build/README.md index 4625589..7ffbbcf 100644 --- a/arcade/raffle/build/README.md +++ b/arcade/raffle/build/README.md @@ -1,4 +1,4 @@ -# puzzle_giveaway_112724.aleo +# giveaway_entry_limits.aleo ## Build Guide diff --git a/arcade/raffle/build/imports/puzzle_arcade_ticket_v002.aleo b/arcade/raffle/build/imports/puzzle_arcade_ticket_v001.aleo similarity index 80% rename from arcade/raffle/build/imports/puzzle_arcade_ticket_v002.aleo rename to arcade/raffle/build/imports/puzzle_arcade_ticket_v001.aleo index e8cbe27..47b73f5 100644 --- a/arcade/raffle/build/imports/puzzle_arcade_ticket_v002.aleo +++ b/arcade/raffle/build/imports/puzzle_arcade_ticket_v001.aleo @@ -1,4 +1,4 @@ -program puzzle_arcade_ticket_v002.aleo; +program puzzle_arcade_ticket_v001.aleo; record PuzzleArcadeTicket: owner as address.private; @@ -10,10 +10,10 @@ mapping registry: function add_program_to_registry: input r0 as address.private; - assert.eq self.caller self.signer; - assert.eq self.caller aleo196a39wq9q8ea779cmlmff0c9pj2gl4f5e8fhjpvmufe5utuq7y8snz4h2l; + assert.eq self.caller self.signer ; + assert.eq self.caller aleo1pedhtu6akw9z68wedu8t3fgxfdh3ye2rypeqkx9cxjpr99chqvyqkjg7rw ; async add_program_to_registry r0 into r1; - output r1 as puzzle_arcade_ticket_v002.aleo/add_program_to_registry.future; + output r1 as puzzle_arcade_ticket_v001.aleo/add_program_to_registry.future; finalize add_program_to_registry: input r0 as address.public; @@ -25,18 +25,18 @@ function mint: cast r0 r1 into r2 as PuzzleArcadeTicket.record; async mint self.caller into r3; output r2 as PuzzleArcadeTicket.record; - output r3 as puzzle_arcade_ticket_v002.aleo/mint.future; + output r3 as puzzle_arcade_ticket_v001.aleo/mint.future; finalize mint: input r0 as address.public; get.or_use registry[r0] false into r1; - assert.eq r1 true; + assert.eq r1 true ; function spend: input r0 as PuzzleArcadeTicket.record; input r1 as u64.public; gte r0.amount r1 into r2; - assert.eq r2 true; + assert.eq r2 true ; sub r0.amount r1 into r3; cast r0.owner r3 into r4 as PuzzleArcadeTicket.record; output r4 as PuzzleArcadeTicket.record; @@ -45,9 +45,9 @@ function join: input r0 as PuzzleArcadeTicket.record; input r1 as PuzzleArcadeTicket.record; gt r0.amount 0u64 into r2; - assert.eq r2 true; + assert.eq r2 true ; gt r1.amount 0u64 into r3; - assert.eq r3 true; + assert.eq r3 true ; add r0.amount r1.amount into r4; cast self.signer r4 into r5 as PuzzleArcadeTicket.record; output r5 as PuzzleArcadeTicket.record; @@ -57,11 +57,11 @@ function join3: input r1 as PuzzleArcadeTicket.record; input r2 as PuzzleArcadeTicket.record; gt r0.amount 0u64 into r3; - assert.eq r3 true; + assert.eq r3 true ; gt r1.amount 0u64 into r4; - assert.eq r4 true; + assert.eq r4 true ; gt r2.amount 0u64 into r5; - assert.eq r5 true; + assert.eq r5 true ; add r0.amount r1.amount into r6; add r6 r2.amount into r7; cast self.signer r7 into r8 as PuzzleArcadeTicket.record; @@ -73,13 +73,13 @@ function join4: input r2 as PuzzleArcadeTicket.record; input r3 as PuzzleArcadeTicket.record; gt r0.amount 0u64 into r4; - assert.eq r4 true; + assert.eq r4 true ; gt r1.amount 0u64 into r5; - assert.eq r5 true; + assert.eq r5 true ; gt r2.amount 0u64 into r6; - assert.eq r6 true; + assert.eq r6 true ; gt r3.amount 0u64 into r7; - assert.eq r7 true; + assert.eq r7 true ; add r0.amount r1.amount into r8; add r8 r2.amount into r9; add r9 r3.amount into r10; @@ -93,15 +93,15 @@ function join5: input r3 as PuzzleArcadeTicket.record; input r4 as PuzzleArcadeTicket.record; gt r0.amount 0u64 into r5; - assert.eq r5 true; + assert.eq r5 true ; gt r1.amount 0u64 into r6; - assert.eq r6 true; + assert.eq r6 true ; gt r2.amount 0u64 into r7; - assert.eq r7 true; + assert.eq r7 true ; gt r3.amount 0u64 into r8; - assert.eq r8 true; + assert.eq r8 true ; gt r4.amount 0u64 into r9; - assert.eq r9 true; + assert.eq r9 true ; add r0.amount r1.amount into r10; add r10 r2.amount into r11; add r11 r3.amount into r12; diff --git a/arcade/raffle/build/main.aleo b/arcade/raffle/build/main.aleo index b5c3c15..28833ec 100644 --- a/arcade/raffle/build/main.aleo +++ b/arcade/raffle/build/main.aleo @@ -1,5 +1,5 @@ -import puzzle_arcade_ticket_v002.aleo; -program puzzle_giveaway_112724.aleo; +import puzzle_arcade_ticket_v001.aleo; +program giveaway_entry_limits.aleo; struct PrivateKey: pk_pt1 as u128; @@ -51,16 +51,16 @@ function mint_prize: output r5 as AuditPrize.record; function buy_one_entry: - input r0 as puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket.record; - call puzzle_arcade_ticket_v002.aleo/spend r0 1000000u64 into r1; + input r0 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; + call puzzle_arcade_ticket_v001.aleo/spend r0 1000000u64 into r1; async buy_one_entry r0.owner into r2; - output r1 as puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket.record; - output r2 as puzzle_giveaway_112724.aleo/buy_one_entry.future; + output r1 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; + output r2 as giveaway_entry_limits.aleo/buy_one_entry.future; finalize buy_one_entry: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - lt r1 20_000u64 into r2; + lt r1 250u64 into r2; assert.eq r2 true; set r0 into entries[r1]; add r1 1u64 into r3; @@ -70,16 +70,16 @@ finalize buy_one_entry: set r5 into user_entries[r0]; function buy_two_entries: - input r0 as puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket.record; - call puzzle_arcade_ticket_v002.aleo/spend r0 2000000u64 into r1; + input r0 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; + call puzzle_arcade_ticket_v001.aleo/spend r0 2000000u64 into r1; async buy_two_entries r0.owner into r2; - output r1 as puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket.record; - output r2 as puzzle_giveaway_112724.aleo/buy_two_entries.future; + output r1 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; + output r2 as giveaway_entry_limits.aleo/buy_two_entries.future; finalize buy_two_entries: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - lt r1 20_000u64 into r2; + lt r1 250u64 into r2; assert.eq r2 true; add r1 0u64 into r3; set r0 into entries[r3]; @@ -92,16 +92,16 @@ finalize buy_two_entries: set r7 into user_entries[r0]; function buy_three_entries: - input r0 as puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket.record; - call puzzle_arcade_ticket_v002.aleo/spend r0 3000000u64 into r1; + input r0 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; + call puzzle_arcade_ticket_v001.aleo/spend r0 3000000u64 into r1; async buy_three_entries r0.owner into r2; - output r1 as puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket.record; - output r2 as puzzle_giveaway_112724.aleo/buy_three_entries.future; + output r1 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; + output r2 as giveaway_entry_limits.aleo/buy_three_entries.future; finalize buy_three_entries: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - lt r1 20_000u64 into r2; + lt r1 250u64 into r2; assert.eq r2 true; add r1 0u64 into r3; set r0 into entries[r3]; @@ -116,16 +116,16 @@ finalize buy_three_entries: set r8 into user_entries[r0]; function buy_four_entries: - input r0 as puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket.record; - call puzzle_arcade_ticket_v002.aleo/spend r0 4000000u64 into r1; + input r0 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; + call puzzle_arcade_ticket_v001.aleo/spend r0 4000000u64 into r1; async buy_four_entries r0.owner into r2; - output r1 as puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket.record; - output r2 as puzzle_giveaway_112724.aleo/buy_four_entries.future; + output r1 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; + output r2 as giveaway_entry_limits.aleo/buy_four_entries.future; finalize buy_four_entries: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - lt r1 20_000u64 into r2; + lt r1 250u64 into r2; assert.eq r2 true; add r1 0u64 into r3; set r0 into entries[r3]; @@ -142,16 +142,16 @@ finalize buy_four_entries: set r9 into user_entries[r0]; function buy_five_entries: - input r0 as puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket.record; - call puzzle_arcade_ticket_v002.aleo/spend r0 5000000u64 into r1; + input r0 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; + call puzzle_arcade_ticket_v001.aleo/spend r0 5000000u64 into r1; async buy_five_entries r0.owner into r2; - output r1 as puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket.record; - output r2 as puzzle_giveaway_112724.aleo/buy_five_entries.future; + output r1 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; + output r2 as giveaway_entry_limits.aleo/buy_five_entries.future; finalize buy_five_entries: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - lt r1 20_000u64 into r2; + lt r1 250u64 into r2; assert.eq r2 true; add r1 0u64 into r3; set r0 into entries[r3]; @@ -170,16 +170,16 @@ finalize buy_five_entries: set r10 into user_entries[r0]; function buy_six_entries: - input r0 as puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket.record; - call puzzle_arcade_ticket_v002.aleo/spend r0 6000000u64 into r1; + input r0 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; + call puzzle_arcade_ticket_v001.aleo/spend r0 6000000u64 into r1; async buy_six_entries r0.owner into r2; - output r1 as puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket.record; - output r2 as puzzle_giveaway_112724.aleo/buy_six_entries.future; + output r1 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; + output r2 as giveaway_entry_limits.aleo/buy_six_entries.future; finalize buy_six_entries: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - lt r1 20_000u64 into r2; + lt r1 250u64 into r2; assert.eq r2 true; add r1 0u64 into r3; set r0 into entries[r3]; @@ -200,16 +200,16 @@ finalize buy_six_entries: set r11 into user_entries[r0]; function buy_seven_entries: - input r0 as puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket.record; - call puzzle_arcade_ticket_v002.aleo/spend r0 7000000u64 into r1; + input r0 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; + call puzzle_arcade_ticket_v001.aleo/spend r0 7000000u64 into r1; async buy_seven_entries r0.owner into r2; - output r1 as puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket.record; - output r2 as puzzle_giveaway_112724.aleo/buy_seven_entries.future; + output r1 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; + output r2 as giveaway_entry_limits.aleo/buy_seven_entries.future; finalize buy_seven_entries: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - lt r1 20_000u64 into r2; + lt r1 250u64 into r2; assert.eq r2 true; add r1 0u64 into r3; set r0 into entries[r3]; @@ -232,16 +232,16 @@ finalize buy_seven_entries: set r12 into user_entries[r0]; function buy_eight_entries: - input r0 as puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket.record; - call puzzle_arcade_ticket_v002.aleo/spend r0 8000000u64 into r1; + input r0 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; + call puzzle_arcade_ticket_v001.aleo/spend r0 8000000u64 into r1; async buy_eight_entries r0.owner into r2; - output r1 as puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket.record; - output r2 as puzzle_giveaway_112724.aleo/buy_eight_entries.future; + output r1 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; + output r2 as giveaway_entry_limits.aleo/buy_eight_entries.future; finalize buy_eight_entries: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - lt r1 20_000u64 into r2; + lt r1 250u64 into r2; assert.eq r2 true; add r1 0u64 into r3; set r0 into entries[r3]; @@ -266,16 +266,16 @@ finalize buy_eight_entries: set r13 into user_entries[r0]; function buy_nine_entries: - input r0 as puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket.record; - call puzzle_arcade_ticket_v002.aleo/spend r0 9000000u64 into r1; + input r0 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; + call puzzle_arcade_ticket_v001.aleo/spend r0 9000000u64 into r1; async buy_nine_entries r0.owner into r2; - output r1 as puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket.record; - output r2 as puzzle_giveaway_112724.aleo/buy_nine_entries.future; + output r1 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; + output r2 as giveaway_entry_limits.aleo/buy_nine_entries.future; finalize buy_nine_entries: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - lt r1 20_000u64 into r2; + lt r1 250u64 into r2; assert.eq r2 true; add r1 0u64 into r3; set r0 into entries[r3]; @@ -302,16 +302,16 @@ finalize buy_nine_entries: set r14 into user_entries[r0]; function buy_ten_entries: - input r0 as puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket.record; - call puzzle_arcade_ticket_v002.aleo/spend r0 10000000u64 into r1; + input r0 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; + call puzzle_arcade_ticket_v001.aleo/spend r0 10000000u64 into r1; async buy_ten_entries r0.owner into r2; - output r1 as puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket.record; - output r2 as puzzle_giveaway_112724.aleo/buy_ten_entries.future; + output r1 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; + output r2 as giveaway_entry_limits.aleo/buy_ten_entries.future; finalize buy_ten_entries: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - lt r1 20_000u64 into r2; + lt r1 250u64 into r2; assert.eq r2 true; add r1 0u64 into r3; set r0 into entries[r3]; @@ -343,7 +343,7 @@ function draw_winner: assert.eq self.caller self.signer; assert.eq self.caller aleo196a39wq9q8ea779cmlmff0c9pj2gl4f5e8fhjpvmufe5utuq7y8snz4h2l; async draw_winner into r0; - output r0 as puzzle_giveaway_112724.aleo/draw_winner.future; + output r0 as giveaway_entry_limits.aleo/draw_winner.future; finalize draw_winner: get total_entries[0u64] into r0; diff --git a/arcade/raffle/build/program.json b/arcade/raffle/build/program.json index 1274791..3cfbb91 100644 --- a/arcade/raffle/build/program.json +++ b/arcade/raffle/build/program.json @@ -1,5 +1,5 @@ { - "program": "puzzle_giveaway_112724.aleo", + "program": "giveaway_entry_limits.aleo", "version": "0.0.0", "description": "", "license": "MIT" diff --git a/arcade/raffle/leo.lock b/arcade/raffle/leo.lock index 187dc7f..7c2e161 100644 --- a/arcade/raffle/leo.lock +++ b/arcade/raffle/leo.lock @@ -1,6 +1,6 @@ [[package]] -name = "puzzle_arcade_ticket_v002.aleo" -location = "local" -path = "/Users/lucas/code/puzzle/serengeti/arcade/raffle/../ticket" -checksum = "62705078d06ab0ce2dfb7244b958735e1c8272e7be51db8adf80386df51a938c" +name = "puzzle_arcade_ticket_v001.aleo" +network = "testnet" +location = "network" +checksum = "cdc6997cbeba912b2bd3e258b21bdc1576f60e05d8573d7e01788aee9163bcd7" dependencies = [] diff --git a/arcade/raffle/program.json b/arcade/raffle/program.json index c4a2b6f..bb07bd3 100644 --- a/arcade/raffle/program.json +++ b/arcade/raffle/program.json @@ -1,14 +1,13 @@ { - "program": "puzzle_giveaway_112724.aleo", + "program": "giveaway_entry_limits.aleo", "version": "0.0.0", "description": "", "license": "MIT", "dependencies": [ { - "name": "puzzle_arcade_ticket_v002.aleo", - "location": "local", - "network": null, - "path": "../ticket" + "name": "puzzle_arcade_ticket_v001.aleo", + "location": "network", + "network": "testnet" } ] } diff --git a/arcade/raffle/src/main.leo b/arcade/raffle/src/main.leo index bdd5a87..3cea5e0 100644 --- a/arcade/raffle/src/main.leo +++ b/arcade/raffle/src/main.leo @@ -1,8 +1,8 @@ -import puzzle_arcade_ticket_v002.aleo; +import puzzle_arcade_ticket_v001.aleo; -program puzzle_giveaway_112724.aleo { +program giveaway_entry_limits.aleo { const OPERATOR: address = aleo196a39wq9q8ea779cmlmff0c9pj2gl4f5e8fhjpvmufe5utuq7y8snz4h2l; - const MAX_ENTRIES: u64 = 20_000u64; + const MAX_ENTRIES: u64 = 250u64; // used for storing the raffle entries (multiple entries per address) // i.e. 0 -> aleo1...asdf, 1 -> aleo1...ghjk @@ -60,11 +60,11 @@ program puzzle_giveaway_112724.aleo { return (prize, audit_prize); } - async transition buy_one_entry (ticket: puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket) -> ( - puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket, + async transition buy_one_entry (ticket: puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket) -> ( + puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket, Future ) { - let spent_ticket: puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket = puzzle_arcade_ticket_v002.aleo/spend (ticket, 1000000u64); + let spent_ticket: puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket = puzzle_arcade_ticket_v001.aleo/spend (ticket, 1000000u64); return (spent_ticket, add_one_entry(ticket.owner)); } async function add_one_entry (public participant: address) { @@ -81,11 +81,11 @@ program puzzle_giveaway_112724.aleo { Mapping::set(user_entries, participant, current_user_entries + 1u16); } - async transition buy_two_entries (ticket: puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket) -> ( - puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket, + async transition buy_two_entries (ticket: puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket) -> ( + puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket, Future ) { - let spent_ticket: puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket = puzzle_arcade_ticket_v002.aleo/spend (ticket, 2000000u64); + let spent_ticket: puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket = puzzle_arcade_ticket_v001.aleo/spend (ticket, 2000000u64); return (spent_ticket, add_two_entries(ticket.owner)); } async function add_two_entries (public participant: address) { @@ -102,11 +102,11 @@ program puzzle_giveaway_112724.aleo { Mapping::set(user_entries, participant, current_user_entries + 2u16); } - async transition buy_three_entries (ticket: puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket) -> ( - puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket, + async transition buy_three_entries (ticket: puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket) -> ( + puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket, Future ) { - let spent_ticket: puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket = puzzle_arcade_ticket_v002.aleo/spend (ticket, 3000000u64); + let spent_ticket: puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket = puzzle_arcade_ticket_v001.aleo/spend (ticket, 3000000u64); return (spent_ticket, add_three_entries(ticket.owner)); } async function add_three_entries (public participant: address) { @@ -123,11 +123,11 @@ program puzzle_giveaway_112724.aleo { Mapping::set(user_entries, participant, current_user_entries + 3u16); } - async transition buy_four_entries(ticket: puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket) -> ( - puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket, + async transition buy_four_entries(ticket: puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket) -> ( + puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket, Future ) { - let spent_ticket: puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket = puzzle_arcade_ticket_v002.aleo/spend (ticket, 4000000u64); + let spent_ticket: puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket = puzzle_arcade_ticket_v001.aleo/spend (ticket, 4000000u64); return (spent_ticket, add_four_entries(ticket.owner)); } async function add_four_entries(public participant: address) { @@ -144,11 +144,11 @@ program puzzle_giveaway_112724.aleo { Mapping::set(user_entries, participant, current_user_entries + 4u16); } - async transition buy_five_entries(ticket: puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket) -> ( - puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket, + async transition buy_five_entries(ticket: puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket) -> ( + puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket, Future ) { - let spent_ticket: puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket = puzzle_arcade_ticket_v002.aleo/spend (ticket, 5000000u64); + let spent_ticket: puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket = puzzle_arcade_ticket_v001.aleo/spend (ticket, 5000000u64); return (spent_ticket, add_five_entries(ticket.owner)); } async function add_five_entries(public participant: address) { @@ -165,11 +165,11 @@ program puzzle_giveaway_112724.aleo { Mapping::set(user_entries, participant, current_user_entries + 5u16); } - async transition buy_six_entries(ticket: puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket) -> ( - puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket, + async transition buy_six_entries(ticket: puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket) -> ( + puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket, Future ) { - let spent_ticket: puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket = puzzle_arcade_ticket_v002.aleo/spend (ticket, 6000000u64); + let spent_ticket: puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket = puzzle_arcade_ticket_v001.aleo/spend (ticket, 6000000u64); return (spent_ticket, add_six_entries(ticket.owner)); } async function add_six_entries(public participant: address) { @@ -186,11 +186,11 @@ program puzzle_giveaway_112724.aleo { Mapping::set(user_entries, participant, current_user_entries + 6u16); } - async transition buy_seven_entries(ticket: puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket) -> ( - puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket, + async transition buy_seven_entries(ticket: puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket) -> ( + puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket, Future ) { - let spent_ticket: puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket = puzzle_arcade_ticket_v002.aleo/spend (ticket, 7000000u64); + let spent_ticket: puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket = puzzle_arcade_ticket_v001.aleo/spend (ticket, 7000000u64); return (spent_ticket, add_seven_entries(ticket.owner)); } async function add_seven_entries(public participant: address) { @@ -207,11 +207,11 @@ program puzzle_giveaway_112724.aleo { Mapping::set(user_entries, participant, current_user_entries + 7u16); } - async transition buy_eight_entries(ticket: puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket) -> ( - puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket, + async transition buy_eight_entries(ticket: puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket) -> ( + puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket, Future ) { - let spent_ticket: puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket = puzzle_arcade_ticket_v002.aleo/spend (ticket, 8000000u64); + let spent_ticket: puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket = puzzle_arcade_ticket_v001.aleo/spend (ticket, 8000000u64); return (spent_ticket, add_eight_entries(ticket.owner)); } async function add_eight_entries(public participant: address) { @@ -228,11 +228,11 @@ program puzzle_giveaway_112724.aleo { Mapping::set(user_entries, participant, current_user_entries + 8u16); } - async transition buy_nine_entries(ticket: puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket) -> ( - puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket, + async transition buy_nine_entries(ticket: puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket) -> ( + puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket, Future ) { - let spent_ticket: puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket = puzzle_arcade_ticket_v002.aleo/spend (ticket, 9000000u64); + let spent_ticket: puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket = puzzle_arcade_ticket_v001.aleo/spend (ticket, 9000000u64); return (spent_ticket, add_nine_entries(ticket.owner)); } async function add_nine_entries(public participant: address) { @@ -249,11 +249,11 @@ program puzzle_giveaway_112724.aleo { Mapping::set(user_entries, participant, current_user_entries + 9u16); } - async transition buy_ten_entries(ticket: puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket) -> ( - puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket, + async transition buy_ten_entries(ticket: puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket) -> ( + puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket, Future ) { - let spent_ticket: puzzle_arcade_ticket_v002.aleo/PuzzleArcadeTicket = puzzle_arcade_ticket_v002.aleo/spend (ticket, 10000000u64); + let spent_ticket: puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket = puzzle_arcade_ticket_v001.aleo/spend (ticket, 10000000u64); return (spent_ticket, add_ten_entries(ticket.owner)); } async function add_ten_entries(public participant: address) { From db8d023ed5a5ea44ba696be2b189971aeaa8cab4 Mon Sep 17 00:00:00 2001 From: Luke Newman <5315645+lukenewman@users.noreply.github.com> Date: Thu, 19 Dec 2024 14:15:35 -0500 Subject: [PATCH 3/5] add max entries --- arcade/raffle/build/README.md | 2 +- arcade/raffle/build/main.aleo | 44 ++++++++++++++++---------------- arcade/raffle/build/program.json | 2 +- arcade/raffle/program.json | 2 +- arcade/raffle/src/main.leo | 4 +-- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/arcade/raffle/build/README.md b/arcade/raffle/build/README.md index 7ffbbcf..5f705dc 100644 --- a/arcade/raffle/build/README.md +++ b/arcade/raffle/build/README.md @@ -1,4 +1,4 @@ -# giveaway_entry_limits.aleo +# giveaway_731_3.aleo ## Build Guide diff --git a/arcade/raffle/build/main.aleo b/arcade/raffle/build/main.aleo index 28833ec..5753376 100644 --- a/arcade/raffle/build/main.aleo +++ b/arcade/raffle/build/main.aleo @@ -1,5 +1,5 @@ import puzzle_arcade_ticket_v001.aleo; -program giveaway_entry_limits.aleo; +program giveaway_731_3.aleo; struct PrivateKey: pk_pt1 as u128; @@ -55,12 +55,12 @@ function buy_one_entry: call puzzle_arcade_ticket_v001.aleo/spend r0 1000000u64 into r1; async buy_one_entry r0.owner into r2; output r1 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; - output r2 as giveaway_entry_limits.aleo/buy_one_entry.future; + output r2 as giveaway_731_3.aleo/buy_one_entry.future; finalize buy_one_entry: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - lt r1 250u64 into r2; + lt r1 50u64 into r2; assert.eq r2 true; set r0 into entries[r1]; add r1 1u64 into r3; @@ -74,12 +74,12 @@ function buy_two_entries: call puzzle_arcade_ticket_v001.aleo/spend r0 2000000u64 into r1; async buy_two_entries r0.owner into r2; output r1 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; - output r2 as giveaway_entry_limits.aleo/buy_two_entries.future; + output r2 as giveaway_731_3.aleo/buy_two_entries.future; finalize buy_two_entries: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - lt r1 250u64 into r2; + lt r1 50u64 into r2; assert.eq r2 true; add r1 0u64 into r3; set r0 into entries[r3]; @@ -96,12 +96,12 @@ function buy_three_entries: call puzzle_arcade_ticket_v001.aleo/spend r0 3000000u64 into r1; async buy_three_entries r0.owner into r2; output r1 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; - output r2 as giveaway_entry_limits.aleo/buy_three_entries.future; + output r2 as giveaway_731_3.aleo/buy_three_entries.future; finalize buy_three_entries: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - lt r1 250u64 into r2; + lt r1 50u64 into r2; assert.eq r2 true; add r1 0u64 into r3; set r0 into entries[r3]; @@ -120,12 +120,12 @@ function buy_four_entries: call puzzle_arcade_ticket_v001.aleo/spend r0 4000000u64 into r1; async buy_four_entries r0.owner into r2; output r1 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; - output r2 as giveaway_entry_limits.aleo/buy_four_entries.future; + output r2 as giveaway_731_3.aleo/buy_four_entries.future; finalize buy_four_entries: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - lt r1 250u64 into r2; + lt r1 50u64 into r2; assert.eq r2 true; add r1 0u64 into r3; set r0 into entries[r3]; @@ -146,12 +146,12 @@ function buy_five_entries: call puzzle_arcade_ticket_v001.aleo/spend r0 5000000u64 into r1; async buy_five_entries r0.owner into r2; output r1 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; - output r2 as giveaway_entry_limits.aleo/buy_five_entries.future; + output r2 as giveaway_731_3.aleo/buy_five_entries.future; finalize buy_five_entries: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - lt r1 250u64 into r2; + lt r1 50u64 into r2; assert.eq r2 true; add r1 0u64 into r3; set r0 into entries[r3]; @@ -174,12 +174,12 @@ function buy_six_entries: call puzzle_arcade_ticket_v001.aleo/spend r0 6000000u64 into r1; async buy_six_entries r0.owner into r2; output r1 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; - output r2 as giveaway_entry_limits.aleo/buy_six_entries.future; + output r2 as giveaway_731_3.aleo/buy_six_entries.future; finalize buy_six_entries: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - lt r1 250u64 into r2; + lt r1 50u64 into r2; assert.eq r2 true; add r1 0u64 into r3; set r0 into entries[r3]; @@ -204,12 +204,12 @@ function buy_seven_entries: call puzzle_arcade_ticket_v001.aleo/spend r0 7000000u64 into r1; async buy_seven_entries r0.owner into r2; output r1 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; - output r2 as giveaway_entry_limits.aleo/buy_seven_entries.future; + output r2 as giveaway_731_3.aleo/buy_seven_entries.future; finalize buy_seven_entries: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - lt r1 250u64 into r2; + lt r1 50u64 into r2; assert.eq r2 true; add r1 0u64 into r3; set r0 into entries[r3]; @@ -236,12 +236,12 @@ function buy_eight_entries: call puzzle_arcade_ticket_v001.aleo/spend r0 8000000u64 into r1; async buy_eight_entries r0.owner into r2; output r1 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; - output r2 as giveaway_entry_limits.aleo/buy_eight_entries.future; + output r2 as giveaway_731_3.aleo/buy_eight_entries.future; finalize buy_eight_entries: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - lt r1 250u64 into r2; + lt r1 50u64 into r2; assert.eq r2 true; add r1 0u64 into r3; set r0 into entries[r3]; @@ -270,12 +270,12 @@ function buy_nine_entries: call puzzle_arcade_ticket_v001.aleo/spend r0 9000000u64 into r1; async buy_nine_entries r0.owner into r2; output r1 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; - output r2 as giveaway_entry_limits.aleo/buy_nine_entries.future; + output r2 as giveaway_731_3.aleo/buy_nine_entries.future; finalize buy_nine_entries: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - lt r1 250u64 into r2; + lt r1 50u64 into r2; assert.eq r2 true; add r1 0u64 into r3; set r0 into entries[r3]; @@ -306,12 +306,12 @@ function buy_ten_entries: call puzzle_arcade_ticket_v001.aleo/spend r0 10000000u64 into r1; async buy_ten_entries r0.owner into r2; output r1 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; - output r2 as giveaway_entry_limits.aleo/buy_ten_entries.future; + output r2 as giveaway_731_3.aleo/buy_ten_entries.future; finalize buy_ten_entries: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - lt r1 250u64 into r2; + lt r1 50u64 into r2; assert.eq r2 true; add r1 0u64 into r3; set r0 into entries[r3]; @@ -343,7 +343,7 @@ function draw_winner: assert.eq self.caller self.signer; assert.eq self.caller aleo196a39wq9q8ea779cmlmff0c9pj2gl4f5e8fhjpvmufe5utuq7y8snz4h2l; async draw_winner into r0; - output r0 as giveaway_entry_limits.aleo/draw_winner.future; + output r0 as giveaway_731_3.aleo/draw_winner.future; finalize draw_winner: get total_entries[0u64] into r0; diff --git a/arcade/raffle/build/program.json b/arcade/raffle/build/program.json index 3cfbb91..3575e3f 100644 --- a/arcade/raffle/build/program.json +++ b/arcade/raffle/build/program.json @@ -1,5 +1,5 @@ { - "program": "giveaway_entry_limits.aleo", + "program": "giveaway_731_3.aleo", "version": "0.0.0", "description": "", "license": "MIT" diff --git a/arcade/raffle/program.json b/arcade/raffle/program.json index bb07bd3..d5cf822 100644 --- a/arcade/raffle/program.json +++ b/arcade/raffle/program.json @@ -1,5 +1,5 @@ { - "program": "giveaway_entry_limits.aleo", + "program": "giveaway_731_3.aleo", "version": "0.0.0", "description": "", "license": "MIT", diff --git a/arcade/raffle/src/main.leo b/arcade/raffle/src/main.leo index 3cea5e0..b6dceb7 100644 --- a/arcade/raffle/src/main.leo +++ b/arcade/raffle/src/main.leo @@ -1,8 +1,8 @@ import puzzle_arcade_ticket_v001.aleo; -program giveaway_entry_limits.aleo { +program giveaway_731_3.aleo { const OPERATOR: address = aleo196a39wq9q8ea779cmlmff0c9pj2gl4f5e8fhjpvmufe5utuq7y8snz4h2l; - const MAX_ENTRIES: u64 = 250u64; + const MAX_ENTRIES: u64 = 50u64; // used for storing the raffle entries (multiple entries per address) // i.e. 0 -> aleo1...asdf, 1 -> aleo1...ghjk From 1008bc99e38ae76b60ee52c350f378ee8d360701 Mon Sep 17 00:00:00 2001 From: Luke Newman <5315645+lukenewman@users.noreply.github.com> Date: Fri, 3 Jan 2025 15:08:04 -0500 Subject: [PATCH 4/5] fix max entry assertion logic --- arcade/raffle/src/main.leo | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/arcade/raffle/src/main.leo b/arcade/raffle/src/main.leo index b6dceb7..a57a4c3 100644 --- a/arcade/raffle/src/main.leo +++ b/arcade/raffle/src/main.leo @@ -70,7 +70,7 @@ program giveaway_731_3.aleo { async function add_one_entry (public participant: address) { // get current raffle count, if first entry, choose default of 0u64 let current_raffle_count: u64 = Mapping::get_or_use(total_entries, 0u64, 0u64); - assert(current_raffle_count < MAX_ENTRIES); + assert(current_raffle_coun + 1u64 < MAX_ENTRIES); // add address to entry mapping Mapping::set(entries, current_raffle_count, participant); @@ -90,7 +90,7 @@ program giveaway_731_3.aleo { } async function add_two_entries (public participant: address) { let current_raffle_count: u64 = Mapping::get_or_use(total_entries, 0u64, 0u64); - assert(current_raffle_count < MAX_ENTRIES); + assert(current_raffle_count + 2u64 < MAX_ENTRIES); for i: u64 in 0u64..2u64 { Mapping::set(entries, current_raffle_count + i, participant); @@ -111,7 +111,7 @@ program giveaway_731_3.aleo { } async function add_three_entries (public participant: address) { let current_raffle_count: u64 = Mapping::get_or_use(total_entries, 0u64, 0u64); - assert(current_raffle_count < MAX_ENTRIES); + assert(current_raffle_count + 3u64 < MAX_ENTRIES); for i: u64 in 0u64..3u64 { Mapping::set(entries, current_raffle_count + i, participant); @@ -132,7 +132,7 @@ program giveaway_731_3.aleo { } async function add_four_entries(public participant: address) { let current_raffle_count: u64 = Mapping::get_or_use(total_entries, 0u64, 0u64); - assert(current_raffle_count < MAX_ENTRIES); + assert(current_raffle_count + 4u64 < MAX_ENTRIES); for i: u64 in 0u64..4u64 { Mapping::set(entries, current_raffle_count + i, participant); @@ -153,7 +153,7 @@ program giveaway_731_3.aleo { } async function add_five_entries(public participant: address) { let current_raffle_count: u64 = Mapping::get_or_use(total_entries, 0u64, 0u64); - assert(current_raffle_count < MAX_ENTRIES); + assert(current_raffle_count + 5u64 < MAX_ENTRIES); for i: u64 in 0u64..5u64 { Mapping::set(entries, current_raffle_count + i, participant); @@ -174,7 +174,7 @@ program giveaway_731_3.aleo { } async function add_six_entries(public participant: address) { let current_raffle_count: u64 = Mapping::get_or_use(total_entries, 0u64, 0u64); - assert(current_raffle_count < MAX_ENTRIES); + assert(current_raffle_count + 6u64 < MAX_ENTRIES); for i: u64 in 0u64..6u64 { Mapping::set(entries, current_raffle_count + i, participant); @@ -195,7 +195,7 @@ program giveaway_731_3.aleo { } async function add_seven_entries(public participant: address) { let current_raffle_count: u64 = Mapping::get_or_use(total_entries, 0u64, 0u64); - assert(current_raffle_count < MAX_ENTRIES); + assert(current_raffle_count + 7u64 < MAX_ENTRIES); for i: u64 in 0u64..7u64 { Mapping::set(entries, current_raffle_count + i, participant); @@ -216,7 +216,7 @@ program giveaway_731_3.aleo { } async function add_eight_entries(public participant: address) { let current_raffle_count: u64 = Mapping::get_or_use(total_entries, 0u64, 0u64); - assert(current_raffle_count < MAX_ENTRIES); + assert(current_raffle_count + 8u64 < MAX_ENTRIES); for i: u64 in 0u64..8u64 { Mapping::set(entries, current_raffle_count + i, participant); @@ -237,7 +237,7 @@ program giveaway_731_3.aleo { } async function add_nine_entries(public participant: address) { let current_raffle_count: u64 = Mapping::get_or_use(total_entries, 0u64, 0u64); - assert(current_raffle_count < MAX_ENTRIES); + assert(current_raffle_count + 9u64 < MAX_ENTRIES); for i: u64 in 0u64..9u64 { Mapping::set(entries, current_raffle_count + i, participant); @@ -258,7 +258,7 @@ program giveaway_731_3.aleo { } async function add_ten_entries(public participant: address) { let current_raffle_count: u64 = Mapping::get_or_use(total_entries, 0u64, 0u64); - assert(current_raffle_count < MAX_ENTRIES); + assert(current_raffle_count + 10u64 < MAX_ENTRIES); for i: u64 in 0u64..10u64 { Mapping::set(entries, current_raffle_count + i, participant); From f9bec4fb673b13d7030969625f3be677971ac6b6 Mon Sep 17 00:00:00 2001 From: Luke Newman <5315645+lukenewman@users.noreply.github.com> Date: Mon, 6 Jan 2025 15:44:12 -0500 Subject: [PATCH 5/5] update var --- arcade/raffle/build/README.md | 2 +- arcade/raffle/build/main.aleo | 300 ++++++++++++++++--------------- arcade/raffle/build/program.json | 2 +- arcade/raffle/program.json | 2 +- arcade/raffle/src/main.leo | 4 +- 5 files changed, 160 insertions(+), 150 deletions(-) diff --git a/arcade/raffle/build/README.md b/arcade/raffle/build/README.md index 5f705dc..5f144d8 100644 --- a/arcade/raffle/build/README.md +++ b/arcade/raffle/build/README.md @@ -1,4 +1,4 @@ -# giveaway_731_3.aleo +# giveaway.aleo ## Build Guide diff --git a/arcade/raffle/build/main.aleo b/arcade/raffle/build/main.aleo index 5753376..f97f2f8 100644 --- a/arcade/raffle/build/main.aleo +++ b/arcade/raffle/build/main.aleo @@ -1,5 +1,5 @@ import puzzle_arcade_ticket_v001.aleo; -program giveaway_731_3.aleo; +program giveaway.aleo; struct PrivateKey: pk_pt1 as u128; @@ -55,295 +55,305 @@ function buy_one_entry: call puzzle_arcade_ticket_v001.aleo/spend r0 1000000u64 into r1; async buy_one_entry r0.owner into r2; output r1 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; - output r2 as giveaway_731_3.aleo/buy_one_entry.future; + output r2 as giveaway.aleo/buy_one_entry.future; finalize buy_one_entry: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - lt r1 50u64 into r2; - assert.eq r2 true; + add r1 1u64 into r2; + lt r2 50u64 into r3; + assert.eq r3 true; set r0 into entries[r1]; - add r1 1u64 into r3; - set r3 into total_entries[0u64]; - get.or_use user_entries[r0] 0u16 into r4; - add r4 1u16 into r5; - set r5 into user_entries[r0]; + add r1 1u64 into r4; + set r4 into total_entries[0u64]; + get.or_use user_entries[r0] 0u16 into r5; + add r5 1u16 into r6; + set r6 into user_entries[r0]; function buy_two_entries: input r0 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; call puzzle_arcade_ticket_v001.aleo/spend r0 2000000u64 into r1; async buy_two_entries r0.owner into r2; output r1 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; - output r2 as giveaway_731_3.aleo/buy_two_entries.future; + output r2 as giveaway.aleo/buy_two_entries.future; finalize buy_two_entries: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - lt r1 50u64 into r2; - assert.eq r2 true; - add r1 0u64 into r3; - set r0 into entries[r3]; - add r1 1u64 into r4; + add r1 2u64 into r2; + lt r2 50u64 into r3; + assert.eq r3 true; + add r1 0u64 into r4; set r0 into entries[r4]; - add r1 2u64 into r5; - set r5 into total_entries[0u64]; - get.or_use user_entries[r0] 0u16 into r6; - add r6 2u16 into r7; - set r7 into user_entries[r0]; + add r1 1u64 into r5; + set r0 into entries[r5]; + add r1 2u64 into r6; + set r6 into total_entries[0u64]; + get.or_use user_entries[r0] 0u16 into r7; + add r7 2u16 into r8; + set r8 into user_entries[r0]; function buy_three_entries: input r0 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; call puzzle_arcade_ticket_v001.aleo/spend r0 3000000u64 into r1; async buy_three_entries r0.owner into r2; output r1 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; - output r2 as giveaway_731_3.aleo/buy_three_entries.future; + output r2 as giveaway.aleo/buy_three_entries.future; finalize buy_three_entries: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - lt r1 50u64 into r2; - assert.eq r2 true; - add r1 0u64 into r3; - set r0 into entries[r3]; - add r1 1u64 into r4; + add r1 3u64 into r2; + lt r2 50u64 into r3; + assert.eq r3 true; + add r1 0u64 into r4; set r0 into entries[r4]; - add r1 2u64 into r5; + add r1 1u64 into r5; set r0 into entries[r5]; - add r1 3u64 into r6; - set r6 into total_entries[0u64]; - get.or_use user_entries[r0] 0u16 into r7; - add r7 3u16 into r8; - set r8 into user_entries[r0]; + add r1 2u64 into r6; + set r0 into entries[r6]; + add r1 3u64 into r7; + set r7 into total_entries[0u64]; + get.or_use user_entries[r0] 0u16 into r8; + add r8 3u16 into r9; + set r9 into user_entries[r0]; function buy_four_entries: input r0 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; call puzzle_arcade_ticket_v001.aleo/spend r0 4000000u64 into r1; async buy_four_entries r0.owner into r2; output r1 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; - output r2 as giveaway_731_3.aleo/buy_four_entries.future; + output r2 as giveaway.aleo/buy_four_entries.future; finalize buy_four_entries: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - lt r1 50u64 into r2; - assert.eq r2 true; - add r1 0u64 into r3; - set r0 into entries[r3]; - add r1 1u64 into r4; + add r1 4u64 into r2; + lt r2 50u64 into r3; + assert.eq r3 true; + add r1 0u64 into r4; set r0 into entries[r4]; - add r1 2u64 into r5; + add r1 1u64 into r5; set r0 into entries[r5]; - add r1 3u64 into r6; + add r1 2u64 into r6; set r0 into entries[r6]; - add r1 4u64 into r7; - set r7 into total_entries[0u64]; - get.or_use user_entries[r0] 0u16 into r8; - add r8 4u16 into r9; - set r9 into user_entries[r0]; + add r1 3u64 into r7; + set r0 into entries[r7]; + add r1 4u64 into r8; + set r8 into total_entries[0u64]; + get.or_use user_entries[r0] 0u16 into r9; + add r9 4u16 into r10; + set r10 into user_entries[r0]; function buy_five_entries: input r0 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; call puzzle_arcade_ticket_v001.aleo/spend r0 5000000u64 into r1; async buy_five_entries r0.owner into r2; output r1 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; - output r2 as giveaway_731_3.aleo/buy_five_entries.future; + output r2 as giveaway.aleo/buy_five_entries.future; finalize buy_five_entries: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - lt r1 50u64 into r2; - assert.eq r2 true; - add r1 0u64 into r3; - set r0 into entries[r3]; - add r1 1u64 into r4; + add r1 5u64 into r2; + lt r2 50u64 into r3; + assert.eq r3 true; + add r1 0u64 into r4; set r0 into entries[r4]; - add r1 2u64 into r5; + add r1 1u64 into r5; set r0 into entries[r5]; - add r1 3u64 into r6; + add r1 2u64 into r6; set r0 into entries[r6]; - add r1 4u64 into r7; + add r1 3u64 into r7; set r0 into entries[r7]; - add r1 5u64 into r8; - set r8 into total_entries[0u64]; - get.or_use user_entries[r0] 0u16 into r9; - add r9 5u16 into r10; - set r10 into user_entries[r0]; + add r1 4u64 into r8; + set r0 into entries[r8]; + add r1 5u64 into r9; + set r9 into total_entries[0u64]; + get.or_use user_entries[r0] 0u16 into r10; + add r10 5u16 into r11; + set r11 into user_entries[r0]; function buy_six_entries: input r0 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; call puzzle_arcade_ticket_v001.aleo/spend r0 6000000u64 into r1; async buy_six_entries r0.owner into r2; output r1 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; - output r2 as giveaway_731_3.aleo/buy_six_entries.future; + output r2 as giveaway.aleo/buy_six_entries.future; finalize buy_six_entries: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - lt r1 50u64 into r2; - assert.eq r2 true; - add r1 0u64 into r3; - set r0 into entries[r3]; - add r1 1u64 into r4; + add r1 6u64 into r2; + lt r2 50u64 into r3; + assert.eq r3 true; + add r1 0u64 into r4; set r0 into entries[r4]; - add r1 2u64 into r5; + add r1 1u64 into r5; set r0 into entries[r5]; - add r1 3u64 into r6; + add r1 2u64 into r6; set r0 into entries[r6]; - add r1 4u64 into r7; + add r1 3u64 into r7; set r0 into entries[r7]; - add r1 5u64 into r8; + add r1 4u64 into r8; set r0 into entries[r8]; - add r1 6u64 into r9; - set r9 into total_entries[0u64]; - get.or_use user_entries[r0] 0u16 into r10; - add r10 6u16 into r11; - set r11 into user_entries[r0]; + add r1 5u64 into r9; + set r0 into entries[r9]; + add r1 6u64 into r10; + set r10 into total_entries[0u64]; + get.or_use user_entries[r0] 0u16 into r11; + add r11 6u16 into r12; + set r12 into user_entries[r0]; function buy_seven_entries: input r0 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; call puzzle_arcade_ticket_v001.aleo/spend r0 7000000u64 into r1; async buy_seven_entries r0.owner into r2; output r1 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; - output r2 as giveaway_731_3.aleo/buy_seven_entries.future; + output r2 as giveaway.aleo/buy_seven_entries.future; finalize buy_seven_entries: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - lt r1 50u64 into r2; - assert.eq r2 true; - add r1 0u64 into r3; - set r0 into entries[r3]; - add r1 1u64 into r4; + add r1 7u64 into r2; + lt r2 50u64 into r3; + assert.eq r3 true; + add r1 0u64 into r4; set r0 into entries[r4]; - add r1 2u64 into r5; + add r1 1u64 into r5; set r0 into entries[r5]; - add r1 3u64 into r6; + add r1 2u64 into r6; set r0 into entries[r6]; - add r1 4u64 into r7; + add r1 3u64 into r7; set r0 into entries[r7]; - add r1 5u64 into r8; + add r1 4u64 into r8; set r0 into entries[r8]; - add r1 6u64 into r9; + add r1 5u64 into r9; set r0 into entries[r9]; - add r1 7u64 into r10; - set r10 into total_entries[0u64]; - get.or_use user_entries[r0] 0u16 into r11; - add r11 7u16 into r12; - set r12 into user_entries[r0]; + add r1 6u64 into r10; + set r0 into entries[r10]; + add r1 7u64 into r11; + set r11 into total_entries[0u64]; + get.or_use user_entries[r0] 0u16 into r12; + add r12 7u16 into r13; + set r13 into user_entries[r0]; function buy_eight_entries: input r0 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; call puzzle_arcade_ticket_v001.aleo/spend r0 8000000u64 into r1; async buy_eight_entries r0.owner into r2; output r1 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; - output r2 as giveaway_731_3.aleo/buy_eight_entries.future; + output r2 as giveaway.aleo/buy_eight_entries.future; finalize buy_eight_entries: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - lt r1 50u64 into r2; - assert.eq r2 true; - add r1 0u64 into r3; - set r0 into entries[r3]; - add r1 1u64 into r4; + add r1 8u64 into r2; + lt r2 50u64 into r3; + assert.eq r3 true; + add r1 0u64 into r4; set r0 into entries[r4]; - add r1 2u64 into r5; + add r1 1u64 into r5; set r0 into entries[r5]; - add r1 3u64 into r6; + add r1 2u64 into r6; set r0 into entries[r6]; - add r1 4u64 into r7; + add r1 3u64 into r7; set r0 into entries[r7]; - add r1 5u64 into r8; + add r1 4u64 into r8; set r0 into entries[r8]; - add r1 6u64 into r9; + add r1 5u64 into r9; set r0 into entries[r9]; - add r1 7u64 into r10; + add r1 6u64 into r10; set r0 into entries[r10]; - add r1 8u64 into r11; - set r11 into total_entries[0u64]; - get.or_use user_entries[r0] 0u16 into r12; - add r12 8u16 into r13; - set r13 into user_entries[r0]; + add r1 7u64 into r11; + set r0 into entries[r11]; + add r1 8u64 into r12; + set r12 into total_entries[0u64]; + get.or_use user_entries[r0] 0u16 into r13; + add r13 8u16 into r14; + set r14 into user_entries[r0]; function buy_nine_entries: input r0 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; call puzzle_arcade_ticket_v001.aleo/spend r0 9000000u64 into r1; async buy_nine_entries r0.owner into r2; output r1 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; - output r2 as giveaway_731_3.aleo/buy_nine_entries.future; + output r2 as giveaway.aleo/buy_nine_entries.future; finalize buy_nine_entries: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - lt r1 50u64 into r2; - assert.eq r2 true; - add r1 0u64 into r3; - set r0 into entries[r3]; - add r1 1u64 into r4; + add r1 9u64 into r2; + lt r2 50u64 into r3; + assert.eq r3 true; + add r1 0u64 into r4; set r0 into entries[r4]; - add r1 2u64 into r5; + add r1 1u64 into r5; set r0 into entries[r5]; - add r1 3u64 into r6; + add r1 2u64 into r6; set r0 into entries[r6]; - add r1 4u64 into r7; + add r1 3u64 into r7; set r0 into entries[r7]; - add r1 5u64 into r8; + add r1 4u64 into r8; set r0 into entries[r8]; - add r1 6u64 into r9; + add r1 5u64 into r9; set r0 into entries[r9]; - add r1 7u64 into r10; + add r1 6u64 into r10; set r0 into entries[r10]; - add r1 8u64 into r11; + add r1 7u64 into r11; set r0 into entries[r11]; - add r1 9u64 into r12; - set r12 into total_entries[0u64]; - get.or_use user_entries[r0] 0u16 into r13; - add r13 9u16 into r14; - set r14 into user_entries[r0]; + add r1 8u64 into r12; + set r0 into entries[r12]; + add r1 9u64 into r13; + set r13 into total_entries[0u64]; + get.or_use user_entries[r0] 0u16 into r14; + add r14 9u16 into r15; + set r15 into user_entries[r0]; function buy_ten_entries: input r0 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; call puzzle_arcade_ticket_v001.aleo/spend r0 10000000u64 into r1; async buy_ten_entries r0.owner into r2; output r1 as puzzle_arcade_ticket_v001.aleo/PuzzleArcadeTicket.record; - output r2 as giveaway_731_3.aleo/buy_ten_entries.future; + output r2 as giveaway.aleo/buy_ten_entries.future; finalize buy_ten_entries: input r0 as address.public; get.or_use total_entries[0u64] 0u64 into r1; - lt r1 50u64 into r2; - assert.eq r2 true; - add r1 0u64 into r3; - set r0 into entries[r3]; - add r1 1u64 into r4; + add r1 10u64 into r2; + lt r2 50u64 into r3; + assert.eq r3 true; + add r1 0u64 into r4; set r0 into entries[r4]; - add r1 2u64 into r5; + add r1 1u64 into r5; set r0 into entries[r5]; - add r1 3u64 into r6; + add r1 2u64 into r6; set r0 into entries[r6]; - add r1 4u64 into r7; + add r1 3u64 into r7; set r0 into entries[r7]; - add r1 5u64 into r8; + add r1 4u64 into r8; set r0 into entries[r8]; - add r1 6u64 into r9; + add r1 5u64 into r9; set r0 into entries[r9]; - add r1 7u64 into r10; + add r1 6u64 into r10; set r0 into entries[r10]; - add r1 8u64 into r11; + add r1 7u64 into r11; set r0 into entries[r11]; - add r1 9u64 into r12; + add r1 8u64 into r12; set r0 into entries[r12]; - add r1 10u64 into r13; - set r13 into total_entries[0u64]; - get.or_use user_entries[r0] 0u16 into r14; - add r14 10u16 into r15; - set r15 into user_entries[r0]; + add r1 9u64 into r13; + set r0 into entries[r13]; + add r1 10u64 into r14; + set r14 into total_entries[0u64]; + get.or_use user_entries[r0] 0u16 into r15; + add r15 10u16 into r16; + set r16 into user_entries[r0]; function draw_winner: assert.eq self.caller self.signer; assert.eq self.caller aleo196a39wq9q8ea779cmlmff0c9pj2gl4f5e8fhjpvmufe5utuq7y8snz4h2l; async draw_winner into r0; - output r0 as giveaway_731_3.aleo/draw_winner.future; + output r0 as giveaway.aleo/draw_winner.future; finalize draw_winner: get total_entries[0u64] into r0; diff --git a/arcade/raffle/build/program.json b/arcade/raffle/build/program.json index 3575e3f..75c7bee 100644 --- a/arcade/raffle/build/program.json +++ b/arcade/raffle/build/program.json @@ -1,5 +1,5 @@ { - "program": "giveaway_731_3.aleo", + "program": "giveaway.aleo", "version": "0.0.0", "description": "", "license": "MIT" diff --git a/arcade/raffle/program.json b/arcade/raffle/program.json index d5cf822..26b0a12 100644 --- a/arcade/raffle/program.json +++ b/arcade/raffle/program.json @@ -1,5 +1,5 @@ { - "program": "giveaway_731_3.aleo", + "program": "giveaway.aleo", "version": "0.0.0", "description": "", "license": "MIT", diff --git a/arcade/raffle/src/main.leo b/arcade/raffle/src/main.leo index a57a4c3..116c8bd 100644 --- a/arcade/raffle/src/main.leo +++ b/arcade/raffle/src/main.leo @@ -1,6 +1,6 @@ import puzzle_arcade_ticket_v001.aleo; -program giveaway_731_3.aleo { +program giveaway.aleo { const OPERATOR: address = aleo196a39wq9q8ea779cmlmff0c9pj2gl4f5e8fhjpvmufe5utuq7y8snz4h2l; const MAX_ENTRIES: u64 = 50u64; @@ -70,7 +70,7 @@ program giveaway_731_3.aleo { async function add_one_entry (public participant: address) { // get current raffle count, if first entry, choose default of 0u64 let current_raffle_count: u64 = Mapping::get_or_use(total_entries, 0u64, 0u64); - assert(current_raffle_coun + 1u64 < MAX_ENTRIES); + assert(current_raffle_count + 1u64 < MAX_ENTRIES); // add address to entry mapping Mapping::set(entries, current_raffle_count, participant);