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
: ARoundDetail
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
: ARoundDetail
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
: ARoundApplication
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
: ARoundApplication
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
: ARoundApplication
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
: ADeposit
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
: AVotingResult
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.