sui_types/
sui_sdk_types_conversions.rs

1// Copyright (c) Mysten Labs, Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4//! Module for conversions between sui-core types and sui-sdk types
5//!
6//! For now this module makes heavy use of the `bcs_convert_impl` macro to implement the `From` trait
7//! for converting between core and external sdk types, relying on the fact that the BCS format of
8//! these types are strictly identical. As time goes on we'll slowly hand implement these impls
9//! directly to avoid going through the BCS machinery.
10
11use fastcrypto::traits::ToFromBytes;
12use sui_sdk_types::{
13    self, AccumulatorWrite, ActiveJwk, Address, Argument, AuthenticatorStateExpire, Bitmap,
14    Bls12381PublicKey, Bls12381Signature, CanceledTransaction, CanceledTransactionV2, ChangeEpoch,
15    CheckpointCommitment, CheckpointContents, CheckpointData, CheckpointSummary, Command,
16    CommandArgumentError, ConsensusDeterminedVersionAssignments, Digest, Ed25519PublicKey,
17    Ed25519Signature, EndOfEpochTransactionKind, ExecutionError, ExecutionStatus,
18    ExecutionTimeObservationKey, ExecutionTimeObservations, FundsWithdrawal, IdOperation,
19    Identifier, Input, Jwk, JwkId, MakeMoveVector, MergeCoins, MoveCall, MoveLocation, MovePackage,
20    MultisigMemberPublicKey, MultisigMemberSignature, Mutability, Object, ObjectIn, ObjectOut,
21    ObjectReference, Owner, PackageUpgradeError, PasskeyAuthenticator, PasskeyPublicKey, Publish,
22    Secp256k1PublicKey, Secp256k1Signature, Secp256r1PublicKey, Secp256r1Signature, SharedInput,
23    SignatureScheme, SignedCheckpointSummary, SignedTransaction, SimpleSignature, SplitCoins,
24    StructTag, SystemPackage, Transaction, TransactionEffects, TransactionEffectsV1,
25    TransactionEffectsV2, TransactionEvents, TransactionExpiration, TransactionKind,
26    TransferObjects, TypeArgumentError, TypeParseError, TypeTag, UnchangedConsensusKind, Upgrade,
27    UserSignature, ValidatorAggregatedSignature, ValidatorCommittee, ValidatorCommitteeMember,
28    ValidatorExecutionTimeObservation, VersionAssignment, VersionAssignmentV2,
29    ZkLoginAuthenticator, ZkLoginPublicIdentifier,
30};
31use tap::Pipe;
32
33use crate::crypto::SuiSignature as _;
34
35#[derive(Debug)]
36pub struct SdkTypeConversionError(String);
37
38impl std::fmt::Display for SdkTypeConversionError {
39    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
40        f.write_str(&self.0)
41    }
42}
43
44impl std::error::Error for SdkTypeConversionError {}
45
46impl From<TypeParseError> for SdkTypeConversionError {
47    fn from(value: TypeParseError) -> Self {
48        Self(value.to_string())
49    }
50}
51
52impl From<anyhow::Error> for SdkTypeConversionError {
53    fn from(value: anyhow::Error) -> Self {
54        Self(value.to_string())
55    }
56}
57
58impl From<bcs::Error> for SdkTypeConversionError {
59    fn from(value: bcs::Error) -> Self {
60        Self(value.to_string())
61    }
62}
63
64impl From<std::array::TryFromSliceError> for SdkTypeConversionError {
65    fn from(value: std::array::TryFromSliceError) -> Self {
66        Self(value.to_string())
67    }
68}
69
70macro_rules! bcs_convert_impl {
71    ($core:ty, $external:ty) => {
72        impl TryFrom<$core> for $external {
73            type Error = bcs::Error;
74
75            fn try_from(value: $core) -> Result<Self, Self::Error> {
76                let bytes = bcs::to_bytes(&value)?;
77                bcs::from_bytes(&bytes)
78            }
79        }
80
81        impl TryFrom<$external> for $core {
82            type Error = bcs::Error;
83
84            fn try_from(value: $external) -> Result<Self, Self::Error> {
85                let bytes = bcs::to_bytes(&value)?;
86                bcs::from_bytes(&bytes)
87            }
88        }
89    };
90}
91
92bcs_convert_impl!(crate::object::Object, Object);
93bcs_convert_impl!(crate::transaction::TransactionData, Transaction);
94bcs_convert_impl!(crate::effects::TransactionEffectsV1, TransactionEffectsV1);
95bcs_convert_impl!(crate::effects::TransactionEffectsV2, TransactionEffectsV2);
96bcs_convert_impl!(
97    crate::messages_checkpoint::CheckpointSummary,
98    CheckpointSummary
99);
100bcs_convert_impl!(
101    crate::messages_checkpoint::CertifiedCheckpointSummary,
102    SignedCheckpointSummary
103);
104bcs_convert_impl!(
105    crate::messages_checkpoint::CheckpointContents,
106    CheckpointContents
107);
108bcs_convert_impl!(
109    crate::full_checkpoint_content::CheckpointData,
110    CheckpointData
111);
112bcs_convert_impl!(crate::signature::GenericSignature, UserSignature);
113bcs_convert_impl!(
114    crate::crypto::ZkLoginPublicIdentifier,
115    ZkLoginPublicIdentifier
116);
117bcs_convert_impl!(
118    crate::crypto::ZkLoginAuthenticatorAsBytes,
119    ZkLoginAuthenticator
120);
121bcs_convert_impl!(
122    crate::zk_login_authenticator::ZkLoginAuthenticator,
123    ZkLoginAuthenticator
124);
125bcs_convert_impl!(
126    crate::crypto::PasskeyAuthenticatorAsBytes,
127    PasskeyAuthenticator
128);
129bcs_convert_impl!(
130    crate::passkey_authenticator::PasskeyAuthenticator,
131    PasskeyAuthenticator
132);
133bcs_convert_impl!(crate::effects::TransactionEvents, TransactionEvents);
134bcs_convert_impl!(crate::transaction::TransactionKind, TransactionKind);
135bcs_convert_impl!(crate::move_package::MovePackage, MovePackage);
136
137impl<const T: bool> From<crate::crypto::AuthorityQuorumSignInfo<T>>
138    for ValidatorAggregatedSignature
139{
140    fn from(value: crate::crypto::AuthorityQuorumSignInfo<T>) -> Self {
141        let crate::crypto::AuthorityQuorumSignInfo {
142            epoch,
143            signature,
144            signers_map,
145        } = value;
146
147        Self {
148            epoch,
149            signature: Bls12381Signature::from_bytes(signature.as_ref()).unwrap(),
150            bitmap: Bitmap::from_iter(signers_map),
151        }
152    }
153}
154
155impl<const T: bool> From<ValidatorAggregatedSignature>
156    for crate::crypto::AuthorityQuorumSignInfo<T>
157{
158    fn from(value: ValidatorAggregatedSignature) -> Self {
159        let ValidatorAggregatedSignature {
160            epoch,
161            signature,
162            bitmap,
163        } = value;
164
165        Self {
166            epoch,
167            signature: crate::crypto::AggregateAuthoritySignature::from_bytes(signature.as_bytes())
168                .unwrap(),
169            signers_map: roaring::RoaringBitmap::from_iter(bitmap.iter()),
170        }
171    }
172}
173
174impl From<crate::object::Owner> for Owner {
175    fn from(value: crate::object::Owner) -> Self {
176        match value {
177            crate::object::Owner::AddressOwner(address) => Self::Address(address.into()),
178            crate::object::Owner::ObjectOwner(object_id) => Self::Object(object_id.into()),
179            crate::object::Owner::Shared {
180                initial_shared_version,
181            } => Self::Shared(initial_shared_version.value()),
182            crate::object::Owner::Immutable => Self::Immutable,
183            crate::object::Owner::ConsensusAddressOwner {
184                start_version,
185                owner,
186            } => Self::ConsensusAddress {
187                start_version: start_version.value(),
188                owner: owner.into(),
189            },
190        }
191    }
192}
193
194impl From<Owner> for crate::object::Owner {
195    fn from(value: Owner) -> Self {
196        match value {
197            Owner::Address(address) => crate::object::Owner::AddressOwner(address.into()),
198            Owner::Object(object_id) => crate::object::Owner::ObjectOwner(object_id.into()),
199            Owner::Shared(initial_shared_version) => crate::object::Owner::Shared {
200                initial_shared_version: initial_shared_version.into(),
201            },
202            Owner::Immutable => crate::object::Owner::Immutable,
203            Owner::ConsensusAddress {
204                start_version,
205                owner,
206            } => crate::object::Owner::ConsensusAddressOwner {
207                start_version: start_version.into(),
208                owner: owner.into(),
209            },
210            _ => unreachable!("sdk shouldn't have a variant that the mono repo doesn't"),
211        }
212    }
213}
214
215impl From<crate::base_types::SuiAddress> for Address {
216    fn from(value: crate::base_types::SuiAddress) -> Self {
217        Self::new(value.to_inner())
218    }
219}
220
221impl From<Address> for crate::base_types::SuiAddress {
222    fn from(value: Address) -> Self {
223        crate::base_types::ObjectID::new(value.into_inner()).into()
224    }
225}
226
227impl From<crate::base_types::ObjectID> for Address {
228    fn from(value: crate::base_types::ObjectID) -> Self {
229        Self::new(value.into_bytes())
230    }
231}
232
233impl From<Address> for crate::base_types::ObjectID {
234    fn from(value: Address) -> Self {
235        Self::new(value.into_inner())
236    }
237}
238
239impl TryFrom<crate::transaction::SenderSignedData> for SignedTransaction {
240    type Error = SdkTypeConversionError;
241
242    fn try_from(value: crate::transaction::SenderSignedData) -> Result<Self, Self::Error> {
243        let crate::transaction::SenderSignedTransaction {
244            intent_message,
245            tx_signatures,
246        } = value.into_inner();
247
248        Self {
249            transaction: intent_message.value.try_into()?,
250            signatures: tx_signatures
251                .into_iter()
252                .map(TryInto::try_into)
253                .collect::<Result<_, _>>()?,
254        }
255        .pipe(Ok)
256    }
257}
258
259impl TryFrom<SignedTransaction> for crate::transaction::SenderSignedData {
260    type Error = SdkTypeConversionError;
261
262    fn try_from(value: SignedTransaction) -> Result<Self, Self::Error> {
263        let SignedTransaction {
264            transaction,
265            signatures,
266        } = value;
267
268        Self::new(
269            transaction.try_into()?,
270            signatures
271                .into_iter()
272                .map(TryInto::try_into)
273                .collect::<Result<_, _>>()?,
274        )
275        .pipe(Ok)
276    }
277}
278
279impl TryFrom<crate::transaction::Transaction> for SignedTransaction {
280    type Error = SdkTypeConversionError;
281
282    fn try_from(value: crate::transaction::Transaction) -> Result<Self, Self::Error> {
283        value.into_data().try_into()
284    }
285}
286
287impl TryFrom<SignedTransaction> for crate::transaction::Transaction {
288    type Error = SdkTypeConversionError;
289
290    fn try_from(value: SignedTransaction) -> Result<Self, Self::Error> {
291        Ok(Self::new(value.try_into()?))
292    }
293}
294
295pub fn type_tag_core_to_sdk(
296    value: move_core_types::language_storage::TypeTag,
297) -> Result<TypeTag, SdkTypeConversionError> {
298    match value {
299        move_core_types::language_storage::TypeTag::Bool => TypeTag::Bool,
300        move_core_types::language_storage::TypeTag::U8 => TypeTag::U8,
301        move_core_types::language_storage::TypeTag::U64 => TypeTag::U64,
302        move_core_types::language_storage::TypeTag::U128 => TypeTag::U128,
303        move_core_types::language_storage::TypeTag::Address => TypeTag::Address,
304        move_core_types::language_storage::TypeTag::Signer => TypeTag::Signer,
305        move_core_types::language_storage::TypeTag::Vector(type_tag) => {
306            TypeTag::Vector(Box::new(type_tag_core_to_sdk(*type_tag)?))
307        }
308        move_core_types::language_storage::TypeTag::Struct(struct_tag) => {
309            TypeTag::Struct(Box::new(struct_tag_core_to_sdk(*struct_tag)?))
310        }
311        move_core_types::language_storage::TypeTag::U16 => TypeTag::U16,
312        move_core_types::language_storage::TypeTag::U32 => TypeTag::U32,
313        move_core_types::language_storage::TypeTag::U256 => TypeTag::U256,
314    }
315    .pipe(Ok)
316}
317
318pub fn struct_tag_core_to_sdk(
319    value: move_core_types::language_storage::StructTag,
320) -> Result<StructTag, SdkTypeConversionError> {
321    let move_core_types::language_storage::StructTag {
322        address,
323        module,
324        name,
325        type_params,
326    } = value;
327
328    let address = Address::new(address.into_bytes());
329    let module = Identifier::new(module.as_str())?;
330    let name = Identifier::new(name.as_str())?;
331    let type_params = type_params
332        .into_iter()
333        .map(type_tag_core_to_sdk)
334        .collect::<Result<_, _>>()?;
335    StructTag::new(address, module, name, type_params).pipe(Ok)
336}
337
338pub fn type_tag_sdk_to_core(
339    value: TypeTag,
340) -> Result<move_core_types::language_storage::TypeTag, SdkTypeConversionError> {
341    match value {
342        TypeTag::Bool => move_core_types::language_storage::TypeTag::Bool,
343        TypeTag::U8 => move_core_types::language_storage::TypeTag::U8,
344        TypeTag::U64 => move_core_types::language_storage::TypeTag::U64,
345        TypeTag::U128 => move_core_types::language_storage::TypeTag::U128,
346        TypeTag::Address => move_core_types::language_storage::TypeTag::Address,
347        TypeTag::Signer => move_core_types::language_storage::TypeTag::Signer,
348        TypeTag::Vector(type_tag) => move_core_types::language_storage::TypeTag::Vector(Box::new(
349            type_tag_sdk_to_core(*type_tag)?,
350        )),
351        TypeTag::Struct(struct_tag) => move_core_types::language_storage::TypeTag::Struct(
352            Box::new(struct_tag_sdk_to_core(*struct_tag)?),
353        ),
354        TypeTag::U16 => move_core_types::language_storage::TypeTag::U16,
355        TypeTag::U32 => move_core_types::language_storage::TypeTag::U32,
356        TypeTag::U256 => move_core_types::language_storage::TypeTag::U256,
357    }
358    .pipe(Ok)
359}
360
361pub fn struct_tag_sdk_to_core(
362    value: StructTag,
363) -> Result<move_core_types::language_storage::StructTag, SdkTypeConversionError> {
364    let address = value.address();
365    let module = value.module();
366    let name = value.name();
367    let type_params = value.type_params();
368
369    let address = move_core_types::account_address::AccountAddress::new(address.into_inner());
370    let module = move_core_types::identifier::Identifier::new(module.as_str())?;
371    let name = move_core_types::identifier::Identifier::new(name.as_str())?;
372    let type_params = type_params
373        .iter()
374        .cloned()
375        .map(type_tag_sdk_to_core)
376        .collect::<Result<_, _>>()?;
377    move_core_types::language_storage::StructTag {
378        address,
379        module,
380        name,
381        type_params,
382    }
383    .pipe(Ok)
384}
385
386impl TryFrom<crate::type_input::TypeInput> for TypeTag {
387    type Error = SdkTypeConversionError;
388
389    fn try_from(value: crate::type_input::TypeInput) -> Result<Self, Self::Error> {
390        match value {
391            crate::type_input::TypeInput::Bool => Self::Bool,
392            crate::type_input::TypeInput::U8 => Self::U8,
393            crate::type_input::TypeInput::U64 => Self::U64,
394            crate::type_input::TypeInput::U128 => Self::U128,
395            crate::type_input::TypeInput::Address => Self::Address,
396            crate::type_input::TypeInput::Signer => Self::Signer,
397            crate::type_input::TypeInput::Vector(type_input) => {
398                Self::Vector(Box::new((*type_input).try_into()?))
399            }
400            crate::type_input::TypeInput::Struct(struct_input) => {
401                Self::Struct(Box::new((*struct_input).try_into()?))
402            }
403            crate::type_input::TypeInput::U16 => Self::U16,
404            crate::type_input::TypeInput::U32 => Self::U32,
405            crate::type_input::TypeInput::U256 => Self::U256,
406        }
407        .pipe(Ok)
408    }
409}
410
411impl TryFrom<crate::type_input::StructInput> for StructTag {
412    type Error = SdkTypeConversionError;
413
414    fn try_from(value: crate::type_input::StructInput) -> Result<Self, Self::Error> {
415        Self::new(
416            Address::new(value.address.into_bytes()),
417            Identifier::new(value.module)?,
418            Identifier::new(value.name)?,
419            value
420                .type_params
421                .into_iter()
422                .map(TryInto::try_into)
423                .collect::<Result<_, _>>()?,
424        )
425        .pipe(Ok)
426    }
427}
428
429impl From<TypeTag> for crate::type_input::TypeInput {
430    fn from(value: TypeTag) -> Self {
431        match value {
432            TypeTag::U8 => Self::U8,
433            TypeTag::U16 => Self::U16,
434            TypeTag::U32 => Self::U32,
435            TypeTag::U64 => Self::U64,
436            TypeTag::U128 => Self::U128,
437            TypeTag::U256 => Self::U256,
438            TypeTag::Bool => Self::Bool,
439            TypeTag::Address => Self::Address,
440            TypeTag::Signer => Self::Signer,
441            TypeTag::Vector(type_tag) => Self::Vector(Box::new((*type_tag).into())),
442            TypeTag::Struct(struct_tag) => Self::Struct(Box::new((*struct_tag).into())),
443        }
444    }
445}
446
447impl From<StructTag> for crate::type_input::StructInput {
448    fn from(value: StructTag) -> Self {
449        Self {
450            address: move_core_types::account_address::AccountAddress::new(
451                value.address().into_inner(),
452            ),
453            module: value.module().as_str().into(),
454            name: value.name().as_str().into(),
455            type_params: value
456                .type_params()
457                .iter()
458                .cloned()
459                .map(crate::type_input::TypeInput::from)
460                .collect(),
461        }
462    }
463}
464
465impl From<crate::digests::ObjectDigest> for Digest {
466    fn from(value: crate::digests::ObjectDigest) -> Self {
467        Self::new(value.into_inner())
468    }
469}
470
471impl From<Digest> for crate::digests::ObjectDigest {
472    fn from(value: Digest) -> Self {
473        Self::new(value.into_inner())
474    }
475}
476
477impl From<crate::digests::TransactionDigest> for Digest {
478    fn from(value: crate::digests::TransactionDigest) -> Self {
479        Self::new(value.into_inner())
480    }
481}
482
483impl From<Digest> for crate::digests::TransactionDigest {
484    fn from(value: Digest) -> Self {
485        Self::new(value.into_inner())
486    }
487}
488
489impl From<crate::messages_checkpoint::CheckpointDigest> for Digest {
490    fn from(value: crate::messages_checkpoint::CheckpointDigest) -> Self {
491        Self::new(value.into_inner())
492    }
493}
494
495impl From<Digest> for crate::messages_checkpoint::CheckpointDigest {
496    fn from(value: Digest) -> Self {
497        Self::new(value.into_inner())
498    }
499}
500
501impl From<crate::digests::Digest> for Digest {
502    fn from(value: crate::digests::Digest) -> Self {
503        Self::new(value.into_inner())
504    }
505}
506
507impl From<Digest> for crate::digests::Digest {
508    fn from(value: Digest) -> Self {
509        Self::new(value.into_inner())
510    }
511}
512
513impl From<crate::digests::CheckpointArtifactsDigest> for Digest {
514    fn from(value: crate::digests::CheckpointArtifactsDigest) -> Self {
515        Self::new(value.into_inner())
516    }
517}
518
519impl From<Digest> for crate::digests::CheckpointArtifactsDigest {
520    fn from(value: Digest) -> Self {
521        Self::new(value.into_inner())
522    }
523}
524
525impl From<crate::committee::Committee> for ValidatorCommittee {
526    fn from(value: crate::committee::Committee) -> Self {
527        Self {
528            epoch: value.epoch(),
529            members: value
530                .voting_rights
531                .into_iter()
532                .map(|(name, stake)| ValidatorCommitteeMember {
533                    public_key: name.into(),
534                    stake,
535                })
536                .collect(),
537        }
538    }
539}
540
541impl From<ValidatorCommittee> for crate::committee::Committee {
542    fn from(value: ValidatorCommittee) -> Self {
543        let ValidatorCommittee { epoch, members } = value;
544
545        Self::new(
546            epoch,
547            members
548                .into_iter()
549                .map(|member| (member.public_key.into(), member.stake))
550                .collect(),
551        )
552    }
553}
554
555impl From<crate::crypto::AuthorityPublicKeyBytes> for Bls12381PublicKey {
556    fn from(value: crate::crypto::AuthorityPublicKeyBytes) -> Self {
557        Self::new(value.0)
558    }
559}
560
561impl From<Bls12381PublicKey> for crate::crypto::AuthorityPublicKeyBytes {
562    fn from(value: Bls12381PublicKey) -> Self {
563        Self::new(value.into_inner())
564    }
565}
566
567impl From<UnchangedConsensusKind> for crate::effects::UnchangedConsensusKind {
568    fn from(value: UnchangedConsensusKind) -> Self {
569        match value {
570            UnchangedConsensusKind::ReadOnlyRoot { version, digest } => {
571                Self::ReadOnlyRoot((version.into(), digest.into()))
572            }
573            UnchangedConsensusKind::MutateDeleted { version } => {
574                Self::MutateConsensusStreamEnded(version.into())
575            }
576            UnchangedConsensusKind::ReadDeleted { version } => {
577                Self::ReadConsensusStreamEnded(version.into())
578            }
579            UnchangedConsensusKind::Canceled { version } => Self::Cancelled(version.into()),
580            UnchangedConsensusKind::PerEpochConfig => Self::PerEpochConfig,
581            _ => unreachable!("sdk shouldn't have a variant that the mono repo doesn't"),
582        }
583    }
584}
585
586impl From<crate::effects::UnchangedConsensusKind> for UnchangedConsensusKind {
587    fn from(value: crate::effects::UnchangedConsensusKind) -> Self {
588        match value {
589            crate::effects::UnchangedConsensusKind::ReadOnlyRoot((version, digest)) => {
590                Self::ReadOnlyRoot {
591                    version: version.into(),
592                    digest: digest.into(),
593                }
594            }
595            crate::effects::UnchangedConsensusKind::MutateConsensusStreamEnded(version) => {
596                Self::MutateDeleted {
597                    version: version.into(),
598                }
599            }
600            crate::effects::UnchangedConsensusKind::ReadConsensusStreamEnded(version) => {
601                Self::ReadDeleted {
602                    version: version.into(),
603                }
604            }
605            crate::effects::UnchangedConsensusKind::Cancelled(version) => Self::Canceled {
606                version: version.into(),
607            },
608            crate::effects::UnchangedConsensusKind::PerEpochConfig => Self::PerEpochConfig,
609        }
610    }
611}
612
613impl From<crate::effects::ObjectIn> for ObjectIn {
614    fn from(value: crate::effects::ObjectIn) -> Self {
615        match value {
616            crate::effects::ObjectIn::NotExist => Self::NotExist,
617            crate::effects::ObjectIn::Exist(((version, digest), owner)) => Self::Exist {
618                version: version.value(),
619                digest: digest.into(),
620                owner: owner.into(),
621            },
622        }
623    }
624}
625
626impl From<crate::effects::ObjectOut> for ObjectOut {
627    fn from(value: crate::effects::ObjectOut) -> Self {
628        match value {
629            crate::effects::ObjectOut::NotExist => Self::NotExist,
630            crate::effects::ObjectOut::ObjectWrite((digest, owner)) => Self::ObjectWrite {
631                digest: digest.into(),
632                owner: owner.into(),
633            },
634            crate::effects::ObjectOut::PackageWrite((version, digest)) => Self::PackageWrite {
635                version: version.value(),
636                digest: digest.into(),
637            },
638
639            crate::effects::ObjectOut::AccumulatorWriteV1(accumulator_write) => {
640                Self::AccumulatorWrite(accumulator_write.into())
641            }
642        }
643    }
644}
645
646impl From<crate::effects::AccumulatorWriteV1> for AccumulatorWrite {
647    fn from(value: crate::effects::AccumulatorWriteV1) -> Self {
648        let operation = match value.operation {
649            crate::effects::AccumulatorOperation::Merge => {
650                sui_sdk_types::AccumulatorOperation::Merge
651            }
652            crate::effects::AccumulatorOperation::Split => {
653                sui_sdk_types::AccumulatorOperation::Split
654            }
655        };
656        Self::new(
657            value.address.address.into(),
658            type_tag_core_to_sdk(value.address.ty).unwrap(),
659            operation,
660            match value.value {
661                crate::effects::AccumulatorValue::Integer(value) => value,
662                crate::effects::AccumulatorValue::IntegerTuple(_, _)
663                | crate::effects::AccumulatorValue::EventDigest(_) => todo!(),
664            },
665        )
666    }
667}
668
669impl From<crate::effects::IDOperation> for IdOperation {
670    fn from(value: crate::effects::IDOperation) -> Self {
671        match value {
672            crate::effects::IDOperation::None => Self::None,
673            crate::effects::IDOperation::Created => Self::Created,
674            crate::effects::IDOperation::Deleted => Self::Deleted,
675        }
676    }
677}
678
679impl From<crate::transaction::TransactionExpiration> for TransactionExpiration {
680    fn from(value: crate::transaction::TransactionExpiration) -> Self {
681        match value {
682            crate::transaction::TransactionExpiration::None => Self::None,
683            crate::transaction::TransactionExpiration::Epoch(epoch) => Self::Epoch(epoch),
684            crate::transaction::TransactionExpiration::ValidDuring {
685                min_epoch,
686                max_epoch,
687                min_timestamp,
688                max_timestamp,
689                chain,
690                nonce,
691            } => Self::ValidDuring {
692                min_epoch,
693                max_epoch,
694                min_timestamp,
695                max_timestamp,
696                chain: Digest::new(*chain.as_bytes()),
697                nonce,
698            },
699        }
700    }
701}
702
703impl From<TransactionExpiration> for crate::transaction::TransactionExpiration {
704    fn from(value: TransactionExpiration) -> Self {
705        match value {
706            TransactionExpiration::None => Self::None,
707            TransactionExpiration::Epoch(epoch) => Self::Epoch(epoch),
708            TransactionExpiration::ValidDuring {
709                min_epoch,
710                max_epoch,
711                min_timestamp,
712                max_timestamp,
713                chain,
714                nonce,
715            } => Self::ValidDuring {
716                min_epoch,
717                max_epoch,
718                min_timestamp,
719                max_timestamp,
720                chain: crate::digests::CheckpointDigest::from(chain).into(),
721                nonce,
722            },
723            _ => unreachable!("sdk shouldn't have a variant that the mono repo doesn't"),
724        }
725    }
726}
727
728impl From<crate::execution_status::TypeArgumentError> for TypeArgumentError {
729    fn from(value: crate::execution_status::TypeArgumentError) -> Self {
730        match value {
731            crate::execution_status::TypeArgumentError::TypeNotFound => Self::TypeNotFound,
732            crate::execution_status::TypeArgumentError::ConstraintNotSatisfied => {
733                Self::ConstraintNotSatisfied
734            }
735        }
736    }
737}
738
739impl From<TypeArgumentError> for crate::execution_status::TypeArgumentError {
740    fn from(value: TypeArgumentError) -> Self {
741        match value {
742            TypeArgumentError::TypeNotFound => Self::TypeNotFound,
743            TypeArgumentError::ConstraintNotSatisfied => Self::ConstraintNotSatisfied,
744            _ => unreachable!("sdk shouldn't have a variant that the mono repo doesn't"),
745        }
746    }
747}
748
749impl From<crate::execution_status::PackageUpgradeError> for PackageUpgradeError {
750    fn from(value: crate::execution_status::PackageUpgradeError) -> Self {
751        match value {
752            crate::execution_status::PackageUpgradeError::UnableToFetchPackage { package_id } => {
753                Self::UnableToFetchPackage {
754                    package_id: package_id.into(),
755                }
756            }
757            crate::execution_status::PackageUpgradeError::NotAPackage { object_id } => {
758                Self::NotAPackage {
759                    object_id: object_id.into(),
760                }
761            }
762            crate::execution_status::PackageUpgradeError::IncompatibleUpgrade => {
763                Self::IncompatibleUpgrade
764            }
765            crate::execution_status::PackageUpgradeError::DigestDoesNotMatch { digest } => {
766                Self::DigestDoesNotMatch {
767                    digest: Digest::from_bytes(digest).unwrap(),
768                }
769            }
770            crate::execution_status::PackageUpgradeError::UnknownUpgradePolicy { policy } => {
771                Self::UnknownUpgradePolicy { policy }
772            }
773            crate::execution_status::PackageUpgradeError::PackageIDDoesNotMatch {
774                package_id,
775                ticket_id,
776            } => Self::PackageIdDoesNotMatch {
777                package_id: package_id.into(),
778                ticket_id: ticket_id.into(),
779            },
780        }
781    }
782}
783
784impl From<PackageUpgradeError> for crate::execution_status::PackageUpgradeError {
785    fn from(value: PackageUpgradeError) -> Self {
786        match value {
787            PackageUpgradeError::UnableToFetchPackage { package_id } => {
788                Self::UnableToFetchPackage {
789                    package_id: package_id.into(),
790                }
791            }
792            PackageUpgradeError::NotAPackage { object_id } => Self::NotAPackage {
793                object_id: object_id.into(),
794            },
795            PackageUpgradeError::IncompatibleUpgrade => Self::IncompatibleUpgrade,
796            PackageUpgradeError::DigestDoesNotMatch { digest } => Self::DigestDoesNotMatch {
797                digest: digest.into_inner().to_vec(),
798            },
799            PackageUpgradeError::UnknownUpgradePolicy { policy } => {
800                Self::UnknownUpgradePolicy { policy }
801            }
802            PackageUpgradeError::PackageIdDoesNotMatch {
803                package_id,
804                ticket_id,
805            } => Self::PackageIDDoesNotMatch {
806                package_id: package_id.into(),
807                ticket_id: ticket_id.into(),
808            },
809            _ => unreachable!("sdk shouldn't have a variant that the mono repo doesn't"),
810        }
811    }
812}
813
814impl From<crate::execution_status::CommandArgumentError> for CommandArgumentError {
815    fn from(value: crate::execution_status::CommandArgumentError) -> Self {
816        match value {
817            crate::execution_status::CommandArgumentError::TypeMismatch => Self::TypeMismatch,
818            crate::execution_status::CommandArgumentError::InvalidBCSBytes => Self::InvalidBcsBytes,
819            crate::execution_status::CommandArgumentError::InvalidUsageOfPureArg => Self::InvalidUsageOfPureArgument,
820            crate::execution_status::CommandArgumentError::InvalidArgumentToPrivateEntryFunction => Self::InvalidArgumentToPrivateEntryFunction,
821            crate::execution_status::CommandArgumentError::IndexOutOfBounds { idx } => Self::IndexOutOfBounds { index: idx },
822            crate::execution_status::CommandArgumentError::SecondaryIndexOutOfBounds { result_idx, secondary_idx } => Self::SecondaryIndexOutOfBounds { result: result_idx, subresult: secondary_idx },
823            crate::execution_status::CommandArgumentError::InvalidResultArity { result_idx } => Self::InvalidResultArity { result: result_idx },
824            crate::execution_status::CommandArgumentError::InvalidGasCoinUsage => Self::InvalidGasCoinUsage,
825            crate::execution_status::CommandArgumentError::InvalidValueUsage => Self::InvalidValueUsage,
826            crate::execution_status::CommandArgumentError::InvalidObjectByValue => Self::InvalidObjectByValue,
827            crate::execution_status::CommandArgumentError::InvalidObjectByMutRef => Self::InvalidObjectByMutRef,
828            crate::execution_status::CommandArgumentError::SharedObjectOperationNotAllowed => Self::ConsensusObjectOperationNotAllowed,
829            crate::execution_status::CommandArgumentError::InvalidArgumentArity => Self::InvalidArgumentArity,
830            crate::execution_status::CommandArgumentError::InvalidTransferObject  => Self::InvalidTransferObject,
831            crate::execution_status::CommandArgumentError::InvalidMakeMoveVecNonObjectArgument =>
832                Self::InvalidMakeMoveVecNonObjectArgument,
833            crate::execution_status::CommandArgumentError::ArgumentWithoutValue  =>
834                Self::ArgumentWithoutValue,
835            crate::execution_status::CommandArgumentError::CannotMoveBorrowedValue =>
836                Self::CannotMoveBorrowedValue,
837            crate::execution_status::CommandArgumentError::CannotWriteToExtendedReference =>
838                Self::CannotWriteToExtendedReference,
839            crate::execution_status::CommandArgumentError::InvalidReferenceArgument =>
840                Self::InvalidReferenceArgument,
841        }
842    }
843}
844
845impl From<CommandArgumentError> for crate::execution_status::CommandArgumentError {
846    fn from(value: CommandArgumentError) -> Self {
847        match value {
848            CommandArgumentError::TypeMismatch => Self::TypeMismatch,
849            CommandArgumentError::InvalidBcsBytes => Self::InvalidBCSBytes,
850            CommandArgumentError::InvalidUsageOfPureArgument => Self::InvalidUsageOfPureArg,
851            CommandArgumentError::InvalidArgumentToPrivateEntryFunction => {
852                Self::InvalidArgumentToPrivateEntryFunction
853            }
854            CommandArgumentError::IndexOutOfBounds { index } => {
855                Self::IndexOutOfBounds { idx: index }
856            }
857            CommandArgumentError::SecondaryIndexOutOfBounds { result, subresult } => {
858                Self::SecondaryIndexOutOfBounds {
859                    result_idx: result,
860                    secondary_idx: subresult,
861                }
862            }
863            CommandArgumentError::InvalidResultArity { result } => {
864                Self::InvalidResultArity { result_idx: result }
865            }
866            CommandArgumentError::InvalidGasCoinUsage => Self::InvalidGasCoinUsage,
867            CommandArgumentError::InvalidValueUsage => Self::InvalidValueUsage,
868            CommandArgumentError::InvalidObjectByValue => Self::InvalidObjectByValue,
869            CommandArgumentError::InvalidObjectByMutRef => Self::InvalidObjectByMutRef,
870            CommandArgumentError::ConsensusObjectOperationNotAllowed => {
871                Self::SharedObjectOperationNotAllowed
872            }
873            CommandArgumentError::InvalidArgumentArity => Self::InvalidArgumentArity,
874            CommandArgumentError::InvalidTransferObject => Self::InvalidTransferObject,
875            CommandArgumentError::InvalidMakeMoveVecNonObjectArgument => {
876                Self::InvalidMakeMoveVecNonObjectArgument
877            }
878            CommandArgumentError::ArgumentWithoutValue => Self::ArgumentWithoutValue,
879            CommandArgumentError::CannotMoveBorrowedValue => Self::CannotMoveBorrowedValue,
880            CommandArgumentError::CannotWriteToExtendedReference => {
881                Self::CannotWriteToExtendedReference
882            }
883            CommandArgumentError::InvalidReferenceArgument => Self::InvalidReferenceArgument,
884            _ => unreachable!("sdk shouldn't have a variant that the mono repo doesn't"),
885        }
886    }
887}
888
889impl From<crate::execution_status::ExecutionFailureStatus> for ExecutionError {
890    fn from(value: crate::execution_status::ExecutionFailureStatus) -> Self {
891        match value {
892            crate::execution_status::ExecutionFailureStatus::InsufficientGas => Self::InsufficientGas,
893            crate::execution_status::ExecutionFailureStatus::InvalidGasObject => Self::InvalidGasObject,
894            crate::execution_status::ExecutionFailureStatus::InvariantViolation => Self::InvariantViolation,
895            crate::execution_status::ExecutionFailureStatus::FeatureNotYetSupported => Self::FeatureNotYetSupported,
896            crate::execution_status::ExecutionFailureStatus::MoveObjectTooBig { object_size, max_object_size } => Self::ObjectTooBig { object_size, max_object_size },
897            crate::execution_status::ExecutionFailureStatus::MovePackageTooBig { object_size, max_object_size } => Self::PackageTooBig { object_size, max_object_size },
898            crate::execution_status::ExecutionFailureStatus::CircularObjectOwnership { object } => Self::CircularObjectOwnership { object: object.into() },
899            crate::execution_status::ExecutionFailureStatus::InsufficientCoinBalance => Self::InsufficientCoinBalance,
900            crate::execution_status::ExecutionFailureStatus::CoinBalanceOverflow => Self::CoinBalanceOverflow,
901            crate::execution_status::ExecutionFailureStatus::PublishErrorNonZeroAddress => Self::PublishErrorNonZeroAddress,
902            crate::execution_status::ExecutionFailureStatus::SuiMoveVerificationError => Self::SuiMoveVerificationError,
903            crate::execution_status::ExecutionFailureStatus::MovePrimitiveRuntimeError(move_location_opt) => Self::MovePrimitiveRuntimeError { location: move_location_opt.0.map(Into::into) },
904            crate::execution_status::ExecutionFailureStatus::MoveAbort(move_location, code) => Self::MoveAbort { location: move_location.into(), code },
905            crate::execution_status::ExecutionFailureStatus::VMVerificationOrDeserializationError => Self::VmVerificationOrDeserializationError,
906            crate::execution_status::ExecutionFailureStatus::VMInvariantViolation => Self::VmInvariantViolation,
907            crate::execution_status::ExecutionFailureStatus::FunctionNotFound => Self::FunctionNotFound,
908            crate::execution_status::ExecutionFailureStatus::ArityMismatch => Self::ArityMismatch,
909            crate::execution_status::ExecutionFailureStatus::TypeArityMismatch => Self::TypeArityMismatch,
910            crate::execution_status::ExecutionFailureStatus::NonEntryFunctionInvoked => Self::NonEntryFunctionInvoked,
911            crate::execution_status::ExecutionFailureStatus::CommandArgumentError { arg_idx, kind } => Self::CommandArgumentError { argument: arg_idx, kind: kind.into() },
912            crate::execution_status::ExecutionFailureStatus::TypeArgumentError { argument_idx, kind } => Self::TypeArgumentError { type_argument: argument_idx, kind: kind.into() },
913            crate::execution_status::ExecutionFailureStatus::UnusedValueWithoutDrop { result_idx, secondary_idx } => Self::UnusedValueWithoutDrop { result: result_idx, subresult: secondary_idx },
914            crate::execution_status::ExecutionFailureStatus::InvalidPublicFunctionReturnType { idx } => Self::InvalidPublicFunctionReturnType { index: idx },
915            crate::execution_status::ExecutionFailureStatus::InvalidTransferObject => Self::InvalidTransferObject,
916            crate::execution_status::ExecutionFailureStatus::EffectsTooLarge { current_size, max_size } => Self::EffectsTooLarge { current_size, max_size },
917            crate::execution_status::ExecutionFailureStatus::PublishUpgradeMissingDependency => Self::PublishUpgradeMissingDependency,
918            crate::execution_status::ExecutionFailureStatus::PublishUpgradeDependencyDowngrade => Self::PublishUpgradeDependencyDowngrade,
919            crate::execution_status::ExecutionFailureStatus::PackageUpgradeError { upgrade_error } => Self::PackageUpgradeError { kind: upgrade_error.into() },
920            crate::execution_status::ExecutionFailureStatus::WrittenObjectsTooLarge { current_size, max_size } => Self::WrittenObjectsTooLarge { object_size: current_size, max_object_size:max_size },
921            crate::execution_status::ExecutionFailureStatus::CertificateDenied => Self::CertificateDenied,
922            crate::execution_status::ExecutionFailureStatus::SuiMoveVerificationTimedout => Self::SuiMoveVerificationTimedout,
923            crate::execution_status::ExecutionFailureStatus::SharedObjectOperationNotAllowed => Self::ConsensusObjectOperationNotAllowed,
924            crate::execution_status::ExecutionFailureStatus::InputObjectDeleted => Self::InputObjectDeleted,
925            crate::execution_status::ExecutionFailureStatus::ExecutionCancelledDueToSharedObjectCongestion { congested_objects } => Self::ExecutionCanceledDueToConsensusObjectCongestion { congested_objects: congested_objects.0.into_iter().map(Into::into).collect() },
926            crate::execution_status::ExecutionFailureStatus::AddressDeniedForCoin { address, coin_type } => Self::AddressDeniedForCoin { address: address.into(), coin_type },
927            crate::execution_status::ExecutionFailureStatus::CoinTypeGlobalPause { coin_type } => Self::CoinTypeGlobalPause { coin_type },
928            crate::execution_status::ExecutionFailureStatus::ExecutionCancelledDueToRandomnessUnavailable => Self::ExecutionCanceledDueToRandomnessUnavailable,
929            crate::execution_status::ExecutionFailureStatus::MoveVectorElemTooBig { value_size, max_scaled_size } => Self::MoveVectorElemTooBig { value_size, max_scaled_size },
930            crate::execution_status::ExecutionFailureStatus::MoveRawValueTooBig { value_size, max_scaled_size } => Self::MoveRawValueTooBig { value_size, max_scaled_size },
931            crate::execution_status::ExecutionFailureStatus::InvalidLinkage => Self::InvalidLinkage,
932            crate::execution_status::ExecutionFailureStatus::InsufficientFundsForWithdraw => {
933                Self::InsufficientFundsForWithdraw
934            }
935            crate::execution_status::ExecutionFailureStatus::NonExclusiveWriteInputObjectModified { id } => {
936                Self::NonExclusiveWriteInputObjectModified { object: id.into() }
937            }
938        }
939    }
940}
941
942impl From<ExecutionError> for crate::execution_status::ExecutionFailureStatus {
943    fn from(value: ExecutionError) -> Self {
944        match value {
945            ExecutionError::InsufficientGas => Self::InsufficientGas,
946            ExecutionError::InvalidGasObject => Self::InvalidGasObject,
947            ExecutionError::InvariantViolation => Self::InvariantViolation,
948            ExecutionError::FeatureNotYetSupported => Self::FeatureNotYetSupported,
949            ExecutionError::ObjectTooBig {
950                object_size,
951                max_object_size,
952            } => Self::MoveObjectTooBig {
953                object_size,
954                max_object_size,
955            },
956            ExecutionError::PackageTooBig {
957                object_size,
958                max_object_size,
959            } => Self::MovePackageTooBig {
960                object_size,
961                max_object_size,
962            },
963            ExecutionError::CircularObjectOwnership { object } => Self::CircularObjectOwnership {
964                object: object.into(),
965            },
966            ExecutionError::InsufficientCoinBalance => Self::InsufficientCoinBalance,
967            ExecutionError::CoinBalanceOverflow => Self::CoinBalanceOverflow,
968            ExecutionError::PublishErrorNonZeroAddress => Self::PublishErrorNonZeroAddress,
969            ExecutionError::SuiMoveVerificationError => Self::SuiMoveVerificationError,
970            ExecutionError::MovePrimitiveRuntimeError { location } => {
971                Self::MovePrimitiveRuntimeError(crate::execution_status::MoveLocationOpt(
972                    location.map(Into::into),
973                ))
974            }
975            ExecutionError::MoveAbort { location, code } => Self::MoveAbort(location.into(), code),
976            ExecutionError::VmVerificationOrDeserializationError => {
977                Self::VMVerificationOrDeserializationError
978            }
979            ExecutionError::VmInvariantViolation => Self::VMInvariantViolation,
980            ExecutionError::FunctionNotFound => Self::FunctionNotFound,
981            ExecutionError::ArityMismatch => Self::ArityMismatch,
982            ExecutionError::TypeArityMismatch => Self::TypeArityMismatch,
983            ExecutionError::NonEntryFunctionInvoked => Self::NonEntryFunctionInvoked,
984            ExecutionError::CommandArgumentError { argument, kind } => Self::CommandArgumentError {
985                arg_idx: argument,
986                kind: kind.into(),
987            },
988            ExecutionError::TypeArgumentError {
989                type_argument,
990                kind,
991            } => Self::TypeArgumentError {
992                argument_idx: type_argument,
993                kind: kind.into(),
994            },
995            ExecutionError::UnusedValueWithoutDrop { result, subresult } => {
996                Self::UnusedValueWithoutDrop {
997                    result_idx: result,
998                    secondary_idx: subresult,
999                }
1000            }
1001            ExecutionError::InvalidPublicFunctionReturnType { index } => {
1002                Self::InvalidPublicFunctionReturnType { idx: index }
1003            }
1004            ExecutionError::InvalidTransferObject => Self::InvalidTransferObject,
1005            ExecutionError::EffectsTooLarge {
1006                current_size,
1007                max_size,
1008            } => Self::EffectsTooLarge {
1009                current_size,
1010                max_size,
1011            },
1012            ExecutionError::PublishUpgradeMissingDependency => {
1013                Self::PublishUpgradeMissingDependency
1014            }
1015            ExecutionError::PublishUpgradeDependencyDowngrade => {
1016                Self::PublishUpgradeDependencyDowngrade
1017            }
1018            ExecutionError::PackageUpgradeError { kind } => Self::PackageUpgradeError {
1019                upgrade_error: kind.into(),
1020            },
1021            ExecutionError::WrittenObjectsTooLarge {
1022                object_size,
1023                max_object_size,
1024            } => Self::WrittenObjectsTooLarge {
1025                current_size: object_size,
1026                max_size: max_object_size,
1027            },
1028            ExecutionError::CertificateDenied => Self::CertificateDenied,
1029            ExecutionError::SuiMoveVerificationTimedout => Self::SuiMoveVerificationTimedout,
1030            ExecutionError::ConsensusObjectOperationNotAllowed => {
1031                Self::SharedObjectOperationNotAllowed
1032            }
1033            ExecutionError::InputObjectDeleted => Self::InputObjectDeleted,
1034            ExecutionError::ExecutionCanceledDueToConsensusObjectCongestion {
1035                congested_objects,
1036            } => Self::ExecutionCancelledDueToSharedObjectCongestion {
1037                congested_objects: crate::execution_status::CongestedObjects(
1038                    congested_objects.into_iter().map(Into::into).collect(),
1039                ),
1040            },
1041            ExecutionError::AddressDeniedForCoin { address, coin_type } => {
1042                Self::AddressDeniedForCoin {
1043                    address: address.into(),
1044                    coin_type,
1045                }
1046            }
1047            ExecutionError::CoinTypeGlobalPause { coin_type } => {
1048                Self::CoinTypeGlobalPause { coin_type }
1049            }
1050            ExecutionError::ExecutionCanceledDueToRandomnessUnavailable => {
1051                Self::ExecutionCancelledDueToRandomnessUnavailable
1052            }
1053            ExecutionError::MoveVectorElemTooBig {
1054                value_size,
1055                max_scaled_size,
1056            } => Self::MoveVectorElemTooBig {
1057                value_size,
1058                max_scaled_size,
1059            },
1060            ExecutionError::MoveRawValueTooBig {
1061                value_size,
1062                max_scaled_size,
1063            } => Self::MoveRawValueTooBig {
1064                value_size,
1065                max_scaled_size,
1066            },
1067            ExecutionError::InvalidLinkage => Self::InvalidLinkage,
1068            _ => unreachable!("sdk shouldn't have a variant that the mono repo doesn't"),
1069        }
1070    }
1071}
1072
1073impl From<crate::execution_status::MoveLocation> for MoveLocation {
1074    fn from(value: crate::execution_status::MoveLocation) -> Self {
1075        Self {
1076            package: Address::new(value.module.address().into_bytes()),
1077            module: Identifier::new(value.module.name().as_str()).unwrap(),
1078            function: value.function,
1079            instruction: value.instruction,
1080            function_name: value
1081                .function_name
1082                .map(|name| Identifier::new(name).unwrap()),
1083        }
1084    }
1085}
1086
1087impl From<MoveLocation> for crate::execution_status::MoveLocation {
1088    fn from(value: MoveLocation) -> Self {
1089        Self {
1090            module: move_core_types::language_storage::ModuleId::new(
1091                move_core_types::account_address::AccountAddress::new(value.package.into_inner()),
1092                move_core_types::identifier::Identifier::new(value.module.as_str()).unwrap(),
1093            ),
1094            function: value.function,
1095            instruction: value.instruction,
1096            function_name: value.function_name.map(|ident| ident.as_str().into()),
1097        }
1098    }
1099}
1100
1101impl From<crate::execution_status::ExecutionStatus> for ExecutionStatus {
1102    fn from(value: crate::execution_status::ExecutionStatus) -> Self {
1103        match value {
1104            crate::execution_status::ExecutionStatus::Success => Self::Success,
1105            crate::execution_status::ExecutionStatus::Failure { error, command } => Self::Failure {
1106                error: error.into(),
1107                command: command.map(|c| c as u64),
1108            },
1109        }
1110    }
1111}
1112
1113impl From<crate::messages_checkpoint::CheckpointCommitment> for CheckpointCommitment {
1114    fn from(value: crate::messages_checkpoint::CheckpointCommitment) -> Self {
1115        match value {
1116            crate::messages_checkpoint::CheckpointCommitment::ECMHLiveObjectSetDigest(digest) => {
1117                Self::EcmhLiveObjectSet {
1118                    digest: digest.digest.into(),
1119                }
1120            }
1121            crate::messages_checkpoint::CheckpointCommitment::CheckpointArtifactsDigest(digest) => {
1122                Self::CheckpointArtifacts {
1123                    digest: digest.into(),
1124                }
1125            }
1126        }
1127    }
1128}
1129
1130impl TryFrom<crate::crypto::PublicKey> for MultisigMemberPublicKey {
1131    type Error = SdkTypeConversionError;
1132
1133    fn try_from(value: crate::crypto::PublicKey) -> Result<Self, Self::Error> {
1134        match value {
1135            crate::crypto::PublicKey::Ed25519(bytes_representation) => {
1136                Self::Ed25519(Ed25519PublicKey::new(bytes_representation.0))
1137            }
1138            crate::crypto::PublicKey::Secp256k1(bytes_representation) => {
1139                Self::Secp256k1(Secp256k1PublicKey::new(bytes_representation.0))
1140            }
1141            crate::crypto::PublicKey::Secp256r1(bytes_representation) => {
1142                Self::Secp256r1(Secp256r1PublicKey::new(bytes_representation.0))
1143            }
1144            crate::crypto::PublicKey::ZkLogin(z) => Self::ZkLogin(z.try_into()?),
1145            crate::crypto::PublicKey::Passkey(p) => {
1146                Self::Passkey(PasskeyPublicKey::new(Secp256r1PublicKey::new(p.0)))
1147            }
1148        }
1149        .pipe(Ok)
1150    }
1151}
1152
1153impl TryFrom<crate::crypto::CompressedSignature> for MultisigMemberSignature {
1154    type Error = SdkTypeConversionError;
1155
1156    fn try_from(value: crate::crypto::CompressedSignature) -> Result<Self, Self::Error> {
1157        match value {
1158            crate::crypto::CompressedSignature::Ed25519(bytes_representation) => {
1159                Self::Ed25519(Ed25519Signature::new(bytes_representation.0))
1160            }
1161            crate::crypto::CompressedSignature::Secp256k1(bytes_representation) => {
1162                Self::Secp256k1(Secp256k1Signature::new(bytes_representation.0))
1163            }
1164            crate::crypto::CompressedSignature::Secp256r1(bytes_representation) => {
1165                Self::Secp256r1(Secp256r1Signature::new(bytes_representation.0))
1166            }
1167            crate::crypto::CompressedSignature::ZkLogin(z) => {
1168                Self::ZkLogin(Box::new(z.try_into()?))
1169            }
1170            crate::crypto::CompressedSignature::Passkey(p) => Self::Passkey(p.try_into()?),
1171        }
1172        .pipe(Ok)
1173    }
1174}
1175
1176impl TryFrom<crate::crypto::Signature> for SimpleSignature {
1177    type Error = SdkTypeConversionError;
1178
1179    fn try_from(value: crate::crypto::Signature) -> Result<Self, Self::Error> {
1180        match value {
1181            crate::crypto::Signature::Ed25519SuiSignature(ed25519_sui_signature) => Self::Ed25519 {
1182                signature: Ed25519Signature::from_bytes(ed25519_sui_signature.signature_bytes())?,
1183                public_key: Ed25519PublicKey::from_bytes(ed25519_sui_signature.public_key_bytes())?,
1184            },
1185            crate::crypto::Signature::Secp256k1SuiSignature(secp256k1_sui_signature) => {
1186                Self::Secp256k1 {
1187                    signature: Secp256k1Signature::from_bytes(
1188                        secp256k1_sui_signature.signature_bytes(),
1189                    )?,
1190                    public_key: Secp256k1PublicKey::from_bytes(
1191                        secp256k1_sui_signature.public_key_bytes(),
1192                    )?,
1193                }
1194            }
1195
1196            crate::crypto::Signature::Secp256r1SuiSignature(secp256r1_sui_signature) => {
1197                Self::Secp256r1 {
1198                    signature: Secp256r1Signature::from_bytes(
1199                        secp256r1_sui_signature.signature_bytes(),
1200                    )?,
1201                    public_key: Secp256r1PublicKey::from_bytes(
1202                        secp256r1_sui_signature.public_key_bytes(),
1203                    )?,
1204                }
1205            }
1206        }
1207        .pipe(Ok)
1208    }
1209}
1210
1211impl From<crate::crypto::SignatureScheme> for SignatureScheme {
1212    fn from(value: crate::crypto::SignatureScheme) -> Self {
1213        match value {
1214            crate::crypto::SignatureScheme::ED25519 => Self::Ed25519,
1215            crate::crypto::SignatureScheme::Secp256k1 => Self::Secp256k1,
1216            crate::crypto::SignatureScheme::Secp256r1 => Self::Secp256r1,
1217            crate::crypto::SignatureScheme::BLS12381 => Self::Bls12381,
1218            crate::crypto::SignatureScheme::MultiSig => Self::Multisig,
1219            crate::crypto::SignatureScheme::ZkLoginAuthenticator => Self::ZkLogin,
1220            crate::crypto::SignatureScheme::PasskeyAuthenticator => Self::Passkey,
1221        }
1222    }
1223}
1224
1225impl From<crate::transaction::SharedObjectMutability> for Mutability {
1226    fn from(value: crate::transaction::SharedObjectMutability) -> Self {
1227        match value {
1228            crate::transaction::SharedObjectMutability::Immutable => Self::Immutable,
1229            crate::transaction::SharedObjectMutability::Mutable => Self::Mutable,
1230            crate::transaction::SharedObjectMutability::NonExclusiveWrite => {
1231                Self::NonExclusiveWrite
1232            }
1233        }
1234    }
1235}
1236
1237impl From<crate::transaction::CallArg> for Input {
1238    fn from(value: crate::transaction::CallArg) -> Self {
1239        match value {
1240            crate::transaction::CallArg::Pure(value) => Self::Pure(value),
1241            crate::transaction::CallArg::Object(object_arg) => match object_arg {
1242                crate::transaction::ObjectArg::ImmOrOwnedObject((id, version, digest)) => {
1243                    Self::ImmutableOrOwned(ObjectReference::new(
1244                        id.into(),
1245                        version.value(),
1246                        digest.into(),
1247                    ))
1248                }
1249                crate::transaction::ObjectArg::SharedObject {
1250                    id,
1251                    initial_shared_version,
1252                    mutability,
1253                } => Self::Shared(SharedInput::new(
1254                    id.into(),
1255                    initial_shared_version.value(),
1256                    mutability,
1257                )),
1258                crate::transaction::ObjectArg::Receiving((id, version, digest)) => Self::Receiving(
1259                    ObjectReference::new(id.into(), version.value(), digest.into()),
1260                ),
1261            },
1262            crate::transaction::CallArg::FundsWithdrawal(withdrawal) => {
1263                let amount = match withdrawal.reservation {
1264                    crate::transaction::Reservation::EntireBalance => {
1265                        todo!("entire balance isn't supported yet")
1266                    }
1267                    crate::transaction::Reservation::MaxAmountU64(amount) => amount,
1268                };
1269
1270                let crate::transaction::WithdrawalTypeArg::Balance(coin_type) = withdrawal.type_arg;
1271                let source = match withdrawal.withdraw_from {
1272                    crate::transaction::WithdrawFrom::Sender => sui_sdk_types::WithdrawFrom::Sender,
1273                    crate::transaction::WithdrawFrom::Sponsor => {
1274                        sui_sdk_types::WithdrawFrom::Sponsor
1275                    }
1276                };
1277
1278                Self::FundsWithdrawal(FundsWithdrawal::new(
1279                    amount,
1280                    coin_type.try_into().unwrap(),
1281                    source,
1282                ))
1283            }
1284        }
1285    }
1286}
1287
1288impl From<Input> for crate::transaction::CallArg {
1289    fn from(value: Input) -> Self {
1290        use crate::transaction::ObjectArg;
1291
1292        match value {
1293            Input::Pure(value) => Self::Pure(value),
1294            Input::ImmutableOrOwned(object_reference) => {
1295                let (id, version, digest) = object_reference.into_parts();
1296                Self::Object(ObjectArg::ImmOrOwnedObject((
1297                    id.into(),
1298                    version.into(),
1299                    digest.into(),
1300                )))
1301            }
1302            Input::Shared(shared_input) => Self::Object(ObjectArg::SharedObject {
1303                id: shared_input.object_id().into(),
1304                initial_shared_version: shared_input.version().into(),
1305                mutability: match shared_input.mutability() {
1306                    Mutability::Immutable => crate::transaction::SharedObjectMutability::Immutable,
1307                    Mutability::Mutable => crate::transaction::SharedObjectMutability::Mutable,
1308                    Mutability::NonExclusiveWrite => {
1309                        crate::transaction::SharedObjectMutability::NonExclusiveWrite
1310                    }
1311                },
1312            }),
1313            Input::Receiving(object_reference) => {
1314                let (id, version, digest) = object_reference.into_parts();
1315                Self::Object(ObjectArg::Receiving((
1316                    id.into(),
1317                    version.into(),
1318                    digest.into(),
1319                )))
1320            }
1321            Input::FundsWithdrawal(withdrawal) => {
1322                Self::FundsWithdrawal(crate::transaction::FundsWithdrawalArg {
1323                    reservation: withdrawal
1324                        .amount()
1325                        .map(crate::transaction::Reservation::MaxAmountU64)
1326                        .unwrap_or(crate::transaction::Reservation::EntireBalance),
1327                    type_arg: crate::transaction::WithdrawalTypeArg::Balance(
1328                        withdrawal.coin_type().to_owned().into(),
1329                    ),
1330                    withdraw_from: match withdrawal.source() {
1331                        sui_sdk_types::WithdrawFrom::Sender => {
1332                            crate::transaction::WithdrawFrom::Sender
1333                        }
1334                        sui_sdk_types::WithdrawFrom::Sponsor => {
1335                            crate::transaction::WithdrawFrom::Sponsor
1336                        }
1337                        _ => {
1338                            unreachable!("sdk shouldn't have a variant that the mono repo doesn't")
1339                        }
1340                    },
1341                })
1342            }
1343            _ => unreachable!("sdk shouldn't have a variant that the mono repo doesn't"),
1344        }
1345    }
1346}
1347
1348impl From<crate::transaction::Argument> for Argument {
1349    fn from(value: crate::transaction::Argument) -> Self {
1350        match value {
1351            crate::transaction::Argument::GasCoin => Self::Gas,
1352            crate::transaction::Argument::Input(idx) => Self::Input(idx),
1353            crate::transaction::Argument::Result(idx) => Self::Result(idx),
1354            crate::transaction::Argument::NestedResult(idx, sub_idx) => {
1355                Self::NestedResult(idx, sub_idx)
1356            }
1357        }
1358    }
1359}
1360
1361impl From<Argument> for crate::transaction::Argument {
1362    fn from(value: Argument) -> Self {
1363        match value {
1364            Argument::Gas => Self::GasCoin,
1365            Argument::Input(idx) => Self::Input(idx),
1366            Argument::Result(idx) => Self::Result(idx),
1367            Argument::NestedResult(idx, sub_idx) => Self::NestedResult(idx, sub_idx),
1368        }
1369    }
1370}
1371
1372impl TryFrom<TransactionEffects> for crate::effects::TransactionEffects {
1373    type Error = SdkTypeConversionError;
1374
1375    fn try_from(value: TransactionEffects) -> Result<Self, Self::Error> {
1376        match value {
1377            TransactionEffects::V1(v1) => Self::V1((*v1).try_into()?),
1378            TransactionEffects::V2(v2) => Self::V2((*v2).try_into()?),
1379        }
1380        .pipe(Ok)
1381    }
1382}
1383
1384impl TryFrom<crate::effects::TransactionEffects> for TransactionEffects {
1385    type Error = SdkTypeConversionError;
1386
1387    fn try_from(value: crate::effects::TransactionEffects) -> Result<Self, Self::Error> {
1388        match value {
1389            crate::effects::TransactionEffects::V1(v1) => Self::V1(Box::new(v1.try_into()?)),
1390            crate::effects::TransactionEffects::V2(v2) => Self::V2(Box::new(v2.try_into()?)),
1391        }
1392        .pipe(Ok)
1393    }
1394}
1395
1396impl TryFrom<crate::transaction::Command> for Command {
1397    type Error = SdkTypeConversionError;
1398
1399    fn try_from(value: crate::transaction::Command) -> Result<Self, Self::Error> {
1400        match value {
1401            crate::transaction::Command::MoveCall(programmable_move_call) => {
1402                Self::MoveCall((*programmable_move_call).try_into()?)
1403            }
1404            crate::transaction::Command::TransferObjects(vec, argument) => {
1405                Self::TransferObjects(TransferObjects {
1406                    objects: vec.into_iter().map(Into::into).collect(),
1407                    address: argument.into(),
1408                })
1409            }
1410            crate::transaction::Command::SplitCoins(argument, vec) => {
1411                Self::SplitCoins(SplitCoins {
1412                    coin: argument.into(),
1413                    amounts: vec.into_iter().map(Into::into).collect(),
1414                })
1415            }
1416            crate::transaction::Command::MergeCoins(argument, vec) => {
1417                Self::MergeCoins(MergeCoins {
1418                    coin: argument.into(),
1419                    coins_to_merge: vec.into_iter().map(Into::into).collect(),
1420                })
1421            }
1422            crate::transaction::Command::Publish(vec, vec1) => Self::Publish(Publish {
1423                modules: vec,
1424                dependencies: vec1.into_iter().map(Into::into).collect(),
1425            }),
1426            crate::transaction::Command::MakeMoveVec(type_input, elements) => {
1427                Self::MakeMoveVector(MakeMoveVector {
1428                    type_: type_input.map(TryInto::try_into).transpose()?,
1429                    elements: elements.into_iter().map(Into::into).collect(),
1430                })
1431            }
1432            crate::transaction::Command::Upgrade(modules, deps, object_id, ticket) => {
1433                Self::Upgrade(Upgrade {
1434                    modules,
1435                    dependencies: deps.into_iter().map(Into::into).collect(),
1436                    package: object_id.into(),
1437                    ticket: ticket.into(),
1438                })
1439            }
1440        }
1441        .pipe(Ok)
1442    }
1443}
1444
1445impl TryFrom<crate::transaction::ProgrammableMoveCall> for MoveCall {
1446    type Error = SdkTypeConversionError;
1447
1448    fn try_from(value: crate::transaction::ProgrammableMoveCall) -> Result<Self, Self::Error> {
1449        Self {
1450            package: value.package.into(),
1451            module: Identifier::new(value.module)?,
1452            function: Identifier::new(value.function)?,
1453            type_arguments: value
1454                .type_arguments
1455                .into_iter()
1456                .map(TryInto::try_into)
1457                .collect::<Result<_, _>>()?,
1458            arguments: value.arguments.into_iter().map(Into::into).collect(),
1459        }
1460        .pipe(Ok)
1461    }
1462}
1463
1464impl From<MoveCall> for crate::transaction::ProgrammableMoveCall {
1465    fn from(value: MoveCall) -> Self {
1466        Self {
1467            package: value.package.into(),
1468            module: value.module.as_str().into(),
1469            function: value.function.as_str().into(),
1470            type_arguments: value.type_arguments.into_iter().map(Into::into).collect(),
1471            arguments: value.arguments.into_iter().map(Into::into).collect(),
1472        }
1473    }
1474}
1475
1476impl From<Command> for crate::transaction::Command {
1477    fn from(value: Command) -> Self {
1478        match value {
1479            Command::MoveCall(move_call) => Self::MoveCall(Box::new(move_call.into())),
1480            Command::TransferObjects(TransferObjects { objects, address }) => {
1481                Self::TransferObjects(
1482                    objects.into_iter().map(Into::into).collect(),
1483                    address.into(),
1484                )
1485            }
1486            Command::SplitCoins(SplitCoins { coin, amounts }) => {
1487                Self::SplitCoins(coin.into(), amounts.into_iter().map(Into::into).collect())
1488            }
1489            Command::MergeCoins(MergeCoins {
1490                coin,
1491                coins_to_merge,
1492            }) => Self::MergeCoins(
1493                coin.into(),
1494                coins_to_merge.into_iter().map(Into::into).collect(),
1495            ),
1496            Command::Publish(Publish {
1497                modules,
1498                dependencies,
1499            }) => Self::Publish(modules, dependencies.into_iter().map(Into::into).collect()),
1500            Command::MakeMoveVector(MakeMoveVector { type_, elements }) => Self::MakeMoveVec(
1501                type_.map(Into::into),
1502                elements.into_iter().map(Into::into).collect(),
1503            ),
1504            Command::Upgrade(Upgrade {
1505                modules,
1506                dependencies,
1507                package,
1508                ticket,
1509            }) => Self::Upgrade(
1510                modules,
1511                dependencies.into_iter().map(Into::into).collect(),
1512                package.into(),
1513                ticket.into(),
1514            ),
1515            _ => unreachable!("sdk shouldn't have a variant that the mono repo doesn't"),
1516        }
1517    }
1518}
1519
1520impl From<crate::transaction::StoredExecutionTimeObservations> for ExecutionTimeObservations {
1521    fn from(value: crate::transaction::StoredExecutionTimeObservations) -> Self {
1522        match value {
1523            crate::transaction::StoredExecutionTimeObservations::V1(vec) => Self::V1(
1524                vec.into_iter()
1525                    .map(|(key, value)| {
1526                        (
1527                            key.into(),
1528                            value
1529                                .into_iter()
1530                                .map(|(name, duration)| ValidatorExecutionTimeObservation {
1531                                    validator: name.into(),
1532                                    duration,
1533                                })
1534                                .collect(),
1535                        )
1536                    })
1537                    .collect(),
1538            ),
1539        }
1540    }
1541}
1542
1543impl From<crate::execution::ExecutionTimeObservationKey> for ExecutionTimeObservationKey {
1544    fn from(value: crate::execution::ExecutionTimeObservationKey) -> Self {
1545        match value {
1546            crate::execution::ExecutionTimeObservationKey::MoveEntryPoint {
1547                package,
1548                module,
1549                function,
1550                type_arguments,
1551            } => Self::MoveEntryPoint {
1552                package: package.into(),
1553                module,
1554                function,
1555                type_arguments: type_arguments
1556                    .into_iter()
1557                    .map(TryInto::try_into)
1558                    .collect::<Result<_, _>>()
1559                    .unwrap(),
1560            },
1561            crate::execution::ExecutionTimeObservationKey::TransferObjects => Self::TransferObjects,
1562            crate::execution::ExecutionTimeObservationKey::SplitCoins => Self::SplitCoins,
1563            crate::execution::ExecutionTimeObservationKey::MergeCoins => Self::MergeCoins,
1564            crate::execution::ExecutionTimeObservationKey::Publish => Self::Publish,
1565            crate::execution::ExecutionTimeObservationKey::MakeMoveVec => Self::MakeMoveVec,
1566            crate::execution::ExecutionTimeObservationKey::Upgrade => Self::Upgrade,
1567        }
1568    }
1569}
1570
1571impl From<crate::transaction::EndOfEpochTransactionKind> for EndOfEpochTransactionKind {
1572    fn from(value: crate::transaction::EndOfEpochTransactionKind) -> Self {
1573        match value {
1574            crate::transaction::EndOfEpochTransactionKind::ChangeEpoch(change_epoch) => {
1575                Self::ChangeEpoch(change_epoch.into())
1576            }
1577            crate::transaction::EndOfEpochTransactionKind::AuthenticatorStateCreate => {
1578                Self::AuthenticatorStateCreate
1579            }
1580            crate::transaction::EndOfEpochTransactionKind::AuthenticatorStateExpire(
1581                authenticator_state_expire,
1582            ) => Self::AuthenticatorStateExpire(authenticator_state_expire.into()),
1583            crate::transaction::EndOfEpochTransactionKind::RandomnessStateCreate => {
1584                Self::RandomnessStateCreate
1585            }
1586            crate::transaction::EndOfEpochTransactionKind::DenyListStateCreate => {
1587                Self::DenyListStateCreate
1588            }
1589            crate::transaction::EndOfEpochTransactionKind::BridgeStateCreate(chain_identifier) => {
1590                Self::BridgeStateCreate {
1591                    chain_id: Digest::new(chain_identifier.as_bytes().to_owned()),
1592                }
1593            }
1594            crate::transaction::EndOfEpochTransactionKind::BridgeCommitteeInit(sequence_number) => {
1595                Self::BridgeCommitteeInit {
1596                    bridge_object_version: sequence_number.value(),
1597                }
1598            }
1599            crate::transaction::EndOfEpochTransactionKind::StoreExecutionTimeObservations(
1600                stored_execution_time_observations,
1601            ) => Self::StoreExecutionTimeObservations(stored_execution_time_observations.into()),
1602            crate::transaction::EndOfEpochTransactionKind::AccumulatorRootCreate => {
1603                Self::AccumulatorRootCreate
1604            }
1605            crate::transaction::EndOfEpochTransactionKind::CoinRegistryCreate => {
1606                Self::CoinRegistryCreate
1607            }
1608            crate::transaction::EndOfEpochTransactionKind::DisplayRegistryCreate => {
1609                Self::DisplayRegistryCreate
1610            }
1611            crate::transaction::EndOfEpochTransactionKind::AddressAliasStateCreate => {
1612                Self::AddressAliasStateCreate
1613            }
1614        }
1615    }
1616}
1617
1618impl From<crate::transaction::ChangeEpoch> for ChangeEpoch {
1619    fn from(
1620        crate::transaction::ChangeEpoch {
1621            epoch,
1622            protocol_version,
1623            storage_charge,
1624            computation_charge,
1625            storage_rebate,
1626            non_refundable_storage_fee,
1627            epoch_start_timestamp_ms,
1628            system_packages,
1629        }: crate::transaction::ChangeEpoch,
1630    ) -> Self {
1631        Self {
1632            epoch,
1633            protocol_version: protocol_version.as_u64(),
1634            storage_charge,
1635            computation_charge,
1636            storage_rebate,
1637            non_refundable_storage_fee,
1638            epoch_start_timestamp_ms,
1639            system_packages: system_packages
1640                .into_iter()
1641                .map(|(version, modules, dependencies)| SystemPackage {
1642                    version: version.value(),
1643                    modules,
1644                    dependencies: dependencies.into_iter().map(Into::into).collect(),
1645                })
1646                .collect(),
1647        }
1648    }
1649}
1650
1651impl From<crate::transaction::AuthenticatorStateExpire> for AuthenticatorStateExpire {
1652    fn from(value: crate::transaction::AuthenticatorStateExpire) -> Self {
1653        Self {
1654            min_epoch: value.min_epoch,
1655            authenticator_object_initial_shared_version: value
1656                .authenticator_obj_initial_shared_version
1657                .value(),
1658        }
1659    }
1660}
1661
1662impl From<crate::messages_consensus::ConsensusDeterminedVersionAssignments>
1663    for ConsensusDeterminedVersionAssignments
1664{
1665    fn from(value: crate::messages_consensus::ConsensusDeterminedVersionAssignments) -> Self {
1666        use crate::messages_consensus::ConsensusDeterminedVersionAssignments::*;
1667        match value {
1668            CancelledTransactions(vec) => Self::CanceledTransactions {
1669                canceled_transactions: vec
1670                    .into_iter()
1671                    .map(|(digest, assignments)| CanceledTransaction {
1672                        digest: digest.into(),
1673                        version_assignments: assignments
1674                            .into_iter()
1675                            .map(|(id, version)| VersionAssignment {
1676                                object_id: id.into(),
1677                                version: version.value(),
1678                            })
1679                            .collect(),
1680                    })
1681                    .collect(),
1682            },
1683            CancelledTransactionsV2(canceled_transactions) => Self::CanceledTransactionsV2 {
1684                canceled_transactions: canceled_transactions
1685                    .into_iter()
1686                    .map(|(digest, assignments)| CanceledTransactionV2 {
1687                        digest: digest.into(),
1688                        version_assignments: assignments
1689                            .into_iter()
1690                            .map(|((id, start_version), version)| VersionAssignmentV2 {
1691                                object_id: id.into(),
1692                                start_version: start_version.value(),
1693                                version: version.value(),
1694                            })
1695                            .collect(),
1696                    })
1697                    .collect(),
1698            },
1699        }
1700    }
1701}
1702
1703impl From<crate::authenticator_state::ActiveJwk> for ActiveJwk {
1704    fn from(value: crate::authenticator_state::ActiveJwk) -> Self {
1705        let crate::authenticator_state::ActiveJwk { jwk_id, jwk, epoch } = value;
1706        Self {
1707            jwk_id: JwkId {
1708                iss: jwk_id.iss,
1709                kid: jwk_id.kid,
1710            },
1711            jwk: Jwk {
1712                kty: jwk.kty,
1713                e: jwk.e,
1714                n: jwk.n,
1715                alg: jwk.alg,
1716            },
1717            epoch,
1718        }
1719    }
1720}
1721
1722// TODO remaining set of enums to add impls for to ensure new additions are caught during review
1723//
1724// impl From<crate::transaction::TransactionKind> for TransactionKind {
1725//     fn from(value: crate::transaction::TransactionKind) -> Self {
1726//         todo!()
1727//     }
1728// }
1729// src/object.rs:pub enum ObjectData {