Skip to content

Commit

Permalink
ProtocolVersion no longer produced by ID
Browse files Browse the repository at this point in the history
  • Loading branch information
bahner committed Oct 11, 2023
1 parent 1277be9 commit a29a370
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 13 deletions.
2 changes: 0 additions & 2 deletions lib/ex_ipfs.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 0 additions & 2 deletions lib/ex_ipfs/id.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ defmodule ExIpfs.Id do
:addresses,
:agent_version,
:id,
:protocol_version,
:public_key,
:protocols
]
Expand All @@ -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"]
}
Expand Down
16 changes: 10 additions & 6 deletions lib/ex_ipfs/utils.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions test/ex_ipfs/id_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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" => []
}
Expand All @@ -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
Expand Down
1 change: 0 additions & 1 deletion test/ex_ipfs_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a29a370

Please sign in to comment.