Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update governance.rs: Fixup anchor return types #1582

Merged
merged 3 commits into from
Mar 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ incremented for features.
### Fixes

* ts: Fix the loss of strict typing using the `methods` namespace on builder functions ([#1539](https://github.com/project-serum/anchor/pull/1539)).
* spl: Update `spl/governance` to use new errors ([#1582](https://github.com/project-serum/anchor/pull/1582)).

### Breaking

Expand Down
11 changes: 3 additions & 8 deletions spl/src/governance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ macro_rules! vote_weight_record {
pub struct VoterWeightRecord(spl_governance_addin_api::voter_weight::VoterWeightRecord);

impl anchor_lang::AccountDeserialize for VoterWeightRecord {
fn try_deserialize(buf: &mut &[u8]) -> std::result::Result<Self, ProgramError> {
fn try_deserialize(buf: &mut &[u8]) -> anchor_lang::Result<Self> {
let mut data = buf;
let vwr: spl_governance_addin_api::voter_weight::VoterWeightRecord =
anchor_lang::AnchorDeserialize::deserialize(&mut data)
Expand All @@ -18,9 +18,7 @@ macro_rules! vote_weight_record {
Ok(VoterWeightRecord(vwr))
}

fn try_deserialize_unchecked(
buf: &mut &[u8],
) -> std::result::Result<Self, ProgramError> {
fn try_deserialize_unchecked(buf: &mut &[u8]) -> anchor_lang::Result<Self> {
let mut data = buf;
let vwr: spl_governance_addin_api::voter_weight::VoterWeightRecord =
anchor_lang::AnchorDeserialize::deserialize(&mut data)
Expand All @@ -30,10 +28,7 @@ macro_rules! vote_weight_record {
}

impl anchor_lang::AccountSerialize for VoterWeightRecord {
fn try_serialize<W: std::io::Write>(
&self,
writer: &mut W,
) -> std::result::Result<(), ProgramError> {
fn try_serialize<W: std::io::Write>(&self, writer: &mut W) -> anchor_lang::Result<()> {
anchor_lang::AnchorSerialize::serialize(&self.0, writer)
.map_err(|_| anchor_lang::error::ErrorCode::AccountDidNotSerialize)?;
Ok(())
Expand Down