Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix an issue where the console cannot create a repository with the module path #73

Merged
merged 1 commit into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .submodules/lib9c
Submodule lib9c added at 178eaf
4 changes: 3 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
"console": "integratedTerminal",
"args": [
"init",
".data"
".data",
"--module-type",
"LibplanetConsole.Node.Delegation.ActionProvider, LibplanetConsole.Node.Delegation"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ private NodeOptions[] GetNodeOptions(ref EndPoint? prevEndPoint)
StorePath = "store",
LogPath = "app.log",
LibraryLogPath = "library.log",
ActionProviderModulePath = ActionProviderModulePath,
ActionProviderType = ActionProviderType,
};
nodeOptionsList.Add(nodeOptions);
if (prevEndPoint is not null)
Expand Down
12 changes: 12 additions & 0 deletions src/console/LibplanetConsole.Console/NodeOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ public sealed record class NodeOptions

public string LibraryLogPath { get; init; } = string.Empty;

public string ActionProviderModulePath { get; init; } = string.Empty;

public string ActionProviderType { get; init; } = string.Empty;

internal string RepositoryPath { get; private set; } = string.Empty;

public static NodeOptions Load(string settingsPath)
Expand All @@ -43,6 +47,8 @@ public static NodeOptions Load(string settingsPath)
LibraryLogPath = Path.GetFullPath(applicationSettings.LibraryLogPath, repositoryPath),
SeedEndPoint = EndPointUtility.ParseOrDefault(applicationSettings.SeedEndPoint),
RepositoryPath = repositoryPath,
ActionProviderModulePath = applicationSettings.ActionProviderModulePath,
ActionProviderType = applicationSettings.ActionProviderType,
};
}

Expand Down Expand Up @@ -74,5 +80,11 @@ private sealed record class ApplicationSettings

[DefaultValue("")]
public string SeedEndPoint { get; init; } = string.Empty;

[DefaultValue("")]
public string ActionProviderModulePath { get; init; } = string.Empty;

[DefaultValue("")]
public string ActionProviderType { get; init; } = string.Empty;
}
}
12 changes: 12 additions & 0 deletions src/console/LibplanetConsole.Console/NodeProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,18 @@ public override string[] Arguments
argumentList.Add(EndPointUtility.ToString(seedEndPoint));
}

if (nodeOptions.ActionProviderModulePath != string.Empty)
{
argumentList.Add("--module-path");
argumentList.Add(nodeOptions.ActionProviderModulePath);
}

if (nodeOptions.ActionProviderType != string.Empty)
{
argumentList.Add("--module-type");
argumentList.Add(nodeOptions.ActionProviderType);
}

var extendedArguments = GetArguments(serviceProvider: node, obj: node);
argumentList.AddRange(extendedArguments);
}
Expand Down
45 changes: 34 additions & 11 deletions src/console/LibplanetConsole.Console/NodeRepositoryProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,38 @@ internal sealed class NodeRepositoryProcess : NodeProcessBase

public string GenesisPath { get; set; } = string.Empty;

public override string[] Arguments =>
[
"init",
OutputPath,
"--private-key",
PrivateKeyUtility.ToString(PrivateKey),
"--end-point",
EndPointUtility.ToString(EndPoint),
"--genesis-path",
GenesisPath,
];
public string ActionProviderModulePath { get; set; } = string.Empty;

public string ActionProviderType { get; set; } = string.Empty;

public override string[] Arguments
{
get
{
var argumentList = new List<string>
{
"init",
OutputPath,
"--private-key",
PrivateKeyUtility.ToString(PrivateKey),
"--end-point",
EndPointUtility.ToString(EndPoint),
"--genesis-path",
GenesisPath,
};
if (ActionProviderModulePath != string.Empty)
{
argumentList.Add("--module-path");
argumentList.Add(ActionProviderModulePath);
}

if (ActionProviderType != string.Empty)
{
argumentList.Add("--module-type");
argumentList.Add(ActionProviderType);
}

return [.. argumentList];
}
}
}
2 changes: 2 additions & 0 deletions src/console/LibplanetConsole.Console/Repository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ public dynamic Save(string repositoryPath, RepositoryPathResolver resolver)
EndPoint = node.EndPoint,
OutputPath = nodePath,
GenesisPath = genesisPath,
ActionProviderModulePath = node.ActionProviderModulePath,
ActionProviderType = node.ActionProviderType,
};
var sb = new StringBuilder();
process.OutputDataReceived += (_, e) => sb.AppendLine(e.Data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,14 @@ public InitializeCommand()

[CommandProperty("module-path")]
[CommandSummary("Indicates the path or the name of the assembly that provides " +
"the IActionProvider.\n" +
"Requires the '--single-node' option to be set.")]
"the IActionProvider")]
[Category("Genesis")]
[CommandPropertyDependency(nameof(IsSingleNode))]
public string ActionProviderModulePath { get; set; } = string.Empty;

[CommandProperty("module-type")]
[CommandSummary("Indicates the type name of the IActionProvider.\n" +
"Requires the '--single-node' option to be set.")]
[CommandSummary("Indicates the type name of the IActionProvider.")]
[CommandExample("--module-type 'LibplanetModule.SimpleActionProvider, LibplanetModule'")]
[Category("Genesis")]
[CommandPropertyDependency(nameof(IsSingleNode))]
public string ActionProviderType { get; set; } = string.Empty;

protected override void OnExecute()
Expand Down
Loading