Skip to content

Commit 608029c

Browse files
committed
interface: Add get_config_data helper
#### Problem The auto-generated clients aren't ready for SDK v3, and Agave is currently using some auto-generated clients functions for the CLI. The client libraries currently create a circular dependency with Agave which we need to break. #### Summary of changes Agave can be transitioned to `solana-config-interface` for everything except the `get_config_data` helper, so add that missing helper.
1 parent 8e6d30c commit 608029c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

interface/src/state.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,11 @@ pub struct ConfigKeys {
1414
#[cfg_attr(feature = "serde", serde(with = "short_vec"))]
1515
pub keys: Vec<(Pubkey, bool)>,
1616
}
17+
18+
/// Utility for extracting the `ConfigKeys` data from the account data.
19+
#[cfg(feature = "bincode")]
20+
pub fn get_config_data(bytes: &[u8]) -> Result<&[u8], bincode::Error> {
21+
bincode::deserialize::<ConfigKeys>(bytes)
22+
.and_then(|keys| bincode::serialized_size(&keys))
23+
.map(|offset| &bytes[offset as usize..])
24+
}

0 commit comments

Comments
 (0)