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

Commit db0b2c5

Browse files
authored
token-2022: Add mint close authority support everywhere (#2754)
* token-2022: Add mint close authority support everywhere * Address feedback
1 parent 480dc68 commit db0b2c5

File tree

4 files changed

+400
-108
lines changed

4 files changed

+400
-108
lines changed

token/program-2022/src/extension/confidential_transfer/processor.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ fn process_configure_account(
9696
let token_account_info = next_account_info(account_info_iter)?;
9797
let mint_info = next_account_info(account_info_iter)?;
9898
let authority_info = next_account_info(account_info_iter)?;
99+
let authority_info_data_len = authority_info.data_len();
99100

100101
check_program_account(token_account_info.owner)?;
101102
let token_account_data = &mut token_account_info.data.borrow_mut();
@@ -107,9 +108,9 @@ fn process_configure_account(
107108

108109
Processor::validate_owner(
109110
program_id,
110-
token_account_info.key,
111111
token_account_info.owner,
112112
authority_info,
113+
authority_info_data_len,
113114
account_info_iter.as_slice(),
114115
)?;
115116

@@ -195,16 +196,17 @@ fn process_empty_account(
195196
let token_account_info = next_account_info(account_info_iter)?;
196197
let instructions_sysvar_info = next_account_info(account_info_iter)?;
197198
let authority_info = next_account_info(account_info_iter)?;
199+
let authority_info_data_len = authority_info.data_len();
198200

199201
check_program_account(token_account_info.owner)?;
200202
let token_account_data = &mut token_account_info.data.borrow_mut();
201203
let mut token_account = StateWithExtensionsMut::<Account>::unpack(token_account_data)?;
202204

203205
Processor::validate_owner(
204206
program_id,
205-
token_account_info.key,
206207
token_account_info.owner,
207208
authority_info,
209+
authority_info_data_len,
208210
account_info_iter.as_slice(),
209211
)?;
210212

@@ -246,6 +248,7 @@ fn process_deposit(
246248
let receiver_token_account_info = next_account_info(account_info_iter)?;
247249
let mint_info = next_account_info(account_info_iter)?;
248250
let authority_info = next_account_info(account_info_iter)?;
251+
let authority_info_data_len = authority_info.data_len();
249252

250253
check_program_account(mint_info.owner)?;
251254
let mint_data = &mint_info.data.borrow_mut();
@@ -263,9 +266,9 @@ fn process_deposit(
263266

264267
Processor::validate_owner(
265268
program_id,
266-
token_account_info.key,
267269
token_account_info.owner,
268270
authority_info,
271+
authority_info_data_len,
269272
account_info_iter.as_slice(),
270273
)?;
271274

@@ -345,6 +348,7 @@ fn process_withdraw(
345348
let mint_info = next_account_info(account_info_iter)?;
346349
let instructions_sysvar_info = next_account_info(account_info_iter)?;
347350
let authority_info = next_account_info(account_info_iter)?;
351+
let authority_info_data_len = authority_info.data_len();
348352

349353
check_program_account(mint_info.owner)?;
350354
let mint_data = &mint_info.data.borrow_mut();
@@ -370,9 +374,9 @@ fn process_withdraw(
370374

371375
Processor::validate_owner(
372376
program_id,
373-
token_account_info.key,
374377
token_account_info.owner,
375378
authority_info,
379+
authority_info_data_len,
376380
account_info_iter.as_slice(),
377381
)?;
378382

@@ -446,6 +450,7 @@ fn process_transfer(
446450
let mint_info = next_account_info(account_info_iter)?;
447451
let instructions_sysvar_info = next_account_info(account_info_iter)?;
448452
let authority_info = next_account_info(account_info_iter)?;
453+
let authority_info_data_len = authority_info.data_len();
449454

450455
check_program_account(mint_info.owner)?;
451456
let mint_data = &mint_info.data.borrow_mut();
@@ -471,9 +476,9 @@ fn process_transfer(
471476

472477
Processor::validate_owner(
473478
program_id,
474-
token_account_info.key,
475479
token_account_info.owner,
476480
authority_info,
481+
authority_info_data_len,
477482
account_info_iter.as_slice(),
478483
)?;
479484

@@ -595,16 +600,17 @@ fn process_apply_pending_balance(
595600
let account_info_iter = &mut accounts.iter();
596601
let token_account_info = next_account_info(account_info_iter)?;
597602
let authority_info = next_account_info(account_info_iter)?;
603+
let authority_info_data_len = authority_info.data_len();
598604

599605
check_program_account(token_account_info.owner)?;
600606
let token_account_data = &mut token_account_info.data.borrow_mut();
601607
let mut token_account = StateWithExtensionsMut::<Account>::unpack(token_account_data)?;
602608

603609
Processor::validate_owner(
604610
program_id,
605-
token_account_info.key,
606611
token_account_info.owner,
607612
authority_info,
613+
authority_info_data_len,
608614
account_info_iter.as_slice(),
609615
)?;
610616

@@ -636,16 +642,17 @@ fn process_allow_balance_credits(
636642
let account_info_iter = &mut accounts.iter();
637643
let token_account_info = next_account_info(account_info_iter)?;
638644
let authority_info = next_account_info(account_info_iter)?;
645+
let authority_info_data_len = authority_info.data_len();
639646

640647
check_program_account(token_account_info.owner)?;
641648
let token_account_data = &mut token_account_info.data.borrow_mut();
642649
let mut token_account = StateWithExtensionsMut::<Account>::unpack(token_account_data)?;
643650

644651
Processor::validate_owner(
645652
program_id,
646-
token_account_info.key,
647653
token_account_info.owner,
648654
authority_info,
655+
authority_info_data_len,
649656
account_info_iter.as_slice(),
650657
)?;
651658

0 commit comments

Comments
 (0)