Skip to content

Commit f259ef5

Browse files
committed
Merge AccountHistory and History as it was merged on EOS RPC
1 parent a7b90ea commit f259ef5

3 files changed

Lines changed: 39 additions & 86 deletions

File tree

config/config.exs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,5 @@ config :eosrpc, EOSRPC.Wallet,
3535
config :eosrpc, EOSRPC.Chain,
3636
url: "http://127.0.0.1:8888/v1/chain"
3737

38-
config :eosrpc, EOSRPC.AccountHistory,
39-
url: "http://127.0.0.1:8888/v1/account_history"
40-
4138
config :eosrpc, EOSRPC.History,
4239
url: "http://127.0.0.1:8888/v1/history"

lib/eosrpc/account_history.ex

Lines changed: 0 additions & 79 deletions
This file was deleted.

lib/eosrpc/history.ex

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,18 @@ defmodule EOSRPC.History do
1111

1212
import EOSRPC
1313

14+
plug(Tesla.Middleware.JSON)
15+
plug(EOSRPC.Middleware.Error)
16+
1417
@doc """
1518
Retrieve a transaction from the blockchain.
1619
"""
17-
def get_transaction(id) do
18-
"/get_transaction" |> url() |> post_request(%{id: id})
20+
def get_transaction(transaction_id) do
21+
"/get_transaction" |> url() |> post_request(%{id: transaction_id})
22+
end
23+
24+
def get_transaction!(transaction_id) do
25+
unwrap_or_raise(get_transaction(transaction_id))
1926
end
2027

2128
@doc """
@@ -27,10 +34,38 @@ defmodule EOSRPC.History do
2734
|> post_request(%{account_name: account_name, pos: pos, offset: offset})
2835
end
2936

30-
def url(url),
31-
do:
37+
def get_actions!(account_name, pos \\ 0, offset \\ 100) do
38+
unwrap_or_raise(get_actions(account, pos, offset))
39+
end
40+
41+
@doc """
42+
Retrieve accounts associated with a public key
43+
"""
44+
def get_key_accounts(public_key) do
45+
"/get_key_accounts" |> url() |> post(%{public_key: public_key})
46+
end
47+
48+
def get_key_accounts!(public_key) do
49+
unwrap_or_raise(get_key_accounts(public_key))
50+
end
51+
52+
@doc """
53+
Retrieve accounts which are created by the given account
54+
"""
55+
def get_controlled_accounts(account_name) do
56+
"/get_controlled_accounts"
57+
|> url()
58+
|> post(%{controlling_account: account_name})
59+
end
60+
61+
def get_controlled_accounts!(account_name) do
62+
unwrap_or_raise(get_controlled_accounts(account_name))
63+
end
64+
65+
def url(url) do
3266
:eosrpc
3367
|> Application.get_env(__MODULE__)
3468
|> Keyword.get(:url)
3569
|> Kernel.<>(url)
70+
end
3671
end

0 commit comments

Comments
 (0)