diff --git a/Cargo.toml b/Cargo.toml index 30a4e83c..9df668c4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,7 @@ [workspace] members = [ + "fil_actor_decoder", + "fil_actor_json_derive", "fil_actors_shared", "fil_actors_test_utils", "actors/account", @@ -86,6 +88,7 @@ fil_actor_cron_state = { version = "24.1.3", path = "./actors/cron" } fil_actor_datacap_state = { version = "24.1.3", path = "./actors/datacap" } fil_actor_evm_state = { version = "24.1.3", path = "./actors/evm" } fil_actor_init_state = { version = "24.1.3", path = "./actors/init" } +fil_actor_json_derive = { version = "0.1.0", path = "./fil_actor_json_derive" } fil_actor_market_state = { version = "24.1.3", path = "./actors/market" } fil_actor_miner_state = { version = "24.1.3", path = "./actors/miner" } fil_actor_multisig_state = { version = "24.1.3", path = "./actors/multisig" } diff --git a/actors/datacap/Cargo.toml b/actors/datacap/Cargo.toml index 2258c1f5..969bd700 100644 --- a/actors/datacap/Cargo.toml +++ b/actors/datacap/Cargo.toml @@ -22,3 +22,14 @@ lazy_static = { workspace = true } num-derive = { workspace = true } num-traits = { workspace = true } serde = { workspace = true } + +# Optional: JSON value conversion +fil_actor_json_derive = { workspace = true, optional = true } +serde_json = { workspace = true, optional = true } + +[dev-dependencies] +serde_json = { workspace = true } + +[features] +default = [] +json = ["dep:fil_actor_json_derive", "dep:serde_json", "fil_actors_shared/json"] diff --git a/actors/datacap/src/v10/types.rs b/actors/datacap/src/v10/types.rs index 4fa3c5e6..fcd2af8f 100644 --- a/actors/datacap/src/v10/types.rs +++ b/actors/datacap/src/v10/types.rs @@ -5,6 +5,7 @@ use fvm_ipld_encoding::tuple::*; use fvm_shared3::address::Address; use fvm_shared3::econ::TokenAmount; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct MintParams { // Recipient of the newly minted tokens. @@ -15,12 +16,14 @@ pub struct MintParams { pub operators: Vec
, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct DestroyParams { pub owner: Address, pub amount: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct GranularityReturn { diff --git a/actors/datacap/src/v11/types.rs b/actors/datacap/src/v11/types.rs index d45a6512..db4e3f05 100644 --- a/actors/datacap/src/v11/types.rs +++ b/actors/datacap/src/v11/types.rs @@ -5,66 +5,77 @@ use fvm_ipld_encoding::tuple::*; use fvm_shared3::address::Address; use fvm_shared3::econ::TokenAmount; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct ConstructorParams { pub governor: Address, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct NameReturn { pub name: String, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct SymbolReturn { pub symbol: String, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct TotalSupplyReturn { pub supply: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct BalanceParams { pub address: Address, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct BalanceReturn { pub balance: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct GetAllowanceReturn { pub allowance: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct IncreaseAllowanceReturn { pub new_allowance: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct DecreaseAllowanceReturn { pub new_allowance: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct RevokeAllowanceReturn { pub old_allowance: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct MintParams { // Recipient of the newly minted tokens. @@ -75,12 +86,14 @@ pub struct MintParams { pub operators: Vec
, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct DestroyParams { pub owner: Address, pub amount: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct GranularityReturn { diff --git a/actors/datacap/src/v12/types.rs b/actors/datacap/src/v12/types.rs index 00b95e9f..5ad6ef78 100644 --- a/actors/datacap/src/v12/types.rs +++ b/actors/datacap/src/v12/types.rs @@ -5,66 +5,77 @@ use fvm_ipld_encoding::tuple::*; use fvm_shared4::address::Address; use fvm_shared4::econ::TokenAmount; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct ConstructorParams { pub governor: Address, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct NameReturn { pub name: String, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct SymbolReturn { pub symbol: String, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct TotalSupplyReturn { pub supply: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct BalanceParams { pub address: Address, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct BalanceReturn { pub balance: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct GetAllowanceReturn { pub allowance: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct IncreaseAllowanceReturn { pub new_allowance: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct DecreaseAllowanceReturn { pub new_allowance: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct RevokeAllowanceReturn { pub old_allowance: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct MintParams { // Recipient of the newly minted tokens. @@ -75,12 +86,14 @@ pub struct MintParams { pub operators: Vec
, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct DestroyParams { pub owner: Address, pub amount: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct GranularityReturn { diff --git a/actors/datacap/src/v13/types.rs b/actors/datacap/src/v13/types.rs index 56374f24..44376e1b 100644 --- a/actors/datacap/src/v13/types.rs +++ b/actors/datacap/src/v13/types.rs @@ -2,66 +2,77 @@ use fvm_ipld_encoding::tuple::*; use fvm_shared4::address::Address; use fvm_shared4::econ::TokenAmount; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct ConstructorParams { pub governor: Address, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct NameReturn { pub name: String, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct SymbolReturn { pub symbol: String, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct TotalSupplyReturn { pub supply: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct BalanceParams { pub address: Address, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct BalanceReturn { pub balance: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct GetAllowanceReturn { pub allowance: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct IncreaseAllowanceReturn { pub new_allowance: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct DecreaseAllowanceReturn { pub new_allowance: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct RevokeAllowanceReturn { pub old_allowance: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct MintParams { // Recipient of the newly minted tokens. @@ -72,12 +83,14 @@ pub struct MintParams { pub operators: Vec
, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct DestroyParams { pub owner: Address, pub amount: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct GranularityReturn { diff --git a/actors/datacap/src/v14/types.rs b/actors/datacap/src/v14/types.rs index 56374f24..44376e1b 100644 --- a/actors/datacap/src/v14/types.rs +++ b/actors/datacap/src/v14/types.rs @@ -2,66 +2,77 @@ use fvm_ipld_encoding::tuple::*; use fvm_shared4::address::Address; use fvm_shared4::econ::TokenAmount; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct ConstructorParams { pub governor: Address, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct NameReturn { pub name: String, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct SymbolReturn { pub symbol: String, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct TotalSupplyReturn { pub supply: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct BalanceParams { pub address: Address, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct BalanceReturn { pub balance: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct GetAllowanceReturn { pub allowance: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct IncreaseAllowanceReturn { pub new_allowance: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct DecreaseAllowanceReturn { pub new_allowance: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct RevokeAllowanceReturn { pub old_allowance: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct MintParams { // Recipient of the newly minted tokens. @@ -72,12 +83,14 @@ pub struct MintParams { pub operators: Vec
, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct DestroyParams { pub owner: Address, pub amount: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct GranularityReturn { diff --git a/actors/datacap/src/v15/types.rs b/actors/datacap/src/v15/types.rs index 56374f24..44376e1b 100644 --- a/actors/datacap/src/v15/types.rs +++ b/actors/datacap/src/v15/types.rs @@ -2,66 +2,77 @@ use fvm_ipld_encoding::tuple::*; use fvm_shared4::address::Address; use fvm_shared4::econ::TokenAmount; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct ConstructorParams { pub governor: Address, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct NameReturn { pub name: String, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct SymbolReturn { pub symbol: String, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct TotalSupplyReturn { pub supply: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct BalanceParams { pub address: Address, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct BalanceReturn { pub balance: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct GetAllowanceReturn { pub allowance: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct IncreaseAllowanceReturn { pub new_allowance: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct DecreaseAllowanceReturn { pub new_allowance: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct RevokeAllowanceReturn { pub old_allowance: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct MintParams { // Recipient of the newly minted tokens. @@ -72,12 +83,14 @@ pub struct MintParams { pub operators: Vec
, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct DestroyParams { pub owner: Address, pub amount: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct GranularityReturn { diff --git a/actors/datacap/src/v16/types.rs b/actors/datacap/src/v16/types.rs index 56374f24..44376e1b 100644 --- a/actors/datacap/src/v16/types.rs +++ b/actors/datacap/src/v16/types.rs @@ -2,66 +2,77 @@ use fvm_ipld_encoding::tuple::*; use fvm_shared4::address::Address; use fvm_shared4::econ::TokenAmount; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct ConstructorParams { pub governor: Address, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct NameReturn { pub name: String, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct SymbolReturn { pub symbol: String, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct TotalSupplyReturn { pub supply: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct BalanceParams { pub address: Address, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct BalanceReturn { pub balance: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct GetAllowanceReturn { pub allowance: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct IncreaseAllowanceReturn { pub new_allowance: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct DecreaseAllowanceReturn { pub new_allowance: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct RevokeAllowanceReturn { pub old_allowance: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct MintParams { // Recipient of the newly minted tokens. @@ -72,12 +83,14 @@ pub struct MintParams { pub operators: Vec
, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct DestroyParams { pub owner: Address, pub amount: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct GranularityReturn { diff --git a/actors/datacap/src/v17/types.rs b/actors/datacap/src/v17/types.rs index 56374f24..44376e1b 100644 --- a/actors/datacap/src/v17/types.rs +++ b/actors/datacap/src/v17/types.rs @@ -2,66 +2,77 @@ use fvm_ipld_encoding::tuple::*; use fvm_shared4::address::Address; use fvm_shared4::econ::TokenAmount; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct ConstructorParams { pub governor: Address, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct NameReturn { pub name: String, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct SymbolReturn { pub symbol: String, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct TotalSupplyReturn { pub supply: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct BalanceParams { pub address: Address, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct BalanceReturn { pub balance: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct GetAllowanceReturn { pub allowance: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct IncreaseAllowanceReturn { pub new_allowance: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct DecreaseAllowanceReturn { pub new_allowance: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct RevokeAllowanceReturn { pub old_allowance: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct MintParams { // Recipient of the newly minted tokens. @@ -72,12 +83,14 @@ pub struct MintParams { pub operators: Vec
, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct DestroyParams { pub owner: Address, pub amount: TokenAmount, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct GranularityReturn { diff --git a/actors/datacap/src/v9/types.rs b/actors/datacap/src/v9/types.rs index 6ffaa903..e8a020e6 100644 --- a/actors/datacap/src/v9/types.rs +++ b/actors/datacap/src/v9/types.rs @@ -2,6 +2,7 @@ use fvm_ipld_encoding::tuple::*; use fvm_shared::address::Address; use fvm_shared::econ::TokenAmount; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct MintParams { // Recipient of the newly minted tokens. @@ -12,6 +13,7 @@ pub struct MintParams { pub operators: Vec
, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct DestroyParams { pub owner: Address, diff --git a/actors/datacap/tests/json_value_tests.rs b/actors/datacap/tests/json_value_tests.rs new file mode 100644 index 00000000..fa9e9e3a --- /dev/null +++ b/actors/datacap/tests/json_value_tests.rs @@ -0,0 +1,180 @@ +#![cfg(feature = "json")] + +//! Unit tests for `to_json_value()` on datacap types across all versions. +//! These test the derive macro output directly, independent of the decoder. + +use serde_json::Value; + +/// Generate tests for a datacap version that has MintParams and DestroyParams. +/// All versions (v9-v17) have these two types. +macro_rules! test_mint_destroy { + ($mod_name:ident, $version:ident, $addr_new_id:path, $token_from_atto:path) => { + mod $mod_name { + use super::*; + + #[test] + fn mint_params_produces_named_fields() { + let params = fil_actor_datacap_state::$version::MintParams { + to: $addr_new_id(1234), + amount: $token_from_atto(5_000_000), + operators: vec![$addr_new_id(5678), $addr_new_id(9999)], + }; + let json = params.to_json_value(); + let obj = json.as_object().expect("expected JSON object"); + assert_eq!(obj.len(), 3); + assert!(obj.contains_key("to")); + assert!(obj.contains_key("amount")); + assert!(obj.contains_key("operators")); + assert_eq!(obj["to"], Value::String("f01234".into())); + assert_eq!(obj["amount"], Value::String("5000000".into())); + let ops = obj["operators"].as_array().unwrap(); + assert_eq!(ops.len(), 2); + assert_eq!(ops[0], Value::String("f05678".into())); + } + + #[test] + fn destroy_params_produces_named_fields() { + let params = fil_actor_datacap_state::$version::DestroyParams { + owner: $addr_new_id(42), + amount: $token_from_atto(999), + }; + let json = params.to_json_value(); + let obj = json.as_object().unwrap(); + assert_eq!(obj["owner"], Value::String("f042".into())); + assert_eq!(obj["amount"], Value::String("999".into())); + } + } + }; +} + +/// Generate tests for versions that have the full type set (v12-v17). +/// Adds transparent type tests and cross-version equivalence. +macro_rules! test_full_types { + ($mod_name:ident, $version:ident) => { + mod $mod_name { + use super::*; + use fil_actor_datacap_state::$version; + use fvm_shared4::address::Address; + use fvm_shared4::econ::TokenAmount; + + #[test] + fn transparent_constructor() { + let p = $version::ConstructorParams { + governor: Address::new_id(100), + }; + assert_eq!(p.to_json_value(), Value::String("f0100".into())); + } + + #[test] + fn transparent_name_return() { + let r = $version::NameReturn { + name: "DataCap".into(), + }; + assert_eq!(r.to_json_value(), Value::String("DataCap".into())); + } + + #[test] + fn transparent_granularity_return() { + let r = $version::GranularityReturn { granularity: 42 }; + assert_eq!(r.to_json_value(), serde_json::json!(42)); + } + + #[test] + fn transparent_token_amount_types() { + let r = $version::TotalSupplyReturn { + supply: TokenAmount::from_atto(1_000_000_000), + }; + assert_eq!(r.to_json_value(), Value::String("1000000000".into())); + + let r = $version::BalanceReturn { + balance: TokenAmount::from_atto(0), + }; + assert_eq!(r.to_json_value(), Value::String("0".into())); + } + } + }; +} + +// v9-v11 use fvm_shared v2/v3 types — tested via decoder snapshot tests. +// v12+ use fvm_shared4 types and can be tested directly here. +test_mint_destroy!( + v12, + v12, + fvm_shared4::address::Address::new_id, + fvm_shared4::econ::TokenAmount::from_atto +); +test_mint_destroy!( + v13, + v13, + fvm_shared4::address::Address::new_id, + fvm_shared4::econ::TokenAmount::from_atto +); +test_mint_destroy!( + v14, + v14, + fvm_shared4::address::Address::new_id, + fvm_shared4::econ::TokenAmount::from_atto +); +test_mint_destroy!( + v15, + v15, + fvm_shared4::address::Address::new_id, + fvm_shared4::econ::TokenAmount::from_atto +); +test_mint_destroy!( + v16, + v16, + fvm_shared4::address::Address::new_id, + fvm_shared4::econ::TokenAmount::from_atto +); +test_mint_destroy!( + v17, + v17, + fvm_shared4::address::Address::new_id, + fvm_shared4::econ::TokenAmount::from_atto +); + +// v11 has full types but uses fvm_shared3 — can't construct with fvm_shared4 types. +// Full type tests for v12-v17 (fvm_shared4, have ConstructorParams, NameReturn, etc.) +test_full_types!(v12_full, v12); +test_full_types!(v13_full, v13); +test_full_types!(v14_full, v14); +test_full_types!(v15_full, v15); +test_full_types!(v16_full, v16); +test_full_types!(v17_full, v17); + +/// Cross-version equivalence: all versions produce the same JSON for MintParams. +#[test] +fn all_versions_produce_same_mint_output() { + use fvm_shared4::address::Address; + use fvm_shared4::econ::TokenAmount; + + let expected = fil_actor_datacap_state::v17::MintParams { + to: Address::new_id(1234), + amount: TokenAmount::from_atto(5_000_000), + operators: vec![Address::new_id(5678)], + } + .to_json_value(); + + // v12-v16 use fvm_shared4 — construct directly + macro_rules! assert_mint_eq { + ($ver:ident) => { + let p = fil_actor_datacap_state::$ver::MintParams { + to: Address::new_id(1234), + amount: TokenAmount::from_atto(5_000_000), + operators: vec![Address::new_id(5678)], + }; + assert_eq!( + p.to_json_value(), + expected, + "v{} mismatch", + stringify!($ver) + ); + }; + } + assert_mint_eq!(v12); + assert_mint_eq!(v13); + assert_mint_eq!(v14); + assert_mint_eq!(v15); + assert_mint_eq!(v16); +} diff --git a/actors/verifreg/Cargo.toml b/actors/verifreg/Cargo.toml index 725d1b5a..58ad30ba 100644 --- a/actors/verifreg/Cargo.toml +++ b/actors/verifreg/Cargo.toml @@ -28,3 +28,15 @@ log = { workspace = true } num-derive = { workspace = true } num-traits = { workspace = true } serde = { workspace = true } + +# Optional: JSON value conversion +fil_actor_json_derive = { workspace = true, optional = true } +serde_json = { workspace = true, optional = true } + +[dev-dependencies] +fil_actors_shared = { workspace = true, features = ["json"] } +serde_json = { workspace = true } + +[features] +default = [] +json = ["dep:fil_actor_json_derive", "dep:serde_json", "fil_actors_shared/json"] diff --git a/actors/verifreg/src/v10/state.rs b/actors/verifreg/src/v10/state.rs index dc0f9d79..55d04ad1 100644 --- a/actors/verifreg/src/v10/state.rs +++ b/actors/verifreg/src/v10/state.rs @@ -219,6 +219,7 @@ impl State { Ok(()) } } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug, PartialEq, Eq)] pub struct Claim { // The provider storing the data (from allocation). @@ -239,6 +240,7 @@ pub struct Claim { pub sector: SectorNumber, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug, PartialEq, Eq)] pub struct Allocation { // The verified client which allocated the DataCap. diff --git a/actors/verifreg/src/v10/types.rs b/actors/verifreg/src/v10/types.rs index c55085a5..3425ca36 100644 --- a/actors/verifreg/src/v10/types.rs +++ b/actors/verifreg/src/v10/types.rs @@ -18,6 +18,7 @@ use super::Claim; pub type AllocationID = u64; pub type ClaimID = u64; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct VerifierParams { pub address: Address, @@ -35,6 +36,7 @@ pub type DataCap = StoragePower; pub const SIGNATURE_DOMAIN_SEPARATION_REMOVE_DATA_CAP: &[u8] = b"fil_removedatacap:"; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapParams { pub verified_client_to_remove: Address, @@ -44,12 +46,14 @@ pub struct RemoveDataCapParams { pub verifier_request_2: RemoveDataCapRequest, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapRequest { pub verifier: Address, pub signature: Signature, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapReturn { pub verified_client: Address, @@ -57,11 +61,13 @@ pub struct RemoveDataCapReturn { pub data_cap_removed: DataCap, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapProposalID { pub id: u64, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Debug, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapProposal { pub verified_client: Address, @@ -88,6 +94,7 @@ impl AddrPairKey { } } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveExpiredAllocationsParams { // Client for which to remove expired allocations. @@ -97,6 +104,7 @@ pub struct RemoveExpiredAllocationsParams { pub allocation_ids: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveExpiredAllocationsReturn { // Ids of the allocations that were either specified by the caller or discovered to be expired. @@ -108,6 +116,7 @@ pub struct RemoveExpiredAllocationsReturn { pub datacap_recovered: DataCap, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct SectorAllocationClaim { pub client: ActorID, @@ -118,12 +127,14 @@ pub struct SectorAllocationClaim { pub sector_expiry: ChainEpoch, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ClaimAllocationsParams { pub sectors: Vec, pub all_or_nothing: bool, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ClaimAllocationsReturn { pub batch_info: BatchReturn, @@ -131,6 +142,7 @@ pub struct ClaimAllocationsReturn { pub claimed_space: BigInt, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ClaimTerm { pub provider: ActorID, @@ -138,6 +150,7 @@ pub struct ClaimTerm { pub term_max: ChainEpoch, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ExtendClaimTermsParams { pub terms: Vec, @@ -151,6 +164,7 @@ pub type ExtendClaimTermsReturn = BatchReturn; // A request to create an allocation with datacap tokens. // See Allocation state for description of field semantics. +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct AllocationRequest { pub provider: ActorID, @@ -162,6 +176,7 @@ pub struct AllocationRequest { } // A request to extend the term of an existing claim with datacap tokens. +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ClaimExtensionRequest { pub provider: ActorID, @@ -171,6 +186,7 @@ pub struct ClaimExtensionRequest { /// Operator-data payload for a datacap token transfer receiver hook specifying an allocation. /// The implied client is the sender of the datacap. +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct AllocationRequests { pub allocations: Vec, @@ -178,6 +194,7 @@ pub struct AllocationRequests { } /// Recipient data payload in response to a datacap token transfer. +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct AllocationsResponse { // Result for each allocation request. @@ -188,18 +205,21 @@ pub struct AllocationsResponse { pub new_allocations: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct GetClaimsParams { pub provider: ActorID, pub claim_ids: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct GetClaimsReturn { pub batch_info: BatchReturn, pub claims: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveExpiredClaimsParams { // Provider to clean up (need not be the caller) @@ -209,6 +229,7 @@ pub struct RemoveExpiredClaimsParams { pub claim_ids: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveExpiredClaimsReturn { // Ids of the claims that were either specified by the caller or discovered to be expired. diff --git a/actors/verifreg/src/v11/state.rs b/actors/verifreg/src/v11/state.rs index 310299b7..573f0b68 100644 --- a/actors/verifreg/src/v11/state.rs +++ b/actors/verifreg/src/v11/state.rs @@ -219,6 +219,7 @@ impl State { Ok(()) } } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug, PartialEq, Eq)] pub struct Claim { // The provider storing the data (from allocation). @@ -239,6 +240,7 @@ pub struct Claim { pub sector: SectorNumber, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug, PartialEq, Eq)] pub struct Allocation { // The verified client which allocated the DataCap. diff --git a/actors/verifreg/src/v11/types.rs b/actors/verifreg/src/v11/types.rs index 7b5579af..b55d7689 100644 --- a/actors/verifreg/src/v11/types.rs +++ b/actors/verifreg/src/v11/types.rs @@ -18,12 +18,14 @@ use super::Claim; pub type AllocationID = u64; pub type ClaimID = u64; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct ConstructorParams { pub root_key: Address, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct VerifierParams { pub address: Address, @@ -35,6 +37,7 @@ pub type AddVerifierParams = VerifierParams; pub type AddVerifiedClientParams = VerifierParams; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct RemoveVerifierParams { @@ -47,6 +50,7 @@ pub type DataCap = StoragePower; pub const SIGNATURE_DOMAIN_SEPARATION_REMOVE_DATA_CAP: &[u8] = b"fil_removedatacap:"; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapParams { pub verified_client_to_remove: Address, @@ -56,12 +60,14 @@ pub struct RemoveDataCapParams { pub verifier_request_2: RemoveDataCapRequest, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapRequest { pub verifier: Address, pub signature: Signature, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapReturn { pub verified_client: Address, @@ -69,11 +75,13 @@ pub struct RemoveDataCapReturn { pub data_cap_removed: DataCap, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapProposalID { pub id: u64, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Debug, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapProposal { pub verified_client: Address, @@ -100,6 +108,7 @@ impl AddrPairKey { } } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveExpiredAllocationsParams { // Client for which to remove expired allocations. @@ -109,6 +118,7 @@ pub struct RemoveExpiredAllocationsParams { pub allocation_ids: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveExpiredAllocationsReturn { // Ids of the allocations that were either specified by the caller or discovered to be expired. @@ -120,6 +130,7 @@ pub struct RemoveExpiredAllocationsReturn { pub datacap_recovered: DataCap, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct SectorAllocationClaim { pub client: ActorID, @@ -130,12 +141,14 @@ pub struct SectorAllocationClaim { pub sector_expiry: ChainEpoch, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ClaimAllocationsParams { pub sectors: Vec, pub all_or_nothing: bool, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ClaimAllocationsReturn { pub batch_info: BatchReturn, @@ -143,6 +156,7 @@ pub struct ClaimAllocationsReturn { pub claimed_space: BigInt, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ClaimTerm { pub provider: ActorID, @@ -150,6 +164,7 @@ pub struct ClaimTerm { pub term_max: ChainEpoch, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ExtendClaimTermsParams { pub terms: Vec, @@ -163,6 +178,7 @@ pub type ExtendClaimTermsReturn = BatchReturn; // A request to create an allocation with datacap tokens. // See Allocation state for description of field semantics. +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct AllocationRequest { pub provider: ActorID, @@ -174,6 +190,7 @@ pub struct AllocationRequest { } // A request to extend the term of an existing claim with datacap tokens. +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ClaimExtensionRequest { pub provider: ActorID, @@ -183,6 +200,7 @@ pub struct ClaimExtensionRequest { /// Operator-data payload for a datacap token transfer receiver hook specifying an allocation. /// The implied client is the sender of the datacap. +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct AllocationRequests { pub allocations: Vec, @@ -190,6 +208,7 @@ pub struct AllocationRequests { } /// Recipient data payload in response to a datacap token transfer. +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct AllocationsResponse { // Result for each allocation request. @@ -200,18 +219,21 @@ pub struct AllocationsResponse { pub new_allocations: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct GetClaimsParams { pub provider: ActorID, pub claim_ids: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct GetClaimsReturn { pub batch_info: BatchReturn, pub claims: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveExpiredClaimsParams { // Provider to clean up (need not be the caller) @@ -221,6 +243,7 @@ pub struct RemoveExpiredClaimsParams { pub claim_ids: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveExpiredClaimsReturn { // Ids of the claims that were either specified by the caller or discovered to be expired. diff --git a/actors/verifreg/src/v12/state.rs b/actors/verifreg/src/v12/state.rs index 6101acdb..8f79c6cb 100644 --- a/actors/verifreg/src/v12/state.rs +++ b/actors/verifreg/src/v12/state.rs @@ -23,6 +23,7 @@ pub const DATACAP_MAP_CONFIG: Config = DEFAULT_HAMT_CONFIG; pub type RemoveDataCapProposalMap = Map2; pub const REMOVE_DATACAP_PROPOSALS_CONFIG: Config = DEFAULT_HAMT_CONFIG; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Debug, Clone)] pub struct State { pub root_key: Address, @@ -199,6 +200,7 @@ impl State { Ok(()) } } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug, PartialEq, Eq)] pub struct Claim { // The provider storing the data (from allocation). @@ -219,6 +221,7 @@ pub struct Claim { pub sector: SectorNumber, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug, PartialEq, Eq)] pub struct Allocation { // The verified client which allocated the DataCap. diff --git a/actors/verifreg/src/v12/types.rs b/actors/verifreg/src/v12/types.rs index f7edc7d7..4413762d 100644 --- a/actors/verifreg/src/v12/types.rs +++ b/actors/verifreg/src/v12/types.rs @@ -19,12 +19,14 @@ use crate::v12::Claim; pub type AllocationID = u64; pub type ClaimID = u64; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct ConstructorParams { pub root_key: Address, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct VerifierParams { pub address: Address, @@ -36,6 +38,7 @@ pub type AddVerifierParams = VerifierParams; pub type AddVerifiedClientParams = VerifierParams; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct RemoveVerifierParams { @@ -48,6 +51,7 @@ pub type DataCap = StoragePower; pub const SIGNATURE_DOMAIN_SEPARATION_REMOVE_DATA_CAP: &[u8] = b"fil_removedatacap:"; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapParams { pub verified_client_to_remove: Address, @@ -57,12 +61,14 @@ pub struct RemoveDataCapParams { pub verifier_request_2: RemoveDataCapRequest, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapRequest { pub verifier: Address, pub signature: Signature, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapReturn { pub verified_client: Address, @@ -70,11 +76,13 @@ pub struct RemoveDataCapReturn { pub data_cap_removed: DataCap, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapProposalID { pub id: u64, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Debug, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapProposal { pub verified_client: Address, @@ -113,6 +121,7 @@ impl MapKey for AddrPairKey { } } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveExpiredAllocationsParams { // Client for which to remove expired allocations. @@ -122,6 +131,7 @@ pub struct RemoveExpiredAllocationsParams { pub allocation_ids: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveExpiredAllocationsReturn { // Ids of the allocations that were either specified by the caller or discovered to be expired. @@ -133,6 +143,7 @@ pub struct RemoveExpiredAllocationsReturn { pub datacap_recovered: DataCap, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct SectorAllocationClaims { pub sector: SectorNumber, @@ -140,6 +151,7 @@ pub struct SectorAllocationClaims { pub claims: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct AllocationClaim { pub client: ActorID, @@ -148,6 +160,7 @@ pub struct AllocationClaim { pub size: PaddedPieceSize, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ClaimAllocationsParams { /// Allocations to claim, grouped by sector. @@ -158,6 +171,7 @@ pub struct ClaimAllocationsParams { pub all_or_nothing: bool, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Default, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct SectorClaimSummary { @@ -165,6 +179,7 @@ pub struct SectorClaimSummary { pub claimed_space: BigInt, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ClaimAllocationsReturn { /// Status of each sector grouping of claims. @@ -173,6 +188,7 @@ pub struct ClaimAllocationsReturn { pub sector_claims: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ClaimTerm { pub provider: ActorID, @@ -180,6 +196,7 @@ pub struct ClaimTerm { pub term_max: ChainEpoch, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ExtendClaimTermsParams { pub terms: Vec, @@ -193,6 +210,7 @@ pub type ExtendClaimTermsReturn = BatchReturn; // A request to create an allocation with datacap tokens. // See Allocation state for description of field semantics. +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct AllocationRequest { pub provider: ActorID, @@ -204,6 +222,7 @@ pub struct AllocationRequest { } // A request to extend the term of an existing claim with datacap tokens. +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ClaimExtensionRequest { pub provider: ActorID, @@ -213,6 +232,7 @@ pub struct ClaimExtensionRequest { /// Operator-data payload for a datacap token transfer receiver hook specifying an allocation. /// The implied client is the sender of the datacap. +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct AllocationRequests { pub allocations: Vec, @@ -220,6 +240,7 @@ pub struct AllocationRequests { } /// Recipient data payload in response to a datacap token transfer. +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct AllocationsResponse { // Result for each allocation request. @@ -230,18 +251,21 @@ pub struct AllocationsResponse { pub new_allocations: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct GetClaimsParams { pub provider: ActorID, pub claim_ids: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct GetClaimsReturn { pub batch_info: BatchReturn, pub claims: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveExpiredClaimsParams { // Provider to clean up (need not be the caller) @@ -251,6 +275,7 @@ pub struct RemoveExpiredClaimsParams { pub claim_ids: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveExpiredClaimsReturn { // Ids of the claims that were either specified by the caller or discovered to be expired. diff --git a/actors/verifreg/src/v13/state.rs b/actors/verifreg/src/v13/state.rs index 22126014..445777c1 100644 --- a/actors/verifreg/src/v13/state.rs +++ b/actors/verifreg/src/v13/state.rs @@ -23,6 +23,7 @@ pub const DATACAP_MAP_CONFIG: Config = DEFAULT_HAMT_CONFIG; pub type RemoveDataCapProposalMap = Map2; pub const REMOVE_DATACAP_PROPOSALS_CONFIG: Config = DEFAULT_HAMT_CONFIG; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Debug, Clone)] pub struct State { pub root_key: Address, @@ -199,6 +200,7 @@ impl State { Ok(()) } } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug, PartialEq, Eq)] pub struct Claim { // The provider storing the data (from allocation). @@ -219,6 +221,7 @@ pub struct Claim { pub sector: SectorNumber, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug, PartialEq, Eq)] pub struct Allocation { // The verified client which allocated the DataCap. diff --git a/actors/verifreg/src/v13/types.rs b/actors/verifreg/src/v13/types.rs index bcf8b09f..10d2f4ee 100644 --- a/actors/verifreg/src/v13/types.rs +++ b/actors/verifreg/src/v13/types.rs @@ -19,12 +19,14 @@ use crate::v13::Claim; pub type AllocationID = u64; pub type ClaimID = u64; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct ConstructorParams { pub root_key: Address, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct VerifierParams { pub address: Address, @@ -36,6 +38,7 @@ pub type AddVerifierParams = VerifierParams; pub type AddVerifiedClientParams = VerifierParams; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct RemoveVerifierParams { @@ -48,6 +51,7 @@ pub type DataCap = StoragePower; pub const SIGNATURE_DOMAIN_SEPARATION_REMOVE_DATA_CAP: &[u8] = b"fil_removedatacap:"; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapParams { pub verified_client_to_remove: Address, @@ -57,12 +61,14 @@ pub struct RemoveDataCapParams { pub verifier_request_2: RemoveDataCapRequest, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapRequest { pub verifier: Address, pub signature: Signature, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapReturn { pub verified_client: Address, @@ -70,11 +76,13 @@ pub struct RemoveDataCapReturn { pub data_cap_removed: DataCap, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapProposalID { pub id: u64, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Debug, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapProposal { pub verified_client: Address, @@ -113,6 +121,7 @@ impl MapKey for AddrPairKey { } } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveExpiredAllocationsParams { // Client for which to remove expired allocations. @@ -122,6 +131,7 @@ pub struct RemoveExpiredAllocationsParams { pub allocation_ids: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveExpiredAllocationsReturn { // Ids of the allocations that were either specified by the caller or discovered to be expired. @@ -133,6 +143,7 @@ pub struct RemoveExpiredAllocationsReturn { pub datacap_recovered: DataCap, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct SectorAllocationClaims { pub sector: SectorNumber, @@ -140,6 +151,7 @@ pub struct SectorAllocationClaims { pub claims: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct AllocationClaim { pub client: ActorID, @@ -148,6 +160,7 @@ pub struct AllocationClaim { pub size: PaddedPieceSize, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ClaimAllocationsParams { /// Allocations to claim, grouped by sector. @@ -158,6 +171,7 @@ pub struct ClaimAllocationsParams { pub all_or_nothing: bool, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Default, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct SectorClaimSummary { @@ -165,6 +179,7 @@ pub struct SectorClaimSummary { pub claimed_space: BigInt, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ClaimAllocationsReturn { /// Status of each sector grouping of claims. @@ -173,6 +188,7 @@ pub struct ClaimAllocationsReturn { pub sector_claims: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ClaimTerm { pub provider: ActorID, @@ -180,6 +196,7 @@ pub struct ClaimTerm { pub term_max: ChainEpoch, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ExtendClaimTermsParams { pub terms: Vec, @@ -193,6 +210,7 @@ pub type ExtendClaimTermsReturn = BatchReturn; // A request to create an allocation with datacap tokens. // See Allocation state for description of field semantics. +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct AllocationRequest { pub provider: ActorID, @@ -204,6 +222,7 @@ pub struct AllocationRequest { } // A request to extend the term of an existing claim with datacap tokens. +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ClaimExtensionRequest { pub provider: ActorID, @@ -213,6 +232,7 @@ pub struct ClaimExtensionRequest { /// Operator-data payload for a datacap token transfer receiver hook specifying an allocation. /// The implied client is the sender of the datacap. +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct AllocationRequests { pub allocations: Vec, @@ -220,6 +240,7 @@ pub struct AllocationRequests { } /// Recipient data payload in response to a datacap token transfer. +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct AllocationsResponse { // Result for each allocation request. @@ -230,18 +251,21 @@ pub struct AllocationsResponse { pub new_allocations: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct GetClaimsParams { pub provider: ActorID, pub claim_ids: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct GetClaimsReturn { pub batch_info: BatchReturn, pub claims: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveExpiredClaimsParams { // Provider to clean up (need not be the caller) @@ -251,6 +275,7 @@ pub struct RemoveExpiredClaimsParams { pub claim_ids: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveExpiredClaimsReturn { // Ids of the claims that were either specified by the caller or discovered to be expired. diff --git a/actors/verifreg/src/v14/state.rs b/actors/verifreg/src/v14/state.rs index 6a753d86..e0b8157f 100644 --- a/actors/verifreg/src/v14/state.rs +++ b/actors/verifreg/src/v14/state.rs @@ -24,6 +24,7 @@ pub const DATACAP_MAP_CONFIG: Config = DEFAULT_HAMT_CONFIG; pub type RemoveDataCapProposalMap = Map2; pub const REMOVE_DATACAP_PROPOSALS_CONFIG: Config = DEFAULT_HAMT_CONFIG; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Debug, Clone)] pub struct State { pub root_key: Address, @@ -200,6 +201,7 @@ impl State { Ok(()) } } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug, PartialEq, Eq)] pub struct Claim { // The provider storing the data (from allocation). @@ -220,6 +222,7 @@ pub struct Claim { pub sector: SectorNumber, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug, PartialEq, Eq)] pub struct Allocation { // The verified client which allocated the DataCap. diff --git a/actors/verifreg/src/v14/types.rs b/actors/verifreg/src/v14/types.rs index 668dc027..2d0d5da1 100644 --- a/actors/verifreg/src/v14/types.rs +++ b/actors/verifreg/src/v14/types.rs @@ -19,12 +19,14 @@ use crate::v14::Claim; pub type AllocationID = u64; pub type ClaimID = u64; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct ConstructorParams { pub root_key: Address, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct VerifierParams { pub address: Address, @@ -36,6 +38,7 @@ pub type AddVerifierParams = VerifierParams; pub type AddVerifiedClientParams = VerifierParams; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct RemoveVerifierParams { @@ -48,6 +51,7 @@ pub type DataCap = StoragePower; pub const SIGNATURE_DOMAIN_SEPARATION_REMOVE_DATA_CAP: &[u8] = b"fil_removedatacap:"; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapParams { pub verified_client_to_remove: Address, @@ -57,12 +61,14 @@ pub struct RemoveDataCapParams { pub verifier_request_2: RemoveDataCapRequest, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapRequest { pub verifier: Address, pub signature: Signature, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapReturn { pub verified_client: Address, @@ -70,11 +76,13 @@ pub struct RemoveDataCapReturn { pub data_cap_removed: DataCap, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapProposalID { pub id: u64, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Debug, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapProposal { pub verified_client: Address, @@ -113,6 +121,7 @@ impl MapKey for AddrPairKey { } } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveExpiredAllocationsParams { // Client for which to remove expired allocations. @@ -122,6 +131,7 @@ pub struct RemoveExpiredAllocationsParams { pub allocation_ids: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveExpiredAllocationsReturn { // Ids of the allocations that were either specified by the caller or discovered to be expired. @@ -133,6 +143,7 @@ pub struct RemoveExpiredAllocationsReturn { pub datacap_recovered: DataCap, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct SectorAllocationClaims { pub sector: SectorNumber, @@ -140,6 +151,7 @@ pub struct SectorAllocationClaims { pub claims: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct AllocationClaim { pub client: ActorID, @@ -148,6 +160,7 @@ pub struct AllocationClaim { pub size: PaddedPieceSize, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ClaimAllocationsParams { /// Allocations to claim, grouped by sector. @@ -158,6 +171,7 @@ pub struct ClaimAllocationsParams { pub all_or_nothing: bool, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Default, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct SectorClaimSummary { @@ -165,6 +179,7 @@ pub struct SectorClaimSummary { pub claimed_space: BigInt, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ClaimAllocationsReturn { /// Status of each sector grouping of claims. @@ -173,6 +188,7 @@ pub struct ClaimAllocationsReturn { pub sector_claims: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ClaimTerm { pub provider: ActorID, @@ -180,6 +196,7 @@ pub struct ClaimTerm { pub term_max: ChainEpoch, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ExtendClaimTermsParams { pub terms: Vec, @@ -193,6 +210,7 @@ pub type ExtendClaimTermsReturn = BatchReturn; // A request to create an allocation with datacap tokens. // See Allocation state for description of field semantics. +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct AllocationRequest { pub provider: ActorID, @@ -204,6 +222,7 @@ pub struct AllocationRequest { } // A request to extend the term of an existing claim with datacap tokens. +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ClaimExtensionRequest { pub provider: ActorID, @@ -213,6 +232,7 @@ pub struct ClaimExtensionRequest { /// Operator-data payload for a datacap token transfer receiver hook specifying an allocation. /// The implied client is the sender of the datacap. +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct AllocationRequests { pub allocations: Vec, @@ -220,6 +240,7 @@ pub struct AllocationRequests { } /// Recipient data payload in response to a datacap token transfer. +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct AllocationsResponse { // Result for each allocation request. @@ -230,18 +251,21 @@ pub struct AllocationsResponse { pub new_allocations: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct GetClaimsParams { pub provider: ActorID, pub claim_ids: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct GetClaimsReturn { pub batch_info: BatchReturn, pub claims: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveExpiredClaimsParams { // Provider to clean up (need not be the caller) @@ -251,6 +275,7 @@ pub struct RemoveExpiredClaimsParams { pub claim_ids: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveExpiredClaimsReturn { // Ids of the claims that were either specified by the caller or discovered to be expired. diff --git a/actors/verifreg/src/v15/state.rs b/actors/verifreg/src/v15/state.rs index 901da797..5fae3413 100644 --- a/actors/verifreg/src/v15/state.rs +++ b/actors/verifreg/src/v15/state.rs @@ -23,6 +23,7 @@ pub const DATACAP_MAP_CONFIG: Config = DEFAULT_HAMT_CONFIG; pub type RemoveDataCapProposalMap = Map2; pub const REMOVE_DATACAP_PROPOSALS_CONFIG: Config = DEFAULT_HAMT_CONFIG; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Debug, Clone)] pub struct State { pub root_key: Address, @@ -199,6 +200,7 @@ impl State { Ok(()) } } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug, PartialEq, Eq)] pub struct Claim { // The provider storing the data (from allocation). @@ -219,6 +221,7 @@ pub struct Claim { pub sector: SectorNumber, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug, PartialEq, Eq)] pub struct Allocation { // The verified client which allocated the DataCap. diff --git a/actors/verifreg/src/v15/types.rs b/actors/verifreg/src/v15/types.rs index 0186e001..7fe129e4 100644 --- a/actors/verifreg/src/v15/types.rs +++ b/actors/verifreg/src/v15/types.rs @@ -19,12 +19,14 @@ use crate::v15::Claim; pub type AllocationID = u64; pub type ClaimID = u64; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct ConstructorParams { pub root_key: Address, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct VerifierParams { pub address: Address, @@ -36,6 +38,7 @@ pub type AddVerifierParams = VerifierParams; pub type AddVerifiedClientParams = VerifierParams; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct RemoveVerifierParams { @@ -48,6 +51,7 @@ pub type DataCap = StoragePower; pub const SIGNATURE_DOMAIN_SEPARATION_REMOVE_DATA_CAP: &[u8] = b"fil_removedatacap:"; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapParams { pub verified_client_to_remove: Address, @@ -57,12 +61,14 @@ pub struct RemoveDataCapParams { pub verifier_request_2: RemoveDataCapRequest, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapRequest { pub verifier: Address, pub signature: Signature, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapReturn { pub verified_client: Address, @@ -70,11 +76,13 @@ pub struct RemoveDataCapReturn { pub data_cap_removed: DataCap, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapProposalID { pub id: u64, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Debug, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapProposal { pub verified_client: Address, @@ -113,6 +121,7 @@ impl MapKey for AddrPairKey { } } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveExpiredAllocationsParams { // Client for which to remove expired allocations. @@ -122,6 +131,7 @@ pub struct RemoveExpiredAllocationsParams { pub allocation_ids: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveExpiredAllocationsReturn { // Ids of the allocations that were either specified by the caller or discovered to be expired. @@ -133,6 +143,7 @@ pub struct RemoveExpiredAllocationsReturn { pub datacap_recovered: DataCap, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct SectorAllocationClaims { pub sector: SectorNumber, @@ -140,6 +151,7 @@ pub struct SectorAllocationClaims { pub claims: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct AllocationClaim { pub client: ActorID, @@ -148,6 +160,7 @@ pub struct AllocationClaim { pub size: PaddedPieceSize, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ClaimAllocationsParams { /// Allocations to claim, grouped by sector. @@ -158,6 +171,7 @@ pub struct ClaimAllocationsParams { pub all_or_nothing: bool, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Default, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct SectorClaimSummary { @@ -165,6 +179,7 @@ pub struct SectorClaimSummary { pub claimed_space: BigInt, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ClaimAllocationsReturn { /// Status of each sector grouping of claims. @@ -173,6 +188,7 @@ pub struct ClaimAllocationsReturn { pub sector_claims: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ClaimTerm { pub provider: ActorID, @@ -180,6 +196,7 @@ pub struct ClaimTerm { pub term_max: ChainEpoch, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ExtendClaimTermsParams { pub terms: Vec, @@ -193,6 +210,7 @@ pub type ExtendClaimTermsReturn = BatchReturn; // A request to create an allocation with datacap tokens. // See Allocation state for description of field semantics. +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct AllocationRequest { pub provider: ActorID, @@ -204,6 +222,7 @@ pub struct AllocationRequest { } // A request to extend the term of an existing claim with datacap tokens. +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ClaimExtensionRequest { pub provider: ActorID, @@ -213,6 +232,7 @@ pub struct ClaimExtensionRequest { /// Operator-data payload for a datacap token transfer receiver hook specifying an allocation. /// The implied client is the sender of the datacap. +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct AllocationRequests { pub allocations: Vec, @@ -220,6 +240,7 @@ pub struct AllocationRequests { } /// Recipient data payload in response to a datacap token transfer. +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct AllocationsResponse { // Result for each allocation request. @@ -230,18 +251,21 @@ pub struct AllocationsResponse { pub new_allocations: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct GetClaimsParams { pub provider: ActorID, pub claim_ids: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct GetClaimsReturn { pub batch_info: BatchReturn, pub claims: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveExpiredClaimsParams { // Provider to clean up (need not be the caller) @@ -251,6 +275,7 @@ pub struct RemoveExpiredClaimsParams { pub claim_ids: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveExpiredClaimsReturn { // Ids of the claims that were either specified by the caller or discovered to be expired. diff --git a/actors/verifreg/src/v16/state.rs b/actors/verifreg/src/v16/state.rs index 09f37e2a..41519a8b 100644 --- a/actors/verifreg/src/v16/state.rs +++ b/actors/verifreg/src/v16/state.rs @@ -200,6 +200,7 @@ impl State { Ok(()) } } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug, PartialEq, Eq)] pub struct Claim { // The provider storing the data (from allocation). @@ -220,6 +221,7 @@ pub struct Claim { pub sector: SectorNumber, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug, PartialEq, Eq)] pub struct Allocation { // The verified client which allocated the DataCap. diff --git a/actors/verifreg/src/v16/types.rs b/actors/verifreg/src/v16/types.rs index fc56f6b2..4245191c 100644 --- a/actors/verifreg/src/v16/types.rs +++ b/actors/verifreg/src/v16/types.rs @@ -19,12 +19,14 @@ use crate::v16::Claim; pub type AllocationID = u64; pub type ClaimID = u64; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct ConstructorParams { pub root_key: Address, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct VerifierParams { pub address: Address, @@ -36,6 +38,7 @@ pub type AddVerifierParams = VerifierParams; pub type AddVerifiedClientParams = VerifierParams; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct RemoveVerifierParams { @@ -48,6 +51,7 @@ pub type DataCap = StoragePower; pub const SIGNATURE_DOMAIN_SEPARATION_REMOVE_DATA_CAP: &[u8] = b"fil_removedatacap:"; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapParams { pub verified_client_to_remove: Address, @@ -57,12 +61,14 @@ pub struct RemoveDataCapParams { pub verifier_request_2: RemoveDataCapRequest, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapRequest { pub verifier: Address, pub signature: Signature, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapReturn { pub verified_client: Address, @@ -70,11 +76,13 @@ pub struct RemoveDataCapReturn { pub data_cap_removed: DataCap, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapProposalID { pub id: u64, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Debug, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapProposal { pub verified_client: Address, @@ -113,6 +121,7 @@ impl MapKey for AddrPairKey { } } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveExpiredAllocationsParams { // Client for which to remove expired allocations. @@ -122,6 +131,7 @@ pub struct RemoveExpiredAllocationsParams { pub allocation_ids: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveExpiredAllocationsReturn { // Ids of the allocations that were either specified by the caller or discovered to be expired. @@ -133,6 +143,7 @@ pub struct RemoveExpiredAllocationsReturn { pub datacap_recovered: DataCap, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct SectorAllocationClaims { pub sector: SectorNumber, @@ -140,6 +151,7 @@ pub struct SectorAllocationClaims { pub claims: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct AllocationClaim { pub client: ActorID, @@ -148,6 +160,7 @@ pub struct AllocationClaim { pub size: PaddedPieceSize, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ClaimAllocationsParams { /// Allocations to claim, grouped by sector. @@ -158,6 +171,7 @@ pub struct ClaimAllocationsParams { pub all_or_nothing: bool, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Default, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct SectorClaimSummary { @@ -165,6 +179,7 @@ pub struct SectorClaimSummary { pub claimed_space: BigInt, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ClaimAllocationsReturn { /// Status of each sector grouping of claims. @@ -173,6 +188,7 @@ pub struct ClaimAllocationsReturn { pub sector_claims: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ClaimTerm { pub provider: ActorID, @@ -180,6 +196,7 @@ pub struct ClaimTerm { pub term_max: ChainEpoch, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ExtendClaimTermsParams { pub terms: Vec, @@ -193,6 +210,7 @@ pub type ExtendClaimTermsReturn = BatchReturn; // A request to create an allocation with datacap tokens. // See Allocation state for description of field semantics. +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct AllocationRequest { pub provider: ActorID, @@ -204,6 +222,7 @@ pub struct AllocationRequest { } // A request to extend the term of an existing claim with datacap tokens. +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ClaimExtensionRequest { pub provider: ActorID, @@ -213,6 +232,7 @@ pub struct ClaimExtensionRequest { /// Operator-data payload for a datacap token transfer receiver hook specifying an allocation. /// The implied client is the sender of the datacap. +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct AllocationRequests { pub allocations: Vec, @@ -220,6 +240,7 @@ pub struct AllocationRequests { } /// Recipient data payload in response to a datacap token transfer. +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct AllocationsResponse { // Result for each allocation request. @@ -230,18 +251,21 @@ pub struct AllocationsResponse { pub new_allocations: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct GetClaimsParams { pub provider: ActorID, pub claim_ids: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct GetClaimsReturn { pub batch_info: BatchReturn, pub claims: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveExpiredClaimsParams { // Provider to clean up (need not be the caller) @@ -251,6 +275,7 @@ pub struct RemoveExpiredClaimsParams { pub claim_ids: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveExpiredClaimsReturn { // Ids of the claims that were either specified by the caller or discovered to be expired. diff --git a/actors/verifreg/src/v17/state.rs b/actors/verifreg/src/v17/state.rs index 0510b538..e38cc2a9 100644 --- a/actors/verifreg/src/v17/state.rs +++ b/actors/verifreg/src/v17/state.rs @@ -200,6 +200,7 @@ impl State { Ok(()) } } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug, PartialEq, Eq)] pub struct Claim { // The provider storing the data (from allocation). @@ -220,6 +221,7 @@ pub struct Claim { pub sector: SectorNumber, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug, PartialEq, Eq)] pub struct Allocation { // The verified client which allocated the DataCap. diff --git a/actors/verifreg/src/v17/types.rs b/actors/verifreg/src/v17/types.rs index 382dbff8..de7b523d 100644 --- a/actors/verifreg/src/v17/types.rs +++ b/actors/verifreg/src/v17/types.rs @@ -19,12 +19,14 @@ use crate::v17::Claim; pub type AllocationID = u64; pub type ClaimID = u64; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct ConstructorParams { pub root_key: Address, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct VerifierParams { pub address: Address, @@ -36,6 +38,7 @@ pub type AddVerifierParams = VerifierParams; pub type AddVerifiedClientParams = VerifierParams; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct RemoveVerifierParams { @@ -48,6 +51,7 @@ pub type DataCap = StoragePower; pub const SIGNATURE_DOMAIN_SEPARATION_REMOVE_DATA_CAP: &[u8] = b"fil_removedatacap:"; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapParams { pub verified_client_to_remove: Address, @@ -57,12 +61,14 @@ pub struct RemoveDataCapParams { pub verifier_request_2: RemoveDataCapRequest, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapRequest { pub verifier: Address, pub signature: Signature, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapReturn { pub verified_client: Address, @@ -70,11 +76,13 @@ pub struct RemoveDataCapReturn { pub data_cap_removed: DataCap, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapProposalID { pub id: u64, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Debug, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapProposal { pub verified_client: Address, @@ -113,6 +121,7 @@ impl MapKey for AddrPairKey { } } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveExpiredAllocationsParams { // Client for which to remove expired allocations. @@ -122,6 +131,7 @@ pub struct RemoveExpiredAllocationsParams { pub allocation_ids: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveExpiredAllocationsReturn { // Ids of the allocations that were either specified by the caller or discovered to be expired. @@ -133,6 +143,7 @@ pub struct RemoveExpiredAllocationsReturn { pub datacap_recovered: DataCap, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct SectorAllocationClaims { pub sector: SectorNumber, @@ -140,6 +151,7 @@ pub struct SectorAllocationClaims { pub claims: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct AllocationClaim { pub client: ActorID, @@ -148,6 +160,7 @@ pub struct AllocationClaim { pub size: PaddedPieceSize, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ClaimAllocationsParams { /// Allocations to claim, grouped by sector. @@ -158,6 +171,7 @@ pub struct ClaimAllocationsParams { pub all_or_nothing: bool, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Default, Serialize_tuple, Deserialize_tuple)] #[serde(transparent)] pub struct SectorClaimSummary { @@ -165,6 +179,7 @@ pub struct SectorClaimSummary { pub claimed_space: BigInt, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ClaimAllocationsReturn { /// Status of each sector grouping of claims. @@ -173,6 +188,7 @@ pub struct ClaimAllocationsReturn { pub sector_claims: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ClaimTerm { pub provider: ActorID, @@ -180,6 +196,7 @@ pub struct ClaimTerm { pub term_max: ChainEpoch, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ExtendClaimTermsParams { pub terms: Vec, @@ -193,6 +210,7 @@ pub type ExtendClaimTermsReturn = BatchReturn; // A request to create an allocation with datacap tokens. // See Allocation state for description of field semantics. +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct AllocationRequest { pub provider: ActorID, @@ -204,6 +222,7 @@ pub struct AllocationRequest { } // A request to extend the term of an existing claim with datacap tokens. +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ClaimExtensionRequest { pub provider: ActorID, @@ -213,6 +232,7 @@ pub struct ClaimExtensionRequest { /// Operator-data payload for a datacap token transfer receiver hook specifying an allocation. /// The implied client is the sender of the datacap. +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct AllocationRequests { pub allocations: Vec, @@ -220,6 +240,7 @@ pub struct AllocationRequests { } /// Recipient data payload in response to a datacap token transfer. +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct AllocationsResponse { // Result for each allocation request. @@ -230,18 +251,21 @@ pub struct AllocationsResponse { pub new_allocations: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct GetClaimsParams { pub provider: ActorID, pub claim_ids: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct GetClaimsReturn { pub batch_info: BatchReturn, pub claims: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveExpiredClaimsParams { // Provider to clean up (need not be the caller) @@ -251,6 +275,7 @@ pub struct RemoveExpiredClaimsParams { pub claim_ids: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveExpiredClaimsReturn { // Ids of the claims that were either specified by the caller or discovered to be expired. diff --git a/actors/verifreg/src/v8/types.rs b/actors/verifreg/src/v8/types.rs index 7b52a833..02c7893d 100644 --- a/actors/verifreg/src/v8/types.rs +++ b/actors/verifreg/src/v8/types.rs @@ -8,6 +8,7 @@ use fvm_shared::crypto::signature::Signature; use fvm_shared::sector::StoragePower; use serde::{Deserialize, Serialize}; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct VerifierParams { pub address: Address, @@ -23,6 +24,7 @@ pub type AddVerifierClientParams = VerifierParams; /// We can introduce policy changes and replace this in the future. pub type DataCap = StoragePower; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Serialize_tuple, Deserialize_tuple)] pub struct BytesParams { /// Address of verified client. @@ -37,6 +39,7 @@ pub type RestoreBytesParams = BytesParams; pub const SIGNATURE_DOMAIN_SEPARATION_REMOVE_DATA_CAP: &[u8] = b"fil_removedatacap:"; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapParams { pub verified_client_to_remove: Address, @@ -46,12 +49,14 @@ pub struct RemoveDataCapParams { pub verifier_request_2: RemoveDataCapRequest, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapRequest { pub verifier: Address, pub signature: Signature, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapReturn { pub verified_client: Address, @@ -63,6 +68,14 @@ pub struct RemoveDataCapReturn { #[serde(transparent)] pub struct RemoveDataCapProposalID(pub u64); +#[cfg(feature = "json")] +impl fil_actors_shared::json_field::JsonField for RemoveDataCapProposalID { + fn to_json_field(&self) -> serde_json::Value { + serde_json::json!(self.0) + } +} + +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Debug, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapProposal { pub verified_client: Address, diff --git a/actors/verifreg/src/v9/state.rs b/actors/verifreg/src/v9/state.rs index 342869e0..570c9901 100644 --- a/actors/verifreg/src/v9/state.rs +++ b/actors/verifreg/src/v9/state.rs @@ -215,6 +215,7 @@ impl State { Ok(()) } } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug, Eq, PartialEq)] pub struct Claim { // The provider storing the data (from allocation). @@ -235,6 +236,7 @@ pub struct Claim { pub sector: SectorNumber, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug, PartialEq, Eq)] pub struct Allocation { // The verified client which allocated the DataCap. diff --git a/actors/verifreg/src/v9/types.rs b/actors/verifreg/src/v9/types.rs index abacd59e..5fa0f4d2 100644 --- a/actors/verifreg/src/v9/types.rs +++ b/actors/verifreg/src/v9/types.rs @@ -18,6 +18,7 @@ use super::Claim; pub type AllocationID = u64; pub type ClaimID = u64; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct VerifierParams { pub address: Address, @@ -35,6 +36,7 @@ pub type DataCap = StoragePower; pub const SIGNATURE_DOMAIN_SEPARATION_REMOVE_DATA_CAP: &[u8] = b"fil_removedatacap:"; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapParams { pub verified_client_to_remove: Address, @@ -44,12 +46,14 @@ pub struct RemoveDataCapParams { pub verifier_request_2: RemoveDataCapRequest, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapRequest { pub verifier: Address, pub signature: Signature, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapReturn { pub verified_client: Address, @@ -57,11 +61,13 @@ pub struct RemoveDataCapReturn { pub data_cap_removed: DataCap, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapProposalID { pub id: u64, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Debug, Serialize_tuple, Deserialize_tuple)] pub struct RemoveDataCapProposal { pub verified_client: Address, @@ -88,6 +94,7 @@ impl AddrPairKey { } } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveExpiredAllocationsParams { // Client for which to remove expired allocations. @@ -97,6 +104,7 @@ pub struct RemoveExpiredAllocationsParams { pub allocation_ids: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveExpiredAllocationsReturn { // Ids of the allocations that were either specified by the caller or discovered to be expired. @@ -108,6 +116,7 @@ pub struct RemoveExpiredAllocationsReturn { pub datacap_recovered: DataCap, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct SectorAllocationClaim { pub client: ActorID, @@ -118,12 +127,14 @@ pub struct SectorAllocationClaim { pub sector_expiry: ChainEpoch, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ClaimAllocationsParams { pub sectors: Vec, pub all_or_nothing: bool, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ClaimAllocationsReturn { pub batch_info: BatchReturn, @@ -131,6 +142,7 @@ pub struct ClaimAllocationsReturn { pub claimed_space: BigInt, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ClaimTerm { pub provider: ActorID, @@ -138,6 +150,7 @@ pub struct ClaimTerm { pub term_max: ChainEpoch, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ExtendClaimTermsParams { pub terms: Vec, @@ -151,6 +164,7 @@ pub type ExtendClaimTermsReturn = BatchReturn; // A request to create an allocation with datacap tokens. // See Allocation state for description of field semantics. +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct AllocationRequest { pub provider: Address, @@ -162,6 +176,7 @@ pub struct AllocationRequest { } // A request to extend the term of an existing claim with datacap tokens. +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct ClaimExtensionRequest { pub provider: Address, @@ -171,6 +186,7 @@ pub struct ClaimExtensionRequest { /// Operator-data payload for a datacap token transfer receiver hook specifying an allocation. /// The implied client is the sender of the datacap. +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct AllocationRequests { pub allocations: Vec, @@ -178,6 +194,7 @@ pub struct AllocationRequests { } /// Recipient data payload in response to a datacap token transfer. +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct AllocationsResponse { // Result for each allocation request. @@ -188,18 +205,21 @@ pub struct AllocationsResponse { pub new_allocations: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct GetClaimsParams { pub provider: ActorID, pub claim_ids: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct GetClaimsReturn { pub batch_info: BatchReturn, pub claims: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveExpiredClaimsParams { // Provider to clean up (need not be the caller) @@ -209,6 +229,7 @@ pub struct RemoveExpiredClaimsParams { pub claim_ids: Vec, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Clone, Debug, PartialEq, Eq, Serialize_tuple, Deserialize_tuple)] pub struct RemoveExpiredClaimsReturn { // Ids of the claims that were either specified by the caller or discovered to be expired. diff --git a/actors/verifreg/tests/json_value_tests.rs b/actors/verifreg/tests/json_value_tests.rs new file mode 100644 index 00000000..31af7587 --- /dev/null +++ b/actors/verifreg/tests/json_value_tests.rs @@ -0,0 +1,202 @@ +#![cfg(feature = "json")] + +//! Unit tests for `to_json_value()` on verifreg types across all versions. +//! These test the derive macro output directly, independent of the decoder. + +use cid::Cid; +use fvm_shared4::piece::PaddedPieceSize; +use serde_json::Value; + +fn test_cid() -> Cid { + "bafkqaaa".parse::().unwrap() +} + +/// Generate core verifreg tests for a version that has Allocation, Claim, and common types. +/// Covers: field names, Cid→string, PaddedPieceSize→u64, ActorID→number, BigInt→string. +macro_rules! test_verifreg_core { + ($mod_name:ident, $version:ident) => { + mod $mod_name { + use super::*; + use fil_actor_verifreg_state::$version; + + #[test] + fn allocation_produces_named_fields() { + let alloc = $version::Allocation { + client: 1001, + provider: 2002, + data: test_cid(), + size: PaddedPieceSize(1 << 30), + term_min: 518400, + term_max: 1555200, + expiration: 4000000, + }; + let json = alloc.to_json_value(); + let obj = json.as_object().expect("expected JSON object"); + assert_eq!(obj.len(), 7); + assert_eq!(obj["client"], serde_json::json!(1001)); + assert_eq!(obj["provider"], serde_json::json!(2002)); + assert!(obj["data"].is_string()); // Cid → string + assert_eq!(obj["size"], serde_json::json!(1 << 30)); // PaddedPieceSize → u64 + } + + #[test] + fn claim_produces_named_fields() { + let claim = $version::Claim { + provider: 3003, + client: 1001, + data: test_cid(), + size: PaddedPieceSize(1 << 20), + term_min: 518400, + term_max: 1555200, + term_start: 100000, + sector: 42, + }; + let json = claim.to_json_value(); + let obj = json.as_object().unwrap(); + assert_eq!(obj.len(), 8); + assert_eq!(obj["sector"], serde_json::json!(42)); + } + + #[test] + fn extend_claim_terms_nested_vec() { + let params = $version::ExtendClaimTermsParams { + terms: vec![$version::ClaimTerm { + provider: 100, + claim_id: 1, + term_max: 999999, + }], + }; + let json = params.to_json_value(); + let terms = json.as_object().unwrap()["terms"].as_array().unwrap(); + assert_eq!(terms.len(), 1); + let t0 = terms[0].as_object().unwrap(); + assert_eq!(t0["provider"], serde_json::json!(100)); + } + } + }; +} + +/// Test BigInt fields (VerifierParams.allowance has #[serde(with = "bigint_ser")]) +macro_rules! test_verifreg_bigint { + ($mod_name:ident, $version:ident) => { + mod $mod_name { + use super::*; + use fil_actor_verifreg_state::$version; + use fvm_shared4::bigint::BigInt; + + #[test] + fn verifier_params_bigint_field() { + let params = $version::VerifierParams { + address: fvm_shared4::address::Address::new_id(555), + allowance: BigInt::from(1_000_000_000_000i64), + }; + let json = params.to_json_value(); + let obj = json.as_object().unwrap(); + assert_eq!(obj["address"], Value::String("f0555".into())); + assert_eq!(obj["allowance"], Value::String("1000000000000".into())); + } + + #[test] + fn sector_claim_summary_transparent_bigint() { + let summary = $version::SectorClaimSummary { + claimed_space: BigInt::from(34359738368i64), + }; + assert_eq!(summary.to_json_value(), Value::String("34359738368".into())); + } + } + }; +} + +/// Test BatchReturn integration (nested in AllocationsResponse) +macro_rules! test_verifreg_batch_return { + ($mod_name:ident, $version:ident, $shared_version:ident) => { + mod $mod_name { + use fil_actor_verifreg_state::$version; + use fil_actors_shared::$shared_version::BatchReturn; + + #[test] + fn batch_return_nested_in_response() { + let resp = $version::AllocationsResponse { + allocation_results: BatchReturn::ok(3), + extension_results: BatchReturn::ok(0), + new_allocations: vec![10, 11, 12], + }; + let json = resp.to_json_value(); + let obj = json.as_object().unwrap(); + let alloc_results = obj["allocation_results"].as_object().unwrap(); + assert_eq!(alloc_results["success_count"], serde_json::json!(3)); + assert!(alloc_results["fail_codes"].as_array().unwrap().is_empty()); + let allocs = obj["new_allocations"].as_array().unwrap(); + assert_eq!( + allocs, + &[ + serde_json::json!(10), + serde_json::json!(11), + serde_json::json!(12) + ] + ); + } + } + }; +} + +// v9-v11 use fvm_shared v2/v3 PaddedPieceSize — tested via decoder snapshot tests. +// v12+ use fvm_shared4 types and can be tested directly here. +test_verifreg_core!(v12_core, v12); +test_verifreg_core!(v13_core, v13); +test_verifreg_core!(v14_core, v14); +test_verifreg_core!(v15_core, v15); +test_verifreg_core!(v16_core, v16); +test_verifreg_core!(v17_core, v17); + +// BigInt tests only for v12+ (v9-v11 VerifierParams use different fvm_shared Address types) +test_verifreg_bigint!(v12_bigint, v12); +test_verifreg_bigint!(v13_bigint, v13); +test_verifreg_bigint!(v14_bigint, v14); +test_verifreg_bigint!(v15_bigint, v15); +test_verifreg_bigint!(v16_bigint, v16); +test_verifreg_bigint!(v17_bigint, v17); + +// BatchReturn tests — v9-v11 use fvm_shared v2/v3, tested via decoder snapshots. +test_verifreg_batch_return!(v12_batch, v12, v12); +test_verifreg_batch_return!(v13_batch, v13, v13); +test_verifreg_batch_return!(v14_batch, v14, v14); +test_verifreg_batch_return!(v15_batch, v15, v15); +test_verifreg_batch_return!(v16_batch, v16, v16); +test_verifreg_batch_return!(v17_batch, v17, v17); + +/// Cross-version equivalence for v12-v17 (all CBOR-identical) +#[test] +fn v12_through_v17_allocation_produce_same_output() { + let cid = test_cid(); + let expected = fil_actor_verifreg_state::v17::Allocation { + client: 1001, + provider: 2002, + data: cid, + size: PaddedPieceSize(1 << 30), + term_min: 518400, + term_max: 1555200, + expiration: 4000000, + } + .to_json_value(); + + macro_rules! assert_alloc_eq { + ($ver:ident) => { + let a = fil_actor_verifreg_state::$ver::Allocation { + client: 1001, + provider: 2002, + data: cid, + size: PaddedPieceSize(1 << 30), + term_min: 518400, + term_max: 1555200, + expiration: 4000000, + }; + assert_eq!(a.to_json_value(), expected, "{} mismatch", stringify!($ver)); + }; + } + assert_alloc_eq!(v12); + assert_alloc_eq!(v13); + assert_alloc_eq!(v14); + assert_alloc_eq!(v15); + assert_alloc_eq!(v16); +} diff --git a/fil_actor_decoder/Cargo.toml b/fil_actor_decoder/Cargo.toml new file mode 100644 index 00000000..e0cf043f --- /dev/null +++ b/fil_actor_decoder/Cargo.toml @@ -0,0 +1,30 @@ +[package] +name = "fil_actor_decoder" +version = "0.1.0" +edition.workspace = true +license.workspace = true +repository.workspace = true +description = "Decode Filecoin built-in actor params and returns from raw CBOR bytes to JSON" + +[dependencies] +anyhow = { workspace = true } +base64 = { workspace = true } +cid = { workspace = true } +clap = { version = "4", features = ["derive"] } +frc42_dispatch = { workspace = true } +fvm_ipld_encoding = { workspace = true } +fvm_shared4 = { workspace = true } +hex = "0.4" +num-bigint = { workspace = true } +serde_json = { workspace = true } + +fil_actor_datacap_state = { workspace = true, features = ["json"] } +fil_actor_verifreg_state = { workspace = true, features = ["json"] } +fil_actors_shared = { workspace = true, features = ["json"] } + +[dev-dependencies] +insta = { version = "1", features = ["json"] } + +[[bin]] +name = "fil-decode" +path = "src/bin/fil_decode.rs" diff --git a/fil_actor_decoder/README.md b/fil_actor_decoder/README.md new file mode 100644 index 00000000..45a3c056 --- /dev/null +++ b/fil_actor_decoder/README.md @@ -0,0 +1,131 @@ +# fil_actor_decoder + +Decode Filecoin built-in actor params and returns from raw CBOR to JSON. + +Supports **datacap** (f07) and **verifreg** (f06) actors across all versions (v9-v17). + +## CLI + +``` +fil-decode + +Commands: + params Decode method params + return Decode method return value +``` + +### Examples + +Decode by explicit version: + +```sh +fil-decode params \ + --actor verifreg --method 4 --version v17 \ + --hex 825501eb50a2528a325eadc4bb68d975a4d1700c9eeaa3480001900000000000 +``` + +```json +{ + "address": "f15nikeuukgjpk3rf3ndmxljgroagj52vdgznkcwy", + "allowance": "439804651110400" +} +``` + +Resolve version from network + epoch: + +```sh +fil-decode params \ + --actor verifreg --method 4 \ + --network mainnet --epoch 5844742 \ + --hex 825501eb50a2528a325eadc4bb68d975a4d1700c9eeaa3480001900000000000 +``` + +Decode params with a different actor and method: + +```sh +fil-decode params \ + --actor verifreg --method 8 --version v17 \ + --hex 821a00303d2980 +``` + +```json +{ + "allocation_ids": [], + "client": 3161385 +} +``` + +### Sourcing CBOR hex + +From Filecoin JSON-RPC (`Filecoin.ChainGetMessage` for params, `Filecoin.StateReplay` for returns): + +```sh +curl -s -X POST https://filfox.info/rpc/v1 \ + -H 'Content-Type: application/json' \ + -d '{"jsonrpc":"2.0","method":"Filecoin.ChainGetMessage","params":[{"/":"bafy2bzacebr2jvq..."}],"id":1}' +``` + +The `Params` field in the response is base64-encoded CBOR. + +## Library API (unstable) + +> **Note:** This is a POC. The library API is not stable and should not be depended on yet. +> Use the CLI for now; the Rust API will be finalized in a later iteration. + +```rust +use fil_actor_decoder::{ActorType, ActorVersion, decode_params, decode_return}; + +let json = decode_params( + ActorType::VerifiedRegistry, + ActorVersion::V17, + 4, // method number + &cbor_bytes, +)?; +``` + +Network/epoch resolution: + +```rust +use fil_actor_decoder::network::{Network, resolve_actor_version}; + +let version = resolve_actor_version(Network::Mainnet, 5_844_742)?; +``` + +## Version support + +| Actor | Versions | Method numbers | +|-------|----------|---------------| +| datacap (f07) | v9: legacy (Mint=2..Allowance=21) | v10+: FRC-0042 hashes | +| verifreg (f06) | v9+: numeric + FRC-0042 | v12+: nested SectorAllocationClaims | + +Key structural differences between versions: +- **datacap v9** has only MintParams/DestroyParams; v10 adds GranularityReturn; v12+ has full type set +- **verifreg v9** uses flat `SectorAllocationClaim` and `Address`-based providers +- **verifreg v10-v11** uses flat `SectorAllocationClaim` with `ActorID`-based providers +- **verifreg v12+** uses nested `SectorAllocationClaims` (CBOR-identical across v12-v17) + +## Directory structure + +``` +fil_actor_decoder/ + src/ + actors/ # Per-actor decoders (datacap, verifreg) with version dispatch + bin/ # CLI binary + tests/ + fixtures/ # Large CBOR hex fixtures + snapshots/ # Insta snapshot files +``` + +## Development + +All tasks are wired through [mise](https://mise.jdx.dev/). Run from the workspace root (`fil-actor-states/`): + +```sh +mise run decoder:test # unit + snapshot tests +mise run decoder:test-all # above + type-level JSON tests across all actor versions +mise run decoder:clippy # lint decoder + shared crates +mise run decoder:snap-review # review pending snapshot changes +mise run decoder:snap-accept # accept all pending snapshot changes +``` + +Snapshot tests use both real on-chain CBOR (sourced via filfox RPC) and synthetic data constructed from actual Filecoin types. diff --git a/fil_actor_decoder/src/actors/datacap.rs b/fil_actor_decoder/src/actors/datacap.rs new file mode 100644 index 00000000..47de0d48 --- /dev/null +++ b/fil_actor_decoder/src/actors/datacap.rs @@ -0,0 +1,495 @@ +//! DataCap actor (f07) param and return decoder. +//! +//! Supports all actor versions: +//! - v9: legacy method numbers (Mint=2, ..., Allowance=21), only MintParams/DestroyParams types +//! - v10-v11: FRC-0042 method hashes, MintParams/DestroyParams/GranularityReturn +//! - v12-v17: FRC-0042 method hashes, full type set (13 structs, CBOR-identical across versions) + +use crate::ActorVersion; +use crate::actors::{cbor_to_json, decode_empty_param}; +use anyhow::{Result, bail}; +use fvm_ipld_encoding::RawBytes; +use fvm_shared4::address::Address; +use fvm_shared4::econ::TokenAmount; +use serde_json::{Value, json}; + +// --------------------------------------------------------------------------- +// JSON helpers for frc46_token types (external — no to_json_value()) +// --------------------------------------------------------------------------- + +fn addr_json(a: &Address) -> Value { + Value::String(a.to_string()) +} + +fn token_json(t: &TokenAmount) -> Value { + Value::String(t.atto().to_string()) +} + +fn raw_bytes_json(rb: &RawBytes) -> Value { + use base64::Engine; + Value::String(base64::engine::general_purpose::STANDARD.encode(rb.bytes())) +} + +fn try_decode_nested(payload_type: &str, rb: &RawBytes) -> Value { + if rb.bytes().is_empty() { + return json!(""); + } + if let Ok(decoded) = crate::actors::verifreg::decode_nested_payload(payload_type, rb.bytes()) { + return decoded; + } + raw_bytes_json(rb) +} + +// --------------------------------------------------------------------------- +// Method numbers +// --------------------------------------------------------------------------- + +/// FRC-0042 method numbers (v10+) +mod methods { + pub const CONSTRUCTOR: u64 = 1; + pub const MINT: u64 = frc42_dispatch::method_hash!("Mint"); + pub const DESTROY: u64 = frc42_dispatch::method_hash!("Destroy"); + pub const NAME: u64 = frc42_dispatch::method_hash!("Name"); + pub const SYMBOL: u64 = frc42_dispatch::method_hash!("Symbol"); + pub const GRANULARITY: u64 = frc42_dispatch::method_hash!("Granularity"); + pub const TOTAL_SUPPLY: u64 = frc42_dispatch::method_hash!("TotalSupply"); + pub const BALANCE: u64 = frc42_dispatch::method_hash!("Balance"); + pub const TRANSFER: u64 = frc42_dispatch::method_hash!("Transfer"); + pub const TRANSFER_FROM: u64 = frc42_dispatch::method_hash!("TransferFrom"); + pub const INCREASE_ALLOWANCE: u64 = frc42_dispatch::method_hash!("IncreaseAllowance"); + pub const DECREASE_ALLOWANCE: u64 = frc42_dispatch::method_hash!("DecreaseAllowance"); + pub const REVOKE_ALLOWANCE: u64 = frc42_dispatch::method_hash!("RevokeAllowance"); + pub const BURN: u64 = frc42_dispatch::method_hash!("Burn"); + pub const BURN_FROM: u64 = frc42_dispatch::method_hash!("BurnFrom"); + pub const ALLOWANCE: u64 = frc42_dispatch::method_hash!("Allowance"); +} + +/// Legacy method numbers (v9 only) +mod v9_methods { + pub const CONSTRUCTOR: u64 = 0; + pub const MINT: u64 = 2; + pub const DESTROY: u64 = 3; + pub const NAME: u64 = 10; + pub const SYMBOL: u64 = 11; + pub const TOTAL_SUPPLY: u64 = 12; + pub const BALANCE_OF: u64 = 13; + pub const TRANSFER: u64 = 14; + pub const TRANSFER_FROM: u64 = 15; + pub const INCREASE_ALLOWANCE: u64 = 16; + pub const DECREASE_ALLOWANCE: u64 = 17; + pub const REVOKE_ALLOWANCE: u64 = 18; + pub const BURN: u64 = 19; + pub const BURN_FROM: u64 = 20; + pub const ALLOWANCE: u64 = 21; +} + +// --------------------------------------------------------------------------- +// frc46_token type decoders (external — no derive) +// --------------------------------------------------------------------------- + +fn decode_transfer_params(bytes: &[u8]) -> Result { + use fil_actors_shared::frc46_token::token::types::TransferParams; + let p: TransferParams = fvm_ipld_encoding::from_slice(bytes)?; + Ok(json!({ + "to": addr_json(&p.to), + "amount": token_json(&p.amount), + "operator_data": try_decode_nested("allocation-requests", &p.operator_data), + })) +} + +fn decode_transfer_from_params(bytes: &[u8]) -> Result { + use fil_actors_shared::frc46_token::token::types::TransferFromParams; + let p: TransferFromParams = fvm_ipld_encoding::from_slice(bytes)?; + Ok(json!({ + "from": addr_json(&p.from), + "to": addr_json(&p.to), + "amount": token_json(&p.amount), + "operator_data": try_decode_nested("allocation-requests", &p.operator_data), + })) +} + +fn decode_increase_allowance_params(bytes: &[u8]) -> Result { + use fil_actors_shared::frc46_token::token::types::IncreaseAllowanceParams; + let p: IncreaseAllowanceParams = fvm_ipld_encoding::from_slice(bytes)?; + Ok(json!({ + "operator": addr_json(&p.operator), + "increase": token_json(&p.increase), + })) +} + +fn decode_decrease_allowance_params(bytes: &[u8]) -> Result { + use fil_actors_shared::frc46_token::token::types::DecreaseAllowanceParams; + let p: DecreaseAllowanceParams = fvm_ipld_encoding::from_slice(bytes)?; + Ok(json!({ + "operator": addr_json(&p.operator), + "decrease": token_json(&p.decrease), + })) +} + +fn decode_revoke_allowance_params(bytes: &[u8]) -> Result { + use fil_actors_shared::frc46_token::token::types::RevokeAllowanceParams; + let p: RevokeAllowanceParams = fvm_ipld_encoding::from_slice(bytes)?; + Ok(json!({ "operator": addr_json(&p.operator) })) +} + +fn decode_burn_params(bytes: &[u8]) -> Result { + use fil_actors_shared::frc46_token::token::types::BurnParams; + let p: BurnParams = fvm_ipld_encoding::from_slice(bytes)?; + Ok(json!({ "amount": token_json(&p.amount) })) +} + +fn decode_burn_from_params(bytes: &[u8]) -> Result { + use fil_actors_shared::frc46_token::token::types::BurnFromParams; + let p: BurnFromParams = fvm_ipld_encoding::from_slice(bytes)?; + Ok(json!({ + "owner": addr_json(&p.owner), + "amount": token_json(&p.amount), + })) +} + +fn decode_get_allowance_params(bytes: &[u8]) -> Result { + use fil_actors_shared::frc46_token::token::types::GetAllowanceParams; + let p: GetAllowanceParams = fvm_ipld_encoding::from_slice(bytes)?; + Ok(json!({ + "owner": addr_json(&p.owner), + "operator": addr_json(&p.operator), + })) +} + +fn decode_transfer_return(bytes: &[u8]) -> Result { + use fil_actors_shared::frc46_token::token::types::TransferReturn; + let r: TransferReturn = fvm_ipld_encoding::from_slice(bytes)?; + Ok(json!({ + "from_balance": token_json(&r.from_balance), + "to_balance": token_json(&r.to_balance), + "recipient_data": try_decode_nested("allocations-response", &r.recipient_data), + })) +} + +fn decode_transfer_from_return(bytes: &[u8]) -> Result { + use fil_actors_shared::frc46_token::token::types::TransferFromReturn; + let r: TransferFromReturn = fvm_ipld_encoding::from_slice(bytes)?; + Ok(json!({ + "from_balance": token_json(&r.from_balance), + "to_balance": token_json(&r.to_balance), + "allowance": token_json(&r.allowance), + "recipient_data": try_decode_nested("allocations-response", &r.recipient_data), + })) +} + +fn decode_burn_return(bytes: &[u8]) -> Result { + use fil_actors_shared::frc46_token::token::types::BurnReturn; + let r: BurnReturn = fvm_ipld_encoding::from_slice(bytes)?; + Ok(json!({ "balance": token_json(&r.balance) })) +} + +fn decode_burn_from_return(bytes: &[u8]) -> Result { + use fil_actors_shared::frc46_token::token::types::BurnFromReturn; + let r: BurnFromReturn = fvm_ipld_encoding::from_slice(bytes)?; + Ok(json!({ + "balance": token_json(&r.balance), + "allowance": token_json(&r.allowance), + })) +} + +fn decode_allowance_return(bytes: &[u8]) -> Result { + let r: TokenAmount = fvm_ipld_encoding::from_slice(bytes)?; + Ok(json!({ "allowance": token_json(&r) })) +} + +// --------------------------------------------------------------------------- +// Version-specific dispatch helpers +// --------------------------------------------------------------------------- + +/// Decode params for v9 (legacy method numbers, only MintParams/DestroyParams types). +fn decode_params_v9(method_num: u64, bytes: &[u8]) -> Result { + use v9_methods::*; + match method_num { + MINT => cbor_to_json!(fil_actor_datacap_state::v9::MintParams, bytes), + DESTROY => cbor_to_json!(fil_actor_datacap_state::v9::DestroyParams, bytes), + // frc46_token types (shared across versions) + TRANSFER => decode_transfer_params(bytes), + TRANSFER_FROM => decode_transfer_from_params(bytes), + INCREASE_ALLOWANCE => decode_increase_allowance_params(bytes), + DECREASE_ALLOWANCE => decode_decrease_allowance_params(bytes), + REVOKE_ALLOWANCE => decode_revoke_allowance_params(bytes), + BURN => decode_burn_params(bytes), + BURN_FROM => decode_burn_from_params(bytes), + ALLOWANCE => decode_get_allowance_params(bytes), + BALANCE_OF => { + // v9 BalanceOf takes a raw Address (no wrapper type) + let addr: fvm_shared4::address::Address = fvm_ipld_encoding::from_slice(bytes)?; + Ok(json!(addr.to_string())) + } + CONSTRUCTOR | NAME | SYMBOL | TOTAL_SUPPLY => decode_empty_param(bytes), + _ => bail!("Unknown datacap v9 method number: {method_num}"), + } +} + +/// Decode returns for v9 (legacy method numbers). +fn decode_return_v9(method_num: u64, bytes: &[u8]) -> Result { + use v9_methods::*; + match method_num { + TRANSFER => decode_transfer_return(bytes), + TRANSFER_FROM => decode_transfer_from_return(bytes), + BURN => decode_burn_return(bytes), + BURN_FROM => decode_burn_from_return(bytes), + INCREASE_ALLOWANCE | DECREASE_ALLOWANCE | REVOKE_ALLOWANCE | ALLOWANCE => { + decode_allowance_return(bytes) + } + // v9 has no typed returns for Name/Symbol/TotalSupply/Balance — raw value + MINT | DESTROY | CONSTRUCTOR | NAME | SYMBOL | TOTAL_SUPPLY | BALANCE_OF => { + decode_empty_param(bytes) + } + _ => bail!("Return decoding not implemented for datacap v9 method {method_num}"), + } +} + +/// Decode params for v10-v11 (FRC-0042 hashes, limited types). +/// MintParams/DestroyParams available; other typed params don't exist yet. +fn decode_params_v10(method_num: u64, bytes: &[u8]) -> Result { + use methods::*; + match method_num { + // v10 has MintParams, DestroyParams (CBOR-identical to v12+) + MINT => cbor_to_json!(fil_actor_datacap_state::v10::MintParams, bytes), + DESTROY => cbor_to_json!(fil_actor_datacap_state::v10::DestroyParams, bytes), + // frc46_token types (shared across versions) + TRANSFER => decode_transfer_params(bytes), + TRANSFER_FROM => decode_transfer_from_params(bytes), + INCREASE_ALLOWANCE => decode_increase_allowance_params(bytes), + DECREASE_ALLOWANCE => decode_decrease_allowance_params(bytes), + REVOKE_ALLOWANCE => decode_revoke_allowance_params(bytes), + BURN => decode_burn_params(bytes), + BURN_FROM => decode_burn_from_params(bytes), + ALLOWANCE => decode_get_allowance_params(bytes), + // v10-v11 has no ConstructorParams, BalanceParams — treat as raw + CONSTRUCTOR | BALANCE | NAME | SYMBOL | TOTAL_SUPPLY | GRANULARITY => { + decode_empty_param(bytes) + } + _ => bail!("Unknown datacap v10 method number: {method_num}"), + } +} + +/// Decode returns for v10-v11 (FRC-0042 hashes, limited return types). +fn decode_return_v10(method_num: u64, bytes: &[u8]) -> Result { + use methods::*; + match method_num { + // v10 added GranularityReturn + GRANULARITY => cbor_to_json!(fil_actor_datacap_state::v10::GranularityReturn, bytes), + TRANSFER => decode_transfer_return(bytes), + TRANSFER_FROM => decode_transfer_from_return(bytes), + BURN => decode_burn_return(bytes), + BURN_FROM => decode_burn_from_return(bytes), + INCREASE_ALLOWANCE | DECREASE_ALLOWANCE | REVOKE_ALLOWANCE | ALLOWANCE => { + decode_allowance_return(bytes) + } + // v10-v11 has no NameReturn/SymbolReturn/etc. — treat as raw + MINT | DESTROY | CONSTRUCTOR | NAME | SYMBOL | TOTAL_SUPPLY | BALANCE => { + decode_empty_param(bytes) + } + _ => bail!("Return decoding not implemented for datacap v10 method {method_num}"), + } +} + +/// Decode params for v12+ (FRC-0042 hashes, full type set). +/// v12-v17 types are CBOR-identical; we use v17 types for all. +fn decode_params_v12plus(method_num: u64, bytes: &[u8]) -> Result { + use methods::*; + match method_num { + CONSTRUCTOR => cbor_to_json!(fil_actor_datacap_state::v17::ConstructorParams, bytes), + BALANCE => cbor_to_json!(fil_actor_datacap_state::v17::BalanceParams, bytes), + MINT => cbor_to_json!(fil_actor_datacap_state::v17::MintParams, bytes), + DESTROY => cbor_to_json!(fil_actor_datacap_state::v17::DestroyParams, bytes), + TRANSFER => decode_transfer_params(bytes), + TRANSFER_FROM => decode_transfer_from_params(bytes), + INCREASE_ALLOWANCE => decode_increase_allowance_params(bytes), + DECREASE_ALLOWANCE => decode_decrease_allowance_params(bytes), + REVOKE_ALLOWANCE => decode_revoke_allowance_params(bytes), + BURN => decode_burn_params(bytes), + BURN_FROM => decode_burn_from_params(bytes), + ALLOWANCE => decode_get_allowance_params(bytes), + NAME | SYMBOL | TOTAL_SUPPLY | GRANULARITY => decode_empty_param(bytes), + _ => bail!("Unknown datacap method number: {method_num}"), + } +} + +/// Decode returns for v12+ (FRC-0042 hashes, full return types). +fn decode_return_v12plus(method_num: u64, bytes: &[u8]) -> Result { + use methods::*; + match method_num { + NAME => cbor_to_json!(fil_actor_datacap_state::v17::NameReturn, bytes), + SYMBOL => cbor_to_json!(fil_actor_datacap_state::v17::SymbolReturn, bytes), + TOTAL_SUPPLY => cbor_to_json!(fil_actor_datacap_state::v17::TotalSupplyReturn, bytes), + BALANCE => cbor_to_json!(fil_actor_datacap_state::v17::BalanceReturn, bytes), + GRANULARITY => cbor_to_json!(fil_actor_datacap_state::v17::GranularityReturn, bytes), + TRANSFER => decode_transfer_return(bytes), + TRANSFER_FROM => decode_transfer_from_return(bytes), + BURN => decode_burn_return(bytes), + BURN_FROM => decode_burn_from_return(bytes), + MINT | DESTROY | CONSTRUCTOR => decode_empty_param(bytes), + INCREASE_ALLOWANCE | DECREASE_ALLOWANCE | REVOKE_ALLOWANCE | ALLOWANCE => { + decode_allowance_return(bytes) + } + _ => bail!("Return decoding not implemented for datacap method {method_num}"), + } +} + +// --------------------------------------------------------------------------- +// Public API +// --------------------------------------------------------------------------- + +pub fn decode_params(version: ActorVersion, method_num: u64, bytes: &[u8]) -> Result { + match version { + ActorVersion::V9 => decode_params_v9(method_num, bytes), + ActorVersion::V10 => decode_params_v10(method_num, bytes), + // v11+ has the full type set; CBOR encoding is version-independent + ActorVersion::V11 + | ActorVersion::V12 + | ActorVersion::V13 + | ActorVersion::V14 + | ActorVersion::V15 + | ActorVersion::V16 + | ActorVersion::V17 => decode_params_v12plus(method_num, bytes), + } +} + +pub fn decode_return(version: ActorVersion, method_num: u64, bytes: &[u8]) -> Result { + match version { + ActorVersion::V9 => decode_return_v9(method_num, bytes), + ActorVersion::V10 => decode_return_v10(method_num, bytes), + ActorVersion::V11 + | ActorVersion::V12 + | ActorVersion::V13 + | ActorVersion::V14 + | ActorVersion::V15 + | ActorVersion::V16 + | ActorVersion::V17 => decode_return_v12plus(method_num, bytes), + } +} + +// --------------------------------------------------------------------------- +// Method name lookup +// --------------------------------------------------------------------------- + +pub fn method_name(method_num: u64) -> &'static str { + match method_num { + // Legacy v9 method numbers + v9_methods::CONSTRUCTOR => "Constructor", + v9_methods::MINT => "Mint", + v9_methods::DESTROY => "Destroy", + v9_methods::NAME => "Name", + v9_methods::SYMBOL => "Symbol", + v9_methods::TOTAL_SUPPLY => "TotalSupply", + v9_methods::BALANCE_OF => "BalanceOf", + v9_methods::TRANSFER => "Transfer", + v9_methods::TRANSFER_FROM => "TransferFrom", + v9_methods::INCREASE_ALLOWANCE => "IncreaseAllowance", + v9_methods::DECREASE_ALLOWANCE => "DecreaseAllowance", + v9_methods::REVOKE_ALLOWANCE => "RevokeAllowance", + v9_methods::BURN => "Burn", + v9_methods::BURN_FROM => "BurnFrom", + v9_methods::ALLOWANCE => "Allowance", + // v10+ constructor + methods::CONSTRUCTOR => "Constructor", + // FRC-0042 method hashes + m if m == methods::MINT => "Mint", + m if m == methods::DESTROY => "Destroy", + m if m == methods::NAME => "Name", + m if m == methods::SYMBOL => "Symbol", + m if m == methods::GRANULARITY => "Granularity", + m if m == methods::TOTAL_SUPPLY => "TotalSupply", + m if m == methods::BALANCE => "Balance", + m if m == methods::TRANSFER => "Transfer", + m if m == methods::TRANSFER_FROM => "TransferFrom", + m if m == methods::INCREASE_ALLOWANCE => "IncreaseAllowance", + m if m == methods::DECREASE_ALLOWANCE => "DecreaseAllowance", + m if m == methods::REVOKE_ALLOWANCE => "RevokeAllowance", + m if m == methods::BURN => "Burn", + m if m == methods::BURN_FROM => "BurnFrom", + m if m == methods::ALLOWANCE => "Allowance", + _ => "Unknown", + } +} + +#[cfg(test)] +mod tests { + use super::*; + use fvm_ipld_encoding::to_vec; + + #[test] + fn test_decode_mint_params_v17() { + let params = fil_actor_datacap_state::v17::MintParams { + to: Address::new_id(1234), + amount: TokenAmount::from_atto(1_000_000_000_000_000_000_i64), + operators: vec![Address::new_id(5678)], + }; + let cbor = to_vec(¶ms).unwrap(); + let result = decode_params(ActorVersion::V17, methods::MINT, &cbor).unwrap(); + assert_eq!(result["to"], "f01234"); + assert_eq!(result["amount"], "1000000000000000000"); + assert_eq!(result["operators"][0], "f05678"); + } + + #[test] + fn test_decode_mint_params_v9() { + // v9 uses fvm_shared v2 Address — construct via cbor roundtrip from v17 + let params_v17 = fil_actor_datacap_state::v17::MintParams { + to: Address::new_id(1234), + amount: TokenAmount::from_atto(1_000_000_000_000_000_000_i64), + operators: vec![Address::new_id(5678)], + }; + // CBOR encoding is identical between v9 and v17 MintParams + let cbor = to_vec(¶ms_v17).unwrap(); + let result = decode_params(ActorVersion::V9, v9_methods::MINT, &cbor).unwrap(); + assert_eq!(result["to"], "f01234"); + } + + #[test] + fn test_decode_destroy_params() { + let params = fil_actor_datacap_state::v17::DestroyParams { + owner: Address::new_id(100), + amount: TokenAmount::from_atto(500), + }; + let cbor = to_vec(¶ms).unwrap(); + let result = decode_params(ActorVersion::V17, methods::DESTROY, &cbor).unwrap(); + assert_eq!(result["owner"], "f0100"); + assert_eq!(result["amount"], "500"); + } + + #[test] + fn test_decode_empty_params() { + let result = decode_params(ActorVersion::V17, methods::NAME, &[]).unwrap(); + assert_eq!(result, json!({})); + } + + #[test] + fn test_decode_balance_params() { + let params = fil_actor_datacap_state::v17::BalanceParams { + address: Address::new_id(42), + }; + let cbor = to_vec(¶ms).unwrap(); + let result = decode_params(ActorVersion::V17, methods::BALANCE, &cbor).unwrap(); + assert_eq!(result, json!("f042")); + } + + #[test] + fn test_v12_uses_v12plus_dispatch() { + // v12 should use the same dispatch as v17 + let result = decode_params(ActorVersion::V12, methods::NAME, &[]).unwrap(); + assert_eq!(result, json!({})); + } + + #[test] + fn test_unknown_method_error() { + assert!(decode_params(ActorVersion::V17, 99999, &[]).is_err()); + } + + #[test] + fn test_method_name() { + assert_eq!(method_name(methods::TRANSFER), "Transfer"); + assert_eq!(method_name(methods::MINT), "Mint"); + assert_eq!(method_name(v9_methods::MINT), "Mint"); + assert_eq!(method_name(v9_methods::BALANCE_OF), "BalanceOf"); + assert_eq!(method_name(99999), "Unknown"); + } +} diff --git a/fil_actor_decoder/src/actors/mod.rs b/fil_actor_decoder/src/actors/mod.rs new file mode 100644 index 00000000..7c5857b0 --- /dev/null +++ b/fil_actor_decoder/src/actors/mod.rs @@ -0,0 +1,22 @@ +pub mod datacap; +pub mod verifreg; + +use anyhow::Result; +use serde_json::{Value, json}; + +macro_rules! cbor_to_json { + ($ty:ty, $bytes:expr) => {{ + let val: $ty = fvm_ipld_encoding::from_slice($bytes)?; + Ok(val.to_json_value()) + }}; +} +pub(crate) use cbor_to_json; + +pub(crate) fn decode_empty_param(bytes: &[u8]) -> Result { + if bytes.is_empty() { + Ok(json!({})) + } else { + use base64::Engine; + Ok(json!({ "raw": base64::engine::general_purpose::STANDARD.encode(bytes) })) + } +} diff --git a/fil_actor_decoder/src/actors/verifreg.rs b/fil_actor_decoder/src/actors/verifreg.rs new file mode 100644 index 00000000..c5f9b36b --- /dev/null +++ b/fil_actor_decoder/src/actors/verifreg.rs @@ -0,0 +1,382 @@ +//! Verified Registry actor (f06) param and return decoder. +//! +//! Supports all actor versions: +//! - v9: numeric + FRC-0042 methods, flat SectorAllocationClaim, Address-based provider +//! - v10-v11: same methods, flat SectorAllocationClaim, ActorID-based provider +//! - v12-v17: same methods, nested SectorAllocationClaims (CBOR-identical across v12-v17) + +use crate::ActorVersion; +use crate::actors::{cbor_to_json, decode_empty_param}; +use anyhow::{Result, bail}; +use serde_json::Value; + +// --------------------------------------------------------------------------- +// Method numbers (shared across v9-v17) +// --------------------------------------------------------------------------- + +mod methods { + pub const CONSTRUCTOR: u64 = 0; + pub const ADD_VERIFIER: u64 = 2; + pub const REMOVE_VERIFIER: u64 = 3; + pub const ADD_VERIFIED_CLIENT: u64 = 4; + pub const REMOVE_VERIFIED_CLIENT_DATA_CAP: u64 = 7; + pub const REMOVE_EXPIRED_ALLOCATIONS: u64 = 8; + pub const CLAIM_ALLOCATIONS: u64 = 9; + pub const GET_CLAIMS: u64 = 10; + pub const EXTEND_CLAIM_TERMS: u64 = 11; + pub const REMOVE_EXPIRED_CLAIMS: u64 = 12; + + // FRC-0042 exported methods + pub const ADD_VERIFIED_CLIENT_EXPORTED: u64 = frc42_dispatch::method_hash!("AddVerifiedClient"); + pub const REMOVE_EXPIRED_ALLOCATIONS_EXPORTED: u64 = + frc42_dispatch::method_hash!("RemoveExpiredAllocations"); + pub const GET_CLAIMS_EXPORTED: u64 = frc42_dispatch::method_hash!("GetClaims"); + pub const EXTEND_CLAIM_TERMS_EXPORTED: u64 = frc42_dispatch::method_hash!("ExtendClaimTerms"); + pub const REMOVE_EXPIRED_CLAIMS_EXPORTED: u64 = + frc42_dispatch::method_hash!("RemoveExpiredClaims"); + pub const UNIVERSAL_RECEIVER_HOOK: u64 = frc42_dispatch::method_hash!("Receive"); +} + +/// Decode nested payloads found inside operator_data / recipient_data. +/// Uses v17 types (CBOR-identical for v12+; v9-v11 have different AllocationRequests +/// but we attempt v17 first and fall back gracefully in the caller). +pub fn decode_nested_payload(payload_type: &str, bytes: &[u8]) -> Result { + match payload_type { + "allocation-requests" => { + cbor_to_json!(fil_actor_verifreg_state::v17::AllocationRequests, bytes) + } + "allocations-response" => { + cbor_to_json!(fil_actor_verifreg_state::v17::AllocationsResponse, bytes) + } + _ => bail!("Unknown nested payload type: {payload_type}"), + } +} + +// --------------------------------------------------------------------------- +// Version-specific dispatch: params +// --------------------------------------------------------------------------- + +/// Shared params that are identical across v9-v17 (same CBOR layout). +fn decode_shared_params(method_num: u64, bytes: &[u8]) -> Result> { + use methods::*; + let val = match method_num { + ADD_VERIFIER | ADD_VERIFIED_CLIENT | ADD_VERIFIED_CLIENT_EXPORTED => { + let p: fil_actor_verifreg_state::v17::VerifierParams = + fvm_ipld_encoding::from_slice(bytes)?; + p.to_json_value() + } + REMOVE_VERIFIER => { + let p: fil_actor_verifreg_state::v17::RemoveVerifierParams = + fvm_ipld_encoding::from_slice(bytes)?; + p.to_json_value() + } + REMOVE_VERIFIED_CLIENT_DATA_CAP => { + let p: fil_actor_verifreg_state::v17::RemoveDataCapParams = + fvm_ipld_encoding::from_slice(bytes)?; + p.to_json_value() + } + REMOVE_EXPIRED_ALLOCATIONS | REMOVE_EXPIRED_ALLOCATIONS_EXPORTED => { + let p: fil_actor_verifreg_state::v17::RemoveExpiredAllocationsParams = + fvm_ipld_encoding::from_slice(bytes)?; + p.to_json_value() + } + GET_CLAIMS | GET_CLAIMS_EXPORTED => { + let p: fil_actor_verifreg_state::v17::GetClaimsParams = + fvm_ipld_encoding::from_slice(bytes)?; + p.to_json_value() + } + EXTEND_CLAIM_TERMS | EXTEND_CLAIM_TERMS_EXPORTED => { + let p: fil_actor_verifreg_state::v17::ExtendClaimTermsParams = + fvm_ipld_encoding::from_slice(bytes)?; + p.to_json_value() + } + REMOVE_EXPIRED_CLAIMS | REMOVE_EXPIRED_CLAIMS_EXPORTED => { + let p: fil_actor_verifreg_state::v17::RemoveExpiredClaimsParams = + fvm_ipld_encoding::from_slice(bytes)?; + p.to_json_value() + } + CONSTRUCTOR => return Ok(Some(decode_empty_param(bytes)?)), + _ => return Ok(None), + }; + Ok(Some(val)) +} + +fn decode_params_v9(method_num: u64, bytes: &[u8]) -> Result { + if let Some(v) = decode_shared_params(method_num, bytes)? { + return Ok(v); + } + use methods::*; + match method_num { + // v9 has flat SectorAllocationClaim and Address-based AllocationRequest + CLAIM_ALLOCATIONS => { + cbor_to_json!(fil_actor_verifreg_state::v9::ClaimAllocationsParams, bytes) + } + UNIVERSAL_RECEIVER_HOOK => { + cbor_to_json!(fil_actor_verifreg_state::v9::AllocationRequests, bytes) + } + _ => bail!("Unknown verifreg v9 method number: {method_num}"), + } +} + +fn decode_params_v10(method_num: u64, bytes: &[u8]) -> Result { + if let Some(v) = decode_shared_params(method_num, bytes)? { + return Ok(v); + } + use methods::*; + match method_num { + // v10-v11 has flat SectorAllocationClaim but ActorID-based + CLAIM_ALLOCATIONS => { + cbor_to_json!(fil_actor_verifreg_state::v10::ClaimAllocationsParams, bytes) + } + UNIVERSAL_RECEIVER_HOOK => { + cbor_to_json!(fil_actor_verifreg_state::v10::AllocationRequests, bytes) + } + _ => bail!("Unknown verifreg v10 method number: {method_num}"), + } +} + +fn decode_params_v12plus(method_num: u64, bytes: &[u8]) -> Result { + if let Some(v) = decode_shared_params(method_num, bytes)? { + return Ok(v); + } + use methods::*; + match method_num { + // v12+ has nested SectorAllocationClaims + CLAIM_ALLOCATIONS => { + cbor_to_json!(fil_actor_verifreg_state::v17::ClaimAllocationsParams, bytes) + } + UNIVERSAL_RECEIVER_HOOK => { + cbor_to_json!(fil_actor_verifreg_state::v17::AllocationRequests, bytes) + } + _ => bail!("Unknown verifreg method number: {method_num}"), + } +} + +// --------------------------------------------------------------------------- +// Version-specific dispatch: returns +// --------------------------------------------------------------------------- + +/// Shared returns that are identical across v9-v17. +fn decode_shared_returns(method_num: u64, bytes: &[u8]) -> Result> { + use methods::*; + let val = match method_num { + REMOVE_VERIFIED_CLIENT_DATA_CAP => { + let r: fil_actor_verifreg_state::v17::RemoveDataCapReturn = + fvm_ipld_encoding::from_slice(bytes)?; + r.to_json_value() + } + REMOVE_EXPIRED_ALLOCATIONS | REMOVE_EXPIRED_ALLOCATIONS_EXPORTED => { + let r: fil_actor_verifreg_state::v17::RemoveExpiredAllocationsReturn = + fvm_ipld_encoding::from_slice(bytes)?; + r.to_json_value() + } + GET_CLAIMS | GET_CLAIMS_EXPORTED => { + let r: fil_actor_verifreg_state::v17::GetClaimsReturn = + fvm_ipld_encoding::from_slice(bytes)?; + r.to_json_value() + } + REMOVE_EXPIRED_CLAIMS | REMOVE_EXPIRED_CLAIMS_EXPORTED => { + let r: fil_actor_verifreg_state::v17::RemoveExpiredClaimsReturn = + fvm_ipld_encoding::from_slice(bytes)?; + r.to_json_value() + } + UNIVERSAL_RECEIVER_HOOK => { + let r: fil_actor_verifreg_state::v17::AllocationsResponse = + fvm_ipld_encoding::from_slice(bytes)?; + r.to_json_value() + } + EXTEND_CLAIM_TERMS | EXTEND_CLAIM_TERMS_EXPORTED => { + let r: fil_actors_shared::v17::BatchReturn = fvm_ipld_encoding::from_slice(bytes)?; + r.to_json_value() + } + CONSTRUCTOR + | ADD_VERIFIER + | REMOVE_VERIFIER + | ADD_VERIFIED_CLIENT + | ADD_VERIFIED_CLIENT_EXPORTED => { + return Ok(Some(decode_empty_param(bytes)?)); + } + _ => return Ok(None), + }; + Ok(Some(val)) +} + +fn decode_return_v9(method_num: u64, bytes: &[u8]) -> Result { + if let Some(v) = decode_shared_returns(method_num, bytes)? { + return Ok(v); + } + use methods::*; + match method_num { + // v9 ClaimAllocationsReturn has different structure: {batch_info, claimed_space} + CLAIM_ALLOCATIONS => { + cbor_to_json!(fil_actor_verifreg_state::v9::ClaimAllocationsReturn, bytes) + } + _ => bail!("Return decoding not implemented for verifreg v9 method {method_num}"), + } +} + +fn decode_return_v10(method_num: u64, bytes: &[u8]) -> Result { + if let Some(v) = decode_shared_returns(method_num, bytes)? { + return Ok(v); + } + use methods::*; + match method_num { + CLAIM_ALLOCATIONS => { + cbor_to_json!(fil_actor_verifreg_state::v10::ClaimAllocationsReturn, bytes) + } + _ => bail!("Return decoding not implemented for verifreg v10 method {method_num}"), + } +} + +fn decode_return_v12plus(method_num: u64, bytes: &[u8]) -> Result { + if let Some(v) = decode_shared_returns(method_num, bytes)? { + return Ok(v); + } + use methods::*; + match method_num { + CLAIM_ALLOCATIONS => { + cbor_to_json!(fil_actor_verifreg_state::v17::ClaimAllocationsReturn, bytes) + } + _ => bail!("Return decoding not implemented for verifreg method {method_num}"), + } +} + +// --------------------------------------------------------------------------- +// Public API +// --------------------------------------------------------------------------- + +pub fn decode_params(version: ActorVersion, method_num: u64, bytes: &[u8]) -> Result { + match version { + ActorVersion::V9 => decode_params_v9(method_num, bytes), + ActorVersion::V10 | ActorVersion::V11 => decode_params_v10(method_num, bytes), + ActorVersion::V12 + | ActorVersion::V13 + | ActorVersion::V14 + | ActorVersion::V15 + | ActorVersion::V16 + | ActorVersion::V17 => decode_params_v12plus(method_num, bytes), + } +} + +pub fn decode_return(version: ActorVersion, method_num: u64, bytes: &[u8]) -> Result { + match version { + ActorVersion::V9 => decode_return_v9(method_num, bytes), + ActorVersion::V10 | ActorVersion::V11 => decode_return_v10(method_num, bytes), + ActorVersion::V12 + | ActorVersion::V13 + | ActorVersion::V14 + | ActorVersion::V15 + | ActorVersion::V16 + | ActorVersion::V17 => decode_return_v12plus(method_num, bytes), + } +} + +// --------------------------------------------------------------------------- +// Method name lookup +// --------------------------------------------------------------------------- + +pub fn method_name(method_num: u64) -> &'static str { + match method_num { + methods::CONSTRUCTOR => "Constructor", + methods::ADD_VERIFIER => "AddVerifier", + methods::REMOVE_VERIFIER => "RemoveVerifier", + methods::ADD_VERIFIED_CLIENT => "AddVerifiedClient", + methods::REMOVE_VERIFIED_CLIENT_DATA_CAP => "RemoveVerifiedClientDataCap", + methods::REMOVE_EXPIRED_ALLOCATIONS => "RemoveExpiredAllocations", + methods::CLAIM_ALLOCATIONS => "ClaimAllocations", + methods::GET_CLAIMS => "GetClaims", + methods::EXTEND_CLAIM_TERMS => "ExtendClaimTerms", + methods::REMOVE_EXPIRED_CLAIMS => "RemoveExpiredClaims", + m if m == methods::ADD_VERIFIED_CLIENT_EXPORTED => "AddVerifiedClientExported", + m if m == methods::REMOVE_EXPIRED_ALLOCATIONS_EXPORTED => { + "RemoveExpiredAllocationsExported" + } + m if m == methods::GET_CLAIMS_EXPORTED => "GetClaimsExported", + m if m == methods::EXTEND_CLAIM_TERMS_EXPORTED => "ExtendClaimTermsExported", + m if m == methods::REMOVE_EXPIRED_CLAIMS_EXPORTED => "RemoveExpiredClaimsExported", + m if m == methods::UNIVERSAL_RECEIVER_HOOK => "UniversalReceiverHook", + _ => "Unknown", + } +} + +#[cfg(test)] +mod tests { + use super::*; + use fvm_ipld_encoding::to_vec; + use fvm_shared4::address::Address; + use num_bigint::BigInt; + use serde_json::json; + + #[test] + fn test_decode_verifier_params() { + let params = fil_actor_verifreg_state::v17::VerifierParams { + address: Address::new_id(1000), + allowance: BigInt::from(5_000_000), + }; + let cbor = to_vec(¶ms).unwrap(); + let result = decode_params(ActorVersion::V17, methods::ADD_VERIFIER, &cbor).unwrap(); + assert_eq!(result["address"], "f01000"); + assert_eq!(result["allowance"], "5000000"); + } + + #[test] + fn test_decode_get_claims_params() { + let params = fil_actor_verifreg_state::v17::GetClaimsParams { + provider: 1234, + claim_ids: vec![1, 2, 3], + }; + let cbor = to_vec(¶ms).unwrap(); + let result = decode_params(ActorVersion::V17, methods::GET_CLAIMS, &cbor).unwrap(); + assert_eq!(result["provider"], 1234); + assert_eq!(result["claim_ids"], json!([1, 2, 3])); + } + + #[test] + fn test_v12_dispatch() { + let result = decode_params(ActorVersion::V12, methods::CONSTRUCTOR, &[]).unwrap(); + assert_eq!(result, json!({})); + } + + #[test] + fn test_v9_dispatch() { + let result = decode_params(ActorVersion::V9, methods::CONSTRUCTOR, &[]).unwrap(); + assert_eq!(result, json!({})); + } + + #[test] + fn test_decode_empty_constructor() { + let result = decode_params(ActorVersion::V17, methods::CONSTRUCTOR, &[]).unwrap(); + assert_eq!(result, json!({})); + } + + #[test] + fn test_unknown_method_error() { + assert!(decode_params(ActorVersion::V17, 99999, &[]).is_err()); + } + + #[test] + fn test_method_name() { + assert_eq!(method_name(methods::ADD_VERIFIER), "AddVerifier"); + assert_eq!(method_name(methods::CLAIM_ALLOCATIONS), "ClaimAllocations"); + assert_eq!(method_name(99999), "Unknown"); + } + + #[test] + fn test_nested_allocation_requests() { + let requests = fil_actor_verifreg_state::v17::AllocationRequests { + allocations: vec![fil_actor_verifreg_state::v17::AllocationRequest { + provider: 100, + data: cid::Cid::default(), + size: fvm_shared4::piece::PaddedPieceSize(1024), + term_min: 518400, + term_max: 1036800, + expiration: 2000000, + }], + extensions: vec![], + }; + let cbor = to_vec(&requests).unwrap(); + let result = decode_nested_payload("allocation-requests", &cbor).unwrap(); + assert_eq!(result["allocations"][0]["provider"], 100); + assert_eq!(result["allocations"][0]["size"], 1024); + } +} diff --git a/fil_actor_decoder/src/bin/fil_decode.rs b/fil_actor_decoder/src/bin/fil_decode.rs new file mode 100644 index 00000000..f4c449cf --- /dev/null +++ b/fil_actor_decoder/src/bin/fil_decode.rs @@ -0,0 +1,79 @@ +//! CLI tool for decoding Filecoin actor params/returns from CBOR to JSON. + +use anyhow::{Context, Result}; +use clap::{Args, Parser, Subcommand}; + +#[derive(Parser)] +#[command( + name = "fil-decode", + about = "Decode Filecoin actor CBOR params/returns to JSON" +)] +struct Cli { + #[command(subcommand)] + command: Command, +} + +#[derive(Args, Clone)] +struct DecodeArgs { + /// Actor type: datacap, verifreg + #[arg(long)] + actor: String, + /// Method number + #[arg(long)] + method: u64, + /// Hex-encoded CBOR bytes (no 0x prefix) + #[arg(long)] + hex: String, + /// Actor version (v16 or v17). If omitted, uses --network + --epoch. + #[arg(long)] + version: Option, + /// Network: mainnet or calibnet (used with --epoch) + #[arg(long)] + network: Option, + /// Epoch (used with --network) + #[arg(long)] + epoch: Option, +} + +#[derive(Subcommand)] +enum Command { + /// Decode method params + Params(DecodeArgs), + /// Decode method return value + Return(DecodeArgs), +} + +fn resolve_version(args: &DecodeArgs) -> Result { + if let Some(v) = &args.version { + return v.parse(); + } + match (&args.network, args.epoch) { + (Some(net), Some(ep)) => { + let network: fil_actor_decoder::network::Network = net.parse()?; + fil_actor_decoder::network::resolve_actor_version(network, ep) + } + _ => anyhow::bail!("Provide either --version or both --network and --epoch"), + } +} + +fn decode_hex(hex_str: &str) -> Result> { + let clean = hex_str.strip_prefix("0x").unwrap_or(hex_str); + hex::decode(clean).context("Invalid hex input") +} + +fn main() -> Result<()> { + let cli = Cli::parse(); + + let (args, decode_fn): (&DecodeArgs, fn(_, _, _, &[u8]) -> _) = match &cli.command { + Command::Params(a) => (a, fil_actor_decoder::decode_params), + Command::Return(a) => (a, fil_actor_decoder::decode_return), + }; + + let actor_type: fil_actor_decoder::ActorType = args.actor.parse()?; + let ver = resolve_version(args)?; + let bytes = decode_hex(&args.hex)?; + let json = decode_fn(actor_type, ver, args.method, &bytes)?; + + println!("{}", serde_json::to_string_pretty(&json)?); + Ok(()) +} diff --git a/fil_actor_decoder/src/lib.rs b/fil_actor_decoder/src/lib.rs new file mode 100644 index 00000000..f5e1cb4c --- /dev/null +++ b/fil_actor_decoder/src/lib.rs @@ -0,0 +1,112 @@ +pub mod actors; +pub mod network; + +use anyhow::{Result, bail}; +use serde_json::Value; + +/// Supported actor types for decoding. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum ActorType { + DataCap, + VerifiedRegistry, +} + +/// Actor state versions, corresponding to network upgrades. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum ActorVersion { + V9, + V10, + V11, + V12, + V13, + V14, + V15, + V16, + V17, +} + +/// Decode CBOR-encoded params for a given actor method. +pub fn decode_params( + actor: ActorType, + version: ActorVersion, + method_num: u64, + raw_bytes: &[u8], +) -> Result { + match actor { + ActorType::DataCap => actors::datacap::decode_params(version, method_num, raw_bytes), + ActorType::VerifiedRegistry => { + actors::verifreg::decode_params(version, method_num, raw_bytes) + } + } +} + +/// Decode CBOR-encoded return value for a given actor method. +pub fn decode_return( + actor: ActorType, + version: ActorVersion, + method_num: u64, + raw_bytes: &[u8], +) -> Result { + match actor { + ActorType::DataCap => actors::datacap::decode_return(version, method_num, raw_bytes), + ActorType::VerifiedRegistry => { + actors::verifreg::decode_return(version, method_num, raw_bytes) + } + } +} + +impl std::str::FromStr for ActorType { + type Err = anyhow::Error; + fn from_str(s: &str) -> Result { + match s.to_lowercase().as_str() { + "datacap" | "f07" | "7" => Ok(ActorType::DataCap), + "verifreg" | "verifiedregistry" | "verified_registry" | "f06" | "6" => { + Ok(ActorType::VerifiedRegistry) + } + _ => bail!("Unknown actor type: {s}. Supported: datacap (f07), verifreg (f06)"), + } + } +} + +impl std::str::FromStr for ActorVersion { + type Err = anyhow::Error; + fn from_str(s: &str) -> Result { + match s.to_lowercase().as_str() { + "v9" | "9" => Ok(ActorVersion::V9), + "v10" | "10" => Ok(ActorVersion::V10), + "v11" | "11" => Ok(ActorVersion::V11), + "v12" | "12" => Ok(ActorVersion::V12), + "v13" | "13" => Ok(ActorVersion::V13), + "v14" | "14" => Ok(ActorVersion::V14), + "v15" | "15" => Ok(ActorVersion::V15), + "v16" | "16" => Ok(ActorVersion::V16), + "v17" | "17" => Ok(ActorVersion::V17), + _ => bail!("Unknown actor version: {s}. Supported: v9..v17"), + } + } +} + +impl std::fmt::Display for ActorType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + ActorType::DataCap => write!(f, "datacap"), + ActorType::VerifiedRegistry => write!(f, "verifreg"), + } + } +} + +impl std::fmt::Display for ActorVersion { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + ActorVersion::V9 => write!(f, "v9"), + ActorVersion::V10 => write!(f, "v10"), + ActorVersion::V11 => write!(f, "v11"), + ActorVersion::V12 => write!(f, "v12"), + ActorVersion::V13 => write!(f, "v13"), + ActorVersion::V14 => write!(f, "v14"), + ActorVersion::V15 => write!(f, "v15"), + ActorVersion::V16 => write!(f, "v16"), + ActorVersion::V17 => write!(f, "v17"), + } + } +} diff --git a/fil_actor_decoder/src/network.rs b/fil_actor_decoder/src/network.rs new file mode 100644 index 00000000..0fa56f8e --- /dev/null +++ b/fil_actor_decoder/src/network.rs @@ -0,0 +1,191 @@ +//! Network and epoch to actor version resolution. + +use crate::ActorVersion; +use anyhow::{Result, bail}; + +/// Supported Filecoin networks. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Network { + Mainnet, + Calibnet, +} + +impl std::str::FromStr for Network { + type Err = anyhow::Error; + fn from_str(s: &str) -> Result { + match s.to_lowercase().as_str() { + "mainnet" | "main" => Ok(Network::Mainnet), + "calibnet" | "calibration" | "calib" => Ok(Network::Calibnet), + _ => bail!("Unknown network: {s}. Supported: mainnet, calibnet"), + } + } +} + +impl std::fmt::Display for Network { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Network::Mainnet => write!(f, "mainnet"), + Network::Calibnet => write!(f, "calibnet"), + } + } +} + +/// Resolve an actor version from a network and epoch. +pub fn resolve_actor_version(network: Network, epoch: i64) -> Result { + let nv = epoch_to_network_version(network, epoch)?; + network_version_to_actor_version(nv) +} + +type NetworkVersion = u32; + +fn epoch_to_network_version(network: Network, epoch: i64) -> Result { + let upgrades = match network { + Network::Mainnet => MAINNET_UPGRADES, + Network::Calibnet => CALIBNET_UPGRADES, + }; + + let mut nv = 0u32; + for &(upgrade_epoch, version) in upgrades { + if epoch >= upgrade_epoch { + nv = version; + } else { + break; + } + } + + if nv < 17 { + bail!( + "Epoch {epoch} on {network} is before NV17 (Shark). \ + Actor versions before v9 are not supported." + ); + } + + Ok(nv) +} + +fn network_version_to_actor_version(nv: NetworkVersion) -> Result { + match nv { + 17 => Ok(ActorVersion::V9), + 18 => Ok(ActorVersion::V10), + 19 | 20 => Ok(ActorVersion::V11), + 21 => Ok(ActorVersion::V12), + 22 => Ok(ActorVersion::V13), + 23 => Ok(ActorVersion::V14), + 24 => Ok(ActorVersion::V15), + 25 | 26 => Ok(ActorVersion::V16), + 27 => Ok(ActorVersion::V17), + _ => bail!("Unsupported network version: NV{nv}"), + } +} + +static MAINNET_UPGRADES: &[(i64, NetworkVersion)] = &[ + (0, 0), + (41_280, 1), + (51_000, 2), + (94_000, 3), + (138_720, 4), + (140_760, 5), + (170_000, 6), + (265_200, 7), + (272_400, 8), + (336_458, 9), + (550_321, 10), + (665_280, 11), + (712_320, 12), + (892_800, 13), + (1_231_620, 14), + (1_594_680, 15), + (1_960_320, 16), + (2_383_680, 17), // Shark + (2_683_348, 18), // Hygge + (2_809_800, 19), // Lightning + (2_870_280, 20), // Thunder + (3_469_380, 21), // Watermelon + (3_855_360, 22), // Dragon + (4_154_640, 23), // Waffle + (4_461_240, 24), // TukTuk + (4_878_840, 25), // Teep + (4_900_440, 26), // Tock + (5_348_280, 27), // GoldenWeek +]; + +static CALIBNET_UPGRADES: &[(i64, NetworkVersion)] = &[ + (0, 0), + (30, 4), + (60, 5), + (90, 6), + (120, 7), + (240, 8), + (270, 9), + (330, 10), + (360, 11), + (390, 12), + (420, 13), + (450, 14), + (480, 15), + (510, 16), + (16_800, 17), // Shark + (322_354, 18), // Hygge + (489_094, 19), // Lightning + (492_214, 20), // Thunder + (1_013_134, 21), // Watermelon + (1_427_974, 22), // Dragon + (1_779_094, 23), // Waffle + (2_078_794, 24), // TukTuk + (2_523_454, 25), // Teep + (2_543_614, 26), // Tock + (3_007_294, 27), // GoldenWeek +]; + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_mainnet_current_epoch() { + let v = resolve_actor_version(Network::Mainnet, 5_833_541).unwrap(); + assert_eq!(v, ActorVersion::V17); + } + + #[test] + fn test_mainnet_dragon() { + let v = resolve_actor_version(Network::Mainnet, 3_900_000).unwrap(); + assert_eq!(v, ActorVersion::V13); + } + + #[test] + fn test_mainnet_watermelon() { + let v = resolve_actor_version(Network::Mainnet, 3_469_380).unwrap(); + assert_eq!(v, ActorVersion::V12); + } + + #[test] + fn test_mainnet_shark() { + let v = resolve_actor_version(Network::Mainnet, 2_383_680).unwrap(); + assert_eq!(v, ActorVersion::V9); + } + + #[test] + fn test_mainnet_before_shark_errors() { + let r = resolve_actor_version(Network::Mainnet, 2_000_000); + assert!(r.is_err()); + } + + #[test] + fn test_calibnet_current() { + let v = resolve_actor_version(Network::Calibnet, 3_100_000).unwrap(); + assert_eq!(v, ActorVersion::V17); + } + + #[test] + fn test_nv20_uses_v11() { + let v = resolve_actor_version(Network::Mainnet, 2_870_280).unwrap(); + assert_eq!(v, ActorVersion::V11); + } + + #[test] + fn test_nv26_uses_v16() { + let v = resolve_actor_version(Network::Mainnet, 4_900_440).unwrap(); + assert_eq!(v, ActorVersion::V16); + } +} diff --git a/fil_actor_decoder/tests/datacap_v11.rs b/fil_actor_decoder/tests/datacap_v11.rs new file mode 100644 index 00000000..a1c06ae8 --- /dev/null +++ b/fil_actor_decoder/tests/datacap_v11.rs @@ -0,0 +1,26 @@ +//! Snapshot tests for Datacap (f07) actor — v11. +//! Real on-chain data from mainnet. + +use fil_actor_decoder::{ActorType, ActorVersion, decode_params, decode_return}; + +fn decode_hex(hex: &str) -> Vec { + hex::decode(hex.strip_prefix("0x").unwrap_or(hex)).unwrap() +} + +const V: ActorVersion = ActorVersion::V11; +const A: ActorType = ActorType::DataCap; + +/// IncreaseAllowanceExported params — mainnet epoch 3019386 (NV19-20/Lightning-Thunder era) +/// Source: bafy2bzacea66krgstyo6gi6y2bbpye5d35xol6ol5e4fprlqokswkouaakxme +#[test] +fn mainnet_increase_allowance_params() { + let hex = "8255019165a67a951b7795e5bcc88f36627218364909854d006f05b59d3b20000000000000"; + insta::assert_json_snapshot!(decode_params(A, V, 1777121560, &decode_hex(hex)).unwrap()); +} + +/// IncreaseAllowanceExported return — same message +#[test] +fn mainnet_increase_allowance_return() { + let hex = "4d006f05b59d3b20000000000000"; + insta::assert_json_snapshot!(decode_return(A, V, 1777121560, &decode_hex(hex)).unwrap()); +} diff --git a/fil_actor_decoder/tests/datacap_v12.rs b/fil_actor_decoder/tests/datacap_v12.rs new file mode 100644 index 00000000..eff9d3bf --- /dev/null +++ b/fil_actor_decoder/tests/datacap_v12.rs @@ -0,0 +1,26 @@ +//! Snapshot tests for Datacap (f07) actor — v12. +//! Real on-chain data from mainnet. + +use fil_actor_decoder::{ActorType, ActorVersion, decode_params, decode_return}; + +fn decode_hex(hex: &str) -> Vec { + hex::decode(hex.strip_prefix("0x").unwrap_or(hex)).unwrap() +} + +const V: ActorVersion = ActorVersion::V12; +const A: ActorType = ActorType::DataCap; + +/// TransferExported params — mainnet epoch 3922481 (NV21/Watermelon era) +/// Source: bafy2bzacea3llgubzhqznvb3pdhg56wcfoa6p7ne3x7jm3lm3okgjefyyok5o +#[test] +fn mainnet_transfer_params() { + let hex = "834200064e0001bc16d674ec8000000000000059012b8284861a002f0688d82a5828000181e203922020b999522c47d73f46df363dee85bb3076cbfd5cf651085413d661db4c1ac544351b00000008000000001a00100a401a005033401a003c77af861a002f0688d82a5828000181e20392202076c8ddc46d1f83dadec5ff6d3479904e6e4ba79ac02f5d5bfe1f6535cd03b2031b00000008000000001a00100a401a005033401a003c77af861a002f0688d82a5828000181e203922020754691b2103f9c6d0ac93b8cb453a2698153494154273eefbfdfc1208e2664051b00000008000000001a00100a401a005033401a003c77af861a002f0688d82a5828000181e203922020cbf0afb40c61555a4490613c5d338c2a6bb424d9c1b482b96f777a739369ec2c1b00000008000000001a00100a401a005033401a003c77af80"; + insta::assert_json_snapshot!(decode_params(A, V, 80475954, &decode_hex(hex)).unwrap()); +} + +/// TransferExported return — same message +#[test] +fn mainnet_transfer_return() { + let hex = "834f0036735ed883156bc000000000000050000501e970dca062a4c2990000000000581c83820480820080841a03ca69321a03ca69331a03ca69341a03ca6935"; + insta::assert_json_snapshot!(decode_return(A, V, 80475954, &decode_hex(hex)).unwrap()); +} diff --git a/fil_actor_decoder/tests/datacap_v13.rs b/fil_actor_decoder/tests/datacap_v13.rs new file mode 100644 index 00000000..df78bb57 --- /dev/null +++ b/fil_actor_decoder/tests/datacap_v13.rs @@ -0,0 +1,26 @@ +//! Snapshot tests for Datacap (f07) actor — v13. +//! Real on-chain data from mainnet. + +use fil_actor_decoder::{ActorType, ActorVersion, decode_params, decode_return}; + +fn decode_hex(hex: &str) -> Vec { + hex::decode(hex.strip_prefix("0x").unwrap_or(hex)).unwrap() +} + +const V: ActorVersion = ActorVersion::V13; +const A: ActorType = ActorType::DataCap; + +/// TransferExported params — mainnet epoch 4144893 (NV22/Dragon era) +/// Source: bafy2bzacebaju3i4rgt7yn7fdts2tceqsvisazpwac3xjxngh2an3zhegibkq +#[test] +fn mainnet_transfer_params() { + let hex = "834200064e00022b1c8c1227a00000000000005901758285861a00303cadd82a5828000181e2039220202e9391a1b9b26f2fc2ec602406442fb176631bbe46d1ea1275d799626f8f79281b00000008000000001a0007e9001a000bdd801a003f7727861a00303cadd82a5828000181e20392202014f852a16257ce81754b7175e5fdef22dce537f5ac8c750e958fad61893017211b00000008000000001a0007e9001a000bdd801a003f772b861a00303cadd82a5828000181e203922020f07a7552f2be0818d0986d0c3f13e67ac6603884f3cfc5aeaa6981bbc0065d071b00000008000000001a0007e9001a000bdd801a003f7733861a00303cadd82a5828000181e2039220206d6cf39f355251c29b9f7f0b208470163402fb87ed33b022d67e5a506016f9211b00000008000000001a0007e9001a000bdd801a003f7737861a00303cadd82a5828000181e203922020b788d8d28dde9d2cd6f18a6b14bfd2ae56a9975a53e545941cdfcb30e5eb18031b00000008000000001a0007e9001a000bdd801a003f773780"; + insta::assert_json_snapshot!(decode_params(A, V, 80475954, &decode_hex(hex)).unwrap()); +} + +/// TransferExported return — same message +#[test] +fn mainnet_transfer_return() { + let hex = "834f0028f2110ceed03b400000000000005000048cc325867a0dc71011395e200000582183820580820080851a043495f51a043495f61a043495f71a043495f81a043495f9"; + insta::assert_json_snapshot!(decode_return(A, V, 80475954, &decode_hex(hex)).unwrap()); +} diff --git a/fil_actor_decoder/tests/datacap_v14.rs b/fil_actor_decoder/tests/datacap_v14.rs new file mode 100644 index 00000000..f4010165 --- /dev/null +++ b/fil_actor_decoder/tests/datacap_v14.rs @@ -0,0 +1,26 @@ +//! Snapshot tests for Datacap (f07) actor — v14. +//! Real on-chain data from mainnet. + +use fil_actor_decoder::{ActorType, ActorVersion, decode_params, decode_return}; + +fn decode_hex(hex: &str) -> Vec { + hex::decode(hex.strip_prefix("0x").unwrap_or(hex)).unwrap() +} + +const V: ActorVersion = ActorVersion::V14; +const A: ActorType = ActorType::DataCap; + +/// TransferExported params — mainnet epoch 4457228 (NV23/Waffle era) +/// Source: bafy2bzaceaeim7hnqzr55vwcgytlsxwopsm7nzurmdqynmi5t6kzt7jd6v7wq +#[test] +fn mainnet_transfer_params() { + let hex = "834200064d006f05b59d3b20000000000000584d8281861a00307300d82a5828000181e203922020709305f312a66323c14b35351802c5cf7361813dc794372df89e3b663f72941e1b00000008000000001a0007e9001a005033401a004451ca80"; + insta::assert_json_snapshot!(decode_params(A, V, 80475954, &decode_hex(hex)).unwrap()); +} + +/// TransferExported return — same message +#[test] +fn mainnet_transfer_return() { + let hex = "834f001711ddb705f32c40000000000000500004ce3e170e007c110a0c76a30c00004d83820180820080811a04e465b4"; + insta::assert_json_snapshot!(decode_return(A, V, 80475954, &decode_hex(hex)).unwrap()); +} diff --git a/fil_actor_decoder/tests/datacap_v15.rs b/fil_actor_decoder/tests/datacap_v15.rs new file mode 100644 index 00000000..f19c25b7 --- /dev/null +++ b/fil_actor_decoder/tests/datacap_v15.rs @@ -0,0 +1,30 @@ +//! Snapshot tests for Datacap (f07) actor — v15. +//! Real on-chain data from mainnet. + +use fil_actor_decoder::{ActorType, ActorVersion, decode_params, decode_return}; + +fn decode_hex(hex: &str) -> Vec { + hex::decode(hex.strip_prefix("0x").unwrap_or(hex)).unwrap() +} + +const V: ActorVersion = ActorVersion::V15; +const A: ActorType = ActorType::DataCap; + +/// TransferFromExported params — mainnet epoch 5421192 (NV24/TukTuk era) +/// Source: bafy2bzaceasbrxgllo7evw4kigtfk45guj2vqonn6rb3vczaeynkrfyhrjz26 +#[test] +fn mainnet_transfer_from_params() { + let hex = std::fs::read_to_string(concat!( + env!("CARGO_MANIFEST_DIR"), + "/tests/fixtures/mainnet_datacap_v15_transfer_from_params.hex" + )) + .unwrap(); + insta::assert_json_snapshot!(decode_params(A, V, 3621052141, &decode_hex(hex.trim())).unwrap()); +} + +/// TransferFromExported return — same message +#[test] +fn mainnet_transfer_from_return() { + let hex = "844f0008e79e12517f937c37937e080000500006c4291bbe996fba4cbecfdb3000005000095e658e0c3abae943c7f400000000585383820f80820080891a05306e471a05306e481a05306e491a05306e4a1a05306e4b1a05306e4c1a05306e4d1a05306e4e1a05306e4f1a05306e501a05306e511a05306e521a05306e531a05306e541a05306e55"; + insta::assert_json_snapshot!(decode_return(A, V, 3621052141, &decode_hex(hex)).unwrap()); +} diff --git a/fil_actor_decoder/tests/datacap_v16.rs b/fil_actor_decoder/tests/datacap_v16.rs new file mode 100644 index 00000000..4528b016 --- /dev/null +++ b/fil_actor_decoder/tests/datacap_v16.rs @@ -0,0 +1,132 @@ +//! Snapshot tests for Datacap (f07) actor — v16. +//! +//! v16 types are structurally identical to v17. These tests confirm v16 +//! decoding produces the same output by constructing params from v16 types. + +use fil_actor_decoder::{ActorType, ActorVersion, decode_params, decode_return}; +use fvm_ipld_encoding::to_vec; +use fvm_shared4::address::Address; +use fvm_shared4::econ::TokenAmount; + +const V: ActorVersion = ActorVersion::V16; +const A: ActorType = ActorType::DataCap; + +#[test] +fn mint_params() { + let p = fil_actor_datacap_state::v16::MintParams { + to: Address::new_id(1234), + amount: TokenAmount::from_atto(1_000_000_000_000_000_000_i64), + operators: vec![Address::new_id(5678)], + }; + insta::assert_json_snapshot!( + decode_params( + A, + V, + frc42_dispatch::method_hash!("Mint"), + &to_vec(&p).unwrap() + ) + .unwrap() + ); +} + +#[test] +fn destroy_params() { + let p = fil_actor_datacap_state::v16::DestroyParams { + owner: Address::new_id(100), + amount: TokenAmount::from_atto(500), + }; + insta::assert_json_snapshot!( + decode_params( + A, + V, + frc42_dispatch::method_hash!("Destroy"), + &to_vec(&p).unwrap() + ) + .unwrap() + ); +} + +#[test] +fn balance_params() { + let p = fil_actor_datacap_state::v16::BalanceParams { + address: Address::new_id(42), + }; + insta::assert_json_snapshot!( + decode_params( + A, + V, + frc42_dispatch::method_hash!("Balance"), + &to_vec(&p).unwrap() + ) + .unwrap() + ); +} + +#[test] +fn name_return() { + let r = fil_actor_datacap_state::v16::NameReturn { + name: "DataCap".into(), + }; + insta::assert_json_snapshot!( + decode_return( + A, + V, + frc42_dispatch::method_hash!("Name"), + &to_vec(&r).unwrap() + ) + .unwrap() + ); +} + +#[test] +fn granularity_return() { + let r = fil_actor_datacap_state::v16::GranularityReturn { + granularity: 1_000_000_000_000_000_000, + }; + insta::assert_json_snapshot!( + decode_return( + A, + V, + frc42_dispatch::method_hash!("Granularity"), + &to_vec(&r).unwrap() + ) + .unwrap() + ); +} + +#[test] +fn transfer_params() { + use fil_actors_shared::frc46_token::token::types::TransferParams; + use fvm_ipld_encoding::RawBytes; + let p = TransferParams { + to: Address::new_id(1000), + amount: TokenAmount::from_atto(100_000_000_000_000_000_000_i128), + operator_data: RawBytes::default(), + }; + insta::assert_json_snapshot!( + decode_params( + A, + V, + frc42_dispatch::method_hash!("Transfer"), + &to_vec(&p).unwrap() + ) + .unwrap() + ); +} + +#[test] +fn burn_params() { + use fil_actors_shared::frc46_token::token::types::BurnParams; + let p = BurnParams { + amount: TokenAmount::from_atto(50_000_000_000_000_000_000_i128), + }; + insta::assert_json_snapshot!( + decode_params( + A, + V, + frc42_dispatch::method_hash!("Burn"), + &to_vec(&p).unwrap() + ) + .unwrap() + ); +} diff --git a/fil_actor_decoder/tests/datacap_v17.rs b/fil_actor_decoder/tests/datacap_v17.rs new file mode 100644 index 00000000..28112293 --- /dev/null +++ b/fil_actor_decoder/tests/datacap_v17.rs @@ -0,0 +1,304 @@ +//! Snapshot tests for Datacap (f07) actor — v17. +//! +//! Real on-chain data sourced via `Filecoin.ChainGetMessage` / `Filecoin.StateReplay` +//! against https://filfox.info/rpc/v1 (mainnet) and https://calibration.filfox.info/rpc/v1. +//! Synthetic tests use `fvm_ipld_encoding::to_vec` on actual v17 types. + +use fil_actor_decoder::{ActorType, ActorVersion, decode_params, decode_return}; +use fvm_ipld_encoding::to_vec; +use fvm_shared4::address::Address; +use fvm_shared4::econ::TokenAmount; + +fn decode_hex(hex: &str) -> Vec { + hex::decode(hex.strip_prefix("0x").unwrap_or(hex)).unwrap() +} + +const V: ActorVersion = ActorVersion::V17; +const A: ActorType = ActorType::DataCap; + +// ── Real on-chain ─────────────────────────────────────────────────────── + +/// TransferFromExported params — mainnet epoch 5833541 +/// Source: bafy2bzaceczilb2427k5qucq5gic6groqm6jvmkfh3djcuupgsnnocqnf2sgs +#[test] +fn mainnet_transfer_from_params() { + let hex = "844500f3e1d7014200064e0003e7336287142000000000000059029d8289861a003917d5d82a5828000181e2039220209e0e0e891fbf41594df42e399568b395516573dcbb3a11c5551b8b330f5e08311b00000008000000001a0007e9001a005033401a005ba62f861a003917d5d82a5828000181e203922020abc76cc4db1d6f5839511427ce1d5cc9bfa2a74d794bc849badb32ac7b7598141b00000008000000001a0007e9001a005033401a005ba632861a003917d5d82a5828000181e2039220209de6e7c5b2d90236419d6e52283922e7da810f67ef8ee8643ba9c63e979355011b00000008000000001a0007e9001a005033401a005ba636861a003917d5d82a5828000181e203922020156e792b858648a625ea5b781be69fa27d6b11f9e2d17a90fc7821175f568a171b00000008000000001a0007e9001a005033401a005ba63a861a003917d5d82a5828000181e2039220202f92e1b2678e395f4eadacee1bea3362e4c592bfe281431d79cccfafece971311b00000008000000001a0007e9001a005033401a005ba63a861a003917d5d82a5828000181e203922020b81e3bd166def41d6a4e72d8e45ec9e3c08a4e180d911a0c82451a370a1094361b00000008000000001a0007e9001a005033401a005ba63c861a003917d5d82a5828000181e2039220203a673fad8c9a0143c822946b939fd51e9759687cad9e9da80184c7cf4765c8061b00000008000000001a0007e9001a005033401a005ba641861a003917d5d82a5828000181e203922020abaa1c7ca669da15106e8e842db9cdb51c7f0c313d5319d98cfd3e79aac183261b00000008000000001a0007e9001a005033401a005ba642861a003917d5d82a5828000181e20392202099c2daf1f95883627f570aa9197dcaf0db17cc3ba3042af26c2196754dc8381d1b00000008000000001a0007e9001a005033401a005ba64280"; + let result = decode_params(A, V, 3621052141, &decode_hex(hex)).unwrap(); + insta::assert_json_snapshot!(result); +} + +/// TransferFromExported return — mainnet epoch 5833541 +/// Source: bafy2bzaceczilb2427k5qucq5gic6groqm6jvmkfh3djcuupgsnnocqnf2sgs +#[test] +fn mainnet_transfer_from_return() { + let hex = "844f002b64d8087cb645a8000000000000500008a1be0855c6267d563ac6c96800004f0018ba708c8e3c47a0000000000000583583820980820080891a0763a1e91a0763a1ea1a0763a1eb1a0763a1ec1a0763a1ed1a0763a1ee1a0763a1ef1a0763a1f01a0763a1f1"; + let result = decode_return(A, V, 3621052141, &decode_hex(hex)).unwrap(); + insta::assert_json_snapshot!(result); +} + +// ── Synthetic ─────────────────────────────────────────────────────────── + +#[test] +fn constructor_params() { + let p = fil_actor_datacap_state::v17::ConstructorParams { + governor: Address::new_id(90), + }; + insta::assert_json_snapshot!(decode_params(A, V, 1, &to_vec(&p).unwrap()).unwrap()); +} + +#[test] +fn mint_params() { + let p = fil_actor_datacap_state::v17::MintParams { + to: Address::new_id(1234), + amount: TokenAmount::from_atto(1_000_000_000_000_000_000_i64), + operators: vec![Address::new_id(5678)], + }; + insta::assert_json_snapshot!( + decode_params( + A, + V, + frc42_dispatch::method_hash!("Mint"), + &to_vec(&p).unwrap() + ) + .unwrap() + ); +} + +#[test] +fn destroy_params() { + let p = fil_actor_datacap_state::v17::DestroyParams { + owner: Address::new_id(100), + amount: TokenAmount::from_atto(500), + }; + insta::assert_json_snapshot!( + decode_params( + A, + V, + frc42_dispatch::method_hash!("Destroy"), + &to_vec(&p).unwrap() + ) + .unwrap() + ); +} + +#[test] +fn balance_params() { + let p = fil_actor_datacap_state::v17::BalanceParams { + address: Address::new_id(42), + }; + insta::assert_json_snapshot!( + decode_params( + A, + V, + frc42_dispatch::method_hash!("Balance"), + &to_vec(&p).unwrap() + ) + .unwrap() + ); +} + +#[test] +fn name_return() { + let r = fil_actor_datacap_state::v17::NameReturn { + name: "DataCap".into(), + }; + insta::assert_json_snapshot!( + decode_return( + A, + V, + frc42_dispatch::method_hash!("Name"), + &to_vec(&r).unwrap() + ) + .unwrap() + ); +} + +#[test] +fn symbol_return() { + let r = fil_actor_datacap_state::v17::SymbolReturn { + symbol: "DCAP".into(), + }; + insta::assert_json_snapshot!( + decode_return( + A, + V, + frc42_dispatch::method_hash!("Symbol"), + &to_vec(&r).unwrap() + ) + .unwrap() + ); +} + +#[test] +fn total_supply_return() { + let r = fil_actor_datacap_state::v17::TotalSupplyReturn { + supply: TokenAmount::from_atto(800_000_000_000_000_000_000_000_i128), + }; + insta::assert_json_snapshot!( + decode_return( + A, + V, + frc42_dispatch::method_hash!("TotalSupply"), + &to_vec(&r).unwrap() + ) + .unwrap() + ); +} + +#[test] +fn balance_return() { + let r = fil_actor_datacap_state::v17::BalanceReturn { + balance: TokenAmount::from_atto(5_000_000_000_000_000_000_i64), + }; + insta::assert_json_snapshot!( + decode_return( + A, + V, + frc42_dispatch::method_hash!("Balance"), + &to_vec(&r).unwrap() + ) + .unwrap() + ); +} + +#[test] +fn granularity_return() { + let r = fil_actor_datacap_state::v17::GranularityReturn { + granularity: 1_000_000_000_000_000_000, + }; + insta::assert_json_snapshot!( + decode_return( + A, + V, + frc42_dispatch::method_hash!("Granularity"), + &to_vec(&r).unwrap() + ) + .unwrap() + ); +} + +#[test] +fn transfer_params() { + use fil_actors_shared::frc46_token::token::types::TransferParams; + use fvm_ipld_encoding::RawBytes; + let p = TransferParams { + to: Address::new_id(1000), + amount: TokenAmount::from_atto(100_000_000_000_000_000_000_i128), + operator_data: RawBytes::default(), + }; + insta::assert_json_snapshot!( + decode_params( + A, + V, + frc42_dispatch::method_hash!("Transfer"), + &to_vec(&p).unwrap() + ) + .unwrap() + ); +} + +#[test] +fn burn_params() { + use fil_actors_shared::frc46_token::token::types::BurnParams; + let p = BurnParams { + amount: TokenAmount::from_atto(50_000_000_000_000_000_000_i128), + }; + insta::assert_json_snapshot!( + decode_params( + A, + V, + frc42_dispatch::method_hash!("Burn"), + &to_vec(&p).unwrap() + ) + .unwrap() + ); +} + +#[test] +fn burn_from_params() { + use fil_actors_shared::frc46_token::token::types::BurnFromParams; + let p = BurnFromParams { + owner: Address::new_id(200), + amount: TokenAmount::from_atto(25_000_000_000_000_000_000_i128), + }; + insta::assert_json_snapshot!( + decode_params( + A, + V, + frc42_dispatch::method_hash!("BurnFrom"), + &to_vec(&p).unwrap() + ) + .unwrap() + ); +} + +#[test] +fn increase_allowance_params() { + use fil_actors_shared::frc46_token::token::types::IncreaseAllowanceParams; + let p = IncreaseAllowanceParams { + operator: Address::new_id(300), + increase: TokenAmount::from_atto(10_000_000_000_000_000_000_i128), + }; + insta::assert_json_snapshot!( + decode_params( + A, + V, + frc42_dispatch::method_hash!("IncreaseAllowance"), + &to_vec(&p).unwrap() + ) + .unwrap() + ); +} + +#[test] +fn decrease_allowance_params() { + use fil_actors_shared::frc46_token::token::types::DecreaseAllowanceParams; + let p = DecreaseAllowanceParams { + operator: Address::new_id(300), + decrease: TokenAmount::from_atto(5_000_000_000_000_000_000_i64), + }; + insta::assert_json_snapshot!( + decode_params( + A, + V, + frc42_dispatch::method_hash!("DecreaseAllowance"), + &to_vec(&p).unwrap() + ) + .unwrap() + ); +} + +#[test] +fn revoke_allowance_params() { + use fil_actors_shared::frc46_token::token::types::RevokeAllowanceParams; + let p = RevokeAllowanceParams { + operator: Address::new_id(300), + }; + insta::assert_json_snapshot!( + decode_params( + A, + V, + frc42_dispatch::method_hash!("RevokeAllowance"), + &to_vec(&p).unwrap() + ) + .unwrap() + ); +} + +#[test] +fn allowance_params() { + use fil_actors_shared::frc46_token::token::types::GetAllowanceParams; + let p = GetAllowanceParams { + owner: Address::new_id(100), + operator: Address::new_id(300), + }; + insta::assert_json_snapshot!( + decode_params( + A, + V, + frc42_dispatch::method_hash!("Allowance"), + &to_vec(&p).unwrap() + ) + .unwrap() + ); +} diff --git a/fil_actor_decoder/tests/fixtures/mainnet_datacap_v15_transfer_from_params.hex b/fil_actor_decoder/tests/fixtures/mainnet_datacap_v15_transfer_from_params.hex new file mode 100644 index 00000000..7d2d93cf --- /dev/null +++ b/fil_actor_decoder/tests/fixtures/mainnet_datacap_v15_transfer_from_params.hex @@ -0,0 +1 @@ +8445008ac2d6014200064e00068155a43676e0000000000000590459828f861a0031ff77d82a5828000181e2039220205981338db41d56ac14ef8c59cd9ab62187425c1a745afc10a3aa0c373e434f0a1b00000008000000001a0007e9001a005033401a00555b72861a0031ff77d82a5828000181e2039220207f5bca8fcaead929162e149e8a4d2b4b84b81087c10bf79c4039e77489ed0f1a1b00000008000000001a0007e9001a005033401a00555b72861a0031ff77d82a5828000181e203922020f7685b16becdbd770277747823a1ea11310dd1294cac0175e266698cb06cd51d1b00000008000000001a0007e9001a005033401a00555b76861a0031ff77d82a5828000181e203922020abc314cde197c819cb0007ca6c149f129e8ba2f312f82fe3feae7cc394e549331b00000008000000001a0007e9001a005033401a00555b76861a0031ff77d82a5828000181e2039220208fe836420d92478f528af06c0f78e86c9d91aff9e0fdc93b7e8c7a9f6942233f1b00000008000000001a0007e9001a005033401a00555b76861a0031ff77d82a5828000181e2039220207d9adfbb1d07736b427dd7e3d0f8a75527957cd85422b13238f162af528fca301b00000008000000001a0007e9001a005033401a00555b7a861a0031ff77d82a5828000181e203922020c3c2b539f2a858bafb491a11653076aedfb562bc2c9c205a58a2de8be4b856181b00000008000000001a0007e9001a005033401a00555b7a861a0031ff77d82a5828000181e2039220203583b448b7ee5ff3f9502b93fb1173b99a8d3115d559bf65f061744e784a0a0f1b00000008000000001a0007e9001a005033401a00555b7a861a0031ff77d82a5828000181e203922020f7685b16becdbd770277747823a1ea11310dd1294cac0175e266698cb06cd51d1b00000008000000001a0007e9001a005033401a00555b7f861a0031ff77d82a5828000181e2039220205f25c00fd69c45e2426a8e474405c51124ea514273caf4b09a4ab994411a8c3a1b00000008000000001a0007e9001a005033401a00555b7f861a0031ff77d82a5828000181e203922020f4244067bdbba0ae44de0ce0fda97ccde8d33fe00708f760b2716ff2fb1510121b00000008000000001a0007e9001a005033401a00555b7f861a0031ff77d82a5828000181e20392202033f069d81188b1804d2d44438271f0e5def5d3c8e929a8b29ac6c4c1221fa00d1b00000008000000001a0007e9001a005033401a00555b83861a0031ff77d82a5828000181e2039220205981338db41d56ac14ef8c59cd9ab62187425c1a745afc10a3aa0c373e434f0a1b00000008000000001a0007e9001a005033401a00555b83861a0031ff77d82a5828000181e2039220208fe836420d92478f528af06c0f78e86c9d91aff9e0fdc93b7e8c7a9f6942233f1b00000008000000001a0007e9001a005033401a00555b83861a0031ff77d82a5828000181e203922020c3c2b539f2a858bafb491a11653076aedfb562bc2c9c205a58a2de8be4b856181b00000008000000001a0007e9001a005033401a00555b8580 \ No newline at end of file diff --git a/fil_actor_decoder/tests/fixtures/mainnet_verifreg_remove_expired_allocations_return.hex b/fil_actor_decoder/tests/fixtures/mainnet_verifreg_remove_expired_allocations_return.hex new file mode 100644 index 00000000..6028c4fb --- /dev/null +++ b/fil_actor_decoder/tests/fixtures/mainnet_verifreg_remove_expired_allocations_return.hex @@ -0,0 +1 @@ +839906a81a04b79ebd1a0622f3ce1a06227ad51a05fe7f4e1a06191f531a061745511a062095d61a0615e37d1a061598971a061c99a01a04c86dda1a06204d301a060c2a0f1a0620545e1a05fe40b01a04bda8a61a0617456d1a0615fdfe1a061b4b011a061745781a05fe81181a04b79eab1a061b20b21a061d33471a06202c981a0617458a1a061affca1a062061951a0614f6361a0623476b1a05fe86261a061d755d1a061b66841a04bb3fac1a061caeef1a061cc8ae1a061d62021a0609972b1a061745541a0568dcbc1a054ba9d81a0615bf8e1a061c2e331a061b44791a0568d19b1a05fcbeb21a054beb771a060412e41a062073801a062297241a06222e481a062351cc1a06206cb21a062070411a061b66d01a0622e3ad1a0612e9351a061744c81a04b339531a0621a7251a0622e4401a061745431a0601d8931a062279bc1a06200f9e1a06224e441a05fe7bce1a05241d8b1a04b7e72f1a062063041a061745651a060c57381a0622ece21a04b7d2bd1a05fe7f4c1a04bb3af11a06153e0b1a0620563c1a06204cc61a061745661a061875361a0621afbb1a0623057f1a06206abf1a0615c1fa1a06206a291a06200cfe1a0612ec0d1a054be4f71a0621bc4a1a061df1e91a061d75641a061d08951a05fe459d1a0620f2111a04bc6c5e1a060c28a61a061ab6191a0620594d1a0617455a1a06202fa91a05fe56ae1a04b7a9101a0622b7e21a0609972d1a061793491a06206d321a05fe86281a04b3386c1a04b7eee01a05fe83ee1a061df6d61a0567de671a04bb75ed1a04b82bc81a062235c21a054ba9dc1a061c2e2e1a061b798b1a061b9f241a06059bbc1a06193f571a062346061a06204a161a061d32d91a0617456f1a0620530d1a061e2f1a1a05fce1611a061bddeb1a062060051a062053871a060997281a05fe7bcd1a061b9f231a0612f1231a0618cb521a0612ef761a061df50f1a0622516b1a056865ce1a04bc645d1a061598d51a061691eb1a05fcf7f11a054be4f91a05fe7a0f1a0600656e1a0612eccb1a062068df1a04b7ccee1a061cc4da1a061caa221a0612f1341a0612e6be1a05fe7bd41a061dd7351a061745601a04b7c17b1a04b82b871a061c2ed61a04be71e11a062072aa1a054bcd4a1a06238c631a060436341a061744ba1a0568acc11a0612e6ab1a06200f851a060249981a0615f7e31a061df9ea1a06022f111a0615cda71a0600f66b1a061c38ae1a06200d4b1a060996f51a05fe7a0c1a061c6d9d1a054bf05f1a0612eb7b1a0612ef871a061c55111a061c5f2f1a05fe82561a0603a1e61a061745871a04b338ec1a061cbfb71a0623c47a1a04bb4c191a06160e1b1a060d825a1a061bc4991a04c1845f1a0612e7291a061b55881a04bb75f01a05fd00fc1a04bd98981a04be6b3a1a05fe825b1a062074701a054bf0681a05686cec1a0622a3711a062034bb1a04b33f7e1a06205ed41a0615ae891a06206bb41a061cfb351a061b0daf1a061745741a062056b61a0622533f1a05fcbd561a06204fac1a04b339601a04b34df11a06026fe81a062271fb1a06205cd91a062059511a05fe7b1e1a06204cc01a0601af451a0612ed0b1a04b345d61a062312521a04bb71061a04b338f11a061e54b51a062392da1a061cb9cb1a061b63d71a061745791a062294bb1a062035601a054bf0631a061bf0cb1a062060641a05fcfa171a061caa431a05fe7cf21a060424ee1a062068441a0623426c1a06204e221a061b0abb1a061c6ec81a06231b391a05fe7b1f1a060265331a0617f9381a062050d61a062014d61a062053e11a054b91f21a0602505a1a0615e58e1a0618cb561a06206ffb1a06206baf1a061c67ac1a0609972e1a054bbfc21a061c8c0f1a06172b3f1a060c2a141a054b98de1a054bbc911a061745621a061c1f631a04bb35dc1a061b0a171a0615c2781a062051bb1a062056b91a04b7e7331a062057421a04bdbeb11a062216191a061c48661a062051b51a05fe33041a0612f4151a05fe7bd01a061c4c961a0622cbe31a062310951a05fe81191a04b33f7d1a062052241a0614f7da1a061ef09b1a0612ecc41a0616f3a31a061745561a062377711a0615c75e1a054bb3731a061b9ac21a061c20ba1a062056b41a0612ef3a1a05fe893d1a062065701a0612e9751a05fe82541a0615bffe1a061745731a06235e881a04b7eef11a0612e7a61a05fce7451a056819231a05fe7ffd1a0615bcdb1a04bb60261a04b338ef1a061ce7b81a0620656e1a061c48621a06200f7e1a062075ed1a04c8835d1a06200d521a054bc3a91a0616a4ea1a061c7f1b1a0612ecd11a04bb3fad1a04c862ff1a0623476c1a05fe893c1a06042ed61a0604360c1a0617454d1a05fe87a71a061ab8341a061de3961a05fe84b21a0617454f1a06202c951a0568acb91a061bf9321a061745691a0620008d1a062306d91a061c59151a061d35391a054bb37f1a062070021a04b339571a06006cda1a054bcd3c1a06204e201a062291d51a054bc3a11a061928a81a054ba04d1a06205da61a061e132c1a04b345cb1a0603f11b1a061dd01b1a054bc39c1a061c7f7d1a05fe86291a061744bf1a062071421a06239ea61a0609972c1a05fe87a91a060404341a0612f3fe1a062053df1a05fce3e81a0601f9ee1a061ce80b1a06203e1a1a05687feb1a054b88071a0601d3411a061c99741a06205f6f1a05fe5a5b1a05fe7ddd1a0615f8981a0612e9d31a061b1e331a061c7d901a061bf27b1a054bdf291a061d14971a062067ca1a061def781a06228d511a062286a51a0612eb6f1a061d5a191a04bc365b1a062059541a05fcef7b1a061eb0db1a061d612b1a054bf06b1a05fe87ab1a0612efc91a0568bf8d1a061d3c391a062056b81a061834981a0615e2241a04b3395c1a05fe7de41a062055461a04b338751a0614e63f1a0612ef381a05fcfa141a061ba29a1a06153c151a04b7c1771a0601d62f1a0618a73b1a061d08911a062064231a06205a751a06234fc11a04bb3aef1a05fe459a1a061745701a06205df21a0622dd141a04b339661a0620d6621a06224d2a1a05fe862b1a05fcf4491a04bb75e31a062309581a061b0a051a0617f39e1a054bb7a41a060587201a061bfabb1a062021f81a0614eab61a062066471a061d2af21a061c7df71a054bc7c61a05fe7cf41a06205f6e1a0612e94f1a061d670d1a062283a51a04b339471a0623059a1a04b79ed51a0615daa31a06232d151a0612e9481a0622d4e71a061dffb21a061ae0391a05fe85791a04b339641a0615e02b1a04bb2caf1a05fe83f21a054bc3a31a061babbe1a0618cb511a04bb3af91a06159e571a062072ad1a061672721a0601e6771a060403711a060996fc1a061c5b9e1a061ebeae1a04be6b391a061c43651a05fe811e1a05fe7cf51a04b35a7b1a054bc7cb1a04b3394f1a04bb35d21a062059d41a0615a55b1a0616a4ec1a06205c2a1a054b91ed1a061baf8f1a060686511a0601e9ad1a0567f4c81a061c367a1a05fe7b1d1a062305a21a061849c61a062051831a0615b3911a061531e41a0612f1211a061b0a181a0615e0251a0621e3dd1a061c72421a06159a891a062392db1a062001301a061b39cf1a0616fa911a061744c41a061ba00f1a061745551a061ba4761a061c230d1a04b7b00c1a061c9d9d1a061bda411a05fe7f521a05670f721a054bb37b1a061ca3ac1a061745501a04b35b791a062055451a062058fb1a05fe7b201a04be7eb41a05fcf25f1a062274951a06206abe1a0614c2301a062056fe1a06204fab1a061c4fac1a04b345f21a061509301a05fe84b41a061baf551a0617458b1a062063741a061745851a061c333d1a060585331a060db2d91a0623e9ac1a062053121a05fe862a1a06206bb11a061745761a061dd0171a06043b611a062052211a061bd9661a054bbfbe1a05fe857c1a0622158a1a0617454a1a0612e7191a04b7c1791a061709c01a04b79e5b1a061c57a91a061549211a061c74bd1a061744c61a0620746f1a062288a21a061cc5f41a05fcef461a060643a41a061b39ba1a061b88271a0622280b1a061caa441a061b49c41a04c184611a062061941a061d3fef1a062364931a06206cb01a061e807a1a062310981a054bb79f1a0612e9711a0615fb161a061bd9681a06159a521a061c7f7f1a0617455f1a061d14941a06201fa71a06204c7c1a04bb1e901a062075f01a061549e11a061d14a91a05fe7ffb1a062395f31a04bb2ca21a0612efca1a063021721a0609970e1a061e0bad1a04bb3fb11a062053dd1a06204d291a04b7b0441a062050641a062035241a0612e6bb1a06239c281a060c36541a06043bfd1a05fcdba51a061b71cb1a0620077b1a061553c51a061745591a0622d8511a05fe82581a05fce9731a05fe811a1a062305821a060c652b1a05fe893f1a054bf05e1a061d7f9a1a062066c51a06204be51a062386a01a062060601a056857a31a061c1b481a061c5f2d1a052602961a061c485d1a061b8e8f1a062055d61a04b7c16f1a04b35b2f1a0615ad351a062318881a06169c911a062054a51a0612e7341a0612e93a1a060436bc1a04b339561a061c4c901a054bd7481a061df40f1a061e05561a062285971a05fcf2ca1a06206d2f1a06200d301a061745521a04b7b7e61a0620df761a061bc0b91a061c2e291a060c40ad1a062306bf1a0623fa9d1a061744bd1a04b34dbd1a0612f4181a062241c21a061d75571a0568cb931a05fcf0371a04b7b7ec1a054bdf1f1a061cb9cc1a0620550e1a054b91f81a0620703f1a05fe7bcf1a04bb44ba1a04bb0a6f1a0620754b1a061b45581a062060611a061dfa161a05fe857f1a060241341a0615c4d41a060c29da1a054bbc9a1a062067c81a062051b61a062051841a06206f391a04bd98891a061970891a0618cb531a061d089c1a061744b61a0614fc361a0612e6b21a06203f871a05fcf7bd1a054bcd3f1a0615c7671a0615d4aa1a05fe82551a0612ebf11a061d595d1a0612e9721a062076801a0620619b1a061745571a04bb28061a06234fbe1a062007591a05fe84b51a04bb0f661a061744c51a04b79eaf1a04b3390a1a06204fe51a061db3761a062059d91a0568cb8a1a04b338721a061c4ac81a061715a21a04bb19601a06206d541a04b3394e1a04b7f6841a0617455e1a061dcfce1a061bdd4c1a06240a491a062057041a062401ba1a062297c21a0616b08e1a05fe87a81a061b57151a062264da1a060414681a06172b5b1a0612f1391a06159a541a061c88811a062305dd1a06206ddc1a061540d51a061c72791a062271fc1a061bedba1a0623b44a1a05fe84b61a04b7eee31a054bcd401a05fe825a1a04b7d3301a0601f6f21a061b55891a06023bd11a04b7f68d1a06240ae71a0620674f1a05fe82591a061c4b251a04bb3afc1a062064241a0612ef701a061c3ba61a061d54981a061c9b1a1a05fe857a1a060d841c1a04b345f11a05fe7f4f1a061745581a061c287d1a061c5d941a0612e6a51a0617c3771a05fe7cf01a04bda8a91a06204d2f1a054bc3a51a04c184601a0612ec701a06153f861a0612ef221a062306f91a0604166a1a0612eeec1a061dd5081a062314f11a06204e8d1a0615c2bd1a0615dddd1a05fcf2691a0623e9a91a0612ef741a0597ca281a062309761a04b7d9861a061ab99f1a062390d81a061d3ff01a0612efb61a05fe7ffa1a0620664b1a06239a4f1a061dace61a06151bdc1a0623e9ae1a061745641a04b7eee41a061c4a801a061d50861a054be4f11a04b33f761a062305c81a061511a71a04b7e0391a060242861a061d4dae1a04b7b7e71a061745681a06200f831a0620545c1a0527dd051a061c3bb81a0605832d1a0603f2e11a061c56461a061d312b1a0615b8bf1a061bd1e01a062051821a06204be41a062351cf1a062288641a062057411a054bd7421a04bb19591a062215af1a04bb6bc31a054beb781a04b338691a06204f6e1a054bcd471a054be4f61a061eb5c01a061744be1a06206dd81a0612ebf01a054beb751a05fe7de01a05fe811c1a06238d031a061c43281a0601f44d1a0616246f1a05fe83f01a0622cc811a062070011a061dc3621a062077e21a05fcfdd91a061552861a05fe7ddf1a04c45de51a054bbfb91a061aff721a061e0f851a05fe89401a061744c11a061c7dbb1a061c48681a06236dfd1a06204f6b1a061893da1a062056ff1a062061971a060409691a0615d6de1a0612e9411a05fe87ad1a054bbfc31a05fce3fe1a06205da91a04c1845d1a061b0a191a061745441a061e0f7e1a04b3386d1a0568acb71a06205f711a06204ddc1a05fe83f31a062057a81a06206e5b1a061dd57b1a05fcf29a1a0614f6e11a04b7eef21a06202cad1a061b99621a0609970d1a05fcfc4b1a0615acb01a061c01551a0620161c1a062278f21a0615eb861a061ee5251a04bb35d41a05fce8681a0615a8e81a04b34df61a06204e231a062054ec1a054b88091a060c6cad1a06153d281a06228d4f1a0612e6a01a04bb3fc91a0612ecd91a061745531a04b345f41a0612e7551a04b338ee1a060d86821a061c5f2e1a0567eada1a062076851a0612f1ec1a06205b5e1a0612f13f1a05fe7cf71a04b345eb1a061cfb021a04b61db41a060c29691a04b34df81a06041ec41a0612ef6a1a0612f4801a0623ae901a061ae4351a05fcef4a1a061b94541a06206ddf1a0614e4e41a04b7afe01a062067c41a054ba04a1a061551621a0568737e1a05fe41d01a061eea111a06202c9b1a061547e61a05fe7ff81a061518071a05fe7cf61a0616e50c1a0568bf831a061744bc1a0612e7231a0615a8821a0622837f1a0568a62b1a05fe8caf1a061c1f5e1a062051b81a06159c6e1a061d14951a05fcfedd1a06232e7f1a054beb761a061c95551a06204e901a060996f91a0620754e1a05fe84b01a04b3396a1a061dec5c1a060c37211a04b7cced1a0620674e1a061c9b1b1a06206cbe1a061b7ecb1a061745751a0614fc3c1a0612ec6d1a04bdb0241a061acf3a1a04bd98961a061c9bb01a061745491a060c46a21a061e8ccf1a0612e9dc1a062400601a060034791a04be777b1a062319071a061c20751a04b7c9601a061c206d1a05fcdb6e1a061504431a0615ecc21a061793461a0617b76c1a061c4f8e1a0622e3a91a0621ad351a0615be911a04b34db31a062326721a061b49cf1a061533521a054beb741a0568998f1a06200fae1a061d436c1a0614ec171a04b7c95e1a061c46841a05fe81171a061598011a0612ecad1a06206e561a04b3395f1a061d08691a0615c9891a054b98d91a061d53201a0615c9771a0615cbca1a06230bb61a04b7c95d1a054beb711a06206eb61a06206ffc1a062064201a062306c71a056820141a062057ad1a061530831a062358331a061c9dbf1a059852f31a0615ea621a0622a01e1a06203d7d1a0617456a1a05fcf5001a04b345d81a05fe82571a061bbd911a0616153c1a06205b611a06154c2a1a06159b681a06226af51a0568b3021a06205c981a06204cbf1a060164e61a061540d01a06235c511a061549e71a0612e99b1a06043d601a062305881a0612ef9c1a061defa61a061745631a062069a51a0620656b1a0615aac71a05fcd81a1a061745721a0617457a1a061dec5b1a061b98361a061744c31a04b339441a06204fad1a061d40611a0615baab1a061745771a0615468c1a04b79f1d1a061c26bb1a061744c21a05fe85781a061c4b231a061691f11a060283d61a061b5be81a0612e9141a054bdf271a061cd6b61a06006c0b1a061df0421a062006dc1a062331071a062363841a061b459a1a0616b7421a0616b08f1a05fe7de31a04b638e01a0617456b1a0620656a1a061546071a0620530a1a0617454c1a062252a51a062056b51a04bb2ca31a0623c47b1a054b98da1a054bc39e1a05fe862c1a0616b0f11a054bbc961a06206bb31a061bf27c1a06027b811a05fe893e1a0603fa6e1a062051411a0612ecb41a04b7ccf91a06043b531a0623cc601a04b7d9821a06230dcd1a05fe7f531a04b34dfb1a054bc3a21a05fe84b31a062046ca1a061504451a05fe811b1a0623984d1a054bc7c91a061eea0e1a05fcfb691a06204a141a061d39bd1a06159b911a061745481a04b7f6871a061c333e1a062398f51a061745711a0622343a1a062055d71a04b7e1fe1a0620628b1a056727b91a04b7ccf61a062073831a05fe7bd11a0620626a1a061b02f31a0615c98a1a0615b8b61a0617ce461a06205b5c1a06204e8c1a0568cb891a061e49ac1a054bcd441a04bb3fb01a0617456e1a062266341a061745891a054bbfb71a06236fd01a04b79e541a0612f3f91a04bb2ca91a061bab631a062050d11a054bbfbf1a04b35a7a1a062060ff1a05fcaa931a061539171a0622cf9d1a04b7e72b1a04c1845e1a06027d891a04bb23791a061e80771a062067c61a054bd7411a061745461a0614ff9b1a061c9be31a05fe7f511a061e12ee1a04bb3fcb1a05fe86271a061e29fb1a054bc3a01a06205b601a061597721a061c4f891a05fce19d1a04bb31411a05fe7de21a061c7c761a04bb35cf1a05fe7a131a0617454b1a04be777a1a0612f4071a054b88141a0617456c1a0620a40a1a06041d8b1a062053e21a062355331a054bc7c51a04bb35df1a062007261a060c6a411a06154b961a061c2e311a0618d9cc1a0620727d1a061c999e1a061df1591a05fcf8821a0615dc851a0615c27c1a061c99a11a056840701a0618a2901a062055401a061744b91a060997271a061596f71a0620563f1a0617454e1a06203e661a061bbefe1a061745881a061b1c301a0612e6b51a05fe7a0e1a0623097b1a061d4db41a05fe83f41a04be777c1a061e75df1a0609972a1a04bb31341a061bfea01a062384081a061748221a04bb28081a062052201a061b25541a06235ddd1a061c55061a04b62c9e1a062063071a05fcfef11a061d84171a04b7d9881a054bcd421a062053101a06223aad1a0620713f1a062305df1a06154abf1a061dd1631a04bb0a721a062057aa1a0620737f1a04b7a8d01a0601d8351a0612f14a1a0612e73f1a06209c7a1a05fe7cf11a04bb3b001a0616e99a1a061c43d41a04b339031a062035251a04bb712f1a04bb0f631a0601d7681a05fcb8a81a054bbfc01a04b338ea1a04bb3fa81a054bf0621a061502f31a0615338a1a062057401a0615017e1a06153f0b1a061ce7b71a04b345ed1a06205c2c1a061745611a0612f1ee1a061511aa1a060243391a04b7d2b91a061e002c1a05fe7bd21a062068da1a062053831a0620530f1a061cf9211a06234db31a054bc7c81a061745861a061d61a11a04b7ccf01a04be82001a04bd9fa81a0612e71b1a0622d4ec1a05fe40ad1a061cba061a061d0afe1a062061991a06200fb41a05fcfbe71a05fe87ac1a0623c3e41a061b55841a061bd9691a054bbc981a062073841a061c8a9e1a05fe7ffc1a0615b5271a054bf0691a04b79eb31a054bbfc11a05fcf1c21a05fe7bd31a0603f5ab1a061508381a0568b30c1a060dae441a062352681a062377771a0622f03e1a061535df1a04b7d9751a04b82bcf1a062062701a05fe7a0d1a0615066d1a0615d8f41a06229a981a054b98e11a061ab57f1a062001341a0615be8f1a061babb91a06226dbf1a06206ac01a062051431a0605ab881a0614e49b1a06209c751a061c7f1d1a060996fa1a06206cbd1a061dc7e51a05fe45001a054bc7ce1a04b338dc1a061cad801a0612f40a1a0600ef231a062054ac1a05fcf6b71a054bb7a51a05fe40261a062294b71a061ccdc91a0612ef331a062051471a061c486d1a0618a73c1a061c7df21a0612e9d21a0615d3541a0568b30b1a0615bbe91a0612f40c1a061cdf5e1a054bcd3d1a061d63d51a05fe7a111a060996f71a061d508d1a05fe83ed1a0612e7071a061d3c371a06204c781a0615a4851a04bda8af1a062001321a062068dc1a054beb6e1a0615e8021a061744c01a06204fec1a05fcf4b41a062060651a05fe7ff91a04bd9fa61a06206ffd1a062055d51a062054601a06231f8f1a062050631a06205c9e1a061c01591a05fe89411a05fe862d1a060996f81a054be4fb1a06202d161a05fe459f1a04b7ccf41a054bb3761a04b7ccf71a0620767f1a061745841a061d107e1a04be71e91a05fe857e1a0623174a1a06204e251a05fe7de11a061b4ada1a0615c3b21a062050d41a05fe83f11a0612e7211a0617455c1a04c9bbf61a062071401a061864491a061c48671a06235d391a061745671a062292b51a060997101a0612efb01a06172b3b1a05fe7ffe1a061d7e121a061bd96a1a0612f10a1a061c486b1a05fe857b1a05fe41cf1a061c0e531a0614e80d1a062072ae1a062306dd1a04be82041a061ce5f51a054bbc8c1a0603267a1a0617455d1a05fe7b1c1a061c0e511a0612ecdb1a05fcffec1a0615cecb1a061b49d91a06180eeb1a062050651a061541741a0612ef641a04bb44bb1a061baeb11a0612e91c1a04bb60241a0623546b1a04b338d41a061db7481a05fe7a121a061bb4081a061dc5dc1a0614febe1a0616362c1a0600f2c61a061ab71a1a0615ad301a0616275f1a06200d361a061e4a511a062053061a062034bf1a0622f3d31a061c8a6d1a06204fa91a062354031a05fce5421a04bb44ab1a061b0c9f1a05fe7fff1a05fe7b191a06206d311a05fe84b71a062063011a060236111a0615b6981a062067521a06205cdc1a06206a241a054bc7ca1a061530d71a062306ce1a0623366a1a0615d7171a061744c71a04be777d1a0612ed141a0603cdca1a0615c41b1a06206a271a061bf2b81a061745471a05fe857d1a062051881a061c05911a0615ec471a061744bb1a061dc9c31a061c7dc01a0615e5941a06173b951a06160aad1a054bcd451a05fce6d51a061745451a05fcf0e61a060c42bf1a0620776d1a054bbc901a05fe7b1b1a06206eb81a06159db31a04b338e21a062306cc1a061622161a04c184621a061be6d71a054bdf251a0612ef341a0612eca61a06245f781a061ceb7e1a0614e8681a061efb901a06231b351a05fe7cf31a06204e241a061de3eb1a06206eb71a0615bec11a060997111a054bbfbb1a060997291a06205eda1a060996f61a06152d891a061c155e1a061db9bd1a060244e91a0612ed0d1a05fe84b11a06153cc01a0612e9881a04bda8b71a04b34dbb1a061ba4951a054bd7491a060da0931a04b64a361a05fe7f4d1a06200fb51a0613084b1a04b33f881a0615a0691a04bb31361a062379eb1a0609970f1a061acc041a0600e8511a054bb79a1a06204c7b1a0617ce4b1a061d4ce81a0612ebe61a0600d32a1a062319431a0616fa921a061d6f1b1a060996fb1a04b7ccf21a05fcf0a51a061b972c1a0615b0381a054bbfb81a05fe83ef1a04b7d32f1a061db1421a0612ecc11a05fe7f501a054bc3a41a061c7b171a06205acd1a06232b171a05fe811d1a04b7c1711a061d65291a06204c791a0615d02c1a04b7d3331a061c7f7b1a062025fc1a06220dda1a061596e11a0614c54c1a0612ecdf1a061542a31a062051421a06230a4b1a05fe7dde1a061e03c31a0620075a1a054b88151a052715d31a062053851a061d086c1a0612e7a51a0612efa21a06204e8a1a06203b6e1a062021f91a0620727f1a05fe87aa1a0612ec1e1a052304161a06230bb71a0612ec181a061c679b1a062054ed1a0617457b1a05fcb4391a0614f55f1a05fe87ae1a062279bb1a05fe7a101a04bb31331a0622f0381a061ccdf01a0568cb951a05fe7b1a1a0622161f1a0620713d1a060239c91a0620626f1a061548771a062295f71a061c28d61a063bf37f821906a8804700354000000000 \ No newline at end of file diff --git a/fil_actor_decoder/tests/snapshots/datacap_v11__mainnet_increase_allowance_params.snap b/fil_actor_decoder/tests/snapshots/datacap_v11__mainnet_increase_allowance_params.snap new file mode 100644 index 00000000..bef34c4e --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/datacap_v11__mainnet_increase_allowance_params.snap @@ -0,0 +1,8 @@ +--- +source: fil_actor_decoder/tests/datacap_v11.rs +expression: "decode_params(A, V, 1777121560, &decode_hex(hex)).unwrap()" +--- +{ + "increase": "34359738368000000000000000000", + "operator": "f1sfs2m6uvdn3zlzn4zchtmytsda3escmf3xiamty" +} diff --git a/fil_actor_decoder/tests/snapshots/datacap_v11__mainnet_increase_allowance_return.snap b/fil_actor_decoder/tests/snapshots/datacap_v11__mainnet_increase_allowance_return.snap new file mode 100644 index 00000000..cfd3b77d --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/datacap_v11__mainnet_increase_allowance_return.snap @@ -0,0 +1,7 @@ +--- +source: fil_actor_decoder/tests/datacap_v11.rs +expression: "decode_return(A, V, 1777121560, &decode_hex(hex)).unwrap()" +--- +{ + "allowance": "34359738368000000000000000000" +} diff --git a/fil_actor_decoder/tests/snapshots/datacap_v12__mainnet_transfer_params.snap b/fil_actor_decoder/tests/snapshots/datacap_v12__mainnet_transfer_params.snap new file mode 100644 index 00000000..79a448bd --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/datacap_v12__mainnet_transfer_params.snap @@ -0,0 +1,45 @@ +--- +source: fil_actor_decoder/tests/datacap_v12.rs +expression: "decode_params(A, V, 80475954, &decode_hex(hex)).unwrap()" +--- +{ + "amount": "137438953472000000000000000000", + "operator_data": { + "allocations": [ + { + "data": "baga6ea4seaqltgksfrd5op2g343d33ufxmyhns75lt3fcccucplgdw2mdlcuini", + "expiration": 3962799, + "provider": 3081864, + "size": 34359738368, + "term_max": 5256000, + "term_min": 1051200 + }, + { + "data": "baga6ea4seaqhnsg5yrwr7a6233c763jupgie43slu6nmal25lp7b6zjvzub3eay", + "expiration": 3962799, + "provider": 3081864, + "size": 34359738368, + "term_max": 5256000, + "term_min": 1051200 + }, + { + "data": "baga6ea4seaqhkrurwiid7hdnbletxdfukorgtaktjfavijz656757qjarytgibi", + "expiration": 3962799, + "provider": 3081864, + "size": 34359738368, + "term_max": 5256000, + "term_min": 1051200 + }, + { + "data": "baga6ea4seaqmx4fpwqggcvk2isigcpc5gogcu25uetm4dnecxfxxo6ttsnu6yla", + "expiration": 3962799, + "provider": 3081864, + "size": 34359738368, + "term_max": 5256000, + "term_min": 1051200 + } + ], + "extensions": [] + }, + "to": "f06" +} diff --git a/fil_actor_decoder/tests/snapshots/datacap_v12__mainnet_transfer_return.snap b/fil_actor_decoder/tests/snapshots/datacap_v12__mainnet_transfer_return.snap new file mode 100644 index 00000000..394de52a --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/datacap_v12__mainnet_transfer_return.snap @@ -0,0 +1,24 @@ +--- +source: fil_actor_decoder/tests/datacap_v12.rs +expression: "decode_return(A, V, 80475954, &decode_hex(hex)).unwrap()" +--- +{ + "from_balance": "1104390710624256000000000000000000", + "recipient_data": { + "allocation_results": { + "fail_codes": [], + "success_count": 4 + }, + "extension_results": { + "fail_codes": [], + "success_count": 0 + }, + "new_allocations": [ + 63596850, + 63596851, + 63596852, + 63596853 + ] + }, + "to_balance": "26000261793185792000000000000000000" +} diff --git a/fil_actor_decoder/tests/snapshots/datacap_v13__mainnet_transfer_params.snap b/fil_actor_decoder/tests/snapshots/datacap_v13__mainnet_transfer_params.snap new file mode 100644 index 00000000..75278f50 --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/datacap_v13__mainnet_transfer_params.snap @@ -0,0 +1,53 @@ +--- +source: fil_actor_decoder/tests/datacap_v13.rs +expression: "decode_params(A, V, 80475954, &decode_hex(hex)).unwrap()" +--- +{ + "amount": "171798691840000000000000000000", + "operator_data": { + "allocations": [ + { + "data": "baga6ea4seaqc5e4rug43e3zpylwgajagiqx3c5tddo7enupkcj25pglcn6hxska", + "expiration": 4159271, + "provider": 3161261, + "size": 34359738368, + "term_max": 777600, + "term_min": 518400 + }, + { + "data": "baga6ea4seaqbj6csufrfptubovfxc5pf7xxsfxhfg722zddvb2ky7llbreyboii", + "expiration": 4159275, + "provider": 3161261, + "size": 34359738368, + "term_max": 777600, + "term_min": 518400 + }, + { + "data": "baga6ea4seaqpa6tvklzl4cay2cmg2db7cpthvrtahccpht6fv2vgtan3yadf2by", + "expiration": 4159283, + "provider": 3161261, + "size": 34359738368, + "term_max": 777600, + "term_min": 518400 + }, + { + "data": "baga6ea4seaqg23htt42veuoctopx6czaqrybmnac7od62m5qellh4wsqmalpsii", + "expiration": 4159287, + "provider": 3161261, + "size": 34359738368, + "term_max": 777600, + "term_min": 518400 + }, + { + "data": "baga6ea4seaqlpcgy2kg55hjm23yyu2yux7jk4vvjs5nfhzkfsqon7szq4xvrqay", + "expiration": 4159287, + "provider": 3161261, + "size": 34359738368, + "term_max": 777600, + "term_min": 518400 + } + ], + "extensions": [] + }, + "to": "f06" +} diff --git a/fil_actor_decoder/tests/snapshots/datacap_v13__mainnet_transfer_return.snap b/fil_actor_decoder/tests/snapshots/datacap_v13__mainnet_transfer_return.snap new file mode 100644 index 00000000..2334a6e8 --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/datacap_v13__mainnet_transfer_return.snap @@ -0,0 +1,25 @@ +--- +source: fil_actor_decoder/tests/datacap_v13.rs +expression: "decode_return(A, V, 80475954, &decode_hex(hex)).unwrap()" +--- +{ + "from_balance": "830474876354560000000000000000000", + "recipient_data": { + "allocation_results": { + "fail_codes": [], + "success_count": 5 + }, + "extension_results": { + "fail_codes": [], + "success_count": 0 + }, + "new_allocations": [ + 70555125, + 70555126, + 70555127, + 70555128, + 70555129 + ] + }, + "to_balance": "23624185883858632000000000000000000" +} diff --git a/fil_actor_decoder/tests/snapshots/datacap_v14__mainnet_transfer_params.snap b/fil_actor_decoder/tests/snapshots/datacap_v14__mainnet_transfer_params.snap new file mode 100644 index 00000000..329d983a --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/datacap_v14__mainnet_transfer_params.snap @@ -0,0 +1,21 @@ +--- +source: fil_actor_decoder/tests/datacap_v14.rs +expression: "decode_params(A, V, 80475954, &decode_hex(hex)).unwrap()" +--- +{ + "amount": "34359738368000000000000000000", + "operator_data": { + "allocations": [ + { + "data": "baga6ea4seaqhbeyf6mjkmyzdyfftkniyalc4643bqe64pfbxfx4j4o3gh5zjihq", + "expiration": 4477386, + "provider": 3175168, + "size": 34359738368, + "term_max": 5256000, + "term_min": 518400 + } + ], + "extensions": [] + }, + "to": "f06" +} diff --git a/fil_actor_decoder/tests/snapshots/datacap_v14__mainnet_transfer_return.snap b/fil_actor_decoder/tests/snapshots/datacap_v14__mainnet_transfer_return.snap new file mode 100644 index 00000000..39c66159 --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/datacap_v14__mainnet_transfer_return.snap @@ -0,0 +1,21 @@ +--- +source: fil_actor_decoder/tests/datacap_v14.rs +expression: "decode_return(A, V, 80475954, &decode_hex(hex)).unwrap()" +--- +{ + "from_balance": "467910917095424000000000000000000", + "recipient_data": { + "allocation_results": { + "fail_codes": [], + "success_count": 1 + }, + "extension_results": { + "fail_codes": [], + "success_count": 0 + }, + "new_allocations": [ + 82077108 + ] + }, + "to_balance": "24952283093649915000000000000000000" +} diff --git a/fil_actor_decoder/tests/snapshots/datacap_v15__mainnet_transfer_from_params.snap b/fil_actor_decoder/tests/snapshots/datacap_v15__mainnet_transfer_from_params.snap new file mode 100644 index 00000000..fda8aff9 --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/datacap_v15__mainnet_transfer_from_params.snap @@ -0,0 +1,134 @@ +--- +source: fil_actor_decoder/tests/datacap_v15.rs +expression: "decode_params(A, V, 3621052141, &decode_hex(hex.trim())).unwrap()" +--- +{ + "amount": "515396075520000000000000000000", + "from": "f03514634", + "operator_data": { + "allocations": [ + { + "data": "baga6ea4seaqftajtrw2b2vvmctxyywontk3cdb2clqnhiwx4ccr2udbxhzbu6cq", + "expiration": 5593970, + "provider": 3276663, + "size": 34359738368, + "term_max": 5256000, + "term_min": 518400 + }, + { + "data": "baga6ea4seaqh6w6kr7fovwjjcyxbjhukjuvuxbfyccd4cc7xtradtz3urhwq6gq", + "expiration": 5593970, + "provider": 3276663, + "size": 34359738368, + "term_max": 5256000, + "term_min": 518400 + }, + { + "data": "baga6ea4seaqpo2c3c27m3plxaj3xi6bduhvbcmin2euuzlaboxrgm2mmwbwnkhi", + "expiration": 5593974, + "provider": 3276663, + "size": 34359738368, + "term_max": 5256000, + "term_min": 518400 + }, + { + "data": "baga6ea4seaqkxqyuzxqzpsazzmaapstmcsprfhululzrf6bp4p7k47gdstsusmy", + "expiration": 5593974, + "provider": 3276663, + "size": 34359738368, + "term_max": 5256000, + "term_min": 518400 + }, + { + "data": "baga6ea4seaqi72bwiigzer4pkkfpa3appdugzhmrv746b7ojhn7iy6u7nfbcgpy", + "expiration": 5593974, + "provider": 3276663, + "size": 34359738368, + "term_max": 5256000, + "term_min": 518400 + }, + { + "data": "baga6ea4seaqh3gw7xmoqo43lij65py6q7ctvkj4vptmfiivrgi4pcyvpkkh4uma", + "expiration": 5593978, + "provider": 3276663, + "size": 34359738368, + "term_max": 5256000, + "term_min": 518400 + }, + { + "data": "baga6ea4seaqmhqvvhhzkqwf27neruelfgb3k5x5vmk6czhbaljmkfxul4s4fmga", + "expiration": 5593978, + "provider": 3276663, + "size": 34359738368, + "term_max": 5256000, + "term_min": 518400 + }, + { + "data": "baga6ea4seaqdla5ujc364x7t7ficxe73cfz3tgungek5kwn7mxygc5copbfaudy", + "expiration": 5593978, + "provider": 3276663, + "size": 34359738368, + "term_max": 5256000, + "term_min": 518400 + }, + { + "data": "baga6ea4seaqpo2c3c27m3plxaj3xi6bduhvbcmin2euuzlaboxrgm2mmwbwnkhi", + "expiration": 5593983, + "provider": 3276663, + "size": 34359738368, + "term_max": 5256000, + "term_min": 518400 + }, + { + "data": "baga6ea4seaqf6joab7ljyrpcijvi4r2eaxcrcjhkkfbhhsxuwcnevomuieniyoq", + "expiration": 5593983, + "provider": 3276663, + "size": 34359738368, + "term_max": 5256000, + "term_min": 518400 + }, + { + "data": "baga6ea4seaqpijcam663xifoitpazyh5vf6m32gth7qaochxmczhc37s7mkraeq", + "expiration": 5593983, + "provider": 3276663, + "size": 34359738368, + "term_max": 5256000, + "term_min": 518400 + }, + { + "data": "baga6ea4seaqdh4dj3aiyrmmajuwuiq4cohyolxxv2peoskniwknmnrgbeip2adi", + "expiration": 5593987, + "provider": 3276663, + "size": 34359738368, + "term_max": 5256000, + "term_min": 518400 + }, + { + "data": "baga6ea4seaqftajtrw2b2vvmctxyywontk3cdb2clqnhiwx4ccr2udbxhzbu6cq", + "expiration": 5593987, + "provider": 3276663, + "size": 34359738368, + "term_max": 5256000, + "term_min": 518400 + }, + { + "data": "baga6ea4seaqi72bwiigzer4pkkfpa3appdugzhmrv746b7ojhn7iy6u7nfbcgpy", + "expiration": 5593987, + "provider": 3276663, + "size": 34359738368, + "term_max": 5256000, + "term_min": 518400 + }, + { + "data": "baga6ea4seaqmhqvvhhzkqwf27neruelfgb3k5x5vmk6czhbaljmkfxul4s4fmga", + "expiration": 5593989, + "provider": 3276663, + "size": 34359738368, + "term_max": 5256000, + "term_min": 518400 + } + ], + "extensions": [] + }, + "to": "f06" +} diff --git a/fil_actor_decoder/tests/snapshots/datacap_v15__mainnet_transfer_from_return.snap b/fil_actor_decoder/tests/snapshots/datacap_v15__mainnet_transfer_from_return.snap new file mode 100644 index 00000000..bb2c6e04 --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/datacap_v15__mainnet_transfer_from_return.snap @@ -0,0 +1,10 @@ +--- +source: fil_actor_decoder/tests/datacap_v15.rs +expression: "decode_return(A, V, 3621052141, &decode_hex(hex)).unwrap()" +--- +{ + "allowance": "48645264235626496000000000000000000", + "from_balance": "180609903147090000000000000000000", + "recipient_data": "g4IPgIIAgIkaBTBuRxoFMG5IGgUwbkkaBTBuShoFMG5LGgUwbkwaBTBuTRoFMG5OGgUwbk8aBTBuUBoFMG5RGgUwblIaBTBuUxoFMG5UGgUwblU=", + "to_balance": "35132390374703532000000000000000000" +} diff --git a/fil_actor_decoder/tests/snapshots/datacap_v16__balance_params.snap b/fil_actor_decoder/tests/snapshots/datacap_v16__balance_params.snap new file mode 100644 index 00000000..ab58c23b --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/datacap_v16__balance_params.snap @@ -0,0 +1,5 @@ +--- +source: fil_actor_decoder/tests/datacap_v16.rs +expression: "decode_params(A, V, frc42_dispatch::method_hash!(\"Balance\"),\n&to_vec(&p).unwrap()).unwrap()" +--- +"f042" diff --git a/fil_actor_decoder/tests/snapshots/datacap_v16__burn_params.snap b/fil_actor_decoder/tests/snapshots/datacap_v16__burn_params.snap new file mode 100644 index 00000000..e07891cf --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/datacap_v16__burn_params.snap @@ -0,0 +1,7 @@ +--- +source: fil_actor_decoder/tests/datacap_v16.rs +expression: "decode_params(A, V, frc42_dispatch::method_hash!(\"Burn\"),\n&to_vec(&p).unwrap()).unwrap()" +--- +{ + "amount": "50000000000000000000" +} diff --git a/fil_actor_decoder/tests/snapshots/datacap_v16__destroy_params.snap b/fil_actor_decoder/tests/snapshots/datacap_v16__destroy_params.snap new file mode 100644 index 00000000..4859e1f5 --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/datacap_v16__destroy_params.snap @@ -0,0 +1,8 @@ +--- +source: fil_actor_decoder/tests/datacap_v16.rs +expression: "decode_params(A, V, frc42_dispatch::method_hash!(\"Destroy\"),\n&to_vec(&p).unwrap()).unwrap()" +--- +{ + "amount": "500", + "owner": "f0100" +} diff --git a/fil_actor_decoder/tests/snapshots/datacap_v16__granularity_return.snap b/fil_actor_decoder/tests/snapshots/datacap_v16__granularity_return.snap new file mode 100644 index 00000000..ef65df67 --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/datacap_v16__granularity_return.snap @@ -0,0 +1,5 @@ +--- +source: fil_actor_decoder/tests/datacap_v16.rs +expression: "decode_return(A, V, frc42_dispatch::method_hash!(\"Granularity\"),\n&to_vec(&r).unwrap()).unwrap()" +--- +1000000000000000000 diff --git a/fil_actor_decoder/tests/snapshots/datacap_v16__mint_params.snap b/fil_actor_decoder/tests/snapshots/datacap_v16__mint_params.snap new file mode 100644 index 00000000..f87c9ad1 --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/datacap_v16__mint_params.snap @@ -0,0 +1,11 @@ +--- +source: fil_actor_decoder/tests/datacap_v16.rs +expression: "decode_params(A, V, frc42_dispatch::method_hash!(\"Mint\"),\n&to_vec(&p).unwrap()).unwrap()" +--- +{ + "amount": "1000000000000000000", + "operators": [ + "f05678" + ], + "to": "f01234" +} diff --git a/fil_actor_decoder/tests/snapshots/datacap_v16__name_return.snap b/fil_actor_decoder/tests/snapshots/datacap_v16__name_return.snap new file mode 100644 index 00000000..ebda2a58 --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/datacap_v16__name_return.snap @@ -0,0 +1,5 @@ +--- +source: fil_actor_decoder/tests/datacap_v16.rs +expression: "decode_return(A, V, frc42_dispatch::method_hash!(\"Name\"),\n&to_vec(&r).unwrap()).unwrap()" +--- +"DataCap" diff --git a/fil_actor_decoder/tests/snapshots/datacap_v16__transfer_params.snap b/fil_actor_decoder/tests/snapshots/datacap_v16__transfer_params.snap new file mode 100644 index 00000000..19bcd98e --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/datacap_v16__transfer_params.snap @@ -0,0 +1,9 @@ +--- +source: fil_actor_decoder/tests/datacap_v16.rs +expression: "decode_params(A, V, frc42_dispatch::method_hash!(\"Transfer\"),\n&to_vec(&p).unwrap()).unwrap()" +--- +{ + "amount": "100000000000000000000", + "operator_data": "", + "to": "f01000" +} diff --git a/fil_actor_decoder/tests/snapshots/datacap_v17__allowance_params.snap b/fil_actor_decoder/tests/snapshots/datacap_v17__allowance_params.snap new file mode 100644 index 00000000..1315291b --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/datacap_v17__allowance_params.snap @@ -0,0 +1,8 @@ +--- +source: fil_actor_decoder/tests/datacap_v17.rs +expression: "decode_params(A, V, frc42_dispatch::method_hash!(\"Allowance\"),\n&to_vec(&p).unwrap()).unwrap()" +--- +{ + "operator": "f0300", + "owner": "f0100" +} diff --git a/fil_actor_decoder/tests/snapshots/datacap_v17__balance_params.snap b/fil_actor_decoder/tests/snapshots/datacap_v17__balance_params.snap new file mode 100644 index 00000000..cd065507 --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/datacap_v17__balance_params.snap @@ -0,0 +1,5 @@ +--- +source: fil_actor_decoder/tests/datacap_v17.rs +expression: "decode_params(A, V, frc42_dispatch::method_hash!(\"Balance\"),\n&to_vec(&p).unwrap()).unwrap()" +--- +"f042" diff --git a/fil_actor_decoder/tests/snapshots/datacap_v17__balance_return.snap b/fil_actor_decoder/tests/snapshots/datacap_v17__balance_return.snap new file mode 100644 index 00000000..ef10f628 --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/datacap_v17__balance_return.snap @@ -0,0 +1,5 @@ +--- +source: fil_actor_decoder/tests/datacap_v17.rs +expression: "decode_return(A, V, frc42_dispatch::method_hash!(\"Balance\"),\n&to_vec(&r).unwrap()).unwrap()" +--- +"5000000000000000000" diff --git a/fil_actor_decoder/tests/snapshots/datacap_v17__burn_from_params.snap b/fil_actor_decoder/tests/snapshots/datacap_v17__burn_from_params.snap new file mode 100644 index 00000000..48b69f8c --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/datacap_v17__burn_from_params.snap @@ -0,0 +1,8 @@ +--- +source: fil_actor_decoder/tests/datacap_v17.rs +expression: "decode_params(A, V, frc42_dispatch::method_hash!(\"BurnFrom\"),\n&to_vec(&p).unwrap()).unwrap()" +--- +{ + "amount": "25000000000000000000", + "owner": "f0200" +} diff --git a/fil_actor_decoder/tests/snapshots/datacap_v17__burn_params.snap b/fil_actor_decoder/tests/snapshots/datacap_v17__burn_params.snap new file mode 100644 index 00000000..a1018373 --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/datacap_v17__burn_params.snap @@ -0,0 +1,7 @@ +--- +source: fil_actor_decoder/tests/datacap_v17.rs +expression: "decode_params(A, V, frc42_dispatch::method_hash!(\"Burn\"),\n&to_vec(&p).unwrap()).unwrap()" +--- +{ + "amount": "50000000000000000000" +} diff --git a/fil_actor_decoder/tests/snapshots/datacap_v17__constructor_params.snap b/fil_actor_decoder/tests/snapshots/datacap_v17__constructor_params.snap new file mode 100644 index 00000000..8448745b --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/datacap_v17__constructor_params.snap @@ -0,0 +1,5 @@ +--- +source: fil_actor_decoder/tests/datacap_v17.rs +expression: "decode_params(A, V, 1, &to_vec(&p).unwrap()).unwrap()" +--- +"f090" diff --git a/fil_actor_decoder/tests/snapshots/datacap_v17__decrease_allowance_params.snap b/fil_actor_decoder/tests/snapshots/datacap_v17__decrease_allowance_params.snap new file mode 100644 index 00000000..bb07cd16 --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/datacap_v17__decrease_allowance_params.snap @@ -0,0 +1,8 @@ +--- +source: fil_actor_decoder/tests/datacap_v17.rs +expression: "decode_params(A, V, frc42_dispatch::method_hash!(\"DecreaseAllowance\"),\n&to_vec(&p).unwrap()).unwrap()" +--- +{ + "decrease": "5000000000000000000", + "operator": "f0300" +} diff --git a/fil_actor_decoder/tests/snapshots/datacap_v17__destroy_params.snap b/fil_actor_decoder/tests/snapshots/datacap_v17__destroy_params.snap new file mode 100644 index 00000000..e1e9ef62 --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/datacap_v17__destroy_params.snap @@ -0,0 +1,8 @@ +--- +source: fil_actor_decoder/tests/datacap_v17.rs +expression: "decode_params(A, V, frc42_dispatch::method_hash!(\"Destroy\"),\n&to_vec(&p).unwrap()).unwrap()" +--- +{ + "amount": "500", + "owner": "f0100" +} diff --git a/fil_actor_decoder/tests/snapshots/datacap_v17__granularity_return.snap b/fil_actor_decoder/tests/snapshots/datacap_v17__granularity_return.snap new file mode 100644 index 00000000..244d094e --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/datacap_v17__granularity_return.snap @@ -0,0 +1,5 @@ +--- +source: fil_actor_decoder/tests/datacap_v17.rs +expression: "decode_return(A, V, frc42_dispatch::method_hash!(\"Granularity\"),\n&to_vec(&r).unwrap()).unwrap()" +--- +1000000000000000000 diff --git a/fil_actor_decoder/tests/snapshots/datacap_v17__increase_allowance_params.snap b/fil_actor_decoder/tests/snapshots/datacap_v17__increase_allowance_params.snap new file mode 100644 index 00000000..d2f80f0b --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/datacap_v17__increase_allowance_params.snap @@ -0,0 +1,8 @@ +--- +source: fil_actor_decoder/tests/datacap_v17.rs +expression: "decode_params(A, V, frc42_dispatch::method_hash!(\"IncreaseAllowance\"),\n&to_vec(&p).unwrap()).unwrap()" +--- +{ + "increase": "10000000000000000000", + "operator": "f0300" +} diff --git a/fil_actor_decoder/tests/snapshots/datacap_v17__mainnet_transfer_from_params.snap b/fil_actor_decoder/tests/snapshots/datacap_v17__mainnet_transfer_from_params.snap new file mode 100644 index 00000000..51fa36a5 --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/datacap_v17__mainnet_transfer_from_params.snap @@ -0,0 +1,86 @@ +--- +source: fil_actor_decoder/tests/datacap_v17.rs +expression: result +--- +{ + "amount": "309237645312000000000000000000", + "from": "f03535091", + "operator_data": { + "allocations": [ + { + "data": "baga6ea4seaqj4dqorep36qkzjx2c4omvnczzkulfopolwoqryvkrxcztb5paqmi", + "expiration": 6006319, + "provider": 3741653, + "size": 34359738368, + "term_max": 5256000, + "term_min": 518400 + }, + { + "data": "baga6ea4seaqkxr3mytnr232yhfirij6odvomtp5cu5gxss6ijg5nwmvmpn2zqfa", + "expiration": 6006322, + "provider": 3741653, + "size": 34359738368, + "term_max": 5256000, + "term_min": 518400 + }, + { + "data": "baga6ea4seaqj3zxhywznsarwigow4uriheropwubb5t67dximq52trr6s6jvkai", + "expiration": 6006326, + "provider": 3741653, + "size": 34359738368, + "term_max": 5256000, + "term_min": 518400 + }, + { + "data": "baga6ea4seaqbk3tzfocymsfgexvfw6a342p2e7llch46ful2sd6hqiixl5liufy", + "expiration": 6006330, + "provider": 3741653, + "size": 34359738368, + "term_max": 5256000, + "term_min": 518400 + }, + { + "data": "baga6ea4seaqc7exbwjty4ok7j2w2z3q35izwfzgfsk76fakddv44zt5p5tuxcmi", + "expiration": 6006330, + "provider": 3741653, + "size": 34359738368, + "term_max": 5256000, + "term_min": 518400 + }, + { + "data": "baga6ea4seaqlqhr32ftn55a5njhhfwhel3e6hqekjyma3ei2bsbekgrxbiijinq", + "expiration": 6006332, + "provider": 3741653, + "size": 34359738368, + "term_max": 5256000, + "term_min": 518400 + }, + { + "data": "baga6ea4seaqduzz7vwgjuakdzarji24tt7kr5f2znb6k3hu5vaayjr6pi5s4qbq", + "expiration": 6006337, + "provider": 3741653, + "size": 34359738368, + "term_max": 5256000, + "term_min": 518400 + }, + { + "data": "baga6ea4seaqkxkq4pstgtwqvcbxi5bbnxhg3khd7bqyt2uyz3ggp2ptzvlaygjq", + "expiration": 6006338, + "provider": 3741653, + "size": 34359738368, + "term_max": 5256000, + "term_min": 518400 + }, + { + "data": "baga6ea4seaqjtqw26h4vra3cp5lqvkizpxfpbwyxzq52gbbk6jwcdftvjxedqhi", + "expiration": 6006338, + "provider": 3741653, + "size": 34359738368, + "term_max": 5256000, + "term_min": 518400 + } + ], + "extensions": [] + }, + "to": "f06" +} diff --git a/fil_actor_decoder/tests/snapshots/datacap_v17__mainnet_transfer_from_return.snap b/fil_actor_decoder/tests/snapshots/datacap_v17__mainnet_transfer_from_return.snap new file mode 100644 index 00000000..9715905a --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/datacap_v17__mainnet_transfer_from_return.snap @@ -0,0 +1,30 @@ +--- +source: fil_actor_decoder/tests/datacap_v17.rs +expression: result +--- +{ + "allowance": "501549100957696000000000000000000", + "from_balance": "880133288230912000000000000000000", + "recipient_data": { + "allocation_results": { + "fail_codes": [], + "success_count": 9 + }, + "extension_results": { + "fail_codes": [], + "success_count": 0 + }, + "new_allocations": [ + 123970025, + 123970026, + 123970027, + 123970028, + 123970029, + 123970030, + 123970031, + 123970032, + 123970033 + ] + }, + "to_balance": "44818898744918762000000000000000000" +} diff --git a/fil_actor_decoder/tests/snapshots/datacap_v17__mint_params.snap b/fil_actor_decoder/tests/snapshots/datacap_v17__mint_params.snap new file mode 100644 index 00000000..093b0e0c --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/datacap_v17__mint_params.snap @@ -0,0 +1,11 @@ +--- +source: fil_actor_decoder/tests/datacap_v17.rs +expression: "decode_params(A, V, frc42_dispatch::method_hash!(\"Mint\"),\n&to_vec(&p).unwrap()).unwrap()" +--- +{ + "amount": "1000000000000000000", + "operators": [ + "f05678" + ], + "to": "f01234" +} diff --git a/fil_actor_decoder/tests/snapshots/datacap_v17__name_return.snap b/fil_actor_decoder/tests/snapshots/datacap_v17__name_return.snap new file mode 100644 index 00000000..0fa96bce --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/datacap_v17__name_return.snap @@ -0,0 +1,5 @@ +--- +source: fil_actor_decoder/tests/datacap_v17.rs +expression: "decode_return(A, V, frc42_dispatch::method_hash!(\"Name\"),\n&to_vec(&r).unwrap()).unwrap()" +--- +"DataCap" diff --git a/fil_actor_decoder/tests/snapshots/datacap_v17__revoke_allowance_params.snap b/fil_actor_decoder/tests/snapshots/datacap_v17__revoke_allowance_params.snap new file mode 100644 index 00000000..ea1979fa --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/datacap_v17__revoke_allowance_params.snap @@ -0,0 +1,7 @@ +--- +source: fil_actor_decoder/tests/datacap_v17.rs +expression: "decode_params(A, V, frc42_dispatch::method_hash!(\"RevokeAllowance\"),\n&to_vec(&p).unwrap()).unwrap()" +--- +{ + "operator": "f0300" +} diff --git a/fil_actor_decoder/tests/snapshots/datacap_v17__symbol_return.snap b/fil_actor_decoder/tests/snapshots/datacap_v17__symbol_return.snap new file mode 100644 index 00000000..1d27464d --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/datacap_v17__symbol_return.snap @@ -0,0 +1,5 @@ +--- +source: fil_actor_decoder/tests/datacap_v17.rs +expression: "decode_return(A, V, frc42_dispatch::method_hash!(\"Symbol\"),\n&to_vec(&r).unwrap()).unwrap()" +--- +"DCAP" diff --git a/fil_actor_decoder/tests/snapshots/datacap_v17__total_supply_return.snap b/fil_actor_decoder/tests/snapshots/datacap_v17__total_supply_return.snap new file mode 100644 index 00000000..a24062b2 --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/datacap_v17__total_supply_return.snap @@ -0,0 +1,5 @@ +--- +source: fil_actor_decoder/tests/datacap_v17.rs +expression: "decode_return(A, V, frc42_dispatch::method_hash!(\"TotalSupply\"),\n&to_vec(&r).unwrap()).unwrap()" +--- +"800000000000000000000000" diff --git a/fil_actor_decoder/tests/snapshots/datacap_v17__transfer_params.snap b/fil_actor_decoder/tests/snapshots/datacap_v17__transfer_params.snap new file mode 100644 index 00000000..3b53e6f9 --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/datacap_v17__transfer_params.snap @@ -0,0 +1,9 @@ +--- +source: fil_actor_decoder/tests/datacap_v17.rs +expression: "decode_params(A, V, frc42_dispatch::method_hash!(\"Transfer\"),\n&to_vec(&p).unwrap()).unwrap()" +--- +{ + "amount": "100000000000000000000", + "operator_data": "", + "to": "f01000" +} diff --git a/fil_actor_decoder/tests/snapshots/verifreg_v10__mainnet_add_verified_client_params.snap b/fil_actor_decoder/tests/snapshots/verifreg_v10__mainnet_add_verified_client_params.snap new file mode 100644 index 00000000..1dea603a --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/verifreg_v10__mainnet_add_verified_client_params.snap @@ -0,0 +1,8 @@ +--- +source: fil_actor_decoder/tests/verifreg_v10.rs +expression: "decode_params(A, V, 4, &decode_hex(hex)).unwrap()" +--- +{ + "address": "f1wfecoxsahxrpynnlnvm6qyp3y2uky375naanqzi", + "allowance": "34359738368" +} diff --git a/fil_actor_decoder/tests/snapshots/verifreg_v10__mainnet_extend_claim_terms_return.snap b/fil_actor_decoder/tests/snapshots/verifreg_v10__mainnet_extend_claim_terms_return.snap new file mode 100644 index 00000000..792c6489 --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/verifreg_v10__mainnet_extend_claim_terms_return.snap @@ -0,0 +1,8 @@ +--- +source: fil_actor_decoder/tests/verifreg_v10.rs +expression: "decode_return(A, V, 11, &decode_hex(hex)).unwrap()" +--- +{ + "fail_codes": [], + "success_count": 188 +} diff --git a/fil_actor_decoder/tests/snapshots/verifreg_v11__mainnet_add_verified_client_params.snap b/fil_actor_decoder/tests/snapshots/verifreg_v11__mainnet_add_verified_client_params.snap new file mode 100644 index 00000000..414c2359 --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/verifreg_v11__mainnet_add_verified_client_params.snap @@ -0,0 +1,8 @@ +--- +source: fil_actor_decoder/tests/verifreg_v11.rs +expression: "decode_params(A, V, 4, &decode_hex(hex)).unwrap()" +--- +{ + "address": "f3vgbksz76yqg2qlrad7aeua5z3zkjjo2yswfc6qp33rm7iwit443fvwx55a2jyy4tap54r7gqm3ytradtmdjq", + "allowance": "34359738368" +} diff --git a/fil_actor_decoder/tests/snapshots/verifreg_v11__mainnet_extend_claim_terms_return.snap b/fil_actor_decoder/tests/snapshots/verifreg_v11__mainnet_extend_claim_terms_return.snap new file mode 100644 index 00000000..8dd994fe --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/verifreg_v11__mainnet_extend_claim_terms_return.snap @@ -0,0 +1,8 @@ +--- +source: fil_actor_decoder/tests/verifreg_v11.rs +expression: "decode_return(A, V, 11, &decode_hex(hex)).unwrap()" +--- +{ + "fail_codes": [], + "success_count": 309 +} diff --git a/fil_actor_decoder/tests/snapshots/verifreg_v12__mainnet_extend_claim_terms_return.snap b/fil_actor_decoder/tests/snapshots/verifreg_v12__mainnet_extend_claim_terms_return.snap new file mode 100644 index 00000000..b9a98874 --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/verifreg_v12__mainnet_extend_claim_terms_return.snap @@ -0,0 +1,8 @@ +--- +source: fil_actor_decoder/tests/verifreg_v12.rs +expression: "decode_return(A, V, 11, &decode_hex(hex)).unwrap()" +--- +{ + "fail_codes": [], + "success_count": 400 +} diff --git a/fil_actor_decoder/tests/snapshots/verifreg_v13__mainnet_extend_claim_terms_return.snap b/fil_actor_decoder/tests/snapshots/verifreg_v13__mainnet_extend_claim_terms_return.snap new file mode 100644 index 00000000..ebc38d38 --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/verifreg_v13__mainnet_extend_claim_terms_return.snap @@ -0,0 +1,8 @@ +--- +source: fil_actor_decoder/tests/verifreg_v13.rs +expression: "decode_return(A, V, 11, &decode_hex(hex)).unwrap()" +--- +{ + "fail_codes": [], + "success_count": 200 +} diff --git a/fil_actor_decoder/tests/snapshots/verifreg_v14__mainnet_extend_claim_terms_return.snap b/fil_actor_decoder/tests/snapshots/verifreg_v14__mainnet_extend_claim_terms_return.snap new file mode 100644 index 00000000..760c08aa --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/verifreg_v14__mainnet_extend_claim_terms_return.snap @@ -0,0 +1,8 @@ +--- +source: fil_actor_decoder/tests/verifreg_v14.rs +expression: "decode_return(A, V, 11, &decode_hex(hex)).unwrap()" +--- +{ + "fail_codes": [], + "success_count": 200 +} diff --git a/fil_actor_decoder/tests/snapshots/verifreg_v15__mainnet_extend_claim_terms_return.snap b/fil_actor_decoder/tests/snapshots/verifreg_v15__mainnet_extend_claim_terms_return.snap new file mode 100644 index 00000000..3fdce048 --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/verifreg_v15__mainnet_extend_claim_terms_return.snap @@ -0,0 +1,8 @@ +--- +source: fil_actor_decoder/tests/verifreg_v15.rs +expression: "decode_return(A, V, 11, &decode_hex(hex)).unwrap()" +--- +{ + "fail_codes": [], + "success_count": 600 +} diff --git a/fil_actor_decoder/tests/snapshots/verifreg_v16__add_verified_client_params.snap b/fil_actor_decoder/tests/snapshots/verifreg_v16__add_verified_client_params.snap new file mode 100644 index 00000000..9f13edcf --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/verifreg_v16__add_verified_client_params.snap @@ -0,0 +1,8 @@ +--- +source: fil_actor_decoder/tests/verifreg_v16.rs +expression: "decode_params(A, V, 4, &to_vec(&p).unwrap()).unwrap()" +--- +{ + "address": "f01000", + "allowance": "5000000" +} diff --git a/fil_actor_decoder/tests/snapshots/verifreg_v16__claim_allocations_params.snap b/fil_actor_decoder/tests/snapshots/verifreg_v16__claim_allocations_params.snap new file mode 100644 index 00000000..e482a2f3 --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/verifreg_v16__claim_allocations_params.snap @@ -0,0 +1,21 @@ +--- +source: fil_actor_decoder/tests/verifreg_v16.rs +expression: "decode_params(A, V, 9, &to_vec(&p).unwrap()).unwrap()" +--- +{ + "all_or_nothing": true, + "sectors": [ + { + "claims": [ + { + "allocation_id": 9999, + "client": 5678, + "data": "baeaaaaa", + "size": 34359738368 + } + ], + "expiry": 6000000, + "sector": 100 + } + ] +} diff --git a/fil_actor_decoder/tests/snapshots/verifreg_v16__extend_claim_terms_params.snap b/fil_actor_decoder/tests/snapshots/verifreg_v16__extend_claim_terms_params.snap new file mode 100644 index 00000000..27777e13 --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/verifreg_v16__extend_claim_terms_params.snap @@ -0,0 +1,13 @@ +--- +source: fil_actor_decoder/tests/verifreg_v16.rs +expression: "decode_params(A, V, 11, &to_vec(&p).unwrap()).unwrap()" +--- +{ + "terms": [ + { + "claim_id": 5678, + "provider": 1234, + "term_max": 5256000 + } + ] +} diff --git a/fil_actor_decoder/tests/snapshots/verifreg_v16__get_claims_params.snap b/fil_actor_decoder/tests/snapshots/verifreg_v16__get_claims_params.snap new file mode 100644 index 00000000..70c415de --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/verifreg_v16__get_claims_params.snap @@ -0,0 +1,12 @@ +--- +source: fil_actor_decoder/tests/verifreg_v16.rs +expression: "decode_params(A, V, 10, &to_vec(&p).unwrap()).unwrap()" +--- +{ + "claim_ids": [ + 100, + 200, + 300 + ], + "provider": 1234 +} diff --git a/fil_actor_decoder/tests/snapshots/verifreg_v16__remove_expired_allocations_params.snap b/fil_actor_decoder/tests/snapshots/verifreg_v16__remove_expired_allocations_params.snap new file mode 100644 index 00000000..5b7f0a31 --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/verifreg_v16__remove_expired_allocations_params.snap @@ -0,0 +1,11 @@ +--- +source: fil_actor_decoder/tests/verifreg_v16.rs +expression: "decode_params(A, V, 8, &to_vec(&p).unwrap()).unwrap()" +--- +{ + "allocation_ids": [ + 10, + 20 + ], + "client": 42 +} diff --git a/fil_actor_decoder/tests/snapshots/verifreg_v16__remove_expired_claims_return.snap b/fil_actor_decoder/tests/snapshots/verifreg_v16__remove_expired_claims_return.snap new file mode 100644 index 00000000..70e64f62 --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/verifreg_v16__remove_expired_claims_return.snap @@ -0,0 +1,20 @@ +--- +source: fil_actor_decoder/tests/verifreg_v16.rs +expression: "decode_return(A, V, 12, &to_vec(&r).unwrap()).unwrap()" +--- +{ + "considered": [ + 10, + 20, + 30 + ], + "results": { + "fail_codes": [ + { + "code": 17, + "idx": 2 + } + ], + "success_count": 2 + } +} diff --git a/fil_actor_decoder/tests/snapshots/verifreg_v16__universal_receiver_hook_params.snap b/fil_actor_decoder/tests/snapshots/verifreg_v16__universal_receiver_hook_params.snap new file mode 100644 index 00000000..9ceb14c7 --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/verifreg_v16__universal_receiver_hook_params.snap @@ -0,0 +1,17 @@ +--- +source: fil_actor_decoder/tests/verifreg_v16.rs +expression: "decode_params(A, V, frc42_dispatch::method_hash!(\"Receive\"),\n&to_vec(&p).unwrap()).unwrap()" +--- +{ + "allocations": [ + { + "data": "baeaaaaa", + "expiration": 6000000, + "provider": 1234, + "size": 1048576, + "term_max": 1036800, + "term_min": 518400 + } + ], + "extensions": [] +} diff --git a/fil_actor_decoder/tests/snapshots/verifreg_v17__calibnet_add_verified_client_exported_params.snap b/fil_actor_decoder/tests/snapshots/verifreg_v17__calibnet_add_verified_client_exported_params.snap new file mode 100644 index 00000000..85771d9c --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/verifreg_v17__calibnet_add_verified_client_exported_params.snap @@ -0,0 +1,8 @@ +--- +source: fil_actor_decoder/tests/verifreg_v17.rs +expression: "decode_params(A, V, 3916220144, &decode_hex(hex)).unwrap()" +--- +{ + "address": "f0163355", + "allowance": "1048576" +} diff --git a/fil_actor_decoder/tests/snapshots/verifreg_v17__calibnet_add_verified_client_params.snap b/fil_actor_decoder/tests/snapshots/verifreg_v17__calibnet_add_verified_client_params.snap new file mode 100644 index 00000000..7915a938 --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/verifreg_v17__calibnet_add_verified_client_params.snap @@ -0,0 +1,8 @@ +--- +source: fil_actor_decoder/tests/verifreg_v17.rs +expression: "decode_params(A, V, 4, &decode_hex(hex)).unwrap()" +--- +{ + "address": "f3q5reevnaozjgnnlvtstxoxsl3cyd754gngljn6msaplriqfoyanvwy2rzx4sx6erqwhnvetvck6icpne4bwa", + "allowance": "24000000000000" +} diff --git a/fil_actor_decoder/tests/snapshots/verifreg_v17__claim_allocations_params.snap b/fil_actor_decoder/tests/snapshots/verifreg_v17__claim_allocations_params.snap new file mode 100644 index 00000000..f87095ec --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/verifreg_v17__claim_allocations_params.snap @@ -0,0 +1,21 @@ +--- +source: fil_actor_decoder/tests/verifreg_v17.rs +expression: "decode_params(A, V, 9, &to_vec(&p).unwrap()).unwrap()" +--- +{ + "all_or_nothing": true, + "sectors": [ + { + "claims": [ + { + "allocation_id": 9999, + "client": 5678, + "data": "baeaaaaa", + "size": 34359738368 + } + ], + "expiry": 6000000, + "sector": 100 + } + ] +} diff --git a/fil_actor_decoder/tests/snapshots/verifreg_v17__claim_allocations_return.snap b/fil_actor_decoder/tests/snapshots/verifreg_v17__claim_allocations_return.snap new file mode 100644 index 00000000..88d9bf94 --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/verifreg_v17__claim_allocations_return.snap @@ -0,0 +1,13 @@ +--- +source: fil_actor_decoder/tests/verifreg_v17.rs +expression: "decode_return(A, V, 9, &to_vec(&r).unwrap()).unwrap()" +--- +{ + "sector_claims": [ + "34359738368" + ], + "sector_results": { + "fail_codes": [], + "success_count": 1 + } +} diff --git a/fil_actor_decoder/tests/snapshots/verifreg_v17__extend_claim_terms_params.snap b/fil_actor_decoder/tests/snapshots/verifreg_v17__extend_claim_terms_params.snap new file mode 100644 index 00000000..f436dd84 --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/verifreg_v17__extend_claim_terms_params.snap @@ -0,0 +1,13 @@ +--- +source: fil_actor_decoder/tests/verifreg_v17.rs +expression: "decode_params(A, V, 11, &to_vec(&p).unwrap()).unwrap()" +--- +{ + "terms": [ + { + "claim_id": 5678, + "provider": 1234, + "term_max": 5256000 + } + ] +} diff --git a/fil_actor_decoder/tests/snapshots/verifreg_v17__get_claims_params.snap b/fil_actor_decoder/tests/snapshots/verifreg_v17__get_claims_params.snap new file mode 100644 index 00000000..2a560b34 --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/verifreg_v17__get_claims_params.snap @@ -0,0 +1,12 @@ +--- +source: fil_actor_decoder/tests/verifreg_v17.rs +expression: "decode_params(A, V, 10, &to_vec(&p).unwrap()).unwrap()" +--- +{ + "claim_ids": [ + 100, + 200, + 300 + ], + "provider": 1234 +} diff --git a/fil_actor_decoder/tests/snapshots/verifreg_v17__get_claims_return.snap b/fil_actor_decoder/tests/snapshots/verifreg_v17__get_claims_return.snap new file mode 100644 index 00000000..6a90cf4c --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/verifreg_v17__get_claims_return.snap @@ -0,0 +1,22 @@ +--- +source: fil_actor_decoder/tests/verifreg_v17.rs +expression: "decode_return(A, V, 10, &to_vec(&r).unwrap()).unwrap()" +--- +{ + "batch_info": { + "fail_codes": [], + "success_count": 3 + }, + "claims": [ + { + "client": 5678, + "data": "baeaaaaa", + "provider": 1234, + "sector": 42, + "size": 34359738368, + "term_max": 5256000, + "term_min": 518400, + "term_start": 4000000 + } + ] +} diff --git a/fil_actor_decoder/tests/snapshots/verifreg_v17__mainnet_add_verified_client_params.snap b/fil_actor_decoder/tests/snapshots/verifreg_v17__mainnet_add_verified_client_params.snap new file mode 100644 index 00000000..b786f8a0 --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/verifreg_v17__mainnet_add_verified_client_params.snap @@ -0,0 +1,8 @@ +--- +source: fil_actor_decoder/tests/verifreg_v17.rs +expression: "decode_params(A, V, 4, &decode_hex(hex)).unwrap()" +--- +{ + "address": "f15nikeuukgjpk3rf3ndmxljgroagj52vdgznkcwy", + "allowance": "439804651110400" +} diff --git a/fil_actor_decoder/tests/snapshots/verifreg_v17__mainnet_extend_claim_terms_return.snap b/fil_actor_decoder/tests/snapshots/verifreg_v17__mainnet_extend_claim_terms_return.snap new file mode 100644 index 00000000..d55f20e9 --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/verifreg_v17__mainnet_extend_claim_terms_return.snap @@ -0,0 +1,8 @@ +--- +source: fil_actor_decoder/tests/verifreg_v17.rs +expression: "decode_return(A, V, 11, &decode_hex(hex)).unwrap()" +--- +{ + "fail_codes": [], + "success_count": 300 +} diff --git a/fil_actor_decoder/tests/snapshots/verifreg_v17__mainnet_remove_expired_allocations_params.snap b/fil_actor_decoder/tests/snapshots/verifreg_v17__mainnet_remove_expired_allocations_params.snap new file mode 100644 index 00000000..e51e70cb --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/verifreg_v17__mainnet_remove_expired_allocations_params.snap @@ -0,0 +1,8 @@ +--- +source: fil_actor_decoder/tests/verifreg_v17.rs +expression: "decode_params(A, V, 8, &decode_hex(hex)).unwrap()" +--- +{ + "allocation_ids": [], + "client": 3161385 +} diff --git a/fil_actor_decoder/tests/snapshots/verifreg_v17__mainnet_remove_expired_allocations_return.snap b/fil_actor_decoder/tests/snapshots/verifreg_v17__mainnet_remove_expired_allocations_return.snap new file mode 100644 index 00000000..9124882e --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/verifreg_v17__mainnet_remove_expired_allocations_return.snap @@ -0,0 +1,1717 @@ +--- +source: fil_actor_decoder/tests/verifreg_v17.rs +expression: "decode_return(A, V, 8, &decode_hex(hex.trim())).unwrap()" +--- +{ + "considered": [ + 79142589, + 102953934, + 102922965, + 100564814, + 102309715, + 102188369, + 102798806, + 102097789, + 102078615, + 102537632, + 80244186, + 102780208, + 101460495, + 102782046, + 100548784, + 79538342, + 102188397, + 102104574, + 102451969, + 102188408, + 100565272, + 79142571, + 102441138, + 102576967, + 102771864, + 102188426, + 102432714, + 102785429, + 102037046, + 102975339, + 100566566, + 102593885, + 102459012, + 79380396, + 102543087, + 102549678, + 102588930, + 101291819, + 102188372, + 90758332, + 88844760, + 102088590, + 102510131, + 102450297, + 90755483, + 100449970, + 88861559, + 100930276, + 102790016, + 102930212, + 102903368, + 102977996, + 102788274, + 102789185, + 102459088, + 102949805, + 101902645, + 102188232, + 78854483, + 102868773, + 102949952, + 102188355, + 100784275, + 102922684, + 102764446, + 102911556, + 100563918, + 86252939, + 79161135, + 102785796, + 102188389, + 101472056, + 102952162, + 79155901, + 100564812, + 79379185, + 102055435, + 102782524, + 102780102, + 102188390, + 102266166, + 102870971, + 102958463, + 102787775, + 102089210, + 102787625, + 102763774, + 101903373, + 88859895, + 102874186, + 102625769, + 102593892, + 102566037, + 100550045, + 102822417, + 79457374, + 101460134, + 102413849, + 102783309, + 102188378, + 102772649, + 100554414, + 79145232, + 102938594, + 101291821, + 102208329, + 102788402, + 100566568, + 78854252, + 79163104, + 100565998, + 102627030, + 90693223, + 79394285, + 79178696, + 102905282, + 88844764, + 102510126, + 102463883, + 102473508, + 101030844, + 102317911, + 102974982, + 102779414, + 102576857, + 102188399, + 102781709, + 102641434, + 100458849, + 102489579, + 102785029, + 102781831, + 101291816, + 100563917, + 102473507, + 101904675, + 102288210, + 101904246, + 102626575, + 102912363, + 90727886, + 79455325, + 102078677, + 102142443, + 100464625, + 88859897, + 100563471, + 100689262, + 101903563, + 102787295, + 79154414, + 102548698, + 102541858, + 101904692, + 101902014, + 100563924, + 102618933, + 102188384, + 79151483, + 79178631, + 102510294, + 79589857, + 102789802, + 88853834, + 102992995, + 100939316, + 102188218, + 90746049, + 101901995, + 102764421, + 100813208, + 102103011, + 102627818, + 100806417, + 102092199, + 100726379, + 102512814, + 102763851, + 101291765, + 100563468, + 102526365, + 88862815, + 101903227, + 101904263, + 102520081, + 102522671, + 100565590, + 100901350, + 102188423, + 78854380, + 102547383, + 103007354, + 79383577, + 102108699, + 101548634, + 102483097, + 79791199, + 101902121, + 102454664, + 79394288, + 100466940, + 79534232, + 79588154, + 100565595, + 102790256, + 88862824, + 90729708, + 102933361, + 102773947, + 78856062, + 102784724, + 102084233, + 102788020, + 102562613, + 102436271, + 102188404, + 102782646, + 102912831, + 100449622, + 102780844, + 78854496, + 78859761, + 100823016, + 102920699, + 102784217, + 102783313, + 100563742, + 102780096, + 100773701, + 101903627, + 78857686, + 102961746, + 79393030, + 78854385, + 102651061, + 102994650, + 102545867, + 102458327, + 102188409, + 102929595, + 102774112, + 88862819, + 102494411, + 102785124, + 100465175, + 102541891, + 100564210, + 100934894, + 102787140, + 102974060, + 102780450, + 102435515, + 102526664, + 102964025, + 100563743, + 100820275, + 102234424, + 102781142, + 102765782, + 102781921, + 88838642, + 100814938, + 102098318, + 102288214, + 102789115, + 102788015, + 102524844, + 101291822, + 88850370, + 102534159, + 102181695, + 101460500, + 88840414, + 88849553, + 102188386, + 102506339, + 79377884, + 102435351, + 102089336, + 102781371, + 102782649, + 79161139, + 102782786, + 79543985, + 102897177, + 102516838, + 102781365, + 100545284, + 101905429, + 100563920, + 102517910, + 102943715, + 102961301, + 100565273, + 78856061, + 102781476, + 102037466, + 102690971, + 101903556, + 102167459, + 102188374, + 102987633, + 102090590, + 88847219, + 102472386, + 102506682, + 102782644, + 101904186, + 100567357, + 102786416, + 101902709, + 100565588, + 102088702, + 102188403, + 102981256, + 79163121, + 101902246, + 100460357, + 90708259, + 100564989, + 102087899, + 79388710, + 78854383, + 102557624, + 102786414, + 102516834, + 102764414, + 102790637, + 80249693, + 102763858, + 88851369, + 102147306, + 102530843, + 101903569, + 79380397, + 80241407, + 102975340, + 100567356, + 100937430, + 100939276, + 102188365, + 100566951, + 102414388, + 102622102, + 100566194, + 102188367, + 102771861, + 90746041, + 102496562, + 102188393, + 102760589, + 102958809, + 102521109, + 102577465, + 88847231, + 102789122, + 78854487, + 100691162, + 88853820, + 102780448, + 102928853, + 88851361, + 102312104, + 88842317, + 102784422, + 102634284, + 78857675, + 100921627, + 102617115, + 88851356, + 102530941, + 100566569, + 102188223, + 102789442, + 102997670, + 101291820, + 100566953, + 100926516, + 101905406, + 102781919, + 100459496, + 100792814, + 102557707, + 102776346, + 90734571, + 88836103, + 100782913, + 102537588, + 102784879, + 100555355, + 100564445, + 102103192, + 101902803, + 102440499, + 102530448, + 102494843, + 88858409, + 102569111, + 102787018, + 102625144, + 102927697, + 102925989, + 101903215, + 102586905, + 79443547, + 102783316, + 100462459, + 102674651, + 102588715, + 88862827, + 100566955, + 101904329, + 90750861, + 102579257, + 102782648, + 102249624, + 102097444, + 78854492, + 100564452, + 102782278, + 78854261, + 102032959, + 101904184, + 100465172, + 102474394, + 102054933, + 79151479, + 100783663, + 102278971, + 102566033, + 102786083, + 102783605, + 102977473, + 79379183, + 100550042, + 102188400, + 102784498, + 102948116, + 78854502, + 102815330, + 102911274, + 100566571, + 100463689, + 79394275, + 102959448, + 102435333, + 102232990, + 88848292, + 101025568, + 102496955, + 102769144, + 102034102, + 102786631, + 102574834, + 102530551, + 88852422, + 100564212, + 102784878, + 101902671, + 102590221, + 102925221, + 78854471, + 102958490, + 79142613, + 102095523, + 102968597, + 101902664, + 102946023, + 102629298, + 102424633, + 100566393, + 78854500, + 102096939, + 79375535, + 100566002, + 88851363, + 102476734, + 102288209, + 79379193, + 102080087, + 102789805, + 102134386, + 100787831, + 100926321, + 101291772, + 102521758, + 102678190, + 79588153, + 102515557, + 100565278, + 100564213, + 78862971, + 88852427, + 78854479, + 79377874, + 102783444, + 102081883, + 102147308, + 102784042, + 88838637, + 102477711, + 101090897, + 100788653, + 90698952, + 102512250, + 100563741, + 102958498, + 102255046, + 102781315, + 102085521, + 102052324, + 101904673, + 102435352, + 102096933, + 102884317, + 102527554, + 102079113, + 102994651, + 102760752, + 102447567, + 102169233, + 102188228, + 102473743, + 102188373, + 102474870, + 102507277, + 79147020, + 102538653, + 102488641, + 100564818, + 90640242, + 88847227, + 102540204, + 102188368, + 78863225, + 102782277, + 102783227, + 100563744, + 79593140, + 100463199, + 102921365, + 102787774, + 102023728, + 102782718, + 102780843, + 102518700, + 78857714, + 102041904, + 100566196, + 102477653, + 102188427, + 102785908, + 102188421, + 102511421, + 101025075, + 101561049, + 103016876, + 102781714, + 100566570, + 102788017, + 102188406, + 102617111, + 100940641, + 102781473, + 102488422, + 88850366, + 100566396, + 102897034, + 102188362, + 101902105, + 79151481, + 102173120, + 79142491, + 102520745, + 102058273, + 102528189, + 102188230, + 102790255, + 102926498, + 102548980, + 100462406, + 101073828, + 102447546, + 102467623, + 102901771, + 102541892, + 102451652, + 79791201, + 102785428, + 102580207, + 102982803, + 102788272, + 102662266, + 102961304, + 88848287, + 101902705, + 102103830, + 102488424, + 102079058, + 102530943, + 102188383, + 102569108, + 102768551, + 102780028, + 79371920, + 102790640, + 102058465, + 102569129, + 100564987, + 102995443, + 79375522, + 101904330, + 103817586, + 101291790, + 102632365, + 79380401, + 102781917, + 102780201, + 79147076, + 102781028, + 102774052, + 101902011, + 102997032, + 101463636, + 100940797, + 100457381, + 102461899, + 102762363, + 102060997, + 102188377, + 102946897, + 100565592, + 100460915, + 100565274, + 102958466, + 101475627, + 100567359, + 88862814, + 102596506, + 102786757, + 102779877, + 102991520, + 102785120, + 90724259, + 102505288, + 102522669, + 86377110, + 102516829, + 102469263, + 102782422, + 79151471, + 78863151, + 102083893, + 102963336, + 102145169, + 102782117, + 101902132, + 101902650, + 100939452, + 78854486, + 102517904, + 88856392, + 102626319, + 102630742, + 102925719, + 100463306, + 102788399, + 102763824, + 102188370, + 79149030, + 102817654, + 102482105, + 102510121, + 101466285, + 102958783, + 103021213, + 102188221, + 78859709, + 101905432, + 102908354, + 102593879, + 90753939, + 100462647, + 79149036, + 88858399, + 102545868, + 102782222, + 88838648, + 102789183, + 100563919, + 79381690, + 79366767, + 102790475, + 102450520, + 102785121, + 102627862, + 100566399, + 100811060, + 102089940, + 101460442, + 88849562, + 102787016, + 102781366, + 102781316, + 102788921, + 79534217, + 102330505, + 102288211, + 102566044, + 102188214, + 102038582, + 101902002, + 102776711, + 100464573, + 88853823, + 102090599, + 102093994, + 100565589, + 101903345, + 102586717, + 101902706, + 102790784, + 102785435, + 102188375, + 79374342, + 102977470, + 102762329, + 100566197, + 79368038, + 102188229, + 79142575, + 78854410, + 102780901, + 102609782, + 102783449, + 90753930, + 78854258, + 102517448, + 102176162, + 79370592, + 102788436, + 78854478, + 79165060, + 102188382, + 102617038, + 102489420, + 103025225, + 102782724, + 103023034, + 102930370, + 102150286, + 100566952, + 102455061, + 102917338, + 100930664, + 102181723, + 101904697, + 102079060, + 102533249, + 102958557, + 102788572, + 102056149, + 102527609, + 102920700, + 102493626, + 103003210, + 100566198, + 79163107, + 88853824, + 100565594, + 79156016, + 100792050, + 102454665, + 100809681, + 79165069, + 103025383, + 102786895, + 100565593, + 102517541, + 79379196, + 102786084, + 101904240, + 102513574, + 102585496, + 102538010, + 100566394, + 101549084, + 78857713, + 100564815, + 102188376, + 102508669, + 102522260, + 101901989, + 102220663, + 100564208, + 79538345, + 102780207, + 88851365, + 79791200, + 101903472, + 102055814, + 101904162, + 102958841, + 100931178, + 101904108, + 102618376, + 102962417, + 102780557, + 102089405, + 102096349, + 100463209, + 103016873, + 101904244, + 93833768, + 102959478, + 79157638, + 102414751, + 102994136, + 102580208, + 101904310, + 100564986, + 102786635, + 102996559, + 102608102, + 102046684, + 103016878, + 102188388, + 79163108, + 102517376, + 102584454, + 88859889, + 78856054, + 102958536, + 102044071, + 79159353, + 100811398, + 102583726, + 79149031, + 102188392, + 102764419, + 102782044, + 86498565, + 102513592, + 101024557, + 100922081, + 102520390, + 102576427, + 102086847, + 102486496, + 102781314, + 102779876, + 102977999, + 102926436, + 102782785, + 88856386, + 79370585, + 102897071, + 79391683, + 88861560, + 78854249, + 102780782, + 88853831, + 88859894, + 102675904, + 102188222, + 102788568, + 101903344, + 88861557, + 100564448, + 100565276, + 102993155, + 102515496, + 100791373, + 102114415, + 100566000, + 102943873, + 102789121, + 102613858, + 102791138, + 100466137, + 102060678, + 100564447, + 79977957, + 88850361, + 102432626, + 102633349, + 100567360, + 102188225, + 102530491, + 102516840, + 102985213, + 102780779, + 102274010, + 102782719, + 102785431, + 100927849, + 102094558, + 101902657, + 100566957, + 88850371, + 100459518, + 102784425, + 79791197, + 102435353, + 102188356, + 102633342, + 78854253, + 90746039, + 102784881, + 102780380, + 100566003, + 102782888, + 102788699, + 102618491, + 100463258, + 102037217, + 79163122, + 102771885, + 102472034, + 101291789, + 100465739, + 102083760, + 102498645, + 102766108, + 102922482, + 102099846, + 102688037, + 79377876, + 100460648, + 102082792, + 78859766, + 102780451, + 102782188, + 88836105, + 101477549, + 102055208, + 102927695, + 101901984, + 79380425, + 101903577, + 102188371, + 78857716, + 101902165, + 78854382, + 101549698, + 102522670, + 90696410, + 102790789, + 101904876, + 102783838, + 101904703, + 100564215, + 78857707, + 102562562, + 79044020, + 101460329, + 78859768, + 100933316, + 101904234, + 101905536, + 103001744, + 102425653, + 100462410, + 102470740, + 102788575, + 102032612, + 79146976, + 102787012, + 88842314, + 102060386, + 90731390, + 100549072, + 102689297, + 102771867, + 102057958, + 100564984, + 102045703, + 100564214, + 102163724, + 90750851, + 102188220, + 101902115, + 102082690, + 102925183, + 90744363, + 100568239, + 102506334, + 102781368, + 102079598, + 102569109, + 100466397, + 102968959, + 88861558, + 102536533, + 102780560, + 101291769, + 102790478, + 100566192, + 78854506, + 102624348, + 101463841, + 79154413, + 102786894, + 102538011, + 102788286, + 102465227, + 102188405, + 102038588, + 101903469, + 79540260, + 102420282, + 79534230, + 102538160, + 102188361, + 101467810, + 102665423, + 101902812, + 103022688, + 100676729, + 79591291, + 102963463, + 102506613, + 79153504, + 102506605, + 100457326, + 102040643, + 102100162, + 102208326, + 102217580, + 102518670, + 102949801, + 102870325, + 102088337, + 78859699, + 102966898, + 102451663, + 102052690, + 88861556, + 90741135, + 102764462, + 102581100, + 102034455, + 79153502, + 102516356, + 100565271, + 102078465, + 101903533, + 102788694, + 78854495, + 102565993, + 102091145, + 88840409, + 102585120, + 102091127, + 102091722, + 102960054, + 79153501, + 88861553, + 102788790, + 102789116, + 102786080, + 102958791, + 90710036, + 102782893, + 102051971, + 102979635, + 102538687, + 93868787, + 102099554, + 102932510, + 102776189, + 102188394, + 100463872, + 78857688, + 100565591, + 102481297, + 102110524, + 102783841, + 102059050, + 102079336, + 102918901, + 90747650, + 102784152, + 102780095, + 100754662, + 102056144, + 102980689, + 102058471, + 101902747, + 100941152, + 102958472, + 101904284, + 102625190, + 102188387, + 102787493, + 102786411, + 102083271, + 100456474, + 102188402, + 102188410, + 102624347, + 102471734, + 102188227, + 78854468, + 102780845, + 102580321, + 102087339, + 102188407, + 102057612, + 79142685, + 102508219, + 102188226, + 100566392, + 102517539, + 102142449, + 100828118, + 102456296, + 101902612, + 88858407, + 102553270, + 100690955, + 102625346, + 102762204, + 102969607, + 102982532, + 102450586, + 102152002, + 102150287, + 100564451, + 79050976, + 102188395, + 102786410, + 102057479, + 102781706, + 102188364, + 102912677, + 102782645, + 79375523, + 103007355, + 88840410, + 88851358, + 100566572, + 102150385, + 88849558, + 102788019, + 102494844, + 100825985, + 100567358, + 100924014, + 102781249, + 101903540, + 79154425, + 100940627, + 103009376, + 79157634, + 102960589, + 100564819, + 78859771, + 88851362, + 100566195, + 102778570, + 102040645, + 100565275, + 102996045, + 88852425, + 102689294, + 100465513, + 102779412, + 102578621, + 102079377, + 102188360, + 79165063, + 102511422, + 102996213, + 102188401, + 102904890, + 102782423, + 79159806, + 102785675, + 90646457, + 79154422, + 102790019, + 100563921, + 102785642, + 102433523, + 102091146, + 102086838, + 102223430, + 102783836, + 102780556, + 90753929, + 102648236, + 88853828, + 79380400, + 102188398, + 102917684, + 102188425, + 88850359, + 102985680, + 79142484, + 101905401, + 79375529, + 102476643, + 102781137, + 88850367, + 78862970, + 102785279, + 100444819, + 102054167, + 102944669, + 79161131, + 79791198, + 100826505, + 79373177, + 102662263, + 102787014, + 88856385, + 102188358, + 102039451, + 102538211, + 100564817, + 102634222, + 79380427, + 100566567, + 102640123, + 88851360, + 102783840, + 102078322, + 102518665, + 100458909, + 79376705, + 100564450, + 102530166, + 79377871, + 100563475, + 102188363, + 79591290, + 101905415, + 88836116, + 102188396, + 102802442, + 100933003, + 102781922, + 102978867, + 88852421, + 79377887, + 102762278, + 101476929, + 102058902, + 102510129, + 102291916, + 102789757, + 102537630, + 102625625, + 100464770, + 102096005, + 102089340, + 102537633, + 90718320, + 102277776, + 102782272, + 102188217, + 101291815, + 102078199, + 102782527, + 102188366, + 102776422, + 102481662, + 102188424, + 102439984, + 101902005, + 100563470, + 102959483, + 102583732, + 100566004, + 79591292, + 102659551, + 101291818, + 79376692, + 102497952, + 102990856, + 102189090, + 79374344, + 102781472, + 102442324, + 102981085, + 102520070, + 79047838, + 102785799, + 100466417, + 102597655, + 79157640, + 88853826, + 102781712, + 102906541, + 102789439, + 102958559, + 102058687, + 102617443, + 79366770, + 102782890, + 102790015, + 79145168, + 100784181, + 101904714, + 101902143, + 102800506, + 100564209, + 79379200, + 102164890, + 102515668, + 78854403, + 102774053, + 79393071, + 79368035, + 100783976, + 100448424, + 88850368, + 78854378, + 79380392, + 88862818, + 102040307, + 102052746, + 102782784, + 102039934, + 102055691, + 102557623, + 78857709, + 102784044, + 102188385, + 101904878, + 102044074, + 100811577, + 79155897, + 102629420, + 100563922, + 102787290, + 102781827, + 102781711, + 102562081, + 102976947, + 88852424, + 102188422, + 102588833, + 79154416, + 79593984, + 79536040, + 101902107, + 102946028, + 100548781, + 102545926, + 102566654, + 102785433, + 102764468, + 100465639, + 100566956, + 103007204, + 102454660, + 102488425, + 88849560, + 102790020, + 102533790, + 100564988, + 102085927, + 88862825, + 79142579, + 88850369, + 100463042, + 100563923, + 100922795, + 102041656, + 90747660, + 101559876, + 102978152, + 102987639, + 102953022, + 102053343, + 79157621, + 79178703, + 102785648, + 100563469, + 102041197, + 102095092, + 102931096, + 88840417, + 102413695, + 102760756, + 102088335, + 102476729, + 102919615, + 102787776, + 102781251, + 101034888, + 102032539, + 102800501, + 102530845, + 101291770, + 102788285, + 102615013, + 100549888, + 88852430, + 78854364, + 102542720, + 101905418, + 100724515, + 102782124, + 100464311, + 88848293, + 100548646, + 102929591, + 102550985, + 101904179, + 102781255, + 102516845, + 102278972, + 102530546, + 101902802, + 102093652, + 90747659, + 102087657, + 101905420, + 102555486, + 88853821, + 102589397, + 100563473, + 101291767, + 102584461, + 100565997, + 101902087, + 102579255, + 102780024, + 102081669, + 79538351, + 102760754, + 102787292, + 88861550, + 102098946, + 102188224, + 102780908, + 100463796, + 102785125, + 100564985, + 79536038, + 102789117, + 102782421, + 102782048, + 102965135, + 102781027, + 102784158, + 102498649, + 100567361, + 100566573, + 101291768, + 88859899, + 102771990, + 100550047, + 79154420, + 88847222, + 79154423, + 102790783, + 102188420, + 102568062, + 79589865, + 100566398, + 102963018, + 102780453, + 100564449, + 102451930, + 102089650, + 102781140, + 100566001, + 101902113, + 102188380, + 80329718, + 102789440, + 102261833, + 102516839, + 102980921, + 102188391, + 102929077, + 101291792, + 101904304, + 102181691, + 100564990, + 102596114, + 102488426, + 101904650, + 102516843, + 100566395, + 100549071, + 102501971, + 102033421, + 102789806, + 102958813, + 79593988, + 102557173, + 88849548, + 100869754, + 102188381, + 100563740, + 102501969, + 101903579, + 100466668, + 102092491, + 102451673, + 102239979, + 102781029, + 102056308, + 101904228, + 79381691, + 102477489, + 101902620, + 79388708, + 102978667, + 78854356, + 102610760, + 100563474, + 102478856, + 102614492, + 102039230, + 102118956, + 100725446, + 102414106, + 102083888, + 102115167, + 102763830, + 102648401, + 102781702, + 102773951, + 102953939, + 102533741, + 102780841, + 102978563, + 100459842, + 79381675, + 102435999, + 100564991, + 100563737, + 102788401, + 100566199, + 102785793, + 100808209, + 102086296, + 102786898, + 102784220, + 102787620, + 88852426, + 102052055, + 102958798, + 102970986, + 102094615, + 102188231, + 79591293, + 101903636, + 100912586, + 102089755, + 102787623, + 102494904, + 102188359, + 100566397, + 102781320, + 102499729, + 102100039, + 102188219, + 102615491, + 102530496, + 102098324, + 102185877, + 102107821, + 88853829, + 100460245, + 102188357, + 100462822, + 101466815, + 102791021, + 88849552, + 100563739, + 102788792, + 102079923, + 78854370, + 102958796, + 102113814, + 79791202, + 102491863, + 88858405, + 101904180, + 101903526, + 103047032, + 102558590, + 102033512, + 102693776, + 102964021, + 100564211, + 102780452, + 102622187, + 102788791, + 102088385, + 101291793, + 88850363, + 101291817, + 102784730, + 101291766, + 102051209, + 102503774, + 102611389, + 100812009, + 101903629, + 100566193, + 102055104, + 101902728, + 79538359, + 78859707, + 102474901, + 88856393, + 101556371, + 79055414, + 100564813, + 102764469, + 101910603, + 78856072, + 102080617, + 79376694, + 102988267, + 101291791, + 102419460, + 100722769, + 88848282, + 102780027, + 102223435, + 102583528, + 101903334, + 100717354, + 102963523, + 102169234, + 102592283, + 101291771, + 79154418, + 100462757, + 102471468, + 102084664, + 88850360, + 100565999, + 79156015, + 102609218, + 101903553, + 100564816, + 88851364, + 102529815, + 102783693, + 102968087, + 100565277, + 79151473, + 102589737, + 102780025, + 102092844, + 79156019, + 102530939, + 102770172, + 102895066, + 102078177, + 102024524, + 101903583, + 102056611, + 102781250, + 102959691, + 100564446, + 102630339, + 102762330, + 88836117, + 86447571, + 102781829, + 102565996, + 101902245, + 101904290, + 102780554, + 102775662, + 102769145, + 102789759, + 100566954, + 101903390, + 86180886, + 102960055, + 101903384, + 102524827, + 102782189, + 102188411, + 100447289, + 102036831, + 100566958, + 102922683, + 100563472, + 79376691, + 102953016, + 102551024, + 90753941, + 100563738, + 102897183, + 102789437, + 100809161, + 102785647, + 102058103, + 102929911, + 102508758, + 104592255 + ], + "datacap_recovered": "58548994179072", + "results": { + "fail_codes": [], + "success_count": 1704 + } +} diff --git a/fil_actor_decoder/tests/snapshots/verifreg_v17__remove_expired_claims_params.snap b/fil_actor_decoder/tests/snapshots/verifreg_v17__remove_expired_claims_params.snap new file mode 100644 index 00000000..1ba7fbbb --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/verifreg_v17__remove_expired_claims_params.snap @@ -0,0 +1,12 @@ +--- +source: fil_actor_decoder/tests/verifreg_v17.rs +expression: "decode_params(A, V, 12, &to_vec(&p).unwrap()).unwrap()" +--- +{ + "claim_ids": [ + 10, + 20, + 30 + ], + "provider": 1234 +} diff --git a/fil_actor_decoder/tests/snapshots/verifreg_v17__remove_expired_claims_return.snap b/fil_actor_decoder/tests/snapshots/verifreg_v17__remove_expired_claims_return.snap new file mode 100644 index 00000000..ac707592 --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/verifreg_v17__remove_expired_claims_return.snap @@ -0,0 +1,20 @@ +--- +source: fil_actor_decoder/tests/verifreg_v17.rs +expression: "decode_return(A, V, 12, &to_vec(&r).unwrap()).unwrap()" +--- +{ + "considered": [ + 10, + 20, + 30 + ], + "results": { + "fail_codes": [ + { + "code": 17, + "idx": 2 + } + ], + "success_count": 2 + } +} diff --git a/fil_actor_decoder/tests/snapshots/verifreg_v17__remove_verifier_params.snap b/fil_actor_decoder/tests/snapshots/verifreg_v17__remove_verifier_params.snap new file mode 100644 index 00000000..8ea2b148 --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/verifreg_v17__remove_verifier_params.snap @@ -0,0 +1,5 @@ +--- +source: fil_actor_decoder/tests/verifreg_v17.rs +expression: "decode_params(A, V, 3, &to_vec(&p).unwrap()).unwrap()" +--- +"f0999" diff --git a/fil_actor_decoder/tests/snapshots/verifreg_v17__universal_receiver_hook_params.snap b/fil_actor_decoder/tests/snapshots/verifreg_v17__universal_receiver_hook_params.snap new file mode 100644 index 00000000..32e5c1d5 --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/verifreg_v17__universal_receiver_hook_params.snap @@ -0,0 +1,17 @@ +--- +source: fil_actor_decoder/tests/verifreg_v17.rs +expression: "decode_params(A, V, frc42_dispatch::method_hash!(\"Receive\"),\n&to_vec(&p).unwrap()).unwrap()" +--- +{ + "allocations": [ + { + "data": "baeaaaaa", + "expiration": 6000000, + "provider": 1234, + "size": 1048576, + "term_max": 1036800, + "term_min": 518400 + } + ], + "extensions": [] +} diff --git a/fil_actor_decoder/tests/snapshots/verifreg_v9__mainnet_add_verified_client_params.snap b/fil_actor_decoder/tests/snapshots/verifreg_v9__mainnet_add_verified_client_params.snap new file mode 100644 index 00000000..43ffebed --- /dev/null +++ b/fil_actor_decoder/tests/snapshots/verifreg_v9__mainnet_add_verified_client_params.snap @@ -0,0 +1,8 @@ +--- +source: fil_actor_decoder/tests/verifreg_v9.rs +expression: "decode_params(A, V, 4, &decode_hex(hex)).unwrap()" +--- +{ + "address": "f12feoiisob4vvzno4rntjafjckjqlc4efrmlqkiq", + "allowance": "34359738368" +} diff --git a/fil_actor_decoder/tests/verifreg_v10.rs b/fil_actor_decoder/tests/verifreg_v10.rs new file mode 100644 index 00000000..69623951 --- /dev/null +++ b/fil_actor_decoder/tests/verifreg_v10.rs @@ -0,0 +1,27 @@ +//! Snapshot tests for Verified Registry (f06) actor — v10. +//! Real on-chain data from mainnet. + +use fil_actor_decoder::{ActorType, ActorVersion, decode_params, decode_return}; + +fn decode_hex(hex: &str) -> Vec { + hex::decode(hex.strip_prefix("0x").unwrap_or(hex)).unwrap() +} + +const V: ActorVersion = ActorVersion::V10; +const A: ActorType = ActorType::VerifiedRegistry; + +/// AddVerifiedClient — mainnet epoch 2739863 (NV18/Hygge era) +/// Source: bafy2bzacebqmyb2xkrbw4evogqkfrbc637sd34szfmu2ylgt7hqyw57glmto6 +#[test] +fn mainnet_add_verified_client_params() { + let hex = "825501b148275e403de2fc35ab6d59e861fbc6a8ac6ffd46000800000000"; + insta::assert_json_snapshot!(decode_params(A, V, 4, &decode_hex(hex)).unwrap()); +} + +/// ExtendClaimTerms return — mainnet epoch 3031412 (NV18/Hygge era) +/// Source: bafy2bzacedrnt7ecmv6zrcqsyj34bsekrww53yxq5ygvx6izdojm5xzzvjxwe +#[test] +fn mainnet_extend_claim_terms_return() { + let hex = "8218bc80"; + insta::assert_json_snapshot!(decode_return(A, V, 11, &decode_hex(hex)).unwrap()); +} diff --git a/fil_actor_decoder/tests/verifreg_v11.rs b/fil_actor_decoder/tests/verifreg_v11.rs new file mode 100644 index 00000000..f7df44e1 --- /dev/null +++ b/fil_actor_decoder/tests/verifreg_v11.rs @@ -0,0 +1,27 @@ +//! Snapshot tests for Verified Registry (f06) actor — v11. +//! Real on-chain data from mainnet. + +use fil_actor_decoder::{ActorType, ActorVersion, decode_params, decode_return}; + +fn decode_hex(hex: &str) -> Vec { + hex::decode(hex.strip_prefix("0x").unwrap_or(hex)).unwrap() +} + +const V: ActorVersion = ActorVersion::V11; +const A: ActorType = ActorType::VerifiedRegistry; + +/// AddVerifiedClient — mainnet epoch 2990400 (NV19-20/Lightning-Thunder era) +/// Source: bafy2bzacecahd7l23crhpn2ten2ydflnis4v5pnceo7pk44hu3myoilatnfic +#[test] +fn mainnet_add_verified_client_params() { + let hex = "82583103a982a967fec40da82e201fc04a03b9de5494bb58958a2f41fbdc59f45913e7365adafde8349c639303fbc8fcd066f13846000800000000"; + insta::assert_json_snapshot!(decode_params(A, V, 4, &decode_hex(hex)).unwrap()); +} + +/// ExtendClaimTerms return — mainnet epoch 3246923 (NV19-20 era) +/// Source: bafy2bzaced7tg3gbeq7ohhzrk4dq42knyctwbqkwf6xieki7e35x7ajijspna +#[test] +fn mainnet_extend_claim_terms_return() { + let hex = "8219013580"; + insta::assert_json_snapshot!(decode_return(A, V, 11, &decode_hex(hex)).unwrap()); +} diff --git a/fil_actor_decoder/tests/verifreg_v12.rs b/fil_actor_decoder/tests/verifreg_v12.rs new file mode 100644 index 00000000..d89376c7 --- /dev/null +++ b/fil_actor_decoder/tests/verifreg_v12.rs @@ -0,0 +1,19 @@ +//! Snapshot tests for Verified Registry (f06) actor — v12. +//! Real on-chain data from mainnet. + +use fil_actor_decoder::{ActorType, ActorVersion, decode_return}; + +fn decode_hex(hex: &str) -> Vec { + hex::decode(hex.strip_prefix("0x").unwrap_or(hex)).unwrap() +} + +const V: ActorVersion = ActorVersion::V12; +const A: ActorType = ActorType::VerifiedRegistry; + +/// ExtendClaimTerms return — mainnet epoch 3569536 (NV21/Watermelon era) +/// Source: bafy2bzaceaabi66hdqakr6yqnquunfkdm7vi3qreh6chrneczezmmx4so7hq4 +#[test] +fn mainnet_extend_claim_terms_return() { + let hex = "8219019080"; + insta::assert_json_snapshot!(decode_return(A, V, 11, &decode_hex(hex)).unwrap()); +} diff --git a/fil_actor_decoder/tests/verifreg_v13.rs b/fil_actor_decoder/tests/verifreg_v13.rs new file mode 100644 index 00000000..9beec322 --- /dev/null +++ b/fil_actor_decoder/tests/verifreg_v13.rs @@ -0,0 +1,19 @@ +//! Snapshot tests for Verified Registry (f06) actor — v13. +//! Real on-chain data from mainnet. + +use fil_actor_decoder::{ActorType, ActorVersion, decode_return}; + +fn decode_hex(hex: &str) -> Vec { + hex::decode(hex.strip_prefix("0x").unwrap_or(hex)).unwrap() +} + +const V: ActorVersion = ActorVersion::V13; +const A: ActorType = ActorType::VerifiedRegistry; + +/// ExtendClaimTerms return — mainnet epoch 3953869 (NV22/Dragon era) +/// Source: bafy2bzaceary67mehfgij5p7ovneqtdh5yvh7yuiwmdktfltmnzbcs3ll7mu2 +#[test] +fn mainnet_extend_claim_terms_return() { + let hex = "8218c880"; + insta::assert_json_snapshot!(decode_return(A, V, 11, &decode_hex(hex)).unwrap()); +} diff --git a/fil_actor_decoder/tests/verifreg_v14.rs b/fil_actor_decoder/tests/verifreg_v14.rs new file mode 100644 index 00000000..3bfa88a5 --- /dev/null +++ b/fil_actor_decoder/tests/verifreg_v14.rs @@ -0,0 +1,19 @@ +//! Snapshot tests for Verified Registry (f06) actor — v14. +//! Real on-chain data from mainnet. + +use fil_actor_decoder::{ActorType, ActorVersion, decode_return}; + +fn decode_hex(hex: &str) -> Vec { + hex::decode(hex.strip_prefix("0x").unwrap_or(hex)).unwrap() +} + +const V: ActorVersion = ActorVersion::V14; +const A: ActorType = ActorType::VerifiedRegistry; + +/// ExtendClaimTerms return — mainnet epoch 4327216 (NV23/Waffle era) +/// Source: bafy2bzacecswz3h3uqyuom3zzydx42zps5ilfjraqqhqynkladmoxrpl5tcmu +#[test] +fn mainnet_extend_claim_terms_return() { + let hex = "8218c880"; + insta::assert_json_snapshot!(decode_return(A, V, 11, &decode_hex(hex)).unwrap()); +} diff --git a/fil_actor_decoder/tests/verifreg_v15.rs b/fil_actor_decoder/tests/verifreg_v15.rs new file mode 100644 index 00000000..bf25f0ff --- /dev/null +++ b/fil_actor_decoder/tests/verifreg_v15.rs @@ -0,0 +1,19 @@ +//! Snapshot tests for Verified Registry (f06) actor — v15. +//! Real on-chain data from mainnet. + +use fil_actor_decoder::{ActorType, ActorVersion, decode_return}; + +fn decode_hex(hex: &str) -> Vec { + hex::decode(hex.strip_prefix("0x").unwrap_or(hex)).unwrap() +} + +const V: ActorVersion = ActorVersion::V15; +const A: ActorType = ActorType::VerifiedRegistry; + +/// ExtendClaimTerms return — mainnet epoch 4684953 (NV24/TukTuk era) +/// Source: bafy2bzaced3hjakmiv4olqvemztxpnmrms3ilu3pbxakm2ykel4wufcn43nl2 +#[test] +fn mainnet_extend_claim_terms_return() { + let hex = "8219025880"; + insta::assert_json_snapshot!(decode_return(A, V, 11, &decode_hex(hex)).unwrap()); +} diff --git a/fil_actor_decoder/tests/verifreg_v16.rs b/fil_actor_decoder/tests/verifreg_v16.rs new file mode 100644 index 00000000..eed94448 --- /dev/null +++ b/fil_actor_decoder/tests/verifreg_v16.rs @@ -0,0 +1,108 @@ +//! Snapshot tests for Verified Registry (f06) actor — v16. +//! +//! v16 types are structurally identical to v17. These tests confirm v16 +//! decoding produces the same output by constructing params from v16 types. + +use fil_actor_decoder::{ActorType, ActorVersion, decode_params, decode_return}; +use fvm_ipld_encoding::to_vec; +use fvm_shared4::address::Address; +use num_bigint::BigInt; + +const V: ActorVersion = ActorVersion::V16; +const A: ActorType = ActorType::VerifiedRegistry; + +#[test] +fn add_verified_client_params() { + let p = fil_actor_verifreg_state::v16::VerifierParams { + address: Address::new_id(1000), + allowance: BigInt::from(5_000_000), + }; + insta::assert_json_snapshot!(decode_params(A, V, 4, &to_vec(&p).unwrap()).unwrap()); +} + +#[test] +fn remove_expired_allocations_params() { + let p = fil_actor_verifreg_state::v16::RemoveExpiredAllocationsParams { + client: 42, + allocation_ids: vec![10, 20], + }; + insta::assert_json_snapshot!(decode_params(A, V, 8, &to_vec(&p).unwrap()).unwrap()); +} + +#[test] +fn get_claims_params() { + let p = fil_actor_verifreg_state::v16::GetClaimsParams { + provider: 1234, + claim_ids: vec![100, 200, 300], + }; + insta::assert_json_snapshot!(decode_params(A, V, 10, &to_vec(&p).unwrap()).unwrap()); +} + +#[test] +fn claim_allocations_params() { + let p = fil_actor_verifreg_state::v16::ClaimAllocationsParams { + sectors: vec![fil_actor_verifreg_state::v16::SectorAllocationClaims { + sector: 100, + expiry: 6000000, + claims: vec![fil_actor_verifreg_state::v16::AllocationClaim { + client: 5678, + allocation_id: 9999, + data: cid::Cid::default(), + size: fvm_shared4::piece::PaddedPieceSize(34359738368), + }], + }], + all_or_nothing: true, + }; + insta::assert_json_snapshot!(decode_params(A, V, 9, &to_vec(&p).unwrap()).unwrap()); +} + +#[test] +fn extend_claim_terms_params() { + let p = fil_actor_verifreg_state::v16::ExtendClaimTermsParams { + terms: vec![fil_actor_verifreg_state::v16::ClaimTerm { + provider: 1234, + claim_id: 5678, + term_max: 5256000, + }], + }; + insta::assert_json_snapshot!(decode_params(A, V, 11, &to_vec(&p).unwrap()).unwrap()); +} + +#[test] +fn remove_expired_claims_return() { + let r = fil_actor_verifreg_state::v16::RemoveExpiredClaimsReturn { + considered: vec![10, 20, 30], + results: fil_actors_shared::v16::BatchReturn { + success_count: 2, + fail_codes: vec![fil_actors_shared::v16::FailCode { + idx: 2, + code: fvm_shared4::error::ExitCode::USR_NOT_FOUND, + }], + }, + }; + insta::assert_json_snapshot!(decode_return(A, V, 12, &to_vec(&r).unwrap()).unwrap()); +} + +#[test] +fn universal_receiver_hook_params() { + let p = fil_actor_verifreg_state::v16::AllocationRequests { + allocations: vec![fil_actor_verifreg_state::v16::AllocationRequest { + provider: 1234, + data: cid::Cid::default(), + size: fvm_shared4::piece::PaddedPieceSize(1048576), + term_min: 518400, + term_max: 1036800, + expiration: 6000000, + }], + extensions: vec![], + }; + insta::assert_json_snapshot!( + decode_params( + A, + V, + frc42_dispatch::method_hash!("Receive"), + &to_vec(&p).unwrap() + ) + .unwrap() + ); +} diff --git a/fil_actor_decoder/tests/verifreg_v17.rs b/fil_actor_decoder/tests/verifreg_v17.rs new file mode 100644 index 00000000..9686a246 --- /dev/null +++ b/fil_actor_decoder/tests/verifreg_v17.rs @@ -0,0 +1,205 @@ +//! Snapshot tests for Verified Registry (f06) actor — v17. +//! +//! Real on-chain data sourced via `Filecoin.ChainGetMessage` / `Filecoin.StateReplay` +//! against https://filfox.info/rpc/v1 (mainnet) and https://calibration.filfox.info/rpc/v1. +//! Synthetic tests use `fvm_ipld_encoding::to_vec` on actual v17 types. + +use fil_actor_decoder::{ActorType, ActorVersion, decode_params, decode_return}; +use fvm_ipld_encoding::to_vec; +use fvm_shared4::address::Address; +use num_bigint::BigInt; + +fn decode_hex(hex: &str) -> Vec { + hex::decode(hex.strip_prefix("0x").unwrap_or(hex)).unwrap() +} + +const V: ActorVersion = ActorVersion::V17; +const A: ActorType = ActorType::VerifiedRegistry; + +// ── Real on-chain — mainnet ───────────────────────────────────────────── + +/// AddVerifiedClient params — mainnet epoch 5844742 +/// Source: bafy2bzacebr2jvqzsqr6bxzll3zxl5f3rt74ovxnrynotcxqfgtmsumthbjmw +#[test] +fn mainnet_add_verified_client_params() { + let hex = "825501eb50a2528a325eadc4bb68d975a4d1700c9eeaa3480001900000000000"; + insta::assert_json_snapshot!(decode_params(A, V, 4, &decode_hex(hex)).unwrap()); +} + +/// RemoveExpiredAllocations params — mainnet epoch 5682849 +/// Source: bafy2bzacebf6jykld5fl4lkmbtgjw54mumprjowyzbzoevesjqqpy2w7jczaq +#[test] +fn mainnet_remove_expired_allocations_params() { + let hex = "821a00303d2980"; + insta::assert_json_snapshot!(decode_params(A, V, 8, &decode_hex(hex)).unwrap()); +} + +/// RemoveExpiredAllocations return — mainnet epoch 5682849 (8537 bytes, loaded from fixture) +/// Source: bafy2bzacebf6jykld5fl4lkmbtgjw54mumprjowyzbzoevesjqqpy2w7jczaq +#[test] +fn mainnet_remove_expired_allocations_return() { + let hex = std::fs::read_to_string(concat!( + env!("CARGO_MANIFEST_DIR"), + "/tests/fixtures/mainnet_verifreg_remove_expired_allocations_return.hex" + )) + .unwrap(); + insta::assert_json_snapshot!(decode_return(A, V, 8, &decode_hex(hex.trim())).unwrap()); +} + +/// ExtendClaimTerms return — mainnet epoch 5844995 (300 claims, all successful) +/// Source: bafy2bzacedu4zc7w3dt5lthct7gog3hsfbtw2ervtgcxm6yfot23be25tvbbs +#[test] +fn mainnet_extend_claim_terms_return() { + let hex = "8219012c80"; + insta::assert_json_snapshot!(decode_return(A, V, 11, &decode_hex(hex)).unwrap()); +} + +// ── Real on-chain — calibnet ──────────────────────────────────────────── + +/// AddVerifiedClient params — calibnet epoch 3531235 +/// Source: bafy2bzacebnkn7rm4hohnpxwpx3s3rjr3k2jhcixdgf753sq5rbqmtcqkvdcg +#[test] +fn calibnet_add_verified_client_params() { + let hex = "8258310387624255a0765266b5759ca7775e4bd8b03ff786699696f99203d71440aec01b5b6351cdf92bf891858eda927512bc81470015d3ef798000"; + insta::assert_json_snapshot!(decode_params(A, V, 4, &decode_hex(hex)).unwrap()); +} + +/// AddVerifiedClientExported params — calibnet epoch 3531856 +/// Source: bafy2bzacedthu6mzx4iqopahgreqc4ujz6hlg235jgr7mixaqeh2camtbzzdw +#[test] +fn calibnet_add_verified_client_exported_params() { + let hex = "8244009bfc094400100000"; + insta::assert_json_snapshot!(decode_params(A, V, 3916220144, &decode_hex(hex)).unwrap()); +} + +// ── Synthetic ─────────────────────────────────────────────────────────── + +#[test] +fn remove_verifier_params() { + let p = fil_actor_verifreg_state::v17::RemoveVerifierParams { + verifier: Address::new_id(999), + }; + insta::assert_json_snapshot!(decode_params(A, V, 3, &to_vec(&p).unwrap()).unwrap()); +} + +#[test] +fn get_claims_params() { + let p = fil_actor_verifreg_state::v17::GetClaimsParams { + provider: 1234, + claim_ids: vec![100, 200, 300], + }; + insta::assert_json_snapshot!(decode_params(A, V, 10, &to_vec(&p).unwrap()).unwrap()); +} + +#[test] +fn get_claims_return() { + let r = fil_actor_verifreg_state::v17::GetClaimsReturn { + batch_info: fil_actors_shared::v17::BatchReturn { + success_count: 3, + fail_codes: vec![], + }, + claims: vec![fil_actor_verifreg_state::v17::Claim { + provider: 1234, + client: 5678, + data: cid::Cid::default(), + size: fvm_shared4::piece::PaddedPieceSize(34359738368), + term_min: 518400, + term_max: 5256000, + term_start: 4000000, + sector: 42, + }], + }; + insta::assert_json_snapshot!(decode_return(A, V, 10, &to_vec(&r).unwrap()).unwrap()); +} + +#[test] +fn claim_allocations_params() { + let p = fil_actor_verifreg_state::v17::ClaimAllocationsParams { + sectors: vec![fil_actor_verifreg_state::v17::SectorAllocationClaims { + sector: 100, + expiry: 6000000, + claims: vec![fil_actor_verifreg_state::v17::AllocationClaim { + client: 5678, + allocation_id: 9999, + data: cid::Cid::default(), + size: fvm_shared4::piece::PaddedPieceSize(34359738368), + }], + }], + all_or_nothing: true, + }; + insta::assert_json_snapshot!(decode_params(A, V, 9, &to_vec(&p).unwrap()).unwrap()); +} + +#[test] +fn claim_allocations_return() { + let r = fil_actor_verifreg_state::v17::ClaimAllocationsReturn { + sector_results: fil_actors_shared::v17::BatchReturn { + success_count: 1, + fail_codes: vec![], + }, + sector_claims: vec![fil_actor_verifreg_state::v17::SectorClaimSummary { + claimed_space: BigInt::from(34359738368_u64), + }], + }; + insta::assert_json_snapshot!(decode_return(A, V, 9, &to_vec(&r).unwrap()).unwrap()); +} + +#[test] +fn extend_claim_terms_params() { + let p = fil_actor_verifreg_state::v17::ExtendClaimTermsParams { + terms: vec![fil_actor_verifreg_state::v17::ClaimTerm { + provider: 1234, + claim_id: 5678, + term_max: 5256000, + }], + }; + insta::assert_json_snapshot!(decode_params(A, V, 11, &to_vec(&p).unwrap()).unwrap()); +} + +#[test] +fn remove_expired_claims_params() { + let p = fil_actor_verifreg_state::v17::RemoveExpiredClaimsParams { + provider: 1234, + claim_ids: vec![10, 20, 30], + }; + insta::assert_json_snapshot!(decode_params(A, V, 12, &to_vec(&p).unwrap()).unwrap()); +} + +#[test] +fn remove_expired_claims_return() { + let r = fil_actor_verifreg_state::v17::RemoveExpiredClaimsReturn { + considered: vec![10, 20, 30], + results: fil_actors_shared::v17::BatchReturn { + success_count: 2, + fail_codes: vec![fil_actors_shared::v17::FailCode { + idx: 2, + code: fvm_shared4::error::ExitCode::USR_NOT_FOUND, + }], + }, + }; + insta::assert_json_snapshot!(decode_return(A, V, 12, &to_vec(&r).unwrap()).unwrap()); +} + +#[test] +fn universal_receiver_hook_params() { + let p = fil_actor_verifreg_state::v17::AllocationRequests { + allocations: vec![fil_actor_verifreg_state::v17::AllocationRequest { + provider: 1234, + data: cid::Cid::default(), + size: fvm_shared4::piece::PaddedPieceSize(1048576), + term_min: 518400, + term_max: 1036800, + expiration: 6000000, + }], + extensions: vec![], + }; + insta::assert_json_snapshot!( + decode_params( + A, + V, + frc42_dispatch::method_hash!("Receive"), + &to_vec(&p).unwrap() + ) + .unwrap() + ); +} diff --git a/fil_actor_decoder/tests/verifreg_v9.rs b/fil_actor_decoder/tests/verifreg_v9.rs new file mode 100644 index 00000000..25763028 --- /dev/null +++ b/fil_actor_decoder/tests/verifreg_v9.rs @@ -0,0 +1,19 @@ +//! Snapshot tests for Verified Registry (f06) actor — v9. +//! Real on-chain data from mainnet. + +use fil_actor_decoder::{ActorType, ActorVersion, decode_params}; + +fn decode_hex(hex: &str) -> Vec { + hex::decode(hex.strip_prefix("0x").unwrap_or(hex)).unwrap() +} + +const V: ActorVersion = ActorVersion::V9; +const A: ActorType = ActorType::VerifiedRegistry; + +/// AddVerifiedClient — mainnet epoch 2459914 (NV17/Shark era) +/// Source: bafy2bzacecnu3o2dhjardiwmudwvjwgbpqktk3mcwfb46w4g27a4c3hlr5zce +#[test] +fn mainnet_add_verified_client_params() { + let hex = "825501d148e4224e0f2b5cb5dc8b669015225260b1708546000800000000"; + insta::assert_json_snapshot!(decode_params(A, V, 4, &decode_hex(hex)).unwrap()); +} diff --git a/fil_actor_json_derive/Cargo.toml b/fil_actor_json_derive/Cargo.toml new file mode 100644 index 00000000..0d361495 --- /dev/null +++ b/fil_actor_json_derive/Cargo.toml @@ -0,0 +1,15 @@ +[package] +name = "fil_actor_json_derive" +version = "0.1.0" +edition.workspace = true +license.workspace = true +repository.workspace = true +description = "Derive macro for converting Serialize_tuple Filecoin actor types to JSON objects with named fields" + +[lib] +proc-macro = true + +[dependencies] +proc-macro2 = "1" +quote = "1" +syn = { version = "2", features = ["derive", "parsing"] } diff --git a/fil_actor_json_derive/src/lib.rs b/fil_actor_json_derive/src/lib.rs new file mode 100644 index 00000000..e17c38e8 --- /dev/null +++ b/fil_actor_json_derive/src/lib.rs @@ -0,0 +1,186 @@ +//! Derive macro for converting `Serialize_tuple` Filecoin actor types into +//! `serde_json::Value` objects with named fields. +//! +//! # Problem +//! +//! Filecoin actor types use `#[derive(Serialize_tuple)]` which serializes structs +//! as CBOR arrays (positional, no field names). When you call `serde_json::to_value()` +//! on these types, you get JSON arrays instead of objects: +//! +//! ```text +//! // MintParams { to: f01234, amount: 1000, operators: [f05678] } +//! serde_json::to_value() → ["f01234", "1000", ["f05678"]] // no field names! +//! ``` +//! +//! # Solution +//! +//! `#[derive(IntoJsonValue)]` generates a `to_json_value()` method that produces +//! proper JSON objects with named fields. Each field is converted via the +//! `JsonField` trait (from `fil_actors_shared::json_field`). +//! +//! ```text +//! params.to_json_value() → {"to": "f01234", "amount": "1000", "operators": ["f05678"]} +//! ``` +//! +//! # Adding New Types +//! +//! To support a new field type, implement `JsonField` for it in +//! `fil_actors_shared/src/json_field.rs`. No macro changes needed. +//! +//! # Field Attributes +//! +//! - `#[json_value(bigint)]` — treat field as BigInt (calls `.to_string()`) +//! - Auto-detected: `#[serde(with = "bigint_ser")]` has the same effect +//! +//! # Struct Attributes +//! +//! - `#[serde(transparent)]` is detected: the generated method delegates to the single field + +use proc_macro::TokenStream; +use quote::quote; +use syn::{Data, DeriveInput, Fields, parse_macro_input}; + +#[proc_macro_derive(IntoJsonValue, attributes(json_value))] +pub fn derive_into_json_value(input: TokenStream) -> TokenStream { + let input = parse_macro_input!(input as DeriveInput); + let name = &input.ident; + + let data = match &input.data { + Data::Struct(data) => data, + _ => { + return syn::Error::new_spanned(&input, "IntoJsonValue only supports structs") + .to_compile_error() + .into(); + } + }; + + let fields = match &data.fields { + Fields::Named(f) => &f.named, + _ => { + return syn::Error::new_spanned( + &input, + "IntoJsonValue only supports structs with named fields", + ) + .to_compile_error() + .into(); + } + }; + + // Check for #[serde(transparent)] + let is_transparent = input.attrs.iter().any(|attr| { + if !attr.path().is_ident("serde") { + return false; + } + let mut found = false; + let _ = attr.parse_nested_meta(|meta| { + if meta.path.is_ident("transparent") { + found = true; + } + Ok(()) + }); + found + }); + + if is_transparent && fields.len() == 1 { + let field = fields.first().unwrap(); + let field_name = field.ident.as_ref().unwrap(); + let converter = field_converter(field_name, &field.attrs); + let expanded = quote! { + impl #name { + pub fn to_json_value(&self) -> serde_json::Value { + #converter + } + } + impl fil_actors_shared::json_field::JsonField for #name { + fn to_json_field(&self) -> serde_json::Value { + self.to_json_value() + } + } + }; + return expanded.into(); + } + + // Regular struct: produce a JSON object with named fields + let field_count = fields.len(); + let field_entries: Vec<_> = fields + .iter() + .map(|f| { + let field_name = f.ident.as_ref().unwrap(); + let field_name_str = field_name.to_string(); + let converter = field_converter(field_name, &f.attrs); + quote! { + map.insert(#field_name_str.to_string(), #converter); + } + }) + .collect(); + + let expanded = quote! { + impl #name { + pub fn to_json_value(&self) -> serde_json::Value { + let mut map = serde_json::Map::with_capacity(#field_count); + #(#field_entries)* + serde_json::Value::Object(map) + } + } + impl fil_actors_shared::json_field::JsonField for #name { + fn to_json_field(&self) -> serde_json::Value { + self.to_json_value() + } + } + }; + + expanded.into() +} + +/// Generate the conversion expression for a single field. +/// +/// - BigInt-annotated fields use `BigIntJsonField::bigint_to_json_field()` +/// - All other fields use `JsonField::to_json_field()` +fn field_converter(field_name: &syn::Ident, attrs: &[syn::Attribute]) -> proc_macro2::TokenStream { + if has_json_value_attr(attrs, "bigint") || has_serde_bigint(attrs) { + quote! { + fil_actors_shared::json_field::BigIntJsonField::bigint_to_json_field(&self.#field_name) + } + } else { + quote! { + fil_actors_shared::json_field::JsonField::to_json_field(&self.#field_name) + } + } +} + +/// Check if a field has a specific `#[json_value(...)]` attribute +fn has_json_value_attr(attrs: &[syn::Attribute], attr_name: &str) -> bool { + attrs.iter().any(|attr| { + if !attr.path().is_ident("json_value") { + return false; + } + let mut found = false; + let _ = attr.parse_nested_meta(|meta| { + if meta.path.is_ident(attr_name) { + found = true; + } + Ok(()) + }); + found + }) +} + +/// Check if a field has `#[serde(with = "bigint_ser")]` +fn has_serde_bigint(attrs: &[syn::Attribute]) -> bool { + attrs.iter().any(|attr| { + if !attr.path().is_ident("serde") { + return false; + } + let mut found = false; + let _ = attr.parse_nested_meta(|meta| { + if meta.path.is_ident("with") + && let Ok(lit) = meta.value().and_then(|v| v.parse::()) + && lit.value().ends_with("bigint_ser") + { + found = true; + } + Ok(()) + }); + found + }) +} diff --git a/fil_actors_shared/Cargo.toml b/fil_actors_shared/Cargo.toml index 6181a2b3..c69797e8 100644 --- a/fil_actors_shared/Cargo.toml +++ b/fil_actors_shared/Cargo.toml @@ -38,9 +38,19 @@ strum = { version = "0.28.0", features = ["derive"] } thiserror = { workspace = true } unsigned-varint = { workspace = true } +# Optional: JSON value conversion +base64 = { workspace = true, optional = true } +fil_actor_json_derive = { workspace = true, optional = true } +serde_json = { workspace = true, optional = true } + [features] default = [] -json = ["fvm_ipld_bitfield/json"] +json = [ + "fvm_ipld_bitfield/json", + "dep:fil_actor_json_derive", + "dep:serde_json", + "dep:base64", +] arb = ["quickcheck"] [package.metadata.cargo-udeps.ignore] diff --git a/fil_actors_shared/src/json_field.rs b/fil_actors_shared/src/json_field.rs new file mode 100644 index 00000000..3766235a --- /dev/null +++ b/fil_actors_shared/src/json_field.rs @@ -0,0 +1,181 @@ +//! Trait-based JSON field conversion for Filecoin actor types. +//! +//! Provides [`JsonField`] — a trait that converts values to `serde_json::Value` +//! with Filecoin-appropriate representations (e.g., `Address` → string, +//! `TokenAmount` → atto string, `Cid` → CID string). +//! +//! Adding a new Filecoin type only requires a trait impl here — no derive macro +//! changes needed. + +use serde_json::Value; + +/// Convert a value to a JSON field representation. +/// +/// Implement this trait for any type that appears as a struct field in +/// `#[derive(IntoJsonValue)]` types. The derive macro calls `.to_json_field()` +/// on each field. +pub trait JsonField { + fn to_json_field(&self) -> Value; +} + +// --------------------------------------------------------------------------- +// Primitives +// --------------------------------------------------------------------------- + +impl JsonField for bool { + fn to_json_field(&self) -> Value { + Value::Bool(*self) + } +} + +impl JsonField for String { + fn to_json_field(&self) -> Value { + Value::String(self.clone()) + } +} + +macro_rules! impl_json_field_number { + ($($t:ty),*) => { + $( + impl JsonField for $t { + fn to_json_field(&self) -> Value { + serde_json::json!(*self) + } + } + )* + }; +} + +impl_json_field_number!(u8, u16, u32, u64, i8, i16, i32, i64, usize, isize); + +// --------------------------------------------------------------------------- +// Containers +// --------------------------------------------------------------------------- + +impl JsonField for Vec { + fn to_json_field(&self) -> Value { + Value::Array(self.iter().map(|item| item.to_json_field()).collect()) + } +} + +impl JsonField for Option { + fn to_json_field(&self) -> Value { + match self { + Some(v) => v.to_json_field(), + None => Value::Null, + } + } +} + +// --------------------------------------------------------------------------- +// Filecoin / FVM types — shared across fvm_shared2, fvm_shared3, fvm_shared4 +// --------------------------------------------------------------------------- + +/// Generates `JsonField` impls for the standard FVM types in a given fvm_shared crate. +/// All three versions (fvm_shared2, fvm_shared3, fvm_shared4) expose identical APIs +/// for Address, TokenAmount, PaddedPieceSize, Signature, and ExitCode. +macro_rules! impl_json_field_fvm_shared { + ($addr:ty, $token:ty, $piece:ty, $sig:ty, $exit:ty) => { + impl JsonField for $addr { + fn to_json_field(&self) -> Value { + Value::String(self.to_string()) + } + } + + impl JsonField for $token { + fn to_json_field(&self) -> Value { + Value::String(self.atto().to_string()) + } + } + + impl JsonField for $piece { + fn to_json_field(&self) -> Value { + serde_json::json!(self.0) + } + } + + impl JsonField for $sig { + fn to_json_field(&self) -> Value { + use base64::Engine; + let mut m = serde_json::Map::with_capacity(2); + m.insert( + "type".to_string(), + Value::String(format!("{:?}", self.signature_type())), + ); + m.insert( + "data".to_string(), + Value::String(base64::engine::general_purpose::STANDARD.encode(self.bytes())), + ); + Value::Object(m) + } + } + + impl JsonField for $exit { + fn to_json_field(&self) -> Value { + Value::from(self.value()) + } + } + }; +} + +impl_json_field_fvm_shared!( + fvm_shared4::address::Address, + fvm_shared4::econ::TokenAmount, + fvm_shared4::piece::PaddedPieceSize, + fvm_shared4::crypto::signature::Signature, + fvm_shared4::error::ExitCode +); +impl_json_field_fvm_shared!( + fvm_shared3::address::Address, + fvm_shared3::econ::TokenAmount, + fvm_shared3::piece::PaddedPieceSize, + fvm_shared3::crypto::signature::Signature, + fvm_shared3::error::ExitCode +); +impl_json_field_fvm_shared!( + crate::fvm_shared2::address::Address, + crate::fvm_shared2::econ::TokenAmount, + crate::fvm_shared2::piece::PaddedPieceSize, + crate::fvm_shared2::crypto::signature::Signature, + crate::fvm_shared2::error::ExitCode +); + +// --------------------------------------------------------------------------- +// Other Filecoin types +// --------------------------------------------------------------------------- + +impl JsonField for num_bigint::BigInt { + fn to_json_field(&self) -> Value { + Value::String(self.to_string()) + } +} + +impl JsonField for cid::Cid { + fn to_json_field(&self) -> Value { + Value::String(self.to_string()) + } +} + +impl JsonField for fvm_ipld_encoding::RawBytes { + fn to_json_field(&self) -> Value { + use base64::Engine; + Value::String(base64::engine::general_purpose::STANDARD.encode(self.bytes())) + } +} + +// --------------------------------------------------------------------------- +// Marker trait for BigInt-like types serialized with `#[serde(with = "bigint_ser")]`. +// The derive macro uses `BigIntJsonField::bigint_to_json_field()` for these. +// --------------------------------------------------------------------------- + +/// Trait used by the derive macro for fields annotated with `#[json_value(bigint)]` +/// or `#[serde(with = "bigint_ser")]`. +pub trait BigIntJsonField { + fn bigint_to_json_field(&self) -> Value; +} + +impl BigIntJsonField for T { + fn bigint_to_json_field(&self) -> Value { + Value::String(self.to_string()) + } +} diff --git a/fil_actors_shared/src/lib.rs b/fil_actors_shared/src/lib.rs index 0779ece3..b7305f91 100644 --- a/fil_actors_shared/src/lib.rs +++ b/fil_actors_shared/src/lib.rs @@ -1,8 +1,13 @@ // Copyright 2019-2022 ChainSafe Systems // SPDX-License-Identifier: Apache-2.0, MIT +#[cfg(feature = "json")] +extern crate self as fil_actors_shared; + pub mod abi; pub mod actor_versions; +#[cfg(feature = "json")] +pub mod json_field; pub mod v10; pub mod v11; pub mod v12; diff --git a/fil_actors_shared/src/v10/util/batch_return.rs b/fil_actors_shared/src/v10/util/batch_return.rs index 65e44fd0..940e4ae4 100644 --- a/fil_actors_shared/src/v10/util/batch_return.rs +++ b/fil_actors_shared/src/v10/util/batch_return.rs @@ -5,12 +5,14 @@ use fvm_ipld_encoding::tuple::*; use fvm_shared3::error::ExitCode; use std::fmt; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug, PartialEq, Eq)] pub struct FailCode { pub idx: u32, pub code: ExitCode, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Clone, PartialEq, Eq, Debug)] pub struct BatchReturn { // Total successes in batch diff --git a/fil_actors_shared/src/v11/util/batch_return.rs b/fil_actors_shared/src/v11/util/batch_return.rs index 57e260a4..2ab46181 100644 --- a/fil_actors_shared/src/v11/util/batch_return.rs +++ b/fil_actors_shared/src/v11/util/batch_return.rs @@ -2,12 +2,14 @@ use fvm_ipld_encoding::tuple::*; use fvm_shared3::error::ExitCode; use std::fmt; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug, PartialEq, Eq)] pub struct FailCode { pub idx: u32, pub code: ExitCode, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Clone, PartialEq, Eq, Debug)] pub struct BatchReturn { // Total successes in batch diff --git a/fil_actors_shared/src/v12/util/batch_return.rs b/fil_actors_shared/src/v12/util/batch_return.rs index 71258a7e..1d9fca40 100644 --- a/fil_actors_shared/src/v12/util/batch_return.rs +++ b/fil_actors_shared/src/v12/util/batch_return.rs @@ -5,12 +5,14 @@ use fvm_ipld_encoding::tuple::*; use fvm_shared4::error::ExitCode; use std::fmt; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug, PartialEq, Eq)] pub struct FailCode { pub idx: u32, pub code: ExitCode, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Clone, PartialEq, Eq, Debug)] pub struct BatchReturn { // Total successes in batch diff --git a/fil_actors_shared/src/v13/util/batch_return.rs b/fil_actors_shared/src/v13/util/batch_return.rs index 3648c4b6..4d102ccd 100644 --- a/fil_actors_shared/src/v13/util/batch_return.rs +++ b/fil_actors_shared/src/v13/util/batch_return.rs @@ -2,12 +2,14 @@ use fvm_ipld_encoding::tuple::*; use fvm_shared4::error::ExitCode; use std::fmt; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug, PartialEq, Eq)] pub struct FailCode { pub idx: u32, pub code: ExitCode, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Clone, PartialEq, Eq, Debug)] pub struct BatchReturn { // Total successes in batch diff --git a/fil_actors_shared/src/v14/util/batch_return.rs b/fil_actors_shared/src/v14/util/batch_return.rs index ea669e5d..9ae519a1 100644 --- a/fil_actors_shared/src/v14/util/batch_return.rs +++ b/fil_actors_shared/src/v14/util/batch_return.rs @@ -2,12 +2,14 @@ use fvm_ipld_encoding::tuple::*; use fvm_shared4::error::ExitCode; use std::fmt; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug, PartialEq, Eq)] pub struct FailCode { pub idx: u32, pub code: ExitCode, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Clone, PartialEq, Eq, Debug)] pub struct BatchReturn { // Total successes in batch diff --git a/fil_actors_shared/src/v15/util/batch_return.rs b/fil_actors_shared/src/v15/util/batch_return.rs index 25071d33..b49598d1 100644 --- a/fil_actors_shared/src/v15/util/batch_return.rs +++ b/fil_actors_shared/src/v15/util/batch_return.rs @@ -2,12 +2,14 @@ use fvm_ipld_encoding::tuple::*; use fvm_shared4::error::ExitCode; use std::fmt; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug, PartialEq, Eq)] pub struct FailCode { pub idx: u32, pub code: ExitCode, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Clone, PartialEq, Eq, Debug)] pub struct BatchReturn { // Total successes in batch diff --git a/fil_actors_shared/src/v16/util/batch_return.rs b/fil_actors_shared/src/v16/util/batch_return.rs index 9142ab6b..783d4a2e 100644 --- a/fil_actors_shared/src/v16/util/batch_return.rs +++ b/fil_actors_shared/src/v16/util/batch_return.rs @@ -2,12 +2,14 @@ use fvm_ipld_encoding::tuple::*; use fvm_shared4::error::ExitCode; use std::fmt; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug, PartialEq, Eq)] pub struct FailCode { pub idx: u32, pub code: ExitCode, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Clone, PartialEq, Eq, Debug)] pub struct BatchReturn { // Total successes in batch diff --git a/fil_actors_shared/src/v17/util/batch_return.rs b/fil_actors_shared/src/v17/util/batch_return.rs index 200eedde..7079e5ba 100644 --- a/fil_actors_shared/src/v17/util/batch_return.rs +++ b/fil_actors_shared/src/v17/util/batch_return.rs @@ -2,12 +2,14 @@ use fvm_ipld_encoding::tuple::*; use fvm_shared4::error::ExitCode; use std::fmt; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug, PartialEq, Eq)] pub struct FailCode { pub idx: u32, pub code: ExitCode, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Clone, PartialEq, Eq, Debug)] pub struct BatchReturn { // Total successes in batch diff --git a/fil_actors_shared/src/v9/util/batch_return.rs b/fil_actors_shared/src/v9/util/batch_return.rs index a53d8cb8..4271c5c9 100644 --- a/fil_actors_shared/src/v9/util/batch_return.rs +++ b/fil_actors_shared/src/v9/util/batch_return.rs @@ -5,12 +5,14 @@ use fvm_ipld_encoding::tuple::*; use fvm_shared::error::ExitCode; use std::fmt; +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Clone, Debug, PartialEq, Eq)] pub struct FailCode { pub idx: u32, pub code: ExitCode, } +#[cfg_attr(feature = "json", derive(fil_actor_json_derive::IntoJsonValue))] #[derive(Serialize_tuple, Deserialize_tuple, Clone, PartialEq, Eq, Debug)] pub struct BatchReturn { // Total successes in batch diff --git a/mise.toml b/mise.toml index 766c657e..352d44fb 100644 --- a/mise.toml +++ b/mise.toml @@ -110,6 +110,34 @@ sed -i -e 's|fil_actor_verifreg_state =.*|fil_actor_verifreg_state = { path = ". sed -i -e 's|fil_actor_market_state =.*|fil_actor_market_state = { path = "../actors/market" }|g' ./forest/Cargo.toml ''' +# --------------------------------------------------------------------------- +# Decoder tasks +# --------------------------------------------------------------------------- + +[tasks."decoder:test"] +description = "Run all decoder tests (unit + snapshot)." +run = "cargo test -p fil_actor_decoder" + +[tasks."decoder:test-all"] +description = "Run decoder + type-level JSON tests across all actor versions." +run = """ +cargo test -p fil_actor_decoder +cargo test -p fil_actor_datacap_state --features json +cargo test -p fil_actor_verifreg_state --features json +""" + +[tasks."decoder:snap-review"] +description = "Review pending insta snapshot changes." +run = "cargo insta review --manifest-path fil_actor_decoder/Cargo.toml" + +[tasks."decoder:snap-accept"] +description = "Accept all pending insta snapshot changes." +run = "cargo insta accept --manifest-path fil_actor_decoder/Cargo.toml" + +[tasks."decoder:clippy"] +description = "Run clippy on the decoder and shared crates." +run = "cargo clippy -p fil_actor_decoder -p fil_actors_shared --features json -- -D warnings" + [tasks.clean] description = "Clean the project." run = "cargo clean"