Skip to content

Commit

Permalink
Merge pull request #1727 from moreal/rc-v100330-to-main
Browse files Browse the repository at this point in the history
Release v100330-1
  • Loading branch information
moreal authored Nov 28, 2022
2 parents f01a7ff + 96c9dd7 commit 44e3c42
Show file tree
Hide file tree
Showing 23 changed files with 812 additions and 129 deletions.
2 changes: 1 addition & 1 deletion Lib9c
Submodule Lib9c updated 87 files
+1 −0 .Lib9c.Benchmarks/Lib9c.Benchmarks.csproj
+0 −26 .Lib9c.Tests/Action/ActionEvaluationTest.cs
+450 −0 .Lib9c.Tests/Action/BattleGrandFinaleTest.cs
+16 −3 .Lib9c.Tests/Action/ClaimStakeReward3Test.cs
+291 −0 .Lib9c.Tests/Action/EventMaterialItemCraftsTest.cs
+48 −0 .Lib9c.Tests/Action/Factory/ClaimStakeRewardFactoryTest.cs
+475 −0 .Lib9c.Tests/Action/TransferAssetsTest.cs
+2 −1 .Lib9c.Tests/Lib9c.Tests.csproj
+49 −0 .Lib9c.Tests/Model/GrandFinale/GrandFinaleInformationTest.cs
+28 −0 .Lib9c.Tests/Model/Mail/MaterialCraftMailTest.cs
+8 −4 .Lib9c.Tests/Model/State/StakeStateTest.cs
+0 −1 .Lib9c.Tests/Policy/BlockPolicyTest.cs
+2 −0 .Lib9c.Tests/StagePolicyTest.cs
+43 −33 .Lib9c.Tests/TableData/ArenaSheetTest.cs
+38 −0 .Lib9c.Tests/TableData/Event/EventMaterialItemRecipeSheetTest.cs
+54 −0 .Lib9c.Tests/TableData/GrandFinale/GrandFinaleParticipantsSheetTest.cs
+53 −0 .Lib9c.Tests/TableData/GrandFinale/GrandFinaleScheduleSheetTest.cs
+2 −2 .Lib9c.Tests/TableData/StakeRegularRewardSheetTest.cs
+7 −0 .Lib9c.Tests/TableSheets.cs
+2 −0 .Lib9c.Tests/TestHelper/BlockChainHelper.cs
+1 −1 .Lib9c.Tools.Tests/Lib9c.Tools.Tests.csproj
+1 −1 .Libplanet
+1 −1 Lib9c.DevExtensions/Lib9c.DevExtensions.csproj
+4 −4 Lib9c.MessagePack/Action/NCActionEvaluation.cs
+0 −0 Lib9c.MessagePack/Formatters/AccountStateDeltaFormatter.cs
+0 −0 Lib9c.MessagePack/Formatters/AddressFormatter.cs
+0 −0 Lib9c.MessagePack/Formatters/BencodexFormatter.cs
+6 −0 Lib9c.MessagePack/Formatters/ExceptionFormatter.cs
+0 −0 Lib9c.MessagePack/Formatters/FungibleAssetValueFormatter.cs
+0 −0 Lib9c.MessagePack/Formatters/NCActionFormatter.cs
+0 −0 Lib9c.MessagePack/Formatters/NineChroniclesResolver.cs
+0 −0 Lib9c.MessagePack/Formatters/NineChroniclesResolverGetFormatterHelper.cs
+0 −0 Lib9c.MessagePack/Formatters/PublicKeyFormatter.cs
+22 −0 Lib9c.MessagePack/Lib9c.MessagePack.csproj
+14 −0 Lib9c.Miner/Lib9c.Miner.csproj
+0 −0 Lib9c.Miner/Miner.cs
+0 −0 Lib9c.Miner/ReorgMiner.cs
+18 −0 Lib9c.sln
+4 −87 Lib9c/Action/ActionBase.cs
+230 −0 Lib9c/Action/BattleGrandFinale.cs
+0 −27 Lib9c/Action/ByteSerializer.cs
+3 −3 Lib9c/Action/ClaimStakeReward.cs
+1 −1 Lib9c/Action/ClaimStakeReward1.cs
+1 −1 Lib9c/Action/ClaimStakeReward3.cs
+267 −0 Lib9c/Action/EventMaterialItemCrafts.cs
+37 −0 Lib9c/Action/Factory/ClaimStakeRewardFactory.cs
+8 −0 Lib9c/Action/IClaimStakeReward.cs
+14 −0 Lib9c/Action/ITransferAssets.cs
+175 −0 Lib9c/Action/TransferAssets.cs
+16 −0 Lib9c/Exceptions/AlreadyFoughtAvatarException.cs
+22 −0 Lib9c/Exceptions/InvalidMaterialCountException.cs
+73 −0 Lib9c/Extensions/EventRecipeExtensions.cs
+3 −3 Lib9c/Helper/RuneHelper.cs
+0 −30 Lib9c/InvalidMinerException.cs
+1 −11 Lib9c/Lib9c.csproj
+6 −6 Lib9c/Model/BattleStatus/Arena/ArenaSkill.cs
+6 −6 Lib9c/Model/BattleStatus/Skill.cs
+62 −0 Lib9c/Model/GrandFinale/GrandFinaleInformation.cs
+1 −0 Lib9c/Model/Mail/IMail.cs
+1 −0 Lib9c/Model/Mail/Mail.cs
+52 −0 Lib9c/Model/Mail/MaterialCraftMail.cs
+2 −3 Lib9c/Model/State/ArenaAvatarState.cs
+0 −3 Lib9c/Model/State/AvatarState.cs
+0 −1 Lib9c/Model/State/CrystalCostState.cs
+0 −5 Lib9c/Model/State/State.cs
+8 −0 Lib9c/Renderer/ActionRenderer.cs
+3 −0 Lib9c/SerializeKeys.cs
+24 −0 Lib9c/TableCSV/Arena/ArenaSheet.csv
+152 −152 Lib9c/TableCSV/Crystal/CrystalStageBuffGachaSheet.csv
+3 −0 Lib9c/TableCSV/Event/EventMaterialItemRecipeSheet.csv
+7 −0 Lib9c/TableCSV/Event/EventMaterialItemRecipeSheet.csv.meta
+1 −0 Lib9c/TableCSV/Event/EventScheduleSheet.csv
+8 −0 Lib9c/TableCSV/GrandFinale.meta
+5 −0 Lib9c/TableCSV/GrandFinale/GrandFinaleParticipantsSheet.csv
+7 −0 Lib9c/TableCSV/GrandFinale/GrandFinaleParticipantsSheet.csv.meta
+2 −0 Lib9c/TableCSV/GrandFinale/GrandFinaleScheduleSheet.csv
+7 −0 Lib9c/TableCSV/GrandFinale/GrandFinaleScheduleSheet.csv.meta
+4 −1 Lib9c/TableCSV/Item/CostumeItemSheet.csv
+4 −1 Lib9c/TableCSV/Item/CostumeStatSheet.csv
+38 −32 Lib9c/TableCSV/Item/ItemRequirementSheet.csv
+5 −5 Lib9c/TableCSV/StakeRegularRewardSheet.csv
+44 −0 Lib9c/TableData/Event/EventMaterialItemRecipeSheet.cs
+50 −0 Lib9c/TableData/GrandFinale/GrandFinaleParticipantsSheet.cs
+43 −0 Lib9c/TableData/GrandFinale/GrandFinaleScheduleSheet.cs
+25 −15 Lib9c/TableData/Sheet.cs
+16 −0 Libplanet.Crypto.Secp256k1/Libplanet.Crypto.Secp256k1.csproj
+0 −0 Libplanet.Crypto.Secp256k1/Secp256K1CryptoBackend.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using Libplanet;
using Libplanet.Crypto;
using Nekoyume.Action;
using Nekoyume.Action.Factory;
using Nekoyume.Model;
using Nekoyume.Model.State;
using NineChronicles.Headless.Executable.Commands;
Expand Down Expand Up @@ -60,10 +61,10 @@ public void ActivateAccount(bool invalid, int expectedCode)
}

[Theory]
[InlineData(false, 0, 195)]
[InlineData(false, 5_000_000, 195)]
[InlineData(true, 0, 195)]
[InlineData(true, 5_000_000, 70)]
[InlineData(false, 0, 198)]
[InlineData(false, 5_000_000, 198)]
[InlineData(true, 0, 198)]
[InlineData(true, 5_000_000, 73)]
public void List(bool excludeObsolete, long blockIndex, int expectedCommandCount)
{
var commandList = _command.List(excludeObsolete, blockIndex);
Expand Down Expand Up @@ -196,6 +197,65 @@ public void ClaimStakeReward(string addressString, int expectedCode)
}
}

[Theory]
[InlineData(0L, typeof(ClaimStakeReward))]
[InlineData(Nekoyume.Action.ClaimStakeReward.ObsoletedIndex - 1, typeof(ClaimStakeReward))]
[InlineData(Nekoyume.Action.ClaimStakeReward.ObsoletedIndex, typeof(ClaimStakeReward))]
[InlineData(Nekoyume.Action.ClaimStakeReward.ObsoletedIndex + 1, typeof(ClaimStakeReward3))]
[InlineData(long.MaxValue, typeof(ClaimStakeReward3))]
public void ClaimStakeRewardWithBlockIndex(long blockIndex, Type expectedActionType)
{
var filePath = Path.Combine(Path.GetTempPath(), Path.GetTempFileName());
var addr = new PrivateKey().ToAddress();
var resultCode = _command.ClaimStakeReward(
addr.ToHex(),
filePath,
blockIndex: blockIndex);
Assert.Equal(0, resultCode);

var rawAction = Convert.FromBase64String(File.ReadAllText(filePath));
var decoded = (List)_codec.Decode(rawAction);
var plainValue = Assert.IsType<Dictionary>(decoded[1]);
var action = ClaimStakeRewardFactory.CreateByBlockIndex(blockIndex, addr);
action.LoadPlainValue(plainValue);
string type = (Text)decoded[0];
Assert.Equal(action.GetType().Name, type);
}

[Theory]
[InlineData(0, 0, -1)]
[InlineData(1, 3, 0)]
[InlineData(4, 4, -1)]
public void ClaimStakeRewardWithActionVersion(
int actionVersionMin,
int actionVersionMax,
int expectedCode)
{
for (var i = actionVersionMin; i < actionVersionMax + 1; i++)
{
var filePath = Path.Combine(Path.GetTempPath(), Path.GetTempFileName());
var addr = new PrivateKey().ToAddress();
var resultCode = _command.ClaimStakeReward(
addr.ToHex(),
filePath,
actionVersion: i);
Assert.Equal(expectedCode, resultCode);

if (expectedCode < 0)
{
continue;
}

var rawAction = Convert.FromBase64String(File.ReadAllText(filePath));
var decoded = (List)_codec.Decode(rawAction);
var plainValue = Assert.IsType<Dictionary>(decoded[1]);
var action = ClaimStakeRewardFactory.CreateByVersion(i, addr);
action.LoadPlainValue(plainValue);
string type = (Text)decoded[0];
Assert.Equal(action.GetType().Name, type);
}
}

[Theory]
[InlineData("0xab1dce17dCE1Db1424BB833Af6cC087cd4F5CB6d", -1)]
[InlineData("ab1dce17dCE1Db1424BB833Af6cC087cd4F5CB6d", 0)]
Expand Down
20 changes: 17 additions & 3 deletions NineChronicles.Headless.Executable.Tests/Commands/TxCommandTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Libplanet.Blocks;
using Libplanet.Crypto;
using Libplanet.Tx;
using Nekoyume.Action;
using Nekoyume.Model;
using Nekoyume.Model.State;
using NineChronicles.Headless.Executable.Commands;
Expand Down Expand Up @@ -87,13 +88,26 @@ public void Sign_Stake()
Assert_Tx(1, filePath);
}

[Fact]
public void Sign_ClaimStakeReward()
[Theory]
[InlineData(null, null)]
[InlineData(0, null)]
[InlineData(ClaimStakeReward.ObsoletedIndex - 1, null)]
[InlineData(ClaimStakeReward.ObsoletedIndex, null)]
[InlineData(ClaimStakeReward.ObsoletedIndex + 1, null)]
[InlineData(long.MaxValue, null)]
[InlineData(null, 1)]
[InlineData(null, 2)]
[InlineData(null, 3)]
public void Sign_ClaimStakeReward(long? blockIndex, int? actionVersion)
{
var filePath = Path.Combine(Path.GetTempPath(), Path.GetTempFileName());
var actionCommand = new ActionCommand(_console);
var avatarAddress = new Address();
actionCommand.ClaimStakeReward(avatarAddress.ToHex(), filePath);
actionCommand.ClaimStakeReward(
avatarAddress.ToHex(),
filePath,
blockIndex,
actionVersion);
Assert_Tx(1, filePath);
}

Expand Down
42 changes: 42 additions & 0 deletions NineChronicles.Headless.Executable.sln
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Libplanet.Net", "Lib9c\.Lib
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lib9c.Tests", "Lib9c\.Lib9c.Tests\Lib9c.Tests.csproj", "{1DB5C746-0DBD-4D92-BE6D-1DF7536D62B6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lib9c.MessagePack", "Lib9c\Lib9c.MessagePack\Lib9c.MessagePack.csproj", "{A9513460-EE7A-455F-A823-5005DB6BA8FC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Libplanet.Crypto.Secp256k1", "Lib9c\Libplanet.Crypto.Secp256k1\Libplanet.Crypto.Secp256k1.csproj", "{84EBA886-FAD6-4167-9857-36BA1B394EBB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Lib9c.Miner", "Lib9c\Lib9c.Miner\Lib9c.Miner.csproj", "{33153A15-DFDD-4BD4-BB9A-6347DD94A658}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -256,6 +262,42 @@ Global
{1DB5C746-0DBD-4D92-BE6D-1DF7536D62B6}.Release|x64.Build.0 = Release|Any CPU
{1DB5C746-0DBD-4D92-BE6D-1DF7536D62B6}.Release|x86.ActiveCfg = Release|Any CPU
{1DB5C746-0DBD-4D92-BE6D-1DF7536D62B6}.Release|x86.Build.0 = Release|Any CPU
{A9513460-EE7A-455F-A823-5005DB6BA8FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A9513460-EE7A-455F-A823-5005DB6BA8FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A9513460-EE7A-455F-A823-5005DB6BA8FC}.Debug|x64.ActiveCfg = Debug|Any CPU
{A9513460-EE7A-455F-A823-5005DB6BA8FC}.Debug|x64.Build.0 = Debug|Any CPU
{A9513460-EE7A-455F-A823-5005DB6BA8FC}.Debug|x86.ActiveCfg = Debug|Any CPU
{A9513460-EE7A-455F-A823-5005DB6BA8FC}.Debug|x86.Build.0 = Debug|Any CPU
{A9513460-EE7A-455F-A823-5005DB6BA8FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A9513460-EE7A-455F-A823-5005DB6BA8FC}.Release|Any CPU.Build.0 = Release|Any CPU
{A9513460-EE7A-455F-A823-5005DB6BA8FC}.Release|x64.ActiveCfg = Release|Any CPU
{A9513460-EE7A-455F-A823-5005DB6BA8FC}.Release|x64.Build.0 = Release|Any CPU
{A9513460-EE7A-455F-A823-5005DB6BA8FC}.Release|x86.ActiveCfg = Release|Any CPU
{A9513460-EE7A-455F-A823-5005DB6BA8FC}.Release|x86.Build.0 = Release|Any CPU
{84EBA886-FAD6-4167-9857-36BA1B394EBB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{84EBA886-FAD6-4167-9857-36BA1B394EBB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{84EBA886-FAD6-4167-9857-36BA1B394EBB}.Debug|x64.ActiveCfg = Debug|Any CPU
{84EBA886-FAD6-4167-9857-36BA1B394EBB}.Debug|x64.Build.0 = Debug|Any CPU
{84EBA886-FAD6-4167-9857-36BA1B394EBB}.Debug|x86.ActiveCfg = Debug|Any CPU
{84EBA886-FAD6-4167-9857-36BA1B394EBB}.Debug|x86.Build.0 = Debug|Any CPU
{84EBA886-FAD6-4167-9857-36BA1B394EBB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{84EBA886-FAD6-4167-9857-36BA1B394EBB}.Release|Any CPU.Build.0 = Release|Any CPU
{84EBA886-FAD6-4167-9857-36BA1B394EBB}.Release|x64.ActiveCfg = Release|Any CPU
{84EBA886-FAD6-4167-9857-36BA1B394EBB}.Release|x64.Build.0 = Release|Any CPU
{84EBA886-FAD6-4167-9857-36BA1B394EBB}.Release|x86.ActiveCfg = Release|Any CPU
{84EBA886-FAD6-4167-9857-36BA1B394EBB}.Release|x86.Build.0 = Release|Any CPU
{33153A15-DFDD-4BD4-BB9A-6347DD94A658}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{33153A15-DFDD-4BD4-BB9A-6347DD94A658}.Debug|Any CPU.Build.0 = Debug|Any CPU
{33153A15-DFDD-4BD4-BB9A-6347DD94A658}.Debug|x64.ActiveCfg = Debug|Any CPU
{33153A15-DFDD-4BD4-BB9A-6347DD94A658}.Debug|x64.Build.0 = Debug|Any CPU
{33153A15-DFDD-4BD4-BB9A-6347DD94A658}.Debug|x86.ActiveCfg = Debug|Any CPU
{33153A15-DFDD-4BD4-BB9A-6347DD94A658}.Debug|x86.Build.0 = Debug|Any CPU
{33153A15-DFDD-4BD4-BB9A-6347DD94A658}.Release|Any CPU.ActiveCfg = Release|Any CPU
{33153A15-DFDD-4BD4-BB9A-6347DD94A658}.Release|Any CPU.Build.0 = Release|Any CPU
{33153A15-DFDD-4BD4-BB9A-6347DD94A658}.Release|x64.ActiveCfg = Release|Any CPU
{33153A15-DFDD-4BD4-BB9A-6347DD94A658}.Release|x64.Build.0 = Release|Any CPU
{33153A15-DFDD-4BD4-BB9A-6347DD94A658}.Release|x86.ActiveCfg = Release|Any CPU
{33153A15-DFDD-4BD4-BB9A-6347DD94A658}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
38 changes: 35 additions & 3 deletions NineChronicles.Headless.Executable/Commands/ActionCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Libplanet.Action;
using Libplanet.Assets;
using Nekoyume.Action;
using Nekoyume.Action.Factory;
using Nekoyume.Model;
using NineChronicles.Headless.Executable.IO;
using NCAction = Libplanet.Action.PolymorphicAction<Nekoyume.Action.ActionBase>;
Expand Down Expand Up @@ -302,18 +303,49 @@ public int ClaimStakeReward(
[Argument("AVATAR-ADDRESS", Description = "A hex-encoded avatar address.")]
string encodedAddress,
[Argument("PATH", Description = "A file path of base64 encoded action.")]
string? filePath = null
string? filePath = null,
[Option("BLOCK-INDEX", Description = "A block index which is used to specifying the action version.")]
long? blockIndex = null,
[Option("ACTION-VERSION", Description = "A version of action.")]
int? actionVersion = null
)
{
try
{
if (blockIndex.HasValue && actionVersion.HasValue)
{
throw new CommandExitedException(
"You can't specify both block index and action version at the same time.",
-1);
}

Address avatarAddress = new Address(ByteUtil.ParseHex(encodedAddress));
Nekoyume.Action.ClaimStakeReward action = new ClaimStakeReward(avatarAddress);
IClaimStakeReward? action = null;
if (blockIndex.HasValue)
{
action = ClaimStakeRewardFactory.CreateByBlockIndex(
blockIndex.Value,
avatarAddress);
}
else if (actionVersion.HasValue)
{
action = ClaimStakeRewardFactory.CreateByVersion(
actionVersion.Value,
avatarAddress);
}

// NOTE: If neither block index nor action version is specified,
// it will be created by the type of the class.
// I considered to create action with max value of
// block index(i.e., long.MaxValue), but it is not good
// because the action of the next version may come along
// with the current version.
action ??= new ClaimStakeReward(avatarAddress);

byte[] raw = Codec.Encode(new List(
new[]
{
(Text) nameof(Nekoyume.Action.ClaimStakeReward),
(Text) action.GetType().Name,
action.PlainValue
}
));
Expand Down
Loading

0 comments on commit 44e3c42

Please sign in to comment.