Skip to content

Commit

Permalink
feat: identifier whitelist documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
JordyRo1 committed Jul 8, 2024
1 parent fb155c9 commit 4364a8f
Showing 1 changed file with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
/// Store whitelist of supported identifiers, unique piece of information that the oracle provide result for.

#[starknet::contract]
pub mod identifier_whitelist {
use starknet::ContractAddress;
use core::starknet::event::EventEmitter;
use openzeppelin::access::ownable::ownable::OwnableComponent::InternalTrait;
use optimistic_oracle::contracts::interfaces::IIdentifierWhitelist;
Expand All @@ -9,7 +12,6 @@ pub mod identifier_whitelist {
impl OwnableImpl = OwnableComponent::OwnableImpl<ContractState>;
impl OwnableInternalImpl = OwnableComponent::InternalImpl<ContractState>;


#[storage]
struct Storage {
supported_identifiers: LegacyMap::<felt252, bool>,
Expand Down Expand Up @@ -38,8 +40,20 @@ pub mod identifier_whitelist {
pub identifier: felt252,
}

#[constructor]
fn constructor(ref self: ContractState, owner: ContractAddress) {
self.ownable.initializer(owner);
}


#[abi(embed_v0)]
impl IIdentifierWhitelistImpl of IIdentifierWhitelist<ContractState> {
/// Add the provided identifier as supported identifier
/// Dev: callable only by the admin
///
/// # Arguments
///
/// * `identifier` - an unique representation of the feed being added
fn add_supported_identifier(ref self: ContractState, identifier: felt252) {
self.ownable.assert_only_owner();
if (!self.supported_identifiers.read(identifier)) {
Expand All @@ -48,6 +62,12 @@ pub mod identifier_whitelist {
self.emit(SupportedIdentifierAdded { identifier });
}

/// Remove the provided identifier as supported identifier
/// Dev: callable only by the admin
///
/// # Arguments
///
/// * `identifier` - an unique representation of the feed being removed
fn remove_supported_identifier(ref self: ContractState, identifier: felt252) {
self.ownable.assert_only_owner();
if (self.supported_identifiers.read(identifier)) {
Expand All @@ -56,6 +76,11 @@ pub mod identifier_whitelist {
self.emit(SupportedIdentifierRemoved { identifier });
}

/// Check if a given identifier is supported or not.
///
/// # Arguments
///
/// * `identifier` - the identifier to check the information for
fn is_identifier_supported(self: @ContractState, identifier: felt252) -> bool {
self.supported_identifiers.read(identifier)
}
Expand Down

0 comments on commit 4364a8f

Please sign in to comment.