hats-finance / AlephZeroAMM-0x0d88a9ece90994ecb3ba704730819d71c139f60f

Apache License 2.0
1 stars 0 forks source link

important Events Not Emitted in Farm Contract #17

Open fonstack opened 10 months ago

fonstack commented 10 months ago

Github username: @0xmahdirostami Twitter username: 0xmahdirostami Severity: minor

Description

The farm::owner_stop_farm and farm::owner_start_new_farm functions in the farm contract are crucial, and emitting events when these actions occur is essential for transparency and informing users about important changes. Adding events for these functions will provide users with a clear record of when the farm is stopped or started.

Impact

The absence of events for these critical functions may result in a lack of transparency, making it difficult for users to track important changes in the farm contract. Emitting events for the start and stop of the farm ensures that users are informed and can make informed decisions about their farming activities.

Recommended Changes

Add the following event definitions:

#[ink(event)]
pub struct FarmStopped {
    end: u64,
}

#[ink(event)]
pub struct FarmStarted {
    start: u64,
    end: u64,
}

Modify the farm::owner_start_new_farm and farm::owner_stop_farm functions to emit these events:

// Inside farm::owner_start_new_farm
FarmContract::emit_event(
    self.env(),
    Event::FarmStarted(FarmStarted {
        start: start,
        end: end,
    }),
);

// Inside farm::owner_stop_farm
FarmContract::emit_event(
    self.env(),
    Event::FarmStopped(FarmStopped {
        end: self.end,
    }),
);

These changes will ensure that events are emitted when the farm is started or stopped, providing users with critical information about the state of the farm contract.

deuszx commented 10 months ago

Duplicate of #6 - we will consider that submission (although note this is the same warden, same submission).