Skip to content

Commit

Permalink
chore: update formatting
Browse files Browse the repository at this point in the history
Latest upgrade in nightly rust leads to changed formatting rules.
  • Loading branch information
ifiokjr committed Oct 3, 2024
1 parent 202f7f3 commit cd51daf
Show file tree
Hide file tree
Showing 114 changed files with 481 additions and 561 deletions.
1 change: 0 additions & 1 deletion .config/nextest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ leak-timeout = "100ms"
# To address this, "archive.include" specifies additional paths that will be included in the archive.
archive.include = [


# Examples:
#
# { path = "application-data", relative-to = "target" },
Expand Down
4 changes: 2 additions & 2 deletions crates/test_utils_solana/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
pub use solana_banks_client::BanksClientExt;
pub use solana_program_runtime;
pub use solana_program_test::processor;
pub use solana_program_test::programs;
pub use solana_program_test::BanksClient;
pub use solana_program_test::BanksClientError;
pub use solana_program_test::ProgramTest;
pub use solana_program_test::ProgramTestBanksClientExt;
pub use solana_program_test::ProgramTestContext;
pub use solana_program_test::ProgramTestError;
pub use solana_program_test::processor;
pub use solana_program_test::programs;
pub use solana_sdk;
#[cfg(feature = "test_validator")]
pub use test_validator_runner::*;
Expand Down
2 changes: 1 addition & 1 deletion crates/test_utils_solana/src/test_validator_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ use anchor_lang::Discriminator;
use anyhow::Context;
use anyhow::Result;
use crossbeam_channel::unbounded;
use futures::future::Shared;
use futures::Future;
use futures::FutureExt;
use futures::future::Shared;
use lazy_static::lazy_static;
use port_check::is_local_ipv4_port_free;
use rand::Rng;
Expand Down
124 changes: 48 additions & 76 deletions crates/test_utils_solana/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ use solana_sdk::bpf_loader_upgradeable::{self};
use solana_sdk::clock::Clock;
use solana_sdk::clock::Slot;
use solana_sdk::commitment_config::CommitmentLevel;
use solana_sdk::message::v0;
use solana_sdk::message::VersionedMessage;
use solana_sdk::message::v0;
use solana_sdk::native_token::sol_to_lamports;
use solana_sdk::program_option::COption;
use solana_sdk::program_pack::Pack;
Expand All @@ -37,13 +37,13 @@ use solana_sdk::signature::Signer;
use solana_sdk::sysvar::rent::Rent;
use solana_sdk::transaction::VersionedTransaction;
use spl_associated_token_account::get_associated_token_address;
use wallet_standard::prelude::*;
use wallet_standard::SolanaSignAndSendTransactionProps;
use wallet_standard::SolanaSignTransactionProps;
use wasm_client_anchor::prelude::*;
use wallet_standard::prelude::*;
use wasm_client_anchor::AnchorClientError;
use wasm_client_anchor::AnchorClientResult;
use wasm_client_anchor::WalletAnchor;
use wasm_client_anchor::prelude::*;

pub const MAX_COMPUTE_UNITS: u64 = DEFAULT_INSTRUCTION_COMPUTE_UNIT_LIMIT as u64;

Expand Down Expand Up @@ -102,14 +102,11 @@ impl BanksClientAsyncExtension for BanksClient {
}: SolanaSignAndSendTransactionProps,
) -> WalletResult<BanksTransactionResultWithMetadata> {
let transaction = self
.wallet_sign_transaction(
wallet,
SolanaSignTransactionProps {
transaction,
chain,
options: options.map(Into::into),
},
)
.wallet_sign_transaction(wallet, SolanaSignTransactionProps {
transaction,
chain,
options: options.map(Into::into),
})
.await?;

let metadata = self
Expand All @@ -131,14 +128,11 @@ impl BanksClientAsyncExtension for BanksClient {
}: SolanaSignAndSendTransactionProps,
) -> AnchorClientResult<BanksTransactionResultWithSimulation> {
let transaction = self
.wallet_sign_transaction(
wallet,
SolanaSignTransactionProps {
transaction,
chain,
options: options.map(Into::into),
},
)
.wallet_sign_transaction(wallet, SolanaSignTransactionProps {
transaction,
chain,
options: options.map(Into::into),
})
.await?;

let result = self
Expand Down Expand Up @@ -333,16 +327,13 @@ impl ProgramTestExtension for ProgramTest {
data: &[u8],
executable: bool,
) {
self.add_account(
pubkey,
Account {
lamports: Rent::default().minimum_balance(data.len()),
data: data.to_vec(),
executable,
owner,
rent_epoch: 0,
},
);
self.add_account(pubkey, Account {
lamports: Rent::default().minimum_balance(data.len()),
data: data.to_vec(),
executable,
owner,
rent_epoch: 0,
});
}

fn add_account_with_anchor<T: AnchorSerialize + Discriminator>(
Expand Down Expand Up @@ -377,16 +368,13 @@ impl ProgramTestExtension for ProgramTest {
}

fn add_account_with_lamports(&mut self, pubkey: Pubkey, owner: Pubkey, lamports: u64) {
self.add_account(
pubkey,
Account {
lamports,
data: vec![],
executable: false,
owner,
rent_epoch: 0,
},
);
self.add_account(pubkey, Account {
lamports,
data: vec![],
executable: false,
owner,
rent_epoch: 0,
});
}

fn add_account_with_packable<P: Pack>(&mut self, pubkey: Pubkey, owner: Pubkey, data: P) {
Expand Down Expand Up @@ -418,17 +406,13 @@ impl ProgramTestExtension for ProgramTest {
decimals: u8,
freeze_authority: Option<Pubkey>,
) {
self.add_account_with_packable(
pubkey,
spl_token_2022::ID,
spl_token_2022::state::Mint {
mint_authority: COption::from(mint_authority),
supply,
decimals,
is_initialized: true,
freeze_authority: COption::from(freeze_authority),
},
);
self.add_account_with_packable(pubkey, spl_token_2022::ID, spl_token_2022::state::Mint {
mint_authority: COption::from(mint_authority),
supply,
decimals,
is_initialized: true,
freeze_authority: COption::from(freeze_authority),
});
}

fn add_token_account(
Expand Down Expand Up @@ -497,23 +481,17 @@ impl ProgramTestExtension for ProgramTest {
let program_data_pubkey = Pubkey::new_unique();
let mut program = Vec::<u8>::new();

bincode::serialize_into(
&mut program,
&UpgradeableLoaderState::Program {
programdata_address: program_data_pubkey,
},
)
bincode::serialize_into(&mut program, &UpgradeableLoaderState::Program {
programdata_address: program_data_pubkey,
})
.unwrap();

let mut program_data = Vec::<u8>::new();

bincode::serialize_into(
&mut program_data,
&UpgradeableLoaderState::ProgramData {
slot: 0,
upgrade_authority_address: Some(program_authority),
},
)
bincode::serialize_into(&mut program_data, &UpgradeableLoaderState::ProgramData {
slot: 0,
upgrade_authority_address: Some(program_authority),
})
.unwrap();

log::info!(
Expand Down Expand Up @@ -570,22 +548,16 @@ impl ProgramTestExtension for ProgramTest {
let program_bytes = solana_program_test::read_file(program_file.clone());

let mut program = Vec::<u8>::new();
bincode::serialize_into(
&mut program,
&UpgradeableLoaderState::Program {
programdata_address: program_data_pubkey,
},
)
bincode::serialize_into(&mut program, &UpgradeableLoaderState::Program {
programdata_address: program_data_pubkey,
})
.unwrap();

let mut program_data = Vec::<u8>::new();
bincode::serialize_into(
&mut program_data,
&UpgradeableLoaderState::ProgramData {
slot: 0,
upgrade_authority_address: Some(program_authority),
},
)
bincode::serialize_into(&mut program_data, &UpgradeableLoaderState::ProgramData {
slot: 0,
upgrade_authority_address: Some(program_authority),
})
.unwrap();

log::info!(
Expand Down
2 changes: 1 addition & 1 deletion crates/test_utils_solana/tests/streams.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ use std::time::Duration;
use assert2::check;
use solana_sdk::signature::Keypair;
use test_utils::SECRET_KEY_WALLET;
use test_utils_solana::prelude::*;
use test_utils_solana::TestValidatorRunner;
use test_utils_solana::TestValidatorRunnerProps;
use test_utils_solana::prelude::*;
use tokio::time::timeout;
use wasm_client_solana::rpc_config::LogsSubscribeRequest;
use wasm_client_solana::rpc_config::RpcTransactionLogsFilter;
Expand Down
4 changes: 2 additions & 2 deletions crates/wallet_standard/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ mod standard;
mod types;

pub mod prelude {
#[cfg(feature = "solana")]
pub use super::solana::prelude::*;
pub use super::ExperimentalDecryptOutput;
pub use super::ExperimentalEncryptOutput;
pub use super::IntoWalletError;
Expand All @@ -31,4 +29,6 @@ pub mod prelude {
pub use super::WalletStandard;
pub use super::WalletStandardConnect;
pub use super::WalletStandardDisconnect;
#[cfg(feature = "solana")]
pub use super::solana::prelude::*;
}
2 changes: 1 addition & 1 deletion crates/wallet_standard_browser/src/browser_wallet_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ use wallet_standard::WalletAccountInfo;
use wallet_standard::WalletError;
use wallet_standard::WalletInfo;
use wallet_standard::WalletResult;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
use wasm_bindgen::JsValue;
use wasm_bindgen::prelude::*;

use crate::FeatureFromJs;
use crate::StandardConnectFeature;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ use js_sys::Array;
use serde::Deserialize;
use serde::Serialize;
use typed_builder::TypedBuilder;
use wallet_standard::EXPERIMENTAL_DECRYPT;
use wallet_standard::ExperimentalDecryptOutput;
use wallet_standard::ExperimentalDecryptProps;
use wallet_standard::WalletError;
use wallet_standard::WalletExperimentalDecrypt;
use wallet_standard::WalletResult;
use wallet_standard::EXPERIMENTAL_DECRYPT;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
use wasm_bindgen::JsValue;
use wasm_bindgen::prelude::*;

use crate::impl_feature_from_js;
use crate::BrowserWallet;
use crate::BrowserWalletAccountInfo;
use crate::impl_feature_from_js;

#[wasm_bindgen]
extern "C" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ use js_sys::Array;
use serde::Deserialize;
use serde::Serialize;
use typed_builder::TypedBuilder;
use wallet_standard::EXPERIMENTAL_ENCRYPT;
use wallet_standard::ExperimentalEncryptOutput;
use wallet_standard::ExperimentalEncryptProps;
use wallet_standard::WalletError;
use wallet_standard::WalletExperimentalEncrypt;
use wallet_standard::WalletResult;
use wallet_standard::EXPERIMENTAL_ENCRYPT;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
use wasm_bindgen::JsValue;
use wasm_bindgen::prelude::*;

use crate::impl_feature_from_js;
use crate::BrowserWallet;
use crate::BrowserWalletAccountInfo;
use crate::impl_feature_from_js;

impl ExperimentalEncryptOutput for BrowserExperimentalEncryptOutput {
fn cipher_text(&self) -> Vec<u8> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ use serde::Serialize;
use solana_sdk::signature::Signature;
use solana_sdk::transaction::TransactionVersion;
use typed_builder::TypedBuilder;
use wallet_standard::SOLANA_SIGN_AND_SEND_TRANSACTION;
use wallet_standard::SolanaSignAndSendTransactionProps;
use wallet_standard::SolanaSignatureOutput;
use wallet_standard::WalletError;
use wallet_standard::WalletResult;
use wallet_standard::WalletSolanaSignAndSendTransaction;
use wallet_standard::SOLANA_SIGN_AND_SEND_TRANSACTION;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
use wasm_bindgen::JsValue;
use wasm_bindgen::prelude::*;

use crate::impl_feature_from_js;
use crate::BrowserWallet;
use crate::BrowserWalletAccountInfo;
use crate::impl_feature_from_js;

#[wasm_bindgen]
extern "C" {
Expand Down
6 changes: 3 additions & 3 deletions crates/wallet_standard_browser/src/features/solana/sign_in.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use async_trait::async_trait;
use js_sys::Array;
use solana_sdk::signature::Signature;
use wallet_standard::SOLANA_SIGN_IN;
use wallet_standard::SolanaSignInInput;
use wallet_standard::SolanaSignInOutput;
use wallet_standard::SolanaSignMessageOutput;
Expand All @@ -11,14 +12,13 @@ use wallet_standard::WalletError;
use wallet_standard::WalletResult;
use wallet_standard::WalletSolanaPubkey;
use wallet_standard::WalletSolanaSignIn;
use wallet_standard::SOLANA_SIGN_IN;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
use wasm_bindgen::JsValue;
use wasm_bindgen::prelude::*;

use crate::impl_feature_from_js;
use crate::BrowserWallet;
use crate::BrowserWalletAccountInfo;
use crate::impl_feature_from_js;

#[wasm_bindgen]
extern "C" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ use serde::Deserialize;
use serde::Serialize;
use solana_sdk::signature::Signature;
use typed_builder::TypedBuilder;
use wallet_standard::SOLANA_SIGN_MESSAGE;
use wallet_standard::SolanaSignMessageOutput;
use wallet_standard::SolanaSignatureOutput;
use wallet_standard::WalletError;
use wallet_standard::WalletResult;
use wallet_standard::WalletSolanaSignMessage;
use wallet_standard::SOLANA_SIGN_MESSAGE;
use wasm_bindgen::prelude::*;
use wasm_bindgen::JsCast;
use wasm_bindgen::JsValue;
use wasm_bindgen::prelude::*;

use crate::impl_feature_from_js;
use crate::BrowserWallet;
use crate::BrowserWalletAccountInfo;
use crate::impl_feature_from_js;

#[wasm_bindgen]
extern "C" {
Expand Down
Loading

0 comments on commit cd51daf

Please sign in to comment.