1use super::{
6 Address, CheckpointTimestamp, Digest, EpochId, Event, GenesisObject, Identifier, Jwk, JwkId,
7 ObjectId, ObjectReference, ProtocolVersion, TypeTag, UserSignature, Version,
8};
9
10#[cfg(feature = "serde")]
11#[cfg_attr(doc_cfg, doc(cfg(feature = "serde")))]
12mod serialization;
13#[cfg(feature = "serde")]
14#[cfg_attr(doc_cfg, doc(cfg(feature = "serde")))]
15pub(crate) use serialization::SignedTransactionWithIntentMessage;
16
17#[derive(Clone, Debug, PartialEq, Eq)]
29#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
30#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
31#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
32pub enum Transaction {
33 #[cfg_attr(feature = "serde", serde(rename = "1"))]
34 V1(TransactionV1),
35 }
38
39impl Transaction {
40 crate::def_is_as_into_opt!(V1(TransactionV1));
41}
42
43impl From<TransactionV1> for Transaction {
44 fn from(v1: TransactionV1) -> Self {
45 Transaction::V1(v1)
46 }
47}
48
49#[derive(Debug, PartialEq, Eq, Clone)]
50#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
51#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
52#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
53pub struct TransactionV1 {
54 pub kind: TransactionKind,
55 pub sender: Address,
56 pub gas_payment: GasPayment,
57 pub expiration: TransactionExpiration,
58}
59
60#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
61pub struct SenderSignedTransaction(
62 #[cfg_attr(
63 feature = "serde",
64 serde(with = "::serde_with::As::<crate::_serde::SignedTransactionWithIntentMessage>")
65 )]
66 pub SignedTransaction,
67);
68
69#[derive(Clone, Debug, PartialEq, Eq)]
70#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
71#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
72#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
73pub struct SignedTransaction {
74 pub transaction: Transaction,
75 pub signatures: Vec<UserSignature>,
76}
77
78#[derive(Clone, Copy, Default, Debug, PartialEq, Eq, Hash)]
89#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
90pub enum TransactionExpiration {
91 #[default]
93 None,
94 Epoch(EpochId),
97}
98
99impl TransactionExpiration {
100 crate::def_is!(None);
101
102 crate::def_is_as_into_opt!(Epoch(EpochId));
103}
104
105#[derive(Clone, Debug, PartialEq, Eq)]
118#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
119#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
120#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
121pub struct GasPayment {
122 pub objects: Vec<ObjectReference>,
123 pub owner: Address,
125 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
130 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
131 pub price: u64,
132 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
134 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
135 pub budget: u64,
136}
137
138#[derive(Clone, Debug, PartialEq, Eq)]
148#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
149#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
150#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
151pub struct RandomnessStateUpdate {
152 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
154 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
155 pub epoch: u64,
156 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
158 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
159 pub randomness_round: u64,
160 #[cfg_attr(
162 feature = "serde",
163 serde(with = "crate::_serde::ReadableBase64Encoded")
164 )]
165 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::Base64"))]
166 pub random_bytes: Vec<u8>,
167 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
169 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
170 pub randomness_obj_initial_shared_version: u64,
171}
172
173#[derive(Clone, Debug, PartialEq, Eq)]
191#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
192pub enum TransactionKind {
193 ProgrammableTransaction(ProgrammableTransaction),
195 Genesis(GenesisTransaction),
200 ConsensusCommitPrologueV1(ConsensusCommitPrologueV1),
202 AuthenticatorStateUpdateV1(AuthenticatorStateUpdateV1),
204 EndOfEpoch(Vec<EndOfEpochTransactionKind>),
207 RandomnessStateUpdate(RandomnessStateUpdate),
209}
210
211impl TransactionKind {
212 crate::def_is_as_into_opt! {
213 ProgrammableTransaction,
214 ConsensusCommitPrologueV1,
215 AuthenticatorStateUpdateV1,
216 RandomnessStateUpdate,
217 }
218
219 crate::def_is_as_into_opt! {
220 Genesis(GenesisTransaction),
221 EndOfEpoch(Vec<EndOfEpochTransactionKind>),
222 }
223}
224
225#[derive(Clone, Debug, PartialEq, Eq)]
251#[cfg_attr(
252 feature = "schemars",
253 derive(schemars::JsonSchema),
254 schemars(tag = "kind", rename_all = "snake_case")
255)]
256#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
257pub enum EndOfEpochTransactionKind {
258 ChangeEpoch(ChangeEpoch),
260 ChangeEpochV2(ChangeEpochV2),
262 ChangeEpochV3(ChangeEpochV3),
264 AuthenticatorStateCreate,
266 AuthenticatorStateExpire(AuthenticatorStateExpire),
268}
269
270impl EndOfEpochTransactionKind {
271 crate::def_is!(AuthenticatorStateCreate);
272
273 crate::def_is_as_into_opt!(ChangeEpoch, ChangeEpochV2, AuthenticatorStateExpire);
274}
275
276#[derive(Debug, Hash, PartialEq, Eq, Clone)]
291#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
292#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
293#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
294pub enum ExecutionTimeObservations {
295 V1(Vec<ExecutionTimeObservation>),
296}
297
298impl ExecutionTimeObservations {
299 crate::def_is_as_into_opt!(V1(Vec<ExecutionTimeObservation>));
300}
301
302#[derive(Debug, Hash, PartialEq, Eq, Clone)]
303#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
304#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
305#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
306pub struct ExecutionTimeObservation {
307 pub key: ExecutionTimeObservationKey,
308 pub observations: Vec<ValidatorExecutionTimeObservation>,
309}
310
311#[derive(Debug, Hash, PartialEq, Eq, Clone)]
323#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
324#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
325#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
326pub struct ValidatorExecutionTimeObservation {
327 pub validator: crate::Bls12381PublicKey,
328 pub duration: std::time::Duration,
329}
330
331#[derive(Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Clone)]
349#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
350#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
351#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
352pub enum ExecutionTimeObservationKey {
353 MoveEntryPoint {
355 package: ObjectId,
357 module: String,
359 function: String,
361 type_arguments: Vec<TypeTag>,
364 },
365 TransferObjects,
366 SplitCoins,
367 MergeCoins,
368 Publish, MakeMoveVec,
370 Upgrade,
371}
372
373impl ExecutionTimeObservationKey {
374 crate::def_is!(
375 MoveEntryPoint,
376 TransferObjects,
377 SplitCoins,
378 MergeCoins,
379 Publish,
380 MakeMoveVec,
381 Upgrade,
382 );
383}
384
385#[derive(Clone, Debug, PartialEq, Eq)]
395#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
396#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
397#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
398pub struct AuthenticatorStateExpire {
399 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
401 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
402 pub min_epoch: u64,
403 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
405 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
406 pub authenticator_obj_initial_shared_version: u64,
407}
408
409#[derive(Clone, Debug, PartialEq, Eq)]
422#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
423#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
424#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
425pub struct AuthenticatorStateUpdateV1 {
426 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
428 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
429 pub epoch: u64,
430 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
432 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
433 pub round: u64,
434 pub new_active_jwks: Vec<ActiveJwk>,
436 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
438 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
439 pub authenticator_obj_initial_shared_version: u64,
440}
441
442#[derive(Clone, Debug, PartialEq, Eq)]
452#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
453#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
454#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
455pub struct ActiveJwk {
456 pub jwk_id: JwkId,
458 pub jwk: Jwk,
460 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
462 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
463 pub epoch: u64,
464}
465
466#[derive(Clone, Debug, PartialEq, Eq)]
467#[cfg_attr(
468 feature = "schemars",
469 derive(schemars::JsonSchema),
470 schemars(tag = "kind", rename_all = "snake_case")
471)]
472#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
473pub enum ConsensusDeterminedVersionAssignments {
474 CancelledTransactions {
476 #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))]
477 cancelled_transactions: Vec<CancelledTransaction>,
478 },
479}
480
481impl ConsensusDeterminedVersionAssignments {
482 crate::def_is!(CancelledTransactions);
483
484 pub fn as_cancelled_transactions(&self) -> &[CancelledTransaction] {
485 let Self::CancelledTransactions {
486 cancelled_transactions,
487 } = self;
488 cancelled_transactions
489 }
490}
491
492#[derive(Clone, Debug, PartialEq, Eq)]
502#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
503#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
504#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
505pub struct CancelledTransaction {
506 pub digest: Digest,
507 #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))]
508 pub version_assignments: Vec<VersionAssignment>,
509}
510
511#[derive(Clone, Debug, PartialEq, Eq)]
521#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
522#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
523#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
524pub struct VersionAssignment {
525 pub object_id: ObjectId,
526 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
527 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
528 pub version: Version,
529}
530
531#[derive(Clone, Debug, PartialEq, Eq)]
542#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
543#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
544#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
545pub struct ConsensusCommitPrologueV1 {
546 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
548 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
549 pub epoch: u64,
550 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
552 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
553 pub round: u64,
554 #[cfg_attr(
557 feature = "serde",
558 serde(with = "crate::_serde::OptionReadableDisplay")
559 )]
560 #[cfg_attr(feature = "schemars", schemars(with = "Option<crate::_schemars::U64>"))]
561 pub sub_dag_index: Option<u64>,
562 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
564 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
565 pub commit_timestamp_ms: CheckpointTimestamp,
566 pub consensus_commit_digest: Digest,
568 pub consensus_determined_version_assignments: ConsensusDeterminedVersionAssignments,
570}
571
572#[derive(Clone, Debug, PartialEq, Eq)]
589#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
590#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
591#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
592pub struct ChangeEpoch {
593 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
595 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
596 pub epoch: EpochId,
597 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
599 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
600 pub protocol_version: ProtocolVersion,
601 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
603 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
604 pub storage_charge: u64,
605 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
607 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
608 pub computation_charge: u64,
609 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
611 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
612 pub storage_rebate: u64,
613 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
615 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
616 pub non_refundable_storage_fee: u64,
617 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
619 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
620 pub epoch_start_timestamp_ms: u64,
621 #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))]
628 pub system_packages: Vec<SystemPackage>,
629}
630
631#[derive(Clone, Debug, PartialEq, Eq)]
649#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
650#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
651#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
652pub struct ChangeEpochV2 {
653 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
655 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
656 pub epoch: EpochId,
657 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
659 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
660 pub protocol_version: ProtocolVersion,
661 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
663 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
664 pub storage_charge: u64,
665 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
667 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
668 pub computation_charge: u64,
669 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
671 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
672 pub computation_charge_burned: u64,
673 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
675 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
676 pub storage_rebate: u64,
677 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
679 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
680 pub non_refundable_storage_fee: u64,
681 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
683 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
684 pub epoch_start_timestamp_ms: u64,
685 #[cfg_attr(test, any(proptest::collection::size_range(0..=2).lift()))]
692 pub system_packages: Vec<SystemPackage>,
693}
694
695#[derive(Clone, Debug, PartialEq, Eq)]
696#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
697#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
698#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
699pub struct ChangeEpochV3 {
700 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
702 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
703 pub epoch: EpochId,
704 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
706 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
707 pub protocol_version: ProtocolVersion,
708 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
710 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
711 pub storage_charge: u64,
712 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
714 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
715 pub computation_charge: u64,
716 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
718 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
719 pub computation_charge_burned: u64,
720 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
722 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
723 pub storage_rebate: u64,
724 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
726 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
727 pub non_refundable_storage_fee: u64,
728 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
730 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
731 pub epoch_start_timestamp_ms: u64,
732 #[cfg_attr(test, any(proptest::collection::size_range(0..=2).lift()))]
739 pub system_packages: Vec<SystemPackage>,
740 pub eligible_active_validators: Vec<u64>,
743}
744
745#[derive(Clone, Debug, PartialEq, Eq)]
746#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
747#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
748#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
749pub struct SystemPackage {
750 #[cfg_attr(feature = "serde", serde(with = "crate::_serde::ReadableDisplay"))]
751 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
752 pub version: Version,
753 #[cfg_attr(
754 feature = "serde",
755 serde(
756 with = "::serde_with::As::<Vec<::serde_with::IfIsHumanReadable<crate::_serde::Base64Encoded, ::serde_with::Bytes>>>"
757 )
758 )]
759 #[cfg_attr(feature = "schemars", schemars(with = "Vec<crate::_schemars::Base64>"))]
760 #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))]
761 pub modules: Vec<Vec<u8>>,
762 pub dependencies: Vec<ObjectId>,
763}
764
765#[derive(Clone, Debug, PartialEq, Eq)]
775#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
776#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
777#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
778pub struct GenesisTransaction {
779 #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))]
780 pub objects: Vec<GenesisObject>,
781 #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=10).lift()))]
782 pub events: Vec<Event>,
783}
784
785#[derive(Clone, Debug, PartialEq, Eq)]
798#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
799#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
800#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
801pub struct ProgrammableTransaction {
802 #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=10).lift()))]
804 pub inputs: Vec<Input>,
805 #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=10).lift()))]
808 pub commands: Vec<Command>,
809}
810
811#[derive(Clone, Debug, PartialEq, Eq, Hash)]
826#[cfg_attr(
827 feature = "schemars",
828 derive(schemars::JsonSchema),
829 schemars(tag = "type", rename_all = "snake_case")
830)]
831#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
832pub enum Input {
833 Pure {
838 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::Base64"))]
839 value: Vec<u8>,
840 },
841 ImmutableOrOwned(ObjectReference),
843 Shared {
845 object_id: ObjectId,
846 #[cfg_attr(feature = "schemars", schemars(with = "crate::_schemars::U64"))]
847 initial_shared_version: u64,
848 mutable: bool,
851 },
852 Receiving(ObjectReference),
855}
856
857impl Input {
858 crate::def_is!(Pure, Shared);
859
860 crate::def_is_as_into_opt!(
861 ImmutableOrOwned(ObjectReference),
862 Receiving(ObjectReference)
863 );
864}
865
866#[derive(Clone, Debug, PartialEq, Eq)]
890#[cfg_attr(
891 feature = "schemars",
892 derive(schemars::JsonSchema),
893 schemars(tag = "command", rename_all = "snake_case")
894)]
895#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
896pub enum Command {
897 MoveCall(MoveCall),
899 TransferObjects(TransferObjects),
904 SplitCoins(SplitCoins),
907 MergeCoins(MergeCoins),
910 Publish(Publish),
913 MakeMoveVector(MakeMoveVector),
917 Upgrade(Upgrade),
926}
927
928impl Command {
929 crate::def_is_as_into_opt!(
930 MoveCall,
931 TransferObjects,
932 SplitCoins,
933 MergeCoins,
934 Publish,
935 MakeMoveVector,
936 Upgrade,
937 );
938}
939
940#[derive(Clone, Debug, PartialEq, Eq)]
950#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
951#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
952#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
953pub struct TransferObjects {
954 #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))]
956 pub objects: Vec<Argument>,
957 pub address: Argument,
959}
960
961#[derive(Clone, Debug, PartialEq, Eq)]
971#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
972#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
973#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
974pub struct SplitCoins {
975 pub coin: Argument,
977 #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))]
979 pub amounts: Vec<Argument>,
980}
981
982#[derive(Clone, Debug, PartialEq, Eq)]
992#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
993#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
994#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
995pub struct MergeCoins {
996 pub coin: Argument,
998 #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))]
1002 pub coins_to_merge: Vec<Argument>,
1003}
1004
1005#[derive(Clone, Debug, PartialEq, Eq)]
1016#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1017#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
1018#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
1019pub struct Publish {
1020 #[cfg_attr(
1022 feature = "serde",
1023 serde(
1024 with = "::serde_with::As::<Vec<::serde_with::IfIsHumanReadable<crate::_serde::Base64Encoded, ::serde_with::Bytes>>>"
1025 )
1026 )]
1027 #[cfg_attr(feature = "schemars", schemars(with = "Vec<crate::_schemars::Base64>"))]
1028 pub modules: Vec<Vec<u8>>,
1029 pub dependencies: Vec<ObjectId>,
1031}
1032
1033#[derive(Clone, Debug, PartialEq, Eq)]
1043#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1044#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
1045#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
1046pub struct MakeMoveVector {
1047 #[cfg_attr(feature = "serde", serde(rename = "type"))]
1052 pub type_: Option<TypeTag>,
1053 #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))]
1055 pub elements: Vec<Argument>,
1056}
1057
1058#[derive(Clone, Debug, PartialEq, Eq)]
1071#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1072#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
1073#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
1074pub struct Upgrade {
1075 #[cfg_attr(
1077 feature = "serde",
1078 serde(
1079 with = "::serde_with::As::<Vec<::serde_with::IfIsHumanReadable<crate::_serde::Base64Encoded, ::serde_with::Bytes>>>"
1080 )
1081 )]
1082 #[cfg_attr(feature = "schemars", schemars(with = "Vec<crate::_schemars::Base64>"))]
1083 pub modules: Vec<Vec<u8>>,
1084 pub dependencies: Vec<ObjectId>,
1086 pub package: ObjectId,
1088 pub ticket: Argument,
1090}
1091
1092#[derive(Clone, Copy, Debug, PartialEq, Eq)]
1110#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
1111pub enum Argument {
1112 Gas,
1115 Input(u16),
1118 Result(u16),
1120 NestedResult(u16, u16),
1125}
1126
1127impl Argument {
1128 crate::def_is!(Gas, Input, Result, NestedResult);
1129
1130 pub fn as_input_opt(&self) -> Option<u16> {
1131 if let Self::Input(idx) = self {
1132 Some(*idx)
1133 } else {
1134 None
1135 }
1136 }
1137
1138 pub fn as_input(&self) -> u16 {
1139 self.as_input_opt().expect("not an input")
1140 }
1141
1142 pub fn as_result_opt(&self) -> Option<u16> {
1143 if let Self::Result(idx) = self {
1144 Some(*idx)
1145 } else {
1146 None
1147 }
1148 }
1149
1150 pub fn as_result(&self) -> u16 {
1151 self.as_result_opt().expect("not a result")
1152 }
1153
1154 pub fn as_nested_result_opt(&self) -> Option<(u16, u16)> {
1155 if let Self::NestedResult(idx0, idx1) = self {
1156 Some((*idx0, *idx1))
1157 } else {
1158 None
1159 }
1160 }
1161
1162 pub fn as_nested_result(&self) -> (u16, u16) {
1163 self.as_nested_result_opt().expect("not a nested result")
1164 }
1165
1166 pub fn get_nested_result(&self, ix: u16) -> Option<Argument> {
1169 match self {
1170 Argument::Result(i) => Some(Argument::NestedResult(*i, ix)),
1171 _ => None,
1172 }
1173 }
1174}
1175
1176#[derive(Clone, Debug, PartialEq, Eq)]
1194#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1195#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
1196#[cfg_attr(feature = "proptest", derive(test_strategy::Arbitrary))]
1197pub struct MoveCall {
1198 pub package: ObjectId,
1200 pub module: Identifier,
1202 pub function: Identifier,
1204 #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))]
1206 pub type_arguments: Vec<TypeTag>,
1207 #[cfg_attr(feature = "proptest", any(proptest::collection::size_range(0..=2).lift()))]
1209 pub arguments: Vec<Argument>,
1210}