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