Skip to content

Commit

Permalink
upgrade to borsh 1
Browse files Browse the repository at this point in the history
  • Loading branch information
billythedummy committed Nov 21, 2024
1 parent 463eccc commit 7a2901b
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ panic = "abort"
# anchor-lang = { git = "https://github.com/lidofinance/anchor", branch = "solana-v1.9.28" }

# https://github.com/tiny-http/tiny-http/pull/225
tiny_http = { git = "https://github.com/tiny-http/tiny-http", rev = "f0fce7ed0bdf7439b5bd0b2d15fa82944aac30f6" }
# tiny_http = { git = "https://github.com/tiny-http/tiny-http", rev = "f0fce7ed0bdf7439b5bd0b2d15fa82944aac30f6" }
2 changes: 1 addition & 1 deletion program/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ no-entrypoint = []
test-bpf = []

[dependencies]
borsh = ">=0.9"
borsh = "^1"
num-derive = "^0.3"
num-traits = "^0.2"
serde = "^1.0"
Expand Down
10 changes: 4 additions & 6 deletions program/src/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ impl LidoInstruction {
// `Borsh::serialize`, which takes an arbitrary writer, and which can
// therefore return an IoError. But when serializing to a vec, there
// is no IO, so for this particular writer, it should never fail.
self.try_to_vec()
borsh::to_vec(self)
.expect("Serializing an Instruction to Vec<u8> does not fail.")
}
}
Expand Down Expand Up @@ -630,11 +630,10 @@ pub fn change_reward_distribution(
Instruction {
program_id: *program_id,
accounts: accounts.to_vec(),
data: LidoInstruction::ChangeRewardDistribution {
data: borsh::to_vec(&LidoInstruction::ChangeRewardDistribution {
new_reward_distribution,
}
})
// Serializing the instruction should never fail.
.try_to_vec()
.unwrap(),
}
}
Expand Down Expand Up @@ -811,8 +810,7 @@ pub fn merge_stake(
program_id: *program_id,
accounts: accounts.to_vec(),
// this can fail on OutOfMemory
data: LidoInstruction::MergeStakeV2 { validator_index }
.try_to_vec()
data: borsh::to_vec(&LidoInstruction::MergeStakeV2 { validator_index })
.unwrap(), // This should never fail.
}
}
Expand Down
2 changes: 1 addition & 1 deletion program/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use serde::Serialize;
use borsh::{BorshDeserialize, BorshSchema, BorshSerialize};
use solana_program::{
account_info::AccountInfo,
borsh::{get_instance_packed_len, try_from_slice_unchecked},
borsh1::{get_instance_packed_len, try_from_slice_unchecked},
clock::Clock,
clock::Epoch,
entrypoint::ProgramResult,
Expand Down

0 comments on commit 7a2901b

Please sign in to comment.