Skip to content
Open
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
6 changes: 4 additions & 2 deletions crates/sncast/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,9 @@ async fn run_async_command(cli: Cli, config: CastConfig, ui: &UI) -> Result<()>
.expect("Failed to build contract");

let result = starknet_commands::declare::declare(
&declare,
declare.contract_name.clone(),
declare.fee_args,
declare.nonce,
&account,
&artifacts,
wait_config,
Expand All @@ -315,7 +317,7 @@ async fn run_async_command(cli: Cli, config: CastConfig, ui: &UI) -> Result<()>
let deploy_command_message = if let Ok(response) = &result {
// TODO(#3785)
let contract_artifacts = artifacts
.get(&declare.contract.clone())
.get(&declare.contract_name)
.expect("Failed to get contract artifacts");
let contract_definition: SierraClass =
serde_json::from_str(&contract_artifacts.sierra)
Expand Down
17 changes: 10 additions & 7 deletions crates/sncast/src/starknet_commands/declare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ use std::sync::Arc;
#[command(about = "Declare a contract to starknet", long_about = None)]
pub struct Declare {
/// Contract name
#[arg(short = 'c', long = "contract-name")]
pub contract: String,
#[arg(short = 'c', long)]
pub contract_name: String,

#[command(flatten)]
pub fee_args: FeeArgs,
Expand All @@ -50,8 +50,11 @@ pub struct Declare {
}

// TODO(#3785)
#[expect(clippy::too_many_arguments)]
pub async fn declare(
declare: &Declare,
contract: String,
fee_args: FeeArgs,
nonce: Option<Felt>,
Comment on lines +55 to +57
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the benefit of making this change?

account: &SingleOwnerAccount<&JsonRpcClient<HttpTransport>, LocalWallet>,
artifacts: &HashMap<String, StarknetContractArtifacts>,
wait_config: WaitForTx,
Expand All @@ -60,9 +63,9 @@ pub async fn declare(
) -> Result<DeclareResponse, StarknetCommandError> {
let contract_artifacts =
artifacts
.get(&declare.contract)
.get(&contract)
.ok_or(StarknetCommandError::ContractArtifactsNotFound(ErrorData {
data: ByteArray::from(declare.contract.as_str()),
data: ByteArray::from(contract.as_str()),
}))?;

let contract_definition: SierraClass = serde_json::from_str(&contract_artifacts.sierra)
Expand All @@ -73,8 +76,8 @@ pub async fn declare(
declare_with_artifacts(
contract_definition,
casm_contract_definition,
declare.fee_args.clone(),
declare.nonce,
fee_args.clone(),
nonce,
account,
wait_config,
skip_on_already_declared,
Expand Down
13 changes: 3 additions & 10 deletions crates/sncast/src/starknet_commands/script/run.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use crate::starknet_commands::declare::Declare;
use crate::starknet_commands::{call, declare, deploy, invoke, tx_status};
use crate::{WaitForTx, get_account};
use anyhow::{Context, Result, anyhow};
Expand Down Expand Up @@ -127,14 +126,6 @@ impl<'a> ExtensionLogic for CastScriptExtension<'a> {
let fee_args: FeeArgs = input_reader.read::<ScriptFeeSettings>()?.into();
let nonce = input_reader.read()?;

let declare = Declare {
contract: contract.clone(),
fee_args,
nonce,
package: None,
rpc: RpcArgs::default(),
};

let declare_tx_id = generate_declare_tx_id(contract.as_str());

if let Some(success_output) =
Expand All @@ -144,7 +135,9 @@ impl<'a> ExtensionLogic for CastScriptExtension<'a> {
}

let declare_result = self.tokio_runtime.block_on(declare::declare(
&declare,
contract.clone(),
fee_args,
nonce,
self.account()?,
self.artifacts,
WaitForTx {
Expand Down
Loading