Events For Indexer

The GrantPicks (Rounds) contract utilizes events to notify external systems about significant actions that occur within the contract. These events are crucial for maintaining transparency and enabling real-time updates on the state of funding rounds, applications, votes, deposits, and payouts.

Round Events

1. Log Create Round Event

rustpub fn log_create_round(env: &Env, round_detail: RoundDetail) {
    env.events().publish(
        (symbol_short!("c_round"), env.current_contract_address()),
        round_detail,
    );
}

Purpose: This event is emitted when a new funding round is created.

  • Parameters:

    • env: The environment context for executing the event.

    • round_detail: A RoundDetail object containing information about the newly created round.

2. Log Update Round Event

rustpub fn log_update_round(env: &Env, round_detail: RoundDetail) {
    env.events().publish(
        (symbol_short!("u_round"), env.current_contract_address()),
        round_detail,
    );
}

Purpose: This event is emitted when an existing funding round is updated.

  • Parameters:

    • env: The environment context for executing the event.

    • round_detail: A RoundDetail object containing updated information about the round.

Application Events

3. Log Create Application Event

rustpub fn log_create_app(env: &Env, round_id: u128, application: RoundApplication) {
    env.events().publish(
        (symbol_short!("c_app"), env.current_contract_address()),
        (round_id, application),
    );
}

Purpose: This event is emitted when a new application is submitted for a funding round.

  • Parameters:

    • env: The environment context for executing the event.

    • round_id: The unique identifier of the round to which the application belongs.

    • application: A RoundApplication object containing details of the submitted application.

4. Log Update Application Event

rustpub fn log_update_app(env: &Env, round_id: u128, application: RoundApplication, updated_by: Address) {
    env.events().publish(
        (symbol_short!("u_app"), env.current_contract_address()),
        (round_id, application, updated_by),
    );
}

Purpose: This event is emitted when an existing application is updated.

  • Parameters:

    • env: The environment context for executing the event.

    • round_id: The unique identifier of the round associated with the application.

    • application: A RoundApplication object containing updated details of the application.

    • updated_by: The address of the user who made the update.

5. Log Delete Application Event

rustpub fn log_delete_app(env: &Env, round_id: u128, application: RoundApplication) {
    env.events().publish(
        (symbol_short!("d_app"), env.current_contract_address()),
        (round_id, application),
    );
}

Purpose: This event is emitted when an application is deleted from a funding round.

  • Parameters:

    • env: The environment context for executing the event.

    • round_id: The unique identifier of the round from which the application was deleted.

    • application: A RoundApplication object representing the deleted application.

Deposit Events

6. Log Create Deposit Event

rustpub fn log_create_deposit(env: &Env, round_id: u128, data: &Deposit) {
    env.events().publish(
        (symbol_short!("c_depo"), env.current_contract_address()),
        (round_id, data.clone()),
    );
}

Purpose: This event is emitted when a deposit is made to a funding round.

  • Parameters:

    • env: The environment context for executing the event.

    • round_id: The unique identifier of the round receiving the deposit.

    • data: A Deposit object containing details of the deposit made.

Vote Events

7. Log Create Vote Event

rustpub fn log_create_vote(env: &Env, round_id: u128, result: VotingResult) {
    env.events().publish(
        (symbol_short!("c_vote"), env.current_contract_address()),
        (round_id, result),
    );
}

Purpose: This event is emitted when a vote is cast in a funding round.

  • Parameters:

    • env: The environment context for executing the event.

    • round_id: The unique identifier of the round in which voting took place.

    • result: A VotingResult object containing details of the vote cast.

Payout Events

8. Log Create Payout Event

rustpub fn log_create_payout(env: &Env, round_id: u128, address: Address, amount: i128) {
    env.events().publish(
        (symbol_short!("c_pay"), env.current_contract_address()),
        (round_id, address, amount),
    );
}

Purpose: This event is emitted when a payout is processed for approved projects in a funding round.

  • Parameters:

    • env: The environment context for executing the event.

    • round_id: The unique identifier of the round associated with the payout.

    • address: The recipient's address who will receive the payout.

    • amount: The amount being paid out.

Update Approved Projects Events

9. Log Update Approved Projects Event

rustpub fn log_update_approved_projects(env: &Env, round_id: u128, project_ids: Vec<u128>) {
    env.events().publish(
        (symbol_short!("u_ap"), env.current_contract_address()),
        (round_id, project_ids),
    );
}

Purpose: This event is emitted when approved projects are updated in a funding round.

  • Parameters:

    • env: The environment context for executing the event.

    • round_id: The unique identifier of the round where projects were approved or updated.

    • project_ids: A vector containing IDs of projects that have been approved or modified.

Update Whitelist Events

10. Log Update Whitelist Event

rustpub fn log_update_whitelist(env: &Env, round_id: u128, address: Address, is_add: bool) {
    env.events().publish(
        (symbol_short!("u_wl"), env.current_contract_address()),
        (round_id, address, is_add),
    );
}

Purpose: This event is emitted when a user is added to or removed from the whitelist for voting in a funding round.

  • Parameters:

    • env: The environment context for executing the event.

    • round_id: The unique identifier of the round associated with whitelisting changes.

    • address: The address of the user being added or removed from the whitelist.

    • is_add: Boolean indicating whether this action adds (true) or removes (false) the user from the whitelist.

Update Blacklist/Flag Events

11. Log Update User Flag Event

rustpub fn log_update_user_flag(env: &Env, round_id: u128, address: Address, is_flag: bool) {
    env.events().publish(
        (symbol_short!("u_bl"), env.current_contract_address()),
        (round_id, address, is_flag),
    );
}

Purpose: This event is emitted when a user is flagged or unflagged in a funding round.

  • Parameters:

    • env: The environment context for executing the event.

    • round_id: The unique identifier of the round where user flagging occurs.

    • address: The address of the user being flagged or unflagged.

    • is_flag: Boolean indicating whether this action flags (true) or unflags (false) the user.

Last updated

Was this helpful?