This commit is contained in:
2026-05-05 05:03:11 +02:00
parent 3e994995d7
commit f2c227e08f
132 changed files with 5767 additions and 4461 deletions

View File

@@ -44,7 +44,7 @@ pub struct KbRaydiumAmmV4Decoder;
impl KbRaydiumAmmV4Decoder {
/// Creates a new decoder.
pub fn new() -> Self {
Self
return Self;
}
/// Decodes one projected transaction into zero or more Raydium AmmV4 events.
@@ -61,7 +61,7 @@ impl KbRaydiumAmmV4Decoder {
"chain transaction '{}' has no internal id",
transaction.signature
)));
}
},
};
let transaction_json_result =
serde_json::from_str::<serde_json::Value>(transaction.transaction_json.as_str());
@@ -72,7 +72,7 @@ impl KbRaydiumAmmV4Decoder {
"cannot parse transaction_json for signature '{}': {}",
transaction.signature, error
)));
}
},
};
let log_messages = kb_extract_log_messages(&transaction_json);
let has_initialize2_log = kb_log_messages_contain_initialize2(&log_messages);
@@ -139,7 +139,7 @@ impl KbRaydiumAmmV4Decoder {
},
));
}
Ok(decoded_events)
return Ok(decoded_events)
}
}
@@ -168,7 +168,7 @@ fn kb_extract_log_messages(
messages.push(text.to_string());
}
}
messages
return messages
}
fn kb_log_messages_contain_initialize2(log_messages: &[std::string::String]) -> bool {
@@ -177,7 +177,7 @@ fn kb_log_messages_contain_initialize2(log_messages: &[std::string::String]) ->
return true;
}
}
false
return false
}
fn kb_parse_accounts_json(
@@ -191,7 +191,7 @@ fn kb_parse_accounts_json(
"cannot parse instruction accounts_json '{}': {}",
accounts_json, error
)));
}
},
};
let mut accounts = std::vec::Vec::new();
for value in values {
@@ -200,7 +200,7 @@ fn kb_parse_accounts_json(
accounts.push(text.to_string());
}
}
Ok(accounts)
return Ok(accounts)
}
fn kb_extract_account(
@@ -210,7 +210,7 @@ fn kb_extract_account(
if index >= accounts.len() {
return None;
}
Some(accounts[index].clone())
return Some(accounts[index].clone())
}
#[cfg(test)]
@@ -240,7 +240,7 @@ mod tests {
.to_string(),
);
dto.id = Some(42);
dto
return dto
}
fn make_instruction() -> crate::KbChainInstructionDto {
@@ -277,7 +277,7 @@ mod tests {
None,
);
dto.id = Some(7);
dto
return dto
}
#[test]
@@ -300,7 +300,7 @@ mod tests {
assert_eq!(event.token_a_mint, Some("TokenA111".to_string()));
assert_eq!(event.token_b_mint, Some("TokenB111".to_string()));
assert_eq!(event.market_account, Some("Market111".to_string()));
}
},
}
}