Skip to content

Commit

Permalink
get it to compile
Browse files Browse the repository at this point in the history
  • Loading branch information
lambda-0x committed Oct 7, 2024
1 parent 37d6ed3 commit 7372768
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 48 deletions.
5 changes: 1 addition & 4 deletions bin/sozo/src/commands/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,10 @@ impl AccountArgs {
} => {
let provider = starknet.provider(env_metadata.as_ref())?;
let signer = signer.signer(env_metadata.as_ref(), false)?;
let txn_action = transaction.to_txn_action()?;
let txn_config = transaction.into();
let txn_config = transaction.try_into()?;
trace!(
?starknet,
?signer,
?txn_action,
?nonce,
poll_interval,
?file,
Expand All @@ -117,7 +115,6 @@ impl AccountArgs {
account::deploy(
provider,
signer,
txn_action,
txn_config,
nonce,
poll_interval,
Expand Down
8 changes: 4 additions & 4 deletions bin/sozo/src/commands/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ pub async fn grant(
ui,
&world,
&models_contracts,
&transaction.into(),
&transaction.try_into()?,
default_namespace,
#[cfg(feature = "walnut")]
&walnut_debugger,
Expand All @@ -183,7 +183,7 @@ pub async fn grant(
ui,
&world,
&owners_resources,
&transaction.into(),
&transaction.try_into()?,
default_namespace,
#[cfg(feature = "walnut")]
&walnut_debugger,
Expand Down Expand Up @@ -223,7 +223,7 @@ pub async fn revoke(
ui,
&world,
&models_contracts,
&transaction.into(),
&transaction.try_into()?,
default_namespace,
#[cfg(feature = "walnut")]
&walnut_debugger,
Expand All @@ -239,7 +239,7 @@ pub async fn revoke(
ui,
&world,
&owners_resources,
&transaction.into(),
&transaction.try_into()?,
default_namespace,
#[cfg(feature = "walnut")]
&walnut_debugger,
Expand Down
4 changes: 2 additions & 2 deletions bin/sozo/src/commands/execute.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl ExecuteArgs {
)
.await?;

let tx_config = self.transaction.into();
let txn_config = self.transaction.try_into()?;

trace!(
contract=?tag_or_address,
Expand All @@ -100,7 +100,7 @@ impl ExecuteArgs {
self.entrypoint,
calldata,
&world,
&tx_config,
&txn_config,
#[cfg(feature = "walnut")]
&walnut_debugger,
)
Expand Down
2 changes: 1 addition & 1 deletion bin/sozo/src/commands/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl MigrateArgs {
.tokio_handle()
.block_on(async {
trace!(name, "Applying migration.");
let txn_config: TxnConfig = transaction.into();
let txn_config: TxnConfig = transaction.try_into()?;

migration::migrate(
&ws,
Expand Down
35 changes: 18 additions & 17 deletions bin/sozo/src/commands/options/transaction.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
use std::fmt::{Display, Formatter};

use anyhow::{bail, Result};
use anyhow::Result;
use bigdecimal::{BigDecimal, Zero};
use clap::builder::PossibleValue;
use clap::{Args, ValueEnum};
use dojo_utils::{
EthManualFeeSetting, FeeSetting, FeeToken, StrkManualFeeSetting, TokenFeeSetting, TxnAction,
TxnConfig,
};
use clap::Args;
use dojo_utils::{EthFeeSetting, FeeSetting, FeeToken, StrkFeeSetting, TokenFeeSetting, TxnConfig};
use num_integer::Integer;
use num_traits::ToPrimitive;
use starknet::core::types::Felt;
Expand Down Expand Up @@ -125,17 +119,21 @@ impl TransactionOptions {
)
}

Ok(FeeSetting::Eth(TokenFeeSetting::Send(EthManualFeeSetting {
max_fee: max_fee_felt,
Ok(FeeSetting::Eth(TokenFeeSetting::Send(EthFeeSetting::Manual {
max_fee_raw: max_fee_felt,
})))
}
(None, Some(max_fee_raw), false) => {
Ok(FeeSetting::Eth(TokenFeeSetting::Send(EthManualFeeSetting {
max_fee: max_fee_raw,
Ok(FeeSetting::Eth(TokenFeeSetting::Send(EthFeeSetting::Manual {
max_fee_raw,
})))
}
(None, None, true) => Ok(FeeSetting::Eth(TokenFeeSetting::EstimateOnly)),
(None, None, false) => Ok(FeeSetting::Eth(TokenFeeSetting::None)),
(None, None, false) => {
Ok(FeeSetting::Eth(TokenFeeSetting::Send(EthFeeSetting::Estimate {
fee_estimate_multiplier: self.fee_estimate_multiplier,
})))
}
_ => Err(anyhow::anyhow!(
"invalid fee option. At most one of --max-fee, --max-fee-raw, and \
--estimate-only can be used."
Expand Down Expand Up @@ -209,9 +207,13 @@ impl TransactionOptions {
};

match (gas_override, gas_price_override) {
(None, None) => Ok(FeeSetting::Strk(TokenFeeSetting::None)),
(None, None) => {
Ok(FeeSetting::Strk(TokenFeeSetting::Send(StrkFeeSetting::Estimate {
gas_estimate_multiplier: self.fee_estimate_multiplier,
})))
}
(gas_override, gas_price_override) => {
Ok(FeeSetting::Strk(TokenFeeSetting::Send(StrkManualFeeSetting {
Ok(FeeSetting::Strk(TokenFeeSetting::Send(StrkFeeSetting::Manual {
gas: gas_override,
gas_price: gas_price_override,
})))
Expand Down Expand Up @@ -240,7 +242,6 @@ impl TryFrom<TransactionOptions> for TxnConfig {
"Converting TransactionOptions to TxnConfig."
);
Ok(Self {
fee_estimate_multiplier: value.fee_estimate_multiplier,
wait: value.wait || value.walnut,
receipt: value.receipt,
walnut: value.walnut,
Expand Down
2 changes: 1 addition & 1 deletion bin/sozo/src/commands/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl RegisterArgs {
register::model_register(
models,
&world,
&transaction.into(),
&transaction.try_into()?,
world_reader,
world_address,
config,
Expand Down
3 changes: 2 additions & 1 deletion crates/dojo-utils/src/tx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,8 @@ pub async fn handle_execute<A>(
calls: Vec<Call>,
) -> Result<Option<InvokeTransactionResult>, AccountError<A::SignError>>
where
A: ConnectedAccount + Sync,
A: ConnectedAccount + Sync + Send,
A::SignError: 'static,
{
let invoke_res = match fee_setting {
FeeSetting::Eth(token_fee_setting) => match token_fee_setting {
Expand Down
2 changes: 2 additions & 0 deletions crates/dojo-world/src/migration/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ pub trait Deployable: Declarable + Sync {
where
A: ConnectedAccount + Send + Sync,
<A as ConnectedAccount>::Provider: Send,
A::SignError: 'static,
{
let declare = match self.declare(&account, txn_config).await {
Ok(res) => Some(res),
Expand Down Expand Up @@ -365,6 +366,7 @@ pub trait Upgradable: Deployable + Declarable + Sync {
where
A: ConnectedAccount + Send + Sync,
<A as ConnectedAccount>::Provider: Send,
A::SignError: 'static,
{
let declare = match self.declare(&account, txn_config).await {
Ok(res) => Some(res),
Expand Down
40 changes: 22 additions & 18 deletions crates/sozo/ops/src/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ pub async fn deploy(
EthFeeSetting::Manual { max_fee_raw } => {
eprintln!(
"You've manually specified the account deployment fee to be {}. \
Therefore, fund at least:\n {}",
Therefore, fund at least:\n {}",
format!("{} ETH", utils::felt_to_bigdecimal(max_fee_raw, 18))
.bright_yellow(),
format!("{} ETH", utils::felt_to_bigdecimal(max_fee_raw, 18))
Expand All @@ -257,13 +257,16 @@ pub async fn deploy(
.into();

eprintln!(
"The estimated account deployment fee is {} STRK. However, to avoid \
failure, fund atleast:\n {}",
format!("{} ETH", utils::felt_to_bigdecimal(estimated_fee, 18))
.bright_yellow(),
format!("{} ETH", utils::felt_to_bigdecimal(estimated_fee_with_buffer, 18))
"The estimated account deployment fee is {} STRK. However, to \
avoid failure, fund atleast:\n {}",
format!("{} ETH", utils::felt_to_bigdecimal(estimated_fee, 18))
.bright_yellow(),
format!(
"{} ETH",
utils::felt_to_bigdecimal(estimated_fee_with_buffer, 18)
)
.bright_yellow()
);
);
}
}

Expand Down Expand Up @@ -347,7 +350,7 @@ pub async fn deploy(
+ (fee_estimate.data_gas_consumed * fee_estimate.data_gas_price);
eprintln!(
"You've manually specified the account deployment fee to be {}. \
Therefore, fund at least:\n {}",
Therefore, fund at least:\n {}",
format!("{} STRK", utils::felt_to_bigdecimal(overall_fee, 18))
.bright_yellow(),
format!("{} STRK", utils::felt_to_bigdecimal(overall_fee, 18))
Expand All @@ -374,16 +377,16 @@ pub async fn deploy(
.into();

eprintln!(
"The estimated account deployment fee is {} STRK. However, to avoid \
failure, fund least:\n {}",
format!("{} STRK", utils::felt_to_bigdecimal(estimated_fee, 18))
.bright_yellow(),
format!(
"{} STRK",
utils::felt_to_bigdecimal(estimated_fee_with_buffer, 18)
)
.bright_yellow()
);
"The estimated account deployment fee is {} STRK. However, to \
avoid failure, fund least:\n {}",
format!("{} STRK", utils::felt_to_bigdecimal(estimated_fee, 18))
.bright_yellow(),
format!(
"{} STRK",
utils::felt_to_bigdecimal(estimated_fee_with_buffer, 18)
)
.bright_yellow()
);
}
}
do_account_deploy_v3(
Expand Down Expand Up @@ -518,6 +521,7 @@ fn write_account_to_file(file: PathBuf, account: AccountConfig) -> Result<(), an
Ok(())
}

#[allow(dead_code)]
async fn simulate_account_deploy(
account_deployment: &starknet::accounts::AccountDeploymentV1<
'_,
Expand Down
7 changes: 7 additions & 0 deletions crates/sozo/ops/src/migration/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ async fn register_namespaces<A>(
where
A: ConnectedAccount + Send + Sync,
<A as ConnectedAccount>::Provider: Send,
A::SignError: 'static,
{
let world = WorldContract::new(world_address, migrator);

Expand Down Expand Up @@ -501,6 +502,7 @@ async fn register_dojo_models<A>(
where
A: ConnectedAccount + Send + Sync,
<A as ConnectedAccount>::Provider: Send,
A::SignError: 'static,
{
if models.is_empty() {
return Ok(RegisterOutput {
Expand Down Expand Up @@ -596,6 +598,7 @@ async fn register_dojo_models_with_declarers<A>(
where
A: ConnectedAccount + Send + Sync,
<A as ConnectedAccount>::Provider: Send,
A::SignError: 'static,
{
if models.is_empty() {
return Ok(RegisterOutput {
Expand Down Expand Up @@ -715,6 +718,7 @@ async fn register_dojo_contracts<A>(
where
A: ConnectedAccount + Send + Sync,
<A as ConnectedAccount>::Provider: Send,
A::SignError: 'static,
{
if contracts.is_empty() {
return Ok(vec![]);
Expand Down Expand Up @@ -819,6 +823,7 @@ async fn register_dojo_contracts_declarers<A>(
where
A: ConnectedAccount + Send + Sync,
<A as ConnectedAccount>::Provider: Send,
A::SignError: 'static,
{
if contracts.is_empty() {
return Ok(vec![]);
Expand Down Expand Up @@ -952,6 +957,7 @@ async fn deploy_contract<A>(
where
A: ConnectedAccount + Send + Sync,
<A as ConnectedAccount>::Provider: Send,
A::SignError: 'static,
{
match contract
.deploy(contract.diff.local_class_hash, constructor_calldata, migrator, txn_config)
Expand Down Expand Up @@ -995,6 +1001,7 @@ async fn upgrade_contract<A>(
where
A: ConnectedAccount + Send + Sync,
<A as ConnectedAccount>::Provider: Send,
A::SignError: 'static,
{
match contract
.upgrade_world(
Expand Down

0 comments on commit 7372768

Please sign in to comment.