From c558e70f77608ce6f4428b4ac28500d6635857bd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B8ren=20Schwartz?=
<132270889+schwartz-concordium@users.noreply.github.com>
Date: Wed, 20 Sep 2023 15:32:45 +0200
Subject: [PATCH] Moved Contract Call Event Before Contract Update (#105)
* Moved contract call before update event
* Fix test
* Updated versions
---
.../Aggregates/Contract/ContractAggregate.cs | 28 +++++++++----------
backend/Application/Application.csproj | 3 +-
.../Contract/ContractAggregateTests.cs | 9 +++---
frontend/package.json | 2 +-
4 files changed, 20 insertions(+), 22 deletions(-)
diff --git a/backend/Application/Aggregates/Contract/ContractAggregate.cs b/backend/Application/Aggregates/Contract/ContractAggregate.cs
index 24c01b3ba..0bb901cbb 100644
--- a/backend/Application/Aggregates/Contract/ContractAggregate.cs
+++ b/backend/Application/Aggregates/Contract/ContractAggregate.cs
@@ -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,
@@ -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
diff --git a/backend/Application/Application.csproj b/backend/Application/Application.csproj
index 8aeffd220..3e1b185bd 100644
--- a/backend/Application/Application.csproj
+++ b/backend/Application/Application.csproj
@@ -4,9 +4,8 @@
net6.0
enable
disable
- 1.7.0
+ 1.7.1
-
diff --git a/backend/Tests/Aggregates/Contract/ContractAggregateTests.cs b/backend/Tests/Aggregates/Contract/ContractAggregateTests.cs
index 2114aeb5a..f3bdeb83c 100644
--- a/backend/Tests/Aggregates/Contract/ContractAggregateTests.cs
+++ b/backend/Tests/Aggregates/Contract/ContractAggregateTests.cs
@@ -129,13 +129,12 @@ await ContractAggregate.StoreEvent(
// Assert
contractEvents.Count.Should().Be(2);
- var updateEvent = contractEvents[0];
- updateEvent.Event.Should().BeOfType();
- updateEvent.ContractAddressIndex.Should().Be(from);
-
- var transferEvent = contractEvents[1];
+ var transferEvent = contractEvents[0];
transferEvent.Event.Should().BeOfType();
transferEvent.ContractAddressIndex.Should().Be(to);
+ var updateEvent = contractEvents[1];
+ updateEvent.Event.Should().BeOfType();
+ updateEvent.ContractAddressIndex.Should().Be(from);
}
[Fact]
diff --git a/frontend/package.json b/frontend/package.json
index ed6058d6a..97c001b51 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -1,7 +1,7 @@
{
"name": "ccscan-frontend",
"description": "CCDScan frontend",
- "version": "1.5.0",
+ "version": "1.5.1",
"engine": "16",
"type": "module",
"private": true,