Skip to content

Commit

Permalink
fix : adds the LNClientException dependency
Browse files Browse the repository at this point in the history
This commit adds the LNClientException class for all the packages by importing it from the rpc package.
  • Loading branch information
Harshit933 authored and vincenzopalazzo committed Jul 23, 2023
1 parent 70186d2 commit b29b395
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 10 deletions.
1 change: 1 addition & 0 deletions packages/cln_common/lib/src/cln_common_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export 'package:cln_common/src/json_rpc/request.dart';
export 'package:cln_common/src/json_rpc/response.dart';

export 'package:cln_common/src/logger/logger_manager.dart';
export 'package:cln_common/src/utils/exception.dart';
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ class LNClientException implements Exception {
int code;
String? data;

LNClientException(this.code, this.message, this.data);
LNClientException({required this.code, required this.message, this.data});
}
6 changes: 5 additions & 1 deletion packages/lnlambda/lib/src/lnlambda_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ class LNLambdaClient implements LightningClient {
body: json.encode(request.toJSON()));
Map<String, dynamic> result = json.decode(response.body);
if (result.containsKey("error")) {
throw Exception(response.body);
var jsonString = result["error"];
throw LNClientException(
code: jsonString["code"],
message: jsonString["message"],
data: jsonString["data"]);
}
return result["result"];
}
Expand Down
Binary file modified packages/lnlambda/lnlambda_example
Binary file not shown.
8 changes: 5 additions & 3 deletions packages/lnlambda/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ name: lnlambda
description: Minimal interface to run lnlambda function with dart.
version: 0.0.1-beta.6
homepage: https://github.com/dart-lightning/lndart.clightning

publish_to: none
environment:
sdk: '>=2.17.5 <3.0.0'

dependencies:
cln_common: ^0.0.1-beta.1
cln_common:
path: ../cln_common
http: ^0.13.4
json_annotation: ^4.5.0

Expand All @@ -16,7 +17,8 @@ dev_dependencies:
test: ^1.16.0
build_runner: ^2.0.0
json_serializable: ^6.2.0
clightning_rpc: ^0.0.2-beta.1
clightning_rpc:
path: ../rpc

#dependency_overrides:
# cln_common:
Expand Down
1 change: 0 additions & 1 deletion packages/rpc/lib/clightning_rpc.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
library clightning.dart;

export 'src/clightning_rpc.dart';
export 'src/utils/exception/ln_client_error.dart';
5 changes: 3 additions & 2 deletions packages/rpc/lib/src/utils/unix_rpc_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import 'dart:io';

import 'package:cln_common/cln_common.dart';
import 'package:jsonrpc2/jsonrpc2.dart';
import 'exception/ln_client_error.dart';

class UnixRPCClient extends ServerProxyBase {
UnixRPCClient(String path) : super(path);
Expand All @@ -26,7 +25,9 @@ class UnixRPCClient extends ServerProxyBase {
if (eventMap.containsKey("error")) {
var error = eventMap["error"];
var exception = LNClientException(
error["code"], error["message"], error["data"]);
code: error["code"],
message: error["message"],
data: error["data"]);
completer.completeError(exception);
} else {
completer.complete(utf8.decode(event));
Expand Down
5 changes: 3 additions & 2 deletions packages/rpc/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: clightning_rpc
description: Generic and Fast way to have your app connected with core lightning with dart and Unix socket
version: 0.0.2-beta.4
homepage: https://github.com/dart-lightning/lndart.clightning

publish_to: none
environment:
sdk: '>=2.12.0 <3.0.0'

Expand All @@ -13,7 +13,8 @@ dev_dependencies:
dependencies:
json_rpc_2: ^3.0.1
jsonrpc2: ^3.0.1
cln_common: ^0.0.1-beta.1
cln_common:
path: ../cln_common

#dependency_overrides:
# cln_common:
Expand Down
1 change: 1 addition & 0 deletions packages/rpc/test/clightning_rpc_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:io';
import 'package:cln_common/cln_common.dart';
import 'package:test/test.dart';
import 'package:clightning_rpc/clightning_rpc.dart';

Expand Down

0 comments on commit b29b395

Please sign in to comment.