Skip to content

Commit

Permalink
Moved Contract Call Event Before Contract Update (#105)
Browse files Browse the repository at this point in the history
* Moved contract call before update event

* Fix test

* Updated versions
  • Loading branch information
Søren Schwartz authored Sep 20, 2023
1 parent 018ccaa commit c558e70
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 22 deletions.
28 changes: 14 additions & 14 deletions backend/Application/Aggregates/Contract/ContractAggregate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,22 +278,8 @@ await repository
));
break;
case ContractUpdated contractUpdated:
await repository
.AddAsync(new ContractEvent(
blockHeight,
transactionHash,
transactionIndex,
eventIndex,
contractUpdated.ContractAddress,
sender,
contractUpdated,
source,
blockSlotTime
));
if (contractUpdated.Instigator is ContractAddress contractInstigator)
{
// Possible a contract has called itself.
eventIndex += 1;
await repository
.AddAsync(new ContractEvent(
blockHeight,
Expand All @@ -308,7 +294,21 @@ await repository
source,
blockSlotTime
));
// Possible a contract has called itself.
eventIndex += 1;
}
await repository
.AddAsync(new ContractEvent(
blockHeight,
transactionHash,
transactionIndex,
eventIndex,
contractUpdated.ContractAddress,
sender,
contractUpdated,
source,
blockSlotTime
));
break;
case ContractUpgraded contractUpgraded:
await repository
Expand Down
3 changes: 1 addition & 2 deletions backend/Application/Application.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
<TargetFramework>net6.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>disable</ImplicitUsings>
<Version>1.7.0</Version>
<Version>1.7.1</Version>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="ConcordiumNetSdk" Version="4.0.1" />
<PackageReference Include="Dapper" Version="2.0.123" />
Expand Down
9 changes: 4 additions & 5 deletions backend/Tests/Aggregates/Contract/ContractAggregateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,12 @@ await ContractAggregate.StoreEvent(

// Assert
contractEvents.Count.Should().Be(2);
var updateEvent = contractEvents[0];
updateEvent.Event.Should().BeOfType<ContractUpdated>();
updateEvent.ContractAddressIndex.Should().Be(from);

var transferEvent = contractEvents[1];
var transferEvent = contractEvents[0];
transferEvent.Event.Should().BeOfType<ContractCall>();
transferEvent.ContractAddressIndex.Should().Be(to);
var updateEvent = contractEvents[1];
updateEvent.Event.Should().BeOfType<ContractUpdated>();
updateEvent.ContractAddressIndex.Should().Be(from);
}

[Fact]
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ccscan-frontend",
"description": "CCDScan frontend",
"version": "1.5.0",
"version": "1.5.1",
"engine": "16",
"type": "module",
"private": true,
Expand Down

0 comments on commit c558e70

Please sign in to comment.