Skip to content

Static Types

Pre-release
Pre-release
Compare
Choose a tag to compare
@dkackman dkackman released this 15 Aug 22:49
· 326 commits to main since this release
772df39

This release moves from dynamic return types on the proxy interfaces, to static types.

This is a significant change as static types are much more familiar to .net developers than dynamics. For those of us used to learning an api by examining the the type system (and yes, using intellisense) this should be a welcome addition.

The beta release of this library will likely be based on these changes.

Example

Before

public async Task<dynamic> GetBlockchainState(CancellationToken cancellationToken = default)

After

public async Task<BlockchainState> GetBlockchainState(CancellationToken cancellationToken = default)

// where BlockChainState and the types it uses are all statically declared

public record BlockchainState
{
    public ulong Difficulty { get; init; }
    public bool GenesisChallengeInitiated { get; init; }
    public int MempoolSize { get; init; }
    public BlockRecord Peak { get; init; }
    public BigInteger Space { get; init; }
    public ulong SubSlotIters { get; init; }
    public SyncState Sync { get; init; }
}

Notes

  • The type names between python and C# are 90% the same
  • There are cases where python uses unnamed dynamic type as dictionaries or tuples. Where the tuples are are concise, .net named tuples are used. In a couple of places intermediate types have been introduced in order to avoid awkward tuple declarations.
  • All of the static chia types are declared as init-only record types.

#7
#14