Skip to content

Commit f546c56

Browse files
authored
Swap spl-pod for solana-zero-copy + solana-nullable (#1069)
* Swap spl-pod for solana-zero-copy + solana-nullable * simplify MaybeNull conversion * Move getrandom dep to interface
1 parent 0cb1495 commit f546c56

60 files changed

Lines changed: 647 additions & 532 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 45 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

clients/cli/Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,13 @@ solana-transaction-status = "3.0.0"
3535
solana-zk-sdk = "6.0.1"
3636
solana-zk-sdk-pod = "0.1.1"
3737
spl-associated-token-account-interface = { version = "2.0.0" }
38-
spl-pod = { version = "0.7.3" }
3938
spl-token-interface = "2.0.0"
4039
spl-token-2022-interface = { version = "2.0.0", path = "../../interface" }
4140
spl-token-2022 = { version = "10.0.0", path = "../../program", features = ["no-entrypoint"] }
4241
spl-token-client = { version = "0.18.0", path = "../rust-legacy" }
4342
spl-token-confidential-transfer-proof-generation = { version = "0.6.0", path = "../../confidential/proof-generation" }
44-
spl-token-metadata-interface = { version = "0.8.0" }
45-
spl-token-group-interface = { version = "0.7.0" }
43+
spl-token-metadata-interface = "1.0.0"
44+
spl-token-group-interface = "0.7.2"
4645
spl-memo-interface = "2.0.0"
4746
strum = "0.28"
4847
strum_macros = "0.28"

clients/cli/src/command.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ use {
3939
},
4040
solana_zk_sdk_pod::encryption::elgamal::PodElGamalPubkey,
4141
spl_associated_token_account_interface::address::get_associated_token_address_with_program_id,
42-
spl_pod::optional_keys::OptionalNonZeroPubkey,
4342
spl_token_2022_interface::{
4443
extension::{
4544
confidential_transfer::{ConfidentialTransferAccount, ConfidentialTransferMint},
@@ -351,12 +350,9 @@ async fn command_create_token(
351350
}
352351

353352
if transfer_hook_program_id.is_some() || enable_transfer_hook {
354-
let program_id = transfer_hook_program_id
355-
.map(OptionalNonZeroPubkey)
356-
.unwrap_or_default();
357353
extensions.push(ExtensionInitializationParams::TransferHook {
358354
authority: Some(authority),
359-
program_id: program_id.into(),
355+
program_id: transfer_hook_program_id,
360356
});
361357
}
362358

clients/rust-legacy/Cargo.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ spl-token-confidential-transfer-proof-extraction = { path = "../../confidential/
5454
spl-token-confidential-transfer-proof-generation = { path = "../../confidential/proof-generation", version = "0.6.0" }
5555
spl-token-2022-interface = { version = "2.0.0", path = "../../interface" }
5656
spl-token-2022 = { version = "10.0.0", path = "../../program", features = ["no-entrypoint"] }
57-
spl-token-group-interface = { version = "0.7.0" }
58-
spl-token-metadata-interface = { version = "0.8.0" }
57+
spl-token-group-interface = "0.7.2"
58+
spl-token-metadata-interface = "1.0.0"
5959
spl-transfer-hook-interface = { version = "2.1.0" }
6060
solana-zk-sdk-pod = "0.1.1"
6161
solana-zk-elgamal-proof-interface = "0.1.2"
@@ -70,7 +70,6 @@ futures-util = "0.3"
7070
solana-program-test = { version = "4.0.0-beta.7", features = ["agave-unstable-api"] }
7171
solana-sdk = "3.0.0"
7272
solana-sdk-ids = "3.1.0"
73-
spl-pod = { version = "0.7.3" }
7473
spl-instruction-padding-interface = "1.0.0"
7574
spl-tlv-account-resolution = "0.11.0"
7675
spl-token-client = { path = ".", features = ["dev-context-only-utils"] }

clients/rust-legacy/src/token.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,10 @@ use {
7777
transfer_with_fee::TransferWithFeeProofData, withdraw::WithdrawProofData,
7878
},
7979
spl_token_group_interface::state::{TokenGroup, TokenGroupMember},
80-
spl_token_metadata_interface::state::{Field, TokenMetadata},
80+
spl_token_metadata_interface::{
81+
solana_nullable::MaybeNull,
82+
state::{Field, TokenMetadata},
83+
},
8184
std::{
8285
fmt, io,
8386
mem::size_of,
@@ -3963,7 +3966,7 @@ where
39633966
&self.program_id,
39643967
&self.pubkey,
39653968
current_authority,
3966-
new_authority.try_into()?,
3969+
MaybeNull::try_from(new_authority).map_err(|_| ProgramError::InvalidArgument)?,
39673970
)],
39683971
signing_keypairs,
39693972
)

clients/rust-legacy/tests/token_group_initialize.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
mod program_test;
22
use {
3+
bytemuck::try_from_bytes,
34
program_test::TestContext,
45
solana_program_test::{tokio, ProgramTest},
56
solana_sdk::{
67
instruction::InstructionError, pubkey::Pubkey, signature::Signer, signer::keypair::Keypair,
78
transaction::TransactionError, transport::TransportError,
89
},
9-
spl_pod::bytemuck::pod_from_bytes,
1010
spl_token_2022_interface::{error::TokenError, extension::BaseStateWithExtensions},
1111
spl_token_client::token::{ExtensionInitializationParams, TokenError as TokenClientError},
1212
spl_token_group_interface::{error::TokenGroupError, state::TokenGroup},
@@ -115,7 +115,7 @@ async fn success_initialize() {
115115
// check that the data is correct
116116
let mint_info = token_context.token.get_mint_info().await.unwrap();
117117
let group_bytes = mint_info.get_extension_bytes::<TokenGroup>().unwrap();
118-
let fetched_group = pod_from_bytes::<TokenGroup>(group_bytes).unwrap();
118+
let fetched_group = try_from_bytes::<TokenGroup>(group_bytes).unwrap();
119119
assert_eq!(fetched_group, &token_group);
120120

121121
// fail double-init

0 commit comments

Comments
 (0)