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/SDK integration #145

Merged
merged 4 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
45 changes: 26 additions & 19 deletions contracts/consumer/converter/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,26 +360,33 @@ impl ConverterApi for ConverterContract<'_> {

// Send over IBC to the Consumer
let channel = IBC_CHANNEL.load(ctx.deps.storage)?;
let add_msg = add_validators_msg(&ctx.env, &channel, &additions)?;
let tomb_msg = tombstone_validators_msg(&ctx.env, &channel, &tombstoned)?;
let jail_msg = jail_validators_msg(&ctx.env, &channel, &jailed)?;

let event = Event::new("valset_update").add_attribute(
"additions",
additions
.iter()
.map(|v| v.address.clone())
.collect::<Vec<String>>()
.join(","),
);
let event = event.add_attribute("jailed", jailed.join(","));
let event = event.add_attribute("tombstoned", tombstoned.join(","));
let resp = Response::new()
.add_event(event)
.add_message(add_msg)
.add_message(tomb_msg)
.add_message(jail_msg);

let mut resp = Response::new();
let mut event = Event::new("valset_update");

if !additions.is_empty() {
let add_msg = add_validators_msg(&ctx.env, &channel, &additions)?;
resp = resp.add_message(add_msg);
event = event.add_attribute(
"additions",
additions
.iter()
.map(|v| v.address.clone())
.collect::<Vec<String>>()
.join(","),
);
}
if !jailed.is_empty() {
let jail_msg = jail_validators_msg(&ctx.env, &channel, &jailed)?;
resp = resp.add_message(jail_msg);
event = event.add_attribute("jailed", jailed.join(","));
}
if !tombstoned.is_empty() {
let tomb_msg = tombstone_validators_msg(&ctx.env, &channel, &tombstoned)?;
resp = resp.add_message(tomb_msg);
event = event.add_attribute("tombstoned", tombstoned.join(","));
}
resp = resp.add_event(event);
Ok(resp)
}
}
12 changes: 6 additions & 6 deletions contracts/consumer/virtual-staking/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,12 +531,12 @@ pub fn sudo(
tombstoned,
} => VirtualStakingContract::new().handle_valset_update(
deps,
&additions,
&removals,
&updated,
&jailed,
&unjailed,
&tombstoned,
&additions.unwrap_or_default(),
&removals.unwrap_or_default(),
&updated.unwrap_or_default(),
&jailed.unwrap_or_default(),
&unjailed.unwrap_or_default(),
&tombstoned.unwrap_or_default(),
),
}
}
Expand Down
12 changes: 6 additions & 6 deletions contracts/consumer/virtual-staking/src/multitest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,12 @@ fn valset_update_sudo() {
let rems = vec!["cosmosval2".to_string()];
let tombs = vec!["cosmosval3".to_string()];
let msg = SudoMsg::ValsetUpdate {
additions: adds,
removals: rems,
updated: vec![],
jailed: vec![],
unjailed: vec![],
tombstoned: tombs,
additions: Some(adds),
removals: Some(rems),
updated: None,
jailed: None,
unjailed: None,
tombstoned: Some(tombs),
};

let res = app
Expand Down
2 changes: 1 addition & 1 deletion packages/apis/src/ibc/packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ pub struct RemoveValidatorsAck {}
#[cw_serde]
pub struct JailValidatorsAck {}

/// Ack sent for ConsumerPacket::Distribute
/// Ack sent for ConsumerPacket::Distribute and ConsumerPacket::DistributeBatch
#[cw_serde]
pub struct DistributeAck {}

Expand Down
12 changes: 6 additions & 6 deletions packages/apis/src/virtual_staking_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ pub enum SudoMsg {
/// - Addition of an existing validator to the active validator set.
/// - Permanent removal (i.e. tombstoning) of a validator from the active set. Implies slashing
ValsetUpdate {
additions: Vec<Validator>,
removals: Vec<String>,
updated: Vec<Validator>,
jailed: Vec<String>,
unjailed: Vec<String>,
tombstoned: Vec<String>,
additions: Option<Vec<Validator>>,
removals: Option<Vec<String>>,
updated: Option<Vec<Validator>>,
jailed: Option<Vec<String>>,
unjailed: Option<Vec<String>>,
tombstoned: Option<Vec<String>>,
},
}
Loading