Skip to content
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
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.

20 changes: 13 additions & 7 deletions crates/sui-core/src/unit_tests/authority_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ use move_binary_format::{
};
use move_core_types::identifier::IdentStr;
use move_core_types::language_storage::StructTag;
use move_core_types::parser::parse_type_tag;
use move_core_types::{
account_address::AccountAddress, ident_str, identifier::Identifier, language_storage::TypeTag,
};
Expand All @@ -24,6 +23,7 @@ use rand::{
use serde_json::json;
use std::collections::HashSet;
use std::fs;
use std::str::FromStr;
use std::{convert::TryInto, env};

use sui_json_rpc_types::{
Expand Down Expand Up @@ -3674,7 +3674,7 @@ async fn test_dynamic_field_struct_name_parsing() {
assert!(matches!(fields[0].type_, DynamicFieldType::DynamicField));
assert_eq!(json!({"name_str": "Test Name"}), fields[0].name.value);
assert_eq!(
parse_type_tag("0x0::object_basics::Name").unwrap(),
TypeTag::from_str("0x0::object_basics::Name").unwrap(),
fields[0].name.type_
)
}
Expand All @@ -3686,7 +3686,10 @@ async fn test_dynamic_field_bytearray_name_parsing() {

assert_eq!(fields.len(), 1);
assert!(matches!(fields[0].type_, DynamicFieldType::DynamicField));
assert_eq!(parse_type_tag("vector<u8>").unwrap(), fields[0].name.type_);
assert_eq!(
TypeTag::from_str("vector<u8>").unwrap(),
fields[0].name.type_
);
assert_eq!(json!("Test Name".as_bytes()), fields[0].name.value);
}

Expand All @@ -3697,7 +3700,7 @@ async fn test_dynamic_field_address_name_parsing() {

assert_eq!(fields.len(), 1);
assert!(matches!(fields[0].type_, DynamicFieldType::DynamicField));
assert_eq!(parse_type_tag("address").unwrap(), fields[0].name.type_);
assert_eq!(TypeTag::from_str("address").unwrap(), fields[0].name.type_);
assert_eq!(json!(sender), fields[0].name.value);
}

Expand All @@ -3709,7 +3712,7 @@ async fn test_dynamic_object_field_struct_name_parsing() {
assert!(matches!(fields[0].type_, DynamicFieldType::DynamicObject));
assert_eq!(json!({"name_str": "Test Name"}), fields[0].name.value);
assert_eq!(
parse_type_tag("0x0::object_basics::Name").unwrap(),
TypeTag::from_str("0x0::object_basics::Name").unwrap(),
fields[0].name.type_
)
}
Expand All @@ -3721,7 +3724,10 @@ async fn test_dynamic_object_field_bytearray_name_parsing() {

assert_eq!(fields.len(), 1);
assert!(matches!(fields[0].type_, DynamicFieldType::DynamicObject));
assert_eq!(parse_type_tag("vector<u8>").unwrap(), fields[0].name.type_);
assert_eq!(
TypeTag::from_str("vector<u8>").unwrap(),
fields[0].name.type_
);
assert_eq!(json!("Test Name".as_bytes()), fields[0].name.value);
}

Expand All @@ -3732,7 +3738,7 @@ async fn test_dynamic_object_field_address_name_parsing() {

assert_eq!(fields.len(), 1);
assert!(matches!(fields[0].type_, DynamicFieldType::DynamicObject));
assert_eq!(parse_type_tag("address").unwrap(), fields[0].name.type_);
assert_eq!(TypeTag::from_str("address").unwrap(), fields[0].name.type_);
assert_eq!(json!(sender), fields[0].name.value);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ Response: {
"data": null,
"errors": [
{
"message": "Bad type: unexpected token Name(\"not_a_type\"), expected type tag",
"message": "Bad type: unexpected end of tokens",
"locations": [
{
"line": 3,
Expand Down
4 changes: 2 additions & 2 deletions crates/sui-replay/src/data_fetcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::types::EPOCH_CHANGE_STRUCT_TAG;
use async_trait::async_trait;
use futures::future::join_all;
use lru::LruCache;
use move_core_types::parser::parse_struct_tag;
use move_core_types::language_storage::StructTag;
use parking_lot::RwLock;
use rand::Rng;
use std::collections::BTreeMap;
Expand Down Expand Up @@ -568,7 +568,7 @@ impl DataFetcher for RemoteFetcher {
reverse: bool,
) -> Result<Vec<SuiEvent>, ReplayEngineError> {
let struct_tag_str = EPOCH_CHANGE_STRUCT_TAG.to_string();
let struct_tag = parse_struct_tag(&struct_tag_str)?;
let struct_tag = StructTag::from_str(&struct_tag_str)?;

let mut epoch_change_events: Vec<SuiEvent> = vec![];
let mut has_next_page = true;
Expand Down
9 changes: 6 additions & 3 deletions crates/sui-transactional-test-runner/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ use crate::test_adapter::{FakeID, SuiTestAdapter};
use anyhow::{bail, ensure};
use clap;
use clap::{Args, Parser};
use move_command_line_common::parser::{parse_u256, parse_u64};
use move_command_line_common::values::{ParsableValue, ParsedValue};
use move_command_line_common::{parser::Parser as MoveCLParser, values::ValueToken};
use move_compiler::editions::Flavor;
use move_core_types::parsing::{
parser::Parser as MoveCLParser,
parser::{parse_u256, parse_u64},
values::ValueToken,
values::{ParsableValue, ParsedValue},
};
use move_core_types::runtime_value::{MoveStruct, MoveValue};
use move_core_types::u256::U256;
use move_symbol_pool::Symbol;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use std::{borrow::BorrowMut, marker::PhantomData, str::FromStr};

use move_command_line_common::{
use move_core_types::parsing::{
parser::{Parser, Token},
types::{ParsedType, TypeToken},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
use std::fmt::{self, Display};

use anyhow::bail;
use move_command_line_common::parser::Token;
use move_core_types::identifier;
use move_core_types::parsing::parser::Token;

#[derive(Eq, PartialEq, Debug, Clone, Copy)]
pub enum CommandToken {
Expand Down
5 changes: 2 additions & 3 deletions crates/sui-transactional-test-runner/src/test_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@ use fastcrypto::encoding::{Base64, Encoding};
use fastcrypto::traits::ToFromBytes;
use move_binary_format::CompiledModule;
use move_bytecode_utils::module_cache::GetModule;
use move_command_line_common::{
address::ParsedAddress, files::verify_and_create_named_address_mapping,
};
use move_command_line_common::files::verify_and_create_named_address_mapping;
use move_compiler::{
editions::{Edition, Flavor},
shared::{NumberFormat, NumericalAddress, PackageConfig, PackagePaths},
Flags, FullyCompiledProgram,
};
use move_core_types::ident_str;
use move_core_types::parsing::address::ParsedAddress;
use move_core_types::{
account_address::AccountAddress,
identifier::IdentStr,
Expand Down
10 changes: 5 additions & 5 deletions crates/sui-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ pub fn sui_framework_address_concat_string(suffix: &str) -> String {
/// Parsing succeeds if and only if `s` matches one of these formats exactly, with no remaining
/// suffix. This function is intended for use within the authority codebases.
pub fn parse_sui_address(s: &str) -> anyhow::Result<SuiAddress> {
use move_command_line_common::address::ParsedAddress;
use move_core_types::parsing::address::ParsedAddress;
Ok(ParsedAddress::parse(s)?
.into_account_address(&resolve_address)?
.into())
Expand All @@ -163,7 +163,7 @@ pub fn parse_sui_address(s: &str) -> anyhow::Result<SuiAddress> {
/// module name (an identifier). Parsing succeeds if and only if `s` matches this format exactly,
/// with no remaining input. This function is intended for use within the authority codebases.
pub fn parse_sui_module_id(s: &str) -> anyhow::Result<ModuleId> {
use move_command_line_common::types::ParsedModuleId;
use move_core_types::parsing::types::ParsedModuleId;
ParsedModuleId::parse(s)?.into_module_id(&resolve_address)
}

Expand All @@ -172,7 +172,7 @@ pub fn parse_sui_module_id(s: &str) -> anyhow::Result<ModuleId> {
/// format exactly, with no remaining input. This function is intended for use within the authority
/// codebases.
pub fn parse_sui_fq_name(s: &str) -> anyhow::Result<(ModuleId, String)> {
use move_command_line_common::types::ParsedFqName;
use move_core_types::parsing::types::ParsedFqName;
ParsedFqName::parse(s)?.into_fq_name(&resolve_address)
}

Expand All @@ -181,15 +181,15 @@ pub fn parse_sui_fq_name(s: &str) -> anyhow::Result<(ModuleId, String)> {
/// brackets). Parsing succeeds if and only if `s` matches this format exactly, with no remaining
/// input. This function is intended for use within the authority codebase.
pub fn parse_sui_struct_tag(s: &str) -> anyhow::Result<StructTag> {
use move_command_line_common::types::ParsedStructType;
use move_core_types::parsing::types::ParsedStructType;
ParsedStructType::parse(s)?.into_struct_tag(&resolve_address)
}

/// Parse `s` as a type: Either a struct type (see `parse_sui_struct_tag`), a primitive type, or a
/// vector with a type parameter. Parsing succeeds if and only if `s` matches this format exactly,
/// with no remaining input. This function is intended for use within the authority codebase.
pub fn parse_sui_type_tag(s: &str) -> anyhow::Result<TypeTag> {
use move_command_line_common::types::ParsedType;
use move_core_types::parsing::types::ParsedType;
ParsedType::parse(s)?.into_type_tag(&resolve_address)
}

Expand Down
2 changes: 1 addition & 1 deletion crates/sui/src/client_ptb/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use std::fmt;

use move_command_line_common::{
use move_core_types::parsing::{
address::{NumericalAddress, ParsedAddress},
types::{ParsedFqName, ParsedModuleId, ParsedStructType, ParsedType},
};
Expand Down
2 changes: 1 addition & 1 deletion crates/sui/src/client_ptb/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use miette::Severity;
use move_binary_format::{
binary_config::BinaryConfig, file_format::SignatureToken, CompiledModule,
};
use move_command_line_common::{
use move_core_types::parsing::{
address::{NumericalAddress, ParsedAddress},
parser::NumberFormat,
};
Expand Down
2 changes: 1 addition & 1 deletion crates/sui/src/client_ptb/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

use std::iter::Peekable;

use move_command_line_common::{
use move_core_types::parsing::{
address::{NumericalAddress, ParsedAddress},
parser::{parse_u128, parse_u16, parse_u256, parse_u32, parse_u64, parse_u8},
types::{ParsedFqName, ParsedModuleId, ParsedStructType, ParsedType},
Expand Down
1 change: 0 additions & 1 deletion external-crates/move/Cargo.lock

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

14 changes: 8 additions & 6 deletions external-crates/move/crates/move-cli/src/sandbox/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ use crate::{
};
use anyhow::Result;
use clap::Parser;
use move_core_types::{
language_storage::TypeTag, parser, transaction_argument::TransactionArgument,
};
use move_core_types::parsing::values::ParsedValue;
use move_core_types::{language_storage::TypeTag, transaction_argument::TransactionArgument};
use move_package::compilation::package_layout::CompiledPackageLayout;
use move_vm_test_utils::gas_schedule::CostTable;
use std::{
fs,
path::{Path, PathBuf},
};
fn parse_transaction_argument(s: &str) -> Result<TransactionArgument> {
let x: ParsedValue<()> = ParsedValue::parse(s)?;
let move_value = x.into_concrete_value(&|_| None)?;
TransactionArgument::try_from(move_value)
}

#[derive(Parser)]
pub enum SandboxCommand {
Expand Down Expand Up @@ -75,7 +79,7 @@ pub enum SandboxCommand {
/// ASCII strings (e.g., 'b"hi" will parse as the vector<u8> value [68, 69]).
#[clap(
long = "args",
value_parser = parser::parse_transaction_argument,
value_parser = parse_transaction_argument,
num_args(1..),
action = clap::ArgAction::Append,
)]
Expand All @@ -84,7 +88,6 @@ pub enum SandboxCommand {
/// `main<T>()`). Must match the type arguments kinds expected by `script_file`.
#[clap(
long = "type-args",
value_parser = parser::parse_type_tag,
num_args(1..),
action = clap::ArgAction::Append,
)]
Expand Down Expand Up @@ -155,7 +158,6 @@ pub struct StructLayoutOptions {
/// Generate layout bindings for `struct` bound to these type arguments.
#[clap(
long = "type-args",
value_parser = parser::parse_type_tag,
requires="struct",
action = clap::ArgAction::Append,
num_args(1..),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ difference.workspace = true
walkdir.workspace = true
sha2.workspace = true
hex.workspace = true
num-bigint.workspace = true
once_cell.workspace = true
serde.workspace = true
dirs-next.workspace = true
Expand All @@ -27,9 +26,3 @@ move-binary-format.workspace = true

[dev-dependencies]
proptest.workspace = true
# Ok to do this since:
# edition = 2021 ==> resolver = 2
# * https://doc.rust-lang.org/edition-guide/rust-2021/default-cargo-resolver.html#summary
# resolver = 2 ==> feature-resolver-version-2 which allows dev-dependencies to set features
# * https://doc.rust-lang.org/cargo/reference/resolver.html#feature-resolver-version-2
move-core-types = { workspace = true, features = ["fuzzing"] }
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@

#![forbid(unsafe_code)]

pub mod address;
pub mod character_sets;
pub mod display;
pub mod env;
pub mod error_bitset;
pub mod files;
pub mod interactive;
pub mod parser;
pub mod testing;
pub mod types;
pub mod values;
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ use crate::{
},
FullyCompiledProgram,
};
use move_command_line_common::parser::{parse_u16, parse_u256, parse_u32};
use move_core_types::account_address::AccountAddress;
use move_core_types::parsing::parser::{parse_u16, parse_u256, parse_u32};
use move_ir_types::location::*;
use move_proc_macros::growing_stack;
use move_symbol_pool::Symbol;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::{
unit_test::filter_test_members::UNIT_TEST_POISON_FUN_NAME,
};

use move_command_line_common::address::NumericalAddress;
use move_core_types::parsing::address::NumericalAddress;
use move_ir_types::location::Loc;
use move_symbol_pool::Symbol;

Expand Down
4 changes: 2 additions & 2 deletions external-crates/move/crates/move-compiler/src/shared/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub use ast_debug::AstDebug;
// Numbers
//**************************************************************************************************

pub use move_command_line_common::parser::{
pub use move_core_types::parsing::parser::{
parse_address_number as parse_address, parse_u128, parse_u16, parse_u256, parse_u32, parse_u64,
parse_u8, NumberFormat,
};
Expand All @@ -71,7 +71,7 @@ pub use move_command_line_common::parser::{
// Address
//**************************************************************************************************

pub use move_command_line_common::address::NumericalAddress;
pub use move_core_types::parsing::address::NumericalAddress;

pub fn parse_named_address(s: &str) -> anyhow::Result<(String, NumericalAddress)> {
let before_after = s.split('=').collect::<Vec<_>>();
Expand Down
Loading
Loading