Skip to content
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
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
# 6.1.0
Issue 21
- [Issue 21](https://github.com/shamblett/ethereum/issues21)

# 6.0.1
Issue 19
- [Issue 19](https://github.com/shamblett/ethereum/issues/19)

# 6.0.0
Issue 18 - Dart 3
- [Issue 18](https://github.com/shamblett/ethereum/issues/18)

# 5.0.2
Issue 17
- [Issue 17](https://github.com/shamblett/ethereum/issues/14)

# 5.0.1
Issue 13
- [Issue 13](https://github.com/shamblett/ethereum/issues/13)

# 5.0.0
Issue 9(NNBD)
- [Issue 9(NNBD)](https://github.com/shamblett/ethereum/issues/9)

# 4.0.3
Linter + pana updates
Expand All @@ -27,15 +32,19 @@ Update for use with Dart 2.1.1

# 4.0.0
Issue 5, new datatypes
- [Issue 5](https://github.com/shamblett/ethereum/issues/5)

# 3.1.0
Issue 4 fixes, linter updates
- [Issue 4](https://github.com/shamblett/ethereum/issues/4)

# 3.0.0
Issue 4, Interface updates - admin
- [Issue 4](https://github.com/shamblett/ethereum/issues/4)

#2 .0.1
Issue 3, updates for Dart 2
- [Issue 3](https://github.com/shamblett/ethereum/issues/3)

# 1.1.0
Minor API(default block parameter) and coverage updates
Expand Down
17 changes: 17 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,20 @@ include: package:lints/recommended.yaml
analyzer:
exclude:
- test/issues/**

dart_code_metrics:
exclude:
metrics:
- test/**
- example/**
rules:
- test/**
- example/**
extends:
- package:dart_code_metrics_presets/dart_all.yaml
rules:
- avoid-dynamic : false
- avoid-non-null-assertion : false
- newline-before-return : false
- avoid-late-keyword : false
- prefer-match-file-name : false
21 changes: 13 additions & 8 deletions lib/ethereum_browser_http_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,21 @@ part 'src/adapters/ethereum_browser_http_adapter.dart';

/// The browser HTTP client
class EthereumBrowserHTTPClient extends Ethereum {
/// The adapter
static final EthereumBrowserHTTPAdapter browserHttpAdapter =
EthereumBrowserHTTPAdapter();

/// Construction
EthereumBrowserHTTPClient() : super(browserHttpAdapter);

/// With connection parameters
EthereumBrowserHTTPClient.withConnectionParameters(String hostname,
[int? port])
: super.withConnectionParameters(
browserHttpAdapter, hostname, Ethereum.rpcHttpScheme, port);

/// The adapter
static EthereumBrowserHTTPAdapter browserHttpAdapter =
EthereumBrowserHTTPAdapter();
EthereumBrowserHTTPClient.withConnectionParameters(
String hostname, [
int? port,
]) : super.withConnectionParameters(
browserHttpAdapter,
hostname,
Ethereum.rpcHttpScheme,
port,
);
}
15 changes: 10 additions & 5 deletions lib/ethereum_browser_ws_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,19 @@ part 'src/adapters/ethereum_browser_ws_adapter.dart';

/// The browser web socket client
class EthereumBrowserWSClient extends Ethereum {
/// The adapter
static final EthereumBrowserWSAdapter browserWSAdapter =
EthereumBrowserWSAdapter();

/// Default construction
EthereumBrowserWSClient() : super(browserWSAdapter);

/// With connection parameters
EthereumBrowserWSClient.withConnectionParameters(String hostname, [int? port])
: super.withConnectionParameters(
browserWSAdapter, hostname, Ethereum.rpcWsScheme, port);

/// The adapter
static EthereumBrowserWSAdapter browserWSAdapter = EthereumBrowserWSAdapter();
: super.withConnectionParameters(
browserWSAdapter,
hostname,
Ethereum.rpcWsScheme,
port,
);
}
16 changes: 10 additions & 6 deletions lib/ethereum_server_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,19 @@ part 'src/adapters/ethereum_server_http_adapter.dart';

/// The server HTTP client
class EthereumServerClient extends Ethereum {
/// The adapter
static final EthereumServerHTTPAdapter serverHttpAdapter =
EthereumServerHTTPAdapter();

/// Default constructor
EthereumServerClient() : super(serverHttpAdapter);

/// With connection parameters
EthereumServerClient.withConnectionParameters(String hostname, [int? port])
: super.withConnectionParameters(
serverHttpAdapter, hostname, Ethereum.rpcHttpScheme, port);

/// The adapter
static EthereumServerHTTPAdapter serverHttpAdapter =
EthereumServerHTTPAdapter();
: super.withConnectionParameters(
serverHttpAdapter,
hostname,
Ethereum.rpcHttpScheme,
port,
);
}
25 changes: 16 additions & 9 deletions lib/src/adapters/ethereum_browser_http_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,25 @@ class EthereumBrowserHTTPAdapter implements EthereumINetworkAdapter {
/// a JSON Object
@override
Future<Map<dynamic, dynamic>> httpRequest(
Uri uri, Map<String, dynamic> request) {
Uri uri,
Map<String, dynamic> request,
) {
final completer = Completer<Map<String, dynamic>>();
final reqText = json.encode(request);
final headers = <String, String>{contentType: jsonMimeType};
BrowserClient().post(uri, headers: headers, body: reqText).then((req) {
final Map<String, dynamic> resp = json.decode(req.body);
completer.complete(resp);
return completer.future;
}, onError: (final error) {
completer.complete(<String, dynamic>{});
return completer.future;
});
BrowserClient()
.post(uri, headers: headers, body: reqText)
.then(
(req) {
final Map<String, dynamic> resp = json.decode(req.body);
completer.complete(resp);
return completer.future;
},
onError: (final error) {
completer.complete(<String, dynamic>{});
return completer.future;
},
);
return completer.future;
}
}
10 changes: 7 additions & 3 deletions lib/src/adapters/ethereum_browser_ws_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,20 @@ part of '../../ethereum_browser_ws_client.dart';
class EthereumBrowserWSAdapter implements EthereumINetworkAdapter {
@override
Future<Map<dynamic, dynamic>> httpRequest(
Uri uri, Map<String, dynamic> request) {
Uri uri,
Map<String, dynamic> request,
) {
final completer = Completer<Map<String, dynamic>>();
final webSocket = WebSocket(uri.toString());
final message = json.encode(request);
webSocket.onOpen.listen((Event e) {
webSocket.send(message.jsify()!);
});
webSocket.onError.listen((Event e) {
print('EthereumBrowserWSAdapter::WebSocket error, message not sent, '
'state is ${webSocket.readyState.toString()}');
print(
'EthereumBrowserWSAdapter::WebSocket error, message not sent, '
'state is ${webSocket.readyState.toString()}',
);
webSocket.close();
completer.complete(<String, dynamic>{});
});
Expand Down
4 changes: 3 additions & 1 deletion lib/src/adapters/ethereum_inetwork_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ abstract class EthereumINetworkAdapter {
/// Processes the HTTP request returning the HTTP response as
/// a map
Future<Map<dynamic, dynamic>> httpRequest(
Uri uri, Map<String, dynamic> request);
Uri uri,
Map<String, dynamic> request,
);
}
18 changes: 9 additions & 9 deletions lib/src/adapters/ethereum_server_http_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ class EthereumServerHTTPAdapter implements EthereumINetworkAdapter {
/// a map
@override
Future<Map<dynamic, dynamic>> httpRequest(
Uri uri, Map<String, dynamic> request) {
Uri uri,
Map<String, dynamic> request,
) {
final client = HttpClient();
final completer = Completer<Map<dynamic, dynamic>>();
client.postUrl(uri).then((HttpClientRequest req) {
Expand All @@ -28,14 +30,12 @@ class EthereumServerHTTPAdapter implements EthereumINetworkAdapter {
req.contentLength = payload.length;
req.write(payload);
req.close().then((HttpClientResponse resp) {
resp.listen(
(dynamic data) {
final Map<dynamic, dynamic>? payload =
json.decode(String.fromCharCodes(data));
completer.complete(payload);
},
onError: print,
);
resp.listen((dynamic data) {
final Map<dynamic, dynamic>? payload = json.decode(
String.fromCharCodes(data),
);
completer.complete(payload);
}, onError: print);
});
}, onError: print);
return completer.future;
Expand Down
8 changes: 4 additions & 4 deletions lib/src/api/ethereum_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ part of '../../ethereum.dart';

/// The API base class
class EthereumApi {
/// Construction
EthereumApi(this._client);

/// Our client
// Our client
final Ethereum _client;

/// Message Id
int get id => _client.id;

/// Last error
EthereumError get lastError => _client.lastError;

/// Construction
EthereumApi(this._client);
}
Loading
Loading