diff --git a/crates/sui/src/client_ptb/ast.rs b/crates/sui/src/client_ptb/ast.rs index bee05a09f9ad8..effa26e0a9603 100644 --- a/crates/sui/src/client_ptb/ast.rs +++ b/crates/sui/src/client_ptb/ast.rs @@ -8,9 +8,12 @@ use move_command_line_common::{ types::{ParsedFqName, ParsedModuleId, ParsedStructType, ParsedType}, }; use move_core_types::runtime_value::MoveValue; -use sui_types::{base_types::ObjectID, Identifier}; +use sui_types::{ + base_types::{ObjectID, RESOLVED_ASCII_STR, RESOLVED_STD_OPTION, RESOLVED_UTF8_STR}, + Identifier, TypeTag, +}; -use crate::{error, sp}; +use crate::{err, error, sp}; use super::error::{PTBResult, Span, Spanned}; @@ -148,6 +151,7 @@ pub enum Argument { U64(u64), U128(u128), U256(move_core_types::u256::U256), + InferredNum(move_core_types::u256::U256), Gas, Identifier(String), VariableAccess(Spanned, Vec>), @@ -158,6 +162,72 @@ pub enum Argument { } impl Argument { + /// Resolve an `Argument` into a `MoveValue` if possible. Errors if the `Argument` is not + /// convertible to a `MoveValue` of the provided `tag`. + pub fn checked_to_pure_move_value(&self, loc: Span, tag: &TypeTag) -> PTBResult { + Ok(match (self, tag) { + (Argument::Bool(b), TypeTag::Bool) => MoveValue::Bool(*b), + (Argument::U8(u), TypeTag::U8) => MoveValue::U8(*u), + (Argument::U16(u), TypeTag::U16) => MoveValue::U16(*u), + (Argument::U32(u), TypeTag::U32) => MoveValue::U32(*u), + (Argument::U64(u), TypeTag::U64) => MoveValue::U64(*u), + (Argument::U128(u), TypeTag::U128) => MoveValue::U128(*u), + (Argument::U256(u), TypeTag::U256) => MoveValue::U256(*u), + // Inferred numbers, unless they need to be used as a specific type default to u64. + (Argument::InferredNum(u), tag) => Self::cast_inferrred_num(*u, tag, loc)?, + (Argument::Address(a), TypeTag::Address) => MoveValue::Address(a.into_inner()), + (Argument::Vector(vs), TypeTag::Vector(ty)) => MoveValue::Vector( + vs.iter() + .map(|sp!(loc, v)| v.checked_to_pure_move_value(*loc, ty)) + .collect::>>() + .map_err(|e| { + e.with_help("Literal vectors cannot contain object values.".to_string()) + })?, + ), + (Argument::String(s), TypeTag::Vector(ty)) if **ty == TypeTag::U8 => { + MoveValue::Vector(s.bytes().map(MoveValue::U8).collect::>()) + } + (Argument::String(s), TypeTag::Struct(stag)) + if { + let resolved = ( + &stag.address, + stag.module.as_ident_str(), + stag.name.as_ident_str(), + ); + resolved == RESOLVED_ASCII_STR || resolved == RESOLVED_UTF8_STR + } => + { + MoveValue::Vector(s.bytes().map(MoveValue::U8).collect::>()) + } + (Argument::Option(sp!(loc, o)), TypeTag::Struct(stag)) + if ( + &stag.address, + stag.module.as_ident_str(), + stag.name.as_ident_str(), + ) == RESOLVED_STD_OPTION + && stag.type_params.len() == 1 => + { + if let Some(v) = o { + let v = v + .as_ref() + .checked_to_pure_move_value(*loc, &stag.type_params[0]) + .map_err(|e| { + e.with_help( + "Literal option values cannot contain object values.".to_string(), + ) + })?; + MoveValue::Vector(vec![v]) + } else { + MoveValue::Vector(vec![]) + } + } + (Argument::Identifier(_) | Argument::VariableAccess(_, _) | Argument::Gas, _) => { + error!(loc, "Unable to convert '{self}' to non-object value.") + } + (arg, tag) => error!(loc, "Unable to serialize '{arg}' as a {tag} value"), + }) + } + /// Resolve an `Argument` into a `MoveValue` if possible. Errors if the `Argument` is not /// convertible to a `MoveValue`. pub fn to_pure_move_value(&self, loc: Span) -> PTBResult { @@ -169,6 +239,8 @@ impl Argument { Argument::U64(u) => MoveValue::U64(*u), Argument::U128(u) => MoveValue::U128(*u), Argument::U256(u) => MoveValue::U256(*u), + // Inferred numbers, unless they need to be used as a specific type default to u64. + Argument::InferredNum(u) => Self::cast_inferrred_num(*u, &TypeTag::U64, loc)?, Argument::Address(a) => MoveValue::Address(a.into_inner()), Argument::Vector(vs) => MoveValue::Vector( vs.iter() @@ -198,6 +270,32 @@ impl Argument { } }) } + + fn cast_inferrred_num( + val: move_core_types::u256::U256, + tag: &TypeTag, + loc: Span, + ) -> PTBResult { + match tag { + TypeTag::U8 => u8::try_from(val) + .map(MoveValue::U8) + .map_err(|_| err!(loc, "Value {val} is too large to be a u8 value")), + TypeTag::U16 => u16::try_from(val) + .map(MoveValue::U16) + .map_err(|_| err!(loc, "Value {val} is too large to be a u16 value")), + TypeTag::U32 => u32::try_from(val) + .map(MoveValue::U32) + .map_err(|_| err!(loc, "Value {val} is too large to be a u32 value")), + TypeTag::U64 => u64::try_from(val) + .map(MoveValue::U64) + .map_err(|_| err!(loc, "Value {val} is too large to be a u64 value")), + TypeTag::U128 => u128::try_from(val) + .map(MoveValue::U128) + .map_err(|_| err!(loc, "Value {val} is too large to be a u128 value")), + TypeTag::U256 => Ok(MoveValue::U256(val)), + _ => error!(loc, "Expected an integer type but got {tag} for '{val}'"), + } + } } impl fmt::Display for Argument { @@ -210,6 +308,7 @@ impl fmt::Display for Argument { Argument::U64(u) => write!(f, "{u}u64"), Argument::U128(u) => write!(f, "{u}u128"), Argument::U256(u) => write!(f, "{u}u256"), + Argument::InferredNum(u) => write!(f, "{u}"), Argument::Gas => write!(f, "gas"), Argument::Identifier(i) => write!(f, "{i}"), Argument::VariableAccess(sp!(_, head), accesses) => { diff --git a/crates/sui/src/client_ptb/builder.rs b/crates/sui/src/client_ptb/builder.rs index e9182c31f528f..dd911567c4af5 100644 --- a/crates/sui/src/client_ptb/builder.rs +++ b/crates/sui/src/client_ptb/builder.rs @@ -20,7 +20,9 @@ use move_command_line_common::{ address::{NumericalAddress, ParsedAddress}, parser::NumberFormat, }; -use move_core_types::{account_address::AccountAddress, ident_str, runtime_value::MoveValue}; +use move_core_types::{ + account_address::AccountAddress, annotated_value::MoveTypeLayout, ident_str, +}; use move_package::BuildConfig; use std::{collections::BTreeMap, path::PathBuf}; use sui_json::{is_receiving_argument, primitive_type}; @@ -59,9 +61,10 @@ trait Resolver<'a>: Send { &mut self, builder: &mut PTBBuilder<'a>, loc: Span, - val: MoveValue, + argument: PTBArg, ) -> PTBResult { - builder.ptb.pure(val).map_err(|e| err!(loc, "{e}")) + let value = argument.to_pure_move_value(loc)?; + builder.ptb.pure(value).map_err(|e| err!(loc, "{e}")) } async fn resolve_object_id( @@ -147,10 +150,34 @@ impl<'a> Resolver<'a> for ToObject { } /// A resolver that resolves object IDs that it encounters to pure PTB values. -struct ToPure; +struct ToPure { + type_: TypeTag, +} + +impl ToPure { + pub fn new(type_: TypeTag) -> Self { + Self { type_ } + } + + pub fn new_from_layout(layout: MoveTypeLayout) -> Self { + Self { + type_: TypeTag::from(&layout), + } + } +} #[async_trait] impl<'a> Resolver<'a> for ToPure { + async fn pure( + &mut self, + builder: &mut PTBBuilder<'a>, + loc: Span, + argument: PTBArg, + ) -> PTBResult { + let value = argument.checked_to_pure_move_value(loc, &self.type_)?; + builder.ptb.pure(value).map_err(|e| err!(loc, "{e}")) + } + async fn resolve_object_id( &mut self, builder: &mut PTBBuilder<'a>, @@ -415,12 +442,14 @@ impl<'a> PTBBuilder<'a> { sp!(loc, arg): Spanned, param: &SignatureToken, ) -> PTBResult { - let (is_primitive, _) = primitive_type(view, ty_args, param); + let (is_primitive, layout) = primitive_type(view, ty_args, param); // If it's a primitive value, see if we've already resolved this argument. Otherwise, we // need to resolve it. if is_primitive { - return self.resolve(loc.wrap(arg), ToPure).await; + return self + .resolve(loc.wrap(arg), ToPure::new_from_layout(layout.unwrap())) + .await; } // Otherwise it's ambiguous what the value should be, and we need to turn to the signature @@ -602,12 +631,10 @@ impl<'a> PTBBuilder<'a> { | PTBArg::U64(_) | PTBArg::U128(_) | PTBArg::U256(_) + | PTBArg::InferredNum(_) | PTBArg::String(_) | PTBArg::Option(_) - | PTBArg::Vector(_)) => { - ctx.pure(self, arg_loc, a.to_pure_move_value(arg_loc)?) - .await - } + | PTBArg::Vector(_)) => ctx.pure(self, arg_loc, a).await, PTBArg::Gas => Ok(Tx::Argument::GasCoin), // NB: the ordering of these lines is important so that shadowing is properly // supported. @@ -766,7 +793,9 @@ impl<'a> PTBBuilder<'a> { // let sp!(cmd_span, tok) = &command.name; match command { ParsedPTBCommand::TransferObjects(obj_args, to_address) => { - let to_arg = self.resolve(to_address, ToPure).await?; + let to_arg = self + .resolve(to_address, ToPure::new(TypeTag::Address)) + .await?; let mut transfer_args = vec![]; for o in obj_args.value.into_iter() { let arg = self.resolve(o, ToObject::default()).await?; @@ -804,7 +833,7 @@ impl<'a> PTBBuilder<'a> { let mut vec_args: Vec = vec![]; if is_primitive_type_tag(&ty_arg) { for arg in args.into_iter() { - let arg = self.resolve(arg, ToPure).await?; + let arg = self.resolve(arg, ToPure::new(ty_arg.clone())).await?; vec_args.push(arg); } } else { @@ -822,7 +851,7 @@ impl<'a> PTBBuilder<'a> { let coin = self.resolve(pre_coin, ToObject::default()).await?; let mut args = vec![]; for arg in amounts.into_iter() { - let arg = self.resolve(arg, ToPure).await?; + let arg = self.resolve(arg, ToPure::new(TypeTag::U64)).await?; args.push(arg); } let res = self.ptb.command(Tx::Command::SplitCoins(coin, args)); diff --git a/crates/sui/src/client_ptb/parser.rs b/crates/sui/src/client_ptb/parser.rs index a483ed84e352e..58766866848d7 100644 --- a/crates/sui/src/client_ptb/parser.rs +++ b/crates/sui/src/client_ptb/parser.rs @@ -360,6 +360,9 @@ impl<'a, I: Iterator> ProgramParser<'a, I> { fn parse_gas_budget(&mut self) -> PTBResult> { Ok(match self.parse_argument()? { sp!(sp, Argument::U64(u)) => sp.wrap(u), + sp!(sp, Argument::InferredNum(n)) => { + sp.wrap(u64::try_from(n).map_err(|_| err!(sp, "Value does not fit within a u64"))?) + } sp!(sp, _) => error!(sp, "Expected a u64 value"), }) } @@ -628,10 +631,10 @@ impl<'a, I: Iterator> ProgramParser<'a, I> { L(T::Ident, A::U128) => parse_num!(parse_u128, V::U128), L(T::Ident, A::U256) => parse_num!(parse_u256, V::U256), - // If there's no suffix, assume u64, and don't consume the peeked character. - _ => match parse_u64(contents.value) { - Ok((value, _)) => contents.span.wrap(V::U64(value)), - Err(e) => error!(contents.span, "{e}"), + // If there's no suffix, parse as `InferredNum`, and don't consume the peeked character. + _ => match parse_u256(contents.value) { + Ok((value, _)) => contents.span.wrap(V::InferredNum(value)), + Err(_) => error!(contents.span, "Invalid integer literal"), }, }) } diff --git a/crates/sui/src/client_ptb/snapshots/sui__client_ptb__parser__tests__parse_args.snap b/crates/sui/src/client_ptb/snapshots/sui__client_ptb__parser__tests__parse_args.snap index ae7627ae60cb0..e3b9d486aa25c 100644 --- a/crates/sui/src/client_ptb/snapshots/sui__client_ptb__parser__tests__parse_args.snap +++ b/crates/sui/src/client_ptb/snapshots/sui__client_ptb__parser__tests__parse_args.snap @@ -26,8 +26,10 @@ expression: parsed start: 0, end: 1, }, - value: U64( - 1, + value: InferredNum( + U256( + 1, + ), ), }, Spanned { @@ -35,8 +37,10 @@ expression: parsed start: 0, end: 5, }, - value: U64( - 1000, + value: InferredNum( + U256( + 1000, + ), ), }, Spanned { @@ -44,8 +48,10 @@ expression: parsed start: 0, end: 11, }, - value: U64( - 100000000, + value: InferredNum( + U256( + 100000000, + ), ), }, Spanned { @@ -80,8 +86,10 @@ expression: parsed start: 0, end: 3, }, - value: U64( - 1, + value: InferredNum( + U256( + 1, + ), ), }, Spanned { @@ -89,8 +97,10 @@ expression: parsed start: 0, end: 7, }, - value: U64( - 4096, + value: InferredNum( + U256( + 4096, + ), ), }, Spanned { @@ -98,8 +108,10 @@ expression: parsed start: 0, end: 13, }, - value: U64( - 4294967296, + value: InferredNum( + U256( + 4294967296, + ), ), }, Spanned { @@ -210,8 +222,10 @@ expression: parsed end: 6, }, value: Some( - U64( - 1, + InferredNum( + U256( + 1, + ), ), ), }, @@ -229,8 +243,10 @@ expression: parsed end: 8, }, value: Some( - U64( - 1, + InferredNum( + U256( + 1, + ), ), ), }, @@ -306,8 +322,10 @@ expression: parsed start: 7, end: 8, }, - value: U64( - 1, + value: InferredNum( + U256( + 1, + ), ), }, Spanned { @@ -315,8 +333,10 @@ expression: parsed start: 10, end: 11, }, - value: U64( - 2, + value: InferredNum( + U256( + 2, + ), ), }, Spanned { @@ -324,8 +344,10 @@ expression: parsed start: 13, end: 14, }, - value: U64( - 3, + value: InferredNum( + U256( + 3, + ), ), }, ], @@ -343,8 +365,10 @@ expression: parsed start: 7, end: 8, }, - value: U64( - 1, + value: InferredNum( + U256( + 1, + ), ), }, Spanned { @@ -352,8 +376,10 @@ expression: parsed start: 10, end: 11, }, - value: U64( - 2, + value: InferredNum( + U256( + 2, + ), ), }, Spanned { @@ -361,8 +387,10 @@ expression: parsed start: 13, end: 14, }, - value: U64( - 3, + value: InferredNum( + U256( + 3, + ), ), }, ], diff --git a/crates/sui/src/client_ptb/snapshots/sui__client_ptb__parser__tests__parse_commands.snap b/crates/sui/src/client_ptb/snapshots/sui__client_ptb__parser__tests__parse_commands.snap index bbb7ae7556809..d90e362c4bae7 100644 --- a/crates/sui/src/client_ptb/snapshots/sui__client_ptb__parser__tests__parse_commands.snap +++ b/crates/sui/src/client_ptb/snapshots/sui__client_ptb__parser__tests__parse_commands.snap @@ -1231,8 +1231,10 @@ expression: parsed start: 18, end: 19, }, - value: U64( - 1, + value: InferredNum( + U256( + 1, + ), ), }, Spanned { @@ -1240,8 +1242,10 @@ expression: parsed start: 21, end: 22, }, - value: U64( - 2, + value: InferredNum( + U256( + 2, + ), ), }, Spanned { @@ -1249,8 +1253,10 @@ expression: parsed start: 24, end: 25, }, - value: U64( - 3, + value: InferredNum( + U256( + 3, + ), ), }, ], @@ -1367,8 +1373,10 @@ expression: parsed end: 17, }, value: Some( - U64( - 1, + InferredNum( + U256( + 1, + ), ), ), }, diff --git a/crates/sui/src/client_ptb/snapshots/sui__client_ptb__parser__tests__parse_commands_invalid.snap b/crates/sui/src/client_ptb/snapshots/sui__client_ptb__parser__tests__parse_commands_invalid.snap index 3d12b177ad063..593eae6a151b4 100644 --- a/crates/sui/src/client_ptb/snapshots/sui__client_ptb__parser__tests__parse_commands_invalid.snap +++ b/crates/sui/src/client_ptb/snapshots/sui__client_ptb__parser__tests__parse_commands_invalid.snap @@ -336,7 +336,7 @@ expression: parsed ], [ PTBError { - message: "number too large to fit in target type", + message: "Value does not fit within a u64", span: Span { start: 13, end: 75, diff --git a/crates/sui/tests/ptb_files/inferrence/infer_correct_num_type.ptb b/crates/sui/tests/ptb_files/inferrence/infer_correct_num_type.ptb new file mode 100644 index 0000000000000..5466133065105 --- /dev/null +++ b/crates/sui/tests/ptb_files/inferrence/infer_correct_num_type.ptb @@ -0,0 +1,14 @@ +--make-move-vec [1,2,3,4] +--make-move-vec [1,2,3,4] +--make-move-vec [1,2,3,4] +--make-move-vec [1,2,3,4] +--make-move-vec [1,2,3,4] +--make-move-vec [1,2,3,4] +--make-move-vec > [vector[1,2,3,4]] +--make-move-vec > [vector[1,2,3,4]] +--make-move-vec > [vector[1,2,3,4]] +--make-move-vec > [vector[1,2,3,4]] +--make-move-vec > [vector[1,2,3,4]] +--make-move-vec > [vector[1,2,3,4]] +--make-move-vec <0x1::option::Option<0x1::option::Option>>> [some(some(vector[1,2,3,4]))] +--gas-budget 100000000 diff --git a/crates/sui/tests/ptb_files/inferrence/infer_correct_num_type_invalid_types.ptb b/crates/sui/tests/ptb_files/inferrence/infer_correct_num_type_invalid_types.ptb new file mode 100644 index 0000000000000..2135842965677 --- /dev/null +++ b/crates/sui/tests/ptb_files/inferrence/infer_correct_num_type_invalid_types.ptb @@ -0,0 +1,16 @@ +--make-move-vec [1,2,3,4u16] +--make-move-vec [1,2,3,4u128] +--make-move-vec [1,2,3,4u8] +--make-move-vec [1,2,3,4u32] +--make-move-vec [1,2u8,3,4] +--make-move-vec [1u64,2,3,4] +--make-move-vec > [vector[1,2u16,3,4]] +--make-move-vec > [1,2,3,4] +--make-move-vec > [vector[1u64,2,3,4]] +--make-move-vec > [vector[1,2u128,3,4]] +--make-move-vec > [vector[1,2u256,3,4]] +--make-move-vec > [vector[1,2,3u8,4]] +--make-move-vec <0x1::option::Option<0x1::option::Option>>> [some(vector[1,2,3,4])] +--make-move-vec <0x1::option::Option<0x1::option::Option>>> [some(some(vector[1,2u128,3,4]))] +--gas-budget 100000000 + diff --git a/crates/sui/tests/snapshots/ptb_files_tests__basic_assign.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__basic_assign.ptb.snap index 0882b46531242..0113f1951ff07 100644 --- a/crates/sui/tests/snapshots/ptb_files_tests__basic_assign.ptb.snap +++ b/crates/sui/tests/snapshots/ptb_files_tests__basic_assign.ptb.snap @@ -8,8 +8,8 @@ expression: "results.join(\"\\n\")" ├─────────────┬──────────────┤ │ command │ values │ ├─────────────┼──────────────┤ -│ assign │ x 10u64 │ -│ assign │ y 11u64 │ +│ assign │ x 10 │ +│ assign │ y 11 │ │ split-coins │ gas [x, y] │ │ assign │ coins │ │ assign │ c0 coins.0 │ diff --git a/crates/sui/tests/snapshots/ptb_files_tests__gas_outside_range.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__gas_outside_range.ptb.snap index 42efd5cc62ea8..14c9baf0e5ddd 100644 --- a/crates/sui/tests/snapshots/ptb_files_tests__gas_outside_range.ptb.snap +++ b/crates/sui/tests/snapshots/ptb_files_tests__gas_outside_range.ptb.snap @@ -7,6 +7,6 @@ expression: "results.join(\"\\n\")" ╭──── 1 │ --gas-budget 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF · ─────────────────────────────────────┬──────────────────────────────────── - · ╰── number too large to fit in target type + · ╰── Invalid integer literal ╰──── diff --git a/crates/sui/tests/snapshots/ptb_files_tests__infer_correct_num_type.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__infer_correct_num_type.ptb.snap new file mode 100644 index 0000000000000..6a0e47302e041 --- /dev/null +++ b/crates/sui/tests/snapshots/ptb_files_tests__infer_correct_num_type.ptb.snap @@ -0,0 +1,70 @@ +--- +source: crates/sui/tests/ptb_files_tests.rs +expression: "results.join(\"\\n\")" +--- + === PREVIEW === +╭─────────────────────────────────────────────────────────────────────────────────────────────────────────╮ +│ PTB Preview │ +├───────────────┬─────────────────────────────────────────────────────────────────────────────────────────┤ +│ command │ values │ +├───────────────┼─────────────────────────────────────────────────────────────────────────────────────────┤ +│ make-move-vec │ [1, 2, 3, 4] │ +│ make-move-vec │ [1, 2, 3, 4] │ +│ make-move-vec │ [1, 2, 3, 4] │ +│ make-move-vec │ [1, 2, 3, 4] │ +│ make-move-vec │ [1, 2, 3, 4] │ +│ make-move-vec │ [1, 2, 3, 4] │ +│ make-move-vec │ > [vector[1, 2, 3, 4]] │ +│ make-move-vec │ > [vector[1, 2, 3, 4]] │ +│ make-move-vec │ > [vector[1, 2, 3, 4]] │ +│ make-move-vec │ > [vector[1, 2, 3, 4]] │ +│ make-move-vec │ > [vector[1, 2, 3, 4]] │ +│ make-move-vec │ > [vector[1, 2, 3, 4]] │ +│ make-move-vec │ <0x1::option::Option<0x1::option::Option>>> [some(some(vector[1, 2, 3, 4]))] │ +│ gas-budget │ 100000000 │ +╰───────────────┴─────────────────────────────────────────────────────────────────────────────────────────╯ + === BUILT PTB === +Input 0: Pure([1]) +Input 1: Pure([2]) +Input 2: Pure([3]) +Input 3: Pure([4]) +Input 4: Pure([1, 0]) +Input 5: Pure([2, 0]) +Input 6: Pure([3, 0]) +Input 7: Pure([4, 0]) +Input 8: Pure([1, 0, 0, 0]) +Input 9: Pure([2, 0, 0, 0]) +Input 10: Pure([3, 0, 0, 0]) +Input 11: Pure([4, 0, 0, 0]) +Input 12: Pure([1, 0, 0, 0, 0, 0, 0, 0]) +Input 13: Pure([2, 0, 0, 0, 0, 0, 0, 0]) +Input 14: Pure([3, 0, 0, 0, 0, 0, 0, 0]) +Input 15: Pure([4, 0, 0, 0, 0, 0, 0, 0]) +Input 16: Pure([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) +Input 17: Pure([2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) +Input 18: Pure([3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) +Input 19: Pure([4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) +Input 20: Pure([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) +Input 21: Pure([2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) +Input 22: Pure([3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) +Input 23: Pure([4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) +Input 24: Pure([4, 1, 2, 3, 4]) +Input 25: Pure([4, 1, 0, 2, 0, 3, 0, 4, 0]) +Input 26: Pure([4, 1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 4, 0, 0, 0]) +Input 27: Pure([4, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0]) +Input 28: Pure([4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) +Input 29: Pure([4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) +Input 30: Pure([1, 1, 4, 1, 2, 3, 4]) +Command 0: MakeMoveVec(Someu8,[Input(0),Input(1),Input(2),Input(3)]) +Command 1: MakeMoveVec(Someu16,[Input(4),Input(5),Input(6),Input(7)]) +Command 2: MakeMoveVec(Someu32,[Input(8),Input(9),Input(10),Input(11)]) +Command 3: MakeMoveVec(Someu64,[Input(12),Input(13),Input(14),Input(15)]) +Command 4: MakeMoveVec(Someu128,[Input(16),Input(17),Input(18),Input(19)]) +Command 5: MakeMoveVec(Someu256,[Input(20),Input(21),Input(22),Input(23)]) +Command 6: MakeMoveVec(Somevector,[Input(24)]) +Command 7: MakeMoveVec(Somevector,[Input(25)]) +Command 8: MakeMoveVec(Somevector,[Input(26)]) +Command 9: MakeMoveVec(Somevector,[Input(27)]) +Command 10: MakeMoveVec(Somevector,[Input(28)]) +Command 11: MakeMoveVec(Somevector,[Input(29)]) +Command 12: MakeMoveVec(Some0x1::option::Option<0x1::option::Option>>,[Input(30)]) diff --git a/crates/sui/tests/snapshots/ptb_files_tests__infer_correct_num_type_invalid_types.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__infer_correct_num_type_invalid_types.ptb.snap new file mode 100644 index 0000000000000..66c8bab7bc953 --- /dev/null +++ b/crates/sui/tests/snapshots/ptb_files_tests__infer_correct_num_type_invalid_types.ptb.snap @@ -0,0 +1,159 @@ +--- +source: crates/sui/tests/ptb_files_tests.rs +expression: "results.join(\"\\n\")" +--- + === PREVIEW === +╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ +│ PTB Preview │ +├───────────────┬─────────────────────────────────────────────────────────────────────────────────────────────┤ +│ command │ values │ +├───────────────┼─────────────────────────────────────────────────────────────────────────────────────────────┤ +│ make-move-vec │ [1, 2, 3, 4u16] │ +│ make-move-vec │ [1, 2, 3, 4u128] │ +│ make-move-vec │ [1, 2, 3, 4u8] │ +│ make-move-vec │ [1, 2, 3, 4u32] │ +│ make-move-vec │ [1, 2u8, 3, 4] │ +│ make-move-vec │ [1u64, 2, 3, 4] │ +│ make-move-vec │ > [vector[1, 2u16, 3, 4]] │ +│ make-move-vec │ > [1, 2, 3, 4] │ +│ make-move-vec │ > [vector[1u64, 2, 3, 4]] │ +│ make-move-vec │ > [vector[1, 2u128, 3, 4]] │ +│ make-move-vec │ > [vector[1, 2u256, 3, 4]] │ +│ make-move-vec │ > [vector[1, 2, 3u8, 4]] │ +│ make-move-vec │ <0x1::option::Option<0x1::option::Option>>> [some(vector[1, 2, 3, 4])] │ +│ make-move-vec │ <0x1::option::Option<0x1::option::Option>>> [some(some(vector[1, 2u128, 3, 4]))] │ +│ gas-budget │ 100000000 │ +╰───────────────┴─────────────────────────────────────────────────────────────────────────────────────────────╯ + === BUILDING PTB ERRORS === + × Error when processing PTB + ╭─[1:29] + 1 │ --make-move-vec [1,2,3,4u16] + · ──┬─ + · ╰── Unable to serialize '4u16' as a u8 value + 2 │ --make-move-vec [1,2,3,4u128] + ╰──── + + × Error when processing PTB + ╭─[2:30] + 1 │ --make-move-vec [1,2,3,4u16] + 2 │ --make-move-vec [1,2,3,4u128] + · ──┬── + · ╰── Unable to serialize '4u128' as a u16 value + 3 │ --make-move-vec [1,2,3,4u8] + ╰──── + + × Error when processing PTB + ╭─[3:30] + 2 │ --make-move-vec [1,2,3,4u128] + 3 │ --make-move-vec [1,2,3,4u8] + · ─┬─ + · ╰── Unable to serialize '4u8' as a u32 value + 4 │ --make-move-vec [1,2,3,4u32] + ╰──── + + × Error when processing PTB + ╭─[4:30] + 3 │ --make-move-vec [1,2,3,4u8] + 4 │ --make-move-vec [1,2,3,4u32] + · ──┬─ + · ╰── Unable to serialize '4u32' as a u64 value + 5 │ --make-move-vec [1,2u8,3,4] + ╰──── + + × Error when processing PTB + ╭─[5:27] + 4 │ --make-move-vec [1,2,3,4u32] + 5 │ --make-move-vec [1,2u8,3,4] + · ─┬─ + · ╰── Unable to serialize '2u8' as a u128 value + 6 │ --make-move-vec [1u64,2,3,4] + ╰──── + + × Error when processing PTB + ╭─[6:25] + 5 │ --make-move-vec [1,2u8,3,4] + 6 │ --make-move-vec [1u64,2,3,4] + · ──┬─ + · ╰── Unable to serialize '1u64' as a u256 value + 7 │ --make-move-vec > [vector[1,2u16,3,4]] + ╰──── + + × Error when processing PTB + ╭─[7:40] + 6 │ --make-move-vec [1u64,2,3,4] + 7 │ --make-move-vec > [vector[1,2u16,3,4]] + · ──┬─ + · ╰── Unable to serialize '2u16' as a u8 value + 8 │ --make-move-vec > [1,2,3,4] + ╰──── + help: Literal vectors cannot contain object values. + + × Error when processing PTB + ╭─[8:32] + 7 │ --make-move-vec > [vector[1,2u16,3,4]] + 8 │ --make-move-vec > [1,2,3,4] + · ┬ + · ╰── Expected an integer type but got vector for '1' + 9 │ --make-move-vec > [vector[1u64,2,3,4]] + ╰──── + + × Error when processing PTB + ╭─[9:39] + 8 │ --make-move-vec > [1,2,3,4] + 9 │ --make-move-vec > [vector[1u64,2,3,4]] + · ──┬─ + · ╰── Unable to serialize '1u64' as a u32 value + 10 │ --make-move-vec > [vector[1,2u128,3,4]] + ╰──── + help: Literal vectors cannot contain object values. + + × Error when processing PTB + ╭─[10:41] + 9 │ --make-move-vec > [vector[1u64,2,3,4]] + 10 │ --make-move-vec > [vector[1,2u128,3,4]] + · ──┬── + · ╰── Unable to serialize '2u128' as a u64 value + 11 │ --make-move-vec > [vector[1,2u256,3,4]] + ╰──── + help: Literal vectors cannot contain object values. + + × Error when processing PTB + ╭─[11:42] + 10 │ --make-move-vec > [vector[1,2u128,3,4]] + 11 │ --make-move-vec > [vector[1,2u256,3,4]] + · ──┬── + · ╰── Unable to serialize '2u256' as a u128 value + 12 │ --make-move-vec > [vector[1,2,3u8,4]] + ╰──── + help: Literal vectors cannot contain object values. + + × Error when processing PTB + ╭─[12:44] + 11 │ --make-move-vec > [vector[1,2u256,3,4]] + 12 │ --make-move-vec > [vector[1,2,3u8,4]] + · ─┬─ + · ╰── Unable to serialize '3u8' as a u256 value + 13 │ --make-move-vec <0x1::option::Option<0x1::option::Option>>> [some(vector[1,2,3,4])] + ╰──── + help: Literal vectors cannot contain object values. + + × Error when processing PTB + ╭─[13:78] + 12 │ --make-move-vec > [vector[1,2,3u8,4]] + 13 │ --make-move-vec <0x1::option::Option<0x1::option::Option>>> [some(vector[1,2,3,4])] + · ───────┬─────── + · ╰── Unable to serialize 'vector[1, 2, 3, 4]' as a 0x1::option::Option> value + 14 │ --make-move-vec <0x1::option::Option<0x1::option::Option>>> [some(some(vector[1,2u128,3,4]))] + ╰──── + help: Literal option values cannot contain object values. + + × Error when processing PTB + ╭─[14:92] + 13 │ --make-move-vec <0x1::option::Option<0x1::option::Option>>> [some(vector[1,2,3,4])] + 14 │ --make-move-vec <0x1::option::Option<0x1::option::Option>>> [some(some(vector[1,2u128,3,4]))] + · ──┬── + · ╰── Unable to serialize '2u128' as a u8 value + 15 │ --gas-budget 100000000 + ╰──── + help: Literal option values cannot contain object values. + diff --git a/crates/sui/tests/snapshots/ptb_files_tests__make_move_vec.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__make_move_vec.ptb.snap index 0892708851b67..2d4f062fc385e 100644 --- a/crates/sui/tests/snapshots/ptb_files_tests__make_move_vec.ptb.snap +++ b/crates/sui/tests/snapshots/ptb_files_tests__make_move_vec.ptb.snap @@ -3,43 +3,30 @@ source: crates/sui/tests/ptb_files_tests.rs expression: "results.join(\"\\n\")" --- === PREVIEW === -╭─────────────────────────────────────────────────────────────────────╮ -│ PTB Preview │ -├───────────────┬─────────────────────────────────────────────────────┤ -│ command │ values │ -├───────────────┼─────────────────────────────────────────────────────┤ -│ make-move-vec │ [1u64, 2u64, 3u64, 4u64] │ -│ make-move-vec │ [] │ -│ make-move-vec │ <0x1::a::b> [@0x1, @0x2] │ -│ make-move-vec │
[@0x1, @0x2] │ -│ make-move-vec │ > [vector[@0x1], vector[@0x2]] │ -│ make-move-vec │ > [none, none] │ -│ make-move-vec │ > [none, none] │ -│ make-move-vec │ > [none, some(1u64)] │ -│ make-move-vec │ > [none, some(some(1u64))] │ -│ make-move-vec │ > [gas] │ -╰───────────────┴─────────────────────────────────────────────────────╯ - === BUILT PTB === -Input 0: Pure([1, 0, 0, 0, 0, 0, 0, 0]) -Input 1: Pure([2, 0, 0, 0, 0, 0, 0, 0]) -Input 2: Pure([3, 0, 0, 0, 0, 0, 0, 0]) -Input 3: Pure([4, 0, 0, 0, 0, 0, 0, 0]) -Input 4: ImmutableOrOwnedObject -Input 5: ImmutableOrOwnedObject -Input 6: Pure([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) -Input 7: Pure([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2]) -Input 8: Pure([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) -Input 9: Pure([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2]) -Input 10: Pure([0]) -Input 11: Pure([1, 1, 0, 0, 0, 0, 0, 0, 0]) -Input 12: Pure([1, 1, 1, 0, 0, 0, 0, 0, 0, 0]) -Command 0: MakeMoveVec(Someu64,[Input(0),Input(1),Input(2),Input(3)]) -Command 1: MakeMoveVec(Someu64,[]) -Command 2: MakeMoveVec(Some0x1::a::b,[Input(4),Input(5)]) -Command 3: MakeMoveVec(Someaddress,[Input(6),Input(7)]) -Command 4: MakeMoveVec(Somevector
,[Input(8),Input(9)]) -Command 5: MakeMoveVec(Some0x1::option::Option,[Input(10),Input(10)]) -Command 6: MakeMoveVec(Some0x1::option::Option,[Input(10),Input(10)]) -Command 7: MakeMoveVec(Some0x1::option::Option,[Input(10),Input(11)]) -Command 8: MakeMoveVec(Some0x1::option::Option,[Input(10),Input(12)]) -Command 9: MakeMoveVec(Some0x2::coin::Coin<0x2::sui::SUI>,[GasCoin]) +╭──────────────────────────────────────────────────────────────────╮ +│ PTB Preview │ +├───────────────┬──────────────────────────────────────────────────┤ +│ command │ values │ +├───────────────┼──────────────────────────────────────────────────┤ +│ make-move-vec │ [1, 2, 3, 4] │ +│ make-move-vec │ [] │ +│ make-move-vec │ <0x1::a::b> [@0x1, @0x2] │ +│ make-move-vec │
[@0x1, @0x2] │ +│ make-move-vec │ > [vector[@0x1], vector[@0x2]] │ +│ make-move-vec │ > [none, none] │ +│ make-move-vec │ > [none, none] │ +│ make-move-vec │ > [none, some(1)] │ +│ make-move-vec │ > [none, some(some(1))] │ +│ make-move-vec │ > [gas] │ +╰───────────────┴──────────────────────────────────────────────────╯ + === BUILDING PTB ERRORS === + × Error when processing PTB + ╭─[9:55] + 8 │ --make-move-vec > [none,some(1)] + 9 │ --make-move-vec > [none,some(some(1))] + · ───┬─── + · ╰── Unable to serialize 'some(1)' as a u64 value + 10 │ --make-move-vec > [gas] + ╰──── + help: Literal option values cannot contain object values. + diff --git a/crates/sui/tests/snapshots/ptb_files_tests__make_move_vec_invalid.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__make_move_vec_invalid.ptb.snap index 0cf734e7a5bde..8d49b1e4b5923 100644 --- a/crates/sui/tests/snapshots/ptb_files_tests__make_move_vec_invalid.ptb.snap +++ b/crates/sui/tests/snapshots/ptb_files_tests__make_move_vec_invalid.ptb.snap @@ -11,11 +11,12 @@ expression: "results.join(\"\\n\")" │ make-move-vec │ > [@0x1, @0x2, @0x3] │ │ make-move-vec │
[true, false] │ ╰───────────────┴──────────────────────────────────────╯ - === BUILT PTB === -Input 0: Pure([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) -Input 1: Pure([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2]) -Input 2: Pure([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3]) -Input 3: Pure([1]) -Input 4: Pure([0]) -Command 0: MakeMoveVec(Somevector
,[Input(0),Input(1),Input(2)]) -Command 1: MakeMoveVec(Someaddress,[Input(3),Input(4)]) + === BUILDING PTB ERRORS === + × Error when processing PTB + ╭─[2:28] + 1 │ --make-move-vec > [@0x1, @0x2, @0x3] + 2 │ --make-move-vec
[true, false] + · ──┬─ + · ╰── Unable to serialize 'true' as a address value + ╰──── + diff --git a/crates/sui/tests/snapshots/ptb_files_tests__merge_coins_valid.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__merge_coins_valid.ptb.snap index dac2101b35d2a..b8faef1a49338 100644 --- a/crates/sui/tests/snapshots/ptb_files_tests__merge_coins_valid.ptb.snap +++ b/crates/sui/tests/snapshots/ptb_files_tests__merge_coins_valid.ptb.snap @@ -8,14 +8,14 @@ expression: "results.join(\"\\n\")" ├─────────────┬────────────────────────────┤ │ command │ values │ ├─────────────┼────────────────────────────┤ -│ split-coins │ gas [1u64, 2u64, 3u64] │ +│ split-coins │ gas [1, 2, 3] │ │ assign │ coins │ │ assign │ c0 coins.0 │ │ assign │ c1 coins.1 │ │ assign │ c2 coins.2 │ │ merge-coins │ c0 [c1, c2] │ │ merge-coins │ gas [c0] │ -│ split-coins │ gas [1u64, 2u64, 3u64] │ +│ split-coins │ gas [1, 2, 3] │ │ assign │ coins │ │ merge-coins │ coins.0 [coins.1, coins.2] │ │ merge-coins │ gas [coins.0] │ diff --git a/crates/sui/tests/snapshots/ptb_files_tests__ptb_with_comments.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__ptb_with_comments.ptb.snap index 4f30342196bf7..b3ba500272948 100644 --- a/crates/sui/tests/snapshots/ptb_files_tests__ptb_with_comments.ptb.snap +++ b/crates/sui/tests/snapshots/ptb_files_tests__ptb_with_comments.ptb.snap @@ -8,7 +8,7 @@ expression: "results.join(\"\\n\")" ├──────────────────┬─────────────────┤ │ command │ values │ ├──────────────────┼─────────────────┤ -│ split-coins │ @0x5 [1000u64] │ +│ split-coins │ @0x5 [1000] │ │ assign │ result │ │ transfer-objects │ [result.0] @0x6 │ ╰──────────────────┴─────────────────╯ diff --git a/crates/sui/tests/snapshots/ptb_files_tests__shadow_warnings.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__shadow_warnings.ptb.snap index bd91cd97bd2c8..7572f6825989f 100644 --- a/crates/sui/tests/snapshots/ptb_files_tests__shadow_warnings.ptb.snap +++ b/crates/sui/tests/snapshots/ptb_files_tests__shadow_warnings.ptb.snap @@ -8,11 +8,11 @@ expression: "results.join(\"\\n\")" ├──────────────┬────────┤ │ command │ values │ ├──────────────┼────────┤ -│ assign │ a 1u64 │ -│ assign │ a 2u64 │ -│ assign │ b 4u64 │ +│ assign │ a 1 │ +│ assign │ a 2 │ +│ assign │ b 4 │ │ assign │ a a │ -│ assign │ a 4u64 │ +│ assign │ a 4 │ │ warn-shadows │ true │ ╰──────────────┴────────╯ === WARNINGS === diff --git a/crates/sui/tests/snapshots/ptb_files_tests__split_coins_valid.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__split_coins_valid.ptb.snap index 9f757169670c8..1deb64324399d 100644 --- a/crates/sui/tests/snapshots/ptb_files_tests__split_coins_valid.ptb.snap +++ b/crates/sui/tests/snapshots/ptb_files_tests__split_coins_valid.ptb.snap @@ -8,10 +8,10 @@ expression: "results.join(\"\\n\")" ├─────────────┬─────────────────────────────────────────────────┤ │ command │ values │ ├─────────────┼─────────────────────────────────────────────────┤ -│ split-coins │ gas [0u64, 1u64, 2u64, 3u64] │ +│ split-coins │ gas [0, 1, 2, 3] │ │ assign │ coins │ │ move-call │ sui::coin::destroy_zero coins.0 │ -│ split-coins │ coins.1 [0u64, 0u64] │ +│ split-coins │ coins.1 [0, 0] │ │ assign │ zcoins │ │ move-call │ sui::coin::destroy_zero zcoins.0 │ │ move-call │ sui::coin::destroy_zero zcoins.1 │ diff --git a/crates/sui/tests/snapshots/ptb_files_tests__transfer_objects_valid.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__transfer_objects_valid.ptb.snap index 3ef885545d265..a6f9d135f4cd5 100644 --- a/crates/sui/tests/snapshots/ptb_files_tests__transfer_objects_valid.ptb.snap +++ b/crates/sui/tests/snapshots/ptb_files_tests__transfer_objects_valid.ptb.snap @@ -3,15 +3,15 @@ source: crates/sui/tests/ptb_files_tests.rs expression: "results.join(\"\\n\")" --- === PREVIEW === -╭───────────────────────────────────────────╮ -│ PTB Preview │ -├──────────────────┬────────────────────────┤ -│ command │ values │ -├──────────────────┼────────────────────────┤ -│ split-coins │ gas [1u64, 2u64, 3u64] │ -│ assign │ s │ -│ transfer-objects │ [s.0, s.1, s.2] @0x1 │ -╰──────────────────┴────────────────────────╯ +╭─────────────────────────────────────────╮ +│ PTB Preview │ +├──────────────────┬──────────────────────┤ +│ command │ values │ +├──────────────────┼──────────────────────┤ +│ split-coins │ gas [1, 2, 3] │ +│ assign │ s │ +│ transfer-objects │ [s.0, s.1, s.2] @0x1 │ +╰──────────────────┴──────────────────────╯ === BUILT PTB === Input 0: Pure([1, 0, 0, 0, 0, 0, 0, 0]) Input 1: Pure([2, 0, 0, 0, 0, 0, 0, 0]) diff --git a/crates/sui/tests/snapshots/ptb_files_tests__valid_types.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__valid_types.ptb.snap index 12d2e68938fa3..9d43f84850b61 100644 --- a/crates/sui/tests/snapshots/ptb_files_tests__valid_types.ptb.snap +++ b/crates/sui/tests/snapshots/ptb_files_tests__valid_types.ptb.snap @@ -10,14 +10,14 @@ expression: "results.join(\"\\n\")" ├───────────────┼───────────────────────────────────────────────────────────────┤ │ make-move-vec │
[@0x1] │ │ make-move-vec │ [true, false] │ -│ make-move-vec │ [0u64] │ -│ make-move-vec │ [0u64] │ -│ make-move-vec │ [0u64] │ -│ make-move-vec │ [0u64] │ -│ make-move-vec │ [0u64] │ -│ make-move-vec │ [0u64] │ -│ make-move-vec │ > [vector[0u64]] │ -│ make-move-vec │ > [vector[0u64]] │ +│ make-move-vec │ [0] │ +│ make-move-vec │ [0] │ +│ make-move-vec │ [0] │ +│ make-move-vec │ [0] │ +│ make-move-vec │ [0] │ +│ make-move-vec │ [0] │ +│ make-move-vec │ > [vector[0]] │ +│ make-move-vec │ > [vector[0]] │ │ assign │ a 0u8 │ │ assign │ b 0u16 │ │ assign │ c 0u32 │ @@ -33,21 +33,12 @@ expression: "results.join(\"\\n\")" │ make-move-vec │ >>> [none] │ │ make-move-vec │ >> [vector[]] │ ╰───────────────┴───────────────────────────────────────────────────────────────╯ - === BUILT PTB === -Input 0: Pure([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]) -Input 1: Pure([1]) -Input 2: Pure([0]) -Input 3: Pure([0, 0, 0, 0, 0, 0, 0, 0]) -Input 4: Pure([1, 0, 0, 0, 0, 0, 0, 0, 0]) -Command 0: MakeMoveVec(Someaddress,[Input(0)]) -Command 1: MakeMoveVec(Somebool,[Input(1),Input(2)]) -Command 2: MakeMoveVec(Someu8,[Input(3)]) -Command 3: MakeMoveVec(Someu16,[Input(3)]) -Command 4: MakeMoveVec(Someu32,[Input(3)]) -Command 5: MakeMoveVec(Someu64,[Input(3)]) -Command 6: MakeMoveVec(Someu128,[Input(3)]) -Command 7: MakeMoveVec(Someu256,[Input(3)]) -Command 8: MakeMoveVec(Somevector,[Input(4)]) -Command 9: MakeMoveVec(Somevector,[Input(4)]) -Command 10: MakeMoveVec(Some0x1::option::Option<0x1::option::Option>>,[Input(2)]) -Command 11: MakeMoveVec(Some0x1::option::Option>,[Input(2)]) + === BUILDING PTB ERRORS === + × Error when processing PTB + ╭─[24:54] + 23 │ --make-move-vec >>> [none] + 24 │ --make-move-vec >> [vector[]] + · ────┬─── + · ╰── Unable to serialize 'vector[]' as a 0x1::option::Option> value + ╰──── + diff --git a/crates/sui/tests/snapshots/ptb_files_tests__whitespace_handling.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__whitespace_handling.ptb.snap index 1bb95a14e51e3..2a88575cc8b3b 100644 --- a/crates/sui/tests/snapshots/ptb_files_tests__whitespace_handling.ptb.snap +++ b/crates/sui/tests/snapshots/ptb_files_tests__whitespace_handling.ptb.snap @@ -8,26 +8,30 @@ expression: "results.join(\"\\n\")" ├───────────────┬─────────────────────────────────────────────────────────────────────────────────────────┤ │ command │ values │ ├───────────────┼─────────────────────────────────────────────────────────────────────────────────────────┤ -│ assign │ x vector[1u64, 2u64, 3u64, 4u64] │ -│ assign │ x vector[1u64, 2u64, 3u64, 4u64] │ +│ assign │ x vector[1, 2, 3, 4] │ +│ assign │ x vector[1, 2, 3, 4] │ │ assign │ x vector["1", "2, 3", "", "4 "] │ │ assign │ x vector["1", "2, 3", "", "4 \n "] │ -│ make-move-vec │ [1u64, 2u64, 3u64, 4u64] │ -│ make-move-vec │ [1u64, 2u64, 3u64, 4u64] │ +│ make-move-vec │ [1, 2, 3, 4] │ +│ make-move-vec │ [1, 2, 3, 4] │ │ make-move-vec │ ["1", "2, 3", "", "4 "] │ │ make-move-vec │ ["1", "2, 3", "", "4 \n "] │ ╰───────────────┴─────────────────────────────────────────────────────────────────────────────────────────╯ === BUILT PTB === -Input 0: Pure([1, 0, 0, 0, 0, 0, 0, 0]) -Input 1: Pure([2, 0, 0, 0, 0, 0, 0, 0]) -Input 2: Pure([3, 0, 0, 0, 0, 0, 0, 0]) -Input 3: Pure([4, 0, 0, 0, 0, 0, 0, 0]) -Input 4: Pure([1, 49]) -Input 5: Pure([10, 50, 44, 32, 32, 32, 32, 32, 32, 32, 51]) -Input 6: Pure([0]) -Input 7: Pure([25, 52, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32]) -Input 8: Pure([37, 52, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32]) +Input 0: Pure([1, 0]) +Input 1: Pure([2, 0]) +Input 2: Pure([3, 0]) +Input 3: Pure([4, 0]) +Input 4: Pure([1, 0, 0, 0, 0, 0, 0, 0]) +Input 5: Pure([2, 0, 0, 0, 0, 0, 0, 0]) +Input 6: Pure([3, 0, 0, 0, 0, 0, 0, 0]) +Input 7: Pure([4, 0, 0, 0, 0, 0, 0, 0]) +Input 8: Pure([1, 49]) +Input 9: Pure([10, 50, 44, 32, 32, 32, 32, 32, 32, 32, 51]) +Input 10: Pure([0]) +Input 11: Pure([25, 52, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32]) +Input 12: Pure([37, 52, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32]) Command 0: MakeMoveVec(Someu16,[Input(0),Input(1),Input(2),Input(3)]) -Command 1: MakeMoveVec(Some0x2::string::String,[Input(0),Input(1),Input(2),Input(3)]) -Command 2: MakeMoveVec(Some0x2::string::String,[Input(4),Input(5),Input(6),Input(7)]) -Command 3: MakeMoveVec(Some0x2::string::String,[Input(4),Input(5),Input(6),Input(8)]) +Command 1: MakeMoveVec(Some0x2::string::String,[Input(4),Input(5),Input(6),Input(7)]) +Command 2: MakeMoveVec(Some0x2::string::String,[Input(8),Input(9),Input(10),Input(11)]) +Command 3: MakeMoveVec(Some0x2::string::String,[Input(8),Input(9),Input(10),Input(12)])