Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions cmd/soroban-cli/src/commands/contract/deploy/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use clap::{arg, command, Parser};
use std::convert::Infallible;
use std::{array::TryFromSliceError, fmt::Debug, num::ParseIntError};

use crate::commands::tx::fetch;
use crate::{
assembled::simulate_and_assemble_transaction,
commands::{
Expand All @@ -29,24 +30,39 @@ use crate::commands::contract::deploy::utils::alias_validator;
pub enum Error {
#[error("error parsing int: {0}")]
ParseIntError(#[from] ParseIntError),

#[error(transparent)]
Client(#[from] SorobanRpcError),

#[error("internal conversion error: {0}")]
TryFromSliceError(#[from] TryFromSliceError),

#[error("xdr processing error: {0}")]
Xdr(#[from] XdrError),

#[error(transparent)]
Config(#[from] config::Error),

#[error(transparent)]
Data(#[from] data::Error),

#[error(transparent)]
Network(#[from] network::Error),

#[error(transparent)]
Builder(#[from] builder::Error),

#[error(transparent)]
Asset(#[from] builder::asset::Error),

#[error(transparent)]
Locator(#[from] locator::Error),

#[error(transparent)]
Fee(#[from] fetch::fee::Error),

#[error(transparent)]
Fetch(#[from] fetch::Error),
}

impl From<Infallible> for Error {
Expand Down Expand Up @@ -152,16 +168,19 @@ impl NetworkRunnable for Cmd {
return Ok(TxnResult::Txn(Box::new(tx)));
}

let txn =
let assembled =
simulate_and_assemble_transaction(&client, &tx, self.fee.resource_config()).await?;
let txn = self.fee.apply_to_assembled_txn(txn).transaction().clone();
let assembled = self.fee.apply_to_assembled_txn(assembled);

let txn = assembled.transaction().clone();
let get_txn_resp = client
.send_transaction_polling(&self.config.sign(txn).await?)
.await?
.try_into()?;
.await?;

self.fee.print_cost_info(&get_txn_resp)?;

if args.is_none_or(|a| !a.no_cache) {
data::write(get_txn_resp, &network.rpc_uri()?)?;
data::write(get_txn_resp.clone().try_into()?, &network.rpc_uri()?)?;
}

Ok(TxnResult::Res(stellar_strkey::Contract(contract_id.0)))
Expand Down
45 changes: 36 additions & 9 deletions cmd/soroban-cli/src/commands/contract/deploy/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ use crate::xdr::{
use clap::{arg, command, Parser};
use rand::Rng;

use soroban_spec_tools::contract as contract_spec;

use crate::commands::tx::fetch;
use crate::{
assembled::simulate_and_assemble_transaction,
commands::{
Expand All @@ -30,6 +29,7 @@ use crate::{
utils::{self, rpc::get_remote_wasm_from_hash},
wasm,
};
use soroban_spec_tools::contract as contract_spec;

pub const CONSTRUCTOR_FUNCTION_NAME: &str = "__constructor";

Expand Down Expand Up @@ -74,52 +74,78 @@ pub struct Cmd {
pub enum Error {
#[error(transparent)]
Install(#[from] upload::Error),

#[error("error parsing int: {0}")]
ParseIntError(#[from] ParseIntError),

#[error("internal conversion error: {0}")]
TryFromSliceError(#[from] TryFromSliceError),

#[error("xdr processing error: {0}")]
Xdr(#[from] XdrError),

#[error("jsonrpc error: {0}")]
JsonRpc(#[from] jsonrpsee_core::Error),

#[error("cannot parse salt: {salt}")]
CannotParseSalt { salt: String },

#[error("cannot parse contract ID {contract_id}: {error}")]
CannotParseContractId {
contract_id: String,
error: stellar_strkey::DecodeError,
},

#[error("cannot parse WASM hash {wasm_hash}: {error}")]
CannotParseWasmHash {
wasm_hash: String,
error: stellar_strkey::DecodeError,
},

#[error("Must provide either --wasm or --wash-hash")]
WasmNotProvided,

#[error(transparent)]
Rpc(#[from] rpc::Error),

#[error(transparent)]
Config(#[from] config::Error),

#[error(transparent)]
StrKey(#[from] stellar_strkey::DecodeError),

#[error(transparent)]
Infallible(#[from] std::convert::Infallible),

#[error(transparent)]
WasmId(#[from] contract::id::wasm::Error),

#[error(transparent)]
Data(#[from] data::Error),

#[error(transparent)]
Network(#[from] network::Error),

#[error(transparent)]
Wasm(#[from] wasm::Error),

#[error(transparent)]
Locator(#[from] locator::Error),

#[error(transparent)]
ContractSpec(#[from] contract_spec::Error),

#[error(transparent)]
ArgParse(#[from] arg_parsing::Error),

#[error("Only ed25519 accounts are allowed")]
OnlyEd25519AccountsAllowed,

#[error(transparent)]
Fee(#[from] fetch::fee::Error),

#[error(transparent)]
Fetch(#[from] fetch::Error),
}

impl Cmd {
Expand Down Expand Up @@ -282,21 +308,22 @@ impl NetworkRunnable for Cmd {

print.infoln("Simulating deploy transaction…");

let txn =
let assembled =
simulate_and_assemble_transaction(&client, &txn, self.fee.resource_config()).await?;
let txn = Box::new(self.fee.apply_to_assembled_txn(txn).transaction().clone());
let assembled = self.fee.apply_to_assembled_txn(assembled);

let txn = Box::new(assembled.transaction().clone());

print.log_transaction(&txn, &network, true)?;
let signed_txn = &config.sign(*txn).await?;
print.globeln("Submitting deploy transaction…");

let get_txn_resp = client
.send_transaction_polling(signed_txn)
.await?
.try_into()?;
let get_txn_resp = client.send_transaction_polling(signed_txn).await?;

self.fee.print_cost_info(&get_txn_resp)?;

if global_args.is_none_or(|a| !a.no_cache) {
data::write(get_txn_resp, &network.rpc_uri()?)?;
data::write(get_txn_resp.clone().try_into()?, &network.rpc_uri()?)?;
}

if let Some(url) = utils::explorer_url_for_contract(&network, &contract_id) {
Expand Down
35 changes: 31 additions & 4 deletions cmd/soroban-cli/src/commands/contract/extend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use crate::{
};
use clap::{command, Parser};

use crate::commands::tx::fetch;
use crate::{
assembled::simulate_and_assemble_transaction,
commands::{
Expand All @@ -31,13 +32,17 @@ pub struct Cmd {
/// Number of ledgers to extend the entries
#[arg(long, required = true)]
pub ledgers_to_extend: u32,

/// Only print the new Time To Live ledger
#[arg(long)]
pub ttl_ledger_only: bool,

#[command(flatten)]
pub key: key::Args,

#[command(flatten)]
pub config: config::Args,

#[command(flatten)]
pub fee: crate::fee::Args,
}
Expand All @@ -64,37 +69,57 @@ pub enum Error {
key: String,
error: soroban_spec_tools::Error,
},

#[error("parsing XDR key {key}: {error}")]
CannotParseXdrKey { key: String, error: XdrError },

#[error(transparent)]
Config(#[from] config::Error),

#[error("either `--key` or `--key-xdr` are required")]
KeyIsRequired,

#[error("xdr processing error: {0}")]
Xdr(#[from] XdrError),

#[error("Ledger entry not found")]
LedgerEntryNotFound,

#[error("missing operation result")]
MissingOperationResult,

#[error(transparent)]
Rpc(#[from] rpc::Error),

#[error(transparent)]
Wasm(#[from] wasm::Error),

#[error(transparent)]
Key(#[from] key::Error),

#[error(transparent)]
Data(#[from] data::Error),

#[error(transparent)]
Network(#[from] network::Error),

#[error(transparent)]
Locator(#[from] locator::Error),

#[error(transparent)]
IntError(#[from] TryFromIntError),

#[error("Failed to fetch state archival settings from network")]
StateArchivalSettingsNotFound,

#[error("Ledgers to extend ({requested}) exceeds network maximum ({max})")]
LedgersToExtendTooLarge { requested: u32, max: u32 },

#[error(transparent)]
Fee(#[from] fetch::fee::Error),

#[error(transparent)]
Fetch(#[from] fetch::Error),
}

impl Cmd {
Expand Down Expand Up @@ -210,13 +235,15 @@ impl NetworkRunnable for Cmd {
if self.fee.build_only {
return Ok(TxnResult::Txn(tx));
}
let tx = simulate_and_assemble_transaction(&client, &tx, self.fee.resource_config())
.await?
.transaction()
.clone();
let assembled =
simulate_and_assemble_transaction(&client, &tx, self.fee.resource_config()).await?;

let tx = assembled.transaction().clone();
let res = client
.send_transaction_polling(&config.sign(tx).await?)
.await?;
self.fee.print_cost_info(&res)?;

if args.is_none_or(|a| !a.no_cache) {
data::write(res.clone().try_into()?, &network.rpc_uri()?)?;
}
Expand Down
Loading