Skip to content

Commit

Permalink
readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Ninjatosba committed Apr 14, 2024
1 parent ae9828c commit 8b1555b
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 14 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
Expand Down
2 changes: 1 addition & 1 deletion artifacts/checksums.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0e07d227b8272b94da7f5e020d401639fe23fd5ffaa1bcb62e365fb61712b8d8 raffle_drop.wasm
a9a6edecd2fc2c37a161d5a28a25c80cf2b577007d4350f92354b2920df476cf raffle_drop.wasm
2 changes: 1 addition & 1 deletion artifacts/checksums_intermediate.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2809aafd2d63401e1756729b144609a3692fda5be4ed3e020c7f1ae48d638152 /target/wasm32-unknown-unknown/release/raffle_drop.wasm
1fd30a662f8a48b58a6a9e6167085550b9fdfedbc06e338f81ec801f7f55c1d4 /target/wasm32-unknown-unknown/release/raffle_drop.wasm
Binary file modified artifacts/raffle_drop.wasm
Binary file not shown.
29 changes: 19 additions & 10 deletions src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ pub fn execute(
msg: ExecuteMsg,
) -> Result<Response, ContractError> {
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),
Expand All @@ -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<Response, ContractError> {
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)
}

Expand Down
2 changes: 1 addition & 1 deletion src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {},
Expand Down

0 comments on commit 8b1555b

Please sign in to comment.