Skip to content

Commit

Permalink
Merge hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm360 committed Feb 9, 2022
2 parents fe3b921 + 3511b1b commit 0f97f4b
Show file tree
Hide file tree
Showing 64 changed files with 9,328 additions and 1,495 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/myget-unstable-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches:
- dev
- 'release/**'
- 'hotfix/**'

jobs:
build-test-package:
Expand Down
6 changes: 4 additions & 2 deletions BeeNet.sln
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.editorconfig = .editorconfig
.gitignore = .gitignore
Bee.Net.sln.licenseheader = Bee.Net.sln.licenseheader
CODE_OF_CONDUCT.md = CODE_OF_CONDUCT.md
CONTRIBUTING.md = CONTRIBUTING.md
LICENSE = LICENSE
README.md = README.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{C162BCCF-B5C8-466A-AAB7-6D85CC171434}"
ProjectSection(SolutionItems) = preProject
tools\README.md = tools\README.md
tools\swarm-debug-api.1_4_1.nswag = tools\swarm-debug-api.1_4_1.nswag
tools\swarm-gateway-api.1_4_1.nswag = tools\swarm-gateway-api.1_4_1.nswag
tools\swarm-debug-api.nswag = tools\swarm-debug-api.nswag
tools\swarm-gateway-api.nswag = tools\swarm-gateway-api.nswag
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "openapi", "openapi", "{1956F8A3-25CE-42BB-8AE5-77ACC56B9B92}"
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.

**Disclaimer**: Bee.Net, as the Bee node, is still in a pre-release phase. Interface can change, and new features will be implemented. At this stage active use in production is discouraged.
Current release is compatible with Bee nodes from version `1.4.1` to `1.4.3`. Other versions could have issues.

Package repositories
--------------------
Expand Down
27 changes: 10 additions & 17 deletions src/BeeNet/BeeNodeClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using Etherna.BeeNet.Clients;
using Etherna.BeeNet.Clients.v1_4_1.DebugApi;
using Etherna.BeeNet.Clients.v1_4_1.GatewayApi;
using Etherna.BeeNet.DtoModel;
using Etherna.BeeNet.Clients.DebugApi;
using Etherna.BeeNet.Clients.GatewayApi;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
Expand All @@ -37,29 +35,23 @@ public BeeNodeClient(
string baseUrl = "http://localhost/",
int? gatewayApiPort = 1633,
int? debugApiPort = 1635,
ClientVersions version = ClientVersions.v1_4_1)
GatewayApiVersion gatewayApiVersion = GatewayApiVersion.v2_0_0,
DebugApiVersion debugApiVersion = DebugApiVersion.v1_2_0)
{
httpClient = new HttpClient();
ClientVersion = version;
DebugApiVersion = debugApiVersion;
GatewayApiVersion = gatewayApiVersion;

if (debugApiPort is not null)
{
DebugApiUrl = new Uri(BuildBaseUrl(baseUrl, debugApiPort.Value));
DebugClient = version switch
{
ClientVersions.v1_4_1 => new AdapterBeeDebugVersion_1_4_1(httpClient, DebugApiUrl),
_ => throw new NotSupportedException($"DebugClient {nameof(ClientVersion)} not supported"),
};
DebugClient = new BeeDebugClient(httpClient, DebugApiUrl, debugApiVersion);
}

if (gatewayApiPort is not null)
{
GatewayApiUrl = new Uri(BuildBaseUrl(baseUrl, gatewayApiPort.Value));
GatewayClient = version switch
{
ClientVersions.v1_4_1 => new AdapterGatewayClient_1_4_1(httpClient, GatewayApiUrl),
_ => throw new NotSupportedException($"GatewayClient {nameof(ClientVersion)} not supported"),
};
GatewayClient = new BeeGatewayClient(httpClient, GatewayApiUrl, gatewayApiVersion);
}
}

Expand All @@ -83,10 +75,11 @@ protected virtual void Dispose(bool disposing)


// Properties.
public ClientVersions ClientVersion { get; }
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
418 changes: 418 additions & 0 deletions src/BeeNet/Clients/DebugApi/BeeDebugClient.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
// See the License for the specific language governing permissions and
// limitations under the License.

namespace Etherna.BeeNet.DtoModel
namespace Etherna.BeeNet.Clients.DebugApi
{
public enum ClientVersions
public enum DebugApiVersion
{
#pragma warning disable CA1707 // Identifiers should not contain underscores
v1_4_1
#pragma warning restore CA1707 // Identifiers should not contain underscores
v1_2_0,
v1_2_1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,26 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using Etherna.BeeNet.DtoModels;
using System.Collections.Generic;
using System.Threading.Tasks;
using Etherna.BeeNet.Clients.v1_4_1.DebugApi;
using Etherna.BeeNet.DtoModel;

namespace Etherna.BeeNet.Clients
namespace Etherna.BeeNet.Clients.DebugApi
{
public interface IBeeDebugClient
{
// Properties.
DebugApiVersion CurrentApiVersion { get; set; }

// Methods.
/// <summary>Buy a new postage batch.</summary>
/// <param name="amount">Amount of BZZ added that the postage batch will have.</param>
/// <param name="depth">Batch depth which specifies how many chunks can be signed with the batch. It is a logarithm. Must be higher than default bucket depth (16)</param>
/// <param name="label">An optional label for this batch</param>
/// <param name="gasPrice">Gas price for transaction</param>
/// <returns>Returns the newly created postage batch ID</returns>
/// <exception cref="BeeNetDebugApiException">A server side error occurred.</exception>
Task<BatchDto> BuyPostageBatchAsync(
Task<string> BuyPostageBatchAsync(
int amount,
int depth,
string? label = null,
Expand All @@ -39,9 +42,9 @@ Task<BatchDto> BuyPostageBatchAsync(
/// <param name="peerId">Swarm address of peer</param>
/// <param name="gasPrice">Gas price for transaction</param>
/// <param name="gasLimit">Gas limit for transaction</param>
/// <returns>OK</returns>
/// <returns>Hash of the transaction</returns>
/// <exception cref="BeeNetDebugApiException">A server side error occurred.</exception>
Task<TransactionHashDto> CashoutChequeForPeerAsync(
Task<string> CashoutChequeForPeerAsync(
string peerId,
int? gasPrice = null,
long? gasLimit = null);
Expand All @@ -50,7 +53,7 @@ Task<TransactionHashDto> CashoutChequeForPeerAsync(
/// <param name="address">Underlay address of peer</param>
/// <returns>Returns overlay address of connected peer</returns>
/// <exception cref="BeeNetDebugApiException">A server side error occurred.</exception>
Task<ConnectDto> ConnectAsync(string address);
Task<string> ConnectToPeerAsync(string address);

/// <summary>Delete a chunk from local storage</summary>
/// <param name="address">Swarm address of chunk</param>
Expand All @@ -69,7 +72,7 @@ Task<TransactionHashDto> CashoutChequeForPeerAsync(
/// <param name="gasPrice">Gas price for transaction</param>
/// <returns>Hash of the transaction</returns>
/// <exception cref="BeeNetDebugApiException">A server side error occurred.</exception>
Task<TransactionHashDto> DeleteTransactionAsync(
Task<string> DeleteTransactionAsync(
string txHash,
int? gasPrice = null);

Expand All @@ -78,7 +81,7 @@ Task<TransactionHashDto> DeleteTransactionAsync(
/// <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<TransactionHashDto> DepositIntoChequeBookAsync(
Task<string> DepositIntoChequeBookAsync(
int amount,
int? gasPrice = null);

Expand All @@ -87,7 +90,7 @@ Task<TransactionHashDto> DepositIntoChequeBookAsync(
/// <param name="depth">New batch depth. Must be higher than the previous depth.</param>
/// <returns>Returns the postage batch ID that was diluted.</returns>
/// <exception cref="BeeNetDebugApiException">A server side error occurred.</exception>
Task<BatchDto> DilutePostageBatchAsync(object id, int depth);
Task<string> DilutePostageBatchAsync(string id, int depth);

/// <summary>Get overlay and underlay addresses of the node</summary>
/// <returns>Own node underlay and overlay addresses</returns>
Expand All @@ -99,6 +102,14 @@ Task<TransactionHashDto> 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 @@ -112,7 +123,7 @@ Task<TransactionHashDto> DepositIntoChequeBookAsync(
/// <summary>Get a list of peers</summary>
/// <returns>Returns overlay addresses of connected peers</returns>
/// <exception cref="BeeNetDebugApiException">A server side error occurred.</exception>
Task<IEnumerable<AddressDto>> GetAllPeersAsync();
Task<IEnumerable<string>> GetAllPeerAddressesAsync();

/// <summary>Get settlements with all known peers and total amount sent or received</summary>
/// <returns>Settlements with all known peers and total amount sent or received</returns>
Expand All @@ -138,7 +149,7 @@ Task<TransactionHashDto> DepositIntoChequeBookAsync(
/// <summary>Get a list of blocklisted peers</summary>
/// <returns>Returns overlay addresses of blocklisted peers</returns>
/// <exception cref="BeeNetDebugApiException">A server side error occurred.</exception>
Task<IEnumerable<AddressDto>> GetBlocklistedPeersAsync();
Task<IEnumerable<string>> GetBlocklistedPeerAddressesAsync();

/// <summary>Get chain state</summary>
/// <returns>Chain State</returns>
Expand All @@ -148,7 +159,7 @@ Task<TransactionHashDto> DepositIntoChequeBookAsync(
/// <summary>Get the address of the chequebook contract used</summary>
/// <returns>Ethereum address of chequebook contract</returns>
/// <exception cref="BeeNetDebugApiException">A server side error occurred.</exception>
Task<ChequeBookAddressDto> GetChequeBookAddressAsync();
Task<string> GetChequeBookAddressAsync();

/// <summary>Get the balance of the chequebook</summary>
/// <returns>Balance of the chequebook</returns>
Expand Down Expand Up @@ -184,6 +195,13 @@ Task<TransactionHashDto> DepositIntoChequeBookAsync(
/// <exception cref="BeeNetDebugApiException">A server side error occurred.</exception>
Task<VersionDto> GetHealthAsync();

/// <summary>
/// Get information about the node
/// </summary>
/// <returns>Information about the node</returns>
/// <exception cref="BeeNetDebugApiException">A server side error occurred.</exception>
Task<NodeInfoDto> GetNodeInfoAsync();

/// <summary>Get list of pending transactions</summary>
/// <returns>List of pending transactions</returns>
/// <exception cref="BeeNetDebugApiException">A server side error occurred.</exception>
Expand All @@ -193,7 +211,7 @@ Task<TransactionHashDto> 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(object id);
Task<StampsGetDto> GetPostageBatchStatusAsync(string id);

/// <summary>Get readiness state of node</summary>
/// <returns>Health State of node</returns>
Expand All @@ -215,7 +233,7 @@ Task<TransactionHashDto> DepositIntoChequeBookAsync(
/// <param name="batchId">Swarm address of the stamp</param>
/// <returns>Returns extended bucket data of the provided batch ID</returns>
/// <exception cref="BeeNetDebugApiException">A server side error occurred.</exception>
Task<StampsBucketsDto> GetStampsBucketsForBatchAsync(object batchId);
Task<StampsBucketsDto> GetStampsBucketsForBatchAsync(string batchId);

/// <returns>Swarm topology of the bee node</returns>
/// <exception cref="BeeNetDebugApiException">A server side error occurred.</exception>
Expand All @@ -242,7 +260,7 @@ Task<TransactionHashDto> DepositIntoChequeBookAsync(
/// <param name="txHash">Hash of the transaction</param>
/// <returns>Hash of the transaction</returns>
/// <exception cref="BeeNetDebugApiException">A server side error occurred.</exception>
Task<TransactionHashDto> RebroadcastTransactionAsync(string txHash);
Task<string> RebroadcastTransactionAsync(string txHash);

/// <summary>Set P2P welcome message</summary>
/// <returns>OK</returns>
Expand All @@ -254,20 +272,20 @@ Task<TransactionHashDto> 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<BatchDto> TopUpPostageBatchAsync(object id, int amount);
Task<string> TopUpPostageBatchAsync(string id, int amount);

/// <summary>Try connection to node</summary>
/// <param name="peerId">Swarm address of peer</param>
/// <returns>Returns round trip time for given peer</returns>
/// <exception cref="BeeNetDebugApiException">A server side error occurred.</exception>
Task<PingPongDto> TryConnectToPeerAsync(string peerId);
Task<string> TryConnectToPeerAsync(string peerId);

/// <summary>Withdraw tokens from the chequebook to the overlay address</summary>
/// <param name="amount">amount of tokens to withdraw</param>
/// <param name="gasPrice">Gas price for transaction</param>
/// <returns>Transaction hash of the withdraw transaction</returns>
/// <exception cref="BeeNetDebugApiException">A server side error occurred.</exception>
Task<TransactionHashDto> WithdrawFromChequeBookAsync(
Task<string> WithdrawFromChequeBookAsync(
int amount,
int? gasPrice = null);
}
Expand Down
Loading

0 comments on commit 0f97f4b

Please sign in to comment.