Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/CoreApi/KeyApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class KeyApi : IKeyApi
public class KeyInfo : IKey
{
/// <inheritdoc />
public MultiHash Id { get; set; }
public Cid Id { get; set; }

/// <inheritdoc />
public string Name { get; set; }
Expand All @@ -37,22 +37,22 @@ internal KeyApi(IpfsClient ipfs)

public async Task<IKey> 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"];
string apiName = (string)jobject["Name"];

return new KeyInfo
{
Id = Cid.Decode(id).Hash,
Id = id,
Name = apiName
};
}

public async Task<IEnumerable<IKey>> 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
Expand All @@ -63,15 +63,15 @@ internal KeyApi(IpfsClient ipfs)

return new KeyInfo
{
Id = Cid.Decode(id).Hash,
Id = id,
Name = name
};
});
}

public async Task<IKey> 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?
Expand All @@ -82,7 +82,7 @@ internal KeyApi(IpfsClient ipfs)

return new KeyInfo
{
Id = Cid.Decode(id).Hash,
Id = id,
Name = keyName
};
})
Expand All @@ -91,15 +91,15 @@ internal KeyApi(IpfsClient ipfs)

public async Task<IKey> 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"];
string currentName = (string)jobject["Now"];

return new KeyInfo
{
Id = Cid.Decode(id).Hash,
Id = id,
Name = currentName
};
}
Expand Down
4 changes: 2 additions & 2 deletions src/IpfsHttpClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

<!-- https://semver.org/spec/v2.0.0.html -->
<Version>0.0.8</Version>
<Version>0.1.0</Version>
<AssemblyVersion>$(Version)</AssemblyVersion>

<!-- Nuget specs -->
Expand Down Expand Up @@ -46,7 +46,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="IpfsShipyard.Ipfs.Core" Version="0.0.5" />
<PackageReference Include="IpfsShipyard.Ipfs.Core" Version="0.1.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Multiformats.Base" Version="2.0.2" />
Expand Down
8 changes: 5 additions & 3 deletions test/CoreApi/NameApiTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

Expand All @@ -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
Expand Down