-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature gate: add activate instruction
- Loading branch information
1 parent
cb72e2a
commit b77b5ca
Showing
8 changed files
with
356 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
//! Module for managing feature IDs | ||
// use { | ||
// crate::error::FeatureGateError, | ||
// solana_program::{program_error::ProgramError, pubkey::Pubkey}, | ||
// solana_sdk::feature_set::FEATURE_NAMES, | ||
// }; | ||
|
||
// /// Returns `true` if the feature ID exists in the current feature set. | ||
// fn feature_exists(feature_id: &Pubkey) -> bool { | ||
// FEATURE_NAMES.iter().any(|(id, _)| id == feature_id) | ||
// } | ||
|
||
// /// Derives the feature ID from a authority's address. | ||
// pub fn derive_feature_id(authority: &Pubkey) -> Result<Pubkey, ProgramError> { | ||
// let nonce = 0u16; // u16::MAX = 65_535 features! | ||
// let mut feature_id = Pubkey::find_program_address(&[b"feature"], &crate::id()).0; | ||
// while feature_exists(&feature_id) { | ||
// nonce.checked_add(1).ok_or(FeatureGateError::Overflow)?; | ||
// feature_id = Pubkey::find_program_address( | ||
// &[b"feature", &nonce.to_le_bytes(), &authority.to_bytes()], | ||
// &crate::id(), | ||
// ) | ||
// .0; | ||
// } | ||
// Ok(feature_id) | ||
// } | ||
|
||
use solana_program::{program_error::ProgramError, pubkey::Pubkey}; | ||
|
||
/// Derives the feature ID from a authority's address. | ||
pub fn derive_feature_id(authority: &Pubkey) -> Result<(Pubkey, u8), ProgramError> { | ||
Ok(Pubkey::find_program_address( | ||
&[b"feature", authority.as_ref()], | ||
&crate::id(), | ||
)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.