-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: use the exeutable tx creator test util for the account tx creat…
…or test util
- Loading branch information
1 parent
5762c79
commit 49b511a
Showing
3 changed files
with
8 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,15 @@ | ||
use starknet_api::core::calculate_contract_address; | ||
use starknet_api::test_utils::deploy_account::DeployAccountTxArgs; | ||
use starknet_api::test_utils::NonceManager; | ||
use starknet_api::transaction::TransactionHash; | ||
|
||
use crate::transaction::transactions::DeployAccountTransaction; | ||
|
||
pub fn deploy_account_tx( | ||
deploy_tx_args: DeployAccountTxArgs, | ||
nonce_manager: &mut NonceManager, | ||
) -> DeployAccountTransaction { | ||
let default_tx_hash = TransactionHash::default(); | ||
let contract_address = calculate_contract_address( | ||
deploy_tx_args.contract_address_salt, | ||
deploy_tx_args.class_hash, | ||
&deploy_tx_args.constructor_calldata, | ||
deploy_tx_args.deployer_address, | ||
) | ||
.unwrap(); | ||
|
||
let deploy_account_tx = starknet_api::test_utils::deploy_account::deploy_account_tx( | ||
let deploy_account_tx = starknet_api::test_utils::deploy_account::executable_deploy_account_tx( | ||
deploy_tx_args, | ||
nonce_manager.next(contract_address), | ||
nonce_manager, | ||
); | ||
DeployAccountTransaction::new(deploy_account_tx, default_tx_hash, contract_address) | ||
DeployAccountTransaction { tx: deploy_account_tx, only_query: false } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,11 @@ | ||
use starknet_api::test_utils::invoke::InvokeTxArgs; | ||
use starknet_api::transaction::TransactionHash; | ||
|
||
use crate::transaction::transactions::InvokeTransaction; | ||
|
||
pub fn invoke_tx(invoke_args: InvokeTxArgs) -> InvokeTransaction { | ||
let default_tx_hash = TransactionHash::default(); | ||
let only_query = invoke_args.only_query; | ||
// TODO: Make TransactionVersion an enum and use match here. | ||
let invoke_tx = starknet_api::test_utils::invoke::invoke_tx(invoke_args); | ||
let invoke_tx = starknet_api::test_utils::invoke::executable_invoke_tx(invoke_args); | ||
|
||
match only_query { | ||
true => InvokeTransaction::new_for_query(invoke_tx, default_tx_hash), | ||
false => InvokeTransaction::new(invoke_tx, default_tx_hash), | ||
} | ||
InvokeTransaction { tx: invoke_tx, only_query } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters