Starknet Auction

First Flight #26
Beginner FriendlyNFT
100 EXP
View results
Submission Details
Severity: low
Invalid

`withdraw` function does not observe the CEI model

Description:

All functions in the protocol observe the CEI model with the exception of the StarknetAuction::withdraw The call to emit the Withdraw event is made after the transfer (to owner or losing bidder(s)) is called.

self.emit(Withdraw {amount: amount, caller: caller});

Impact:

If the transfer is reverted the event will not be emitted. This is very low impact. However the event information may be useful for troubleshooting or for a user monitoring the contract.

Recommended Mitigation

The Withdraw event in the withdraw method should be called before the transfer methods are called.

fn withdraw(ref self: ContractState) {
assert(self.started.read(), 'Auction is not started');
assert(self.ended.read(), 'Auction is not ended');
let caller = get_caller_address();
let sender = get_contract_address();
let erc20_dispatcher = IERC20Dispatcher { contract_address: self.erc20_token.read() };
let amount = self.bid_values.entry(caller).read();
let amount_owner = self.highest_bid.read();
+ self.emit(Withdraw {amount: amount, caller: caller});
if caller == self.nft_owner.read() {
self.highest_bid.write(0);
erc20_dispatcher.transfer_from(sender, caller, amount_owner.into());
}
if amount > 0 {
let sender = get_contract_address();
erc20_dispatcher.transfer_from(sender, caller, amount.into());
}
- self.emit(Withdraw {amount: amount, caller: caller});
}
Updates

Lead Judging Commences

bube Lead Judge 8 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.