Skip to content

Commit

Permalink
feat(action-factory): apply "claim_stake_reward6" to ClaimStakeReward…
Browse files Browse the repository at this point in the history
…Factory
  • Loading branch information
boscohyun committed Aug 10, 2023
1 parent 5be071d commit 9041ecc
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 @@ -47,7 +47,9 @@ public static IEnumerable<object[]> 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)
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 > ClaimStakeReward5.ObsoleteBlockIndex)
{
return new ClaimStakeReward(avatarAddress);
}

if (blockIndex > ClaimStakeReward4.ObsoleteBlockIndex)
{
return new ClaimStakeReward5(avatarAddress);
Expand Down Expand Up @@ -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}"),
};
Expand Down

0 comments on commit 9041ecc

Please sign in to comment.