Skip to content

Commit

Permalink
[refactor] hyperledger-iroha#3660: Remove unused boxed structures
Browse files Browse the repository at this point in the history
Signed-off-by: Shanin Roman <[email protected]>
  • Loading branch information
Erigara committed Mar 1, 2024
1 parent 1304cfc commit bc2b69b
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 110 deletions.
Binary file modified configs/swarm/executor.wasm
Binary file not shown.
12 changes: 4 additions & 8 deletions configs/swarm/genesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,16 @@
{
"Mint": {
"Asset": {
"Numeric": {
"object": "13",
"destination_id": "rose##alice@wonderland"
}
"object": "13",
"destination_id": "rose##alice@wonderland"
}
}
},
{
"Mint": {
"Asset": {
"Numeric": {
"object": "44",
"destination_id": "cabbage#garden_of_live_flowers#alice@wonderland"
}
"object": "44",
"destination_id": "cabbage#garden_of_live_flowers#alice@wonderland"
}
}
},
Expand Down
22 changes: 0 additions & 22 deletions core/src/smartcontracts/isi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,6 @@ impl Execute for AccountMintBox {
}
}

impl Execute for AssetMintBox {
fn execute(
self,
authority: &AccountId,
wsv: &mut WorldStateView,
) -> std::prelude::v1::Result<(), Error> {
let Self::Numeric(isi) = self;
isi.execute(authority, wsv)
}
}

impl Execute for BurnBox {
#[iroha_logger::log(name = "burn", skip_all, fields(destination))]
fn execute(self, authority: &AccountId, wsv: &mut WorldStateView) -> Result<(), Error> {
Expand All @@ -129,17 +118,6 @@ impl Execute for BurnBox {
}
}

impl Execute for AssetBurnBox {
fn execute(
self,
authority: &AccountId,
wsv: &mut WorldStateView,
) -> std::prelude::v1::Result<(), Error> {
let Self::Numeric(isi) = self;
isi.execute(authority, wsv)
}
}

impl Execute for TransferBox {
#[iroha_logger::log(name = "transfer", skip_all, fields(from, to))]
fn execute(self, authority: &AccountId, wsv: &mut WorldStateView) -> Result<(), Error> {
Expand Down
52 changes: 6 additions & 46 deletions data_model/src/isi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -673,12 +673,6 @@ mod transparent {
=> AccountMintBoxRef<'a> => MintBoxRef<'a>[Account]
}

impl_into_box! {
Mint<Numeric, Asset>
=> AssetMintBox => MintBox[Asset],
=> AssetMintBoxRef<'a> => MintBoxRef<'a>[Asset]
}

impl_into_box! {
Mint<PublicKey, Account> |
Mint<SignatureCheckCondition, Account> |
Expand Down Expand Up @@ -741,12 +735,6 @@ mod transparent {
destination_id,
}

impl_into_box! {
Burn<Numeric, Asset>
=> AssetBurnBox => BurnBox[Asset],
=> AssetBurnBoxRef<'a> => BurnBoxRef<'a>[Asset]
}

impl_into_box! {
Burn<PublicKey, Account> |
Burn<Numeric, Asset> |
Expand Down Expand Up @@ -1117,8 +1105,7 @@ isi_box! {
#[enum_ref(transparent)]
Account(AccountMintBox),
/// Mint for [`Asset`].
#[enum_ref(transparent)]
Asset(AssetMintBox),
Asset(Mint<Numeric, Asset>),
/// Mint [`Trigger`] repetitions.
TriggerRepetitions(Mint<u32, Trigger<TriggeringFilterBox>>),
}
Expand All @@ -1139,19 +1126,6 @@ isi_box! {
}
}

isi_box! {
#[strum_discriminants(
vis(pub(crate)),
name(AssetMintType),
derive(Encode),
)]
/// Enum with all supported [`Mint`] instructions related to [`Asset`].
pub enum AssetMintBox {
/// Mint [`Asset`] of [`Numeric`] type.
Numeric(Mint<Numeric, Asset>),
}
}

isi_box! {
#[strum_discriminants(
vis(pub(crate)),
Expand All @@ -1163,26 +1137,12 @@ isi_box! {
/// Burn [`PublicKey`] for [`Account`].
AccountPublicKey(Burn<PublicKey, Account>),
/// Burn [`Asset`].
#[enum_ref(transparent)]
Asset(AssetBurnBox),
Asset(Burn<Numeric, Asset>),
/// Burn [`Trigger`] repetitions.
TriggerRepetitions(Burn<u32, Trigger<TriggeringFilterBox>>),
}
}

isi_box! {
#[strum_discriminants(
vis(pub(crate)),
name(AssetBurnType),
derive(Encode),
)]
/// Enum with all supported [`Burn`] instructions related to [`Asset`].
pub enum AssetBurnBox {
/// Burn [`Asset`] of [`Numeric`] type.
Numeric(Burn<Numeric, Asset>),
}
}

isi_box! {
#[strum_discriminants(
vis(pub(crate)),
Expand Down Expand Up @@ -1556,9 +1516,9 @@ pub mod error {
/// The prelude re-exports most commonly used traits, structs and macros from this crate.
pub mod prelude {
pub use super::{
AccountMintBox, AssetBurnBox, AssetMintBox, AssetTransferBox, Burn, BurnBox,
ExecuteTrigger, Fail, Grant, GrantBox, InstructionBox, Log, Mint, MintBox, NewParameter,
Register, RegisterBox, RemoveKeyValue, RemoveKeyValueBox, Revoke, RevokeBox, SetKeyValue,
SetKeyValueBox, SetParameter, Transfer, TransferBox, Unregister, UnregisterBox, Upgrade,
AccountMintBox, AssetTransferBox, Burn, BurnBox, ExecuteTrigger, Fail, Grant, GrantBox,
InstructionBox, Log, Mint, MintBox, NewParameter, Register, RegisterBox, RemoveKeyValue,
RemoveKeyValueBox, Revoke, RevokeBox, SetKeyValue, SetKeyValueBox, SetParameter, Transfer,
TransferBox, Unregister, UnregisterBox, Upgrade,
};
}
8 changes: 2 additions & 6 deletions data_model/src/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,19 +306,15 @@ pub fn visit_mint<V: Visit + ?Sized>(visitor: &mut V, authority: &AccountId, isi
visitor.visit_mint_account_signature_check_condition(authority, obj)
}
},
MintBox::Asset(mint_asset) => match mint_asset {
AssetMintBox::Numeric(obj) => visitor.visit_mint_asset_numeric(authority, obj),
},
MintBox::Asset(obj) => visitor.visit_mint_asset_numeric(authority, obj),
MintBox::TriggerRepetitions(obj) => visitor.visit_mint_trigger_repetitions(authority, obj),
}
}

pub fn visit_burn<V: Visit + ?Sized>(visitor: &mut V, authority: &AccountId, isi: &BurnBox) {
match isi {
BurnBox::AccountPublicKey(obj) => visitor.visit_burn_account_public_key(authority, obj),
BurnBox::Asset(burn_asset) => match burn_asset {
AssetBurnBox::Numeric(obj) => visitor.visit_burn_asset_numeric(authority, obj),
},
BurnBox::Asset(obj) => visitor.visit_burn_asset_numeric(authority, obj),
BurnBox::TriggerRepetitions(obj) => visitor.visit_burn_trigger_repetitions(authority, obj),
}
}
Expand Down
32 changes: 10 additions & 22 deletions docs/source/references/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -279,15 +279,6 @@
}
]
},
"AssetBurnBox": {
"Enum": [
{
"tag": "Numeric",
"discriminant": 0,
"type": "Burn<Numeric, Asset>"
}
]
},
"AssetChanged": {
"Struct": [
{
Expand Down Expand Up @@ -533,15 +524,6 @@
}
]
},
"AssetMintBox": {
"Enum": [
{
"tag": "Numeric",
"discriminant": 0,
"type": "Mint<Numeric, Asset>"
}
]
},
"AssetTransferBox": {
"Enum": [
{
Expand Down Expand Up @@ -741,7 +723,7 @@
{
"tag": "Asset",
"discriminant": 1,
"type": "AssetBurnBox"
"type": "Burn<Numeric, Asset>"
},
{
"tag": "TriggerRepetitions",
Expand All @@ -751,6 +733,12 @@
]
},
"ChainId": "String",
"Compact<u128>": {
"Int": "Compact"
},
"Compact<u32>": {
"Int": "Compact"
},
"ConfigurationEvent": {
"Enum": [
{
Expand Down Expand Up @@ -2516,7 +2504,7 @@
{
"tag": "Asset",
"discriminant": 1,
"type": "AssetMintBox"
"type": "Mint<Numeric, Asset>"
},
{
"tag": "TriggerRepetitions",
Expand Down Expand Up @@ -2691,11 +2679,11 @@
"Struct": [
{
"name": "mantissa",
"type": "u128"
"type": "Compact<u128>"
},
{
"name": "scale",
"type": "u32"
"type": "Compact<u32>"
}
]
},
Expand Down
2 changes: 0 additions & 2 deletions schema/gen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ types!(
Action<TriggeringFilterBox>,
Algorithm,
Asset,
AssetBurnBox,
AssetChanged,
AssetDefinition,
AssetDefinitionEvent,
Expand All @@ -85,7 +84,6 @@ types!(
AssetEventFilter,
AssetFilter,
AssetId,
AssetMintBox,
AssetTransferBox,
AssetValue,
AssetValueType,
Expand Down
Binary file modified tools/parity_scale_decoder/samples/trigger.bin
Binary file not shown.
6 changes: 2 additions & 4 deletions tools/parity_scale_decoder/samples/trigger.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
{
"Mint": {
"Asset": {
"Numeric": {
"object": "1",
"destination_id": "rose##alice@wonderland"
}
"object": "1",
"destination_id": "rose##alice@wonderland"
}
}
}
Expand Down

0 comments on commit bc2b69b

Please sign in to comment.