Skip to content

Commit

Permalink
sui-json: move sui-json into its own crate
Browse files Browse the repository at this point in the history
  • Loading branch information
bmwill committed May 23, 2022
1 parent 9181192 commit 9fd648f
Show file tree
Hide file tree
Showing 18 changed files with 65 additions and 21 deletions.
20 changes: 20 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ members = [
"crates/sui-adapter-transactional-tests",
"crates/sui-config",
"crates/sui-faucet",
"crates/sui-json",
"crates/sui-network",
"crates/sui-node",
"crates/sui-transactional-test-runner",
Expand Down
26 changes: 26 additions & 0 deletions crates/sui-json/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "sui-json"
version = "0.0.0"
authors = ["Mysten Labs <[email protected]>"]
license = "Apache-2.0"
publish = false
edition = "2021"

[dependencies]
anyhow = { version = "1.0.57", features = ["backtrace"] }
bcs = "0.1.3"
hex = "0.4.3"
serde = { version = "1.0.137", features = ["derive"] }
serde_json = "1.0.79"
schemars = "0.8.8"

sui-types = { path = "../sui-types" }

move-binary-format = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" }
move-core-types = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b", features = ["address20"] }

[dev-dependencies]
test-fuzz = "3.0.2"

sui-adapter = { path = "../sui-adapter" }
sui-framework = { path = "../../sui_programmability/framework" }
10 changes: 3 additions & 7 deletions sui_core/src/sui_json.rs → crates/sui-json/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

use std::collections::VecDeque;
use std::fmt::{Debug, Formatter};

use anyhow::{anyhow, bail};
// Alias the type names for clarity
use move_binary_format::{
access::ModuleAccess,
file_format::{SignatureToken, Visibility},
Expand All @@ -18,15 +14,15 @@ use move_core_types::{
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use serde_json::{json, Number, Value as JsonValue};

use std::collections::VecDeque;
use std::fmt::{Debug, Formatter};
use sui_types::base_types::{decode_bytes_hex, ObjectID, SuiAddress};
use sui_types::move_package::MovePackage;

const HEX_PREFIX: &str = "0x";

#[cfg(test)]
#[path = "unit_tests/sui_json.rs"]
mod base_types_tests;
mod tests;

#[derive(Eq, PartialEq, Debug, Clone)]
pub enum SuiJsonCallArg {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ use sui_types::base_types::{ObjectID, SuiAddress, TransactionDigest};
use sui_types::object::Object;
use sui_types::SUI_FRAMEWORK_ADDRESS;

use crate::sui_json::{resolve_move_function_args, SuiJsonCallArg, SuiJsonValue};

use super::{is_homogeneous, HEX_PREFIX};
use super::{resolve_move_function_args, SuiJsonCallArg, SuiJsonValue};

#[test]
fn test_json_is_homogeneous() {
Expand Down Expand Up @@ -290,7 +289,8 @@ fn test_basic_args_linter_pure_args() {

#[test]
fn test_basic_args_linter_top_level() {
let path = Path::new(env!("CARGO_MANIFEST_DIR")).join("../sui_programmability/examples/nfts");
let path =
Path::new(env!("CARGO_MANIFEST_DIR")).join("../../sui_programmability/examples/nfts");
let compiled_modules = sui_framework::build_and_verify_user_package(&path).unwrap();
let example_package = Object::new_package(compiled_modules, TransactionDigest::genesis());
let example_package = example_package.data.try_as_package().unwrap();
Expand Down
1 change: 1 addition & 0 deletions sui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ sui-types = { path = "../crates/sui-types" }
sui-verifier = { path = "../crates/sui-verifier" }
sui-open-rpc = { path = "open_rpc" }
sui-open-rpc-macros = { path = "open_rpc/macros" }
sui-json = { path = "../crates/sui-json" }

rustyline = "9.1.2"
rustyline-derive = "0.6.0"
Expand Down
2 changes: 1 addition & 1 deletion sui/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use serde_with::serde_as;
use sui_core::gateway_state::GatewayTxSeqNumber;
use sui_core::gateway_types::{GetObjectInfoResponse, SuiInputObjectKind, SuiObjectRef};
use sui_core::gateway_types::{TransactionEffectsResponse, TransactionResponse};
use sui_core::sui_json::SuiJsonValue;
use sui_json::SuiJsonValue;
use sui_open_rpc_macros::open_rpc;
use sui_types::sui_serde::Base64;
use sui_types::{
Expand Down
2 changes: 1 addition & 1 deletion sui/src/generate_json_rpc_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use sui::wallet_commands::{EXAMPLE_NFT_DESCRIPTION, EXAMPLE_NFT_NAME, EXAMPLE_NF
use sui_core::gateway_types::{
GetObjectInfoResponse, SuiObjectRef, TransactionEffectsResponse, TransactionResponse,
};
use sui_core::sui_json::SuiJsonValue;
use sui_json::SuiJsonValue;
use sui_types::base_types::{ObjectID, SuiAddress};
use sui_types::SUI_FRAMEWORK_ADDRESS;
use test_utils::network::start_test_network;
Expand Down
2 changes: 1 addition & 1 deletion sui/src/rpc_gateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use tracing::debug;

use sui_core::gateway_state::{GatewayClient, GatewayState, GatewayTxSeqNumber};
use sui_core::gateway_types::GetObjectInfoResponse;
use sui_core::sui_json::SuiJsonValue;
use sui_json::SuiJsonValue;
use sui_types::sui_serde::Base64;
use sui_types::{
base_types::{ObjectID, SuiAddress, TransactionDigest},
Expand Down
2 changes: 1 addition & 1 deletion sui/src/rpc_gateway_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use sui_core::gateway_state::{GatewayAPI, GatewayTxSeqNumber};
use sui_core::gateway_types::{
GetObjectInfoResponse, SuiObjectRef, TransactionEffectsResponse, TransactionResponse,
};
use sui_core::sui_json::SuiJsonValue;
use sui_json::SuiJsonValue;
use sui_types::base_types::{ObjectID, SuiAddress, TransactionDigest};
use sui_types::messages::{Transaction, TransactionData};
use sui_types::sui_serde::Base64;
Expand Down
2 changes: 1 addition & 1 deletion sui/src/sui_full_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ use sui_core::{
gateway_types::{
GetObjectInfoResponse, SuiObjectRef, TransactionEffectsResponse, TransactionResponse,
},
sui_json::SuiJsonValue,
};
use sui_core::{authority_client::NetworkAuthorityClient, gateway_state::GatewayTxSeqNumber};
use sui_json::SuiJsonValue;
use sui_types::base_types::{ObjectID, SuiAddress, TransactionDigest};
use tracing::info;

Expand Down
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 @@ -19,7 +19,7 @@ use sui::{
};
use sui_config::{AccountConfig, GenesisConfig, NetworkConfig, ObjectConfig};
use sui_core::gateway_types::{GetObjectInfoResponse, SuiObject, SuiTransactionEffects};
use sui_core::sui_json::SuiJsonValue;
use sui_json::SuiJsonValue;
use sui_types::{
base_types::{ObjectID, SequenceNumber, SuiAddress},
crypto::get_key_pair,
Expand Down
2 changes: 1 addition & 1 deletion sui/src/unit_tests/rpc_server_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ use sui_core::gateway_state::GatewayTxSeqNumber;
use sui_core::gateway_types::{
GetObjectInfoResponse, TransactionEffectsResponse, TransactionResponse,
};
use sui_core::sui_json::SuiJsonValue;
use sui_framework::build_move_package_to_bytes;
use sui_json::SuiJsonValue;
use sui_types::sui_serde::Base64;
use sui_types::{
base_types::{ObjectID, SuiAddress, TransactionDigest},
Expand Down
2 changes: 1 addition & 1 deletion sui/src/wallet_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ use sui_core::gateway_types::{
GetObjectInfoResponse, SuiCertifiedTransaction, SuiExecutionStatus, SuiObject, SuiObjectRef,
SuiTransactionEffects,
};
use sui_core::sui_json::SuiJsonValue;
use sui_framework::build_move_package_to_bytes;
use sui_json::SuiJsonValue;
use sui_types::{
base_types::{ObjectID, SuiAddress},
gas_coin::GasCoin,
Expand Down
1 change: 1 addition & 0 deletions sui_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ sui-network = { path = "../crates/sui-network" }
sui-types = { path = "../crates/sui-types" }
sui_storage = { path = "../sui_storage" }
sui-config = { path = "../crates/sui-config" }
sui-json = { path = "../crates/sui-json" }

move-binary-format = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" }
move-bytecode-utils = { git = "https://github.com/move-language/move", rev = "1b2d3b4274345f5b4b6a1a1bde5aee452003ab5b" }
Expand Down
2 changes: 1 addition & 1 deletion sui_core/src/gateway_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ use sui_types::{
SUI_FRAMEWORK_ADDRESS,
};

use crate::sui_json::{resolve_move_function_args, SuiJsonCallArg, SuiJsonValue};
use crate::transaction_input_checker;
use crate::{
authority::GatewayStore, authority_aggregator::AuthorityAggregator,
authority_client::AuthorityAPI,
};
use sui_json::{resolve_move_function_args, SuiJsonCallArg, SuiJsonValue};

use crate::gateway_types::*;

Expand Down
2 changes: 1 addition & 1 deletion sui_core/src/gateway_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use sui_types::move_package::disassemble_modules;
use sui_types::object::{Data, Object, ObjectRead, Owner};
use sui_types::sui_serde::{Base64, Encoding};

use crate::sui_json::SuiJsonValue;
use sui_json::SuiJsonValue;

#[cfg(test)]
#[path = "unit_tests/gateway_types_tests.rs"]
Expand Down
1 change: 0 additions & 1 deletion sui_core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ pub mod gateway_state;
pub mod gateway_types;
pub mod make;
pub mod safe_client;
pub mod sui_json;
pub mod transaction_input_checker;

0 comments on commit 9fd648f

Please sign in to comment.