Skip to content

Commit

Permalink
Merge pull request #157 from Entropy-Foundation/view_functions
Browse files Browse the repository at this point in the history
View functions
  • Loading branch information
sjoshisupra authored Jan 1, 2025
2 parents f2105ac + f3c57d0 commit 406396f
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,18 @@ module supra_framework::vesting_without_staking {
borrow_global<VestingContract>(vesting_contract_address).vesting_schedule.period_duration
}

#[view]
// Return the `withdrawal_address` of the contract
public fun get_withdrawal_addr(vesting_contract_addr: address): address acquires VestingContract {
borrow_global<VestingContract>(vesting_contract_addr).withdrawal_address
}

#[view]
// Return the `admin` address of the contract
public fun get_contract_admin(vesting_contract_addr: address): address acquires VestingContract {
borrow_global<VestingContract>(vesting_contract_addr).admin
}

#[view]
//Return the vesting record of the shareholder as a tuple `(init_amount, left_amount, last_vested_period)`
public fun get_vesting_record(
Expand Down Expand Up @@ -2331,6 +2343,8 @@ module supra_framework::vesting_without_staking {
let vested_amount = 0;
// Because the time is behind the start time, vest will do nothing.
vest(contract_address);
assert!(get_withdrawal_addr(contract_address)==withdrawal_address,98);
assert!(get_contract_admin(contract_address)==admin_address,99);
assert!(coin::balance<SupraCoin>(contract_address) == 1000, 0);
assert!(coin::balance<SupraCoin>(shareholder_address) == vested_amount, 0);
// Time is now at the start time, vest will unlock the first period, which is 2/10.
Expand Down

0 comments on commit 406396f

Please sign in to comment.