no-std support for monero-serai (#311)

* Move monero-serai from std to std-shims, where possible

* no-std fixes

* Make the HttpRpc its own feature, thiserror only on std

* Drop monero-rs's epee for a homegrown one

We only need it for a single function. While I tried jeffro's, it didn't work
out of the box, had three unimplemented!s, and is no where near viable for
no_std.

Fixes #182, though should be further tested.

* no-std monero-serai

* Allow base58-monero via git

* cargo fmt
This commit is contained in:
Luke Parker
2023-06-29 04:14:29 -04:00
committed by GitHub
parent d25c668ee4
commit ac708b3b2a
30 changed files with 487 additions and 261 deletions

View File

@@ -1,5 +1,10 @@
use core::ops::Deref;
use std_shims::{sync::OnceLock, collections::HashMap};
use std_shims::{
sync::OnceLock,
vec::Vec,
string::{String, ToString},
collections::HashMap,
};
use zeroize::{Zeroize, Zeroizing};
use rand_core::{RngCore, CryptoRng};

View File

@@ -1,25 +1,25 @@
use core::fmt;
use std_shims::string::String;
use zeroize::{Zeroize, ZeroizeOnDrop, Zeroizing};
use rand_core::{RngCore, CryptoRng};
use thiserror::Error;
pub(crate) mod classic;
use classic::{CLASSIC_SEED_LENGTH, CLASSIC_SEED_LENGTH_WITH_CHECKSUM, ClassicSeed};
/// Error when decoding a seed.
#[derive(Clone, Copy, PartialEq, Eq, Debug, Error)]
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
#[cfg_attr(feature = "std", derive(thiserror::Error))]
pub enum SeedError {
#[error("invalid number of words in seed")]
#[cfg_attr(feature = "std", error("invalid number of words in seed"))]
InvalidSeedLength,
#[error("unknown language")]
#[cfg_attr(feature = "std", error("unknown language"))]
UnknownLanguage,
#[error("invalid checksum")]
#[cfg_attr(feature = "std", error("invalid checksum"))]
InvalidChecksum,
#[error("english old seeds don't support checksums")]
#[cfg_attr(feature = "std", error("english old seeds don't support checksums"))]
EnglishOldWithChecksum,
#[error("invalid seed")]
#[cfg_attr(feature = "std", error("invalid seed"))]
InvalidSeed,
}