Skip to content

Commit

Permalink
fix deposit transaction
Browse files Browse the repository at this point in the history
  • Loading branch information
Ino Murko committed Dec 7, 2020
1 parent eafc094 commit 5fb6349
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
12 changes: 6 additions & 6 deletions apps/omg/lib/omg/output.ex
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ defmodule OMG.Output do
# TODO(achiurizo)
# remove the validation here and port the error tuple response handling into ex_plasma.
defp clean_and_validate_data([raw_type, [owner, currency, amount]]) do
with {:ok, type} <- RawData.parse_uint256(raw_type),
{:ok, _} <- valid_output_type?(type),
{:ok, owner1} <- RawData.parse_address(owner),
with {:ok, parsed_type} <- RawData.parse_uint256(raw_type),
{:ok, _} <- valid_output_type?(parsed_type),
{:ok, parsed_owner} <- RawData.parse_address(owner),
{:ok, _} <- non_zero_owner?(owner),
{:ok, currency1} <- RawData.parse_address(currency),
{:ok, amount1} <- RawData.parse_amount(amount),
do: {:ok, type, owner1, currency1, amount1}
{:ok, parsed_currency} <- RawData.parse_address(currency),
{:ok, parsed_amount} <- RawData.parse_amount(amount),
do: {:ok, parsed_type, parsed_owner, parsed_currency, parsed_amount}
end

defp non_zero_owner?(<<0::160>>), do: {:error, :output_guard_cant_be_zero}
Expand Down
21 changes: 14 additions & 7 deletions apps/omg_eth/test/omg_eth/root_chain_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ defmodule OMG.Eth.RootChainTest do

alias ExPlasma.Builder
alias ExPlasma.Crypto
alias ExPlasma.Transaction.Type.PaymentV1
alias OMG.Eth.Configuration
alias OMG.Eth.Encoding
alias OMG.Eth.RootChain
Expand Down Expand Up @@ -64,13 +65,8 @@ defmodule OMG.Eth.RootChainTest do

defp deposit_then_start_exit(owner, amount, currency) do
owner = Encoding.from_hex(owner)

deposit =
ExPlasma.payment_v1()
|> Builder.new()
|> Builder.add_output(output_guard: owner, token: currency, amount: amount)

{:ok, rlp} = ExPlasma.Transaction.encode(deposit, signed: false)
currency = Encoding.from_hex(currency)
rlp = deposit_transaction(amount, owner, currency)

{:ok, deposit_tx} =
rlp
Expand Down Expand Up @@ -115,4 +111,15 @@ defmodule OMG.Eth.RootChainTest do

{:ok, %{"status" => "0x1"}} = Support.DevHelper.transact_sync!(add_exit_queue)
end

defp deposit_transaction(amount_in_wei, address, currency) do
address
|> deposit(currency, amount_in_wei)
|> ExPlasma.encode!(signed: false)
end

defp deposit(owner, token, amount) do
output = PaymentV1.new_output(owner, token, amount)
Builder.new(ExPlasma.payment_v1(), outputs: [output])
end
end
1 change: 0 additions & 1 deletion apps/omg_status/lib/omg_status/metric/event.ex
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ defmodule OMG.Status.Metric.Event do
:read - OMG.DB KV layer has three types of actions: write, read, multiread
:multiread - OMG.DB KV layer has three types of actions: write, read, multiread
@services - We're interested in the events queue length that particular OMG.EthereumEventListener service process
is handling. We're interested in the message queue length of particular OMG.EthereumEventListener service process
"""
def name(:transaction_submission), do: "transaction_submission"
def name(:transaction_submission_success), do: "transaction_submission_success"
Expand Down
1 change: 0 additions & 1 deletion mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"idna": {:hex, :idna, "6.0.1", "1d038fb2e7668ce41fbf681d2c45902e52b3cb9e9c77b55334353b222c2ee50c", [:rebar3], [{:unicode_util_compat, "0.5.0", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "a02c8a1c4fd601215bb0b0324c8a6986749f807ce35f25449ec9e69758708122"},
"ink": {:hex, :ink, "1.2.0", "8dc46993a5cae17e392be5a2b5a0cb79b12c72ad7b31ca43f5fc586a20d5c429", [:mix], [{:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "26570ca0a5698e93567e5c522463c0ad8e271bcf0a61a54d7303f4621a873472"},
"jason": {:hex, :jason, "1.2.2", "ba43e3f2709fd1aa1dce90aaabfd039d000469c05c56f0b8e31978e03fa39052", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "18a228f5f0058ee183f29f9eae0805c6e59d61c3b006760668d8d18ff0d12179"},
"keccakf1600": {:hex, :keccakf1600_orig, "2.0.0", "0a7217ddb3ee8220d449bbf7575ec39d4e967099f220a91e3dfca4dbaef91963", [:rebar3], [], "hexpm", "bdbbb02d67bea35605f95d4e3de48203347374e414da7945c4f2f7fd13ffe632"},
"libgraph": {:hex, :libgraph, "0.13.3", "20732b7bafb933dcf7351c479e03076ebd14a85fd3202c67a1c197f4f7c2466b", [:mix], [], "hexpm", "78f2576eef615440b46f10060b1de1c86640441422832052686df53dc3c148c6"},
"libsecp256k1": {:git, "https://github.com/omgnetwork/libsecp256k1", "83d4c91b7b5ad79fdd3c020be8c57ff6e2212780", [branch: "elixir-only"]},
"libsecp256k1_source": {:git, "https://github.com/bitcoin-core/secp256k1.git", "d33352151699bd7598b868369dace092f7855740", [ref: "d33352151699bd7598b868369dace092f7855740"]},
Expand Down

0 comments on commit 5fb6349

Please sign in to comment.