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

feat: support no_std for alloy-genesis/alloy-serde #320

Merged
merged 12 commits into from
Mar 21, 2024

Conversation

yjhmelody
Copy link
Contributor

Motivation

Solution

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@@ -1,5 +1,6 @@
//! Json U256 serde helpers.

#[allow(unused_imports)]
Copy link
Contributor Author

@yjhmelody yjhmelody Mar 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems the clippy warnings are not correct, for no_std must import String/ToString.
If not imports them, cargo test -p alloy-serde --no-default-features will fail.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can feature gate these imports instead:

see also

https://github.com/alloy-rs/alloy/blob/main/crates/eips/src/eip2930.rs#L7-L8

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

supportive

smol nits, replace unused_imports with #[cfg(not(feature = "std"))]

@@ -226,7 +230,7 @@ pub struct GenesisAccount {
skip_serializing_if = "Option::is_none",
deserialize_with = "deserialize_storage_map"
)]
pub storage: Option<HashMap<B256, B256>>,
pub storage: Option<BTreeMap<B256, B256>>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually prefer the BtreeMap change here so serialize/deserialize is consistent

@@ -1,5 +1,6 @@
//! Json U256 serde helpers.

#[allow(unused_imports)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can feature gate these imports instead:

see also

https://github.com/alloy-rs/alloy/blob/main/crates/eips/src/eip2930.rs#L7-L8

Comment on lines 182 to 183
#[allow(unused_imports)]
use alloc::{vec, vec::Vec};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm,

pending @DaniPopes

Co-authored-by: Oliver Nordbjerg <onbjerg@users.noreply.github.com>
@mattsse mattsse merged commit d3af591 into alloy-rs:main Mar 21, 2024
16 checks passed
malik672 added a commit to malik672/alloy that referenced this pull request Mar 21, 2024
feat: support no_std for alloy-genesis/alloy-serde (alloy-rs#320)
@yjhmelody yjhmelody deleted the feat/genesis-no-std branch March 22, 2024 02:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants