pub struct SessionRequest {
pub amount: String,
pub unit_type: Option<String>,
pub currency: String,
pub decimals: Option<u8>,
pub recipient: Option<String>,
pub suggested_deposit: Option<String>,
pub method_details: Option<Value>,
}Expand description
Session request (for session intent).
Represents a pay-as-you-go session payment request. All fields are strings to remain method-agnostic. Use the methods layer for typed accessors.
§Examples
use mpp::protocol::intents::SessionRequest;
let req = SessionRequest {
amount: "1000".to_string(),
unit_type: Some("second".to_string()),
currency: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48".to_string(),
decimals: None,
recipient: Some("0x742d35Cc6634C0532925a3b844Bc9e7595f1B0F2".to_string()),
suggested_deposit: Some("60000".to_string()),
method_details: None,
};
assert_eq!(req.amount, "1000");
assert_eq!(req.unit_type, Some("second".to_string()));Fields§
§amount: StringAmount per unit in base units (e.g., wei per second)
unit_type: Option<String>Unit type for the session rate (e.g., “second”, “minute”, “request”). Optional.
currency: StringCurrency/asset identifier (token address, ISO 4217 code, or symbol)
decimals: Option<u8>Token decimals for amount conversion (e.g., 6 for pathUSD).
When set, amount and suggested_deposit are treated as human-readable
values and will be scaled by 10^decimals during challenge creation.
The field is stripped from wire serialization.
recipient: Option<String>Recipient address (optional, server may be recipient)
suggested_deposit: Option<String>Suggested deposit amount in base units
method_details: Option<Value>Method-specific extension fields (interpreted by methods layer)
Implementations§
Source§impl SessionRequest
impl SessionRequest
Sourcepub fn with_base_units(self) -> Result<Self>
pub fn with_base_units(self) -> Result<Self>
Apply the decimals transform, converting human-readable amounts to base units.
Transforms both amount and suggested_deposit (if present).
If decimals is None, returns self unchanged.
Sourcepub fn parse_amount(&self) -> Result<u128>
pub fn parse_amount(&self) -> Result<u128>
Parse the amount as u128.
Returns an error if the amount is not a valid unsigned integer.
Trait Implementations§
Source§impl Clone for SessionRequest
impl Clone for SessionRequest
Source§fn clone(&self) -> SessionRequest
fn clone(&self) -> SessionRequest
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more