Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add alloc features in no_std #18

Merged
merged 2 commits into from
Apr 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,9 @@ foundry.
cargo clippy --no-default-features
cargo clippy
cargo clippy --target wasm32-unknown-unknown
cargo clippy --features eip712-serde
cargo clippy --all-features

# Note on `no_std`

We try to support `no_std` with `alloc`. These crates will work in environments
without standard, as long as the `alloc` crate exists.
4 changes: 2 additions & 2 deletions abi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repository.workspace = true
ethers-primitives.workspace = true
sol-type-parser.workspace = true

hex.workspace = true
hex = { workspace = true, features = ["alloc"] }
tiny-keccak = { workspace = true, features = ["keccak"] }

thiserror = { workspace = true, optional = true }
Expand All @@ -27,7 +27,7 @@ serde = { workspace = true, optional = true }
hex-literal.workspace = true

[features]
default = ["std"]
default = ["std", "hex/alloc"]
std = ["ethers-primitives/std", "hex/std", "serde?/std", "thiserror"]
# TODO: Can we remove std from here?
eip712-serde = ["std", "dep:serde"]
2 changes: 1 addition & 1 deletion abi/src/sol_types/sol_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use core::marker::PhantomData;
use ethers_primitives::{B160, I256, U256};

#[cfg(not(feature = "std"))]
use crate::no_std_prelude::{Borrow, String as RustString, ToOwned, ToString, Vec};
use crate::no_std_prelude::{Borrow, String as RustString, ToOwned, Vec};
#[cfg(feature = "std")]
use std::{borrow::Borrow, string::String as RustString};

Expand Down
2 changes: 1 addition & 1 deletion dyn-abi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ethers-primitives.workspace = true

hex.workspace = true
serde.workspace = true
serde_json.workspace = true
serde_json = { workspace = true, features = ["alloc"] }

[features]
default = ["std"]
Expand Down