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

chore: Updated SDK to latest utxorpc-spec 0.7.0 #4

Merged
merged 1 commit into from
Jul 15, 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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
**/appsettings.json
**/appsettings.*.json
**/bin
**/obj
**/obj
.env
21 changes: 21 additions & 0 deletions publish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
# Clean and build the project
source .env
rm -rf ./src/Utxorpc.Sdk/bin/
rm -rf ./src/Utxorpc.Sdk/obj

dotnet clean
dotnet build --configuration Release

# Pack your project
dotnet pack --configuration Release

PACKAGE_FILE=$(find ./src/Utxorpc.Sdk/bin/Release -name "*.nupkg" | head -n 1)

if [ -z "$PACKAGE_FILE" ]; then
echo "No .nupkg file found."
exit 1
fi

echo "Found package file: $PACKAGE_FILE"
dotnet nuget push "$PACKAGE_FILE" --api-key ${NUGET_API_KEY} --source https://api.nuget.org/v3/index.json
11 changes: 6 additions & 5 deletions src/Utxorpc.Sdk.Example/Program.cs
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
using Google.Protobuf;
using Utxorpc.Sdk;
using Utxorpc.Sync.V1;
using Utxorpc.V1alpha.Sync;

var utxoRpcClient = new UtxorpcClient("http://localhost:50051");
var chainSyncClient = utxoRpcClient.ChainSyncClient;
var chainSyncClient = utxoRpcClient.SyncClient;

var request = new FetchBlockRequest();
request.Ref.Add(
new BlockRef
{
Hash = ByteString.CopyFrom(
Convert.FromHexString("3fc0126deefb17acda42ed941f8e61eaaf58ca72a386f831ccfb0daeb61e6d42")
Convert.FromHexString("34c65aba4b299113a488b74e2efe3a3dd272d25b470d25f374b2c693d4386535")
),
Index = 39822377
Index = 54131816
}
);


var response = await chainSyncClient.FetchBlockAsync(request);
var blockHash = Convert.ToHexString(response.Block[0].Cardano.Header.Hash.ToByteArray());
var blockSlot = response.Block[0].Cardano.Header.Slot;
Console.WriteLine($"Block: {blockHash} Slot: {blockSlot}");
Console.WriteLine($"Block: {blockHash} Slot: {blockSlot} Block Data: {response.Block[0].Cardano.Body.Tx.Count}");
4 changes: 2 additions & 2 deletions src/Utxorpc.Sdk/Utxorpc.Sdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageId>Utxorpc.Sdk</PackageId>
<Version>0.1.1-alpha</Version>
<Version>0.7.0-alpha</Version>
<Authors>clark@txpipe.io</Authors>
<Company>TxPipe LLC</Company>
<PackageDescription>A gRPC interface for UTxO Blockchains</PackageDescription>
Expand All @@ -14,7 +14,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Utxorpc.Spec" Version="0.1.2-alpha" />
<PackageReference Include="Utxorpc.Spec" Version="0.7.0-alpha" />
</ItemGroup>

<ItemGroup>
Expand Down
13 changes: 7 additions & 6 deletions src/Utxorpc.Sdk/UtxorpcClient.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
using Grpc.Net.Client;
using Utxorpc.Submit.V1;
using Utxorpc.Sync.V1;
using Utxorpc.Watch.V1;
using Utxorpc.Build.V1;
using Utxorpc.V1alpha.Cardano;
using Utxorpc.V1alpha.Query;
using Utxorpc.V1alpha.Submit;
using Utxorpc.V1alpha.Sync;
using Utxorpc.V1alpha.Watch;

namespace Utxorpc.Sdk;

public class UtxorpcClient(string url)
{
public ChainSyncService.ChainSyncServiceClient ChainSyncClient => new(GrpcChannel.ForAddress(url));
public SyncService.SyncServiceClient SyncClient => new(GrpcChannel.ForAddress(url));
public WatchService.WatchServiceClient WatchClient => new(GrpcChannel.ForAddress(url));
public SubmitService.SubmitServiceClient SubmitClient => new(GrpcChannel.ForAddress(url));
public LedgerStateService.LedgerStateServiceClient LedgerStateClient => new(GrpcChannel.ForAddress(url));
public QueryService.QueryServiceClient QueryClient => new(GrpcChannel.ForAddress(url));
}