From 89959ad67be0952c466075a6cfb224ba281031b7 Mon Sep 17 00:00:00 2001 From: Saurabh Joshi Date: Wed, 1 Jan 2025 14:55:23 +0530 Subject: [PATCH 1/3] add view function for getting admin of the contract --- .../supra-framework/sources/vesting_without_staking.move | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/aptos-move/framework/supra-framework/sources/vesting_without_staking.move b/aptos-move/framework/supra-framework/sources/vesting_without_staking.move index 9c9d2f4132dac..3799f2f9881a8 100644 --- a/aptos-move/framework/supra-framework/sources/vesting_without_staking.move +++ b/aptos-move/framework/supra-framework/sources/vesting_without_staking.move @@ -182,6 +182,11 @@ module supra_framework::vesting_without_staking { borrow_global(vesting_contract_address).vesting_schedule.period_duration } + #[view] + public fun get_contract_admin(vesting_contract_addr: address): address acquires VestingContract { + borrow_global(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( From 3bec7e48c91da8a20a28058702d79c830f5f546f Mon Sep 17 00:00:00 2001 From: Saurabh Joshi Date: Wed, 1 Jan 2025 15:03:25 +0530 Subject: [PATCH 2/3] add comment/test --- .../supra-framework/sources/vesting_without_staking.move | 2 ++ 1 file changed, 2 insertions(+) diff --git a/aptos-move/framework/supra-framework/sources/vesting_without_staking.move b/aptos-move/framework/supra-framework/sources/vesting_without_staking.move index 3799f2f9881a8..0a64c4ded8066 100644 --- a/aptos-move/framework/supra-framework/sources/vesting_without_staking.move +++ b/aptos-move/framework/supra-framework/sources/vesting_without_staking.move @@ -183,6 +183,7 @@ module supra_framework::vesting_without_staking { } #[view] + // Return the `admin` address of the contract public fun get_contract_admin(vesting_contract_addr: address): address acquires VestingContract { borrow_global(vesting_contract_addr).admin } @@ -2336,6 +2337,7 @@ 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_contract_admin(contract_address)==admin_address,99); assert!(coin::balance(contract_address) == 1000, 0); assert!(coin::balance(shareholder_address) == vested_amount, 0); // Time is now at the start time, vest will unlock the first period, which is 2/10. From f3c57d06fc4fa6ba86b58c7d10d9c61fb87f22c4 Mon Sep 17 00:00:00 2001 From: Saurabh Joshi Date: Wed, 1 Jan 2025 15:30:02 +0530 Subject: [PATCH 3/3] add view function for withdrawal address --- .../supra-framework/sources/vesting_without_staking.move | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/aptos-move/framework/supra-framework/sources/vesting_without_staking.move b/aptos-move/framework/supra-framework/sources/vesting_without_staking.move index 0a64c4ded8066..5dc9fa3f9e10d 100644 --- a/aptos-move/framework/supra-framework/sources/vesting_without_staking.move +++ b/aptos-move/framework/supra-framework/sources/vesting_without_staking.move @@ -182,6 +182,12 @@ module supra_framework::vesting_without_staking { borrow_global(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(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 { @@ -2337,6 +2343,7 @@ 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(contract_address) == 1000, 0); assert!(coin::balance(shareholder_address) == vested_amount, 0);