Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unwrap_or_default attr values #829

Merged
merged 3 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ci/bootstrap-env/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ fn main() -> Result<()> {
);

// Persist contract code_ids in local.yaml so we can use SKIP_CONTRACT_STORE locally to avoid having to re-store them again
cfg.contract_deploy_info = orc.contract_map.deploy_info().clone();
cfg.contract_deploy_info
.clone_from(orc.contract_map.deploy_info());
fs::write(
"ci/configs/cosm-orc/local.yaml",
serde_yaml::to_string(&cfg)?,
Expand Down
3 changes: 2 additions & 1 deletion ci/integration-tests/src/helpers/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ fn global_setup() -> Cfg {
.unwrap();
save_gas_report(&orc, &gas_report_dir);
// persist stored code_ids in CONFIG, so we can reuse for all tests
cfg.contract_deploy_info = orc.contract_map.deploy_info().clone();
cfg.contract_deploy_info
.clone_from(orc.contract_map.deploy_info());
}

Cfg {
Expand Down
8 changes: 4 additions & 4 deletions contracts/external/cw721-roles/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,14 +319,14 @@ pub fn execute_update_token_role(
let mut token = contract.tokens.load(deps.storage, &token_id)?;

// Update role with new value
token.extension.role = role.clone();
token.extension.role.clone_from(&role);
contract.tokens.save(deps.storage, &token_id, &token)?;

Ok(Response::default()
.add_attribute("action", "update_token_role")
.add_attribute("sender", info.sender)
.add_attribute("token_id", token_id)
.add_attribute("role", role.unwrap_or_default()))
.add_attribute("role", role.unwrap_or("None".to_string())))
}

pub fn execute_update_token_uri(
Expand All @@ -341,14 +341,14 @@ pub fn execute_update_token_uri(
let mut token = contract.tokens.load(deps.storage, &token_id)?;

// Set new token URI
token.token_uri = token_uri.clone();
token.token_uri.clone_from(&token_uri);
contract.tokens.save(deps.storage, &token_id, &token)?;

Ok(Response::new()
.add_attribute("action", "update_token_uri")
.add_attribute("sender", info.sender)
.add_attribute("token_id", token_id)
.add_attribute("token_uri", token_uri.unwrap_or_default()))
.add_attribute("token_uri", token_uri.unwrap_or("None".to_string())))
}

pub fn execute_update_token_weight(
Expand Down
14 changes: 14 additions & 0 deletions contracts/external/cw721-roles/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,20 @@ fn test_update_token_role() {
// Token was updated successfully
let info: NftInfoResponse<MetadataExt> = query_token_info(&app, &cw721_addr, "1").unwrap();
assert_eq!(info.extension.role, Some("queen".to_string()));

// Can set to None
app.execute_contract(
Addr::unchecked(DAO),
cw721_addr.clone(),
&ExecuteMsg::Extension {
msg: ExecuteExt::UpdateTokenRole {
token_id: "1".to_string(),
role: None,
},
},
&[],
)
.unwrap();
}

#[test]
Expand Down
5 changes: 4 additions & 1 deletion contracts/proposal/dao-proposal-condorcet/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,10 @@ pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> Result<Response, ContractE

Ok(Response::default()
.add_attribute("proposal_execution_failed", proposal_id.to_string())
.add_attribute("error", msg.result.into_result().err().unwrap_or_default()))
.add_attribute(
"error",
msg.result.into_result().err().unwrap_or("None".to_string()),
))
}
_ => unimplemented!("pre-propose and hooks not yet supported"),
}
Expand Down
5 changes: 4 additions & 1 deletion contracts/proposal/dao-proposal-multiple/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,10 @@ pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> Result<Response, ContractE

Ok(Response::new()
.add_attribute("proposal execution failed", proposal_id.to_string())
.add_attribute("error", msg.result.into_result().err().unwrap_or_default()))
.add_attribute(
"error",
msg.result.into_result().err().unwrap_or("None".to_string()),
))
}
TaggedReplyId::FailedProposalHook(idx) => {
let addr = PROPOSAL_HOOKS.remove_hook_by_index(deps.storage, idx)?;
Expand Down
5 changes: 4 additions & 1 deletion contracts/proposal/dao-proposal-single/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1081,7 +1081,10 @@ pub fn reply(deps: DepsMut, _env: Env, msg: Reply) -> Result<Response, ContractE

Ok(Response::new()
.add_attribute("proposal_execution_failed", proposal_id.to_string())
.add_attribute("error", msg.result.into_result().err().unwrap_or_default()))
.add_attribute(
"error",
msg.result.into_result().err().unwrap_or("None".to_string()),
))
}
TaggedReplyId::FailedProposalHook(idx) => {
let addr = PROPOSAL_HOOKS.remove_hook_by_index(deps.storage, idx)?;
Expand Down
5 changes: 4 additions & 1 deletion contracts/voting/dao-voting-token-staked/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,10 @@ pub fn reply(deps: DepsMut, env: Env, msg: Reply) -> Result<Response, ContractEr
// Construct the response
let mut res = Response::new()
.add_attribute("denom", info.denom)
.add_attribute("token_contract", info.token_contract.unwrap_or_default());
.add_attribute(
"token_contract",
info.token_contract.unwrap_or("None".to_string()),
);

// If a callback has been configured, set the module
// instantiate callback data.
Expand Down
Loading