diff --git a/lib/archethic/transaction_chain/transaction/validation_stamp/ledger_operations.ex b/lib/archethic/transaction_chain/transaction/validation_stamp/ledger_operations.ex index 6652691cc..595c791cd 100644 --- a/lib/archethic/transaction_chain/transaction/validation_stamp/ledger_operations.ex +++ b/lib/archethic/transaction_chain/transaction/validation_stamp/ledger_operations.ex @@ -390,8 +390,6 @@ defmodule ArchEthic.TransactionChain.Transaction.ValidationStamp.LedgerOperation # Unspent output amount (2 UCO) 0, 0, 0, 0, 11, 235, 194, 0, # Unspent output type (UCO) - 0, - # Unspent output reward? 0 >> """ @@ -422,7 +420,7 @@ defmodule ArchEthic.TransactionChain.Transaction.ValidationStamp.LedgerOperation ...> 0, 0, 0, 0, 60, 203, 247, 0, 0, ...> 1, 0, 0, 34, 118, 242, 194, 93, 131, 130, 195, 9, 97, 237, ...> 220, 195, 112, 1, 54, 221, 86, 154, 234, 96, 217, 149, 84, 188, 63, 242, 166, 47, 158, 139, 207, - ...> 0, 0, 0, 0, 11, 235, 194, 0, 0, 0>> + ...> 0, 0, 0, 0, 11, 235, 194, 0, 0>> ...> |> LedgerOperations.deserialize() { %LedgerOperations{ @@ -440,8 +438,7 @@ defmodule ArchEthic.TransactionChain.Transaction.ValidationStamp.LedgerOperation from: <<0, 0, 34, 118, 242, 194, 93, 131, 130, 195, 9, 97, 237, 220, 195, 112, 1, 54, 221, 86, 154, 234, 96, 217, 149, 84, 188, 63, 242, 166, 47, 158, 139, 207>>, amount: 200_000_000, - type: :UCO, - reward?: false + type: :UCO } ] }, diff --git a/lib/archethic/transaction_chain/transaction/validation_stamp/ledger_operations/unspent_output.ex b/lib/archethic/transaction_chain/transaction/validation_stamp/ledger_operations/unspent_output.ex index 74ecb12b5..87a2609fe 100644 --- a/lib/archethic/transaction_chain/transaction/validation_stamp/ledger_operations/unspent_output.ex +++ b/lib/archethic/transaction_chain/transaction/validation_stamp/ledger_operations/unspent_output.ex @@ -14,8 +14,7 @@ defmodule ArchEthic.TransactionChain.Transaction.ValidationStamp.LedgerOperation @type t :: %__MODULE__{ amount: non_neg_integer(), from: Crypto.versioned_hash(), - type: TransactionMovementType.t(), - reward?: boolean() + type: TransactionMovementType.t() } @doc """ @@ -39,8 +38,6 @@ defmodule ArchEthic.TransactionChain.Transaction.ValidationStamp.LedgerOperation # Amount 0, 0, 0, 0, 62, 149, 186, 128, # UCO Unspent Output - 0, - # Reward? 0 >> @@ -64,16 +61,12 @@ defmodule ArchEthic.TransactionChain.Transaction.ValidationStamp.LedgerOperation 1, # NFT address 0, 49, 101, 72, 154, 152, 3, 174, 47, 2, 35, 7, 92, 122, 206, 185, 71, 140, 74, - 197, 46, 99, 117, 89, 96, 100, 20, 0, 34, 181, 215, 143, 175, - # Reward? - 0 + 197, 46, 99, 117, 89, 96, 100, 20, 0, 34, 181, 215, 143, 175 >> """ @spec serialize(__MODULE__.t()) :: <<_::64, _::_*8>> - def serialize(%__MODULE__{from: from, amount: amount, type: type, reward?: reward?}) do - reward_bit = if reward?, do: 1, else: 0 - - <> + def serialize(%__MODULE__{from: from, amount: amount, type: type}) do + <> end @doc """ @@ -83,15 +76,14 @@ defmodule ArchEthic.TransactionChain.Transaction.ValidationStamp.LedgerOperation iex> <<0, 0, 214, 107, 17, 107, 227, 11, 17, 43, 204, 48, 78, 129, 145, 126, 45, 68, 194, ...> 159, 19, 92, 240, 29, 37, 105, 183, 232, 56, 42, 163, 236, 251, 186, - ...> 0, 0, 0, 0, 62, 149, 186, 128, 0, 0>> + ...> 0, 0, 0, 0, 62, 149, 186, 128, 0>> ...> |> UnspentOutput.deserialize() { %UnspentOutput{ from: <<0, 0, 214, 107, 17, 107, 227, 11, 17, 43, 204, 48, 78, 129, 145, 126, 45, 68, 194, 159, 19, 92, 240, 29, 37, 105, 183, 232, 56, 42, 163, 236, 251, 186>>, amount: 1_050_000_000, - type: :UCO, - reward?: false + type: :UCO }, "" } @@ -99,7 +91,7 @@ defmodule ArchEthic.TransactionChain.Transaction.ValidationStamp.LedgerOperation iex> <<0, 0, 214, 107, 17, 107, 227, 11, 17, 43, 204, 48, 78, 129, 145, 126, 45, 68, 194, ...> 159, 19, 92, 240, 29, 37, 105, 183, 232, 56, 42, 163, 236, 251, 186, ...> 0, 0, 0, 0, 62, 149, 186, 128, 1, 0, 0, 49, 101, 72, 154, 152, 3, 174, 47, 2, 35, 7, 92, 122, 206, 185, 71, 140, 74, - ...> 197, 46, 99, 117, 89, 96, 100, 20, 0, 34, 181, 215, 143, 175, 0 + ...> 197, 46, 99, 117, 89, 96, 100, 20, 0, 34, 181, 215, 143, 175 ...> >> ...> |> UnspentOutput.deserialize() { @@ -108,8 +100,7 @@ defmodule ArchEthic.TransactionChain.Transaction.ValidationStamp.LedgerOperation 159, 19, 92, 240, 29, 37, 105, 183, 232, 56, 42, 163, 236, 251, 186>>, amount: 1_050_000_000, type: {:NFT, <<0, 0, 49, 101, 72, 154, 152, 3, 174, 47, 2, 35, 7, 92, 122, 206, 185, 71, 140, 74, - 197, 46, 99, 117, 89, 96, 100, 20, 0, 34, 181, 215, 143, 175>>}, - reward?: false + 197, 46, 99, 117, 89, 96, 100, 20, 0, 34, 181, 215, 143, 175>>} }, "" } @@ -117,16 +108,13 @@ defmodule ArchEthic.TransactionChain.Transaction.ValidationStamp.LedgerOperation @spec deserialize(bitstring()) :: {__MODULE__.t(), bitstring} def deserialize(data) when is_bitstring(data) do {address, <>} = Utils.deserialize_address(data) - {type, <>} = TransactionMovementType.deserialize(rest) - - reward? = if reward_bit == 1, do: true, else: false + {type, rest} = TransactionMovementType.deserialize(rest) { %__MODULE__{ from: address, amount: amount, - type: type, - reward?: reward? + type: type }, rest } @@ -136,8 +124,7 @@ defmodule ArchEthic.TransactionChain.Transaction.ValidationStamp.LedgerOperation def from_map(unspent_output = %{}) do res = %__MODULE__{ from: Map.get(unspent_output, :from), - amount: Map.get(unspent_output, :amount), - reward?: Map.get(unspent_output, :reward) + amount: Map.get(unspent_output, :amount) } case Map.get(unspent_output, :type) do @@ -150,12 +137,11 @@ defmodule ArchEthic.TransactionChain.Transaction.ValidationStamp.LedgerOperation end @spec to_map(t()) :: map() - def to_map(%__MODULE__{from: from, amount: amount, type: :UCO, reward?: reward?}) do + def to_map(%__MODULE__{from: from, amount: amount, type: :UCO}) do %{ from: from, amount: amount, - type: "UCO", - reward: reward? + type: "UCO" } end @@ -164,8 +150,7 @@ defmodule ArchEthic.TransactionChain.Transaction.ValidationStamp.LedgerOperation from: from, amount: amount, type: "NFT", - nft_address: nft_address, - reward: false + nft_address: nft_address } end end diff --git a/priv/migrations/2_create_validation_stamp_type.cql b/priv/migrations/2_create_validation_stamp_type.cql index 7ef7f8c2a..1826eb776 100644 --- a/priv/migrations/2_create_validation_stamp_type.cql +++ b/priv/migrations/2_create_validation_stamp_type.cql @@ -9,8 +9,7 @@ CREATE TYPE IF NOT EXISTS archethic.ledger_operations_unspent_output( "from" blob, amount bigint, type varchar, - nft_address blob, - reward boolean + nft_address blob ); CREATE TYPE IF NOT EXISTS archethic.ledger_operations(