Skip to main content

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