iota_rest_api/transactions/
unresolved.rs

1// Copyright (c) 2025 IOTA Stiftung
2// SPDX-License-Identifier: Apache-2.0
3
4use iota_sdk_types::{Address, Command, Digest, ObjectId, TransactionExpiration, Version};
5
6pub(crate) type OptionReadableDisplay =
7    ::serde_with::As<Option<::serde_with::IfIsHumanReadable<::serde_with::DisplayFromStr>>>;
8
9// A potentially unresolved user transaction
10#[derive(serde::Serialize, serde::Deserialize)]
11pub struct UnresolvedTransaction {
12    #[serde(flatten)]
13    pub ptb: UnresolvedProgrammableTransaction,
14    pub sender: Address,
15    pub gas_payment: Option<UnresolvedGasPayment>,
16    pub expiration: TransactionExpiration,
17}
18
19#[derive(serde::Serialize, serde::Deserialize)]
20pub struct UnresolvedProgrammableTransaction {
21    pub inputs: Vec<UnresolvedInputArgument>,
22    pub commands: Vec<Command>,
23}
24
25#[derive(serde::Serialize, serde::Deserialize)]
26pub struct UnresolvedGasPayment {
27    pub objects: Vec<UnresolvedObjectReference>,
28    pub owner: Address,
29    #[serde(with = "OptionReadableDisplay")]
30    pub price: Option<u64>,
31    #[serde(with = "OptionReadableDisplay")]
32    pub budget: Option<u64>,
33}
34
35#[derive(serde::Serialize, serde::Deserialize)]
36pub struct UnresolvedObjectReference {
37    pub object_id: ObjectId,
38    #[serde(with = "OptionReadableDisplay")]
39    pub version: Option<Version>,
40    pub digest: Option<Digest>,
41}
42
43#[derive(serde::Serialize, serde::Deserialize)]
44pub enum UnresolvedInputArgument {
45    // contains no structs or objects
46    Pure {
47        #[serde(with = "::serde_with::As::<::serde_with::Bytes>")]
48        value: Vec<u8>,
49    },
50    // A Move object, either immutable, or owned mutable.
51    ImmutableOrOwned(UnresolvedObjectReference),
52    // A Move object that's shared.
53    // SharedObject::mutable controls whether caller asks for a mutable reference to shared
54    // object.
55    Shared {
56        object_id: ObjectId,
57        #[serde(with = "OptionReadableDisplay")]
58        initial_shared_version: Option<u64>,
59        mutable: Option<bool>,
60    },
61    // A Move object that can be received in this transaction.
62    Receiving(UnresolvedObjectReference),
63}