Skip to content

Commit 3094b49

Browse files
committed
types: add unresolved transaction builder types
1 parent fa562c9 commit 3094b49

File tree

4 files changed

+100
-1
lines changed

4 files changed

+100
-1
lines changed

src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ mod _serde {
1515
pub(crate) type ReadableDisplay =
1616
::serde_with::As<::serde_with::IfIsHumanReadable<::serde_with::DisplayFromStr>>;
1717

18+
pub(crate) type OptionReadableDisplay =
19+
::serde_with::As<Option<::serde_with::IfIsHumanReadable<::serde_with::DisplayFromStr>>>;
20+
1821
pub(crate) type ReadableBase64Encoded =
1922
::serde_with::As<::serde_with::IfIsHumanReadable<Base64Encoded, ::serde_with::Bytes>>;
2023

src/types/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ pub use transaction::{
4949
ConsensusCommitPrologue, ConsensusCommitPrologueV2, EndOfEpochTransactionKind, GasPayment,
5050
GenesisTransaction, InputArgument, MakeMoveVector, MergeCoins, MoveCall,
5151
ProgrammableTransaction, Publish, RandomnessStateUpdate, SignedTransaction, SplitCoins,
52-
SystemPackage, Transaction, TransactionExpiration, TransactionKind, TransferObjects, Upgrade,
52+
SystemPackage, Transaction, TransactionExpiration, TransactionKind, TransferObjects,
53+
UnresolvedGasPayment, UnresolvedInputArgument, UnresolvedObjectReference,
54+
UnresolvedProgrammableTransaction, UnresolvedTransaction, Upgrade,
5355
};
5456
pub use type_tag::{Identifier, StructTag, TypeParseError, TypeTag};

src/types/transaction/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ use super::{
77
#[cfg_attr(doc_cfg, doc(cfg(feature = "serde")))]
88
mod serialization;
99

10+
mod unresolved;
11+
pub use unresolved::{
12+
UnresolvedGasPayment, UnresolvedInputArgument, UnresolvedObjectReference,
13+
UnresolvedProgrammableTransaction, UnresolvedTransaction,
14+
};
15+
1016
#[derive(Clone, Debug, PartialEq, Eq)]
1117
pub struct Transaction {
1218
pub kind: TransactionKind,

src/types/transaction/unresolved.rs

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
use crate::types::{object::Version, Address, ObjectDigest, ObjectId};
2+
3+
use super::{Command, TransactionExpiration};
4+
5+
// A potentially Unresolved user transaction
6+
#[cfg_attr(
7+
feature = "serde",
8+
derive(serde_derive::Serialize, serde_derive::Deserialize)
9+
)]
10+
pub struct UnresolvedTransaction {
11+
#[cfg_attr(feature = "serde", serde(flatten))]
12+
pub ptb: UnresolvedProgrammableTransaction,
13+
pub sender: Address,
14+
pub gas_payment: Option<UnresolvedGasPayment>,
15+
pub expiration: TransactionExpiration,
16+
}
17+
18+
#[cfg_attr(
19+
feature = "serde",
20+
derive(serde_derive::Serialize, serde_derive::Deserialize)
21+
)]
22+
pub struct UnresolvedProgrammableTransaction {
23+
pub inputs: Vec<UnresolvedInputArgument>,
24+
pub commands: Vec<Command>,
25+
}
26+
27+
#[cfg_attr(
28+
feature = "serde",
29+
derive(serde_derive::Serialize, serde_derive::Deserialize)
30+
)]
31+
pub struct UnresolvedGasPayment {
32+
pub objects: Vec<UnresolvedObjectReference>,
33+
pub owner: Address,
34+
#[cfg_attr(
35+
feature = "serde",
36+
serde(with = "crate::_serde::OptionReadableDisplay")
37+
)]
38+
pub price: Option<u64>,
39+
#[cfg_attr(
40+
feature = "serde",
41+
serde(with = "crate::_serde::OptionReadableDisplay")
42+
)]
43+
pub budget: Option<u64>,
44+
}
45+
46+
#[cfg_attr(
47+
feature = "serde",
48+
derive(serde_derive::Serialize, serde_derive::Deserialize)
49+
)]
50+
pub struct UnresolvedObjectReference {
51+
pub object_id: ObjectId,
52+
#[cfg_attr(
53+
feature = "serde",
54+
serde(with = "crate::_serde::OptionReadableDisplay")
55+
)]
56+
pub version: Option<Version>,
57+
pub digest: Option<ObjectDigest>,
58+
}
59+
60+
#[cfg_attr(
61+
feature = "serde",
62+
derive(serde_derive::Serialize, serde_derive::Deserialize)
63+
)]
64+
pub enum UnresolvedInputArgument {
65+
// contains no structs or objects
66+
Pure {
67+
#[cfg_attr(
68+
feature = "serde",
69+
serde(with = "::serde_with::As::<::serde_with::Bytes>")
70+
)]
71+
value: Vec<u8>,
72+
},
73+
// A Move object, either immutable, or owned mutable.
74+
ImmutableOrOwned(UnresolvedObjectReference),
75+
// A Move object that's shared.
76+
// SharedObject::mutable controls whether caller asks for a mutable reference to shared object.
77+
Shared {
78+
object_id: ObjectId,
79+
#[cfg_attr(
80+
feature = "serde",
81+
serde(with = "crate::_serde::OptionReadableDisplay")
82+
)]
83+
initial_shared_version: Option<u64>,
84+
mutable: Option<bool>,
85+
},
86+
// A Move object that can be received in this transaction.
87+
Receiving(UnresolvedObjectReference),
88+
}

0 commit comments

Comments
 (0)