Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added basetuple with arguments up to 39 in again #92

Merged
merged 1 commit into from
Sep 14, 2024
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
60 changes: 60 additions & 0 deletions Substrate.NetApi.Console/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
using Serilog;
using Substrate.NetApi;
using Substrate.NetApi.Model.Extrinsics;

internal class Program
{
private static async Task Main(string[] args)
{
// Configure Serilog for logging
Log.Logger = new LoggerConfiguration()
.WriteTo.Console()
.MinimumLevel.Debug()
.CreateLogger();

// Set up a cancellation token for graceful shutdown
CancellationTokenSource cts = new CancellationTokenSource();

await MainAsync(cts.Token);

// Keep the application alive to continue monitoring the connection
Console.WriteLine("Press any key to exit...");
Console.ReadKey();

// Cleanup logging resources
await Log.CloseAndFlushAsync();
}

private static async Task MainAsync(CancellationToken token)
{
// Create the client
string substrateNodeUrl = "wss://rpc-parachain.bajun.network";
var client = new SubstrateClient(new Uri(substrateNodeUrl), ChargeTransactionPayment.Default());

while (!token.IsCancellationRequested)
{
// Ensure the client is connected
if (!client.IsConnected)
{
Log.Information("Attempting to connect to the client...");
await client.ConnectAsync(
useMetaData: true,
standardSubstrate: true,
maxRetryAttempts: 5,
delayRetryMilliseconds: 5000,
token: token
);
Log.Information("Client connected successfully.");
}

var currentBlocknumber = await client.State.GetStorageAsync(Utils.HexToByteArray("0x26aa394eea5630e07c48ae0c9558cef702a5c1b19ab7a04f536c519aca4983ac"), (string)null, token);
Log.Information("MainAsync running... block: {blocknumber}", currentBlocknumber.ToString());

// Wait before next call
await Task.Delay(12000);
}

// Gracefully shut down
await client.CloseAsync();
}
}
18 changes: 18 additions & 0 deletions Substrate.NetApi.Console/Substrate.NetApi.Console.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Substrate.NetApi\Substrate.NetApi.csproj" />
</ItemGroup>

</Project>
Loading
Loading