Skip to content

Commit

Permalink
Add more functionality to the vesting skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
tensojka committed Nov 27, 2023
1 parent 044bc13 commit 60a6275
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions src/vesting.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ trait IVesting<TContractState> {
fn vest(ref self: TContractState, grantee: ContractAddress, vested_timestamp: u64);

fn add_vesting_milestone(
ref self: TContractState, vesting_timestamp: u64, grantee: ContractAddress
ref self: TContractState, vesting_timestamp: u64, grantee: ContractAddress, amount: u128
);
// add_linear_vesting_schedule
// add_cliff_linear_vesting_schedule
Expand All @@ -15,11 +15,25 @@ trait IVesting<TContractState> {

#[starknet::component]
mod vesting {
// TODO: must depend on Ownable or Proposals to clarify who has the right to add vesting milestones
#[storage]
struct Storage {
milestone: LegacyMap::<(u64, ContractAddress), u128>
}

#[derive(starknet::Event, Drop)]
#[event]
enum Event {
VestingMilestoneAdded: VestingMilestoneAdded
}

#[derive(starknet::Event, Drop)]
struct VestingMilestoneAdded {
grantee: ContractAddress,
timestamp: u64,
amount: u128
}

#[embeddable_as(VestingImpl)]
impl Vesting<
TContractState, +HasComponent<TContractState>
Expand All @@ -28,12 +42,20 @@ mod vesting {
ref self: ComponentState<TContractState>,
grantee: ContractAddress,
vested_timestamp: u64
) {}
) {
let amt_to_vest = self.milestone.read((vested_timestamp, grantee));
assert(amt_to_vest != 0, 'no vesting milestone found');
}

fn add_vesting_milestone(
ref self: ComponentState<TContractState>,
vesting_timestamp: u64,
grantee: ContractAddress
) {}
grantee: ContractAddress,
amount: u128
) {
// TODO: check if caller is eligible to add vesting milestone or if this is part of a proposal
self.milestone.write((vested_timestamp, grantee), amount);
self.emit(VestingMilestoneAdded { grantee: grantee, timestamp: vesting_timestamp, amount: u128})
}
}
}

0 comments on commit 60a6275

Please sign in to comment.