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