Skip to content
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
9 changes: 1 addition & 8 deletions src/rpc/methods/eth/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub const METHOD_GET_STORAGE_AT: u64 = 5;
JsonSchema,
derive_more::From,
derive_more::Into,
derive_more::Deref,
GetSize,
)]
pub struct EthBytes(
Expand Down Expand Up @@ -59,14 +60,6 @@ impl FromStr for EthBytes {
}
}

impl Deref for EthBytes {
type Target = Vec<u8>;

fn deref(&self) -> &Self::Target {
&self.0
}
}

#[derive(Debug, Deserialize, Serialize)]
pub struct GetBytecodeReturn(pub Option<Cid>);

Expand Down
34 changes: 15 additions & 19 deletions src/shim/address.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
// Copyright 2019-2026 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

use std::{
fmt::Display,
ops::{Deref, DerefMut},
str::FromStr,
};
use std::{fmt::Display, str::FromStr};

use data_encoding::Encoding;
use data_encoding_macro::new_encoding;
Expand Down Expand Up @@ -113,7 +109,20 @@ mod network_guard_impl {
/// parse both versions and discard the prefix. See also [`StrictAddress`].
///
/// For more information, see: <https://spec.filecoin.io/appendix/address/>
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
#[derive(
Copy,
Clone,
Debug,
Hash,
PartialEq,
Eq,
PartialOrd,
Ord,
Serialize,
Deserialize,
derive_more::Deref,
derive_more::DerefMut,
)]
#[serde(transparent)]
#[cfg_attr(test, derive(derive_quickcheck_arbitrary::Arbitrary))]
pub struct Address(Address_latest);
Expand Down Expand Up @@ -247,19 +256,6 @@ impl Display for Address {
}
}

impl Deref for Address {
type Target = Address_latest;
fn deref(&self) -> &Self::Target {
&self.0
}
}

impl DerefMut for Address {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}

impl GetSize for Address {
fn get_heap_size(&self) -> usize {
0 // all variants of the internal payload are stack-allocated
Expand Down
27 changes: 11 additions & 16 deletions src/shim/bigint.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
// Copyright 2019-2026 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

use std::ops::{Deref, DerefMut};

use super::fvm_shared_latest::bigint::bigint_ser;
use serde::{Deserialize, Serialize};

#[derive(Default, Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[derive(
Default,
Clone,
Debug,
PartialEq,
Eq,
Serialize,
Deserialize,
derive_more::Deref,
derive_more::DerefMut,
)]
#[serde(transparent)]
pub struct BigInt(#[serde(with = "bigint_ser")] num_bigint::BigInt);

impl Deref for BigInt {
type Target = num_bigint::BigInt;
fn deref(&self) -> &Self::Target {
&self.0
}
}

impl DerefMut for BigInt {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}

impl From<num_bigint::BigInt> for BigInt {
fn from(other: num_bigint::BigInt) -> Self {
BigInt(other)
Expand Down
30 changes: 14 additions & 16 deletions src/shim/econ.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use serde::{Deserialize, Serialize};
use static_assertions::const_assert_eq;
use std::{
fmt,
ops::{Add, AddAssign, Deref, DerefMut, Div, Mul, MulAssign, Neg, Rem, Sub, SubAssign},
ops::{Add, AddAssign, Div, Mul, MulAssign, Neg, Rem, Sub, SubAssign},
sync::LazyLock,
};

Expand All @@ -25,7 +25,19 @@ const_assert_eq!(TOTAL_FILECOIN_BASE, fvm_shared2::TOTAL_FILECOIN_BASE);
pub static TOTAL_FILECOIN: LazyLock<TokenAmount> =
LazyLock::new(|| TokenAmount::from_whole(TOTAL_FILECOIN_BASE));

#[derive(Clone, PartialEq, Eq, Ord, PartialOrd, Hash, Serialize, Deserialize, Default)]
#[derive(
Clone,
PartialEq,
Eq,
Ord,
PartialOrd,
Hash,
Serialize,
Deserialize,
Default,
derive_more::Deref,
derive_more::DerefMut,
)]
#[serde(transparent)]
pub struct TokenAmount(TokenAmount_latest);

Expand Down Expand Up @@ -99,20 +111,6 @@ impl Neg for &TokenAmount {
}
}

impl Deref for TokenAmount {
type Target = TokenAmount_latest;

fn deref(&self) -> &Self::Target {
&self.0
}
}

impl DerefMut for TokenAmount {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}

impl std::fmt::Display for TokenAmount {
// This trait requires `fmt` with this exact signature.
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
Expand Down
27 changes: 11 additions & 16 deletions src/shim/randomness.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright 2019-2026 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT

use std::ops::{Deref, DerefMut};

use super::fvm_shared_latest::randomness::Randomness as Randomness_latest;
use fvm_shared2::randomness::Randomness as Randomness_v2;
use fvm_shared3::randomness::Randomness as Randomness_v3;
Expand Down Expand Up @@ -31,7 +29,17 @@ use serde::{Deserialize, Serialize};
/// assert_eq!(fvm3_rand, rand_shim.clone().into());
/// assert_eq!(fvm2_rand, rand_shim.into());
/// ```
#[derive(PartialEq, Eq, Default, Clone, Debug, Deserialize, Serialize)]
#[derive(
PartialEq,
Eq,
Default,
Clone,
Debug,
Deserialize,
Serialize,
derive_more::Deref,
derive_more::DerefMut,
)]
#[serde(transparent)]
pub struct Randomness(Randomness_latest);

Expand All @@ -41,19 +49,6 @@ impl Randomness {
}
}

impl Deref for Randomness {
type Target = Randomness_latest;
fn deref(&self) -> &Self::Target {
&self.0
}
}

impl DerefMut for Randomness {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}

impl From<Randomness_v4> for Randomness {
fn from(other: Randomness_v4) -> Self {
Randomness(other)
Expand Down
56 changes: 23 additions & 33 deletions src/shim/sector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use get_size2::GetSize;
use num_derive::FromPrimitive;
use serde::{Deserialize, Serialize};
use std::hash::{Hash, Hasher};
use std::ops::Deref;

pub type SectorNumber = fvm_shared4::sector::SectorNumber;

Expand All @@ -48,7 +47,9 @@ pub type SectorNumber = fvm_shared4::sector::SectorNumber;
/// assert_eq!(fvm3_proof, proof_shim.into());
/// assert_eq!(fvm2_proof, proof_shim.into());
/// ```
#[derive(serde::Serialize, serde::Deserialize, Clone, Copy, Eq, PartialEq, Debug)]
#[derive(
serde::Serialize, serde::Deserialize, Clone, Copy, Eq, PartialEq, Debug, derive_more::Deref,
)]
pub struct RegisteredSealProof(RegisteredSealProofV4);

impl RegisteredSealProof {
Expand Down Expand Up @@ -97,13 +98,6 @@ impl RegisteredSealProof {
}
}

impl Deref for RegisteredSealProof {
type Target = RegisteredSealProofV4;
fn deref(&self) -> &Self::Target {
&self.0
}
}

impl From<i64> for RegisteredSealProof {
fn from(value: i64) -> Self {
RegisteredSealProof(RegisteredSealProofV4::from(value))
Expand Down Expand Up @@ -151,7 +145,15 @@ impl quickcheck::Arbitrary for RegisteredSealProof {
/// Represents a shim over `SectorInfo` from `fvm_shared` with convenience
/// methods to convert to an older version of the type
#[derive(
Eq, PartialEq, Debug, Clone, derive_more::From, derive_more::Into, Serialize, Deserialize,
Eq,
PartialEq,
Debug,
Clone,
derive_more::From,
derive_more::Into,
derive_more::Deref,
Serialize,
Deserialize,
)]
pub struct SectorInfo(SectorInfoV4);

Expand Down Expand Up @@ -180,13 +182,6 @@ impl SectorInfo {
}
}

impl Deref for SectorInfo {
type Target = SectorInfoV4;
fn deref(&self) -> &Self::Target {
&self.0
}
}

impl From<SectorInfo> for SectorInfoV2 {
fn from(value: SectorInfo) -> SectorInfoV2 {
SectorInfoV2 {
Expand Down Expand Up @@ -226,7 +221,16 @@ impl quickcheck::Arbitrary for ExtendedSectorInfo {
}
}

#[derive(serde::Serialize, serde::Deserialize, Clone, Debug, Eq, PartialEq, derive_more::Into)]
#[derive(
serde::Serialize,
serde::Deserialize,
Clone,
Debug,
Eq,
PartialEq,
derive_more::Into,
derive_more::Deref,
)]
pub struct RegisteredPoStProof(RegisteredPoStProofV4);

#[cfg(test)]
Expand All @@ -236,13 +240,6 @@ impl quickcheck::Arbitrary for RegisteredPoStProof {
}
}

impl Deref for RegisteredPoStProof {
type Target = RegisteredPoStProofV4;
fn deref(&self) -> &Self::Target {
&self.0
}
}

impl TryFrom<RegisteredPoStProof> for fil_actors_shared::filecoin_proofs_api::RegisteredPoStProof {
type Error = anyhow::Error;

Expand Down Expand Up @@ -342,6 +339,7 @@ sector_size_conversion!(SectorSizeV2, SectorSizeV3, SectorSizeV4);
PartialEq,
derive_more::From,
derive_more::Into,
derive_more::Deref,
Eq,
)]
#[cfg_attr(test, derive(derive_quickcheck_arbitrary::Arbitrary))]
Expand All @@ -367,14 +365,6 @@ impl PoStProof {
}
}

impl Deref for PoStProof {
type Target = PoStProofV4;

fn deref(&self) -> &Self::Target {
&self.0
}
}

impl From<PoStProofV2> for PoStProof {
fn from(value: PoStProofV2) -> PoStProof {
PoStProof(PoStProofV4 {
Expand Down
23 changes: 4 additions & 19 deletions src/shim/state_tree.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Copyright 2019-2026 ChainSafe Systems
// SPDX-License-Identifier: Apache-2.0, MIT
use std::{
ops::{Deref, DerefMut},
sync::Arc,
};
use std::sync::Arc;

use crate::{
networks::{ACTOR_BUNDLES_METADATA, ActorBundleMetadata},
Expand Down Expand Up @@ -413,7 +410,9 @@ where
/// assert_eq!(fvm3_actor_state, state_shim.clone().into());
/// assert_eq!(fvm2_actor_state, state_shim.into());
/// ```
#[derive(PartialEq, Eq, Clone, Debug, Serialize, Deserialize)]
#[derive(
PartialEq, Eq, Clone, Debug, Serialize, Deserialize, derive_more::Deref, derive_more::DerefMut,
)]
#[serde(transparent)]
#[cfg_attr(test, derive(derive_quickcheck_arbitrary::Arbitrary))]
pub struct ActorState(ActorState_latest);
Expand Down Expand Up @@ -443,20 +442,6 @@ impl ActorState {
}
}

impl Deref for ActorState {
type Target = ActorState_latest;

fn deref(&self) -> &Self::Target {
&self.0
}
}

impl DerefMut for ActorState {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}

impl From<&ActorStateV2> for ActorState {
fn from(value: &ActorStateV2) -> Self {
Self(ActorState_latest {
Expand Down
Loading
Loading