mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-05-12 06:19:33 +00:00
Signed-off-by: Arnaud <arno.deville@gmail.com> Co-authored-by: Eric <5089238+emizzle@users.noreply.github.com>
33 lines
683 B
Nim
33 lines
683 B
Nim
import std/typetraits
|
|
from pkg/libp2p import
|
|
Cid, PeerId, SignedPeerRecord, MultiAddress, AddressInfo, init, `$`
|
|
import pkg/contractabi
|
|
import pkg/codexdht/discv5/node as dn
|
|
import pkg/serde/json
|
|
import pkg/questionable/results
|
|
import ../errors
|
|
|
|
export json
|
|
|
|
proc fromJson*(_: type Cid, json: JsonNode): ?!Cid =
|
|
expectJsonKind(Cid, JString, json)
|
|
Cid.init(json.str).mapFailure
|
|
|
|
func `%`*(cid: Cid): JsonNode =
|
|
% $cid
|
|
|
|
func `%`*(obj: PeerId): JsonNode =
|
|
% $obj
|
|
|
|
func `%`*(obj: SignedPeerRecord): JsonNode =
|
|
% $obj
|
|
|
|
func `%`*(obj: dn.Address): JsonNode =
|
|
% $obj
|
|
|
|
func `%`*(obj: AddressInfo): JsonNode =
|
|
% $obj.address
|
|
|
|
func `%`*(obj: MultiAddress): JsonNode =
|
|
% $obj
|