Contract e49fbcf9fb09acd0a2e990863d43068541dd12fe61f1f31bd24d54f5a12d03c9

← Back to Index 📥 Download WASM

Meta

rssdkver 21.7.7#5da789c50b18a4c2be53394138212fed56f0dfc4
rsver 1.81.0

Instances

  • CBVQVSWZWDTIPJ46A6U7KIHTEP7PHRL5ZG5LNRKHO5OAV2CHNXVY5D2R

Interface

Initializes the ScorerFactory contract with the initial manager (scorer_creator)

Arguments

  • env - The Soroban environment
  • scorer_creator - The address that will be set as both the factory creator and initial manager
  • scorer_wasm_hash - The hash of the Wasm binary for the scorer contract

Panics

  • When the contract is already initialized
  • When the scorer_creator fails authentication
fn initialize(
    env: soroban_sdk::Env,
    scorer_creator: soroban_sdk::Address,
    scorer_wasm_hash: soroban_sdk::BytesN<32>,
)

Checks if the contract has been initialized

Arguments

  • env - The Soroban environment

Returns

  • bool - True if the contract is initialized, false otherwise
fn is_initialized(env: soroban_sdk::Env) -> bool

Verifies if the provided address is the scorer factory creator

Arguments

  • env - The Soroban environment
  • address - The address to check

Returns

  • bool - True if the address is the scorer factory creator, false otherwise

Panics

  • When the factory creator address is not found in storage
fn is_scorer_factory_creator(
    env: soroban_sdk::Env,
    address: soroban_sdk::Address,
) -> bool

Checks if the provided address is a manager

Arguments

  • env - The Soroban environment
  • address - The address to check

Returns

  • bool - True if the address is a manager, false otherwise
fn is_manager(env: soroban_sdk::Env, address: soroban_sdk::Address) -> bool

Deploy a new scorer contract

Arguments

  • env - The Soroban environment
  • deployer - The address that will deploy the scorer contract
  • salt - A unique value to ensure unique contract addresses
  • init_fn - The initialization function name to call on the deployed contract
  • init_args - Arguments to pass to the initialization function, must include:
  • Argument at index (len-3): scorer_name (String)
  • Argument at index (len-2): scorer_description (String)
  • Argument at index (len-1): scorer_icon (String)

Returns

  • Address - The address of the newly deployed scorer contract

Panics

  • When the deployer is not the current contract and fails authentication
  • When the deployer is not a registered manager (Error::Unauthorized)
  • When init_args has fewer than 3 arguments (Error::InvalidInitArgs)
fn create_scorer(
    env: soroban_sdk::Env,
    deployer: soroban_sdk::Address,
    salt: soroban_sdk::BytesN<32>,
    init_fn: soroban_sdk::Symbol,
    init_args: soroban_sdk::Vec,
) -> soroban_sdk::Address

Returns a map of all scorer contracts created by this factory

Arguments

  • env - The Soroban environment

Returns

  • Map<Address, (String, String, String)> - A map where keys are scorer contract addresses and values are tuples containing (scorer_name, scorer_description, scorer_icon)

Panics

  • When the scorers map cannot be found in storage (Error::ScorersWereNotFound)
fn get_scorers(
    env: soroban_sdk::Env,
) -> soroban_sdk::Map<
    soroban_sdk::Address,
    (soroban_sdk::String, soroban_sdk::String, soroban_sdk::String),
>

Adds a new manager to the contract

Arguments

  • env - The Soroban environment
  • caller - The address that will authenticate the addition of the new manager
  • manager - The address to be added as a manager

Panics

  • When the caller is not the scorer factory creator or a manager (Error::Unauthorized)
  • When the manager already exists (Error::ManagerAlreadyExists)
fn add_manager(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    manager: soroban_sdk::Address,
)

Removes a manager from the contract

Arguments

  • env - The Soroban environment
  • caller - The address that will authenticate the removal of the manager
  • manager - The address to be removed as a manager

Panics

  • When the caller is not the scorer factory creator or a manager (Error::Unauthorized)
  • When the manager to be removed is not found (Error::ManagerNotFound)
  • When attempting to remove the last manager (Error::CannotRemoveLastManager)
fn remove_manager(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    manager: soroban_sdk::Address,
)

Retrieves all the managers from the contract.

Arguments

  • env - The Soroban environment

Returns

  • Vec<Address> - A vector of all manager addresses

Panics

  • When the managers vector cannot be found in storage (Error::ManagersNotFound)
fn get_managers(env: soroban_sdk::Env) -> soroban_sdk::Vec

Retrieves the address of the contract creator.

Arguments

  • env - The Soroban environment

Returns

  • Address - The address of the scorer factory creator

Panics

  • When the creator's address is not found in storage (Error::ContractCreatorNotFound)
fn get_contract_creator(env: soroban_sdk::Env) -> soroban_sdk::Address

Removes a scorer contract from the factory's registry

Arguments

  • env - The Soroban environment
  • caller - The address that will authenticate the removal of the scorer
  • scorer_address - The address of the scorer contract to be removed

Returns

  • () - Returns unit type on success

Panics

  • When the caller is not a registered manager (Error::Unauthorized)
  • When the scorer address is not found in the registry (Error::ScorerNotFound)
fn remove_scorer(
    env: soroban_sdk::Env,
    caller: soroban_sdk::Address,
    scorer_address: soroban_sdk::Address,
)

Imports

WebAssembly Text (WAT) ▶