Skip to content

Commit

Permalink
fix-msgs
Browse files Browse the repository at this point in the history
  • Loading branch information
kaisbaccour committed Oct 18, 2022
1 parent d8755c3 commit de5d4f8
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions contracts/double-dice-roll/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,23 +97,23 @@ pub fn execute_roll_dice_multiple_times(
{
return Err(ContractError::JobIdAlreadyPresent);
}
let response = Response::new();
for job in 1..n_times {
let nois_proxy = NOIS_PROXY.load(deps.storage)?;
let nois_proxy = NOIS_PROXY.load(deps.storage)?;

response.to_owned().add_message(WasmMsg::Execute {
contract_addr: nois_proxy.into(),
//GetNextRandomness requests the randomness from the proxy
//The job id is needed to know what randomness we are referring to upon reception in the callback
//In this example, the job_id represents one round of dice rolling.
let mut msgs = Vec::<WasmMsg>::new();

for job in 1..n_times {
let msg = WasmMsg::Execute {
contract_addr: nois_proxy.to_owned().into(),
msg: to_binary(&ProxyExecuteMsg::GetNextRandomness {
job_id: job_id.to_owned() + "-" + &job.to_string(),
})?,
//For now the randomness is for free. You don't need to send any funds to request randomness
funds: vec![],
});
};

msgs.push(msg);
}
Ok(response)

Ok(Response::new().add_messages(msgs))
}

//The execute_receive function is triggered upon reception of the randomness from the proxy contract
Expand Down

0 comments on commit de5d4f8

Please sign in to comment.