Skip to content

Commit

Permalink
Fix issue with instantiating cw-abc with hatchers (#830)
Browse files Browse the repository at this point in the history
allow self to call method
  • Loading branch information
ismellike authored May 20, 2024
1 parent f656e8a commit 455880f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
6 changes: 4 additions & 2 deletions contracts/external/cw-abc/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,15 +417,17 @@ pub fn toggle_pause(deps: DepsMut, info: MessageInfo) -> Result<Response, Contra
.add_attribute("is_paused", is_paused.to_string()))
}

/// Add and remove addresses from the hatcher allowlist (only callable by owner)
/// Add and remove addresses from the hatcher allowlist (only callable by owner and self)
pub fn update_hatch_allowlist(
deps: DepsMut,
env: Env,
info: MessageInfo,
to_add: Vec<HatcherAllowlistEntryMsg>,
to_remove: Vec<String>,
) -> Result<Response, ContractError> {
cw_ownable::assert_owner(deps.storage, &info.sender)?;
if env.contract.address != info.sender {
cw_ownable::assert_owner(deps.storage, &info.sender)?;
}

let list = hatcher_allowlist();

Expand Down
11 changes: 8 additions & 3 deletions contracts/external/cw-abc/src/test_tube/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,13 @@ fn test_allowlist() {
},
closed: ClosedConfig {},
},
hatcher_allowlist: None,
hatcher_allowlist: Some(vec![HatcherAllowlistEntryMsg {
addr: "replaced to accounts[9]".to_string(),
config: HatcherAllowlistConfigMsg {
config_type: HatcherAllowlistConfigType::Address {},
contribution_limits_override: None,
},
}]),
curve_type: CurveType::Constant {
value: Uint128::one(),
scale: 1,
Expand Down Expand Up @@ -403,8 +409,7 @@ fn test_allowlist() {
))
);

// Enable the allow list, normally this would be passed in through
// instantiation.
// Update the allowlist
abc.execute(
&ExecuteMsg::UpdateHatchAllowlist {
to_add: vec![
Expand Down
18 changes: 17 additions & 1 deletion contracts/external/cw-abc/src/test_tube/test_env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,17 @@ impl TestEnvBuilder {
funding_pool_forwarding: Some(accounts[0].address()),
supply: SupplyToken {
subdenom: DENOM.to_string(),
metadata: None,
metadata: Some(NewDenomMetadata {
description: "Awesome token, get it meow!".to_string(),
additional_denom_units: Some(vec![DenomUnit {
denom: "cat".to_string(),
exponent: 6,
aliases: vec![],
}]),
display: "cat".to_string(),
name: "Cat Token".to_string(),
symbol: "CAT".to_string(),
}),
decimals: 6,
max_supply: Some(Uint128::from(1_000_000_000u128)),
},
Expand Down Expand Up @@ -297,6 +307,12 @@ impl TestEnvBuilder {

msg.funding_pool_forwarding = Some(accounts[0].address());

if let Some(allowlist) = msg.hatcher_allowlist.as_mut() {
for member in allowlist {
member.addr = accounts[9].address();
}
}

let abc = CwAbc::deploy(app, &msg, &accounts[0])?;

let issuer_addr = CwAbc::query(&abc, &QueryMsg::TokenContract {})?;
Expand Down

0 comments on commit 455880f

Please sign in to comment.