Skip to content

Commit

Permalink
update ClaimStakeRewardFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
boscohyun committed Aug 22, 2023
1 parent 838f0f8 commit 06d47b8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .Lib9c.Tests/Action/Factory/ClaimStakeRewardFactoryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ public static IEnumerable<object[]> GetAllClaimStakeRewardV1()
[InlineData(ClaimStakeReward4.ObsoleteBlockIndex + 1, typeof(ClaimStakeReward5))]
[InlineData(ClaimStakeReward5.ObsoleteBlockIndex, typeof(ClaimStakeReward5))]
[InlineData(ClaimStakeReward5.ObsoleteBlockIndex + 1, typeof(ClaimStakeReward6))]
[InlineData(long.MaxValue, typeof(ClaimStakeReward6))]
[InlineData(ClaimStakeReward6.ObsoleteBlockIndex, typeof(ClaimStakeReward6))]
[InlineData(ClaimStakeReward6.ObsoleteBlockIndex + 1, typeof(ClaimStakeReward))]
[InlineData(long.MaxValue, typeof(ClaimStakeReward))]
public void Create_ByBlockIndex_Success(
long blockIndex,
Type type)
Expand Down
6 changes: 6 additions & 0 deletions Lib9c/Action/Factory/ClaimStakeRewardFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ public static IClaimStakeReward CreateByBlockIndex(
long blockIndex,
Address avatarAddress)
{
if (blockIndex > ClaimStakeReward6.ObsoleteBlockIndex)
{
return new ClaimStakeReward(avatarAddress);
}

if (blockIndex > ClaimStakeReward5.ObsoleteBlockIndex)
{
return new ClaimStakeReward6(avatarAddress);
Expand Down Expand Up @@ -48,6 +53,7 @@ public static IClaimStakeReward CreateByVersion(
4 => new ClaimStakeReward4(avatarAddress),
5 => new ClaimStakeReward5(avatarAddress),
6 => new ClaimStakeReward6(avatarAddress),
7 => new ClaimStakeReward(avatarAddress),
_ => throw new ArgumentOutOfRangeException(
$"Invalid version: {version}"),
};
Expand Down

0 comments on commit 06d47b8

Please sign in to comment.