@@ -233,7 +233,7 @@ pub enum TokenInstruction {
233
233
/// transferred to the destination account.
234
234
///
235
235
/// 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
237
237
/// hardware wallet.
238
238
///
239
239
/// Accounts expected by this instruction:
@@ -250,7 +250,7 @@ pub enum TokenInstruction {
250
250
/// 2. `[writable]` The destination account.
251
251
/// 3. `[]` The source account's multisignature owner/delegate.
252
252
/// 4. ..4+M `[signer]` M signer accounts.
253
- Transfer2 {
253
+ TransferChecked {
254
254
/// The amount of tokens to transfer.
255
255
amount : u64 ,
256
256
/// Expected number of base 10 digits to the right of the decimal place.
@@ -259,7 +259,7 @@ pub enum TokenInstruction {
259
259
/// Approves a delegate. A delegate is given the authority over
260
260
/// tokens on behalf of the source account's owner.
261
261
///
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
263
263
/// by the caller. This may be useful when creating transactions offline or within a hardware
264
264
/// wallet.
265
265
///
@@ -277,15 +277,15 @@ pub enum TokenInstruction {
277
277
/// 2. `[]` The delegate.
278
278
/// 3. `[]` The source account's multisignature owner.
279
279
/// 4. ..4+M `[signer]` M signer accounts
280
- Approve2 {
280
+ ApproveChecked {
281
281
/// The amount of tokens the delegate is approved for.
282
282
amount : u64 ,
283
283
/// Expected number of base 10 digits to the right of the decimal place.
284
284
decimals : u8 ,
285
285
} ,
286
286
/// Mints new tokens to an account. The native mint does not support minting.
287
287
///
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
289
289
/// caller. This may be useful when creating transactions offline or within a hardware wallet.
290
290
///
291
291
/// Accounts expected by this instruction:
@@ -300,16 +300,16 @@ pub enum TokenInstruction {
300
300
/// 1. `[writable]` The account to mint tokens to.
301
301
/// 2. `[]` The mint's multisignature mint-tokens authority.
302
302
/// 3. ..3+M `[signer]` M signer accounts.
303
- MintTo2 {
303
+ MintToChecked {
304
304
/// The amount of new tokens to mint.
305
305
amount : u64 ,
306
306
/// Expected number of base 10 digits to the right of the decimal place.
307
307
decimals : u8 ,
308
308
} ,
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
310
310
/// associated with the native mint, use `CloseAccount` instead.
311
311
///
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.
313
313
/// This may be useful when creating transactions offline or within a hardware wallet.
314
314
///
315
315
/// Accounts expected by this instruction:
@@ -324,7 +324,7 @@ pub enum TokenInstruction {
324
324
/// 1. `[writable]` The token mint.
325
325
/// 2. `[]` The account's multisignature owner/delegate.
326
326
/// 3. ..3+M `[signer]` M signer accounts.
327
- Burn2 {
327
+ BurnChecked {
328
328
/// The amount of tokens to burn.
329
329
amount : u64 ,
330
330
/// Expected number of base 10 digits to the right of the decimal place.
@@ -392,7 +392,7 @@ impl TokenInstruction {
392
392
. ok_or ( InvalidInstruction ) ?;
393
393
let ( & decimals, _rest) = rest. split_first ( ) . ok_or ( InvalidInstruction ) ?;
394
394
395
- Self :: Transfer2 { amount, decimals }
395
+ Self :: TransferChecked { amount, decimals }
396
396
}
397
397
13 => {
398
398
let ( amount, rest) = rest. split_at ( 8 ) ;
@@ -403,7 +403,7 @@ impl TokenInstruction {
403
403
. ok_or ( InvalidInstruction ) ?;
404
404
let ( & decimals, _rest) = rest. split_first ( ) . ok_or ( InvalidInstruction ) ?;
405
405
406
- Self :: Approve2 { amount, decimals }
406
+ Self :: ApproveChecked { amount, decimals }
407
407
}
408
408
14 => {
409
409
let ( amount, rest) = rest. split_at ( 8 ) ;
@@ -414,7 +414,7 @@ impl TokenInstruction {
414
414
. ok_or ( InvalidInstruction ) ?;
415
415
let ( & decimals, _rest) = rest. split_first ( ) . ok_or ( InvalidInstruction ) ?;
416
416
417
- Self :: MintTo2 { amount, decimals }
417
+ Self :: MintToChecked { amount, decimals }
418
418
}
419
419
15 => {
420
420
let ( amount, rest) = rest. split_at ( 8 ) ;
@@ -425,7 +425,7 @@ impl TokenInstruction {
425
425
. ok_or ( InvalidInstruction ) ?;
426
426
let ( & decimals, _rest) = rest. split_first ( ) . ok_or ( InvalidInstruction ) ?;
427
427
428
- Self :: Burn2 { amount, decimals }
428
+ Self :: BurnChecked { amount, decimals }
429
429
}
430
430
431
431
_ => return Err ( TokenError :: InvalidInstruction . into ( ) ) ,
@@ -479,22 +479,22 @@ impl TokenInstruction {
479
479
Self :: CloseAccount => buf. push ( 9 ) ,
480
480
Self :: FreezeAccount => buf. push ( 10 ) ,
481
481
Self :: ThawAccount => buf. push ( 11 ) ,
482
- & Self :: Transfer2 { amount, decimals } => {
482
+ & Self :: TransferChecked { amount, decimals } => {
483
483
buf. push ( 12 ) ;
484
484
buf. extend_from_slice ( & amount. to_le_bytes ( ) ) ;
485
485
buf. push ( decimals) ;
486
486
}
487
- & Self :: Approve2 { amount, decimals } => {
487
+ & Self :: ApproveChecked { amount, decimals } => {
488
488
buf. push ( 13 ) ;
489
489
buf. extend_from_slice ( & amount. to_le_bytes ( ) ) ;
490
490
buf. push ( decimals) ;
491
491
}
492
- & Self :: MintTo2 { amount, decimals } => {
492
+ & Self :: MintToChecked { amount, decimals } => {
493
493
buf. push ( 14 ) ;
494
494
buf. extend_from_slice ( & amount. to_le_bytes ( ) ) ;
495
495
buf. push ( decimals) ;
496
496
}
497
- & Self :: Burn2 { amount, decimals } => {
497
+ & Self :: BurnChecked { amount, decimals } => {
498
498
buf. push ( 15 ) ;
499
499
buf. extend_from_slice ( & amount. to_le_bytes ( ) ) ;
500
500
buf. push ( decimals) ;
@@ -910,9 +910,9 @@ pub fn thaw_account(
910
910
} )
911
911
}
912
912
913
- /// Creates a `Transfer2 ` instruction.
913
+ /// Creates a `TransferChecked ` instruction.
914
914
#[ allow( clippy:: too_many_arguments) ]
915
- pub fn transfer2 (
915
+ pub fn transfer_checked (
916
916
token_program_id : & Pubkey ,
917
917
source_pubkey : & Pubkey ,
918
918
mint_pubkey : & Pubkey ,
@@ -922,7 +922,7 @@ pub fn transfer2(
922
922
amount : u64 ,
923
923
decimals : u8 ,
924
924
) -> Result < Instruction , ProgramError > {
925
- let data = TokenInstruction :: Transfer2 { amount, decimals } . pack ( ) ;
925
+ let data = TokenInstruction :: TransferChecked { amount, decimals } . pack ( ) ;
926
926
927
927
let mut accounts = Vec :: with_capacity ( 4 + signer_pubkeys. len ( ) ) ;
928
928
accounts. push ( AccountMeta :: new ( * source_pubkey, false ) ) ;
@@ -943,9 +943,9 @@ pub fn transfer2(
943
943
} )
944
944
}
945
945
946
- /// Creates an `Approve2 ` instruction.
946
+ /// Creates an `ApproveChecked ` instruction.
947
947
#[ allow( clippy:: too_many_arguments) ]
948
- pub fn approve2 (
948
+ pub fn approve_checked (
949
949
token_program_id : & Pubkey ,
950
950
source_pubkey : & Pubkey ,
951
951
mint_pubkey : & Pubkey ,
@@ -955,7 +955,7 @@ pub fn approve2(
955
955
amount : u64 ,
956
956
decimals : u8 ,
957
957
) -> Result < Instruction , ProgramError > {
958
- let data = TokenInstruction :: Approve2 { amount, decimals } . pack ( ) ;
958
+ let data = TokenInstruction :: ApproveChecked { amount, decimals } . pack ( ) ;
959
959
960
960
let mut accounts = Vec :: with_capacity ( 4 + signer_pubkeys. len ( ) ) ;
961
961
accounts. push ( AccountMeta :: new ( * source_pubkey, false ) ) ;
@@ -976,8 +976,8 @@ pub fn approve2(
976
976
} )
977
977
}
978
978
979
- /// Creates a `MintTo2 ` instruction.
980
- pub fn mint_to2 (
979
+ /// Creates a `MintToChecked ` instruction.
980
+ pub fn mint_to_checked (
981
981
token_program_id : & Pubkey ,
982
982
mint_pubkey : & Pubkey ,
983
983
account_pubkey : & Pubkey ,
@@ -986,7 +986,7 @@ pub fn mint_to2(
986
986
amount : u64 ,
987
987
decimals : u8 ,
988
988
) -> Result < Instruction , ProgramError > {
989
- let data = TokenInstruction :: MintTo2 { amount, decimals } . pack ( ) ;
989
+ let data = TokenInstruction :: MintToChecked { amount, decimals } . pack ( ) ;
990
990
991
991
let mut accounts = Vec :: with_capacity ( 3 + signer_pubkeys. len ( ) ) ;
992
992
accounts. push ( AccountMeta :: new ( * mint_pubkey, false ) ) ;
@@ -1006,8 +1006,8 @@ pub fn mint_to2(
1006
1006
} )
1007
1007
}
1008
1008
1009
- /// Creates a `Burn2 ` instruction.
1010
- pub fn burn2 (
1009
+ /// Creates a `BurnChecked ` instruction.
1010
+ pub fn burn_checked (
1011
1011
token_program_id : & Pubkey ,
1012
1012
account_pubkey : & Pubkey ,
1013
1013
mint_pubkey : & Pubkey ,
@@ -1016,7 +1016,7 @@ pub fn burn2(
1016
1016
amount : u64 ,
1017
1017
decimals : u8 ,
1018
1018
) -> Result < Instruction , ProgramError > {
1019
- let data = TokenInstruction :: Burn2 { amount, decimals } . pack ( ) ;
1019
+ let data = TokenInstruction :: BurnChecked { amount, decimals } . pack ( ) ;
1020
1020
1021
1021
let mut accounts = Vec :: with_capacity ( 3 + signer_pubkeys. len ( ) ) ;
1022
1022
accounts. push ( AccountMeta :: new ( * account_pubkey, false ) ) ;
@@ -1156,7 +1156,7 @@ mod test {
1156
1156
let unpacked = TokenInstruction :: unpack ( & expect) . unwrap ( ) ;
1157
1157
assert_eq ! ( unpacked, check) ;
1158
1158
1159
- let check = TokenInstruction :: Transfer2 {
1159
+ let check = TokenInstruction :: TransferChecked {
1160
1160
amount : 1 ,
1161
1161
decimals : 2 ,
1162
1162
} ;
@@ -1166,7 +1166,7 @@ mod test {
1166
1166
let unpacked = TokenInstruction :: unpack ( & expect) . unwrap ( ) ;
1167
1167
assert_eq ! ( unpacked, check) ;
1168
1168
1169
- let check = TokenInstruction :: Approve2 {
1169
+ let check = TokenInstruction :: ApproveChecked {
1170
1170
amount : 1 ,
1171
1171
decimals : 2 ,
1172
1172
} ;
@@ -1176,7 +1176,7 @@ mod test {
1176
1176
let unpacked = TokenInstruction :: unpack ( & expect) . unwrap ( ) ;
1177
1177
assert_eq ! ( unpacked, check) ;
1178
1178
1179
- let check = TokenInstruction :: MintTo2 {
1179
+ let check = TokenInstruction :: MintToChecked {
1180
1180
amount : 1 ,
1181
1181
decimals : 2 ,
1182
1182
} ;
@@ -1186,7 +1186,7 @@ mod test {
1186
1186
let unpacked = TokenInstruction :: unpack ( & expect) . unwrap ( ) ;
1187
1187
assert_eq ! ( unpacked, check) ;
1188
1188
1189
- let check = TokenInstruction :: Burn2 {
1189
+ let check = TokenInstruction :: BurnChecked {
1190
1190
amount : 1 ,
1191
1191
decimals : 2 ,
1192
1192
} ;
0 commit comments