Skip to content

Commit

Permalink
A few improvements on Wallet display (#1679)
Browse files Browse the repository at this point in the history
  • Loading branch information
lxfind authored and longbowlu committed May 12, 2022
1 parent 6c920cc commit a363f41
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 19 deletions.
2 changes: 1 addition & 1 deletion sui/src/unit_tests/cli_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ async fn test_object_info_get_command() -> Result<(), anyhow::Error> {
.execute(&mut context)
.await?
.print(true);
let obj_owner = format!("{:?}", address);
let obj_owner = format!("{}", address);

retry_assert!(
logs_contain(obj_owner.as_str()),
Expand Down
18 changes: 10 additions & 8 deletions sui_core/src/gateway_state/gateway_responses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,17 @@ impl Display for PublishResponse {
writeln!(writer, "----- Publish Results ----")?;
writeln!(
writer,
"The newly published package object: {:?}",
self.package
"The newly published package object ID: {:?}",
self.package.0
)?;
writeln!(
writer,
"List of objects created by running module initializers:"
)?;
for obj in &self.created_objects {
writeln!(writer, "{}", obj)?;
if !self.created_objects.is_empty() {
writeln!(
writer,
"List of objects created by running module initializers:\n"
)?;
for obj in &self.created_objects {
writeln!(writer, "{}\n", obj)?;
}
}
let gas_coin = GasCoin::try_from(&self.updated_gas).map_err(fmt::Error::custom)?;
writeln!(writer, "Updated Gas : {}", gas_coin)?;
Expand Down
24 changes: 18 additions & 6 deletions sui_types/src/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -949,20 +949,32 @@ impl Display for TransactionEffects {
writeln!(writer, "Status : {:?}", self.status)?;
if !self.created.is_empty() {
writeln!(writer, "Created Objects:")?;
for (obj, _) in &self.created {
writeln!(writer, "{:?} {:?} {:?}", obj.0, obj.1, obj.2)?;
for ((id, _, _), owner) in &self.created {
writeln!(writer, " - ID: {:?} , Owner: {}", id, owner)?;
}
}
if !self.mutated.is_empty() {
writeln!(writer, "Mutated Objects:")?;
for (obj, _) in &self.mutated {
writeln!(writer, "{:?} {:?} {:?}", obj.0, obj.1, obj.2)?;
for ((id, _, _), owner) in &self.mutated {
writeln!(writer, " - ID: {:?} , Owner: {}", id, owner)?;
}
}
if !self.deleted.is_empty() {
writeln!(writer, "Deleted Objects:")?;
for obj in &self.deleted {
writeln!(writer, "{:?} {:?} {:?}", obj.0, obj.1, obj.2)?;
for (id, _, _) in &self.deleted {
writeln!(writer, " - ID: {:?}", id)?;
}
}
if !self.wrapped.is_empty() {
writeln!(writer, "Wrapped Objects:")?;
for (id, _, _) in &self.wrapped {
writeln!(writer, " - ID: {:?}", id)?;
}
}
if !self.unwrapped.is_empty() {
writeln!(writer, "Unwrapped Objects:")?;
for ((id, _, _), owner) in &self.unwrapped {
writeln!(writer, " - ID: {:?} , Owner: {}", id, owner)?;
}
}
write!(f, "{}", writer)
Expand Down
26 changes: 22 additions & 4 deletions sui_types/src/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,25 @@ impl std::cmp::PartialEq<ObjectID> for Owner {
}
}

impl Display for Owner {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
Self::AddressOwner(address) => {
write!(f, "Account Address ( {} )", address)
}
Self::ObjectOwner(address) => {
write!(f, "Object ID: ( {} )", address)
}
Self::Immutable => {
write!(f, "Immutable")
}
Self::Shared => {
write!(f, "Shared")
}
}
}
}

#[derive(Eq, PartialEq, Debug, Clone, Deserialize, Serialize, Hash, JsonSchema)]
pub struct Object {
/// The meat of the object
Expand Down Expand Up @@ -639,11 +658,10 @@ impl Display for Object {

write!(
f,
"Owner: {:?}\nVersion: {:?}\nID: {:?}\nReadonly: {:?}\nType: {}",
self.owner,
self.version().value(),
"ID: {:?}\nVersion: {:?}\nOwner: {}\nType: {}",
self.id(),
self.is_immutable(),
self.version().value(),
self.owner,
type_string
)
}
Expand Down

0 comments on commit a363f41

Please sign in to comment.