v0.1.0-pre.062
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// file: kb-lib/src/materializer/risk/core.rs
|
||||
// version: 5
|
||||
// version: 6
|
||||
|
||||
//! Stable fact-only risk projections for committed SPL Token and ATA observations.
|
||||
|
||||
@@ -168,9 +168,9 @@ impl crate::MtApiEventMaterializer for crate::MtRiskMaterializer {
|
||||
|
||||
fn accepts_event(event: &crate::MdDecodedProtocolEvent) -> bool {
|
||||
let token_program = (event.program_id.0 == kb_program_ids::SPL_TOKEN_PROGRAM_ID
|
||||
&& event.surface_code.0 == "spl_token")
|
||||
&& event.surface_code.0 == "spl.token")
|
||||
|| (event.program_id.0 == kb_program_ids::SPL_TOKEN_2022_PROGRAM_ID
|
||||
&& event.surface_code.0 == "spl_token_2022");
|
||||
&& event.surface_code.0 == "spl.token_2022");
|
||||
let token_risk = token_program && RISK_ENTRIES.contains(&event.event_name.0.as_str());
|
||||
return ACCEPTED_FAMILIES.contains(&event.event_family)
|
||||
&& (token_risk || is_ata_recovery(event));
|
||||
@@ -178,7 +178,7 @@ fn accepts_event(event: &crate::MdDecodedProtocolEvent) -> bool {
|
||||
|
||||
fn is_ata_recovery(event: &crate::MdDecodedProtocolEvent) -> bool {
|
||||
return event.program_id.0 == kb_program_ids::ASSOCIATED_TOKEN_PROGRAM_ID
|
||||
&& event.surface_code.0 == "spl_associated_token_account"
|
||||
&& event.surface_code.0 == "spl.associated_token_account"
|
||||
&& event.event_family == crate::MdEventFamily::Lifecycle
|
||||
&& event.event_name.0 == "recover_nested";
|
||||
}
|
||||
@@ -312,9 +312,9 @@ mod tests {
|
||||
slot: crate::MdSlot(1),
|
||||
instruction_path: crate::MdInstructionPath("0".to_string()),
|
||||
program_id: crate::MdProgramId(kb_program_ids::SPL_TOKEN_PROGRAM_ID.to_string()),
|
||||
protocol_code: crate::MdProtocolCode("spl_token".to_string()),
|
||||
surface_code: crate::MdSurfaceCode("spl_token".to_string()),
|
||||
event_code: crate::MdEventCode(format!("spl_token.{entry}")),
|
||||
protocol_code: crate::MdProtocolCode("spl.token".to_string()),
|
||||
surface_code: crate::MdSurfaceCode("spl.token".to_string()),
|
||||
event_code: crate::MdEventCode(format!("spl.token.{entry}")),
|
||||
event_name: crate::MdEventName(entry.to_string()),
|
||||
event_family: family,
|
||||
source_kind: crate::MdEventSourceKind::Instruction,
|
||||
@@ -341,9 +341,9 @@ mod tests {
|
||||
let mut observation = observation(entry, family, parameters, failed);
|
||||
observation.event.program_id =
|
||||
crate::MdProgramId(kb_program_ids::SPL_TOKEN_2022_PROGRAM_ID.to_string());
|
||||
observation.event.protocol_code = crate::MdProtocolCode("spl_token_2022".to_string());
|
||||
observation.event.surface_code = crate::MdSurfaceCode("spl_token_2022".to_string());
|
||||
observation.event.event_code = crate::MdEventCode(format!("spl_token_2022.{entry}"));
|
||||
observation.event.protocol_code = crate::MdProtocolCode("spl.token_2022".to_string());
|
||||
observation.event.surface_code = crate::MdSurfaceCode("spl.token_2022".to_string());
|
||||
observation.event.event_code = crate::MdEventCode(format!("spl.token_2022.{entry}"));
|
||||
observation.event_key = format!("token_2022:{entry}:0");
|
||||
return observation;
|
||||
}
|
||||
@@ -358,10 +358,10 @@ mod tests {
|
||||
program_id: crate::MdProgramId(
|
||||
kb_program_ids::ASSOCIATED_TOKEN_PROGRAM_ID.to_string(),
|
||||
),
|
||||
protocol_code: crate::MdProtocolCode("spl_associated_token_account".to_string()),
|
||||
surface_code: crate::MdSurfaceCode("spl_associated_token_account".to_string()),
|
||||
protocol_code: crate::MdProtocolCode("spl.associated_token_account".to_string()),
|
||||
surface_code: crate::MdSurfaceCode("spl.associated_token_account".to_string()),
|
||||
event_code: crate::MdEventCode(
|
||||
"spl_associated_token_account.recover_nested".to_string(),
|
||||
"spl.associated_token_account.recover_nested".to_string(),
|
||||
),
|
||||
event_name: crate::MdEventName("recover_nested".to_string()),
|
||||
event_family: crate::MdEventFamily::Lifecycle,
|
||||
|
||||
Reference in New Issue
Block a user