diff --git a/src/CoreApi/KeyApi.cs b/src/CoreApi/KeyApi.cs index 5012877..a152542 100644 --- a/src/CoreApi/KeyApi.cs +++ b/src/CoreApi/KeyApi.cs @@ -16,7 +16,7 @@ class KeyApi : IKeyApi public class KeyInfo : IKey { /// - public MultiHash Id { get; set; } + public Cid Id { get; set; } /// public string Name { get; set; } @@ -37,7 +37,7 @@ internal KeyApi(IpfsClient ipfs) public async Task CreateAsync(string name, string keyType, int size, CancellationToken cancel = default(CancellationToken)) { - var json = await ipfs.DoCommandAsync("key/gen", cancel, name, $"type={keyType}", $"size={size}", "ipns-base=base32"); + var json = await ipfs.DoCommandAsync("key/gen", cancel, name, $"type={keyType}", $"size={size}", "ipns-base=base36"); var jobject = JObject.Parse(json); string id = (string)jobject["Id"]; @@ -45,14 +45,14 @@ internal KeyApi(IpfsClient ipfs) return new KeyInfo { - Id = Cid.Decode(id).Hash, + Id = id, Name = apiName }; } public async Task> ListAsync(CancellationToken cancel = default(CancellationToken)) { - var json = await ipfs.DoCommandAsync("key/list", cancel, null, "l=true", "ipns-base=base32"); + var json = await ipfs.DoCommandAsync("key/list", cancel, null, "l=true", "ipns-base=base36"); var keys = (JArray)(JObject.Parse(json)["Keys"]); return keys @@ -63,7 +63,7 @@ internal KeyApi(IpfsClient ipfs) return new KeyInfo { - Id = Cid.Decode(id).Hash, + Id = id, Name = name }; }); @@ -71,7 +71,7 @@ internal KeyApi(IpfsClient ipfs) public async Task RemoveAsync(string name, CancellationToken cancel = default(CancellationToken)) { - var json = await ipfs.DoCommandAsync("key/rm", cancel, name, "ipns-base=base32"); + var json = await ipfs.DoCommandAsync("key/rm", cancel, name, "ipns-base=base36"); var keys = JObject.Parse(json)["Keys"] as JArray; return keys? @@ -82,7 +82,7 @@ internal KeyApi(IpfsClient ipfs) return new KeyInfo { - Id = Cid.Decode(id).Hash, + Id = id, Name = keyName }; }) @@ -91,7 +91,7 @@ internal KeyApi(IpfsClient ipfs) public async Task RenameAsync(string oldName, string newName, CancellationToken cancel = default(CancellationToken)) { - var json = await ipfs.DoCommandAsync("key/rename", cancel, oldName, $"arg={newName}", "ipns-base=base32"); + var json = await ipfs.DoCommandAsync("key/rename", cancel, oldName, $"arg={newName}", "ipns-base=base36"); var jobject = JObject.Parse(json); string id = (string)jobject["Id"]; @@ -99,7 +99,7 @@ internal KeyApi(IpfsClient ipfs) return new KeyInfo { - Id = Cid.Decode(id).Hash, + Id = id, Name = currentName }; } diff --git a/src/IpfsHttpClient.csproj b/src/IpfsHttpClient.csproj index 1dcb732..6cd4566 100644 --- a/src/IpfsHttpClient.csproj +++ b/src/IpfsHttpClient.csproj @@ -9,7 +9,7 @@ true - 0.0.8 + 0.1.0 $(Version) @@ -46,7 +46,7 @@ - + diff --git a/test/CoreApi/NameApiTest.cs b/test/CoreApi/NameApiTest.cs index fcf1eac..7b13365 100644 --- a/test/CoreApi/NameApiTest.cs +++ b/test/CoreApi/NameApiTest.cs @@ -1,5 +1,6 @@ using Microsoft.VisualStudio.TestTools.UnitTesting; using System; +using System.Text; using System.Threading; using System.Threading.Tasks; @@ -24,18 +25,19 @@ public async Task Resolve() } [TestMethod] - [Ignore("takes forever")] public async Task Publish() { var ipfs = TestFixture.Ipfs; var cs = new CancellationTokenSource(TimeSpan.FromMinutes(5)); var content = await ipfs.FileSystem.AddTextAsync("hello world"); - var key = await ipfs.Key.CreateAsync("name-publish-test", "rsa", 1024); + var key = await ipfs.Key.CreateAsync("name-publish-test", "rsa", 2048); + try { var result = await ipfs.Name.PublishAsync(content.Id, key.Name, cancel: cs.Token); Assert.IsNotNull(result); - StringAssert.EndsWith(result.NamePath, key.Id.ToString()); + + StringAssert.EndsWith(result.NamePath, key.Id); StringAssert.EndsWith(result.ContentPath, content.Id.Encode()); } finally