Skip to content

Commit

Permalink
Merge pull request #2126 from planetarium/release/4
Browse files Browse the repository at this point in the history
release: version 4
  • Loading branch information
boscohyun authored Jul 11, 2023
2 parents 14ca945 + ced0918 commit 4fe61b8
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@ public void ClaimStakeReward(string addressString, int expectedCode)
[InlineData(ClaimStakeReward2.ObsoletedIndex, typeof(ClaimStakeReward2))]
[InlineData(ClaimStakeReward2.ObsoletedIndex + 1, typeof(ClaimStakeReward3))]
[InlineData(ClaimStakeReward3.ObsoleteBlockIndex, typeof(ClaimStakeReward3))]
[InlineData(ClaimStakeReward3.ObsoleteBlockIndex + 1, typeof(ClaimStakeReward))]
[InlineData(ClaimStakeReward3.ObsoleteBlockIndex + 1, typeof(ClaimStakeReward4))]
[InlineData(ClaimStakeReward4.ObsoleteBlockIndex, typeof(ClaimStakeReward4))]
[InlineData(ClaimStakeReward4.ObsoleteBlockIndex + 1, typeof(ClaimStakeReward))]
[InlineData(long.MaxValue, typeof(ClaimStakeReward))]
public void ClaimStakeRewardWithBlockIndex(long blockIndex, Type expectedActionType)
{
Expand All @@ -217,8 +219,8 @@ public void ClaimStakeRewardWithBlockIndex(long blockIndex, Type expectedActionT

[Theory]
[InlineData(0, 0, -1)]
[InlineData(1, 4, 0)]
[InlineData(5, 5, -1)]
[InlineData(1, 5, 0)]
[InlineData(6, 6, -1)]
public void ClaimStakeRewardWithActionVersion(
int actionVersionMin,
int actionVersionMax,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public void Sign_Stake(bool gas)
[InlineData(null, 2, true)]
[InlineData(null, 3, false)]
[InlineData(null, 4, true)]
[InlineData(null, 5, false)]
public void Sign_ClaimStakeReward(long? blockIndex, int? actionVersion, bool gas)
{
var filePath = Path.Combine(Path.GetTempPath(), Path.GetTempFileName());
Expand Down
1 change: 1 addition & 0 deletions NineChronicles.Headless.Executable/Commands/TxCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public void Sign(
nameof(ClaimStakeReward1) => new ClaimStakeReward1(),
nameof(ClaimStakeReward2) => new ClaimStakeReward2(),
nameof(ClaimStakeReward3) => new ClaimStakeReward3(),
nameof(ClaimStakeReward4) => new ClaimStakeReward4(),
nameof(ClaimStakeReward) => new ClaimStakeReward(),
nameof(TransferAsset) => new TransferAsset(),
nameof(MigrateMonsterCollection) => new MigrateMonsterCollection(),
Expand Down
23 changes: 2 additions & 21 deletions NineChronicles.Headless/GraphTypes/States/StakeStateType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,8 @@ public StakeStateType()
Field<NonNullGraphType<LongGraphType>>(
"claimableBlockIndex",
description: "The block index the user can claim rewards.",
resolve: context =>
{
var stakeState = context.Source.StakeState;
if (context.Source.BlockIndex >= ActionObsoleteConfig.V100290ObsoleteIndex)
{
if (stakeState.ReceivedBlockIndex > 0)
{
long lastStep = Math.DivRem(
stakeState.ReceivedBlockIndex - stakeState.StartedBlockIndex,
StakeState.RewardInterval,
out _
);

return stakeState.StartedBlockIndex + (lastStep + 1) * StakeState.RewardInterval;
}

return stakeState.StartedBlockIndex + StakeState.RewardInterval;
}

return Math.Max(stakeState.StartedBlockIndex, stakeState.ReceivedBlockIndex) + StakeState.RewardInterval;
});
resolve: context => context.Source.StakeState.GetClaimableBlockIndex(
context.Source.BlockIndex));
Field<NonNullGraphType<StakeAchievementsType>>(
nameof(StakeState.Achievements),
description: "The staking achievements.",
Expand Down

0 comments on commit 4fe61b8

Please sign in to comment.