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

✨ Fetch winners in claiming closed state #208

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
108 commits
Select commit Hold shift + click to select a range
396e3c3
DC7 (#1)
kevincharm Mar 28, 2024
fc0fbd5
🐔 Setup next repo (#2)
b-tarczynski Apr 4, 2024
ec909c0
💅 Enable styled components in next app (#3)
b-tarczynski Apr 8, 2024
ee226c9
🏎️ Migrate to turbo and pnpm (#4)
b-tarczynski Apr 10, 2024
94a2d33
🥷 Remove outdated code (#5)
b-tarczynski Apr 11, 2024
3629e80
🐔 Configure wagmi (#6)
b-tarczynski Apr 11, 2024
1b68408
🤟 Migrate Information component (#8)
b-tarczynski Apr 15, 2024
d5f04ea
👐 Add winners count to useReadAuctionParams (#9)
b-tarczynski Apr 15, 2024
bfc475a
👩‍🚀 Update auction ABI to the latest version (#10)
b-tarczynski Apr 15, 2024
5800c37
👖 Add a linter coinfiguration (#11)
p-sad Apr 16, 2024
1223af1
👩‍🚒 Add bids provider (#12)
b-tarczynski Apr 16, 2024
7efc05c
🦀 Run lint in CI (#13)
p-sad Apr 17, 2024
23c96aa
🎈 Use correct branch in CI job (#15)
b-tarczynski Apr 17, 2024
363777e
Update deployment scripts (#7)
kevincharm Apr 17, 2024
6ea254e
🪄 Support Hardhat chain in frontend app (#16)
b-tarczynski Apr 17, 2024
0c0aaa5
📜 Migrate bids list on homepage (#14)
b-tarczynski Apr 17, 2024
b046e27
🎈 Add environment example (#20)
b-tarczynski Apr 19, 2024
eaaac13
📖 Migrate bids page (#17)
b-tarczynski Apr 19, 2024
a0b2fc9
🪄 Utilize getBidsWithAddresses function (#19)
b-tarczynski Apr 19, 2024
35e430e
🧹 Migrate settled bids list (#18)
b-tarczynski Apr 19, 2024
ec1142d
🐔 Add a connect wallet warning (#21)
p-sad Apr 19, 2024
543c5ba
🤺 Persist bid place in BidsProvider (#22)
b-tarczynski Apr 19, 2024
639b82d
🎸 Add Gitcoin flow with first step (#23)
pazernykormoran Apr 22, 2024
be43040
🥾 Check Gitcoin score and adjust stepper (#24)
pazernykormoran Apr 23, 2024
ca92304
🍫 Add top bar (#25)
b-tarczynski Apr 23, 2024
9acfa97
🫴 Add Place Bid form (#26)
p-sad Apr 23, 2024
6fb17d4
🎪 Add user's Gitcoin score view (#27)
b-tarczynski Apr 23, 2024
1a1aef6
⏳ Add awaiting bidding view (#29)
b-tarczynski Apr 24, 2024
a6f9da9
🧱 Add claiming static views (#30)
b-tarczynski Apr 24, 2024
55483b5
Add You don't have passport page (#28)
pazernykormoran Apr 24, 2024
0ff473c
🧦 Handle user's invalid network (#31)
b-tarczynski Apr 24, 2024
0694819
ℹ️ Add WinType to useUserBid (#33)
pazernykormoran Apr 25, 2024
45df029
💅🏻 Update colors (#34)
mrushkova Apr 25, 2024
93dfb7a
🕹️ Update buttons (#35)
mrushkova Apr 25, 2024
f5c4b28
🏧 Add claiming flow components (#32)
b-tarczynski Apr 25, 2024
7434832
🖌️ Update typography (#38)
mrushkova Apr 25, 2024
e9d34dc
🥸 Update header (#40)
mrushkova Apr 26, 2024
27ba9cf
🪮 Add withdraw with voucher view (#39)
pazernykormoran Apr 26, 2024
75861c0
🔮 Add claimed field to useUserBid (#37)
pazernykormoran Apr 26, 2024
28286ec
🐷 Add Place Bid transaction flow (#36)
p-sad Apr 26, 2024
8a7cdd3
💅 Resolve transient props in styled components warnings (#41)
b-tarczynski Apr 26, 2024
6f81419
🎰 Update bid page & lists (#42)
mrushkova Apr 29, 2024
fe3079f
🪗 Update accordion styles (#46)
mrushkova Apr 29, 2024
cb47d98
🦑 Add Bump Bid flow (#43)
p-sad Apr 29, 2024
b791d3e
🫴 Handle voucher claiming (#44)
b-tarczynski Apr 29, 2024
710805c
🧚 Add footer (#48)
mrushkova Apr 29, 2024
a137e4a
🥸 Implement claiming review (#45)
pazernykormoran Apr 29, 2024
5386bac
🎲 Update action section (#50)
mrushkova Apr 30, 2024
222a65d
Migrate backend routes (#47)
kevincharm Apr 30, 2024
b4657f9
👨‍🎨 Correctly handle bid bumps (#53)
b-tarczynski Apr 30, 2024
ff866b6
🍡 Display balance with less precision digits (#51)
mrushkova Apr 30, 2024
0aefe81
🥇 Handle rest win flows (#52)
pazernykormoran Apr 30, 2024
7d26659
🍦 Integrate with voucher claiming api (#54)
b-tarczynski May 2, 2024
da17eb1
🌑 Integrate with Gitcoin backend (#55)
pazernykormoran May 9, 2024
7113e0a
🦙 Add status toasts for blockchain transactions (#56)
p-sad May 9, 2024
27c199c
🔀 Handle create passport button (#57)
pazernykormoran May 13, 2024
b32a639
🥘 Correctly calculate voucher expiration (#58)
b-tarczynski May 13, 2024
5818c27
🔦 Highlight auction bid only once (#59)
b-tarczynski May 13, 2024
46c1f9e
🎨 Update application metadata (#60)
b-tarczynski May 14, 2024
3472c4a
🤺 Update Arbitrum Sepolia contract address (#61)
b-tarczynski May 14, 2024
578a7e5
🎓 Make AddressLink black (#62)
b-tarczynski May 14, 2024
37a00f4
🐣 Send address for scoring when recalculating (#64)
b-tarczynski May 16, 2024
30829d8
add Feistel shuffle test coverage (#49)
kevincharm May 28, 2024
7be621f
add supplementary documentation (#65)
kevincharm May 28, 2024
6835de9
Make settling permissionless & cleanup (#67)
kevincharm Jun 6, 2024
31892be
☎️ Add mobile layout (#68)
mrushkova Jun 7, 2024
d95d689
🪙 Add mobile styles for all bids page (#69)
mrushkova Jun 10, 2024
b6fd919
👩🏻‍🎤 Add mobile styles for user action section (#70)
mrushkova Jun 11, 2024
30bb503
🎉 Add mobile styles for win flow (#71)
mrushkova Jun 11, 2024
c21dcd0
🤳🏻 Make buttons wide on mobile (#72)
mrushkova Jun 11, 2024
7595fab
🥅 Add mobile styles for modal (#73)
mrushkova Jun 11, 2024
a26a814
🎹 Add tablet styles (#74)
mrushkova Jun 12, 2024
cf71858
🌝 Add share buttons (#75)
mrushkova Jun 17, 2024
e7a4a64
🖌️ Remove stepper background color (#76)
b-tarczynski Jun 17, 2024
96b6f43
🏆 Update auction address on Mainnet (#78)
b-tarczynski Jun 17, 2024
ca1d7f8
🖼️ Add Farcaster Frames (#79)
wslyvh Jun 18, 2024
268791a
🎒 Update accordion copy (#80)
b-tarczynski Jun 18, 2024
17ccd73
Deploy to arb1 (#77)
kevincharm Jun 18, 2024
849ad0b
audit
wslyvh Jun 18, 2024
0b8f246
fix start date
wslyvh Jun 18, 2024
9f1d629
🔐 Update sourcify link (#81)
b-tarczynski Jun 18, 2024
287a9d2
Add dot to full terms link
b-tarczynski Jun 18, 2024
23ca15b
cache-control headers
wslyvh Jun 18, 2024
9a1ec45
cache-control
wslyvh Jun 18, 2024
3979167
revalidation
wslyvh Jun 18, 2024
512b7dd
🍪 Implement wagmi storage in cookies (#82)
b-tarczynski Jun 18, 2024
9ccf9a2
remove setHeader
wslyvh Jun 18, 2024
f7d392d
frame images
wslyvh Jun 18, 2024
f963aed
💌 Update share message (#83)
mrushkova Jun 20, 2024
9d9a7c5
frames metadata
wslyvh Jun 21, 2024
5c9e868
👋🏻 Add visit link (#84)
mrushkova Jun 25, 2024
1f6815e
🗞️ Update funds text (#85)
b-tarczynski Jun 27, 2024
b1b00f1
✍️ Add TL;DR accordion section (#86)
b-tarczynski Jul 4, 2024
282b28b
add voucher codes
kevincharm Jul 9, 2024
d4ea79d
🥨 Redirect directly to redeem ticket page (#87)
b-tarczynski Jul 9, 2024
c001538
⏰ Update displaying deadlines (#88)
b-tarczynski Jul 10, 2024
ff5a021
🏆 Display deadlines for not connected wallets (#89)
b-tarczynski Jul 10, 2024
4c62624
voucher codes
wslyvh Jul 10, 2024
fdf576f
logging
wslyvh Jul 10, 2024
b3b827a
error message
wslyvh Jul 10, 2024
664cd46
add voucher codes
wslyvh Jul 10, 2024
f71d942
build fix
wslyvh Jul 10, 2024
bbdab69
remove error banner
wslyvh Jul 10, 2024
98e074d
build fix
wslyvh Jul 10, 2024
0f8b1ff
🌊 Replace websockets with http transport (#90)
b-tarczynski Jul 10, 2024
af35ba6
Query winners in claiming closed state
b-tarczynski Aug 2, 2024
96aedf8
Lint
b-tarczynski Aug 2, 2024
d0ef8e1
Fix winners in raffle settled state
b-tarczynski Aug 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
37 changes: 37 additions & 0 deletions .github/actions/install-dependencies/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Install Node and package dependencies
description: "Install Node dependencies with pnpm"

runs:
using: "composite"
steps:
- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20

- uses: pnpm/action-setup@v3
with:
version: 8.3.1
run_install: false

- name: Get pnpm cache directory
id: pnpm-cache-dir
shell: bash
run: echo "dir=$(pnpm store path)" >> $GITHUB_OUTPUT

- name: Cache PNPM
uses: actions/cache@v4
id: pnpm-cache
with:
path: |
${{ steps.pnpm-cache-dir.outputs.dir }}
key: ${{ runner.os }}-node-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: ${{ runner.os }}-node-

- name: Install packages
shell: bash
run: pnpm install --frozen-lockfile

- name: Build everything in the monorepo
shell: bash
run: pnpm build
16 changes: 16 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: CI
on:
pull_request:
push:
branches:
- master
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
clean: false
- name: Install Node and dependencies
uses: ./.github/actions/install-dependencies
- run: pnpm run lint
113 changes: 0 additions & 113 deletions .github/workflows/ci.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ tsconfig.tsbuildinfo
# Eslint cache
.eslintcache

# Build files
.turbo

# Generated by Certora
.certora_*
.last_confs
Expand Down
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

7 changes: 7 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
use-lockfile-v6=true
strict-peer-dependencies=false
auto-install-peers=false
dedupe-peer-dependents=false
resolve-peers-from-workspace-root=false
save-workspace-protocol=true
resolution-mode=highest
34 changes: 2 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,3 @@
# Devcon Ticket Sale System

## Running Hardhat node
Change directory to `packages/contracts` and execute:
```shell
yarn node:run
```
This will start a Hardhat node, deploy the contracts and place initial bids using the first twenty auto-generated accounts.

## Custom tasks
A number of custom Hardhat tasks were defined to aid testing.

### Managing local node
- `yarn node:increase-time [--value <INT>]` - increase block time by *value* seconds, defaults to six hour
- `yarn node:accounts` - print a list of available accounts

### Interacting with AuctionRaffle contract

#### Hardhat
- `yarn hardhat:bid --account <STRING> --amount <STRING>` - using *account* place bid of *amount* ETH
- `yarn hardhat:bid-random --amount <INT> [--account <INT>]` - using randomly generated accounts place *amount* of bids using funds from account with index *account* (defaults to `0`)
- `yarn hardhat:settle-auction` - settle auction
- `yarn hardhat:settle-raffle` - settle raffle using random numbers
- `yarn hardhat:settle` - increase time, settle auction and raffle

#### Arbitrum Rinkeby
- `yarn rinkeby:generate-dotenv [--path <STRING>] [--count <INT>]` - generate .env file needed for other tasks, *path* - output path, *count* - number of private keys to generate
- `yarn rinkeby:transfer-ether` - transfer ether from `DEPLOYER` to `PRIVATE_KEYS` accounts
- `yarn rinkeby:init-bids` - place initial bids using `PRIVATE_KEYS` accounts

#### Ethereum Mainnet
- `yarn ethereum:generate-random-numbers --blocks <ARRAY> --secret <STRING>` - generate random numbers for raffle settlement, *blocks* - array of block numbers from which extract block hash (e.g. "[1234, 5678]"), *secret* - secret number represented as 32 bytes hex string
# Devcon Ticket Sale System (Auction-Raffle)

This repository houses the Auction-Raffle ticket sale system used for Devcon.
Binary file not shown.
16 changes: 6 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@
"name": "devcon-raffle",
"private": true,
"version": "0.0.1",
"packageManager": "pnpm@8.3.1",
"scripts": {
"lint": "wsrun -c lint",
"build": "wsrun -te -c build",
"test": "wsrun -c test",
"verify": "wsrun -m -c verify",
"update": "git submodule update --remote"
"lint": "turbo lint --filter=frontend",
"build": "turbo build",
"test": "turbo test",
"verify": "turbo verify"
},
"workspaces": [
"packages/contracts",
"packages/frontend"
],
"devDependencies": {
"wsrun": "^5.2.4"
"turbo": "^1.13.2"
}
}
1 change: 0 additions & 1 deletion packages/backend
Submodule backend deleted from 234ccf
9 changes: 9 additions & 0 deletions packages/contracts/.prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
"options": {
"printWidth": 120
}
},
{
"files": "*.ts",
"options": {
"semi": false,
"singleQuote": true,
"printWidth": 120,
"bracketSpacing": true
}
}
]
}
64 changes: 64 additions & 0 deletions packages/contracts/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,65 @@
# Contracts

## High-level Overview

`AuctionRaffle.sol` is a combined auction and raffle system for Devcon ticket sales. At a high level, the contract progresses through the following phases.

1. Initial phase: This is the initial state of the contract, before bidding starts.

2. Bidding phase: When bidding opens after a configurable timestamp, the contract accepts bids from eligible wallets through the `bid` function. Alternatively, eligible wallets may also increase their existing bids using the `bump` function. The eligibility of a wallet is verified by an attestation mechanism that is hosted by the operator (see `contracts/verifier/ScoreAttestationVerifier.sol`). For Devcon 7, eligibility is determined by a Gitcoin passport score (also, see the [Gitcoin Passport Score Attestation](#gitcoin-passport-score-attestation) section below).

3. Auction phase: After the bidding period has ended, the operator settles the auction by calling the `settleAuction` function, which determines the auction winners (the number of auction winners is configurable).

4. Raffle phase: After the auction has settled, the operator begins the raffling phase by requesting a verifiable random number from Chainlink VRF. When the random number is delivered to the contract, the raffle winners are determined. The raffle winners are lazily evaluated using a Feistel shuffle to minimise gas usage (see: [Improving the Devcon Raffle](https://docs.fairy.dev/case-studies/improving-the-devcon-raffle)).

5. Claim phase: After the raffle has settled, some participants may withdraw none, some, or all of their bid amounts depending on the outcome of the Auction Raffle.

- Auction winners are not entitled to claim any amount.
- The first raffle winner is the lucky winner of the _golden ticket_ and may use the `claim` function to withdraw their full bid amount.
- All other raffle winners may withdraw their bid amount minus the reserve price.
- Losers may withdraw their full bid amount (there was previously a non-refundable 2% fee, but that has now been removed).

## Gitcoin Passport Score Attestation

For this 2024's edition of Devcon, users must have possess a minimum score on Gitcoin Passport in order to bid for a ticket. The `frontend` package in this repository has a backend component that queries the Gitcoin Passport API and returns signed attestations that users must include with their bids. A sequence diagram of this attestation flow is supplied below.

![passport_msd](./docs/auction_raffle_passport_msd.jpg)

## Running Hardhat node

Change directory to `packages/contracts` and execute:

```shell
pnpm node:run
```

This will start a Hardhat node, deploy the contracts and place initial bids using the first twenty auto-generated accounts.

## Custom tasks

A number of custom Hardhat tasks were defined to aid testing.

### Managing local node

- `pnpm node:increase-time [--value <INT>]` - increase block time by _value_ seconds, defaults to six hour
- `pnpm node:accounts` - print a list of available accounts

### Interacting with AuctionRaffle contract

#### Hardhat

- `pnpm hardhat:bid --account <STRING> --amount <STRING>` - using _account_ place bid of _amount_ ETH
- `pnpm hardhat:bid-random --amount <INT> [--account <INT>]` - using randomly generated accounts place _amount_ of bids using funds from account with index _account_ (defaults to `0`)
- `pnpm hardhat:settle-auction` - settle auction
- `pnpm hardhat:settle-raffle` - settle raffle using random numbers
- `pnpm hardhat:settle` - increase time, settle auction and raffle

#### Arbitrum Rinkeby

- `pnpm rinkeby:generate-dotenv [--path <STRING>] [--count <INT>]` - generate .env file needed for other tasks, _path_ - output path, _count_ - number of private keys to generate
- `pnpm rinkeby:transfer-ether` - transfer ether from `DEPLOYER` to `PRIVATE_KEYS` accounts
- `pnpm rinkeby:init-bids` - place initial bids using `PRIVATE_KEYS` accounts

#### Ethereum Mainnet

- `pnpm ethereum:generate-random-numbers --blocks <ARRAY> --secret <STRING>` - generate random numbers for raffle settlement, _blocks_ - array of block numbers from which extract block hash (e.g. "[1234, 5678]"), _secret_ - secret number represented as 32 bytes hex string
Loading