diff --git a/README.md b/README.md index b31de60..3c52803 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,9 @@ The contract is deployed on the Juno Network and integrates with the Nois protoc - **Instantiation**: Sets up the contract with the Nois proxy address and participant count. - **Execution**: - **Request Randomness**: Initiates a randomness request to the Nois protocol, requiring a unique job ID and necessary funds. - - **Pick Winners (Nois Receive)**: Receives randomness from Nois, selects 100 winners, and handles different outcomes based on the job ID context ("test" or regular). + - **Nois Receive**: Receives randomness from Nois, then saves the randomness based on the job ID. If the job id constains the word "test", the contract will save the randomness as a test value. Otherwise, it will save the randomness as the final value. Test value can be reseted if another request is made. But the final value can only be set once. + - **Pick Test Winners**: Selects test winners based on the test randomness value. + - **Pick Winners**: Selects winners based on the final randomness value. - **Queries**: Provides smart queries for accessing participant count, list of winners, admin details, etc. # **Setup and Configuration** diff --git a/artifacts/checksums.txt b/artifacts/checksums.txt index 922c923..b19915e 100644 --- a/artifacts/checksums.txt +++ b/artifacts/checksums.txt @@ -1 +1 @@ -0e07d227b8272b94da7f5e020d401639fe23fd5ffaa1bcb62e365fb61712b8d8 raffle_drop.wasm +a9a6edecd2fc2c37a161d5a28a25c80cf2b577007d4350f92354b2920df476cf raffle_drop.wasm diff --git a/artifacts/checksums_intermediate.txt b/artifacts/checksums_intermediate.txt index 5bd811c..4d5235d 100644 --- a/artifacts/checksums_intermediate.txt +++ b/artifacts/checksums_intermediate.txt @@ -1 +1 @@ -2809aafd2d63401e1756729b144609a3692fda5be4ed3e020c7f1ae48d638152 /target/wasm32-unknown-unknown/release/raffle_drop.wasm +1fd30a662f8a48b58a6a9e6167085550b9fdfedbc06e338f81ec801f7f55c1d4 /target/wasm32-unknown-unknown/release/raffle_drop.wasm diff --git a/artifacts/raffle_drop.wasm b/artifacts/raffle_drop.wasm index 785949b..4125ffc 100644 Binary files a/artifacts/raffle_drop.wasm and b/artifacts/raffle_drop.wasm differ diff --git a/src/contract.rs b/src/contract.rs index b9cc494..2bf191d 100644 --- a/src/contract.rs +++ b/src/contract.rs @@ -48,9 +48,10 @@ pub fn execute( msg: ExecuteMsg, ) -> Result { match msg { - ExecuteMsg::RequestRandomness { job_id } => { - execute_request_randomness(deps, env, info, job_id) - } + ExecuteMsg::RequestRandomness { + job_id, + delay_in_mins, + } => execute_request_randomness(deps, env, info, job_id, delay_in_mins), ExecuteMsg::NoisReceive { callback } => execute_set_randomness(deps, env, info, callback), ExecuteMsg::PickTestWinners {} => pick_test_winners(deps, env, info), ExecuteMsg::PickWinners {} => pick_winners(deps, env, info), @@ -59,21 +60,29 @@ pub fn execute( pub fn execute_request_randomness( deps: DepsMut, - _env: Env, + env: Env, info: MessageInfo, job_id: String, + delay_in_mins: u64, ) -> Result { let nois_proxy = NOIS_PROXY.load(deps.storage)?; if info.sender != ADMIN.load(deps.storage)? { return Err(ContractError::Unauthorized {}); } - - let res = Response::new().add_message(WasmMsg::Execute { - contract_addr: nois_proxy.into(), - msg: to_json_binary(&ProxyExecuteMsg::GetNextRandomness { job_id })?, - funds: info.funds.clone(), - }); + let now = env.block.time; + let res = Response::new() + .add_message(WasmMsg::Execute { + contract_addr: nois_proxy.into(), + msg: to_json_binary(&ProxyExecuteMsg::GetRandomnessAfter { + after: now.plus_minutes(delay_in_mins), + job_id: job_id.clone(), + })?, + funds: info.funds.clone(), + }) + .add_attribute("action", "request_randomness") + .add_attribute("job_id", job_id) + .add_attribute("after", now.plus_minutes(delay_in_mins).to_string()); Ok(res) } diff --git a/src/msg.rs b/src/msg.rs index caf78e2..e514c0a 100644 --- a/src/msg.rs +++ b/src/msg.rs @@ -9,7 +9,7 @@ pub struct InstantiateMsg { #[cw_serde] pub enum ExecuteMsg { - RequestRandomness { job_id: String }, + RequestRandomness { job_id: String, delay_in_mins: u64 }, NoisReceive { callback: NoisCallback }, PickTestWinners {}, PickWinners {},