diff --git a/.github/workflows/build-test-format.yml b/.github/workflows/build-test-format.yml index 1e9b8878..b73d195b 100644 --- a/.github/workflows/build-test-format.yml +++ b/.github/workflows/build-test-format.yml @@ -9,7 +9,7 @@ on: env: RUST_FMT: nightly-2023-04-01-x86_64-unknown-linux-gnu - RUST_CLIPPY: 1.68 + RUST_CLIPPY: 1.73 jobs: rustfmt: @@ -48,7 +48,7 @@ jobs: run: cargo build --manifest-path=./rust-bindings/Cargo.toml --release - name: Test Rust Project - run: cargo test --manifest-path=./rust-bindings/Cargo.toml --release + run: cargo test --manifest-path=./rust-bindings/Cargo.toml --release - name: Setup .NET uses: actions/setup-dotnet@v3 @@ -58,11 +58,12 @@ jobs: - name: Restore dependencies run: dotnet restore + - name: Check formatting + run: dotnet format --verify-no-changes + - name: Build - run: dotnet build --no-restore + run: dotnet build --no-restore -warnaserror - name: Test run: dotnet test --filter FullyQualifiedName!~IntegrationTests --no-build --verbosity normal - - name: Check formatting - run: dotnet format --verify-no-changes diff --git a/concordium-base b/concordium-base index 872e8590..66eef319 160000 --- a/concordium-base +++ b/concordium-base @@ -1 +1 @@ -Subproject commit 872e8590b3de8391a854a5f6282ac49e2005a520 +Subproject commit 66eef31986a3475ab68f2546c297857e9d9b7125 diff --git a/examples/DeployModule/Program.cs b/examples/DeployModule/Program.cs index b9301c1d..2e4d85f2 100644 --- a/examples/DeployModule/Program.cs +++ b/examples/DeployModule/Program.cs @@ -61,7 +61,7 @@ private static async Task Run(DeployModuleOptions o) // Prepare the transaction for signing. var sender = account.AccountAddress; - var sequenceNumber = client.GetNextAccountSequenceNumber(sender).Item1; + var (sequenceNumber, _) = await client.GetNextAccountSequenceNumberAsync(sender); var expiry = Expiry.AtMinutesFromNow(30); var preparedTransfer = transferPayload.Prepare(sender, sequenceNumber, expiry); @@ -69,7 +69,7 @@ private static async Task Run(DeployModuleOptions o) var signedTransfer = preparedTransfer.Sign(account); // Submit the transaction. - var txHash = client.SendAccountTransaction(signedTransfer); + var txHash = await client.SendAccountTransactionAsync(signedTransfer); // Print the transaction hash. Console.WriteLine($"Successfully submitted transfer transaction with hash {txHash}"); diff --git a/examples/InitContract/Program.cs b/examples/InitContract/Program.cs index 1a30f8aa..05b65476 100644 --- a/examples/InitContract/Program.cs +++ b/examples/InitContract/Program.cs @@ -78,7 +78,7 @@ private static async Task Run(InitContractOptions o) // Prepare the transaction for signing. var sender = account.AccountAddress; - var sequenceNumber = client.GetNextAccountSequenceNumber(sender).Item1; + var (sequenceNumber, _) = await client.GetNextAccountSequenceNumberAsync(sender); var expiry = Expiry.AtMinutesFromNow(30); var preparedPayload = payload.Prepare(sender, sequenceNumber, expiry, maxEnergy); @@ -86,7 +86,7 @@ private static async Task Run(InitContractOptions o) var signedTrx = preparedPayload.Sign(account); // Submit the transaction. - var txHash = client.SendAccountTransaction(signedTrx); + var txHash = await client.SendAccountTransactionAsync(signedTrx); // Print the transaction hash. Console.WriteLine($"Successfully submitted init-contract transaction with hash {txHash}"); diff --git a/rust-bindings/Cargo.lock b/rust-bindings/Cargo.lock index 1efcef23..f105b381 100644 --- a/rust-bindings/Cargo.lock +++ b/rust-bindings/Cargo.lock @@ -179,21 +179,21 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "chrono" -version = "0.4.31" +version = "0.4.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f2c685bad3eb3d45a01354cedb7d5faa66194d1d58ba6e267a8de788f79db38" +checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" dependencies = [ "android-tzdata", "iana-time-zone", "js-sys", "num-traits", "wasm-bindgen", - "windows-targets", + "windows-targets 0.52.6", ] [[package]] name = "concordium-contracts-common" -version = "9.0.0" +version = "9.2.0" dependencies = [ "base64", "bs58", @@ -213,7 +213,7 @@ dependencies = [ [[package]] name = "concordium-contracts-common-derive" -version = "4.0.1" +version = "4.1.0" dependencies = [ "proc-macro2", "quote", @@ -771,7 +771,7 @@ version = "0.51.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f1f8cf84f35d2db49a46868f947758c7a1138116f7fac3bc844f43ade1292e64" dependencies = [ - "windows-targets", + "windows-targets 0.48.5", ] [[package]] @@ -780,13 +780,29 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm 0.52.6", + "windows_aarch64_msvc 0.52.6", + "windows_i686_gnu 0.52.6", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.6", + "windows_x86_64_gnu 0.52.6", + "windows_x86_64_gnullvm 0.52.6", + "windows_x86_64_msvc 0.52.6", ] [[package]] @@ -795,42 +811,90 @@ version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + [[package]] name = "windows_aarch64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + [[package]] name = "windows_i686_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + [[package]] name = "windows_i686_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + [[package]] name = "windows_x86_64_gnu" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + [[package]] name = "windows_x86_64_msvc" version = "0.48.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + [[package]] name = "wyz" version = "0.5.1" diff --git a/src/Client/ConcordiumClient.cs b/src/Client/ConcordiumClient.cs index f8e5ccc6..87e19956 100644 --- a/src/Client/ConcordiumClient.cs +++ b/src/Client/ConcordiumClient.cs @@ -812,5 +812,8 @@ public Task>> GetBlockItems(IBlockHash return QueryResponse>.From(response, BlockItem.From, token); } + /// + /// Dispose the client + /// public void Dispose() => this.Raw.Dispose(); } diff --git a/src/Client/RawClient.cs b/src/Client/RawClient.cs index 0d741d9e..d15c2478 100644 --- a/src/Client/RawClient.cs +++ b/src/Client/RawClient.cs @@ -714,5 +714,8 @@ private static GrpcChannelOptions SetSchemeIfNotSet(GrpcChannelOptions? channelO return channelOptions; } + /// + /// Dispose the RawClient. + /// public void Dispose() => this._grpcChannel.Dispose(); } diff --git a/src/Crypto/Ed25519SignKey.cs b/src/Crypto/Ed25519SignKey.cs index 6b35200e..552abfc1 100644 --- a/src/Crypto/Ed25519SignKey.cs +++ b/src/Crypto/Ed25519SignKey.cs @@ -83,6 +83,7 @@ public byte[] Sign(byte[] bytes) return algorithm.Sign(key, bytes); } + /// Determines whether one Ed25519SignKey is equal to a second Ed25519SignKey. public bool Equals(Ed25519SignKey? other) { if (other is null) @@ -98,5 +99,6 @@ public bool Equals(Ed25519SignKey? other) return this._value.SequenceEqual(other._value); } + /// Get hash code for the Ed25519SignKey. public override int GetHashCode() => Helpers.HashCode.GetHashCodeByteArray(this._value); } diff --git a/src/Crypto/ISigner.cs b/src/Crypto/ISigner.cs index 545f1cec..c36a8dde 100644 --- a/src/Crypto/ISigner.cs +++ b/src/Crypto/ISigner.cs @@ -1,5 +1,6 @@ namespace Concordium.Sdk.Crypto; +/// Implementers of this interface hold keys for signing data. public interface ISigner { /// diff --git a/src/Helpers/HashCode.cs b/src/Helpers/HashCode.cs index 214df4a3..e2e405f8 100644 --- a/src/Helpers/HashCode.cs +++ b/src/Helpers/HashCode.cs @@ -5,6 +5,10 @@ namespace Concordium.Sdk.Helpers; /// public static class HashCode { + + /// + /// Helper for getting a hash code for a byte array. + /// public static int GetHashCodeByteArray(byte[] array) { unchecked diff --git a/src/Transactions/ITransactionSigner.cs b/src/Transactions/ITransactionSigner.cs index 5aa62194..cbe56b97 100644 --- a/src/Transactions/ITransactionSigner.cs +++ b/src/Transactions/ITransactionSigner.cs @@ -31,7 +31,7 @@ public interface ITransactionSigner /// /// Sign a transaction hash. /// - /// A byte array representing the transaction hash to sign. + /// A byte array representing the transaction hash to sign. /// A representing the transaction signature. /// Unexpected length of a signature returned by the signing. public AccountTransactionSignature Sign(byte[] data); diff --git a/src/Transactions/RawPayload.cs b/src/Transactions/RawPayload.cs index 6e6f8573..5bad42dc 100644 --- a/src/Transactions/RawPayload.cs +++ b/src/Transactions/RawPayload.cs @@ -17,5 +17,8 @@ public sealed record RawPayload(byte[] Bytes) : AccountTransactionPayload /// internal override PayloadSize Size() => new((uint)this.Bytes.Length); + /// + /// Get the array of bytes representing this payload. + /// public override byte[] ToBytes() => this.Bytes; } diff --git a/src/Transactions/TransactionSigner.cs b/src/Transactions/TransactionSigner.cs index 37cc9610..97283bab 100644 --- a/src/Transactions/TransactionSigner.cs +++ b/src/Transactions/TransactionSigner.cs @@ -24,9 +24,11 @@ public sealed class TransactionSigner : ITransactionSigner public TransactionSigner() => this._signers = new Dictionary>(); + /// Get the number of signatures this signer can produce. public byte GetSignatureCount() => (byte)this._signers.Values.SelectMany(x => x.Values).Count(); + /// Get credential-key-map of the signer. public ImmutableDictionary> GetSignerEntries() => this._signers .Select( diff --git a/src/Types/AccountAddress.cs b/src/Types/AccountAddress.cs index ee6751c9..fc86dd92 100644 --- a/src/Types/AccountAddress.cs +++ b/src/Types/AccountAddress.cs @@ -237,7 +237,10 @@ public static bool TryDeserial(ReadOnlySpan bytes, out (AccountAddress? Ac return true; } + /// Determines whether one AccountAddress is equal to a second AccountAddress. + /// This does not consider two distinct aliases to the same account as equal. public bool Equals(AccountAddress? other) => other is not null && this._value.SequenceEqual(other._value); + /// Get hash code for the AccountAddress. public override int GetHashCode() => Helpers.HashCode.GetHashCodeByteArray(this._value); } diff --git a/src/Types/AccountSequenceNumber.cs b/src/Types/AccountSequenceNumber.cs index 557969bc..2eb3e7e6 100644 --- a/src/Types/AccountSequenceNumber.cs +++ b/src/Types/AccountSequenceNumber.cs @@ -15,6 +15,9 @@ namespace Concordium.Sdk.Types; /// public readonly record struct AccountSequenceNumber { + /// + /// The number of bytes used to represent this type when serialized. + /// public const uint BytesLength = sizeof(ulong); /// diff --git a/src/Types/AccountStakingInfo.cs b/src/Types/AccountStakingInfo.cs index 7b83fe0c..85931f74 100644 --- a/src/Types/AccountStakingInfo.cs +++ b/src/Types/AccountStakingInfo.cs @@ -2,6 +2,9 @@ namespace Concordium.Sdk.Types; +/// +/// Information related to staking for a specific account. +/// public interface IAccountStakingInfo { } internal static class AccountStakingInfo diff --git a/src/Types/AccountTransactionEffects.cs b/src/Types/AccountTransactionEffects.cs index 6eb5005b..c989f51b 100644 --- a/src/Types/AccountTransactionEffects.cs +++ b/src/Types/AccountTransactionEffects.cs @@ -279,6 +279,7 @@ internal IEnumerable GetAffectedAccountAddresses() /// /// Receiver account. /// The list of releases. Ordered by increasing timestamp. +/// Additional data attached to the transaction. public sealed record TransferredWithSchedule (AccountAddress To, IList<(DateTimeOffset, CcdAmount)> Amount, OnChainData? Memo) : IAccountTransactionEffects { diff --git a/src/Types/BakerEvent.cs b/src/Types/BakerEvent.cs index 72982fc9..cd4a819f 100644 --- a/src/Types/BakerEvent.cs +++ b/src/Types/BakerEvent.cs @@ -51,6 +51,7 @@ internal static IBakerEvent From(BakerEvent bakerEvent) => ), BakerEvent.EventOneofCase.None => throw new MissingEnumException(bakerEvent.EventCase), + BakerEvent.EventOneofCase.DelegationRemoved => throw new NotImplementedException(), _ => throw new MissingEnumException(bakerEvent.EventCase) }; } diff --git a/src/Types/BakerPoolOpenStatus.cs b/src/Types/BakerPoolOpenStatus.cs index a03dcf9b..44584107 100644 --- a/src/Types/BakerPoolOpenStatus.cs +++ b/src/Types/BakerPoolOpenStatus.cs @@ -2,6 +2,9 @@ namespace Concordium.Sdk.Types; +/// +/// The status of the baker pool in regards to delegations. +/// public enum BakerPoolOpenStatus { /// diff --git a/src/Types/BlockHashInput.cs b/src/Types/BlockHashInput.cs index 9601e798..f8aaaaaa 100644 --- a/src/Types/BlockHashInput.cs +++ b/src/Types/BlockHashInput.cs @@ -7,6 +7,9 @@ namespace Concordium.Sdk.Types; /// public interface IBlockHashInput { + /// + /// Convert this into the type expected by the gRPC API. + /// BlockHashInput Into(); } @@ -17,6 +20,9 @@ public sealed record Best : IBlockHashInput { private static readonly Empty _empty = new(); + /// + /// Convert this into the type expected by the gRPC API. + /// public BlockHashInput Into() => new() { Best = _empty, @@ -31,6 +37,9 @@ public sealed record LastFinal : IBlockHashInput { private static readonly Empty _empty = new(); + /// + /// Convert this into the type expected by the gRPC API. + /// public BlockHashInput Into() => new() { LastFinal = _empty @@ -42,6 +51,9 @@ public sealed record LastFinal : IBlockHashInput /// public sealed record Given(BlockHash BlockHash) : IBlockHashInput { + /// + /// Convert this into the type expected by the gRPC API. + /// public BlockHashInput Into() => new() { Given = this.BlockHash.ToProto() }; } diff --git a/src/Types/BlockHeight.cs b/src/Types/BlockHeight.cs index 7cdf6d07..e1d74aeb 100644 --- a/src/Types/BlockHeight.cs +++ b/src/Types/BlockHeight.cs @@ -7,6 +7,9 @@ namespace Concordium.Sdk.Types; /// public interface IBlockHeight { + /// + /// Convert into a BlocksAtHeightRequest. + /// BlocksAtHeightRequest Into(); } @@ -18,6 +21,9 @@ public sealed record AbsoluteHeight(ulong Height) : IBlockHeight { internal static AbsoluteHeight From(AbsoluteBlockHeight blockHeight) => new(blockHeight.Value); + /// + /// Convert an AbsoluteHeight into a BlocksAtHeightRequest. + /// public BlocksAtHeightRequest Into() => new() { @@ -40,6 +46,9 @@ public BlocksAtHeightRequest Into() => /// public sealed record RelativeHeight(ulong Height, uint GenesisIndex, bool Restrict) : IBlockHeight { + /// + /// Convert a RelativeHeight into a BlocksAtHeightRequest. + /// public BlocksAtHeightRequest Into() => new() { diff --git a/src/Types/CcdAmount.cs b/src/Types/CcdAmount.cs index 9a315f85..cf5ca11b 100644 --- a/src/Types/CcdAmount.cs +++ b/src/Types/CcdAmount.cs @@ -136,10 +136,17 @@ public static bool TryDeserial(ReadOnlySpan bytes, out (CcdAmount? Amount, /// public byte[] ToBytes() => Serialization.ToBytes(this.Value); + /// + /// Return the largest of two amounts. + /// + public static CcdAmount Max(CcdAmount first, CcdAmount second) => first < second ? second : first; + + /// Determines whether one CcdAmount is less than a second CcdAmount. public static bool operator <(CcdAmount left, CcdAmount right) => left.Value.CompareTo(right.Value) < 0; + /// Determines whether one CcdAmount is greater than a second CcdAmount. public static bool operator >(CcdAmount left, CcdAmount right) => left.Value.CompareTo(right.Value) > 0; - + /// Determines whether one CcdAmount is less or equal than a second CcdAmount. public static bool operator <=(CcdAmount left, CcdAmount right) => left.Value.CompareTo(right.Value) <= 0; - + /// Determines whether one CcdAmount is greater or equal than a second CcdAmount. public static bool operator >=(CcdAmount left, CcdAmount right) => left.Value.CompareTo(right.Value) >= 0; } diff --git a/src/Types/ContractInitializedEvent.cs b/src/Types/ContractInitializedEvent.cs index 8bce0a6b..f40dc62d 100644 --- a/src/Types/ContractInitializedEvent.cs +++ b/src/Types/ContractInitializedEvent.cs @@ -41,7 +41,7 @@ internal static ContractInitializedEvent From(Grpc.V2.ContractInitializedEvent i } /// - /// Deserialize events from . + /// Deserialize events using a . /// /// Module schema in hexadecimal. /// List of deserialized json uft8 encoded events. Possible null if this was returned from deserialization. diff --git a/src/Types/ContractName.cs b/src/Types/ContractName.cs index 585c89a6..6c05ac76 100644 --- a/src/Types/ContractName.cs +++ b/src/Types/ContractName.cs @@ -112,9 +112,13 @@ public static bool TryDeserial(ReadOnlySpan bytes, out (ContractName? Cont /// public enum ValidationError { + /// Contract name did not include the mandatory prefix of 'init_'. MissingInitPrefix, + /// The contract name is more than 100 characters. TooLong, + /// The contract name contained the character '.'. ContainsDot, + /// The contract name contains characters that are not alphanumeric ASCII. InvalidCharacters, } diff --git a/src/Types/ContractTraceElement.cs b/src/Types/ContractTraceElement.cs index 730d2c5d..9cdc41df 100644 --- a/src/Types/ContractTraceElement.cs +++ b/src/Types/ContractTraceElement.cs @@ -75,7 +75,7 @@ public sealed record Updated( IList Events) : IContractTraceElement { /// - /// Deserialize message from . + /// Deserialize message using a . /// /// Versioned module schema. /// deserialized as json uft8 encoded. @@ -84,13 +84,13 @@ public Utf8Json GetDeserializeMessage(VersionedModuleSchema schema) => GetDeserializeMessage(schema, this.ReceiveName.GetContractName(), this.ReceiveName.GetEntrypoint(), this.Message); /// - /// Deserialize message from . + /// Deserialize message using a . /// /// Module schema. /// Contract name. /// Entrypoint on contract. /// Message to entrypoint. - /// deserialized as json uft8 encoded. + /// deserialized as json uft8 encoded. /// Thrown when message wasn't able to be deserialized from schema. public static Utf8Json GetDeserializeMessage( VersionedModuleSchema schema, @@ -101,7 +101,7 @@ Parameter message InteropBinding.GetReceiveContractParameter(schema, contractIdentifier, entryPoint, message); /// - /// Deserialize events from . + /// Deserialize events using a . /// /// Module schema. /// List of deserialized json uft8 encoded events. Possible null if this was returned from deserialization. @@ -136,7 +136,7 @@ public sealed record Transferred(ContractAddress From, CcdAmount Amount, Account public sealed record Interrupted(ContractAddress Address, IList Events) : IContractTraceElement { /// - /// Deserialize events from . + /// Deserialize events using a . /// /// Module schema. /// Contract name. diff --git a/src/Types/ContractVersion.cs b/src/Types/ContractVersion.cs index 4ed0cce6..108fd67d 100644 --- a/src/Types/ContractVersion.cs +++ b/src/Types/ContractVersion.cs @@ -3,11 +3,17 @@ namespace Concordium.Sdk.Types; /// -/// Contract version. +/// Smart Contract Module version. /// public enum ContractVersion { + /// + /// Smart Contract Module version 0. + /// V0 = 0, + /// + /// Smart Contract Module version 1. + /// V1 = 1 } diff --git a/src/Types/DelegationEvent.cs b/src/Types/DelegationEvent.cs index bcd2e633..923e8983 100644 --- a/src/Types/DelegationEvent.cs +++ b/src/Types/DelegationEvent.cs @@ -27,6 +27,7 @@ internal static IDelegationEvent From(DelegationEvent delegationEvent) => DelegationAdded.From(delegationEvent.DelegationAdded), DelegationEvent.EventOneofCase.DelegationRemoved => DelegationRemoved.From(delegationEvent.DelegationRemoved), + DelegationEvent.EventOneofCase.BakerRemoved => throw new NotImplementedException(), DelegationEvent.EventOneofCase.None => throw new MissingEnumException(delegationEvent.EventCase), _ => throw new MissingEnumException(delegationEvent.EventCase) diff --git a/src/Types/DelegationTarget.cs b/src/Types/DelegationTarget.cs index 876c6fb3..6de3ab02 100644 --- a/src/Types/DelegationTarget.cs +++ b/src/Types/DelegationTarget.cs @@ -2,9 +2,12 @@ namespace Concordium.Sdk.Types; +/// +/// The target for delegation of stake. +/// public abstract record DelegationTarget { - public static DelegationTarget From(Grpc.V2.DelegationTarget stakeDelegatorTarget) => + internal static DelegationTarget From(Grpc.V2.DelegationTarget stakeDelegatorTarget) => stakeDelegatorTarget.TargetCase switch { Grpc.V2.DelegationTarget.TargetOneofCase.Passive => diff --git a/src/Types/Expiry.cs b/src/Types/Expiry.cs index 4f69525b..bd15737a 100644 --- a/src/Types/Expiry.cs +++ b/src/Types/Expiry.cs @@ -10,6 +10,9 @@ namespace Concordium.Sdk.Types; /// public readonly record struct Expiry : IEquatable { + /// + /// Get the number of bytes used to represent an expiry when serialized. + /// public const int BytesLength = sizeof(ulong); /// @@ -104,13 +107,17 @@ public static DateTimeOffset Now() public Grpc.V2.TransactionTime ToProto() => new() { Value = (ulong)this._timestamp.ToUnixTimeSeconds() }; + /// Determines whether one Expiry is less than a second Expiry\. public static bool operator <(Expiry left, Expiry right) => left._timestamp < right._timestamp; + /// Determines whether one Expiry is greater than a second Expiry\. public static bool operator >(Expiry left, Expiry right) => left._timestamp > right._timestamp; + /// Determines whether one Expiry is less or equal than a second Expiry\. public static bool operator <=(Expiry left, Expiry right) => left._timestamp <= right._timestamp; + /// Determines whether one Expiry is greater or equal than a second Expiry\. public static bool operator >=(Expiry left, Expiry right) => left._timestamp >= right._timestamp; } diff --git a/src/Types/Hash.cs b/src/Types/Hash.cs index 09f1acfb..7355f1e0 100644 --- a/src/Types/Hash.cs +++ b/src/Types/Hash.cs @@ -5,6 +5,9 @@ namespace Concordium.Sdk.Types; /// public abstract record Hash : IEquatable { + /// + /// Number of bytes used to represent the hash. + /// public const int BytesLength = 32; /// @@ -68,6 +71,9 @@ protected Hash(byte[] hashAsBytes) /// public sealed override string ToString() => Convert.ToHexString(this._value).ToLowerInvariant(); + /// + /// Indicates that two hashes are the same hash. + /// public virtual bool Equals(Hash? other) { if (other is null) @@ -88,5 +94,8 @@ public virtual bool Equals(Hash? other) return this._value.SequenceEqual(other._value); } + /// + /// Get the hash code for a hash. + /// public override int GetHashCode() => Helpers.HashCode.GetHashCodeByteArray(this._value); } diff --git a/src/Types/OnChainData.cs b/src/Types/OnChainData.cs index 112b774a..01b25be2 100644 --- a/src/Types/OnChainData.cs +++ b/src/Types/OnChainData.cs @@ -180,15 +180,7 @@ public static bool TryDeserial(ReadOnlySpan bytes, out (OnChainData? OnCha /// Gets hash code. public override int GetHashCode() => Helpers.HashCode.GetHashCodeByteArray(this._value); - internal static OnChainData? From(Grpc.V2.Memo? memo) - { - if (memo == null || memo.Value.Length == 0) - { - return null; - } - - return From(memo.Value.ToByteArray()); - } + internal static OnChainData From(Grpc.V2.Memo memo) => From(memo.Value.ToByteArray()); internal static OnChainData From(Grpc.V2.RegisteredData registeredData) => From(registeredData.Value.ToByteArray()); } diff --git a/src/Types/PayloadSize.cs b/src/Types/PayloadSize.cs index 7cdc755c..902a9f32 100644 --- a/src/Types/PayloadSize.cs +++ b/src/Types/PayloadSize.cs @@ -8,6 +8,9 @@ namespace Concordium.Sdk.Types; /// Payload size public readonly record struct PayloadSize(uint Size) { + /// + /// Number of bytes used to represent this type when serialized. + /// public const uint BytesLength = sizeof(uint); /// diff --git a/src/Types/ReceiveName.cs b/src/Types/ReceiveName.cs index b98800d4..d3ba1615 100644 --- a/src/Types/ReceiveName.cs +++ b/src/Types/ReceiveName.cs @@ -67,8 +67,11 @@ public static ReceiveName Parse(string name) /// public enum ValidationError { + /// Receive name did not include the mandatory '.' character. MissingDotSeparator, + /// The receive name is more than 100 characters. TooLong, + /// The receive name contained characters that are not ASCII alphanumeric or ASCII punctuation. InvalidCharacters, } diff --git a/src/Types/RejectReason.cs b/src/Types/RejectReason.cs index 837bc7d2..0053ec9b 100644 --- a/src/Types/RejectReason.cs +++ b/src/Types/RejectReason.cs @@ -190,7 +190,7 @@ public sealed record RejectedReceive(int RejectReason, ContractAddress ContractA Parameter Parameter) : IRejectReason { /// - /// Deserialize message from . + /// Deserialize message using a . /// /// Versioned module schema. /// deserialized as json uft8 encoded. diff --git a/src/Types/RewardOverview.cs b/src/Types/RewardOverview.cs index b9c77531..b5de6d64 100644 --- a/src/Types/RewardOverview.cs +++ b/src/Types/RewardOverview.cs @@ -70,6 +70,24 @@ public sealed record RewardOverviewV0( /// /// Reward Overview version 1. /// +/// +/// The active protocol version at the time of this reward overview. +/// +/// +/// The total number of CCD in existence at the time of this reward overview. +/// +/// +/// The total number of encrypted/shielded CCD at the time of this reward overview. +/// +/// +/// The amount of CCD in the Baking Reward Account. +/// +/// +/// The amount of CCD in the Finalization Reward Account. +/// +/// +/// The amount of CCD in the GAS Account. +/// /// /// The transaction reward fraction accruing to the foundation (to be /// paid at next payday). diff --git a/src/Types/UpdatePayload.cs b/src/Types/UpdatePayload.cs index 1cfcd7f6..623ef3d3 100644 --- a/src/Types/UpdatePayload.cs +++ b/src/Types/UpdatePayload.cs @@ -16,28 +16,51 @@ public interface IUpdatePayload /// public enum UpdateType { + /// Update of protocol version. ProtocolUpdate, + /// Update of the election difficulty. ElectionDifficultyUpdate, + /// Update of conversion rate of Euro per energy. EuroPerEnergyUpdate, + /// Update of conversion rate of CCD per Euro. MicroCcdPerEuroUpdate, + /// Update of account marked as foundation account. FoundationAccountUpdate, + /// Update of distribution of minted CCD. MintDistributionUpdate, + /// Update of distribution of transaction fee. TransactionFeeDistributionUpdate, + /// Update of distribution of GAS rewards. GasRewardsUpdate, + /// Update of minimum threshold for becoming a validator. BakerStakeThresholdUpdate, + /// Introduce new Identity Disclosure Authority. AddAnonymityRevokerUpdate, + /// Introduce new Identity Provider. AddIdentityProviderUpdate, + /// Update of root keys. RootUpdate, + /// Update of level1 keys. Level1Update, + /// Update of level2 keys. Level2Update, + /// Update of pool parameters. PoolParametersCpv1Update, + /// Update of cooldown parameters. CooldownParametersCpv1Update, + /// Update of time parameters. TimeParametersCpv1Update, + /// Update of distribution of minted CCD. MintDistributionCpv1Update, + /// Update of distribution of GAS rewards. GasRewardsCpv2Update, + /// Update of timeout parameters. TimeoutParametersUpdate, + /// Update of min-block-time parameters. MinBlockTimeUpdate, + /// Update of block energy limit parameters. BlockEnergyLimitUpdate, + /// Update of finalization committee parameters. FinalizationCommitteeParametersUpdate, } diff --git a/src/Types/VersionedModuleSource.cs b/src/Types/VersionedModuleSource.cs index e4d980cf..2af501ef 100644 --- a/src/Types/VersionedModuleSource.cs +++ b/src/Types/VersionedModuleSource.cs @@ -140,18 +140,18 @@ public static VersionedModuleSource FromFile(string modulePath) var bytes = File.ReadAllBytes(modulePath); if (TryDeserial(bytes, out var versionedModule)) { - return versionedModule.VersionedModuleSource; + return versionedModule.VersionedModuleSource!; } else { - throw new DeserialException(versionedModule.Error); + throw new DeserialException(versionedModule.Error!); } } /// - /// Create a versioned module schema from a byte array. + /// Create a from a byte array. /// - /// The serialized schema. + /// Span of bytes with the serialized smart contract module /// Where to write the result of the operation. public static bool TryDeserial(ReadOnlySpan bytes, out (VersionedModuleSource? VersionedModuleSource, string? Error) output) { diff --git a/src/Wallets/WalletAccount.cs b/src/Wallets/WalletAccount.cs index f0633f73..3b2b2b6f 100644 --- a/src/Wallets/WalletAccount.cs +++ b/src/Wallets/WalletAccount.cs @@ -114,12 +114,15 @@ private static WalletAccount FromBrowserWalletKeyExportFormat(string json) return From(genesisWallet); } + /// Get credential-key-map of the account. public ImmutableDictionary< AccountCredentialIndex, ImmutableDictionary > GetSignerEntries() => this._signer.GetSignerEntries(); + /// Get the number of signatures included in the AccountSignature when signing using this account. public byte GetSignatureCount() => this._signer.GetSignatureCount(); + /// Produce an AccountTransactionSignature using this account. public AccountTransactionSignature Sign(byte[] data) => this._signer.Sign(data); } diff --git a/src/Wallets/WalletDataSourceException.cs b/src/Wallets/WalletDataSourceException.cs index 87162fc2..1d0b0534 100644 --- a/src/Wallets/WalletDataSourceException.cs +++ b/src/Wallets/WalletDataSourceException.cs @@ -10,11 +10,14 @@ namespace Concordium.Sdk.Wallets; /// public class WalletDataSourceException : Exception { + /// Initialize instance with no message. public WalletDataSourceException() { } + /// Initialize instance with a message. public WalletDataSourceException(string message) : base(message) { } + /// Initialize instance with a message and a reference to an inner exception. public WalletDataSourceException(string message, Exception inner) : base(message, inner) { } }