Hello substrate sandbox: Successfully connected to local duniter v2s node; Best bloc realtime subscription
This commit is contained in:
parent
acf0e8f29b
commit
3513b0440d
|
@ -45,8 +45,8 @@ android {
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
|
||||||
applicationId "gecko.axiomteam.fr"
|
applicationId "gecko.axiomteam.fr"
|
||||||
minSdkVersion 16
|
minSdkVersion 19
|
||||||
targetSdkVersion 30
|
targetSdkVersion 31
|
||||||
versionCode flutterVersionCode.toInteger()
|
versionCode flutterVersionCode.toInteger()
|
||||||
versionName flutterVersionName
|
versionName flutterVersionName
|
||||||
multiDexEnabled true
|
multiDexEnabled true
|
||||||
|
|
|
@ -9,9 +9,12 @@
|
||||||
<uses-permission android:name="android.permission.CAMERA" />
|
<uses-permission android:name="android.permission.CAMERA" />
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||||
<application android:requestLegacyExternalStorage="true"
|
<application
|
||||||
|
android:requestLegacyExternalStorage="true"
|
||||||
android:name="${applicationName}"
|
android:name="${applicationName}"
|
||||||
android:label="Ğecko">
|
android:label="Ğecko"
|
||||||
|
android:usesCleartextTraffic="true">
|
||||||
|
<!-- TODO: Remove usesCleartextTraffic for production mode ! kopa -->
|
||||||
<!-- android:icon="@mipmap/ic_launcher"> -->
|
<!-- android:icon="@mipmap/ic_launcher"> -->
|
||||||
<activity
|
<activity
|
||||||
android:requestLegacyExternalStorage="true"
|
android:requestLegacyExternalStorage="true"
|
||||||
|
|
|
@ -25,6 +25,7 @@ import 'package:gecko/models/chest_data.dart';
|
||||||
import 'package:gecko/providers/chest_provider.dart';
|
import 'package:gecko/providers/chest_provider.dart';
|
||||||
import 'package:gecko/models/g1_wallets_list.dart';
|
import 'package:gecko/models/g1_wallets_list.dart';
|
||||||
import 'package:gecko/providers/generate_wallets.dart';
|
import 'package:gecko/providers/generate_wallets.dart';
|
||||||
|
import 'package:gecko/providers/substrate_sdk.dart';
|
||||||
import 'package:gecko/providers/wallets_profiles.dart';
|
import 'package:gecko/providers/wallets_profiles.dart';
|
||||||
import 'package:gecko/providers/home.dart';
|
import 'package:gecko/providers/home.dart';
|
||||||
import 'package:gecko/providers/my_wallets.dart';
|
import 'package:gecko/providers/my_wallets.dart';
|
||||||
|
@ -154,7 +155,8 @@ class Gecko extends StatelessWidget {
|
||||||
ChangeNotifierProvider(create: (_) => WalletOptionsProvider()),
|
ChangeNotifierProvider(create: (_) => WalletOptionsProvider()),
|
||||||
ChangeNotifierProvider(create: (_) => ChangePinProvider()),
|
ChangeNotifierProvider(create: (_) => ChangePinProvider()),
|
||||||
ChangeNotifierProvider(create: (_) => SearchProvider()),
|
ChangeNotifierProvider(create: (_) => SearchProvider()),
|
||||||
ChangeNotifierProvider(create: (_) => CesiumPlusProvider())
|
ChangeNotifierProvider(create: (_) => CesiumPlusProvider()),
|
||||||
|
ChangeNotifierProvider(create: (_) => SubstrateSdk())
|
||||||
],
|
],
|
||||||
child: GraphQLProvider(
|
child: GraphQLProvider(
|
||||||
client: _client,
|
client: _client,
|
||||||
|
@ -178,8 +180,8 @@ class Gecko extends StatelessWidget {
|
||||||
),
|
),
|
||||||
primaryColor: const Color(0xffFFD58D),
|
primaryColor: const Color(0xffFFD58D),
|
||||||
textTheme: const TextTheme(
|
textTheme: const TextTheme(
|
||||||
bodyText1: TextStyle(),
|
bodyText1: TextStyle(fontSize: 20),
|
||||||
bodyText2: TextStyle(),
|
bodyText2: TextStyle(fontSize: 18),
|
||||||
).apply(
|
).apply(
|
||||||
bodyColor: const Color(0xFF000000),
|
bodyColor: const Color(0xFF000000),
|
||||||
),
|
),
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:polkawallet_sdk/api/types/networkParams.dart';
|
||||||
|
import 'package:polkawallet_sdk/polkawallet_sdk.dart';
|
||||||
|
import 'package:polkawallet_sdk/storage/keyring.dart';
|
||||||
|
|
||||||
|
class SubstrateSdk with ChangeNotifier {
|
||||||
|
final String subNode = '192.168.1.85:9944';
|
||||||
|
final bool isSsl = false;
|
||||||
|
|
||||||
|
final WalletSDK sdk = WalletSDK();
|
||||||
|
final Keyring keyring = Keyring();
|
||||||
|
bool sdkReady = false;
|
||||||
|
bool nodeConnected = false;
|
||||||
|
int blocNumber = 0;
|
||||||
|
|
||||||
|
Future<void> initApi() async {
|
||||||
|
await keyring.init([0, 2]);
|
||||||
|
|
||||||
|
await sdk.init(keyring);
|
||||||
|
sdkReady = true;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> connectNode() async {
|
||||||
|
final String socketKind = isSsl ? 'wss' : 'ws';
|
||||||
|
final node = NetworkParams();
|
||||||
|
node.name = 'pokaniter';
|
||||||
|
node.endpoint = '$socketKind://$subNode';
|
||||||
|
node.ss58 = 42;
|
||||||
|
final res = await sdk.api.connectNode(keyring, [node]).timeout(
|
||||||
|
const Duration(seconds: 10),
|
||||||
|
onTimeout: () => null,
|
||||||
|
);
|
||||||
|
if (res != null) {
|
||||||
|
nodeConnected = true;
|
||||||
|
notifyListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Subscribe bloc number
|
||||||
|
sdk.api.setting.subscribeBestNumber((res) {
|
||||||
|
blocNumber = int.parse(res.toString());
|
||||||
|
notifyListeners();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -12,6 +12,7 @@ import 'package:gecko/screens/onBoarding/1.dart';
|
||||||
import 'package:gecko/screens/search.dart';
|
import 'package:gecko/screens/search.dart';
|
||||||
import 'package:gecko/screens/settings.dart';
|
import 'package:gecko/screens/settings.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:gecko/screens/substrate_sandbox.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class HomeScreen extends StatelessWidget {
|
class HomeScreen extends StatelessWidget {
|
||||||
|
@ -176,9 +177,28 @@ Widget geckHome(context) {
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
)
|
),
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
|
const SizedBox(height: 15),
|
||||||
|
Row(mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[
|
||||||
|
ElevatedButton(
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
primary: yellowC, // background
|
||||||
|
onPrimary: Colors.black, // foreground
|
||||||
|
),
|
||||||
|
onPressed: () => Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(builder: (context) {
|
||||||
|
return const SubstrateSandBox();
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
child: const Text(
|
||||||
|
'SUBSTRATE SANDBOX',
|
||||||
|
style: TextStyle(fontSize: 20),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]),
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 1,
|
flex: 1,
|
||||||
child: Container(
|
child: Container(
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:gecko/globals.dart';
|
||||||
|
import 'package:gecko/providers/substrate_sdk.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
|
class SubstrateSandBox extends StatelessWidget {
|
||||||
|
const SubstrateSandBox({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
SubstrateSdk _sub = Provider.of<SubstrateSdk>(context, listen: false);
|
||||||
|
|
||||||
|
return StatefulWrapper(
|
||||||
|
onInit: () async {
|
||||||
|
await _sub.initApi();
|
||||||
|
await _sub.connectNode();
|
||||||
|
},
|
||||||
|
child: Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
|
toolbarHeight: 60 * ratio,
|
||||||
|
title: const SizedBox(
|
||||||
|
height: 22,
|
||||||
|
child: Text('Substrate Sandbox'),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
body: SafeArea(
|
||||||
|
child: Consumer<SubstrateSdk>(builder: (context, _sub, _) {
|
||||||
|
return Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: <Widget>[
|
||||||
|
Text('js-api chargé ?: ${_sub.sdkReady}'),
|
||||||
|
Text(
|
||||||
|
'Noeud connecté ?: ${_sub.nodeConnected} (${_sub.subNode})'),
|
||||||
|
if (_sub.nodeConnected)
|
||||||
|
Text('Numéro de bloc: ${_sub.blocNumber}'),
|
||||||
|
]);
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class StatefulWrapper extends StatefulWidget {
|
||||||
|
final Function onInit;
|
||||||
|
final Widget child;
|
||||||
|
const StatefulWrapper({Key? key, required this.onInit, required this.child})
|
||||||
|
: super(key: key);
|
||||||
|
@override
|
||||||
|
_StatefulWrapperState createState() => _StatefulWrapperState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _StatefulWrapperState extends State<StatefulWrapper> {
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
widget.onInit();
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return widget.child;
|
||||||
|
}
|
||||||
|
}
|
112
pubspec.lock
112
pubspec.lock
|
@ -8,6 +8,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "30.0.0"
|
version: "30.0.0"
|
||||||
|
aes_ecb_pkcs5_flutter:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: aes_ecb_pkcs5_flutter
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.1.2"
|
||||||
analyzer:
|
analyzer:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -43,6 +50,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.8.2"
|
version: "2.8.2"
|
||||||
|
auth_header:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: auth_header
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "3.0.1"
|
||||||
barcode:
|
barcode:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -347,6 +361,13 @@ packages:
|
||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
flutter_inappwebview:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: flutter_inappwebview
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "5.3.2"
|
||||||
flutter_launcher_icons:
|
flutter_launcher_icons:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -404,6 +425,20 @@ packages:
|
||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
get:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: get
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "4.6.1"
|
||||||
|
get_storage:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: get_storage
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.3"
|
||||||
glob:
|
glob:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -530,6 +565,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "4.0.0"
|
version: "4.0.0"
|
||||||
|
http_server:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: http_server
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.0"
|
||||||
image:
|
image:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -591,6 +633,27 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.3"
|
version: "1.0.3"
|
||||||
|
jaguar:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: jaguar
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "3.0.12"
|
||||||
|
jaguar_common:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: jaguar_common
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "3.0.0"
|
||||||
|
jaguar_flutter_asset:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: jaguar_flutter_asset
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "3.0.0"
|
||||||
jdenticon_dart:
|
jdenticon_dart:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -668,6 +731,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.1"
|
version: "1.0.1"
|
||||||
|
mobx:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: mobx
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.6+1"
|
||||||
nested:
|
nested:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -815,6 +885,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.3"
|
version: "2.0.3"
|
||||||
|
path_tree:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: path_tree
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "3.0.0"
|
||||||
pdf:
|
pdf:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -885,6 +962,13 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "3.4.0"
|
version: "3.4.0"
|
||||||
|
polkawallet_sdk:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: polkawallet_sdk
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.4.1"
|
||||||
pool:
|
pool:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -1258,6 +1342,34 @@ packages:
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.0.0"
|
version: "1.0.0"
|
||||||
|
webview_flutter:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: webview_flutter
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.8.0"
|
||||||
|
webview_flutter_android:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: webview_flutter_android
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.8.3"
|
||||||
|
webview_flutter_platform_interface:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: webview_flutter_platform_interface
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "1.8.0"
|
||||||
|
webview_flutter_wkwebview:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: webview_flutter_wkwebview
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "2.7.1"
|
||||||
win32:
|
win32:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
|
@ -72,6 +72,7 @@ dependencies:
|
||||||
desktop_window: ^0.4.0
|
desktop_window: ^0.4.0
|
||||||
durt: ^0.1.6
|
durt: ^0.1.6
|
||||||
package_info_plus: ^1.3.0
|
package_info_plus: ^1.3.0
|
||||||
|
polkawallet_sdk: ^0.4.1
|
||||||
|
|
||||||
flutter_icons:
|
flutter_icons:
|
||||||
android: "ic_launcher"
|
android: "ic_launcher"
|
||||||
|
|
Loading…
Reference in New Issue