@@ -26,15 +26,11 @@ pub enum TokenInstruction {
26
26
/// Accounts expected by this instruction:
27
27
///
28
28
/// 0. `[writable]` The mint to initialize.
29
- /// 1. If supply is non-zero: `[writable]` The account to hold all the newly minted tokens.
30
29
///
31
30
InitializeMint {
32
- /// Initial amount of tokens to mint.
33
- amount : u64 ,
34
31
/// Number of base 10 digits to the right of the decimal place.
35
32
decimals : u8 ,
36
- /// The authority/multisignature to mint tokens, if supply is non-zero. If present,
37
- /// further minting is supported.
33
+ /// The authority/multisignature to mint tokens. If present, further minting is supported.
38
34
mint_authority : COption < Pubkey > ,
39
35
/// The freeze authority/multisignature of the mint.
40
36
freeze_authority : COption < Pubkey > ,
@@ -230,17 +226,12 @@ impl TokenInstruction {
230
226
}
231
227
Ok ( match input[ 0 ] {
232
228
0 => {
233
- if input. len ( )
234
- < size_of :: < u8 > ( ) + size_of :: < u64 > ( ) + size_of :: < u8 > ( ) + size_of :: < bool > ( )
235
- {
229
+ if input. len ( ) < size_of :: < u8 > ( ) + size_of :: < u8 > ( ) + size_of :: < bool > ( ) {
236
230
return Err ( TokenError :: InvalidInstruction . into ( ) ) ;
237
231
}
238
232
let mut input_len = 0 ;
239
233
input_len += size_of :: < u8 > ( ) ;
240
234
241
- #[ allow( clippy:: cast_ptr_alignment) ]
242
- let amount = unsafe { * ( & input[ input_len] as * const u8 as * const u64 ) } ;
243
- input_len += size_of :: < u64 > ( ) ;
244
235
let decimals = unsafe { * ( & input[ input_len] as * const u8 ) } ;
245
236
input_len += size_of :: < u8 > ( ) ;
246
237
@@ -258,7 +249,6 @@ impl TokenInstruction {
258
249
Self :: InitializeMint {
259
250
mint_authority,
260
251
freeze_authority,
261
- amount,
262
252
decimals,
263
253
}
264
254
}
@@ -339,17 +329,11 @@ impl TokenInstruction {
339
329
Self :: InitializeMint {
340
330
mint_authority,
341
331
freeze_authority,
342
- amount,
343
332
decimals,
344
333
} => {
345
334
output[ output_len] = 0 ;
346
335
output_len += size_of :: < u8 > ( ) ;
347
336
348
- #[ allow( clippy:: cast_ptr_alignment) ]
349
- let value = unsafe { & mut * ( & mut output[ output_len] as * mut u8 as * mut u64 ) } ;
350
- * value = * amount;
351
- output_len += size_of :: < u64 > ( ) ;
352
-
353
337
let value = unsafe { & mut * ( & mut output[ output_len] as * mut u8 ) } ;
354
338
* value = * decimals;
355
339
output_len += size_of :: < u8 > ( ) ;
@@ -480,31 +464,20 @@ impl AuthorityType {
480
464
pub fn initialize_mint (
481
465
token_program_id : & Pubkey ,
482
466
mint_pubkey : & Pubkey ,
483
- account_pubkey : Option < & Pubkey > ,
484
- mint_authority_pubkey : Option < & Pubkey > ,
467
+ mint_authority_pubkey : & Pubkey ,
485
468
freeze_authority_pubkey : Option < & Pubkey > ,
486
- amount : u64 ,
487
469
decimals : u8 ,
488
470
) -> Result < Instruction , ProgramError > {
489
- let mint_authority = mint_authority_pubkey . cloned ( ) . into ( ) ;
471
+ let mint_authority = COption :: Some ( * mint_authority_pubkey ) ;
490
472
let freeze_authority = freeze_authority_pubkey. cloned ( ) . into ( ) ;
491
473
let data = TokenInstruction :: InitializeMint {
492
474
mint_authority,
493
475
freeze_authority,
494
- amount,
495
476
decimals,
496
477
}
497
478
. pack ( ) ?;
498
479
499
- let mut accounts = vec ! [ AccountMeta :: new( * mint_pubkey, false ) ] ;
500
- if amount != 0 {
501
- match account_pubkey {
502
- Some ( pubkey) => accounts. push ( AccountMeta :: new ( * pubkey, false ) ) ,
503
- None => {
504
- return Err ( ProgramError :: NotEnoughAccountKeys ) ;
505
- }
506
- }
507
- }
480
+ let accounts = vec ! [ AccountMeta :: new( * mint_pubkey, false ) ] ;
508
481
509
482
Ok ( Instruction {
510
483
program_id : * token_program_id,
@@ -832,25 +805,23 @@ mod test {
832
805
#[ test]
833
806
fn test_instruction_packing ( ) {
834
807
let check = TokenInstruction :: InitializeMint {
835
- amount : 1 ,
836
808
decimals : 2 ,
837
809
mint_authority : COption :: None ,
838
810
freeze_authority : COption :: None ,
839
811
} ;
840
812
let packed = check. pack ( ) . unwrap ( ) ;
841
- let expect = Vec :: from ( [ 0u8 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 2 , 0 , 0 ] ) ;
813
+ let expect = Vec :: from ( [ 0u8 , 2 , 0 , 0 ] ) ;
842
814
assert_eq ! ( packed, expect) ;
843
815
let unpacked = TokenInstruction :: unpack ( & expect) . unwrap ( ) ;
844
816
assert_eq ! ( unpacked, check) ;
845
817
846
818
let check = TokenInstruction :: InitializeMint {
847
- amount : 1 ,
848
819
decimals : 2 ,
849
820
mint_authority : COption :: Some ( Pubkey :: new ( & [ 2u8 ; 32 ] ) ) ,
850
821
freeze_authority : COption :: Some ( Pubkey :: new ( & [ 3u8 ; 32 ] ) ) ,
851
822
} ;
852
823
let packed = check. pack ( ) . unwrap ( ) ;
853
- let mut expect = vec ! [ 0u8 , 1 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 2 ] ;
824
+ let mut expect = vec ! [ 0u8 , 2 ] ;
854
825
expect. extend_from_slice ( & [ 1 ] ) ;
855
826
expect. extend_from_slice ( & [ 2u8 ; 32 ] ) ;
856
827
expect. extend_from_slice ( & [ 1 ] ) ;
0 commit comments