From b6832313ddceb40a36a87029ba01b3af427820d1 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Tue, 11 Jul 2023 12:32:41 +0900 Subject: [PATCH 1/6] Bump lib9c:release/0.2.1 --- Lib9c | 2 +- .../Commands/ActionCommandTest.cs | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Lib9c b/Lib9c index 79d36a1f6..20b4a83b8 160000 --- a/Lib9c +++ b/Lib9c @@ -1 +1 @@ -Subproject commit 79d36a1f6c62dac3398e6c237fda7ef47aa13644 +Subproject commit 20b4a83b84d556f5b914fbf05d68d4e73c0b6369 diff --git a/NineChronicles.Headless.Executable.Tests/Commands/ActionCommandTest.cs b/NineChronicles.Headless.Executable.Tests/Commands/ActionCommandTest.cs index 9a8a71915..1940b1d4a 100644 --- a/NineChronicles.Headless.Executable.Tests/Commands/ActionCommandTest.cs +++ b/NineChronicles.Headless.Executable.Tests/Commands/ActionCommandTest.cs @@ -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) { @@ -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, From 6def42c0b7bbb2028733b7901b9cf826d9778d9c Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Tue, 11 Jul 2023 12:33:38 +0900 Subject: [PATCH 2/6] fix: use lib9c method in `StakeStateContext` --- .../GraphTypes/States/StakeStateType.cs | 23 ++----------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/NineChronicles.Headless/GraphTypes/States/StakeStateType.cs b/NineChronicles.Headless/GraphTypes/States/StakeStateType.cs index 8ec543489..11748c814 100644 --- a/NineChronicles.Headless/GraphTypes/States/StakeStateType.cs +++ b/NineChronicles.Headless/GraphTypes/States/StakeStateType.cs @@ -56,27 +56,8 @@ public StakeStateType() Field>( "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>( nameof(StakeState.Achievements), description: "The staking achievements.", From 0b5ab6260267bcfe3896fb1411c63507f1ead5cc Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Tue, 11 Jul 2023 14:02:45 +0900 Subject: [PATCH 3/6] feat: add case for "ClaimStakeReward4" in tx sign command --- .../Commands/TxCommandTest.cs | 1 + NineChronicles.Headless.Executable/Commands/TxCommand.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/NineChronicles.Headless.Executable.Tests/Commands/TxCommandTest.cs b/NineChronicles.Headless.Executable.Tests/Commands/TxCommandTest.cs index 876eba904..8c8fe890e 100644 --- a/NineChronicles.Headless.Executable.Tests/Commands/TxCommandTest.cs +++ b/NineChronicles.Headless.Executable.Tests/Commands/TxCommandTest.cs @@ -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()); diff --git a/NineChronicles.Headless.Executable/Commands/TxCommand.cs b/NineChronicles.Headless.Executable/Commands/TxCommand.cs index 0688df95c..79ce7bda3 100644 --- a/NineChronicles.Headless.Executable/Commands/TxCommand.cs +++ b/NineChronicles.Headless.Executable/Commands/TxCommand.cs @@ -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(), From 89f844d6c3cb6eae2cb58fdb2f490e74134f001d Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Tue, 11 Jul 2023 14:30:37 +0900 Subject: [PATCH 4/6] bump: lib9c:release/0.2.1 --- Lib9c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib9c b/Lib9c index 20b4a83b8..a19017dcc 160000 --- a/Lib9c +++ b/Lib9c @@ -1 +1 @@ -Subproject commit 20b4a83b84d556f5b914fbf05d68d4e73c0b6369 +Subproject commit a19017dccf21566c28084b8d5a41ea9c6520dade From 51415ad390764427fd1ab2b1fad1d7fd794aaa8f Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Tue, 11 Jul 2023 14:30:37 +0900 Subject: [PATCH 5/6] bump: lib9c:release/0.2.1 --- Lib9c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib9c b/Lib9c index a19017dcc..5b785a452 160000 --- a/Lib9c +++ b/Lib9c @@ -1 +1 @@ -Subproject commit a19017dccf21566c28084b8d5a41ea9c6520dade +Subproject commit 5b785a4526a0c2cebc4634a486991a323b0868fb From ced0918d91d88be014f3e771b397fd61f7493d66 Mon Sep 17 00:00:00 2001 From: Hyun Seungmin Date: Tue, 11 Jul 2023 16:43:51 +0900 Subject: [PATCH 6/6] bump: lib9c:main --- Lib9c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib9c b/Lib9c index 5b785a452..627e12ba3 160000 --- a/Lib9c +++ b/Lib9c @@ -1 +1 @@ -Subproject commit 5b785a4526a0c2cebc4634a486991a323b0868fb +Subproject commit 627e12ba3dd6ec8463398b6e83f609712bd692b2