Implement the initialize function which is called once on deployment to set up the contract state.
Function signature:
rustpub fn initialize(
env: Env,
admin: Address,
property_metadata: PropertyMetadata,
total_supply: i128,
compliance_contract: Address,
) -> Result<(), ContractError>
Requirements:
Can only be called once. Subsequent calls must return ContractError::AlreadyInitialized.
total_supply must be greater than 0. If not, return ContractError::InvalidSupply.
admin must be a valid Stellar address.
All PropertyMetadata fields must be non-empty strings.
On success, emit an Initialized event with the property ID and total supply.
Assign the full total_supply to the admin balance on initialisation.
Acceptance criteria:
Function implemented in lib.rs, logic in a submodule
Error cases tested
Happy path tested
Initialized event emitted and tested
Implement the initialize function which is called once on deployment to set up the contract state.
Function signature:
rustpub fn initialize(
env: Env,
admin: Address,
property_metadata: PropertyMetadata,
total_supply: i128,
compliance_contract: Address,
) -> Result<(), ContractError>
Requirements:
Can only be called once. Subsequent calls must return ContractError::AlreadyInitialized.
total_supply must be greater than 0. If not, return ContractError::InvalidSupply.
admin must be a valid Stellar address.
All PropertyMetadata fields must be non-empty strings.
On success, emit an Initialized event with the property ID and total supply.
Assign the full total_supply to the admin balance on initialisation.
Acceptance criteria:
Function implemented in lib.rs, logic in a submodule
Error cases tested
Happy path tested
Initialized event emitted and tested