diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index f856d212..81cb5096 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -33,7 +33,7 @@ jobs:
- name: Export FVM settings as environment variables
uses: kuhnroyal/flutter-fvm-config-action@v1
-
+
- uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
diff --git a/docker-compose.yml b/docker-compose.yml
index 53e529fa..75d7942d 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -4,4 +4,4 @@ services:
tests:
build:
context: .
- dockerfile: docker/Dockerfile
\ No newline at end of file
+ dockerfile: docker/Dockerfile
diff --git a/melos.yaml b/melos.yaml
index 0a711578..28b1e1f7 100644
--- a/melos.yaml
+++ b/melos.yaml
@@ -15,10 +15,10 @@ scripts:
run: fvm dart run melos exec --scope="${SCOPE:-*}" -c 1 --fail-fast -- 'fvm dart test --coverage="coverage"'
format:
- run: fvm dart run melos exec --scope="${SCOPE:-*}" -c 1 --fail-fast -- 'fvm dart format --set-exit-if-changed .'
+ run: fvm dart run melos exec --scope="${SCOPE:-*}" -c 1 --fail-fast -- 'fvm dart format .'
analyze:
- run: fvm dart run melos exec --scope="${SCOPE:-*}" -c 1 --fail-fast -- 'fvm dart analyze .'
+ run: fvm dart run melos exec --scope="${SCOPE:-*}" -c 1 --fail-fast -- 'fvm dart analyze --fatal-infos .'
# CI commands
# OBS: CI we do not use FVM
@@ -29,4 +29,4 @@ scripts:
run: dart run melos exec --scope="${SCOPE:-*}" -c 1 --fail-fast -- 'dart format --set-exit-if-changed .'
analyze:ci:
- run: dart run melos exec --scope="${SCOPE:-*}" -c 1 --fail-fast -- 'dart analyze .'
\ No newline at end of file
+ run: dart run melos exec --scope="${SCOPE:-*}" -c 1 --fail-fast -- 'dart analyze --fatal-infos .'
\ No newline at end of file
diff --git a/packages/polkadart/example/polkadart_example.dart b/packages/polkadart/example/polkadart_example.dart
index 90ed9900..e9fe19f1 100644
--- a/packages/polkadart/example/polkadart_example.dart
+++ b/packages/polkadart/example/polkadart_example.dart
@@ -1,7 +1,7 @@
import 'package:polkadart/polkadart.dart' show Provider, StateApi;
void main() async {
- final polkadart = Provider(Uri.parse('wss://kusama-rpc.polkadot.io'));
+ final polkadart = Provider.fromUri(Uri.parse('wss://kusama-rpc.polkadot.io'));
final api = StateApi(polkadart);
final runtimeVersion = await api.getRuntimeVersion();
print(runtimeVersion.toJson());
diff --git a/packages/polkadart/lib/apis/apis.dart b/packages/polkadart/lib/apis/apis.dart
index d76ffdf8..f3a2c80e 100644
--- a/packages/polkadart/lib/apis/apis.dart
+++ b/packages/polkadart/lib/apis/apis.dart
@@ -5,10 +5,14 @@ import 'dart:async' show Future, StreamSubscription;
import 'package:convert/convert.dart' show hex;
import '../primitives/primitives.dart'
show
- RuntimeVersion,
- RuntimeMetadata,
BlockHash,
+ ChainType,
+ Health,
KeyValue,
+ RuntimeVersion,
+ RuntimeMetadata,
+ PeerInfo,
+ SyncState,
StorageKey,
StorageData,
StorageChangeSet,
@@ -16,3 +20,4 @@ import '../primitives/primitives.dart'
import '../../provider.dart' show Provider;
part './state.dart';
+part './system.dart';
diff --git a/packages/polkadart/lib/apis/state.dart b/packages/polkadart/lib/apis/state.dart
index 3bbd86d3..3518fa3e 100644
--- a/packages/polkadart/lib/apis/state.dart
+++ b/packages/polkadart/lib/apis/state.dart
@@ -13,8 +13,8 @@ class StateApi
{
if (at != null) {
params.add('0x${hex.encode(at)}');
}
- final result = await _provider.send('state_call', params);
- final data = result.result as String;
+ final response = await _provider.send('state_call', params);
+ final data = response.result as String;
return Uint8List.fromList(hex.decode(data.substring(2)));
}
@@ -63,8 +63,8 @@ class StateApi
{
if (at != null) {
params.add('0x${hex.encode(at)}');
}
- final result = await _provider.send('state_getStorage', params);
- final data = result.result as String?;
+ final response = await _provider.send('state_getStorage', params);
+ final data = response.result as String?;
return data == null
? null
: Uint8List.fromList(hex.decode(data.substring(2)));
@@ -76,8 +76,8 @@ class StateApi
{
if (at != null) {
params.add('0x${hex.encode(at)}');
}
- final result = await _provider.send('state_getStorageHash', params);
- final data = result.result as String?;
+ final response = await _provider.send('state_getStorageHash', params);
+ final data = response.result as String?;
return data == null
? null
: Uint8List.fromList(hex.decode(data.substring(2)));
diff --git a/packages/polkadart/lib/apis/system.dart b/packages/polkadart/lib/apis/system.dart
new file mode 100644
index 00000000..5cfec274
--- /dev/null
+++ b/packages/polkadart/lib/apis/system.dart
@@ -0,0 +1,153 @@
+part of apis;
+
+/// Substrate system RPC API
+class SystemApi
{
+ final P _provider;
+
+ const SystemApi(this._provider);
+
+ /// Get the node's implementation name. Plain old string.
+ Future name() async {
+ final response = await _provider.send('system_name', []);
+ return response.result as String;
+ }
+
+ /// Get the node implementation's version. Should be a semver string.
+ Future version() async {
+ final response = await _provider.send('system_version', []);
+ return response.result as String;
+ }
+
+ /// Get the chain's name. Given as a string identifier.
+ Future chain() async {
+ final response = await _provider.send('system_chain', []);
+ return response.result as String;
+ }
+
+ /// Get the chain's type.
+ Future chainType() async {
+ final response = await _provider.send('system_chainType', []);
+ return ChainType.fromJson(response.result);
+ }
+
+ /// Return health status of the node.
+ ///
+ /// Node is considered healthy if it is:
+ /// - connected to some peers (unless running in dev mode)
+ /// - not performing a major sync
+ Future health() async {
+ final response = await _provider.send('system_health', []);
+ return Health.fromJson(response.result as Map);
+ }
+
+ /// Returns the base58-encoded PeerId of the node.
+ Future localPeerId() async {
+ final response = await _provider.send('system_localPeerId', []);
+ return response.result as String;
+ }
+
+ /// Returns the multi-addresses that the local node is listening on
+ ///
+ /// The addresses include a trailing `/p2p/` with the local PeerId, and are thus suitable to
+ /// be passed to `addReservedPeer` or as a bootnode address for example.
+ Future> localListenAddresses() async {
+ final response = await _provider.send('system_localListenAddresses', []);
+ return (response.result as List).cast().toList();
+ }
+
+ /// Returns currently connected peers
+ ///
+ /// unsafe: This method is only active with appropriate flags
+ Future>> peers() async {
+ final response = await _provider.send('system_peers', []);
+ return (response.result as List)
+ .cast