diff --git a/Cargo.lock b/Cargo.lock index 6051d09..74a5ce3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2883,7 +2883,7 @@ dependencies = [ [[package]] name = "starknet" version = "0.6.0" -source = "git+https://github.com/xJonathanLEI/starknet-rs?rev=f16271877c9dbf08bc7bf61e4fc72decc13ff73d#f16271877c9dbf08bc7bf61e4fc72decc13ff73d" +source = "git+https://github.com/xJonathanLEI/starknet-rs?rev=4ab2f36872435ce57b1d8f55856702a6a30f270a#4ab2f36872435ce57b1d8f55856702a6a30f270a" dependencies = [ "starknet-accounts", "starknet-contract", @@ -2898,7 +2898,7 @@ dependencies = [ [[package]] name = "starknet-accounts" version = "0.5.0" -source = "git+https://github.com/xJonathanLEI/starknet-rs?rev=f16271877c9dbf08bc7bf61e4fc72decc13ff73d#f16271877c9dbf08bc7bf61e4fc72decc13ff73d" +source = "git+https://github.com/xJonathanLEI/starknet-rs?rev=4ab2f36872435ce57b1d8f55856702a6a30f270a#4ab2f36872435ce57b1d8f55856702a6a30f270a" dependencies = [ "async-trait", "auto_impl", @@ -2911,7 +2911,7 @@ dependencies = [ [[package]] name = "starknet-contract" version = "0.5.0" -source = "git+https://github.com/xJonathanLEI/starknet-rs?rev=f16271877c9dbf08bc7bf61e4fc72decc13ff73d#f16271877c9dbf08bc7bf61e4fc72decc13ff73d" +source = "git+https://github.com/xJonathanLEI/starknet-rs?rev=4ab2f36872435ce57b1d8f55856702a6a30f270a#4ab2f36872435ce57b1d8f55856702a6a30f270a" dependencies = [ "serde", "serde_json", @@ -2925,7 +2925,7 @@ dependencies = [ [[package]] name = "starknet-core" version = "0.6.0" -source = "git+https://github.com/xJonathanLEI/starknet-rs?rev=f16271877c9dbf08bc7bf61e4fc72decc13ff73d#f16271877c9dbf08bc7bf61e4fc72decc13ff73d" +source = "git+https://github.com/xJonathanLEI/starknet-rs?rev=4ab2f36872435ce57b1d8f55856702a6a30f270a#4ab2f36872435ce57b1d8f55856702a6a30f270a" dependencies = [ "base64 0.21.2", "flate2", @@ -2942,7 +2942,7 @@ dependencies = [ [[package]] name = "starknet-crypto" version = "0.6.0" -source = "git+https://github.com/xJonathanLEI/starknet-rs?rev=f16271877c9dbf08bc7bf61e4fc72decc13ff73d#f16271877c9dbf08bc7bf61e4fc72decc13ff73d" +source = "git+https://github.com/xJonathanLEI/starknet-rs?rev=4ab2f36872435ce57b1d8f55856702a6a30f270a#4ab2f36872435ce57b1d8f55856702a6a30f270a" dependencies = [ "crypto-bigint", "hex", @@ -2961,7 +2961,7 @@ dependencies = [ [[package]] name = "starknet-crypto-codegen" version = "0.3.2" -source = "git+https://github.com/xJonathanLEI/starknet-rs?rev=f16271877c9dbf08bc7bf61e4fc72decc13ff73d#f16271877c9dbf08bc7bf61e4fc72decc13ff73d" +source = "git+https://github.com/xJonathanLEI/starknet-rs?rev=4ab2f36872435ce57b1d8f55856702a6a30f270a#4ab2f36872435ce57b1d8f55856702a6a30f270a" dependencies = [ "starknet-curve", "starknet-ff", @@ -2971,7 +2971,7 @@ dependencies = [ [[package]] name = "starknet-curve" version = "0.4.0" -source = "git+https://github.com/xJonathanLEI/starknet-rs?rev=f16271877c9dbf08bc7bf61e4fc72decc13ff73d#f16271877c9dbf08bc7bf61e4fc72decc13ff73d" +source = "git+https://github.com/xJonathanLEI/starknet-rs?rev=4ab2f36872435ce57b1d8f55856702a6a30f270a#4ab2f36872435ce57b1d8f55856702a6a30f270a" dependencies = [ "starknet-ff", ] @@ -2979,7 +2979,7 @@ dependencies = [ [[package]] name = "starknet-ff" version = "0.3.4" -source = "git+https://github.com/xJonathanLEI/starknet-rs?rev=f16271877c9dbf08bc7bf61e4fc72decc13ff73d#f16271877c9dbf08bc7bf61e4fc72decc13ff73d" +source = "git+https://github.com/xJonathanLEI/starknet-rs?rev=4ab2f36872435ce57b1d8f55856702a6a30f270a#4ab2f36872435ce57b1d8f55856702a6a30f270a" dependencies = [ "ark-ff", "bigdecimal 0.3.1", @@ -2993,7 +2993,7 @@ dependencies = [ [[package]] name = "starknet-macros" version = "0.1.3" -source = "git+https://github.com/xJonathanLEI/starknet-rs?rev=f16271877c9dbf08bc7bf61e4fc72decc13ff73d#f16271877c9dbf08bc7bf61e4fc72decc13ff73d" +source = "git+https://github.com/xJonathanLEI/starknet-rs?rev=4ab2f36872435ce57b1d8f55856702a6a30f270a#4ab2f36872435ce57b1d8f55856702a6a30f270a" dependencies = [ "starknet-core", "syn 2.0.28", @@ -3002,7 +3002,7 @@ dependencies = [ [[package]] name = "starknet-providers" version = "0.6.0" -source = "git+https://github.com/xJonathanLEI/starknet-rs?rev=f16271877c9dbf08bc7bf61e4fc72decc13ff73d#f16271877c9dbf08bc7bf61e4fc72decc13ff73d" +source = "git+https://github.com/xJonathanLEI/starknet-rs?rev=4ab2f36872435ce57b1d8f55856702a6a30f270a#4ab2f36872435ce57b1d8f55856702a6a30f270a" dependencies = [ "async-trait", "auto_impl", @@ -3021,7 +3021,7 @@ dependencies = [ [[package]] name = "starknet-signers" version = "0.4.0" -source = "git+https://github.com/xJonathanLEI/starknet-rs?rev=f16271877c9dbf08bc7bf61e4fc72decc13ff73d#f16271877c9dbf08bc7bf61e4fc72decc13ff73d" +source = "git+https://github.com/xJonathanLEI/starknet-rs?rev=4ab2f36872435ce57b1d8f55856702a6a30f270a#4ab2f36872435ce57b1d8f55856702a6a30f270a" dependencies = [ "async-trait", "auto_impl", diff --git a/Cargo.toml b/Cargo.toml index c6ee192..4624569 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,7 +31,7 @@ serde = { version = "1.0.164", features = ["derive"] } serde_json = { version = "1.0.99", features = ["preserve_order"] } serde_with = "2.3.3" shellexpand = "3.1.0" -starknet = { git = "https://github.com/xJonathanLEI/starknet-rs", rev = "f16271877c9dbf08bc7bf61e4fc72decc13ff73d" } +starknet = { git = "https://github.com/xJonathanLEI/starknet-rs", rev = "4ab2f36872435ce57b1d8f55856702a6a30f270a" } tempfile = "3.8.0" thiserror = "1.0.40" tokio = { version = "1.28.2", default-features = false, features = ["macros", "rt-multi-thread"] } diff --git a/src/account_factory/braavos.rs b/src/account_factory/braavos.rs index 78364e7..24fe915 100644 --- a/src/account_factory/braavos.rs +++ b/src/account_factory/braavos.rs @@ -1,7 +1,10 @@ use async_trait::async_trait; use starknet::{ accounts::{AccountFactory, PreparedAccountDeployment, RawAccountDeployment}, - core::{crypto::compute_hash_on_elements, types::FieldElement}, + core::{ + crypto::compute_hash_on_elements, + types::{BlockId, BlockTag, FieldElement}, + }, macros::selector, providers::Provider, signers::Signer, @@ -15,6 +18,7 @@ pub struct BraavosAccountFactory { signer_public_key: FieldElement, signer: S, provider: P, + block_id: BlockId, } impl BraavosAccountFactory @@ -38,8 +42,14 @@ where signer_public_key: signer_public_key.scalar(), signer, provider, + block_id: BlockId::Tag(BlockTag::Latest), }) } + + pub fn set_block_id(&mut self, block_id: BlockId) -> &Self { + self.block_id = block_id; + self + } } #[cfg_attr(not(target_arch = "wasm32"), async_trait)] @@ -73,6 +83,10 @@ where &self.provider } + fn block_id(&self) -> BlockId { + self.block_id + } + async fn sign_deployment( &self, deployment: &RawAccountDeployment, diff --git a/src/account_factory/mod.rs b/src/account_factory/mod.rs index 500691c..4ac6657 100644 --- a/src/account_factory/mod.rs +++ b/src/account_factory/mod.rs @@ -3,7 +3,7 @@ use starknet::{ accounts::{ AccountFactory, ArgentAccountFactory, OpenZeppelinAccountFactory, RawAccountDeployment, }, - core::types::FieldElement, + core::types::{BlockId, FieldElement}, providers::Provider, signers::Signer, }; @@ -59,6 +59,14 @@ where } } + fn block_id(&self) -> BlockId { + match self { + AnyAccountFactory::OpenZeppelin(inner) => inner.block_id(), + AnyAccountFactory::Argent(inner) => inner.block_id(), + AnyAccountFactory::Braavos(inner) => inner.block_id(), + } + } + async fn sign_deployment( &self, deployment: &RawAccountDeployment, diff --git a/src/subcommands/account/deploy.rs b/src/subcommands/account/deploy.rs index 48eb435..e503020 100644 --- a/src/subcommands/account/deploy.rs +++ b/src/subcommands/account/deploy.rs @@ -5,7 +5,7 @@ use clap::Parser; use colored::Colorize; use starknet::{ accounts::{AccountFactory, ArgentAccountFactory, OpenZeppelinAccountFactory}, - core::types::FieldElement, + core::types::{BlockId, BlockTag, FieldElement}, providers::Provider, signers::Signer, }; @@ -89,15 +89,16 @@ impl Deploy { ); } - AnyAccountFactory::OpenZeppelin( - OpenZeppelinAccountFactory::new( - undeployed_status.class_hash, - chain_id, - signer.clone(), - provider.clone(), - ) - .await?, + let mut factory = OpenZeppelinAccountFactory::new( + undeployed_status.class_hash, + chain_id, + signer.clone(), + provider.clone(), ) + .await?; + factory.set_block_id(BlockId::Tag(BlockTag::Pending)); + + AnyAccountFactory::OpenZeppelin(factory) } AccountVariant::Argent(argent_config) => { // It's probably not worth it to continue to support legacy account deployment. @@ -117,16 +118,17 @@ impl Deploy { ); } - AnyAccountFactory::Argent( - ArgentAccountFactory::new( - undeployed_status.class_hash, - chain_id, - FieldElement::ZERO, - signer.clone(), - provider.clone(), - ) - .await?, + let mut factory = ArgentAccountFactory::new( + undeployed_status.class_hash, + chain_id, + FieldElement::ZERO, + signer.clone(), + provider.clone(), ) + .await?; + factory.set_block_id(BlockId::Tag(BlockTag::Pending)); + + AnyAccountFactory::Argent(factory) } AccountVariant::Braavos(braavos_config) => { if !matches!(braavos_config.multisig, BraavosMultisigConfig::Off) { @@ -151,17 +153,18 @@ impl Deploy { ); } - AnyAccountFactory::Braavos( - BraavosAccountFactory::new( - undeployed_status.class_hash, - context.mock_implementation, - braavos_config.implementation, - chain_id, - signer.clone(), - provider.clone(), - ) - .await?, + let mut factory = BraavosAccountFactory::new( + undeployed_status.class_hash, + context.mock_implementation, + braavos_config.implementation, + chain_id, + signer.clone(), + provider.clone(), ) + .await?; + factory.set_block_id(BlockId::Tag(BlockTag::Pending)); + + AnyAccountFactory::Braavos(factory) } // Reject other variants as we add more types } }