Skip to content

Commit

Permalink
Feat(engine-types): optional serde integration (#468)
Browse files Browse the repository at this point in the history
  • Loading branch information
mfornet authored and birchmd committed Jun 7, 2022
1 parent 7024bc6 commit fb542ca
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions engine-transactions/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ aurora-engine-precompiles = { path = "../engine-precompiles", default-features =
evm = { git = "https://github.com/aurora-is-near/sputnikvm.git", rev = "37448b6cacd98b06282cff5a559684505c29bd2b", default-features = false }
rlp = { version = "0.5.0", default-features = false }
hex = { version = "0.4", default-features = false, features = ["alloc"] }
serde = { version = "1", features = ["derive"], optional = true }

[features]
std = ["aurora-engine-types/std", "aurora-engine-precompiles/std", "evm/std", "rlp/std", "hex/std"]
impl-serde = ["aurora-engine-types/impl-serde", "serde"]
3 changes: 3 additions & 0 deletions engine-transactions/src/eip_2930.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ use aurora_engine_sdk as sdk;
use aurora_engine_types::types::{Address, Wei};
use aurora_engine_types::{Vec, H160, H256, U256};
use rlp::{Decodable, DecoderError, Encodable, Rlp, RlpStream};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};

/// Type indicator (per EIP-2718) for access list transactions
pub const TYPE_BYTE: u8 = 0x01;

#[derive(Debug, Eq, PartialEq, Clone)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct AccessTuple {
pub address: H160,
pub storage_keys: Vec<H256>,
Expand Down
2 changes: 2 additions & 0 deletions engine-types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ ethabi = { git = "https://github.com/darwinia-network/ethabi", branch = "xavier-
hex = { version = "0.4", default-features = false, features = ["alloc"] }
primitive-types = { version = "0.10.0", default-features = false, features = ["rlp"] }
sha3 = { version = "0.9.1", default-features = false }
serde = { version = "1", features = ["derive"], optional = true }

[dev-dependencies]
bstr = "0.2"
Expand All @@ -28,3 +29,4 @@ rand = "0.7.3"
[features]
default = ["std"]
std = ["primitive-types/std"]
impl-serde = ["primitive-types/impl-serde", "serde"]
3 changes: 3 additions & 0 deletions engine-types/src/types/address.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
use crate::{format, String, H160};
use borsh::maybestd::io;
use borsh::{BorshDeserialize, BorshSerialize};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};

/// Base Eth Address type
#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Address(H160);

impl Address {
Expand Down
3 changes: 3 additions & 0 deletions engine-types/src/types/wei.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ use crate::types::balance::error;
use crate::types::Fee;
use crate::{Add, Display, Sub, SubAssign, U256};
use borsh::{BorshDeserialize, BorshSerialize};
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};

pub const ZERO_NEP141_WEI: NEP141Wei = NEP141Wei::new(0);
pub const ZERO_WEI: Wei = Wei::new_u64(0);
Expand Down Expand Up @@ -66,6 +68,7 @@ impl SubAssign<NEP141Wei> for NEP141Wei {

/// Newtype to distinguish balances (denominated in Wei) from other U256 types.
#[derive(Default, Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Wei(U256);

impl Wei {
Expand Down
2 changes: 2 additions & 0 deletions engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ ethabi = { git = "https://github.com/darwinia-network/ethabi", branch = "xavier-
hex = { version = "0.4", default-features = false, features = ["alloc"] }
byte-slice-cast = { version = "1.0", default-features = false }
rjson = { git = "https://github.com/aurora-is-near/rjson", rev = "cc3da949", default-features = false, features = ["integer"] }
serde = { version = "1", features = ["derive"], optional = true }

[dev-dependencies]
serde = { version = "1", features = ["derive"] }
Expand All @@ -58,3 +59,4 @@ mainnet = ["contract", "log"]
testnet = ["contract", "log"]
mainnet-test = ["meta-call"]
testnet-test = ["meta-call"]
impl-serde = ["aurora-engine-types/impl-serde", "serde", "aurora-engine-transactions/impl-serde"]
3 changes: 3 additions & 0 deletions engine/src/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ use crate::prelude::{
use crate::proof::Proof;
use aurora_engine_types::types::{Fee, NEP141Wei, Yocto};
use evm::backend::Log;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};

/// Borsh-encoded parameters for the `new` function.
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
Expand Down Expand Up @@ -41,6 +43,7 @@ pub struct MetaCallArgs {

/// Borsh-encoded log for use in a `SubmitResult`.
#[derive(Debug, Clone, PartialEq, Eq, BorshSerialize, BorshDeserialize)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct ResultLog {
pub address: Address,
pub topics: Vec<RawU256>,
Expand Down

0 comments on commit fb542ca

Please sign in to comment.