celestia_types/
error.rs

1use crate::consts::appconsts;
2
3/// Alias for a `Result` with the error type [`celestia_types::Error`].
4///
5/// [`celestia_types::Error`]: crate::Error
6pub type Result<T, E = Error> = std::result::Result<T, E>;
7
8/// `Result` counterpart for functions exposed to uniffi with [`UniffiError`]
9///
10/// [`UniffiError`]: crate::error::UniffiError
11#[cfg(feature = "uniffi")]
12pub type UniffiResult<T> = std::result::Result<T, UniffiError>;
13
14/// Representation of all the errors that can occur when interacting with [`celestia_types`].
15///
16/// [`celestia_types`]: crate
17#[derive(Debug, thiserror::Error)]
18pub enum Error {
19    /// Unsupported namespace version.
20    #[error("Unsupported namespace version: {0}")]
21    UnsupportedNamespaceVersion(u8),
22
23    /// Unsupported app version.
24    #[error("Unsupported app version: {0}")]
25    UnsupportedAppVersion(u64),
26
27    /// Invalid namespace size.
28    #[error("Invalid namespace size")]
29    InvalidNamespaceSize,
30
31    /// Error propagated from the [`tendermint`].
32    #[error(transparent)]
33    Tendermint(#[from] tendermint::Error),
34
35    /// Data length different than expected.
36    #[error("Length ({0}) different than expected ({1})")]
37    InvalidLength(usize, usize),
38
39    /// Error propagated from the [`tendermint_proto`].
40    #[error(transparent)]
41    Protobuf(#[from] tendermint_proto::Error),
42
43    /// Error propagated from the [`leopard_codec`].
44    #[error(transparent)]
45    LeopardCodec(#[from] leopard_codec::LeopardError),
46
47    /// Missing header.
48    #[error("Missing header")]
49    MissingHeader,
50
51    /// Missing commit.
52    #[error("Missing commit")]
53    MissingCommit,
54
55    /// Missing validator set.
56    #[error("Missing validator set")]
57    MissingValidatorSet,
58
59    /// Missing data availability header.
60    #[error("Missing data availability header")]
61    MissingDataAvailabilityHeader,
62
63    /// Missing proof.
64    #[error("Missing proof")]
65    MissingProof,
66
67    /// Missing shares.
68    #[error("Missing shares")]
69    MissingShares,
70
71    /// Missing fee field
72    #[error("Missing fee field")]
73    MissingFee,
74
75    /// Missing sum field
76    #[error("Missing sum field")]
77    MissingSum,
78
79    /// Missing mode info field
80    #[error("Missing mode info field")]
81    MissingModeInfo,
82
83    /// Missing bitarray field
84    #[error("Missing bitarray field")]
85    MissingBitarray,
86
87    /// Bit array too large
88    #[error("Bit array to large")]
89    BitarrayTooLarge,
90
91    /// Malformed CompactBitArray
92    #[error("CompactBitArray malformed")]
93    MalformedCompactBitArray,
94
95    /// Wrong proof type.
96    #[error("Wrong proof type")]
97    WrongProofType,
98
99    /// Unsupported share version.
100    #[error("Unsupported share version: {0}")]
101    UnsupportedShareVersion(u8),
102
103    /// Invalid share size.
104    #[error("Invalid share size: {0}")]
105    InvalidShareSize(usize),
106
107    /// Invalid nmt leaf size.
108    #[error("Invalid nmt leaf size: {0}")]
109    InvalidNmtLeafSize(usize),
110
111    /// Invalid nmt node order.
112    #[error("Invalid nmt node order")]
113    InvalidNmtNodeOrder,
114
115    /// Share sequence length exceeded.
116    #[error(
117        "Sequence len must fit into {len} bytes, got value {0}",
118        len = appconsts::SEQUENCE_LEN_BYTES
119    )]
120    ShareSequenceLenExceeded(usize),
121
122    /// Invalid namespace in version 0.
123    #[error("Invalid namespace v0")]
124    InvalidNamespaceV0,
125
126    /// Invalid namespace in version 255.
127    #[error("Invalid namespace v255")]
128    InvalidNamespaceV255,
129
130    /// Invalid namespaced hash.
131    #[error(transparent)]
132    InvalidNamespacedHash(#[from] nmt_rs::InvalidNamespacedHash),
133
134    /// Invalid index of signature in commit.
135    #[error("Invalid index of signature in commit {0}, height {1}")]
136    InvalidSignatureIndex(usize, u64),
137
138    /// Invalid axis.
139    #[error("Invalid axis type: {0}")]
140    InvalidAxis(i32),
141
142    /// Invalid Shwap proof type in Protobuf.
143    #[error("Invalid proof type: {0}")]
144    InvalidShwapProofType(i32),
145
146    /// Could not deserialise Public Key
147    #[error("Could not deserialize public key")]
148    InvalidPublicKey,
149
150    /// Range proof verification error.
151    #[error("Range proof verification failed: {0:?}")]
152    RangeProofError(nmt_rs::simple_merkle::error::RangeProofError),
153
154    /// Row root computed from shares doesn't match one received in `DataAvailabilityHeaderz
155    #[error("Computed root doesn't match received one")]
156    RootMismatch,
157
158    /// Unexpected signature in absent commit.
159    #[error("Unexpected absent commit signature")]
160    UnexpectedAbsentSignature,
161
162    /// Error that happened during validation.
163    #[error("Validation error: {0}")]
164    Validation(#[from] ValidationError),
165
166    /// Error that happened during verification.
167    #[error("Verification error: {0}")]
168    Verification(#[from] VerificationError),
169
170    /// Max share version exceeded.
171    #[error(
172        "Share version has to be at most {ver}, got {0}",
173        ver = appconsts::MAX_SHARE_VERSION
174    )]
175    MaxShareVersionExceeded(u8),
176
177    /// An error related to the namespaced merkle tree.
178    #[error("Nmt error: {0}")]
179    Nmt(&'static str),
180
181    /// Invalid address bech32 prefix.
182    #[error("Invalid address prefix: {0}")]
183    InvalidAddressPrefix(String),
184
185    /// Invalid size of the address.
186    #[error("Invalid address size: {0}")]
187    InvalidAddressSize(usize),
188
189    /// Invalid address.
190    #[error("Invalid address: {0}")]
191    InvalidAddress(String),
192
193    /// Invalid coin amount.
194    #[error("Invalid coin amount: {0}")]
195    InvalidCoinAmount(String),
196
197    /// Invalid coin denomination.
198    #[error("Invalid coin denomination: {0}")]
199    InvalidCoinDenomination(String),
200
201    /// Invalid balance
202    #[error("Invalid balance: {0:?}")]
203    InvalidBalance(String),
204
205    /// Invalid Public Key
206    #[error("Invalid Public Key")]
207    InvalidPublicKeyType(String),
208
209    /// Unsupported fraud proof type.
210    #[error("Unsupported fraud proof type: {0}")]
211    UnsupportedFraudProofType(String),
212
213    /// Data square index out of range.
214    #[error("Index ({0}) out of range ({1})")]
215    IndexOutOfRange(usize, usize),
216
217    /// Data square index out of range.
218    #[error("Data square index out of range. row: {0}, column: {1}")]
219    EdsIndexOutOfRange(u16, u16),
220
221    /// Could not create EDS, provided number of shares doesn't form a pefect square.
222    #[error("Invalid dimensions of EDS")]
223    EdsInvalidDimentions,
224
225    /// Zero block height.
226    #[error("Invalid zero block height")]
227    ZeroBlockHeight,
228
229    /// Expected first share of a blob
230    #[error("Expected first share of a blob")]
231    ExpectedShareWithSequenceStart,
232
233    /// Unexpected share from reserved namespace.
234    #[error("Unexpected share from reserved namespace")]
235    UnexpectedReservedNamespace,
236
237    /// Unexpected start of a new blob
238    #[error("Unexpected start of a new blob")]
239    UnexpectedSequenceStart,
240
241    /// Metadata mismatch between shares in blob.
242    #[error("Metadata mismatch between shares in blob: {0}")]
243    BlobSharesMetadataMismatch(String),
244
245    /// Blob too large, length must fit u32
246    #[error("Blob too large")]
247    BlobTooLarge,
248
249    /// NamespaceData too large, length must fit u16
250    #[error("NamespaceData too large")]
251    NamespaceDataTooLarge,
252
253    /// Invalid comittment length
254    #[error("Invalid committment length")]
255    InvalidComittmentLength,
256
257    /// Missing signer field in blob with share version 1
258    #[error("Missing signer field in blob")]
259    MissingSigner,
260
261    /// Signer is not supported in share version 0
262    #[error("Signer is not supported in share version 0")]
263    SignerNotSupported,
264
265    /// Empty blob list provided when creating MsgPayForBlobs
266    #[error("Empty blob list")]
267    EmptyBlobList,
268
269    /// Missing delegation response
270    #[error("Missing belegation response")]
271    MissingDelegationResponse,
272
273    /// Missing delegation
274    #[error("Missing delegation")]
275    MissingDelegation,
276
277    /// Missing balance
278    #[error("Missing balance")]
279    MissingBalance,
280
281    /// Missing unbond
282    #[error("Missing unbond")]
283    MissingUnbond,
284
285    /// Missing completion time
286    #[error("Missing completion time")]
287    MissingCompletionTime,
288
289    /// Missing redelegation
290    #[error("Missing redelegation")]
291    MissingRedelegation,
292
293    /// Missing redelegation entry
294    #[error("Missing redelegation entry")]
295    MissingRedelegationEntry,
296
297    /// Invalid Cosmos decimal
298    #[error("Invalid Cosmos decimal: {0}")]
299    InvalidCosmosDecimal(String),
300}
301
302impl From<prost::DecodeError> for Error {
303    fn from(value: prost::DecodeError) -> Self {
304        Error::Protobuf(tendermint_proto::Error::decode_message(value))
305    }
306}
307
308#[cfg(all(feature = "wasm-bindgen", target_arch = "wasm32"))]
309impl From<Error> for wasm_bindgen::JsValue {
310    fn from(value: Error) -> Self {
311        js_sys::Error::new(&value.to_string()).into()
312    }
313}
314
315/// Representation of the errors that can occur when validating data.
316///
317/// See [`ValidateBasic`]
318///
319/// [`ValidateBasic`]: crate::ValidateBasic
320#[derive(Debug, thiserror::Error)]
321pub enum ValidationError {
322    /// Not enough voting power for a commit.
323    #[error("Not enought voting power (got {0}, needed {1})")]
324    NotEnoughVotingPower(u64, u64),
325
326    /// Other errors that can happen during validation.
327    #[error("{0}")]
328    Other(String),
329}
330
331/// Representation of the errors that can occur when verifying data.
332///
333/// See [`ExtendedHeader::verify`].
334///
335/// [`ExtendedHeader::verify`]: crate::ExtendedHeader::verify
336#[derive(Debug, thiserror::Error)]
337pub enum VerificationError {
338    /// Not enough voting power for a commit.
339    #[error("Not enought voting power (got {0}, needed {1})")]
340    NotEnoughVotingPower(u64, u64),
341
342    /// Other errors that can happen during verification.
343    #[error("{0}")]
344    Other(String),
345}
346
347macro_rules! validation_error {
348    ($fmt:literal $(,)?) => {
349        $crate::ValidationError::Other(std::format!($fmt))
350    };
351    ($fmt:literal, $($arg:tt)*) => {
352        $crate::ValidationError::Other(std::format!($fmt, $($arg)*))
353    };
354}
355
356macro_rules! bail_validation {
357    ($($arg:tt)*) => {
358        return Err($crate::validation_error!($($arg)*).into())
359    };
360}
361
362macro_rules! verification_error {
363    ($fmt:literal $(,)?) => {
364        $crate::VerificationError::Other(std::format!($fmt))
365    };
366    ($fmt:literal, $($arg:tt)*) => {
367        $crate::VerificationError::Other(std::format!($fmt, $($arg)*))
368    };
369}
370
371macro_rules! bail_verification {
372    ($($arg:tt)*) => {
373        return Err($crate::verification_error!($($arg)*).into())
374    };
375}
376
377// NOTE: This need to be always after the macro definitions
378pub(crate) use bail_validation;
379pub(crate) use bail_verification;
380pub(crate) use validation_error;
381pub(crate) use verification_error;
382
383/// Errors raised when converting from uniffi helper types
384#[cfg(feature = "uniffi")]
385#[derive(Debug, uniffi::Error, thiserror::Error)]
386pub enum UniffiConversionError {
387    /// Invalid namespace length
388    #[error("Invalid namespace length")]
389    InvalidNamespaceLength,
390
391    /// Invalid commitment length
392    #[error("Invalid commitment hash length")]
393    InvalidCommitmentLength,
394
395    /// Invalid account id length
396    #[error("Invalid account id length")]
397    InvalidAccountIdLength,
398
399    /// Invalid hash length
400    #[error("Invalid hash length")]
401    InvalidHashLength,
402
403    /// Invalid chain ID lenght
404    #[error("Invalid chain id length")]
405    InvalidChainIdLength,
406
407    /// Invalid public key
408    #[error("Invalid public key")]
409    InvalidPublicKey,
410
411    /// Invalid parts header
412    #[error("Invalid parts header {msg}")]
413    InvalidPartsHeader {
414        /// error message
415        msg: String,
416    },
417
418    /// Timestamp out of range
419    #[error("Timestamp out of range")]
420    TimestampOutOfRange,
421
422    /// Header height out of range
423    #[error("Header heigth out of range")]
424    HeaderHeightOutOfRange,
425
426    /// Invalid signature length
427    #[error("Invalid signature length")]
428    InvalidSignatureLength,
429
430    /// Invalid round index
431    #[error("Invalid round index")]
432    InvalidRoundIndex,
433
434    /// Invalid validator index
435    #[error("Invalid validator index")]
436    InvalidValidatorIndex,
437
438    /// Invalid voting power
439    #[error("Voting power out of range")]
440    InvalidVotingPower,
441
442    /// Invalid signed header
443    #[error("Invalid signed header")]
444    InvalidSignedHeader,
445
446    /// Could not generate commitment
447    #[error("Could not generate commitment")]
448    CouldNotGenerateCommitment {
449        /// error message
450        msg: String,
451    },
452
453    /// Invalid address
454    #[error("Invalid address")]
455    InvalidAddress {
456        /// error message
457        msg: String,
458    },
459}
460
461/// Representation of all the errors that can occur when interacting with [`celestia_types`].
462///
463/// [`celestia_types`]: crate
464#[cfg(feature = "uniffi")]
465#[derive(Debug, uniffi::Error, thiserror::Error)]
466pub enum UniffiError {
467    /// Unsupported namespace version.
468    #[error("Unsupported namespace version: {0}")]
469    UnsupportedNamespaceVersion(u8),
470
471    /// Unsupported app version.
472    #[error("Unsupported app version: {0}")]
473    UnsupportedAppVersion(u64),
474
475    /// Invalid namespace size.
476    #[error("Invalid namespace size")]
477    InvalidNamespaceSize,
478
479    /// Error propagated from the [`tendermint`].
480    #[error("Tendermint error: {0}")]
481    Tendermint(String),
482
483    /// Error propagated from the [`tendermint_proto`].
484    #[error("tendermint_proto error: {0}")]
485    Protobuf(String),
486
487    /// Data length different than expected.
488    #[error("Length ({0}) different than expected ({1})")]
489    InvalidLength(u64, u64),
490
491    /// Error propagated from the [`leopard_codec`].
492    #[error("Leopard codec error: {0}")]
493    LeopardCodec(String),
494
495    /// Missing header.
496    #[error("Missing header")]
497    MissingHeader,
498
499    /// Missing commit.
500    #[error("Missing commit")]
501    MissingCommit,
502
503    /// Missing validator set.
504    #[error("Missing validator set")]
505    MissingValidatorSet,
506
507    /// Missing data availability header.
508    #[error("Missing data availability header")]
509    MissingDataAvailabilityHeader,
510
511    /// Missing proof.
512    #[error("Missing proof")]
513    MissingProof,
514
515    /// Missing shares.
516    #[error("Missing shares")]
517    MissingShares,
518
519    /// Missing fee field
520    #[error("Missing fee field")]
521    MissingFee,
522
523    /// Missing sum field
524    #[error("Missing sum field")]
525    MissingSum,
526
527    /// Missing mode info field
528    #[error("Missing mode info field")]
529    MissingModeInfo,
530
531    /// Missing bitarray field
532    #[error("Missing bitarray field")]
533    MissingBitarray,
534
535    /// Bit array too large
536    #[error("Bit array to large")]
537    BitarrayTooLarge,
538
539    /// Malformed CompactBitArray
540    #[error("CompactBitArray malformed")]
541    MalformedCompactBitArray,
542
543    /// Wrong proof type.
544    #[error("Wrong proof type")]
545    WrongProofType,
546
547    /// Unsupported share version.
548    #[error("Unsupported share version: {0}")]
549    UnsupportedShareVersion(u8),
550
551    /// Invalid share size.
552    #[error("Invalid share size: {0}")]
553    InvalidShareSize(u64),
554
555    /// Invalid nmt leaf size.
556    #[error("Invalid nmt leaf size: {0}")]
557    InvalidNmtLeafSize(u64),
558
559    /// Invalid nmt node order.
560    #[error("Invalid nmt node order")]
561    InvalidNmtNodeOrder,
562
563    /// Share sequence length exceeded.
564    #[error(
565        "Sequence len must fit into {len} bytes, got value {0}",
566        len = appconsts::SEQUENCE_LEN_BYTES
567    )]
568    ShareSequenceLenExceeded(u64),
569
570    /// Invalid namespace in version 0.
571    #[error("Invalid namespace v0")]
572    InvalidNamespaceV0,
573
574    /// Invalid namespace in version 255.
575    #[error("Invalid namespace v255")]
576    InvalidNamespaceV255,
577
578    /// Invalid namespaced hash.
579    #[error("Invalid namespace hash: {0}")]
580    InvalidNamespacedHash(String),
581
582    /// Invalid index of signature in commit.
583    #[error("Invalid index of signature in commit {0}, height {1}")]
584    InvalidSignatureIndex(u64, u64),
585
586    /// Invalid axis.
587    #[error("Invalid axis type: {0}")]
588    InvalidAxis(i32),
589
590    /// Invalid Shwap proof type in Protobuf.
591    #[error("Invalid proof type: {0}")]
592    InvalidShwapProofType(i32),
593
594    /// Could not deserialise Public Key
595    #[error("Could not deserialize public key")]
596    InvalidPublicKey,
597
598    /// Range proof verification error.
599    #[error("Range proof verification failed: {0:?}")]
600    RangeProofError(String),
601
602    /// Row root computed from shares doesn't match one received in `DataAvailabilityHeaderz
603    #[error("Computed root doesn't match received one")]
604    RootMismatch,
605
606    /// Unexpected signature in absent commit.
607    #[error("Unexpected absent commit signature")]
608    UnexpectedAbsentSignature,
609
610    /// Error that happened during validation.
611    #[error("Validation error: {0}")]
612    Validation(String),
613
614    /// Error that happened during verification.
615    #[error("Verification error: {0}")]
616    Verification(String),
617
618    /// Max share version exceeded.
619    #[error(
620        "Share version has to be at most {ver}, got {0}",
621        ver = appconsts::MAX_SHARE_VERSION
622    )]
623    MaxShareVersionExceeded(u8),
624
625    /// An error related to the namespaced merkle tree.
626    #[error("Nmt error: {0}")]
627    Nmt(String),
628
629    /// Invalid address bech32 prefix.
630    #[error("Invalid address prefix: {0}")]
631    InvalidAddressPrefix(String),
632
633    /// Invalid size of the address.
634    #[error("Invalid address size: {0}")]
635    InvalidAddressSize(u64),
636
637    /// Invalid address.
638    #[error("Invalid address: {0}")]
639    InvalidAddress(String),
640
641    /// Invalid coin amount.
642    #[error("Invalid coin amount: {0}")]
643    InvalidCoinAmount(String),
644
645    /// Invalid coin denomination.
646    #[error("Invalid coin denomination: {0}")]
647    InvalidCoinDenomination(String),
648
649    /// Invalid balance
650    #[error("Invalid balance")]
651    InvalidBalance(String),
652
653    /// Invalid Public Key
654    #[error("Invalid Public Key")]
655    InvalidPublicKeyType(String),
656
657    /// Unsupported fraud proof type.
658    #[error("Unsupported fraud proof type: {0}")]
659    UnsupportedFraudProofType(String),
660
661    /// Data square index out of range.
662    #[error("Index ({0}) out of range ({1})")]
663    IndexOutOfRange(u64, u64),
664
665    /// Data square index out of range.
666    #[error("Data square index out of range. row: {0}, column: {1}")]
667    EdsIndexOutOfRange(u16, u16),
668
669    /// Could not create EDS, provided number of shares doesn't form a pefect square.
670    #[error("Invalid dimensions of EDS")]
671    EdsInvalidDimentions,
672
673    /// Zero block height.
674    #[error("Invalid zero block height")]
675    ZeroBlockHeight,
676
677    /// Expected first share of a blob
678    #[error("Expected first share of a blob")]
679    ExpectedShareWithSequenceStart,
680
681    /// Unexpected share from reserved namespace.
682    #[error("Unexpected share from reserved namespace")]
683    UnexpectedReservedNamespace,
684
685    /// Unexpected start of a new blob
686    #[error("Unexpected start of a new blob")]
687    UnexpectedSequenceStart,
688
689    /// Metadata mismatch between shares in blob.
690    #[error("Metadata mismatch between shares in blob: {0}")]
691    BlobSharesMetadataMismatch(String),
692
693    /// Blob too large, length must fit u32
694    #[error("Blob too large")]
695    BlobTooLarge,
696
697    /// NamespaceData too large, length must fit u16
698    #[error("NamespaceData too large")]
699    NamespaceDataTooLarge,
700
701    /// Invalid comittment length
702    #[error("Invalid committment length")]
703    InvalidComittmentLength,
704
705    /// Missing signer field in blob with share version 1
706    #[error("Missing signer field in blob")]
707    MissingSigner,
708
709    /// Signer is not supported in share version 0
710    #[error("Signer is not supported in share version 0")]
711    SignerNotSupported,
712
713    /// Empty blob list provided when creating MsgPayForBlobs
714    #[error("Empty blob list")]
715    EmptyBlobList,
716
717    /// Missing DelegationResponse
718    #[error("Missing DelegationResponse")]
719    MissingDelegationResponse,
720
721    /// Missing Delegation
722    #[error("Missing Delegation")]
723    MissingDelegation,
724
725    /// Missing Balance
726    #[error("Missing Balance")]
727    MissingBalance,
728
729    /// Missing unbond
730    #[error("Missing unbond")]
731    MissingUnbond,
732
733    /// Missing completion time
734    #[error("Missing completion time")]
735    MissingCompletionTime,
736
737    /// Missing redelegation
738    #[error("Missing redelegation")]
739    MissingRedelegation,
740
741    /// Missing redelegation entry
742    #[error("Missing redelegation entry")]
743    MissingRedelegationEntry,
744
745    /// Invalid Cosmos decimal
746    #[error("Invalid Cosmos decimal: {0}")]
747    InvalidCosmosDecimal(String),
748}
749
750#[cfg(feature = "uniffi")]
751impl From<Error> for UniffiError {
752    fn from(value: Error) -> Self {
753        match value {
754            Error::UnsupportedNamespaceVersion(v) => UniffiError::UnsupportedNamespaceVersion(v),
755            Error::UnsupportedAppVersion(v) => UniffiError::UnsupportedAppVersion(v),
756            Error::InvalidNamespaceSize => UniffiError::InvalidNamespaceSize,
757            Error::Tendermint(e) => UniffiError::Tendermint(e.to_string()),
758            Error::Protobuf(e) => UniffiError::Protobuf(e.to_string()),
759            Error::InvalidLength(recv, expected) => {
760                UniffiError::InvalidLength(recv as u64, expected as u64)
761            }
762            Error::LeopardCodec(e) => UniffiError::LeopardCodec(e.to_string()),
763            Error::MissingHeader => UniffiError::MissingHeader,
764            Error::MissingCommit => UniffiError::MissingCommit,
765            Error::MissingValidatorSet => UniffiError::MissingValidatorSet,
766            Error::MissingDataAvailabilityHeader => UniffiError::MissingDataAvailabilityHeader,
767            Error::MissingProof => UniffiError::MissingProof,
768            Error::MissingShares => UniffiError::MissingShares,
769            Error::MissingFee => UniffiError::MissingFee,
770            Error::MissingSum => UniffiError::MissingSum,
771            Error::MissingModeInfo => UniffiError::MissingModeInfo,
772            Error::MissingBitarray => UniffiError::MissingBitarray,
773            Error::BitarrayTooLarge => UniffiError::BitarrayTooLarge,
774            Error::MalformedCompactBitArray => UniffiError::MalformedCompactBitArray,
775            Error::WrongProofType => UniffiError::WrongProofType,
776            Error::UnsupportedShareVersion(v) => UniffiError::UnsupportedShareVersion(v),
777            Error::InvalidShareSize(s) => {
778                UniffiError::InvalidShareSize(s.try_into().expect("size to fit"))
779            }
780            Error::InvalidNmtLeafSize(s) => {
781                UniffiError::InvalidNmtLeafSize(s.try_into().expect("size to fit"))
782            }
783            Error::InvalidNmtNodeOrder => UniffiError::InvalidNmtNodeOrder,
784            Error::ShareSequenceLenExceeded(l) => {
785                UniffiError::ShareSequenceLenExceeded(l.try_into().expect("length to fit"))
786            }
787            Error::InvalidNamespaceV0 => UniffiError::InvalidNamespaceV0,
788            Error::InvalidNamespaceV255 => UniffiError::InvalidNamespaceV255,
789            Error::InvalidNamespacedHash(h) => UniffiError::InvalidNamespacedHash(h.to_string()),
790            Error::InvalidSignatureIndex(i, h) => {
791                UniffiError::InvalidSignatureIndex(i.try_into().expect("index to fit"), h)
792            }
793            Error::InvalidAxis(a) => UniffiError::InvalidAxis(a),
794            Error::InvalidShwapProofType(t) => UniffiError::InvalidShwapProofType(t),
795            Error::InvalidPublicKey => UniffiError::InvalidPublicKey,
796            Error::RangeProofError(e) => UniffiError::RangeProofError(format!("{e:?}")),
797            Error::RootMismatch => UniffiError::RootMismatch,
798            Error::UnexpectedAbsentSignature => UniffiError::UnexpectedAbsentSignature,
799            Error::Validation(e) => UniffiError::Validation(e.to_string()),
800            Error::Verification(e) => UniffiError::Verification(e.to_string()),
801            Error::MaxShareVersionExceeded(v) => UniffiError::MaxShareVersionExceeded(v),
802            Error::Nmt(e) => UniffiError::Nmt(e.to_string()),
803            Error::InvalidAddressPrefix(p) => UniffiError::InvalidAddressPrefix(p),
804            Error::InvalidAddressSize(s) => {
805                UniffiError::InvalidAddressSize(s.try_into().expect("size to fit"))
806            }
807            Error::InvalidAddress(a) => UniffiError::InvalidAddress(a),
808            Error::InvalidCoinAmount(a) => UniffiError::InvalidCoinAmount(a),
809            Error::InvalidCoinDenomination(d) => UniffiError::InvalidCoinDenomination(d),
810            Error::InvalidBalance(b) => UniffiError::InvalidBalance(b),
811            Error::InvalidPublicKeyType(t) => UniffiError::InvalidPublicKeyType(t),
812            Error::UnsupportedFraudProofType(t) => UniffiError::UnsupportedFraudProofType(t),
813            Error::IndexOutOfRange(i, r) => UniffiError::IndexOutOfRange(
814                i.try_into().expect("index to fit"),
815                r.try_into().expect("range to fit"),
816            ),
817            Error::EdsIndexOutOfRange(r, c) => UniffiError::EdsIndexOutOfRange(r, c),
818            Error::EdsInvalidDimentions => UniffiError::EdsInvalidDimentions,
819            Error::ZeroBlockHeight => UniffiError::ZeroBlockHeight,
820            Error::ExpectedShareWithSequenceStart => UniffiError::ExpectedShareWithSequenceStart,
821            Error::UnexpectedReservedNamespace => UniffiError::UnexpectedReservedNamespace,
822            Error::UnexpectedSequenceStart => UniffiError::UnexpectedSequenceStart,
823            Error::BlobSharesMetadataMismatch(s) => UniffiError::BlobSharesMetadataMismatch(s),
824            Error::BlobTooLarge => UniffiError::BlobTooLarge,
825            Error::NamespaceDataTooLarge => UniffiError::NamespaceDataTooLarge,
826            Error::InvalidComittmentLength => UniffiError::InvalidComittmentLength,
827            Error::MissingSigner => UniffiError::MissingSigner,
828            Error::SignerNotSupported => UniffiError::SignerNotSupported,
829            Error::EmptyBlobList => UniffiError::EmptyBlobList,
830            Error::MissingDelegationResponse => UniffiError::MissingDelegationResponse,
831            Error::MissingDelegation => UniffiError::MissingDelegation,
832            Error::MissingBalance => UniffiError::MissingBalance,
833            Error::MissingUnbond => UniffiError::MissingUnbond,
834            Error::MissingCompletionTime => UniffiError::MissingCompletionTime,
835            Error::MissingRedelegation => UniffiError::MissingRedelegation,
836            Error::MissingRedelegationEntry => UniffiError::MissingRedelegationEntry,
837            Error::InvalidCosmosDecimal(s) => UniffiError::InvalidCosmosDecimal(s),
838        }
839    }
840}