Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
limemloh committed Sep 11, 2024
1 parent 09f9290 commit d60ea69
Show file tree
Hide file tree
Showing 37 changed files with 251 additions and 43 deletions.
2 changes: 1 addition & 1 deletion concordium-base
Submodule concordium-base updated 140 files
4 changes: 2 additions & 2 deletions examples/DeployModule/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ 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);

// Sign the transaction using the account keys.
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}");
Expand Down
4 changes: 2 additions & 2 deletions examples/InitContract/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ 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);

// Sign the transaction using the account keys.
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}");
Expand Down
90 changes: 77 additions & 13 deletions rust-bindings/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/Client/ConcordiumClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -812,5 +812,8 @@ public Task<QueryResponse<IAsyncEnumerable<BlockItem>>> GetBlockItems(IBlockHash
return QueryResponse<IAsyncEnumerable<BlockItem>>.From(response, BlockItem.From, token);
}

/// <summary>
/// Dispose the client
/// </summary>
public void Dispose() => this.Raw.Dispose();
}
3 changes: 3 additions & 0 deletions src/Client/RawClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -714,5 +714,8 @@ private static GrpcChannelOptions SetSchemeIfNotSet(GrpcChannelOptions? channelO
return channelOptions;
}

/// <summary>
/// Dispose the RawClient.
/// </summary>
public void Dispose() => this._grpcChannel.Dispose();
}
2 changes: 2 additions & 0 deletions src/Crypto/Ed25519SignKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public byte[] Sign(byte[] bytes)
return algorithm.Sign(key, bytes);
}

/// <summary> Determines whether one Ed25519SignKey is equal to a second Ed25519SignKey. </summary>
public bool Equals(Ed25519SignKey? other)
{
if (other is null)
Expand All @@ -98,5 +99,6 @@ public bool Equals(Ed25519SignKey? other)
return this._value.SequenceEqual(other._value);
}

/// <summary> Get hash code for the Ed25519SignKey. </summary>
public override int GetHashCode() => Helpers.HashCode.GetHashCodeByteArray(this._value);
}
1 change: 1 addition & 0 deletions src/Crypto/ISigner.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace Concordium.Sdk.Crypto;

/// <summary> Implementers of this interface hold keys for signing data. </summary>
public interface ISigner
{
/// <summary>
Expand Down
4 changes: 4 additions & 0 deletions src/Helpers/HashCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ namespace Concordium.Sdk.Helpers;
/// </summary>
public static class HashCode
{

/// <summary>
/// Helper for getting a hash code for a byte array.
/// </summary>
public static int GetHashCodeByteArray(byte[] array)
{
unchecked
Expand Down
2 changes: 1 addition & 1 deletion src/Transactions/ITransactionSigner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public interface ITransactionSigner
/// <summary>
/// Sign a transaction hash.
/// </summary>
/// <param name="bytes">A byte array representing the transaction hash to sign.</param>
/// <param name="data">A byte array representing the transaction hash to sign.</param>
/// <returns>A <see cref="AccountTransactionSignature"/> representing the transaction signature.</returns>
/// <exception cref="ArgumentException">Unexpected length of a signature returned by the signing.</exception>
public AccountTransactionSignature Sign(byte[] data);
Expand Down
3 changes: 3 additions & 0 deletions src/Transactions/RawPayload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@ public sealed record RawPayload(byte[] Bytes) : AccountTransactionPayload
/// </summary>
internal override PayloadSize Size() => new((uint)this.Bytes.Length);

/// <summary>
/// Get the array of bytes representing this payload.
/// </summary>
public override byte[] ToBytes() => this.Bytes;
}
2 changes: 2 additions & 0 deletions src/Transactions/TransactionSigner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ public sealed class TransactionSigner : ITransactionSigner
public TransactionSigner() =>
this._signers = new Dictionary<AccountCredentialIndex, Dictionary<AccountKeyIndex, ISigner>>();

/// <summary> Get the number of signatures this signer can produce.</summary>
public byte GetSignatureCount()
=> (byte)this._signers.Values.SelectMany(x => x.Values).Count();

/// <summary> Get credential-key-map of the signer.</summary>
public ImmutableDictionary<AccountCredentialIndex, ImmutableDictionary<AccountKeyIndex, ISigner>>
GetSignerEntries() => this._signers
.Select(
Expand Down
3 changes: 3 additions & 0 deletions src/Types/AccountAddress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,10 @@ public static bool TryDeserial(ReadOnlySpan<byte> bytes, out (AccountAddress? Ac
return true;
}

/// <summary> Determines whether one AccountAddress is equal to a second AccountAddress. </summary>
/// <remarks> This does not consider two distinct aliases to the same account as equal. </remarks>
public bool Equals(AccountAddress? other) => other is not null && this._value.SequenceEqual(other._value);

/// <summary> Get hash code for the AccountAddress. </summary>
public override int GetHashCode() => Helpers.HashCode.GetHashCodeByteArray(this._value);
}
3 changes: 3 additions & 0 deletions src/Types/AccountSequenceNumber.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ namespace Concordium.Sdk.Types;
/// </summary>
public readonly record struct AccountSequenceNumber
{
/// <summary>
/// The number of bytes used to represent this type when serialized.
/// </summary>
public const uint BytesLength = sizeof(ulong);

/// <summary>
Expand Down
3 changes: 3 additions & 0 deletions src/Types/AccountStakingInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace Concordium.Sdk.Types;

/// <summary>
/// Information related to staking for a specific account.
/// </summary>
public interface IAccountStakingInfo { }

internal static class AccountStakingInfo
Expand Down
1 change: 1 addition & 0 deletions src/Types/AccountTransactionEffects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ internal IEnumerable<AccountAddress> GetAffectedAccountAddresses()
/// </summary>
/// <param name="To">Receiver account.</param>
/// <param name="Amount">The list of releases. Ordered by increasing timestamp.</param>
/// <param name="Memo">Additional data attached to the transaction.</param>
public sealed record TransferredWithSchedule
(AccountAddress To, IList<(DateTimeOffset, CcdAmount)> Amount, OnChainData? Memo) : IAccountTransactionEffects
{
Expand Down
1 change: 1 addition & 0 deletions src/Types/BakerEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ internal static IBakerEvent From(BakerEvent bakerEvent) =>
),
BakerEvent.EventOneofCase.None =>
throw new MissingEnumException<BakerEvent.EventOneofCase>(bakerEvent.EventCase),
BakerEvent.EventOneofCase.DelegationRemoved => throw new NotImplementedException(),
_ => throw new MissingEnumException<BakerEvent.EventOneofCase>(bakerEvent.EventCase)
};
}
Expand Down
3 changes: 3 additions & 0 deletions src/Types/BakerPoolOpenStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace Concordium.Sdk.Types;

/// <summary>
/// The status of the baker pool in regards to delegations.
/// </summary>
public enum BakerPoolOpenStatus
{
/// <summary>
Expand Down
12 changes: 12 additions & 0 deletions src/Types/BlockHashInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ namespace Concordium.Sdk.Types;
/// </summary>
public interface IBlockHashInput
{
/// <summary>
/// Convert this into type expected by the gRPC.
/// </summary>
BlockHashInput Into();
}

Expand All @@ -17,6 +20,9 @@ public sealed record Best : IBlockHashInput
{
private static readonly Empty _empty = new();

/// <summary>
/// Convert this into type expected by the gRPC.
/// </summary>
public BlockHashInput Into() => new()
{
Best = _empty,
Expand All @@ -31,6 +37,9 @@ public sealed record LastFinal : IBlockHashInput
{
private static readonly Empty _empty = new();

/// <summary>
/// Convert this into type expected by the gRPC.
/// </summary>
public BlockHashInput Into() => new()
{
LastFinal = _empty
Expand All @@ -42,6 +51,9 @@ public sealed record LastFinal : IBlockHashInput
/// </summary>
public sealed record Given(BlockHash BlockHash) : IBlockHashInput
{
/// <summary>
/// Convert this into type expected by the gRPC.
/// </summary>
public BlockHashInput Into() => new() { Given = this.BlockHash.ToProto() };
}

Expand Down
Loading

0 comments on commit d60ea69

Please sign in to comment.