Skip to content

Commit 6ed8c9d

Browse files
committed
Updated patterns + deps
1 parent 10462f0 commit 6ed8c9d

20 files changed

Lines changed: 1783 additions & 958 deletions

File tree

Cargo.lock

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

pinocchio/interface/Cargo.toml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
[package]
22
name = "p-stake-interface"
33
version = "0.1.0"
4-
edition = "2021"
4+
edition = { workspace = true }
55
authors = { workspace = true }
66
repository = { workspace = true }
77
homepage = { workspace = true }
88
license = { workspace = true }
99

10+
[features]
11+
serde = ["dep:serde"]
12+
1013
[dependencies]
11-
solana-pubkey = "3.0.0"
12-
wincode = { git = "https://github.com/anza-xyz/wincode", rev = "19a7dc6f56e20ff7978cd4f4b4ae7e0ae74f2457", default-features = false, features = ["alloc", "derive"] }
13-
solana-clock = "3"
14+
solana-address = "1.0.0"
15+
wincode = { git = "https://github.com/anza-xyz/wincode.git", branch = "master", default-features = false, features = ["derive"] }
16+
serde = { version = "1.0", features = ["derive"], optional = true }
1417

1518
[dev-dependencies]
1619
bincode = "1.3.3"
17-
proptest = "1.6.0"
20+
proptest = "1.9.0"
21+
solana-pubkey = "3.0.0"
1822
solana-stake-interface = { path = "../../interface", features = ["bincode"] }

pinocchio/interface/src/error.rs

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,36 @@
1-
// TODO: These may not be backward compatible with StakeStakeV2 serialization errs in interface/src/state.rs
2-
// Need to think about this.
1+
//! Error types for stake state parsing.
2+
3+
use crate::state::StakeStateV2Tag;
4+
35
#[derive(Debug)]
46
pub enum StakeStateError {
5-
WrongLength { expected: usize, actual: usize },
7+
/// Input is shorter than 200 bytes.
8+
UnexpectedEof,
9+
10+
/// The discriminant tag is not a valid variant
11+
InvalidTag(u32),
12+
13+
/// An invalid state transition was attempted.
14+
InvalidTransition {
15+
from: StakeStateV2Tag,
16+
to: StakeStateV2Tag,
17+
},
18+
19+
/// Pass-through for wincode read errors.
620
Read(wincode::ReadError),
21+
22+
/// Pass-through for wincode write errors.
23+
Write(wincode::WriteError),
724
}
825

926
impl From<wincode::ReadError> for StakeStateError {
10-
#[inline(always)]
1127
fn from(e: wincode::ReadError) -> Self {
12-
Self::Read(e)
28+
StakeStateError::Read(e)
1329
}
1430
}
1531

16-
#[inline(always)]
17-
pub(crate) fn invalid_tag(tag: u32) -> StakeStateError {
18-
StakeStateError::Read(wincode::error::invalid_tag_encoding(tag as usize))
19-
}
20-
21-
#[inline(always)]
22-
pub(crate) fn slice_as_array<const N: usize>(s: &[u8]) -> Result<&[u8; N], StakeStateError> {
23-
s.try_into().map_err(|_| {
24-
StakeStateError::Read(wincode::ReadError::Custom(
25-
"slice length mismatch for array",
26-
))
27-
})
28-
}
29-
30-
#[inline(always)]
31-
pub(crate) fn slice_as_array_mut<const N: usize>(
32-
s: &mut [u8],
33-
) -> Result<&mut [u8; N], StakeStateError> {
34-
s.try_into().map_err(|_| {
35-
StakeStateError::Read(wincode::ReadError::Custom(
36-
"slice length mismatch for array",
37-
))
38-
})
32+
impl From<wincode::WriteError> for StakeStateError {
33+
fn from(e: wincode::WriteError) -> Self {
34+
StakeStateError::Write(e)
35+
}
3936
}

pinocchio/interface/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
pub mod error;
2-
pub mod pod;
32
pub mod state;

pinocchio/interface/src/pod.rs

Lines changed: 0 additions & 70 deletions
This file was deleted.

0 commit comments

Comments
 (0)