Skip to content

Commit

Permalink
Merge pull request #1920 from moreal/independent-lib9c-devex
Browse files Browse the repository at this point in the history
Override polymorphic action's action type loader
  • Loading branch information
moreal authored Mar 10, 2023
2 parents 9317ad0 + 67447b6 commit 2890584
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Lib9c
Submodule Lib9c updated 44 files
+64 −0 .Lib9c.DevExtensions.Tests/Action/Craft/UnlocakCraftActionTest.cs
+104 −0 .Lib9c.DevExtensions.Tests/Action/Craft/UnlockRecipeTest.cs
+527 −0 .Lib9c.DevExtensions.Tests/Action/ManipulateStateTest.cs
+54 −0 .Lib9c.DevExtensions.Tests/Action/Stage/ClearStageTest.cs
+56 −0 .Lib9c.Tests/Action/AccountStateDeltaExtensionsTest.cs
+94 −0 .Lib9c.Tests/Action/AccountStateViewExtensionsTest.cs
+38 −0 .Lib9c.Tests/Action/Coupons/CouponsFixture.cs
+196 −0 .Lib9c.Tests/Action/Coupons/IssueCouponsTest.cs
+374 −0 .Lib9c.Tests/Action/Coupons/RedeemCouponTest.cs
+279 −0 .Lib9c.Tests/Action/Coupons/TransferCouponsTest.cs
+16 −0 .Lib9c.Tests/Action/TransferAsset2Test.cs
+162 −0 .Lib9c.Tests/Model/Coupons/CouponTest.cs
+79 −0 .Lib9c.Tests/Model/Coupons/RewardSetTest.cs
+12 −2 .Lib9c.Tests/Util/InitializeUtil.cs
+2 −12 .Lib9c.Tools/Lib9c.Tools.csproj
+1 −1 .Libplanet
+28 −3 .github/workflows/main.yml
+78 −0 Lib9c.DevExtensions/Action/Craft/UnlockCraftAction.cs
+52 −0 Lib9c.DevExtensions/Action/Craft/UnlockRecipe.cs
+1 −1 Lib9c.DevExtensions/Action/CreateOrReplaceAvatar.cs
+46 −0 Lib9c.DevExtensions/Action/ManipulateState.cs
+54 −0 Lib9c.DevExtensions/Action/Stage/ClearStage.cs
+1 −7 Lib9c.DevExtensions/Lib9c.DevExtensions.csproj
+7 −4 Lib9c.DevExtensions/Utils.cs
+0 −10 Lib9c.Miner/Miner.cs
+0 −116 Lib9c.Miner/ReorgMiner.cs
+15 −14 Lib9c.Policy/Lib9c.Policy.csproj
+15 −12 Lib9c.Renderers/Lib9c.Renderers.csproj
+0 −0 Lib9c.Renderers/Renderers/ActionRenderer.cs
+0 −0 Lib9c.Renderers/Renderers/BlockRenderer.cs
+16 −14 Lib9c.Utils/Lib9c.Utils.csproj
+0 −41 Lib9c.sln
+25 −0 Lib9c/Action/AccountStateDeltaExtensions.cs
+19 −0 Lib9c/Action/AccountStateViewExtensions.cs
+81 −0 Lib9c/Action/Coupons/IssueCoupons.cs
+93 −0 Lib9c/Action/Coupons/RedeemCoupon.cs
+78 −0 Lib9c/Action/Coupons/TransferCoupons.cs
+2 −0 Lib9c/Action/TransferAsset2.cs
+1 −21 Lib9c/Lib9c.csproj
+77 −0 Lib9c/Model/Coupons/Coupon.cs
+160 −0 Lib9c/Model/Coupons/RewardSet.cs
+0 −1 Lib9c/Model/Quest/QuestList.cs
+35 −0 Lib9c/Model/State/StateExtensions.cs
+1 −0 Lib9c/SerializeKeys.cs
8 changes: 4 additions & 4 deletions NineChronicles.Headless.Executable.sln
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ Global
{71CBCF83-FE87-4D84-A20C-FD328855E445}.Release|x64.Build.0 = Release|Any CPU
{71CBCF83-FE87-4D84-A20C-FD328855E445}.Release|x86.ActiveCfg = Release|Any CPU
{71CBCF83-FE87-4D84-A20C-FD328855E445}.Release|x86.Build.0 = Release|Any CPU
{71CBCF83-FE87-4D84-A20C-FD328855E445}.DevEx|Any CPU.ActiveCfg = DevEx|Any CPU
{71CBCF83-FE87-4D84-A20C-FD328855E445}.DevEx|Any CPU.Build.0 = DevEx|Any CPU
{71CBCF83-FE87-4D84-A20C-FD328855E445}.DevEx|Any CPU.ActiveCfg = Debug|Any CPU
{71CBCF83-FE87-4D84-A20C-FD328855E445}.DevEx|Any CPU.Build.0 = Debug|Any CPU
{106573F6-F9C1-41B7-8F02-40E76F177C24}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{106573F6-F9C1-41B7-8F02-40E76F177C24}.Debug|Any CPU.Build.0 = Debug|Any CPU
{106573F6-F9C1-41B7-8F02-40E76F177C24}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -273,8 +273,8 @@ Global
{8411BF58-22E7-4174-AEE6-7332FE690906}.Release|x64.Build.0 = Release|Any CPU
{8411BF58-22E7-4174-AEE6-7332FE690906}.Release|x86.ActiveCfg = Release|Any CPU
{8411BF58-22E7-4174-AEE6-7332FE690906}.Release|x86.Build.0 = Release|Any CPU
{8411BF58-22E7-4174-AEE6-7332FE690906}.DevEx|Any CPU.ActiveCfg = DevEx|Any CPU
{8411BF58-22E7-4174-AEE6-7332FE690906}.DevEx|Any CPU.Build.0 = DevEx|Any CPU
{8411BF58-22E7-4174-AEE6-7332FE690906}.DevEx|Any CPU.ActiveCfg = Debug|Any CPU
{8411BF58-22E7-4174-AEE6-7332FE690906}.DevEx|Any CPU.Build.0 = Debug|Any CPU
{858AEAB3-CC9C-41C4-9727-4243708FD803}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{858AEAB3-CC9C-41C4-9727-4243708FD803}.Debug|Any CPU.Build.0 = Debug|Any CPU
{858AEAB3-CC9C-41C4-9727-4243708FD803}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@
<ProjectReference Include="..\Lib9c\.Libplanet\Libplanet.Extensions.Cocona\Libplanet.Extensions.Cocona.csproj" />
<ProjectReference Include="..\Lib9c\Lib9c.Utils\Lib9c.Utils.csproj" />
<ProjectReference Include="..\NineChronicles.Headless\NineChronicles.Headless.csproj" />
</ItemGroup>

<ItemGroup Condition=" '$(Configuration)' != 'DevEx' ">
<!-- NOTE: Lib9c.DevExtensions project will be contained by Lib9c project
when the configuration is 'DevEx'.-->
<ProjectReference Include="..\Lib9c\Lib9c.DevExtensions\Lib9c.DevExtensions.csproj" />
</ItemGroup>

Expand Down
19 changes: 19 additions & 0 deletions NineChronicles.Headless.Executable/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,22 @@ public async Task Run(

IActionTypeLoader MakeStaticActionTypeLoader() => new StaticActionTypeLoader(
Assembly.GetEntryAssembly() is { } entryAssembly
#if LIB9C_DEV_EXTENSIONS
? new[]
{
typeof(ActionBase).Assembly,
typeof(Lib9c.DevExtensions.Action.CreateOrReplaceAvatar).Assembly,
entryAssembly
}
: new[]
{
typeof(ActionBase).Assembly,
typeof(Lib9c.DevExtensions.Action.CreateOrReplaceAvatar).Assembly
},
#else
? new[] { typeof(ActionBase).Assembly, entryAssembly }
: new[] { typeof(ActionBase).Assembly },
#endif
typeof(ActionBase)
);

Expand Down Expand Up @@ -388,6 +402,11 @@ public async Task Run(
actionTypeLoader = MakeStaticActionTypeLoader();
}

if (actionTypeLoader is StaticActionTypeLoader staticActionTypeLoader)
{
PolymorphicAction<ActionBase>.ActionTypeLoader = staticActionTypeLoader;
}

var minerPrivateKey = string.IsNullOrEmpty(headlessConfig.MinerPrivateKeyString)
? null
: new PrivateKey(ByteUtil.ParseHex(headlessConfig.MinerPrivateKeyString));
Expand Down
2 changes: 1 addition & 1 deletion NineChronicles.Headless/NineChroniclesNodeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ async Task minerLoopAction(
PrivateKey privateKey,
CancellationToken cancellationToken)
{
var miner = new Miner(chain, swarm, privateKey, actionTypeLoader);
var miner = new Miner(chain, privateKey, actionTypeLoader);
Log.Debug("Miner called.");
while (!cancellationToken.IsCancellationRequested)
{
Expand Down

0 comments on commit 2890584

Please sign in to comment.