diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index ced12a7..1388937 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -2,6 +2,9 @@ PODS: - Flutter (1.0.0) - flutter_native_splash (0.0.1): - Flutter + - fluttertoast (0.0.2): + - Flutter + - Toast - passkeys_ios (0.0.1): - Flutter - path_provider_foundation (0.0.1): @@ -10,6 +13,7 @@ PODS: - shared_preferences_foundation (0.0.1): - Flutter - FlutterMacOS + - Toast (4.1.0) - ua_client_hints (1.2.2): - Flutter - web3_signers (0.0.1): @@ -18,17 +22,24 @@ PODS: DEPENDENCIES: - Flutter (from `Flutter`) - flutter_native_splash (from `.symlinks/plugins/flutter_native_splash/ios`) + - fluttertoast (from `.symlinks/plugins/fluttertoast/ios`) - passkeys_ios (from `.symlinks/plugins/passkeys_ios/ios`) - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`) - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`) - ua_client_hints (from `.symlinks/plugins/ua_client_hints/ios`) - web3_signers (from `.symlinks/plugins/web3_signers/ios`) +SPEC REPOS: + trunk: + - Toast + EXTERNAL SOURCES: Flutter: :path: Flutter flutter_native_splash: :path: ".symlinks/plugins/flutter_native_splash/ios" + fluttertoast: + :path: ".symlinks/plugins/fluttertoast/ios" passkeys_ios: :path: ".symlinks/plugins/passkeys_ios/ios" path_provider_foundation: @@ -43,9 +54,11 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 flutter_native_splash: 52501b97d1c0a5f898d687f1646226c1f93c56ef + fluttertoast: 31b00dabfa7fb7bacd9e7dbee580d7a2ff4bf265 passkeys_ios: fdae8c06e2178a9fcb9261a6cb21fb9a06a81d53 path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695 + Toast: ec33c32b8688982cecc6348adeae667c1b9938da ua_client_hints: 7f4e0f5d390685e8f7efd6eb363594f760108926 web3_signers: 5f49d582ab0d1fe673b3220aa6ecf25bb3cbed6b diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 64e1869..bc1d45b 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -216,7 +216,7 @@ isa = PBXProject; attributes = { BuildIndependentTargetsInParallel = YES; - LastUpgradeCheck = 1430; + LastUpgradeCheck = 1510; ORGANIZATIONNAME = ""; TargetAttributes = { 331C8080294A63A400263BE5 = { diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 87131a0..8e3ca5d 100644 --- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ (); diff --git a/example/lib/providers/wallet_provider.dart b/example/lib/providers/wallet_provider.dart index e1f134f..8f353e2 100644 --- a/example/lib/providers/wallet_provider.dart +++ b/example/lib/providers/wallet_provider.dart @@ -15,8 +15,11 @@ class WalletProvider extends ChangeNotifier { SmartWallet? _wallet; SmartWallet? get wallet => _wallet; + String _errorMessage = ""; + String get errorMessage => _errorMessage; + WalletProvider() - : _chain = Chains.getChain(Network.baseTestent) + : _chain = Chains.getChain(Network.baseTestnet) ..accountFactory = EthereumAddress.fromHex( "0x402A266e92993EbF04a5B3fd6F0e2b21bFC83070") ..bundlerUrl = @@ -50,6 +53,8 @@ class WalletProvider extends ChangeNotifier { log("wallet created ${_wallet?.address.hex} "); } catch (e) { + _errorMessage = e.toString(); + notifyListeners(); log("something happened: $e"); } } @@ -75,13 +80,15 @@ class WalletProvider extends ChangeNotifier { } } + Future mintNFt() async {} + Future sendTransaction(String recipient, String amount) async { if (_wallet != null) { final etherAmount = w3d.EtherAmount.fromBigInt(w3d.EtherUnit.wei, BigInt.from(double.parse(amount) * math.pow(10, 18))); final response = - await _wallet!.send(EthereumAddress.fromHex(recipient), etherAmount); - final receipt = await response.wait(); + await _wallet?.send(EthereumAddress.fromHex(recipient), etherAmount); + final receipt = await response?.wait(); log("Transaction receipt Hash: ${receipt?.userOpHash}"); } else { diff --git a/example/lib/screens/create_account.dart b/example/lib/screens/create_account.dart index 387cc42..d74cab2 100644 --- a/example/lib/screens/create_account.dart +++ b/example/lib/screens/create_account.dart @@ -1,8 +1,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:fluttertoast/fluttertoast.dart'; import 'package:provider/provider.dart'; +import 'package:variancedemo/main.dart'; import 'package:variancedemo/providers/wallet_provider.dart'; -import 'package:variancedemo/utils/widgets.dart'; class CreateAccountScreen extends StatefulWidget { const CreateAccountScreen({super.key}); @@ -14,6 +15,15 @@ class CreateAccountScreen extends StatefulWidget { class _CreateAccountScreenState extends State { final TextEditingController controller = TextEditingController(); final _formKey = GlobalKey(); + FToast? fToast; + + @override + void initState() { + super.initState(); + fToast = FToast(); + fToast?.init(context); + } + @override Widget build(BuildContext context) { return SafeArea( @@ -79,14 +89,17 @@ class _CreateAccountScreenState extends State { SizedBox( height: 45.h, child: TextButton( + key: globalScaffoldMessengerKey, onPressed: () async { - try { - await value.registerWithPassKey(controller.text, - requiresUserVerification: true); - // ignore: use_build_context_synchronously + await value.registerWithPassKey(controller.text, + requiresUserVerification: true); + // ignore: use_build_context_synchronously + if (value.errorMessage.isNotEmpty) { + fToast?.showToast( + gravity: ToastGravity.BOTTOM, + child: Text(value.errorMessage)); + } else { Navigator.pushNamed(context, '/home'); - } catch (e) { - showSnackbar(e.toString()); } }, style: TextButton.styleFrom( diff --git a/example/lib/screens/home/home_screen.dart b/example/lib/screens/home/home_screen.dart new file mode 100644 index 0000000..7f34217 --- /dev/null +++ b/example/lib/screens/home/home_screen.dart @@ -0,0 +1,123 @@ +import 'dart:developer'; +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:provider/provider.dart'; +import 'package:variancedemo/providers/wallet_provider.dart'; +import 'package:variancedemo/screens/home/home_widgets.dart'; +import 'package:variancedemo/utils/widgets.dart'; +import 'package:variancedemo/variance_colors.dart'; + +class WalletHome extends StatefulWidget { + const WalletHome({super.key}); + + @override + State createState() => _WalletHomeState(); +} + +class _WalletHomeState extends State { + final _formKey = GlobalKey(); + TextEditingController amountController = TextEditingController(); + TextEditingController addressController = TextEditingController(); + + @override + Widget build(BuildContext context) { + return Scaffold( + backgroundColor: VarianceColors.primary, + body: SafeArea( + child: Padding( + padding: EdgeInsets.symmetric(vertical: 19.h, horizontal: 16.w), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const WalletBalance(), + 50.verticalSpace, + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + TextButton.icon( + onPressed: () { + showModalBottomSheetContent(context); + }, + style: TextButton.styleFrom( + backgroundColor: const Color(0xffE1FF01)), + icon: const Icon(Icons.qr_code_2_sharp), + label: const Text(' Receive')), + 50.horizontalSpace, + TextButton.icon( + onPressed: () {}, + style: TextButton.styleFrom( + backgroundColor: const Color(0xffE1FF01)), + icon: const Icon( + Icons.all_inclusive_outlined, + ), + label: const Text('Mint NFT')), + ], + ), + 60.verticalSpace, + AddressBar( + hintText: 'Eth Address', + textEditingController: addressController, + ), + 18.verticalSpace, + TextFormField( + style: TextStyle( + fontSize: 51.sp, + fontWeight: FontWeight.w600, + color: VarianceColors.secondary), + key: _formKey, + validator: (value) { + if (value == null || value.isEmpty) { + return 'Please enter a value'; + } else if (int.parse(value) > 100) { + return 'Value should be less than or equal to 100'; + } + return null; + }, + onChanged: (value) { + if (value.isEmpty) { + return; + } + }, + textAlign: TextAlign.center, + controller: amountController, + keyboardType: TextInputType.number, + decoration: const InputDecoration( + focusColor: Colors.white, + fillColor: Colors.white, + border: InputBorder.none, + hintText: '0.0', + hintStyle: TextStyle( + fontSize: 51, color: VarianceColors.secondary), + ), + cursorColor: VarianceColors.secondary, + inputFormatters: [ + FilteringTextInputFormatter.allow( + RegExp(r'^\.?\d*(?().sendTransaction( + addressController.text, amountController.text); + }, + child: const Text('Send')), + ), + ], + ), + ), + ), + ); + } +} diff --git a/example/lib/screens/home_screen.dart b/example/lib/screens/home/home_widgets.dart similarity index 53% rename from example/lib/screens/home_screen.dart rename to example/lib/screens/home/home_widgets.dart index c003f4c..abf928b 100644 --- a/example/lib/screens/home_screen.dart +++ b/example/lib/screens/home/home_widgets.dart @@ -1,115 +1,16 @@ import 'dart:async'; -import 'dart:developer'; import 'package:flutter/material.dart'; +import 'dart:ui' as ui; import 'package:flutter/services.dart'; -import 'package:flutter/widgets.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:provider/provider.dart'; import 'package:qr_flutter/qr_flutter.dart'; import 'package:variancedemo/providers/wallet_provider.dart'; import 'package:variancedemo/variance_colors.dart'; -import 'dart:ui' as ui; - import 'package:web3_signers/web3_signers.dart'; import 'package:web3dart/web3dart.dart'; -class WalletHome extends StatefulWidget { - const WalletHome({super.key}); - - @override - State createState() => _WalletHomeState(); -} - -class _WalletHomeState extends State { - final _formKey = GlobalKey(); - TextEditingController amountController = TextEditingController(); - TextEditingController addressController = TextEditingController(); - - @override - Widget build(BuildContext context) { - return Scaffold( - backgroundColor: VarianceColors.primary, - body: SafeArea( - child: Padding( - padding: EdgeInsets.symmetric(vertical: 19.h, horizontal: 16.w), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const WalletBalance(), - 110.verticalSpace, - AddressBar( - hintText: 'Eth Address', - textEditingController: addressController, - ), - 18.verticalSpace, - TextFormField( - style: TextStyle( - fontSize: 51.sp, - fontWeight: FontWeight.w600, - color: VarianceColors.secondary), - key: _formKey, - validator: (value) { - if (value == null || value.isEmpty) { - return 'Please enter a value'; - } else if (int.parse(value) > 100) { - return 'Value should be less than or equal to 100'; - } - return null; - }, - onChanged: (value) { - if (value.isEmpty) { - return; - } - }, - textAlign: TextAlign.center, - controller: amountController, - keyboardType: TextInputType.number, - decoration: const InputDecoration( - focusColor: Colors.white, - fillColor: Colors.white, - border: InputBorder.none, - hintText: '0.0', - hintStyle: TextStyle( - fontSize: 51, color: VarianceColors.secondary), - ), - cursorColor: VarianceColors.secondary, - inputFormatters: [ - FilteringTextInputFormatter.allow( - RegExp(r'^\.?\d*(?().sendTransaction( - addressController.text, amountController.text); - }, - child: const Text('Send')), - ), - ], - ), - ), - ), - floatingActionButton: FloatingActionButton.large( - child: const Icon(Icons.qr_code_2_sharp), - onPressed: () { - showModalBottomSheetContent(context); - }, - ), - ); - } -} - String address = ''; class WalletBalance extends StatefulWidget { @@ -188,85 +89,6 @@ class _WalletBalanceState extends State { } } -class CryptoTransaction { - final String name; - final double amount; - final String date; - - CryptoTransaction({ - required this.name, - required this.amount, - required this.date, - }); -} - -class AddressBar extends StatefulWidget { - final String hintText; - final TextEditingController? textEditingController; - final TextStyle? hintTextStyle; - - // Add an optional parameter for the initial value - final String initialValue; - - const AddressBar({ - required this.hintText, - this.hintTextStyle, - this.textEditingController, - this.initialValue = "0.0", // Provide a default initial value - Key? key, - }) : super(key: key); - - @override - State createState() => _AddressBarState(); -} - -class _AddressBarState extends State { - bool pwdVisibility = false; - final formKey = GlobalKey(); - late final TextEditingController textEditingController; - @override - void initState() { - super.initState(); - // Initialize the TextEditingController with the initial value - textEditingController = widget.textEditingController ?? - TextEditingController(text: widget.initialValue); - } - - @override - Widget build(BuildContext context) { - return TextFormField( - cursorColor: VarianceColors.primary, - controller: widget.textEditingController, - textAlign: TextAlign.center, - decoration: InputDecoration( - fillColor: VarianceColors.secondary, - filled: true, - hintText: widget.hintText, - hintStyle: widget.hintTextStyle, - enabledBorder: OutlineInputBorder( - borderSide: const BorderSide( - color: Colors.white, - width: 1, - ), - borderRadius: BorderRadius.circular(10), - ), - focusedBorder: OutlineInputBorder( - borderSide: const BorderSide( - color: Colors.white, - width: 1, - ), - borderRadius: BorderRadius.circular(10)), - ), - validator: (val) { - if (val!.isEmpty) { - return 'Required'; - } - return null; - }, - ); - } -} - String message = address; final FutureBuilder qrFutureBuilder = FutureBuilder( future: _loadOverlayImage(), @@ -351,7 +173,8 @@ showModalBottomSheetContent(BuildContext context) { const SizedBox(height: 5), const Spacer(), SizedBox( - width: 50, + width: 60, + height: 30, child: TextButton( onPressed: () { Clipboard.setData(ClipboardData( @@ -360,6 +183,7 @@ showModalBottomSheetContent(BuildContext context) { }, style: TextButton.styleFrom( backgroundColor: const Color(0xff32353E), + padding: const EdgeInsets.all(5), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(10), ), diff --git a/example/lib/utils/widgets.dart b/example/lib/utils/widgets.dart index 71449f3..2431ee7 100644 --- a/example/lib/utils/widgets.dart +++ b/example/lib/utils/widgets.dart @@ -1,8 +1,76 @@ - import 'package:flutter/material.dart'; +import 'package:flutter/material.dart'; import 'package:variancedemo/main.dart'; +import 'package:variancedemo/variance_colors.dart'; void showSnackbar(String message) { - var currentScaffoldMessenger = globalScaffoldMessengerKey.currentState; - currentScaffoldMessenger?.hideCurrentSnackBar(); - currentScaffoldMessenger?.showSnackBar(SnackBar(content: Text(message))); - } \ No newline at end of file + var currentScaffoldMessenger = globalScaffoldMessengerKey.currentState; + currentScaffoldMessenger?.hideCurrentSnackBar(); + currentScaffoldMessenger?.showSnackBar(SnackBar(content: Text(message))); +} + +class AddressBar extends StatefulWidget { + final String hintText; + final TextEditingController? textEditingController; + final TextStyle? hintTextStyle; + + // Add an optional parameter for the initial value + final String initialValue; + + const AddressBar({ + required this.hintText, + this.hintTextStyle, + this.textEditingController, + this.initialValue = "0.0", // Provide a default initial value + Key? key, + }) : super(key: key); + + @override + State createState() => _AddressBarState(); +} + +class _AddressBarState extends State { + bool pwdVisibility = false; + final formKey = GlobalKey(); + late final TextEditingController textEditingController; + @override + void initState() { + super.initState(); + // Initialize the TextEditingController with the initial value + textEditingController = widget.textEditingController ?? + TextEditingController(text: widget.initialValue); + } + + @override + Widget build(BuildContext context) { + return TextFormField( + cursorColor: VarianceColors.primary, + controller: widget.textEditingController, + textAlign: TextAlign.center, + decoration: InputDecoration( + fillColor: VarianceColors.secondary, + filled: true, + hintText: widget.hintText, + hintStyle: widget.hintTextStyle, + enabledBorder: OutlineInputBorder( + borderSide: const BorderSide( + color: Colors.white, + width: 1, + ), + borderRadius: BorderRadius.circular(10), + ), + focusedBorder: OutlineInputBorder( + borderSide: const BorderSide( + color: Colors.white, + width: 1, + ), + borderRadius: BorderRadius.circular(10)), + ), + validator: (val) { + if (val!.isEmpty) { + return 'Required'; + } + return null; + }, + ); + } +} diff --git a/example/pubspec.lock b/example/pubspec.lock index a9d01ab..751e951 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -232,6 +232,14 @@ packages: description: flutter source: sdk version: "0.0.0" + fluttertoast: + dependency: "direct main" + description: + name: fluttertoast + sha256: dfdde255317af381bfc1c486ed968d5a43a2ded9c931e87cbecd88767d6a71c1 + url: "https://pub.dev" + source: hosted + version: "8.2.4" google_fonts: dependency: "direct main" description: @@ -304,30 +312,6 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.2" - leak_tracker: - dependency: transitive - description: - name: leak_tracker - sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" - url: "https://pub.dev" - source: hosted - version: "10.0.0" - leak_tracker_flutter_testing: - dependency: transitive - description: - name: leak_tracker_flutter_testing - sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 - url: "https://pub.dev" - source: hosted - version: "2.0.1" - leak_tracker_testing: - dependency: transitive - description: - name: leak_tracker_testing - sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 - url: "https://pub.dev" - source: hosted - version: "2.0.1" lints: dependency: transitive description: @@ -340,26 +324,26 @@ packages: dependency: transitive description: name: matcher - sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb + sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" url: "https://pub.dev" source: hosted - version: "0.12.16+1" + version: "0.12.16" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" url: "https://pub.dev" source: hosted - version: "0.8.0" + version: "0.5.0" meta: dependency: transitive description: name: meta - sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 + sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.10.0" nested: dependency: transitive description: @@ -420,10 +404,10 @@ packages: dependency: transitive description: name: path - sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" + sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" url: "https://pub.dev" source: hosted - version: "1.9.0" + version: "1.8.3" path_provider: dependency: "direct main" description: @@ -716,14 +700,6 @@ packages: url: "https://pub.dev" source: hosted version: "2.1.4" - vm_service: - dependency: transitive - description: - name: vm_service - sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957 - url: "https://pub.dev" - source: hosted - version: "13.0.0" wallet: dependency: transitive description: diff --git a/example/pubspec.yaml b/example/pubspec.yaml index b6111f9..b660c99 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -21,6 +21,7 @@ dependencies: shared_preferences: ^2.2.2 path_provider: ^2.1.1 web3_signers: ^0.0.6-r2 + fluttertoast: ^8.2.4 variance_dart: path: ../ diff --git a/lib/src/4337/chains.dart b/lib/src/4337/chains.dart index a6fc878..c141c61 100644 --- a/lib/src/4337/chains.dart +++ b/lib/src/4337/chains.dart @@ -124,7 +124,7 @@ class Chains { jsonRpcUrl: "https://rpc.ankr.com/polygon_mumbai", entrypoint: EntryPointAddress.v06, ), - Network.baseTestent: Chain( + Network.baseTestnet: Chain( chainId: 84532, explorer: "https://sepolia.basescan.org/", jsonRpcUrl: "https://rpc.ankr.com/base_sepolia", @@ -194,7 +194,7 @@ enum Network { // testnet sepolia, mumbai, - baseTestent, + baseTestnet, // localhost localhost diff --git a/pubspec.lock b/pubspec.lock index 2d24973..70f7886 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -359,18 +359,18 @@ packages: dependency: transitive description: name: material_color_utilities - sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" + sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" url: "https://pub.dev" source: hosted - version: "0.8.0" + version: "0.5.0" meta: dependency: transitive description: name: meta - sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 + sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e url: "https://pub.dev" source: hosted - version: "1.11.0" + version: "1.10.0" mime: dependency: transitive description: @@ -656,6 +656,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.1.0" + web: + dependency: transitive + description: + name: web + sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152 + url: "https://pub.dev" + source: hosted + version: "0.3.0" web3_signers: dependency: "direct main" description: