diff --git a/README.md b/README.md index 5295303..897b418 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ A digital wallet app, developed in dart language and flutter framework. The idea - [QR code scanner](https://github.com/juliuscanute/qr_code_scanner) to scan addresses - [Web3Dart](https://github.com/simolus3/web3dart) to interact with Ethereum blockchain - [Flutter hooks](https://github.com/rrousselGit/flutter_hooks) to manage widget life-cycle. +- [Solidity](https://github.com/allanclempe/ether-wallet-contract) smart contract | Wallet | Change network | Transfer tokens | | :--------------------------------------------------------------: | :-------------------------------------------------------------------: | :----------------------------------------------------------------------: | @@ -30,6 +31,12 @@ $ flutter packages pub run build_runner build $ flutter run ``` +running on the browser + +```bash +$ flutter run -d chrome +``` + How to run tests ```bash @@ -48,9 +55,11 @@ After setting up your wallet, you will need some tokens to play with. Use the li **_Transfer test Ether to your wallet_** -Also to process transactions on the network, you will also need ETH to pay transaction fees, called gas. You also can claim some using the link below. +To process transactions on the network, you will also need ETH to pay transaction fees, called gas. You also can claim some to test your wallet. Each network has its own faucet. -[https://faucet.ropsten.be/](https://faucet.ropsten.be/) +- Ropsten: [https://faucet.ropsten.be/](https://faucet.ropsten.be/) +- Polygon (old MATIC): [https://faucet.polygon.technology/](https://faucet.polygon.technology/) +- BSC: [https://testnet.binance.org/faucet-smart](https://testnet.binance.org/faucet-smart) just be patient, the transaction might take a while to be processed. @@ -58,6 +67,7 @@ just be patient, the transaction might take a while to be processed. Feel free to check out the smart contract used in this project [https://github.com/allanclempe/ether-wallet-contract](https://github.com/allanclempe/ether-wallet-contract) + ### Buy me a coffee If you enjoy my work, a small donation would be greatly appreciated. diff --git a/android/app/src/main/res/drawable-v21/launch_background.xml b/android/app/src/main/res/drawable-v21/launch_background.xml new file mode 100644 index 0000000..f74085f --- /dev/null +++ b/android/app/src/main/res/drawable-v21/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/android/app/src/main/res/values-night/styles.xml b/android/app/src/main/res/values-night/styles.xml new file mode 100644 index 0000000..449a9f9 --- /dev/null +++ b/android/app/src/main/res/values-night/styles.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/lib/components/form/paper_form.dart b/lib/components/form/paper_form.dart index 752e995..6d69258 100644 --- a/lib/components/form/paper_form.dart +++ b/lib/components/form/paper_form.dart @@ -12,12 +12,15 @@ class PaperForm extends StatelessWidget { @override Widget build(BuildContext context) { return Form( - child: Padding( - padding: EdgeInsets.all(padding), - child: Column(children: [ - ...children, - ..._buildButtons(), - ]), + child: Container( + constraints: const BoxConstraints(maxWidth: 480), + child: Padding( + padding: EdgeInsets.all(padding), + child: Column(children: [ + ...children, + ..._buildButtons(), + ]), + ), ), ); } diff --git a/lib/components/wallet/balance.dart b/lib/components/wallet/balance.dart index 726afe1..1955f4a 100644 --- a/lib/components/wallet/balance.dart +++ b/lib/components/wallet/balance.dart @@ -2,6 +2,7 @@ import 'package:etherwallet/components/copyButton/copy_button.dart'; import 'package:etherwallet/utils/eth_amount_formatter.dart'; import 'package:flutter/material.dart'; import 'package:qr_flutter/qr_flutter.dart'; +import 'package:flutter/foundation.dart' show kIsWeb; class Balance extends StatelessWidget { const Balance({ @@ -31,7 +32,8 @@ class Balance extends StatelessWidget { text: const Text('Copy address'), value: address, ), - if (address != null && mediaQuery.orientation == Orientation.portrait) + if (address != null && + (mediaQuery.orientation == Orientation.portrait || kIsWeb)) QrImage( data: address!, size: 150.0, diff --git a/lib/components/wallet/display_mnemonic.dart b/lib/components/wallet/display_mnemonic.dart index 5e19fee..98c33db 100644 --- a/lib/components/wallet/display_mnemonic.dart +++ b/lib/components/wallet/display_mnemonic.dart @@ -14,6 +14,7 @@ class DisplayMnemonic extends HookWidget { Widget build(BuildContext context) { return Center( child: Container( + constraints: const BoxConstraints(maxWidth: 420), margin: const EdgeInsets.all(25), child: SingleChildScrollView( child: Column( diff --git a/lib/service/contract_locator.dart b/lib/service/contract_locator.dart index 72f95b6..f9fc428 100644 --- a/lib/service/contract_locator.dart +++ b/lib/service/contract_locator.dart @@ -5,6 +5,8 @@ import 'package:etherwallet/utils/contract_parser.dart'; import 'package:web3dart/web3dart.dart'; import 'package:web_socket_channel/io.dart'; import 'package:http/http.dart'; +import 'package:web_socket_channel/web_socket_channel.dart'; +import 'package:flutter/foundation.dart' show kIsWeb; class ContractLocator { ContractLocator._(); @@ -29,7 +31,13 @@ class ContractLocator { final wsAddress = networkConfig.web3RdpUrl; final client = Web3Client(networkConfig.web3HttpUrl, Client(), socketConnector: wsAddress != null - ? () => IOWebSocketChannel.connect(wsAddress).cast() + ? () { + if (kIsWeb) + return WebSocketChannel.connect(Uri.parse(wsAddress)) + .cast(); + + return IOWebSocketChannel.connect(wsAddress).cast(); + } : null); final contract = await ContractParser.fromAssets( diff --git a/lib/wallet_transfer_page.dart b/lib/wallet_transfer_page.dart index 9e4a406..954a792 100644 --- a/lib/wallet_transfer_page.dart +++ b/lib/wallet_transfer_page.dart @@ -3,6 +3,7 @@ import 'package:etherwallet/context/transfer/wallet_transfer_provider.dart'; import 'package:etherwallet/model/network_type.dart'; import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; +import 'package:flutter/foundation.dart' show kIsWeb; import 'components/wallet/loading.dart'; @@ -26,19 +27,20 @@ class WalletTransferPage extends HookWidget { appBar: AppBar( title: Text(title), actions: [ - IconButton( - icon: const Icon(Icons.camera_alt), - onPressed: !transferStore.state.loading - ? () { - Navigator.of(context).pushNamed( - '/qrcode_reader', - arguments: (scannedAddress) { - qrcodeAddress.value = scannedAddress.toString(); - }, - ); - } - : null, - ), + if (!kIsWeb) + IconButton( + icon: const Icon(Icons.camera_alt), + onPressed: !transferStore.state.loading + ? () { + Navigator.of(context).pushNamed( + '/qrcode_reader', + arguments: (scannedAddress) { + qrcodeAddress.value = scannedAddress.toString(); + }, + ); + } + : null, + ), ], ), body: transferStore.state.loading diff --git a/pubspec.lock b/pubspec.lock index 42beb9c..b55eb09 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -231,7 +231,7 @@ packages: name: firebase_analytics url: "https://pub.dartlang.org" source: hosted - version: "8.0.4" + version: "8.2.0" firebase_analytics_platform_interface: dependency: transitive description: @@ -252,7 +252,7 @@ packages: name: firebase_core url: "https://pub.dartlang.org" source: hosted - version: "1.1.1" + version: "1.4.0" firebase_core_platform_interface: dependency: transitive description: @@ -266,7 +266,7 @@ packages: name: firebase_core_web url: "https://pub.dartlang.org" source: hosted - version: "1.0.3" + version: "1.1.0" fixnum: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 1cd03c5..d087a3a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -18,7 +18,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 2.1.0+8 +version: 2.2.0+9 environment: sdk: ">=2.12.0 <3.0.0" @@ -41,7 +41,7 @@ dependencies: intl: ^0.16.1 flutter_spinkit: ^5.0.0 qr_code_scanner: ^0.4.0 - firebase_analytics: ^8.0.4 + firebase_analytics: ^8.2.0 url_launcher: ^6.0.2 flutter_hooks: ^0.16.0 built_value: ^8.0.6 diff --git a/web/favicon.png b/web/favicon.png new file mode 100644 index 0000000..8aaa46a Binary files /dev/null and b/web/favicon.png differ diff --git a/web/icons/Icon-192.png b/web/icons/Icon-192.png new file mode 100644 index 0000000..b749bfe Binary files /dev/null and b/web/icons/Icon-192.png differ diff --git a/web/icons/Icon-512.png b/web/icons/Icon-512.png new file mode 100644 index 0000000..88cfd48 Binary files /dev/null and b/web/icons/Icon-512.png differ diff --git a/web/index.html b/web/index.html new file mode 100644 index 0000000..2f57ea8 --- /dev/null +++ b/web/index.html @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + etherwallet + + + + + + + + + + + + + + + diff --git a/web/manifest.json b/web/manifest.json new file mode 100644 index 0000000..c1a121f --- /dev/null +++ b/web/manifest.json @@ -0,0 +1,23 @@ +{ + "name": "etherwallet", + "short_name": "etherwallet", + "start_url": ".", + "display": "standalone", + "background_color": "#0175C2", + "theme_color": "#0175C2", + "description": "Ethereum wallet using an ERC-20 smart contract.", + "orientation": "portrait-primary", + "prefer_related_applications": false, + "icons": [ + { + "src": "icons/Icon-192.png", + "sizes": "192x192", + "type": "image/png" + }, + { + "src": "icons/Icon-512.png", + "sizes": "512x512", + "type": "image/png" + } + ] +}