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

Update .NET SDK and make .NET backend compatible with P8 #392

Merged
merged 2 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions backend/Application/Api/GraphQL/ChainParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ internal static ChainParameters From(IChainParameters chainParameters)
Concordium.Sdk.Types.ChainParametersV0 chainParametersV0 => ChainParametersV0.From(chainParametersV0),
Concordium.Sdk.Types.ChainParametersV1 chainParametersV1 => ChainParametersV1.From(chainParametersV1),
Concordium.Sdk.Types.ChainParametersV2 chainParametersV2 => ChainParametersV2.From(chainParametersV2),
Concordium.Sdk.Types.ChainParametersV3 chainParametersV3 => ChainParametersV3.From(chainParametersV3),
_ => throw new NotImplementedException()
};
}
Expand Down
51 changes: 51 additions & 0 deletions backend/Application/Api/GraphQL/ChainParametersV3.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using Application.Api.GraphQL.Accounts;
using Application.Api.GraphQL.Extensions;

namespace Application.Api.GraphQL;

public class ChainParametersV3 : ChainParameters, IEquatable<ChainParametersV3>
{
public ulong RewardPeriodLength { get; init; }

internal static ChainParametersV3 From(Concordium.Sdk.Types.ChainParametersV3 input)
{
return new ChainParametersV3
{
EuroPerEnergy = ExchangeRate.From(input.EuroPerEnergy),
MicroCcdPerEuro = ExchangeRate.From(input.MicroCcdPerEuro),
AccountCreationLimit = (int)input.AccountCreationLimit.Limit,
FoundationAccountAddress = AccountAddress.From(input.FoundationAccount),
RewardPeriodLength = input.TimeParameters.RewardPeriodLength.RewardPeriodEpochs.Count,
};

}

public bool Equals(ChainParametersV3? other)
{
return other != null &&
base.Equals(other) &&
RewardPeriodLength == other.RewardPeriodLength;
}

public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
return obj.GetType() == GetType() && Equals(obj as ChainParametersV2);
limemloh marked this conversation as resolved.
Show resolved Hide resolved
}

public override int GetHashCode()
{
return Id;
}

public static bool operator ==(ChainParametersV3? left, ChainParametersV3? right)
{
return Equals(left, right);
}

public static bool operator !=(ChainParametersV3? left, ChainParametersV3? right)
{
return !Equals(left, right);
}
}
6 changes: 6 additions & 0 deletions backend/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## Unreleased changes

## 1.10.0

- Added
- Minimal support for Concordium Protocol Version 8.
- Introduce `ChainParametersV3` in the GraphQL API.

## 1.9.2

- Bugfix
Expand Down
4 changes: 3 additions & 1 deletion backend/Tests/Aggregates/Contract/ContractAggregateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,9 @@ public async Task GivenContractInitialization_WhenNodeImport_ThenStoreContractEv
new ContractAddress(contractIndex, 0),
CcdAmount.Zero,
contractNameParse.ContractName!,
new List<Concordium.Sdk.Types.ContractEvent>())
new List<Concordium.Sdk.Types.ContractEvent>(),
null
)
);
var client = new Mock<IContractNodeClient>();
var transactionDetails = new AccountTransactionDetailsBuilder(contractInitialized)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ public async Task WhenGetOrderedContractEvents_ThenGetOrderedContractEvents()
contractAddress,
CcdAmount.Zero,
contractNameOutput.ContractName!,
new List<ContractEvent>()
new List<ContractEvent>(),
null
));
var contractInitializedEvent = ContractEventBuilder.Create()
.WithContractAddress(address)
Expand Down
6 changes: 4 additions & 2 deletions backend/Tests/Api/GraphQL/Import/BakerImportHandlerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ public async Task WhenUpdateCurrentPaydayStatusOnAllBakers_ThenBakersUpdates()
),
afterStatus,
CcdAmount.Zero,
null
null,
false
);
var bakerPoolStatuses = () => Task.FromResult(new[] { bakerPoolStatus });

Expand Down Expand Up @@ -225,7 +226,8 @@ public async Task TestFirstBlockAfterPaydayBakerAddition()
""),
null,
CcdAmount.Zero,
null
null,
false
)
});

Expand Down
3 changes: 2 additions & 1 deletion backend/Tests/Api/GraphQL/Import/BakerWriterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ public async Task UpdateBakersFromAccountBaker()
PendingChange: new AccountBakerRemovePending(_anyDateTimeOffset),
RestakeEarnings: false,
StakedAmount: CcdAmount.Zero,
BakerPoolInfo: null
BakerPoolInfo: null,
IsSuspended: false
)
};

Expand Down
5 changes: 4 additions & 1 deletion backend/Tests/Api/GraphQL/Import/TransactionsWriterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,10 @@ public async Task TransactionEvents_ContractInitialized()
{
new(Convert.FromHexString(firstEvent)),
new(Convert.FromHexString(secondEvent))
}));
},
null
)
);

var accountTransactionDetails = new AccountTransactionDetailsBuilder(contractInitialized)
.Build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,14 @@ type ChainParametersV2 implements ChainParameters {
foundationAccountAddress: AccountAddress!
}

type ChainParametersV3 implements ChainParameters {
rewardPeriodLength: UnsignedLong!
euroPerEnergy: ExchangeRate!
microCcdPerEuro: ExchangeRate!
accountCreationLimit: Int!
foundationAccountAddress: AccountAddress!
}

type ChainUpdateEnqueued {
effectiveTime: DateTime!
effectiveImmediately: Boolean!
Expand Down Expand Up @@ -2127,7 +2135,7 @@ enum AccountTransactionType {
SIMPLE_TRANSFER
"Transfer encrypted amount."
ENCRYPTED_TRANSFER
"Same as transfer, but with a memo field."
"Same as transfer but with a memo field."
SIMPLE_TRANSFER_WITH_MEMO
"Same as encrypted transfer, but with a memo."
ENCRYPTED_TRANSFER_WITH_MEMO
Expand Down Expand Up @@ -2196,9 +2204,9 @@ enum ContractVersion {

"Enumeration of the types of credentials."
enum CredentialDeploymentTransactionType {
"Initial credential is a credential that is submitted by the identity\nprovider on behalf of the user. There is at most one initial credential\nper identity."
"Initial credential is a credential that is submitted by the identity\nprovider on behalf of the user. There is only one initial credential\nper identity."
INITIAL
"A normal credential is one where the identity behind it is only known to\nthe owner of the account, unless the identity disclosure process was\nhas been initiated."
"A normal credential is one where the identity behind it is only known to\nthe owner of the account, unless the anonymity revocation process was\nfollowed."
NORMAL
}

Expand Down Expand Up @@ -2307,6 +2315,8 @@ enum UpdateTransactionType {
BLOCK_ENERGY_LIMIT_UPDATE
"Update of finalization committee parameters."
FINALIZATION_COMMITTEE_PARAMETERS_UPDATE
"Update of validator score parameters."
VALIDATOR_SCORE_PARAMETERS_UPDATE
}

"The `@specifiedBy` directive is used within the type system definition language to provide a URL for specifying the behavior of custom scalar definitions."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ decimal blockCommission
AmountFraction.From(blockCommission)),
BakerPoolOpenStatus.OpenForAll, ""),
null,
CcdAmount.Zero, null
CcdAmount.Zero, null,
false
);
}

Expand Down
Loading