diff --git a/Cargo.lock b/Cargo.lock index bdd4b7b..e0346d9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -808,7 +808,7 @@ dependencies = [ [[package]] name = "reflector-dao-contract" -version = "0.2.0" +version = "0.3.0" dependencies = [ "soroban-sdk", ] diff --git a/Cargo.toml b/Cargo.toml index b49171f..ac1f9b2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "reflector-dao-contract" -version = "0.2.0" +version = "0.3.0" edition = "2021" [lib] diff --git a/src/lib.rs b/src/lib.rs index e55cb1f..b95a711 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -55,7 +55,7 @@ impl DAOContract { // save the configuration e.set_admin(&config.admin); e.set_token(&config.token); - e.set_last_unlock(e.ledger().timestamp()); + e.set_last_unlock(config.start_date); //set deposit params set_deposit(&e, config.deposit_params); // transfer tokens to the DAO contract diff --git a/src/test.rs b/src/test.rs index db6dd7f..a01c593 100644 --- a/src/test.rs +++ b/src/test.rs @@ -45,7 +45,8 @@ fn init_contract_with_admin<'a>() -> (Env, DAOContractClient<'a>, ContractConfig (BallotCategory::AddPriceFeed, 100_000_0000000), (BallotCategory::AddAsset, 5_000_0000000), (BallotCategory::General, 10_000_0000000), - ]) + ]), + start_date: 0, }; //set admin @@ -147,6 +148,19 @@ fn test() { assert!(balance > 0); }); + env.as_contract(&client.address, || { + let last_unlock = env.get_last_unlock(); + assert_eq!(last_unlock, UNLOCK_PERIOD as u64); + }); + + //unlock again + client.unlock(&developer, &operators); + + env.as_contract(&client.address, || { + let last_unlock = env.get_last_unlock(); + assert_eq!(last_unlock, (UNLOCK_PERIOD * 2) as u64); + }); + let available = client.available(&developer); assert!(available > 0); diff --git a/src/types/contract_config.rs b/src/types/contract_config.rs index f252e99..cf57b2a 100644 --- a/src/types/contract_config.rs +++ b/src/types/contract_config.rs @@ -14,5 +14,7 @@ pub struct ContractConfig { /// Initial funding amount pub amount: i128, /// Initial deposit amounts for each ballot category - pub deposit_params: Map + pub deposit_params: Map, + /// DAO start date + pub start_date: u64 }