diff --git a/crates/sui/src/client_commands.rs b/crates/sui/src/client_commands.rs index f81ac558fb27c..5e051de558a21 100644 --- a/crates/sui/src/client_commands.rs +++ b/crates/sui/src/client_commands.rs @@ -133,6 +133,9 @@ macro_rules! serialize_or_execute { }}; } +/// Only to be used within CLI +pub const GAS_SAFE_OVERHEAD: u64 = 1000; + #[derive(Parser)] #[clap(rename_all = "kebab-case")] pub enum SuiClientCommands { @@ -613,9 +616,12 @@ pub enum SuiClientCommands { /// Global options for most transaction execution related commands #[derive(Args, Debug)] pub struct Opts { - /// Gas budget for this transaction (in MIST) + /// An optional gas budget for this transaction (in MIST). If gas budget is not provided, the + /// tool will first perform a dry run to estimate the gas cost, and then it will execute the + /// transaction. Please note that this incurs a small cost in performance due to the additional + /// dry run call. #[arg(long)] - pub gas_budget: u64, + pub gas_budget: Option, /// Perform a dry run of the transaction, without executing it. #[arg(long)] pub dry_run: bool, @@ -647,7 +653,7 @@ impl Opts { /// Uses the passed gas_budget for the gas budget variable and sets all other flags to false. pub fn for_testing(gas_budget: u64) -> Self { Self { - gas_budget, + gas_budget: Some(gas_budget), dry_run: false, serialize_unsigned_transaction: false, serialize_signed_transaction: false, @@ -657,7 +663,7 @@ impl Opts { /// and sets all other flags to false. pub fn for_testing_dry_run(gas_budget: u64) -> Self { Self { - gas_budget, + gas_budget: Some(gas_budget), dry_run: true, serialize_unsigned_transaction: false, serialize_signed_transaction: false, @@ -934,11 +940,27 @@ impl SuiClientCommands { ) .await; } + + let gas_budget = match gas_budget { + Some(gas_budget) => gas_budget, + None => { + estimate_gas_budget( + context, + sender, + tx_kind.clone(), + gas_price, + gas.map(|x| vec![x]), + None, + ) + .await? + } + }; + let data = client .transaction_builder() .tx_data( sender, - tx_kind, + tx_kind.clone(), gas_budget, gas_price, gas.into_iter().collect(), @@ -1040,6 +1062,21 @@ impl SuiClientCommands { .await; } + let gas_budget = match gas_budget { + Some(gas_budget) => gas_budget, + None => { + estimate_gas_budget( + context, + sender, + tx_kind.clone(), + gas_price, + gas.map(|x| vec![x]), + None, + ) + .await? + } + }; + let data = client .transaction_builder() .tx_data( @@ -1265,6 +1302,20 @@ impl SuiClientCommands { ) .await; } + let gas_budget = match gas_budget { + Some(gas_budget) => gas_budget, + None => { + estimate_gas_budget( + context, + signer, + tx_kind.clone(), + gas_price, + gas.map(|x| vec![x]), + None, + ) + .await? + } + }; let data = client .transaction_builder() .tx_data( @@ -1320,6 +1371,20 @@ impl SuiClientCommands { ) .await; } + let gas_budget = match gas_budget { + Some(gas_budget) => gas_budget, + None => { + estimate_gas_budget( + context, + from, + tx_kind.clone(), + gas_price, + gas.map(|x| vec![x]), + None, + ) + .await? + } + }; let data = client .transaction_builder() .tx_data( @@ -1371,6 +1436,20 @@ impl SuiClientCommands { ) .await; } + let gas_budget = match gas_budget { + Some(gas_budget) => gas_budget, + None => { + estimate_gas_budget( + context, + from, + tx_kind.clone(), + gas_price, + Some(vec![object_id]), + None, + ) + .await? + } + }; let data = client .transaction_builder() .tx_data( @@ -1455,6 +1534,20 @@ impl SuiClientCommands { .await; } + let gas_budget = match gas_budget { + Some(gas_budget) => gas_budget, + None => { + estimate_gas_budget( + context, + from, + kind.clone(), + gas_price, + gas.map(|x| vec![x]), + None, + ) + .await? + } + }; let data = client .transaction_builder() .tx_data( @@ -1529,6 +1622,20 @@ impl SuiClientCommands { .await; } + let gas_budget = match gas_budget { + Some(gas_budget) => gas_budget, + None => { + estimate_gas_budget( + context, + signer, + kind.clone(), + gas_price, + Some(input_coins.clone()), + None, + ) + .await? + } + }; let data = client .transaction_builder() .tx_data( @@ -1582,6 +1689,20 @@ impl SuiClientCommands { .await; } + let gas_budget = match gas_budget { + Some(gas_budget) => gas_budget, + None => { + estimate_gas_budget( + context, + signer, + tx_kind.clone(), + gas_price, + Some(input_coins.clone()), + None, + ) + .await? + } + }; let data = client .transaction_builder() .tx_data(signer, tx_kind, gas_budget, gas_price, input_coins, None) @@ -1734,6 +1855,21 @@ impl SuiClientCommands { .await; } + let gas_budget = match gas_budget { + Some(gas_budget) => gas_budget, + None => { + estimate_gas_budget( + context, + signer, + tx_kind.clone(), + gas_price, + gas.map(|x| vec![x]), + None, + ) + .await? + } + }; + let data = client .transaction_builder() .tx_data( @@ -1787,6 +1923,21 @@ impl SuiClientCommands { ) .await; } + + let gas_budget = match gas_budget { + Some(gas_budget) => gas_budget, + None => { + estimate_gas_budget( + context, + signer, + tx_kind.clone(), + gas_price, + gas.map(|x| vec![x]), + None, + ) + .await? + } + }; let data = client .transaction_builder() .tx_data( @@ -2997,15 +3148,19 @@ fn format_balance( } /// Helper function to reduce code duplication for executing dry run -async fn execute_dry_run( +pub async fn execute_dry_run( context: &mut WalletContext, signer: SuiAddress, kind: TransactionKind, - gas_budget: u64, + gas_budget: Option, gas_price: u64, gas_payment: Option>, sponsor: Option, ) -> Result { + let gas_budget = match gas_budget { + Some(gas_budget) => gas_budget, + None => max_gas_budget(context).await?, + }; let dry_run_tx_data = context .get_client() .await? @@ -3021,3 +3176,52 @@ async fn execute_dry_run( .map_err(|e| anyhow!("Dry run failed: {e}"))?; Ok(SuiClientCommandResult::DryRun(response)) } + +/// Call a dry run with the transaction data to estimate the gas budget. +/// The estimated gas budget is computed as following: +/// * the maximum between A and B, where: +/// A = computation cost + GAS_SAFE_OVERHEAD * reference gas price +/// B = computation cost + storage cost - storage rebate + GAS_SAFE_OVERHEAD * reference gas price +/// overhead +/// +/// This gas estimate is computed exactly as in the TypeScript SDK +/// +pub async fn estimate_gas_budget( + context: &mut WalletContext, + signer: SuiAddress, + kind: TransactionKind, + gas_price: u64, + gas_payment: Option>, + sponsor: Option, +) -> Result { + let client = context.get_client().await?; + let Ok(SuiClientCommandResult::DryRun(dry_run)) = + execute_dry_run(context, signer, kind, None, gas_price, gas_payment, sponsor).await + else { + bail!("Could not automatically determine the gas budget. Please supply one using the --gas-budget flag.") + }; + + let safe_overhead = GAS_SAFE_OVERHEAD * client.read_api().get_reference_gas_price().await?; + let computation_cost_with_overhead = + dry_run.effects.gas_cost_summary().computation_cost + safe_overhead; + + let gas_usage = dry_run.effects.gas_cost_summary().net_gas_usage() + safe_overhead as i64; + Ok(computation_cost_with_overhead.max(if gas_usage < 0 { 0 } else { gas_usage as u64 })) +} + +/// Queries the protocol config for the maximum gas allowed in a transaction. +pub async fn max_gas_budget(context: &mut WalletContext) -> Result { + let cfg = context + .get_client() + .await? + .read_api() + .get_protocol_config(None) + .await?; + Ok(match cfg.attributes.get("max_tx_gas") { + Some(Some(sui_json_rpc_types::SuiProtocolConfigValue::U64(y))) => *y, + _ => bail!( + "Could not automatically find the maximum gas allowed in a transaction from the \ + protocol config. Please provide a gas budget with the --gas-budget flag." + ), + }) +} diff --git a/crates/sui/src/client_ptb/ast.rs b/crates/sui/src/client_ptb/ast.rs index dc0a21e49f509..bee05a09f9ad8 100644 --- a/crates/sui/src/client_ptb/ast.rs +++ b/crates/sui/src/client_ptb/ast.rs @@ -108,7 +108,7 @@ pub struct ProgramMetadata { pub gas_object_id: Option>, pub json_set: bool, pub dry_run_set: bool, - pub gas_budget: Spanned, + pub gas_budget: Option>, } /// A parsed module access consisting of the address, module name, and function name. diff --git a/crates/sui/src/client_ptb/displays/ptb_preview.rs b/crates/sui/src/client_ptb/displays/ptb_preview.rs index 94aac6405e2cd..9b78ab1b7231c 100644 --- a/crates/sui/src/client_ptb/displays/ptb_preview.rs +++ b/crates/sui/src/client_ptb/displays/ptb_preview.rs @@ -24,12 +24,9 @@ impl<'a> Display for PTBPreview<'a> { builder.push_record([command, vals]); } } - // index of horizontal line to draw after commands - let line_index = builder.count_rows(); - builder.push_record([ - GAS_BUDGET, - self.program_metadata.gas_budget.value.to_string().as_str(), - ]); + if let Some(gas_budget) = self.program_metadata.gas_budget { + builder.push_record([GAS_BUDGET, gas_budget.value.to_string().as_str()]); + } if let Some(gas_coin_id) = self.program_metadata.gas_object_id { builder.push_record([GAS_COIN, gas_coin_id.value.to_string().as_str()]); } @@ -53,8 +50,6 @@ impl<'a> Display for PTBPreview<'a> { table.with(TableStyle::rounded().horizontals([ HorizontalLine::new(1, TableStyle::modern().get_horizontal()), HorizontalLine::new(2, TableStyle::modern().get_horizontal()), - HorizontalLine::new(2, TableStyle::modern().get_horizontal()), - HorizontalLine::new(line_index + 2, TableStyle::modern().get_horizontal()), ])); table.with(tabled::settings::style::BorderSpanCorrection); diff --git a/crates/sui/src/client_ptb/parser.rs b/crates/sui/src/client_ptb/parser.rs index a1f4d8e46ec96..a483ed84e352e 100644 --- a/crates/sui/src/client_ptb/parser.rs +++ b/crates/sui/src/client_ptb/parser.rs @@ -193,14 +193,6 @@ impl<'a, I: Iterator> ProgramParser<'a, I> { .push(err!(sp, "Trailing {tok} found after the last command",)); } - let Some(gas_budget) = self.state.gas_budget else { - self.state.errors.push(err!( - sp => help: { "Use --gas-budget to set a gas budget" }, - "Gas budget not set." - )); - return Err(self.state.errors); - }; - if self.state.errors.is_empty() { Ok(( A::Program { @@ -215,7 +207,7 @@ impl<'a, I: Iterator> ProgramParser<'a, I> { gas_object_id: self.state.gas_object_id, json_set: self.state.json_set, dry_run_set: self.state.dry_run_set, - gas_budget, + gas_budget: self.state.gas_budget, }, )) } else { diff --git a/crates/sui/src/client_ptb/ptb.rs b/crates/sui/src/client_ptb/ptb.rs index f4565e2530056..b99e7b5d1d521 100644 --- a/crates/sui/src/client_ptb/ptb.rs +++ b/crates/sui/src/client_ptb/ptb.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 use crate::{ - client_commands::SuiClientCommandResult, + client_commands::{estimate_gas_budget, execute_dry_run, SuiClientCommandResult}, client_ptb::{ ast::{ParsedProgram, Program}, builder::PTBBuilder, @@ -31,7 +31,8 @@ use sui_types::{ gas::GasCostSummary, quorum_driver_types::ExecuteTransactionRequestType, transaction::{ - ProgrammableTransaction, SenderSignedData, Transaction, TransactionData, TransactionDataAPI, + ProgrammableTransaction, SenderSignedData, Transaction, TransactionData, + TransactionDataAPI, TransactionKind, }, }; @@ -138,45 +139,57 @@ impl PTB { anyhow::bail!("No active address, cannot execute PTB"); }; + // get the gas price + let gas_price = context + .get_client() + .await? + .read_api() + .get_reference_gas_price() + .await?; + + // build the tx kind + let tx_kind = TransactionKind::ProgrammableTransaction(ProgrammableTransaction { + inputs: ptb.inputs, + commands: ptb.commands, + }); + + // estimate the gas budget if none is provided, otherwise use the provided one + let gas_budget = match program_metadata.gas_budget { + Some(gas_budget) => gas_budget.value, + None => { + estimate_gas_budget(context, sender, tx_kind.clone(), gas_price, None, None).await? + } + }; + // find the gas coins if we have no gas coin given let coins = if let Some(gas) = program_metadata.gas_object_id { context.get_object_ref(gas.value).await? } else { context - .gas_for_owner_budget(sender, program_metadata.gas_budget.value, BTreeSet::new()) + .gas_for_owner_budget(sender, gas_budget, BTreeSet::new()) .await? .1 .object_ref() }; - // get the gas price - let gas_price = context - .get_client() - .await? - .read_api() - .get_reference_gas_price() - .await?; - - // create the transaction data that will be sent to the network - let tx_data = TransactionData::new_programmable( - sender, - vec![coins], - ptb, - program_metadata.gas_budget.value, - gas_price, - ); - if program_metadata.dry_run_set { - let response = context - .get_client() - .await? - .read_api() - .dry_run_transaction_block(tx_data) - .await?; - println!("{}", SuiClientCommandResult::DryRun(response)); + let response = execute_dry_run( + context, + sender, + tx_kind, + Some(gas_budget), + gas_price, + Some(vec![coins.0]), + None, + ) + .await?; + println!("{}", response); return Ok(()); } + // create the transaction data that will be sent to the network + let tx_data = TransactionData::new(tx_kind.clone(), sender, coins, gas_budget, gas_price); + if program_metadata.serialize_unsigned_set { serialize_or_execute!(tx_data, true, false, context, PTB).print(true); return Ok(()); @@ -322,6 +335,10 @@ pub fn ptb_description() -> clap::Command { \n --assign new_coins # bound new_coins to the result of previous transaction" ) .value_names(["NAME", "VALUE"])) + .arg(arg!( + --"dry-run" + "Perform a dry run of the PTB instead of executing it." + )) .arg(arg!( --"gas-coin" ... "The object ID of the gas coin to use. If not specified, it will try to use the first \ @@ -329,7 +346,10 @@ pub fn ptb_description() -> clap::Command { )) .arg(arg!( --"gas-budget" - "The gas budget for the transaction, in MIST." + "An optional gas budget for this PTB (in MIST). If gas budget is not provided, the \ + tool will first perform a dry run to estimate the gas cost, and then it will execute \ + the transaction. Please note that this incurs a small cost in performance due to the \ + additional dry run call." )) .arg(arg!( --"make-move-vec" 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 a9f426fa77a8a..bbb7ae7556809 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 @@ -32,13 +32,15 @@ expression: parsed gas_object_id: None, json_set: false, dry_run_set: false, - gas_budget: Spanned { - span: Span { - start: 18, - end: 32, + gas_budget: Some( + Spanned { + span: Span { + start: 18, + end: 32, + }, + value: 1, }, - value: 1, - }, + ), }, ), ( @@ -70,13 +72,15 @@ expression: parsed gas_object_id: None, json_set: false, dry_run_set: false, - gas_budget: Spanned { - span: Span { - start: 22, - end: 36, + gas_budget: Some( + Spanned { + span: Span { + start: 22, + end: 36, + }, + value: 1, }, - value: 1, - }, + ), }, ), ( @@ -117,13 +121,15 @@ expression: parsed gas_object_id: None, json_set: false, dry_run_set: false, - gas_budget: Spanned { - span: Span { - start: 19, - end: 33, + gas_budget: Some( + Spanned { + span: Span { + start: 19, + end: 33, + }, + value: 1, }, - value: 1, - }, + ), }, ), ( @@ -183,13 +189,15 @@ expression: parsed gas_object_id: None, json_set: false, dry_run_set: false, - gas_budget: Spanned { - span: Span { - start: 28, - end: 42, + gas_budget: Some( + Spanned { + span: Span { + start: 28, + end: 42, + }, + value: 1, }, - value: 1, - }, + ), }, ), ( @@ -240,13 +248,15 @@ expression: parsed gas_object_id: None, json_set: false, dry_run_set: false, - gas_budget: Spanned { - span: Span { - start: 25, - end: 39, + gas_budget: Some( + Spanned { + span: Span { + start: 25, + end: 39, + }, + value: 1, }, - value: 1, - }, + ), }, ), ( @@ -312,13 +322,15 @@ expression: parsed gas_object_id: None, json_set: false, dry_run_set: false, - gas_budget: Spanned { - span: Span { - start: 27, - end: 41, + gas_budget: Some( + Spanned { + span: Span { + start: 27, + end: 41, + }, + value: 1, }, - value: 1, - }, + ), }, ), ( @@ -378,13 +390,15 @@ expression: parsed gas_object_id: None, json_set: false, dry_run_set: false, - gas_budget: Spanned { - span: Span { - start: 23, - end: 37, + gas_budget: Some( + Spanned { + span: Span { + start: 23, + end: 37, + }, + value: 1, }, - value: 1, - }, + ), }, ), ( @@ -435,13 +449,15 @@ expression: parsed gas_object_id: None, json_set: false, dry_run_set: false, - gas_budget: Spanned { - span: Span { - start: 20, - end: 34, + gas_budget: Some( + Spanned { + span: Span { + start: 20, + end: 34, + }, + value: 1, }, - value: 1, - }, + ), }, ), ( @@ -501,13 +517,15 @@ expression: parsed gas_object_id: None, json_set: false, dry_run_set: false, - gas_budget: Spanned { - span: Span { - start: 23, - end: 37, + gas_budget: Some( + Spanned { + span: Span { + start: 23, + end: 37, + }, + value: 1, }, - value: 1, - }, + ), }, ), ( @@ -558,13 +576,15 @@ expression: parsed gas_object_id: None, json_set: false, dry_run_set: false, - gas_budget: Spanned { - span: Span { - start: 20, - end: 34, + gas_budget: Some( + Spanned { + span: Span { + start: 20, + end: 34, + }, + value: 1, }, - value: 1, - }, + ), }, ), ( @@ -603,13 +623,15 @@ expression: parsed gas_object_id: None, json_set: false, dry_run_set: false, - gas_budget: Spanned { - span: Span { - start: 25, - end: 39, + gas_budget: Some( + Spanned { + span: Span { + start: 25, + end: 39, + }, + value: 1, }, - value: 1, - }, + ), }, ), ( @@ -667,13 +689,15 @@ expression: parsed gas_object_id: None, json_set: false, dry_run_set: false, - gas_budget: Spanned { - span: Span { - start: 32, - end: 46, + gas_budget: Some( + Spanned { + span: Span { + start: 32, + end: 46, + }, + value: 1, }, - value: 1, - }, + ), }, ), ( @@ -778,13 +802,15 @@ expression: parsed gas_object_id: None, json_set: false, dry_run_set: false, - gas_budget: Spanned { - span: Span { - start: 72, - end: 86, + gas_budget: Some( + Spanned { + span: Span { + start: 72, + end: 86, + }, + value: 1, }, - value: 1, - }, + ), }, ), ( @@ -866,13 +892,15 @@ expression: parsed gas_object_id: None, json_set: false, dry_run_set: false, - gas_budget: Spanned { - span: Span { - start: 41, - end: 55, + gas_budget: Some( + Spanned { + span: Span { + start: 41, + end: 55, + }, + value: 1, }, - value: 1, - }, + ), }, ), ( @@ -954,13 +982,15 @@ expression: parsed gas_object_id: None, json_set: false, dry_run_set: false, - gas_budget: Spanned { - span: Span { - start: 40, - end: 54, + gas_budget: Some( + Spanned { + span: Span { + start: 40, + end: 54, + }, + value: 1, }, - value: 1, - }, + ), }, ), ( @@ -993,13 +1023,15 @@ expression: parsed gas_object_id: None, json_set: false, dry_run_set: false, - gas_budget: Spanned { - span: Span { - start: 11, - end: 25, + gas_budget: Some( + Spanned { + span: Span { + start: 11, + end: 25, + }, + value: 1, }, - value: 1, - }, + ), }, ), ( @@ -1057,13 +1089,15 @@ expression: parsed gas_object_id: None, json_set: false, dry_run_set: false, - gas_budget: Spanned { - span: Span { - start: 15, - end: 29, + gas_budget: Some( + Spanned { + span: Span { + start: 15, + end: 29, + }, + value: 1, }, - value: 1, - }, + ), }, ), ( @@ -1106,13 +1140,15 @@ expression: parsed gas_object_id: None, json_set: false, dry_run_set: false, - gas_budget: Spanned { - span: Span { - start: 15, - end: 29, + gas_budget: Some( + Spanned { + span: Span { + start: 15, + end: 29, + }, + value: 1, }, - value: 1, - }, + ), }, ), ( @@ -1155,13 +1191,15 @@ expression: parsed gas_object_id: None, json_set: false, dry_run_set: false, - gas_budget: Spanned { - span: Span { - start: 16, - end: 30, + gas_budget: Some( + Spanned { + span: Span { + start: 16, + end: 30, + }, + value: 1, }, - value: 1, - }, + ), }, ), ( @@ -1232,13 +1270,15 @@ expression: parsed gas_object_id: None, json_set: false, dry_run_set: false, - gas_budget: Spanned { - span: Span { - start: 27, - end: 41, + gas_budget: Some( + Spanned { + span: Span { + start: 27, + end: 41, + }, + value: 1, }, - value: 1, - }, + ), }, ), ( @@ -1287,13 +1327,15 @@ expression: parsed gas_object_id: None, json_set: false, dry_run_set: false, - gas_budget: Spanned { - span: Span { - start: 16, - end: 30, + gas_budget: Some( + Spanned { + span: Span { + start: 16, + end: 30, + }, + value: 1, }, - value: 1, - }, + ), }, ), ( @@ -1346,13 +1388,15 @@ expression: parsed gas_object_id: None, json_set: false, dry_run_set: false, - gas_budget: Spanned { - span: Span { - start: 19, - end: 33, + gas_budget: Some( + Spanned { + span: Span { + start: 19, + end: 33, + }, + value: 1, }, - value: 1, - }, + ), }, ), ( @@ -1376,13 +1420,15 @@ expression: parsed ), json_set: false, dry_run_set: false, - gas_budget: Spanned { - span: Span { - start: 16, - end: 30, + gas_budget: Some( + Spanned { + span: Span { + start: 16, + end: 30, + }, + value: 1, }, - value: 1, - }, + ), }, ), ( @@ -1398,13 +1444,15 @@ expression: parsed gas_object_id: None, json_set: false, dry_run_set: false, - gas_budget: Spanned { - span: Span { - start: 10, - end: 24, + gas_budget: Some( + Spanned { + span: Span { + start: 10, + end: 24, + }, + value: 1, }, - value: 1, - }, + ), }, ), ( @@ -1420,13 +1468,15 @@ expression: parsed gas_object_id: None, json_set: true, dry_run_set: false, - gas_budget: Spanned { - span: Span { - start: 7, - end: 21, + gas_budget: Some( + Spanned { + span: Span { + start: 7, + end: 21, + }, + value: 1, }, - value: 1, - }, + ), }, ), ( @@ -1442,13 +1492,15 @@ expression: parsed gas_object_id: None, json_set: false, dry_run_set: false, - gas_budget: Spanned { - span: Span { - start: 10, - end: 24, + gas_budget: Some( + Spanned { + span: Span { + start: 10, + end: 24, + }, + value: 1, }, - value: 1, - }, + ), }, ), ( @@ -1464,13 +1516,15 @@ expression: parsed gas_object_id: None, json_set: false, dry_run_set: false, - gas_budget: Spanned { - span: Span { - start: 15, - end: 29, + gas_budget: Some( + Spanned { + span: Span { + start: 15, + end: 29, + }, + value: 1, }, - value: 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 42e38b7477795..3d12b177ad063 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 @@ -15,17 +15,6 @@ expression: parsed ), severity: Error, }, - PTBError { - message: "Gas budget not set.", - span: Span { - start: 9, - end: 9, - }, - help: Some( - "Use --gas-budget to set a gas budget", - ), - severity: Error, - }, ], [ PTBError { @@ -39,17 +28,6 @@ expression: parsed ), severity: Error, }, - PTBError { - message: "Gas budget not set.", - span: Span { - start: 9, - end: 9, - }, - help: Some( - "Use --gas-budget to set a gas budget", - ), - severity: Error, - }, ], [ PTBError { @@ -63,17 +41,6 @@ expression: parsed ), severity: Error, }, - PTBError { - message: "Gas budget not set.", - span: Span { - start: 11, - end: 11, - }, - help: Some( - "Use --gas-budget to set a gas budget", - ), - severity: Error, - }, ], [ PTBError { @@ -85,17 +52,6 @@ expression: parsed help: None, severity: Error, }, - PTBError { - message: "Gas budget not set.", - span: Span { - start: 20, - end: 20, - }, - help: Some( - "Use --gas-budget to set a gas budget", - ), - severity: Error, - }, ], [ PTBError { @@ -109,17 +65,6 @@ expression: parsed ), severity: Error, }, - PTBError { - message: "Gas budget not set.", - span: Span { - start: 22, - end: 22, - }, - help: Some( - "Use --gas-budget to set a gas budget", - ), - severity: Error, - }, ], [ PTBError { @@ -131,17 +76,6 @@ expression: parsed help: None, severity: Error, }, - PTBError { - message: "Gas budget not set.", - span: Span { - start: 18, - end: 18, - }, - help: Some( - "Use --gas-budget to set a gas budget", - ), - severity: Error, - }, ], [ PTBError { @@ -155,17 +89,6 @@ expression: parsed ), severity: Error, }, - PTBError { - message: "Gas budget not set.", - span: Span { - start: 26, - end: 26, - }, - help: Some( - "Use --gas-budget to set a gas budget", - ), - severity: Error, - }, ], [ PTBError { @@ -177,17 +100,6 @@ expression: parsed help: None, severity: Error, }, - PTBError { - message: "Gas budget not set.", - span: Span { - start: 15, - end: 15, - }, - help: Some( - "Use --gas-budget to set a gas budget", - ), - severity: Error, - }, ], [ PTBError { @@ -201,17 +113,6 @@ expression: parsed ), severity: Error, }, - PTBError { - message: "Gas budget not set.", - span: Span { - start: 17, - end: 17, - }, - help: Some( - "Use --gas-budget to set a gas budget", - ), - severity: Error, - }, ], [ PTBError { @@ -225,17 +126,6 @@ expression: parsed ), severity: Error, }, - PTBError { - message: "Gas budget not set.", - span: Span { - start: 13, - end: 13, - }, - help: Some( - "Use --gas-budget to set a gas budget", - ), - severity: Error, - }, ], [ PTBError { @@ -247,17 +137,6 @@ expression: parsed help: None, severity: Error, }, - PTBError { - message: "Gas budget not set.", - span: Span { - start: 19, - end: 19, - }, - help: Some( - "Use --gas-budget to set a gas budget", - ), - severity: Error, - }, ], [ PTBError { @@ -271,17 +150,6 @@ expression: parsed ), severity: Error, }, - PTBError { - message: "Gas budget not set.", - span: Span { - start: 21, - end: 21, - }, - help: Some( - "Use --gas-budget to set a gas budget", - ), - severity: Error, - }, ], [ PTBError { @@ -293,17 +161,6 @@ expression: parsed help: None, severity: Error, }, - PTBError { - message: "Gas budget not set.", - span: Span { - start: 15, - end: 15, - }, - help: Some( - "Use --gas-budget to set a gas budget", - ), - severity: Error, - }, ], [ PTBError { @@ -317,17 +174,6 @@ expression: parsed ), severity: Error, }, - PTBError { - message: "Gas budget not set.", - span: Span { - start: 17, - end: 17, - }, - help: Some( - "Use --gas-budget to set a gas budget", - ), - severity: Error, - }, ], [ PTBError { @@ -341,17 +187,6 @@ expression: parsed ), severity: Error, }, - PTBError { - message: "Gas budget not set.", - span: Span { - start: 13, - end: 13, - }, - help: Some( - "Use --gas-budget to set a gas budget", - ), - severity: Error, - }, ], [ PTBError { @@ -363,17 +198,6 @@ expression: parsed help: None, severity: Error, }, - PTBError { - message: "Gas budget not set.", - span: Span { - start: 19, - end: 19, - }, - help: Some( - "Use --gas-budget to set a gas budget", - ), - severity: Error, - }, ], [ PTBError { @@ -387,17 +211,6 @@ expression: parsed ), severity: Error, }, - PTBError { - message: "Gas budget not set.", - span: Span { - start: 21, - end: 21, - }, - help: Some( - "Use --gas-budget to set a gas budget", - ), - severity: Error, - }, ], [ PTBError { @@ -409,17 +222,6 @@ expression: parsed help: None, severity: Error, }, - PTBError { - message: "Gas budget not set.", - span: Span { - start: 15, - end: 15, - }, - help: Some( - "Use --gas-budget to set a gas budget", - ), - severity: Error, - }, ], [ PTBError { @@ -431,17 +233,6 @@ expression: parsed help: None, severity: Error, }, - PTBError { - message: "Gas budget not set.", - span: Span { - start: 25, - end: 25, - }, - help: Some( - "Use --gas-budget to set a gas budget", - ), - severity: Error, - }, ], [ PTBError { @@ -453,17 +244,6 @@ expression: parsed help: None, severity: Error, }, - PTBError { - message: "Gas budget not set.", - span: Span { - start: 21, - end: 21, - }, - help: Some( - "Use --gas-budget to set a gas budget", - ), - severity: Error, - }, ], [ PTBError { @@ -477,17 +257,6 @@ expression: parsed ), severity: Error, }, - PTBError { - message: "Gas budget not set.", - span: Span { - start: 11, - end: 11, - }, - help: Some( - "Use --gas-budget to set a gas budget", - ), - severity: Error, - }, ], [ PTBError { @@ -501,17 +270,6 @@ expression: parsed ), severity: Error, }, - PTBError { - message: "Gas budget not set.", - span: Span { - start: 39, - end: 39, - }, - help: Some( - "Use --gas-budget to set a gas budget", - ), - severity: Error, - }, ], [ PTBError { @@ -523,17 +281,6 @@ expression: parsed help: None, severity: Error, }, - PTBError { - message: "Gas budget not set.", - span: Span { - start: 8, - end: 8, - }, - help: Some( - "Use --gas-budget to set a gas budget", - ), - severity: Error, - }, ], [ PTBError { @@ -547,17 +294,6 @@ expression: parsed ), severity: Error, }, - PTBError { - message: "Gas budget not set.", - span: Span { - start: 14, - end: 14, - }, - help: Some( - "Use --gas-budget to set a gas budget", - ), - severity: Error, - }, ], [ PTBError { @@ -571,17 +307,6 @@ expression: parsed ), severity: Error, }, - PTBError { - message: "Gas budget not set.", - span: Span { - start: 15, - end: 15, - }, - help: Some( - "Use --gas-budget to set a gas budget", - ), - severity: Error, - }, ], [ PTBError { @@ -595,17 +320,6 @@ expression: parsed ), severity: Error, }, - PTBError { - message: "Gas budget not set.", - span: Span { - start: 18, - end: 18, - }, - help: Some( - "Use --gas-budget to set a gas budget", - ), - severity: Error, - }, ], [ PTBError { @@ -619,17 +333,6 @@ expression: parsed ), severity: Error, }, - PTBError { - message: "Gas budget not set.", - span: Span { - start: 16, - end: 16, - }, - help: Some( - "Use --gas-budget to set a gas budget", - ), - severity: Error, - }, ], [ PTBError { @@ -641,17 +344,6 @@ expression: parsed help: None, severity: Error, }, - PTBError { - message: "Gas budget not set.", - span: Span { - start: 75, - end: 75, - }, - help: Some( - "Use --gas-budget to set a gas budget", - ), - severity: Error, - }, ], [ PTBError { @@ -665,17 +357,6 @@ expression: parsed ), severity: Error, }, - PTBError { - message: "Gas budget not set.", - span: Span { - start: 16, - end: 16, - }, - help: Some( - "Use --gas-budget to set a gas budget", - ), - severity: Error, - }, ], [ PTBError { @@ -687,17 +368,6 @@ expression: parsed help: None, severity: Error, }, - PTBError { - message: "Gas budget not set.", - span: Span { - start: 17, - end: 17, - }, - help: Some( - "Use --gas-budget to set a gas budget", - ), - severity: Error, - }, ], [ PTBError { @@ -709,17 +379,6 @@ expression: parsed help: None, severity: Error, }, - PTBError { - message: "Gas budget not set.", - span: Span { - start: 17, - end: 17, - }, - help: Some( - "Use --gas-budget to set a gas budget", - ), - severity: Error, - }, ], [ PTBError { @@ -733,17 +392,6 @@ expression: parsed ), severity: Error, }, - PTBError { - message: "Gas budget not set.", - span: Span { - start: 15, - end: 15, - }, - help: Some( - "Use --gas-budget to set a gas budget", - ), - severity: Error, - }, ], [ PTBError { @@ -757,17 +405,6 @@ expression: parsed ), severity: Error, }, - PTBError { - message: "Gas budget not set.", - span: Span { - start: 10, - end: 10, - }, - help: Some( - "Use --gas-budget to set a gas budget", - ), - severity: Error, - }, ], [ PTBError { @@ -781,17 +418,6 @@ expression: parsed ), severity: Error, }, - PTBError { - message: "Gas budget not set.", - span: Span { - start: 20, - end: 20, - }, - help: Some( - "Use --gas-budget to set a gas budget", - ), - severity: Error, - }, ], [ PTBError { @@ -805,16 +431,5 @@ expression: parsed ), severity: Error, }, - PTBError { - message: "Gas budget not set.", - span: Span { - start: 12, - end: 12, - }, - help: Some( - "Use --gas-budget to set a gas budget", - ), - severity: Error, - }, ], ] diff --git a/crates/sui/src/client_ptb/snapshots/sui__client_ptb__parser__tests__parse_publish.snap b/crates/sui/src/client_ptb/snapshots/sui__client_ptb__parser__tests__parse_publish.snap index 59890802cea60..fef41e7a46396 100644 --- a/crates/sui/src/client_ptb/snapshots/sui__client_ptb__parser__tests__parse_publish.snap +++ b/crates/sui/src/client_ptb/snapshots/sui__client_ptb__parser__tests__parse_publish.snap @@ -32,13 +32,15 @@ expression: parsed gas_object_id: None, json_set: false, dry_run_set: false, - gas_budget: Spanned { - span: Span { - start: 18, - end: 32, + gas_budget: Some( + Spanned { + span: Span { + start: 18, + end: 32, + }, + value: 1, }, - value: 1, - }, + ), }, ), ( @@ -70,13 +72,15 @@ expression: parsed gas_object_id: None, json_set: false, dry_run_set: false, - gas_budget: Spanned { - span: Span { - start: 18, - end: 32, + gas_budget: Some( + Spanned { + span: Span { + start: 18, + end: 32, + }, + value: 1, }, - value: 1, - }, + ), }, ), ] diff --git a/crates/sui/src/client_ptb/snapshots/sui__client_ptb__parser__tests__parse_unexpected_top_level.snap b/crates/sui/src/client_ptb/snapshots/sui__client_ptb__parser__tests__parse_unexpected_top_level.snap index a8c8904dadef4..7e27e6a7e840f 100644 --- a/crates/sui/src/client_ptb/snapshots/sui__client_ptb__parser__tests__parse_unexpected_top_level.snap +++ b/crates/sui/src/client_ptb/snapshots/sui__client_ptb__parser__tests__parse_unexpected_top_level.snap @@ -14,15 +14,4 @@ expression: result.unwrap_err() ), severity: Error, }, - PTBError { - message: "Gas budget not set.", - span: Span { - start: 0, - end: 2, - }, - help: Some( - "Use --gas-budget to set a gas budget", - ), - severity: Error, - }, ] diff --git a/crates/sui/tests/cli_tests.rs b/crates/sui/tests/cli_tests.rs index 8820de0a9ca52..c3e7a62d667b4 100644 --- a/crates/sui/tests/cli_tests.rs +++ b/crates/sui/tests/cli_tests.rs @@ -21,9 +21,11 @@ use sui_types::transaction::{ }; use tokio::time::sleep; -use sui::client_commands::{Opts, OptsWithGas, SwitchResponse}; use sui::{ - client_commands::{SuiClientCommandResult, SuiClientCommands}, + client_commands::{ + estimate_gas_budget, Opts, OptsWithGas, SuiClientCommandResult, SuiClientCommands, + SwitchResponse, + }, sui_commands::SuiCommand, }; use sui_config::{ @@ -2758,7 +2760,7 @@ async fn test_serialize_tx() -> Result<(), anyhow::Error> { sui_coin_object_id: coin, amount: Some(1), opts: Opts { - gas_budget: rgp * TEST_ONLY_GAS_UNIT_FOR_TRANSFER, + gas_budget: Some(rgp * TEST_ONLY_GAS_UNIT_FOR_TRANSFER), dry_run: false, serialize_unsigned_transaction: true, serialize_signed_transaction: false, @@ -2772,7 +2774,7 @@ async fn test_serialize_tx() -> Result<(), anyhow::Error> { sui_coin_object_id: coin, amount: Some(1), opts: Opts { - gas_budget: rgp * TEST_ONLY_GAS_UNIT_FOR_TRANSFER, + gas_budget: Some(rgp * TEST_ONLY_GAS_UNIT_FOR_TRANSFER), dry_run: false, serialize_unsigned_transaction: false, serialize_signed_transaction: true, @@ -2787,7 +2789,7 @@ async fn test_serialize_tx() -> Result<(), anyhow::Error> { sui_coin_object_id: coin, amount: Some(1), opts: Opts { - gas_budget: rgp * TEST_ONLY_GAS_UNIT_FOR_TRANSFER, + gas_budget: Some(rgp * TEST_ONLY_GAS_UNIT_FOR_TRANSFER), dry_run: false, serialize_unsigned_transaction: false, serialize_signed_transaction: true, @@ -3587,3 +3589,49 @@ async fn test_transfer_sui() -> Result<(), anyhow::Error> { } Ok(()) } + +#[sim_test] +async fn test_gas_estimation() -> Result<(), anyhow::Error> { + let (mut test_cluster, client, rgp, objects, _, addresses) = test_cluster_helper().await; + let object_id1 = objects[0]; + let address2 = addresses[0]; + let context = &mut test_cluster.wallet; + let amount = 1000; + let sender = context.active_address().unwrap(); + let tx_builder = client.transaction_builder(); + let tx_kind = tx_builder.transfer_sui_tx_kind(address2, Some(amount)); + let gas_estimate = estimate_gas_budget(context, sender, tx_kind, rgp, None, None).await; + assert!(gas_estimate.is_ok()); + + let transfer_sui_cmd = SuiClientCommands::TransferSui { + to: KeyIdentity::Address(address2), + sui_coin_object_id: object_id1, + amount: Some(amount), + opts: Opts { + gas_budget: None, + dry_run: false, + serialize_unsigned_transaction: false, + serialize_signed_transaction: false, + }, + } + .execute(context) + .await + .unwrap(); + if let SuiClientCommandResult::TransferSui(response) = transfer_sui_cmd { + assert!(response.status_ok().unwrap()); + let gas_used = response.effects.as_ref().unwrap().gas_object().object_id(); + assert_eq!(gas_used, object_id1); + assert!( + response + .effects + .as_ref() + .unwrap() + .gas_cost_summary() + .gas_used() + <= gas_estimate.unwrap() + ); + } else { + panic!("TransferSui test failed"); + } + Ok(()) +} diff --git a/crates/sui/tests/ptb_files/assign/assign_invalid.ptb b/crates/sui/tests/ptb_files/assign/assign_invalid.ptb index e185c70e3f7cc..a56f3e7e24e1a 100644 --- a/crates/sui/tests/ptb_files/assign/assign_invalid.ptb +++ b/crates/sui/tests/ptb_files/assign/assign_invalid.ptb @@ -33,4 +33,3 @@ --assign gas 1 --assign none 2 ---gas-budget 1 diff --git a/crates/sui/tests/ptb_files/assign/assign_valid.ptb b/crates/sui/tests/ptb_files/assign/assign_valid.ptb index 621145beac0a0..6e4de10e32d59 100644 --- a/crates/sui/tests/ptb_files/assign/assign_valid.ptb +++ b/crates/sui/tests/ptb_files/assign/assign_valid.ptb @@ -23,4 +23,3 @@ # Can assign to the other field as well --assign c1 c.1 ---gas-budget 1 diff --git a/crates/sui/tests/ptb_files/assign/basic_assign.ptb b/crates/sui/tests/ptb_files/assign/basic_assign.ptb index 325c9c7e19097..9c2c5d4ccfb8c 100644 --- a/crates/sui/tests/ptb_files/assign/basic_assign.ptb +++ b/crates/sui/tests/ptb_files/assign/basic_assign.ptb @@ -6,4 +6,3 @@ --assign "c1" coins.1 --merge-coins gas [c0, c1] ---gas-budget 10000000 diff --git a/crates/sui/tests/ptb_files/assign/shadow_warnings.ptb b/crates/sui/tests/ptb_files/assign/shadow_warnings.ptb index ced9672acd26e..84d162fb4a530 100644 --- a/crates/sui/tests/ptb_files/assign/shadow_warnings.ptb +++ b/crates/sui/tests/ptb_files/assign/shadow_warnings.ptb @@ -3,5 +3,4 @@ --assign b 4 --assign a a --assign a 4 ---gas-budget 1 --warn-shadows diff --git a/crates/sui/tests/ptb_files/comments/ptb_with_comments.ptb b/crates/sui/tests/ptb_files/comments/ptb_with_comments.ptb index 32d10f6efa09b..80768171dc67b 100644 --- a/crates/sui/tests/ptb_files/comments/ptb_with_comments.ptb +++ b/crates/sui/tests/ptb_files/comments/ptb_with_comments.ptb @@ -1,7 +1,6 @@ # Testing comments, including # "nested" comments # This ptb splits a coin into two # and then transfers the coin to another address ---gas-budget 100000 # First split the coin --split-coins @0x005 [1000] # Then assign the result to variable result diff --git a/crates/sui/tests/ptb_files/make_move_vec/make_move_vec.ptb b/crates/sui/tests/ptb_files/make_move_vec/make_move_vec.ptb index c6ce62ecb9bfe..92cdc94fc7d7e 100644 --- a/crates/sui/tests/ptb_files/make_move_vec/make_move_vec.ptb +++ b/crates/sui/tests/ptb_files/make_move_vec/make_move_vec.ptb @@ -1,4 +1,3 @@ ---gas-budget 1000 # Can parse with spaces, basic make-move-vec works --make-move-vec [1, 2,3, 4] # Can have empty arrays diff --git a/crates/sui/tests/ptb_files/make_move_vec/make_move_vec_invalid.ptb b/crates/sui/tests/ptb_files/make_move_vec/make_move_vec_invalid.ptb index ae2915036ea42..23206a4839eeb 100644 --- a/crates/sui/tests/ptb_files/make_move_vec/make_move_vec_invalid.ptb +++ b/crates/sui/tests/ptb_files/make_move_vec/make_move_vec_invalid.ptb @@ -1,5 +1,3 @@ ---gas-budget 10000 - # Type mismatches -- we don't do any type of type checking, so if you mess # these types up you'll get a runtime error from executing the PTB. # In the future we may want to add (simple!) type checking to the PTB creation. diff --git a/crates/sui/tests/ptb_files/make_move_vec/make_move_vec_invalid_args.ptb b/crates/sui/tests/ptb_files/make_move_vec/make_move_vec_invalid_args.ptb index 3520fb1118829..b26d450458767 100644 --- a/crates/sui/tests/ptb_files/make_move_vec/make_move_vec_invalid_args.ptb +++ b/crates/sui/tests/ptb_files/make_move_vec/make_move_vec_invalid_args.ptb @@ -1,5 +1,3 @@ ---gas-budget 10000000 - # No type args --make-move-vec [100] diff --git a/crates/sui/tests/ptb_files/make_move_vec/resolve_array_inside_array.ptb b/crates/sui/tests/ptb_files/make_move_vec/resolve_array_inside_array.ptb index 0ca756c57a922..6ae1707774daa 100644 --- a/crates/sui/tests/ptb_files/make_move_vec/resolve_array_inside_array.ptb +++ b/crates/sui/tests/ptb_files/make_move_vec/resolve_array_inside_array.ptb @@ -1,5 +1,3 @@ ---gas-budget 10000 - # Nested array inside an array # This is caught statically since from the shape of it we know this is wrong. --make-move-vec > [[@0x1], [@0x2], [@0x3]] diff --git a/crates/sui/tests/ptb_files/make_move_vec/resolve_array_inside_array_through_bindings.ptb b/crates/sui/tests/ptb_files/make_move_vec/resolve_array_inside_array_through_bindings.ptb index b2626ae5b8f10..437330cdbf286 100644 --- a/crates/sui/tests/ptb_files/make_move_vec/resolve_array_inside_array_through_bindings.ptb +++ b/crates/sui/tests/ptb_files/make_move_vec/resolve_array_inside_array_through_bindings.ptb @@ -1,5 +1,3 @@ ---gas-budget 1000000000 - # Nested array inside an array but the inner array is bound to variables # Again, since we don't typecheck this will be a runtime PTB error --make-move-vec
[@0x1] diff --git a/crates/sui/tests/ptb_files/merge_coins/merge_coins_invalid_args.ptb b/crates/sui/tests/ptb_files/merge_coins/merge_coins_invalid_args.ptb index 4d51d066f6fb3..03b457c96cbea 100644 --- a/crates/sui/tests/ptb_files/merge_coins/merge_coins_invalid_args.ptb +++ b/crates/sui/tests/ptb_files/merge_coins/merge_coins_invalid_args.ptb @@ -1,5 +1,3 @@ ---gas-budget 1000000 - # Invalid number of arguments --merge-coins @0x1 diff --git a/crates/sui/tests/ptb_files/merge_coins/merge_coins_valid.ptb b/crates/sui/tests/ptb_files/merge_coins/merge_coins_valid.ptb index 3e2b9debc5298..6f86c98dee66a 100644 --- a/crates/sui/tests/ptb_files/merge_coins/merge_coins_valid.ptb +++ b/crates/sui/tests/ptb_files/merge_coins/merge_coins_valid.ptb @@ -1,5 +1,3 @@ ---gas-budget 100000000 - # Split gas coin, and then assign out to its different parts --split-coins gas [1,2,3] --assign coins diff --git a/crates/sui/tests/ptb_files/move_call/move_call.ptb b/crates/sui/tests/ptb_files/move_call/move_call.ptb index 36272363de3b9..937b51c14e86c 100644 --- a/crates/sui/tests/ptb_files/move_call/move_call.ptb +++ b/crates/sui/tests/ptb_files/move_call/move_call.ptb @@ -1,4 +1,3 @@ ---gas-budget 1000 --assign a none --make-move-vec <0x1::option::Option> [a] --move-call 0x1::option::is_none a diff --git a/crates/sui/tests/ptb_files/move_call/move_call_fun_resolution.ptb b/crates/sui/tests/ptb_files/move_call/move_call_fun_resolution.ptb index 0503799dd7b4e..6629e01f0b8fe 100644 --- a/crates/sui/tests/ptb_files/move_call/move_call_fun_resolution.ptb +++ b/crates/sui/tests/ptb_files/move_call/move_call_fun_resolution.ptb @@ -1,4 +1,3 @@ ---gas-budget 1000 # Try to use identifier/address that is not in scope --move-call zero_x_zero::option::is_none none --assign a none diff --git a/crates/sui/tests/ptb_files/move_call/move_call_parsing.ptb b/crates/sui/tests/ptb_files/move_call/move_call_parsing.ptb index 447944d8e0088..e9f97f7e13492 100644 --- a/crates/sui/tests/ptb_files/move_call/move_call_parsing.ptb +++ b/crates/sui/tests/ptb_files/move_call/move_call_parsing.ptb @@ -1,3 +1,2 @@ ---gas-budget 1000 # Invalid module access --move-call invalid_access diff --git a/crates/sui/tests/ptb_files/parsing/keywords.ptb b/crates/sui/tests/ptb_files/parsing/keywords.ptb index 6671a5b7bd4c5..7254f049a8e87 100644 --- a/crates/sui/tests/ptb_files/parsing/keywords.ptb +++ b/crates/sui/tests/ptb_files/parsing/keywords.ptb @@ -4,4 +4,3 @@ --assign none @0x1 --assign gas @0x1 ---gas-budget 11 diff --git a/crates/sui/tests/ptb_files/parsing/multiple_function_args.ptb b/crates/sui/tests/ptb_files/parsing/multiple_function_args.ptb index 0386cd5252909..cc3f86cde3005 100644 --- a/crates/sui/tests/ptb_files/parsing/multiple_function_args.ptb +++ b/crates/sui/tests/ptb_files/parsing/multiple_function_args.ptb @@ -1,3 +1,2 @@ # Should result in an error complaining that three arguments were found --move-call std::option::is_none "'a (this is an unmatched paren in a string'" "\"b)\"" c ---gas-budget 111111 diff --git a/crates/sui/tests/ptb_files/parsing/not_keywords.ptb b/crates/sui/tests/ptb_files/parsing/not_keywords.ptb index 8883766224f7a..694297cc3d1e3 100644 --- a/crates/sui/tests/ptb_files/parsing/not_keywords.ptb +++ b/crates/sui/tests/ptb_files/parsing/not_keywords.ptb @@ -8,4 +8,3 @@ --assign none-a @0x1 --assign vector-a @0x1 ---gas-budget 11 diff --git a/crates/sui/tests/ptb_files/parsing/quote_escapes.ptb b/crates/sui/tests/ptb_files/parsing/quote_escapes.ptb index 77222c021bd1e..f74ce499d2097 100644 --- a/crates/sui/tests/ptb_files/parsing/quote_escapes.ptb +++ b/crates/sui/tests/ptb_files/parsing/quote_escapes.ptb @@ -10,4 +10,3 @@ --assign bar "']'" --assign bar "\"]\"" ---gas-budget 11 diff --git a/crates/sui/tests/ptb_files/parsing/valid_types.ptb b/crates/sui/tests/ptb_files/parsing/valid_types.ptb index 7b126438af892..bfe7b4392e672 100644 --- a/crates/sui/tests/ptb_files/parsing/valid_types.ptb +++ b/crates/sui/tests/ptb_files/parsing/valid_types.ptb @@ -32,4 +32,3 @@ # Std lib types --make-move-vec >> [vector[]] ---gas-budget 1 diff --git a/crates/sui/tests/ptb_files/parsing/whitespace_handling.ptb b/crates/sui/tests/ptb_files/parsing/whitespace_handling.ptb index 4357e8c0248d5..4daff10842a08 100644 --- a/crates/sui/tests/ptb_files/parsing/whitespace_handling.ptb +++ b/crates/sui/tests/ptb_files/parsing/whitespace_handling.ptb @@ -14,4 +14,3 @@ --make-move-vec "['1', '2, 3','',\"4 \"]" ---gas-budget 100 diff --git a/crates/sui/tests/ptb_files/publish/publish_non_existent_package.ptb b/crates/sui/tests/ptb_files/publish/publish_non_existent_package.ptb index 59008705534b7..feeb488040fec 100644 --- a/crates/sui/tests/ptb_files/publish/publish_non_existent_package.ptb +++ b/crates/sui/tests/ptb_files/publish/publish_non_existent_package.ptb @@ -1,3 +1,2 @@ ---gas-budget 1000 # Point to a non-existent package --publish not_a_valid_pkg diff --git a/crates/sui/tests/ptb_files/publish/publish_too_many_args.ptb b/crates/sui/tests/ptb_files/publish/publish_too_many_args.ptb index 1e81d7c7754ec..e47529947c710 100644 --- a/crates/sui/tests/ptb_files/publish/publish_too_many_args.ptb +++ b/crates/sui/tests/ptb_files/publish/publish_too_many_args.ptb @@ -1,3 +1,2 @@ ---gas-budget 1000 # too many args --publish too many args diff --git a/crates/sui/tests/ptb_files/publish/publish_valid.ptb b/crates/sui/tests/ptb_files/publish/publish_valid.ptb index a4f7f100e959e..b2e9474450e2d 100644 --- a/crates/sui/tests/ptb_files/publish/publish_valid.ptb +++ b/crates/sui/tests/ptb_files/publish/publish_valid.ptb @@ -1,2 +1 @@ --publish tests/ptb_files/publish/test_pkg ---gas-budget 1000000 diff --git a/crates/sui/tests/ptb_files/resolution/keyword_resolution.ptb b/crates/sui/tests/ptb_files/resolution/keyword_resolution.ptb index 6bc088a00cd9f..3a6a049cc7eb6 100644 --- a/crates/sui/tests/ptb_files/resolution/keyword_resolution.ptb +++ b/crates/sui/tests/ptb_files/resolution/keyword_resolution.ptb @@ -1,4 +1,3 @@ --assign gas @0x1 --assign none @0x1 ---gas-budget 11 diff --git a/crates/sui/tests/ptb_files/resolution/variable_resolution_fixing.ptb b/crates/sui/tests/ptb_files/resolution/variable_resolution_fixing.ptb index 1218dce77bb25..c2220c1c6224d 100644 --- a/crates/sui/tests/ptb_files/resolution/variable_resolution_fixing.ptb +++ b/crates/sui/tests/ptb_files/resolution/variable_resolution_fixing.ptb @@ -3,5 +3,3 @@ # Make sure that the second usage of 's' here binds to/uses the same input as the move call above --make-move-vec
[s] ---gas-budget 100000 - diff --git a/crates/sui/tests/ptb_files/resolution/variable_shadowing.ptb b/crates/sui/tests/ptb_files/resolution/variable_shadowing.ptb index 97b70e08d8037..93c35a88bf8c7 100644 --- a/crates/sui/tests/ptb_files/resolution/variable_shadowing.ptb +++ b/crates/sui/tests/ptb_files/resolution/variable_shadowing.ptb @@ -4,4 +4,3 @@ # Make sure that the second usage of 's' here is not the same as the first definition of 's' --make-move-vec
[s] ---gas-budget 100000 diff --git a/crates/sui/tests/ptb_files/split_coins/split_coins_valid.ptb b/crates/sui/tests/ptb_files/split_coins/split_coins_valid.ptb index aed6dd8366691..16a6a0e657d5f 100644 --- a/crates/sui/tests/ptb_files/split_coins/split_coins_valid.ptb +++ b/crates/sui/tests/ptb_files/split_coins/split_coins_valid.ptb @@ -9,4 +9,3 @@ --move-call sui::coin::destroy_zero zcoins.1 # Can merge the split coins back --merge-coins gas [coins.1, coins.2, coins.3] ---gas-budget 10000000 diff --git a/crates/sui/tests/ptb_files/transfer_objects/transfer_objects_invalid.ptb b/crates/sui/tests/ptb_files/transfer_objects/transfer_objects_invalid.ptb index 243dd897d51d0..0f6a1906e89f9 100644 --- a/crates/sui/tests/ptb_files/transfer_objects/transfer_objects_invalid.ptb +++ b/crates/sui/tests/ptb_files/transfer_objects/transfer_objects_invalid.ptb @@ -9,4 +9,3 @@ --assign s --transfer-objects s @0x1 ---gas-budget 100 diff --git a/crates/sui/tests/ptb_files/transfer_objects/transfer_objects_valid.ptb b/crates/sui/tests/ptb_files/transfer_objects/transfer_objects_valid.ptb index cbfdd436a2b21..fbcbcee737cf8 100644 --- a/crates/sui/tests/ptb_files/transfer_objects/transfer_objects_valid.ptb +++ b/crates/sui/tests/ptb_files/transfer_objects/transfer_objects_valid.ptb @@ -1,4 +1,3 @@ ---gas-budget 10000000 --split-coins gas [1,2,3] --assign s --transfer-objects [s.0, s.1, s.2] @0x1 diff --git a/crates/sui/tests/snapshots/ptb_files_tests__assign_invalid.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__assign_invalid.ptb.snap index 836a46711cc00..e17a1324325a0 100644 --- a/crates/sui/tests/snapshots/ptb_files_tests__assign_invalid.ptb.snap +++ b/crates/sui/tests/snapshots/ptb_files_tests__assign_invalid.ptb.snap @@ -80,7 +80,7 @@ expression: "results.join(\"\\n\")" 16 │ --assign gas 1 · ─┬─ · ╰── Expected a variable name but found reserved word 'gas'. - 17 │ --assign none 2 + 17 │ --assign none 2 ╰──── help: Variable names cannot be 'address', 'bool', 'vector', 'some', 'none', 'gas', 'u8', 'u16', 'u32', 'u64', 'u128', or 'u256'. @@ -88,10 +88,9 @@ expression: "results.join(\"\\n\")" × Error when processing PTB ╭─[17:10] 16 │ --assign gas 1 - 17 │ --assign none 2 + 17 │ --assign none 2 · ──┬─ · ╰── Expected a variable name but found reserved word 'none'. - 18 │ --gas-budget 1 ╰──── help: Variable names cannot be 'address', 'bool', 'vector', 'some', 'none', 'gas', 'u8', 'u16', 'u32', 'u64', 'u128', or 'u256'. diff --git a/crates/sui/tests/snapshots/ptb_files_tests__assign_valid.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__assign_valid.ptb.snap index 674f749d90147..c41fb4504ed63 100644 --- a/crates/sui/tests/snapshots/ptb_files_tests__assign_valid.ptb.snap +++ b/crates/sui/tests/snapshots/ptb_files_tests__assign_valid.ptb.snap @@ -20,8 +20,6 @@ expression: "results.join(\"\\n\")" │ assign │ c │ │ assign │ c0 c.0 │ │ assign │ c1 c.1 │ -├───────────────┼──────────────────┤ -│ gas-budget │ 1 │ ╰───────────────┴──────────────────╯ === 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, 0]) diff --git a/crates/sui/tests/snapshots/ptb_files_tests__bad_ptb.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__bad_ptb.ptb.snap index 70f3b8b799133..d912ed46c0876 100644 --- a/crates/sui/tests/snapshots/ptb_files_tests__bad_ptb.ptb.snap +++ b/crates/sui/tests/snapshots/ptb_files_tests__bad_ptb.ptb.snap @@ -48,12 +48,3 @@ expression: "results.join(\"\\n\")" 8 │ --assign Z none ╰──── - × Error when processing PTB - ╭─[9:39] - 8 │ --assign Z none - 9 │ --move-call 0x1::option::is_no Z - · ▲ - · ╰── Gas budget not set. - ╰──── - help: Use --gas-budget to set a gas budget - 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 d4feaf5575b73..0882b46531242 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 @@ -15,8 +15,6 @@ expression: "results.join(\"\\n\")" │ assign │ c0 coins.0 │ │ assign │ c1 coins.1 │ │ merge-coins │ gas [c0, c1] │ -├─────────────┼──────────────┤ -│ gas-budget │ 10000000 │ ╰─────────────┴──────────────╯ === BUILT PTB === Input 0: Pure([10, 0, 0, 0, 0, 0, 0, 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 2ff0911b80c89..42efd5cc62ea8 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 @@ -10,11 +10,3 @@ expression: "results.join(\"\\n\")" · ╰── number too large to fit in target type ╰──── - × Error when processing PTB - ╭──── - 1 │ --gas-budget 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF - · ▲ - · ╰── Gas budget not set. - ╰──── - help: Use --gas-budget to set a gas budget - diff --git a/crates/sui/tests/snapshots/ptb_files_tests__invalid_commands.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__invalid_commands.ptb.snap index 126c760e383c0..05f82215891ea 100644 --- a/crates/sui/tests/snapshots/ptb_files_tests__invalid_commands.ptb.snap +++ b/crates/sui/tests/snapshots/ptb_files_tests__invalid_commands.ptb.snap @@ -61,12 +61,3 @@ expression: "results.join(\"\\n\")" ╰──── help: Did you mean '--transfer-objects'? - × Error when processing PTB - ╭─[6:18] - 5 │ --move-vec - 6 │ --transfer-object - · ▲ - · ╰── Gas budget not set. - ╰──── - help: Use --gas-budget to set a gas budget - diff --git a/crates/sui/tests/snapshots/ptb_files_tests__invalid_types.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__invalid_types.ptb.snap index 44689ad5e9e09..b837ff6bdcd7d 100644 --- a/crates/sui/tests/snapshots/ptb_files_tests__invalid_types.ptb.snap +++ b/crates/sui/tests/snapshots/ptb_files_tests__invalid_types.ptb.snap @@ -163,12 +163,3 @@ expression: "results.join(\"\\n\")" · ╰── Expected '::' but found '>' ╰──── - × Error when processing PTB - ╭─[18:43] - 17 │ --make-move-vec > [vector[0]] - 18 │ --make-move-vec > [vector[0]] - · ▲ - · ╰── Gas budget not set. - ╰──── - help: Use --gas-budget to set a gas budget - diff --git a/crates/sui/tests/snapshots/ptb_files_tests__keyword_resolution.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__keyword_resolution.ptb.snap index 9790fb17a79ad..65a0d3cddbdbd 100644 --- a/crates/sui/tests/snapshots/ptb_files_tests__keyword_resolution.ptb.snap +++ b/crates/sui/tests/snapshots/ptb_files_tests__keyword_resolution.ptb.snap @@ -8,7 +8,7 @@ expression: "results.join(\"\\n\")" 1 │ --assign gas @0x1 · ─┬─ · ╰── Expected a variable name but found reserved word 'gas'. - 2 │ --assign none @0x1 + 2 │ --assign none @0x1 ╰──── help: Variable names cannot be 'address', 'bool', 'vector', 'some', 'none', 'gas', 'u8', 'u16', 'u32', 'u64', 'u128', or 'u256'. @@ -16,10 +16,9 @@ expression: "results.join(\"\\n\")" × Error when processing PTB ╭─[2:10] 1 │ --assign gas @0x1 - 2 │ --assign none @0x1 + 2 │ --assign none @0x1 · ──┬─ · ╰── Expected a variable name but found reserved word 'none'. - 3 │ --gas-budget 11 ╰──── help: Variable names cannot be 'address', 'bool', 'vector', 'some', 'none', 'gas', 'u8', 'u16', 'u32', 'u64', 'u128', or 'u256'. diff --git a/crates/sui/tests/snapshots/ptb_files_tests__keywords.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__keywords.ptb.snap index d4ac2236af3b7..0ba68dea16374 100644 --- a/crates/sui/tests/snapshots/ptb_files_tests__keywords.ptb.snap +++ b/crates/sui/tests/snapshots/ptb_files_tests__keywords.ptb.snap @@ -30,7 +30,7 @@ expression: "results.join(\"\\n\")" 3 │ --assign none @0x1 · ──┬─ · ╰── Expected a variable name but found reserved word 'none'. - 4 │ --assign gas @0x1 + 4 │ --assign gas @0x1 ╰──── help: Variable names cannot be 'address', 'bool', 'vector', 'some', 'none', 'gas', 'u8', 'u16', 'u32', 'u64', 'u128', or 'u256'. @@ -38,10 +38,9 @@ expression: "results.join(\"\\n\")" × Error when processing PTB ╭─[4:10] 3 │ --assign none @0x1 - 4 │ --assign gas @0x1 + 4 │ --assign gas @0x1 · ─┬─ · ╰── Expected a variable name but found reserved word 'gas'. - 5 │ --gas-budget 11 ╰──── help: Variable names cannot be 'address', 'bool', 'vector', 'some', 'none', 'gas', 'u8', 'u16', 'u32', 'u64', 'u128', or 'u256'. 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 b1e26108dc7d9..0892708851b67 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 @@ -18,8 +18,6 @@ expression: "results.join(\"\\n\")" │ make-move-vec │ > [none, some(1u64)] │ │ make-move-vec │ > [none, some(some(1u64))] │ │ make-move-vec │ > [gas] │ -├───────────────┼─────────────────────────────────────────────────────┤ -│ gas-budget │ 1000 │ ╰───────────────┴─────────────────────────────────────────────────────╯ === BUILT PTB === Input 0: Pure([1, 0, 0, 0, 0, 0, 0, 0]) 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 622f3e6bf882f..0cf734e7a5bde 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 @@ -10,8 +10,6 @@ expression: "results.join(\"\\n\")" ├───────────────┼──────────────────────────────────────┤ │ make-move-vec │ > [@0x1, @0x2, @0x3] │ │ make-move-vec │
[true, false] │ -├───────────────┼──────────────────────────────────────┤ -│ gas-budget │ 10000 │ ╰───────────────┴──────────────────────────────────────╯ === 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]) diff --git a/crates/sui/tests/snapshots/ptb_files_tests__make_move_vec_invalid_args.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__make_move_vec_invalid_args.ptb.snap index 48cf7978c977e..3a9a86922057a 100644 --- a/crates/sui/tests/snapshots/ptb_files_tests__make_move_vec_invalid_args.ptb.snap +++ b/crates/sui/tests/snapshots/ptb_files_tests__make_move_vec_invalid_args.ptb.snap @@ -4,55 +4,54 @@ expression: "results.join(\"\\n\")" --- === ERRORS AFTER PARSING INPUT COMMANDS === × Error when processing PTB - ╭─[2:17] - 1 │ --gas-budget 10000000 - 2 │ --make-move-vec [100] + ╭─[1:17] + 1 │ --make-move-vec [100] · ┬ · ╰── Expected '<' but found '[' - 3 │ --make-move-vec <> [100] + 2 │ --make-move-vec <> [100] ╰──── × Error when processing PTB - ╭─[3:18] - 2 │ --make-move-vec [100] - 3 │ --make-move-vec <> [100] + ╭─[2:18] + 1 │ --make-move-vec [100] + 2 │ --make-move-vec <> [100] · ┬ · ╰── Unexpected '>' - 4 │ --make-move-vec + 3 │ --make-move-vec ╰──── help: Expected a type here × Error when processing PTB - ╭─[5:1] - 4 │ --make-move-vec - 5 │ --make-move-vec [] + ╭─[4:1] + 3 │ --make-move-vec + 4 │ --make-move-vec [] · ───────┬─────── · ╰── Expected '[' but found command '--make-move-vec' - 6 │ --make-move-vec u64 [] + 5 │ --make-move-vec u64 [] ╰──── × Error when processing PTB - ╭─[5:21] - 4 │ --make-move-vec - 5 │ --make-move-vec [] + ╭─[4:21] + 3 │ --make-move-vec + 4 │ --make-move-vec [] · ┬ · ╰── Expected '>' but found ',' - 6 │ --make-move-vec u64 [] + 5 │ --make-move-vec u64 [] ╰──── × Error when processing PTB - ╭─[6:17] - 5 │ --make-move-vec [] - 6 │ --make-move-vec u64 [] + ╭─[5:17] + 4 │ --make-move-vec [] + 5 │ --make-move-vec u64 [] · ─┬─ · ╰── Expected '<' but found identifier 'u64' - 7 │ --make-move-vec 10 + 6 │ --make-move-vec 10 ╰──── × Error when processing PTB - ╭─[7:23] - 6 │ --make-move-vec u64 [] - 7 │ --make-move-vec 10 + ╭─[6:23] + 5 │ --make-move-vec u64 [] + 6 │ --make-move-vec 10 · ─┬ · ╰── Expected '[' but found number '10' ╰──── diff --git a/crates/sui/tests/snapshots/ptb_files_tests__merge_coins_invalid_args.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__merge_coins_invalid_args.ptb.snap index 60f6bc8496bb5..32b1d2a07785c 100644 --- a/crates/sui/tests/snapshots/ptb_files_tests__merge_coins_invalid_args.ptb.snap +++ b/crates/sui/tests/snapshots/ptb_files_tests__merge_coins_invalid_args.ptb.snap @@ -4,20 +4,20 @@ expression: "results.join(\"\\n\")" --- === ERRORS AFTER PARSING INPUT COMMANDS === × Error when processing PTB - ╭─[3:1] - 2 │ --merge-coins @0x1 - 3 │ --merge-coins @0x1 true + ╭─[2:1] + 1 │ --merge-coins @0x1 + 2 │ --merge-coins @0x1 true · ──────┬────── · ╰── Expected '[' but found command '--merge-coins' - 4 │ --merge-coins @0x1 [true, false] + 3 │ --merge-coins @0x1 [true, false] ╰──── × Error when processing PTB - ╭─[3:20] - 2 │ --merge-coins @0x1 - 3 │ --merge-coins @0x1 true + ╭─[2:20] + 1 │ --merge-coins @0x1 + 2 │ --merge-coins @0x1 true · ──┬─ · ╰── Expected '[' but found identifier 'true' - 4 │ --merge-coins @0x1 [true, false] + 3 │ --merge-coins @0x1 [true, false] ╰──── 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 b38d920674df9..dac2101b35d2a 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 @@ -19,8 +19,6 @@ expression: "results.join(\"\\n\")" │ assign │ coins │ │ merge-coins │ coins.0 [coins.1, coins.2] │ │ merge-coins │ gas [coins.0] │ -├─────────────┼────────────────────────────┤ -│ gas-budget │ 100000000 │ ╰─────────────┴────────────────────────────╯ === BUILT PTB === Input 0: Pure([1, 0, 0, 0, 0, 0, 0, 0]) diff --git a/crates/sui/tests/snapshots/ptb_files_tests__move_call.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__move_call.ptb.snap index 4be161e92201d..1646420a92cdc 100644 --- a/crates/sui/tests/snapshots/ptb_files_tests__move_call.ptb.snap +++ b/crates/sui/tests/snapshots/ptb_files_tests__move_call.ptb.snap @@ -15,8 +15,6 @@ expression: "results.join(\"\\n\")" │ move-call │ 0x1::option::is_none none │ │ assign │ a none │ │ move-call │ 0x1::option::is_none a │ -├───────────────┼────────────────────────────────┤ -│ gas-budget │ 1000 │ ╰───────────────┴────────────────────────────────╯ === BUILT PTB === Input 0: Pure([0]) diff --git a/crates/sui/tests/snapshots/ptb_files_tests__move_call_fun_resolution.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__move_call_fun_resolution.ptb.snap index 200356fd1cc2a..eeafbff14541c 100644 --- a/crates/sui/tests/snapshots/ptb_files_tests__move_call_fun_resolution.ptb.snap +++ b/crates/sui/tests/snapshots/ptb_files_tests__move_call_fun_resolution.ptb.snap @@ -3,90 +3,87 @@ source: crates/sui/tests/ptb_files_tests.rs expression: "results.join(\"\\n\")" --- === PREVIEW === -╭─────────────────────────────────────────────────────╮ -│ PTB Preview │ -├────────────┬────────────────────────────────────────┤ -│ command │ values │ -├────────────┼────────────────────────────────────────┤ -│ move-call │ zero_x_zero::option::is_none none │ -│ assign │ a none │ -│ assign │ zero_x_zero @0x0 │ -│ move-call │ zero_x_zero::option::is_none a │ -│ move-call │ std::Option::is_none a │ -│ move-call │ std::option::isnone a │ -│ move-call │ std::option::is_none │ -│ move-call │ std::option::is_none a b │ -│ move-call │ sui::coin::destroy_zero @0x1 │ -│ move-call │ std::option::is_none a │ -├────────────┼────────────────────────────────────────┤ -│ gas-budget │ 1000 │ -╰────────────┴────────────────────────────────────────╯ +╭────────────────────────────────────────────────────╮ +│ PTB Preview │ +├───────────┬────────────────────────────────────────┤ +│ command │ values │ +├───────────┼────────────────────────────────────────┤ +│ move-call │ zero_x_zero::option::is_none none │ +│ assign │ a none │ +│ assign │ zero_x_zero @0x0 │ +│ move-call │ zero_x_zero::option::is_none a │ +│ move-call │ std::Option::is_none a │ +│ move-call │ std::option::isnone a │ +│ move-call │ std::option::is_none │ +│ move-call │ std::option::is_none a b │ +│ move-call │ sui::coin::destroy_zero @0x1 │ +│ move-call │ std::option::is_none a │ +╰───────────┴────────────────────────────────────────╯ === BUILDING PTB ERRORS === × Error when processing PTB - ╭─[2:13] - 1 │ --gas-budget 1000 - 2 │ --move-call zero_x_zero::option::is_none none + ╭─[1:13] + 1 │ --move-call zero_x_zero::option::is_none none · ─────┬───── · ╰── Unbound named address: 'zero_x_zero' - 3 │ --assign a none + 2 │ --assign a none ╰──── help: This is most likely because the named address 'zero_x_zero' is not in scope. You can either bind a variable to the address that you want to use or use the address in the command. × Error when processing PTB - ╭─[5:13] - 4 │ --assign zero_x_zero @0x0 - 5 │ --move-call zero_x_zero::option::is_none a + ╭─[4:13] + 3 │ --assign zero_x_zero @0x0 + 4 │ --move-call zero_x_zero::option::is_none a · ─────┬───── · ╰── Object 0x0000000000000000000000000000000000000000000000000000000000000000 does not exist. - 6 │ --move-call std::Option::is_none a + 5 │ --move-call std::Option::is_none a ╰──── × Error when processing PTB - ╭─[6:18] - 5 │ --move-call zero_x_zero::option::is_none a - 6 │ --move-call std::Option::is_none a + ╭─[5:18] + 4 │ --move-call zero_x_zero::option::is_none a + 5 │ --move-call std::Option::is_none a · ───┬── · ╰── Module not found in package: "Option". - 7 │ --move-call std::option::isnone a + 6 │ --move-call std::option::isnone a ╰──── help: Did you mean 'option'? × Error when processing PTB - ╭─[7:26] - 6 │ --move-call std::Option::is_none a - 7 │ --move-call std::option::isnone a + ╭─[6:26] + 5 │ --move-call std::Option::is_none a + 6 │ --move-call std::option::isnone a · ───┬── · ╰── Could not resolve function 'isnone' in module 'option' - 8 │ --move-call std::option::is_none + 7 │ --move-call std::option::is_none ╰──── help: Did you mean 'is_none'? × Error when processing PTB - ╭─[8:13] - 7 │ --move-call std::option::isnone a - 8 │ --move-call std::option::is_none + ╭─[7:13] + 6 │ --move-call std::option::isnone a + 7 │ --move-call std::option::is_none · ──────────┬───────── · ╰── Expected 1 argument, but got 0 - 9 │ --move-call std::option::is_none a b + 8 │ --move-call std::option::is_none a b ╰──── × Error when processing PTB - ╭─[9:39] - 8 │ --move-call std::option::is_none - 9 │ --move-call std::option::is_none a b - · ─┬─ - · ╰── Expected 1 argument, but got 2 - 10 │ --move-call sui::coin::destroy_zero @0x1 - ╰──── + ╭─[8:39] + 7 │ --move-call std::option::is_none + 8 │ --move-call std::option::is_none a b + · ─┬─ + · ╰── Expected 1 argument, but got 2 + 9 │ --move-call sui::coin::destroy_zero @0x1 + ╰──── × Error when processing PTB - ╭─[10:37] - 9 │ --move-call std::option::is_none a b - 10 │ --move-call sui::coin::destroy_zero @0x1 + ╭─[9:37] + 8 │ --move-call std::option::is_none a b + 9 │ --move-call sui::coin::destroy_zero @0x1 · ──┬─ · ╰── Not enough type parameters supplied for Move call - 11 │ --move-call std::option::is_none a + 10 │ --move-call std::option::is_none a ╰──── diff --git a/crates/sui/tests/snapshots/ptb_files_tests__move_call_parsing.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__move_call_parsing.ptb.snap index 03e4be538f9a4..ac7e6646b633f 100644 --- a/crates/sui/tests/snapshots/ptb_files_tests__move_call_parsing.ptb.snap +++ b/crates/sui/tests/snapshots/ptb_files_tests__move_call_parsing.ptb.snap @@ -4,9 +4,8 @@ expression: "results.join(\"\\n\")" --- === ERRORS AFTER PARSING INPUT COMMANDS === × Error when processing PTB - ╭─[2:27] - 1 │ --gas-budget 1000 - 2 │ --move-call invalid_access + ╭──── + 1 │ --move-call invalid_access · ▲ · ╰── Expected '::' but found end of input ╰──── diff --git a/crates/sui/tests/snapshots/ptb_files_tests__multiple_function_args.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__multiple_function_args.ptb.snap index 1727ace9109d0..2d0ecc150147e 100644 --- a/crates/sui/tests/snapshots/ptb_files_tests__multiple_function_args.ptb.snap +++ b/crates/sui/tests/snapshots/ptb_files_tests__multiple_function_args.ptb.snap @@ -3,21 +3,18 @@ source: crates/sui/tests/ptb_files_tests.rs expression: "results.join(\"\\n\")" --- === PREVIEW === -╭───────────────────────────────────────────────────────────────────────────────────────────╮ -│ PTB Preview │ -├────────────┬──────────────────────────────────────────────────────────────────────────────┤ -│ command │ values │ -├────────────┼──────────────────────────────────────────────────────────────────────────────┤ -│ move-call │ std::option::is_none "a (this is an unmatched paren in a string" "b)" c │ -├────────────┼──────────────────────────────────────────────────────────────────────────────┤ -│ gas-budget │ 111111 │ -╰────────────┴──────────────────────────────────────────────────────────────────────────────╯ +╭──────────────────────────────────────────────────────────────────────────────────────────╮ +│ PTB Preview │ +├───────────┬──────────────────────────────────────────────────────────────────────────────┤ +│ command │ values │ +├───────────┼──────────────────────────────────────────────────────────────────────────────┤ +│ move-call │ std::option::is_none "a (this is an unmatched paren in a string" "b)" c │ +╰───────────┴──────────────────────────────────────────────────────────────────────────────╯ === BUILDING PTB ERRORS === × Error when processing PTB - ╭─[1:40] - 1 │ --move-call std::option::is_none 'a (this is an unmatched paren in a string' "b)" c + ╭──── + 1 │ --move-call std::option::is_none 'a (this is an unmatched paren in a string' "b)" c · ─────────────────────────┬──────────────────────── · ╰── Expected 1 argument, but got 3 - 2 │ --gas-budget 111111 ╰──── diff --git a/crates/sui/tests/snapshots/ptb_files_tests__non_integer_gas_budget.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__non_integer_gas_budget.ptb.snap index c4942541956ce..3d5b7c2c4ee57 100644 --- a/crates/sui/tests/snapshots/ptb_files_tests__non_integer_gas_budget.ptb.snap +++ b/crates/sui/tests/snapshots/ptb_files_tests__non_integer_gas_budget.ptb.snap @@ -10,11 +10,3 @@ expression: "results.join(\"\\n\")" · ╰── Expected a u64 value ╰──── - × Error when processing PTB - ╭──── - 1 │ --gas-budget @0x1 - · ▲ - · ╰── Gas budget not set. - ╰──── - help: Use --gas-budget to set a gas budget - diff --git a/crates/sui/tests/snapshots/ptb_files_tests__not_keywords.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__not_keywords.ptb.snap index 101baa222dc06..06dc83990c957 100644 --- a/crates/sui/tests/snapshots/ptb_files_tests__not_keywords.ptb.snap +++ b/crates/sui/tests/snapshots/ptb_files_tests__not_keywords.ptb.snap @@ -3,20 +3,18 @@ source: crates/sui/tests/ptb_files_tests.rs expression: "results.join(\"\\n\")" --- === PREVIEW === -╭────────────────────────────╮ -│ PTB Preview │ -├────────────┬───────────────┤ -│ command │ values │ -├────────────┼───────────────┤ -│ assign │ gasa @0x1 │ -│ assign │ somea @0x1 │ -│ assign │ nonea @0x1 │ -│ assign │ vectora @0x1 │ -│ assign │ gas-a @0x1 │ -│ assign │ some-a @0x1 │ -│ assign │ none-a @0x1 │ -│ assign │ vector-a @0x1 │ -├────────────┼───────────────┤ -│ gas-budget │ 11 │ -╰────────────┴───────────────╯ +╭─────────────────────────╮ +│ PTB Preview │ +├─────────┬───────────────┤ +│ command │ values │ +├─────────┼───────────────┤ +│ assign │ gasa @0x1 │ +│ assign │ somea @0x1 │ +│ assign │ nonea @0x1 │ +│ assign │ vectora @0x1 │ +│ assign │ gas-a @0x1 │ +│ assign │ some-a @0x1 │ +│ assign │ none-a @0x1 │ +│ assign │ vector-a @0x1 │ +╰─────────┴───────────────╯ === BUILT PTB === 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 86bce195b4749..4f30342196bf7 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 @@ -11,8 +11,6 @@ expression: "results.join(\"\\n\")" │ split-coins │ @0x5 [1000u64] │ │ assign │ result │ │ transfer-objects │ [result.0] @0x6 │ -├──────────────────┼─────────────────┤ -│ gas-budget │ 100000 │ ╰──────────────────┴─────────────────╯ === BUILT PTB === Input 0: SharedObject(mutable: true) diff --git a/crates/sui/tests/snapshots/ptb_files_tests__publish_non_existent_package.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__publish_non_existent_package.ptb.snap index 92ae6f8183dca..bcd4f5da85243 100644 --- a/crates/sui/tests/snapshots/ptb_files_tests__publish_non_existent_package.ptb.snap +++ b/crates/sui/tests/snapshots/ptb_files_tests__publish_non_existent_package.ptb.snap @@ -3,20 +3,17 @@ source: crates/sui/tests/ptb_files_tests.rs expression: "results.join(\"\\n\")" --- === PREVIEW === -╭──────────────────────────────╮ -│ PTB Preview │ -├────────────┬─────────────────┤ -│ command │ values │ -├────────────┼─────────────────┤ -│ publish │ not_a_valid_pkg │ -├────────────┼─────────────────┤ -│ gas-budget │ 1000 │ -╰────────────┴─────────────────╯ +╭───────────────────────────╮ +│ PTB Preview │ +├─────────┬─────────────────┤ +│ command │ values │ +├─────────┼─────────────────┤ +│ publish │ not_a_valid_pkg │ +╰─────────┴─────────────────╯ === BUILDING PTB ERRORS === × Error when processing PTB - ╭─[2:1] - 1 │ --gas-budget 1000 - 2 │ --publish not_a_valid_pkg + ╭──── + 1 │ --publish not_a_valid_pkg · ────────────┬──────────── · ╰── No such file or directory (os error 2) ╰──── diff --git a/crates/sui/tests/snapshots/ptb_files_tests__publish_too_many_args.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__publish_too_many_args.ptb.snap index 0d2136d2fcf5e..a73e63df2a89f 100644 --- a/crates/sui/tests/snapshots/ptb_files_tests__publish_too_many_args.ptb.snap +++ b/crates/sui/tests/snapshots/ptb_files_tests__publish_too_many_args.ptb.snap @@ -4,9 +4,8 @@ expression: "results.join(\"\\n\")" --- === ERRORS AFTER PARSING INPUT COMMANDS === × Error when processing PTB - ╭─[2:15] - 1 │ --gas-budget 1000 - 2 │ --publish too many args + ╭──── + 1 │ --publish too many args · ──┬─ · ╰── Unexpected identifier 'many' ╰──── diff --git a/crates/sui/tests/snapshots/ptb_files_tests__publish_valid.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__publish_valid.ptb.snap index b123f5b19212d..0fda4fef99905 100644 --- a/crates/sui/tests/snapshots/ptb_files_tests__publish_valid.ptb.snap +++ b/crates/sui/tests/snapshots/ptb_files_tests__publish_valid.ptb.snap @@ -3,14 +3,12 @@ source: crates/sui/tests/ptb_files_tests.rs expression: "results.join(\"\\n\")" --- === PREVIEW === -╭───────────────────────────────────────────────╮ -│ PTB Preview │ -├────────────┬──────────────────────────────────┤ -│ command │ values │ -├────────────┼──────────────────────────────────┤ -│ publish │ tests/ptb_files/publish/test_pkg │ -├────────────┼──────────────────────────────────┤ -│ gas-budget │ 1000000 │ -╰────────────┴──────────────────────────────────╯ +╭────────────────────────────────────────────╮ +│ PTB Preview │ +├─────────┬──────────────────────────────────┤ +│ command │ values │ +├─────────┼──────────────────────────────────┤ +│ publish │ tests/ptb_files/publish/test_pkg │ +╰─────────┴──────────────────────────────────╯ === BUILT PTB === Command 0: Publish(_,) diff --git a/crates/sui/tests/snapshots/ptb_files_tests__quote_escapes.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__quote_escapes.ptb.snap index 717763c3c1baf..3cfa584bc85a3 100644 --- a/crates/sui/tests/snapshots/ptb_files_tests__quote_escapes.ptb.snap +++ b/crates/sui/tests/snapshots/ptb_files_tests__quote_escapes.ptb.snap @@ -3,20 +3,18 @@ source: crates/sui/tests/ptb_files_tests.rs expression: "results.join(\"\\n\")" --- === PREVIEW === -╭──────────────────────╮ -│ PTB Preview │ -├────────────┬─────────┤ -│ command │ values │ -├────────────┼─────────┤ -│ assign │ bar "(" │ -│ assign │ bar "(" │ -│ assign │ bar ")" │ -│ assign │ bar ")" │ -│ assign │ bar "[" │ -│ assign │ bar "[" │ -│ assign │ bar "]" │ -│ assign │ bar "]" │ -├────────────┼─────────┤ -│ gas-budget │ 11 │ -╰────────────┴─────────╯ +╭───────────────────╮ +│ PTB Preview │ +├─────────┬─────────┤ +│ command │ values │ +├─────────┼─────────┤ +│ assign │ bar "(" │ +│ assign │ bar "(" │ +│ assign │ bar ")" │ +│ assign │ bar ")" │ +│ assign │ bar "[" │ +│ assign │ bar "[" │ +│ assign │ bar "]" │ +│ assign │ bar "]" │ +╰─────────┴─────────╯ === BUILT PTB === diff --git a/crates/sui/tests/snapshots/ptb_files_tests__resolve_array_inside_array.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__resolve_array_inside_array.ptb.snap index e05d349e727b6..7ad70f9396bae 100644 --- a/crates/sui/tests/snapshots/ptb_files_tests__resolve_array_inside_array.ptb.snap +++ b/crates/sui/tests/snapshots/ptb_files_tests__resolve_array_inside_array.ptb.snap @@ -4,9 +4,8 @@ expression: "results.join(\"\\n\")" --- === ERRORS AFTER PARSING INPUT COMMANDS === × Error when processing PTB - ╭─[2:36] - 1 │ --gas-budget 10000 - 2 │ --make-move-vec > [[@0x1], [@0x2], [@0x3]] + ╭──── + 1 │ --make-move-vec > [[@0x1], [@0x2], [@0x3]] · ┬ · ╰── Unexpected '[' ╰──── diff --git a/crates/sui/tests/snapshots/ptb_files_tests__resolve_array_inside_array_through_bindings.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__resolve_array_inside_array_through_bindings.ptb.snap index 525c326695a2f..d7a87af338940 100644 --- a/crates/sui/tests/snapshots/ptb_files_tests__resolve_array_inside_array_through_bindings.ptb.snap +++ b/crates/sui/tests/snapshots/ptb_files_tests__resolve_array_inside_array_through_bindings.ptb.snap @@ -11,8 +11,6 @@ expression: "results.join(\"\\n\")" │ make-move-vec │
[@0x1] │ │ assign │ a │ │ make-move-vec │ > [a, a] │ -├───────────────┼──────────────────────────┤ -│ gas-budget │ 1000000000 │ ╰───────────────┴──────────────────────────╯ === 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]) 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 5f5003389fea3..bd91cd97bd2c8 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 @@ -13,8 +13,6 @@ expression: "results.join(\"\\n\")" │ assign │ b 4u64 │ │ assign │ a a │ │ assign │ a 4u64 │ -├──────────────┼────────┤ -│ gas-budget │ 1 │ │ warn-shadows │ true │ ╰──────────────┴────────╯ === WARNINGS === @@ -54,7 +52,7 @@ expression: "results.join(\"\\n\")" 5 │ --assign a 4 · ┬ · ╰── Variable 'a' used again here (shadowed) for the 4th time. - 6 │ --gas-budget 1 + 6 │ --warn-shadows ╰──── help: You can either rename this variable, or do not pass the `warn- shadows` flag to ignore these types of errors. diff --git a/crates/sui/tests/snapshots/ptb_files_tests__split_coins_invalid.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__split_coins_invalid.ptb.snap index 1c6634b52fc26..ff0c0a3a67a6e 100644 --- a/crates/sui/tests/snapshots/ptb_files_tests__split_coins_invalid.ptb.snap +++ b/crates/sui/tests/snapshots/ptb_files_tests__split_coins_invalid.ptb.snap @@ -31,12 +31,3 @@ expression: "results.join(\"\\n\")" ╰──── help: Expected an argument here - × Error when processing PTB - ╭─[3:22] - 2 │ --split-coins gas [0] 5 - 3 │ --split-coins [1] gas - · ▲ - · ╰── Gas budget not set. - ╰──── - help: Use --gas-budget to set a gas budget - 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 f097b40c251d1..9f757169670c8 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 @@ -16,8 +16,6 @@ expression: "results.join(\"\\n\")" │ move-call │ sui::coin::destroy_zero zcoins.0 │ │ move-call │ sui::coin::destroy_zero zcoins.1 │ │ merge-coins │ gas [coins.1, coins.2, coins.3] │ -├─────────────┼─────────────────────────────────────────────────┤ -│ gas-budget │ 10000000 │ ╰─────────────┴─────────────────────────────────────────────────╯ === BUILT PTB === Input 0: Pure([0, 0, 0, 0, 0, 0, 0, 0]) diff --git a/crates/sui/tests/snapshots/ptb_files_tests__transfer_objects_invalid.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__transfer_objects_invalid.ptb.snap index 12d148be32888..b0acd0fe3cf21 100644 --- a/crates/sui/tests/snapshots/ptb_files_tests__transfer_objects_invalid.ptb.snap +++ b/crates/sui/tests/snapshots/ptb_files_tests__transfer_objects_invalid.ptb.snap @@ -23,9 +23,8 @@ expression: "results.join(\"\\n\")" × Error when processing PTB ╭─[5:20] 4 │ --assign s - 5 │ --transfer-objects s @0x1 + 5 │ --transfer-objects s @0x1 · ┬ · ╰── Expected '[' but found identifier 's' - 6 │ --gas-budget 100 ╰──── 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 b8df2a012f8fc..3ef885545d265 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 @@ -11,8 +11,6 @@ expression: "results.join(\"\\n\")" │ split-coins │ gas [1u64, 2u64, 3u64] │ │ assign │ s │ │ transfer-objects │ [s.0, s.1, s.2] @0x1 │ -├──────────────────┼────────────────────────┤ -│ gas-budget │ 10000000 │ ╰──────────────────┴────────────────────────╯ === BUILT PTB === Input 0: Pure([1, 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 cd19e22d104c8..12d2e68938fa3 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 @@ -32,8 +32,6 @@ expression: "results.join(\"\\n\")" │ assign │ f 0u256 │ │ make-move-vec │ >>> [none] │ │ make-move-vec │ >> [vector[]] │ -├───────────────┼───────────────────────────────────────────────────────────────┤ -│ gas-budget │ 1 │ ╰───────────────┴───────────────────────────────────────────────────────────────╯ === 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]) diff --git a/crates/sui/tests/snapshots/ptb_files_tests__variable_resolution_fixing.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__variable_resolution_fixing.ptb.snap index b43710b336ffd..bcac7513dc56f 100644 --- a/crates/sui/tests/snapshots/ptb_files_tests__variable_resolution_fixing.ptb.snap +++ b/crates/sui/tests/snapshots/ptb_files_tests__variable_resolution_fixing.ptb.snap @@ -11,8 +11,6 @@ expression: "results.join(\"\\n\")" │ assign │ s @0x1 │ │ move-call │ sui::coin::value s │ │ make-move-vec │
[s] │ -├───────────────┼───────────────────────────────────┤ -│ gas-budget │ 100000 │ ╰───────────────┴───────────────────────────────────╯ === BUILT PTB === Input 0: ImmutableOrOwnedObject diff --git a/crates/sui/tests/snapshots/ptb_files_tests__variable_shadowing.ptb.snap b/crates/sui/tests/snapshots/ptb_files_tests__variable_shadowing.ptb.snap index 9759ce77fcac2..374910048cd37 100644 --- a/crates/sui/tests/snapshots/ptb_files_tests__variable_shadowing.ptb.snap +++ b/crates/sui/tests/snapshots/ptb_files_tests__variable_shadowing.ptb.snap @@ -12,8 +12,6 @@ expression: "results.join(\"\\n\")" │ move-call │ sui::coin::destroy_zero s │ │ assign │ s @0x2 │ │ make-move-vec │
[s] │ -├───────────────┼──────────────────────────────────────────┤ -│ gas-budget │ 100000 │ ╰───────────────┴──────────────────────────────────────────╯ === BUILT PTB === Input 0: ImmutableOrOwnedObject 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 649bf7d58c295..1bb95a14e51e3 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 @@ -16,8 +16,6 @@ expression: "results.join(\"\\n\")" │ make-move-vec │ [1u64, 2u64, 3u64, 4u64] │ │ make-move-vec │ ["1", "2, 3", "", "4 "] │ │ make-move-vec │ ["1", "2, 3", "", "4 \n "] │ -├───────────────┼─────────────────────────────────────────────────────────────────────────────────────────┤ -│ gas-budget │ 100 │ ╰───────────────┴─────────────────────────────────────────────────────────────────────────────────────────╯ === BUILT PTB === Input 0: Pure([1, 0, 0, 0, 0, 0, 0, 0]) diff --git a/docs/content/references/cli/ptb.mdx b/docs/content/references/cli/ptb.mdx index bda81fcff84ba..5c993245ac58a 100644 --- a/docs/content/references/cli/ptb.mdx +++ b/docs/content/references/cli/ptb.mdx @@ -10,26 +10,107 @@ The `client ptb` command allows you to specify the transactions for execution in The following list itemizes all the available args for the `sui client ptb` command. Use the `--help` for a long help version that includes some examples on how to use this command. ``` -Build, preview, and execute PTBs. Depending on your shell, you might have to use quotes around arrays or other passed values. Use --help to see examples for how to use the core functionality of this command. +Build, preview, and execute programmable transaction blocks. Depending on your shell, you might have to use quotes around arrays or other passed values. Use --help to see examples for how to use the core functionality of this +command. Usage: sui client ptb [OPTIONS] Options: - --assign Assign a value to a variable name to use later in the PTB. - --gas-coin The object ID of the gas coin to use. If not specified, it will try to use the first gas coin that it finds that has at least the requested gas-budget balance. - --gas-budget The gas budget for the transaction, in MIST. - --make-move-vec <[VALUES]> Given n-values of the same type, it constructs a vector. For non objects or an empty vector, the type tag must be specified. - --merge-coins <[COIN OBJECTS]> Merge N coins into the provided coin. - --move-call Make a move call to a function. - --split-coins <[AMOUNT]> Split the coin into N coins as per the given array of amounts. - --transfer-objects <[OBJECTS]> Transfer objects to the specified address. - --publish Publish the move package. It takes as input the folder where the package exists. - --upgrade Upgrade the move package. It takes as input the folder where the package exists. - --preview Preview the list of PTB transactions instead of executing them. - --summary Show only a short summary (digest, execution status, gas cost). Do not use this flag when you need all the transaction data and the execution effects. - --warn-shadows Enable shadow warning when the same variable name is declared multiple times. Off by default. - --json Return command outputs in json format - -h, --help Print help (see more with '--help') + --assign + Assign a value to a variable name to use later in the PTB. + If only a name is supplied, the result of the last transaction is bound to that name. + If a name and value are supplied, then the name is bound to that value. + + Examples: + --assign MYVAR 100 + --assign X [100,5000] + --split-coins gas [1000, 5000, 75000] + --assign new_coins # bound new_coins to the result of previous transaction + + --dry-run + Perform a dry run of the PTB instead of executing it. + + --gas-coin + The object ID of the gas coin to use. If not specified, it will try to use the first gas coin that it finds that has at least the requested gas-budget balance. + + --gas-budget + An optional gas budget for this PTB (in MIST). If gas budget is not provided, the tool will first perform a dry run to estimate the gas cost, and then it will execute the transaction. Please note that this incurs a small + cost in performance due to the additional dry run call. + + --make-move-vec <[VALUES]> + Given n-values of the same type, it constructs a vector. For non objects or an empty vector, the type tag must be specified. + + Examples: + --make-move-vec [] + --make-move-vec [1, 2, 3, 4] + --make-move-vec > [none,none] + --make-move-vec > [gas] + + --merge-coins <[COIN OBJECTS]> + Merge N coins into the provided coin. + + Examples: + --merge-coins @coin_object_id [@coin_obj_id1, @coin_obj_id2] + + --move-call + Make a move call to a function. + + Examples: + --move-call std::option::is_none none + --assign a none + --move-call std::option::is_none a + + --split-coins <[AMOUNT]> + Split the coin into N coins as per the given array of amounts. + + Examples: + --split-coins gas [1000, 5000, 75000] + --assign new_coins # bounds the result of split-coins command to variable new_coins + --split-coins @coin_object_id [100] + + --transfer-objects <[OBJECTS]> + Transfer objects to the specified address. + + Examples: + --transfer-objects [obj1, obj2, obj3] @address + + --split-coins gas [1000, 5000, 75000] + --assign new_coins # bound new_coins to result of split-coins to use next + --transfer-objects [new_coins.0, new_coins.1, new_coins.2] @to_address + + --publish + Publish the Move package. It takes as input the folder where the package exists. + + Examples: + --move-call sui::tx_context::sender + --assign sender + --publish "." + --assign upgrade_cap + --transfer-objects sender "[upgrade_cap]" + + --upgrade + Upgrade the move package. It takes as input the folder where the package exists. + + --preview + Preview the list of PTB transactions instead of executing them. + + --serialize-unsigned-transaction + Instead of executing the transaction, serialize the bcs bytes of the unsigned transaction data using base64 encoding. + + --serialize-signed-transaction + Instead of executing the transaction, serialize the bcs bytes of the signed transaction data using base64 encoding. + + --summary + Show only a short summary (digest, execution status, gas cost). Do not use this flag when you need all the transaction data and the execution effects. + + --warn-shadows + Enable shadow warning when the same variable name is declared multiple times. Off by default. + + --json + Return command outputs in json format. + + -h, --help + Print help (see a summary with '-h') ``` ## Design philosophy and concepts