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