From c2e8ccb2c5b9cab539f04b389f82727f448b9d61 Mon Sep 17 00:00:00 2001 From: Artur64 Date: Tue, 3 Dec 2019 23:51:44 +0200 Subject: [PATCH] Added Account.get/1 function, updated ranch version --- lib/core/account.ex | 24 ++++++++++++++++++++++++ mix.exs | 2 +- mix.lock | 2 +- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/lib/core/account.ex b/lib/core/account.ex index 89dced4..0e0d7a8 100644 --- a/lib/core/account.ex +++ b/lib/core/account.ex @@ -157,6 +157,30 @@ defmodule AeppSDK.Account do @doc """ Get an actual account information + ## Example + iex> AeppSDK.Account.get(client) + {:ok, + %{ + auth_fun: nil, + balance: 151688000000000000000, + contract_id: nil, + id: "ak_6A2vcm1Sz6aqJezkLCssUXcyZTX7X8D5UwbuS2fRJr9KkYpRU", + kind: "basic", + nonce: 0, + payable: true + }} + """ + @spec get(Client.t()) :: {:ok, account()} | {:error, String.t()} | {:error, Env.t()} + def get(%Client{connection: connection, keypair: %{public: pubkey}}) + when is_binary(pubkey) do + response = AccountApi.get_account_by_pubkey(connection, pubkey) + + prepare_result(response) + end + + @doc """ + Get an actual account information + ## Example iex> pubkey = "ak_6A2vcm1Sz6aqJezkLCssUXcyZTX7X8D5UwbuS2fRJr9KkYpRU" iex> AeppSDK.Account.get(client, pubkey) diff --git a/mix.exs b/mix.exs index c615951..5ff3d92 100644 --- a/mix.exs +++ b/mix.exs @@ -42,7 +42,7 @@ defmodule AeppSdkElixir.MixProject do github: "aeternity/enacl", ref: "26180f42c0b3a450905d2efd8bc7fd5fd9cece75", override: true}, {:tesla, "~> 1.2.1"}, {:poison, "~> 3.0.0"}, - {:ranch, github: "ninenines/ranch", tag: "1.4.0"}, + {:ranch, "~> 1.7"}, {:hackney, "~> 1.15"}, {:argon2_elixir, "~> 2.0"}, {:uuid, "~> 1.1"}, diff --git a/mix.lock b/mix.lock index 01d406f..95afb8d 100644 --- a/mix.lock +++ b/mix.lock @@ -30,7 +30,7 @@ "nimble_parsec": {:hex, :nimble_parsec, "0.5.2", "1d71150d5293d703a9c38d4329da57d3935faed2031d64bc19e77b654ef2d177", [:mix], [], "hexpm"}, "parse_trans": {:hex, :parse_trans, "3.3.0", "09765507a3c7590a784615cfd421d101aec25098d50b89d7aa1d66646bc571c1", [:rebar3], [], "hexpm"}, "poison": {:hex, :poison, "3.0.0", "625ebd64d33ae2e65201c2c14d6c85c27cc8b68f2d0dd37828fde9c6920dd131", [:mix], [], "hexpm"}, - "ranch": {:git, "https://github.com/ninenines/ranch.git", "55c2a9d623454f372a15e99721a37093d8773b48", [tag: "1.4.0"]}, + "ranch": {:hex, :ranch, "1.7.1", "6b1fab51b49196860b733a49c07604465a47bdb78aa10c1c16a3d199f7f8c881", [:rebar3], [], "hexpm"}, "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.5", "6eaf7ad16cb568bb01753dbbd7a95ff8b91c7979482b95f38443fe2c8852a79b", [:make, :mix, :rebar3], [], "hexpm"}, "tesla": {:hex, :tesla, "1.2.1", "864783cc27f71dd8c8969163704752476cec0f3a51eb3b06393b3971dc9733ff", [:mix], [{:exjsx, ">= 3.0.0", [hex: :exjsx, repo: "hexpm", optional: true]}, {:fuse, "~> 2.4", [hex: :fuse, repo: "hexpm", optional: true]}, {:hackney, "~> 1.6", [hex: :hackney, repo: "hexpm", optional: true]}, {:ibrowse, "~> 4.4.0", [hex: :ibrowse, repo: "hexpm", optional: true]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: true]}, {:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:poison, ">= 1.0.0", [hex: :poison, repo: "hexpm", optional: true]}], "hexpm"}, "unicode_util_compat": {:hex, :unicode_util_compat, "0.4.1", "d869e4c68901dd9531385bb0c8c40444ebf624e60b6962d95952775cac5e90cd", [:rebar3], [], "hexpm"},