Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

refactor(web3): extract payments_value helper for x402 list response

Steven Enamakel1d3b1a2d8ae7
diff --git a/crates/openhuman-core/src/web3/x402/schemas.rs b/crates/openhuman-core/src/web3/x402/schemas.rs
index 379efdac3b..8c6939870b 100644
--- a/crates/openhuman-core/src/web3/x402/schemas.rs
+++ b/crates/openhuman-core/src/web3/x402/schemas.rs
@@ -139,10 +139,14 @@ fn handle_list_payments(params: Map<String, Value>) -> ControllerFuture {
let response = crate::modules::x402_service::list_payments(&config, limit)
.await
.map_err(|error| format!("x402 list_payments: {error}"))?;
- Ok(json!({ "payments": response.payments }))
+ Ok(payments_value(response.payments))
})
}
+fn payments_value(payments: Vec<tinywallet_bus::wire::X402PaymentRecord>) -> Value {
+ json!({ "payments": payments })
+}
+
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
struct UpdateBudgetParams {
diff --git a/crates/openhuman-core/src/web3/x402/schemas_tests.rs b/crates/openhuman-core/src/web3/x402/schemas_tests.rs
index 6d984e02b4..195eb83832 100644
--- a/crates/openhuman-core/src/web3/x402/schemas_tests.rs
+++ b/crates/openhuman-core/src/web3/x402/schemas_tests.rs
@@ -48,3 +48,46 @@ fn budget_response_preserves_legacy_camel_case_rpc_shape() {
})
);
}
+
+#[test]
+fn payment_list_preserves_legacy_rpc_shape_and_rfc3339_values() {
+ let value = payments_value(vec![tinywallet_bus::wire::X402PaymentRecord {
+ id: "payment-1".into(),
+ url: "https://api.example.test/resource".into(),
+ asset: "USDC".into(),
+ amount_atomic: 2_500,
+ amount_display: "0.002500 USDC".into(),
+ recipient: "0x0000000000000000000000000000000000000001".into(),
+ network: "eip155:1".into(),
+ tx_signature: Some("0xabc".into()),
+ status: tinywallet_bus::wire::X402PaymentStatus::Settled,
+ timestamp: "2026-10-11T19:02:03Z".into(),
+ authorization_valid_until: Some("2026-10-11T19:03:03Z".into()),
+ solana_last_valid_block_height: None,
+ authorization_expired_at: None,
+ authorization_expiry_observed_height: None,
+ session_id: "session-1".into(),
+ thread_id: Some("thread-1".into()),
+ }]);
+
+ assert_eq!(
+ value,
+ json!({
+ "payments": [{
+ "id": "payment-1",
+ "url": "https://api.example.test/resource",
+ "asset": "USDC",
+ "amountAtomic": 2500,
+ "amountDisplay": "0.002500 USDC",
+ "recipient": "0x0000000000000000000000000000000000000001",
+ "network": "eip155:1",
+ "txSignature": "0xabc",
+ "status": "settled",
+ "timestamp": "2026-10-11T19:02:03Z",
+ "authorizationValidUntil": "2026-10-11T19:03:03Z",
+ "sessionId": "session-1",
+ "threadId": "thread-1"
+ }]
+ })
+ );
+}