pub struct Invocation { /* private fields */ }Expand description
An active transaction invocation.
This structure represents a transaction that is being prepared for execution. It holds the transaction template (TIR), parameter definitions, and current argument values.
Use the builder methods (with_arg, with_args) to populate arguments,
then convert to a TRP resolve request using into_resolve_request.
§Example
use serde_json::json;
use tx3_sdk::tii::Protocol;
let protocol = Protocol::from_file("protocol.tii")?;
let invocation = protocol.invoke("transfer", None)?;
// Set arguments
let invocation = invocation
.with_arg("sender", json!("addr1..."))
.with_arg("amount", json!(1000000));
// Check what's missing
for (name, ty) in invocation.unspecified_params() {
println!("Need: {} ({:?})", name, ty);
}
// Convert to resolve request
let resolve_params = invocation.into_resolve_request()?;Implementations§
Source§impl Invocation
impl Invocation
Sourcepub fn params(&mut self) -> &ParamMap
pub fn params(&mut self) -> &ParamMap
Returns a reference to all parameters for this invocation.
§Returns
A reference to the map of parameter names to their types.
Sourcepub fn unspecified_params(
&mut self,
) -> impl Iterator<Item = (&String, &ParamType)>
pub fn unspecified_params( &mut self, ) -> impl Iterator<Item = (&String, &ParamType)>
Returns an iterator over parameters that haven’t been specified yet.
This is useful for checking which required arguments are still missing before submitting the transaction.
§Returns
An iterator over (name, type) pairs for unspecified parameters.
Sourcepub fn set_arg(&mut self, name: &str, value: Value)
pub fn set_arg(&mut self, name: &str, value: Value)
Sets a single argument value.
§Arguments
name- The parameter name (case-insensitive)value- The JSON value to set
Sourcepub fn into_resolve_request(self) -> Result<ResolveParams, Error>
pub fn into_resolve_request(self) -> Result<ResolveParams, Error>
Converts this invocation into a TRP resolve request.
This method consumes the invocation and creates the parameters needed
to call the TRP resolve method.
§Returns
Returns ResolveParams that can be passed to trp::Client::resolve.
§Errors
Currently this method always succeeds, but returns Result for future
compatibility.
Trait Implementations§
Source§impl Clone for Invocation
impl Clone for Invocation
Source§fn clone(&self) -> Invocation
fn clone(&self) -> Invocation
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more