Skip to content

Commit 7e740a1

Browse files
authored
deps: Bump to SDK v4 / address v2 (#133)
#### Problem The newest SDK crates are out, but the record program isn't using them. #### Summary of changes Bump everything to the newest versions. At the same time, switch from solana-pubkey to solana-address.
1 parent 1a9189f commit 7e740a1

File tree

8 files changed

+197
-151
lines changed

8 files changed

+197
-151
lines changed

Cargo.lock

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

program/Cargo.toml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,22 @@ no-entrypoint = []
1414
bytemuck = { version = "1.23.1", features = ["derive"] }
1515
num-derive = "0.4"
1616
num-traits = "0.2"
17-
solana-account-info = "3.0.0"
18-
solana-instruction = { version = "3.0.0", features = ["std"] }
17+
solana-account-info = "3.1.0"
18+
solana-address = { version = "2.0.0", features = ["bytemuck", "decode"] }
19+
solana-instruction = { version = "3.1.0", features = ["std"] }
1920
solana-msg = "3.0.0"
20-
solana-program-entrypoint = "3.0.0"
21+
solana-program-entrypoint = "3.1.0"
2122
solana-program-error = "3.0.0"
2223
solana-program-pack = "3.0.0"
23-
solana-pubkey = { version = "3.0.0", features = ["bytemuck"] }
2424
solana-rent = "3.0.0"
2525
solana-security-txt = "1.1.2"
2626
thiserror = "2.0.12"
2727

2828
[dev-dependencies]
2929
mollusk-svm = "0.7.0"
30-
solana-account = "3.0.0"
31-
solana-system-interface = "2"
30+
solana-account = "3.1.0"
31+
solana-address = { version = "2.0.0", features = ["atomic"] }
32+
solana-system-interface = { version = "3", features = ["bincode"] }
3233

3334
[lib]
3435
crate-type = ["cdylib", "lib"]

program/src/entrypoint.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
#![cfg(all(target_os = "solana", not(feature = "no-entrypoint")))]
44

55
use {
6-
solana_account_info::AccountInfo, solana_program_error::ProgramResult, solana_pubkey::Pubkey,
6+
solana_account_info::AccountInfo, solana_address::Address, solana_program_error::ProgramResult,
77
solana_security_txt::security_txt,
88
};
99

1010
solana_program_entrypoint::entrypoint!(process_instruction);
1111
fn process_instruction(
12-
program_id: &Pubkey,
12+
program_id: &Address,
1313
accounts: &[AccountInfo],
1414
instruction_data: &[u8],
1515
) -> ProgramResult {

program/src/instruction.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
33
use {
44
crate::id,
5+
solana_address::Address,
56
solana_instruction::{AccountMeta, Instruction},
67
solana_program_error::ProgramError,
7-
solana_pubkey::Pubkey,
88
std::mem::size_of,
99
};
1010

@@ -134,7 +134,7 @@ impl<'a> RecordInstruction<'a> {
134134
}
135135

136136
/// Create a `RecordInstruction::Initialize` instruction
137-
pub fn initialize(record_account: &Pubkey, authority: &Pubkey) -> Instruction {
137+
pub fn initialize(record_account: &Address, authority: &Address) -> Instruction {
138138
Instruction {
139139
program_id: id(),
140140
accounts: vec![
@@ -146,7 +146,7 @@ pub fn initialize(record_account: &Pubkey, authority: &Pubkey) -> Instruction {
146146
}
147147

148148
/// Create a `RecordInstruction::Write` instruction
149-
pub fn write(record_account: &Pubkey, signer: &Pubkey, offset: u64, data: &[u8]) -> Instruction {
149+
pub fn write(record_account: &Address, signer: &Address, offset: u64, data: &[u8]) -> Instruction {
150150
Instruction {
151151
program_id: id(),
152152
accounts: vec![
@@ -159,9 +159,9 @@ pub fn write(record_account: &Pubkey, signer: &Pubkey, offset: u64, data: &[u8])
159159

160160
/// Create a `RecordInstruction::SetAuthority` instruction
161161
pub fn set_authority(
162-
record_account: &Pubkey,
163-
signer: &Pubkey,
164-
new_authority: &Pubkey,
162+
record_account: &Address,
163+
signer: &Address,
164+
new_authority: &Address,
165165
) -> Instruction {
166166
Instruction {
167167
program_id: id(),
@@ -175,7 +175,11 @@ pub fn set_authority(
175175
}
176176

177177
/// Create a `RecordInstruction::CloseAccount` instruction
178-
pub fn close_account(record_account: &Pubkey, signer: &Pubkey, receiver: &Pubkey) -> Instruction {
178+
pub fn close_account(
179+
record_account: &Address,
180+
signer: &Address,
181+
receiver: &Address,
182+
) -> Instruction {
179183
Instruction {
180184
program_id: id(),
181185
accounts: vec![
@@ -188,7 +192,7 @@ pub fn close_account(record_account: &Pubkey, signer: &Pubkey, receiver: &Pubkey
188192
}
189193

190194
/// Create a `RecordInstruction::Reallocate` instruction
191-
pub fn reallocate(record_account: &Pubkey, signer: &Pubkey, data_length: u64) -> Instruction {
195+
pub fn reallocate(record_account: &Address, signer: &Address, data_length: u64) -> Instruction {
192196
Instruction {
193197
program_id: id(),
194198
accounts: vec![

program/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ pub mod state;
1010
// Export current SDK types for downstream users building with a different SDK
1111
// version
1212
pub use {
13-
solana_account_info, solana_instruction, solana_msg, solana_program_entrypoint,
14-
solana_program_error, solana_program_pack, solana_pubkey,
13+
solana_account_info, solana_address, solana_instruction, solana_msg, solana_program_entrypoint,
14+
solana_program_error, solana_program_pack,
1515
};
1616

17-
solana_pubkey::declare_id!("recr1L3PCGKLbckBqMNcJhuuyU1zgo8nBhfLVsJNwr5");
17+
solana_address::declare_id!("recr1L3PCGKLbckBqMNcJhuuyU1zgo8nBhfLVsJNwr5");

program/src/processor.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
use {
44
crate::{error::RecordError, instruction::RecordInstruction, state::RecordData},
55
solana_account_info::{next_account_info, AccountInfo},
6+
solana_address::Address,
67
solana_msg::msg,
78
solana_program_error::{ProgramError, ProgramResult},
89
solana_program_pack::IsInitialized,
9-
solana_pubkey::Pubkey,
1010
};
1111

12-
fn check_authority(authority_info: &AccountInfo, expected_authority: &Pubkey) -> ProgramResult {
12+
fn check_authority(authority_info: &AccountInfo, expected_authority: &Address) -> ProgramResult {
1313
if expected_authority != authority_info.key {
1414
msg!("Incorrect record authority provided");
1515
return Err(RecordError::IncorrectAuthority.into());
@@ -23,7 +23,7 @@ fn check_authority(authority_info: &AccountInfo, expected_authority: &Pubkey) ->
2323

2424
/// Instruction processor
2525
pub fn process_instruction(
26-
_program_id: &Pubkey,
26+
_program_id: &Address,
2727
accounts: &[AccountInfo],
2828
input: &[u8],
2929
) -> ProgramResult {

program/src/state.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//! Program state
22
use {
33
bytemuck::{Pod, Zeroable},
4+
solana_address::Address,
45
solana_program_pack::IsInitialized,
5-
solana_pubkey::Pubkey,
66
};
77

88
/// Header type for recorded account data
@@ -13,7 +13,7 @@ pub struct RecordData {
1313
pub version: u8,
1414

1515
/// The account allowed to update the data
16-
pub authority: Pubkey,
16+
pub authority: Address,
1717
}
1818

1919
impl RecordData {
@@ -37,20 +37,20 @@ pub(crate) mod tests {
3737

3838
/// Version for tests
3939
pub const TEST_VERSION: u8 = 1;
40-
/// Pubkey for tests
41-
pub const TEST_PUBKEY: Pubkey = Pubkey::new_from_array([100; 32]);
40+
/// Address for tests
41+
pub const TEST_ADDRESS: Address = Address::new_from_array([100; 32]);
4242
/// Bytes for tests
4343
pub const TEST_BYTES: [u8; 8] = [42; 8];
4444
/// `RecordData` for tests
4545
pub const TEST_RECORD_DATA: RecordData = RecordData {
4646
version: TEST_VERSION,
47-
authority: TEST_PUBKEY,
47+
authority: TEST_ADDRESS,
4848
};
4949

5050
#[test]
5151
fn serialize_data() {
5252
let mut expected = vec![TEST_VERSION];
53-
expected.extend_from_slice(&TEST_PUBKEY.to_bytes());
53+
expected.extend_from_slice(&TEST_ADDRESS.to_bytes());
5454
assert_eq!(bytemuck::bytes_of(&TEST_RECORD_DATA), expected);
5555
assert_eq!(
5656
*bytemuck::try_from_bytes::<RecordData>(&expected).unwrap(),
@@ -61,7 +61,7 @@ pub(crate) mod tests {
6161
#[test]
6262
fn deserialize_invalid_slice() {
6363
let mut expected = vec![TEST_VERSION];
64-
expected.extend_from_slice(&TEST_PUBKEY.to_bytes());
64+
expected.extend_from_slice(&TEST_ADDRESS.to_bytes());
6565
expected.extend_from_slice(&TEST_BYTES);
6666
let err = bytemuck::try_from_bytes::<RecordData>(&expected)
6767
.map_err(|_| ProgramError::InvalidArgument)

0 commit comments

Comments
 (0)