Skip to content

Commit

Permalink
Fix unwrap_or_default attr values
Browse files Browse the repository at this point in the history
  • Loading branch information
ismellike committed May 8, 2024
1 parent 3ab7017 commit f9730c1
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 6 deletions.
4 changes: 2 additions & 2 deletions contracts/external/cw721-roles/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ pub fn execute_update_token_role(
.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 @@ -348,7 +348,7 @@ pub fn execute_update_token_uri(
.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

0 comments on commit f9730c1

Please sign in to comment.