Browse Source

token: Fix typos for cargo-spellcheck (#7503)

* token: Fix typos

#### Problem

There are typos in the token code, and people sometimes fix them, but
mostly don't.

#### Summary of changes

Starting with the `token/*` directory, fix all typos or properly put
them between backticks if they're code.

These were all found using `cargo spellcheck` and a specialized
dictionary with programming / Solana / ZK terminology. Once all of the
typos are fixed, then we can add the spellchecking to CI.

* Update doctests
Jon C 10 months ago
parent
commit
d4adbd3b4b
5 changed files with 69 additions and 64 deletions
  1. 1 1
      program/README.md
  2. 38 37
      program/src/instruction.rs
  3. 1 1
      program/src/native_mint.rs
  4. 26 22
      program/src/processor.rs
  5. 3 3
      program/src/state.rs

+ 1 - 1
program/README.md

@@ -5,7 +5,7 @@ A token program on the Solana blockchain, usable for fungible and non-fungible t
 This program provides an interface and implementation that third parties can
 utilize to create and use their tokens.
 
-Full documentation is available at https://spl.solana.com/token
+Full documentation is available at the [SPL Token docs](https://spl.solana.com/token).
 
 ## Audit
 

+ 38 - 37
program/src/instruction.rs

@@ -16,7 +16,7 @@ use {
 pub const MIN_SIGNERS: usize = 1;
 /// Maximum number of multisignature signers (max N)
 pub const MAX_SIGNERS: usize = 11;
-/// Serialized length of a u64, for unpacking
+/// Serialized length of a `u64`, for unpacking
 const U64_BYTES: usize = 8;
 
 /// Instructions supported by the token program.
@@ -80,8 +80,8 @@ pub enum TokenInstruction<'a> {
     ///
     ///   0. `[writable]` The multisignature account to initialize.
     ///   1. `[]` Rent sysvar
-    ///   2. ..2+N. `[]` The signer accounts, must equal to N where 1 <= N <=
-    ///      11.
+    ///   2. ..`2+N`. `[]` The signer accounts, must equal to N where `1 <= N <=
+    ///      11`.
     InitializeMultisig {
         /// The number of signers (M) required to validate this multisignature
         /// account.
@@ -103,7 +103,7 @@ pub enum TokenInstruction<'a> {
     ///   0. `[writable]` The source account.
     ///   1. `[writable]` The destination account.
     ///   2. `[]` The source account's multisignature owner/delegate.
-    ///   3. ..3+M `[signer]` M signer accounts.
+    ///   3. ..`3+M` `[signer]` M signer accounts.
     Transfer {
         /// The amount of tokens to transfer.
         amount: u64,
@@ -122,7 +122,7 @@ pub enum TokenInstruction<'a> {
     ///   0. `[writable]` The source account.
     ///   1. `[]` The delegate.
     ///   2. `[]` The source account's multisignature owner.
-    ///   3. ..3+M `[signer]` M signer accounts
+    ///   3. ..`3+M` `[signer]` M signer accounts
     Approve {
         /// The amount of tokens the delegate is approved for.
         amount: u64,
@@ -138,7 +138,7 @@ pub enum TokenInstruction<'a> {
     ///   * Multisignature owner
     ///   0. `[writable]` The source account.
     ///   1. `[]` The source account's multisignature owner.
-    ///   2. ..2+M `[signer]` M signer accounts
+    ///   2. ..`2+M` `[signer]` M signer accounts
     Revoke,
     /// Sets a new authority of a mint or account.
     ///
@@ -151,7 +151,7 @@ pub enum TokenInstruction<'a> {
     ///   * Multisignature authority
     ///   0. `[writable]` The mint or account to change the authority of.
     ///   1. `[]` The mint's or account's current multisignature authority.
-    ///   2. ..2+M `[signer]` M signer accounts
+    ///   2. ..`2+M` `[signer]` M signer accounts
     SetAuthority {
         /// The type of authority to update.
         authority_type: AuthorityType,
@@ -172,7 +172,7 @@ pub enum TokenInstruction<'a> {
     ///   0. `[writable]` The mint.
     ///   1. `[writable]` The account to mint tokens to.
     ///   2. `[]` The mint's multisignature mint-tokens authority.
-    ///   3. ..3+M `[signer]` M signer accounts.
+    ///   3. ..`3+M` `[signer]` M signer accounts.
     MintTo {
         /// The amount of new tokens to mint.
         amount: u64,
@@ -191,7 +191,7 @@ pub enum TokenInstruction<'a> {
     ///   0. `[writable]` The account to burn from.
     ///   1. `[writable]` The token mint.
     ///   2. `[]` The account's multisignature owner/delegate.
-    ///   3. ..3+M `[signer]` M signer accounts.
+    ///   3. ..`3+M` `[signer]` M signer accounts.
     Burn {
         /// The amount of tokens to burn.
         amount: u64,
@@ -210,9 +210,9 @@ pub enum TokenInstruction<'a> {
     ///   0. `[writable]` The account to close.
     ///   1. `[writable]` The destination account.
     ///   2. `[]` The account's multisignature owner.
-    ///   3. ..3+M `[signer]` M signer accounts.
+    ///   3. ..`3+M` `[signer]` M signer accounts.
     CloseAccount,
-    /// Freeze an Initialized account using the Mint's freeze_authority (if
+    /// Freeze an Initialized account using the Mint's `freeze_authority` (if
     /// set).
     ///
     /// Accounts expected by this instruction:
@@ -226,9 +226,9 @@ pub enum TokenInstruction<'a> {
     ///   0. `[writable]` The account to freeze.
     ///   1. `[]` The token mint.
     ///   2. `[]` The mint's multisignature freeze authority.
-    ///   3. ..3+M `[signer]` M signer accounts.
+    ///   3. ..`3+M` `[signer]` M signer accounts.
     FreezeAccount,
-    /// Thaw a Frozen account using the Mint's freeze_authority (if set).
+    /// Thaw a Frozen account using the Mint's `freeze_authority` (if set).
     ///
     /// Accounts expected by this instruction:
     ///
@@ -241,7 +241,7 @@ pub enum TokenInstruction<'a> {
     ///   0. `[writable]` The account to freeze.
     ///   1. `[]` The token mint.
     ///   2. `[]` The mint's multisignature freeze authority.
-    ///   3. ..3+M `[signer]` M signer accounts.
+    ///   3. ..`3+M` `[signer]` M signer accounts.
     ThawAccount,
 
     /// Transfers tokens from one account to another either directly or via a
@@ -266,7 +266,7 @@ pub enum TokenInstruction<'a> {
     ///   1. `[]` The token mint.
     ///   2. `[writable]` The destination account.
     ///   3. `[]` The source account's multisignature owner/delegate.
-    ///   4. ..4+M `[signer]` M signer accounts.
+    ///   4. ..`4+M` `[signer]` M signer accounts.
     TransferChecked {
         /// The amount of tokens to transfer.
         amount: u64,
@@ -293,7 +293,7 @@ pub enum TokenInstruction<'a> {
     ///   1. `[]` The token mint.
     ///   2. `[]` The delegate.
     ///   3. `[]` The source account's multisignature owner.
-    ///   4. ..4+M `[signer]` M signer accounts
+    ///   4. ..`4+M` `[signer]` M signer accounts
     ApproveChecked {
         /// The amount of tokens the delegate is approved for.
         amount: u64,
@@ -303,8 +303,8 @@ pub enum TokenInstruction<'a> {
     /// Mints new tokens to an account.  The native mint does not support
     /// minting.
     ///
-    /// This instruction differs from MintTo in that the decimals value is
-    /// checked by the caller.  This may be useful when creating transactions
+    /// This instruction differs from `MintTo` in that the decimals value is
+    /// checked by the caller. This may be useful when creating transactions
     /// offline or within a hardware wallet.
     ///
     /// Accounts expected by this instruction:
@@ -318,7 +318,7 @@ pub enum TokenInstruction<'a> {
     ///   0. `[writable]` The mint.
     ///   1. `[writable]` The account to mint tokens to.
     ///   2. `[]` The mint's multisignature mint-tokens authority.
-    ///   3. ..3+M `[signer]` M signer accounts.
+    ///   3. ..`3+M` `[signer]` M signer accounts.
     MintToChecked {
         /// The amount of new tokens to mint.
         amount: u64,
@@ -344,17 +344,17 @@ pub enum TokenInstruction<'a> {
     ///   0. `[writable]` The account to burn from.
     ///   1. `[writable]` The token mint.
     ///   2. `[]` The account's multisignature owner/delegate.
-    ///   3. ..3+M `[signer]` M signer accounts.
+    ///   3. ..`3+M` `[signer]` M signer accounts.
     BurnChecked {
         /// The amount of tokens to burn.
         amount: u64,
         /// Expected number of base 10 digits to the right of the decimal place.
         decimals: u8,
     },
-    /// Like InitializeAccount, but the owner pubkey is passed via instruction
-    /// data rather than the accounts list. This variant may be preferable
-    /// when using Cross Program Invocation from an instruction that does
-    /// not need the owner's `AccountInfo` otherwise.
+    /// Like [`InitializeAccount`], but the owner pubkey is passed via
+    /// instruction data rather than the accounts list. This variant may be
+    /// preferable when using Cross Program Invocation from an instruction
+    /// that does not need the owner's `AccountInfo` otherwise.
     ///
     /// Accounts expected by this instruction:
     ///
@@ -376,7 +376,7 @@ pub enum TokenInstruction<'a> {
     ///   0. `[writable]`  The native token account to sync with its underlying
     ///      lamports.
     SyncNative,
-    /// Like InitializeAccount2, but does not require the Rent sysvar to be
+    /// Like [`InitializeAccount2`], but does not require the Rent sysvar to be
     /// provided
     ///
     /// Accounts expected by this instruction:
@@ -387,14 +387,14 @@ pub enum TokenInstruction<'a> {
         /// The new account's owner/multisignature.
         owner: Pubkey,
     },
-    /// Like InitializeMultisig, but does not require the Rent sysvar to be
+    /// Like [`InitializeMultisig`], but does not require the Rent sysvar to be
     /// provided
     ///
     /// Accounts expected by this instruction:
     ///
     ///   0. `[writable]` The multisignature account to initialize.
-    ///   1. ..1+N. `[]` The signer accounts, must equal to N where 1 <= N <=
-    ///      11.
+    ///   1. ..`1+N` `[]` The signer accounts, must equal to N where `1 <= N <=
+    ///      11`.
     InitializeMultisig2 {
         /// The number of signers (M) required to validate this multisignature
         /// account.
@@ -439,7 +439,7 @@ pub enum TokenInstruction<'a> {
     /// Data expected by this instruction:
     ///   None
     InitializeImmutableOwner,
-    /// Convert an Amount of tokens to a UiAmount `string`, using the given
+    /// Convert an Amount of tokens to a `UiAmount` string, using the given
     /// mint. In this version of the program, the mint can only specify the
     /// number of decimals.
     ///
@@ -455,9 +455,9 @@ pub enum TokenInstruction<'a> {
         /// The amount of tokens to reformat.
         amount: u64,
     },
-    /// Convert a UiAmount of tokens to a little-endian `u64` raw Amount, using
-    /// the given mint. In this version of the program, the mint can only
-    /// specify the number of decimals.
+    /// Convert a `UiAmount` of tokens to a little-endian `u64` raw Amount,
+    /// using the given mint. In this version of the program, the mint can
+    /// only specify the number of decimals.
     ///
     /// Return data can be fetched using `sol_get_return_data` and deserializing
     /// the return data as a little-endian `u64`.
@@ -466,7 +466,7 @@ pub enum TokenInstruction<'a> {
     ///
     ///   0. `[]` The mint to calculate for
     UiAmountToAmount {
-        /// The ui_amount of tokens to reformat.
+        /// The `ui_amount` of tokens to reformat.
         ui_amount: &'a str,
     },
     // Any new variants also need to be added to program-2022 `TokenInstruction`, so that the
@@ -475,7 +475,7 @@ pub enum TokenInstruction<'a> {
 }
 impl<'a> TokenInstruction<'a> {
     /// Unpacks a byte buffer into a
-    /// [TokenInstruction](enum.TokenInstruction.html).
+    /// [`TokenInstruction`](enum.TokenInstruction.html).
     pub fn unpack(input: &'a [u8]) -> Result<Self, ProgramError> {
         use TokenError::InvalidInstruction;
 
@@ -579,7 +579,7 @@ impl<'a> TokenInstruction<'a> {
         })
     }
 
-    /// Packs a [TokenInstruction](enum.TokenInstruction.html) into a byte
+    /// Packs a [`TokenInstruction`](enum.TokenInstruction.html) into a byte
     /// buffer.
     pub fn pack(&self) -> Vec<u8> {
         let mut buf = Vec::with_capacity(size_of::<Self>());
@@ -738,7 +738,7 @@ impl<'a> TokenInstruction<'a> {
     }
 }
 
-/// Specifies the authority type for SetAuthority instructions
+/// Specifies the authority type for `SetAuthority` instructions
 #[repr(u8)]
 #[derive(Clone, Debug, PartialEq)]
 pub enum AuthorityType {
@@ -1431,7 +1431,8 @@ pub fn ui_amount_to_amount(
     })
 }
 
-/// Utility function that checks index is between MIN_SIGNERS and MAX_SIGNERS
+/// Utility function that checks index is between `MIN_SIGNERS` and
+/// `MAX_SIGNERS`
 pub fn is_valid_signer_index(index: usize) -> bool {
     (MIN_SIGNERS..=MAX_SIGNERS).contains(&index)
 }

+ 1 - 1
program/src/native_mint.rs

@@ -1,6 +1,6 @@
 //! The Mint that represents the native token
 
-/// There are 10^9 lamports in one SOL
+/// There are `10^9` lamports in one SOL
 pub const DECIMALS: u8 = 9;
 
 // The Mint for native SOL Token accounts

+ 26 - 22
program/src/processor.rs

@@ -61,7 +61,7 @@ impl Processor {
         Ok(())
     }
 
-    /// Processes an [InitializeMint](enum.TokenInstruction.html) instruction.
+    /// Processes an [`InitializeMint`](enum.TokenInstruction.html) instruction.
     pub fn process_initialize_mint(
         accounts: &[AccountInfo],
         decimals: u8,
@@ -71,7 +71,8 @@ impl Processor {
         Self::_process_initialize_mint(accounts, decimals, mint_authority, freeze_authority, true)
     }
 
-    /// Processes an [InitializeMint2](enum.TokenInstruction.html) instruction.
+    /// Processes an [`InitializeMint2`](enum.TokenInstruction.html)
+    /// instruction.
     pub fn process_initialize_mint2(
         accounts: &[AccountInfo],
         decimals: u8,
@@ -141,7 +142,7 @@ impl Processor {
         Ok(())
     }
 
-    /// Processes an [InitializeAccount](enum.TokenInstruction.html)
+    /// Processes an [`InitializeAccount`](enum.TokenInstruction.html)
     /// instruction.
     pub fn process_initialize_account(
         program_id: &Pubkey,
@@ -150,7 +151,7 @@ impl Processor {
         Self::_process_initialize_account(program_id, accounts, None, true)
     }
 
-    /// Processes an [InitializeAccount2](enum.TokenInstruction.html)
+    /// Processes an [`InitializeAccount2`](enum.TokenInstruction.html)
     /// instruction.
     pub fn process_initialize_account2(
         program_id: &Pubkey,
@@ -160,7 +161,7 @@ impl Processor {
         Self::_process_initialize_account(program_id, accounts, Some(&owner), true)
     }
 
-    /// Processes an [InitializeAccount3](enum.TokenInstruction.html)
+    /// Processes an [`InitializeAccount3`](enum.TokenInstruction.html)
     /// instruction.
     pub fn process_initialize_account3(
         program_id: &Pubkey,
@@ -212,19 +213,19 @@ impl Processor {
         Ok(())
     }
 
-    /// Processes a [InitializeMultisig](enum.TokenInstruction.html)
+    /// Processes a [`InitializeMultisig`](enum.TokenInstruction.html)
     /// instruction.
     pub fn process_initialize_multisig(accounts: &[AccountInfo], m: u8) -> ProgramResult {
         Self::_process_initialize_multisig(accounts, m, true)
     }
 
-    /// Processes a [InitializeMultisig2](enum.TokenInstruction.html)
+    /// Processes a [`InitializeMultisig2`](enum.TokenInstruction.html)
     /// instruction.
     pub fn process_initialize_multisig2(accounts: &[AccountInfo], m: u8) -> ProgramResult {
         Self::_process_initialize_multisig(accounts, m, false)
     }
 
-    /// Processes a [Transfer](enum.TokenInstruction.html) instruction.
+    /// Processes a [`Transfer`](enum.TokenInstruction.html) instruction.
     pub fn process_transfer(
         program_id: &Pubkey,
         accounts: &[AccountInfo],
@@ -341,7 +342,7 @@ impl Processor {
         Ok(())
     }
 
-    /// Processes an [Approve](enum.TokenInstruction.html) instruction.
+    /// Processes an [`Approve`](enum.TokenInstruction.html) instruction.
     pub fn process_approve(
         program_id: &Pubkey,
         accounts: &[AccountInfo],
@@ -392,7 +393,7 @@ impl Processor {
         Ok(())
     }
 
-    /// Processes an [Revoke](enum.TokenInstruction.html) instruction.
+    /// Processes an [`Revoke`](enum.TokenInstruction.html) instruction.
     pub fn process_revoke(program_id: &Pubkey, accounts: &[AccountInfo]) -> ProgramResult {
         let account_info_iter = &mut accounts.iter();
         let source_account_info = next_account_info(account_info_iter)?;
@@ -420,7 +421,7 @@ impl Processor {
         Ok(())
     }
 
-    /// Processes a [SetAuthority](enum.TokenInstruction.html) instruction.
+    /// Processes a [`SetAuthority`](enum.TokenInstruction.html) instruction.
     pub fn process_set_authority(
         program_id: &Pubkey,
         accounts: &[AccountInfo],
@@ -518,7 +519,7 @@ impl Processor {
         Ok(())
     }
 
-    /// Processes a [MintTo](enum.TokenInstruction.html) instruction.
+    /// Processes a [`MintTo`](enum.TokenInstruction.html) instruction.
     pub fn process_mint_to(
         program_id: &Pubkey,
         accounts: &[AccountInfo],
@@ -583,7 +584,7 @@ impl Processor {
         Ok(())
     }
 
-    /// Processes a [Burn](enum.TokenInstruction.html) instruction.
+    /// Processes a [`Burn`](enum.TokenInstruction.html) instruction.
     pub fn process_burn(
         program_id: &Pubkey,
         accounts: &[AccountInfo],
@@ -668,7 +669,7 @@ impl Processor {
         Ok(())
     }
 
-    /// Processes a [CloseAccount](enum.TokenInstruction.html) instruction.
+    /// Processes a [`CloseAccount`](enum.TokenInstruction.html) instruction.
     pub fn process_close_account(program_id: &Pubkey, accounts: &[AccountInfo]) -> ProgramResult {
         let account_info_iter = &mut accounts.iter();
         let source_account_info = next_account_info(account_info_iter)?;
@@ -709,8 +710,8 @@ impl Processor {
         Ok(())
     }
 
-    /// Processes a [FreezeAccount](enum.TokenInstruction.html) or a
-    /// [ThawAccount](enum.TokenInstruction.html) instruction.
+    /// Processes a [`FreezeAccount`](enum.TokenInstruction.html) or a
+    /// [`ThawAccount`](enum.TokenInstruction.html) instruction.
     pub fn process_toggle_freeze_account(
         program_id: &Pubkey,
         accounts: &[AccountInfo],
@@ -754,7 +755,7 @@ impl Processor {
         Ok(())
     }
 
-    /// Processes a [SyncNative](enum.TokenInstruction.html) instruction
+    /// Processes a [`SyncNative`](enum.TokenInstruction.html) instruction
     pub fn process_sync_native(program_id: &Pubkey, accounts: &[AccountInfo]) -> ProgramResult {
         let account_info_iter = &mut accounts.iter();
         let native_account_info = next_account_info(account_info_iter)?;
@@ -779,7 +780,8 @@ impl Processor {
         Ok(())
     }
 
-    /// Processes a [GetAccountDataSize](enum.TokenInstruction.html) instruction
+    /// Processes a [`GetAccountDataSize`](enum.TokenInstruction.html)
+    /// instruction
     pub fn process_get_account_data_size(
         program_id: &Pubkey,
         accounts: &[AccountInfo],
@@ -794,7 +796,7 @@ impl Processor {
         Ok(())
     }
 
-    /// Processes an [InitializeImmutableOwner](enum.TokenInstruction.html)
+    /// Processes an [`InitializeImmutableOwner`](enum.TokenInstruction.html)
     /// instruction
     pub fn process_initialize_immutable_owner(accounts: &[AccountInfo]) -> ProgramResult {
         let account_info_iter = &mut accounts.iter();
@@ -807,7 +809,8 @@ impl Processor {
         Ok(())
     }
 
-    /// Processes an [AmountToUiAmount](enum.TokenInstruction.html) instruction
+    /// Processes an [`AmountToUiAmount`](enum.TokenInstruction.html)
+    /// instruction
     pub fn process_amount_to_ui_amount(
         program_id: &Pubkey,
         accounts: &[AccountInfo],
@@ -825,7 +828,8 @@ impl Processor {
         Ok(())
     }
 
-    /// Processes an [AmountToUiAmount](enum.TokenInstruction.html) instruction
+    /// Processes an [`AmountToUiAmount`](enum.TokenInstruction.html)
+    /// instruction
     pub fn process_ui_amount_to_amount(
         program_id: &Pubkey,
         accounts: &[AccountInfo],
@@ -843,7 +847,7 @@ impl Processor {
         Ok(())
     }
 
-    /// Processes an [Instruction](enum.Instruction.html).
+    /// Processes an [`Instruction`](enum.Instruction.html).
     pub fn process(program_id: &Pubkey, accounts: &[AccountInfo], input: &[u8]) -> ProgramResult {
         let instruction = TokenInstruction::unpack(input)?;
 

+ 3 - 3
program/src/state.rs

@@ -98,7 +98,7 @@ pub struct Account {
     pub delegate: COption<Pubkey>,
     /// The account's state
     pub state: AccountState,
-    /// If is_native.is_some, this is a native token, and the value logs the
+    /// If `is_native.is_some`, this is a native token, and the value logs the
     /// rent-exempt reserve. An Account is required to be rent-exempt, so
     /// the value is used by the Processor to ensure that wrapped SOL
     /// accounts do not drop below this threshold.
@@ -117,7 +117,7 @@ impl Account {
     pub fn is_native(&self) -> bool {
         self.is_native.is_some()
     }
-    /// Checks if a token Account's owner is the system_program or the
+    /// Checks if a token Account's owner is the `system_program` or the
     /// incinerator
     pub fn is_owned_by_system_program_or_incinerator(&self) -> bool {
         solana_program::system_program::check_id(&self.owner)
@@ -344,7 +344,7 @@ pub trait GenericTokenAccount {
 pub const ACCOUNT_INITIALIZED_INDEX: usize = 108;
 
 /// Check if the account data buffer represents an initialized account.
-/// This is checking the `state` (AccountState) field of an Account object.
+/// This is checking the `state` (`AccountState`) field of an Account object.
 pub fn is_initialized_account(account_data: &[u8]) -> bool {
     *account_data
         .get(ACCOUNT_INITIALIZED_INDEX)