diff --git a/src/airdrop.cairo b/src/airdrop.cairo index 00d12c2..dfcc58c 100644 --- a/src/airdrop.cairo +++ b/src/airdrop.cairo @@ -1,3 +1,4 @@ +use governance::interfaces::erc20::{IERC20Dispatcher}; use starknet::{ContractAddress}; use array::{Array}; @@ -11,12 +12,21 @@ struct Claim { trait IAirdrop { // Claims the given allotment of tokens fn claim(ref self: TStorage, claim: Claim, proof: Array::); + + // Return the root of the airdrop + fn get_root(self: @TStorage) -> felt252; + + // Return the token being dropped + fn get_token(self: @TStorage) -> IERC20Dispatcher; + + // Return whether the claim has been claimed (always false for invalid claims) + fn is_claimed(self: @TStorage, claim: Claim) -> bool; } #[starknet::contract] mod Airdrop { - use super::{IAirdrop, ContractAddress, Claim}; - use governance::interfaces::erc20::{IERC20Dispatcher, IERC20DispatcherTrait}; + use super::{IAirdrop, ContractAddress, Claim, IERC20Dispatcher}; + use governance::interfaces::erc20::{IERC20DispatcherTrait}; use hash::{LegacyHash}; use array::{ArrayTrait, SpanTrait}; use starknet::{ContractAddressIntoFelt252}; @@ -81,5 +91,17 @@ mod Airdrop { self.emit(Claimed { claim }); } + + fn get_root(self: @ContractState) -> felt252 { + self.root.read() + } + + fn get_token(self: @ContractState) -> IERC20Dispatcher { + self.token.read() + } + + fn is_claimed(self: @ContractState, claim: Claim) -> bool { + self.claimed.read(LegacyHash::hash(0, claim)) + } } } diff --git a/src/factory_test.cairo b/src/factory_test.cairo index 1521c5b..c20d491 100644 --- a/src/factory_test.cairo +++ b/src/factory_test.cairo @@ -80,6 +80,10 @@ fn test_deploy() { assert(erc20.balance_of(get_contract_address()) == 5678 - 1111, 'deployer balance'); // assert(erc20.balance_of(result.airdrop.unwrap().contract_address) == 1111, 'airdrop balance'); + let drop = result.airdrop.unwrap(); + assert(drop.get_root() == 'root', 'airdrop root'); + assert(drop.get_token().contract_address == result.token.contract_address, 'airdrop token'); + assert( result.governor.get_voting_token().contract_address == result.token.contract_address, 'voting_token'