Add method id
to SysbarId trait (#18604)
This commit is contained in:
@ -32,6 +32,10 @@ macro_rules! declare_sysvar_id(
|
||||
$crate::declare_id!($name);
|
||||
|
||||
impl $crate::sysvar::SysvarId for $type {
|
||||
fn id() -> $crate::pubkey::Pubkey {
|
||||
id()
|
||||
}
|
||||
|
||||
fn check_id(pubkey: &$crate::pubkey::Pubkey) -> bool {
|
||||
check_id(pubkey)
|
||||
}
|
||||
@ -51,6 +55,8 @@ macro_rules! declare_sysvar_id(
|
||||
crate::declare_id!("Sysvar1111111111111111111111111111111111111");
|
||||
|
||||
pub trait SysvarId {
|
||||
fn id() -> Pubkey;
|
||||
|
||||
fn check_id(pubkey: &Pubkey) -> bool;
|
||||
}
|
||||
|
||||
@ -113,6 +119,10 @@ mod tests {
|
||||
}
|
||||
crate::declare_id!("TestSysvar111111111111111111111111111111111");
|
||||
impl crate::sysvar::SysvarId for TestSysvar {
|
||||
fn id() -> crate::pubkey::Pubkey {
|
||||
id()
|
||||
}
|
||||
|
||||
fn check_id(pubkey: &crate::pubkey::Pubkey) -> bool {
|
||||
check_id(pubkey)
|
||||
}
|
||||
|
@ -270,6 +270,9 @@ mod tests {
|
||||
}
|
||||
crate::declare_id!("TestSysvar111111111111111111111111111111111");
|
||||
impl solana_program::sysvar::SysvarId for TestSysvar {
|
||||
fn id() -> crate::pubkey::Pubkey {
|
||||
id()
|
||||
}
|
||||
fn check_id(pubkey: &crate::pubkey::Pubkey) -> bool {
|
||||
check_id(pubkey)
|
||||
}
|
||||
|
Reference in New Issue
Block a user