From 9041ecc1ac5462d98e56378871d751e2b60bb180 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Thu, 10 Aug 2023 17:21:47 +0900 Subject: [PATCH] feat(action-factory): apply "claim_stake_reward6" to ClaimStakeRewardFactory --- .Lib9c.Tests/Action/Factory/ClaimStakeRewardFactoryTest.cs | 4 +++- Lib9c/Action/Factory/ClaimStakeRewardFactory.cs | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.Lib9c.Tests/Action/Factory/ClaimStakeRewardFactoryTest.cs b/.Lib9c.Tests/Action/Factory/ClaimStakeRewardFactoryTest.cs index cdadf39299..326d99c636 100644 --- a/.Lib9c.Tests/Action/Factory/ClaimStakeRewardFactoryTest.cs +++ b/.Lib9c.Tests/Action/Factory/ClaimStakeRewardFactoryTest.cs @@ -47,7 +47,9 @@ public static IEnumerable GetAllClaimStakeRewardV1() [InlineData(ClaimStakeReward3.ObsoleteBlockIndex + 1, typeof(ClaimStakeReward4))] [InlineData(ClaimStakeReward4.ObsoleteBlockIndex, typeof(ClaimStakeReward4))] [InlineData(ClaimStakeReward4.ObsoleteBlockIndex + 1, typeof(ClaimStakeReward5))] - [InlineData(long.MaxValue, typeof(ClaimStakeReward5))] + [InlineData(ClaimStakeReward5.ObsoleteBlockIndex, typeof(ClaimStakeReward5))] + [InlineData(ClaimStakeReward5.ObsoleteBlockIndex + 1, typeof(ClaimStakeReward))] + [InlineData(long.MaxValue, typeof(ClaimStakeReward))] public void Create_ByBlockIndex_Success( long blockIndex, Type type) diff --git a/Lib9c/Action/Factory/ClaimStakeRewardFactory.cs b/Lib9c/Action/Factory/ClaimStakeRewardFactory.cs index fa14d7ca92..ccd06aaffd 100644 --- a/Lib9c/Action/Factory/ClaimStakeRewardFactory.cs +++ b/Lib9c/Action/Factory/ClaimStakeRewardFactory.cs @@ -11,6 +11,11 @@ public static IClaimStakeReward CreateByBlockIndex( long blockIndex, Address avatarAddress) { + if (blockIndex > ClaimStakeReward5.ObsoleteBlockIndex) + { + return new ClaimStakeReward(avatarAddress); + } + if (blockIndex > ClaimStakeReward4.ObsoleteBlockIndex) { return new ClaimStakeReward5(avatarAddress); @@ -42,6 +47,7 @@ public static IClaimStakeReward CreateByVersion( 3 => new ClaimStakeReward3(avatarAddress), 4 => new ClaimStakeReward4(avatarAddress), 5 => new ClaimStakeReward5(avatarAddress), + 6 => new ClaimStakeReward(avatarAddress), _ => throw new ArgumentOutOfRangeException( $"Invalid version: {version}"), };