Skip to content
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
10 changes: 10 additions & 0 deletions .github/workflows/nuget-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,13 @@ jobs:

# Flag to toggle pushing symbols along with nuget package to the server, disabled by default
# INCLUDE_SYMBOLS: false

- name: publish CES on version change
id: publish_ces_nuget
uses: rohith/publish-nuget@v2
with:
PROJECT_FILE_PATH: Casper.Network.SDK.CES/Casper.Network.SDK.CES.csproj
PACKAGE_NAME: Casper.Network.SDK.CES
VERSION_REGEX: ^\s*<PackageVersion>(.*)<\/PackageVersion>\s*$
TAG_FORMAT: v*
NUGET_KEY: ${{secrets.NUGET_API_KEY}}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ obj/
riderModule.iml
/_ReSharper.Caches/
/.vs
*.DotSettings.user
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,29 @@ All notable changes to this project will be documented in this file. The format
[comment]: <> (Security: in case of vulnerabilities)


## [3.3.0]

### Added

* Added Casper Event Standard (CES) schema loading, event decoding, and extraction of contract events from execution results through `CESContractSchema`, `CESEvent`, and `CESParser`. These types are provided by the separate `Casper.Network.SDK.CES` NuGet package, which depends on the core SDK and supports .NET 8 and .NET Standard 2.0. Import the `Casper.Network.SDK.CES` namespace to use them. [PR#111](https://github.com/make-software/casper-net-sdk/pull/111).
* Added binary deserialization of `CLValue` and `NamedArg` values through `FromBytes()` and `FromReader()` methods on their byte serializers, and of named argument lists through `NamedArg.ListFromBytes()` and `NamedArg.ListFromReader()`. [PR#110](https://github.com/make-software/casper-net-sdk/pull/110).
* Added `CLValueDictionary.Parse()` to decode dictionary entries into their value bytes, seed URef, and item key, and `CLValueReader` to read values from a binary stream using a known `CLTypeInfo`. [PR#110](https://github.com/make-software/casper-net-sdk/pull/110) and [PR#111](https://github.com/make-software/casper-net-sdk/pull/111).
* Added a `ServerEventsClient(string sseUrl)` constructor for Casper 2.x nodes that accepts a full HTTP or HTTPS event stream URL, including a custom path and query parameters. [PR#113](https://github.com/make-software/casper-net-sdk/pull/113).
* Added `KeyPair.Create()`, `KeyPair.FromBytes()`, and `KeyPair.RawBytes` for key generation and raw private-key import/export. Raw keys must contain 32 bytes: an ED25519 seed or a SECP256K1 unsigned scalar in big-endian order. [PR#117](https://github.com/make-software/casper-net-sdk/pull/117).
* Added Casper 2.0 guides for `TransactionV1`, balance queries, and addressable entities, and refreshed the existing articles and tutorials. [PR#115](https://github.com/make-software/casper-net-sdk/pull/115).

### Fixed

* Fixed incorrect deserialization of `Version2` block headers. [PR#119](https://github.com/make-software/casper-net-sdk/pull/119).
* Renamed `Message.HashAddr` to `Message.EntityAddr` and changed its JSON field from `hash_addr` to `entity_addr` to match Casper 2.0 responses. Applications using `HashAddr` must update their references. [PR#120](https://github.com/make-software/casper-net-sdk/pull/120).
* Fixed speculative execution response parsing for Casper 2.x nodes while preserving support for Casper 1.x responses. [PR#120](https://github.com/make-software/casper-net-sdk/pull/120).
* Corrected the return type of `SpeceulativeExecutionWithBlockHash()` in `ICasperClient` and `NetCasperClient` from `RpcResponse<PutDeployResult>` to `RpcResponse<SpeculativeExecutionResult>`. Callers and interface implementations must use the corrected type. [PR#120](https://github.com/make-software/casper-net-sdk/pull/120).
* Fixed intermittent invalid SECP256K1 signatures by normalizing the signature's `s` component instead of retrying with the same signer. [PR#117](https://github.com/make-software/casper-net-sdk/pull/117).

### Deprecated

* `KeyPair.CreateNew()` is marked as obsolete. Use `KeyPair.Create()` instead. The old method remains available as a compatibility wrapper. [PR#117](https://github.com/make-software/casper-net-sdk/pull/117).

## [3.2.0]

### Fixed
Expand Down Expand Up @@ -207,6 +230,8 @@ This new type permits to parse correctly the value `"00"` used for system blocks
### Added
* Initial release of Casper .NET SDK.

[3.3.0]: https://github.com/make-software/casper-net-sdk/releases/tag/v3.3.0
[3.2.0]: https://github.com/make-software/casper-net-sdk/releases/tag/v3.2.0
[3.0.0]: https://github.com/make-software/casper-net-sdk/releases/tag/v3.0.0
[3.0.0-beta4]: https://github.com/make-software/casper-net-sdk/releases/tag/v3.0.0-beta4
[3.0.0-beta3]: https://github.com/make-software/casper-net-sdk/releases/tag/v3.0.0-beta3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using NUnit.Framework;
using Org.BouncyCastle.Utilities.Encoders;

namespace NetCasperTest
namespace Casper.Network.SDK.CES.Test
{
/// <summary>
/// Verifies that <see cref="CESContractSchema"/> and <see cref="CESEvent"/> round-trip
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using NUnit.Framework;
using Org.BouncyCastle.Utilities.Encoders;

namespace NetCasperTest
namespace Casper.Network.SDK.CES.Test
{
[TestFixture]
public class CESParserGetEventsTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using NUnit.Framework;
using Org.BouncyCastle.Utilities.Encoders;

namespace NetCasperTest
namespace Casper.Network.SDK.CES.Test
{
[TestFixture]
public class CESParserTest
Expand Down
29 changes: 29 additions & 0 deletions Casper.Network.SDK.CES.Test/Casper.Network.SDK.CES.Test.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>9.0</LangVersion>
<IsPackable>false</IsPackable>
<RootNamespace>Casper.Network.SDK.CES.Test</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="coverlet.collector" Version="3.2.0" />
</ItemGroup>

<PropertyGroup>
<CustomTargetFramework Condition="'$(TEST_FRAMEWORK)' != ''">$(TEST_FRAMEWORK)</CustomTargetFramework>
<CustomTargetFramework Condition="'$(CustomTargetFramework)' == ''">net8.0</CustomTargetFramework>
</PropertyGroup>

<ItemGroup Condition="'$(CustomTargetFramework)' == 'net8.0'">
<ProjectReference Include="..\Casper.Network.SDK.CES\Casper.Network.SDK.CES.csproj" Properties="TargetFramework=net8.0" />
</ItemGroup>
<ItemGroup Condition="'$(CustomTargetFramework)' == 'netstandard2.0'">
<ProjectReference Include="..\Casper.Network.SDK.CES\Casper.Network.SDK.CES.csproj" Properties="TargetFramework=netstandard2.0" />
</ItemGroup>

</Project>
File renamed without changes.
34 changes: 34 additions & 0 deletions Casper.Network.SDK.CES/Casper.Network.SDK.CES.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net8.0;netstandard2.0</TargetFrameworks>
<LangVersion>9.0</LangVersion>
<NoWarn>CS1591</NoWarn>
<AssemblyVersion>3.3.0.0</AssemblyVersion>
<FileVersion>3.3.0</FileVersion>
<PackageVersion>3.3.0</PackageVersion>
<PackageId>Casper.Network.SDK.CES</PackageId>
<Title>Casper.Network.SDK.CES</Title>
<Authors>make-software</Authors>
<PackageProjectUrl>https://github.com/make-software/casper-net-sdk</PackageProjectUrl>
<RepositoryUrl>https://github.com/make-software/casper-net-sdk</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>Casper NetCasperSDK CES</PackageTags>
<PackageReadmeFile>README_nuget.md</PackageReadmeFile>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<Description>Casper Event Standard (CES) schema and event parsing for the Casper .NET SDK.</Description>
<RootNamespace>Casper.Network.SDK.CES</RootNamespace>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Casper.Network.SDK\Casper.Network.SDK.csproj" />
<Compile Include="..\Casper.Network.SDK\Compat\IsExternalInit.cs" Link="Compat\IsExternalInit.cs" />
</ItemGroup>

<ItemGroup>
<None Include="README_nuget.md" Pack="true" PackagePath="\" />
<None Include="..\LICENSE" Pack="true" PackagePath="\" />
</ItemGroup>

</Project>
28 changes: 28 additions & 0 deletions Casper.Network.SDK.CES/README_nuget.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Casper Event Standard (CES) for .NET

`Casper.Network.SDK.CES` parses typed events emitted by Casper smart contracts that follow the Casper Event Standard. It supports .NET 8 and .NET Standard 2.0 and depends on `Casper.Network.SDK`.

## Installation

```bash
dotnet add package Casper.Network.SDK.CES
```

## Usage

```csharp
using System;
using Casper.Network.SDK;
using Casper.Network.SDK.CES;

var client = new NetCasperClient("http://127.0.0.1:11101/rpc");
var schema = await CESContractSchema.LoadAsync(client, contractPackageHash);

var events = CESParser.GetEvents(executionResult.Effect, new[] { schema });
foreach (var evt in events)
Console.WriteLine(evt.Name);
```

`contractPackageHash` is the hash of the contract package to watch, and `executionResult` is the execution result of a processed transaction.

See the [CES documentation](https://make-software.github.io/casper-net-sdk/Articles/CasperEventStandard.html) and the [SSE example](https://github.com/make-software/casper-net-sdk/tree/master/Docs/Examples/CESParser) for more details.
12 changes: 12 additions & 0 deletions Casper.Network.SDK.sln
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Casper.Network.SDK", "Caspe
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Casper.Network.SDK.Test", "Casper.Network.SDK.Test\Casper.Network.SDK.Test.csproj", "{F0C55C8D-6C59-4066-A6CF-82F2710A1DC1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Casper.Network.SDK.CES", "Casper.Network.SDK.CES\Casper.Network.SDK.CES.csproj", "{46B8D7E6-8764-4CD5-9246-0DB9B328B020}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Casper.Network.SDK.CES.Test", "Casper.Network.SDK.CES.Test\Casper.Network.SDK.CES.Test.csproj", "{B47F84D8-CE31-4C16-A784-55FCA082C29F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -18,5 +22,13 @@ Global
{F0C55C8D-6C59-4066-A6CF-82F2710A1DC1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F0C55C8D-6C59-4066-A6CF-82F2710A1DC1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F0C55C8D-6C59-4066-A6CF-82F2710A1DC1}.Release|Any CPU.Build.0 = Release|Any CPU
{46B8D7E6-8764-4CD5-9246-0DB9B328B020}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{46B8D7E6-8764-4CD5-9246-0DB9B328B020}.Debug|Any CPU.Build.0 = Debug|Any CPU
{46B8D7E6-8764-4CD5-9246-0DB9B328B020}.Release|Any CPU.ActiveCfg = Release|Any CPU
{46B8D7E6-8764-4CD5-9246-0DB9B328B020}.Release|Any CPU.Build.0 = Release|Any CPU
{B47F84D8-CE31-4C16-A784-55FCA082C29F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B47F84D8-CE31-4C16-A784-55FCA082C29F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B47F84D8-CE31-4C16-A784-55FCA082C29F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B47F84D8-CE31-4C16-A784-55FCA082C29F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
4 changes: 0 additions & 4 deletions Casper.Network.SDK.sln.DotSettings.user

This file was deleted.

6 changes: 3 additions & 3 deletions Casper.Network.SDK/Casper.Network.SDK.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
<TargetFrameworks>net8.0;netstandard2.0</TargetFrameworks>
<LangVersion>9.0</LangVersion>
<NoWarn>CS1591</NoWarn>
<AssemblyVersion>3.2.0.0</AssemblyVersion>
<FileVersion>3.2.0</FileVersion>
<PackageVersion>3.2.0</PackageVersion>
<AssemblyVersion>3.3.0.0</AssemblyVersion>
<FileVersion>3.3.0</FileVersion>
<PackageVersion>3.3.0</PackageVersion>
<Title>Casper.Network.SDK</Title>
<Authors>make-software</Authors>
<PackageProjectUrl>https://github.com/make-software/casper-net-sdk</PackageProjectUrl>
Expand Down
2 changes: 2 additions & 0 deletions Casper.Network.SDK/README_nuget.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

The Casper .NET SDK allows developers to interact with the Casper Network using the .NET languages. The project itself is being developed with C#.

For Casper Event Standard (CES) schema and event parsing, install the separate `Casper.Network.SDK.CES` package and import the `Casper.Network.SDK.CES` namespace.

## GitHub repository

https://github.com/make-software/casper-net-sdk
19 changes: 17 additions & 2 deletions Docs/Articles/CasperEventStandard.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@

The **Casper Event Standard (CES)** is a convention adopted by contract developers for emitting and consuming typed events from Casper smart contracts. Contracts that follow CES store a self-describing schema alongside their events, making it possible to decode any event without out-of-band knowledge of its structure.

The Casper .NET SDK provides the `Casper.Network.SDK.CES` namespace with three classes: `CESContractSchema` (schema loading and parsing), `CESEvent` (event parsing and field access), and `CESParser` (scanning execution results).
The `Casper.Network.SDK.CES` NuGet package provides the `Casper.Network.SDK.CES` namespace with three main classes: `CESContractSchema` (schema loading and parsing), `CESEvent` (event parsing and field access), and `CESParser` (scanning execution results).

## Installation

Add the CES package to your application. It depends on `Casper.Network.SDK`, which NuGet installs automatically:

```bash
dotnet add package Casper.Network.SDK.CES
```

---

Expand Down Expand Up @@ -55,6 +63,7 @@ The simplest way to load a contract's schema is `CESContractSchema.LoadAsync`. I
When you pass a contract-package hash, the method resolves the latest active contract version automatically. You can also request a specific version with the optional `version` parameter.

```csharp
using Casper.Network.SDK;
using Casper.Network.SDK.CES;

var client = new NetCasperClient("https://rpc.testnet.casperlabs.io/rpc");
Expand Down Expand Up @@ -247,4 +256,10 @@ Console.WriteLine(json);

## Parsing CES events in the SSE stream

See `Docs/Examples/CESParser/Program.cs` for a runnable sample that connects to the node SSE stream, listens to `TransactionProcessed` events, and pretty-prints parsed CES events.
See [the CES parser example](https://github.com/make-software/casper-net-sdk/tree/master/Docs/Examples/CESParser) for a runnable sample that references the CES library, connects to the node SSE stream, listens to `TransactionProcessed` events, and pretty-prints parsed CES events.

Run it from the repository root, supplying the contract-package hash to watch:

```bash
dotnet run --project Docs/Examples/CESParser -- <contract-package-hash>
```
8 changes: 8 additions & 0 deletions Docs/Articles/GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Install-Package Casper.Network.SDK
dotnet add package Casper.Network.SDK
```

For Casper Event Standard schema and event parsing, also install `Casper.Network.SDK.CES` and import `Casper.Network.SDK.CES`. See the [CES guide](./CasperEventStandard.md).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This note points NuGet users to Casper.Network.SDK.CES, but the "Add a reference to the source code" section just below still names only Casper.Network.SDK.csproj. CES no longer compiles into that project. So anyone who references the SDK from source and then follows the CES guide gets unresolved Casper.Network.SDK.CES / CESParser symbols.

Could that section also mention the CES project, e.g. dotnet add reference ../casper-net-sdk/Casper.Network.SDK.CES/Casper.Network.SDK.CES.csproj?

Basis
  • CESParser moved from Casper.Network.SDK/CES/ to Casper.Network.SDK.CES/CESParser.cs, and Casper.Network.SDK.csproj has no reference to the new project.
  • The source-reference section is unchanged by this PR. The other docs that mention CES (CasperEventStandard.md, README.md, the CES README_nuget.md) only give the dotnet add package route.


## Add a reference to the source code

Clone the GitHub repository in your solution folder and add a reference in your project to the `Casper.Network.SDK.csproj` file.
Expand All @@ -32,6 +34,12 @@ cd your-project
dotnet add reference ../casper-net-sdk/Casper.Network.SDK/Casper.Network.SDK.csproj
```

If you need the CES parser, also add a reference to the `Casper.Network.SDK.CES.csproj` project in the same way:

```bash
dotnet add reference ../casper-net-sdk/Casper.Network.SDK.CES/Casper.Network.SDK.CES.csproj
```

## Create a minimal console application

Create a new console app and add the SDK package:
Expand Down
2 changes: 1 addition & 1 deletion Docs/Examples/CESParser/CESParser.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\Casper.Network.SDK\Casper.Network.SDK.csproj" />
<ProjectReference Include="..\..\..\Casper.Network.SDK.CES\Casper.Network.SDK.CES.csproj" />
</ItemGroup>

</Project>
4 changes: 3 additions & 1 deletion Docs/docfx.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
{
"src": [
{
"src": "..",
"files": [
"Casper.Network.SDK/**.csproj"
"Casper.Network.SDK/Casper.Network.SDK.csproj",
"Casper.Network.SDK.CES/Casper.Network.SDK.CES.csproj"
]
}
],
Expand Down
3 changes: 2 additions & 1 deletion Docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The Casper .NET SDK allows developers to interact with the Casper Network using
* [Working with AddressableEntity](./Articles/WorkingWithAddressableEntity.md) — Query entities (accounts, contracts, and system contracts) on Casper 2.0.
* [Key management](./Articles/KeyManagement.md) — Create, load, and save public/private key pairs.
* [Working with Server-Sent Events (SSE)](./Articles/WorkingWithSSE.md) — Listen to real-time events from a Casper node.
* [Casper Event Standard (CES)](./Articles/CasperEventStandard.md) — Decode typed events emitted by smart contracts.
* [Casper Event Standard (CES)](./Articles/CasperEventStandard.md) — Decode typed events emitted by smart contracts with the separate `Casper.Network.SDK.CES` package.
* [Running a local Casper network with NCTL](./Articles/RunningNctlLocally.md) — Set up a local test network using Docker.
* [Migration from v2.x to v3.0](./Articles/Casper20MigrationGuide.md) — Upgrade your application for Casper 2.0 compatibility.

Expand All @@ -43,3 +43,4 @@ See the complete list of examples [here](./Examples/index.md).

* [GitHub repository](https://github.com/make-software/casper-net-sdk)
* [NuGet package](https://www.nuget.org/packages/Casper.Network.SDK/)
* [CES NuGet package](https://www.nuget.org/packages/Casper.Network.SDK.CES/)
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ Install-Package Casper.Network.SDK
dotnet add package Casper.Network.SDK
```

### Casper Event Standard (CES)

CES schema and event parsing is provided by the separate `Casper.Network.SDK.CES` package, which depends on the core SDK:

```bash
dotnet add package Casper.Network.SDK.CES
```

Import `Casper.Network.SDK.CES` to use `CESContractSchema`, `CESEvent`, and `CESParser`. See the [CES documentation](Docs/Articles/CasperEventStandard.md) and [SSE example](Docs/Examples/CESParser/Program.cs).

## Run a Casper node locally with NCTL

[NCTL](https://github.com/casper-network/casper-node/tree/release-1.4.3/utils/nctl) is a CLI application to control one or multiple Casper networks locally. Many developers wish to spin up relatively small test networks to localize their testing before deploying to the blockchain.
Expand Down
Loading