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

Commit e0b70a9

Browse files
rename ops to syscall for better readability (#3944)
1 parent b9aba3f commit e0b70a9

File tree

1 file changed

+16
-16
lines changed
  • token/program-2022/src/extension/confidential_transfer

1 file changed

+16
-16
lines changed

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use {
3030
transfer_fee::TransferFeeConfig,
3131
},
3232
solana_program::{clock::Clock, sysvar::Sysvar},
33-
solana_zk_token_sdk::zk_token_elgamal::ops,
33+
solana_zk_token_sdk::zk_token_elgamal::ops as syscall,
3434
};
3535

3636
/// Decodes the zero-knowledge proof instruction associated with the token instruction.
@@ -346,12 +346,12 @@ fn process_deposit(
346346
// Prevent unnecessary ciphertext arithmetic syscalls if `amount_lo` or `amount_hi` is zero
347347
if amount_lo > 0 {
348348
confidential_transfer_account.pending_balance_lo =
349-
ops::add_to(&confidential_transfer_account.pending_balance_lo, amount_lo)
349+
syscall::add_to(&confidential_transfer_account.pending_balance_lo, amount_lo)
350350
.ok_or(ProgramError::InvalidInstructionData)?;
351351
}
352352
if amount_hi > 0 {
353353
confidential_transfer_account.pending_balance_hi =
354-
ops::add_to(&confidential_transfer_account.pending_balance_hi, amount_hi)
354+
syscall::add_to(&confidential_transfer_account.pending_balance_hi, amount_hi)
355355
.ok_or(ProgramError::InvalidInstructionData)?;
356356
}
357357

@@ -447,7 +447,7 @@ fn process_withdraw(
447447
// Prevent unnecessary ciphertext arithmetic syscalls if the withdraw amount is zero
448448
if amount > 0 {
449449
confidential_transfer_account.available_balance =
450-
ops::subtract_from(&confidential_transfer_account.available_balance, amount)
450+
syscall::subtract_from(&confidential_transfer_account.available_balance, amount)
451451
.ok_or(ProgramError::InvalidInstructionData)?;
452452
}
453453
// Check that the final available balance ciphertext is consistent with the actual ciphertext
@@ -695,7 +695,7 @@ fn process_source_for_transfer(
695695
return Err(TokenError::ConfidentialTransferElGamalPubkeyMismatch.into());
696696
}
697697

698-
let new_source_available_balance = ops::subtract_with_lo_hi(
698+
let new_source_available_balance = syscall::subtract_with_lo_hi(
699699
&confidential_transfer_account.available_balance,
700700
source_transfer_amount_lo,
701701
source_transfer_amount_hi,
@@ -750,13 +750,13 @@ fn process_destination_for_transfer(
750750
return Err(TokenError::ConfidentialTransferElGamalPubkeyMismatch.into());
751751
}
752752

753-
destination_confidential_transfer_account.pending_balance_lo = ops::add(
753+
destination_confidential_transfer_account.pending_balance_lo = syscall::add(
754754
&destination_confidential_transfer_account.pending_balance_lo,
755755
destination_transfer_amount_lo,
756756
)
757757
.ok_or(ProgramError::InvalidInstructionData)?;
758758

759-
destination_confidential_transfer_account.pending_balance_hi = ops::add(
759+
destination_confidential_transfer_account.pending_balance_hi = syscall::add(
760760
&destination_confidential_transfer_account.pending_balance_hi,
761761
destination_transfer_amount_hi,
762762
)
@@ -779,12 +779,12 @@ fn process_destination_for_transfer(
779779
.into();
780780

781781
// Subtract the fee amount from the destination pending balance
782-
destination_confidential_transfer_account.pending_balance_lo = ops::subtract(
782+
destination_confidential_transfer_account.pending_balance_lo = syscall::subtract(
783783
&destination_confidential_transfer_account.pending_balance_lo,
784784
&destination_fee_lo,
785785
)
786786
.ok_or(ProgramError::InvalidInstructionData)?;
787-
destination_confidential_transfer_account.pending_balance_hi = ops::subtract(
787+
destination_confidential_transfer_account.pending_balance_hi = syscall::subtract(
788788
&destination_confidential_transfer_account.pending_balance_hi,
789789
&destination_fee_hi,
790790
)
@@ -804,7 +804,7 @@ fn process_destination_for_transfer(
804804
.into();
805805

806806
// Add the fee amount to the destination withheld fee
807-
destination_confidential_transfer_account.withheld_amount = ops::add_with_lo_hi(
807+
destination_confidential_transfer_account.withheld_amount = syscall::add_with_lo_hi(
808808
&destination_confidential_transfer_account.withheld_amount,
809809
&withdraw_withheld_authority_fee_lo,
810810
&withdraw_withheld_authority_fee_hi,
@@ -845,7 +845,7 @@ fn process_apply_pending_balance(
845845
let mut confidential_transfer_account =
846846
token_account.get_extension_mut::<ConfidentialTransferAccount>()?;
847847

848-
confidential_transfer_account.available_balance = ops::add_with_lo_hi(
848+
confidential_transfer_account.available_balance = syscall::add_with_lo_hi(
849849
&confidential_transfer_account.available_balance,
850850
&confidential_transfer_account.pending_balance_lo,
851851
&confidential_transfer_account.pending_balance_hi,
@@ -1009,7 +1009,7 @@ fn process_withdraw_withheld_tokens_from_mint(
10091009

10101010
// The proof data contains the mint withheld amount encrypted under the destination ElGamal pubkey.
10111011
// This amount is added to the destination pending balance.
1012-
destination_confidential_transfer_account.pending_balance_lo = ops::add(
1012+
destination_confidential_transfer_account.pending_balance_lo = syscall::add(
10131013
&destination_confidential_transfer_account.pending_balance_lo,
10141014
&proof_data.destination_ciphertext,
10151015
)
@@ -1078,7 +1078,7 @@ fn process_withdraw_withheld_tokens_from_accounts(
10781078
.get_extension_mut::<ConfidentialTransferAccount>()
10791079
.map_err(|_| TokenError::InvalidState)?;
10801080

1081-
aggregate_withheld_amount = ops::add(
1081+
aggregate_withheld_amount = syscall::add(
10821082
&aggregate_withheld_amount,
10831083
&confidential_transfer_destination_account.withheld_amount,
10841084
)
@@ -1090,7 +1090,7 @@ fn process_withdraw_withheld_tokens_from_accounts(
10901090
match harvest_from_account(mint_account_info.key, account_info) {
10911091
Ok(encrypted_withheld_amount) => {
10921092
aggregate_withheld_amount =
1093-
ops::add(&aggregate_withheld_amount, &encrypted_withheld_amount)
1093+
syscall::add(&aggregate_withheld_amount, &encrypted_withheld_amount)
10941094
.ok_or(ProgramError::InvalidInstructionData)?;
10951095
}
10961096
Err(e) => {
@@ -1135,7 +1135,7 @@ fn process_withdraw_withheld_tokens_from_accounts(
11351135

11361136
// The proof data contains the mint withheld amount encrypted under the destination ElGamal pubkey.
11371137
// This amount is added to the destination pending balance.
1138-
destination_confidential_transfer_account.pending_balance_lo = ops::add(
1138+
destination_confidential_transfer_account.pending_balance_lo = syscall::add(
11391139
&destination_confidential_transfer_account.pending_balance_lo,
11401140
&proof_data.destination_ciphertext,
11411141
)
@@ -1184,7 +1184,7 @@ fn process_harvest_withheld_tokens_to_mint(accounts: &[AccountInfo]) -> ProgramR
11841184
for token_account_info in token_account_infos {
11851185
match harvest_from_account(mint_account_info.key, token_account_info) {
11861186
Ok(withheld_amount) => {
1187-
let new_mint_withheld_amount = ops::add(
1187+
let new_mint_withheld_amount = syscall::add(
11881188
&confidential_transfer_mint.withheld_amount,
11891189
&withheld_amount,
11901190
)

0 commit comments

Comments
 (0)