Skip to content

Commit

Permalink
Integrated fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gdanezis committed Sep 10, 2024
1 parent 924f940 commit 531a402
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 23 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions crates/sui-json/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,6 @@ impl SuiJsonValue {
Ok(Self(json_value))
}

pub fn new_unchecked(json_value: JsonValue) -> Result<SuiJsonValue, anyhow::Error> {
Ok(Self(json_value))
}

fn check_value(json_value: &JsonValue) -> Result<(), anyhow::Error> {
match json_value {
// No checks needed for Bool and String
Expand Down Expand Up @@ -399,7 +395,7 @@ fn json_value_to_sui_address(value: &JsonValue) -> anyhow::Result<SuiAddress> {
}
}

pub fn move_value_to_json(move_value: &MoveValue) -> Option<JsonValue> {
fn move_value_to_json(move_value: &MoveValue) -> Option<JsonValue> {
Some(match move_value {
MoveValue::Vector(values) => JsonValue::Array(
values
Expand Down
1 change: 0 additions & 1 deletion crates/sui-light-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ serde_json.workspace = true
sui-types.workspace = true
sui-config.workspace = true
sui-rest-api.workspace = true
sui-json.workspace = true
sui-sdk.workspace = true
move-binary-format.workspace = true
sui-json-rpc-types.workspace = true
Expand Down
21 changes: 6 additions & 15 deletions crates/sui-light-client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use sui_types::{

use sui_config::genesis::Genesis;

use sui_json::{move_value_to_json, SuiJsonValue};
use sui_package_resolver::Result as ResolverResult;
use sui_package_resolver::{Package, PackageStore, Resolver};
use sui_sdk::SuiClientBuilder;
Expand Down Expand Up @@ -141,7 +140,6 @@ async fn query_last_checkpoint_of_epoch(config: &Config, epoch_id: u64) -> anyho
.await
.expect("Cannot connect to graphql")
.text()
// .json::<HashMap<String, String>>()
.await
.expect("Cannot parse response");

Expand Down Expand Up @@ -417,12 +415,10 @@ async fn get_verified_effects_and_events(
config: &Config,
tid: TransactionDigest,
) -> anyhow::Result<(TransactionEffects, Option<TransactionEvents>)> {
let sui_mainnet: Arc<sui_sdk::SuiClient> = Arc::new(
SuiClientBuilder::default()
.build(config.full_node_url.as_str())
.await
.unwrap(),
);
let sui_mainnet: sui_sdk::SuiClient = SuiClientBuilder::default()
.build(config.full_node_url.as_str())
.await
.unwrap();
let read_api = sui_mainnet.read_api();

// Lookup the transaction id and get the checkpoint sequence number
Expand Down Expand Up @@ -560,17 +556,14 @@ pub async fn main() {

let result = BoundedVisitor::deserialize_value(&event.contents, &type_layout)
.expect("Cannot deserialize");
let json = move_value_to_json(&result).expect("Cannot convert to json");
let json_val =
SuiJsonValue::new_unchecked(json).expect("Cannot convert to json");

println!(
"Event:\n - Package: {}\n - Module: {}\n - Sender: {}\n - Type: {}\n{}",
event.package_id,
event.transaction_module,
event.sender,
event.type_,
serde_json::to_string_pretty(&json_val.to_json_value()).unwrap()
serde_json::to_string_pretty(&result).unwrap()
);
}
} else {
Expand All @@ -592,8 +585,6 @@ pub async fn main() {
let result =
BoundedVisitor::deserialize_value(move_object.contents(), &type_layout)
.expect("Cannot deserialize");
let json = move_value_to_json(&result).expect("Cannot convert to json");
let json_val = SuiJsonValue::new_unchecked(json).expect("Cannot convert to json");

let (oid, version, hash) = object.compute_object_reference();
println!(
Expand All @@ -603,7 +594,7 @@ pub async fn main() {
hash,
object.owner,
object_type,
serde_json::to_string_pretty(&json_val.to_json_value()).unwrap()
serde_json::to_string_pretty(&result).unwrap()
);
}
}
Expand Down
5 changes: 4 additions & 1 deletion crates/sui-light-client/src/proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use anyhow::anyhow;

use serde::{Deserialize, Serialize};
use sui_types::{
base_types::ObjectRef,
committee::Committee,
Expand All @@ -14,7 +15,7 @@ use sui_types::{
};

/// Define aspect of Sui state that need to be certified in a proof
#[derive(Default)]
#[derive(Default, Debug, Serialize, Deserialize)]
pub struct ProofTarget {
/// Objects that need to be certified
pub objects: Vec<(ObjectRef, Object)>,
Expand Down Expand Up @@ -58,6 +59,7 @@ impl ProofTarget {

/// Part of a Proof that provides evidence relating to a specific transaction to
/// certify objects and events.
#[derive(Debug, Serialize, Deserialize)]
pub struct TransactionProof {
/// Checkpoint contents including this transaction.
pub checkpoint_contents: CheckpointContents,
Expand All @@ -74,6 +76,7 @@ pub struct TransactionProof {

/// A proof for specific targets. It certifies a checkpoint summary and optionally includes
/// transaction evidence to certify objects and events.
#[derive(Debug, Serialize, Deserialize)]
pub struct Proof {
/// Targets of the proof are objects, events or a committee that need to be certified
pub targets: ProofTarget,
Expand Down

0 comments on commit 531a402

Please sign in to comment.