Skip to content
This repository has been archived by the owner on Jun 30, 2021. It is now read-only.

Ethereum transactions logic and endpoints #1080

Merged
merged 15 commits into from
Jul 11, 2019

Conversation

T-Dnzt
Copy link

@T-Dnzt T-Dnzt commented Jun 28, 2019

Issue/Task Number: #1060

Overview

This PR adds the first blockchain transaction flow, to send funds from the hot wallet directly to an external address. This should actually only be used to get funds out of the hot wallet and into one of the cold wallets used together as the pool of funds the eWallet has access to.

Changes

  • Add a BlockchainTransactionGate and a TransactionDispatcherGate
  • Renamed the TransactionGate to LocalTransactionGate
  • Add a system of transaction trackers in the eWallet sub-app, managed by a registry. Each tracker starts its own blockchain transaction listener on the blockchain side via a blockchain registry.
  • There are lot of TODOs left in the code, that will be fixed in a future PR.

Usage

You will need to go through the blockchain setup that @mederic-p has done in order to have Geth setup properly.

Impact

You will need to run Geth in order to have the blockchain features working (errors aren't currently handled). Tests can be run without it.

@T-Dnzt T-Dnzt force-pushed the 1060-eth-transactions-logic branch from 01dccb4 to fb80753 Compare June 28, 2019 07:47
@T-Dnzt T-Dnzt changed the title [WIP] Eth transactions logic and endpoints Ethereum transactions logic and endpoints Jul 4, 2019
@T-Dnzt T-Dnzt force-pushed the 1060-eth-transactions-logic branch from 83fa752 to 4727c05 Compare July 4, 2019 10:59
@T-Dnzt T-Dnzt changed the base branch from master to eth-blockchain July 4, 2019 10:59
}
)

%{config_pid: config_pid}
:ok = Application.put_env(:ewallet, :node_adapter, {:dumb, DumbAdapter})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be better to put it in the test.exs config?

Copy link
Contributor

@unnawut unnawut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1st batch

case Account.get(master_account_id) do
nil ->
{
Map.delete(attrs, "master_account"),
{:master_account, {:error, prepare_error(master_account_id)}}
[{:master_account, {:error, prepare_account_error(master_account_id)}} | errors]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we refactor/move this implementation detail inside e.g. prepare_account_error(errors, :master_account, master_account_id)? Also prepare_hot_wallet_error(errors, :primary_hot_wallet, primary_hot_wallet_address).

apps/eth_blockchain/lib/eth_blockchain/adapter.ex Outdated Show resolved Hide resolved
apps/eth_blockchain/lib/eth_blockchain/adapter.ex Outdated Show resolved Hide resolved
adapter,
state,
confirmations_count,
confirmations_count > (threshold || 10)
Copy link
Contributor

@ripzery ripzery Jul 10, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we define a module attribute for the default confirmations threshold (10) somewhere?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also wonder isn't it suppose to be >=?

@T-Dnzt
Copy link
Author

T-Dnzt commented Jul 11, 2019

Merging, the linting issues will be fixed in the eth-blockchain branch 👌

@T-Dnzt T-Dnzt merged commit 31b0cae into eth-blockchain Jul 11, 2019
@unnawut unnawut deleted the 1060-eth-transactions-logic branch August 27, 2019 07:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants