How to convert PublishedImmutableData.xorname to xorname string?

Quick question. In some areas Fleming APIs return property link which is of the form safe://hbyyyynjbyfza393dx7kzkih6q1rax8sffjiz9skcmethgtorddc5xxak9 and in other places they return property xorname which is a byte list.

How do I convert the xorname to the form for a link and vice versa (JavaSript)?

EDIT: I’ve noticed that I don’t need this for PublishedImmutableData because it is available as PublishedImmutableData.resolved_from.xorurl but I think we’ll still need APIs to convert between the two.

I don’t think the CLI APIs cover such conversion yet. It’s a good idea for @maidsafe though to be consistent with the return values.

Anyway, I’ve solved this some months ago by having little helper functions:

In short, it uses the cids package @maidsafe used in their JavaScript API. I’m not sure my function is up-to-date still.

2 Likes

Good points. Agreed, we should be consistent :+1:

I’m not sure we ever need to be returning xorname (this can get gotten from a xorurl eg).

At the moment @happybeing we don’t have the XorUrlEncoder api exposed yet (which would handle this).I’ll get this in ASAP (https://github.com/maidsafe/safe_browser/issues/1022)

3 Likes

Also, I’ve been working on some minor feature which includes the xorurl in the objects returned by fetch.

1 Like

This topic was automatically closed after 60 days. New replies are no longer allowed.