Skip to content

Commit

Permalink
Merge pull request #29 from polkawallet-io/develop
Browse files Browse the repository at this point in the history
Release 0.4.9
  • Loading branch information
RomeroYang authored Aug 8, 2022
2 parents f3fbb20 + ec57669 commit cc7d6bb
Show file tree
Hide file tree
Showing 93 changed files with 21,173 additions and 5,515 deletions.
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
js_api/.yarn/releases/** binary
js_api/.yarn/plugins/** binary
js_api/dist/** binary
assets/*.js binary
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ app.*.map.json
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages

js_api/node_modules/
js_api/dist/main.js.LICENSE.txt
js_api/.yarn/*
!js_api/.yarn/patches
!js_api/.yarn/plugins
!js_api/.yarn/releases
!js_api/.yarn/sdks
!js_api/.yarn/versions

js_api/dist/*.js.LICENSE.txt

js_as_extension/node_modules/
js_api_eth/node_modules/
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## [0.4.9] - 20220808

* add bridge api
* fix DApp browser request parsing with unknown address format

## [0.4.8] - 20220621

* upgrade flutter 3.0.1
Expand Down
9 changes: 9 additions & 0 deletions assets/bridge.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<html>
<head>
<meta charset="utf-8" />
<script type="application/javascript" src="bridge.js"></script>
</head>
<body>
<h1>polkawallet bridge js runner</h1>
</body>
</html>
329 changes: 329 additions & 0 deletions assets/bridge.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions assets/index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<html>
<head>
<meta charset="utf-8" />
<script type="application/javascript" src="index.js"></script>
</head>
<body>
<h1>polkadot-js/api runner</h1>
</body>
Expand Down
2 changes: 2 additions & 0 deletions assets/index.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
targets:
$default:
sources:
- lib/**
19 changes: 1 addition & 18 deletions example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,16 @@
additional functionality it is fine to subclass or reimplement
FlutterApplication and put your custom class here. -->
<application
android:name="${applicationName}"
android:label="example"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
to determine the Window background behind the Flutter UI. -->
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
Expand Down
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buildscript {
ext.kotlin_version = '1.3.50'
ext.kotlin_version = '1.6.10'
repositories {
google()
jcenter()
Expand Down
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
android.enableR8=true
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
26 changes: 25 additions & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ 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';
import 'package:polkawallet_sdk/storage/keyringEVM.dart';
import 'package:polkawallet_sdk_example/pages/account.dart';
import 'package:polkawallet_sdk_example/pages/dAppPage.dart';
import 'package:polkawallet_sdk_example/pages/ethWithJS.dart';
import 'package:polkawallet_sdk_example/pages/evm.dart';
import 'package:polkawallet_sdk_example/pages/keyring.dart';
import 'package:polkawallet_sdk_example/pages/setting.dart';
import 'package:polkawallet_sdk_example/pages/tx.dart';
Expand All @@ -23,11 +26,13 @@ class MyApp extends StatefulWidget {
class _MyAppState extends State<MyApp> {
final WalletSDK sdk = WalletSDK();
final Keyring keyring = Keyring();
final KeyringEVM keyringEVM = KeyringEVM();

bool _sdkReady = false;

Future<void> _initApi() async {
await keyring.init([0, 2]);
await keyringEVM.init();

await sdk.init(keyring);
setState(() {
Expand Down Expand Up @@ -77,6 +82,8 @@ class _MyAppState extends State<MyApp> {
AccountPage.route: (_) => AccountPage(sdk, _showResult),
TxPage.route: (_) => TxPage(sdk, keyring, _showResult),
StakingPage.route: (_) => StakingPage(sdk, keyring, _showResult),
EVMPage.route: (_) => EVMPage(sdk, keyringEVM, _showResult),
EthWithJSPage.route: (_) => EthWithJSPage(sdk, keyringEVM, _showResult),
},
);
}
Expand Down Expand Up @@ -145,7 +152,7 @@ class _MyHomePageState extends State<MyHomePage> {
child: _connecting
? CupertinoActivityIndicator()
: Text(_apiConnected
? 'connected ${widget.sdk.api.connectedNode.name}'
? 'connected ${widget.sdk.api.connectedNode?.name}'
: 'connect'),
onPressed: _apiConnected || _connecting
? null
Expand Down Expand Up @@ -217,6 +224,23 @@ class _MyHomePageState extends State<MyHomePage> {
Navigator.of(context).pushNamed(StakingPage.route);
},
),
Divider(),
ListTile(
title: Text('ethers'),
subtitle: Text('ethers keyring'),
onTap: () {
Navigator.of(context).pushNamed(EVMPage.route);
},
),
Divider(),
ListTile(
title: Text('sdk.eth'),
subtitle: Text('eth js keyring'),
onTap: () {
Navigator.of(context).pushNamed(EthWithJSPage.route);
},
),
Divider(),
],
),
), // This trailing comma makes auto-formatting nicer for build methods.
Expand Down
22 changes: 10 additions & 12 deletions example/lib/pages/account.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import 'dart:convert';

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:polkawallet_sdk/polkawallet_sdk.dart';
import 'package:polkawallet_sdk/api/types/balanceData.dart';
import 'package:polkawallet_sdk/polkawallet_sdk.dart';
import 'package:polkawallet_sdk_example/pages/keyring.dart';

class AccountPage extends StatefulWidget {
Expand All @@ -28,14 +27,14 @@ class _AccountPageState extends State<AccountPage> {

bool _submitting = false;

BalanceData _balance;
String _msgChannel;
BalanceData? _balance;
String? _msgChannel;

Future<void> _encodeAddress() async {
setState(() {
_submitting = true;
});
final Map res = await widget.sdk.api.account.encodeAddress([_testPubKey]);
final res = await widget.sdk.api.account.encodeAddress([_testPubKey]);
widget.showResult(
context,
'encodeAddress',
Expand All @@ -50,7 +49,7 @@ class _AccountPageState extends State<AccountPage> {
setState(() {
_submitting = true;
});
final Map res = await widget.sdk.api.account.decodeAddress([_testAddress]);
final res = await widget.sdk.api.account.decodeAddress([_testAddress]);
widget.showResult(
context,
'decodeAddress',
Expand All @@ -65,7 +64,7 @@ class _AccountPageState extends State<AccountPage> {
setState(() {
_submitting = true;
});
final List res = await widget.sdk.api.account.getPubKeyIcons([_testPubKey]);
final res = await widget.sdk.api.account.getPubKeyIcons([_testPubKey]);
widget.showResult(
context, 'getPubKeyIcons', JsonEncoder.withIndent(' ').convert(res));
setState(() {
Expand All @@ -77,8 +76,7 @@ class _AccountPageState extends State<AccountPage> {
setState(() {
_submitting = true;
});
final List res =
await widget.sdk.api.account.getAddressIcons([_testAddress]);
final res = await widget.sdk.api.account.getAddressIcons([_testAddress]);
widget.showResult(
context, 'getAddressIcons', JsonEncoder.withIndent(' ').convert(res));
setState(() {
Expand All @@ -90,7 +88,7 @@ class _AccountPageState extends State<AccountPage> {
setState(() {
_submitting = true;
});
final List res = await widget.sdk.api.account
final res = await widget.sdk.api.account
.queryIndexInfo([_testAddress, _testAddressGav]);
widget.showResult(
context, 'queryIndexInfo', JsonEncoder.withIndent(' ').convert(res));
Expand All @@ -105,7 +103,7 @@ class _AccountPageState extends State<AccountPage> {
});
final res = await widget.sdk.api.account.queryBalance(_testAddress);
widget.showResult(context, 'queryBalance',
JsonEncoder.withIndent(' ').convert(res.toJson()));
JsonEncoder.withIndent(' ').convert(res?.toJson()));
setState(() {
_submitting = false;
});
Expand Down Expand Up @@ -139,7 +137,7 @@ class _AccountPageState extends State<AccountPage> {
@override
void dispose() {
if (_msgChannel != null) {
widget.sdk.api.unsubscribeMessage(_msgChannel);
widget.sdk.api.unsubscribeMessage(_msgChannel!);
}
super.dispose();
}
Expand Down
2 changes: 1 addition & 1 deletion example/lib/pages/dAppPage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class _DAppPageState extends State<DAppPage> {

@override
Widget build(BuildContext context) {
final String url = ModalRoute.of(context).settings.arguments;
final url = ModalRoute.of(context)?.settings.arguments as String;
return Scaffold(
appBar: AppBar(
title: Text(
Expand Down
Loading

0 comments on commit cc7d6bb

Please sign in to comment.