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

implementing life cycle rpc method like getmanifest to be able to run the plugin #26

Merged
merged 7 commits into from
Jun 16, 2022

Conversation

vincenzopalazzo
Copy link
Member

@vincenzopalazzo vincenzopalazzo commented Jun 15, 2022

This should unlock you! this time for real!

Fixes #19

swaptr and others added 5 commits June 16, 2022 04:32
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>

# Title: 

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>

# Title: 

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
@vincenzopalazzo vincenzopalazzo added the plugin API Plugin API related label Jun 15, 2022
@vincenzopalazzo vincenzopalazzo added this to In progress in lndart plugin via automation Jun 15, 2022
@vincenzopalazzo vincenzopalazzo changed the title implementing draft method like getmanifest to be able to run the plugin implementing life cycle rpc method like getmanifest to be able to run the plugin Jun 15, 2022
Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
.toList();
response["subscriptions"] = plugin.subscriptions;
response["hooks"] = plugin.hooks.toList();
response["notifications"] = [];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this [] and not plugin.notifications?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the notification it is not a list of string but a list of object! So we need to find a way of how to do that!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So like a list of notification objects, similar to JRPCLightning?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the two concept are analogous, are implementing the same stuff

@@ -46,12 +49,12 @@ class Plugin implements CLNPlugin {
required String def,
required String description,
required bool deprecated}) {
options = Option(
options.add(Option(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we are maintaining a List<Option> so shouldn't we just add the new option onto the list?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the option are the value that the user can put with --some=hello, so this is a list of option and not a single one!

We need to add inside the list the options, and I was unable to understand way you was doing options = Option I assumed it was a mistake

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is correct?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why should be wrong? this code the code that I removed is also wrong! you are casting a option into a List

.toList();
response["subscriptions"] = plugin.subscriptions;
response["hooks"] = plugin.hooks.toList();
response["notifications"] = [];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
response["notifications"] = [];
response["notifications"] = [];

We need to check what type of object it is required by cln here @swaptr

Comment on lines +96 to +103
response["options"] = plugin.options.map((opt) => opt.toMap()).toList();
response["rpcmethods"] = plugin.rpcMethods.values
.where((rpc) => rpc.name != "init" && rpc.name != "getmanifest")
.map((rpc) => rpc.toMap())
.toList();
response["subscriptions"] = plugin.subscriptions;
response["hooks"] = plugin.hooks.toList();
response["notifications"] = [];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to check this with attention with the core lightning docs, maybe we can write some units tests @swaptr

packages/cln_plugin/lib/src/cln_plugin_base.dart Outdated Show resolved Hide resolved
@@ -138,7 +144,7 @@ class Plugin implements CLNPlugin {
var result = HashMap<String, Object>();
result["level"] = level;
result["message"] = message;
stdout.write(jsonDecode(Response(result: result).toJson()));
stdout.write(Response(result: result).toJson());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure that this works?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error on IDE disappears but when I try to log the messageSocket in start() method, this is returned 2022-06-16T16:00:01.315Z UNUSUAL plugin-cln_plugin_example.exe: Killing plugin: Malformed JSON-RPC notification missing "method" or "params": {"jsonrpc":"2.0","result":{"level":"debug","message":"Instance of 'Request'"}}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe you need to put the also the id inside the constructor?

Somethings like Response(id: 40, result: result).toJson()

.toList();
response["subscriptions"] = plugin.subscriptions;
response["hooks"] = plugin.hooks.toList();
response["notifications"] = [];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the notification it is not a list of string but a list of object! So we need to find a way of how to do that!

Co-authored-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin API Plugin API related
Projects
Development

Successfully merging this pull request may close these issues.

plugin: implementing the log plugin method
2 participants