Skip to content

Commit

Permalink
rustfmt: format comments
Browse files Browse the repository at this point in the history
  • Loading branch information
buffalojoec committed Nov 7, 2023
1 parent f1571f5 commit c01a2d1
Show file tree
Hide file tree
Showing 220 changed files with 3,462 additions and 2,320 deletions.
6 changes: 4 additions & 2 deletions associated-token-account/program-test/tests/extended_mint.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Mark this test as BPF-only due to current `ProgramTest` limitations when CPIing into the system program
// Mark this test as BPF-only due to current `ProgramTest` limitations when
// CPIing into the system program
#![cfg(feature = "test-sbf")]

mod program_test;
Expand Down Expand Up @@ -34,7 +35,8 @@ async fn test_associated_token_account_with_transfer_fees() {
let rent = banks_client.get_rent().await.unwrap();

// create extended mint
// ... in the future, a mint can be pre-loaded in program_test.rs like the regular mint
// ... in the future, a mint can be pre-loaded in program_test.rs like the
// regular mint
let mint_account = Keypair::new();
let token_mint_address = mint_account.pubkey();
let mint_authority = Keypair::new();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Mark this test as BPF-only due to current `ProgramTest` limitations when CPIing into the system program
// Mark this test as BPF-only due to current `ProgramTest` limitations when
// CPIing into the system program
#![cfg(feature = "test-sbf")]

mod program_test;
Expand Down Expand Up @@ -86,8 +87,8 @@ async fn test_create_with_fewer_lamports() {
.unwrap();
let expected_token_account_balance = rent.minimum_balance(expected_token_account_len);

// Transfer lamports into `associated_token_address` before creating it - enough to be
// rent-exempt for 0 data, but not for an initialized token account
// Transfer lamports into `associated_token_address` before creating it - enough
// to be rent-exempt for 0 data, but not for an initialized token account
let mut transaction = Transaction::new_with_payer(
&[system_instruction::transfer(
&payer.pubkey(),
Expand Down
6 changes: 4 additions & 2 deletions associated-token-account/program-test/tests/program_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ pub fn program_test(token_mint_address: Pubkey, use_latest_spl_token: bool) -> P
"token-mint-data.bin",
);

// Dial down the BPF compute budget to detect if the program gets bloated in the future
// Dial down the BPF compute budget to detect if the program gets bloated in the
// future
pc.set_compute_max_units(60_000);

pc
Expand Down Expand Up @@ -75,7 +76,8 @@ pub fn program_test_2022(
"token-mint-data.bin",
);

// Dial down the BPF compute budget to detect if the program gets bloated in the future
// Dial down the BPF compute budget to detect if the program gets bloated in the
// future
pc.set_compute_max_units(50_000);

pc
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Mark this test as BPF-only due to current `ProgramTest` limitations when CPIing into the system program
// Mark this test as BPF-only due to current `ProgramTest` limitations when
// CPIing into the system program
#![cfg(feature = "test-sbf")]

mod program_test;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Mark this test as BPF-only due to current `ProgramTest` limitations when CPIing into the system program
// Mark this test as BPF-only due to current `ProgramTest` limitations when
// CPIing into the system program
#![cfg(feature = "test-sbf")]

mod program_test;
Expand Down
13 changes: 7 additions & 6 deletions associated-token-account/program/src/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use {
/// Instructions supported by the AssociatedTokenAccount program
#[derive(Clone, Debug, PartialEq, BorshDeserialize, BorshSerialize, BorshSchema)]
pub enum AssociatedTokenAccountInstruction {
/// Creates an associated token account for the given wallet address and token mint
/// Returns an error if the account exists.
/// Creates an associated token account for the given wallet address and
/// token mint Returns an error if the account exists.
///
/// 0. `[writeable,signer]` Funding account (must be a system account)
/// 1. `[writeable]` Associated token account address to be created
Expand All @@ -23,9 +23,9 @@ pub enum AssociatedTokenAccountInstruction {
/// 4. `[]` System program
/// 5. `[]` SPL Token program
Create,
/// Creates an associated token account for the given wallet address and token mint,
/// if it doesn't already exist. Returns an error if the account exists,
/// but with a different owner.
/// Creates an associated token account for the given wallet address and
/// token mint, if it doesn't already exist. Returns an error if the
/// account exists, but with a different owner.
///
/// 0. `[writeable,signer]` Funding account (must be a system account)
/// 1. `[writeable]` Associated token account address to be created
Expand All @@ -50,7 +50,8 @@ pub enum AssociatedTokenAccountInstruction {
/// 2. `[writeable]` Wallet's associated token account
/// 3. `[]` Owner associated token account address, must be owned by `5`
/// 4. `[]` Token mint for the owner associated token account
/// 5. `[writeable, signer]` Wallet address for the owner associated token account
/// 5. `[writeable, signer]` Wallet address for the owner associated token
/// account
/// 6. `[]` SPL Token program
RecoverNested,
}
Expand Down
13 changes: 8 additions & 5 deletions associated-token-account/program/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ pub mod instruction;
pub mod processor;
pub mod tools;

// Export current SDK types for downstream users building with a different SDK version
// Export current SDK types for downstream users building with a different SDK
// version
pub use solana_program;
use solana_program::{
instruction::{AccountMeta, Instruction},
Expand All @@ -32,7 +33,8 @@ pub(crate) fn get_associated_token_address_and_bump_seed(
)
}

/// Derives the associated token account address for the given wallet address and token mint
/// Derives the associated token account address for the given wallet address
/// and token mint
pub fn get_associated_token_address(
wallet_address: &Pubkey,
token_mint_address: &Pubkey,
Expand All @@ -44,7 +46,8 @@ pub fn get_associated_token_address(
)
}

/// Derives the associated token account address for the given wallet address, token mint and token program id
/// Derives the associated token account address for the given wallet address,
/// token mint and token program id
pub fn get_associated_token_address_with_program_id(
wallet_address: &Pubkey,
token_mint_address: &Pubkey,
Expand Down Expand Up @@ -75,7 +78,8 @@ fn get_associated_token_address_and_bump_seed_internal(
)
}

/// Create an associated token account for the given wallet address and token mint
/// Create an associated token account for the given wallet address and token
/// mint
///
/// Accounts expected by this instruction:
///
Expand All @@ -85,7 +89,6 @@ fn get_associated_token_address_and_bump_seed_internal(
/// 3. `[]` The token mint for the new associated token account
/// 4. `[]` System program
/// 5. `[]` SPL Token program
///
#[deprecated(
since = "1.0.5",
note = "please use `instruction::create_associated_token_account` instead"
Expand Down
7 changes: 4 additions & 3 deletions associated-token-account/program/src/tools/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ use {
std::convert::TryInto,
};

/// Creates associated token account using Program Derived Address for the given seeds
/// Creates associated token account using Program Derived Address for the given
/// seeds
pub fn create_pda_account<'a>(
payer: &AccountInfo<'a>,
rent: &Rent,
Expand Down Expand Up @@ -71,8 +72,8 @@ pub fn create_pda_account<'a>(
}
}

/// Determines the required initial data length for a new token account based on the extensions
/// initialized on the Mint
/// Determines the required initial data length for a new token account based on
/// the extensions initialized on the Mint
pub fn get_account_len<'a>(
mint: &AccountInfo<'a>,
spl_token_program: &AccountInfo<'a>,
Expand Down
3 changes: 2 additions & 1 deletion binary-option/program/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ pub mod spl_utils;
pub mod state;
pub mod system_utils;
pub mod validation_utils;
// Export current sdk types for downstream users building with a different sdk version
// Export current sdk types for downstream users building with a different sdk
// version
pub use solana_program;

solana_program::declare_id!("betw959P4WToez4DkuXwNsJszqbpe3HuY56AcG5yevx");
10 changes: 6 additions & 4 deletions binary-option/program/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,9 @@ pub fn process_trade(
binary_option.decrement_supply(n_b)?;
}
}
// Delegate the burn authority to the PDA, so a private key is unnecessary on collection
// This can probably be optimized to reduce the number of instructions needed at some point
// Delegate the burn authority to the PDA, so a private key is unnecessary on
// collection This can probably be optimized to reduce the number of
// instructions needed at some point
spl_approve(
token_program_info,
buyer_long_token_account_info,
Expand Down Expand Up @@ -589,8 +590,9 @@ pub fn process_trade(

pub fn process_settle(_program_id: &Pubkey, accounts: &[AccountInfo]) -> ProgramResult {
// This should NEVER be called directly (otherwise this is literally a rug)
// The `pool_owner_info` needs to approve this action, so the recommended use case is to have a higher
// level program own the pool and use an oracle to resolve settlements
// The `pool_owner_info` needs to approve this action, so the recommended use
// case is to have a higher level program own the pool and use an oracle to
// resolve settlements
let account_info_iter = &mut accounts.iter();
let binary_option_account_info = next_account_info(account_info_iter)?;
let winning_mint_account_info = next_account_info(account_info_iter)?;
Expand Down
17 changes: 10 additions & 7 deletions binary-oracle-pair/program/src/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ pub enum PoolInstruction {
/// 0. `[]` Pool
/// 1. `[]` Authority
/// 2. `[s]` User transfer authority
/// 3. `[w]` Token SOURCE Account, amount is transferable by pool authority with allowances.
/// 3. `[w]` Token SOURCE Account, amount is transferable by pool
/// authority with allowances.
/// 4. `[w]` Deposit token account
/// 5. `[w]` token_P PASS mint
/// 6. `[w]` token_F FAIL mint
Expand All @@ -55,12 +56,13 @@ pub enum PoolInstruction {
Deposit(u64),

/// Withdraw from the pool.
/// If current slot is < mint_end slot, 1 Pass AND 1 Fail token convert to 1 deposit
/// If current slot is > decide_end_slot slot && decide == Some(true), 1 Pass convert to 1 deposit
/// otherwise 1 Fail converts to 1 deposit
/// If current slot is < mint_end slot, 1 Pass AND 1 Fail token convert to
/// 1 deposit If current slot is > decide_end_slot slot && decide ==
/// Some(true), 1 Pass convert to 1 deposit otherwise 1 Fail converts
/// to 1 deposit
///
/// Pass tokens convert 1:1 to the deposit token iff decision is set to Some(true)
/// AND current slot is > decide_end_slot.
/// Pass tokens convert 1:1 to the deposit token iff decision is set to
/// Some(true) AND current slot is > decide_end_slot.
///
/// 0. `[]` Pool
/// 1. `[]` Authority
Expand All @@ -76,7 +78,8 @@ pub enum PoolInstruction {
Withdraw(u64),

/// Trigger the decision.
/// Call only succeeds once and if current slot > mint_end slot AND < decide_end slot
/// Call only succeeds once and if current slot > mint_end slot AND <
/// decide_end slot
/// 0. `[]` Pool
/// 1. `[s]` Decider pubkey
/// 2. `[]` Sysvar Clock
Expand Down
3 changes: 2 additions & 1 deletion binary-oracle-pair/program/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ pub mod state;
#[cfg(not(feature = "no-entrypoint"))]
mod entrypoint;

// Export current sdk types for downstream users building with a different sdk version
// Export current sdk types for downstream users building with a different sdk
// version
pub use solana_program;

// Binary Oracle Pair id
Expand Down
3 changes: 2 additions & 1 deletion examples/rust/cross-program-invocation/tests/functional.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Mark this test as BPF-only due to current `ProgramTest` limitations when CPIing into the system program
// Mark this test as BPF-only due to current `ProgramTest` limitations when
// CPIing into the system program
#![cfg(feature = "test-sbf")]

use {
Expand Down
3 changes: 2 additions & 1 deletion examples/rust/sysvar/src/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ pub fn process_instruction(
let rent_via_account = Rent::from_account_info(rent_sysvar_info)?;
// Both produce the same sysvar
assert_eq!(rent_via_sysvar, rent_via_account);
// Can't print `exemption_threshold` because BPF does not support printing floats
// Can't print `exemption_threshold` because BPF does not support printing
// floats
msg!(
"Rent: lamports_per_byte_year: {:?}, burn_percent: {:?}",
rent_via_sysvar.lamports_per_byte_year,
Expand Down
55 changes: 32 additions & 23 deletions feature-proposal/program/src/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,45 @@ use {
pub enum FeatureProposalInstruction {
/// Propose a new feature.
///
/// This instruction will create a variety of accounts to support the feature proposal, all
/// funded by account 0:
/// * A new token mint with a supply of `tokens_to_mint`, owned by the program and never
/// modified again
/// * A new "distributor" token account that holds the total supply, owned by account 0.
/// * A new "acceptance" token account that holds 0 tokens, owned by the program. Tokens
/// transfers to this address are irrevocable and permanent.
/// * A new feature id account that has been funded and allocated (as described in
/// This instruction will create a variety of accounts to support the
/// feature proposal, all funded by account 0:
/// * A new token mint with a supply of `tokens_to_mint`, owned by the
/// program and never modified again
/// * A new "distributor" token account that holds the total supply, owned
/// by account 0.
/// * A new "acceptance" token account that holds 0 tokens, owned by the
/// program. Tokens transfers to this address are irrevocable and
/// permanent.
/// * A new feature id account that has been funded and allocated (as
/// described in
/// `solana_program::feature`)
///
/// On successful execution of the instruction, the feature proposer is expected to distribute
/// the tokens in the distributor token account out to all participating parties.
/// On successful execution of the instruction, the feature proposer is
/// expected to distribute the tokens in the distributor token account
/// out to all participating parties.
///
/// Based on the provided acceptance criteria, if `AcceptanceCriteria::tokens_required`
/// tokens are transferred into the acceptance token account before
/// `AcceptanceCriteria::deadline` then the proposal is eligible to be accepted.
/// Based on the provided acceptance criteria, if
/// `AcceptanceCriteria::tokens_required` tokens are transferred into
/// the acceptance token account before `AcceptanceCriteria::deadline`
/// then the proposal is eligible to be accepted.
///
/// The `FeatureProposalInstruction::Tally` instruction must be executed, by any party, to
/// complete the feature acceptance process.
/// The `FeatureProposalInstruction::Tally` instruction must be executed, by
/// any party, to complete the feature acceptance process.
///
/// Accounts expected by this instruction:
///
/// 0. `[writeable,signer]` Funding account (must be a system account)
/// 1. `[writeable,signer]` Unallocated feature proposal account to create
/// 2. `[writeable]` Token mint address from `get_mint_address`
/// 3. `[writeable]` Distributor token account address from `get_distributor_token_address`
/// 4. `[writeable]` Acceptance token account address from `get_acceptance_token_address`
/// 5. `[writeable]` Feature id account address from `get_feature_id_address`
/// 3. `[writeable]` Distributor token account address from
/// `get_distributor_token_address`
/// 4. `[writeable]` Acceptance token account address from
/// `get_acceptance_token_address`
/// 5. `[writeable]` Feature id account address from
/// `get_feature_id_address`
/// 6. `[]` System program
/// 7. `[]` SPL Token program
/// 8. `[]` Rent sysvar
///
Propose {
/// Total number of tokens to mint for this proposal
#[allow(dead_code)] // not dead code..
Expand All @@ -60,17 +67,19 @@ pub enum FeatureProposalInstruction {
acceptance_criteria: AcceptanceCriteria,
},

/// `Tally` is a permission-less instruction to check the acceptance criteria for the feature
/// proposal, which may result in:
/// `Tally` is a permission-less instruction to check the acceptance
/// criteria for the feature proposal, which may result in:
/// * No action
/// * Feature proposal acceptance
/// * Feature proposal expiration
///
/// Accounts expected by this instruction:
///
/// 0. `[writeable]` Feature proposal account
/// 1. `[]` Acceptance token account address from `get_acceptance_token_address`
/// 2. `[writeable]` Derived feature id account address from `get_feature_id_address`
/// 1. `[]` Acceptance token account address from
/// `get_acceptance_token_address`
/// 2. `[writeable]` Derived feature id account address from
/// `get_feature_id_address`
/// 3. `[]` System program
/// 4. `[]` Clock sysvar
Tally,
Expand Down
Loading

0 comments on commit c01a2d1

Please sign in to comment.