MCPcopy Create free account
hub / github.com/cowprotocol/services / app_code

Function app_code

crates/app-data/src/app_data.rs:407–417  ·  view source on GitHub ↗

Extracts the `appCode` from a full app-data document, if present. `appCode` sits at the document root, next to (not inside) the protocol `metadata`, so it is not part of [`ProtocolAppData`] and callers that want it — e.g. for analytics — parse it separately with this helper. Returns `None` for absent or malformed app data.

(full_app_data: &[u8])

Source from the content-addressed store, hash-verified

405/// it — e.g. for analytics — parse it separately with this helper. Returns
406/// `None` for absent or malformed app data.
407pub fn app_code(full_app_data: &[u8]) -> Option<String> {
408 #[derive(Deserialize)]
409 struct AppCode {
410 #[serde(rename = "appCode")]
411 app_code: Option<String>,
412 }
413
414 serde_json::from_slice::<AppCode>(full_app_data)
415 .ok()?
416 .app_code
417}
418
419/// The root app data JSON object.
420///

Callers 5

fast_path_volume_feesMethod · 0.85
evaluateMethod · 0.85
calculate_quoteMethod · 0.85

Calls 1

okMethod · 0.80

Tested by

no test coverage detected