Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit e78e265

Browse files
committed
Rename x2 instructions to xChecked
1 parent bb9f022 commit e78e265

File tree

3 files changed

+79
-79
lines changed

3 files changed

+79
-79
lines changed

token/cli/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ fn command_transfer(
214214
let amount = spl_token::ui_amount_to_amount(ui_amount, sender_token_balance.decimals);
215215

216216
let mut transaction = Transaction::new_with_payer(
217-
&[transfer2(
217+
&[transfer_checked(
218218
&spl_token::id(),
219219
&sender,
220220
&mint_pubkey,
@@ -251,7 +251,7 @@ fn command_burn(config: &Config, source: Pubkey, ui_amount: f64) -> CommandResul
251251
let mint_pubkey = Account::unpack_from_slice(&data)?.mint;
252252
let amount = spl_token::ui_amount_to_amount(ui_amount, source_token_balance.decimals);
253253
let mut transaction = Transaction::new_with_payer(
254-
&[burn2(
254+
&[burn_checked(
255255
&spl_token::id(),
256256
&source,
257257
&mint_pubkey,
@@ -289,7 +289,7 @@ fn command_mint(
289289
let amount = spl_token::ui_amount_to_amount(ui_amount, recipient_token_balance.decimals);
290290

291291
let mut transaction = Transaction::new_with_payer(
292-
&[mint_to2(
292+
&[mint_to_checked(
293293
&spl_token::id(),
294294
&token,
295295
&recipient,

token/program/src/instruction.rs

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ pub enum TokenInstruction {
233233
/// transferred to the destination account.
234234
///
235235
/// This instruction differs from Transfer in that the token mint and decimals value is
236-
/// asserted by the caller. This may be useful when creating transactions offline or within a
236+
/// checked by the caller. This may be useful when creating transactions offline or within a
237237
/// hardware wallet.
238238
///
239239
/// Accounts expected by this instruction:
@@ -250,7 +250,7 @@ pub enum TokenInstruction {
250250
/// 2. `[writable]` The destination account.
251251
/// 3. `[]` The source account's multisignature owner/delegate.
252252
/// 4. ..4+M `[signer]` M signer accounts.
253-
Transfer2 {
253+
TransferChecked {
254254
/// The amount of tokens to transfer.
255255
amount: u64,
256256
/// Expected number of base 10 digits to the right of the decimal place.
@@ -259,7 +259,7 @@ pub enum TokenInstruction {
259259
/// Approves a delegate. A delegate is given the authority over
260260
/// tokens on behalf of the source account's owner.
261261
///
262-
/// This instruction differs from Approve in that the token mint and decimals value is asserted
262+
/// This instruction differs from Approve in that the token mint and decimals value is checked
263263
/// by the caller. This may be useful when creating transactions offline or within a hardware
264264
/// wallet.
265265
///
@@ -277,15 +277,15 @@ pub enum TokenInstruction {
277277
/// 2. `[]` The delegate.
278278
/// 3. `[]` The source account's multisignature owner.
279279
/// 4. ..4+M `[signer]` M signer accounts
280-
Approve2 {
280+
ApproveChecked {
281281
/// The amount of tokens the delegate is approved for.
282282
amount: u64,
283283
/// Expected number of base 10 digits to the right of the decimal place.
284284
decimals: u8,
285285
},
286286
/// Mints new tokens to an account. The native mint does not support minting.
287287
///
288-
/// This instruction differs from MintTo in that the decimals value is asserted by the
288+
/// This instruction differs from MintTo in that the decimals value is checked by the
289289
/// caller. This may be useful when creating transactions offline or within a hardware wallet.
290290
///
291291
/// Accounts expected by this instruction:
@@ -300,16 +300,16 @@ pub enum TokenInstruction {
300300
/// 1. `[writable]` The account to mint tokens to.
301301
/// 2. `[]` The mint's multisignature mint-tokens authority.
302302
/// 3. ..3+M `[signer]` M signer accounts.
303-
MintTo2 {
303+
MintToChecked {
304304
/// The amount of new tokens to mint.
305305
amount: u64,
306306
/// Expected number of base 10 digits to the right of the decimal place.
307307
decimals: u8,
308308
},
309-
/// Burns tokens by removing them from an account. `Burn2` does not support accounts
309+
/// Burns tokens by removing them from an account. `BurnChecked` does not support accounts
310310
/// associated with the native mint, use `CloseAccount` instead.
311311
///
312-
/// This instruction differs from Burn in that the decimals value is asserted by the caller.
312+
/// This instruction differs from Burn in that the decimals value is checked by the caller.
313313
/// This may be useful when creating transactions offline or within a hardware wallet.
314314
///
315315
/// Accounts expected by this instruction:
@@ -324,7 +324,7 @@ pub enum TokenInstruction {
324324
/// 1. `[writable]` The token mint.
325325
/// 2. `[]` The account's multisignature owner/delegate.
326326
/// 3. ..3+M `[signer]` M signer accounts.
327-
Burn2 {
327+
BurnChecked {
328328
/// The amount of tokens to burn.
329329
amount: u64,
330330
/// Expected number of base 10 digits to the right of the decimal place.
@@ -392,7 +392,7 @@ impl TokenInstruction {
392392
.ok_or(InvalidInstruction)?;
393393
let (&decimals, _rest) = rest.split_first().ok_or(InvalidInstruction)?;
394394

395-
Self::Transfer2 { amount, decimals }
395+
Self::TransferChecked { amount, decimals }
396396
}
397397
13 => {
398398
let (amount, rest) = rest.split_at(8);
@@ -403,7 +403,7 @@ impl TokenInstruction {
403403
.ok_or(InvalidInstruction)?;
404404
let (&decimals, _rest) = rest.split_first().ok_or(InvalidInstruction)?;
405405

406-
Self::Approve2 { amount, decimals }
406+
Self::ApproveChecked { amount, decimals }
407407
}
408408
14 => {
409409
let (amount, rest) = rest.split_at(8);
@@ -414,7 +414,7 @@ impl TokenInstruction {
414414
.ok_or(InvalidInstruction)?;
415415
let (&decimals, _rest) = rest.split_first().ok_or(InvalidInstruction)?;
416416

417-
Self::MintTo2 { amount, decimals }
417+
Self::MintToChecked { amount, decimals }
418418
}
419419
15 => {
420420
let (amount, rest) = rest.split_at(8);
@@ -425,7 +425,7 @@ impl TokenInstruction {
425425
.ok_or(InvalidInstruction)?;
426426
let (&decimals, _rest) = rest.split_first().ok_or(InvalidInstruction)?;
427427

428-
Self::Burn2 { amount, decimals }
428+
Self::BurnChecked { amount, decimals }
429429
}
430430

431431
_ => return Err(TokenError::InvalidInstruction.into()),
@@ -479,22 +479,22 @@ impl TokenInstruction {
479479
Self::CloseAccount => buf.push(9),
480480
Self::FreezeAccount => buf.push(10),
481481
Self::ThawAccount => buf.push(11),
482-
&Self::Transfer2 { amount, decimals } => {
482+
&Self::TransferChecked { amount, decimals } => {
483483
buf.push(12);
484484
buf.extend_from_slice(&amount.to_le_bytes());
485485
buf.push(decimals);
486486
}
487-
&Self::Approve2 { amount, decimals } => {
487+
&Self::ApproveChecked { amount, decimals } => {
488488
buf.push(13);
489489
buf.extend_from_slice(&amount.to_le_bytes());
490490
buf.push(decimals);
491491
}
492-
&Self::MintTo2 { amount, decimals } => {
492+
&Self::MintToChecked { amount, decimals } => {
493493
buf.push(14);
494494
buf.extend_from_slice(&amount.to_le_bytes());
495495
buf.push(decimals);
496496
}
497-
&Self::Burn2 { amount, decimals } => {
497+
&Self::BurnChecked { amount, decimals } => {
498498
buf.push(15);
499499
buf.extend_from_slice(&amount.to_le_bytes());
500500
buf.push(decimals);
@@ -910,9 +910,9 @@ pub fn thaw_account(
910910
})
911911
}
912912

913-
/// Creates a `Transfer2` instruction.
913+
/// Creates a `TransferChecked` instruction.
914914
#[allow(clippy::too_many_arguments)]
915-
pub fn transfer2(
915+
pub fn transfer_checked(
916916
token_program_id: &Pubkey,
917917
source_pubkey: &Pubkey,
918918
mint_pubkey: &Pubkey,
@@ -922,7 +922,7 @@ pub fn transfer2(
922922
amount: u64,
923923
decimals: u8,
924924
) -> Result<Instruction, ProgramError> {
925-
let data = TokenInstruction::Transfer2 { amount, decimals }.pack();
925+
let data = TokenInstruction::TransferChecked { amount, decimals }.pack();
926926

927927
let mut accounts = Vec::with_capacity(4 + signer_pubkeys.len());
928928
accounts.push(AccountMeta::new(*source_pubkey, false));
@@ -943,9 +943,9 @@ pub fn transfer2(
943943
})
944944
}
945945

946-
/// Creates an `Approve2` instruction.
946+
/// Creates an `ApproveChecked` instruction.
947947
#[allow(clippy::too_many_arguments)]
948-
pub fn approve2(
948+
pub fn approve_checked(
949949
token_program_id: &Pubkey,
950950
source_pubkey: &Pubkey,
951951
mint_pubkey: &Pubkey,
@@ -955,7 +955,7 @@ pub fn approve2(
955955
amount: u64,
956956
decimals: u8,
957957
) -> Result<Instruction, ProgramError> {
958-
let data = TokenInstruction::Approve2 { amount, decimals }.pack();
958+
let data = TokenInstruction::ApproveChecked { amount, decimals }.pack();
959959

960960
let mut accounts = Vec::with_capacity(4 + signer_pubkeys.len());
961961
accounts.push(AccountMeta::new(*source_pubkey, false));
@@ -976,8 +976,8 @@ pub fn approve2(
976976
})
977977
}
978978

979-
/// Creates a `MintTo2` instruction.
980-
pub fn mint_to2(
979+
/// Creates a `MintToChecked` instruction.
980+
pub fn mint_to_checked(
981981
token_program_id: &Pubkey,
982982
mint_pubkey: &Pubkey,
983983
account_pubkey: &Pubkey,
@@ -986,7 +986,7 @@ pub fn mint_to2(
986986
amount: u64,
987987
decimals: u8,
988988
) -> Result<Instruction, ProgramError> {
989-
let data = TokenInstruction::MintTo2 { amount, decimals }.pack();
989+
let data = TokenInstruction::MintToChecked { amount, decimals }.pack();
990990

991991
let mut accounts = Vec::with_capacity(3 + signer_pubkeys.len());
992992
accounts.push(AccountMeta::new(*mint_pubkey, false));
@@ -1006,8 +1006,8 @@ pub fn mint_to2(
10061006
})
10071007
}
10081008

1009-
/// Creates a `Burn2` instruction.
1010-
pub fn burn2(
1009+
/// Creates a `BurnChecked` instruction.
1010+
pub fn burn_checked(
10111011
token_program_id: &Pubkey,
10121012
account_pubkey: &Pubkey,
10131013
mint_pubkey: &Pubkey,
@@ -1016,7 +1016,7 @@ pub fn burn2(
10161016
amount: u64,
10171017
decimals: u8,
10181018
) -> Result<Instruction, ProgramError> {
1019-
let data = TokenInstruction::Burn2 { amount, decimals }.pack();
1019+
let data = TokenInstruction::BurnChecked { amount, decimals }.pack();
10201020

10211021
let mut accounts = Vec::with_capacity(3 + signer_pubkeys.len());
10221022
accounts.push(AccountMeta::new(*account_pubkey, false));
@@ -1156,7 +1156,7 @@ mod test {
11561156
let unpacked = TokenInstruction::unpack(&expect).unwrap();
11571157
assert_eq!(unpacked, check);
11581158

1159-
let check = TokenInstruction::Transfer2 {
1159+
let check = TokenInstruction::TransferChecked {
11601160
amount: 1,
11611161
decimals: 2,
11621162
};
@@ -1166,7 +1166,7 @@ mod test {
11661166
let unpacked = TokenInstruction::unpack(&expect).unwrap();
11671167
assert_eq!(unpacked, check);
11681168

1169-
let check = TokenInstruction::Approve2 {
1169+
let check = TokenInstruction::ApproveChecked {
11701170
amount: 1,
11711171
decimals: 2,
11721172
};
@@ -1176,7 +1176,7 @@ mod test {
11761176
let unpacked = TokenInstruction::unpack(&expect).unwrap();
11771177
assert_eq!(unpacked, check);
11781178

1179-
let check = TokenInstruction::MintTo2 {
1179+
let check = TokenInstruction::MintToChecked {
11801180
amount: 1,
11811181
decimals: 2,
11821182
};
@@ -1186,7 +1186,7 @@ mod test {
11861186
let unpacked = TokenInstruction::unpack(&expect).unwrap();
11871187
assert_eq!(unpacked, check);
11881188

1189-
let check = TokenInstruction::Burn2 {
1189+
let check = TokenInstruction::BurnChecked {
11901190
amount: 1,
11911191
decimals: 2,
11921192
};

0 commit comments

Comments
 (0)