3
3
solana_program_test:: tokio:: time,
4
4
solana_sdk:: {
5
5
account:: Account as BaseAccount ,
6
- epoch_info:: EpochInfo ,
7
6
hash:: Hash ,
8
7
instruction:: Instruction ,
9
8
message:: Message ,
@@ -26,21 +25,25 @@ use {
26
25
} ,
27
26
instruction,
28
27
pod:: EncryptionPubkey ,
29
- solana_zk_token_sdk:: {
30
- encryption:: { auth_encryption:: * , elgamal:: * } ,
31
- errors:: ProofError ,
32
- instruction:: transfer_with_fee:: FeeParameters ,
33
- } ,
28
+ solana_zk_token_sdk:: errors:: ProofError ,
34
29
state:: { Account , AccountState , Mint , Multisig } ,
35
30
} ,
36
31
std:: {
37
- convert:: TryInto ,
38
32
fmt, io,
39
33
sync:: { Arc , RwLock } ,
40
34
time:: { Duration , Instant } ,
41
35
} ,
42
36
thiserror:: Error ,
43
37
} ;
38
+ #[ cfg( feature = "proof-program" ) ]
39
+ use {
40
+ solana_sdk:: epoch_info:: EpochInfo ,
41
+ spl_token_2022:: solana_zk_token_sdk:: {
42
+ encryption:: { auth_encryption:: * , elgamal:: * } ,
43
+ instruction:: transfer_with_fee:: FeeParameters ,
44
+ } ,
45
+ std:: convert:: TryInto ,
46
+ } ;
44
47
45
48
#[ derive( Error , Debug ) ]
46
49
pub enum TokenError {
@@ -1516,6 +1519,7 @@ where
1516
1519
}
1517
1520
1518
1521
/// Configures confidential transfers for a token account
1522
+ #[ cfg( feature = "proof-program" ) ]
1519
1523
pub async fn confidential_transfer_configure_token_account < S : Signer > (
1520
1524
& self ,
1521
1525
token_account : & Pubkey ,
@@ -1532,6 +1536,7 @@ where
1532
1536
. await
1533
1537
}
1534
1538
1539
+ #[ cfg( feature = "proof-program" ) ]
1535
1540
pub async fn confidential_transfer_configure_token_account_with_pending_counter < S : Signer > (
1536
1541
& self ,
1537
1542
token_account : & Pubkey ,
@@ -1554,6 +1559,7 @@ where
1554
1559
. await
1555
1560
}
1556
1561
1562
+ #[ cfg( feature = "proof-program" ) ]
1557
1563
pub async fn confidential_transfer_configure_token_account_with_pending_counter_and_keypair <
1558
1564
S : Signer ,
1559
1565
> (
@@ -1585,6 +1591,7 @@ where
1585
1591
}
1586
1592
1587
1593
/// Approves a token account for confidential transfers
1594
+ #[ cfg( feature = "proof-program" ) ]
1588
1595
pub async fn confidential_transfer_approve_account < S : Signer > (
1589
1596
& self ,
1590
1597
token_account : & Pubkey ,
@@ -1603,6 +1610,7 @@ where
1603
1610
}
1604
1611
1605
1612
/// Prepare a token account with the confidential transfer extension for closing
1613
+ #[ cfg( feature = "proof-program" ) ]
1606
1614
pub async fn confidential_transfer_empty_account < S : Signer > (
1607
1615
& self ,
1608
1616
token_account : & Pubkey ,
@@ -1618,6 +1626,7 @@ where
1618
1626
. await
1619
1627
}
1620
1628
1629
+ #[ cfg( feature = "proof-program" ) ]
1621
1630
pub async fn confidential_transfer_empty_account_with_keypair < S : Signer > (
1622
1631
& self ,
1623
1632
token_account : & Pubkey ,
@@ -1649,6 +1658,7 @@ where
1649
1658
1650
1659
/// Fetch and decrypt the available balance of a confidential token account using the uniquely
1651
1660
/// derived decryption key from a signer
1661
+ #[ cfg( feature = "proof-program" ) ]
1652
1662
pub async fn confidential_transfer_get_available_balance < S : Signer > (
1653
1663
& self ,
1654
1664
token_account : & Pubkey ,
@@ -1666,6 +1676,7 @@ where
1666
1676
1667
1677
/// Fetch and decrypt the available balance of a confidential token account using a custom
1668
1678
/// decryption key
1679
+ #[ cfg( feature = "proof-program" ) ]
1669
1680
pub async fn confidential_transfer_get_available_balance_with_key (
1670
1681
& self ,
1671
1682
token_account : & Pubkey ,
@@ -1688,6 +1699,7 @@ where
1688
1699
1689
1700
/// Fetch and decrypt the pending balance of a confidential token account using the uniquely
1690
1701
/// derived decryption key from a signer
1702
+ #[ cfg( feature = "proof-program" ) ]
1691
1703
pub async fn confidential_transfer_get_pending_balance < S : Signer > (
1692
1704
& self ,
1693
1705
token_account : & Pubkey ,
@@ -1702,6 +1714,7 @@ where
1702
1714
1703
1715
/// Fetch and decrypt the pending balance of a confidential token account using a custom
1704
1716
/// decryption key
1717
+ #[ cfg( feature = "proof-program" ) ]
1705
1718
pub async fn confidential_transfer_get_pending_balance_with_key (
1706
1719
& self ,
1707
1720
token_account : & Pubkey ,
@@ -1728,6 +1741,7 @@ where
1728
1741
Ok ( pending_balance)
1729
1742
}
1730
1743
1744
+ #[ cfg( feature = "proof-program" ) ]
1731
1745
pub async fn confidential_transfer_get_withheld_amount < S : Signer > (
1732
1746
& self ,
1733
1747
withdraw_withheld_authority : & S ,
@@ -1744,6 +1758,7 @@ where
1744
1758
. await
1745
1759
}
1746
1760
1761
+ #[ cfg( feature = "proof-program" ) ]
1747
1762
pub async fn confidential_transfer_get_withheld_amount_with_key (
1748
1763
& self ,
1749
1764
withdraw_withheld_authority_elgamal_keypair : & ElGamalKeypair ,
@@ -1770,6 +1785,7 @@ where
1770
1785
}
1771
1786
1772
1787
/// Fetch the ElGamal public key associated with a confidential token account
1788
+ #[ cfg( feature = "proof-program" ) ]
1773
1789
pub async fn confidential_transfer_get_encryption_pubkey < S : Signer > (
1774
1790
& self ,
1775
1791
token_account : & Pubkey ,
@@ -1786,6 +1802,7 @@ where
1786
1802
}
1787
1803
1788
1804
/// Fetch the ElGamal pubkey key of the auditor associated with a confidential token mint
1805
+ #[ cfg( feature = "proof-program" ) ]
1789
1806
pub async fn confidential_transfer_get_auditor_encryption_pubkey < S : Signer > (
1790
1807
& self ,
1791
1808
) -> TokenResult < Option < ElGamalPubkey > > {
@@ -1806,6 +1823,7 @@ where
1806
1823
1807
1824
/// Fetch the ElGamal pubkey key of the withdraw withheld authority associated with a
1808
1825
/// confidential token mint
1826
+ #[ cfg( feature = "proof-program" ) ]
1809
1827
pub async fn confidential_transfer_get_withdraw_withheld_authority_encryption_pubkey <
1810
1828
S : Signer ,
1811
1829
> (
@@ -1827,6 +1845,7 @@ where
1827
1845
}
1828
1846
1829
1847
/// Deposit SPL Tokens into the pending balance of a confidential token account
1848
+ #[ cfg( feature = "proof-program" ) ]
1830
1849
pub async fn confidential_transfer_deposit < S : Signer > (
1831
1850
& self ,
1832
1851
token_account : & Pubkey ,
@@ -1856,6 +1875,7 @@ where
1856
1875
/// Withdraw SPL Tokens from the available balance of a confidential token account using the
1857
1876
/// uniquely derived decryption key from a signer
1858
1877
#[ allow( clippy:: too_many_arguments) ]
1878
+ #[ cfg( feature = "proof-program" ) ]
1859
1879
pub async fn confidential_transfer_withdraw < S : Signer > (
1860
1880
& self ,
1861
1881
token_account : & Pubkey ,
@@ -1886,6 +1906,7 @@ where
1886
1906
/// Withdraw SPL Tokens from the available balance of a confidential token account using custom
1887
1907
/// keys
1888
1908
#[ allow( clippy:: too_many_arguments) ]
1909
+ #[ cfg( feature = "proof-program" ) ]
1889
1910
pub async fn confidential_transfer_withdraw_with_key < S : Signer > (
1890
1911
& self ,
1891
1912
token_account : & Pubkey ,
@@ -1930,6 +1951,7 @@ where
1930
1951
1931
1952
/// Transfer tokens confidentially using the uniquely derived decryption keys from a signer
1932
1953
#[ allow( clippy:: too_many_arguments) ]
1954
+ #[ cfg( feature = "proof-program" ) ]
1933
1955
pub async fn confidential_transfer_transfer < S : Signer > (
1934
1956
& self ,
1935
1957
source_token_account : & Pubkey ,
@@ -1964,6 +1986,7 @@ where
1964
1986
1965
1987
/// Transfer tokens confidentially using custom decryption keys
1966
1988
#[ allow( clippy:: too_many_arguments) ]
1989
+ #[ cfg( feature = "proof-program" ) ]
1967
1990
pub async fn confidential_transfer_transfer_with_key < S : Signer > (
1968
1991
& self ,
1969
1992
source_token_account : & Pubkey ,
@@ -2019,6 +2042,7 @@ where
2019
2042
/// Transfer tokens confidentially with fee using the uniquely derived decryption keys from a
2020
2043
/// signer
2021
2044
#[ allow( clippy:: too_many_arguments) ]
2045
+ #[ cfg( feature = "proof-program" ) ]
2022
2046
pub async fn confidential_transfer_transfer_with_fee < S : Signer > (
2023
2047
& self ,
2024
2048
source_token_account : & Pubkey ,
@@ -2057,6 +2081,7 @@ where
2057
2081
2058
2082
/// Transfer tokens confidential with fee using custom decryption keys
2059
2083
#[ allow( clippy:: too_many_arguments) ]
2084
+ #[ cfg( feature = "proof-program" ) ]
2060
2085
pub async fn confidential_transfer_transfer_with_fee_with_key < S : Signer > (
2061
2086
& self ,
2062
2087
source_token_account : & Pubkey ,
@@ -2124,6 +2149,7 @@ where
2124
2149
2125
2150
/// Applies the confidential transfer pending balance to the available balance using the
2126
2151
/// uniquely derived decryption key
2152
+ #[ cfg( feature = "proof-program" ) ]
2127
2153
pub async fn confidential_transfer_apply_pending_balance < S : Signer > (
2128
2154
& self ,
2129
2155
token_account : & Pubkey ,
@@ -2148,6 +2174,7 @@ where
2148
2174
2149
2175
/// Applies the confidential transfer pending balance to the available balance using a custom
2150
2176
/// decryption key
2177
+ #[ cfg( feature = "proof-program" ) ]
2151
2178
pub async fn confidential_transfer_apply_pending_balance_with_key < S : Signer > (
2152
2179
& self ,
2153
2180
token_account : & Pubkey ,
@@ -2176,6 +2203,7 @@ where
2176
2203
}
2177
2204
2178
2205
/// Enable confidential transfer `Deposit` and `Transfer` instructions for a token account
2206
+ #[ cfg( feature = "proof-program" ) ]
2179
2207
pub async fn confidential_transfer_enable_confidential_credits < S : Signer > (
2180
2208
& self ,
2181
2209
token_account : & Pubkey ,
@@ -2196,6 +2224,7 @@ where
2196
2224
}
2197
2225
2198
2226
/// Disable confidential transfer `Deposit` and `Transfer` instructions for a token account
2227
+ #[ cfg( feature = "proof-program" ) ]
2199
2228
pub async fn confidential_transfer_disable_confidential_credits < S : Signer > (
2200
2229
& self ,
2201
2230
token_account : & Pubkey ,
@@ -2216,6 +2245,7 @@ where
2216
2245
}
2217
2246
2218
2247
/// Enable a confidential extension token account to receive non-confidential payments
2248
+ #[ cfg( feature = "proof-program" ) ]
2219
2249
pub async fn confidential_transfer_enable_non_confidential_credits < S : Signer > (
2220
2250
& self ,
2221
2251
token_account : & Pubkey ,
@@ -2236,6 +2266,7 @@ where
2236
2266
}
2237
2267
2238
2268
/// Disable non-confidential payments for a confidential extension token account
2269
+ #[ cfg( feature = "proof-program" ) ]
2239
2270
pub async fn confidential_transfer_disable_non_confidential_credits < S : Signer > (
2240
2271
& self ,
2241
2272
token_account : & Pubkey ,
@@ -2256,6 +2287,7 @@ where
2256
2287
}
2257
2288
2258
2289
/// Withdraw withheld confidential tokens from mint using the uniquely derived decryption key
2290
+ #[ cfg( feature = "proof-program" ) ]
2259
2291
pub async fn confidential_transfer_withdraw_withheld_tokens_from_mint < S : Signer > (
2260
2292
& self ,
2261
2293
withdraw_withheld_authority : & S ,
@@ -2281,6 +2313,7 @@ where
2281
2313
}
2282
2314
2283
2315
/// Withdraw withheld confidential tokens from mint using a custom decryption key
2316
+ #[ cfg( feature = "proof-program" ) ]
2284
2317
pub async fn confidential_transfer_withdraw_withheld_tokens_from_mint_with_key < S : Signer > (
2285
2318
& self ,
2286
2319
withdraw_withheld_authority : & S ,
@@ -2314,6 +2347,7 @@ where
2314
2347
2315
2348
/// Withdraw withheld confidential tokens from accounts using the uniquely derived decryption
2316
2349
/// key
2350
+ #[ cfg( feature = "proof-program" ) ]
2317
2351
pub async fn confidential_transfer_withdraw_withheld_tokens_from_accounts < S : Signer > (
2318
2352
& self ,
2319
2353
withdraw_withheld_authority : & S ,
@@ -2341,6 +2375,7 @@ where
2341
2375
2342
2376
/// Withdraw withheld confidential tokens from accounts using a custom decryption key
2343
2377
#[ allow( clippy:: too_many_arguments) ]
2378
+ #[ cfg( feature = "proof-program" ) ]
2344
2379
pub async fn confidential_transfer_withdraw_withheld_tokens_from_accounts_with_key <
2345
2380
S : Signer ,
2346
2381
> (
@@ -2377,6 +2412,7 @@ where
2377
2412
}
2378
2413
2379
2414
/// Harvest withheld confidential tokens to mint
2415
+ #[ cfg( feature = "proof-program" ) ]
2380
2416
pub async fn confidential_transfer_harvest_withheld_tokens_to_mint (
2381
2417
& self ,
2382
2418
sources : & [ & Pubkey ] ,
0 commit comments