From 3b682f170670dae519c4982809782afeca3268aa Mon Sep 17 00:00:00 2001 From: Jonathan LEI Date: Tue, 14 Jan 2025 12:44:53 +0800 Subject: [PATCH] feat: deprecate pre-v3 transactions (#688) --- examples/declare_cairo1_contract.rs | 2 +- examples/deploy_account_with_ledger.rs | 2 +- examples/deploy_argent_account.rs | 2 +- examples/deploy_contract.rs | 2 +- examples/mint_tokens.rs | 2 +- examples/transfer_with_ledger.rs | 2 +- starknet-accounts/src/account/mod.rs | 8 ++++++-- starknet-accounts/src/factory/mod.rs | 4 +++- starknet-accounts/tests/single_owner_account.rs | 5 ++++- starknet-contract/src/factory.rs | 5 ++++- starknet-contract/tests/contract_deployment.rs | 1 + 11 files changed, 24 insertions(+), 11 deletions(-) diff --git a/examples/declare_cairo1_contract.rs b/examples/declare_cairo1_contract.rs index 86ab0fdd..ae467f92 100644 --- a/examples/declare_cairo1_contract.rs +++ b/examples/declare_cairo1_contract.rs @@ -48,7 +48,7 @@ async fn main() { let flattened_class = contract_artifact.flatten().unwrap(); let result = account - .declare_v2(Arc::new(flattened_class), compiled_class_hash) + .declare_v3(Arc::new(flattened_class), compiled_class_hash) .send() .await .unwrap(); diff --git a/examples/deploy_account_with_ledger.rs b/examples/deploy_account_with_ledger.rs index ef4ba9ae..95274415 100644 --- a/examples/deploy_account_with_ledger.rs +++ b/examples/deploy_account_with_ledger.rs @@ -34,7 +34,7 @@ async fn main() { .await .unwrap(); - let deployment = factory.deploy_v1(salt); + let deployment = factory.deploy_v3(salt); let est_fee = deployment.estimate_fee().await.unwrap(); diff --git a/examples/deploy_argent_account.rs b/examples/deploy_argent_account.rs index b296c645..6057b87d 100644 --- a/examples/deploy_argent_account.rs +++ b/examples/deploy_argent_account.rs @@ -29,7 +29,7 @@ async fn main() { .await .unwrap(); - let deployment = factory.deploy_v1(salt); + let deployment = factory.deploy_v3(salt); let est_fee = deployment.estimate_fee().await.unwrap(); diff --git a/examples/deploy_contract.rs b/examples/deploy_contract.rs index 049bad5e..bbc74ace 100644 --- a/examples/deploy_contract.rs +++ b/examples/deploy_contract.rs @@ -49,7 +49,7 @@ async fn main() { let contract_factory = ContractFactory::new(class_hash, account); contract_factory - .deploy_v1(vec![felt!("123456")], felt!("1122"), false) + .deploy_v3(vec![felt!("123456")], felt!("1122"), false) .send() .await .expect("Unable to deploy contract"); diff --git a/examples/mint_tokens.rs b/examples/mint_tokens.rs index 7a2deaec..81c5d5f7 100644 --- a/examples/mint_tokens.rs +++ b/examples/mint_tokens.rs @@ -38,7 +38,7 @@ async fn main() { account.set_block_id(BlockId::Tag(BlockTag::Pending)); let result = account - .execute_v1(vec![Call { + .execute_v3(vec![Call { to: tst_token_address, selector: get_selector_from_name("mint").unwrap(), calldata: vec![ diff --git a/examples/transfer_with_ledger.rs b/examples/transfer_with_ledger.rs index d6fd1fff..c67ed005 100644 --- a/examples/transfer_with_ledger.rs +++ b/examples/transfer_with_ledger.rs @@ -44,7 +44,7 @@ async fn main() { account.set_block_id(BlockId::Tag(BlockTag::Pending)); let result = account - .execute_v1(vec![Call { + .execute_v3(vec![Call { to: eth_token_address, selector: get_selector_from_name("transfer").unwrap(), calldata: vec![felt!("0x1234"), felt!("100"), Felt::ZERO], diff --git a/starknet-accounts/src/account/mod.rs b/starknet-accounts/src/account/mod.rs index 4979377d..8627c4d7 100644 --- a/starknet-accounts/src/account/mod.rs +++ b/starknet-accounts/src/account/mod.rs @@ -92,6 +92,7 @@ pub trait Account: ExecutionEncoder + Sized { /// Generates an instance of [`ExecutionV1`] for sending `INVOKE` v1 transactions. Pays /// transaction fees in `ETH`. + #[deprecated = "pre-v3 transactions are deprecated and will be disabled on Starknet soon; use `execute_v3` instead"] fn execute_v1(&self, calls: Vec) -> ExecutionV1<'_, Self> { ExecutionV1::new(calls, self) } @@ -104,8 +105,9 @@ pub trait Account: ExecutionEncoder + Sized { /// Generates an instance of [`ExecutionV1`] for sending `INVOKE` v1 transactions. Pays /// transaction fees in `ETH`. - #[deprecated = "use version specific variants (`execute_v1` & `execute_v3`) instead"] + #[deprecated = "pre-v3 transactions are deprecated and will be disabled on Starknet soon; use `execute_v3` instead"] fn execute(&self, calls: Vec) -> ExecutionV1<'_, Self> { + #[allow(deprecated)] self.execute_v1(calls) } @@ -124,6 +126,7 @@ pub trait Account: ExecutionEncoder + Sized { /// /// This method is only used for declaring Sierra (Cairo 1) classes. To declare legacy (Cairo 0) /// classes use [`declare_legacy`](fn.declare_legacy) instead. + #[deprecated = "pre-v3 transactions are deprecated and will be disabled on Starknet soon; use `declare_v3` instead"] fn declare_v2( &self, contract_class: Arc, @@ -170,12 +173,13 @@ pub trait Account: ExecutionEncoder + Sized { /// /// This method is only used for declaring Sierra (Cairo 1) classes. To declare legacy (Cairo 0) /// classes use [`declare_legacy`](fn.declare_legacy) instead. - #[deprecated = "use version specific variants (`declare_v2` & `declare_v3`) instead"] + #[deprecated = "pre-v3 transactions are deprecated and will be disabled on Starknet soon; use `declare_v3` instead"] fn declare( &self, contract_class: Arc, compiled_class_hash: Felt, ) -> DeclarationV2<'_, Self> { + #[allow(deprecated)] self.declare_v2(contract_class, compiled_class_hash) } diff --git a/starknet-accounts/src/factory/mod.rs b/starknet-accounts/src/factory/mod.rs index e1d7d09c..c3578e0d 100644 --- a/starknet-accounts/src/factory/mod.rs +++ b/starknet-accounts/src/factory/mod.rs @@ -117,6 +117,7 @@ pub trait AccountFactory: Sized { /// Generates an instance of [`AccountDeploymentV1`] for sending `DEPLOY_ACCOUNT` v1 /// transactions. Pays transaction fees in `ETH`. + #[deprecated = "pre-v3 transactions are deprecated and will be disabled on Starknet soon; use `deploy_v3` instead"] fn deploy_v1(&self, salt: Felt) -> AccountDeploymentV1<'_, Self> { AccountDeploymentV1::new(salt, self) } @@ -129,8 +130,9 @@ pub trait AccountFactory: Sized { /// Generates an instance of [`AccountDeploymentV1`] for sending `DEPLOY_ACCOUNT` v1 /// transactions. Pays transaction fees in `ETH`. - #[deprecated = "use version specific variants (`deploy_v1` & `deploy_v3`) instead"] + #[deprecated = "pre-v3 transactions are deprecated and will be disabled on Starknet soon; use `deploy_v3` instead"] fn deploy(&self, salt: Felt) -> AccountDeploymentV1<'_, Self> { + #[allow(deprecated)] self.deploy_v1(salt) } } diff --git a/starknet-accounts/tests/single_owner_account.rs b/starknet-accounts/tests/single_owner_account.rs index 8b1eb038..df0d1e53 100644 --- a/starknet-accounts/tests/single_owner_account.rs +++ b/starknet-accounts/tests/single_owner_account.rs @@ -202,6 +202,7 @@ async fn can_get_nonce_inner(provider: P, address: &s assert_ne!(account.get_nonce().await.unwrap(), Felt::ZERO); } +#[allow(deprecated)] async fn can_estimate_invoke_v1_fee_inner(provider: P, address: &str) { let signer = LocalWallet::from(SigningKey::from_secret_scalar( Felt::from_hex("00ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap(), @@ -268,7 +269,7 @@ async fn can_parse_fee_estimation_error_inner( account.set_block_id(BlockId::Tag(BlockTag::Pending)); match account - .execute_v1(vec![Call { + .execute_v3(vec![Call { to: eth_token_address, selector: get_selector_from_name("transfer").unwrap(), calldata: vec![ @@ -290,6 +291,7 @@ async fn can_parse_fee_estimation_error_inner( } } +#[allow(deprecated)] async fn can_execute_eth_transfer_invoke_v1_inner( provider: P, address: &str, @@ -400,6 +402,7 @@ async fn can_execute_eth_transfer_invoke_v3_with_manual_gas_inner Felt::ZERO); } +#[allow(deprecated)] async fn can_declare_cairo1_contract_v2_inner( provider: P, address: &str, diff --git a/starknet-contract/src/factory.rs b/starknet-contract/src/factory.rs index a3a8ff64..8bc9ffe4 100644 --- a/starknet-contract/src/factory.rs +++ b/starknet-contract/src/factory.rs @@ -88,6 +88,7 @@ where { /// Generates an instance of [`DeploymentV1`] for sending `INVOKE` v1 transactions for the /// contract deployment. Pays transaction fees in `ETH`. + #[deprecated = "pre-v3 transactions are deprecated and will be disabled on Starknet soon; use `deploy_v3` instead"] pub const fn deploy_v1( &self, constructor_calldata: Vec, @@ -128,13 +129,14 @@ where /// Generates an instance of [`DeploymentV1`] for sending `INVOKE` v1 transactions for the /// contract deployment. Pays transaction fees in `ETH`. - #[deprecated = "use version specific variants (`deploy_v1` & `deploy_v3`) instead"] + #[deprecated = "pre-v3 transactions are deprecated and will be disabled on Starknet soon; use `deploy_v3` instead"] pub const fn deploy( &self, constructor_calldata: Vec, salt: Felt, unique: bool, ) -> DeploymentV1<'_, A> { + #[allow(deprecated)] self.deploy_v1(constructor_calldata, salt, unique) } } @@ -399,6 +401,7 @@ mod tests { use super::*; + #[allow(deprecated)] #[test] #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] fn test_deployed_address_unique() { diff --git a/starknet-contract/tests/contract_deployment.rs b/starknet-contract/tests/contract_deployment.rs index 11611a90..ceff895b 100644 --- a/starknet-contract/tests/contract_deployment.rs +++ b/starknet-contract/tests/contract_deployment.rs @@ -14,6 +14,7 @@ const CHAIN_ID: Felt = Felt::from_raw([ 1555806712078248243, ]); +#[allow(deprecated)] #[tokio::test] async fn can_deploy_contract_to_alpha_sepolia_with_invoke_v1() { let rpc_url = std::env::var("STARKNET_RPC")