Skip to content

Commit

Permalink
merge 0.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm360 committed Mar 23, 2022
2 parents 0f97f4b + 00e7d19 commit 4b2ac30
Show file tree
Hide file tree
Showing 56 changed files with 14,250 additions and 406 deletions.
3 changes: 0 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,3 @@ indent_size = 2

# C# files
[*.cs]

# CA1014: Mark assemblies with CLSCompliant
dotnet_diagnostic.CA1014.severity = none # Not interested in feature
3 changes: 2 additions & 1 deletion .github/workflows/myget-unstable-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@master
- name: Checkout
uses: actions/checkout@master
with:
fetch-depth: 0

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/nuget-stable-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@master
- name: Checkout
uses: actions/checkout@master
with:
fetch-depth: 0

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Bee.Net is a .Net client for the [Bee Swarm](https://github.com/ethersphere/bee)

With this client you can consume public and debug api of any Bee node exposing them.

Current release is compatible with Bee nodes from version `1.4.1` to `1.4.3`. Other versions could have issues.
Current release is compatible with Bee nodes from version `1.4.1` to `1.5.0`. Other versions could have issues.

Package repositories
--------------------
Expand Down
4 changes: 3 additions & 1 deletion src/BeeNet/BeeNet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
<TargetFramework>netstandard2.0</TargetFramework>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<RootNamespace>Etherna.BeeNet</RootNamespace>

<Authors>Etherna Sagl</Authors>
<Description>A .Net client for Swarm Bee</Description>

<LangVersion>9.0</LangVersion>
<Nullable>enable</Nullable>
<EnableNETAnalyzers>true</EnableNETAnalyzers>
Expand All @@ -32,7 +34,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageReference Include="System.Text.Json" Version="6.0.0" />
<PackageReference Include="System.Text.Json" Version="6.0.2" />
</ItemGroup>

<ItemGroup>
Expand Down
8 changes: 2 additions & 6 deletions src/BeeNet/BeeNodeClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@ public BeeNodeClient(
string baseUrl = "http://localhost/",
int? gatewayApiPort = 1633,
int? debugApiPort = 1635,
GatewayApiVersion gatewayApiVersion = GatewayApiVersion.v2_0_0,
DebugApiVersion debugApiVersion = DebugApiVersion.v1_2_0)
GatewayApiVersion gatewayApiVersion = GatewayApiVersion.v3_0_0,
DebugApiVersion debugApiVersion = DebugApiVersion.v2_0_0)
{
httpClient = new HttpClient();
DebugApiVersion = debugApiVersion;
GatewayApiVersion = gatewayApiVersion;

if (debugApiPort is not null)
{
Expand Down Expand Up @@ -76,10 +74,8 @@ protected virtual void Dispose(bool disposing)

// Properties.
public Uri? DebugApiUrl { get; }
public DebugApiVersion DebugApiVersion { get; }
public IBeeDebugClient? DebugClient { get; }
public Uri? GatewayApiUrl { get; }
public GatewayApiVersion GatewayApiVersion { get; }
public IBeeGatewayClient? GatewayClient { get; }

// Helpers.
Expand Down
127 changes: 89 additions & 38 deletions src/BeeNet/Clients/DebugApi/BeeDebugClient.cs

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/BeeNet/Clients/DebugApi/DebugApiVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ namespace Etherna.BeeNet.Clients.DebugApi
public enum DebugApiVersion
{
v1_2_0,
v1_2_1
v1_2_1,
v2_0_0
}
}
67 changes: 67 additions & 0 deletions src/BeeNet/Clients/DebugApi/DtoFixer/PostageBatchDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Copyright 2021-present Etherna Sagl
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace Etherna.BeeNet.Clients.DebugApi.DtoFixer
{
public class PostageBatchDto
{
/// <summary>
/// Internal debugging property. It indicates if the batch is expired.
/// </summary>
[System.Text.Json.Serialization.JsonPropertyName("exists")]
public bool Exists { get; set; } = default!;

/// <summary>
/// The time (in seconds) remaining until the batch expires; -1 signals that the batch never expires; 0 signals that the batch has already expired.
/// </summary>

[System.Text.Json.Serialization.JsonPropertyName("batchTTL")]
public int BatchTTL { get; set; } = default!;

[System.Text.Json.Serialization.JsonPropertyName("batchID")]
public string BatchID { get; set; } = default!;

[System.Text.Json.Serialization.JsonPropertyName("utilization")]
public int Utilization { get; set; } = default!;

/// <summary>
/// Indicate that the batch was discovered by the Bee node, but it awaits enough on-chain confirmations before declaring the batch as usable.
/// </summary>

[System.Text.Json.Serialization.JsonPropertyName("usable")]
public bool Usable { get; set; } = default!;

[System.Text.Json.Serialization.JsonPropertyName("label")]
public string Label { get; set; } = default!;

[System.Text.Json.Serialization.JsonPropertyName("depth")]
public int Depth { get; set; } = default!;

/// <summary>
/// Numeric string that represents integer which might exceeds `Number.MAX_SAFE_INTEGER` limit (2^53-1)
/// </summary>

[System.Text.Json.Serialization.JsonPropertyName("amount")]
public string Amount { get; set; } = default!;

[System.Text.Json.Serialization.JsonPropertyName("bucketDepth")]
public int BucketDepth { get; set; } = default!;

[System.Text.Json.Serialization.JsonPropertyName("blockNumber")]
public int BlockNumber { get; set; } = default!;

[System.Text.Json.Serialization.JsonPropertyName("immutableFlag")]
public bool ImmutableFlag { get; set; } = default!;
}
}
46 changes: 23 additions & 23 deletions src/BeeNet/Clients/DebugApi/IBeeDebugClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ public interface IBeeDebugClient
/// <returns>Returns the newly created postage batch ID</returns>
/// <exception cref="BeeNetDebugApiException">A server side error occurred.</exception>
Task<string> BuyPostageBatchAsync(
int amount,
long amount,
int depth,
string? label = null,
bool? immutable = null,
int? gasPrice = null);
long? gasPrice = null);

/// <summary>Cashout the last cheque for the peer</summary>
/// <param name="peerId">Swarm address of peer</param>
Expand All @@ -46,7 +46,7 @@ Task<string> BuyPostageBatchAsync(
/// <exception cref="BeeNetDebugApiException">A server side error occurred.</exception>
Task<string> CashoutChequeForPeerAsync(
string peerId,
int? gasPrice = null,
long? gasPrice = null,
long? gasLimit = null);

/// <summary>Connect to address</summary>
Expand Down Expand Up @@ -74,16 +74,16 @@ Task<string> CashoutChequeForPeerAsync(
/// <exception cref="BeeNetDebugApiException">A server side error occurred.</exception>
Task<string> DeleteTransactionAsync(
string txHash,
int? gasPrice = null);
long? gasPrice = null);

/// <summary>Deposit tokens from overlay address into chequebook</summary>
/// <param name="amount">amount of tokens to deposit</param>
/// <param name="gasPrice">Gas price for transaction</param>
/// <returns>Transaction hash of the deposit transaction</returns>
/// <exception cref="BeeNetDebugApiException">A server side error occurred.</exception>
Task<string> DepositIntoChequeBookAsync(
int amount,
int? gasPrice = null);
long amount,
long? gasPrice = null);

/// <summary>Dilute an existing postage batch.</summary>
/// <param name="id">Batch ID to dilute</param>
Expand All @@ -102,14 +102,6 @@ Task<string> DepositIntoChequeBookAsync(
/// <exception cref="BeeNetDebugApiException">A server side error occurred.</exception>
Task<IEnumerable<BalanceDto>> GetAllBalancesAsync();

/// <summary>
/// Get all globally available batches that were purchased by all nodes.
/// </summary>
/// <returns></returns>
/// <returns>Returns an array of all available and currently valid postage batches.</returns>
/// <exception cref="BeeNetDebugApiException">A server side error occurred.</exception>
Task<IEnumerable<ValidPostageBatchDto>> GetAllBatchesFromAllNodesAsync();

/// <summary>Get last cheques for all peers</summary>
/// <returns>Last cheques</returns>
/// <exception cref="BeeNetDebugApiException">A server side error occurred.</exception>
Expand All @@ -130,16 +122,19 @@ Task<string> DepositIntoChequeBookAsync(
/// <exception cref="BeeNetDebugApiException">A server side error occurred.</exception>
Task<SettlementDto> GetAllSettlementsAsync();

/// <summary>Get all available stamps for this node</summary>
/// <returns>Returns an array of all available postage batches.</returns>
/// <exception cref="BeeNetDebugApiException">A server side error occurred.</exception>
Task<IEnumerable<StampsGetDto>> GetAllStampsAsync();

/// <summary>Get time based settlements with all known peers and total amount sent or received</summary>
/// <returns>Time based settlements with all known peers and total amount sent or received</returns>
/// <exception cref="BeeNetDebugApiException">A server side error occurred.</exception>
Task<TimeSettlementsDto> GetAllTimeSettlementsAsync();

/// <summary>
/// Get all globally available batches that were purchased by all nodes.
/// </summary>
/// <returns></returns>
/// <returns>Returns an array of all available and currently valid postage batches.</returns>
/// <exception cref="BeeNetDebugApiException">A server side error occurred.</exception>
Task<IEnumerable<BatchDto>> GetAllValidPostageBatchesFromAllNodesAsync();

/// <summary>Get the balances with a specific peer including prepaid services</summary>
/// <param name="address">Swarm address of peer</param>
/// <returns>Balance with the specific peer</returns>
Expand Down Expand Up @@ -202,6 +197,11 @@ Task<string> DepositIntoChequeBookAsync(
/// <exception cref="BeeNetDebugApiException">A server side error occurred.</exception>
Task<NodeInfoDto> GetNodeInfoAsync();

/// <summary>Get all owned postage batches by this node</summary>
/// <returns>List of all owned postage batches</returns>
/// <exception cref="BeeNetDebugApiException">A server side error occurred</exception>
Task<IEnumerable<PostageBatchDto>> GetOwnedPostageBatchesByNodeAsync();

/// <summary>Get list of pending transactions</summary>
/// <returns>List of pending transactions</returns>
/// <exception cref="BeeNetDebugApiException">A server side error occurred.</exception>
Expand All @@ -211,7 +211,7 @@ Task<string> DepositIntoChequeBookAsync(
/// <param name="id">Swarm address of the stamp</param>
/// <returns>Returns an individual postage batch state</returns>
/// <exception cref="BeeNetDebugApiException">A server side error occurred.</exception>
Task<StampsGetDto> GetPostageBatchStatusAsync(string id);
Task<PostageBatchDto> GetPostageBatchAsync(string id);

/// <summary>Get readiness state of node</summary>
/// <returns>Health State of node</returns>
Expand Down Expand Up @@ -272,7 +272,7 @@ Task<string> DepositIntoChequeBookAsync(
/// <param name="amount">Amount of BZZ per chunk to top up to an existing postage batch.</param>
/// <returns>Returns the postage batch ID that was topped up</returns>
/// <exception cref="BeeNetDebugApiException">A server side error occurred.</exception>
Task<string> TopUpPostageBatchAsync(string id, int amount);
Task<string> TopUpPostageBatchAsync(string id, long amount);

/// <summary>Try connection to node</summary>
/// <param name="peerId">Swarm address of peer</param>
Expand All @@ -286,7 +286,7 @@ Task<string> DepositIntoChequeBookAsync(
/// <returns>Transaction hash of the withdraw transaction</returns>
/// <exception cref="BeeNetDebugApiException">A server side error occurred.</exception>
Task<string> WithdrawFromChequeBookAsync(
int amount,
int? gasPrice = null);
long amount,
long? gasPrice = null);
}
}
Loading

0 comments on commit 4b2ac30

Please sign in to comment.