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