solana_conditional_liquidity/
registry.rsuse bytemuck::{Pod, Zeroable};
use solana_program::{account_info::AccountInfo, pubkey, pubkey::Pubkey};
const MAX_ITEMS: usize = 64;
#[derive(Pod, Zeroable, Copy, Clone)]
#[repr(C)]
pub struct Registry {
pub registered_segmenters: [Pubkey; MAX_ITEMS],
}
impl Registry {
pub const PROGRAM_ID: Pubkey = pubkey!("SRegZsVZDDqwc7W5iMUSsmKNnXzgfczKzFpimRp5iWw");
pub const DISCRIMINATOR: [u8; 8] = [47, 174, 110, 246, 184, 182, 252, 218];
pub fn is_segmenter_registered(&self, key: &Pubkey) -> bool {
self.registered_segmenters.binary_search(key).is_ok()
}
pub fn deserialize(bytes: &[u8]) -> &Self {
bytemuck::from_bytes(&bytes[8..])
}
}
pub fn is_invoked_by_segmenter(registry: &AccountInfo<'_>, segmenter: &AccountInfo<'_>) -> bool {
if *registry.owner != Registry::PROGRAM_ID {
return false;
}
if !segmenter.is_signer {
return false;
}
let registry_account_data = registry.data.borrow();
if registry_account_data[..8] != Registry::DISCRIMINATOR {
return false;
}
let registry_state = Registry::deserialize(®istry_account_data);
registry_state.is_segmenter_registered(segmenter.key)
}
#[cfg(test)]
mod tests {
use std::{cell::RefCell, rc::Rc};
use base64::Engine;
use solana_program::system_program;
use super::*;
#[test]
fn test_deserialize_registry_account() {
let mut registry_data = base64::engine::general_purpose::STANDARD
.decode("L65u9ri2/NoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADmpy9pZ0kSP2HFqsTSMjxFxburQjxQioc8A4BaVKbWtBAWsWrJs+pByyagNT2RTZ5E/wZAQB0FNhQpY/WTUev0FyJOST1AtAGCROxwJ16TmEm/91X11Lmzcymw9zcmibQnqAzYRp+mQPsmo+2htSt8O7nGFhRpTDQdq9qCtx9jA==")
.unwrap();
let mut registry_lamports = 15200640;
let registry = AccountInfo {
key: &pubkey!("Reg1Y127DNKYUTf3LinfEs3oiSiywJsyAobJMjqYqDE"),
is_signer: false,
is_writable: false,
lamports: Rc::new(RefCell::new(&mut registry_lamports)),
data: Rc::new(RefCell::new(&mut registry_data)),
owner: &Registry::PROGRAM_ID,
executable: false,
rent_epoch: 18446744073709551615,
};
let data = registry.data.borrow();
Registry::deserialize(&data);
}
#[test]
#[should_panic]
fn test_deserialize_invalid_registry_account() {
let mut registry_data = base64::engine::general_purpose::STANDARD
.decode("L65u9ri2/NoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADmpy9pZ0kSP2HFqsTSMjxFxburQjxQioc8A4BaVKbWtBAWsWrJs+pByyagNT2RTZ5E/wZAQB0FNhQpY/WTUev0FyJOST1AtAGCROxwJ16TmEm/91X11Lmzcymw9zcmibQnqAzYRp+mQPsmo+2htSt8O7nGFhRpTDQdq9qCtx9jA==")
.unwrap();
let mut registry_lamports = 15200640;
let registry = AccountInfo {
key: &pubkey!("Reg1Y127DNKYUTf3LinfEs3oiSiywJsyAobJMjqYqDE"),
is_signer: false,
is_writable: false,
lamports: Rc::new(RefCell::new(&mut registry_lamports)),
data: Rc::new(RefCell::new(&mut registry_data)),
owner: &Registry::PROGRAM_ID,
executable: false,
rent_epoch: 18446744073709551615,
};
let data = registry.data.borrow();
Registry::deserialize(&data);
}
#[test]
fn test_is_invoked_by_segmenter() {
let mut registry_data = base64::engine::general_purpose::STANDARD
.decode("L65u9ri2/NoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADmpy9pZ0kSP2HFqsTSMjxFxburQjxQioc8A4BaVKbWtBAWsWrJs+pByyagNT2RTZ5E/wZAQB0FNhQpY/WTUev0FyJOST1AtAGCROxwJ16TmEm/91X11Lmzcymw9zcmibQnqAzYRp+mQPsmo+2htSt8O7nGFhRpTDQdq9qCtx9jA==")
.unwrap();
let mut registry_lamports = 15200640;
let registry = AccountInfo {
key: &Pubkey::new_unique(),
is_signer: false,
is_writable: false,
lamports: Rc::new(RefCell::new(&mut registry_lamports)),
data: Rc::new(RefCell::new(&mut registry_data)),
owner: &Registry::PROGRAM_ID,
executable: false,
rent_epoch: 18446744073709551615,
};
let mut segmenter_lamports = 0;
let mut segmenter_data = [];
let segmenter = AccountInfo {
key: &pubkey!("F2Me9XknvkPYjvoEgTXXKqARg58Ezo6ZmGhpYdS3UTmF"),
is_signer: true,
is_writable: false,
lamports: Rc::new(RefCell::new(&mut segmenter_lamports)),
data: Rc::new(RefCell::new(&mut segmenter_data)),
owner: &system_program::id(),
executable: false,
rent_epoch: 18446744073709551615,
};
assert!(is_invoked_by_segmenter(®istry, &segmenter));
let mut segmenter_lamports = 0;
let mut segmenter_data = [];
let segmenter = AccountInfo {
key: &pubkey!("F2Me9XknvkPYjvoEgTXXKqARg58Ezo6ZmGhpYdS3UTmF"),
is_signer: false,
is_writable: false,
lamports: Rc::new(RefCell::new(&mut segmenter_lamports)),
data: Rc::new(RefCell::new(&mut segmenter_data)),
owner: &system_program::id(),
executable: false,
rent_epoch: 18446744073709551615,
};
assert!(!is_invoked_by_segmenter(®istry, &segmenter));
let mut segmenter_lamports = 0;
let mut segmenter_data = [];
let segmenter = AccountInfo {
key: &Pubkey::new_unique(),
is_signer: true,
is_writable: false,
lamports: Rc::new(RefCell::new(&mut segmenter_lamports)),
data: Rc::new(RefCell::new(&mut segmenter_data)),
owner: &system_program::id(),
executable: false,
rent_epoch: 18446744073709551615,
};
assert!(!is_invoked_by_segmenter(®istry, &segmenter));
}
#[test]
fn test_is_invoked_by_segmenter_invalid_registry() {
let mut registry_data = base64::engine::general_purpose::STANDARD
.decode("L65u9ri2/NoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADmpy9pZ0kSP2HFqsTSMjxFxburQjxQioc8A4BaVKbWtBAWsWrJs+pByyagNT2RTZ5E/wZAQB0FNhQpY/WTUev0FyJOST1AtAGCROxwJ16TmEm/91X11Lmzcymw9zcmibQnqAzYRp+mQPsmo+2htSt8O7nGFhRpTDQdq9qCtx9jA==")
.unwrap();
let mut registry_lamports = 15200640;
let registry = AccountInfo {
key: &Pubkey::new_unique(),
is_signer: false,
is_writable: false,
lamports: Rc::new(RefCell::new(&mut registry_lamports)),
data: Rc::new(RefCell::new(&mut registry_data)),
owner: &Pubkey::new_unique(),
executable: false,
rent_epoch: 18446744073709551615,
};
let mut segmenter_lamports = 0;
let mut segmenter_data = [];
let segmenter = AccountInfo {
key: &pubkey!("F2Me9XknvkPYjvoEgTXXKqARg58Ezo6ZmGhpYdS3UTmF"),
is_signer: true,
is_writable: false,
lamports: Rc::new(RefCell::new(&mut segmenter_lamports)),
data: Rc::new(RefCell::new(&mut segmenter_data)),
owner: &system_program::id(),
executable: false,
rent_epoch: 18446744073709551615,
};
assert!(!is_invoked_by_segmenter(®istry, &segmenter));
let mut segmenter_lamports = 0;
let mut segmenter_data = [];
let segmenter = AccountInfo {
key: &pubkey!("F2Me9XknvkPYjvoEgTXXKqARg58Ezo6ZmGhpYdS3UTmF"),
is_signer: false,
is_writable: false,
lamports: Rc::new(RefCell::new(&mut segmenter_lamports)),
data: Rc::new(RefCell::new(&mut segmenter_data)),
owner: &system_program::id(),
executable: false,
rent_epoch: 18446744073709551615,
};
assert!(!is_invoked_by_segmenter(®istry, &segmenter));
let mut segmenter_lamports = 0;
let mut segmenter_data = [];
let segmenter = AccountInfo {
key: &Pubkey::new_unique(),
is_signer: true,
is_writable: false,
lamports: Rc::new(RefCell::new(&mut segmenter_lamports)),
data: Rc::new(RefCell::new(&mut segmenter_data)),
owner: &system_program::id(),
executable: false,
rent_epoch: 18446744073709551615,
};
assert!(!is_invoked_by_segmenter(®istry, &segmenter));
}
}