From a29a370338456337c9ae2e3479289d51ff5f6ca0 Mon Sep 17 00:00:00 2001 From: Lars Bahner Date: Wed, 11 Oct 2023 16:21:27 +0200 Subject: [PATCH] ProtocolVersion no longer produced by ID --- lib/ex_ipfs.ex | 2 -- lib/ex_ipfs/id.ex | 2 -- lib/ex_ipfs/utils.ex | 16 ++++++++++------ test/ex_ipfs/id_test.exs | 2 -- test/ex_ipfs_test.exs | 1 - 5 files changed, 10 insertions(+), 13 deletions(-) diff --git a/lib/ex_ipfs.ex b/lib/ex_ipfs.ex index bfd551b..928a6d9 100644 --- a/lib/ex_ipfs.ex +++ b/lib/ex_ipfs.ex @@ -32,7 +32,6 @@ defmodule ExIpfs do addresses: list, agent_version: String.t(), id: String.t(), - protocol_version: String.t(), public_key: String.t(), protocols: list } @@ -242,7 +241,6 @@ defmodule ExIpfs do - PublicKey: the public key of the node. - Addresses: the addresses of the node. - AgentVersion: the version of the node. - - ProtocolVersion: the protocol version of the node. - Protocols: the protocols of the node. """ @spec id :: {:ok, id()} | ExIpfs.Api.error_response() diff --git a/lib/ex_ipfs/id.ex b/lib/ex_ipfs/id.ex index 1302771..08f80ae 100644 --- a/lib/ex_ipfs/id.ex +++ b/lib/ex_ipfs/id.ex @@ -5,7 +5,6 @@ defmodule ExIpfs.Id do :addresses, :agent_version, :id, - :protocol_version, :public_key, :protocols ] @@ -16,7 +15,6 @@ defmodule ExIpfs.Id do addresses: map["Addresses"], agent_version: map["AgentVersion"], id: map["ID"], - protocol_version: map["ProtocolVersion"], public_key: map["PublicKey"], protocols: map["Protocols"] } diff --git a/lib/ex_ipfs/utils.ex b/lib/ex_ipfs/utils.ex index cbfab7d..f359982 100644 --- a/lib/ex_ipfs/utils.ex +++ b/lib/ex_ipfs/utils.ex @@ -241,20 +241,24 @@ defmodule ExIpfs.Utils do _ -> data end end - - def map_has_keys?(response, expected_keys) do + + def map_has_keys?(response, expected_keys) do if Enum.all?(expected_keys, &Map.has_key?(response, &1)) do response else - raise ArgumentError, message: "Missing some of #{inspect(expected_keys)} in response from IPFS API" + raise ArgumentError, + message: "Missing some of #{inspect(expected_keys)} in response from IPFS API" end end def map_get_key!(response, key) do case response do - %{^key => value} -> value - _ -> raise ArgumentError, message: "Problem extracting #{inspect(key)} from response from IPFS API" + %{^key => value} -> + value + + _ -> + raise ArgumentError, + message: "Problem extracting #{inspect(key)} from response from IPFS API" end end - end diff --git a/test/ex_ipfs/id_test.exs b/test/ex_ipfs/id_test.exs index 17a4843..b4535d0 100644 --- a/test/ex_ipfs/id_test.exs +++ b/test/ex_ipfs/id_test.exs @@ -9,7 +9,6 @@ defmodule ExIpfs.IdTest do "Addresses" => ["/ip4/"], "AgentVersion" => "go-ipfs/0.4.22/", "ID" => "Qm", - "ProtocolVersion" => "ipfs/0.1.0", "PublicKey" => "CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQD", "Protocols" => [] } @@ -28,7 +27,6 @@ defmodule ExIpfs.IdTest do assert e.addresses == ["/ip4/"] assert e.agent_version == "go-ipfs/0.4.22/" assert e.id == "Qm" - assert e.protocol_version == "ipfs/0.1.0" assert e.public_key == "CAASpgIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQD" assert e.protocols == [] end diff --git a/test/ex_ipfs_test.exs b/test/ex_ipfs_test.exs index 6e1b9a5..789d30e 100644 --- a/test/ex_ipfs_test.exs +++ b/test/ex_ipfs_test.exs @@ -88,7 +88,6 @@ defmodule ExIpfsTest do assert %ExIpfs.Id{} = response assert is_binary(response.agent_version) assert is_binary(response.id) - assert is_binary(response.protocol_version) assert is_binary(response.public_key) assert is_list(response.addresses) assert is_list(response.protocols)