Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: deprecate pre-v3 transactions #688

Merged
merged 1 commit into from
Jan 14, 2025
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
2 changes: 1 addition & 1 deletion examples/declare_cairo1_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion examples/deploy_account_with_ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion examples/deploy_argent_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion examples/deploy_contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion examples/mint_tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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![
Expand Down
2 changes: 1 addition & 1 deletion examples/transfer_with_ledger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down
8 changes: 6 additions & 2 deletions starknet-accounts/src/account/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Call>) -> ExecutionV1<'_, Self> {
ExecutionV1::new(calls, self)
}
Expand All @@ -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<Call>) -> ExecutionV1<'_, Self> {
#[allow(deprecated)]
self.execute_v1(calls)
}

Expand All @@ -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<FlattenedSierraClass>,
Expand Down Expand Up @@ -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<FlattenedSierraClass>,
compiled_class_hash: Felt,
) -> DeclarationV2<'_, Self> {
#[allow(deprecated)]
self.declare_v2(contract_class, compiled_class_hash)
}

Expand Down
4 changes: 3 additions & 1 deletion starknet-accounts/src/factory/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
}
}
Expand Down
5 changes: 4 additions & 1 deletion starknet-accounts/tests/single_owner_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ async fn can_get_nonce_inner<P: Provider + Send + Sync>(provider: P, address: &s
assert_ne!(account.get_nonce().await.unwrap(), Felt::ZERO);
}

#[allow(deprecated)]
async fn can_estimate_invoke_v1_fee_inner<P: Provider + Send + Sync>(provider: P, address: &str) {
let signer = LocalWallet::from(SigningKey::from_secret_scalar(
Felt::from_hex("00ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap(),
Expand Down Expand Up @@ -268,7 +269,7 @@ async fn can_parse_fee_estimation_error_inner<P: Provider + Send + Sync>(
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![
Expand All @@ -290,6 +291,7 @@ async fn can_parse_fee_estimation_error_inner<P: Provider + Send + Sync>(
}
}

#[allow(deprecated)]
async fn can_execute_eth_transfer_invoke_v1_inner<P: Provider + Send + Sync>(
provider: P,
address: &str,
Expand Down Expand Up @@ -400,6 +402,7 @@ async fn can_execute_eth_transfer_invoke_v3_with_manual_gas_inner<P: Provider +
assert!(result.transaction_hash > Felt::ZERO);
}

#[allow(deprecated)]
async fn can_declare_cairo1_contract_v2_inner<P: Provider + Send + Sync>(
provider: P,
address: &str,
Expand Down
5 changes: 4 additions & 1 deletion starknet-contract/src/factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Felt>,
Expand Down Expand Up @@ -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<Felt>,
salt: Felt,
unique: bool,
) -> DeploymentV1<'_, A> {
#[allow(deprecated)]
self.deploy_v1(constructor_calldata, salt, unique)
}
}
Expand Down Expand Up @@ -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() {
Expand Down
1 change: 1 addition & 0 deletions starknet-contract/tests/contract_deployment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Loading