Skip to content

Commit

Permalink
chore(iota-sdk): Privatize public fields (#3940)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaughterOfMars authored Nov 8, 2024
1 parent 3cc3077 commit db5a337
Show file tree
Hide file tree
Showing 23 changed files with 255 additions and 216 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 7 additions & 14 deletions crates/iota-cluster-test/src/cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,20 +384,13 @@ pub fn new_wallet_context_from_cluster(
keystore
.add_key(None, IotaKeyPair::Ed25519(key_pair))
.unwrap();
IotaClientConfig {
keystore,
envs: vec![IotaEnv {
alias: "localnet".to_string(),
rpc: fullnode_url.into(),
ws: None,
basic_auth: None,
}],
active_address: Some(address),
active_env: Some("localnet".to_string()),
}
.persisted(&wallet_config_path)
.save()
.unwrap();
IotaClientConfig::new(keystore)
.with_envs([IotaEnv::new("localnet", fullnode_url)])
.with_active_address(address)
.with_active_env("localnet".to_string())
.persisted(&wallet_config_path)
.save()
.unwrap();

info!(
"Initialize wallet from config path: {:?}",
Expand Down
4 changes: 2 additions & 2 deletions crates/iota-cluster-test/src/wallet_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ impl WalletClient {

pub fn sign(&self, txn_data: &TransactionData, desc: &str) -> Signature {
self.get_wallet()
.config
.keystore
.config()
.keystore()
.sign_secure(&self.address, txn_data, Intent::iota_transaction())
.unwrap_or_else(|e| panic!("Failed to sign transaction for {}. {}", desc, e))
}
Expand Down
4 changes: 2 additions & 2 deletions crates/iota-e2e-tests/tests/apy_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ async fn test_apy() {
// for that address.
test_cluster
.wallet
.config
.keystore
.config_mut()
.keystore_mut()
.add_key(None, IotaKeyPair::Ed25519(keypair))
.unwrap();

Expand Down
34 changes: 18 additions & 16 deletions crates/iota-e2e-tests/tests/full_node_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ async fn test_full_node_shared_objects() -> Result<(), anyhow::Error> {
let context = &mut test_cluster.wallet;

let sender = context
.config
.keystore
.config()
.keystore()
.addresses()
.first()
.cloned()
Expand Down Expand Up @@ -159,14 +159,14 @@ async fn test_sponsored_transaction() -> Result<(), anyhow::Error> {
let tx = to_sender_signed_transaction_with_multi_signers(tx_data, vec![
test_cluster
.wallet
.config
.keystore
.config()
.keystore()
.get_key(&sender)
.unwrap(),
test_cluster
.wallet
.config
.keystore
.config()
.keystore()
.get_key(&sponsor)
.unwrap(),
]);
Expand Down Expand Up @@ -526,8 +526,8 @@ async fn do_test_full_node_sync_flood() {
let context = &mut context.lock().await;

let sender = context
.config
.keystore
.config()
.keystore()
.addresses()
.first()
.cloned()
Expand Down Expand Up @@ -817,12 +817,12 @@ async fn test_execute_tx_with_serialized_signature() -> Result<(), anyhow::Error
let mut test_cluster = TestClusterBuilder::new().build().await;
let context = &mut test_cluster.wallet;
context
.config
.keystore
.config_mut()
.keystore_mut()
.add_key(None, IotaKeyPair::Secp256k1(get_key_pair().1))?;
context
.config
.keystore
.config_mut()
.keystore_mut()
.add_key(None, IotaKeyPair::Ed25519(get_key_pair().1))?;

let jsonrpc_client = &test_cluster.fullnode_handle.rpc_client;
Expand Down Expand Up @@ -1122,8 +1122,8 @@ async fn test_pass_back_no_object() -> Result<(), anyhow::Error> {
let context = &mut test_cluster.wallet;

let sender = context
.config
.keystore
.config()
.keystore()
.addresses()
.first()
.cloned()
Expand Down Expand Up @@ -1161,8 +1161,10 @@ async fn test_pass_back_no_object() -> Result<(), anyhow::Error> {
rgp,
)
.unwrap();
let tx =
to_sender_signed_transaction(tx_data, context.config.keystore.get_key(&sender).unwrap());
let tx = to_sender_signed_transaction(
tx_data,
context.config().keystore().get_key(&sender).unwrap(),
);

let digest = *tx.digest();
let _res = transaction_orchestrator
Expand Down
8 changes: 4 additions & 4 deletions crates/iota-faucet/src/bin/merge_coins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ async fn _split_coins_equally(
.await?;

let signature = wallet
.config
.keystore
.config()
.keystore()
.sign_secure(&active_address, &tx_data, Intent::iota_transaction())
.unwrap();
let tx = Transaction::from_data(tx_data, vec![signature]);
Expand Down Expand Up @@ -112,8 +112,8 @@ async fn _merge_coins(gas_coin: &str, mut wallet: WalletContext) -> Result<(), a
.pay_iota(active_address, coin_vector, target, target_amount, 1000000)
.await?;
let signature = wallet
.config
.keystore
.config()
.keystore()
.sign_secure(&active_address, &tx_data, Intent::iota_transaction())
.unwrap();
let tx = Transaction::from_data(tx_data, vec![signature]);
Expand Down
6 changes: 3 additions & 3 deletions crates/iota-faucet/src/faucet/simple_faucet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -427,8 +427,8 @@ impl SimpleFaucet {
) -> Result<IotaTransactionBlockResponse, FaucetError> {
let signature = self
.wallet
.config
.keystore
.config()
.keystore()
.sign_secure(&self.active_address, &tx_data, Intent::iota_transaction())
.map_err(FaucetError::internal)?;
let tx = Transaction::from_data(tx_data, vec![signature]);
Expand Down Expand Up @@ -1123,7 +1123,7 @@ mod tests {
ctx: &mut WalletContext,
tx_data: TransactionData,
) -> Result<IotaTransactionBlockEffects, anyhow::Error> {
let signature = ctx.config.keystore.sign_secure(
let signature = ctx.config().keystore().sign_secure(
&tx_data.sender(),
&tx_data,
Intent::iota_transaction(),
Expand Down
6 changes: 3 additions & 3 deletions crates/iota-package-management/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub async fn update_lock_file(
)
};
let install_dir = install_dir.unwrap_or(PathBuf::from("."));
let env = context.config.get_active_env().context(
let env = context.config().get_active_env().context(
"Could not resolve environment from active wallet context. \
Try ensure `iota client active-env` is valid.",
)?;
Expand All @@ -89,15 +89,15 @@ pub async fn update_lock_file(
match command {
LockCommand::Publish => lock_file::schema::update_managed_address(
&mut lock,
&env.alias,
env.alias(),
lock_file::schema::ManagedAddressUpdate::Published {
chain_id: chain_identifier,
original_id: original_id.to_string(),
},
),
LockCommand::Upgrade => lock_file::schema::update_managed_address(
&mut lock,
&env.alias,
env.alias(),
lock_file::schema::ManagedAddressUpdate::Upgraded {
latest_id: original_id.to_string(),
version: version.into(),
Expand Down
28 changes: 14 additions & 14 deletions crates/iota-rosetta/src/unit_tests/balance_changing_tx_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ use crate::{
async fn test_transfer_iota() {
let network = TestClusterBuilder::new().build().await;
let client = network.wallet.get_client().await.unwrap();
let keystore = &network.wallet.config.keystore;
let keystore = network.wallet.config().keystore();
let rgp = network.get_reference_gas_price().await;

// Test Transfer Iota
Expand Down Expand Up @@ -82,7 +82,7 @@ async fn test_transfer_iota() {
async fn test_transfer_iota_whole_coin() {
let network = TestClusterBuilder::new().build().await;
let client = network.wallet.get_client().await.unwrap();
let keystore = &network.wallet.config.keystore;
let keystore = network.wallet.config().keystore();
let rgp = network.get_reference_gas_price().await;

// Test transfer iota whole coin
Expand Down Expand Up @@ -112,7 +112,7 @@ async fn test_transfer_iota_whole_coin() {
async fn test_transfer_object() {
let network = TestClusterBuilder::new().build().await;
let client = network.wallet.get_client().await.unwrap();
let keystore = &network.wallet.config.keystore;
let keystore = network.wallet.config().keystore();
let rgp = network.get_reference_gas_price().await;

// Test transfer object
Expand Down Expand Up @@ -143,7 +143,7 @@ async fn test_transfer_object() {
async fn test_publish_and_move_call() {
let network = TestClusterBuilder::new().build().await;
let client = network.wallet.get_client().await.unwrap();
let keystore = &network.wallet.config.keystore;
let keystore = network.wallet.config().keystore();
let rgp = network.get_reference_gas_price().await;

// Test publish
Expand Down Expand Up @@ -237,7 +237,7 @@ async fn test_publish_and_move_call() {
async fn test_split_coin() {
let network = TestClusterBuilder::new().build().await;
let client = network.wallet.get_client().await.unwrap();
let keystore = &network.wallet.config.keystore;
let keystore = network.wallet.config().keystore();
let rgp = network.get_reference_gas_price().await;

// Test spilt coin
Expand Down Expand Up @@ -270,7 +270,7 @@ async fn test_split_coin() {
async fn test_merge_coin() {
let network = TestClusterBuilder::new().build().await;
let client = network.wallet.get_client().await.unwrap();
let keystore = &network.wallet.config.keystore;
let keystore = network.wallet.config().keystore();
let rgp = network.get_reference_gas_price().await;

// Test merge coin
Expand Down Expand Up @@ -304,7 +304,7 @@ async fn test_merge_coin() {
async fn test_pay() {
let network = TestClusterBuilder::new().build().await;
let client = network.wallet.get_client().await.unwrap();
let keystore = &network.wallet.config.keystore;
let keystore = network.wallet.config().keystore();
let rgp = network.get_reference_gas_price().await;

// Test Pay
Expand Down Expand Up @@ -337,7 +337,7 @@ async fn test_pay() {
async fn test_pay_multiple_coin_multiple_recipient() {
let network = TestClusterBuilder::new().build().await;
let client = network.wallet.get_client().await.unwrap();
let keystore = &network.wallet.config.keystore;
let keystore = network.wallet.config().keystore();
let rgp = network.get_reference_gas_price().await;

// Test Pay multiple coin multiple recipient
Expand Down Expand Up @@ -374,7 +374,7 @@ async fn test_pay_multiple_coin_multiple_recipient() {
async fn test_pay_iota_multiple_coin_same_recipient() {
let network = TestClusterBuilder::new().build().await;
let client = network.wallet.get_client().await.unwrap();
let keystore = &network.wallet.config.keystore;
let keystore = network.wallet.config().keystore();
let rgp = network.get_reference_gas_price().await;

// Test Pay multiple coin same recipient
Expand Down Expand Up @@ -410,7 +410,7 @@ async fn test_pay_iota_multiple_coin_same_recipient() {
async fn test_pay_iota() {
let network = TestClusterBuilder::new().build().await;
let client = network.wallet.get_client().await.unwrap();
let keystore = &network.wallet.config.keystore;
let keystore = network.wallet.config().keystore();
let rgp = network.get_reference_gas_price().await;

// Test Pay Iota
Expand Down Expand Up @@ -445,7 +445,7 @@ async fn test_pay_iota() {
async fn test_failed_pay_iota() {
let network = TestClusterBuilder::new().build().await;
let client = network.wallet.get_client().await.unwrap();
let keystore = &network.wallet.config.keystore;
let keystore = network.wallet.config().keystore();
let rgp = network.get_reference_gas_price().await;

// Test failed Pay Iota
Expand Down Expand Up @@ -480,7 +480,7 @@ async fn test_failed_pay_iota() {
async fn test_stake_iota() {
let network = TestClusterBuilder::new().build().await;
let client = network.wallet.get_client().await.unwrap();
let keystore = &network.wallet.config.keystore;
let keystore = network.wallet.config().keystore();
let rgp = network.get_reference_gas_price().await;

// Test Delegate Iota
Expand Down Expand Up @@ -528,7 +528,7 @@ async fn test_stake_iota() {
async fn test_stake_iota_with_none_amount() {
let network = TestClusterBuilder::new().build().await;
let client = network.wallet.get_client().await.unwrap();
let keystore = &network.wallet.config.keystore;
let keystore = network.wallet.config().keystore();
let rgp = network.get_reference_gas_price().await;

// Test Staking Iota
Expand Down Expand Up @@ -576,7 +576,7 @@ async fn test_stake_iota_with_none_amount() {
async fn test_pay_all_iota() {
let network = TestClusterBuilder::new().build().await;
let client = network.wallet.get_client().await.unwrap();
let keystore = &network.wallet.config.keystore;
let keystore = network.wallet.config().keystore();
let rgp = network.get_reference_gas_price().await;

// Test Pay All Iota
Expand Down
12 changes: 6 additions & 6 deletions crates/iota-rosetta/tests/end_to_end_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async fn test_get_staked_iota() {
let test_cluster = TestClusterBuilder::new().build().await;
let address = test_cluster.get_address_0();
let client = test_cluster.wallet.get_client().await.unwrap();
let keystore = &test_cluster.wallet.config.keystore;
let keystore = test_cluster.wallet.config().keystore();

let (rosetta_client, _handle) = start_rosetta_test_server(client.clone()).await;

Expand Down Expand Up @@ -132,7 +132,7 @@ async fn test_stake() {
let test_cluster = TestClusterBuilder::new().build().await;
let sender = test_cluster.get_address_0();
let client = test_cluster.wallet.get_client().await.unwrap();
let keystore = &test_cluster.wallet.config.keystore;
let keystore = test_cluster.wallet.config().keystore();

let (rosetta_client, _handle) = start_rosetta_test_server(client.clone()).await;

Expand Down Expand Up @@ -193,7 +193,7 @@ async fn test_stake_all() {
let test_cluster = TestClusterBuilder::new().build().await;
let sender = test_cluster.get_address_0();
let client = test_cluster.wallet.get_client().await.unwrap();
let keystore = &test_cluster.wallet.config.keystore;
let keystore = test_cluster.wallet.config().keystore();

let (rosetta_client, _handle) = start_rosetta_test_server(client.clone()).await;

Expand Down Expand Up @@ -258,7 +258,7 @@ async fn test_withdraw_stake() {
.await;
let sender = test_cluster.get_address_0();
let client = test_cluster.wallet.get_client().await.unwrap();
let keystore = &test_cluster.wallet.config.keystore;
let keystore = test_cluster.wallet.config().keystore();

let (rosetta_client, _handle) = start_rosetta_test_server(client.clone()).await;

Expand Down Expand Up @@ -382,7 +382,7 @@ async fn test_pay_iota() {
let sender = test_cluster.get_address_0();
let recipient = test_cluster.get_address_1();
let client = test_cluster.wallet.get_client().await.unwrap();
let keystore = &test_cluster.wallet.config.keystore;
let keystore = test_cluster.wallet.config().keystore();

let (rosetta_client, _handle) = start_rosetta_test_server(client.clone()).await;

Expand Down Expand Up @@ -440,7 +440,7 @@ async fn test_pay_iota_multiple_times() {
let sender = test_cluster.get_address_0();
let recipient = test_cluster.get_address_1();
let client = test_cluster.wallet.get_client().await.unwrap();
let keystore = &test_cluster.wallet.config.keystore;
let keystore = test_cluster.wallet.config().keystore();

let (rosetta_client, _handle) = start_rosetta_test_server(client.clone()).await;

Expand Down
2 changes: 1 addition & 1 deletion crates/iota-rosetta/tests/gas_budget_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async fn pay_with_gas_budget(budget: u64) -> TransactionIdentifierResponseResult
let sender = test_cluster.get_address_0();
let recipient = test_cluster.get_address_1();
let client = test_cluster.wallet.get_client().await.unwrap();
let keystore = &test_cluster.wallet.config.keystore;
let keystore = test_cluster.wallet.config().keystore();

let (rosetta_client, _handle) = start_rosetta_test_server(client.clone()).await;

Expand Down
Loading

0 comments on commit db5a337

Please sign in to comment.