sui_transaction_builder/intent/mod.rs
1//! High-level transaction intents.
2//!
3//! Intents describe *what* a transaction should accomplish without requiring the caller to
4//! manually manage coin selection or object resolution. When the transaction is built with
5//! [`TransactionBuilder::build`](crate::TransactionBuilder::build), registered resolvers
6//! communicate with the network to fill in the details.
7//!
8//! Currently the only built-in intent is [`CoinWithBalance`], which requests a coin of a
9//! given type and amount.
10
11use crate::Argument;
12use crate::TransactionBuilder;
13
14mod coin_with_balance;
15pub use coin_with_balance::CoinWithBalance;
16
17const MAX_GAS_OBJECTS: usize = 250; // 256
18#[allow(unused)]
19const MAX_COMMANDS: usize = 1000; // 1024
20#[allow(unused)]
21const MAX_INPUT_OBJECTS: usize = 2000; // 2048
22const MAX_ARGUMENTS: usize = 500; // 512
23
24pub(crate) type BoxError = Box<dyn std::error::Error + Send + Sync + 'static>;
25
26pub(crate) trait Intent: std::any::Any + Send + Sync {
27 fn register(self, builder: &mut TransactionBuilder) -> Argument;
28}
29
30#[async_trait::async_trait]
31pub(crate) trait IntentResolver: std::any::Any + std::fmt::Debug + Send + Sync {
32 // Perform any required resolutions
33 async fn resolve(
34 &self,
35 builder: &mut TransactionBuilder,
36 client: &mut sui_rpc::Client,
37 ) -> Result<(), BoxError>;
38}