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

Make settling permissionless & cleanup #67

Merged
merged 3 commits into from
Jun 6, 2024
Merged
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
7 changes: 3 additions & 4 deletions packages/contracts/contracts/AuctionRaffle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ contract AuctionRaffle is Ownable, Config, BidModel, StateModel, VRFRequester {
uint256[] _raffleParticipants;

uint256[] _auctionWinners;
uint256[] _raffleWinners;

bool _proceedsClaimed;

Expand Down Expand Up @@ -126,7 +125,7 @@ contract AuctionRaffle is Ownable, Config, BidModel, StateModel, VRFRequester {
* This is done to efficiently remove auction winners from _raffleParticipants array as they no longer take part
* in the raffle.
*/
function settleAuction() external onlyOwner onlyInState(State.BIDDING_CLOSED) {
function settleAuction() external onlyInState(State.BIDDING_CLOSED) {
_settleState = SettleState.AUCTION_SETTLED;
uint256 biddersCount = getBiddersCount();
uint256 raffleWinnersCount = _raffleWinnersCount;
Expand Down Expand Up @@ -154,7 +153,7 @@ contract AuctionRaffle is Ownable, Config, BidModel, StateModel, VRFRequester {
/**
* @notice Initiate raffle draw by requesting a random number from Chainlink VRF.
*/
function settleRaffle() external onlyOwner onlyInState(State.AUCTION_SETTLED) returns (uint256) {
function settleRaffle() external onlyInState(State.AUCTION_SETTLED) returns (uint256) {
uint256 reqId = _getRandomNumber();
emit RandomNumberRequested(reqId);
return reqId;
Expand All @@ -176,7 +175,7 @@ contract AuctionRaffle is Ownable, Config, BidModel, StateModel, VRFRequester {
* @notice Allows a bidder to claim their funds after the raffle is settled.
* Golden Ticket winner can withdraw the full bid amount.
* Raffle winner can withdraw the bid amount minus `_reservePrice`.
* Non-winning bidder can withdraw the bid amount minus 2% fee.
* Non-winning bidder can withdraw the full bid amount.
* Auction winner pays the full bid amount and is not entitled to any withdrawal.
*/
function claim(uint256 bidderID) external onlyInState(State.RAFFLE_SETTLED) {
Expand Down
11 changes: 7 additions & 4 deletions packages/contracts/test/contracts/AuctionRaffle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,9 @@ describe('AuctionRaffle', function () {
await bid(9)
})

it('reverts if called not by owner', async function () {
await expect(auctionRaffle.settleAuction()).to.be.revertedWith('Ownable: caller is not the owner')
it('can be called by anyone', async function () {
await endBidding(auctionRaffleAsOwner)
await expect(auctionRaffle.settleAuction()).to.not.be.reverted
})

it('reverts if bidding is in progress', async function () {
Expand Down Expand Up @@ -483,8 +484,10 @@ describe('AuctionRaffle', function () {
await bid(9)
})

it('reverts if called not by owner', async function () {
await expect(auctionRaffle.settleRaffle()).to.be.revertedWith('Ownable: caller is not the owner')
it('can be called by anyone', async function () {
await endBidding(auctionRaffleAsOwner)
await auctionRaffle.settleAuction()
await expect(auctionRaffle.settleRaffle()).to.not.be.reverted
})

it('reverts if raffle is not settled', async function () {
Expand Down