Skip to main content

sui_sdk_types/transaction/
mod.rs

1use crate::Digest;
2
3use super::Address;
4use super::CheckpointTimestamp;
5use super::EpochId;
6use super::GenesisObject;
7use super::Identifier;
8use super::Jwk;
9use super::JwkId;
10use super::ObjectReference;
11use super::ProtocolVersion;
12use super::TypeTag;
13use super::UserSignature;
14use super::Version;
15
16#[cfg(feature = "serde")]
17#[cfg_attr(doc_cfg, doc(cfg(feature = "serde")))]
18mod serialization;
19#[cfg(feature = "serde")]
20#[cfg_attr(doc_cfg, doc(cfg(feature = "serde")))]
21pub(crate) use serialization::SignedTransactionWithIntentMessage;
22
23/// A transaction
24///
25/// # BCS
26///
27/// The BCS serialized form for this type is defined by the following ABNF:
28///
29/// ```text
30/// transaction = %x00 transaction-v1
31///
32/// transaction-v1 = transaction-kind address gas-payment transaction-expiration
33/// ```
34#[derive(Clone, Debug, PartialEq, Eq)]
35#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
36pub struct Transaction {
37    pub kind: TransactionKind,
38    pub sender: Address,
39    pub gas_payment: GasPayment,
40    pub expiration: TransactionExpiration,
41}
42
43#[derive(Clone, Debug, PartialEq, Eq)]
44#[cfg_attr(
45    feature = "serde",
46    derive(serde_derive::Serialize, serde_derive::Deserialize)
47)]
48#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
49pub struct SignedTransaction {
50    pub transaction: Transaction,
51    #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=1).lift()))]
52    pub signatures: Vec<UserSignature>,
53}
54
55/// A TTL for a transaction
56///
57/// # BCS
58///
59/// The BCS serialized form for this type is defined by the following ABNF:
60///
61/// ```text
62/// transaction-expiration =  %x00      ; none
63///                        =/ %x01 u64  ; epoch
64/// ```
65#[derive(Clone, Copy, Default, Debug, PartialEq, Eq, Hash)]
66#[cfg_attr(
67    feature = "serde",
68    derive(serde_derive::Serialize, serde_derive::Deserialize)
69)]
70#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
71#[non_exhaustive]
72pub enum TransactionExpiration {
73    /// The transaction has no expiration
74    #[default]
75    None,
76
77    /// Validators wont sign a transaction unless the expiration Epoch
78    /// is greater than or equal to the current epoch
79    Epoch(EpochId),
80
81    /// ValidDuring enables gas payments from address balances.
82    ///
83    /// When transactions use address balances for gas payment instead of explicit gas coins,
84    /// we lose the natural transaction uniqueness and replay prevention that comes from
85    /// mutation of gas coin objects.
86    ///
87    /// By bounding expiration and providing a nonce, validators must only retain
88    /// executed digests for the maximum possible expiry range to differentiate
89    /// retries from unique transactions with otherwise identical inputs.
90    ValidDuring {
91        /// Transaction invalid before this epoch. Must equal current epoch.
92        min_epoch: Option<EpochId>,
93        /// Transaction expires after this epoch. Must equal current epoch
94        max_epoch: Option<EpochId>,
95        /// Future support for sub-epoch timing (not yet implemented)
96        min_timestamp: Option<u64>,
97        /// Future support for sub-epoch timing (not yet implemented)
98        max_timestamp: Option<u64>,
99        /// Network identifier to prevent cross-chain replay
100        chain: Digest,
101        /// User-provided uniqueness identifier to differentiate otherwise identical transactions
102        nonce: u32,
103    },
104}
105
106/// Payment information for executing a transaction
107///
108/// # BCS
109///
110/// The BCS serialized form for this type is defined by the following ABNF:
111///
112/// ```text
113/// gas-payment = (vector object-ref) ; gas coin objects
114///               address             ; owner
115///               u64                 ; price
116///               u64                 ; budget
117/// ```
118#[derive(Clone, Debug, PartialEq, Eq)]
119#[cfg_attr(
120    feature = "serde",
121    derive(serde_derive::Serialize, serde_derive::Deserialize)
122)]
123#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
124pub struct GasPayment {
125    #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))]
126    pub objects: Vec<ObjectReference>,
127
128    /// Owner of the gas objects, either the transaction sender or a sponsor
129    pub owner: Address,
130
131    /// Gas unit price to use when charging for computation
132    ///
133    /// Must be greater-than-or-equal-to the network's current RGP (reference gas price)
134    pub price: u64,
135
136    /// Total budget willing to spend for the execution of a transaction
137    pub budget: u64,
138}
139
140/// Randomness update
141///
142/// # BCS
143///
144/// The BCS serialized form for this type is defined by the following ABNF:
145///
146/// ```text
147/// randomness-state-update = u64 u64 bytes u64
148/// ```
149#[derive(Clone, Debug, PartialEq, Eq)]
150#[cfg_attr(
151    feature = "serde",
152    derive(serde_derive::Serialize, serde_derive::Deserialize)
153)]
154#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
155pub struct RandomnessStateUpdate {
156    /// Epoch of the randomness state update transaction
157    pub epoch: u64,
158
159    /// Randomness round of the update
160    pub randomness_round: u64,
161
162    /// Updated random bytes
163    #[cfg_attr(
164        feature = "serde",
165        serde(with = "crate::_serde::ReadableBase64Encoded")
166    )]
167    pub random_bytes: Vec<u8>,
168
169    /// The initial version of the randomness object that it was shared at.
170    pub randomness_obj_initial_shared_version: u64,
171}
172
173/// Transaction type
174///
175/// # BCS
176///
177/// The BCS serialized form for this type is defined by the following ABNF:
178///
179/// ```text
180/// transaction-kind    =  %x00 ptb
181///                     =/ %x01 change-epoch
182///                     =/ %x02 genesis-transaction
183///                     =/ %x03 consensus-commit-prologue
184///                     =/ %x04 authenticator-state-update
185///                     =/ %x05 (vector end-of-epoch-transaction-kind)
186///                     =/ %x06 randomness-state-update
187///                     =/ %x07 consensus-commit-prologue-v2
188///                     =/ %x08 consensus-commit-prologue-v3
189///                     =/ %x09 consensus-commit-prologue-v4
190///                     =/ %x0A ptb
191/// ```
192#[derive(Clone, Debug, PartialEq, Eq)]
193#[cfg_attr(
194    feature = "serde",
195    derive(serde_derive::Serialize, serde_derive::Deserialize)
196)]
197#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
198#[non_exhaustive]
199pub enum TransactionKind {
200    /// A user transaction comprised of a list of native commands and move calls
201    ProgrammableTransaction(ProgrammableTransaction),
202
203    /// System transaction used to end an epoch.
204    ///
205    /// The ChangeEpoch variant is now deprecated (but the ChangeEpoch struct is still used by
206    /// EndOfEpochTransaction below).
207    ChangeEpoch(ChangeEpoch),
208
209    /// Transaction used to initialize the chain state.
210    ///
211    /// Only valid if in the genesis checkpoint (0) and if this is the very first transaction ever
212    /// executed on the chain.
213    Genesis(GenesisTransaction),
214
215    /// V1 consensus commit update
216    ConsensusCommitPrologue(ConsensusCommitPrologue),
217
218    /// Update set of valid JWKs used for zklogin
219    AuthenticatorStateUpdate(AuthenticatorStateUpdate),
220
221    /// Set of operations to run at the end of the epoch to close out the current epoch and start
222    /// the next one.
223    EndOfEpoch(
224        #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=1).lift()))]
225        Vec<EndOfEpochTransactionKind>,
226    ),
227
228    /// Randomness update
229    RandomnessStateUpdate(RandomnessStateUpdate),
230
231    /// V2 consensus commit update
232    ConsensusCommitPrologueV2(ConsensusCommitPrologueV2),
233
234    /// V3 consensus commit update
235    ConsensusCommitPrologueV3(ConsensusCommitPrologueV3),
236
237    /// V4 consensus commit update
238    ConsensusCommitPrologueV4(ConsensusCommitPrologueV4),
239
240    /// A system transaction comprised of a list of native commands and move calls
241    ProgrammableSystemTransaction(ProgrammableTransaction),
242}
243
244/// Operation run at the end of an epoch
245///
246/// # BCS
247///
248/// The BCS serialized form for this type is defined by the following ABNF:
249///
250/// ```text
251/// end-of-epoch-transaction-kind   =  eoe-change-epoch
252///                                 =/ eoe-authenticator-state-create
253///                                 =/ eoe-authenticator-state-expire
254///                                 =/ eoe-randomness-state-create
255///                                 =/ eoe-deny-list-state-create
256///                                 =/ eoe-bridge-state-create
257///                                 =/ eoe-bridge-committee-init
258///                                 =/ eoe-store-execution-time-observations
259///
260/// eoe-change-epoch                = %x00 change-epoch
261/// eoe-authenticator-state-create  = %x01
262/// eoe-authenticator-state-expire  = %x02 authenticator-state-expire
263/// eoe-randomness-state-create     = %x03
264/// eoe-deny-list-state-create      = %x04
265/// eoe-bridge-state-create         = %x05 digest
266/// eoe-bridge-committee-init       = %x06 u64
267/// eoe-store-execution-time-observations = %x07 stored-execution-time-observations
268/// ```
269#[derive(Clone, Debug, PartialEq, Eq)]
270#[cfg_attr(
271    feature = "serde",
272    derive(serde_derive::Serialize, serde_derive::Deserialize)
273)]
274#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
275#[non_exhaustive]
276pub enum EndOfEpochTransactionKind {
277    /// End the epoch and start the next one
278    ChangeEpoch(ChangeEpoch),
279
280    /// Create and initialize the authenticator object used for zklogin
281    AuthenticatorStateCreate,
282
283    /// Expire JWKs used for zklogin
284    AuthenticatorStateExpire(AuthenticatorStateExpire),
285
286    /// Create and initialize the randomness object
287    RandomnessStateCreate,
288
289    /// Create and initialize the deny list object
290    DenyListStateCreate,
291
292    /// Create and initialize the bridge object
293    BridgeStateCreate { chain_id: Digest },
294
295    /// Initialize the bridge committee
296    BridgeCommitteeInit { bridge_object_version: u64 },
297
298    /// Execution time observations from the committee to preserve cross epoch
299    StoreExecutionTimeObservations(ExecutionTimeObservations),
300
301    /// Create and initialize the accumulator root object
302    AccumulatorRootCreate,
303
304    /// Create and initialize the coin metadata registry object
305    CoinRegistryCreate,
306
307    /// Create and initialize the display metadata registry object
308    DisplayRegistryCreate,
309
310    /// Create and initialize the address alias state object
311    AddressAliasStateCreate,
312
313    /// Contains the end-of-epoch-computed storage cost for accumulator objects.
314    WriteAccumulatorStorageCost { storage_cost: u64 },
315
316    /// Create and initialize the forwarding address registry object
317    ForwardingAddressRegistryCreate,
318}
319
320/// Set of Execution Time Observations from the committee.
321///
322/// # BCS
323///
324/// The BCS serialized form for this type is defined by the following ABNF:
325///
326/// ```text
327/// stored-execution-time-observations =  %x00 v1-stored-execution-time-observations
328///
329/// v1-stored-execution-time-observations = (vec
330///                                          execution-time-observation-key
331///                                          (vec execution-time-observation)
332///                                         )
333/// ```
334#[derive(Debug, Hash, PartialEq, Eq, Clone)]
335#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
336#[cfg_attr(
337    feature = "serde",
338    derive(serde_derive::Serialize, serde_derive::Deserialize)
339)]
340#[non_exhaustive]
341pub enum ExecutionTimeObservations {
342    V1(
343        #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=1).lift()))]
344        Vec<(
345            ExecutionTimeObservationKey,
346            Vec<ValidatorExecutionTimeObservation>,
347        )>,
348    ),
349}
350
351/// An execution time observation from a particular validator
352///
353/// # BCS
354///
355/// The BCS serialized form for this type is defined by the following ABNF:
356///
357/// ```text
358/// execution-time-observation = bls-public-key duration
359/// duration =  u64 ; seconds
360///             u32 ; subsecond nanoseconds
361/// ```
362#[derive(Debug, Hash, PartialEq, Eq, Clone)]
363#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
364#[cfg_attr(
365    feature = "serde",
366    derive(serde_derive::Serialize, serde_derive::Deserialize)
367)]
368pub struct ValidatorExecutionTimeObservation {
369    pub validator: crate::Bls12381PublicKey,
370    #[cfg_attr(feature = "proptest", strategy(proptest::strategy::Strategy::prop_map(proptest::arbitrary::any::<u32>(), |x| std::time::Duration::from_millis(x.into()))))]
371    pub duration: std::time::Duration,
372}
373
374/// Key for an execution time observation
375///
376/// # BCS
377///
378/// The BCS serialized form for this type is defined by the following ABNF:
379///
380/// ```text
381/// execution-time-observation-key  =  %x00 move-entry-point
382///                                 =/ %x01 ; transfer-objects
383///                                 =/ %x02 ; split-coins
384///                                 =/ %x03 ; merge-coins
385///                                 =/ %x04 ; publish
386///                                 =/ %x05 ; make-move-vec
387///                                 =/ %x06 ; upgrade
388/// ValidatorExecutionTimeObservation
389/// move-entry-point = address string string (vec type-tag)
390/// ```
391#[derive(Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Clone)]
392#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
393#[cfg_attr(
394    feature = "serde",
395    derive(serde_derive::Serialize, serde_derive::Deserialize)
396)]
397#[non_exhaustive]
398pub enum ExecutionTimeObservationKey {
399    // Containts all the fields from `ProgrammableMoveCall` besides `arguments`.
400    MoveEntryPoint {
401        /// The package containing the module and function.
402        package: Address,
403        /// The specific module in the package containing the function.
404        module: String,
405        /// The function to be called.
406        function: String,
407        /// The type arguments to the function.
408        /// NOTE: This field is currently not populated.
409        #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=1).lift()))]
410        type_arguments: Vec<TypeTag>,
411    },
412    TransferObjects,
413    SplitCoins,
414    MergeCoins,
415    Publish, // special case: should not be used; we only use hard-coded estimate for this
416    MakeMoveVec,
417    Upgrade,
418}
419
420/// Expire old JWKs
421///
422/// # BCS
423///
424/// The BCS serialized form for this type is defined by the following ABNF:
425///
426/// ```text
427/// authenticator-state-expire = u64 u64
428/// ```
429#[derive(Clone, Debug, PartialEq, Eq)]
430#[cfg_attr(
431    feature = "serde",
432    derive(serde_derive::Serialize, serde_derive::Deserialize)
433)]
434#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
435pub struct AuthenticatorStateExpire {
436    /// expire JWKs that have a lower epoch than this
437    pub min_epoch: u64,
438
439    /// The initial version of the authenticator object that it was shared at.
440    pub authenticator_object_initial_shared_version: u64,
441}
442
443/// Update the set of valid JWKs
444///
445/// # BCS
446///
447/// The BCS serialized form for this type is defined by the following ABNF:
448///
449/// ```text
450/// authenticator-state-update = u64 ; epoch
451///                              u64 ; round
452///                              (vector active-jwk)
453///                              u64 ; initial version of the authenticator object
454/// ```
455#[derive(Clone, Debug, PartialEq, Eq)]
456#[cfg_attr(
457    feature = "serde",
458    derive(serde_derive::Serialize, serde_derive::Deserialize)
459)]
460#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
461pub struct AuthenticatorStateUpdate {
462    /// Epoch of the authenticator state update transaction
463    pub epoch: u64,
464
465    /// Consensus round of the authenticator state update
466    pub round: u64,
467
468    /// newly active jwks
469    #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=1).lift()))]
470    pub new_active_jwks: Vec<ActiveJwk>,
471
472    /// The initial version of the authenticator object that it was shared at.
473    pub authenticator_obj_initial_shared_version: u64,
474}
475
476/// A new Jwk
477///
478/// # BCS
479///
480/// The BCS serialized form for this type is defined by the following ABNF:
481///
482/// ```text
483/// active-jwk = jwk-id jwk u64
484/// ```
485#[derive(Clone, Debug, PartialEq, Eq)]
486#[cfg_attr(
487    feature = "serde",
488    derive(serde_derive::Serialize, serde_derive::Deserialize)
489)]
490#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
491pub struct ActiveJwk {
492    /// Identifier used to uniquely identify a Jwk
493    pub jwk_id: JwkId,
494
495    /// The Jwk
496    pub jwk: Jwk,
497
498    /// Most recent epoch in which the jwk was validated
499    pub epoch: u64,
500}
501
502/// V1 of the consensus commit prologue system transaction
503///
504/// # BCS
505///
506/// The BCS serialized form for this type is defined by the following ABNF:
507///
508/// ```text
509/// consensus-commit-prologue = u64 u64 u64
510/// ```
511#[derive(Clone, Debug, PartialEq, Eq)]
512#[cfg_attr(
513    feature = "serde",
514    derive(serde_derive::Serialize, serde_derive::Deserialize)
515)]
516#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
517pub struct ConsensusCommitPrologue {
518    /// Epoch of the commit prologue transaction
519    pub epoch: u64,
520
521    /// Consensus round of the commit
522    pub round: u64,
523
524    /// Unix timestamp from consensus
525    pub commit_timestamp_ms: CheckpointTimestamp,
526}
527
528/// V2 of the consensus commit prologue system transaction
529///
530/// # BCS
531///
532/// The BCS serialized form for this type is defined by the following ABNF:
533///
534/// ```text
535/// consensus-commit-prologue-v2 = u64 u64 u64 digest
536/// ```
537#[derive(Clone, Debug, PartialEq, Eq)]
538#[cfg_attr(
539    feature = "serde",
540    derive(serde_derive::Serialize, serde_derive::Deserialize)
541)]
542#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
543pub struct ConsensusCommitPrologueV2 {
544    /// Epoch of the commit prologue transaction
545    pub epoch: u64,
546
547    /// Consensus round of the commit
548    pub round: u64,
549
550    /// Unix timestamp from consensus
551    pub commit_timestamp_ms: CheckpointTimestamp,
552
553    /// Digest of consensus output
554    pub consensus_commit_digest: Digest,
555}
556
557/// Version assignments performed by consensus
558///
559/// # BCS
560///
561/// The BCS serialized form for this type is defined by the following ABNF:
562///
563/// ```text
564/// consensus-determined-version-assignments = canceled-transactions
565///
566/// canceled-transactions = %x00 (vector canceled-transaction)
567///                       = %x01 (vector canceled-transaction-v2)
568/// ```
569#[derive(Clone, Debug, PartialEq, Eq)]
570#[cfg_attr(
571    feature = "serde",
572    derive(serde_derive::Serialize, serde_derive::Deserialize)
573)]
574#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
575#[non_exhaustive]
576pub enum ConsensusDeterminedVersionAssignments {
577    /// Canceled transaction version assignment.
578    CanceledTransactions {
579        #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=1).lift()))]
580        canceled_transactions: Vec<CanceledTransaction>,
581    },
582    /// Canceled transaction version assignment V2.
583    CanceledTransactionsV2 {
584        #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=1).lift()))]
585        canceled_transactions: Vec<CanceledTransactionV2>,
586    },
587}
588
589/// A transaction that was canceled
590///
591/// # BCS
592///
593/// The BCS serialized form for this type is defined by the following ABNF:
594///
595/// ```text
596/// canceled-transaction = digest (vector version-assignment)
597/// ```
598#[derive(Clone, Debug, PartialEq, Eq)]
599#[cfg_attr(
600    feature = "serde",
601    derive(serde_derive::Serialize, serde_derive::Deserialize)
602)]
603#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
604pub struct CanceledTransaction {
605    pub digest: Digest,
606    #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))]
607    pub version_assignments: Vec<VersionAssignment>,
608}
609
610/// Object version assignment from consensus
611///
612/// # BCS
613///
614/// The BCS serialized form for this type is defined by the following ABNF:
615///
616/// ```text
617/// version-assignment = address u64
618/// ```
619#[derive(Clone, Debug, PartialEq, Eq)]
620#[cfg_attr(
621    feature = "serde",
622    derive(serde_derive::Serialize, serde_derive::Deserialize)
623)]
624#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
625pub struct VersionAssignment {
626    pub object_id: Address,
627    pub version: Version,
628}
629
630/// A transaction that was canceled
631///
632/// # BCS
633///
634/// The BCS serialized form for this type is defined by the following ABNF:
635///
636/// ```text
637/// canceled-transaction-v2 = digest (vector version-assignment-v2)
638/// ```
639#[derive(Clone, Debug, PartialEq, Eq)]
640#[cfg_attr(
641    feature = "serde",
642    derive(serde_derive::Serialize, serde_derive::Deserialize)
643)]
644#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
645pub struct CanceledTransactionV2 {
646    pub digest: Digest,
647    #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))]
648    pub version_assignments: Vec<VersionAssignmentV2>,
649}
650
651/// Object version assignment from consensus
652///
653/// # BCS
654///
655/// The BCS serialized form for this type is defined by the following ABNF:
656///
657/// ```text
658/// version-assignment-v2 = address u64 u64
659/// ```
660#[derive(Clone, Debug, PartialEq, Eq)]
661#[cfg_attr(
662    feature = "serde",
663    derive(serde_derive::Serialize, serde_derive::Deserialize)
664)]
665#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
666pub struct VersionAssignmentV2 {
667    pub object_id: Address,
668    pub start_version: Version,
669    pub version: Version,
670}
671
672/// V3 of the consensus commit prologue system transaction
673///
674/// # BCS
675///
676/// The BCS serialized form for this type is defined by the following ABNF:
677///
678/// ```text
679/// consensus-commit-prologue-v3 = u64 u64 (option u64) u64 digest
680///                                consensus-determined-version-assignments
681/// ```
682#[derive(Clone, Debug, PartialEq, Eq)]
683#[cfg_attr(
684    feature = "serde",
685    derive(serde_derive::Serialize, serde_derive::Deserialize)
686)]
687#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
688pub struct ConsensusCommitPrologueV3 {
689    /// Epoch of the commit prologue transaction
690    pub epoch: u64,
691
692    /// Consensus round of the commit
693    pub round: u64,
694
695    /// The sub DAG index of the consensus commit. This field will be populated if there
696    /// are multiple consensus commits per round.
697    pub sub_dag_index: Option<u64>,
698
699    /// Unix timestamp from consensus
700    pub commit_timestamp_ms: CheckpointTimestamp,
701
702    /// Digest of consensus output
703    pub consensus_commit_digest: Digest,
704
705    /// Stores consensus handler determined shared object version assignments.
706    pub consensus_determined_version_assignments: ConsensusDeterminedVersionAssignments,
707}
708
709/// V4 of the consensus commit prologue system transaction
710///
711/// # BCS
712///
713/// The BCS serialized form for this type is defined by the following ABNF:
714///
715/// ```text
716/// consensus-commit-prologue-v4 = u64 u64 (option u64) u64 digest
717///                                consensus-determined-version-assignments
718///                                digest
719/// ```
720#[derive(Clone, Debug, PartialEq, Eq)]
721#[cfg_attr(
722    feature = "serde",
723    derive(serde_derive::Serialize, serde_derive::Deserialize)
724)]
725#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
726pub struct ConsensusCommitPrologueV4 {
727    /// Epoch of the commit prologue transaction
728    pub epoch: u64,
729
730    /// Consensus round of the commit
731    pub round: u64,
732
733    /// The sub DAG index of the consensus commit. This field will be populated if there
734    /// are multiple consensus commits per round.
735    pub sub_dag_index: Option<u64>,
736
737    /// Unix timestamp from consensus
738    pub commit_timestamp_ms: CheckpointTimestamp,
739
740    /// Digest of consensus output
741    pub consensus_commit_digest: Digest,
742
743    /// Stores consensus handler determined shared object version assignments.
744    pub consensus_determined_version_assignments: ConsensusDeterminedVersionAssignments,
745
746    /// Digest of any additional state computed by the consensus handler.
747    /// Used to detect forking bugs as early as possible.
748    pub additional_state_digest: Digest,
749}
750
751/// System transaction used to change the epoch
752///
753/// # BCS
754///
755/// The BCS serialized form for this type is defined by the following ABNF:
756///
757/// ```text
758/// change-epoch = u64  ; next epoch
759///                u64  ; protocol version
760///                u64  ; storage charge
761///                u64  ; computation charge
762///                u64  ; storage rebate
763///                u64  ; non-refundable storage fee
764///                u64  ; epoch start timestamp
765///                (vector system-package)
766/// ```
767#[derive(Clone, Debug, PartialEq, Eq)]
768#[cfg_attr(
769    feature = "serde",
770    derive(serde_derive::Serialize, serde_derive::Deserialize)
771)]
772#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
773pub struct ChangeEpoch {
774    /// The next (to become) epoch ID.
775    pub epoch: EpochId,
776
777    /// The protocol version in effect in the new epoch.
778    pub protocol_version: ProtocolVersion,
779
780    /// The total amount of gas charged for storage during the epoch.
781    pub storage_charge: u64,
782
783    /// The total amount of gas charged for computation during the epoch.
784    pub computation_charge: u64,
785
786    /// The amount of storage rebate refunded to the txn senders.
787    pub storage_rebate: u64,
788
789    /// The non-refundable storage fee.
790    pub non_refundable_storage_fee: u64,
791
792    /// Unix timestamp when epoch started
793    pub epoch_start_timestamp_ms: u64,
794
795    /// System packages (specifically framework and move stdlib) that are written before the new
796    /// epoch starts. This tracks framework upgrades on chain. When executing the ChangeEpoch txn,
797    /// the validator must write out the modules below.  Modules are provided with the version they
798    /// will be upgraded to, their modules in serialized form (which include their package ID), and
799    /// a list of their transitive dependencies.
800    #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=1).lift()))]
801    pub system_packages: Vec<SystemPackage>,
802}
803
804/// System package
805///
806/// # BCS
807///
808/// The BCS serialized form for this type is defined by the following ABNF:
809///
810/// ```text
811/// system-package = u64                ; version
812///                  (vector bytes)     ; modules
813///                  (vector address) ; dependencies
814/// ```
815#[derive(Clone, Debug, PartialEq, Eq)]
816#[cfg_attr(
817    feature = "serde",
818    derive(serde_derive::Serialize, serde_derive::Deserialize)
819)]
820#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
821pub struct SystemPackage {
822    pub version: Version,
823    #[cfg_attr(
824        feature = "serde",
825        serde(
826            with = "::serde_with::As::<Vec<::serde_with::IfIsHumanReadable<crate::_serde::Base64Encoded, ::serde_with::Bytes>>>"
827        )
828    )]
829    #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=1).lift()))]
830    pub modules: Vec<Vec<u8>>,
831    #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=1).lift()))]
832    pub dependencies: Vec<Address>,
833}
834
835/// The genesis transaction
836///
837/// # BCS
838///
839/// The BCS serialized form for this type is defined by the following ABNF:
840///
841/// ```text
842/// genesis-transaction = (vector genesis-object)
843/// ```
844#[derive(Clone, Debug, PartialEq, Eq)]
845#[cfg_attr(
846    feature = "serde",
847    derive(serde_derive::Serialize, serde_derive::Deserialize)
848)]
849#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
850pub struct GenesisTransaction {
851    #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=1).lift()))]
852    pub objects: Vec<GenesisObject>,
853}
854
855/// A user transaction
856///
857/// Contains a series of native commands and move calls where the results of one command can be
858/// used in future commands.
859///
860/// # BCS
861///
862/// The BCS serialized form for this type is defined by the following ABNF:
863///
864/// ```text
865/// ptb = (vector input) (vector command)
866/// ```
867#[derive(Clone, Debug, PartialEq, Eq)]
868#[cfg_attr(
869    feature = "serde",
870    derive(serde_derive::Serialize, serde_derive::Deserialize)
871)]
872#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
873pub struct ProgrammableTransaction {
874    /// Input objects or primitive values
875    #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=10).lift()))]
876    pub inputs: Vec<Input>,
877
878    /// The commands to be executed sequentially. A failure in any command will
879    /// result in the failure of the entire transaction.
880    #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))]
881    pub commands: Vec<Command>,
882}
883
884/// An input to a user transaction
885///
886/// # BCS
887///
888/// The BCS serialized form for this type is defined by the following ABNF:
889///
890/// ```text
891/// input = input-pure / input-immutable-or-owned / input-shared / input-receiving
892///
893/// input-pure                  = %x00 bytes
894/// input-immutable-or-owned    = %x01 object-ref
895/// input-shared                = %x02 address u64 bool
896/// input-receiving             = %x04 object-ref
897/// ```
898#[derive(Clone, Debug, PartialEq, Eq)]
899#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
900#[non_exhaustive]
901pub enum Input {
902    /// A move value serialized as BCS.
903    ///
904    /// For normal operations this is required to be a move primitive type and not contain structs
905    /// or objects.
906    Pure(Vec<u8>),
907
908    /// A move object that is either immutable or address owned
909    ImmutableOrOwned(ObjectReference),
910
911    /// A move object whose owner is "Shared"
912    Shared(SharedInput),
913
914    /// A move object that is attempted to be received in this transaction.
915    Receiving(ObjectReference),
916
917    /// Reservation to withdraw balance from a funds accumulator. This will be converted into a
918    /// `sui::funds_accumulator::Withdrawal` struct and passed into Move.
919    /// It is allowed to have multiple withdraw arguments even for the same funds type.
920    FundsWithdrawal(FundsWithdrawal),
921}
922
923/// A move object whose owner is "Shared"
924#[derive(Clone, Debug, PartialEq, Eq)]
925#[cfg_attr(
926    feature = "serde",
927    derive(serde_derive::Serialize, serde_derive::Deserialize)
928)]
929#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
930pub struct SharedInput {
931    object_id: Address,
932    version: u64,
933    mutability: Mutability,
934}
935
936impl SharedInput {
937    pub fn new<M: Into<Mutability>>(object_id: Address, version: u64, mutable: M) -> Self {
938        Self {
939            object_id,
940            version,
941            mutability: mutable.into(),
942        }
943    }
944
945    pub fn object_id(&self) -> Address {
946        self.object_id
947    }
948
949    pub fn version(&self) -> u64 {
950        self.version
951    }
952
953    pub fn mutability(&self) -> Mutability {
954        self.mutability
955    }
956}
957
958#[derive(Copy, Clone, Debug, PartialEq, Eq)]
959#[cfg_attr(
960    feature = "serde",
961    derive(serde_derive::Serialize, serde_derive::Deserialize)
962)]
963#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
964pub enum Mutability {
965    // The "classic" mutable/immutable modes.
966    Immutable,
967    Mutable,
968    // Non-exclusive write is used to allow multiple transactions to
969    // simultaneously add disjoint dynamic fields to an object.
970    // (Currently only used by settlement transactions).
971    NonExclusiveWrite,
972}
973
974impl From<bool> for Mutability {
975    fn from(mutable: bool) -> Self {
976        if mutable {
977            Self::Mutable
978        } else {
979            Self::Immutable
980        }
981    }
982}
983
984impl Mutability {
985    pub fn is_mutable(self) -> bool {
986        match self {
987            Mutability::Immutable => false,
988            Mutability::Mutable => true,
989            Mutability::NonExclusiveWrite => false,
990        }
991    }
992}
993
994#[derive(Debug, PartialEq, Eq, Hash, Clone)]
995#[cfg_attr(
996    feature = "serde",
997    derive(serde_derive::Serialize, serde_derive::Deserialize)
998)]
999#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
1000#[non_exhaustive]
1001enum Reservation {
1002    // Reserve a specific amount of the balance.
1003    Amount(u64),
1004}
1005
1006#[derive(Debug, PartialEq, Eq, Hash, Clone)]
1007#[cfg_attr(
1008    feature = "serde",
1009    derive(serde_derive::Serialize, serde_derive::Deserialize)
1010)]
1011#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
1012#[non_exhaustive]
1013enum WithdrawalType {
1014    Balance(TypeTag),
1015}
1016
1017#[derive(Debug, PartialEq, Eq, Hash, Clone)]
1018#[cfg_attr(
1019    feature = "serde",
1020    derive(serde_derive::Serialize, serde_derive::Deserialize)
1021)]
1022#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
1023pub struct FundsWithdrawal {
1024    /// The reservation of the funds accumulator to withdraw.
1025    reservation: Reservation,
1026    /// The type argument of the funds accumulator to withdraw, e.g. `Balance<_>`.
1027    type_: WithdrawalType,
1028    /// The source of the funds to withdraw.
1029    source: WithdrawFrom,
1030}
1031
1032impl FundsWithdrawal {
1033    pub fn new(amount: u64, coin_type: TypeTag, source: WithdrawFrom) -> Self {
1034        Self {
1035            reservation: Reservation::Amount(amount),
1036            type_: WithdrawalType::Balance(coin_type),
1037            source,
1038        }
1039    }
1040
1041    pub fn amount(&self) -> Option<u64> {
1042        match self.reservation {
1043            Reservation::Amount(amount) => Some(amount),
1044        }
1045    }
1046
1047    pub fn coin_type(&self) -> &TypeTag {
1048        match &self.type_ {
1049            WithdrawalType::Balance(coin_type) => coin_type,
1050        }
1051    }
1052
1053    pub fn source(&self) -> WithdrawFrom {
1054        self.source
1055    }
1056}
1057
1058/// The source of the funds for a [`FundsWithdrawal`].
1059///
1060/// # BCS
1061///
1062/// The BCS serialized form for this type is defined by the following ABNF:
1063///
1064/// ```text
1065/// withdraw-from =  withdraw-from-sender
1066///               =/ withdraw-from-sponsor
1067///               =/ withdraw-from-allowance
1068///
1069/// withdraw-from-sender    = %x00
1070/// withdraw-from-sponsor   = %x01
1071/// withdraw-from-allowance = %x02 address address
1072/// ```
1073#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
1074#[cfg_attr(
1075    feature = "serde",
1076    derive(serde_derive::Serialize, serde_derive::Deserialize)
1077)]
1078#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
1079#[non_exhaustive]
1080pub enum WithdrawFrom {
1081    /// Withdraw from the sender of the transaction.
1082    Sender,
1083    /// Withdraw from the sponsor of the transaction (gas owner).
1084    Sponsor,
1085    /// Withdraw from `funder`'s balance under the given allowance object.
1086    ///
1087    /// The funder is declared in the transaction so that the debited account is derivable from
1088    /// the transaction alone; signing verifies it against the (immutable) allowance object.
1089    Allowance {
1090        /// The address whose balance is debited.
1091        funder: Address,
1092        /// The `ObjectId` of the allowance object authorizing the withdrawal.
1093        allowance: Address,
1094    },
1095}
1096
1097/// A single command in a programmable transaction.
1098///
1099/// # BCS
1100///
1101/// The BCS serialized form for this type is defined by the following ABNF:
1102///
1103/// ```text
1104/// command =  command-move-call
1105///         =/ command-transfer-objects
1106///         =/ command-split-coins
1107///         =/ command-merge-coins
1108///         =/ command-publish
1109///         =/ command-make-move-vector
1110///         =/ command-upgrade
1111///
1112/// command-move-call           = %x00 move-call
1113/// command-transfer-objects    = %x01 transfer-objects
1114/// command-split-coins         = %x02 split-coins
1115/// command-merge-coins         = %x03 merge-coins
1116/// command-publish             = %x04 publish
1117/// command-make-move-vector    = %x05 make-move-vector
1118/// command-upgrade             = %x06 upgrade
1119/// ```
1120#[derive(Clone, Debug, PartialEq, Eq)]
1121#[cfg_attr(
1122    feature = "serde",
1123    derive(serde_derive::Serialize, serde_derive::Deserialize)
1124)]
1125#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
1126#[non_exhaustive]
1127pub enum Command {
1128    /// A call to either an entry or a public Move function
1129    MoveCall(MoveCall),
1130
1131    /// `(Vec<forall T:key+store. T>, address)`
1132    /// It sends n-objects to the specified address. These objects must have store
1133    /// (public transfer) and either the previous owner must be an address or the object must
1134    /// be newly created.
1135    TransferObjects(TransferObjects),
1136
1137    /// `(&mut Coin<T>, Vec<u64>)` -> `Vec<Coin<T>>`
1138    /// It splits off some amounts into a new coins with those amounts
1139    SplitCoins(SplitCoins),
1140
1141    /// `(&mut Coin<T>, Vec<Coin<T>>)`
1142    /// It merges n-coins into the first coin
1143    MergeCoins(MergeCoins),
1144
1145    /// Publishes a Move package. It takes the package bytes and a list of the package's transitive
1146    /// dependencies to link against on-chain.
1147    Publish(Publish),
1148
1149    /// `forall T: Vec<T> -> vector<T>`
1150    /// Given n-values of the same type, it constructs a vector. For non objects or an empty vector,
1151    /// the type tag must be specified.
1152    MakeMoveVector(MakeMoveVector),
1153
1154    /// Upgrades a Move package
1155    /// Takes (in order):
1156    /// 1. A vector of serialized modules for the package.
1157    /// 2. A vector of object ids for the transitive dependencies of the new package.
1158    /// 3. The object ID of the package being upgraded.
1159    /// 4. An argument holding the `UpgradeTicket` that must have been produced from an earlier command in the same
1160    ///    programmable transaction.
1161    Upgrade(Upgrade),
1162}
1163
1164/// Command to transfer ownership of a set of objects to an address
1165///
1166/// # BCS
1167///
1168/// The BCS serialized form for this type is defined by the following ABNF:
1169///
1170/// ```text
1171/// transfer-objects = (vector argument) argument
1172/// ```
1173#[derive(Clone, Debug, PartialEq, Eq)]
1174#[cfg_attr(
1175    feature = "serde",
1176    derive(serde_derive::Serialize, serde_derive::Deserialize)
1177)]
1178#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
1179pub struct TransferObjects {
1180    /// Set of objects to transfer
1181    #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))]
1182    pub objects: Vec<Argument>,
1183
1184    /// The address to transfer ownership to
1185    pub address: Argument,
1186}
1187
1188/// Command to split a single coin object into multiple coins
1189///
1190/// # BCS
1191///
1192/// The BCS serialized form for this type is defined by the following ABNF:
1193///
1194/// ```text
1195/// split-coins = argument (vector argument)
1196/// ```
1197#[derive(Clone, Debug, PartialEq, Eq)]
1198#[cfg_attr(
1199    feature = "serde",
1200    derive(serde_derive::Serialize, serde_derive::Deserialize)
1201)]
1202#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
1203pub struct SplitCoins {
1204    /// The coin to split
1205    pub coin: Argument,
1206
1207    /// The amounts to split off
1208    #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))]
1209    pub amounts: Vec<Argument>,
1210}
1211
1212/// Command to merge multiple coins of the same type into a single coin
1213///
1214/// # BCS
1215///
1216/// The BCS serialized form for this type is defined by the following ABNF:
1217///
1218/// ```text
1219/// merge-coins = argument (vector argument)
1220/// ```
1221#[derive(Clone, Debug, PartialEq, Eq)]
1222#[cfg_attr(
1223    feature = "serde",
1224    derive(serde_derive::Serialize, serde_derive::Deserialize)
1225)]
1226#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
1227pub struct MergeCoins {
1228    /// Coin to merge coins into
1229    pub coin: Argument,
1230
1231    /// Set of coins to merge into `coin`
1232    ///
1233    /// All listed coins must be of the same type and be the same type as `coin`
1234    #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))]
1235    pub coins_to_merge: Vec<Argument>,
1236}
1237
1238/// Command to publish a new move package
1239///
1240/// # BCS
1241///
1242/// The BCS serialized form for this type is defined by the following ABNF:
1243///
1244/// ```text
1245/// publish = (vector bytes)        ; the serialized move modules
1246///           (vector address)    ; the set of package dependencies
1247/// ```
1248#[derive(Clone, Debug, PartialEq, Eq)]
1249#[cfg_attr(
1250    feature = "serde",
1251    derive(serde_derive::Serialize, serde_derive::Deserialize)
1252)]
1253#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
1254pub struct Publish {
1255    /// The serialized move modules
1256    #[cfg_attr(
1257        feature = "serde",
1258        serde(
1259            with = "::serde_with::As::<Vec<::serde_with::IfIsHumanReadable<crate::_serde::Base64Encoded, ::serde_with::Bytes>>>"
1260        )
1261    )]
1262    pub modules: Vec<Vec<u8>>,
1263
1264    /// Set of packages that the to-be published package depends on
1265    #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))]
1266    pub dependencies: Vec<Address>,
1267}
1268
1269/// Command to build a move vector out of a set of individual elements
1270///
1271/// # BCS
1272///
1273/// The BCS serialized form for this type is defined by the following ABNF:
1274///
1275/// ```text
1276/// make-move-vector = (option type-tag) (vector argument)
1277/// ```
1278#[derive(Clone, Debug, PartialEq, Eq)]
1279#[cfg_attr(
1280    feature = "serde",
1281    derive(serde_derive::Serialize, serde_derive::Deserialize)
1282)]
1283#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
1284pub struct MakeMoveVector {
1285    /// Type of the individual elements
1286    ///
1287    /// This is required to be set when the type can't be inferred, for example when the set of
1288    /// provided arguments are all pure input values.
1289    #[cfg_attr(feature = "serde", serde(rename = "type"))]
1290    pub type_: Option<TypeTag>,
1291
1292    /// The set individual elements to build the vector with
1293    #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))]
1294    pub elements: Vec<Argument>,
1295}
1296
1297/// Command to upgrade an already published package
1298///
1299/// # BCS
1300///
1301/// The BCS serialized form for this type is defined by the following ABNF:
1302///
1303/// ```text
1304/// upgrade = (vector bytes)        ; move modules
1305///           (vector address)    ; dependencies
1306///           address             ; package-id of the package
1307///           argument              ; upgrade ticket
1308/// ```
1309#[derive(Clone, Debug, PartialEq, Eq)]
1310#[cfg_attr(
1311    feature = "serde",
1312    derive(serde_derive::Serialize, serde_derive::Deserialize)
1313)]
1314#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
1315pub struct Upgrade {
1316    /// The serialized move modules
1317    #[cfg_attr(
1318        feature = "serde",
1319        serde(
1320            with = "::serde_with::As::<Vec<::serde_with::IfIsHumanReadable<crate::_serde::Base64Encoded, ::serde_with::Bytes>>>"
1321        )
1322    )]
1323    #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=1).lift()))]
1324    pub modules: Vec<Vec<u8>>,
1325
1326    /// Set of packages that the to-be published package depends on
1327    #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))]
1328    pub dependencies: Vec<Address>,
1329
1330    /// Package id of the package to upgrade
1331    pub package: Address,
1332
1333    /// Ticket authorizing the upgrade
1334    pub ticket: Argument,
1335}
1336
1337/// An argument to a programmable transaction command
1338///
1339/// # BCS
1340///
1341/// The BCS serialized form for this type is defined by the following ABNF:
1342///
1343/// ```text
1344/// argument    =  argument-gas
1345///             =/ argument-input
1346///             =/ argument-result
1347///             =/ argument-nested-result
1348///
1349/// argument-gas            = %x00
1350/// argument-input          = %x01 u16
1351/// argument-result         = %x02 u16
1352/// argument-nested-result  = %x03 u16 u16
1353/// ```
1354#[derive(Clone, Copy, Debug, PartialEq, Eq)]
1355#[cfg_attr(
1356    feature = "serde",
1357    derive(serde_derive::Serialize, serde_derive::Deserialize)
1358)]
1359#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
1360pub enum Argument {
1361    /// The gas coin. The gas coin can only be used by-ref, except for with
1362    /// `TransferObjects`, which can use it by-value.
1363    Gas,
1364
1365    /// One of the input objects or primitive values (from
1366    /// `ProgrammableTransaction` inputs)
1367    Input(u16),
1368
1369    /// The result of another command (from `ProgrammableTransaction` commands)
1370    Result(u16),
1371
1372    /// Like a `Result` but it accesses a nested result. Currently, the only usage
1373    /// of this is to access a value from a Move call with multiple return values.
1374    // (command index, subresult index)
1375    NestedResult(u16, u16),
1376}
1377
1378impl Argument {
1379    /// Turn a Result into a NestedResult. If the argument is not a Result, returns None.
1380    pub fn nested(&self, ix: u16) -> Option<Argument> {
1381        match self {
1382            Argument::Result(i) => Some(Argument::NestedResult(*i, ix)),
1383            _ => None,
1384        }
1385    }
1386}
1387
1388/// Command to call a move function
1389///
1390/// Functions that can be called by a `MoveCall` command are those that have a function signature
1391/// that is either `entry` or `public` (which don't have a reference return type).
1392///
1393/// # BCS
1394///
1395/// The BCS serialized form for this type is defined by the following ABNF:
1396///
1397/// ```text
1398/// move-call = address           ; package id
1399///             identifier          ; module name
1400///             identifier          ; function name
1401///             (vector type-tag)   ; type arguments, if any
1402///             (vector argument)   ; input arguments
1403/// ```
1404#[derive(Clone, Debug, PartialEq, Eq)]
1405#[cfg_attr(
1406    feature = "serde",
1407    derive(serde_derive::Serialize, serde_derive::Deserialize)
1408)]
1409#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
1410pub struct MoveCall {
1411    /// The package containing the module and function.
1412    pub package: Address,
1413
1414    /// The specific module in the package containing the function.
1415    pub module: Identifier,
1416
1417    /// The function to be called.
1418    pub function: Identifier,
1419
1420    /// The type arguments to the function.
1421    #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))]
1422    pub type_arguments: Vec<TypeTag>,
1423
1424    /// The arguments to the function.
1425    #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))]
1426    pub arguments: Vec<Argument>,
1427}