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

Commit 7440e4b

Browse files
[token-client] use Signersinstead of Signer for confidential transfer client functions (#7175)
1 parent 3ee1da9 commit 7440e4b

File tree

4 files changed

+76
-69
lines changed

4 files changed

+76
-69
lines changed

token/cli/src/command.rs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1604,27 +1604,32 @@ async fn command_transfer(
16041604
.unwrap();
16051605

16061606
// setup proofs
1607+
let create_range_proof_context_signer = &[&range_proof_context_state_account];
1608+
let create_equality_proof_context_signer = &[&equality_proof_context_state_account];
1609+
let create_ciphertext_validity_proof_context_signer =
1610+
&[&ciphertext_validity_proof_context_state_account];
1611+
16071612
let _ = try_join!(
16081613
token.confidential_transfer_create_context_state_account(
16091614
&range_proof_pubkey,
16101615
&context_state_authority_pubkey,
16111616
&range_proof_data,
16121617
true,
1613-
&range_proof_context_state_account,
1618+
create_range_proof_context_signer
16141619
),
16151620
token.confidential_transfer_create_context_state_account(
16161621
&equality_proof_pubkey,
16171622
&context_state_authority_pubkey,
16181623
&equality_proof_data,
16191624
false,
1620-
&equality_proof_context_state_account,
1625+
create_equality_proof_context_signer
16211626
),
16221627
token.confidential_transfer_create_context_state_account(
16231628
&ciphertext_validity_proof_pubkey,
16241629
&context_state_authority_pubkey,
16251630
&ciphertext_validity_proof_data,
16261631
false,
1627-
&ciphertext_validity_proof_context_state_account,
1632+
create_ciphertext_validity_proof_context_signer
16281633
)
16291634
)?;
16301635

@@ -1655,24 +1660,25 @@ async fn command_transfer(
16551660
.await?;
16561661

16571662
// close context state accounts
1663+
let close_context_state_signer = &[&context_state_authority];
16581664
let _ = try_join!(
16591665
token.confidential_transfer_close_context_state(
16601666
&equality_proof_pubkey,
16611667
&sender,
16621668
&context_state_authority_pubkey,
1663-
&context_state_authority,
1669+
close_context_state_signer
16641670
),
16651671
token.confidential_transfer_close_context_state(
16661672
&ciphertext_validity_proof_pubkey,
16671673
&sender,
16681674
&context_state_authority_pubkey,
1669-
&context_state_authority,
1675+
close_context_state_signer
16701676
),
16711677
token.confidential_transfer_close_context_state(
16721678
&range_proof_pubkey,
16731679
&sender,
16741680
&context_state_authority_pubkey,
1675-
&context_state_authority,
1681+
close_context_state_signer
16761682
),
16771683
)?;
16781684

@@ -3353,21 +3359,23 @@ async fn command_deposit_withdraw_confidential_tokens(
33533359

33543360
// set up context state accounts
33553361
let context_state_authority_pubkey = context_state_authority.pubkey();
3362+
let create_equality_proof_signer = &[&equality_proof_context_state_keypair];
3363+
let create_range_proof_signer = &[&range_proof_context_state_keypair];
33563364

33573365
let _ = try_join!(
33583366
token.confidential_transfer_create_context_state_account(
33593367
&equality_proof_context_state_pubkey,
33603368
&context_state_authority_pubkey,
33613369
&equality_proof_data,
33623370
false,
3363-
&equality_proof_context_state_keypair,
3371+
create_equality_proof_signer
33643372
),
33653373
token.confidential_transfer_create_context_state_account(
33663374
&range_proof_context_state_pubkey,
33673375
&context_state_authority_pubkey,
33683376
&range_proof_data,
33693377
true,
3370-
&range_proof_context_state_keypair,
3378+
create_range_proof_signer,
33713379
)
33723380
)?;
33733381

@@ -3392,18 +3400,19 @@ async fn command_deposit_withdraw_confidential_tokens(
33923400
.await?;
33933401

33943402
// close context state account
3403+
let close_context_state_signer = &[&context_state_authority];
33953404
let _ = try_join!(
33963405
token.confidential_transfer_close_context_state(
33973406
&equality_proof_context_state_pubkey,
33983407
&token_account_address,
33993408
&context_state_authority_pubkey,
3400-
&context_state_authority,
3409+
close_context_state_signer
34013410
),
34023411
token.confidential_transfer_close_context_state(
34033412
&range_proof_context_state_pubkey,
34043413
&token_account_address,
34053414
&context_state_authority_pubkey,
3406-
&context_state_authority,
3415+
close_context_state_signer
34073416
)
34083417
)?;
34093418

token/client/src/token.rs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2271,16 +2271,17 @@ where
22712271
/// Create a record account containing zero-knowledge proof needed for a
22722272
/// confidential transfer.
22732273
pub async fn confidential_transfer_create_record_account<
2274-
S: Signer,
2274+
S1: Signer,
2275+
S2: Signer,
22752276
ZK: Pod + ZkProofData<U>,
22762277
U: Pod,
22772278
>(
22782279
&self,
22792280
record_account: &Pubkey,
22802281
record_authority: &Pubkey,
22812282
proof_data: &ZK,
2282-
record_account_signer: &S,
2283-
record_authority_signer: &S,
2283+
record_account_signer: &S1,
2284+
record_authority_signer: &S2,
22842285
) -> TokenResult<Vec<T::Output>> {
22852286
let proof_data = bytes_of(proof_data);
22862287
let space = proof_data
@@ -2326,11 +2327,8 @@ where
23262327
};
23272328

23282329
let first_ixs = create_record_instructions(true, first_chunk, 0);
2329-
self.process_ixs(
2330-
&first_ixs,
2331-
&[record_account_signer, record_authority_signer],
2332-
)
2333-
.await?;
2330+
let first_ixs_signers: [&dyn Signer; 2] = [record_account_signer, record_authority_signer];
2331+
self.process_ixs(&first_ixs, &first_ixs_signers).await?;
23342332

23352333
let subsequent_chunk_size =
23362334
calculate_record_max_chunk_size(create_record_instructions, false);
@@ -2354,28 +2352,28 @@ where
23542352
}
23552353

23562354
/// Close a record account.
2357-
pub async fn confidential_transfer_close_record_account<S: Signer>(
2355+
pub async fn confidential_transfer_close_record_account<S: Signers>(
23582356
&self,
23592357
record_account: &Pubkey,
23602358
record_authority: &Pubkey,
23612359
receiver: &Pubkey,
2362-
record_authority_signer: &S,
2360+
signing_keypairs: &S,
23632361
) -> TokenResult<T::Output> {
23642362
self.process_ixs(
23652363
&[spl_record::instruction::close_account(
23662364
record_account,
23672365
record_authority,
23682366
receiver,
23692367
)],
2370-
&[record_authority_signer],
2368+
signing_keypairs,
23712369
)
23722370
.await
23732371
}
23742372

23752373
/// Create a context state account containing zero-knowledge proof needed
23762374
/// for a confidential transfer instruction.
23772375
pub async fn confidential_transfer_create_context_state_account<
2378-
S: Signer,
2376+
S: Signers,
23792377
ZK: Pod + ZkProofData<U>,
23802378
U: Pod,
23812379
>(
@@ -2384,7 +2382,7 @@ where
23842382
context_state_authority: &Pubkey,
23852383
proof_data: &ZK,
23862384
split_account_creation_and_proof_verification: bool,
2387-
signer: &S,
2385+
signing_keypairs: &S,
23882386
) -> TokenResult<T::Output> {
23892387
let instruction_type = zk_proof_type_to_instruction(ZK::PROOF_TYPE)?;
23902388
let space = size_of::<ProofContextState<U>>();
@@ -2410,7 +2408,7 @@ where
24102408
space as u64,
24112409
&zk_elgamal_proof_program::id(),
24122410
)],
2413-
&[signer],
2411+
signing_keypairs,
24142412
)
24152413
.await?;
24162414

@@ -2443,14 +2441,14 @@ where
24432441
),
24442442
instruction_type.encode_verify_proof(Some(context_state_info), proof_data),
24452443
],
2446-
&[signer],
2444+
signing_keypairs,
24472445
)
24482446
.await
24492447
}
24502448
}
24512449

24522450
/// Close a ZK Token proof program context state
2453-
pub async fn confidential_transfer_close_context_state<S: Signer>(
2451+
pub async fn confidential_transfer_close_context_state<S: Signers>(
24542452
&self,
24552453
context_state_account: &Pubkey,
24562454
lamport_destination_account: &Pubkey,
@@ -2467,7 +2465,7 @@ where
24672465
context_state_info,
24682466
lamport_destination_account,
24692467
)],
2470-
&[signing_keypairs],
2468+
signing_keypairs,
24712469
)
24722470
.await
24732471
}

0 commit comments

Comments
 (0)