diff --git a/SVSim.Database/Migrations/20260609003820_AddViewerPresents.Designer.cs b/SVSim.Database/Migrations/20260609004113_AddViewerPresents.Designer.cs
similarity index 99%
rename from SVSim.Database/Migrations/20260609003820_AddViewerPresents.Designer.cs
rename to SVSim.Database/Migrations/20260609004113_AddViewerPresents.Designer.cs
index e7e81e9..4de17ed 100644
--- a/SVSim.Database/Migrations/20260609003820_AddViewerPresents.Designer.cs
+++ b/SVSim.Database/Migrations/20260609004113_AddViewerPresents.Designer.cs
@@ -12,7 +12,7 @@ using SVSim.Database;
namespace SVSim.Database.Migrations
{
[DbContext(typeof(SVSimDbContext))]
- [Migration("20260609003820_AddViewerPresents")]
+ [Migration("20260609004113_AddViewerPresents")]
partial class AddViewerPresents
{
///
@@ -2902,12 +2902,6 @@ namespace SVSim.Database.Migrations
b.Property("RewardType")
.HasColumnType("integer");
- b.Property("RowVersion")
- .IsConcurrencyToken()
- .IsRequired()
- .ValueGeneratedOnAddOrUpdate()
- .HasColumnType("bytea");
-
b.Property("Source")
.HasMaxLength(64)
.HasColumnType("character varying(64)");
diff --git a/SVSim.Database/Migrations/20260609003820_AddViewerPresents.cs b/SVSim.Database/Migrations/20260609004113_AddViewerPresents.cs
similarity index 96%
rename from SVSim.Database/Migrations/20260609003820_AddViewerPresents.cs
rename to SVSim.Database/Migrations/20260609004113_AddViewerPresents.cs
index cf0cdce..0a2722a 100644
--- a/SVSim.Database/Migrations/20260609003820_AddViewerPresents.cs
+++ b/SVSim.Database/Migrations/20260609004113_AddViewerPresents.cs
@@ -34,8 +34,7 @@ namespace SVSim.Database.Migrations
Message = table.Column(type: "text", nullable: false),
CreatedAt = table.Column(type: "timestamp with time zone", nullable: false),
ClaimedAt = table.Column(type: "timestamp with time zone", nullable: true),
- Source = table.Column(type: "character varying(64)", maxLength: 64, nullable: true),
- RowVersion = table.Column(type: "bytea", rowVersion: true, nullable: false)
+ Source = table.Column(type: "character varying(64)", maxLength: 64, nullable: true)
},
constraints: table =>
{
diff --git a/SVSim.Database/Migrations/SVSimDbContextModelSnapshot.cs b/SVSim.Database/Migrations/SVSimDbContextModelSnapshot.cs
index 7d82e5d..6a93865 100644
--- a/SVSim.Database/Migrations/SVSimDbContextModelSnapshot.cs
+++ b/SVSim.Database/Migrations/SVSimDbContextModelSnapshot.cs
@@ -2899,12 +2899,6 @@ namespace SVSim.Database.Migrations
b.Property("RewardType")
.HasColumnType("integer");
- b.Property("RowVersion")
- .IsConcurrencyToken()
- .IsRequired()
- .ValueGeneratedOnAddOrUpdate()
- .HasColumnType("bytea");
-
b.Property("Source")
.HasMaxLength(64)
.HasColumnType("character varying(64)");
diff --git a/SVSim.Database/Models/ViewerPresent.cs b/SVSim.Database/Models/ViewerPresent.cs
index 6527577..6cbee23 100644
--- a/SVSim.Database/Models/ViewerPresent.cs
+++ b/SVSim.Database/Models/ViewerPresent.cs
@@ -1,5 +1,3 @@
-using System.ComponentModel.DataAnnotations;
-
namespace SVSim.Database.Models;
///
@@ -39,13 +37,6 @@ public class ViewerPresent
/// this today — the tutorial-step advance is route-gated, not Source-gated.
///
public string? Source { get; set; }
-
- ///
- /// EF Core optimistic concurrency for the claim path. Two concurrent claims of the
- /// same PresentId: first wins, second's CommitAsync throws DbUpdateConcurrencyException.
- ///
- [Timestamp]
- public byte[] RowVersion { get; set; } = Array.Empty();
}
public enum PresentStatus : byte
diff --git a/SVSim.EmulatedEntrypoint/Controllers/GiftController.cs b/SVSim.EmulatedEntrypoint/Controllers/GiftController.cs
index dd56b0a..449add5 100644
--- a/SVSim.EmulatedEntrypoint/Controllers/GiftController.cs
+++ b/SVSim.EmulatedEntrypoint/Controllers/GiftController.cs
@@ -84,8 +84,12 @@ public class GiftController : SVSimController
{
if (state == 1)
{
+ // Wire reward_type on the gift endpoint follows a gift-specific scheme that
+ // diverges from UserGoodsType for currencies: wire "1" means Crystal (enum=2),
+ // wire "9" means Rupy (enum=9), wire "4" means Item (enum=4). A naked cast would
+ // resolve wire 1 -> UserGoodsType.RedEther and silently grant the wrong wallet.
var granted = await tx.GrantAsync(
- (UserGoodsType)p.RewardType,
+ WireRewardTypeToUserGoodsType(p.RewardType),
p.RewardDetailId,
(int)p.RewardCount);
@@ -161,6 +165,14 @@ public class GiftController : SVSimController
};
}
+ private static UserGoodsType WireRewardTypeToUserGoodsType(int wireType) => wireType switch
+ {
+ 1 => UserGoodsType.Crystal,
+ 4 => UserGoodsType.Item,
+ 9 => UserGoodsType.Rupy,
+ _ => throw new InvalidOperationException($"Unmapped gift wire reward_type {wireType}"),
+ };
+
private async Task<(List Unclaimed, List History)> ReadTopWindowAsync(
long viewerId, int page)
{
diff --git a/SVSim.UnitTests/Controllers/GiftControllerTests.cs b/SVSim.UnitTests/Controllers/GiftControllerTests.cs
index 557bf12..d3f7fb2 100644
--- a/SVSim.UnitTests/Controllers/GiftControllerTests.cs
+++ b/SVSim.UnitTests/Controllers/GiftControllerTests.cs
@@ -16,6 +16,7 @@ public class GiftControllerTests
{
using var factory = new SVSimTestFactory();
long viewerId = await factory.SeedViewerAsync(tutorialState: 31);
+ await factory.SeedTutorialPresentsAsync(viewerId);
using var client = factory.CreateAuthenticatedClient(viewerId);
var response = await client.PostAsync("/tutorial/gift_top",
@@ -54,6 +55,7 @@ public class GiftControllerTests
using var factory = new SVSimTestFactory();
await factory.SeedGlobalsAsync();
long viewerId = await factory.SeedViewerAsync(tutorialState: 31);
+ await factory.SeedTutorialPresentsAsync(viewerId);
using var client = factory.CreateAuthenticatedClient(viewerId);
var pre = await factory.GetViewerCurrencyAsync(viewerId);
@@ -100,6 +102,7 @@ public class GiftControllerTests
using var factory = new SVSimTestFactory();
await factory.SeedGlobalsAsync();
long viewerId = await factory.SeedViewerAsync(tutorialState: 31);
+ await factory.SeedTutorialPresentsAsync(viewerId);
using var client = factory.CreateAuthenticatedClient(viewerId);
var json = $$"""{"present_id_array":["71478626"],"state":1,{{BaseAuthBlock}}}""";
@@ -129,6 +132,7 @@ public class GiftControllerTests
using var factory = new SVSimTestFactory();
await factory.SeedGlobalsAsync();
long viewerId = await factory.SeedViewerAsync(tutorialState: 31);
+ await factory.SeedTutorialPresentsAsync(viewerId);
using var client = factory.CreateAuthenticatedClient(viewerId);
var json = $$"""{"present_id_array":["71478626","71478627"],"state":1,{{BaseAuthBlock}}}""";
@@ -167,6 +171,7 @@ public class GiftControllerTests
// 100, not the hardcoded 41 the endpoint used to emit, or the client's tutorial
// state machine regresses on a no-op retry.
long viewerId = await factory.SeedViewerAsync(tutorialState: 100);
+ await factory.SeedTutorialPresentsAsync(viewerId);
using var client = factory.CreateAuthenticatedClient(viewerId);
var json = $$"""{"present_id_array":["71478626"],"state":1,{{BaseAuthBlock}}}""";
@@ -192,6 +197,7 @@ public class GiftControllerTests
// found and incremented, not duplicated. The (ViewerId, ItemId) unique index
// added 2026-05-25 would otherwise throw on SaveChanges → 500 to the client.
await factory.SeedOwnedItemAsync(viewerId, itemId: 1, count: 5, itemName: "PreOwnedItem");
+ await factory.SeedTutorialPresentsAsync(viewerId);
using var client = factory.CreateAuthenticatedClient(viewerId);
@@ -224,6 +230,7 @@ public class GiftControllerTests
using var factory = new SVSimTestFactory();
await factory.SeedGlobalsAsync();
long viewerId = await factory.SeedViewerAsync(tutorialState: 31);
+ await factory.SeedTutorialPresentsAsync(viewerId);
using var client = factory.CreateAuthenticatedClient(viewerId);
var preFirst = await factory.GetViewerCurrencyAsync(viewerId);