-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into vo/client-gen-dotnet
- Loading branch information
Showing
21 changed files
with
894 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Substrate.NetApi.Model.Types; | ||
|
||
namespace Sails.Remoting.Abstractions; | ||
|
||
public interface IRemotingProvider | ||
{ | ||
/// <summary> | ||
/// Creates an instance implementing the <see cref="IRemoting"/> interface | ||
/// with initial account for signing transactions. | ||
/// </summary> | ||
/// <param name="signingAccount"></param> | ||
/// <returns></returns> | ||
IRemoting CreateRemoting(Account signingAccount); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Substrate.Gear.Api.Generated; | ||
|
||
namespace Sails.Remoting; | ||
|
||
internal interface INodeClientProvider | ||
{ | ||
/// <summary> | ||
/// Returns connected node client. | ||
/// </summary> | ||
/// <param name="cancellationToken"></param> | ||
/// <returns></returns> | ||
Task<SubstrateClientExt> GetNodeClientAsync(CancellationToken cancellationToken); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using EnsureThat; | ||
using Sails.Remoting.Options; | ||
using Substrate.Gear.Api.Generated; | ||
using Substrate.NetApi.Model.Extrinsics; | ||
|
||
namespace Sails.Remoting; | ||
|
||
internal sealed class NodeClientProvider : IDisposable, INodeClientProvider | ||
{ | ||
public NodeClientProvider(NodeClientOptions options) | ||
{ | ||
EnsureArg.IsNotNull(options, nameof(options)); | ||
EnsureArg.IsNotNull(options.GearNodeUri, nameof(options.GearNodeUri)); | ||
|
||
this.nodeClient = new SubstrateClientExt(options.GearNodeUri, ChargeTransactionPayment.Default()); | ||
} | ||
|
||
private readonly SubstrateClientExt nodeClient; | ||
|
||
/// <inheritdoc/> | ||
public void Dispose() | ||
{ | ||
this.nodeClient.Dispose(); | ||
GC.SuppressFinalize(this); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public async Task<SubstrateClientExt> GetNodeClientAsync(CancellationToken cancellationToken) | ||
{ | ||
await this.nodeClient.ConnectAsync(cancellationToken).ConfigureAwait(false); | ||
return this.nodeClient; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System; | ||
using EnsureThat; | ||
using Sails.Remoting.Abstractions; | ||
using Substrate.NetApi.Model.Types; | ||
|
||
namespace Sails.Remoting; | ||
|
||
internal sealed class RemotingProvider : IRemotingProvider | ||
{ | ||
public RemotingProvider(Func<Account, IRemoting> remotingFactory) | ||
{ | ||
EnsureArg.IsNotNull(remotingFactory, nameof(remotingFactory)); | ||
|
||
this.remotingFactory = remotingFactory; | ||
} | ||
|
||
private readonly Func<Account, IRemoting> remotingFactory; | ||
|
||
/// <inheritdoc/> | ||
public IRemoting CreateRemoting(Account signingAccount) | ||
{ | ||
EnsureArg.IsNotNull(signingAccount, nameof(signingAccount)); | ||
|
||
return this.remotingFactory(signingAccount); | ||
} | ||
} |
Oops, something went wrong.