pump_swap correction.
This commit is contained in:
@@ -1484,7 +1484,16 @@ fn parse_pump_fees_instruction_data(
|
||||
let decoded_fields_result = decode_borsh_fields(&decoded[8..], spec.fields);
|
||||
let decoded_fields = match decoded_fields_result {
|
||||
Ok(decoded_fields) => decoded_fields,
|
||||
Err(error) => return Err(error),
|
||||
Err(error) => {
|
||||
tracing::debug!(
|
||||
decoder = "pump_fees",
|
||||
discriminator_hex = bytes_to_hex(discriminator.as_slice()),
|
||||
payload_size = decoded.len().saturating_sub(8),
|
||||
error = %error,
|
||||
"ignoring malformed pump_fees instruction payload"
|
||||
);
|
||||
return Ok(None);
|
||||
},
|
||||
};
|
||||
return Ok(Some(PumpFeesInstructionData {
|
||||
spec,
|
||||
@@ -1544,7 +1553,16 @@ fn decode_pump_fees_anchor_event_from_base64(
|
||||
let fields_result = decode_borsh_fields(&payload[8..], spec.fields);
|
||||
let fields_json = match fields_result {
|
||||
Ok(fields_json) => fields_json,
|
||||
Err(error) => return Err(error),
|
||||
Err(error) => {
|
||||
tracing::debug!(
|
||||
decoder = "pump_fees",
|
||||
discriminator_hex = bytes_to_hex(discriminator.as_slice()),
|
||||
payload_size = payload.len().saturating_sub(8),
|
||||
error = %error,
|
||||
"ignoring malformed pump_fees anchor event payload"
|
||||
);
|
||||
return Ok(None);
|
||||
},
|
||||
};
|
||||
return Ok(Some(PumpFeesAnchorEventData {
|
||||
spec,
|
||||
@@ -2422,6 +2440,37 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ignores_truncated_known_instruction_payload() {
|
||||
let mut data = std::vec::Vec::new();
|
||||
data.extend_from_slice(&super::PUMP_FEES_GET_FEES_DISCRIMINATOR);
|
||||
let encoded = bs58::encode(data).into_string();
|
||||
let data_json = serde_json::json!(encoded).to_string();
|
||||
let decoded_result = super::parse_pump_fees_instruction_data(Some(&data_json));
|
||||
match decoded_result {
|
||||
Ok(None) => {},
|
||||
Ok(Some(decoded)) => panic!("unexpected decoded truncated instruction: {}", decoded.spec.name),
|
||||
Err(error) => panic!("truncated instruction should be ignored: {}", error),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ignores_truncated_known_anchor_event_payload() {
|
||||
let data = pump_fees_anchor_event_prefix(
|
||||
&super::PUMP_FEES_SOCIAL_FEE_PDA_CLAIMED_DISCRIMINATOR,
|
||||
);
|
||||
let encoded = {
|
||||
use base64::Engine as _;
|
||||
base64::engine::general_purpose::STANDARD.encode(data)
|
||||
};
|
||||
let decoded_result = super::decode_pump_fees_anchor_event_from_base64(encoded.as_str());
|
||||
match decoded_result {
|
||||
Ok(None) => {},
|
||||
Ok(Some(decoded)) => panic!("unexpected decoded truncated anchor event: {}", decoded.spec.name),
|
||||
Err(error) => panic!("truncated anchor event should be ignored: {}", error),
|
||||
}
|
||||
}
|
||||
|
||||
fn pump_fees_anchor_event_prefix(event_discriminator: &[u8; 8]) -> std::vec::Vec<u8> {
|
||||
let mut data = std::vec::Vec::new();
|
||||
data.extend_from_slice(&super::PUMP_FEES_ANCHOR_SELF_CPI_LOG_DISCRIMINATOR);
|
||||
|
||||
Reference in New Issue
Block a user