1use 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, MoveCall, MoveLocation, MovePackage,
21 MultisigMemberPublicKey, MultisigMemberSignature, Mutability, Object, ObjectIn, ObjectOut,
22 ObjectReference, Owner, PackageUpgradeError, PasskeyAuthenticator, PasskeyPublicKey, Publish,
23 Secp256k1PublicKey, Secp256k1Signature, Secp256r1PublicKey, Secp256r1Signature, SharedInput,
24 SignatureScheme, SignedCheckpointSummary, SignedTransaction, SimpleSignature, SplitCoins,
25 StructTag, SystemPackage, Transaction, TransactionEffects, TransactionEffectsV1,
26 TransactionEffectsV2, TransactionEvents, TransactionExpiration, TransactionKind,
27 TransferObjects, TypeArgumentError, TypeParseError, TypeTag, UnchangedConsensusKind, Upgrade,
28 UserSignature, ValidatorAggregatedSignature, ValidatorCommittee, ValidatorCommitteeMember,
29 ValidatorExecutionTimeObservation, VersionAssignment, VersionAssignmentV2,
30 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 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 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 }
1216 .pipe(Ok)
1217 }
1218}
1219
1220impl TryFrom<crate::crypto::CompressedSignature> for MultisigMemberSignature {
1221 type Error = SdkTypeConversionError;
1222
1223 fn try_from(value: crate::crypto::CompressedSignature) -> Result<Self, Self::Error> {
1224 match value {
1225 crate::crypto::CompressedSignature::Ed25519(bytes_representation) => {
1226 Self::Ed25519(Ed25519Signature::new(bytes_representation.0))
1227 }
1228 crate::crypto::CompressedSignature::Secp256k1(bytes_representation) => {
1229 Self::Secp256k1(Secp256k1Signature::new(bytes_representation.0))
1230 }
1231 crate::crypto::CompressedSignature::Secp256r1(bytes_representation) => {
1232 Self::Secp256r1(Secp256r1Signature::new(bytes_representation.0))
1233 }
1234 crate::crypto::CompressedSignature::ZkLogin(z) => {
1235 Self::ZkLogin(Box::new(z.try_into()?))
1236 }
1237 crate::crypto::CompressedSignature::Passkey(p) => Self::Passkey(p.try_into()?),
1238 }
1239 .pipe(Ok)
1240 }
1241}
1242
1243impl TryFrom<crate::crypto::Signature> for SimpleSignature {
1244 type Error = SdkTypeConversionError;
1245
1246 fn try_from(value: crate::crypto::Signature) -> Result<Self, Self::Error> {
1247 match value {
1248 crate::crypto::Signature::Ed25519SuiSignature(ed25519_sui_signature) => Self::Ed25519 {
1249 signature: Ed25519Signature::from_bytes(ed25519_sui_signature.signature_bytes())?,
1250 public_key: Ed25519PublicKey::from_bytes(ed25519_sui_signature.public_key_bytes())?,
1251 },
1252 crate::crypto::Signature::Secp256k1SuiSignature(secp256k1_sui_signature) => {
1253 Self::Secp256k1 {
1254 signature: Secp256k1Signature::from_bytes(
1255 secp256k1_sui_signature.signature_bytes(),
1256 )?,
1257 public_key: Secp256k1PublicKey::from_bytes(
1258 secp256k1_sui_signature.public_key_bytes(),
1259 )?,
1260 }
1261 }
1262
1263 crate::crypto::Signature::Secp256r1SuiSignature(secp256r1_sui_signature) => {
1264 Self::Secp256r1 {
1265 signature: Secp256r1Signature::from_bytes(
1266 secp256r1_sui_signature.signature_bytes(),
1267 )?,
1268 public_key: Secp256r1PublicKey::from_bytes(
1269 secp256r1_sui_signature.public_key_bytes(),
1270 )?,
1271 }
1272 }
1273 }
1274 .pipe(Ok)
1275 }
1276}
1277
1278impl From<crate::crypto::SignatureScheme> for SignatureScheme {
1279 fn from(value: crate::crypto::SignatureScheme) -> Self {
1280 match value {
1281 crate::crypto::SignatureScheme::ED25519 => Self::Ed25519,
1282 crate::crypto::SignatureScheme::Secp256k1 => Self::Secp256k1,
1283 crate::crypto::SignatureScheme::Secp256r1 => Self::Secp256r1,
1284 crate::crypto::SignatureScheme::BLS12381 => Self::Bls12381,
1285 crate::crypto::SignatureScheme::MultiSig => Self::Multisig,
1286 crate::crypto::SignatureScheme::ZkLoginAuthenticator => Self::ZkLogin,
1287 crate::crypto::SignatureScheme::PasskeyAuthenticator => Self::Passkey,
1288 }
1289 }
1290}
1291
1292impl From<crate::transaction::SharedObjectMutability> for Mutability {
1293 fn from(value: crate::transaction::SharedObjectMutability) -> Self {
1294 match value {
1295 crate::transaction::SharedObjectMutability::Immutable => Self::Immutable,
1296 crate::transaction::SharedObjectMutability::Mutable => Self::Mutable,
1297 crate::transaction::SharedObjectMutability::NonExclusiveWrite => {
1298 Self::NonExclusiveWrite
1299 }
1300 }
1301 }
1302}
1303
1304impl From<crate::transaction::CallArg> for Input {
1305 fn from(value: crate::transaction::CallArg) -> Self {
1306 match value {
1307 crate::transaction::CallArg::Pure(value) => Self::Pure(value),
1308 crate::transaction::CallArg::Object(object_arg) => match object_arg {
1309 crate::transaction::ObjectArg::ImmOrOwnedObject((id, version, digest)) => {
1310 Self::ImmutableOrOwned(ObjectReference::new(
1311 id.into(),
1312 version.value(),
1313 digest.into(),
1314 ))
1315 }
1316 crate::transaction::ObjectArg::SharedObject {
1317 id,
1318 initial_shared_version,
1319 mutability,
1320 } => Self::Shared(SharedInput::new(
1321 id.into(),
1322 initial_shared_version.value(),
1323 mutability,
1324 )),
1325 crate::transaction::ObjectArg::Receiving((id, version, digest)) => Self::Receiving(
1326 ObjectReference::new(id.into(), version.value(), digest.into()),
1327 ),
1328 },
1329 crate::transaction::CallArg::FundsWithdrawal(withdrawal) => {
1330 let crate::transaction::Reservation::MaxAmountU64(amount) = withdrawal.reservation;
1331 let crate::transaction::WithdrawalTypeArg::Balance(coin_type) = withdrawal.type_arg;
1332 let source = match withdrawal.withdraw_from {
1333 crate::transaction::WithdrawFrom::Sender => sui_sdk_types::WithdrawFrom::Sender,
1334 crate::transaction::WithdrawFrom::Sponsor => {
1335 sui_sdk_types::WithdrawFrom::Sponsor
1336 }
1337 crate::transaction::WithdrawFrom::SenderAllowance { funder, allowance } => {
1338 sui_sdk_types::WithdrawFrom::SenderAllowance {
1339 funder: funder.into(),
1340 allowance: allowance.into(),
1341 }
1342 }
1343 };
1344
1345 Self::FundsWithdrawal(FundsWithdrawal::new(
1346 amount,
1347 type_tag_core_to_sdk(coin_type).unwrap(),
1348 source,
1349 ))
1350 }
1351 }
1352 }
1353}
1354
1355impl From<Input> for crate::transaction::CallArg {
1356 fn from(value: Input) -> Self {
1357 use crate::transaction::ObjectArg;
1358
1359 match value {
1360 Input::Pure(value) => Self::Pure(value),
1361 Input::ImmutableOrOwned(object_reference) => {
1362 let (id, version, digest) = object_reference.into_parts();
1363 Self::Object(ObjectArg::ImmOrOwnedObject((
1364 id.into(),
1365 version.into(),
1366 digest.into(),
1367 )))
1368 }
1369 Input::Shared(shared_input) => Self::Object(ObjectArg::SharedObject {
1370 id: shared_input.object_id().into(),
1371 initial_shared_version: shared_input.version().into(),
1372 mutability: match shared_input.mutability() {
1373 Mutability::Immutable => crate::transaction::SharedObjectMutability::Immutable,
1374 Mutability::Mutable => crate::transaction::SharedObjectMutability::Mutable,
1375 Mutability::NonExclusiveWrite => {
1376 crate::transaction::SharedObjectMutability::NonExclusiveWrite
1377 }
1378 },
1379 }),
1380 Input::Receiving(object_reference) => {
1381 let (id, version, digest) = object_reference.into_parts();
1382 Self::Object(ObjectArg::Receiving((
1383 id.into(),
1384 version.into(),
1385 digest.into(),
1386 )))
1387 }
1388 Input::FundsWithdrawal(withdrawal) => {
1389 Self::FundsWithdrawal(crate::transaction::FundsWithdrawalArg {
1390 reservation: withdrawal
1391 .amount()
1392 .map(crate::transaction::Reservation::MaxAmountU64)
1393 .unwrap(),
1394 type_arg: crate::transaction::WithdrawalTypeArg::Balance(
1395 type_tag_sdk_to_core(withdrawal.coin_type().to_owned()).unwrap(),
1396 ),
1397 withdraw_from: match withdrawal.source() {
1398 sui_sdk_types::WithdrawFrom::Sender => {
1399 crate::transaction::WithdrawFrom::Sender
1400 }
1401 sui_sdk_types::WithdrawFrom::Sponsor => {
1402 crate::transaction::WithdrawFrom::Sponsor
1403 }
1404 sui_sdk_types::WithdrawFrom::SenderAllowance { funder, allowance } => {
1405 crate::transaction::WithdrawFrom::SenderAllowance {
1406 funder: funder.into(),
1407 allowance: allowance.into(),
1408 }
1409 }
1410 _ => {
1411 unreachable!("sdk shouldn't have a variant that the mono repo doesn't")
1412 }
1413 },
1414 })
1415 }
1416 _ => unreachable!("sdk shouldn't have a variant that the mono repo doesn't"),
1417 }
1418 }
1419}
1420
1421impl From<crate::transaction::Argument> for Argument {
1422 fn from(value: crate::transaction::Argument) -> Self {
1423 match value {
1424 crate::transaction::Argument::GasCoin => Self::Gas,
1425 crate::transaction::Argument::Input(idx) => Self::Input(idx),
1426 crate::transaction::Argument::Result(idx) => Self::Result(idx),
1427 crate::transaction::Argument::NestedResult(idx, sub_idx) => {
1428 Self::NestedResult(idx, sub_idx)
1429 }
1430 }
1431 }
1432}
1433
1434impl From<Argument> for crate::transaction::Argument {
1435 fn from(value: Argument) -> Self {
1436 match value {
1437 Argument::Gas => Self::GasCoin,
1438 Argument::Input(idx) => Self::Input(idx),
1439 Argument::Result(idx) => Self::Result(idx),
1440 Argument::NestedResult(idx, sub_idx) => Self::NestedResult(idx, sub_idx),
1441 }
1442 }
1443}
1444
1445impl TryFrom<TransactionEffects> for crate::effects::TransactionEffects {
1446 type Error = SdkTypeConversionError;
1447
1448 fn try_from(value: TransactionEffects) -> Result<Self, Self::Error> {
1449 match value {
1450 TransactionEffects::V1(v1) => Self::V1((*v1).try_into()?),
1451 TransactionEffects::V2(v2) => Self::V2((*v2).try_into()?),
1452 }
1453 .pipe(Ok)
1454 }
1455}
1456
1457impl TryFrom<crate::effects::TransactionEffects> for TransactionEffects {
1458 type Error = SdkTypeConversionError;
1459
1460 fn try_from(value: crate::effects::TransactionEffects) -> Result<Self, Self::Error> {
1461 match value {
1462 crate::effects::TransactionEffects::V1(v1) => Self::V1(Box::new(v1.try_into()?)),
1463 crate::effects::TransactionEffects::V2(v2) => Self::V2(Box::new(v2.try_into()?)),
1464 }
1465 .pipe(Ok)
1466 }
1467}
1468
1469impl TryFrom<crate::transaction::Command> for Command {
1470 type Error = SdkTypeConversionError;
1471
1472 fn try_from(value: crate::transaction::Command) -> Result<Self, Self::Error> {
1473 match value {
1474 crate::transaction::Command::MoveCall(programmable_move_call) => {
1475 Self::MoveCall((*programmable_move_call).try_into()?)
1476 }
1477 crate::transaction::Command::TransferObjects(vec, argument) => {
1478 Self::TransferObjects(TransferObjects {
1479 objects: vec.into_iter().map(Into::into).collect(),
1480 address: argument.into(),
1481 })
1482 }
1483 crate::transaction::Command::SplitCoins(argument, vec) => {
1484 Self::SplitCoins(SplitCoins {
1485 coin: argument.into(),
1486 amounts: vec.into_iter().map(Into::into).collect(),
1487 })
1488 }
1489 crate::transaction::Command::MergeCoins(argument, vec) => {
1490 Self::MergeCoins(MergeCoins {
1491 coin: argument.into(),
1492 coins_to_merge: vec.into_iter().map(Into::into).collect(),
1493 })
1494 }
1495 crate::transaction::Command::Publish(vec, vec1) => Self::Publish(Publish {
1496 modules: vec,
1497 dependencies: vec1.into_iter().map(Into::into).collect(),
1498 }),
1499 crate::transaction::Command::MakeMoveVec(type_input, elements) => {
1500 Self::MakeMoveVector(MakeMoveVector {
1501 type_: type_input.map(TryInto::try_into).transpose()?,
1502 elements: elements.into_iter().map(Into::into).collect(),
1503 })
1504 }
1505 crate::transaction::Command::Upgrade(modules, deps, object_id, ticket) => {
1506 Self::Upgrade(Upgrade {
1507 modules,
1508 dependencies: deps.into_iter().map(Into::into).collect(),
1509 package: object_id.into(),
1510 ticket: ticket.into(),
1511 })
1512 }
1513 }
1514 .pipe(Ok)
1515 }
1516}
1517
1518impl TryFrom<crate::transaction::ProgrammableMoveCall> for MoveCall {
1519 type Error = SdkTypeConversionError;
1520
1521 fn try_from(value: crate::transaction::ProgrammableMoveCall) -> Result<Self, Self::Error> {
1522 Self {
1523 package: value.package.into(),
1524 module: Identifier::new(value.module)?,
1525 function: Identifier::new(value.function)?,
1526 type_arguments: value
1527 .type_arguments
1528 .into_iter()
1529 .map(TryInto::try_into)
1530 .collect::<Result<_, _>>()?,
1531 arguments: value.arguments.into_iter().map(Into::into).collect(),
1532 }
1533 .pipe(Ok)
1534 }
1535}
1536
1537impl From<MoveCall> for crate::transaction::ProgrammableMoveCall {
1538 fn from(value: MoveCall) -> Self {
1539 Self {
1540 package: value.package.into(),
1541 module: value.module.as_str().into(),
1542 function: value.function.as_str().into(),
1543 type_arguments: value.type_arguments.into_iter().map(Into::into).collect(),
1544 arguments: value.arguments.into_iter().map(Into::into).collect(),
1545 }
1546 }
1547}
1548
1549impl From<Command> for crate::transaction::Command {
1550 fn from(value: Command) -> Self {
1551 match value {
1552 Command::MoveCall(move_call) => Self::MoveCall(Box::new(move_call.into())),
1553 Command::TransferObjects(TransferObjects { objects, address }) => {
1554 Self::TransferObjects(
1555 objects.into_iter().map(Into::into).collect(),
1556 address.into(),
1557 )
1558 }
1559 Command::SplitCoins(SplitCoins { coin, amounts }) => {
1560 Self::SplitCoins(coin.into(), amounts.into_iter().map(Into::into).collect())
1561 }
1562 Command::MergeCoins(MergeCoins {
1563 coin,
1564 coins_to_merge,
1565 }) => Self::MergeCoins(
1566 coin.into(),
1567 coins_to_merge.into_iter().map(Into::into).collect(),
1568 ),
1569 Command::Publish(Publish {
1570 modules,
1571 dependencies,
1572 }) => Self::Publish(modules, dependencies.into_iter().map(Into::into).collect()),
1573 Command::MakeMoveVector(MakeMoveVector { type_, elements }) => Self::MakeMoveVec(
1574 type_.map(Into::into),
1575 elements.into_iter().map(Into::into).collect(),
1576 ),
1577 Command::Upgrade(Upgrade {
1578 modules,
1579 dependencies,
1580 package,
1581 ticket,
1582 }) => Self::Upgrade(
1583 modules,
1584 dependencies.into_iter().map(Into::into).collect(),
1585 package.into(),
1586 ticket.into(),
1587 ),
1588 _ => unreachable!("sdk shouldn't have a variant that the mono repo doesn't"),
1589 }
1590 }
1591}
1592
1593impl From<crate::transaction::StoredExecutionTimeObservations> for ExecutionTimeObservations {
1594 fn from(value: crate::transaction::StoredExecutionTimeObservations) -> Self {
1595 match value {
1596 crate::transaction::StoredExecutionTimeObservations::V1(vec) => Self::V1(
1597 vec.into_iter()
1598 .map(|(key, value)| {
1599 (
1600 key.into(),
1601 value
1602 .into_iter()
1603 .map(|(name, duration)| ValidatorExecutionTimeObservation {
1604 validator: name.into(),
1605 duration,
1606 })
1607 .collect(),
1608 )
1609 })
1610 .collect(),
1611 ),
1612 }
1613 }
1614}
1615
1616impl From<crate::execution::ExecutionTimeObservationKey> for ExecutionTimeObservationKey {
1617 fn from(value: crate::execution::ExecutionTimeObservationKey) -> Self {
1618 match value {
1619 crate::execution::ExecutionTimeObservationKey::MoveEntryPoint {
1620 package,
1621 module,
1622 function,
1623 type_arguments,
1624 } => Self::MoveEntryPoint {
1625 package: package.into(),
1626 module,
1627 function,
1628 type_arguments: type_arguments
1629 .into_iter()
1630 .map(TryInto::try_into)
1631 .collect::<Result<_, _>>()
1632 .unwrap(),
1633 },
1634 crate::execution::ExecutionTimeObservationKey::TransferObjects => Self::TransferObjects,
1635 crate::execution::ExecutionTimeObservationKey::SplitCoins => Self::SplitCoins,
1636 crate::execution::ExecutionTimeObservationKey::MergeCoins => Self::MergeCoins,
1637 crate::execution::ExecutionTimeObservationKey::Publish => Self::Publish,
1638 crate::execution::ExecutionTimeObservationKey::MakeMoveVec => Self::MakeMoveVec,
1639 crate::execution::ExecutionTimeObservationKey::Upgrade => Self::Upgrade,
1640 }
1641 }
1642}
1643
1644impl From<crate::transaction::EndOfEpochTransactionKind> for EndOfEpochTransactionKind {
1645 fn from(value: crate::transaction::EndOfEpochTransactionKind) -> Self {
1646 match value {
1647 crate::transaction::EndOfEpochTransactionKind::ChangeEpoch(change_epoch) => {
1648 Self::ChangeEpoch(change_epoch.into())
1649 }
1650 crate::transaction::EndOfEpochTransactionKind::AuthenticatorStateCreate => {
1651 Self::AuthenticatorStateCreate
1652 }
1653 crate::transaction::EndOfEpochTransactionKind::AuthenticatorStateExpire(
1654 authenticator_state_expire,
1655 ) => Self::AuthenticatorStateExpire(authenticator_state_expire.into()),
1656 crate::transaction::EndOfEpochTransactionKind::RandomnessStateCreate => {
1657 Self::RandomnessStateCreate
1658 }
1659 crate::transaction::EndOfEpochTransactionKind::DenyListStateCreate => {
1660 Self::DenyListStateCreate
1661 }
1662 crate::transaction::EndOfEpochTransactionKind::BridgeStateCreate(chain_identifier) => {
1663 Self::BridgeStateCreate {
1664 chain_id: Digest::new(chain_identifier.as_bytes().to_owned()),
1665 }
1666 }
1667 crate::transaction::EndOfEpochTransactionKind::BridgeCommitteeInit(sequence_number) => {
1668 Self::BridgeCommitteeInit {
1669 bridge_object_version: sequence_number.value(),
1670 }
1671 }
1672 crate::transaction::EndOfEpochTransactionKind::StoreExecutionTimeObservations(
1673 stored_execution_time_observations,
1674 ) => Self::StoreExecutionTimeObservations(stored_execution_time_observations.into()),
1675 crate::transaction::EndOfEpochTransactionKind::AccumulatorRootCreate => {
1676 Self::AccumulatorRootCreate
1677 }
1678 crate::transaction::EndOfEpochTransactionKind::CoinRegistryCreate => {
1679 Self::CoinRegistryCreate
1680 }
1681 crate::transaction::EndOfEpochTransactionKind::DisplayRegistryCreate => {
1682 Self::DisplayRegistryCreate
1683 }
1684 crate::transaction::EndOfEpochTransactionKind::AddressAliasStateCreate => {
1685 Self::AddressAliasStateCreate
1686 }
1687 crate::transaction::EndOfEpochTransactionKind::WriteAccumulatorStorageCost(
1688 storage_cost,
1689 ) => Self::WriteAccumulatorStorageCost {
1690 storage_cost: storage_cost.storage_cost,
1691 },
1692 crate::transaction::EndOfEpochTransactionKind::ForwardingAddressRegistryCreate => {
1693 Self::ForwardingAddressRegistryCreate
1694 }
1695 }
1696 }
1697}
1698
1699impl From<crate::transaction::ChangeEpoch> for ChangeEpoch {
1700 fn from(
1701 crate::transaction::ChangeEpoch {
1702 epoch,
1703 protocol_version,
1704 storage_charge,
1705 computation_charge,
1706 storage_rebate,
1707 non_refundable_storage_fee,
1708 epoch_start_timestamp_ms,
1709 system_packages,
1710 }: crate::transaction::ChangeEpoch,
1711 ) -> Self {
1712 Self {
1713 epoch,
1714 protocol_version: protocol_version.as_u64(),
1715 storage_charge,
1716 computation_charge,
1717 storage_rebate,
1718 non_refundable_storage_fee,
1719 epoch_start_timestamp_ms,
1720 system_packages: system_packages
1721 .into_iter()
1722 .map(|(version, modules, dependencies)| SystemPackage {
1723 version: version.value(),
1724 modules,
1725 dependencies: dependencies.into_iter().map(Into::into).collect(),
1726 })
1727 .collect(),
1728 }
1729 }
1730}
1731
1732impl From<crate::transaction::AuthenticatorStateExpire> for AuthenticatorStateExpire {
1733 fn from(value: crate::transaction::AuthenticatorStateExpire) -> Self {
1734 Self {
1735 min_epoch: value.min_epoch,
1736 authenticator_object_initial_shared_version: value
1737 .authenticator_obj_initial_shared_version
1738 .value(),
1739 }
1740 }
1741}
1742
1743impl From<crate::messages_consensus::ConsensusDeterminedVersionAssignments>
1744 for ConsensusDeterminedVersionAssignments
1745{
1746 fn from(value: crate::messages_consensus::ConsensusDeterminedVersionAssignments) -> Self {
1747 use crate::messages_consensus::ConsensusDeterminedVersionAssignments::*;
1748 match value {
1749 CancelledTransactions(vec) => Self::CanceledTransactions {
1750 canceled_transactions: vec
1751 .into_iter()
1752 .map(|(digest, assignments)| CanceledTransaction {
1753 digest: digest.into(),
1754 version_assignments: assignments
1755 .into_iter()
1756 .map(|(id, version)| VersionAssignment {
1757 object_id: id.into(),
1758 version: version.value(),
1759 })
1760 .collect(),
1761 })
1762 .collect(),
1763 },
1764 CancelledTransactionsV2(canceled_transactions) => Self::CanceledTransactionsV2 {
1765 canceled_transactions: canceled_transactions
1766 .into_iter()
1767 .map(|(digest, assignments)| CanceledTransactionV2 {
1768 digest: digest.into(),
1769 version_assignments: assignments
1770 .into_iter()
1771 .map(|((id, start_version), version)| VersionAssignmentV2 {
1772 object_id: id.into(),
1773 start_version: start_version.value(),
1774 version: version.value(),
1775 })
1776 .collect(),
1777 })
1778 .collect(),
1779 },
1780 }
1781 }
1782}
1783
1784impl From<crate::authenticator_state::ActiveJwk> for ActiveJwk {
1785 fn from(value: crate::authenticator_state::ActiveJwk) -> Self {
1786 let crate::authenticator_state::ActiveJwk { jwk_id, jwk, epoch } = value;
1787 Self {
1788 jwk_id: JwkId {
1789 iss: jwk_id.iss,
1790 kid: jwk_id.kid,
1791 },
1792 jwk: Jwk {
1793 kty: jwk.kty,
1794 e: jwk.e,
1795 n: jwk.n,
1796 alg: jwk.alg,
1797 },
1798 epoch,
1799 }
1800 }
1801}
1802
1803