diff --git a/.gitignore b/.gitignore index ec9131840..0418c9d7f 100644 --- a/.gitignore +++ b/.gitignore @@ -46,6 +46,12 @@ test/services/coins/particl/particl_wallet_test_parameters.dart # Exceptions to above rules. !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages +# asset symlinks +/assets/default_themes +/assets/icon +/assets/lottie +/assets/in_app_logo_icons + # other coverage scripts/**/build @@ -59,3 +65,34 @@ libtor_ffi.dll flutter_libsparkmobile.dll secp256k1.dll /libisar.so +/lib/app_config.g.dart +/android/app/src/main/app_icon-playstore.png + +## other generated project files + +pubspec.yaml + +/android/app/build.gradle +/android/app/src/debug/AndroidManifest.xml +/android/app/src/profile/AndroidManifest.xml +/android/app/src/main/AndroidManifest.xml +/android/app/src/main/profile/AndroidManifest.xml +/android/app/src/main/kotlin/com/cypherstack/stackwallet/MainActivity.kt +/android/app/src/main/res/**/ic_launcher.png + +/ios/Runner/Info.plist +/ios/Runner.xcodeproj/project.pbxproj +/ios/Runner/Assets.xcassets/AppIcon.appiconset/*.png + +/linux/CMakeLists.txt +/linux/my_application.cc + +/macos/Runner/Configs/AppInfo.xcconfig +/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +/macos/Runner.xcodeproj/project.pbxproj +/macos/Runner/Assets.xcassets/AppIcon.appiconset/*.png + +/windows/runner/Runner.rc +/windows/runner/main.cpp +/windows/CMakeLists.txt +/windows/runner/resources/app_icon.ico diff --git a/analysis_options.yaml b/analysis_options.yaml index c363d17cd..ea46ed3ca 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -82,7 +82,7 @@ linter: # `// ignore_for_file: name_of_lint` syntax on the line or in the file # producing the lint. rules: - always_use_package_imports: true + prefer_relative_imports: true avoid_relative_lib_imports: true no_leading_underscores_for_local_identifiers: false no_leading_underscores_for_library_prefixes: false diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png deleted file mode 100644 index 9ce95f8f2..000000000 Binary files a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png deleted file mode 100644 index 1cffbb8e1..000000000 Binary files a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png deleted file mode 100644 index 5e7ef3a9c..000000000 Binary files a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png deleted file mode 100644 index 0334611f2..000000000 Binary files a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png deleted file mode 100644 index ab5dd7ded..000000000 Binary files a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ diff --git a/assets/default_themes/dark.zip b/asset_sources/bundled_themes/stack_duo/dark.zip similarity index 100% rename from assets/default_themes/dark.zip rename to asset_sources/bundled_themes/stack_duo/dark.zip diff --git a/assets/default_themes/light.zip b/asset_sources/bundled_themes/stack_duo/light.zip similarity index 100% rename from assets/default_themes/light.zip rename to asset_sources/bundled_themes/stack_duo/light.zip diff --git a/asset_sources/bundled_themes/stack_wallet/dark.zip b/asset_sources/bundled_themes/stack_wallet/dark.zip new file mode 100644 index 000000000..c6d417500 Binary files /dev/null and b/asset_sources/bundled_themes/stack_wallet/dark.zip differ diff --git a/asset_sources/bundled_themes/stack_wallet/light.zip b/asset_sources/bundled_themes/stack_wallet/light.zip new file mode 100644 index 000000000..d94ce2ac8 Binary files /dev/null and b/asset_sources/bundled_themes/stack_wallet/light.zip differ diff --git a/asset_sources/icon/stack_duo/app_icon_alpha.png b/asset_sources/icon/stack_duo/app_icon_alpha.png new file mode 100644 index 000000000..4d1e1de9f Binary files /dev/null and b/asset_sources/icon/stack_duo/app_icon_alpha.png differ diff --git a/asset_sources/icon/stack_duo/icon.png b/asset_sources/icon/stack_duo/icon.png new file mode 100644 index 000000000..3078ee9e2 Binary files /dev/null and b/asset_sources/icon/stack_duo/icon.png differ diff --git a/asset_sources/icon/stack_duo/macos-icon.png b/asset_sources/icon/stack_duo/macos-icon.png new file mode 100644 index 000000000..026154cba Binary files /dev/null and b/asset_sources/icon/stack_duo/macos-icon.png differ diff --git a/assets/icon/app_icon_alpha.png b/asset_sources/icon/stack_wallet/app_icon_alpha.png similarity index 100% rename from assets/icon/app_icon_alpha.png rename to asset_sources/icon/stack_wallet/app_icon_alpha.png diff --git a/assets/icon/icon.png b/asset_sources/icon/stack_wallet/icon.png similarity index 100% rename from assets/icon/icon.png rename to asset_sources/icon/stack_wallet/icon.png diff --git a/assets/icon/macos-icon.png b/asset_sources/icon/stack_wallet/macos-icon.png similarity index 100% rename from assets/icon/macos-icon.png rename to asset_sources/icon/stack_wallet/macos-icon.png diff --git a/assets/images/splash.png b/asset_sources/icon/stack_wallet/splash.png similarity index 100% rename from assets/images/splash.png rename to asset_sources/icon/stack_wallet/splash.png diff --git a/asset_sources/in_app_logo_icons/stack_duo/stack-duo-icon_dark.svg b/asset_sources/in_app_logo_icons/stack_duo/stack-duo-icon_dark.svg new file mode 100644 index 000000000..eb16522e5 --- /dev/null +++ b/asset_sources/in_app_logo_icons/stack_duo/stack-duo-icon_dark.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/asset_sources/in_app_logo_icons/stack_duo/stack-duo-icon_light.svg b/asset_sources/in_app_logo_icons/stack_duo/stack-duo-icon_light.svg new file mode 100644 index 000000000..eb16522e5 --- /dev/null +++ b/asset_sources/in_app_logo_icons/stack_duo/stack-duo-icon_light.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/asset_sources/in_app_logo_icons/stack_wallet/dummy b/asset_sources/in_app_logo_icons/stack_wallet/dummy new file mode 100644 index 000000000..061d11394 --- /dev/null +++ b/asset_sources/in_app_logo_icons/stack_wallet/dummy @@ -0,0 +1 @@ +Dummy file to ensure dir structure is preserved. Stack app icon is in standard themes. \ No newline at end of file diff --git a/assets/lottie/arrow_rotate.json b/asset_sources/lottie/stack_duo/arrow_rotate.json similarity index 100% rename from assets/lottie/arrow_rotate.json rename to asset_sources/lottie/stack_duo/arrow_rotate.json diff --git a/assets/lottie/icon_send.json b/asset_sources/lottie/stack_duo/icon_send.json similarity index 100% rename from assets/lottie/icon_send.json rename to asset_sources/lottie/stack_duo/icon_send.json diff --git a/asset_sources/lottie/stack_duo/loader.json b/asset_sources/lottie/stack_duo/loader.json new file mode 100644 index 000000000..dae536282 --- /dev/null +++ b/asset_sources/lottie/stack_duo/loader.json @@ -0,0 +1 @@ +{"v":"5.10.2","fr":30,"ip":0,"op":93,"w":700,"h":700,"nm":"Stack-duo-animation","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":3,"nm":"Null 1","sr":1,"ks":{"o":{"a":0,"k":0,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":42,"s":[0]},{"t":55,"s":[180]}],"ix":10},"p":{"a":0,"k":[350,350,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"ip":0,"op":101,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"gray ring Outlines","parent":1,"sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.167],"y":[0.167]},"t":1,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":7,"s":[70]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.333],"y":[0]},"t":79,"s":[70]},{"t":85,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0},"t":1,"s":[199,0,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.667,"y":0.667},"o":{"x":0.333,"y":0.333},"t":27,"s":[-63.24,0,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.667,"y":0.667},"o":{"x":0.333,"y":0.333},"t":42,"s":[-63.24,0,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.667,"y":0.667},"o":{"x":0.333,"y":0.333},"t":55,"s":[-63.24,0,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.333,"y":0.333},"t":61,"s":[-63.24,0,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.333,"y":0},"t":65,"s":[-63.24,0,0],"to":[0,0,0],"ti":[0,0,0]},{"t":85,"s":[-198.24,0,0]}],"ix":2,"l":2},"a":{"a":0,"k":[128,128,0],"ix":1,"l":2},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[0.119,0.119,5.929]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":1,"s":[70,70,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0.233,0.233,-2.61]},"t":18,"s":[80,80,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":27,"s":[100,100,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":42,"s":[100,100,100]},{"i":{"x":[0.833,0.833,0.833],"y":[1,1,-2.367]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":55,"s":[100,100,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,7.852]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":56,"s":[100,100,100]},{"t":85,"s":[70,70,100]}],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[27.84,-7.24],[5.65,0],[0,35.77],[-35.77,0],[-5.22,-1.37],[0,-30.12]],"o":[[-5.22,1.37],[-35.77,0],[0,-35.77],[5.65,0],[27.84,7.24],[0,30.12]],"v":[[16.36,62.67],[0,64.76],[-64.77,0],[0,-64.76],[16.36,-62.67],[64.76,0]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ind":1,"ty":"sh","ix":2,"ks":{"a":0,"k":{"i":[[38.26,22.13],[23.31,0],[0,-70.69],[-70.7,0],[-18.83,10.89],[0,47.38]],"o":[[-18.83,-10.89],[-70.7,0],[0,70.69],[23.31,0],[38.26,-22.13],[0,-47.38]],"v":[[63.99,-110.88],[0,-128],[-128,0],[0,128],[63.99,110.88],[128,0]],"c":true},"ix":2},"nm":"Path 2","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"mm","mm":1,"nm":"Merge Paths 1","mn":"ADBE Vector Filter - Merge","hd":false},{"ty":"fl","c":{"a":0,"k":[0.576470588235,0.576470588235,0.576470588235,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[128,128],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":6,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":93,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"black ball Outlines","parent":1,"sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.167],"y":[0.167]},"t":1,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":7,"s":[100]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.333],"y":[0]},"t":79,"s":[100]},{"t":85,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0},"t":1,"s":[-199.4,0,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.667,"y":0.667},"o":{"x":0.333,"y":0.333},"t":27,"s":[64.76,0,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.667,"y":0.667},"o":{"x":0.333,"y":0.333},"t":42,"s":[64.76,0,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.667,"y":0.667},"o":{"x":0.333,"y":0.333},"t":55,"s":[64.76,0,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.333,"y":0.333},"t":61,"s":[64.76,0,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.333,"y":0},"t":65,"s":[64.76,0,0],"to":[0,0,0],"ti":[0,0,0]},{"t":85,"s":[196.76,0,0]}],"ix":2,"l":2},"a":{"a":0,"k":[128.25,128.25,0],"ix":1,"l":2},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":1,"s":[70,70,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":18,"s":[80,80,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":27,"s":[100,100,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":42,"s":[100,100,100]},{"i":{"x":[0.833,0.833,0.833],"y":[1,1,-2.367]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":55,"s":[100,100,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,7.852]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":56,"s":[100,100,100]},{"t":85,"s":[70,70,100]}],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,-70.69],[70.69,0],[18.83,10.89],[11.26,20.03],[0,22.77],[-10.43,18.52],[-19.87,11.49],[-23.31,0]],"o":[[0,70.69],[-23.31,0],[-19.87,-11.49],[-10.43,-18.52],[0,-22.77],[11.26,-20.03],[18.83,-10.89],[70.69,0]],"v":[[128,0],[0,128],[-63.99,110.88],[-111.62,62.67],[-128,0],[-111.62,-62.67],[-63.99,-110.88],[0,-128]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0,0,0,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[128.25,128.25],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":4,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":93,"st":0,"ct":1,"bm":0}],"markers":[]} \ No newline at end of file diff --git a/assets/lottie/loader_and_checkmark.json b/asset_sources/lottie/stack_duo/loader_and_checkmark.json similarity index 100% rename from assets/lottie/loader_and_checkmark.json rename to asset_sources/lottie/stack_duo/loader_and_checkmark.json diff --git a/assets/lottie/onion_animation.json b/asset_sources/lottie/stack_duo/onion_animation.json similarity index 100% rename from assets/lottie/onion_animation.json rename to asset_sources/lottie/stack_duo/onion_animation.json diff --git a/asset_sources/lottie/stack_wallet/arrow_rotate.json b/asset_sources/lottie/stack_wallet/arrow_rotate.json new file mode 100644 index 000000000..c729d2e7a --- /dev/null +++ b/asset_sources/lottie/stack_wallet/arrow_rotate.json @@ -0,0 +1 @@ +{"v":"5.10.2","fr":30,"ip":0,"op":60,"w":30,"h":30,"nm":"arrow-rotate","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"arrow-rotate","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":0,"s":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":44,"s":[200]},{"t":60,"s":[360]}],"ix":10},"p":{"a":0,"k":[15,15,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,-0.828],[0,0],[3.389,0],[1.441,-4.074],[-0.781,-0.277],[-0.276,0.778],[-3.22,0],[-1.369,-1.823],[0,0],[0,-0.83],[-0.83,0],[0,0],[-0.023,0],[0,0],[0,0.83],[0,0],[0.83,0]],"o":[[0,0],[-1.964,-2.437],[-4.533,0],[-0.276,0.741],[0.781,0.277],[1.031,-2.916],[2.494,0],[0,0],[-0.83,0],[0,0.83],[0,0],[0.023,0],[0,0],[0.83,0],[0,0],[0,-0.828],[-0.83,0]],"v":[[8.25,-8.25],[8.25,-6.497],[-0.042,-10.5],[-9.902,-3.502],[-8.988,-1.584],[-7.073,-2.498],[-0.042,-7.5],[6,-4.5],[4.5,-4.5],[3,-3],[4.5,-1.5],[8.452,-1.5],[8.522,-1.5],[9.75,-1.5],[11.25,-3],[11.25,-8.25],[9.75,-9.75]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ind":1,"ty":"sh","ix":2,"ks":{"a":0,"k":{"i":[[0,0],[-0.828,0],[0,0.83],[0,0],[-3.347,0],[-1.439,4.073],[0.783,0.277],[0.277,-0.778],[3.262,0],[1.411,1.823],[0,0],[0,0.83],[0.83,0],[0,0],[0,-0.83]],"o":[[0,0.83],[0.828,0],[0,0],[1.922,2.438],[4.575,0],[0.277,-0.783],[-0.778,-0.277],[-1.031,2.916],[-2.452,0],[0,0],[0.83,0],[0,-0.83],[0,0],[-0.828,0],[0,0]],"v":[[-11.25,8.25],[-9.75,9.75],[-8.25,8.25],[-8.25,6.497],[0,10.5],[9.9,3.502],[8.986,1.584],[7.073,2.498],[0,7.5],[-6.042,4.5],[-4.5,4.5],[-3,3],[-4.5,1.5],[-9.75,1.5],[-11.25,3]],"c":true},"ix":2},"nm":"Path 2","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"mm","mm":1,"nm":"Merge Paths 1","mn":"ADBE Vector Filter - Merge","hd":false},{"ty":"fl","c":{"a":0,"k":[0.137254908681,0.137254908681,0.137254908681,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Vector","np":4,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":60,"st":0,"ct":1,"bm":0}],"markers":[]} \ No newline at end of file diff --git a/asset_sources/lottie/stack_wallet/icon_send.json b/asset_sources/lottie/stack_wallet/icon_send.json new file mode 100644 index 000000000..7dc1f7c2d --- /dev/null +++ b/asset_sources/lottie/stack_wallet/icon_send.json @@ -0,0 +1 @@ +{"v":"5.10.2","fr":30,"ip":0,"op":100,"w":24,"h":24,"nm":"icon-send","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"MASK","td":1,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[12,12,0],"ix":2,"l":2},"a":{"a":0,"k":[0.125,0.125,0],"ix":1,"l":2},"s":{"a":0,"k":[87.368,87.368,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[23.75,23.75],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"fl","c":{"a":0,"k":[1,1,1,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0.125,0.125],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":100,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"Arrow","tt":1,"tp":1,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0},"t":0,"s":[-1.009,25.009,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.667,"y":1},"o":{"x":0.333,"y":0},"t":33,"s":[11.695,12.306,0],"to":[0,0,0],"ti":[0,0,0]},{"t":53,"s":[24.398,-0.397,0]}],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,-0.69],[-0.69,0],[0,0],[0,0],[-0.488,-0.488],[-0.488,0.488],[0,0],[0,0],[-0.69,0],[0,0.69],[0,0],[0.234,0.234],[0.332,0]],"o":[[-0.69,0],[0,0.69],[0,0],[0,0],[-0.488,0.488],[0.488,0.488],[0,0],[0,0],[0,0.69],[0.69,0],[0,0],[0,-0.332],[-0.234,-0.234],[0,0]],"v":[[-2,-5.25],[-3.25,-4],[-2,-2.75],[0.982,-2.75],[-4.884,3.116],[-4.884,4.884],[-3.116,4.884],[2.75,-0.982],[2.75,2],[4,3.25],[5.25,2],[5.25,-4],[4.884,-4.884],[4,-5.25]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0.137254908681,0.137254908681,0.137254908681,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Vector (Stroke)","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":100,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"Outline","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[12,12,0],"ix":2,"l":2},"a":{"a":0,"k":[12,0.063,0],"ix":1,"l":2},"s":{"a":0,"k":[90.104,90.104,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[24,24],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"st","c":{"a":0,"k":[0.137254901961,0.137254901961,0.137254901961,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2.5,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[12,0.063],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":58,"s":[0]},{"t":97,"s":[100]}],"ix":1},"e":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":58,"s":[100]},{"t":97,"s":[100]}],"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":0,"op":100,"st":0,"ct":1,"bm":0}],"markers":[{"tm":0,"cm":"{\r\n\"name\":\"SEGMENT 1\"\r\n}","dr":0},{"tm":53,"cm":"{\r\n\"name\":\"SEGMENT 2\"\r\n}","dr":0},{"tm":97,"cm":"{\r\n\"name\":\"SEGMENT 3\"\r\n}","dr":0}]} \ No newline at end of file diff --git a/assets/lottie/test2.json b/asset_sources/lottie/stack_wallet/loader.json similarity index 100% rename from assets/lottie/test2.json rename to asset_sources/lottie/stack_wallet/loader.json diff --git a/asset_sources/lottie/stack_wallet/loader_and_checkmark.json b/asset_sources/lottie/stack_wallet/loader_and_checkmark.json new file mode 100644 index 000000000..406f52030 --- /dev/null +++ b/asset_sources/lottie/stack_wallet/loader_and_checkmark.json @@ -0,0 +1 @@ +{"v":"5.10.2","fr":30,"ip":0,"op":130,"w":24,"h":24,"nm":"Loader","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"Arrow","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":0,"s":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":115,"s":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":117,"s":[80]},{"t":122,"s":[100]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[12,12,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":117,"s":[30,30,100]},{"t":122,"s":[100,100,100]}],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0]],"v":[[4.75,-3],[-1.25,3],[-4.75,-0.5]],"c":false},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[1,1,1,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2.5,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Vector","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":0,"k":100,"ix":1},"e":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":117,"s":[100]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":119,"s":[30]},{"t":122,"s":[0]}],"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":0,"op":130,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"Fill","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":0,"s":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":115,"s":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":117,"s":[30]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":119,"s":[70]},{"t":122,"s":[100]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[12,12,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":117,"s":[241.821,241.821,100]},{"t":122,"s":[1511.821,1511.821,100]}],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[24,24],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"fl","c":{"a":0,"k":[0,0.647058823529,0.470588235294,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[6.243,6.243],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":130,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"Сircle green","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.167],"y":[0]},"t":0,"s":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.333],"y":[0]},"t":73,"s":[0]},{"t":74,"s":[100]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[12,12,0],"ix":2,"l":2},"a":{"a":0,"k":[0,-0.063,0],"ix":1,"l":2},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.754]},"t":0,"s":[113.562,113.562,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":111,"s":[113.562,113.562,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":115,"s":[90,90,100]},{"t":122,"s":[113.562,113.562,100]}],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[19.125,19.125],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"st","c":{"a":0,"k":[0,0.647058823529,0.470588235294,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,-0.063],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0.833],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":74,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.167],"y":[0]},"t":87,"s":[0]},{"t":111,"s":[0]}],"ix":1},"e":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.333],"y":[0]},"t":74,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.167],"y":[0.167]},"t":87,"s":[55]},{"t":111,"s":[100]}],"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim","hd":false},{"ty":"st","c":{"a":0,"k":[0,0.647058823529,0.470588235294,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false}],"ip":0,"op":130,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":4,"ty":4,"nm":"Сircle black 2 turn","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":0,"s":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":36,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.167],"y":[0]},"t":37,"s":[100]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.333],"y":[0]},"t":74,"s":[100]},{"t":75,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[12,12,0],"ix":2,"l":2},"a":{"a":0,"k":[0,-0.063,0],"ix":1,"l":2},"s":{"a":0,"k":[113.562,113.562,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[19.125,19.125],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"st","c":{"a":0,"k":[0.137254901961,0.137254901961,0.137254901961,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,-0.063],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0.833],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":37,"s":[0.2]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":50,"s":[0.2]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":57,"s":[27.5]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":72,"s":[99]},{"t":74,"s":[100]}],"ix":1},"e":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.333],"y":[0]},"t":37,"s":[0.1]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":50,"s":[55]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":57,"s":[73]},{"t":74,"s":[100]}],"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim","hd":false},{"ty":"st","c":{"a":0,"k":[0.137254908681,0.137254908681,0.137254908681,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false}],"ip":0,"op":130,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":5,"ty":4,"nm":"Сircle black 1 turn","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.833],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":0,"s":[100]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":37,"s":[100]},{"t":38,"s":[0]}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[12,12,0],"ix":2,"l":2},"a":{"a":0,"k":[0,-0.063,0],"ix":1,"l":2},"s":{"a":0,"k":[113.562,113.562,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[19.125,19.125],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"st","c":{"a":0,"k":[0.137254901961,0.137254901961,0.137254901961,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,-0.063],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.333],"y":[0]},"t":0,"s":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":13,"s":[0.2]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.167],"y":[0.167]},"t":20,"s":[27.5]},{"t":37,"s":[100]}],"ix":1},"e":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.333],"y":[0]},"t":0,"s":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":13,"s":[55]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.167],"y":[0.167]},"t":20,"s":[73]},{"t":37,"s":[99]}],"ix":2},"o":{"a":0,"k":0,"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim","hd":false},{"ty":"st","c":{"a":0,"k":[0.137254908681,0.137254908681,0.137254908681,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false}],"ip":0,"op":130,"st":0,"ct":1,"bm":0}],"markers":[{"tm":0,"cm":"{\r\n\"name\":\"marker 1\"\r\n}","dr":0},{"tm":74,"cm":"{\r\n\"name\":\"marker 2\"\r\n}","dr":0},{"tm":130,"cm":"{\r\n\"name\":\"marker 3\"\r\n}","dr":0}]} \ No newline at end of file diff --git a/asset_sources/lottie/stack_wallet/onion_animation.json b/asset_sources/lottie/stack_wallet/onion_animation.json new file mode 100644 index 000000000..9988b5a7c --- /dev/null +++ b/asset_sources/lottie/stack_wallet/onion_animation.json @@ -0,0 +1 @@ +{"v":"5.10.2","fr":25,"ip":0,"op":436,"w":180,"h":180,"nm":"onion-character-animation","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"failed","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[150.3,44.3,0],"ix":2,"l":2},"a":{"a":0,"k":[17.188,17.188,0],"ix":1,"l":2},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":393,"s":[0,0,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":408,"s":[100,100,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":414,"s":[108,108,100]},{"t":429,"s":[100,100,100]}],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[-6.919,6.919],[6.919,-6.919]],"c":false},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[1,0.878431432387,0.415686304429,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[17.188,17.187],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[-6.919,-6.919],[6.919,6.919]],"c":false},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[1,0.878431432387,0.415686304429,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[17.188,17.188],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 2","np":3,"cix":2,"bm":0,"ix":2,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-8.388,0],[0,-8.388],[8.388,0],[0,8.387]],"o":[[8.388,0],[0,8.387],[-8.388,0],[0,-8.388]],"v":[[0,-15.188],[15.188,0.001],[0,15.188],[-15.188,0.001]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[1,0.513725490196,0.513725490196,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[17.188,17.188],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 3","np":3,"cix":2,"bm":0,"ix":3,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":600,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"globe","sr":1,"ks":{"o":{"a":1,"k":[{"t":195,"s":[100],"h":1},{"t":213,"s":[0],"h":1},{"t":378,"s":[100],"h":1},{"t":427,"s":[0],"h":1}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[150.25,44.25,0],"ix":2,"l":2},"a":{"a":0,"k":[17.188,17.188,0],"ix":1,"l":2},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":32,"s":[0,0,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":47,"s":[100,100,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":53,"s":[108,108,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.167,0.167,0.167],"y":[0,0,0]},"t":68,"s":[100,100,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":328,"s":[100,100,100]},{"t":341,"s":[0,0,100],"h":1},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":378,"s":[100,100,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":390,"s":[100,100,100]},{"t":427,"s":[0,0,100]}],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[2.001,17.795],[32.376,17.795]],"c":false},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[17.33,2],[17.33,32.375]],"c":false},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 2","np":2,"cix":2,"bm":0,"ix":2,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[-4.233,0],[-1.818,-2.345]],"o":[[1.817,-2.345],[4.233,0],[0,0]],"v":[[-9.721,1.975],[-0.001,-1.975],[9.721,1.975]],"c":false},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[17.188,27.059],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 3","np":2,"cix":2,"bm":0,"ix":3,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[-4.589,0],[-1.622,2.672]],"o":[[1.622,2.672],[4.589,0],[0,0]],"v":[[-10.14,-2.278],[0,2.278],[10.14,-2.278]],"c":false},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[17.188,8.227],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 4","np":2,"cix":2,"bm":0,"ix":4,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-4.026,0],[0,-8.388],[4.026,0],[0,8.387]],"o":[[4.026,0],[0,8.387],[-4.026,0],[0,-8.388]],"v":[[0,-15.188],[7.29,0.001],[0,15.188],[-7.29,0.001]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[17.188,17.188],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 5","np":2,"cix":2,"bm":0,"ix":5,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-8.388,0],[0,-8.388],[8.388,0],[0,8.387]],"o":[[8.388,0],[0,8.387],[-8.388,0],[0,-8.388]],"v":[[0,-15.188],[15.188,0.001],[0,15.188],[-15.188,0.001]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[1,0.878431432387,0.415686304429,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[17.188,17.188],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 6","np":3,"cix":2,"bm":0,"ix":6,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":600,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":3,"ty":4,"nm":"globe 2","sr":1,"ks":{"o":{"a":1,"k":[{"t":195,"s":[0],"h":1},{"t":213,"s":[100],"h":1}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[150.25,44.25,0],"ix":2,"l":2},"a":{"a":0,"k":[17.188,17.188,0],"ix":1,"l":2},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":32,"s":[0,0,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":47,"s":[100,100,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":53,"s":[108,108,100]},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.167,0.167,0.167],"y":[0,0,0]},"t":68,"s":[100,100,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":328,"s":[100,100,100]},{"t":341,"s":[0,0,100]}],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[2.001,17.795],[32.376,17.795]],"c":false},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0]],"o":[[0,0],[0,0]],"v":[[17.33,2],[17.33,32.375]],"c":false},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 2","np":2,"cix":2,"bm":0,"ix":2,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[-4.233,0],[-1.818,-2.345]],"o":[[1.817,-2.345],[4.233,0],[0,0]],"v":[[-9.721,1.975],[-0.001,-1.975],[9.721,1.975]],"c":false},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[17.188,27.059],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 3","np":2,"cix":2,"bm":0,"ix":3,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[-4.589,0],[-1.622,2.672]],"o":[[1.622,2.672],[4.589,0],[0,0]],"v":[[-10.14,-2.278],[0,2.278],[10.14,-2.278]],"c":false},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[17.188,8.227],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 4","np":2,"cix":2,"bm":0,"ix":4,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-4.026,0],[0,-8.388],[4.026,0],[0,8.387]],"o":[[4.026,0],[0,8.387],[-4.026,0],[0,-8.388]],"v":[[0,-15.188],[7.29,0.001],[0,15.188],[-7.29,0.001]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[17.188,17.188],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 5","np":2,"cix":2,"bm":0,"ix":5,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-8.388,0],[0,-8.388],[8.388,0],[0,8.387]],"o":[[8.388,0],[0,8.387],[-8.388,0],[0,-8.388]],"v":[[0,-15.188],[15.188,0.001],[0,15.188],[-15.188,0.001]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[0.549019607843,0.901960784314,0.803921568627,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[17.188,17.188],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 6","np":3,"cix":2,"bm":0,"ix":6,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":600,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":4,"ty":3,"nm":"null-indicator","sr":1,"ks":{"o":{"a":0,"k":0,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":38,"s":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":75,"s":[153.988]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":165,"s":[514]},{"t":211,"s":[720],"h":1},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":378,"s":[514]},{"t":424,"s":[720]}],"ix":10},"p":{"a":0,"k":[150.125,44.219,0],"ix":2,"l":2},"a":{"a":0,"k":[60.125,-45.781,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"ip":0,"op":600,"st":0,"bm":0},{"ddd":0,"ind":5,"ty":4,"nm":"indicator-left ","parent":4,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[50.969,-46.99,0],"ix":2,"l":2},"a":{"a":0,"k":[12.968,22.698,0],"ix":1,"l":2},"s":{"a":1,"k":[{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":40,"s":[0,0,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":45,"s":[100,100,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":51,"s":[108,108,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":66,"s":[100,100,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":191,"s":[100,100,100]},{"t":218,"s":[0,0,100],"h":1},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":378,"s":[100,100,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":385,"s":[100,100,100]},{"t":402,"s":[0,0,100]}],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-0.932,0],[0,-0.931],[0.932,0],[0,0.932]],"o":[[0.932,0],[0,0.932],[-0.932,0],[0,-0.931]],"v":[[0,-1.688],[1.687,-0.001],[0,1.688],[-1.687,-0.001]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[1,0.878431432387,0.415686304429,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[22.249,3.688],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,-10.616],[-8.447,-2.437]],"o":[[-10.394,0.857],[0,9.232],[0,0]],"v":[[9.281,-19.82],[-9.281,0.361],[5.343,19.82]],"c":false},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[11.281,23.576],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 2","np":2,"cix":2,"bm":0,"ix":2,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":600,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":6,"ty":4,"nm":"indicator-right ","parent":4,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[69.531,-44.51,0],"ix":2,"l":2},"a":{"a":0,"k":[12.968,22.698,0],"ix":1,"l":2},"s":{"a":1,"k":[{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":40,"s":[0,0,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":45,"s":[100,100,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":51,"s":[108,108,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":66,"s":[100,100,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":191,"s":[100,100,100]},{"t":218,"s":[0,0,100],"h":1},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":378,"s":[100,100,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":385,"s":[100,100,100]},{"t":402,"s":[0,0,100]}],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-0.932,0],[0,-0.931],[0.932,0],[0,0.932]],"o":[[0.932,0],[0,0.932],[-0.932,0],[0,-0.931]],"v":[[0,-1.688],[1.687,-0.001],[0,1.688],[-1.687,-0.001]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[1,0.878431432387,0.415686304429,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[3.687,41.708],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,-9.232],[10.395,-0.857]],"o":[[8.447,2.438],[0,10.615],[0,0]],"v":[[-5.344,-19.82],[9.281,-0.361],[-9.281,19.82]],"c":false},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[14.655,21.819],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 2","np":2,"cix":2,"bm":0,"ix":2,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":600,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":7,"ty":4,"nm":"network-small","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":235,"s":[100]},{"t":243,"s":[0],"h":1},{"t":265,"s":[100],"h":1},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":319,"s":[100]},{"t":327,"s":[0],"h":1}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[168.65,44.817,0],"ix":2,"l":2},"a":{"a":0,"k":[3.912,13.78,0],"ix":1,"l":2},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":211,"s":[0,0,100]},{"t":222,"s":[100,100,100],"h":1},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":265,"s":[0,0,100]},{"t":276,"s":[100,100,100]}],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,-4.365],[2.407,-3.331]],"o":[[2.348,3.306],[0,4.424],[0,0]],"v":[[-1.816,-11.78],[1.913,-0.067],[-1.913,11.78]],"c":false},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[3.913,13.78],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":600,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":8,"ty":4,"nm":"network-small","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":235,"s":[100]},{"t":243,"s":[0],"h":1},{"t":265,"s":[100],"h":1},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":319,"s":[100]},{"t":327,"s":[0],"h":1}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[131.975,44.817,0],"ix":2,"l":2},"a":{"a":0,"k":[3.912,13.78,0],"ix":1,"l":2},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":211,"s":[0,0,100]},{"t":222,"s":[100,100,100],"h":1},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":265,"s":[0,0,100]},{"t":276,"s":[100,100,100]}],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,-4.365],[-2.407,-3.331]],"o":[[-2.348,3.306],[0,4.424],[0,0]],"v":[[1.816,-11.78],[-1.913,-0.067],[1.913,11.78]],"c":false},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[3.912,13.78],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":600,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":9,"ty":4,"nm":"network-large","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":246,"s":[100]},{"t":254,"s":[0],"h":1},{"t":276,"s":[100],"h":1},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":308,"s":[100]},{"t":316,"s":[0],"h":1}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[172.999,44.817,0],"ix":2,"l":2},"a":{"a":0,"k":[4.625,17.738,0],"ix":1,"l":2},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":222,"s":[0,0,100]},{"t":233,"s":[100,100,100],"h":1},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":276,"s":[0,0,100]},{"t":287,"s":[100,100,100]}],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,-5.868],[3.298,-4.406]],"o":[[3.238,4.383],[0,5.927],[0,0]],"v":[[-2.527,-15.738],[2.626,-0.066],[-2.626,15.738]],"c":false},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[4.625,17.737],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":600,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":10,"ty":4,"nm":"network-large","sr":1,"ks":{"o":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":246,"s":[100]},{"t":254,"s":[0],"h":1},{"t":276,"s":[100],"h":1},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":308,"s":[100]},{"t":316,"s":[0],"h":1}],"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[127.626,44.817,0],"ix":2,"l":2},"a":{"a":0,"k":[4.625,17.738,0],"ix":1,"l":2},"s":{"a":1,"k":[{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":222,"s":[0,0,100]},{"t":233,"s":[100,100,100],"h":1},{"i":{"x":[0.667,0.667,0.667],"y":[1,1,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":276,"s":[0,0,100]},{"t":287,"s":[100,100,100]}],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,-5.868],[-3.298,-4.406]],"o":[[-3.238,4.383],[0,5.927],[0,0]],"v":[[2.527,-15.738],[-2.626,-0.066],[2.626,15.738]],"c":false},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[4.625,17.737],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":600,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":11,"ty":3,"nm":"null-body ","sr":1,"ks":{"o":{"a":0,"k":0,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":216,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":225,"s":[-10]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":243,"s":[10]},{"t":252,"s":[0]}],"ix":10},"p":{"a":0,"k":[90,101,0],"ix":2,"l":2},"a":{"a":0,"k":[0,11,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"ip":0,"op":600,"st":0,"bm":0},{"ddd":0,"ind":12,"ty":4,"nm":"hand-right ","parent":11,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":15,"s":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":23,"s":[26]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":308,"s":[26]},{"t":317,"s":[0],"h":1},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":378,"s":[26]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":414,"s":[26]},{"t":423,"s":[0]}],"ix":10},"p":{"a":0,"k":[31.615,10.647,0],"ix":2,"l":2},"a":{"a":0,"k":[7.62,2.379,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[-0.469,-0.257],[14.905,-11.105],[-2.867,9.613],[-4.387,7.038]],"o":[[-0.146,-0.515],[4.244,2.323],[0,0],[0,0],[0,0]],"v":[[-6.294,-13.745],[-5.426,-14.434],[-3.238,7.488],[-8.799,5.079],[-3.74,-4.723]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[0.572549019608,0.478431402468,0.839215746113,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[13.667,16.691],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":600,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":13,"ty":4,"nm":"hand-left ","parent":11,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":15,"s":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":23,"s":[-26]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":308,"s":[-26]},{"t":317,"s":[0],"h":1},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":378,"s":[-26]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":414,"s":[-26]},{"t":423,"s":[0]}],"ix":10},"p":{"a":0,"k":[-31.366,10.897,0],"ix":2,"l":2},"a":{"a":0,"k":[19.478,2.629,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0.471,-0.258],[-14.903,-11.103],[2.867,9.613],[4.387,7.037]],"o":[[0.146,-0.516],[-4.246,2.325],[0,0],[0,0],[0,0]],"v":[[6.292,-13.742],[5.421,-14.433],[3.238,7.488],[8.798,5.078],[3.738,-4.722]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[0.572549019608,0.478431402468,0.839215746113,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[13.665,16.691],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":600,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":14,"ty":4,"nm":"eyes ","parent":11,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":0,"s":[0.213,-2.898,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":6,"s":[0.463,3,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":51,"s":[0.463,3,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":58,"s":[0.2,-2.898,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":79,"s":[0.2,-2.9,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":82,"s":[-6.787,-2.898,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":96,"s":[-6.8,-2.899,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":100,"s":[0.2,-2.9,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":133,"s":[0.2,-2.9,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":136,"s":[5,-9.9,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":151,"s":[5,-9.9,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":155,"s":[0.2,-2.9,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":297,"s":[0.213,-2.898,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":303,"s":[0.463,3,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":322,"s":[0.463,3,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":329,"s":[0.2,-2.898,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":408,"s":[0.213,-2.898,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":414,"s":[0.463,3,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":422,"s":[0.463,3,0],"to":[0,0,0],"ti":[0,0,0]},{"t":429,"s":[0.2,-2.898,0]}],"ix":2,"l":2},"a":{"a":0,"k":[17.045,9.606,0],"ix":1,"l":2},"s":{"a":1,"k":[{"i":{"x":[0.833,0.833,0.833],"y":[1,0.833,1]},"o":{"x":[0.333,0.333,0.333],"y":[0,0,0]},"t":19,"s":[100,100,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":23,"s":[100,7.967,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":37,"s":[100,8,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":40,"s":[100,100,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":112,"s":[100,100,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":114,"s":[100,8,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":118,"s":[100,8,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":120,"s":[100,100,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":169,"s":[100,100,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":171,"s":[100,8,100]},{"i":{"x":[0.833,0.833,0.833],"y":[0.833,0.833,0.833]},"o":{"x":[0.167,0.167,0.167],"y":[0.167,0.167,0.167]},"t":175,"s":[100,8,100]},{"t":178,"s":[100,100,100]}],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,-4.201],[1.872,0],[0,4.201],[-1.873,0]],"o":[[0,4.201],[-1.873,0],[0,-4.201],[1.872,0]],"v":[[3.391,0],[-0.001,7.606],[-3.391,0],[-0.001,-7.606]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[28.7,9.606],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,-4.201],[1.873,0],[0,4.201],[-1.872,0]],"o":[[0,4.201],[-1.872,0],[0,-4.201],[1.873,0]],"v":[[3.391,0],[-0.001,7.606],[-3.391,0],[-0.001,-7.606]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[5.391,9.606],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 2","np":3,"cix":2,"bm":0,"ix":2,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":600,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":15,"ty":4,"nm":"socket ","parent":11,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":15,"s":[31.022,33.297,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":23,"s":[23,33.297,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":1},"o":{"x":0.167,"y":0.167},"t":308,"s":[23,33.297,0],"to":[0,0,0],"ti":[0,0,0]},{"t":318,"s":[31.022,33.297,0],"h":1},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":378,"s":[23,33.297,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":1},"o":{"x":0.167,"y":0.167},"t":414,"s":[23,33.297,0],"to":[0,0,0],"ti":[0,0,0]},{"t":424,"s":[31.022,33.297,0]}],"ix":2,"l":2},"a":{"a":0,"k":[24.058,14.693,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[-1.1,0],[0,0],[0,-1.1],[0,0],[1.1,0],[0,0],[0,1.1]],"o":[[0,-1.1],[0,0],[1.1,0],[0,0],[0,1.1],[0,0],[-1.1,0],[0,0]],"v":[[-2.435,-7.07],[-0.435,-9.07],[0.435,-9.07],[2.435,-7.07],[2.435,7.07],[0.435,9.07],[-0.435,9.07],[-2.435,7.07]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[0.964705942191,0.901960844152,0.658823529412,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[4.435,11.07],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,-3.981],[3.98,0],[0,0]],"o":[[0,0],[3.98,0],[0,3.981],[0,0],[0,0]],"v":[[-6.771,-7.208],[-0.438,-7.208],[6.771,0.001],[-0.438,7.208],[-6.771,7.208]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[1,0.878431432387,0.415686304429,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[10.534,11.07],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 2","np":3,"cix":2,"bm":0,"ix":2,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0.696,0.681],[4.036,0.072],[0,0],[-17.923,-16.81],[0.72,-0.711]],"o":[[-13.443,-13.126],[0,0],[0,0],[0.739,0.693],[-0.693,0.685]],"v":[[12.516,9.362],[-15.743,-4.76],[-15.743,-7.963],[15.001,6.767],[15.023,9.345]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[0.768627510819,0.768627510819,0.768627510819,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[30.373,17.343],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 3","np":3,"cix":2,"bm":0,"ix":3,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":600,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":16,"ty":4,"nm":"plug ","parent":11,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":1,"k":[{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":15,"s":[-26.789,33.296,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":23,"s":[-18,33.296,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":1},"o":{"x":0.167,"y":0.167},"t":308,"s":[-18,33.296,0],"to":[0,0,0],"ti":[0,0,0]},{"t":317,"s":[-26.789,33.296,0],"h":1},{"i":{"x":0.833,"y":0.833},"o":{"x":0.167,"y":0.167},"t":378,"s":[-18,33.296,0],"to":[0,0,0],"ti":[0,0,0]},{"i":{"x":0.833,"y":1},"o":{"x":0.167,"y":0.167},"t":414,"s":[-18,33.296,0],"to":[0,0,0],"ti":[0,0,0]},{"t":423,"s":[-26.789,33.296,0]}],"ix":2,"l":2},"a":{"a":0,"k":[27.268,14.693,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[1.1,0],[0,0],[0,1.101],[0,0],[-1.1,0],[0,0],[0,-1.099]],"o":[[0,1.101],[0,0],[-1.1,0],[0,0],[0,-1.099],[0,0],[1.1,0],[0,0]],"v":[[2.435,7.07],[0.435,9.07],[-0.435,9.07],[-2.435,7.07],[-2.435,-7.07],[-0.435,-9.07],[0.435,-9.07],[2.435,-7.07]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[0.964705942191,0.901960844152,0.658823529412,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[43.486,11.07],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0.82,0],[0,0],[0,0],[0,0],[0,-0.821]],"o":[[0,0],[0,0],[0,0],[0.82,0],[0,0.819]],"v":[[3.933,1.484],[-5.417,1.484],[-5.417,-1.484],[3.933,-1.484],[5.417,0.001]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[0.768627510819,0.768627510819,0.768627510819,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[47.119,14.778],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 2","np":3,"cix":2,"bm":0,"ix":2,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0.82,0],[0,0],[0,0],[0,0],[0,-0.82]],"o":[[0,0],[0,0],[0,0],[0.82,0],[0,0.819]],"v":[[3.933,1.484],[-5.417,1.484],[-5.417,-1.484],[3.933,-1.484],[5.417,0.001]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[0.768627510819,0.768627510819,0.768627510819,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[47.119,7.363],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 3","np":3,"cix":2,"bm":0,"ix":3,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,3.981],[-3.981,0],[0,0]],"o":[[0,0],[-3.981,0],[0,-3.981],[0,0],[0,0]],"v":[[6.771,7.208],[0.438,7.208],[-6.771,0.001],[0.438,-7.208],[6.771,-7.208]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[1,0.878431432387,0.415686304429,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[37.387,11.07],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 4","np":3,"cix":2,"bm":0,"ix":4,"mn":"ADBE Vector Group","hd":false},{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-0.696,0.681],[-4.036,0.072],[0,0],[17.924,-16.81],[-0.72,-0.711]],"o":[[13.443,-13.126],[0,0],[0,0],[-0.738,0.693],[0.693,0.685]],"v":[[-12.515,9.362],[15.742,-4.76],[15.742,-7.963],[-15.001,6.767],[-15.022,9.345]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[0.768627510819,0.768627510819,0.768627510819,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[17.742,17.343],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 5","np":3,"cix":2,"bm":0,"ix":5,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":600,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":17,"ty":4,"nm":"body ","parent":11,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[-0.017,-4.078,0],"ix":2,"l":2},"a":{"a":0,"k":[37.53,43.53,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0.61,-3.511],[0.08,-0.38],[0.069,-0.28],[0.03,-0.1],[2.54,-3.51],[2.45,-1.981],[0.639,-0.45],[1.029,-0.591],[0.66,-0.32],[0.68,-0.28],[0.861,-0.28],[0.77,-0.189],[0.281,-0.069],[2.509,0],[0,0],[5.781,12],[-2.75,7.73],[-4.95,4.051],[-2.63,2.12],[-1.01,1.029],[-0.29,0.381],[0.06,1.44],[0.179,1.27],[-1,0.109],[-0.39,-0.201],[0,0],[0,0],[0,0],[0,0],[0,0],[-0.13,-0.131],[-0.069,-0.11],[0,-0.411],[0,0],[-0.029,-0.409],[-0.02,-0.199],[-0.02,-0.159],[-0.09,-0.29],[-0.05,-0.14],[-0.04,-0.091],[-0.071,-0.109],[-0.09,-0.111],[-0.031,-0.04],[-0.55,-0.549],[-0.139,-0.141],[-2.41,-1.94],[-4.18,-5.951],[-0.83,-2.4],[-0.071,-0.241],[-0.05,-0.21],[-0.17,-0.9]],"o":[[-0.06,0.38],[-0.059,0.28],[-0.021,0.09],[-1.061,4.23],[-1.861,2.55],[-0.611,0.49],[-0.971,0.68],[-0.641,0.359],[-0.66,0.321],[-0.84,0.34],[-0.759,0.241],[-0.28,0.07],[-2.45,0.531],[0,0],[-13.32,0],[-3.54,-7.34],[2.18,-6.091],[2.62,-2.139],[2.72,-2.19],[0.551,-0.56],[1.03,-1.369],[-0.121,-2.79],[-0.161,-1.17],[0.361,-0.06],[0,0],[0,0],[0,0],[0,0],[0,0],[0.15,0.091],[0.091,0.09],[0.221,0.33],[0,0],[0,0.38],[0.011,0.201],[0.02,0.15],[0.04,0.301],[0.049,0.149],[0.04,0.09],[0.05,0.119],[0.059,0.12],[0.021,0.04],[0.279,0.37],[0.12,0.13],[1.02,0.98],[5.571,4.48],[1.461,2.089],[0.08,0.23],[0.069,0.21],[0.26,0.88],[0.679,3.5]],"v":[[34.92,12.91],[34.7,14.051],[34.511,14.889],[34.441,15.18],[28.941,26.88],[22.441,33.721],[20.561,35.139],[17.561,37.04],[15.62,38.059],[13.62,38.96],[11.07,39.889],[8.78,40.529],[7.95,40.729],[0.481,41.529],[0.45,41.529],[-31.09,21.699],[-32.78,-1.6],[-21.46,-16.561],[-13.44,-22.771],[-8.11,-27.41],[-6.9,-28.79],[-5.809,-33.45],[-6.269,-39.26],[-4.65,-41.469],[-3.51,-41.26],[0.45,-39.191],[0.481,-39.18],[0.481,-39.171],[5,-36.611],[5.71,-36.21],[6.13,-35.889],[6.38,-35.59],[6.721,-34.469],[6.721,-33.43],[6.75,-32.251],[6.8,-31.65],[6.86,-31.191],[7.061,-30.299],[7.21,-29.861],[7.33,-29.579],[7.521,-29.23],[7.74,-28.889],[7.811,-28.771],[9,-27.421],[9.4,-27.01],[14.36,-22.751],[30.3,-8.51],[33.74,-1.73],[33.971,-1.029],[34.16,-0.4],[34.811,2.27]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[0.572549019608,0.478431402468,0.839215746113,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[37.53,43.53],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":600,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":18,"ty":3,"nm":"null-foot-leg-right ","sr":1,"ks":{"o":{"a":0,"k":0,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":216,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":225,"s":[-16]},{"t":234,"s":[0]}],"ix":10},"p":{"a":0,"k":[104.625,119.5,0],"ix":2,"l":2},"a":{"a":0,"k":[14.625,29.5,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"ip":0,"op":600,"st":0,"bm":0},{"ddd":0,"ind":19,"ty":4,"nm":"foot-right ","parent":18,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.167],"y":[0.167]},"t":100,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":106,"s":[-16.958]},{"t":112,"s":[0]}],"ix":10},"p":{"a":0,"k":[12.563,62.71,0],"ix":2,"l":2},"a":{"a":0,"k":[3.168,10.693,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,-4.229],[0,4.229],[5.063,0]],"o":[[0,4.229],[0,-4.229],[-5.064,0]],"v":[[-9.168,1.714],[9.168,1.714],[0,-5.943]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[0.572549019608,0.478431402468,0.839215746113,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[11.168,7.944],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":600,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":20,"ty":4,"nm":"leg-right ","parent":18,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[14.726,61.506,0],"ix":2,"l":2},"a":{"a":0,"k":[4.042,31.23,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0]],"v":[[-2.628,14.816],[2.628,14.816],[2.628,-14.816],[-2.628,-14.816]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[0.572549019608,0.478431402468,0.839215746113,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[4.042,16.23],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":600,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":21,"ty":3,"nm":"null-foot-leg-left","sr":1,"ks":{"o":{"a":0,"k":0,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":234,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":243,"s":[16]},{"t":252,"s":[0]}],"ix":10},"p":{"a":0,"k":[76.125,119.75,0],"ix":2,"l":2},"a":{"a":0,"k":[-13.706,29.818,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"ip":0,"op":600,"st":0,"bm":0},{"ddd":0,"ind":22,"ty":4,"nm":"foot-left ","parent":21,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.167],"y":[0.167]},"t":115,"s":[0]},{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":122,"s":[14]},{"t":128,"s":[0]}],"ix":10},"p":{"a":0,"k":[-11.138,62.21,0],"ix":2,"l":2},"a":{"a":0,"k":[19.667,10.193,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,-4.229],[0,4.229],[-5.064,0]],"o":[[0,4.229],[0,-4.229],[5.063,0]],"v":[[9.167,1.714],[-9.167,1.714],[0,-5.943]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[0.572549019608,0.478431402468,0.839215746113,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[11.167,7.944],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":600,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":23,"ty":4,"nm":"leg-left ","parent":21,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[-13.8,46.604,0],"ix":2,"l":2},"a":{"a":0,"k":[4.041,16.327,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,0],[0,0],[0,0],[0,0]],"o":[[0,0],[0,0],[0,0],[0,0]],"v":[[2.627,14.913],[-2.627,14.913],[-2.627,-14.913],[2.627,-14.913]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[0.572549019608,0.478431402468,0.839215746113,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[4.041,16.327],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":600,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":24,"ty":4,"nm":"feather-right ","parent":11,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[2.257,-40.214,0],"ix":2,"l":2},"a":{"a":0,"k":[4.979,16.819,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[-1.92,-1.305],[-0.994,2.399],[-2.288,2.372],[4.027,-4.656],[0.654,-1.84]],"o":[[0.396,-1.953],[2.156,-5.198],[-2.176,0.596],[-2.233,2.583],[1.92,1.304]],"v":[[-1.844,8.944],[0.169,2.347],[7.605,-8.944],[-3.521,-2.013],[-7.605,5.031]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[0.549019607843,0.901960844152,0.803921628466,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[9.604,10.944],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":600,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":25,"ty":4,"nm":"feather-left ","parent":11,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[-2.563,-41.523,0],"ix":2,"l":2},"a":{"a":0,"k":[9.913,18.048,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[1.773,0.237],[1.134,3.207],[1.239,1.692],[-2.752,-3.696],[0.074,-1.377]],"o":[[-0.114,-2.056],[-1.171,-3.316],[1.418,0.498],[3.356,4.509],[-1.773,-0.236]],"v":[[0.059,7.463],[-1.565,-0.649],[-5.538,-8.173],[2.182,-2.518],[5.378,8.173]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[0.549019607843,0.901960844152,0.803921628466,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[7.538,10.173],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":600,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":26,"ty":4,"nm":"feather-center ","parent":11,"sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[1.25,-36.84,0],"ix":2,"l":2},"a":{"a":0,"k":[4.789,33.995,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[1.865,0.364],[-0.623,5.891],[-1.236,4.546],[-0.391,-6.65],[0.616,-4.418]],"o":[[-0.218,-4.542],[0.653,-6.176],[1.225,4.483],[0.367,6.262],[-1.865,-0.364]],"v":[[-3.197,15.403],[-2.745,-0.342],[0.286,-16.495],[3.048,0.332],[2.4,16.495]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"st","c":{"a":0,"k":[0.294117647059,0.290196078431,0.560784313725,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":2,"ix":5},"lc":2,"lj":2,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"fl","c":{"a":0,"k":[0.549019607843,0.901960844152,0.803921628466,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[5.414,18.495],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":600,"st":0,"ct":1,"bm":0},{"ddd":0,"ind":27,"ty":4,"nm":"floor ","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[89.799,153.743,0],"ix":2,"l":2},"a":{"a":0,"k":[48.548,6.287,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,-3.334],[26.675,0],[0,3.334],[-26.674,0]],"o":[[0,3.334],[-26.674,0],[0,-3.334],[26.675,0]],"v":[[48.298,0],[0,6.037],[-48.298,0],[0,-6.037]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"fl","c":{"a":0,"k":[0.921568687289,0.921568687289,0.921568687289,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[48.548,6.287],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Group 1","np":2,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":600,"st":0,"ct":1,"bm":0}],"markers":[{"tm":75,"cm":"connecting-start","dr":0},{"tm":165,"cm":"connecting-end","dr":0},{"tm":255,"cm":"connected-start","dr":0},{"tm":290,"cm":"connected-end","dr":0},{"tm":297,"cm":"disconnection-start","dr":0},{"tm":341,"cm":"disconnection-end","dr":0},{"tm":378,"cm":"failed-start","dr":0},{"tm":433,"cm":"failed-end","dr":0}]} \ No newline at end of file diff --git a/asset_sources/other/playstore_icon/stack_duo/app_icon-playstore.png b/asset_sources/other/playstore_icon/stack_duo/app_icon-playstore.png new file mode 100644 index 000000000..3078ee9e2 Binary files /dev/null and b/asset_sources/other/playstore_icon/stack_duo/app_icon-playstore.png differ diff --git a/android/app/src/main/app_icon-playstore.png b/asset_sources/other/playstore_icon/stack_wallet/app_icon-playstore.png similarity index 100% rename from android/app/src/main/app_icon-playstore.png rename to asset_sources/other/playstore_icon/stack_wallet/app_icon-playstore.png diff --git a/crypto_plugins/flutter_libmonero b/crypto_plugins/flutter_libmonero index 2c684cedb..6e71b956c 160000 --- a/crypto_plugins/flutter_libmonero +++ b/crypto_plugins/flutter_libmonero @@ -1 +1 @@ -Subproject commit 2c684cedba6c3d9353c7ea748cadb5a246008027 +Subproject commit 6e71b956c3801f65a662c7f140e871c246166db3 diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png deleted file mode 100644 index bf0e52d56..000000000 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png and /dev/null differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png deleted file mode 100644 index 8ec20c962..000000000 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png and /dev/null differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png deleted file mode 100644 index 7cf1c3f05..000000000 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png and /dev/null differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png deleted file mode 100644 index 77bd1ebee..000000000 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png and /dev/null differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png deleted file mode 100644 index 58a18fd25..000000000 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png and /dev/null differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png deleted file mode 100644 index c4fc493e5..000000000 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png and /dev/null differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png deleted file mode 100644 index bb4d9059b..000000000 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png and /dev/null differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png deleted file mode 100644 index 7cf1c3f05..000000000 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png and /dev/null differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png deleted file mode 100644 index 5057e0501..000000000 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png and /dev/null differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png deleted file mode 100644 index 7e15811d5..000000000 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png and /dev/null differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png deleted file mode 100644 index 7e15811d5..000000000 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png and /dev/null differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png deleted file mode 100644 index 734d47915..000000000 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png and /dev/null differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png deleted file mode 100644 index 1beac09a1..000000000 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png and /dev/null differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png deleted file mode 100644 index def4d5e02..000000000 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png and /dev/null differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png deleted file mode 100644 index b332a550b..000000000 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png and /dev/null differ diff --git a/lib/app_config.dart b/lib/app_config.dart new file mode 100644 index 000000000..4b7003177 --- /dev/null +++ b/lib/app_config.dart @@ -0,0 +1,72 @@ +import 'wallets/crypto_currency/crypto_currency.dart'; +import 'wallets/crypto_currency/intermediate/frost_currency.dart'; + +part 'app_config.g.dart'; + +abstract class AppConfig { + static const appName = _prefix + _separator + suffix; + + static const prefix = _prefix; + static const suffix = _suffix; + + static String get appDefaultDataDirName => _appDataDirName; + static String get commitHash => _commitHash; + + static ({String light, String dark})? get appIconAsset => _appIconAsset; + + static List get coins => _supportedCoins; + + static CryptoCurrency? getCryptoCurrencyFor(String coinIdentifier) { + try { + return coins.firstWhere((e) => e.identifier == coinIdentifier); + } catch (_) { + return null; + } + } + + static CryptoCurrency? getCryptoCurrencyForTicker( + final String ticker, { + bool caseInsensitive = true, + }) { + final _ticker = caseInsensitive ? ticker.toLowerCase() : ticker; + try { + return coins.firstWhere( + caseInsensitive + ? (e) => e.ticker.toLowerCase() == _ticker && e is! FrostCurrency + : (e) => e.ticker == _ticker && e is! FrostCurrency, + ); + } catch (_) { + return null; + } + } + + static bool isStackCoin(String? ticker) { + if (ticker == null) { + return false; + } + + if (getCryptoCurrencyForTicker(ticker, caseInsensitive: false) != null) { + return true; + } + + try { + getCryptoCurrencyByPrettyName(ticker); + return true; + } catch (_) { + return false; + } + } + + /// Fuzzy logic. Use with caution!! + @Deprecated("dangerous") + static CryptoCurrency getCryptoCurrencyByPrettyName(final String prettyName) { + final name = prettyName.replaceAll(" ", "").toLowerCase(); + try { + return coins.firstWhere( + (e) => e.identifier.toLowerCase() == name || e.prettyName == prettyName, + ); + } catch (_) { + throw Exception("getCryptoCurrencyByPrettyName($prettyName) failed!"); + } + } +} diff --git a/lib/db/db_version_migration.dart b/lib/db/db_version_migration.dart index eb75bf5b1..fe563f5ea 100644 --- a/lib/db/db_version_migration.dart +++ b/lib/db/db_version_migration.dart @@ -10,33 +10,31 @@ import 'package:hive/hive.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/db/hive/db.dart'; -import 'package:stackwallet/db/isar/main_db.dart'; -import 'package:stackwallet/db/migrate_wallets_to_isar.dart'; -import 'package:stackwallet/electrumx_rpc/electrumx_client.dart'; -import 'package:stackwallet/models/contact.dart'; -import 'package:stackwallet/models/exchange/change_now/exchange_transaction.dart'; -import 'package:stackwallet/models/exchange/response_objects/trade.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/models/isar/models/contact_entry.dart' - as isar_contact; -import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; -import 'package:stackwallet/models/models.dart'; -import 'package:stackwallet/models/node_model.dart'; -import 'package:stackwallet/services/mixins/wallet_db.dart'; -import 'package:stackwallet/services/node_service.dart'; -import 'package:stackwallet/services/wallets_service.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/default_nodes.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/prefs.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/firo.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; import 'package:tuple/tuple.dart'; +import '../app_config.dart'; +import '../electrumx_rpc/electrumx_client.dart'; +import '../models/contact.dart'; +import '../models/exchange/change_now/exchange_transaction.dart'; +import '../models/exchange/response_objects/trade.dart'; +import '../models/isar/models/blockchain_data/address.dart'; +import '../models/isar/models/contact_entry.dart' as isar_contact; +import '../models/isar/models/isar_models.dart' as isar_models; +import '../models/models.dart'; +import '../models/node_model.dart'; +import '../services/mixins/wallet_db.dart'; +import '../services/node_service.dart'; +import '../services/wallets_service.dart'; +import '../utilities/amount/amount.dart'; +import '../utilities/constants.dart'; +import '../utilities/flutter_secure_storage_interface.dart'; +import '../utilities/logger.dart'; +import '../utilities/prefs.dart'; +import '../wallets/crypto_currency/crypto_currency.dart'; +import 'hive/db.dart'; +import 'isar/main_db.dart'; +import 'migrate_wallets_to_isar.dart'; + class DbVersionMigrator with WalletDB { Future migrate( int fromVersion, { @@ -59,14 +57,16 @@ class DbVersionMigrator with WalletDB { ElectrumXClient? client; int? latestSetId; + final firo = Firo(CryptoCurrencyNetwork.main); // only instantiate client if there are firo wallets - if (walletInfoList.values.any((element) => element.coin == Coin.firo)) { + if (walletInfoList.values + .any((element) => element.coinIdentifier == firo.identifier)) { await Hive.openBox(DB.boxNameNodeModels); await Hive.openBox(DB.boxNamePrimaryNodes); - final node = nodeService.getPrimaryNodeFor(coin: Coin.firo) ?? - DefaultNodes.firo; - List failovers = nodeService - .failoverNodesFor(coin: Coin.firo) + final node = + nodeService.getPrimaryNodeFor(currency: firo) ?? firo.defaultNode; + final List failovers = nodeService + .failoverNodesFor(currency: firo) .map( (e) => ElectrumXNode( address: e.host, @@ -80,11 +80,12 @@ class DbVersionMigrator with WalletDB { client = ElectrumXClient.from( node: ElectrumXNode( - address: node.host, - port: node.port, - name: node.name, - id: node.id, - useSSL: node.useSSL), + address: node.host, + port: node.port, + name: node.name, + id: node.id, + useSSL: node.useSSL, + ), prefs: prefs, failovers: failovers, cryptoCurrency: Firo(CryptoCurrencyNetwork.main), @@ -96,26 +97,29 @@ class DbVersionMigrator with WalletDB { // default to 2 for now latestSetId = 2; Logging.instance.log( - "Failed to fetch latest coin id during firo db migrate: $e \nUsing a default value of 2", - level: LogLevel.Warning); + "Failed to fetch latest coin id during firo db migrate: $e \nUsing a default value of 2", + level: LogLevel.Warning, + ); } } for (final walletInfo in walletInfoList.values) { // migrate each firo wallet's lelantus coins - if (walletInfo.coin == Coin.firo) { + if (walletInfo.coinIdentifier == firo.identifier) { await Hive.openBox(walletInfo.walletId); final _lelantusCoins = DB.instance.get( - boxName: walletInfo.walletId, key: '_lelantus_coins') as List?; + boxName: walletInfo.walletId, + key: '_lelantus_coins', + ) as List?; final List> lelantusCoins = []; - for (var lCoin in _lelantusCoins ?? []) { + for (final lCoin in _lelantusCoins ?? []) { lelantusCoins .add({lCoin.keys.first: lCoin.values.first as LelantusCoin}); } - List> coins = []; + final List> coins = []; for (final element in lelantusCoins) { - LelantusCoin coin = element.values.first; + final LelantusCoin coin = element.values.first; int anonSetId = coin.anonymitySetId; if (coin.anonymitySetId == 1 && (coin.publicCoin == '' || @@ -123,21 +127,31 @@ class DbVersionMigrator with WalletDB { anonSetId = latestSetId!; } coins.add({ - element.keys.first: LelantusCoin(coin.index, coin.value, - coin.publicCoin, coin.txId, anonSetId, coin.isUsed) + element.keys.first: LelantusCoin( + coin.index, + coin.value, + coin.publicCoin, + coin.txId, + anonSetId, + coin.isUsed, + ), }); } Logger.print("newcoins $coins", normalLength: false); await DB.instance.put( - boxName: walletInfo.walletId, - key: '_lelantus_coins', - value: coins); + boxName: walletInfo.walletId, + key: '_lelantus_coins', + value: coins, + ); } } // update version await DB.instance.put( - boxName: DB.boxNameDBInfo, key: "hive_data_version", value: 1); + boxName: DB.boxNameDBInfo, + key: "hive_data_version", + value: 1, + ); // try to continue migrating return await migrate(1, secureStore: secureStore); @@ -161,7 +175,10 @@ class DbVersionMigrator with WalletDB { // update version await DB.instance.put( - boxName: DB.boxNameDBInfo, key: "hive_data_version", value: 2); + boxName: DB.boxNameDBInfo, + key: "hive_data_version", + value: 2, + ); // try to continue migrating return await migrate(2, secureStore: secureStore); @@ -176,16 +193,26 @@ class DbVersionMigrator with WalletDB { // update version await DB.instance.put( - boxName: DB.boxNameDBInfo, key: "hive_data_version", value: 3); + boxName: DB.boxNameDBInfo, + key: "hive_data_version", + value: 3, + ); return await migrate(3, secureStore: secureStore); case 3: // clear possible broken firo cache - await DB.instance.clearSharedTransactionCache(coin: Coin.firo); + await DB.instance.clearSharedTransactionCache( + currency: Firo( + CryptoCurrencyNetwork.test, + ), + ); // update version await DB.instance.put( - boxName: DB.boxNameDBInfo, key: "hive_data_version", value: 4); + boxName: DB.boxNameDBInfo, + key: "hive_data_version", + value: 4, + ); // try to continue migrating return await migrate(4, secureStore: secureStore); @@ -196,7 +223,10 @@ class DbVersionMigrator with WalletDB { // update version await DB.instance.put( - boxName: DB.boxNameDBInfo, key: "hive_data_version", value: 5); + boxName: DB.boxNameDBInfo, + key: "hive_data_version", + value: 5, + ); // try to continue migrating return await migrate(5, secureStore: secureStore); @@ -212,11 +242,17 @@ class DbVersionMigrator with WalletDB { "light"; await DB.instance.put( - boxName: DB.boxNamePrefs, key: "theme", value: themeName); + boxName: DB.boxNamePrefs, + key: "theme", + value: themeName, + ); // update version await DB.instance.put( - boxName: DB.boxNameDBInfo, key: "hive_data_version", value: 6); + boxName: DB.boxNameDBInfo, + key: "hive_data_version", + value: 6, + ); // try to continue migrating return await migrate(6, secureStore: secureStore); @@ -287,7 +323,10 @@ class DbVersionMigrator with WalletDB { // update version await DB.instance.put( - boxName: DB.boxNameDBInfo, key: "hive_data_version", value: 7); + boxName: DB.boxNameDBInfo, + key: "hive_data_version", + value: 7, + ); // try to continue migrating return await migrate(7, secureStore: secureStore); @@ -298,7 +337,10 @@ class DbVersionMigrator with WalletDB { // update version await DB.instance.put( - boxName: DB.boxNameDBInfo, key: "hive_data_version", value: 8); + boxName: DB.boxNameDBInfo, + key: "hive_data_version", + value: 8, + ); // try to continue migrating return await migrate(8, secureStore: secureStore); @@ -311,8 +353,10 @@ class DbVersionMigrator with WalletDB { await MainDB.instance.initMainDB(); for (final walletId in walletInfoList.keys) { final info = walletInfoList[walletId]!; - if (info.coin == Coin.bitcoincash || - info.coin == Coin.bitcoincashTestnet) { + if (info.coinIdentifier == + Bitcoincash(CryptoCurrencyNetwork.main).identifier || + info.coinIdentifier == + Bitcoincash(CryptoCurrencyNetwork.test).identifier) { final ids = await MainDB.instance .getAddresses(walletId) .filter() @@ -328,7 +372,10 @@ class DbVersionMigrator with WalletDB { // update version await DB.instance.put( - boxName: DB.boxNameDBInfo, key: "hive_data_version", value: 9); + boxName: DB.boxNameDBInfo, + key: "hive_data_version", + value: 9, + ); // try to continue migrating return await migrate(9, secureStore: secureStore); @@ -339,7 +386,10 @@ class DbVersionMigrator with WalletDB { // update version await DB.instance.put( - boxName: DB.boxNameDBInfo, key: "hive_data_version", value: 10); + boxName: DB.boxNameDBInfo, + key: "hive_data_version", + value: 10, + ); // try to continue migrating return await migrate(10, secureStore: secureStore); @@ -350,7 +400,10 @@ class DbVersionMigrator with WalletDB { // update version await DB.instance.put( - boxName: DB.boxNameDBInfo, key: "hive_data_version", value: 11); + boxName: DB.boxNameDBInfo, + key: "hive_data_version", + value: 11, + ); // try to continue migrating return await migrate(11, secureStore: secureStore); @@ -361,7 +414,10 @@ class DbVersionMigrator with WalletDB { // update version await DB.instance.put( - boxName: DB.boxNameDBInfo, key: "hive_data_version", value: 12); + boxName: DB.boxNameDBInfo, + key: "hive_data_version", + value: 12, + ); // try to continue migrating return await migrate(12, secureStore: secureStore); @@ -392,7 +448,8 @@ class DbVersionMigrator with WalletDB { // we need to manually migrate epic cash transactions as they are not // stored on the epic cash blockchain - if (info.coin == Coin.epicCash) { + final epic = Epiccash(CryptoCurrencyNetwork.main); + if (info.coinIdentifier == epic.identifier) { final txnData = walletBox.get("latest_tx_model") as TransactionData?; // we ever only used index 0 in the past @@ -404,7 +461,7 @@ class DbVersionMigrator with WalletDB { final txns = txnData.getAllTransactions(); for (final tx in txns.values) { - bool isIncoming = tx.txType == "Received"; + final bool isIncoming = tx.txType == "Received"; final iTx = isar_models.Transaction( walletId: walletId, @@ -417,7 +474,7 @@ class DbVersionMigrator with WalletDB { amount: tx.amount, amountString: Amount( rawValue: BigInt.from(tx.amount), - fractionDigits: info.coin.decimals, + fractionDigits: epic.fractionDigits, ).toJsonString(), fee: tx.fees, height: tx.height, @@ -470,12 +527,14 @@ class DbVersionMigrator with WalletDB { if ((await secureStore.read(key: '${walletId}_mnemonicPassphrase')) == null) { await secureStore.write( - key: '${walletId}_mnemonicPassphrase', value: ""); + key: '${walletId}_mnemonicPassphrase', + value: "", + ); } // doing this for epic cash will delete transaction history as it is not // stored on the epic cash blockchain - if (info.coin != Coin.epicCash) { + if (info.coinIdentifier != epic.identifier) { // set flag to initiate full rescan on opening wallet await DB.instance.put( boxName: DB.boxNameDBInfo, @@ -498,6 +557,8 @@ class DbVersionMigrator with WalletDB { final count = await MainDB.instance.getTransactions(walletId).count(); + final crypto = AppConfig.getCryptoCurrencyFor(info.coinIdentifier)!; + for (var i = 0; i < count; i += 50) { final txns = await MainDB.instance .getTransactions(walletId) @@ -512,7 +573,7 @@ class DbVersionMigrator with WalletDB { tx ..amountString = Amount( rawValue: BigInt.from(tx.amount), - fractionDigits: info.coin.decimals, + fractionDigits: crypto.fractionDigits, ).toJsonString(), tx.address.value, ), @@ -531,11 +592,13 @@ class DbVersionMigrator with WalletDB { final keys = List.from(addressBookBox.keys); final contacts = keys - .map((id) => Contact.fromJson( - Map.from( - addressBookBox.get(id) as Map, - ), - )) + .map( + (id) => Contact.fromJson( + Map.from( + addressBookBox.get(id) as Map, + ), + ), + ) .toList(growable: false); final List newContacts = []; @@ -547,7 +610,7 @@ class DbVersionMigrator with WalletDB { for (final entry in contact.addresses) { newContactAddressEntries.add( isar_contact.ContactAddressEntry() - ..coinName = entry.coin.name + ..coinName = entry.coin.identifier ..address = entry.address ..label = entry.label ..other = entry.other, @@ -580,11 +643,13 @@ class DbVersionMigrator with WalletDB { await prefs.init(); await MainDB.instance.initMainDB(); + final firo = Firo(CryptoCurrencyNetwork.main); + for (final walletId in walletInfoList.keys) { final info = walletInfoList[walletId]!; assert(info.walletId == walletId); - if (info.coin == Coin.firo && + if (info.coinIdentifier == firo.identifier && MainDB.instance.isar.lelantusCoins .where() .walletIdEqualTo(walletId) diff --git a/lib/db/hive/db.dart b/lib/db/hive/db.dart index 6f4ebd3c3..3f1c86cb7 100644 --- a/lib/db/hive/db.dart +++ b/lib/db/hive/db.dart @@ -13,13 +13,14 @@ import 'dart:isolate'; import 'package:cw_core/wallet_info.dart' as xmr; import 'package:hive/hive.dart'; import 'package:mutex/mutex.dart'; -import 'package:stackwallet/models/exchange/response_objects/trade.dart'; -import 'package:stackwallet/models/node_model.dart'; -import 'package:stackwallet/models/notification_model.dart'; -import 'package:stackwallet/models/trade_wallet_lookup.dart'; -import 'package:stackwallet/services/wallets_service.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/logger.dart'; +import '../../app_config.dart'; +import '../../models/exchange/response_objects/trade.dart'; +import '../../models/node_model.dart'; +import '../../models/notification_model.dart'; +import '../../models/trade_wallet_lookup.dart'; +import '../../services/wallets_service.dart'; +import '../../utilities/logger.dart'; +import '../../wallets/crypto_currency/crypto_currency.dart'; class DB { // legacy (required for migrations) @@ -48,17 +49,18 @@ class DB { static const String boxNamePrefs = "prefs"; static const String boxNameOneTimeDialogsShown = "oneTimeDialogsShown"; - String _boxNameTxCache({required Coin coin}) => "${coin.name}_txCache"; + String _boxNameTxCache({required CryptoCurrency currency}) => + "${currency.identifier}_txCache"; // firo only - String _boxNameSetCache({required Coin coin}) => - "${coin.name}_anonymitySetCache"; - String _boxNameSetSparkCache({required Coin coin}) => - "${coin.name}_anonymitySetSparkCache"; - String _boxNameUsedSerialsCache({required Coin coin}) => - "${coin.name}_usedSerialsCache"; - String _boxNameSparkUsedCoinsTagsCache({required Coin coin}) => - "${coin.name}_sparkUsedCoinsTagsCache"; + String _boxNameSetCache({required CryptoCurrency currency}) => + "${currency.identifier}_anonymitySetCache"; + String _boxNameSetSparkCache({required CryptoCurrency currency}) => + "${currency.identifier}_anonymitySetSparkCache"; + String _boxNameUsedSerialsCache({required CryptoCurrency currency}) => + "${currency.identifier}_usedSerialsCache"; + String _boxNameSparkUsedCoinsTagsCache({required CryptoCurrency currency}) => + "${currency.identifier}_sparkUsedCoinsTagsCache"; Box? _boxNodeModels; Box? _boxPrimaryNodes; @@ -77,11 +79,11 @@ class DB { final Map> _walletBoxes = {}; - final Map> _txCacheBoxes = {}; - final Map> _setCacheBoxes = {}; - final Map> _setSparkCacheBoxes = {}; - final Map> _usedSerialsCacheBoxes = {}; - final Map> _getSparkUsedCoinsTagsCacheBoxes = {}; + final Map> _txCacheBoxes = {}; + final Map> _setCacheBoxes = {}; + final Map> _setSparkCacheBoxes = {}; + final Map> _usedSerialsCacheBoxes = {}; + final Map> _getSparkUsedCoinsTagsCacheBoxes = {}; // exposed for monero Box get moneroWalletInfoBox => _walletInfoSource!; @@ -97,7 +99,8 @@ class DB { // TODO: make sure this works properly if (Isolate.current.debugName != "main") { throw Exception( - "DB.instance should not be accessed outside the main isolate!"); + "DB.instance should not be accessed outside the main isolate!", + ); } return _instance; @@ -160,17 +163,22 @@ class DB { names.removeWhere((name, dyn) { final jsonObject = Map.from(dyn as Map); try { - Coin.values.byName(jsonObject["coin"] as String); + AppConfig.getCryptoCurrencyFor(jsonObject["coin"] as String); return false; } catch (e, s) { Logging.instance.log( - "Error, ${jsonObject["coin"]} does not exist, $name wallet cannot be loaded", - level: LogLevel.Error); + "Error, ${jsonObject["coin"]} does not exist, $name wallet cannot be loaded", + level: LogLevel.Error, + ); return true; } }); - final mapped = Map.from(names).map((name, dyn) => MapEntry( - name, WalletInfo.fromJson(Map.from(dyn as Map)))); + final mapped = Map.from(names).map( + (name, dyn) => MapEntry( + name, + WalletInfo.fromJson(Map.from(dyn as Map)), + ), + ); for (final entry in mapped.entries) { if (Hive.isBoxOpen(entry.value.walletId)) { @@ -183,70 +191,90 @@ class DB { } } - Future> getTxCacheBox({required Coin coin}) async { - if (_txCacheBoxes[coin]?.isOpen != true) { - _txCacheBoxes.remove(coin); + Future> getTxCacheBox({required CryptoCurrency currency}) async { + if (_txCacheBoxes[currency.identifier]?.isOpen != true) { + _txCacheBoxes.remove(currency.identifier); } - return _txCacheBoxes[coin] ??= - await Hive.openBox(_boxNameTxCache(coin: coin)); + return _txCacheBoxes[currency.identifier] ??= + await Hive.openBox(_boxNameTxCache(currency: currency)); } - Future closeTxCacheBox({required Coin coin}) async { - await _txCacheBoxes[coin]?.close(); + Future closeTxCacheBox({required CryptoCurrency currency}) async { + await _txCacheBoxes[currency.identifier]?.close(); } - Future> getAnonymitySetCacheBox({required Coin coin}) async { - if (_setCacheBoxes[coin]?.isOpen != true) { - _setCacheBoxes.remove(coin); + Future> getAnonymitySetCacheBox({ + required CryptoCurrency currency, + }) async { + if (_setCacheBoxes[currency.identifier]?.isOpen != true) { + _setCacheBoxes.remove(currency.identifier); } - return _setCacheBoxes[coin] ??= - await Hive.openBox(_boxNameSetCache(coin: coin)); + return _setCacheBoxes[currency.identifier] ??= + await Hive.openBox(_boxNameSetCache(currency: currency)); } - Future> getSparkAnonymitySetCacheBox( - {required Coin coin}) async { - if (_setSparkCacheBoxes[coin]?.isOpen != true) { - _setSparkCacheBoxes.remove(coin); + Future> getSparkAnonymitySetCacheBox({ + required CryptoCurrency currency, + }) async { + if (_setSparkCacheBoxes[currency.identifier]?.isOpen != true) { + _setSparkCacheBoxes.remove(currency.identifier); } - return _setSparkCacheBoxes[coin] ??= - await Hive.openBox(_boxNameSetSparkCache(coin: coin)); + return _setSparkCacheBoxes[currency.identifier] ??= + await Hive.openBox(_boxNameSetSparkCache(currency: currency)); } - Future closeAnonymitySetCacheBox({required Coin coin}) async { - await _setCacheBoxes[coin]?.close(); + Future closeAnonymitySetCacheBox({ + required CryptoCurrency currency, + }) async { + await _setCacheBoxes[currency.identifier]?.close(); } - Future> getUsedSerialsCacheBox({required Coin coin}) async { - if (_usedSerialsCacheBoxes[coin]?.isOpen != true) { - _usedSerialsCacheBoxes.remove(coin); + Future> getUsedSerialsCacheBox({ + required CryptoCurrency currency, + }) async { + if (_usedSerialsCacheBoxes[currency.identifier]?.isOpen != true) { + _usedSerialsCacheBoxes.remove(currency.identifier); } - return _usedSerialsCacheBoxes[coin] ??= - await Hive.openBox(_boxNameUsedSerialsCache(coin: coin)); - } - - Future> getSparkUsedCoinsTagsCacheBox( - {required Coin coin}) async { - if (_getSparkUsedCoinsTagsCacheBoxes[coin]?.isOpen != true) { - _getSparkUsedCoinsTagsCacheBoxes.remove(coin); - } - return _getSparkUsedCoinsTagsCacheBoxes[coin] ??= + return _usedSerialsCacheBoxes[currency.identifier] ??= await Hive.openBox( - _boxNameSparkUsedCoinsTagsCache(coin: coin)); + _boxNameUsedSerialsCache(currency: currency), + ); } - Future closeUsedSerialsCacheBox({required Coin coin}) async { - await _usedSerialsCacheBoxes[coin]?.close(); + Future> getSparkUsedCoinsTagsCacheBox({ + required CryptoCurrency currency, + }) async { + if (_getSparkUsedCoinsTagsCacheBoxes[currency.identifier]?.isOpen != true) { + _getSparkUsedCoinsTagsCacheBoxes.remove(currency.identifier); + } + return _getSparkUsedCoinsTagsCacheBoxes[currency.identifier] ??= + await Hive.openBox( + _boxNameSparkUsedCoinsTagsCache(currency: currency), + ); + } + + Future closeUsedSerialsCacheBox({ + required CryptoCurrency currency, + }) async { + await _usedSerialsCacheBoxes[currency.identifier]?.close(); } /// Clear all cached transactions for the specified coin - Future clearSharedTransactionCache({required Coin coin}) async { - await deleteAll(boxName: _boxNameTxCache(coin: coin)); - if (coin == Coin.firo || coin == Coin.firoTestNet) { - await deleteAll(boxName: _boxNameSetCache(coin: coin)); - await deleteAll(boxName: _boxNameSetSparkCache(coin: coin)); - await deleteAll(boxName: _boxNameUsedSerialsCache(coin: coin)); + Future clearSharedTransactionCache({ + required CryptoCurrency currency, + }) async { + await deleteAll(boxName: _boxNameTxCache(currency: currency)); + if (currency is Firo) { + await deleteAll(boxName: _boxNameSetCache(currency: currency)); await deleteAll( - boxName: _boxNameSparkUsedCoinsTagsCache(coin: coin)); + boxName: _boxNameSetSparkCache(currency: currency), + ); + await deleteAll( + boxName: _boxNameUsedSerialsCache(currency: currency), + ); + await deleteAll( + boxName: _boxNameSparkUsedCoinsTagsCache(currency: currency), + ); } } @@ -284,23 +312,28 @@ class DB { // writes - Future put( - {required String boxName, - required dynamic key, - required T value}) async => + Future put({ + required String boxName, + required dynamic key, + required T value, + }) async => await mutex .protect(() async => await Hive.box(boxName).put(key, value)); Future add({required String boxName, required T value}) async => await mutex.protect(() async => await Hive.box(boxName).add(value)); - Future addAll( - {required String boxName, required Iterable values}) async => + Future addAll({ + required String boxName, + required Iterable values, + }) async => await mutex .protect(() async => await Hive.box(boxName).addAll(values)); - Future delete( - {required dynamic key, required String boxName}) async => + Future delete({ + required dynamic key, + required String boxName, + }) async => await mutex.protect(() async => await Hive.box(boxName).delete(key)); Future deleteAll({required String boxName}) async { diff --git a/lib/db/isar/main_db.dart b/lib/db/isar/main_db.dart index ac5a544f4..931f18263 100644 --- a/lib/db/isar/main_db.dart +++ b/lib/db/isar/main_db.dart @@ -11,21 +11,21 @@ import 'package:decimal/decimal.dart'; import 'package:flutter_native_splash/cli_commands.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/exceptions/main_db/main_db_exception.dart'; -import 'package:stackwallet/models/isar/models/block_explorer.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart'; -import 'package:stackwallet/models/isar/models/contact_entry.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/models/isar/ordinal.dart'; -import 'package:stackwallet/models/isar/stack_theme.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/stack_file_system.dart'; -import 'package:stackwallet/wallets/isar/models/frost_wallet_info.dart'; -import 'package:stackwallet/wallets/isar/models/spark_coin.dart'; -import 'package:stackwallet/wallets/isar/models/token_wallet_info.dart'; -import 'package:stackwallet/wallets/isar/models/wallet_info.dart'; -import 'package:stackwallet/wallets/isar/models/wallet_info_meta.dart'; +import '../../exceptions/main_db/main_db_exception.dart'; +import '../../models/isar/models/block_explorer.dart'; +import '../../models/isar/models/blockchain_data/v2/transaction_v2.dart'; +import '../../models/isar/models/contact_entry.dart'; +import '../../models/isar/models/isar_models.dart'; +import '../../models/isar/ordinal.dart'; +import '../../models/isar/stack_theme.dart'; +import '../../utilities/amount/amount.dart'; +import '../../utilities/stack_file_system.dart'; +import '../../wallets/crypto_currency/crypto_currency.dart'; +import '../../wallets/isar/models/frost_wallet_info.dart'; +import '../../wallets/isar/models/spark_coin.dart'; +import '../../wallets/isar/models/token_wallet_info.dart'; +import '../../wallets/isar/models/wallet_info.dart'; +import '../../wallets/isar/models/wallet_info_meta.dart'; import 'package:tuple/tuple.dart'; part '../queries/queries.dart'; @@ -149,15 +149,17 @@ class MainDB { } // tx block explorers - TransactionBlockExplorer? getTransactionBlockExplorer({required Coin coin}) { + TransactionBlockExplorer? getTransactionBlockExplorer( + {required CryptoCurrency cryptoCurrency}) { return isar.transactionBlockExplorers .where() - .tickerEqualTo(coin.ticker) + .tickerEqualTo(cryptoCurrency.ticker) .findFirstSync(); } Future putTransactionBlockExplorer( - TransactionBlockExplorer explorer) async { + TransactionBlockExplorer explorer, + ) async { try { return await isar.writeTxn(() async { return await isar.transactionBlockExplorers.put(explorer); @@ -169,7 +171,8 @@ class MainDB { // addresses QueryBuilder getAddresses( - String walletId) => + String walletId, + ) => isar.addresses.where().walletIdEqualTo(walletId); Future putAddress(Address address) async { @@ -194,7 +197,7 @@ class MainDB { Future> updateOrPutAddresses(List
addresses) async { try { - List ids = []; + final List ids = []; await isar.writeTxn(() async { for (final address in addresses) { final storedAddress = await isar.addresses @@ -239,13 +242,16 @@ class MainDB { }); } catch (e) { throw MainDBException( - "failed updateAddress: from=$oldAddress to=$newAddress", e); + "failed updateAddress: from=$oldAddress to=$newAddress", + e, + ); } } // transactions QueryBuilder getTransactions( - String walletId) => + String walletId, + ) => isar.transactions.where().walletIdEqualTo(walletId); Future putTransaction(Transaction transaction) async { @@ -284,7 +290,9 @@ class MainDB { isar.utxos.where().walletIdEqualTo(walletId); QueryBuilder getUTXOsByAddress( - String walletId, String address) => + String walletId, + String address, + ) => isar.utxos .where() .walletIdEqualTo(walletId) @@ -357,7 +365,9 @@ class MainDB { }); Future getTransactionNote( - String walletId, String txid) async { + String walletId, + String txid, + ) async { return isar.transactionNotes.getByTxidWalletId( txid, walletId, @@ -374,7 +384,8 @@ class MainDB { // address labels QueryBuilder getAddressLabels( - String walletId) => + String walletId, + ) => isar.addressLabels.where().walletIdEqualTo(walletId); Future putAddressLabel(AddressLabel addressLabel) => @@ -392,7 +403,9 @@ class MainDB { }); Future getAddressLabel( - String walletId, String addressString) async { + String walletId, + String addressString, + ) async { return isar.addressLabels.getByAddressStringWalletId( addressString, walletId, @@ -573,7 +586,7 @@ class MainDB { List transactions, ) async { try { - List ids = []; + final List ids = []; await isar.writeTxn(() async { for (final tx in transactions) { final storedTx = await isar.transactionV2s @@ -595,7 +608,9 @@ class MainDB { return ids; } catch (e) { throw MainDBException( - "failed updateOrPutTransactionV2s: $transactions", e); + "failed updateOrPutTransactionV2s: $transactions", + e, + ); } } diff --git a/lib/db/migrate_wallets_to_isar.dart b/lib/db/migrate_wallets_to_isar.dart index ab263a1c2..f957ff6e9 100644 --- a/lib/db/migrate_wallets_to_isar.dart +++ b/lib/db/migrate_wallets_to_isar.dart @@ -2,16 +2,18 @@ import 'dart:convert'; import 'package:hive_flutter/hive_flutter.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/db/hive/db.dart'; -import 'package:stackwallet/db/isar/main_db.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; -import 'package:stackwallet/wallets/isar/models/token_wallet_info.dart'; -import 'package:stackwallet/wallets/isar/models/wallet_info.dart'; -import 'package:stackwallet/wallets/isar/models/wallet_info_meta.dart'; -import 'package:stackwallet/wallets/wallet/supporting/epiccash_wallet_info_extension.dart'; + +import '../app_config.dart'; +import '../models/isar/models/blockchain_data/v2/transaction_v2.dart'; +import '../models/isar/models/isar_models.dart'; +import '../utilities/flutter_secure_storage_interface.dart'; +import '../wallets/crypto_currency/crypto_currency.dart'; +import '../wallets/isar/models/token_wallet_info.dart'; +import '../wallets/isar/models/wallet_info.dart'; +import '../wallets/isar/models/wallet_info_meta.dart'; +import '../wallets/wallet/supporting/epiccash_wallet_info_extension.dart'; +import 'hive/db.dart'; +import 'isar/main_db.dart'; Future migrateWalletsToIsar({ required SecureStorageInterface secureStore, @@ -37,13 +39,13 @@ Future migrateWalletsToIsar({ // final List< ({ - Coin coin, + String coinIdentifier, String name, String walletId, })> oldInfo = Map.from(names).values.map((e) { final map = e as Map; return ( - coin: Coin.values.byName(map["coin"] as String), + coinIdentifier: map["coin"] as String, walletId: map["id"] as String, name: map["name"] as String, ); @@ -93,16 +95,16 @@ Future migrateWalletsToIsar({ } // reset stellar + tezos address type - if (old.coin == Coin.stellar || - old.coin == Coin.stellarTestnet || - old.coin == Coin.tezos) { + if (old.coinIdentifier == Stellar(CryptoCurrencyNetwork.main).identifier || + old.coinIdentifier == Stellar(CryptoCurrencyNetwork.test).identifier || + old.coinIdentifier == Tezos(CryptoCurrencyNetwork.main).identifier) { await MainDB.instance.deleteWalletBlockchainData(old.walletId); } // // Set other data values // - Map otherData = {}; + final Map otherData = {}; final List? tokenContractAddresses = walletBox.get( "ethTokenContracts", @@ -129,7 +131,7 @@ Future migrateWalletsToIsar({ } // epiccash specifics - if (old.coin == Coin.epicCash) { + if (old.coinIdentifier == Epiccash(CryptoCurrencyNetwork.main)) { final epicWalletInfo = ExtraEpiccashWalletInfo.fromMap({ "receivingIndex": walletBox.get("receivingIndex") as int? ?? 0, "changeIndex": walletBox.get("changeIndex") as int? ?? 0, @@ -142,7 +144,9 @@ Future migrateWalletsToIsar({ otherData[WalletInfoKeys.epiccashData] = jsonEncode( epicWalletInfo.toMap(), ); - } else if (old.coin == Coin.firo || old.coin == Coin.firoTestNet) { + } else if (old.coinIdentifier == + Firo(CryptoCurrencyNetwork.main).identifier || + old.coinIdentifier == Firo(CryptoCurrencyNetwork.test).identifier) { otherData[WalletInfoKeys.lelantusCoinIsarRescanRequired] = walletBox .get(WalletInfoKeys.lelantusCoinIsarRescanRequired) as bool? ?? true; @@ -161,10 +165,11 @@ Future migrateWalletsToIsar({ ); final info = WalletInfo( - coinName: old.coin.name, + coinName: old.coinIdentifier, walletId: old.walletId, name: old.name, - mainAddressType: old.coin.primaryAddressType, + mainAddressType: AppConfig.getCryptoCurrencyFor(old.coinIdentifier)! + .primaryAddressType, favouriteOrderIndex: favourites.indexOf(old.walletId), cachedChainHeight: walletBox.get( DBKeys.storedChainHeight, diff --git a/lib/db/queries/queries.dart b/lib/db/queries/queries.dart index 7e14de0e6..c8bbe7385 100644 --- a/lib/db/queries/queries.dart +++ b/lib/db/queries/queries.dart @@ -8,7 +8,7 @@ * */ -part of 'package:stackwallet/db/isar/main_db.dart'; +part of '../isar/main_db.dart'; enum CCFilter { all, @@ -42,7 +42,7 @@ extension MainDBQueries on MainDB { required CCFilter filter, required CCSortDescriptor sort, required String searchTerm, - required Coin coin, + required CryptoCurrency cryptoCurrency, }) { var preSort = getUTXOs(walletId).filter().group((q) { final qq = q.group( @@ -79,7 +79,7 @@ extension MainDBQueries on MainDB { qq = qq.or().valueEqualTo( Amount.fromDecimal( maybeDecimal, - fractionDigits: coin.decimals, + fractionDigits: cryptoCurrency.fractionDigits, ).raw.toInt(), ); } @@ -114,7 +114,7 @@ extension MainDBQueries on MainDB { required CCFilter filter, required CCSortDescriptor sort, required String searchTerm, - required Coin coin, + required CryptoCurrency cryptoCurrency, }) { var preSort = getUTXOs(walletId).filter().group((q) { final qq = q.group( @@ -151,7 +151,7 @@ extension MainDBQueries on MainDB { qq = qq.or().valueEqualTo( Amount.fromDecimal( maybeDecimal, - fractionDigits: coin.decimals, + fractionDigits: cryptoCurrency.fractionDigits, ).raw.toInt(), ); } diff --git a/lib/dto/ethereum/eth_token_tx_extra_dto.dart b/lib/dto/ethereum/eth_token_tx_extra_dto.dart index aab41bb76..c902d2bba 100644 --- a/lib/dto/ethereum/eth_token_tx_extra_dto.dart +++ b/lib/dto/ethereum/eth_token_tx_extra_dto.dart @@ -10,8 +10,9 @@ import 'dart:convert'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import '../../utilities/amount/amount.dart'; +import '../../wallets/crypto_currency/coins/ethereum.dart'; +import '../../wallets/crypto_currency/crypto_currency.dart'; class EthTokenTxExtraDTO { EthTokenTxExtraDTO({ @@ -42,7 +43,7 @@ class EthTokenTxExtraDTO { to: map['to'] as String, value: Amount( rawValue: BigInt.parse(map['value'] as String), - fractionDigits: Coin.ethereum.decimals, + fractionDigits: Ethereum(CryptoCurrencyNetwork.main).fractionDigits, ), gas: _amountFromJsonNum(map['gas']), gasPrice: _amountFromJsonNum(map['gasPrice']), @@ -70,7 +71,7 @@ class EthTokenTxExtraDTO { static Amount _amountFromJsonNum(dynamic json) { return Amount( rawValue: BigInt.from(json as num), - fractionDigits: Coin.ethereum.decimals, + fractionDigits: Ethereum(CryptoCurrencyNetwork.main).fractionDigits, ); } diff --git a/lib/dto/ethereum/eth_tx_dto.dart b/lib/dto/ethereum/eth_tx_dto.dart index e0708646d..2f60e9792 100644 --- a/lib/dto/ethereum/eth_tx_dto.dart +++ b/lib/dto/ethereum/eth_tx_dto.dart @@ -10,8 +10,9 @@ import 'dart:convert'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import '../../utilities/amount/amount.dart'; +import '../../wallets/crypto_currency/coins/ethereum.dart'; +import '../../wallets/crypto_currency/crypto_currency.dart'; class EthTxDTO { EthTxDTO({ @@ -75,7 +76,7 @@ class EthTxDTO { } return Amount( rawValue: BigInt.parse(json.toString()), - fractionDigits: Coin.ethereum.decimals, + fractionDigits: Ethereum(CryptoCurrencyNetwork.main).fractionDigits, ); } diff --git a/lib/dto/ordinals/address_inscription_response.dart b/lib/dto/ordinals/address_inscription_response.dart index 240374284..fa3144b57 100644 --- a/lib/dto/ordinals/address_inscription_response.dart +++ b/lib/dto/ordinals/address_inscription_response.dart @@ -1,5 +1,5 @@ -import 'package:stackwallet/dto/ordinals/litescribe_response.dart'; -import 'package:stackwallet/dto/ordinals/inscription_data.dart'; +import 'litescribe_response.dart'; +import 'inscription_data.dart'; class AddressInscriptionResponse extends LitescribeResponse { final int status; diff --git a/lib/electrumx_rpc/cached_electrumx_client.dart b/lib/electrumx_rpc/cached_electrumx_client.dart index 559526f17..569c092fa 100644 --- a/lib/electrumx_rpc/cached_electrumx_client.dart +++ b/lib/electrumx_rpc/cached_electrumx_client.dart @@ -11,10 +11,10 @@ import 'dart:convert'; import 'dart:math'; -import 'package:stackwallet/db/hive/db.dart'; -import 'package:stackwallet/electrumx_rpc/electrumx_client.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/logger.dart'; +import '../db/hive/db.dart'; +import 'electrumx_client.dart'; +import '../utilities/logger.dart'; +import '../wallets/crypto_currency/crypto_currency.dart'; import 'package:string_validator/string_validator.dart'; class CachedElectrumXClient { @@ -34,10 +34,11 @@ class CachedElectrumXClient { Future> getAnonymitySet({ required String groupId, String blockhash = "", - required Coin coin, + required CryptoCurrency cryptoCurrency, }) async { try { - final box = await DB.instance.getAnonymitySetCacheBox(coin: coin); + final box = + await DB.instance.getAnonymitySetCacheBox(currency: cryptoCurrency); final cachedSet = box.get(groupId) as Map?; Map set; @@ -68,30 +69,38 @@ class CachedElectrumXClient { ? base64ToReverseHex(newSet["blockHash"] as String) : newSet["blockHash"]; for (int i = (newSet["coins"] as List).length - 1; i >= 0; i--) { - dynamic newCoin = newSet["coins"][i]; - List translatedCoin = []; - translatedCoin.add(!isHexadecimal(newCoin[0] as String) - ? base64ToHex(newCoin[0] as String) - : newCoin[0]); - translatedCoin.add(!isHexadecimal(newCoin[1] as String) - ? base64ToReverseHex(newCoin[1] as String) - : newCoin[1]); + final dynamic newCoin = newSet["coins"][i]; + final List translatedCoin = []; + translatedCoin.add( + !isHexadecimal(newCoin[0] as String) + ? base64ToHex(newCoin[0] as String) + : newCoin[0], + ); + translatedCoin.add( + !isHexadecimal(newCoin[1] as String) + ? base64ToReverseHex(newCoin[1] as String) + : newCoin[1], + ); try { - translatedCoin.add(!isHexadecimal(newCoin[2] as String) - ? base64ToHex(newCoin[2] as String) - : newCoin[2]); + translatedCoin.add( + !isHexadecimal(newCoin[2] as String) + ? base64ToHex(newCoin[2] as String) + : newCoin[2], + ); } catch (e) { translatedCoin.add(newCoin[2]); } - translatedCoin.add(!isHexadecimal(newCoin[3] as String) - ? base64ToReverseHex(newCoin[3] as String) - : newCoin[3]); + translatedCoin.add( + !isHexadecimal(newCoin[3] as String) + ? base64ToReverseHex(newCoin[3] as String) + : newCoin[3], + ); set["coins"].insert(0, translatedCoin); } // save set to db await box.put(groupId, set); Logging.instance.log( - "Updated current anonymity set for ${coin.name} with group ID $groupId", + "Updated current anonymity set for ${cryptoCurrency.identifier} with group ID $groupId", level: LogLevel.Info, ); } @@ -99,8 +108,9 @@ class CachedElectrumXClient { return set; } catch (e, s) { Logging.instance.log( - "Failed to process CachedElectrumX.getAnonymitySet(): $e\n$s", - level: LogLevel.Error); + "Failed to process CachedElectrumX.getAnonymitySet(): $e\n$s", + level: LogLevel.Error, + ); rethrow; } } @@ -108,11 +118,13 @@ class CachedElectrumXClient { Future> getSparkAnonymitySet({ required String groupId, String blockhash = "", - required Coin coin, + required CryptoCurrency cryptoCurrency, required bool useOnlyCacheIfNotEmpty, }) async { try { - final box = await DB.instance.getSparkAnonymitySetCacheBox(coin: coin); + final box = await DB.instance.getSparkAnonymitySetCacheBox( + currency: cryptoCurrency, + ); final cachedSet = box.get(groupId) as Map?; Map set; @@ -152,7 +164,7 @@ class CachedElectrumXClient { // save set to db await box.put(groupId, set); Logging.instance.log( - "Updated current anonymity set for ${coin.name} with group ID $groupId", + "Updated current anonymity set for ${cryptoCurrency.identifier} with group ID $groupId", level: LogLevel.Info, ); } @@ -160,8 +172,9 @@ class CachedElectrumXClient { return set; } catch (e, s) { Logging.instance.log( - "Failed to process CachedElectrumX.getSparkAnonymitySet(): $e\n$s", - level: LogLevel.Error); + "Failed to process CachedElectrumX.getSparkAnonymitySet(): $e\n$s", + level: LogLevel.Error, + ); rethrow; } } @@ -182,11 +195,11 @@ class CachedElectrumXClient { /// ElectrumX api only called if the tx does not exist in local db Future> getTransaction({ required String txHash, - required Coin coin, + required CryptoCurrency cryptoCurrency, bool verbose = true, }) async { try { - final box = await DB.instance.getTxCacheBox(coin: coin); + final box = await DB.instance.getTxCacheBox(currency: cryptoCurrency); final cachedTx = box.get(txHash) as Map?; if (cachedTx == null) { @@ -213,22 +226,24 @@ class CachedElectrumXClient { } } catch (e, s) { Logging.instance.log( - "Failed to process CachedElectrumX.getTransaction(): $e\n$s", - level: LogLevel.Error); + "Failed to process CachedElectrumX.getTransaction(): $e\n$s", + level: LogLevel.Error, + ); rethrow; } } Future> getUsedCoinSerials({ - required Coin coin, + required CryptoCurrency cryptoCurrency, int startNumber = 0, }) async { try { - final box = await DB.instance.getUsedSerialsCacheBox(coin: coin); + final box = + await DB.instance.getUsedSerialsCacheBox(currency: cryptoCurrency); final _list = box.get("serials") as List?; - Set cachedSerials = + final Set cachedSerials = _list == null ? {} : List.from(_list).toSet(); startNumber = max( @@ -269,14 +284,16 @@ class CachedElectrumXClient { } Future> getSparkUsedCoinsTags({ - required Coin coin, + required CryptoCurrency cryptoCurrency, }) async { try { - final box = await DB.instance.getSparkUsedCoinsTagsCacheBox(coin: coin); + final box = await DB.instance.getSparkUsedCoinsTagsCacheBox( + currency: cryptoCurrency, + ); final _list = box.get("tags") as List?; - Set cachedTags = + final Set cachedTags = _list == null ? {} : List.from(_list).toSet(); final startNumber = max( @@ -314,8 +331,9 @@ class CachedElectrumXClient { } /// Clear all cached transactions for the specified coin - Future clearSharedTransactionCache({required Coin coin}) async { - await DB.instance.clearSharedTransactionCache(coin: coin); - await DB.instance.closeAnonymitySetCacheBox(coin: coin); + Future clearSharedTransactionCache( + {required CryptoCurrency cryptoCurrency}) async { + await DB.instance.clearSharedTransactionCache(currency: cryptoCurrency); + await DB.instance.closeAnonymitySetCacheBox(currency: cryptoCurrency); } } diff --git a/lib/electrumx_rpc/client_manager.dart b/lib/electrumx_rpc/client_manager.dart index 26db04b4b..662c218ea 100644 --- a/lib/electrumx_rpc/client_manager.dart +++ b/lib/electrumx_rpc/client_manager.dart @@ -1,7 +1,7 @@ import 'dart:async'; import 'package:electrum_adapter/electrum_adapter.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; +import '../wallets/crypto_currency/crypto_currency.dart'; class ClientManager { ClientManager._(); diff --git a/lib/electrumx_rpc/electrumx_client.dart b/lib/electrumx_rpc/electrumx_client.dart index a5fcf5605..c37547f92 100644 --- a/lib/electrumx_rpc/electrumx_client.dart +++ b/lib/electrumx_rpc/electrumx_client.dart @@ -20,17 +20,17 @@ import 'package:event_bus/event_bus.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter_libsparkmobile/flutter_libsparkmobile.dart'; import 'package:mutex/mutex.dart'; -import 'package:stackwallet/electrumx_rpc/client_manager.dart'; -import 'package:stackwallet/exceptions/electrumx/no_such_transaction.dart'; -import 'package:stackwallet/services/event_bus/events/global/tor_connection_status_changed_event.dart'; -import 'package:stackwallet/services/event_bus/events/global/tor_status_changed_event.dart'; -import 'package:stackwallet/services/event_bus/global_event_bus.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/prefs.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/dogecoin.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/firo.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; +import 'client_manager.dart'; +import '../exceptions/electrumx/no_such_transaction.dart'; +import '../services/event_bus/events/global/tor_connection_status_changed_event.dart'; +import '../services/event_bus/events/global/tor_status_changed_event.dart'; +import '../services/event_bus/global_event_bus.dart'; +import '../services/tor_service.dart'; +import '../utilities/logger.dart'; +import '../utilities/prefs.dart'; +import '../wallets/crypto_currency/coins/dogecoin.dart'; +import '../wallets/crypto_currency/coins/firo.dart'; +import '../wallets/crypto_currency/crypto_currency.dart'; import 'package:stream_channel/stream_channel.dart'; class WifiOnlyException implements Exception {} diff --git a/lib/exceptions/address/address_exception.dart b/lib/exceptions/address/address_exception.dart index 073dc72a3..3b01028e0 100644 --- a/lib/exceptions/address/address_exception.dart +++ b/lib/exceptions/address/address_exception.dart @@ -8,7 +8,7 @@ * */ -import 'package:stackwallet/exceptions/sw_exception.dart'; +import '../sw_exception.dart'; class AddressException extends SWException { AddressException(super.message); diff --git a/lib/exceptions/electrumx/no_such_transaction.dart b/lib/exceptions/electrumx/no_such_transaction.dart index b74fae29a..e302345b5 100644 --- a/lib/exceptions/electrumx/no_such_transaction.dart +++ b/lib/exceptions/electrumx/no_such_transaction.dart @@ -8,7 +8,7 @@ * */ -import 'package:stackwallet/exceptions/sw_exception.dart'; +import '../sw_exception.dart'; class NoSuchTransactionException extends SWException { final String txid; diff --git a/lib/exceptions/exchange/exchange_exception.dart b/lib/exceptions/exchange/exchange_exception.dart index c383c27da..952170d72 100644 --- a/lib/exceptions/exchange/exchange_exception.dart +++ b/lib/exceptions/exchange/exchange_exception.dart @@ -8,7 +8,7 @@ * */ -import 'package:stackwallet/exceptions/sw_exception.dart'; +import '../sw_exception.dart'; enum ExchangeExceptionType { generic, serializeResponseError, orderNotFound } diff --git a/lib/exceptions/exchange/majestic_bank/mb_exception.dart b/lib/exceptions/exchange/majestic_bank/mb_exception.dart index 00b2ad6f8..9475d2dd3 100644 --- a/lib/exceptions/exchange/majestic_bank/mb_exception.dart +++ b/lib/exceptions/exchange/majestic_bank/mb_exception.dart @@ -8,7 +8,7 @@ * */ -import 'package:stackwallet/exceptions/exchange/exchange_exception.dart'; +import '../exchange_exception.dart'; class MBException extends ExchangeException { MBException(super.message, super.type); diff --git a/lib/exceptions/exchange/pair_unavailable_exception.dart b/lib/exceptions/exchange/pair_unavailable_exception.dart index ecb1e66f4..3942e13cc 100644 --- a/lib/exceptions/exchange/pair_unavailable_exception.dart +++ b/lib/exceptions/exchange/pair_unavailable_exception.dart @@ -8,7 +8,7 @@ * */ -import 'package:stackwallet/exceptions/exchange/exchange_exception.dart'; +import 'exchange_exception.dart'; class PairUnavailableException extends ExchangeException { PairUnavailableException(super.message, super.type); diff --git a/lib/exceptions/exchange/unsupported_currency_exception.dart b/lib/exceptions/exchange/unsupported_currency_exception.dart index 38e1c2cad..55deb4050 100644 --- a/lib/exceptions/exchange/unsupported_currency_exception.dart +++ b/lib/exceptions/exchange/unsupported_currency_exception.dart @@ -8,7 +8,7 @@ * */ -import 'package:stackwallet/exceptions/exchange/exchange_exception.dart'; +import 'exchange_exception.dart'; class UnsupportedCurrencyException extends ExchangeException { UnsupportedCurrencyException(super.message, super.type, this.currency); diff --git a/lib/exceptions/json_rpc/json_rpc_exception.dart b/lib/exceptions/json_rpc/json_rpc_exception.dart index e0a51ce84..7668e346d 100644 --- a/lib/exceptions/json_rpc/json_rpc_exception.dart +++ b/lib/exceptions/json_rpc/json_rpc_exception.dart @@ -8,7 +8,7 @@ * */ -import 'package:stackwallet/exceptions/sw_exception.dart'; +import '../sw_exception.dart'; class JsonRpcException implements SWException { JsonRpcException(this.message); diff --git a/lib/exceptions/main_db/main_db_exception.dart b/lib/exceptions/main_db/main_db_exception.dart index 65bfc5987..00f6438a5 100644 --- a/lib/exceptions/main_db/main_db_exception.dart +++ b/lib/exceptions/main_db/main_db_exception.dart @@ -8,7 +8,7 @@ * */ -import 'package:stackwallet/exceptions/sw_exception.dart'; +import '../sw_exception.dart'; class MainDBException extends SWException { MainDBException(super.message, this.originalError); diff --git a/lib/exceptions/wallet/insufficient_balance_exception.dart b/lib/exceptions/wallet/insufficient_balance_exception.dart index d03572c4a..9c4b4d0af 100644 --- a/lib/exceptions/wallet/insufficient_balance_exception.dart +++ b/lib/exceptions/wallet/insufficient_balance_exception.dart @@ -8,7 +8,7 @@ * */ -import 'package:stackwallet/exceptions/sw_exception.dart'; +import '../sw_exception.dart'; class InsufficientBalanceException extends SWException { InsufficientBalanceException(super.message); diff --git a/lib/exceptions/wallet/paynym_send_exception.dart b/lib/exceptions/wallet/paynym_send_exception.dart index bdbd47f6b..9aa3308c6 100644 --- a/lib/exceptions/wallet/paynym_send_exception.dart +++ b/lib/exceptions/wallet/paynym_send_exception.dart @@ -8,7 +8,7 @@ * */ -import 'package:stackwallet/exceptions/sw_exception.dart'; +import '../sw_exception.dart'; class PaynymSendException extends SWException { PaynymSendException(super.message); diff --git a/lib/frost_route_generator.dart b/lib/frost_route_generator.dart index d401c7030..1266b94bc 100644 --- a/lib/frost_route_generator.dart +++ b/lib/frost_route_generator.dart @@ -1,28 +1,28 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_1a.dart'; -import 'package:stackwallet/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_1b.dart'; -import 'package:stackwallet/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_2.dart'; -import 'package:stackwallet/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_3.dart'; -import 'package:stackwallet/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_4.dart'; -import 'package:stackwallet/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_5.dart'; -import 'package:stackwallet/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_1a.dart'; -import 'package:stackwallet/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_1b.dart'; -import 'package:stackwallet/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_1c.dart'; -import 'package:stackwallet/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_2abd.dart'; -import 'package:stackwallet/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_2c.dart'; -import 'package:stackwallet/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_3abd.dart'; -import 'package:stackwallet/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_3c.dart'; -import 'package:stackwallet/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_4.dart'; -import 'package:stackwallet/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_5.dart'; -import 'package:stackwallet/pages/send_view/frost_ms/send_steps/frost_send_step_1a.dart'; -import 'package:stackwallet/pages/send_view/frost_ms/send_steps/frost_send_step_1b.dart'; -import 'package:stackwallet/pages/send_view/frost_ms/send_steps/frost_send_step_2.dart'; -import 'package:stackwallet/pages/send_view/frost_ms/send_steps/frost_send_step_3.dart'; -import 'package:stackwallet/pages/send_view/frost_ms/send_steps/frost_send_step_4.dart'; -import 'package:stackwallet/route_generator.dart'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/frost_currency.dart'; +import 'pages/add_wallet_views/frost_ms/new/steps/frost_create_step_1a.dart'; +import 'pages/add_wallet_views/frost_ms/new/steps/frost_create_step_1b.dart'; +import 'pages/add_wallet_views/frost_ms/new/steps/frost_create_step_2.dart'; +import 'pages/add_wallet_views/frost_ms/new/steps/frost_create_step_3.dart'; +import 'pages/add_wallet_views/frost_ms/new/steps/frost_create_step_4.dart'; +import 'pages/add_wallet_views/frost_ms/new/steps/frost_create_step_5.dart'; +import 'pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_1a.dart'; +import 'pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_1b.dart'; +import 'pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_1c.dart'; +import 'pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_2abd.dart'; +import 'pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_2c.dart'; +import 'pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_3abd.dart'; +import 'pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_3c.dart'; +import 'pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_4.dart'; +import 'pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_5.dart'; +import 'pages/send_view/frost_ms/send_steps/frost_send_step_1a.dart'; +import 'pages/send_view/frost_ms/send_steps/frost_send_step_1b.dart'; +import 'pages/send_view/frost_ms/send_steps/frost_send_step_2.dart'; +import 'pages/send_view/frost_ms/send_steps/frost_send_step_3.dart'; +import 'pages/send_view/frost_ms/send_steps/frost_send_step_4.dart'; +import 'route_generator.dart'; +import 'wallets/crypto_currency/intermediate/frost_currency.dart'; typedef FrostStepRoute = ({String routeName, String title}); diff --git a/lib/main.dart b/lib/main.dart index 011b8a27a..a714447ab 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -14,6 +14,7 @@ import 'dart:math'; import 'package:coinlib_flutter/coinlib_flutter.dart'; import 'package:cw_core/node.dart'; +import 'package:cw_core/pathForWallet.dart'; import 'package:cw_core/unspent_coins_info.dart'; import 'package:cw_core/wallet_info.dart'; import 'package:cw_core/wallet_type.dart'; @@ -28,54 +29,56 @@ import 'package:hive_flutter/hive_flutter.dart'; import 'package:isar/isar.dart'; import 'package:keyboard_dismisser/keyboard_dismisser.dart'; import 'package:path_provider/path_provider.dart'; -import 'package:stackwallet/db/db_version_migration.dart'; -import 'package:stackwallet/db/hive/db.dart'; -import 'package:stackwallet/db/isar/main_db.dart'; -import 'package:stackwallet/models/exchange/change_now/exchange_transaction.dart'; -import 'package:stackwallet/models/exchange/change_now/exchange_transaction_status.dart'; -import 'package:stackwallet/models/exchange/response_objects/trade.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/models/models.dart'; -import 'package:stackwallet/models/node_model.dart'; -import 'package:stackwallet/models/notification_model.dart'; -import 'package:stackwallet/models/trade_wallet_lookup.dart'; -import 'package:stackwallet/pages/home_view/home_view.dart'; -import 'package:stackwallet/pages/intro_view.dart'; -import 'package:stackwallet/pages/loading_view.dart'; -import 'package:stackwallet/pages/pinpad_views/create_pin_view.dart'; -import 'package:stackwallet/pages/pinpad_views/lock_screen_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/restore_from_encrypted_string_view.dart'; -import 'package:stackwallet/pages_desktop_specific/password/desktop_login_view.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/desktop/storage_crypto_handler_provider.dart'; -import 'package:stackwallet/providers/global/auto_swb_service_provider.dart'; -import 'package:stackwallet/providers/global/base_currencies_provider.dart'; -// import 'package:stackwallet/providers/global/has_authenticated_start_state_provider.dart'; -import 'package:stackwallet/providers/global/trades_service_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/route_generator.dart'; -// import 'package:stackwallet/services/buy/buy_data_loading_service.dart'; -import 'package:stackwallet/services/debug_service.dart'; -import 'package:stackwallet/services/exchange/exchange_data_loading_service.dart'; -import 'package:stackwallet/services/locale_service.dart'; -import 'package:stackwallet/services/node_service.dart'; -import 'package:stackwallet/services/notifications_api.dart'; -import 'package:stackwallet/services/notifications_service.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/services/trade_service.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/themes/theme_service.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/backup_frequency_type.dart'; -import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/prefs.dart'; -import 'package:stackwallet/utilities/stack_file_system.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/all_wallets_info_provider.dart'; -import 'package:stackwallet/widgets/crypto_notifications.dart'; import 'package:window_size/window_size.dart'; +import 'app_config.dart'; +import 'db/db_version_migration.dart'; +import 'db/hive/db.dart'; +import 'db/isar/main_db.dart'; +import 'models/exchange/change_now/exchange_transaction.dart'; +import 'models/exchange/change_now/exchange_transaction_status.dart'; +import 'models/exchange/response_objects/trade.dart'; +import 'models/isar/models/isar_models.dart'; +import 'models/models.dart'; +import 'models/node_model.dart'; +import 'models/notification_model.dart'; +import 'models/trade_wallet_lookup.dart'; +import 'pages/home_view/home_view.dart'; +import 'pages/intro_view.dart'; +import 'pages/loading_view.dart'; +import 'pages/pinpad_views/create_pin_view.dart'; +import 'pages/pinpad_views/lock_screen_view.dart'; +import 'pages/settings_views/global_settings_view/stack_backup_views/restore_from_encrypted_string_view.dart'; +import 'pages_desktop_specific/password/desktop_login_view.dart'; +import 'providers/db/main_db_provider.dart'; +import 'providers/desktop/storage_crypto_handler_provider.dart'; +import 'providers/global/auto_swb_service_provider.dart'; +import 'providers/global/base_currencies_provider.dart'; +// import 'package:stackwallet/providers/global/has_authenticated_start_state_provider.dart'; +import 'providers/global/trades_service_provider.dart'; +import 'providers/providers.dart'; +import 'route_generator.dart'; +// import 'package:stackwallet/services/buy/buy_data_loading_service.dart'; +import 'services/debug_service.dart'; +import 'services/exchange/exchange_data_loading_service.dart'; +import 'services/locale_service.dart'; +import 'services/node_service.dart'; +import 'services/notifications_api.dart'; +import 'services/notifications_service.dart'; +import 'services/tor_service.dart'; +import 'services/trade_service.dart'; +import 'themes/theme_providers.dart'; +import 'themes/theme_service.dart'; +import 'utilities/constants.dart'; +import 'utilities/enums/backup_frequency_type.dart'; +import 'utilities/flutter_secure_storage_interface.dart'; +import 'utilities/logger.dart'; +import 'utilities/prefs.dart'; +import 'utilities/stack_file_system.dart'; +import 'utilities/util.dart'; +import 'wallets/isar/providers/all_wallets_info_provider.dart'; +import 'widgets/crypto_notifications.dart'; + final openedFromSWBFileStringStateProvider = StateProvider((ref) => null); @@ -86,9 +89,15 @@ void main(List args) async { WidgetsFlutterBinding.ensureInitialized(); if (Util.isDesktop && args.length == 2 && args.first == "-d") { - StackFileSystem.overrideDir = args.last; + StackFileSystem.setDesktopOverrideDir(args.last); } + // Tell flutter_libmonero how to get access to the application dir + FS.setApplicationRootDirectoryFunction( + StackFileSystem.applicationRootDirectory, + ); + // TODO set any other external libs file paths (bad external lib design workaround) + final loadCoinlibFuture = loadCoinlib(); GoogleFonts.config.allowRuntimeFetching = false; @@ -102,7 +111,7 @@ void main(List args) async { } if (Util.isDesktop && !Platform.isIOS) { - setWindowTitle('Stack Wallet'); + setWindowTitle(AppConfig.appName); setWindowMinSize(const Size(1220, 100)); setWindowMaxSize(Size.infinite); @@ -585,8 +594,8 @@ class _MaterialAppWithThemeState extends ConsumerState routeOnSuccessArguments: encrypted, biometricsCancelButtonString: "CANCEL", biometricsLocalizedReason: - "Authenticate to restore Stack Wallet backup", - biometricsAuthenticationTitle: "Restore Stack backup", + "Authenticate to restore ${AppConfig.appName} backup", + biometricsAuthenticationTitle: "Restore ${AppConfig.prefix} backup", ), settings: const RouteSettings(name: "/swbrestorelockscreen"), ), @@ -617,7 +626,7 @@ class _MaterialAppWithThemeState extends ConsumerState return MaterialApp( key: GlobalKey(), navigatorKey: navigatorKey, - title: 'Stack Wallet', + title: AppConfig.appName, onGenerateRoute: RouteGenerator.generateRoute, theme: ThemeData( extensions: [colorScheme], @@ -761,9 +770,10 @@ class _MaterialAppWithThemeState extends ConsumerState isInitialAppLogin: true, routeOnSuccess: HomeView.routeName, routeOnSuccessArguments: startupWalletId, - biometricsAuthenticationTitle: "Unlock Stack", + biometricsAuthenticationTitle: + "Unlock ${AppConfig.prefix}", biometricsLocalizedReason: - "Unlock your stack wallet using biometrics", + "Unlock your ${AppConfig.appName} using biometrics", biometricsCancelButtonString: "Cancel", ); } else { diff --git a/lib/models/add_wallet_list_entity/add_wallet_list_entity.dart b/lib/models/add_wallet_list_entity/add_wallet_list_entity.dart index f59725f6b..cf842d9a4 100644 --- a/lib/models/add_wallet_list_entity/add_wallet_list_entity.dart +++ b/lib/models/add_wallet_list_entity/add_wallet_list_entity.dart @@ -9,10 +9,10 @@ */ import 'package:equatable/equatable.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import '../../wallets/crypto_currency/crypto_currency.dart'; abstract class AddWalletListEntity extends Equatable { - Coin get coin; + CryptoCurrency get cryptoCurrency; String get name; String get ticker; } diff --git a/lib/models/add_wallet_list_entity/sub_classes/coin_entity.dart b/lib/models/add_wallet_list_entity/sub_classes/coin_entity.dart index 10e78688f..41c4eef63 100644 --- a/lib/models/add_wallet_list_entity/sub_classes/coin_entity.dart +++ b/lib/models/add_wallet_list_entity/sub_classes/coin_entity.dart @@ -8,23 +8,23 @@ * */ -import 'package:stackwallet/models/add_wallet_list_entity/add_wallet_list_entity.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import '../add_wallet_list_entity.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; class CoinEntity extends AddWalletListEntity { CoinEntity(this._coin); - final Coin _coin; + final CryptoCurrency _coin; @override - Coin get coin => _coin; + CryptoCurrency get cryptoCurrency => _coin; @override - String get name => coin.prettyName; + String get name => cryptoCurrency.prettyName; @override - String get ticker => coin.ticker; + String get ticker => cryptoCurrency.ticker; @override - List get props => [coin, name, ticker]; + List get props => [cryptoCurrency.identifier, name, ticker]; } diff --git a/lib/models/add_wallet_list_entity/sub_classes/eth_token_entity.dart b/lib/models/add_wallet_list_entity/sub_classes/eth_token_entity.dart index 000bc810f..5980b6503 100644 --- a/lib/models/add_wallet_list_entity/sub_classes/eth_token_entity.dart +++ b/lib/models/add_wallet_list_entity/sub_classes/eth_token_entity.dart @@ -8,17 +8,19 @@ * */ -import 'package:stackwallet/models/add_wallet_list_entity/add_wallet_list_entity.dart'; -import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import '../add_wallet_list_entity.dart'; +import '../../isar/models/ethereum/eth_contract.dart'; +import '../../../wallets/crypto_currency/coins/ethereum.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; class EthTokenEntity extends AddWalletListEntity { EthTokenEntity(this.token); final EthContract token; + // TODO: check other networks in future and handle differently? @override - Coin get coin => Coin.ethereum; + CryptoCurrency get cryptoCurrency => Ethereum(CryptoCurrencyNetwork.main); @override String get name => token.name; @@ -27,5 +29,6 @@ class EthTokenEntity extends AddWalletListEntity { String get ticker => token.symbol; @override - List get props => [coin, name, ticker, token.address]; + List get props => + [cryptoCurrency.identifier, name, ticker, token.address]; } diff --git a/lib/models/address_book_filter.dart b/lib/models/address_book_filter.dart index 578ffc8c9..4958f3536 100644 --- a/lib/models/address_book_filter.dart +++ b/lib/models/address_book_filter.dart @@ -9,46 +9,46 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import '../wallets/crypto_currency/crypto_currency.dart'; class AddressBookFilter extends ChangeNotifier { - AddressBookFilter(Set coins) { + AddressBookFilter(Set coins) { _coins = coins; } - Set _coins = {}; + Set _coins = {}; - Set get coins => _coins; + Set get coins => _coins; - set coins(Set coins) { + set coins(Set coins) { _coins = coins; notifyListeners(); } - void add(Coin coin, bool shouldNotifyListeners) { + void add(CryptoCurrency coin, bool shouldNotifyListeners) { _coins.add(coin); if (shouldNotifyListeners) { notifyListeners(); } } - void addAll(Iterable coins, bool shouldNotifyListeners) { + void addAll(Iterable coins, bool shouldNotifyListeners) { _coins.addAll(coins); if (shouldNotifyListeners) { notifyListeners(); } } - void remove(Coin coin, bool shouldNotifyListeners) { - _coins.removeWhere((e) => e.name == coin.name); + void remove(CryptoCurrency coin, bool shouldNotifyListeners) { + _coins.removeWhere((e) => e.identifier == coin.identifier); if (shouldNotifyListeners) { notifyListeners(); } } - void removeMany(Set coins, bool shouldNotifyListeners) { + void removeMany(Set coins, bool shouldNotifyListeners) { for (final coin in coins) { - _coins.removeWhere((e) => e.name == coin.name); + _coins.removeWhere((e) => e.identifier == coin.identifier); } if (shouldNotifyListeners) { notifyListeners(); diff --git a/lib/models/balance.dart b/lib/models/balance.dart index 9f4b36a1c..66eb6ab92 100644 --- a/lib/models/balance.dart +++ b/lib/models/balance.dart @@ -10,8 +10,8 @@ import 'dart:convert'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import '../utilities/amount/amount.dart'; +import '../wallets/crypto_currency/crypto_currency.dart'; class Balance { final Amount total; @@ -26,10 +26,10 @@ class Balance { required this.pendingSpendable, }); - factory Balance.zeroForCoin({required Coin coin}) { + factory Balance.zeroFor({required CryptoCurrency currency}) { final amount = Amount( rawValue: BigInt.zero, - fractionDigits: coin.decimals, + fractionDigits: currency.fractionDigits, ); return Balance( diff --git a/lib/models/buy/buy_form_state.dart b/lib/models/buy/buy_form_state.dart index edc1b482f..978a84152 100644 --- a/lib/models/buy/buy_form_state.dart +++ b/lib/models/buy/buy_form_state.dart @@ -10,7 +10,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:stackwallet/services/buy/buy.dart'; +import '../../services/buy/buy.dart'; class BuyFormState extends ChangeNotifier { Buy? _buy; diff --git a/lib/models/buy/response_objects/order.dart b/lib/models/buy/response_objects/order.dart index 44e385c9e..7e2a26ef4 100644 --- a/lib/models/buy/response_objects/order.dart +++ b/lib/models/buy/response_objects/order.dart @@ -8,7 +8,7 @@ * */ -import 'package:stackwallet/models/buy/response_objects/quote.dart'; +import 'quote.dart'; class SimplexOrder { final SimplexQuote quote; diff --git a/lib/models/buy/response_objects/quote.dart b/lib/models/buy/response_objects/quote.dart index 6eb846d14..32c28ea04 100644 --- a/lib/models/buy/response_objects/quote.dart +++ b/lib/models/buy/response_objects/quote.dart @@ -9,8 +9,8 @@ */ import 'package:decimal/decimal.dart'; -import 'package:stackwallet/models/buy/response_objects/crypto.dart'; -import 'package:stackwallet/models/buy/response_objects/fiat.dart'; +import 'crypto.dart'; +import 'fiat.dart'; class SimplexQuote { final Crypto crypto; diff --git a/lib/models/buy/simplex/simplex.dart b/lib/models/buy/simplex/simplex.dart index 4b959377b..15d71eeb6 100644 --- a/lib/models/buy/simplex/simplex.dart +++ b/lib/models/buy/simplex/simplex.dart @@ -9,10 +9,10 @@ */ import 'package:decimal/decimal.dart'; -import 'package:stackwallet/models/buy/response_objects/crypto.dart'; -import 'package:stackwallet/models/buy/response_objects/fiat.dart'; -import 'package:stackwallet/models/buy/response_objects/order.dart'; -import 'package:stackwallet/models/buy/response_objects/quote.dart'; +import '../response_objects/crypto.dart'; +import '../response_objects/fiat.dart'; +import '../response_objects/order.dart'; +import '../response_objects/quote.dart'; class Simplex { List supportedCryptos = []; diff --git a/lib/models/contact.dart b/lib/models/contact.dart index 239680fd7..46cea2a76 100644 --- a/lib/models/contact.dart +++ b/lib/models/contact.dart @@ -10,7 +10,7 @@ import 'dart:convert'; -import 'package:stackwallet/models/contact_address_entry.dart'; +import 'contact_address_entry.dart'; import 'package:uuid/uuid.dart'; @Deprecated("Use lib/models/isar/models/contact_entry.dart instead") diff --git a/lib/models/contact_address_entry.dart b/lib/models/contact_address_entry.dart index 6f1ad1d54..b11f4f737 100644 --- a/lib/models/contact_address_entry.dart +++ b/lib/models/contact_address_entry.dart @@ -10,11 +10,12 @@ import 'dart:convert'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import '../app_config.dart'; +import '../wallets/crypto_currency/crypto_currency.dart'; @Deprecated("Use lib/models/isar/models/contact_entry.dart instead") class ContactAddressEntry { - final Coin coin; + final CryptoCurrency coin; final String address; final String label; final String? other; @@ -27,7 +28,7 @@ class ContactAddressEntry { }); ContactAddressEntry copyWith({ - Coin? coin, + CryptoCurrency? coin, String? address, String? label, String? other, @@ -42,7 +43,7 @@ class ContactAddressEntry { factory ContactAddressEntry.fromJson(Map jsonObject) { return ContactAddressEntry( - coin: Coin.values.byName(jsonObject["coin"] as String), + coin: AppConfig.getCryptoCurrencyFor(jsonObject["coin"] as String)!, address: jsonObject["address"] as String, label: jsonObject["label"] as String, other: jsonObject["other"] as String?, @@ -53,7 +54,7 @@ class ContactAddressEntry { return { "label": label, "address": address, - "coin": coin.name, + "coin": coin.identifier, "other": other ?? "", }; } diff --git a/lib/models/contact_address_entry_data.dart b/lib/models/contact_address_entry_data.dart index d7fb17684..106f07dd6 100644 --- a/lib/models/contact_address_entry_data.dart +++ b/lib/models/contact_address_entry_data.dart @@ -9,9 +9,8 @@ */ import 'package:flutter/cupertino.dart'; -import 'package:stackwallet/models/isar/models/contact_entry.dart'; -import 'package:stackwallet/utilities/address_utils.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import 'isar/models/contact_entry.dart'; +import '../wallets/crypto_currency/crypto_currency.dart'; class AddressEntryData extends ChangeNotifier { late int id; @@ -20,7 +19,7 @@ class AddressEntryData extends ChangeNotifier { String? _addressLabel; String? _address; - Coin? _coin; + CryptoCurrency? _coin; String? get addressLabel => _addressLabel; @@ -36,9 +35,9 @@ class AddressEntryData extends ChangeNotifier { notifyListeners(); } - Coin? get coin => _coin; + CryptoCurrency? get coin => _coin; - set coin(Coin? coin) { + set coin(CryptoCurrency? coin) { _coin = coin; notifyListeners(); } @@ -73,12 +72,12 @@ class AddressEntryData extends ChangeNotifier { if (_address == null) { return false; } - return AddressUtils.validateAddress(_address!, _coin!); + return _coin!.validateAddress(_address!); } ContactAddressEntry buildAddressEntry() { return ContactAddressEntry() - ..coinName = coin!.name + ..coinName = coin!.identifier ..address = address! ..other = null ..label = addressLabel!; @@ -86,6 +85,6 @@ class AddressEntryData extends ChangeNotifier { @override String toString() { - return "AddressEntryData: { addressLabel: $addressLabel, address: $address, coin: ${coin?.name} }"; + return "AddressEntryData: { addressLabel: $addressLabel, address: $address, coin: ${coin?.identifier} }"; } } diff --git a/lib/models/epicbox_config_model.dart b/lib/models/epicbox_config_model.dart index 5c3509c12..55650f11e 100644 --- a/lib/models/epicbox_config_model.dart +++ b/lib/models/epicbox_config_model.dart @@ -11,7 +11,7 @@ import 'dart:convert'; import 'package:hive/hive.dart'; -import 'package:stackwallet/models/epicbox_server_model.dart'; +import 'epicbox_server_model.dart'; part 'type_adaptors/epicbox_config_model.g.dart'; diff --git a/lib/models/exchange/active_pair.dart b/lib/models/exchange/active_pair.dart index 56e348d11..63393fb47 100644 --- a/lib/models/exchange/active_pair.dart +++ b/lib/models/exchange/active_pair.dart @@ -9,7 +9,7 @@ */ import 'package:flutter/foundation.dart'; -import 'package:stackwallet/models/exchange/aggregate_currency.dart'; +import 'aggregate_currency.dart'; class ActivePair extends ChangeNotifier { AggregateCurrency? _send; diff --git a/lib/models/exchange/aggregate_currency.dart b/lib/models/exchange/aggregate_currency.dart index cad2708e9..841262c1d 100644 --- a/lib/models/exchange/aggregate_currency.dart +++ b/lib/models/exchange/aggregate_currency.dart @@ -8,8 +8,8 @@ * */ -import 'package:stackwallet/models/isar/exchange_cache/currency.dart'; -import 'package:stackwallet/models/isar/exchange_cache/pair.dart'; +import '../isar/exchange_cache/currency.dart'; +import '../isar/exchange_cache/pair.dart'; import 'package:tuple/tuple.dart'; class AggregateCurrency { diff --git a/lib/models/exchange/change_now/cn_exchange_estimate.dart b/lib/models/exchange/change_now/cn_exchange_estimate.dart index 08d96d2dd..8d3c43566 100644 --- a/lib/models/exchange/change_now/cn_exchange_estimate.dart +++ b/lib/models/exchange/change_now/cn_exchange_estimate.dart @@ -9,7 +9,7 @@ */ import 'package:decimal/decimal.dart'; -import 'package:stackwallet/utilities/logger.dart'; +import '../../../utilities/logger.dart'; enum CNEstimateType { direct, reverse } diff --git a/lib/models/exchange/change_now/estimated_exchange_amount.dart b/lib/models/exchange/change_now/estimated_exchange_amount.dart index 03b8da4cf..8313e686b 100644 --- a/lib/models/exchange/change_now/estimated_exchange_amount.dart +++ b/lib/models/exchange/change_now/estimated_exchange_amount.dart @@ -9,7 +9,7 @@ */ import 'package:decimal/decimal.dart'; -import 'package:stackwallet/utilities/logger.dart'; +import '../../../utilities/logger.dart'; class EstimatedExchangeAmount { /// Estimated exchange amount diff --git a/lib/models/exchange/change_now/exchange_transaction.dart b/lib/models/exchange/change_now/exchange_transaction.dart index e1d6a41ed..e19d1c9c8 100644 --- a/lib/models/exchange/change_now/exchange_transaction.dart +++ b/lib/models/exchange/change_now/exchange_transaction.dart @@ -10,7 +10,7 @@ import 'package:decimal/decimal.dart'; import 'package:hive/hive.dart'; -import 'package:stackwallet/models/exchange/change_now/exchange_transaction_status.dart'; +import 'exchange_transaction_status.dart'; import 'package:uuid/uuid.dart'; part '../../type_adaptors/exchange_transaction.g.dart'; diff --git a/lib/models/exchange/change_now/exchange_transaction_status.dart b/lib/models/exchange/change_now/exchange_transaction_status.dart index cd337fb81..679d1af13 100644 --- a/lib/models/exchange/change_now/exchange_transaction_status.dart +++ b/lib/models/exchange/change_now/exchange_transaction_status.dart @@ -9,7 +9,7 @@ */ import 'package:hive/hive.dart'; -import 'package:stackwallet/utilities/logger.dart'; +import '../../../utilities/logger.dart'; part '../../type_adaptors/exchange_transaction_status.g.dart'; diff --git a/lib/models/exchange/incomplete_exchange.dart b/lib/models/exchange/incomplete_exchange.dart index 7ca7bfe09..1397afb1a 100644 --- a/lib/models/exchange/incomplete_exchange.dart +++ b/lib/models/exchange/incomplete_exchange.dart @@ -10,9 +10,9 @@ import 'package:decimal/decimal.dart'; import 'package:flutter/foundation.dart'; -import 'package:stackwallet/models/exchange/response_objects/estimate.dart'; -import 'package:stackwallet/models/exchange/response_objects/trade.dart'; -import 'package:stackwallet/utilities/enums/exchange_rate_type_enum.dart'; +import 'response_objects/estimate.dart'; +import 'response_objects/trade.dart'; +import '../../utilities/enums/exchange_rate_type_enum.dart'; class IncompleteExchangeModel extends ChangeNotifier { final String sendTicker; diff --git a/lib/models/exchange/majestic_bank/mb_limit.dart b/lib/models/exchange/majestic_bank/mb_limit.dart index a549b3b39..e564e332d 100644 --- a/lib/models/exchange/majestic_bank/mb_limit.dart +++ b/lib/models/exchange/majestic_bank/mb_limit.dart @@ -9,7 +9,7 @@ */ import 'package:decimal/decimal.dart'; -import 'package:stackwallet/models/exchange/majestic_bank/mb_object.dart'; +import 'mb_object.dart'; class MBLimit extends MBObject { MBLimit({ diff --git a/lib/models/exchange/majestic_bank/mb_order.dart b/lib/models/exchange/majestic_bank/mb_order.dart index 8361c63db..7a8c828ba 100644 --- a/lib/models/exchange/majestic_bank/mb_order.dart +++ b/lib/models/exchange/majestic_bank/mb_order.dart @@ -9,7 +9,7 @@ */ import 'package:decimal/decimal.dart'; -import 'package:stackwallet/models/exchange/majestic_bank/mb_object.dart'; +import 'mb_object.dart'; enum MBOrderType { fixed, diff --git a/lib/models/exchange/majestic_bank/mb_order_calculation.dart b/lib/models/exchange/majestic_bank/mb_order_calculation.dart index 4ac6711f0..2b0e70a8c 100644 --- a/lib/models/exchange/majestic_bank/mb_order_calculation.dart +++ b/lib/models/exchange/majestic_bank/mb_order_calculation.dart @@ -9,7 +9,7 @@ */ import 'package:decimal/decimal.dart'; -import 'package:stackwallet/models/exchange/majestic_bank/mb_object.dart'; +import 'mb_object.dart'; class MBOrderCalculation extends MBObject { MBOrderCalculation({ diff --git a/lib/models/exchange/majestic_bank/mb_order_status.dart b/lib/models/exchange/majestic_bank/mb_order_status.dart index 7dbb274cc..6bec09b12 100644 --- a/lib/models/exchange/majestic_bank/mb_order_status.dart +++ b/lib/models/exchange/majestic_bank/mb_order_status.dart @@ -9,7 +9,7 @@ */ import 'package:decimal/decimal.dart'; -import 'package:stackwallet/models/exchange/majestic_bank/mb_object.dart'; +import 'mb_object.dart'; class MBOrderStatus extends MBObject { MBOrderStatus({ diff --git a/lib/models/exchange/majestic_bank/mb_rate.dart b/lib/models/exchange/majestic_bank/mb_rate.dart index 2702a359d..c4b5d2b8a 100644 --- a/lib/models/exchange/majestic_bank/mb_rate.dart +++ b/lib/models/exchange/majestic_bank/mb_rate.dart @@ -9,7 +9,7 @@ */ import 'package:decimal/decimal.dart'; -import 'package:stackwallet/models/exchange/majestic_bank/mb_object.dart'; +import 'mb_object.dart'; class MBRate extends MBObject { MBRate({required this.fromCurrency, required this.toCurrency, required this.rate,}); diff --git a/lib/models/exchange/response_objects/estimate.dart b/lib/models/exchange/response_objects/estimate.dart index ef48e5850..d51fda17c 100644 --- a/lib/models/exchange/response_objects/estimate.dart +++ b/lib/models/exchange/response_objects/estimate.dart @@ -9,7 +9,7 @@ */ import 'package:decimal/decimal.dart'; -import 'package:stackwallet/utilities/logger.dart'; +import '../../../utilities/logger.dart'; class Estimate { final Decimal estimatedAmount; diff --git a/lib/models/exchange/response_objects/fixed_rate_market.dart b/lib/models/exchange/response_objects/fixed_rate_market.dart index 6b2c8dc3e..103d9d99f 100644 --- a/lib/models/exchange/response_objects/fixed_rate_market.dart +++ b/lib/models/exchange/response_objects/fixed_rate_market.dart @@ -9,7 +9,7 @@ */ import 'package:decimal/decimal.dart'; -import 'package:stackwallet/utilities/logger.dart'; +import '../../../utilities/logger.dart'; class FixedRateMarket { /// Currency ticker diff --git a/lib/models/exchange/response_objects/trade.dart b/lib/models/exchange/response_objects/trade.dart index 5f52183a3..86adb0bee 100644 --- a/lib/models/exchange/response_objects/trade.dart +++ b/lib/models/exchange/response_objects/trade.dart @@ -9,8 +9,8 @@ */ import 'package:hive/hive.dart'; -import 'package:stackwallet/models/exchange/change_now/exchange_transaction.dart'; -import 'package:stackwallet/services/exchange/change_now/change_now_exchange.dart'; +import '../change_now/exchange_transaction.dart'; +import '../../../services/exchange/change_now/change_now_exchange.dart'; part 'trade.g.dart'; diff --git a/lib/models/exchange/simpleswap/sp_currency.dart b/lib/models/exchange/simpleswap/sp_currency.dart index f45a80332..04a77de67 100644 --- a/lib/models/exchange/simpleswap/sp_currency.dart +++ b/lib/models/exchange/simpleswap/sp_currency.dart @@ -8,7 +8,7 @@ * */ -import 'package:stackwallet/utilities/logger.dart'; +import '../../../utilities/logger.dart'; class SPCurrency { /// currency name diff --git a/lib/models/fusion_progress_ui_state.dart b/lib/models/fusion_progress_ui_state.dart index 62168e359..2da6e354f 100644 --- a/lib/models/fusion_progress_ui_state.dart +++ b/lib/models/fusion_progress_ui_state.dart @@ -1,5 +1,5 @@ import 'package:flutter/cupertino.dart'; -import 'package:stackwallet/pages_desktop_specific/cashfusion/sub_widgets/fusion_dialog.dart'; +import '../pages_desktop_specific/cashfusion/sub_widgets/fusion_dialog.dart'; class FusionProgressUIState extends ChangeNotifier { /// Whether we are able to connect to the server. diff --git a/lib/models/isar/exchange_cache/currency.dart b/lib/models/isar/exchange_cache/currency.dart index 5a3915e08..71c7890ce 100644 --- a/lib/models/isar/exchange_cache/currency.dart +++ b/lib/models/isar/exchange_cache/currency.dart @@ -9,8 +9,9 @@ */ import 'package:isar/isar.dart'; -import 'package:stackwallet/models/isar/exchange_cache/pair.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; + +import '../../../app_config.dart'; +import 'pair.dart'; part 'currency.g.dart'; @@ -98,7 +99,7 @@ class Currency { rateType: rateType, isAvailable: json["isAvailable"] as bool?, isStackCoin: - json["isStackCoin"] as bool? ?? Currency.checkIsStackCoin(ticker), + json["isStackCoin"] as bool? ?? AppConfig.isStackCoin(ticker), tokenContract: json["tokenContract"] as String?, )..id = json["id"] as int?; } catch (e) { @@ -158,13 +159,4 @@ class Currency { String toString() { return "Currency: ${toJson()}"; } - - static bool checkIsStackCoin(String ticker) { - try { - coinFromTickerCaseInsensitive(ticker); - return true; - } catch (_) { - return false; - } - } } diff --git a/lib/models/isar/models/block_explorer.dart b/lib/models/isar/models/block_explorer.dart index 05d832580..6bde45001 100644 --- a/lib/models/isar/models/block_explorer.dart +++ b/lib/models/isar/models/block_explorer.dart @@ -9,7 +9,8 @@ */ import 'package:isar/isar.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import '../../../app_config.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; part 'block_explorer.g.dart'; @@ -28,9 +29,9 @@ class TransactionBlockExplorer { late final String url; @ignore - Coin? get coin { + CryptoCurrency? get coin { try { - return coinFromTickerCaseInsensitive(ticker); + return AppConfig.getCryptoCurrencyForTicker(ticker); } catch (_) { return null; } diff --git a/lib/models/isar/models/blockchain_data/address.dart b/lib/models/isar/models/blockchain_data/address.dart index e3314d754..bcc7d22c5 100644 --- a/lib/models/isar/models/blockchain_data/address.dart +++ b/lib/models/isar/models/blockchain_data/address.dart @@ -11,9 +11,9 @@ import 'dart:convert'; import 'package:isar/isar.dart'; -import 'package:stackwallet/exceptions/address/address_exception.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/crypto_currency_address.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; +import '../../../../exceptions/address/address_exception.dart'; +import 'crypto_currency_address.dart'; +import 'transaction.dart'; part 'address.g.dart'; diff --git a/lib/models/isar/models/blockchain_data/transaction.dart b/lib/models/isar/models/blockchain_data/transaction.dart index 59848b1fd..73d935681 100644 --- a/lib/models/isar/models/blockchain_data/transaction.dart +++ b/lib/models/isar/models/blockchain_data/transaction.dart @@ -12,10 +12,10 @@ import 'dart:convert'; import 'dart:math'; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/input.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/output.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; +import 'address.dart'; +import 'input.dart'; +import 'output.dart'; +import '../../../../utilities/amount/amount.dart'; import 'package:tuple/tuple.dart'; part 'transaction.g.dart'; diff --git a/lib/models/isar/models/blockchain_data/v2/transaction_v2.dart b/lib/models/isar/models/blockchain_data/v2/transaction_v2.dart index 470bd483b..b7ba87546 100644 --- a/lib/models/isar/models/blockchain_data/v2/transaction_v2.dart +++ b/lib/models/isar/models/blockchain_data/v2/transaction_v2.dart @@ -2,12 +2,12 @@ import 'dart:convert'; import 'dart:math'; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/input_v2.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/output_v2.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/extensions/extensions.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart'; +import '../transaction.dart'; +import 'input_v2.dart'; +import 'output_v2.dart'; +import '../../../../../utilities/amount/amount.dart'; +import '../../../../../utilities/extensions/extensions.dart'; +import '../../../../../wallets/wallet/wallet_mixin_interfaces/spark_interface.dart'; part 'transaction_v2.g.dart'; diff --git a/lib/models/isar/models/contact_entry.dart b/lib/models/isar/models/contact_entry.dart index 6289e8d18..66cd68dc1 100644 --- a/lib/models/isar/models/contact_entry.dart +++ b/lib/models/isar/models/contact_entry.dart @@ -9,7 +9,9 @@ */ import 'package:isar/isar.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; + +import '../../../app_config.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; part 'contact_entry.g.dart'; @@ -36,7 +38,7 @@ class ContactEntry { @ignore List get addressesSorted { final List sorted = []; - for (final coin in Coin.values) { + for (final coin in AppConfig.coins) { final slice = addresses.where((e) => e.coin == coin).toList(); if (slice.isNotEmpty) { slice.sort( @@ -56,13 +58,13 @@ class ContactEntry { List? addresses, bool? isFavorite, }) { - List _addresses = []; + final List _addresses = []; if (addresses == null) { - for (var e in this.addresses) { + for (final e in this.addresses) { _addresses.add(e.copyWith()); } } else { - for (var e in addresses) { + for (final e in addresses) { _addresses.add(e.copyWith()); } } @@ -101,18 +103,18 @@ class ContactAddressEntry { late final String? other; @ignore - Coin get coin => Coin.values.byName(coinName); + CryptoCurrency get coin => AppConfig.getCryptoCurrencyFor(coinName)!; ContactAddressEntry(); ContactAddressEntry copyWith({ - Coin? coin, + CryptoCurrency? coin, String? address, String? label, String? other, }) { return ContactAddressEntry() - ..coinName = coin?.name ?? coinName + ..coinName = coin?.identifier ?? coinName ..address = address ?? this.address ..label = label ?? this.label ..other = other ?? this.other; @@ -122,7 +124,7 @@ class ContactAddressEntry { return { "label": label, "address": address, - "coin": coin.name, + "coin": coin.identifier, "other": other ?? "", }; } diff --git a/lib/models/isar/models/ethereum/eth_contract.dart b/lib/models/isar/models/ethereum/eth_contract.dart index 59b350e0d..df19d9d8d 100644 --- a/lib/models/isar/models/ethereum/eth_contract.dart +++ b/lib/models/isar/models/ethereum/eth_contract.dart @@ -9,7 +9,7 @@ */ import 'package:isar/isar.dart'; -import 'package:stackwallet/models/isar/models/contract.dart'; +import '../contract.dart'; part 'eth_contract.g.dart'; diff --git a/lib/models/isar/models/log.dart b/lib/models/isar/models/log.dart index 31334327a..79f5808b2 100644 --- a/lib/models/isar/models/log.dart +++ b/lib/models/isar/models/log.dart @@ -10,7 +10,7 @@ import 'package:isar/isar.dart'; // import 'package:stackwallet/models/isar/type_converters/log_level_converter.dart'; -import 'package:stackwallet/utilities/enums/log_level_enum.dart'; +import '../../../utilities/enums/log_level_enum.dart'; part 'log.g.dart'; diff --git a/lib/models/isar/ordinal.dart b/lib/models/isar/ordinal.dart index 06ba52ef5..c5c3a23da 100644 --- a/lib/models/isar/ordinal.dart +++ b/lib/models/isar/ordinal.dart @@ -1,7 +1,7 @@ import 'package:isar/isar.dart'; -import 'package:stackwallet/db/isar/main_db.dart'; -import 'package:stackwallet/dto/ordinals/inscription_data.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; +import '../../db/isar/main_db.dart'; +import '../../dto/ordinals/inscription_data.dart'; +import 'models/isar_models.dart'; part 'ordinal.g.dart'; diff --git a/lib/models/isar/stack_theme.dart b/lib/models/isar/stack_theme.dart index 09f42b1b6..ce5002a1d 100644 --- a/lib/models/isar/stack_theme.dart +++ b/lib/models/isar/stack_theme.dart @@ -13,12 +13,12 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/extensions/impl/box_shadow.dart'; -import 'package:stackwallet/utilities/extensions/impl/gradient.dart'; -import 'package:stackwallet/utilities/extensions/impl/string.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/stack_file_system.dart'; +import '../../app_config.dart'; +import '../../utilities/extensions/impl/box_shadow.dart'; +import '../../utilities/extensions/impl/gradient.dart'; +import '../../utilities/extensions/impl/string.dart'; +import '../../utilities/logger.dart'; +import '../../utilities/stack_file_system.dart'; part 'stack_theme.g.dart'; @@ -1482,10 +1482,10 @@ class StackTheme { // ==== coinColors ===================================================== @ignore - Map get coinColors => + Map get coinColors => _coinColors ??= parseCoinColors(coinColorsJsonString); @ignore - Map? _coinColors; + Map? _coinColors; late final String coinColorsJsonString; // ==== assets ===================================================== @@ -1548,7 +1548,8 @@ class StackTheme { json["colors"]["box_shadows"]["home_view_button_bar"] == null ? null : jsonEncode( - json["colors"]["box_shadows"]["home_view_button_bar"] as Map) + json["colors"]["box_shadows"]["home_view_button_bar"] as Map, + ) ..coinColorsJsonString = jsonEncode(json["colors"]['coin'] as Map) ..overlayInt = parseColor(json["colors"]["overlay"] as String) ..accentColorBlueInt = @@ -1587,7 +1588,8 @@ class StackTheme { ..buttonBackBorderSecondaryInt = parseColor(json["colors"]["button_back_border_secondary"] as String) ..buttonBackBorderSecondaryDisabledInt = parseColor( - json["colors"]["button_back_border_secondary_disabled"] as String) + json["colors"]["button_back_border_secondary_disabled"] as String, + ) ..numberBackDefaultInt = parseColor(json["colors"]["number_back_default"] as String) ..numpadBackDefaultInt = @@ -1621,7 +1623,8 @@ class StackTheme { ..buttonTextBorderlessInt = parseColor(json["colors"]["button_text_borderless"] as String) ..buttonTextBorderlessDisabledInt = parseColor( - json["colors"]["button_text_borderless_disabled"] as String) + json["colors"]["button_text_borderless_disabled"] as String, + ) ..numberTextDefaultInt = parseColor(json["colors"]["number_text_default"] as String) ..numpadTextDefaultInt = @@ -1629,9 +1632,11 @@ class StackTheme { ..bottomNavTextInt = parseColor(json["colors"]["bottom_nav_text"] as String) ..customTextButtonEnabledTextInt = parseColor( - json["colors"]["custom_text_button_enabled_text"] as String) + json["colors"]["custom_text_button_enabled_text"] as String, + ) ..customTextButtonDisabledTextInt = parseColor( - json["colors"]["custom_text_button_disabled_text"] as String) + json["colors"]["custom_text_button_disabled_text"] as String, + ) ..switchBGOnInt = parseColor(json["colors"]["switch_bg_on"] as String) ..switchBGOffInt = parseColor(json["colors"]["switch_bg_off"] as String) ..switchBGDisabledInt = @@ -1651,7 +1656,8 @@ class StackTheme { ..stepIndicatorBGLinesInt = parseColor(json["colors"]["step_indicator_bg_lines"] as String) ..stepIndicatorBGLinesInactiveInt = parseColor( - json["colors"]["step_indicator_bg_lines_inactive"] as String) + json["colors"]["step_indicator_bg_lines_inactive"] as String, + ) ..stepIndicatorIconTextInt = parseColor(json["colors"]["step_indicator_icon_text"] as String) ..stepIndicatorIconNumberInt = @@ -1687,7 +1693,8 @@ class StackTheme { ..bottomNavIconIconInt = parseColor(json["colors"]["bottom_nav_icon_icon"] as String) ..bottomNavIconIconHighlightedInt = parseColor( - json["colors"]["bottom_nav_icon_icon_highlighted"] as String) + json["colors"]["bottom_nav_icon_icon_highlighted"] as String, + ) ..topNavIconPrimaryInt = parseColor(json["colors"]["top_nav_icon_primary"] as String) ..topNavIconGreenInt = @@ -1717,13 +1724,17 @@ class StackTheme { ..textFieldSuccessBorderInt = parseColor(json["colors"]["text_field_success_border"] as String) ..textFieldActiveSearchIconLeftInt = parseColor( - json["colors"]["text_field_active_search_icon_left"] as String) + json["colors"]["text_field_active_search_icon_left"] as String, + ) ..textFieldDefaultSearchIconLeftInt = parseColor( - json["colors"]["text_field_default_search_icon_left"] as String) + json["colors"]["text_field_default_search_icon_left"] as String, + ) ..textFieldErrorSearchIconLeftInt = parseColor( - json["colors"]["text_field_error_search_icon_left"] as String) + json["colors"]["text_field_error_search_icon_left"] as String, + ) ..textFieldSuccessSearchIconLeftInt = parseColor( - json["colors"]["text_field_success_search_icon_left"] as String) + json["colors"]["text_field_success_search_icon_left"] as String, + ) ..textFieldActiveTextInt = parseColor(json["colors"]["text_field_active_text"] as String) ..textFieldDefaultTextInt = @@ -1739,23 +1750,31 @@ class StackTheme { ..textFieldSuccessLabelInt = parseColor(json["colors"]["text_field_success_label"] as String) ..textFieldActiveSearchIconRightInt = parseColor( - json["colors"]["text_field_active_search_icon_right"] as String) + json["colors"]["text_field_active_search_icon_right"] as String, + ) ..textFieldDefaultSearchIconRightInt = parseColor( - json["colors"]["text_field_default_search_icon_right"] as String) + json["colors"]["text_field_default_search_icon_right"] as String, + ) ..textFieldErrorSearchIconRightInt = parseColor( - json["colors"]["text_field_error_search_icon_right"] as String) + json["colors"]["text_field_error_search_icon_right"] as String, + ) ..textFieldSuccessSearchIconRightInt = parseColor( - json["colors"]["text_field_success_search_icon_right"] as String) + json["colors"]["text_field_success_search_icon_right"] as String, + ) ..settingsItem2ActiveBGInt = parseColor( - json["colors"]["settings_item_level_two_active_bg"] as String) + json["colors"]["settings_item_level_two_active_bg"] as String, + ) ..settingsItem2ActiveTextInt = parseColor( - json["colors"]["settings_item_level_two_active_text"] as String) + json["colors"]["settings_item_level_two_active_text"] as String, + ) ..settingsItem2ActiveSubInt = parseColor( - json["colors"]["settings_item_level_two_active_sub"] as String) + json["colors"]["settings_item_level_two_active_sub"] as String, + ) ..radioButtonIconBorderInt = parseColor(json["colors"]["radio_button_icon_border"] as String) ..radioButtonIconBorderDisabledInt = parseColor( - json["colors"]["radio_button_icon_border_disabled"] as String) + json["colors"]["radio_button_icon_border_disabled"] as String, + ) ..radioButtonBorderEnabledInt = parseColor(json["colors"]["radio_button_border_enabled"] as String) ..radioButtonBorderDisabledInt = @@ -1809,9 +1828,11 @@ class StackTheme { ..rateTypeToggleColorOffInt = parseColor(json["colors"]["rate_type_toggle_color_off"] as String) ..rateTypeToggleDesktopColorOnInt = parseColor( - json["colors"]["rate_type_toggle_desktop_color_on"] as String) + json["colors"]["rate_type_toggle_desktop_color_on"] as String, + ) ..rateTypeToggleDesktopColorOffInt = parseColor( - json["colors"]["rate_type_toggle_desktop_color_off"] as String) + json["colors"]["rate_type_toggle_desktop_color_off"] as String, + ) ..ethTagTextInt = parseColor(json["colors"]["eth_tag_text"] as String) ..ethTagBGInt = parseColor(json["colors"]["eth_tag_bg"] as String) ..ethWalletTagTextInt = @@ -1851,20 +1872,20 @@ class StackTheme { } /// parse coin colors json and fetch color or use default - static Map parseCoinColors(String jsonString) { + static Map parseCoinColors(String jsonString) { final json = jsonDecode(jsonString) as Map; final map = Map.from(json); - final Map result = {}; + final Map result = {}; - for (final coin in Coin.values.map((e) => e.mainNetVersion)) { - if (map[coin.name] is String) { - result[coin] = Color( - (map[coin.name] as String).toBigIntFromHex.toInt(), + for (final mainNetId in AppConfig.coins.map((e) => e.mainNetId)) { + if (map[mainNetId] is String) { + result[mainNetId] = Color( + (map[mainNetId] as String).toBigIntFromHex.toInt(), ); } else { Logging.instance.log( - "Color not found in theme for $coin", + "Color not found in theme for $mainNetId", level: LogLevel.Error, ); } @@ -2080,31 +2101,31 @@ class ThemeAssetsV2 implements IThemeAssets { late final String coinPlaceholder; @ignore - Map get coinIcons => _coinIcons ??= parseCoinAssetsString( + Map get coinIcons => _coinIcons ??= parseCoinAssetsString( coinIconsString, placeHolder: coinPlaceholder, ); @ignore - Map? _coinIcons; + Map? _coinIcons; late final String coinIconsString; @ignore - Map get coinImages => _coinImages ??= parseCoinAssetsString( + Map get coinImages => _coinImages ??= parseCoinAssetsString( coinImagesString, placeHolder: coinPlaceholder, ); @ignore - Map? _coinImages; + Map? _coinImages; late final String coinImagesString; @ignore - Map get coinSecondaryImages => + Map get coinSecondaryImages => _coinSecondaryImages ??= parseCoinAssetsString( coinSecondaryImagesString, placeHolder: coinPlaceholder, ); @ignore - Map? _coinSecondaryImages; + Map? _coinSecondaryImages; late final String coinSecondaryImagesString; ThemeAssetsV2(); @@ -2166,17 +2187,17 @@ class ThemeAssetsV2 implements IThemeAssets { return jsonEncode(map); } - static Map parseCoinAssetsString( + static Map parseCoinAssetsString( String jsonString, { required String placeHolder, }) { final json = jsonDecode(jsonString) as Map; final map = Map.from(json); - final Map result = {}; + final Map result = {}; - for (final coin in Coin.values) { - result[coin] = map[coin.name] as String? ?? placeHolder; + for (final coin in AppConfig.coins) { + result[coin.mainNetId] = map[coin.mainNetId] as String? ?? placeHolder; } return result; @@ -2350,35 +2371,35 @@ class ThemeAssetsV3 implements IThemeAssets { late final String? dummy3; @ignore - Map get coinIcons => _coinIcons ??= parseCoinAssetsString( + Map get coinIcons => _coinIcons ??= parseCoinAssetsString( coinIconsString, placeHolder: coinPlaceholder, ); @ignore - Map? _coinIcons; + Map? _coinIcons; late final String coinIconsString; @ignore - Map get coinImages => _coinImages ??= parseCoinAssetsString( + Map get coinImages => _coinImages ??= parseCoinAssetsString( coinImagesString, placeHolder: coinPlaceholder, ); @ignore - Map? _coinImages; + Map? _coinImages; late final String coinImagesString; @ignore - Map get coinSecondaryImages => + Map get coinSecondaryImages => _coinSecondaryImages ??= parseCoinAssetsString( coinSecondaryImagesString, placeHolder: coinPlaceholder, ); @ignore - Map? _coinSecondaryImages; + Map? _coinSecondaryImages; late final String coinSecondaryImagesString; @ignore - Map? get coinCardImages => + Map? get coinCardImages => _coinCardImages ??= coinCardImagesString == null ? null : parseCoinAssetsString( @@ -2386,11 +2407,11 @@ class ThemeAssetsV3 implements IThemeAssets { placeHolder: coinPlaceholder, ); @ignore - Map? _coinCardImages; + Map? _coinCardImages; late final String? coinCardImagesString; @ignore - Map? get coinCardFavoritesImages => + Map? get coinCardFavoritesImages => _coinCardFavoritesImages ??= coinCardFavoritesImagesString == null ? null : parseCoinAssetsString( @@ -2398,7 +2419,7 @@ class ThemeAssetsV3 implements IThemeAssets { placeHolder: coinPlaceholder, ); @ignore - Map? _coinCardFavoritesImages; + Map? _coinCardFavoritesImages; @Name("otherStringParam1") late final String? coinCardFavoritesImagesString; @@ -2501,19 +2522,18 @@ class ThemeAssetsV3 implements IThemeAssets { return jsonEncode(map); } - static Map parseCoinAssetsString( + static Map parseCoinAssetsString( String jsonString, { required String placeHolder, }) { final json = jsonDecode(jsonString) as Map; final map = Map.from(json); - final Map result = {}; + final Map result = {}; - for (final coin in Coin.values) { - result[coin] = map[coin.name] as String? ?? placeHolder; - - result[coin] = prependIfNeeded(result[coin]!); + for (final coin in AppConfig.coins) { + result[coin.mainNetId] = map[coin.mainNetId] as String? ?? placeHolder; + result[coin.mainNetId] = prependIfNeeded(result[coin.mainNetId]!); } return result; diff --git a/lib/models/node_model.dart b/lib/models/node_model.dart index ce79722ef..636be9aac 100644 --- a/lib/models/node_model.dart +++ b/lib/models/node_model.dart @@ -9,8 +9,8 @@ */ import 'package:hive/hive.dart'; -import 'package:stackwallet/utilities/default_nodes.dart'; -import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; +import '../utilities/default_nodes.dart'; +import '../utilities/flutter_secure_storage_interface.dart'; part 'type_adaptors/node_model.g.dart'; diff --git a/lib/models/paymint/transactions_model.dart b/lib/models/paymint/transactions_model.dart index db2dd2eee..c00f31565 100644 --- a/lib/models/paymint/transactions_model.dart +++ b/lib/models/paymint/transactions_model.dart @@ -11,8 +11,6 @@ import 'package:dart_numerics/dart_numerics.dart'; import 'package:decimal/decimal.dart'; import 'package:hive/hive.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; part '../type_adaptors/transactions_model.g.dart'; @@ -236,19 +234,11 @@ class Transaction { timestamp: json['timestamp'] as int? ?? (DateTime.now().millisecondsSinceEpoch ~/ 1000), txType: json['txType'] as String, - amount: (Decimal.parse(json["amount"].toString()) * - Decimal.fromInt(Constants.satsPerCoin(Coin - .firo).toInt())) // dirty hack but we need 8 decimal places here to keep consistent data structure - .toBigInt() - .toInt(), + amount: _parse(json["amount"].toString()), aliens: [], worthNow: json['worthNow'] as String, worthAtBlockTimestamp: json['worthAtBlockTimestamp'] as String? ?? "0", - fees: (Decimal.parse(json["fees"].toString()) * - Decimal.fromInt(Constants.satsPerCoin(Coin - .firo).toInt())) // dirty hack but we need 8 decimal places here to keep consistent data structure - .toBigInt() - .toInt(), + fees: _parse(json["fees"].toString()), inputSize: json['inputSize'] as int? ?? 0, outputSize: json['outputSize'] as int? ?? 0, inputs: [], @@ -411,12 +401,7 @@ class Output { scriptpubkeyAsm: json['scriptPubKey']['asm'] as String?, scriptpubkeyType: json['scriptPubKey']['type'] as String?, scriptpubkeyAddress: address, - value: (Decimal.parse( - (json["value"] ?? 0).toString()) * - Decimal.fromInt(Constants.satsPerCoin(Coin - .firo).toInt())) // dirty hack but we need 8 decimal places here to keep consistent data structure - .toBigInt() - .toInt(), + value: _parse((json["value"] ?? 0).toString()), ); } catch (s, e) { return Output( @@ -425,11 +410,11 @@ class Output { scriptpubkeyAsm: "", scriptpubkeyType: "", scriptpubkeyAddress: "", - value: (Decimal.parse(0.toString()) * - Decimal.fromInt(Constants.satsPerCoin(Coin - .firo).toInt())) // dirty hack but we need 8 decimal places here to keep consistent data structure - .toBigInt() - .toInt()); + value: _parse(0.toString())); } } } + +int _parse(String value) { + return (Decimal.parse(value) * Decimal.fromInt(8)).toBigInt().toInt(); +} diff --git a/lib/models/paynym/paynym_account.dart b/lib/models/paynym/paynym_account.dart index 4727820b4..184f8c8aa 100644 --- a/lib/models/paynym/paynym_account.dart +++ b/lib/models/paynym/paynym_account.dart @@ -8,8 +8,8 @@ * */ -import 'package:stackwallet/models/paynym/paynym_account_lite.dart'; -import 'package:stackwallet/models/paynym/paynym_code.dart'; +import 'paynym_account_lite.dart'; +import 'paynym_code.dart'; class PaynymAccount { final String nymID; diff --git a/lib/models/signing_data.dart b/lib/models/signing_data.dart index 24dac4546..265a021db 100644 --- a/lib/models/signing_data.dart +++ b/lib/models/signing_data.dart @@ -9,8 +9,8 @@ */ import 'package:coinlib_flutter/coinlib_flutter.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart'; +import 'isar/models/isar_models.dart'; +import '../utilities/enums/derive_path_type_enum.dart'; class SigningData { SigningData({ diff --git a/lib/models/stack_restoring_ui_state.dart b/lib/models/stack_restoring_ui_state.dart index e66e4e99f..6ee4e9e1b 100644 --- a/lib/models/stack_restoring_ui_state.dart +++ b/lib/models/stack_restoring_ui_state.dart @@ -10,9 +10,9 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/wallet_restore_state.dart'; -import 'package:stackwallet/utilities/enums/stack_restoring_status.dart'; -import 'package:stackwallet/wallets/wallet/wallet.dart'; +import 'wallet_restore_state.dart'; +import '../utilities/enums/stack_restoring_status.dart'; +import '../wallets/wallet/wallet.dart'; class StackRestoringUIState extends ChangeNotifier { bool _walletsWasSet = false; diff --git a/lib/models/transaction_filter.dart b/lib/models/transaction_filter.dart index 9c9c7b879..8141cf3bd 100644 --- a/lib/models/transaction_filter.dart +++ b/lib/models/transaction_filter.dart @@ -8,7 +8,7 @@ * */ -import 'package:stackwallet/utilities/amount/amount.dart'; +import '../utilities/amount/amount.dart'; class TransactionFilter { final bool sent; diff --git a/lib/models/tx_info.dart b/lib/models/tx_info.dart index ddb361979..9ce2642ea 100644 --- a/lib/models/tx_info.dart +++ b/lib/models/tx_info.dart @@ -8,9 +8,9 @@ * */ -import 'package:stackwallet/models/isar/models/blockchain_data/utxo.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/wallets/models/tx_recipient.dart'; +import 'isar/models/blockchain_data/utxo.dart'; +import '../utilities/amount/amount.dart'; +import '../wallets/models/tx_recipient.dart'; // TODO use something like this instead of Map transactionObject diff --git a/lib/models/wallet_restore_state.dart b/lib/models/wallet_restore_state.dart index 37598651d..fee03e46d 100644 --- a/lib/models/wallet_restore_state.dart +++ b/lib/models/wallet_restore_state.dart @@ -9,14 +9,14 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/stack_restoring_status.dart'; -import 'package:stackwallet/wallets/wallet/wallet.dart'; +import '../utilities/enums/stack_restoring_status.dart'; +import '../wallets/crypto_currency/crypto_currency.dart'; +import '../wallets/wallet/wallet.dart'; class WalletRestoreState extends ChangeNotifier { final String walletId; final String walletName; - final Coin coin; + final CryptoCurrency coin; late StackRestoringStatus _restoringStatus; Wallet? wallet; String? address; diff --git a/lib/networking/http.dart b/lib/networking/http.dart index ad15b659c..a4f25c225 100644 --- a/lib/networking/http.dart +++ b/lib/networking/http.dart @@ -4,7 +4,7 @@ import 'dart:io'; import 'package:flutter/foundation.dart'; import 'package:socks5_proxy/socks_client.dart'; -import 'package:stackwallet/utilities/logger.dart'; +import '../utilities/logger.dart'; // WIP wrapper layer diff --git a/lib/notifications/notification_card.dart b/lib/notifications/notification_card.dart index ada6400f6..feb81ce54 100644 --- a/lib/notifications/notification_card.dart +++ b/lib/notifications/notification_card.dart @@ -13,18 +13,18 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/models/isar/stack_theme.dart'; -import 'package:stackwallet/models/notification_model.dart'; -import 'package:stackwallet/themes/coin_icon_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/format.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../app_config.dart'; +import '../models/isar/stack_theme.dart'; +import '../models/notification_model.dart'; +import '../themes/coin_icon_provider.dart'; +import '../themes/stack_colors.dart'; +import '../themes/theme_providers.dart'; +import '../utilities/format.dart'; +import '../utilities/text_styles.dart'; +import '../utilities/util.dart'; +import '../widgets/conditional_parent.dart'; +import '../widgets/rounded_container.dart'; +import '../widgets/rounded_white_container.dart'; class NotificationCard extends ConsumerWidget { const NotificationCard({ @@ -44,7 +44,8 @@ class NotificationCard extends ConsumerWidget { String coinIconPath(IThemeAssets assets, WidgetRef ref) { try { - final coin = coinFromPrettyName(notification.coinName); + final coin = + AppConfig.getCryptoCurrencyByPrettyName(notification.coinName); return ref.read(coinIconProvider(coin)); } catch (_) { return notification.iconAssetName; diff --git a/lib/notifications/show_flush_bar.dart b/lib/notifications/show_flush_bar.dart index 6364d76c4..b955a41ec 100644 --- a/lib/notifications/show_flush_bar.dart +++ b/lib/notifications/show_flush_bar.dart @@ -12,11 +12,12 @@ import 'package:another_flushbar/flushbar.dart'; import 'package:another_flushbar/flushbar_route.dart' as flushRoute; import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/flush_bar_type.dart'; -export 'package:stackwallet/utilities/enums/flush_bar_type.dart'; +import '../themes/stack_colors.dart'; +import '../utilities/constants.dart'; +import '../utilities/enums/flush_bar_type.dart'; + +export '../utilities/enums/flush_bar_type.dart'; Future showFloatingFlushBar({ required FlushBarType type, diff --git a/lib/pages/add_wallet_views/add_token_view/add_custom_token_view.dart b/lib/pages/add_wallet_views/add_token_view/add_custom_token_view.dart index dd807976b..155d741b7 100644 --- a/lib/pages/add_wallet_views/add_token_view/add_custom_token_view.dart +++ b/lib/pages/add_wallet_views/add_token_view/add_custom_token_view.dart @@ -13,19 +13,19 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart'; -import 'package:stackwallet/services/ethereum/ethereum_api.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/show_loading.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../../models/isar/models/ethereum/eth_contract.dart'; +import '../../../services/ethereum/ethereum_api.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/show_loading.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../widgets/background.dart'; +import '../../../widgets/conditional_parent.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../widgets/desktop/primary_button.dart'; +import '../../../widgets/desktop/secondary_button.dart'; +import '../../../widgets/stack_dialog.dart'; class AddCustomTokenView extends ConsumerStatefulWidget { const AddCustomTokenView({ diff --git a/lib/pages/add_wallet_views/add_token_view/edit_wallet_tokens_view.dart b/lib/pages/add_wallet_views/add_token_view/edit_wallet_tokens_view.dart index 82ca119a4..4a54b9b3d 100644 --- a/lib/pages/add_wallet_views/add_token_view/edit_wallet_tokens_view.dart +++ b/lib/pages/add_wallet_views/add_token_view/edit_wallet_tokens_view.dart @@ -14,38 +14,38 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/db/isar/main_db.dart'; -import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/add_wallet_views/add_token_view/add_custom_token_view.dart'; -import 'package:stackwallet/pages/add_wallet_views/add_token_view/sub_widgets/add_token_list.dart'; -import 'package:stackwallet/pages/add_wallet_views/add_token_view/sub_widgets/add_token_list_element.dart'; -import 'package:stackwallet/pages/add_wallet_views/add_token_view/sub_widgets/add_token_text.dart'; -import 'package:stackwallet/pages/home_view/home_view.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_home_view.dart'; -import 'package:stackwallet/providers/global/price_provider.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/default_eth_tokens.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/wallets/wallet/impl/ethereum_wallet.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../../db/isar/main_db.dart'; +import '../../../models/isar/models/ethereum/eth_contract.dart'; +import '../../../notifications/show_flush_bar.dart'; +import 'add_custom_token_view.dart'; +import 'sub_widgets/add_token_list.dart'; +import 'sub_widgets/add_token_list_element.dart'; +import 'sub_widgets/add_token_text.dart'; +import '../../home_view/home_view.dart'; +import '../../../pages_desktop_specific/desktop_home_view.dart'; +import '../../../providers/global/price_provider.dart'; +import '../../../providers/global/wallets_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/default_eth_tokens.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../wallets/wallet/impl/ethereum_wallet.dart'; +import '../../../widgets/background.dart'; +import '../../../widgets/conditional_parent.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/desktop/desktop_app_bar.dart'; +import '../../../widgets/desktop/desktop_dialog.dart'; +import '../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../widgets/desktop/desktop_scaffold.dart'; +import '../../../widgets/desktop/primary_button.dart'; +import '../../../widgets/desktop/secondary_button.dart'; +import '../../../widgets/icon_widgets/x_icon.dart'; +import '../../../widgets/rounded_white_container.dart'; +import '../../../widgets/stack_text_field.dart'; +import '../../../widgets/textfield_icon_button.dart'; class EditWalletTokensView extends ConsumerStatefulWidget { const EditWalletTokensView({ diff --git a/lib/pages/add_wallet_views/add_token_view/sub_widgets/add_custom_token_selector.dart b/lib/pages/add_wallet_views/add_token_view/sub_widgets/add_custom_token_selector.dart index 9be56029a..0274a99f3 100644 --- a/lib/pages/add_wallet_views/add_token_view/sub_widgets/add_custom_token_selector.dart +++ b/lib/pages/add_wallet_views/add_token_view/sub_widgets/add_custom_token_selector.dart @@ -10,11 +10,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; class AddCustomTokenSelector extends StatelessWidget { const AddCustomTokenSelector({ diff --git a/lib/pages/add_wallet_views/add_token_view/sub_widgets/add_token_list.dart b/lib/pages/add_wallet_views/add_token_view/sub_widgets/add_token_list.dart index 9580d799f..19e4e833a 100644 --- a/lib/pages/add_wallet_views/add_token_view/sub_widgets/add_token_list.dart +++ b/lib/pages/add_wallet_views/add_token_view/sub_widgets/add_token_list.dart @@ -9,9 +9,9 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/pages/add_wallet_views/add_token_view/sub_widgets/add_custom_token_selector.dart'; -import 'package:stackwallet/pages/add_wallet_views/add_token_view/sub_widgets/add_token_list_element.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; +import 'add_custom_token_selector.dart'; +import 'add_token_list_element.dart'; +import '../../../../widgets/conditional_parent.dart'; class AddTokenList extends StatelessWidget { const AddTokenList({ diff --git a/lib/pages/add_wallet_views/add_token_view/sub_widgets/add_token_list_element.dart b/lib/pages/add_wallet_views/add_token_view/sub_widgets/add_token_list_element.dart index e6d9149a7..89a818529 100644 --- a/lib/pages/add_wallet_views/add_token_view/sub_widgets/add_token_list_element.dart +++ b/lib/pages/add_wallet_views/add_token_view/sub_widgets/add_token_list_element.dart @@ -8,24 +8,23 @@ * */ -import 'dart:io'; - import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/isar/exchange_cache/currency.dart'; -import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart'; -import 'package:stackwallet/services/exchange/change_now/change_now_exchange.dart'; -import 'package:stackwallet/services/exchange/exchange_data_loading_service.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/draggable_switch_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; + +import '../../../../models/isar/exchange_cache/currency.dart'; +import '../../../../models/isar/models/ethereum/eth_contract.dart'; +import '../../../../services/exchange/change_now/change_now_exchange.dart'; +import '../../../../services/exchange/exchange_data_loading_service.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../widgets/app_icon.dart'; +import '../../../../widgets/conditional_parent.dart'; +import '../../../../widgets/custom_buttons/draggable_switch_button.dart'; +import '../../../../widgets/rounded_white_container.dart'; class AddTokenListElementData { AddTokenListElementData(this.token); @@ -35,7 +34,7 @@ class AddTokenListElementData { } class AddTokenListElement extends ConsumerStatefulWidget { - const AddTokenListElement({Key? key, required this.data}) : super(key: key); + const AddTokenListElement({super.key, required this.data}); final AddTokenListElementData data; @@ -79,14 +78,7 @@ class _AddTokenListElementState extends ConsumerState { currency.image, width: iconSize, height: iconSize, - placeholderBuilder: (_) => SvgPicture.file( - File( - ref.watch( - themeAssetsProvider.select( - (value) => value.stackIcon, - ), - ), - ), + placeholderBuilder: (_) => AppIcon( width: iconSize, height: iconSize, ), diff --git a/lib/pages/add_wallet_views/add_token_view/sub_widgets/add_token_text.dart b/lib/pages/add_wallet_views/add_token_view/sub_widgets/add_token_text.dart index 7b901aa74..d92e210f1 100644 --- a/lib/pages/add_wallet_views/add_token_view/sub_widgets/add_token_text.dart +++ b/lib/pages/add_wallet_views/add_token_view/sub_widgets/add_token_text.dart @@ -9,7 +9,7 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; +import '../../../../utilities/text_styles.dart'; class AddTokenText extends StatelessWidget { const AddTokenText({ diff --git a/lib/pages/add_wallet_views/add_wallet_view/add_wallet_view.dart b/lib/pages/add_wallet_views/add_wallet_view/add_wallet_view.dart index 34048fcbb..86c45d807 100644 --- a/lib/pages/add_wallet_views/add_wallet_view/add_wallet_view.dart +++ b/lib/pages/add_wallet_views/add_wallet_view/add_wallet_view.dart @@ -16,35 +16,37 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/db/isar/main_db.dart'; -import 'package:stackwallet/models/add_wallet_list_entity/add_wallet_list_entity.dart'; -import 'package:stackwallet/models/add_wallet_list_entity/sub_classes/coin_entity.dart'; -import 'package:stackwallet/models/add_wallet_list_entity/sub_classes/eth_token_entity.dart'; -import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart'; -import 'package:stackwallet/pages/add_wallet_views/add_token_view/add_custom_token_view.dart'; -import 'package:stackwallet/pages/add_wallet_views/add_token_view/sub_widgets/add_custom_token_selector.dart'; -import 'package:stackwallet/pages/add_wallet_views/add_wallet_view/sub_widgets/add_wallet_text.dart'; -import 'package:stackwallet/pages/add_wallet_views/add_wallet_view/sub_widgets/expanding_sub_list_item.dart'; -import 'package:stackwallet/pages/add_wallet_views/add_wallet_view/sub_widgets/next_button.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/default_eth_tokens.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/expandable.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; + +import '../../../app_config.dart'; +import '../../../db/isar/main_db.dart'; +import '../../../models/add_wallet_list_entity/add_wallet_list_entity.dart'; +import '../../../models/add_wallet_list_entity/sub_classes/coin_entity.dart'; +import '../../../models/add_wallet_list_entity/sub_classes/eth_token_entity.dart'; +import '../../../models/isar/models/ethereum/eth_contract.dart'; +import '../../../pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart'; +import '../../../providers/providers.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/default_eth_tokens.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../widgets/background.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/desktop/desktop_app_bar.dart'; +import '../../../widgets/desktop/desktop_dialog.dart'; +import '../../../widgets/desktop/desktop_scaffold.dart'; +import '../../../widgets/expandable.dart'; +import '../../../widgets/icon_widgets/x_icon.dart'; +import '../../../widgets/rounded_white_container.dart'; +import '../../../widgets/stack_text_field.dart'; +import '../../../widgets/textfield_icon_button.dart'; +import '../add_token_view/add_custom_token_view.dart'; +import '../add_token_view/sub_widgets/add_custom_token_selector.dart'; +import 'sub_widgets/add_wallet_text.dart'; +import 'sub_widgets/expanding_sub_list_item.dart'; +import 'sub_widgets/next_button.dart'; class AddWalletView extends ConsumerStatefulWidget { const AddWalletView({super.key}); @@ -61,10 +63,12 @@ class _AddWalletViewState extends ConsumerState { String _searchTerm = ""; - final List _coinsTestnet = [ - ...Coin.values.where((e) => e.isTestNet), + final _coinsTestnet = [ + ...AppConfig.coins.where((e) => e.network == CryptoCurrencyNetwork.test), + ]; + final _coins = [ + ...AppConfig.coins.where((e) => e.network == CryptoCurrencyNetwork.main), ]; - final List _coins = [...Coin.values.where((e) => !e.isTestNet)]; final List coinEntities = []; final List tokenEntities = []; @@ -81,7 +85,7 @@ class _AddWalletViewState extends ConsumerState { (e) => e.ticker.toLowerCase().contains(lowercaseTerm) || e.name.toLowerCase().contains(lowercaseTerm) || - e.coin.name.toLowerCase().contains(lowercaseTerm) || + e.cryptoCurrency.identifier.toLowerCase().contains(lowercaseTerm) || (e is EthTokenEntity && e.token.address.toLowerCase().contains(lowercaseTerm)), ); @@ -129,15 +133,13 @@ class _AddWalletViewState extends ConsumerState { _searchFocusNode = FocusNode(); // _coinsTestnet.remove(Coin.firoTestNet); if (Platform.isWindows) { - _coins.remove(Coin.monero); - _coins.remove(Coin.wownero); + _coins.removeWhere((e) => e is Monero || e is Wownero); } else if (Platform.isLinux) { - _coins.remove(Coin.wownero); + _coins.removeWhere((e) => e is Wownero); } if (Util.isDesktop && !kDebugMode) { - _coins.remove(Coin.bitcoinFrost); - _coins.remove(Coin.bitcoinFrostTestNet); + _coins.removeWhere((e) => e is BitcoinFrost); } coinEntities.addAll(_coins.map((e) => CoinEntity(e))); @@ -146,17 +148,19 @@ class _AddWalletViewState extends ConsumerState { coinEntities.addAll(_coinsTestnet.map((e) => CoinEntity(e))); } - final contracts = - MainDB.instance.getEthContracts().sortByName().findAllSync(); + if (AppConfig.coins.whereType().isNotEmpty) { + final contracts = + MainDB.instance.getEthContracts().sortByName().findAllSync(); - if (contracts.isEmpty) { - contracts.addAll(DefaultTokens.list); - MainDB.instance.putEthContracts(contracts).then( - (value) => ref.read(priceAnd24hChangeNotifierProvider).updatePrice()); + if (contracts.isEmpty) { + contracts.addAll(DefaultTokens.list); + MainDB.instance.putEthContracts(contracts).then((value) => + ref.read(priceAnd24hChangeNotifierProvider).updatePrice()); + } + + tokenEntities.addAll(contracts.map((e) => EthTokenEntity(e))); } - tokenEntities.addAll(contracts.map((e) => EthTokenEntity(e))); - WidgetsBinding.instance.addPostFrameCallback((_) { ref.refresh(addWalletSelectedEntityStateProvider); }); @@ -286,15 +290,16 @@ class _AddWalletViewState extends ConsumerState { initialState: ExpandableState.expanded, animationDurationMultiplier: 0.5, ), - ExpandingSubListItem( - title: "Tokens", - entities: filter(_searchTerm, tokenEntities), - initialState: ExpandableState.expanded, - animationDurationMultiplier: 0.5, - trailing: AddCustomTokenSelector( - addFunction: _addToken, + if (tokenEntities.isNotEmpty) + ExpandingSubListItem( + title: "Tokens", + entities: filter(_searchTerm, tokenEntities), + initialState: ExpandableState.expanded, + animationDurationMultiplier: 0.5, + trailing: AddCustomTokenSelector( + addFunction: _addToken, + ), ), - ), ], ), ), @@ -418,11 +423,12 @@ class _AddWalletViewState extends ConsumerState { entities: filter(_searchTerm, coinEntities), initialState: ExpandableState.expanded, ), - ExpandingSubListItem( - title: "Tokens", - entities: filter(_searchTerm, tokenEntities), - initialState: ExpandableState.expanded, - ), + if (tokenEntities.isNotEmpty) + ExpandingSubListItem( + title: "Tokens", + entities: filter(_searchTerm, tokenEntities), + initialState: ExpandableState.expanded, + ), ], ), ), diff --git a/lib/pages/add_wallet_views/add_wallet_view/sub_widgets/add_wallet_entity_list.dart b/lib/pages/add_wallet_views/add_wallet_view/sub_widgets/add_wallet_entity_list.dart index c1e903ae5..2be9e6e7f 100644 --- a/lib/pages/add_wallet_views/add_wallet_view/sub_widgets/add_wallet_entity_list.dart +++ b/lib/pages/add_wallet_views/add_wallet_view/sub_widgets/add_wallet_entity_list.dart @@ -9,8 +9,8 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/models/add_wallet_list_entity/add_wallet_list_entity.dart'; -import 'package:stackwallet/pages/add_wallet_views/add_wallet_view/sub_widgets/coin_select_item.dart'; +import '../../../../models/add_wallet_list_entity/add_wallet_list_entity.dart'; +import 'coin_select_item.dart'; class AddWalletEntityList extends StatelessWidget { const AddWalletEntityList({ diff --git a/lib/pages/add_wallet_views/add_wallet_view/sub_widgets/add_wallet_text.dart b/lib/pages/add_wallet_views/add_wallet_view/sub_widgets/add_wallet_text.dart index 77c5bcefb..85c17dbf2 100644 --- a/lib/pages/add_wallet_views/add_wallet_view/sub_widgets/add_wallet_text.dart +++ b/lib/pages/add_wallet_views/add_wallet_view/sub_widgets/add_wallet_text.dart @@ -9,10 +9,10 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; +import '../../../../utilities/text_styles.dart'; class AddWalletText extends StatelessWidget { - const AddWalletText({Key? key, required this.isDesktop}) : super(key: key); + const AddWalletText({super.key, required this.isDesktop}); final bool isDesktop; diff --git a/lib/pages/add_wallet_views/add_wallet_view/sub_widgets/coin_select_item.dart b/lib/pages/add_wallet_views/add_wallet_view/sub_widgets/coin_select_item.dart index 410ebc7bd..68527ccaf 100644 --- a/lib/pages/add_wallet_views/add_wallet_view/sub_widgets/coin_select_item.dart +++ b/lib/pages/add_wallet_views/add_wallet_view/sub_widgets/coin_select_item.dart @@ -14,24 +14,24 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/add_wallet_list_entity/add_wallet_list_entity.dart'; -import 'package:stackwallet/models/add_wallet_list_entity/sub_classes/eth_token_entity.dart'; -import 'package:stackwallet/models/isar/exchange_cache/currency.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/services/exchange/change_now/change_now_exchange.dart'; -import 'package:stackwallet/services/exchange/exchange_data_loading_service.dart'; -import 'package:stackwallet/themes/coin_icon_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; +import '../../../../models/add_wallet_list_entity/add_wallet_list_entity.dart'; +import '../../../../models/add_wallet_list_entity/sub_classes/eth_token_entity.dart'; +import '../../../../models/isar/exchange_cache/currency.dart'; +import '../../../../providers/providers.dart'; +import '../../../../services/exchange/change_now/change_now_exchange.dart'; +import '../../../../services/exchange/exchange_data_loading_service.dart'; +import '../../../../themes/coin_icon_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; class CoinSelectItem extends ConsumerWidget { const CoinSelectItem({ - Key? key, + super.key, required this.entity, - }) : super(key: key); + }); final AddWalletListEntity entity; @@ -90,7 +90,7 @@ class CoinSelectItem extends ConsumerWidget { ) : SvgPicture.file( File( - ref.watch(coinIconProvider(entity.coin)), + ref.watch(coinIconProvider(entity.cryptoCurrency)), ), width: 26, height: 26, diff --git a/lib/pages/add_wallet_views/add_wallet_view/sub_widgets/expanding_sub_list_item.dart b/lib/pages/add_wallet_views/add_wallet_view/sub_widgets/expanding_sub_list_item.dart index 8940dd3d9..1affe8787 100644 --- a/lib/pages/add_wallet_views/add_wallet_view/sub_widgets/expanding_sub_list_item.dart +++ b/lib/pages/add_wallet_views/add_wallet_view/sub_widgets/expanding_sub_list_item.dart @@ -10,14 +10,14 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/models/add_wallet_list_entity/add_wallet_list_entity.dart'; -import 'package:stackwallet/pages/add_wallet_views/add_wallet_view/sub_widgets/add_wallet_entity_list.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/animated_widgets/rotate_icon.dart'; -import 'package:stackwallet/widgets/expandable.dart'; +import '../../../../models/add_wallet_list_entity/add_wallet_list_entity.dart'; +import 'add_wallet_entity_list.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../widgets/animated_widgets/rotate_icon.dart'; +import '../../../../widgets/expandable.dart'; class ExpandingSubListItem extends StatefulWidget { const ExpandingSubListItem({ diff --git a/lib/pages/add_wallet_views/add_wallet_view/sub_widgets/next_button.dart b/lib/pages/add_wallet_views/add_wallet_view/sub_widgets/next_button.dart index 6756d3ca2..56b5fa258 100644 --- a/lib/pages/add_wallet_views/add_wallet_view/sub_widgets/next_button.dart +++ b/lib/pages/add_wallet_views/add_wallet_view/sub_widgets/next_button.dart @@ -10,12 +10,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/add_wallet_list_entity/sub_classes/eth_token_entity.dart'; -import 'package:stackwallet/pages/add_wallet_views/create_or_restore_wallet_view/create_or_restore_wallet_view.dart'; -import 'package:stackwallet/pages/add_wallet_views/select_wallet_for_token_view.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; +import '../../../../models/add_wallet_list_entity/sub_classes/eth_token_entity.dart'; +import '../../create_or_restore_wallet_view/create_or_restore_wallet_view.dart'; +import '../../select_wallet_for_token_view.dart'; +import '../../../../providers/providers.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/text_styles.dart'; class AddWalletNextButton extends ConsumerWidget { const AddWalletNextButton({ diff --git a/lib/pages/add_wallet_views/create_or_restore_wallet_view/create_or_restore_wallet_view.dart b/lib/pages/add_wallet_views/create_or_restore_wallet_view/create_or_restore_wallet_view.dart index ef4d55319..7c9b434c6 100644 --- a/lib/pages/add_wallet_views/create_or_restore_wallet_view/create_or_restore_wallet_view.dart +++ b/lib/pages/add_wallet_views/create_or_restore_wallet_view/create_or_restore_wallet_view.dart @@ -9,24 +9,24 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/models/add_wallet_list_entity/add_wallet_list_entity.dart'; -import 'package:stackwallet/pages/add_wallet_views/create_or_restore_wallet_view/sub_widgets/coin_image.dart'; -import 'package:stackwallet/pages/add_wallet_views/create_or_restore_wallet_view/sub_widgets/create_or_restore_wallet_subtitle.dart'; -import 'package:stackwallet/pages/add_wallet_views/create_or_restore_wallet_view/sub_widgets/create_or_restore_wallet_title.dart'; -import 'package:stackwallet/pages/add_wallet_views/create_or_restore_wallet_view/sub_widgets/create_wallet_button_group.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; +import '../../../models/add_wallet_list_entity/add_wallet_list_entity.dart'; +import 'sub_widgets/coin_image.dart'; +import 'sub_widgets/create_or_restore_wallet_subtitle.dart'; +import 'sub_widgets/create_or_restore_wallet_title.dart'; +import 'sub_widgets/create_wallet_button_group.dart'; +import '../../../pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/util.dart'; +import '../../../widgets/background.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/desktop/desktop_app_bar.dart'; +import '../../../widgets/desktop/desktop_scaffold.dart'; class CreateOrRestoreWalletView extends StatelessWidget { const CreateOrRestoreWalletView({ - Key? key, + super.key, required this.entity, - }) : super(key: key); + }); static const routeName = "/createOrRestoreWallet"; @@ -57,7 +57,7 @@ class CreateOrRestoreWalletView extends StatelessWidget { flex: 10, ),*/ CreateRestoreWalletTitle( - coin: entity.coin, + coin: entity.cryptoCurrency, isDesktop: isDesktop, ), const SizedBox( @@ -73,7 +73,7 @@ class CreateOrRestoreWalletView extends StatelessWidget { height: 32, ), CoinImage( - coin: entity.coin, + coin: entity.cryptoCurrency, width: isDesktop ? 324 : MediaQuery.of(context).size.width / 1.6, @@ -85,7 +85,7 @@ class CreateOrRestoreWalletView extends StatelessWidget { height: 32, ), CreateWalletButtonGroup( - coin: entity.coin, + coin: entity.cryptoCurrency, isDesktop: isDesktop, ), /*const Spacer( @@ -129,7 +129,7 @@ class CreateOrRestoreWalletView extends StatelessWidget { flex: 2, ), CoinImage( - coin: entity.coin, + coin: entity.cryptoCurrency, width: isDesktop ? 324 : MediaQuery.of(context).size.width / 1.6, @@ -141,7 +141,7 @@ class CreateOrRestoreWalletView extends StatelessWidget { flex: 2, ), CreateRestoreWalletTitle( - coin: entity.coin, + coin: entity.cryptoCurrency, isDesktop: isDesktop, ), const SizedBox( @@ -154,7 +154,7 @@ class CreateOrRestoreWalletView extends StatelessWidget { flex: 5, ), CreateWalletButtonGroup( - coin: entity.coin, + coin: entity.cryptoCurrency, isDesktop: isDesktop, ), ], diff --git a/lib/pages/add_wallet_views/create_or_restore_wallet_view/sub_widgets/coin_image.dart b/lib/pages/add_wallet_views/create_or_restore_wallet_view/sub_widgets/coin_image.dart index 0d13044be..ea33e9518 100644 --- a/lib/pages/add_wallet_views/create_or_restore_wallet_view/sub_widgets/coin_image.dart +++ b/lib/pages/add_wallet_views/create_or_restore_wallet_view/sub_widgets/coin_image.dart @@ -13,19 +13,19 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/themes/coin_image_provider.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/util.dart'; +import '../../../../themes/coin_image_provider.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/crypto_currency/crypto_currency.dart'; class CoinImage extends ConsumerWidget { const CoinImage({ - Key? key, + super.key, required this.coin, this.width, this.height, - }) : super(key: key); + }); - final Coin coin; + final CryptoCurrency coin; final double? width; final double? height; diff --git a/lib/pages/add_wallet_views/create_or_restore_wallet_view/sub_widgets/create_or_restore_wallet_subtitle.dart b/lib/pages/add_wallet_views/create_or_restore_wallet_view/sub_widgets/create_or_restore_wallet_subtitle.dart index d450a9f52..d66ded246 100644 --- a/lib/pages/add_wallet_views/create_or_restore_wallet_view/sub_widgets/create_or_restore_wallet_subtitle.dart +++ b/lib/pages/add_wallet_views/create_or_restore_wallet_view/sub_widgets/create_or_restore_wallet_subtitle.dart @@ -9,7 +9,7 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; +import '../../../../utilities/text_styles.dart'; class CreateRestoreWalletSubTitle extends StatelessWidget { const CreateRestoreWalletSubTitle({ diff --git a/lib/pages/add_wallet_views/create_or_restore_wallet_view/sub_widgets/create_or_restore_wallet_title.dart b/lib/pages/add_wallet_views/create_or_restore_wallet_view/sub_widgets/create_or_restore_wallet_title.dart index ae7e917c8..8e6a1ca61 100644 --- a/lib/pages/add_wallet_views/create_or_restore_wallet_view/sub_widgets/create_or_restore_wallet_title.dart +++ b/lib/pages/add_wallet_views/create_or_restore_wallet_view/sub_widgets/create_or_restore_wallet_title.dart @@ -9,17 +9,17 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../wallets/crypto_currency/crypto_currency.dart'; class CreateRestoreWalletTitle extends StatelessWidget { const CreateRestoreWalletTitle({ - Key? key, + super.key, required this.coin, required this.isDesktop, - }) : super(key: key); + }); - final Coin coin; + final CryptoCurrency coin; final bool isDesktop; @override diff --git a/lib/pages/add_wallet_views/create_or_restore_wallet_view/sub_widgets/create_wallet_button_group.dart b/lib/pages/add_wallet_views/create_or_restore_wallet_view/sub_widgets/create_wallet_button_group.dart index 36c914fd8..1dabb24d3 100644 --- a/lib/pages/add_wallet_views/create_or_restore_wallet_view/sub_widgets/create_wallet_button_group.dart +++ b/lib/pages/add_wallet_views/create_or_restore_wallet_view/sub_widgets/create_wallet_button_group.dart @@ -11,21 +11,22 @@ import 'dart:io'; import 'package:flutter/material.dart'; -import 'package:stackwallet/pages/add_wallet_views/name_your_wallet_view/name_your_wallet_view.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/enums/add_wallet_type_enum.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; +import '../../name_your_wallet_view/name_your_wallet_view.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/enums/add_wallet_type_enum.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../wallets/crypto_currency/coins/wownero.dart'; +import '../../../../wallets/crypto_currency/crypto_currency.dart'; import 'package:tuple/tuple.dart'; class CreateWalletButtonGroup extends StatelessWidget { const CreateWalletButtonGroup({ - Key? key, + super.key, required this.coin, required this.isDesktop, - }) : super(key: key); + }); - final Coin coin; + final CryptoCurrency coin; final bool isDesktop; @override @@ -34,7 +35,7 @@ class CreateWalletButtonGroup extends StatelessWidget { crossAxisAlignment: isDesktop ? CrossAxisAlignment.center : CrossAxisAlignment.stretch, children: [ - if (Platform.isAndroid || coin != Coin.wownero) + if (Platform.isAndroid || coin is! Wownero) ConstrainedBox( constraints: BoxConstraints( minHeight: isDesktop ? 70 : 0, @@ -61,7 +62,7 @@ class CreateWalletButtonGroup extends StatelessWidget { ), ), ), - if (Platform.isAndroid || coin != Coin.wownero) + if (Platform.isAndroid || coin is! Wownero) SizedBox( height: isDesktop ? 16 : 12, ), diff --git a/lib/pages/add_wallet_views/frost_ms/new/create_new_frost_ms_wallet_view.dart b/lib/pages/add_wallet_views/frost_ms/new/create_new_frost_ms_wallet_view.dart index 5ce23eaad..a97c7b785 100644 --- a/lib/pages/add_wallet_views/frost_ms/new/create_new_frost_ms_wallet_view.dart +++ b/lib/pages/add_wallet_views/frost_ms/new/create_new_frost_ms_wallet_view.dart @@ -1,25 +1,25 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/frost_route_generator.dart'; -import 'package:stackwallet/providers/frost_wallet/frost_wallet_providers.dart'; -import 'package:stackwallet/services/frost.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/frost_currency.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/dialogs/simple_mobile_dialog.dart'; -import 'package:stackwallet/widgets/frost_mascot.dart'; -import 'package:stackwallet/widgets/frost_scaffold.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../../../frost_route_generator.dart'; +import '../../../../providers/frost_wallet/frost_wallet_providers.dart'; +import '../../../../services/frost.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/crypto_currency/intermediate/frost_currency.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/conditional_parent.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/custom_buttons/blue_text_button.dart'; +import '../../../../widgets/desktop/desktop_app_bar.dart'; +import '../../../../widgets/desktop/desktop_scaffold.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/dialogs/simple_mobile_dialog.dart'; +import '../../../../widgets/frost_mascot.dart'; +import '../../../../widgets/frost_scaffold.dart'; +import '../../../../widgets/rounded_white_container.dart'; +import '../../../../widgets/stack_dialog.dart'; class CreateNewFrostMsWalletView extends ConsumerStatefulWidget { const CreateNewFrostMsWalletView({ diff --git a/lib/pages/add_wallet_views/frost_ms/new/select_new_frost_import_type_view.dart b/lib/pages/add_wallet_views/frost_ms/new/select_new_frost_import_type_view.dart index 1a7378bc6..3546dd964 100644 --- a/lib/pages/add_wallet_views/frost_ms/new/select_new_frost_import_type_view.dart +++ b/lib/pages/add_wallet_views/frost_ms/new/select_new_frost_import_type_view.dart @@ -1,22 +1,22 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/frost_route_generator.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/frost_currency.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/dialogs/simple_mobile_dialog.dart'; -import 'package:stackwallet/widgets/frost_scaffold.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../../frost_route_generator.dart'; +import '../../../../pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/crypto_currency/intermediate/frost_currency.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/conditional_parent.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/desktop/desktop_app_bar.dart'; +import '../../../../widgets/desktop/desktop_scaffold.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/dialogs/simple_mobile_dialog.dart'; +import '../../../../widgets/frost_scaffold.dart'; +import '../../../../widgets/rounded_white_container.dart'; class SelectNewFrostImportTypeView extends ConsumerStatefulWidget { const SelectNewFrostImportTypeView({ diff --git a/lib/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_1a.dart b/lib/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_1a.dart index 0f1cd84aa..cd2f0ea1d 100644 --- a/lib/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_1a.dart +++ b/lib/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_1a.dart @@ -2,21 +2,21 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:qr_flutter/qr_flutter.dart'; -import 'package:stackwallet/frost_route_generator.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart'; -import 'package:stackwallet/providers/frost_wallet/frost_wallet_providers.dart'; -import 'package:stackwallet/services/frost.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/custom_buttons/checkbox_text_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/simple_copy_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/detail_item.dart'; -import 'package:stackwallet/widgets/dialogs/simple_mobile_dialog.dart'; -import 'package:stackwallet/widgets/frost_step_user_steps.dart'; +import '../../../../../frost_route_generator.dart'; +import '../../../../wallet_view/transaction_views/transaction_details_view.dart'; +import '../../../../../providers/frost_wallet/frost_wallet_providers.dart'; +import '../../../../../services/frost.dart'; +import '../../../../../themes/stack_colors.dart'; +import '../../../../../utilities/assets.dart'; +import '../../../../../utilities/text_styles.dart'; +import '../../../../../utilities/util.dart'; +import '../../../../../widgets/custom_buttons/checkbox_text_button.dart'; +import '../../../../../widgets/custom_buttons/simple_copy_button.dart'; +import '../../../../../widgets/desktop/primary_button.dart'; +import '../../../../../widgets/desktop/secondary_button.dart'; +import '../../../../../widgets/detail_item.dart'; +import '../../../../../widgets/dialogs/simple_mobile_dialog.dart'; +import '../../../../../widgets/frost_step_user_steps.dart'; class FrostCreateStep1a extends ConsumerStatefulWidget { const FrostCreateStep1a({super.key}); diff --git a/lib/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_1b.dart b/lib/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_1b.dart index 21ed92a7d..f38d05234 100644 --- a/lib/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_1b.dart +++ b/lib/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_1b.dart @@ -1,16 +1,16 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/frost_route_generator.dart'; -import 'package:stackwallet/providers/frost_wallet/frost_wallet_providers.dart'; -import 'package:stackwallet/services/frost.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/custom_buttons/checkbox_text_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/frost_step_user_steps.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; -import 'package:stackwallet/widgets/textfields/frost_step_field.dart'; +import '../../../../../frost_route_generator.dart'; +import '../../../../../providers/frost_wallet/frost_wallet_providers.dart'; +import '../../../../../services/frost.dart'; +import '../../../../../utilities/text_styles.dart'; +import '../../../../../utilities/util.dart'; +import '../../../../../widgets/custom_buttons/checkbox_text_button.dart'; +import '../../../../../widgets/desktop/primary_button.dart'; +import '../../../../../widgets/frost_step_user_steps.dart'; +import '../../../../../widgets/rounded_white_container.dart'; +import '../../../../../widgets/stack_dialog.dart'; +import '../../../../../widgets/textfields/frost_step_field.dart'; class FrostCreateStep1b extends ConsumerStatefulWidget { const FrostCreateStep1b({super.key}); diff --git a/lib/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_2.dart b/lib/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_2.dart index f993d6783..a57148fee 100644 --- a/lib/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_2.dart +++ b/lib/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_2.dart @@ -1,20 +1,20 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/frost_route_generator.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart'; -import 'package:stackwallet/providers/frost_wallet/frost_wallet_providers.dart'; -import 'package:stackwallet/services/frost.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/custom_buttons/checkbox_text_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/frost_qr_dialog_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/simple_copy_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/detail_item.dart'; -import 'package:stackwallet/widgets/dialogs/frost/frost_error_dialog.dart'; -import 'package:stackwallet/widgets/frost_step_user_steps.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; -import 'package:stackwallet/widgets/textfields/frost_step_field.dart'; +import '../../../../../frost_route_generator.dart'; +import '../../../../wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart'; +import '../../../../../providers/frost_wallet/frost_wallet_providers.dart'; +import '../../../../../services/frost.dart'; +import '../../../../../utilities/logger.dart'; +import '../../../../../utilities/util.dart'; +import '../../../../../widgets/custom_buttons/checkbox_text_button.dart'; +import '../../../../../widgets/custom_buttons/frost_qr_dialog_button.dart'; +import '../../../../../widgets/custom_buttons/simple_copy_button.dart'; +import '../../../../../widgets/desktop/primary_button.dart'; +import '../../../../../widgets/detail_item.dart'; +import '../../../../../widgets/dialogs/frost/frost_error_dialog.dart'; +import '../../../../../widgets/frost_step_user_steps.dart'; +import '../../../../../widgets/stack_dialog.dart'; +import '../../../../../widgets/textfields/frost_step_field.dart'; class FrostCreateStep2 extends ConsumerStatefulWidget { const FrostCreateStep2({ diff --git a/lib/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_3.dart b/lib/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_3.dart index 54cabcec0..20130a2da 100644 --- a/lib/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_3.dart +++ b/lib/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_3.dart @@ -1,20 +1,21 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/frost_route_generator.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart'; -import 'package:stackwallet/providers/frost_wallet/frost_wallet_providers.dart'; -import 'package:stackwallet/services/frost.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/custom_buttons/checkbox_text_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/frost_qr_dialog_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/simple_copy_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/detail_item.dart'; -import 'package:stackwallet/widgets/dialogs/frost/frost_error_dialog.dart'; -import 'package:stackwallet/widgets/frost_step_user_steps.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; -import 'package:stackwallet/widgets/textfields/frost_step_field.dart'; + +import '../../../../../frost_route_generator.dart'; +import '../../../../../providers/frost_wallet/frost_wallet_providers.dart'; +import '../../../../../services/frost.dart'; +import '../../../../../utilities/logger.dart'; +import '../../../../../utilities/util.dart'; +import '../../../../../widgets/custom_buttons/checkbox_text_button.dart'; +import '../../../../../widgets/custom_buttons/frost_qr_dialog_button.dart'; +import '../../../../../widgets/custom_buttons/simple_copy_button.dart'; +import '../../../../../widgets/desktop/primary_button.dart'; +import '../../../../../widgets/detail_item.dart'; +import '../../../../../widgets/dialogs/frost/frost_error_dialog.dart'; +import '../../../../../widgets/frost_step_user_steps.dart'; +import '../../../../../widgets/stack_dialog.dart'; +import '../../../../../widgets/textfields/frost_step_field.dart'; +import '../../../../wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart'; class FrostCreateStep3 extends ConsumerStatefulWidget { const FrostCreateStep3({super.key}); diff --git a/lib/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_4.dart b/lib/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_4.dart index 864e905bf..b8f7aee88 100644 --- a/lib/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_4.dart +++ b/lib/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_4.dart @@ -2,14 +2,15 @@ import 'dart:typed_data'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/frost_route_generator.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart'; -import 'package:stackwallet/providers/frost_wallet/frost_wallet_providers.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/custom_buttons/simple_copy_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/detail_item.dart'; -import 'package:stackwallet/widgets/frost_step_user_steps.dart'; + +import '../../../../../frost_route_generator.dart'; +import '../../../../../providers/frost_wallet/frost_wallet_providers.dart'; +import '../../../../../utilities/util.dart'; +import '../../../../../widgets/custom_buttons/simple_copy_button.dart'; +import '../../../../../widgets/desktop/primary_button.dart'; +import '../../../../../widgets/detail_item.dart'; +import '../../../../../widgets/frost_step_user_steps.dart'; +import '../../../../wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart'; class FrostCreateStep4 extends ConsumerStatefulWidget { const FrostCreateStep4({super.key}); diff --git a/lib/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_5.dart b/lib/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_5.dart index 586a1c189..8f2e87fb0 100644 --- a/lib/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_5.dart +++ b/lib/pages/add_wallet_views/frost_ms/new/steps/frost_create_step_5.dart @@ -3,32 +3,33 @@ import 'dart:typed_data'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/frost_route_generator.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/home_view/home_view.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_home_view.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/frost_wallet/frost_wallet_providers.dart'; -import 'package:stackwallet/providers/global/node_service_provider.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/providers/global/secure_store_provider.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/services/frost.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/models/wallet_info.dart'; -import 'package:stackwallet/wallets/wallet/impl/bitcoin_frost_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet.dart'; -import 'package:stackwallet/widgets/custom_buttons/checkbox_text_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/simple_copy_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/detail_item.dart'; -import 'package:stackwallet/widgets/loading_indicator.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; + +import '../../../../../frost_route_generator.dart'; +import '../../../../../notifications/show_flush_bar.dart'; +import '../../../../../pages_desktop_specific/desktop_home_view.dart'; +import '../../../../../providers/db/main_db_provider.dart'; +import '../../../../../providers/frost_wallet/frost_wallet_providers.dart'; +import '../../../../../providers/global/node_service_provider.dart'; +import '../../../../../providers/global/prefs_provider.dart'; +import '../../../../../providers/global/secure_store_provider.dart'; +import '../../../../../providers/global/wallets_provider.dart'; +import '../../../../../services/frost.dart'; +import '../../../../../themes/stack_colors.dart'; +import '../../../../../utilities/assets.dart'; +import '../../../../../utilities/logger.dart'; +import '../../../../../utilities/text_styles.dart'; +import '../../../../../utilities/util.dart'; +import '../../../../../wallets/isar/models/wallet_info.dart'; +import '../../../../../wallets/wallet/impl/bitcoin_frost_wallet.dart'; +import '../../../../../wallets/wallet/wallet.dart'; +import '../../../../../widgets/custom_buttons/checkbox_text_button.dart'; +import '../../../../../widgets/custom_buttons/simple_copy_button.dart'; +import '../../../../../widgets/desktop/primary_button.dart'; +import '../../../../../widgets/detail_item.dart'; +import '../../../../../widgets/loading_indicator.dart'; +import '../../../../../widgets/rounded_container.dart'; +import '../../../../home_view/home_view.dart'; +import '../../../../wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart'; class FrostCreateStep5 extends ConsumerStatefulWidget { const FrostCreateStep5({super.key}); @@ -143,7 +144,7 @@ class _FrostCreateStep5State extends ConsumerState { final data = ref.read(pFrostScaffoldArgs)!; final info = WalletInfo.createNew( - coin: data.info.frostCurrency.coin, + coin: data.info.frostCurrency, name: data.info.walletName, ); diff --git a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_1a.dart b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_1a.dart index 3b20a8820..ff8f03c71 100644 --- a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_1a.dart +++ b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_1a.dart @@ -2,27 +2,28 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:qr_flutter/qr_flutter.dart'; -import 'package:stackwallet/frost_route_generator.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/frost_wallet/frost_wallet_providers.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/services/frost.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/models/frost_wallet_info.dart'; -import 'package:stackwallet/wallets/wallet/impl/bitcoin_frost_wallet.dart'; -import 'package:stackwallet/widgets/custom_buttons/checkbox_text_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/simple_copy_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/detail_item.dart'; -import 'package:stackwallet/widgets/dialogs/frost/frost_error_dialog.dart'; -import 'package:stackwallet/widgets/dialogs/simple_mobile_dialog.dart'; -import 'package:stackwallet/widgets/frost_step_user_steps.dart'; + +import '../../../../frost_route_generator.dart'; +import '../../../../providers/db/main_db_provider.dart'; +import '../../../../providers/frost_wallet/frost_wallet_providers.dart'; +import '../../../../providers/global/wallets_provider.dart'; +import '../../../../services/frost.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/logger.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/isar/models/frost_wallet_info.dart'; +import '../../../../wallets/wallet/impl/bitcoin_frost_wallet.dart'; +import '../../../../widgets/custom_buttons/checkbox_text_button.dart'; +import '../../../../widgets/custom_buttons/simple_copy_button.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/desktop/secondary_button.dart'; +import '../../../../widgets/detail_item.dart'; +import '../../../../widgets/dialogs/frost/frost_error_dialog.dart'; +import '../../../../widgets/dialogs/simple_mobile_dialog.dart'; +import '../../../../widgets/frost_step_user_steps.dart'; +import '../../../wallet_view/transaction_views/transaction_details_view.dart'; class FrostReshareStep1a extends ConsumerStatefulWidget { const FrostReshareStep1a({super.key}); diff --git a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_1b.dart b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_1b.dart index 0df4c4b09..e29d1110b 100644 --- a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_1b.dart +++ b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_1b.dart @@ -1,20 +1,21 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:frostdart/frostdart.dart'; -import 'package:stackwallet/frost_route_generator.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/frost_wallet/frost_wallet_providers.dart'; -import 'package:stackwallet/providers/global/secure_store_provider.dart'; -import 'package:stackwallet/services/frost.dart'; -import 'package:stackwallet/utilities/format.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/models/frost_wallet_info.dart'; -import 'package:stackwallet/widgets/custom_buttons/checkbox_text_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/dialogs/frost/frost_error_dialog.dart'; -import 'package:stackwallet/widgets/frost_step_user_steps.dart'; -import 'package:stackwallet/widgets/textfields/frost_step_field.dart'; + +import '../../../../frost_route_generator.dart'; +import '../../../../providers/db/main_db_provider.dart'; +import '../../../../providers/frost_wallet/frost_wallet_providers.dart'; +import '../../../../providers/global/secure_store_provider.dart'; +import '../../../../services/frost.dart'; +import '../../../../utilities/format.dart'; +import '../../../../utilities/logger.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/isar/models/frost_wallet_info.dart'; +import '../../../../widgets/custom_buttons/checkbox_text_button.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/dialogs/frost/frost_error_dialog.dart'; +import '../../../../widgets/frost_step_user_steps.dart'; +import '../../../../widgets/textfields/frost_step_field.dart'; class FrostReshareStep1b extends ConsumerStatefulWidget { const FrostReshareStep1b({ diff --git a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_1c.dart b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_1c.dart index 2bbfef1de..3514cc20d 100644 --- a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_1c.dart +++ b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_1c.dart @@ -2,18 +2,19 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/frost_route_generator.dart'; -import 'package:stackwallet/providers/frost_wallet/frost_wallet_providers.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/show_loading.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/models/wallet_info.dart'; -import 'package:stackwallet/wallets/models/incomplete_frost_wallet.dart'; -import 'package:stackwallet/widgets/custom_buttons/checkbox_text_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/frost_step_user_steps.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; -import 'package:stackwallet/widgets/textfields/frost_step_field.dart'; + +import '../../../../frost_route_generator.dart'; +import '../../../../providers/frost_wallet/frost_wallet_providers.dart'; +import '../../../../utilities/logger.dart'; +import '../../../../utilities/show_loading.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/isar/models/wallet_info.dart'; +import '../../../../wallets/models/incomplete_frost_wallet.dart'; +import '../../../../widgets/custom_buttons/checkbox_text_button.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/frost_step_user_steps.dart'; +import '../../../../widgets/stack_dialog.dart'; +import '../../../../widgets/textfields/frost_step_field.dart'; class FrostReshareStep1c extends ConsumerStatefulWidget { const FrostReshareStep1c({super.key}); @@ -49,7 +50,7 @@ class _FrostReshareStep1cState extends ConsumerState { final info = WalletInfo.createNew( name: data.info.walletName, - coin: data.info.frostCurrency.coin, + coin: data.info.frostCurrency, ); final wallet = IncompleteFrostWallet(); diff --git a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_2abd.dart b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_2abd.dart index 1a688bb03..a95d8ec47 100644 --- a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_2abd.dart +++ b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_2abd.dart @@ -2,21 +2,22 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/frost_route_generator.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/frost_wallet/frost_wallet_providers.dart'; -import 'package:stackwallet/services/frost.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/models/frost_wallet_info.dart'; -import 'package:stackwallet/widgets/custom_buttons/checkbox_text_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/frost_qr_dialog_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/simple_copy_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/detail_item.dart'; -import 'package:stackwallet/widgets/dialogs/frost/frost_error_dialog.dart'; -import 'package:stackwallet/widgets/textfields/frost_step_field.dart'; + +import '../../../../frost_route_generator.dart'; +import '../../../../providers/db/main_db_provider.dart'; +import '../../../../providers/frost_wallet/frost_wallet_providers.dart'; +import '../../../../services/frost.dart'; +import '../../../../utilities/logger.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/isar/models/frost_wallet_info.dart'; +import '../../../../widgets/custom_buttons/checkbox_text_button.dart'; +import '../../../../widgets/custom_buttons/frost_qr_dialog_button.dart'; +import '../../../../widgets/custom_buttons/simple_copy_button.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/detail_item.dart'; +import '../../../../widgets/dialogs/frost/frost_error_dialog.dart'; +import '../../../../widgets/textfields/frost_step_field.dart'; +import '../../../wallet_view/transaction_views/transaction_details_view.dart'; class FrostReshareStep2abd extends ConsumerStatefulWidget { const FrostReshareStep2abd({super.key}); diff --git a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_2c.dart b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_2c.dart index 798c503e5..b134ea5e4 100644 --- a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_2c.dart +++ b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_2c.dart @@ -2,14 +2,15 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/frost_route_generator.dart'; -import 'package:stackwallet/providers/frost_wallet/frost_wallet_providers.dart'; -import 'package:stackwallet/services/frost.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/dialogs/frost/frost_error_dialog.dart'; -import 'package:stackwallet/widgets/textfields/frost_step_field.dart'; + +import '../../../../frost_route_generator.dart'; +import '../../../../providers/frost_wallet/frost_wallet_providers.dart'; +import '../../../../services/frost.dart'; +import '../../../../utilities/logger.dart'; +import '../../../../utilities/util.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/dialogs/frost/frost_error_dialog.dart'; +import '../../../../widgets/textfields/frost_step_field.dart'; class FrostReshareStep2c extends ConsumerStatefulWidget { const FrostReshareStep2c({super.key}); diff --git a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_3abd.dart b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_3abd.dart index d49df3cc7..a899ddda1 100644 --- a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_3abd.dart +++ b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_3abd.dart @@ -2,19 +2,20 @@ import 'dart:ffi'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/frost_route_generator.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart'; -import 'package:stackwallet/providers/frost_wallet/frost_wallet_providers.dart'; -import 'package:stackwallet/services/frost.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/custom_buttons/checkbox_text_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/frost_qr_dialog_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/simple_copy_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/detail_item.dart'; -import 'package:stackwallet/widgets/dialogs/frost/frost_error_dialog.dart'; -import 'package:stackwallet/widgets/textfields/frost_step_field.dart'; + +import '../../../../frost_route_generator.dart'; +import '../../../../providers/frost_wallet/frost_wallet_providers.dart'; +import '../../../../services/frost.dart'; +import '../../../../utilities/logger.dart'; +import '../../../../utilities/util.dart'; +import '../../../../widgets/custom_buttons/checkbox_text_button.dart'; +import '../../../../widgets/custom_buttons/frost_qr_dialog_button.dart'; +import '../../../../widgets/custom_buttons/simple_copy_button.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/detail_item.dart'; +import '../../../../widgets/dialogs/frost/frost_error_dialog.dart'; +import '../../../../widgets/textfields/frost_step_field.dart'; +import '../../../wallet_view/transaction_views/transaction_details_view.dart'; class FrostReshareStep3abd extends ConsumerStatefulWidget { const FrostReshareStep3abd({super.key}); diff --git a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_3c.dart b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_3c.dart index 3bde7bc76..190abfa56 100644 --- a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_3c.dart +++ b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_3c.dart @@ -1,14 +1,15 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/frost_route_generator.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart'; -import 'package:stackwallet/providers/frost_wallet/frost_wallet_providers.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/custom_buttons/checkbox_text_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/frost_qr_dialog_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/simple_copy_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/detail_item.dart'; + +import '../../../../frost_route_generator.dart'; +import '../../../../providers/frost_wallet/frost_wallet_providers.dart'; +import '../../../../utilities/util.dart'; +import '../../../../widgets/custom_buttons/checkbox_text_button.dart'; +import '../../../../widgets/custom_buttons/frost_qr_dialog_button.dart'; +import '../../../../widgets/custom_buttons/simple_copy_button.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/detail_item.dart'; +import '../../../wallet_view/transaction_views/transaction_details_view.dart'; class FrostReshareStep3c extends ConsumerStatefulWidget { const FrostReshareStep3c({super.key}); diff --git a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_4.dart b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_4.dart index 12de74573..f476c9096 100644 --- a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_4.dart +++ b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_4.dart @@ -2,23 +2,24 @@ import 'dart:ffi'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/frost_route_generator.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart'; -import 'package:stackwallet/pages/wallet_view/wallet_view.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/desktop_wallet_view.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/frost_wallet/frost_wallet_providers.dart'; -import 'package:stackwallet/services/frost.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/models/frost_wallet_info.dart'; -import 'package:stackwallet/widgets/custom_buttons/checkbox_text_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/frost_qr_dialog_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/simple_copy_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/detail_item.dart'; -import 'package:stackwallet/widgets/dialogs/frost/frost_error_dialog.dart'; -import 'package:stackwallet/widgets/textfields/frost_step_field.dart'; + +import '../../../../frost_route_generator.dart'; +import '../../../../pages_desktop_specific/my_stack_view/wallet_view/desktop_wallet_view.dart'; +import '../../../../providers/db/main_db_provider.dart'; +import '../../../../providers/frost_wallet/frost_wallet_providers.dart'; +import '../../../../services/frost.dart'; +import '../../../../utilities/logger.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/isar/models/frost_wallet_info.dart'; +import '../../../../widgets/custom_buttons/checkbox_text_button.dart'; +import '../../../../widgets/custom_buttons/frost_qr_dialog_button.dart'; +import '../../../../widgets/custom_buttons/simple_copy_button.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/detail_item.dart'; +import '../../../../widgets/dialogs/frost/frost_error_dialog.dart'; +import '../../../../widgets/textfields/frost_step_field.dart'; +import '../../../wallet_view/transaction_views/transaction_details_view.dart'; +import '../../../wallet_view/wallet_view.dart'; // was FinishResharingView class FrostReshareStep4 extends ConsumerStatefulWidget { diff --git a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_5.dart b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_5.dart index fe0875747..834a0a638 100644 --- a/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_5.dart +++ b/lib/pages/add_wallet_views/frost_ms/reshare/frost_reshare_step_5.dart @@ -1,26 +1,27 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/frost_route_generator.dart'; -import 'package:stackwallet/pages/home_view/home_view.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart'; -import 'package:stackwallet/pages/wallet_view/wallet_view.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_home_view.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/desktop_wallet_view.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/frost_wallet/frost_wallet_providers.dart'; -import 'package:stackwallet/providers/global/node_service_provider.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/providers/global/secure_store_provider.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/show_loading.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/wallet/impl/bitcoin_frost_wallet.dart'; -import 'package:stackwallet/widgets/custom_buttons/simple_copy_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/detail_item.dart'; -import 'package:stackwallet/widgets/dialogs/frost/frost_error_dialog.dart'; + +import '../../../../frost_route_generator.dart'; +import '../../../../pages_desktop_specific/desktop_home_view.dart'; +import '../../../../pages_desktop_specific/my_stack_view/wallet_view/desktop_wallet_view.dart'; +import '../../../../providers/db/main_db_provider.dart'; +import '../../../../providers/frost_wallet/frost_wallet_providers.dart'; +import '../../../../providers/global/node_service_provider.dart'; +import '../../../../providers/global/prefs_provider.dart'; +import '../../../../providers/global/secure_store_provider.dart'; +import '../../../../providers/global/wallets_provider.dart'; +import '../../../../utilities/logger.dart'; +import '../../../../utilities/show_loading.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/wallet/impl/bitcoin_frost_wallet.dart'; +import '../../../../widgets/custom_buttons/simple_copy_button.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/detail_item.dart'; +import '../../../../widgets/dialogs/frost/frost_error_dialog.dart'; +import '../../../home_view/home_view.dart'; +import '../../../wallet_view/transaction_views/transaction_details_view.dart'; +import '../../../wallet_view/wallet_view.dart'; // was VerifyUpdatedWalletView class FrostReshareStep5 extends ConsumerStatefulWidget { diff --git a/lib/pages/add_wallet_views/frost_ms/restore/restore_frost_ms_wallet_view.dart b/lib/pages/add_wallet_views/frost_ms/restore/restore_frost_ms_wallet_view.dart index 03a7ee8bf..59a798a41 100644 --- a/lib/pages/add_wallet_views/frost_ms/restore/restore_frost_ms_wallet_view.dart +++ b/lib/pages/add_wallet_views/frost_ms/restore/restore_frost_ms_wallet_view.dart @@ -5,40 +5,41 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:frostdart/frostdart.dart' as frost; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/home_view/home_view.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_home_view.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/global/node_service_provider.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/providers/global/secure_store_provider.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/services/frost.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/show_loading.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/frost_currency.dart'; -import 'package:stackwallet/wallets/isar/models/frost_wallet_info.dart'; -import 'package:stackwallet/wallets/isar/models/wallet_info.dart'; -import 'package:stackwallet/wallets/wallet/impl/bitcoin_frost_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/frost_mascot.dart'; -import 'package:stackwallet/widgets/icon_widgets/clipboard_icon.dart'; -import 'package:stackwallet/widgets/icon_widgets/qrcode_icon.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; + +import '../../../../notifications/show_flush_bar.dart'; +import '../../../../pages_desktop_specific/desktop_home_view.dart'; +import '../../../../providers/db/main_db_provider.dart'; +import '../../../../providers/global/node_service_provider.dart'; +import '../../../../providers/global/prefs_provider.dart'; +import '../../../../providers/global/secure_store_provider.dart'; +import '../../../../providers/global/wallets_provider.dart'; +import '../../../../services/frost.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/logger.dart'; +import '../../../../utilities/show_loading.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/crypto_currency/intermediate/frost_currency.dart'; +import '../../../../wallets/isar/models/frost_wallet_info.dart'; +import '../../../../wallets/isar/models/wallet_info.dart'; +import '../../../../wallets/wallet/impl/bitcoin_frost_wallet.dart'; +import '../../../../wallets/wallet/wallet.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/conditional_parent.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/desktop/desktop_app_bar.dart'; +import '../../../../widgets/desktop/desktop_scaffold.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/frost_mascot.dart'; +import '../../../../widgets/icon_widgets/clipboard_icon.dart'; +import '../../../../widgets/icon_widgets/qrcode_icon.dart'; +import '../../../../widgets/icon_widgets/x_icon.dart'; +import '../../../../widgets/stack_dialog.dart'; +import '../../../../widgets/stack_text_field.dart'; +import '../../../../widgets/textfield_icon_button.dart'; +import '../../../home_view/home_view.dart'; class RestoreFrostMsWalletView extends ConsumerStatefulWidget { const RestoreFrostMsWalletView({ @@ -75,7 +76,7 @@ class _RestoreFrostMsWalletViewState final myName = participants[myNameIndex]; final info = WalletInfo.createNew( - coin: widget.frostCurrency.coin, + coin: widget.frostCurrency, name: widget.walletName, ); diff --git a/lib/pages/add_wallet_views/name_your_wallet_view/name_your_wallet_view.dart b/lib/pages/add_wallet_views/name_your_wallet_view/name_your_wallet_view.dart index 3cfeb6bbd..eb2797da6 100644 --- a/lib/pages/add_wallet_views/name_your_wallet_view/name_your_wallet_view.dart +++ b/lib/pages/add_wallet_views/name_your_wallet_view/name_your_wallet_view.dart @@ -13,50 +13,50 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/pages/add_wallet_views/create_or_restore_wallet_view/sub_widgets/coin_image.dart'; -import 'package:stackwallet/pages/add_wallet_views/frost_ms/new/create_new_frost_ms_wallet_view.dart'; -import 'package:stackwallet/pages/add_wallet_views/frost_ms/new/select_new_frost_import_type_view.dart'; -import 'package:stackwallet/pages/add_wallet_views/frost_ms/restore/restore_frost_ms_wallet_view.dart'; -import 'package:stackwallet/pages/add_wallet_views/new_wallet_options/new_wallet_options_view.dart'; -import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart'; -import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/restore_options_view/restore_options_view.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/ui/verify_recovery_phrase/mnemonic_word_count_state_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/add_wallet_type_enum.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/name_generator.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/bitcoin_frost.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/isar/models/wallet_info.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/dice_icon.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; import 'package:tuple/tuple.dart'; +import '../../../pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart'; +import '../../../providers/db/main_db_provider.dart'; +import '../../../providers/ui/verify_recovery_phrase/mnemonic_word_count_state_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/enums/add_wallet_type_enum.dart'; +import '../../../utilities/name_generator.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../wallets/crypto_currency/intermediate/frost_currency.dart'; +import '../../../wallets/isar/models/wallet_info.dart'; +import '../../../widgets/background.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/desktop/desktop_app_bar.dart'; +import '../../../widgets/desktop/desktop_scaffold.dart'; +import '../../../widgets/desktop/primary_button.dart'; +import '../../../widgets/desktop/secondary_button.dart'; +import '../../../widgets/icon_widgets/dice_icon.dart'; +import '../../../widgets/icon_widgets/x_icon.dart'; +import '../../../widgets/rounded_white_container.dart'; +import '../../../widgets/stack_text_field.dart'; +import '../../../widgets/textfield_icon_button.dart'; +import '../create_or_restore_wallet_view/sub_widgets/coin_image.dart'; +import '../frost_ms/new/create_new_frost_ms_wallet_view.dart'; +import '../frost_ms/new/select_new_frost_import_type_view.dart'; +import '../frost_ms/restore/restore_frost_ms_wallet_view.dart'; +import '../new_wallet_options/new_wallet_options_view.dart'; +import '../new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart'; +import '../restore_wallet_view/restore_options_view/restore_options_view.dart'; + class NameYourWalletView extends ConsumerStatefulWidget { const NameYourWalletView({ - Key? key, + super.key, required this.addWalletType, required this.coin, - }) : super(key: key); + }); static const routeName = "/nameYourWallet"; final AddWalletType addWalletType; - final Coin coin; + final CryptoCurrency coin; @override ConsumerState createState() => _NameYourWalletViewState(); @@ -64,7 +64,7 @@ class NameYourWalletView extends ConsumerStatefulWidget { class _NameYourWalletViewState extends ConsumerState { late final AddWalletType addWalletType; - late final Coin coin; + late final CryptoCurrency coin; late TextEditingController textEditingController; late FocusNode textFieldFocusNode; @@ -96,7 +96,7 @@ class _NameYourWalletViewState extends ConsumerState { if (mounted) { ref.read(mnemonicWordCountStateProvider.state).state = - Constants.possibleLengthsForCoin(coin).last; + coin.possibleMnemonicLengths.last; ref.read(pNewWalletOptions.notifier).state = null; switch (widget.addWalletType) { @@ -244,7 +244,7 @@ class _NameYourWalletViewState extends ConsumerState { height: isDesktop ? 0 : 16, ), Text( - "Name your ${coin.prettyName} ${coin.isFrost ? "multisig " : ""}wallet", + "Name your ${coin.prettyName} ${coin is FrostCurrency ? "multisig " : ""}wallet", textAlign: TextAlign.center, style: isDesktop ? STextStyles.desktopH2(context) @@ -254,7 +254,7 @@ class _NameYourWalletViewState extends ConsumerState { height: isDesktop ? 16 : 8, ), Text( - "Enter a label for your wallet (e.g. ${coin.isFrost ? "Multisig" : "Savings"})", + "Enter a label for your wallet (e.g. ${coin is FrostCurrency ? "Multisig" : "Savings"})", textAlign: TextAlign.center, style: isDesktop ? STextStyles.desktopSubtitleH2(context) @@ -383,7 +383,7 @@ class _NameYourWalletViewState extends ConsumerState { const SizedBox( height: 32, ), - if (widget.coin.isFrost) + if (widget.coin is FrostCurrency) if (widget.addWalletType == AddWalletType.Restore) PrimaryButton( label: "Next", @@ -395,15 +395,13 @@ class _NameYourWalletViewState extends ConsumerState { RestoreFrostMsWalletView.routeName, arguments: ( walletName: name, - // TODO: [prio=med] this will cause issues if frost is ever applied to other coins - frostCurrency: coin.isTestNet - ? BitcoinFrost(CryptoCurrencyNetwork.test) - : BitcoinFrost(CryptoCurrencyNetwork.main), + frostCurrency: coin, ), ); }, ), - if (widget.coin.isFrost && widget.addWalletType == AddWalletType.New) + if (widget.coin is FrostCurrency && + widget.addWalletType == AddWalletType.New) Column( children: [ PrimaryButton( @@ -416,10 +414,7 @@ class _NameYourWalletViewState extends ConsumerState { CreateNewFrostMsWalletView.routeName, arguments: ( walletName: name, - // TODO: [prio=med] this will cause issues if frost is ever applied to other coins - frostCurrency: coin.isTestNet - ? BitcoinFrost(CryptoCurrencyNetwork.test) - : BitcoinFrost(CryptoCurrencyNetwork.main), + frostCurrency: coin, ), ); }, @@ -437,10 +432,7 @@ class _NameYourWalletViewState extends ConsumerState { SelectNewFrostImportTypeView.routeName, arguments: ( walletName: name, - // TODO: [prio=med] this will cause issues if frost is ever applied to other coins - frostCurrency: coin.isTestNet - ? BitcoinFrost(CryptoCurrencyNetwork.test) - : BitcoinFrost(CryptoCurrencyNetwork.main), + frostCurrency: coin, ), ); }, @@ -480,7 +472,7 @@ class _NameYourWalletViewState extends ConsumerState { // ), ], ), - if (!widget.coin.isFrost) + if (widget.coin is! FrostCurrency) ConstrainedBox( constraints: BoxConstraints( minWidth: isDesktop ? 480 : 0, diff --git a/lib/pages/add_wallet_views/new_wallet_options/new_wallet_options_view.dart b/lib/pages/add_wallet_views/new_wallet_options/new_wallet_options_view.dart index f6d3075b2..1008fd5df 100644 --- a/lib/pages/add_wallet_views/new_wallet_options/new_wallet_options_view.dart +++ b/lib/pages/add_wallet_views/new_wallet_options/new_wallet_options_view.dart @@ -2,31 +2,33 @@ import 'package:dropdown_button2/dropdown_button2.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/pages/add_wallet_views/create_or_restore_wallet_view/sub_widgets/coin_image.dart'; -import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart'; -import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/restore_options_view/sub_widgets/mobile_mnemonic_length_selector.dart'; -import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/sub_widgets/mnemonic_word_count_select_sheet.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart'; -import 'package:stackwallet/providers/ui/verify_recovery_phrase/mnemonic_word_count_state_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; import 'package:tuple/tuple.dart'; +import '../../../pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart'; +import '../../../providers/ui/verify_recovery_phrase/mnemonic_word_count_state_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../widgets/background.dart'; +import '../../../widgets/conditional_parent.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/desktop/desktop_app_bar.dart'; +import '../../../widgets/desktop/desktop_scaffold.dart'; +import '../../../widgets/desktop/primary_button.dart'; +import '../../../widgets/rounded_white_container.dart'; +import '../../../widgets/stack_text_field.dart'; +import '../create_or_restore_wallet_view/sub_widgets/coin_image.dart'; +import '../new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart'; +import '../restore_wallet_view/restore_options_view/sub_widgets/mobile_mnemonic_length_selector.dart'; +import '../restore_wallet_view/sub_widgets/mnemonic_word_count_select_sheet.dart'; + final pNewWalletOptions = StateProvider<({String mnemonicPassphrase, int mnemonicWordsCount})?>( - (ref) => null); + (ref) => null, +); enum NewWalletOptions { Default, @@ -35,15 +37,15 @@ enum NewWalletOptions { class NewWalletOptionsView extends ConsumerStatefulWidget { const NewWalletOptionsView({ - Key? key, + super.key, required this.walletName, required this.coin, - }) : super(key: key); + }); static const routeName = "/newWalletOptionsView"; final String walletName; - final Coin coin; + final CryptoCurrency coin; @override ConsumerState createState() => @@ -74,7 +76,7 @@ class _NewWalletOptionsViewState extends ConsumerState { @override Widget build(BuildContext context) { - final lengths = Constants.possibleLengthsForCoin(widget.coin).toList(); + final lengths = widget.coin.possibleMnemonicLengths; return ConditionalParent( condition: Util.isDesktop, builder: (child) => DesktopScaffold( @@ -339,7 +341,8 @@ class _NewWalletOptionsViewState extends ConsumerState { ), GestureDetector( key: const Key( - "mnemonicPassphraseFieldShowPasswordButtonKey"), + "mnemonicPassphraseFieldShowPasswordButtonKey", + ), onTap: () async { setState(() { hidePassword = !hidePassword; diff --git a/lib/pages/add_wallet_views/new_wallet_recovery_phrase_view/new_wallet_recovery_phrase_view.dart b/lib/pages/add_wallet_views/new_wallet_recovery_phrase_view/new_wallet_recovery_phrase_view.dart index bb855d757..510abe67d 100644 --- a/lib/pages/add_wallet_views/new_wallet_recovery_phrase_view/new_wallet_recovery_phrase_view.dart +++ b/lib/pages/add_wallet_views/new_wallet_recovery_phrase_view/new_wallet_recovery_phrase_view.dart @@ -15,28 +15,29 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_view/sub_widgets/mnemonic_table.dart'; -import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart'; -import 'package:stackwallet/pages/add_wallet_views/verify_recovery_phrase_view/verify_recovery_phrase_view.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_home_view.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart'; -import 'package:stackwallet/providers/global/secure_store_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/clipboard_interface.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/wallets/wallet/wallet.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; import 'package:tuple/tuple.dart'; +import '../../../notifications/show_flush_bar.dart'; +import '../../../pages_desktop_specific/desktop_home_view.dart'; +import '../../../pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart'; +import '../../../providers/global/secure_store_provider.dart'; +import '../../../providers/providers.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/clipboard_interface.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../wallets/wallet/wallet.dart'; +import '../../../widgets/conditional_parent.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/desktop/desktop_app_bar.dart'; +import '../../../widgets/desktop/desktop_scaffold.dart'; +import '../new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart'; +import '../verify_recovery_phrase_view/verify_recovery_phrase_view.dart'; +import 'sub_widgets/mnemonic_table.dart'; + class NewWalletRecoveryPhraseView extends ConsumerStatefulWidget { const NewWalletRecoveryPhraseView({ Key? key, diff --git a/lib/pages/add_wallet_views/new_wallet_recovery_phrase_view/sub_widgets/mnemonic_table.dart b/lib/pages/add_wallet_views/new_wallet_recovery_phrase_view/sub_widgets/mnemonic_table.dart index 837954235..4f26fcffa 100644 --- a/lib/pages/add_wallet_views/new_wallet_recovery_phrase_view/sub_widgets/mnemonic_table.dart +++ b/lib/pages/add_wallet_views/new_wallet_recovery_phrase_view/sub_widgets/mnemonic_table.dart @@ -9,7 +9,7 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_view/sub_widgets/mnemonic_table_item.dart'; +import 'mnemonic_table_item.dart'; class MnemonicTable extends StatelessWidget { const MnemonicTable({ diff --git a/lib/pages/add_wallet_views/new_wallet_recovery_phrase_view/sub_widgets/mnemonic_table_item.dart b/lib/pages/add_wallet_views/new_wallet_recovery_phrase_view/sub_widgets/mnemonic_table_item.dart index 728948c5b..c39c496d7 100644 --- a/lib/pages/add_wallet_views/new_wallet_recovery_phrase_view/sub_widgets/mnemonic_table_item.dart +++ b/lib/pages/add_wallet_views/new_wallet_recovery_phrase_view/sub_widgets/mnemonic_table_item.dart @@ -9,9 +9,9 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../widgets/rounded_white_container.dart'; class MnemonicTableItem extends StatelessWidget { const MnemonicTableItem({ diff --git a/lib/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart b/lib/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart index 8e3f8750f..2c1a248e7 100644 --- a/lib/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart +++ b/lib/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart @@ -15,44 +15,42 @@ import 'package:bip39/bip39.dart' as bip39; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/pages/add_wallet_views/new_wallet_options/new_wallet_options_view.dart'; -import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_view/new_wallet_recovery_phrase_view.dart'; -import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/recovery_phrase_explanation_dialog.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/global/secure_store_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/services/transaction_notification_tracker.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/default_nodes.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/tezos.dart'; -import 'package:stackwallet/wallets/isar/models/wallet_info.dart'; -import 'package:stackwallet/wallets/wallet/wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/mnemonic_interface.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/loading_indicator.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; import 'package:tuple/tuple.dart'; +import '../../../pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart'; +import '../../../providers/db/main_db_provider.dart'; +import '../../../providers/global/secure_store_provider.dart'; +import '../../../providers/providers.dart'; +import '../../../services/transaction_notification_tracker.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/logger.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../wallets/isar/models/wallet_info.dart'; +import '../../../wallets/wallet/wallet.dart'; +import '../../../wallets/wallet/wallet_mixin_interfaces/mnemonic_interface.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/desktop/desktop_app_bar.dart'; +import '../../../widgets/desktop/desktop_scaffold.dart'; +import '../../../widgets/loading_indicator.dart'; +import '../../../widgets/rounded_container.dart'; +import '../../../widgets/rounded_white_container.dart'; +import '../new_wallet_options/new_wallet_options_view.dart'; +import '../new_wallet_recovery_phrase_view/new_wallet_recovery_phrase_view.dart'; +import 'recovery_phrase_explanation_dialog.dart'; + class NewWalletRecoveryPhraseWarningView extends ConsumerStatefulWidget { const NewWalletRecoveryPhraseWarningView({ - Key? key, + super.key, required this.coin, required this.walletName, - }) : super(key: key); + }); static const routeName = "/newWalletRecoveryPhraseWarning"; - final Coin coin; + final CryptoCurrency coin; final String walletName; @override @@ -62,7 +60,7 @@ class NewWalletRecoveryPhraseWarningView extends ConsumerStatefulWidget { class _NewWalletRecoveryPhraseWarningViewState extends ConsumerState { - late final Coin coin; + late final CryptoCurrency coin; late final String walletName; late final bool isDesktop; @@ -79,8 +77,8 @@ class _NewWalletRecoveryPhraseWarningViewState debugPrint("BUILD: $runtimeType"); final options = ref.read(pNewWalletOptions.state).state; - final seedCount = options?.mnemonicWordsCount ?? - Constants.defaultSeedPhraseLengthFor(coin: coin); + final seedCount = + options?.mnemonicWordsCount ?? coin.defaultSeedPhraseLength; return MasterScaffold( isDesktop: isDesktop, @@ -118,7 +116,7 @@ class _NewWalletRecoveryPhraseWarningViewState ); }, ), - ) + ), ], ), body: SingleChildScrollView( @@ -180,7 +178,8 @@ class _NewWalletRecoveryPhraseWarningViewState "access to your wallet.", style: isDesktop ? STextStyles.desktopTextMediumRegular( - context) + context, + ) : STextStyles.subtitle(context).copyWith( fontSize: 12, ), @@ -359,13 +358,14 @@ class _NewWalletRecoveryPhraseWarningViewState child: Text( "Do not show them to anyone.", style: STextStyles.navBarTitle( - context), + context, + ), ), ), ], ), ], - ) + ), ], ), ), @@ -410,12 +410,14 @@ class _NewWalletRecoveryPhraseWarningViewState MaterialTapTargetSize.shrinkWrap, value: ref .watch( - checkBoxStateProvider.state) + checkBoxStateProvider.state, + ) .state, onChanged: (newValue) { ref .read( - checkBoxStateProvider.state) + checkBoxStateProvider.state, + ) .state = newValue!; }, ), @@ -428,7 +430,8 @@ class _NewWalletRecoveryPhraseWarningViewState "I understand that Stack Wallet does not keep and cannot restore my recovery phrase, and If I lose my recovery phrase, I will not be able to access my funds.", style: isDesktop ? STextStyles.desktopTextMedium( - context) + context, + ) : STextStyles.baseXS(context) .copyWith( height: 1.3, @@ -452,21 +455,23 @@ class _NewWalletRecoveryPhraseWarningViewState .state ? () async { try { - unawaited(showDialog( - context: context, - barrierDismissible: false, - useSafeArea: true, - builder: (ctx) { - return const Center( - child: LoadingIndicator( - width: 50, - height: 50, - ), - ); - }, - )); + unawaited( + showDialog( + context: context, + barrierDismissible: false, + useSafeArea: true, + builder: (ctx) { + return const Center( + child: LoadingIndicator( + width: 50, + height: 50, + ), + ); + }, + ), + ); String? otherDataJsonString; - if (widget.coin == Coin.tezos) { + if (widget.coin is Tezos) { otherDataJsonString = jsonEncode({ WalletInfoKeys .tezosDerivationPath: @@ -474,7 +479,7 @@ class _NewWalletRecoveryPhraseWarningViewState .value, }); // }//todo: probably not needed (broken anyways) - // else if (widget.coin == Coin.epicCash) { + // else if (widget.coin is Epiccash) { // final int secondsSinceEpoch = // DateTime.now().millisecondsSinceEpoch ~/ 1000; // const int epicCashFirstBlock = 1565370278; @@ -504,8 +509,7 @@ class _NewWalletRecoveryPhraseWarningViewState // ), // }, // ); - } else if (widget.coin == - Coin.firo) { + } else if (widget.coin is Firo) { otherDataJsonString = jsonEncode( { WalletInfoKeys @@ -524,15 +528,18 @@ class _NewWalletRecoveryPhraseWarningViewState var node = ref .read( - nodeServiceChangeNotifierProvider) - .getPrimaryNodeFor(coin: coin); + nodeServiceChangeNotifierProvider, + ) + .getPrimaryNodeFor( + currency: coin, + ); if (node == null) { - node = - DefaultNodes.getNodeFor(coin); + node = coin.defaultNode; await ref .read( - nodeServiceChangeNotifierProvider) + nodeServiceChangeNotifierProvider, + ) .setPrimaryNodeFor( coin: coin, node: node, @@ -549,34 +556,35 @@ class _NewWalletRecoveryPhraseWarningViewState String? mnemonic; String? privateKey; - wordCount = Constants - .defaultSeedPhraseLengthFor( - coin: info.coin, - ); + wordCount = info + .coin.defaultSeedPhraseLength; - if (coin == Coin.monero || - coin == Coin.wownero) { + if (coin is Monero || + coin is Wownero) { // currently a special case due to the // xmr/wow libraries handling their // own mnemonic generation } else if (wordCount > 0) { if (ref - .read(pNewWalletOptions - .state) + .read( + pNewWalletOptions.state, + ) .state != null) { if (coin .hasMnemonicPassphraseSupport) { mnemonicPassphrase = ref - .read(pNewWalletOptions - .state) + .read( + pNewWalletOptions.state, + ) .state! .mnemonicPassphrase; } else {} wordCount = ref .read( - pNewWalletOptions.state) + pNewWalletOptions.state, + ) .state! .mnemonicWordsCount; } else { @@ -587,7 +595,8 @@ class _NewWalletRecoveryPhraseWarningViewState 24 < wordCount || wordCount % 3 != 0) { throw Exception( - "Invalid word count"); + "Invalid word count", + ); } final strength = @@ -604,9 +613,11 @@ class _NewWalletRecoveryPhraseWarningViewState secureStorageInterface: ref.read(secureStoreProvider), nodeService: ref.read( - nodeServiceChangeNotifierProvider), + nodeServiceChangeNotifierProvider, + ), prefs: ref.read( - prefsChangeNotifierProvider), + prefsChangeNotifierProvider, + ), mnemonicPassphrase: mnemonicPassphrase, mnemonic: mnemonic, @@ -616,31 +627,36 @@ class _NewWalletRecoveryPhraseWarningViewState await wallet.init(); // pop progress dialog - if (mounted) { + if (context.mounted) { Navigator.pop(context); } // set checkbox back to unchecked to annoy users to agree again :P ref .read( - checkBoxStateProvider.state) + checkBoxStateProvider.state, + ) .state = false; - if (mounted) { - unawaited(Navigator.of(context) - .pushNamed( - NewWalletRecoveryPhraseView - .routeName, - arguments: Tuple2( - wallet, - await (wallet - as MnemonicInterface) - .getMnemonicAsWords(), + if (context.mounted) { + final nav = Navigator.of(context); + unawaited( + nav.pushNamed( + NewWalletRecoveryPhraseView + .routeName, + arguments: Tuple2( + wallet, + await (wallet + as MnemonicInterface) + .getMnemonicAsWords(), + ), ), - )); + ); } } catch (e, s) { - Logging.instance.log("$e\n$s", - level: LogLevel.Fatal); + Logging.instance.log( + "$e\n$s", + level: LogLevel.Fatal, + ); // TODO: handle gracefully // any network/socket exception here will break new wallet creation rethrow; @@ -656,18 +672,22 @@ class _NewWalletRecoveryPhraseWarningViewState : Theme.of(context) .extension()! .getPrimaryDisabledButtonStyle( - context), + context, + ), child: Text( "View recovery phrase", style: isDesktop ? ref .read( - checkBoxStateProvider.state) + checkBoxStateProvider.state, + ) .state ? STextStyles.desktopButtonEnabled( - context) + context, + ) : STextStyles.desktopButtonDisabled( - context) + context, + ) : STextStyles.button(context), ), ), diff --git a/lib/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/recovery_phrase_explanation_dialog.dart b/lib/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/recovery_phrase_explanation_dialog.dart index 2e6edcc3c..bb9626c67 100644 --- a/lib/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/recovery_phrase_explanation_dialog.dart +++ b/lib/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/recovery_phrase_explanation_dialog.dart @@ -9,9 +9,9 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../widgets/desktop/secondary_button.dart'; +import '../../../widgets/stack_dialog.dart'; class RecoveryPhraseExplanationDialog extends StatelessWidget { const RecoveryPhraseExplanationDialog({Key? key}) : super(key: key); diff --git a/lib/pages/add_wallet_views/restore_wallet_view/confirm_recovery_dialog.dart b/lib/pages/add_wallet_views/restore_wallet_view/confirm_recovery_dialog.dart index dcdbc7dc8..70a519fad 100644 --- a/lib/pages/add_wallet_views/restore_wallet_view/confirm_recovery_dialog.dart +++ b/lib/pages/add_wallet_views/restore_wallet_view/confirm_recovery_dialog.dart @@ -10,15 +10,15 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../widgets/desktop/desktop_dialog.dart'; +import '../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../widgets/desktop/primary_button.dart'; +import '../../../widgets/desktop/secondary_button.dart'; +import '../../../widgets/stack_dialog.dart'; class ConfirmRecoveryDialog extends StatelessWidget { const ConfirmRecoveryDialog({Key? key, required this.onConfirm}) diff --git a/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/restore_options_view.dart b/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/restore_options_view.dart index 3c7bdfd9e..424596f1d 100644 --- a/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/restore_options_view.dart +++ b/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/restore_options_view.dart @@ -12,30 +12,33 @@ import 'package:dropdown_button2/dropdown_button2.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/pages/add_wallet_views/create_or_restore_wallet_view/sub_widgets/coin_image.dart'; -import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/restore_options_view/sub_widgets/mobile_mnemonic_length_selector.dart'; -import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/restore_options_view/sub_widgets/restore_from_date_picker.dart'; -import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/restore_options_view/sub_widgets/restore_options_next_button.dart'; -import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/restore_options_view/sub_widgets/restore_options_platform_layout.dart'; -import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/restore_wallet_view.dart'; -import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/sub_widgets/mnemonic_word_count_select_sheet.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart'; -import 'package:stackwallet/providers/ui/verify_recovery_phrase/mnemonic_word_count_state_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/format.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/date_picker/date_picker.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/expandable.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; +import '../../create_or_restore_wallet_view/sub_widgets/coin_image.dart'; +import 'sub_widgets/mobile_mnemonic_length_selector.dart'; +import 'sub_widgets/restore_from_date_picker.dart'; +import 'sub_widgets/restore_options_next_button.dart'; +import 'sub_widgets/restore_options_platform_layout.dart'; +import '../restore_wallet_view.dart'; +import '../sub_widgets/mnemonic_word_count_select_sheet.dart'; +import '../../../../pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart'; +import '../../../../providers/ui/verify_recovery_phrase/mnemonic_word_count_state_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/format.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/crypto_currency/coins/epiccash.dart'; +import '../../../../wallets/crypto_currency/coins/monero.dart'; +import '../../../../wallets/crypto_currency/coins/wownero.dart'; +import '../../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../../widgets/conditional_parent.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/date_picker/date_picker.dart'; +import '../../../../widgets/desktop/desktop_app_bar.dart'; +import '../../../../widgets/desktop/desktop_scaffold.dart'; +import '../../../../widgets/expandable.dart'; +import '../../../../widgets/rounded_white_container.dart'; +import '../../../../widgets/stack_text_field.dart'; import 'package:tuple/tuple.dart'; class RestoreOptionsView extends ConsumerStatefulWidget { @@ -48,7 +51,7 @@ class RestoreOptionsView extends ConsumerStatefulWidget { static const routeName = "/restoreOptions"; final String walletName; - final Coin coin; + final CryptoCurrency coin; @override ConsumerState createState() => _RestoreOptionsViewState(); @@ -56,7 +59,7 @@ class RestoreOptionsView extends ConsumerStatefulWidget { class _RestoreOptionsViewState extends ConsumerState { late final String walletName; - late final Coin coin; + late final CryptoCurrency coin; late final bool isDesktop; late TextEditingController _dateController; @@ -69,8 +72,7 @@ class _RestoreOptionsViewState extends ConsumerState { bool hidePassword = true; bool _expandedAdavnced = false; - bool get supportsMnemonicPassphrase => - !(coin == Coin.monero || coin == Coin.wownero || coin == Coin.epicCash); + bool get supportsMnemonicPassphrase => coin.hasMnemonicPassphraseSupport; @override void initState() { @@ -153,7 +155,7 @@ class _RestoreOptionsViewState extends ConsumerState { ), builder: (_) { return MnemonicWordCountSelectSheet( - lengthOptions: Constants.possibleLengthsForCoin(coin), + lengthOptions: coin.possibleMnemonicLengths, ); }, ); @@ -161,9 +163,9 @@ class _RestoreOptionsViewState extends ConsumerState { @override Widget build(BuildContext context) { - debugPrint("BUILD: $runtimeType with ${coin.name} $walletName"); + debugPrint("BUILD: $runtimeType with ${coin.identifier} $walletName"); - final lengths = Constants.possibleLengthsForCoin(coin).toList(); + final lengths = coin.possibleMnemonicLengths; return MasterScaffold( isDesktop: isDesktop, @@ -217,9 +219,9 @@ class _RestoreOptionsViewState extends ConsumerState { SizedBox( height: isDesktop ? 40 : 24, ), - if (coin == Coin.monero || - coin == Coin.epicCash || - (coin == Coin.wownero && + if (coin is Monero || + coin is Epiccash || + (coin is Wownero && ref.watch(mnemonicWordCountStateProvider.state).state == 25)) Text( @@ -233,17 +235,17 @@ class _RestoreOptionsViewState extends ConsumerState { : STextStyles.smallMed12(context), textAlign: TextAlign.left, ), - if (coin == Coin.monero || - coin == Coin.epicCash || - (coin == Coin.wownero && + if (coin is Monero || + coin is Epiccash || + (coin is Wownero && ref.watch(mnemonicWordCountStateProvider.state).state == 25)) SizedBox( height: isDesktop ? 16 : 8, ), - if (coin == Coin.monero || - coin == Coin.epicCash || - (coin == Coin.wownero && + if (coin is Monero || + coin is Epiccash || + (coin is Wownero && ref.watch(mnemonicWordCountStateProvider.state).state == 25)) if (!isDesktop) @@ -251,9 +253,9 @@ class _RestoreOptionsViewState extends ConsumerState { onTap: chooseDate, controller: _dateController, ), - if (coin == Coin.monero || - coin == Coin.epicCash || - (coin == Coin.wownero && + if (coin is Monero || + coin is Epiccash || + (coin is Wownero && ref.watch(mnemonicWordCountStateProvider.state).state == 25)) if (isDesktop) @@ -262,17 +264,17 @@ class _RestoreOptionsViewState extends ConsumerState { onTap: chooseDesktopDate, controller: _dateController, ), - if (coin == Coin.monero || - coin == Coin.epicCash || - (coin == Coin.wownero && + if (coin is Monero || + coin is Epiccash || + (coin is Wownero && ref.watch(mnemonicWordCountStateProvider.state).state == 25)) const SizedBox( height: 8, ), - if (coin == Coin.monero || - coin == Coin.epicCash || - (coin == Coin.wownero && + if (coin is Monero || + coin is Epiccash || + (coin is Wownero && ref.watch(mnemonicWordCountStateProvider.state).state == 25)) RoundedWhiteContainer( @@ -291,9 +293,9 @@ class _RestoreOptionsViewState extends ConsumerState { ), ), ), - if (coin == Coin.monero || - coin == Coin.epicCash || - (coin == Coin.wownero && + if (coin is Monero || + coin is Epiccash || + (coin is Wownero && ref.watch(mnemonicWordCountStateProvider.state).state == 25)) SizedBox( diff --git a/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/sub_widgets/mobile_mnemonic_length_selector.dart b/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/sub_widgets/mobile_mnemonic_length_selector.dart index 25526283f..7299ca476 100644 --- a/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/sub_widgets/mobile_mnemonic_length_selector.dart +++ b/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/sub_widgets/mobile_mnemonic_length_selector.dart @@ -11,12 +11,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/providers/ui/verify_recovery_phrase/mnemonic_word_count_state_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; +import '../../../../../providers/ui/verify_recovery_phrase/mnemonic_word_count_state_provider.dart'; +import '../../../../../themes/stack_colors.dart'; +import '../../../../../utilities/assets.dart'; +import '../../../../../utilities/constants.dart'; +import '../../../../../utilities/text_styles.dart'; +import '../../../../../utilities/util.dart'; class MobileMnemonicLengthSelector extends ConsumerWidget { const MobileMnemonicLengthSelector({ diff --git a/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/sub_widgets/restore_from_date_picker.dart b/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/sub_widgets/restore_from_date_picker.dart index bf09b8b60..58869bdf4 100644 --- a/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/sub_widgets/restore_from_date_picker.dart +++ b/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/sub_widgets/restore_from_date_picker.dart @@ -10,10 +10,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; +import '../../../../../themes/stack_colors.dart'; +import '../../../../../utilities/assets.dart'; +import '../../../../../utilities/text_styles.dart'; +import '../../../../../utilities/util.dart'; class RestoreFromDatePicker extends StatefulWidget { const RestoreFromDatePicker({ diff --git a/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/sub_widgets/restore_options_next_button.dart b/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/sub_widgets/restore_options_next_button.dart index 0302e74ec..8ac5ed213 100644 --- a/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/sub_widgets/restore_options_next_button.dart +++ b/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/sub_widgets/restore_options_next_button.dart @@ -9,8 +9,8 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; +import '../../../../../themes/stack_colors.dart'; +import '../../../../../utilities/text_styles.dart'; class RestoreOptionsNextButton extends StatelessWidget { const RestoreOptionsNextButton({ diff --git a/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/sub_widgets/restore_options_platform_layout.dart b/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/sub_widgets/restore_options_platform_layout.dart index fa95e4291..9f606eb66 100644 --- a/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/sub_widgets/restore_options_platform_layout.dart +++ b/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/sub_widgets/restore_options_platform_layout.dart @@ -9,7 +9,7 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; +import '../../../../../themes/stack_colors.dart'; class RestoreOptionsPlatformLayout extends StatelessWidget { const RestoreOptionsPlatformLayout({ diff --git a/lib/pages/add_wallet_views/restore_wallet_view/restore_wallet_view.dart b/lib/pages/add_wallet_views/restore_wallet_view/restore_wallet_view.dart index 14174b22b..41eddad6d 100644 --- a/lib/pages/add_wallet_views/restore_wallet_view/restore_wallet_view.dart +++ b/lib/pages/add_wallet_views/restore_wallet_view/restore_wallet_view.dart @@ -18,58 +18,62 @@ import 'package:bip39/bip39.dart' as bip39; import 'package:bip39/src/wordlists/english.dart' as bip39wordlist; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:flutter_libmonero/monero/monero.dart'; -import 'package:flutter_libmonero/wownero/wownero.dart'; +import 'package:flutter_libmonero/monero/monero.dart' as libxmr; +import 'package:flutter_libmonero/wownero/wownero.dart' as libwow; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/add_wallet_views/add_token_view/edit_wallet_tokens_view.dart'; -import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/confirm_recovery_dialog.dart'; -import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/sub_widgets/restore_failed_dialog.dart'; -import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/sub_widgets/restore_succeeded_dialog.dart'; -import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/sub_widgets/restoring_dialog.dart'; -import 'package:stackwallet/pages/add_wallet_views/select_wallet_for_token_view.dart'; -import 'package:stackwallet/pages/add_wallet_views/verify_recovery_phrase_view/verify_recovery_phrase_view.dart'; -import 'package:stackwallet/pages/home_view/home_view.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_home_view.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/global/secure_store_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/services/transaction_notification_tracker.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/address_utils.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/barcode_scanner_interface.dart'; -import 'package:stackwallet/utilities/clipboard_interface.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/custom_text_selection_controls.dart'; -import 'package:stackwallet/utilities/default_nodes.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/form_input_status_enum.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/models/wallet_info.dart'; -import 'package:stackwallet/wallets/wallet/impl/epiccash_wallet.dart'; -import 'package:stackwallet/wallets/wallet/impl/monero_wallet.dart'; -import 'package:stackwallet/wallets/wallet/impl/wownero_wallet.dart'; -import 'package:stackwallet/wallets/wallet/supporting/epiccash_wallet_info_extension.dart'; -import 'package:stackwallet/wallets/wallet/wallet.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/clipboard_icon.dart'; -import 'package:stackwallet/widgets/icon_widgets/qrcode_icon.dart'; -import 'package:stackwallet/widgets/table_view/table_view.dart'; -import 'package:stackwallet/widgets/table_view/table_view_cell.dart'; -import 'package:stackwallet/widgets/table_view/table_view_row.dart'; +import '../../../notifications/show_flush_bar.dart'; +import '../add_token_view/edit_wallet_tokens_view.dart'; +import 'confirm_recovery_dialog.dart'; +import 'sub_widgets/restore_failed_dialog.dart'; +import 'sub_widgets/restore_succeeded_dialog.dart'; +import 'sub_widgets/restoring_dialog.dart'; +import '../select_wallet_for_token_view.dart'; +import '../verify_recovery_phrase_view/verify_recovery_phrase_view.dart'; +import '../../home_view/home_view.dart'; +import '../../../pages_desktop_specific/desktop_home_view.dart'; +import '../../../pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart'; +import '../../../providers/db/main_db_provider.dart'; +import '../../../providers/global/secure_store_provider.dart'; +import '../../../providers/providers.dart'; +import '../../../services/transaction_notification_tracker.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/address_utils.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/barcode_scanner_interface.dart'; +import '../../../utilities/clipboard_interface.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/custom_text_selection_controls.dart'; +import '../../../utilities/enums/form_input_status_enum.dart'; +import '../../../utilities/logger.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../wallets/crypto_currency/coins/epiccash.dart'; +import '../../../wallets/crypto_currency/coins/ethereum.dart'; +import '../../../wallets/crypto_currency/coins/firo.dart'; +import '../../../wallets/crypto_currency/coins/monero.dart'; +import '../../../wallets/crypto_currency/coins/wownero.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../wallets/isar/models/wallet_info.dart'; +import '../../../wallets/wallet/impl/epiccash_wallet.dart'; +import '../../../wallets/wallet/impl/monero_wallet.dart'; +import '../../../wallets/wallet/impl/wownero_wallet.dart'; +import '../../../wallets/wallet/supporting/epiccash_wallet_info_extension.dart'; +import '../../../wallets/wallet/wallet.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/desktop/desktop_app_bar.dart'; +import '../../../widgets/desktop/desktop_scaffold.dart'; +import '../../../widgets/desktop/primary_button.dart'; +import '../../../widgets/icon_widgets/clipboard_icon.dart'; +import '../../../widgets/icon_widgets/qrcode_icon.dart'; +import '../../../widgets/table_view/table_view.dart'; +import '../../../widgets/table_view/table_view_cell.dart'; +import '../../../widgets/table_view/table_view_row.dart'; import 'package:wakelock/wakelock.dart'; class RestoreWalletView extends ConsumerStatefulWidget { const RestoreWalletView({ - Key? key, + super.key, required this.walletName, required this.coin, required this.seedWordsLength, @@ -77,12 +81,12 @@ class RestoreWalletView extends ConsumerStatefulWidget { required this.restoreFromDate, this.barcodeScanner = const BarcodeScannerWrapper(), this.clipboard = const ClipboardWrapper(), - }) : super(key: key); + }); static const routeName = "/restoreWallet"; final String walletName; - final Coin coin; + final CryptoCurrency coin; final String mnemonicPassphrase; final int seedWordsLength; final DateTime restoreFromDate; @@ -166,7 +170,7 @@ class _RestoreWalletViewState extends ConsumerState { @override void dispose() { - for (var element in _controllers) { + for (final element in _controllers) { element.dispose(); } @@ -176,13 +180,15 @@ class _RestoreWalletViewState extends ConsumerState { // TODO: check for wownero wordlist? bool _isValidMnemonicWord(String word) { // TODO: get the actual language - if (widget.coin == Coin.monero) { - var moneroWordList = monero.getMoneroWordList("English"); + if (widget.coin is Monero) { + final moneroWordList = libxmr.monero.getMoneroWordList("English"); return moneroWordList.contains(word); } - if (widget.coin == Coin.wownero) { - var wowneroWordList = wownero.getWowneroWordList("English", - seedWordsLength: widget.seedWordsLength); + if (widget.coin is Wownero) { + final wowneroWordList = libwow.wownero.getWowneroWordList( + "English", + seedWordsLength: widget.seedWordsLength, + ); return wowneroWordList.contains(word); } return _wordListHashSet.contains(word); @@ -201,7 +207,7 @@ class _RestoreWalletViewState extends ConsumerState { Future attemptRestore() async { if (_formKey.currentState!.validate()) { String mnemonic = ""; - for (var element in _controllers) { + for (final element in _controllers) { mnemonic += " ${element.text.trim().toLowerCase()}"; } mnemonic = mnemonic.trim(); @@ -209,24 +215,25 @@ class _RestoreWalletViewState extends ConsumerState { int height = 0; String? otherDataJsonString; - if (widget.coin == Coin.monero) { - height = monero.getHeigthByDate(date: widget.restoreFromDate); - } else if (widget.coin == Coin.wownero) { - height = wownero.getHeightByDate(date: widget.restoreFromDate); + if (widget.coin is Monero) { + height = libxmr.monero.getHeigthByDate(date: widget.restoreFromDate); + } else if (widget.coin is Wownero) { + height = libwow.wownero.getHeightByDate(date: widget.restoreFromDate); } // todo: wait until this implemented - // else if (widget.coin == Coin.wownero) { + // else if (widget.coin is Wownero) { // height = wownero.getHeightByDate(date: widget.restoreFromDate); // } // TODO: make more robust estimate of date maybe using https://explorer.epic.tech/api-index - if (widget.coin == Coin.epicCash) { - int secondsSinceEpoch = + if (widget.coin is Epiccash) { + final int secondsSinceEpoch = widget.restoreFromDate.millisecondsSinceEpoch ~/ 1000; const int epicCashFirstBlock = 1565370278; const double overestimateSecondsPerBlock = 61; - int chosenSeconds = secondsSinceEpoch - epicCashFirstBlock; - int approximateHeight = chosenSeconds ~/ overestimateSecondsPerBlock; + final int chosenSeconds = secondsSinceEpoch - epicCashFirstBlock; + final int approximateHeight = + chosenSeconds ~/ overestimateSecondsPerBlock; //todo: check if print needed // debugPrint( // "approximate height: $approximateHeight chosen_seconds: $chosenSeconds"); @@ -250,7 +257,7 @@ class _RestoreWalletViewState extends ConsumerState { ), }, ); - } else if (widget.coin == Coin.firo) { + } else if (widget.coin is Firo) { otherDataJsonString = jsonEncode( { WalletInfoKeys.lelantusCoinIsarRescanRequired: false, @@ -260,12 +267,14 @@ class _RestoreWalletViewState extends ConsumerState { // TODO: do actual check to make sure it is a valid mnemonic for monero if (bip39.validateMnemonic(mnemonic) == false && - !(widget.coin == Coin.monero || widget.coin == Coin.wownero)) { - unawaited(showFloatingFlushBar( - type: FlushBarType.warning, - message: "Invalid seed phrase!", - context: context, - )); + !(widget.coin is Monero || widget.coin is Wownero)) { + unawaited( + showFloatingFlushBar( + type: FlushBarType.warning, + message: "Invalid seed phrase!", + context: context, + ), + ); } else { if (!Platform.isLinux) await Wakelock.enable(); @@ -278,30 +287,35 @@ class _RestoreWalletViewState extends ConsumerState { bool isRestoring = true; // show restoring in progress - unawaited(showDialog( - context: context, - useSafeArea: false, - barrierDismissible: false, - builder: (context) { - return RestoringDialog( - onCancel: () async { - isRestoring = false; - await ref.read(pWallets).deleteWallet( - info, - ref.read(secureStoreProvider), - ); + if (mounted) { + unawaited( + showDialog( + context: context, + useSafeArea: false, + barrierDismissible: false, + builder: (context) { + return RestoringDialog( + onCancel: () async { + isRestoring = false; + + await ref.read(pWallets).deleteWallet( + info, + ref.read(secureStoreProvider), + ); + }, + ); }, - ); - }, - )); + ), + ); + } var node = ref .read(nodeServiceChangeNotifierProvider) - .getPrimaryNodeFor(coin: widget.coin); + .getPrimaryNodeFor(currency: widget.coin); if (node == null) { - node = DefaultNodes.getNodeFor(widget.coin); + node = widget.coin.defaultNode; await ref.read(nodeServiceChangeNotifierProvider).setPrimaryNodeFor( coin: widget.coin, node: node, @@ -324,15 +338,15 @@ class _RestoreWalletViewState extends ConsumerState { // TODO: extract interface with isRestore param switch (wallet.runtimeType) { - case EpiccashWallet: + case const (EpiccashWallet): await (wallet as EpiccashWallet).init(isRestore: true); break; - case MoneroWallet: + case const (MoneroWallet): await (wallet as MoneroWallet).init(isRestore: true); break; - case WowneroWallet: + case const (WowneroWallet): await (wallet as WowneroWallet).init(isRestore: true); break; @@ -355,12 +369,11 @@ class _RestoreWalletViewState extends ConsumerState { if (isCreateSpecialEthWallet) { ref.read(createSpecialEthWalletRoutingFlag.notifier).state = false; - ref - .read(newEthWalletTriggerTempUntilHiveCompletelyDeleted.state) - .state = + ref.read(newEthWalletTriggerTempUntilHiveCompletelyDeleted.state).state = !ref - .read(newEthWalletTriggerTempUntilHiveCompletelyDeleted - .state) + .read( + newEthWalletTriggerTempUntilHiveCompletelyDeleted.state, + ) .state; } @@ -385,7 +398,7 @@ class _RestoreWalletViewState extends ConsumerState { (route) => false, ), ); - if (info.coin == Coin.ethereum) { + if (info.coin is Ethereum) { unawaited( Navigator.of(context).pushNamed( EditWalletTokensView.routeName, @@ -451,7 +464,9 @@ class _RestoreWalletViewState extends ConsumerState { } InputDecoration _getInputDecorationFor( - FormInputStatus status, String prefix) { + FormInputStatus status, + String prefix, + ) { Color color; Color prefixColor; Color borderColor; @@ -656,9 +671,10 @@ class _RestoreWalletViewState extends ConsumerState { if (FocusScope.of(context).hasFocus) { FocusScope.of(context).unfocus(); await Future.delayed( - const Duration(milliseconds: 50)); + const Duration(milliseconds: 50), + ); } - if (mounted) { + if (context.mounted) { Navigator.of(context).pop(); } }, @@ -788,8 +804,9 @@ class _RestoreWalletViewState extends ConsumerState { "Paste", style: STextStyles .desktopButtonSmallSecondaryEnabled( - context), - ) + context, + ), + ), ], ), ), @@ -836,12 +853,14 @@ class _RestoreWalletViewState extends ConsumerState { textCapitalization: TextCapitalization.none, key: Key( - "restoreMnemonicFormField_$i"), + "restoreMnemonicFormField_$i", + ), decoration: _getInputDecorationFor( - _inputStatuses[ - i * 4 + j - 1], - "${i * 4 + j}"), + _inputStatuses[ + i * 4 + j - 1], + "${i * 4 + j}", + ), autovalidateMode: AutovalidateMode .onUserInteraction, @@ -861,9 +880,10 @@ class _RestoreWalletViewState extends ConsumerState { formInputStatus = FormInputStatus.empty; } else if (_isValidMnemonicWord( - value - .trim() - .toLowerCase())) { + value + .trim() + .toLowerCase(), + )) { formInputStatus = FormInputStatus.valid; } else { @@ -921,17 +941,18 @@ class _RestoreWalletViewState extends ConsumerState { TextAlign.left, style: STextStyles.label( - context) - .copyWith( + context, + ).copyWith( color: Theme.of( - context) + context, + ) .extension< StackColors>()! .textError, ), ), ), - ) + ), ], ), ), @@ -945,7 +966,7 @@ class _RestoreWalletViewState extends ConsumerState { for (int i = rows * cols; i < _seedWordCount - remainder; i++) ...[ - TableViewCell( + const TableViewCell( flex: 1, child: Column( // ... (existing code for input field) @@ -965,11 +986,13 @@ class _RestoreWalletViewState extends ConsumerState { textCapitalization: TextCapitalization.none, key: Key( - "restoreMnemonicFormField_$i"), + "restoreMnemonicFormField_$i", + ), decoration: _getInputDecorationFor( - _inputStatuses[i], - "${i + 1}"), + _inputStatuses[i], + "${i + 1}", + ), autovalidateMode: AutovalidateMode .onUserInteraction, @@ -984,9 +1007,10 @@ class _RestoreWalletViewState extends ConsumerState { formInputStatus = FormInputStatus.empty; } else if (_isValidMnemonicWord( - value - .trim() - .toLowerCase())) { + value + .trim() + .toLowerCase(), + )) { formInputStatus = FormInputStatus.valid; } else { @@ -1029,17 +1053,18 @@ class _RestoreWalletViewState extends ConsumerState { TextAlign.left, style: STextStyles.label( - context) - .copyWith( + context, + ).copyWith( color: Theme.of( - context) + context, + ) .extension< StackColors>()! .textError, ), ), ), - ) + ), ], ), ), @@ -1095,7 +1120,9 @@ class _RestoreWalletViewState extends ConsumerState { textCapitalization: TextCapitalization.none, key: Key("restoreMnemonicFormField_$i"), decoration: _getInputDecorationFor( - _inputStatuses[i - 1], "$i"), + _inputStatuses[i - 1], + "$i", + ), autovalidateMode: AutovalidateMode.onUserInteraction, selectionControls: @@ -1107,7 +1134,8 @@ class _RestoreWalletViewState extends ConsumerState { if (value.isEmpty) { formInputStatus = FormInputStatus.empty; } else if (_isValidMnemonicWord( - value.trim().toLowerCase())) { + value.trim().toLowerCase(), + )) { formInputStatus = FormInputStatus.valid; } else { formInputStatus = @@ -1155,7 +1183,7 @@ class _RestoreWalletViewState extends ConsumerState { ), ), ), - ) + ), ], ), Padding( diff --git a/lib/pages/add_wallet_views/restore_wallet_view/sub_widgets/mnemonic_word_count_select_sheet.dart b/lib/pages/add_wallet_views/restore_wallet_view/sub_widgets/mnemonic_word_count_select_sheet.dart index 010f195bc..c1533bad4 100644 --- a/lib/pages/add_wallet_views/restore_wallet_view/sub_widgets/mnemonic_word_count_select_sheet.dart +++ b/lib/pages/add_wallet_views/restore_wallet_view/sub_widgets/mnemonic_word_count_select_sheet.dart @@ -10,10 +10,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/providers/ui/verify_recovery_phrase/mnemonic_word_count_state_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; +import '../../../../providers/ui/verify_recovery_phrase/mnemonic_word_count_state_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/text_styles.dart'; class MnemonicWordCountSelectSheet extends ConsumerWidget { const MnemonicWordCountSelectSheet({ diff --git a/lib/pages/add_wallet_views/restore_wallet_view/sub_widgets/restore_failed_dialog.dart b/lib/pages/add_wallet_views/restore_wallet_view/sub_widgets/restore_failed_dialog.dart index 02f4e714b..fc45b372a 100644 --- a/lib/pages/add_wallet_views/restore_wallet_view/sub_widgets/restore_failed_dialog.dart +++ b/lib/pages/add_wallet_views/restore_wallet_view/sub_widgets/restore_failed_dialog.dart @@ -10,13 +10,13 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/providers/global/secure_store_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../../../providers/global/secure_store_provider.dart'; +import '../../../../providers/providers.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/logger.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../../widgets/stack_dialog.dart'; class RestoreFailedDialog extends ConsumerStatefulWidget { const RestoreFailedDialog({ diff --git a/lib/pages/add_wallet_views/restore_wallet_view/sub_widgets/restore_succeeded_dialog.dart b/lib/pages/add_wallet_views/restore_wallet_view/sub_widgets/restore_succeeded_dialog.dart index 0b816cbe9..4c5364e44 100644 --- a/lib/pages/add_wallet_views/restore_wallet_view/sub_widgets/restore_succeeded_dialog.dart +++ b/lib/pages/add_wallet_views/restore_wallet_view/sub_widgets/restore_succeeded_dialog.dart @@ -10,14 +10,14 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/stack_dialog.dart'; class RestoreSucceededDialog extends StatelessWidget { const RestoreSucceededDialog({Key? key}) : super(key: key); diff --git a/lib/pages/add_wallet_views/restore_wallet_view/sub_widgets/restoring_dialog.dart b/lib/pages/add_wallet_views/restore_wallet_view/sub_widgets/restoring_dialog.dart index 2be19e08a..29a4dcf40 100644 --- a/lib/pages/add_wallet_views/restore_wallet_view/sub_widgets/restoring_dialog.dart +++ b/lib/pages/add_wallet_views/restore_wallet_view/sub_widgets/restoring_dialog.dart @@ -9,14 +9,14 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/animated_widgets/rotating_arrows.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../widgets/animated_widgets/rotating_arrows.dart'; +import '../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../../widgets/desktop/secondary_button.dart'; +import '../../../../widgets/stack_dialog.dart'; class RestoringDialog extends StatefulWidget { const RestoringDialog({ diff --git a/lib/pages/add_wallet_views/select_wallet_for_token_view.dart b/lib/pages/add_wallet_views/select_wallet_for_token_view.dart index d0f466a0c..648f6a0de 100644 --- a/lib/pages/add_wallet_views/select_wallet_for_token_view.dart +++ b/lib/pages/add_wallet_views/select_wallet_for_token_view.dart @@ -10,26 +10,26 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/add_wallet_list_entity/sub_classes/coin_entity.dart'; -import 'package:stackwallet/models/add_wallet_list_entity/sub_classes/eth_token_entity.dart'; -import 'package:stackwallet/pages/add_wallet_views/add_token_view/edit_wallet_tokens_view.dart'; -import 'package:stackwallet/pages/add_wallet_views/create_or_restore_wallet_view/create_or_restore_wallet_view.dart'; -import 'package:stackwallet/pages/add_wallet_views/verify_recovery_phrase_view/verify_recovery_phrase_view.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/all_wallets_info_provider.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/eth_wallet_radio.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/wallet_info_row/wallet_info_row.dart'; +import '../../models/add_wallet_list_entity/sub_classes/coin_entity.dart'; +import '../../models/add_wallet_list_entity/sub_classes/eth_token_entity.dart'; +import 'add_token_view/edit_wallet_tokens_view.dart'; +import 'create_or_restore_wallet_view/create_or_restore_wallet_view.dart'; +import 'verify_recovery_phrase_view/verify_recovery_phrase_view.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import '../../wallets/isar/providers/all_wallets_info_provider.dart'; +import '../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../widgets/background.dart'; +import '../../widgets/conditional_parent.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/desktop/desktop_app_bar.dart'; +import '../../widgets/desktop/desktop_scaffold.dart'; +import '../../widgets/desktop/primary_button.dart'; +import '../../widgets/eth_wallet_radio.dart'; +import '../../widgets/rounded_container.dart'; +import '../../widgets/rounded_white_container.dart'; +import '../../widgets/wallet_info_row/wallet_info_row.dart'; import 'package:tuple/tuple.dart'; final newEthWalletTriggerTempUntilHiveCompletelyDeleted = @@ -70,7 +70,7 @@ class _SelectWalletForTokenViewState ref.read(createSpecialEthWalletRoutingFlag.notifier).state = true; Navigator.of(context).pushNamed( CreateOrRestoreWalletView.routeName, - arguments: CoinEntity(widget.entity.coin), + arguments: CoinEntity(widget.entity.cryptoCurrency), ); } @@ -78,7 +78,7 @@ class _SelectWalletForTokenViewState Widget build(BuildContext context) { final ethWalletInfos = ref .watch(pAllWalletsInfo) - .where((e) => e.coin == widget.entity.coin) + .where((e) => e.coin == widget.entity.cryptoCurrency) .toList(); final _hasEthWallets = ethWalletInfos.isNotEmpty; diff --git a/lib/pages/add_wallet_views/verify_recovery_phrase_view/sub_widgets/word_table.dart b/lib/pages/add_wallet_views/verify_recovery_phrase_view/sub_widgets/word_table.dart index 260522cc0..8674f6b07 100644 --- a/lib/pages/add_wallet_views/verify_recovery_phrase_view/sub_widgets/word_table.dart +++ b/lib/pages/add_wallet_views/verify_recovery_phrase_view/sub_widgets/word_table.dart @@ -10,7 +10,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/pages/add_wallet_views/verify_recovery_phrase_view/sub_widgets/word_table_item.dart'; +import 'word_table_item.dart'; class WordTable extends ConsumerWidget { const WordTable({ diff --git a/lib/pages/add_wallet_views/verify_recovery_phrase_view/sub_widgets/word_table_item.dart b/lib/pages/add_wallet_views/verify_recovery_phrase_view/sub_widgets/word_table_item.dart index 2990aaae4..64135fe95 100644 --- a/lib/pages/add_wallet_views/verify_recovery_phrase_view/sub_widgets/word_table_item.dart +++ b/lib/pages/add_wallet_views/verify_recovery_phrase_view/sub_widgets/word_table_item.dart @@ -10,10 +10,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; +import '../../../../providers/providers.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/text_styles.dart'; class WordTableItem extends ConsumerWidget { const WordTableItem({ diff --git a/lib/pages/add_wallet_views/verify_recovery_phrase_view/verify_mnemonic_passphrase_dialog.dart b/lib/pages/add_wallet_views/verify_recovery_phrase_view/verify_mnemonic_passphrase_dialog.dart index bae25a7e1..77b650c81 100644 --- a/lib/pages/add_wallet_views/verify_recovery_phrase_view/verify_mnemonic_passphrase_dialog.dart +++ b/lib/pages/add_wallet_views/verify_recovery_phrase_view/verify_mnemonic_passphrase_dialog.dart @@ -1,20 +1,20 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/add_wallet_views/new_wallet_options/new_wallet_options_view.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; +import '../../../notifications/show_flush_bar.dart'; +import '../new_wallet_options/new_wallet_options_view.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../widgets/conditional_parent.dart'; +import '../../../widgets/desktop/desktop_dialog.dart'; +import '../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../widgets/desktop/primary_button.dart'; +import '../../../widgets/desktop/secondary_button.dart'; +import '../../../widgets/stack_dialog.dart'; +import '../../../widgets/stack_text_field.dart'; class VerifyMnemonicPassphraseDialog extends ConsumerStatefulWidget { const VerifyMnemonicPassphraseDialog({super.key}); diff --git a/lib/pages/add_wallet_views/verify_recovery_phrase_view/verify_recovery_phrase_view.dart b/lib/pages/add_wallet_views/verify_recovery_phrase_view/verify_recovery_phrase_view.dart index 90163db3f..9155690cb 100644 --- a/lib/pages/add_wallet_views/verify_recovery_phrase_view/verify_recovery_phrase_view.dart +++ b/lib/pages/add_wallet_views/verify_recovery_phrase_view/verify_recovery_phrase_view.dart @@ -14,40 +14,40 @@ import 'dart:math'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/add_wallet_views/add_token_view/edit_wallet_tokens_view.dart'; -import 'package:stackwallet/pages/add_wallet_views/new_wallet_options/new_wallet_options_view.dart'; -import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_view/new_wallet_recovery_phrase_view.dart'; -import 'package:stackwallet/pages/add_wallet_views/select_wallet_for_token_view.dart'; -import 'package:stackwallet/pages/add_wallet_views/verify_recovery_phrase_view/sub_widgets/word_table.dart'; -import 'package:stackwallet/pages/add_wallet_views/verify_recovery_phrase_view/verify_mnemonic_passphrase_dialog.dart'; -import 'package:stackwallet/pages/home_view/home_view.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_home_view.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/global/secure_store_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/wallets/wallet/wallet.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; +import '../../../notifications/show_flush_bar.dart'; +import '../add_token_view/edit_wallet_tokens_view.dart'; +import '../new_wallet_options/new_wallet_options_view.dart'; +import '../new_wallet_recovery_phrase_view/new_wallet_recovery_phrase_view.dart'; +import '../select_wallet_for_token_view.dart'; +import 'sub_widgets/word_table.dart'; +import 'verify_mnemonic_passphrase_dialog.dart'; +import '../../home_view/home_view.dart'; +import '../../../pages_desktop_specific/desktop_home_view.dart'; +import '../../../pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart'; +import '../../../providers/db/main_db_provider.dart'; +import '../../../providers/global/secure_store_provider.dart'; +import '../../../providers/providers.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../wallets/crypto_currency/coins/ethereum.dart'; +import '../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../wallets/wallet/wallet.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/desktop/desktop_app_bar.dart'; +import '../../../widgets/desktop/desktop_scaffold.dart'; import 'package:tuple/tuple.dart'; final createSpecialEthWalletRoutingFlag = StateProvider((ref) => false); class VerifyRecoveryPhraseView extends ConsumerStatefulWidget { const VerifyRecoveryPhraseView({ - Key? key, + super.key, required this.wallet, required this.mnemonic, - }) : super(key: key); + }); static const routeName = "/verifyRecoveryPhrase"; @@ -154,7 +154,7 @@ class _VerifyRecoveryPhraseViewState DesktopHomeView.routeName, ), ); - if (widget.wallet.info.coin == Coin.ethereum) { + if (widget.wallet.info.coin is Ethereum) { unawaited( Navigator.of(context).pushNamed( EditWalletTokensView.routeName, @@ -177,7 +177,7 @@ class _VerifyRecoveryPhraseViewState (route) => false, ), ); - if (widget.wallet.info.coin == Coin.ethereum) { + if (widget.wallet.info.coin is Ethereum) { unawaited( Navigator.of(context).pushNamed( EditWalletTokensView.routeName, @@ -198,12 +198,14 @@ class _VerifyRecoveryPhraseViewState ); } } else { - unawaited(showFloatingFlushBar( - type: FlushBarType.warning, - message: "Incorrect. Please try again.", - iconAsset: Assets.svg.circleX, - context: context, - )); + unawaited( + showFloatingFlushBar( + type: FlushBarType.warning, + message: "Incorrect. Please try again.", + iconAsset: Assets.svg.circleX, + context: context, + ), + ); final int next = Random().nextInt(_mnemonic.length); ref @@ -221,7 +223,10 @@ class _VerifyRecoveryPhraseViewState } Tuple2, String> randomize( - List mnemonic, int chosenIndex, int wordsToShow) { + List mnemonic, + int chosenIndex, + int wordsToShow, + ) { final List remaining = []; final String chosenWord = mnemonic[chosenIndex]; @@ -354,7 +359,8 @@ class _VerifyRecoveryPhraseViewState .extension()! .textFieldDefaultBG, borderRadius: BorderRadius.circular( - Constants.size.circularBorderRadius), + Constants.size.circularBorderRadius, + ), ), child: Padding( padding: const EdgeInsets.symmetric( @@ -391,11 +397,13 @@ class _VerifyRecoveryPhraseViewState builder: (_, ref, __) { final selectedWord = ref .watch( - verifyMnemonicSelectedWordStateProvider.state) + verifyMnemonicSelectedWordStateProvider.state, + ) .state; final correctWord = ref .watch( - verifyMnemonicCorrectWordStateProvider.state) + verifyMnemonicCorrectWordStateProvider.state, + ) .state; return ConstrainedBox( @@ -406,7 +414,8 @@ class _VerifyRecoveryPhraseViewState onPressed: selectedWord.isNotEmpty ? () async { await _continue( - correctWord == selectedWord); + correctWord == selectedWord, + ); } : null, style: selectedWord.isNotEmpty @@ -421,9 +430,11 @@ class _VerifyRecoveryPhraseViewState "Verify", style: selectedWord.isNotEmpty ? STextStyles.desktopButtonEnabled( - context) + context, + ) : STextStyles.desktopButtonDisabled( - context), + context, + ), ) : Text( "Continue", diff --git a/lib/pages/address_book_views/address_book_view.dart b/lib/pages/address_book_views/address_book_view.dart index 40e71434e..b9ed9560f 100644 --- a/lib/pages/address_book_views/address_book_view.dart +++ b/lib/pages/address_book_views/address_book_view.dart @@ -11,29 +11,31 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/models/isar/models/contact_entry.dart'; -import 'package:stackwallet/pages/address_book_views/subviews/add_address_book_entry_view.dart'; -import 'package:stackwallet/pages/address_book_views/subviews/address_book_filter_view.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/global/address_book_service_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/providers/ui/address_book_providers/address_book_filter_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart'; -import 'package:stackwallet/widgets/address_book_card.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../app_config.dart'; +import '../../models/isar/models/blockchain_data/address.dart'; +import '../../models/isar/models/contact_entry.dart'; +import 'subviews/add_address_book_entry_view.dart'; +import 'subviews/address_book_filter_view.dart'; +import '../../providers/db/main_db_provider.dart'; +import '../../providers/global/address_book_service_provider.dart'; +import '../../providers/providers.dart'; +import '../../providers/ui/address_book_providers/address_book_filter_provider.dart'; +import '../../app_config.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import '../../wallets/crypto_currency/crypto_currency.dart'; +import '../../wallets/wallet/wallet_mixin_interfaces/spark_interface.dart'; +import '../../widgets/address_book_card.dart'; +import '../../widgets/background.dart'; +import '../../widgets/conditional_parent.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/icon_widgets/x_icon.dart'; +import '../../widgets/rounded_white_container.dart'; +import '../../widgets/stack_text_field.dart'; +import '../../widgets/textfield_icon_button.dart'; class AddressBookView extends ConsumerStatefulWidget { const AddressBookView({ @@ -44,7 +46,7 @@ class AddressBookView extends ConsumerStatefulWidget { static const String routeName = "/addressBook"; - final Coin? coin; + final CryptoCurrency? coin; final String? filterTerm; @override @@ -64,8 +66,10 @@ class _AddressBookViewState extends ConsumerState { ref.refresh(addressBookFilterProvider); if (widget.coin == null) { - final List coins = Coin.values.toList(); - coins.remove(Coin.firoTestNet); + final coins = [...AppConfig.coins]; + coins.removeWhere( + (e) => e is Firo && e.network == CryptoCurrencyNetwork.test, + ); final bool showTestNet = ref.read(prefsChangeNotifierProvider).showTestNetCoins; @@ -73,9 +77,10 @@ class _AddressBookViewState extends ConsumerState { if (showTestNet) { ref.read(addressBookFilterProvider).addAll(coins, false); } else { - ref - .read(addressBookFilterProvider) - .addAll(coins.where((e) => !e.isTestNet), false); + ref.read(addressBookFilterProvider).addAll( + coins.where((e) => e.network != CryptoCurrencyNetwork.test), + false, + ); } } else { ref.read(addressBookFilterProvider).add(widget.coin!, false); @@ -100,14 +105,14 @@ class _AddressBookViewState extends ConsumerState { addresses.add( ContactAddressEntry() - ..coinName = wallet.info.coin.name + ..coinName = wallet.info.coin.identifier ..address = addressString ..label = "Current Receiving" ..other = wallet.info.name, ); } final self = ContactEntry( - name: "My Stack", + name: "My ${AppConfig.prefix}", addresses: addresses, isFavorite: true, customId: "default", diff --git a/lib/pages/address_book_views/subviews/add_address_book_entry_view.dart b/lib/pages/address_book_views/subviews/add_address_book_entry_view.dart index 20237f174..bf1ee6b39 100644 --- a/lib/pages/address_book_views/subviews/add_address_book_entry_view.dart +++ b/lib/pages/address_book_views/subviews/add_address_book_entry_view.dart @@ -12,31 +12,31 @@ import 'package:emojis/emoji.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/models/isar/models/contact_entry.dart'; -import 'package:stackwallet/pages/address_book_views/subviews/new_contact_address_entry_form.dart'; -import 'package:stackwallet/providers/global/address_book_service_provider.dart'; -import 'package:stackwallet/providers/ui/address_book_providers/address_entry_data_provider.dart'; -import 'package:stackwallet/providers/ui/address_book_providers/contact_name_is_not_empty_state_provider.dart'; -import 'package:stackwallet/providers/ui/address_book_providers/valid_contact_state_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/barcode_scanner_interface.dart'; -import 'package:stackwallet/utilities/clipboard_interface.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/emoji_select_sheet.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../../models/isar/models/contact_entry.dart'; +import 'new_contact_address_entry_form.dart'; +import '../../../providers/global/address_book_service_provider.dart'; +import '../../../providers/ui/address_book_providers/address_entry_data_provider.dart'; +import '../../../providers/ui/address_book_providers/contact_name_is_not_empty_state_provider.dart'; +import '../../../providers/ui/address_book_providers/valid_contact_state_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/barcode_scanner_interface.dart'; +import '../../../utilities/clipboard_interface.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../widgets/background.dart'; +import '../../../widgets/conditional_parent.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/custom_buttons/blue_text_button.dart'; +import '../../../widgets/desktop/desktop_dialog.dart'; +import '../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../widgets/desktop/primary_button.dart'; +import '../../../widgets/desktop/secondary_button.dart'; +import '../../../widgets/emoji_select_sheet.dart'; +import '../../../widgets/icon_widgets/x_icon.dart'; +import '../../../widgets/stack_text_field.dart'; +import '../../../widgets/textfield_icon_button.dart'; import 'package:uuid/uuid.dart'; class AddAddressBookEntryView extends ConsumerStatefulWidget { diff --git a/lib/pages/address_book_views/subviews/add_new_contact_address_view.dart b/lib/pages/address_book_views/subviews/add_new_contact_address_view.dart index 11d6566a2..4a2c3c497 100644 --- a/lib/pages/address_book_views/subviews/add_new_contact_address_view.dart +++ b/lib/pages/address_book_views/subviews/add_new_contact_address_view.dart @@ -11,22 +11,22 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/models/isar/models/contact_entry.dart'; -import 'package:stackwallet/pages/address_book_views/subviews/new_contact_address_entry_form.dart'; -import 'package:stackwallet/providers/global/address_book_service_provider.dart'; -import 'package:stackwallet/providers/ui/address_book_providers/address_entry_data_provider.dart'; -import 'package:stackwallet/providers/ui/address_book_providers/valid_contact_state_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/barcode_scanner_interface.dart'; -import 'package:stackwallet/utilities/clipboard_interface.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; +import '../../../models/isar/models/contact_entry.dart'; +import 'new_contact_address_entry_form.dart'; +import '../../../providers/global/address_book_service_provider.dart'; +import '../../../providers/ui/address_book_providers/address_entry_data_provider.dart'; +import '../../../providers/ui/address_book_providers/valid_contact_state_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/barcode_scanner_interface.dart'; +import '../../../utilities/clipboard_interface.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../widgets/background.dart'; +import '../../../widgets/conditional_parent.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/desktop/primary_button.dart'; +import '../../../widgets/desktop/secondary_button.dart'; class AddNewContactAddressView extends ConsumerStatefulWidget { const AddNewContactAddressView({ diff --git a/lib/pages/address_book_views/subviews/address_book_filter_view.dart b/lib/pages/address_book_views/subviews/address_book_filter_view.dart index 64eb97552..035628c80 100644 --- a/lib/pages/address_book_views/subviews/address_book_filter_view.dart +++ b/lib/pages/address_book_views/subviews/address_book_filter_view.dart @@ -10,22 +10,23 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/providers/ui/address_book_providers/address_book_filter_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../providers/global/prefs_provider.dart'; +import '../../../providers/ui/address_book_providers/address_book_filter_provider.dart'; +import '../../../app_config.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../widgets/background.dart'; +import '../../../widgets/conditional_parent.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../widgets/desktop/primary_button.dart'; +import '../../../widgets/desktop/secondary_button.dart'; +import '../../../widgets/rounded_white_container.dart'; class AddressBookFilterView extends ConsumerStatefulWidget { - const AddressBookFilterView({Key? key}) : super(key: key); + const AddressBookFilterView({super.key}); static const String routeName = "/addressBookFilter"; @@ -35,19 +36,23 @@ class AddressBookFilterView extends ConsumerStatefulWidget { } class _AddressBookFilterViewState extends ConsumerState { - late final List _coins; + late final List _coins; @override void initState() { - List coins = [...Coin.values]; - coins.remove(Coin.firoTestNet); + final coins = [...AppConfig.coins]; + coins.removeWhere( + (e) => e is Firo && e.network == CryptoCurrencyNetwork.test, + ); - bool showTestNet = ref.read(prefsChangeNotifierProvider).showTestNetCoins; + final showTestNet = ref.read(prefsChangeNotifierProvider).showTestNetCoins; if (showTestNet) { _coins = coins.toList(growable: false); } else { - _coins = coins.where((e) => !e.isTestNet).toList(growable: false); + _coins = coins + .where((e) => e.network != CryptoCurrencyNetwork.test) + .toList(growable: false); } super.initState(); } diff --git a/lib/pages/address_book_views/subviews/coin_select_sheet.dart b/lib/pages/address_book_views/subviews/coin_select_sheet.dart index 922502abd..d39f7b08c 100644 --- a/lib/pages/address_book_views/subviews/coin_select_sheet.dart +++ b/lib/pages/address_book_views/subviews/coin_select_sheet.dart @@ -13,21 +13,24 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/themes/coin_image_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; +import '../../../providers/global/prefs_provider.dart'; +import '../../../app_config.dart'; +import '../../../themes/coin_image_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; class CoinSelectSheet extends StatelessWidget { - const CoinSelectSheet({Key? key}) : super(key: key); + const CoinSelectSheet({super.key}); @override Widget build(BuildContext context) { final maxHeight = MediaQuery.of(context).size.height * 0.60; - var coins_ = [...Coin.values]; - coins_.remove(Coin.firoTestNet); + final coins_ = [...AppConfig.coins]; + coins_.removeWhere( + (e) => e is Firo && e.network == CryptoCurrencyNetwork.test, + ); return Container( decoration: BoxDecoration( color: Theme.of(context).extension()!.popupBG, @@ -85,7 +88,11 @@ class CoinSelectSheet extends StatelessWidget { shrinkWrap: true, itemCount: showTestNet ? coins_.length - : coins_.where((e) => !e.isTestNet).length, + : coins_ + .where( + (e) => e.network != CryptoCurrencyNetwork.test, + ) + .length, itemBuilder: (builderContext, index) { final coin = coins_[index]; return Padding( diff --git a/lib/pages/address_book_views/subviews/contact_details_view.dart b/lib/pages/address_book_views/subviews/contact_details_view.dart index 419081f2b..2d12334f0 100644 --- a/lib/pages/address_book_views/subviews/contact_details_view.dart +++ b/lib/pages/address_book_views/subviews/contact_details_view.dart @@ -15,36 +15,35 @@ import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/address_book_views/subviews/add_new_contact_address_view.dart'; -import 'package:stackwallet/pages/address_book_views/subviews/edit_contact_address_view.dart'; -import 'package:stackwallet/pages/address_book_views/subviews/edit_contact_name_emoji_view.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/global/address_book_service_provider.dart'; -import 'package:stackwallet/providers/ui/address_book_providers/address_entry_data_provider.dart'; -import 'package:stackwallet/themes/coin_icon_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/clipboard_interface.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/loading_indicator.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; -import 'package:stackwallet/widgets/transaction_card.dart'; +import '../../../models/isar/models/isar_models.dart'; +import '../../../notifications/show_flush_bar.dart'; +import 'add_new_contact_address_view.dart'; +import 'edit_contact_address_view.dart'; +import 'edit_contact_name_emoji_view.dart'; +import '../../../providers/db/main_db_provider.dart'; +import '../../../providers/global/address_book_service_provider.dart'; +import '../../../providers/ui/address_book_providers/address_entry_data_provider.dart'; +import '../../../themes/coin_icon_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/clipboard_interface.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../widgets/background.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/custom_buttons/blue_text_button.dart'; +import '../../../widgets/loading_indicator.dart'; +import '../../../widgets/rounded_container.dart'; +import '../../../widgets/rounded_white_container.dart'; +import '../../../widgets/stack_dialog.dart'; +import '../../../widgets/transaction_card.dart'; import 'package:tuple/tuple.dart'; class ContactDetailsView extends ConsumerStatefulWidget { const ContactDetailsView({ - Key? key, + super.key, required this.contactId, this.clipboard = const ClipboardWrapper(), - }) : super(key: key); + }); static const String routeName = "/contactDetails"; @@ -79,7 +78,7 @@ class _ContactDetailsViewState extends ConsumerState { .sortByTimestampDesc() .findAll(); - List> result = []; + final List> result = []; for (final tx in transactions) { result.add(Tuple2(tx.walletId, tx)); @@ -151,7 +150,7 @@ class _ContactDetailsViewState extends ConsumerState { height: 20, ), onPressed: () { - bool isFavorite = _contact.isFavorite; + final bool isFavorite = _contact.isFavorite; ref.read(addressBookServiceProvider).editContact( _contact.copyWith(isFavorite: !isFavorite)); diff --git a/lib/pages/address_book_views/subviews/contact_popup.dart b/lib/pages/address_book_views/subviews/contact_popup.dart index ae31f8c09..5411736e0 100644 --- a/lib/pages/address_book_views/subviews/contact_popup.dart +++ b/lib/pages/address_book_views/subviews/contact_popup.dart @@ -14,27 +14,27 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/models/send_view_auto_fill_data.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/address_book_views/subviews/contact_details_view.dart'; -import 'package:stackwallet/pages/exchange_view/exchange_step_views/step_2_view.dart'; -import 'package:stackwallet/pages/send_view/send_view.dart'; -import 'package:stackwallet/providers/global/active_wallet_provider.dart'; -import 'package:stackwallet/providers/global/address_book_service_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/coin_icon_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/clipboard_interface.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; import 'package:tuple/tuple.dart'; +import '../../../models/send_view_auto_fill_data.dart'; +import '../../../notifications/show_flush_bar.dart'; +import '../../../providers/global/active_wallet_provider.dart'; +import '../../../providers/global/address_book_service_provider.dart'; +import '../../../providers/providers.dart'; +import '../../../themes/coin_icon_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/clipboard_interface.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../widgets/app_icon.dart'; +import '../../../widgets/rounded_container.dart'; +import '../../../widgets/rounded_white_container.dart'; +import '../../exchange_view/exchange_step_views/step_2_view.dart'; +import '../../send_view/send_view.dart'; +import 'contact_details_view.dart'; + final exchangeFromAddressBookAddressStateProvider = StateProvider((ref) => ""); @@ -56,8 +56,8 @@ class ContactPopUp extends ConsumerWidget { final active = ref.read(currentWalletIdProvider); - bool hasActiveWallet = active != null; - bool isExchangeFlow = + final bool hasActiveWallet = active != null; + final bool isExchangeFlow = ref.watch(exchangeFlowIsActiveStateProvider.state).state; final addresses = contact.addressesSorted.where((e) { @@ -118,16 +118,8 @@ class ContactPopUp extends ConsumerWidget { borderRadius: BorderRadius.circular(32), ), child: contact.customId == "default" - ? Center( - child: SvgPicture.file( - File( - ref.watch( - themeProvider.select( - (value) => value - .assets.stackIcon, - ), - ), - ), + ? const Center( + child: AppIcon( width: 20, ), ) diff --git a/lib/pages/address_book_views/subviews/edit_contact_address_view.dart b/lib/pages/address_book_views/subviews/edit_contact_address_view.dart index a061f1ed5..d9c6e584f 100644 --- a/lib/pages/address_book_views/subviews/edit_contact_address_view.dart +++ b/lib/pages/address_book_views/subviews/edit_contact_address_view.dart @@ -13,22 +13,22 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/models/isar/models/contact_entry.dart'; -import 'package:stackwallet/pages/address_book_views/subviews/new_contact_address_entry_form.dart'; -import 'package:stackwallet/providers/global/address_book_service_provider.dart'; -import 'package:stackwallet/providers/ui/address_book_providers/address_entry_data_provider.dart'; -import 'package:stackwallet/providers/ui/address_book_providers/valid_contact_state_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/barcode_scanner_interface.dart'; -import 'package:stackwallet/utilities/clipboard_interface.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; +import '../../../models/isar/models/contact_entry.dart'; +import 'new_contact_address_entry_form.dart'; +import '../../../providers/global/address_book_service_provider.dart'; +import '../../../providers/ui/address_book_providers/address_entry_data_provider.dart'; +import '../../../providers/ui/address_book_providers/valid_contact_state_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/barcode_scanner_interface.dart'; +import '../../../utilities/clipboard_interface.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../widgets/background.dart'; +import '../../../widgets/conditional_parent.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/desktop/primary_button.dart'; +import '../../../widgets/desktop/secondary_button.dart'; class EditContactAddressView extends ConsumerStatefulWidget { const EditContactAddressView({ diff --git a/lib/pages/address_book_views/subviews/edit_contact_name_emoji_view.dart b/lib/pages/address_book_views/subviews/edit_contact_name_emoji_view.dart index 8974d8a32..c1d8c139e 100644 --- a/lib/pages/address_book_views/subviews/edit_contact_name_emoji_view.dart +++ b/lib/pages/address_book_views/subviews/edit_contact_name_emoji_view.dart @@ -14,22 +14,22 @@ import 'package:emojis/emoji.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/providers/global/address_book_service_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/emoji_select_sheet.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../../providers/global/address_book_service_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../widgets/background.dart'; +import '../../../widgets/conditional_parent.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/desktop/desktop_dialog.dart'; +import '../../../widgets/desktop/primary_button.dart'; +import '../../../widgets/desktop/secondary_button.dart'; +import '../../../widgets/emoji_select_sheet.dart'; +import '../../../widgets/icon_widgets/x_icon.dart'; +import '../../../widgets/stack_text_field.dart'; +import '../../../widgets/textfield_icon_button.dart'; class EditContactNameEmojiView extends ConsumerStatefulWidget { const EditContactNameEmojiView({ diff --git a/lib/pages/address_book_views/subviews/new_contact_address_entry_form.dart b/lib/pages/address_book_views/subviews/new_contact_address_entry_form.dart index 7381de7cc..fc4c8f900 100644 --- a/lib/pages/address_book_views/subviews/new_contact_address_entry_form.dart +++ b/lib/pages/address_book_views/subviews/new_contact_address_entry_form.dart @@ -15,34 +15,35 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/pages/address_book_views/subviews/coin_select_sheet.dart'; -import 'package:stackwallet/providers/providers.dart'; +import 'coin_select_sheet.dart'; +import '../../../providers/providers.dart'; // import 'package:stackwallet/providers/global/should_show_lockscreen_on_resume_state_provider.dart'; -import 'package:stackwallet/providers/ui/address_book_providers/address_entry_data_provider.dart'; -import 'package:stackwallet/themes/coin_icon_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/address_utils.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/barcode_scanner_interface.dart'; -import 'package:stackwallet/utilities/clipboard_interface.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/icon_widgets/clipboard_icon.dart'; -import 'package:stackwallet/widgets/icon_widgets/qrcode_icon.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../../providers/ui/address_book_providers/address_entry_data_provider.dart'; +import '../../../app_config.dart'; +import '../../../themes/coin_icon_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/address_utils.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/barcode_scanner_interface.dart'; +import '../../../utilities/clipboard_interface.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/logger.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../widgets/icon_widgets/clipboard_icon.dart'; +import '../../../widgets/icon_widgets/qrcode_icon.dart'; +import '../../../widgets/icon_widgets/x_icon.dart'; +import '../../../widgets/stack_text_field.dart'; +import '../../../widgets/textfield_icon_button.dart'; class NewContactAddressEntryForm extends ConsumerStatefulWidget { const NewContactAddressEntryForm({ - Key? key, + super.key, required this.id, required this.barcodeScanner, required this.clipboard, - }) : super(key: key); + }); final int id; @@ -62,7 +63,7 @@ class _NewContactAddressEntryFormState late final FocusNode addressLabelFocusNode; late final FocusNode addressFocusNode; - List coins = []; + List coins = []; @override void initState() { @@ -72,7 +73,7 @@ class _NewContactAddressEntryFormState ..text = ref.read(addressEntryDataProvider(widget.id)).address ?? ""; addressLabelFocusNode = FocusNode(); addressFocusNode = FocusNode(); - coins = [...Coin.values]; + coins = [...AppConfig.coins]; super.initState(); } @@ -88,15 +89,20 @@ class _NewContactAddressEntryFormState @override Widget build(BuildContext context) { final isDesktop = Util.isDesktop; - bool showTestNet = ref.watch( - prefsChangeNotifierProvider.select((value) => value.showTestNetCoins), - ); if (isDesktop) { - coins = [...Coin.values]; + coins = [...AppConfig.coins]; + coins.removeWhere( + (e) => e is Firo && e.network == CryptoCurrencyNetwork.test, + ); - coins.remove(Coin.firoTestNet); + final showTestNet = + ref.read(prefsChangeNotifierProvider).showTestNetCoins; if (showTestNet) { - coins = coins.where((e) => !e.isTestNet).toList(); + coins = coins.toList(); + } else { + coins = coins + .where((e) => e.network != CryptoCurrencyNetwork.test) + .toList(); } } @@ -104,7 +110,7 @@ class _NewContactAddressEntryFormState children: [ if (isDesktop) DropdownButtonHideUnderline( - child: DropdownButton2( + child: DropdownButton2( hint: Text( "Select cryptocurrency", style: STextStyles.fieldLabel(context), @@ -128,10 +134,12 @@ class _NewContactAddressEntryFormState ), ), isExpanded: true, - value: ref.watch(addressEntryDataProvider(widget.id) - .select((value) => value.coin)), + value: ref.watch( + addressEntryDataProvider(widget.id) + .select((value) => value.coin), + ), onChanged: (value) { - if (value is Coin) { + if (value is CryptoCurrency) { ref.read(addressEntryDataProvider(widget.id)).coin = value; } }, @@ -145,7 +153,7 @@ class _NewContactAddressEntryFormState ), items: [ ...coins.map( - (coin) => DropdownMenuItem( + (coin) => DropdownMenuItem( value: coin, child: Padding( padding: const EdgeInsets.symmetric(vertical: 4), @@ -205,7 +213,7 @@ class _NewContactAddressEntryFormState context: context, builder: (_) => const CoinSelectSheet(), ).then((value) { - if (value is Coin) { + if (value is CryptoCurrency) { ref.read(addressEntryDataProvider(widget.id)).coin = value; } @@ -214,8 +222,10 @@ class _NewContactAddressEntryFormState child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - ref.watch(addressEntryDataProvider(widget.id) - .select((value) => value.coin)) == + ref.watch( + addressEntryDataProvider(widget.id) + .select((value) => value.coin), + ) == null ? Text( "Select cryptocurrency", @@ -245,8 +255,9 @@ class _NewContactAddressEntryFormState Text( ref .watch( - addressEntryDataProvider(widget.id) - .select((value) => value.coin))! + addressEntryDataProvider(widget.id) + .select((value) => value.coin), + )! .prettyName, style: STextStyles.itemSubtitle12(context), ), @@ -335,8 +346,10 @@ class _NewContactAddressEntryFormState suffixIcon: UnconstrainedBox( child: Row( children: [ - if (ref.watch(addressEntryDataProvider(widget.id) - .select((value) => value.address)) != + if (ref.watch( + addressEntryDataProvider(widget.id) + .select((value) => value.address), + ) != null) TextFieldIconButton( key: const Key("addAddressBookClearAddressButtonKey"), @@ -348,8 +361,10 @@ class _NewContactAddressEntryFormState }, child: const XIcon(), ), - if (ref.watch(addressEntryDataProvider(widget.id) - .select((value) => value.address)) == + if (ref.watch( + addressEntryDataProvider(widget.id) + .select((value) => value.address), + ) == null) TextFieldIconButton( key: const Key("addAddressPasteAddressButtonKey"), @@ -372,8 +387,10 @@ class _NewContactAddressEntryFormState child: const ClipboardIcon(), ), if (!Util.isDesktop && - ref.watch(addressEntryDataProvider(widget.id) - .select((value) => value.address)) == + ref.watch( + addressEntryDataProvider(widget.id) + .select((value) => value.address), + ) == null) TextFieldIconButton( key: const Key("addAddressBookEntryScanQrButtonKey"), @@ -419,11 +436,12 @@ class _NewContactAddressEntryFormState .read(addressEntryDataProvider(widget.id)) .coin != null) { - if (AddressUtils.validateAddress( - qrResult.rawContent, - ref - .read(addressEntryDataProvider(widget.id)) - .coin!)) { + if (ref + .read(addressEntryDataProvider(widget.id)) + .coin! + .validateAddress( + qrResult.rawContent, + )) { addressController.text = qrResult.rawContent; ref .read(addressEntryDataProvider(widget.id)) @@ -436,8 +454,9 @@ class _NewContactAddressEntryFormState // .state) // .state = true; Logging.instance.log( - "Failed to get camera permissions to scan address qr code: $e\n$s", - level: LogLevel.Warning); + "Failed to get camera permissions to scan address qr code: $e\n$s", + level: LogLevel.Warning, + ); } }, child: const QrCodeIcon(), @@ -466,8 +485,10 @@ class _NewContactAddressEntryFormState }, ), ), - if (!ref.watch(addressEntryDataProvider(widget.id) - .select((value) => value.isValidAddress)) && + if (!ref.watch( + addressEntryDataProvider(widget.id) + .select((value) => value.isValidAddress), + ) && addressController.text.isNotEmpty) Row( children: [ diff --git a/lib/pages/buy_view/buy_form.dart b/lib/pages/buy_view/buy_form.dart index d986a1e3c..1baf97db3 100644 --- a/lib/pages/buy_view/buy_form.dart +++ b/lib/pages/buy_view/buy_form.dart @@ -16,56 +16,58 @@ import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:intl/intl.dart'; -import 'package:stackwallet/models/buy/response_objects/crypto.dart'; -import 'package:stackwallet/models/buy/response_objects/fiat.dart'; -import 'package:stackwallet/models/buy/response_objects/quote.dart'; -import 'package:stackwallet/models/contact_address_entry.dart'; -import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart'; -import 'package:stackwallet/pages/address_book_views/address_book_view.dart'; -import 'package:stackwallet/pages/buy_view/buy_quote_preview.dart'; -import 'package:stackwallet/pages/buy_view/sub_widgets/crypto_selection_view.dart'; -import 'package:stackwallet/pages/buy_view/sub_widgets/fiat_selection_view.dart'; -import 'package:stackwallet/pages/exchange_view/choose_from_stack_view.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/address_book_address_chooser/address_book_address_chooser.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/services/buy/buy_response.dart'; -import 'package:stackwallet/services/buy/simplex/simplex_api.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/address_utils.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/barcode_scanner_interface.dart'; -import 'package:stackwallet/utilities/clipboard_interface.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/custom_loading_overlay.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/addressbook_icon.dart'; -import 'package:stackwallet/widgets/icon_widgets/clipboard_icon.dart'; -import 'package:stackwallet/widgets/icon_widgets/qrcode_icon.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; + +import '../../app_config.dart'; +import '../../models/buy/response_objects/crypto.dart'; +import '../../models/buy/response_objects/fiat.dart'; +import '../../models/buy/response_objects/quote.dart'; +import '../../models/contact_address_entry.dart'; +import '../../models/isar/models/ethereum/eth_contract.dart'; +import '../../pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/address_book_address_chooser/address_book_address_chooser.dart'; +import '../../providers/providers.dart'; +import '../../services/buy/buy_response.dart'; +import '../../services/buy/simplex/simplex_api.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/address_utils.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/barcode_scanner_interface.dart'; +import '../../utilities/clipboard_interface.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/logger.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import '../../wallets/crypto_currency/crypto_currency.dart'; +import '../../widgets/conditional_parent.dart'; +import '../../widgets/custom_buttons/blue_text_button.dart'; +import '../../widgets/custom_loading_overlay.dart'; +import '../../widgets/desktop/desktop_dialog.dart'; +import '../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../widgets/desktop/primary_button.dart'; +import '../../widgets/icon_widgets/addressbook_icon.dart'; +import '../../widgets/icon_widgets/clipboard_icon.dart'; +import '../../widgets/icon_widgets/qrcode_icon.dart'; +import '../../widgets/icon_widgets/x_icon.dart'; +import '../../widgets/rounded_container.dart'; +import '../../widgets/rounded_white_container.dart'; +import '../../widgets/stack_dialog.dart'; +import '../../widgets/stack_text_field.dart'; +import '../../widgets/textfield_icon_button.dart'; +import '../address_book_views/address_book_view.dart'; +import '../exchange_view/choose_from_stack_view.dart'; +import 'buy_quote_preview.dart'; +import 'sub_widgets/crypto_selection_view.dart'; +import 'sub_widgets/fiat_selection_view.dart'; class BuyForm extends ConsumerStatefulWidget { const BuyForm({ - Key? key, + super.key, this.coin, this.tokenContract, this.clipboard = const ClipboardWrapper(), this.scanner = const BarcodeScannerWrapper(), - }) : super(key: key); + }); - final Coin? coin; + final CryptoCurrency? coin; final ClipboardInterface clipboard; final BarcodeScannerInterface scanner; @@ -76,7 +78,7 @@ class BuyForm extends ConsumerStatefulWidget { } class _BuyFormState extends ConsumerState { - late final Coin? coin; + late final CryptoCurrency? coin; late final ClipboardInterface clipboard; late final BarcodeScannerInterface scanner; @@ -249,7 +251,8 @@ class _BuyFormState extends ConsumerState { ], ), ); - }) + }, + ) : await Navigator.of(context).push( MaterialPageRoute( builder: (_) => CryptoSelectionView( @@ -386,7 +389,8 @@ class _BuyFormState extends ConsumerState { ], ), ); - }) + }, + ) : await Navigator.of(context).push( MaterialPageRoute( builder: (_) => FiatSelectionView( @@ -406,17 +410,6 @@ class _BuyFormState extends ConsumerState { // return null; // } - bool isStackCoin(String? ticker) { - if (ticker == null) return false; - - try { - coinFromTickerCaseInsensitive(ticker); - return true; - } on ArgumentError catch (_) { - return false; - } - } - Future previewQuote(SimplexQuote quote) async { bool shouldPop = false; unawaited( @@ -501,7 +494,7 @@ class _BuyFormState extends ConsumerState { ), ), ], - ) + ), ], ), ), @@ -517,9 +510,10 @@ class _BuyFormState extends ConsumerState { child: Text( "Ok", style: STextStyles.button(context).copyWith( - color: Theme.of(context) - .extension()! - .accentColorDark), + color: Theme.of(context) + .extension()! + .accentColorDark, + ), ), onPressed: () { Navigator.of(context).pop(); @@ -589,7 +583,7 @@ class _BuyFormState extends ConsumerState { ), ), ], - ) + ), ], ), ), @@ -606,9 +600,10 @@ class _BuyFormState extends ConsumerState { child: Text( "Ok", style: STextStyles.button(context).copyWith( - color: Theme.of(context) - .extension()! - .accentColorDark), + color: Theme.of(context) + .extension()! + .accentColorDark, + ), ), onPressed: () { Navigator.of(context).pop(); @@ -701,7 +696,8 @@ class _BuyFormState extends ConsumerState { ], ), ); - }) + }, + ) : await Navigator.of(context).push( MaterialPageRoute( builder: (_) => BuyQuotePreviewView( @@ -742,7 +738,7 @@ class _BuyFormState extends ConsumerState { Fiat.fromJson({'ticker': 'USD', 'name': 'United States Dollar'}); selectedCrypto = Crypto.fromJson({ 'ticker': widget.coin?.ticker ?? 'BTC', - 'name': widget.coin?.prettyName ?? 'Bitcoin' + 'name': widget.coin?.prettyName ?? 'Bitcoin', }); // THIS IS BAD. No way to be certain the simplex ticker points to the same @@ -907,7 +903,9 @@ class _BuyFormState extends ConsumerState { children: [ Container( padding: const EdgeInsets.symmetric( - vertical: 3, horizontal: 6), + vertical: 3, + horizontal: 6, + ), decoration: BoxDecoration( color: Theme.of(context) .extension()! @@ -916,12 +914,14 @@ class _BuyFormState extends ConsumerState { ), child: Text( format.simpleCurrencySymbol( - selectedFiat?.ticker ?? "ERR".toUpperCase()), + selectedFiat?.ticker ?? "ERR".toUpperCase(), + ), textAlign: TextAlign.center, style: STextStyles.smallMed12(context).copyWith( - color: Theme.of(context) - .extension()! - .accentColorDark), + color: Theme.of(context) + .extension()! + .accentColorDark, + ), ), ), const SizedBox( @@ -976,7 +976,7 @@ class _BuyFormState extends ConsumerState { }); validateAmount(); }, - ) + ), ], ), SizedBox( @@ -1026,47 +1026,53 @@ class _BuyFormState extends ConsumerState { fit: BoxFit.scaleDown, child: Padding( padding: const EdgeInsets.all(12), - child: Row(children: [ - const SizedBox(width: 2), - buyWithFiat - ? Container( - padding: const EdgeInsets.symmetric( - vertical: 3, horizontal: 6), - decoration: BoxDecoration( - color: Theme.of(context) - .extension()! - .currencyListItemBG, - borderRadius: BorderRadius.circular(4), - ), - child: Text( - format.simpleCurrencySymbol( - selectedFiat?.ticker.toUpperCase() ?? - "ERR"), - textAlign: TextAlign.center, - style: STextStyles.smallMed12(context).copyWith( + child: Row( + children: [ + const SizedBox(width: 2), + buyWithFiat + ? Container( + padding: const EdgeInsets.symmetric( + vertical: 3, + horizontal: 6, + ), + decoration: BoxDecoration( + color: Theme.of(context) + .extension()! + .currencyListItemBG, + borderRadius: BorderRadius.circular(4), + ), + child: Text( + format.simpleCurrencySymbol( + selectedFiat?.ticker.toUpperCase() ?? "ERR", + ), + textAlign: TextAlign.center, + style: + STextStyles.smallMed12(context).copyWith( color: Theme.of(context) .extension()! - .accentColorDark), + .accentColorDark, + ), + ), + ) + : CoinIconForTicker( + ticker: selectedCrypto?.ticker ?? "BTC", + size: 20, ), - ) - : CoinIconForTicker( - ticker: selectedCrypto?.ticker ?? "BTC", - size: 20, - ), - SizedBox( - width: buyWithFiat - ? 8 - : 10), // maybe make isDesktop-aware? - Text( - buyWithFiat - ? selectedFiat?.ticker ?? "ERR" - : selectedCrypto?.ticker ?? "ERR", - style: STextStyles.smallMed14(context).copyWith( + SizedBox( + width: buyWithFiat ? 8 : 10, + ), // maybe make isDesktop-aware? + Text( + buyWithFiat + ? selectedFiat?.ticker ?? "ERR" + : selectedCrypto?.ticker ?? "ERR", + style: STextStyles.smallMed14(context).copyWith( color: Theme.of(context) .extension()! - .accentColorDark), - ), - ]), + .accentColorDark, + ), + ), + ], + ), ), ), suffixIcon: Padding( @@ -1078,7 +1084,8 @@ class _BuyFormState extends ConsumerState { _buyAmountController.text.isNotEmpty ? TextFieldIconButton( key: const Key( - "buyViewClearAmountFieldButtonKey"), + "buyViewClearAmountFieldButtonKey", + ), onTap: () { // if (_BuyFormState.buyWithFiat) { // _buyAmountController.text = _BuyFormState @@ -1099,7 +1106,8 @@ class _BuyFormState extends ConsumerState { ) : TextFieldIconButton( key: const Key( - "buyViewPasteAddressFieldButtonKey"), + "buyViewPasteAddressFieldButtonKey", + ), onTap: () async { final ClipboardData? data = await clipboard .getData(Clipboard.kTextPlain); @@ -1145,12 +1153,12 @@ class _BuyFormState extends ConsumerState { Theme.of(context).extension()!.textDark3, ), ), - if (isStackCoin(selectedCrypto?.ticker)) + if (AppConfig.isStackCoin(selectedCrypto?.ticker)) CustomTextButton( text: "Choose from Stack", onTap: () { try { - final coin = coinFromTickerCaseInsensitive( + final coin = AppConfig.getCryptoCurrencyForTicker( selectedCrypto!.ticker, ); Navigator.of(context) @@ -1236,7 +1244,8 @@ class _BuyFormState extends ConsumerState { _addressToggleFlag ? TextFieldIconButton( key: const Key( - "buyViewClearAddressFieldButtonKey"), + "buyViewClearAddressFieldButtonKey", + ), onTap: () { _receiveAddressController.text = ""; _address = ""; @@ -1248,7 +1257,8 @@ class _BuyFormState extends ConsumerState { ) : TextFieldIconButton( key: const Key( - "buyViewPasteAddressFieldButtonKey"), + "buyViewPasteAddressFieldButtonKey", + ), onTap: () async { final ClipboardData? data = await clipboard .getData(Clipboard.kTextPlain); @@ -1257,7 +1267,9 @@ class _BuyFormState extends ConsumerState { String content = data.text!.trim(); if (content.contains("\n")) { content = content.substring( - 0, content.indexOf("\n")); + 0, + content.indexOf("\n"), + ); } _receiveAddressController.text = content; @@ -1275,7 +1287,7 @@ class _BuyFormState extends ConsumerState { : const XIcon(), ), if (_receiveAddressController.text.isEmpty && - isStackCoin(selectedCrypto?.ticker) && + AppConfig.isStackCoin(selectedCrypto?.ticker) && isDesktop) TextFieldIconButton( key: const Key("buyViewAddressBookButtonKey"), @@ -1300,7 +1312,8 @@ class _BuyFormState extends ConsumerState { child: Text( "Address book", style: STextStyles.desktopH3( - context), + context, + ), ), ), const DesktopDialogCloseButton(), @@ -1308,9 +1321,13 @@ class _BuyFormState extends ConsumerState { ), Expanded( child: AddressBookAddressChooser( - coin: coinFromTickerCaseInsensitive( - selectedCrypto!.ticker - .toString()), + coin: AppConfig.coins.firstWhere( + (e) => + e.ticker.toLowerCase() == + selectedCrypto!.ticker + .toString() + .toLowerCase(), + ), ), ), ], @@ -1331,7 +1348,7 @@ class _BuyFormState extends ConsumerState { child: const AddressBookIcon(), ), if (_receiveAddressController.text.isEmpty && - isStackCoin(selectedCrypto?.ticker) && + AppConfig.isStackCoin(selectedCrypto?.ticker) && !isDesktop) TextFieldIconButton( key: const Key("buyViewAddressBookButtonKey"), @@ -1352,21 +1369,25 @@ class _BuyFormState extends ConsumerState { if (FocusScope.of(context).hasFocus) { FocusScope.of(context).unfocus(); await Future.delayed( - const Duration(milliseconds: 75)); + const Duration(milliseconds: 75), + ); } final qrResult = await scanner.scan(); Logging.instance.log( - "qrResult content: ${qrResult.rawContent}", - level: LogLevel.Info); + "qrResult content: ${qrResult.rawContent}", + level: LogLevel.Info, + ); final results = AddressUtils.parseUri( - qrResult.rawContent); + qrResult.rawContent, + ); Logging.instance.log( - "qrResult parsed: $results", - level: LogLevel.Info); + "qrResult parsed: $results", + level: LogLevel.Info, + ); if (results.isNotEmpty) { // auto fill address diff --git a/lib/pages/buy_view/buy_in_wallet_view.dart b/lib/pages/buy_view/buy_in_wallet_view.dart index b0183eb79..512ae5315 100644 --- a/lib/pages/buy_view/buy_in_wallet_view.dart +++ b/lib/pages/buy_view/buy_in_wallet_view.dart @@ -9,24 +9,24 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart'; -import 'package:stackwallet/pages/buy_view/buy_view.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../models/isar/models/ethereum/eth_contract.dart'; +import 'buy_view.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/text_styles.dart'; +import '../../wallets/crypto_currency/crypto_currency.dart'; +import '../../widgets/background.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; class BuyInWalletView extends StatefulWidget { const BuyInWalletView({ - Key? key, + super.key, required this.coin, this.contract, - }) : super(key: key); + }); static const String routeName = "/stackBuyInWalletView"; - final Coin? coin; + final CryptoCurrency? coin; final EthContract? contract; @override @@ -34,7 +34,7 @@ class BuyInWalletView extends StatefulWidget { } class _BuyInWalletViewState extends State { - late final Coin? coin; + late final CryptoCurrency? coin; @override Widget build(BuildContext context) { diff --git a/lib/pages/buy_view/buy_order_details.dart b/lib/pages/buy_view/buy_order_details.dart index 04a556850..9c44f01db 100644 --- a/lib/pages/buy_view/buy_order_details.dart +++ b/lib/pages/buy_view/buy_order_details.dart @@ -11,17 +11,17 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/models/buy/response_objects/order.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../models/buy/response_objects/order.dart'; +import '../../themes/stack_colors.dart'; +import '../../themes/theme_providers.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import '../../widgets/background.dart'; +import '../../widgets/conditional_parent.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/desktop/primary_button.dart'; +import '../../widgets/rounded_white_container.dart'; class BuyOrderDetailsView extends ConsumerStatefulWidget { const BuyOrderDetailsView({ diff --git a/lib/pages/buy_view/buy_quote_preview.dart b/lib/pages/buy_view/buy_quote_preview.dart index 66b9af812..ec65de1f5 100644 --- a/lib/pages/buy_view/buy_quote_preview.dart +++ b/lib/pages/buy_view/buy_quote_preview.dart @@ -14,18 +14,18 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:intl/intl.dart'; -import 'package:stackwallet/models/buy/response_objects/quote.dart'; -import 'package:stackwallet/pages/buy_view/sub_widgets/buy_warning_popup.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../models/buy/response_objects/quote.dart'; +import 'sub_widgets/buy_warning_popup.dart'; +import '../../themes/stack_colors.dart'; +import '../../themes/theme_providers.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import '../../widgets/background.dart'; +import '../../widgets/conditional_parent.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/desktop/primary_button.dart'; +import '../../widgets/rounded_white_container.dart'; class BuyQuotePreviewView extends ConsumerStatefulWidget { const BuyQuotePreviewView({ diff --git a/lib/pages/buy_view/buy_view.dart b/lib/pages/buy_view/buy_view.dart index e87fa3398..9589621cc 100644 --- a/lib/pages/buy_view/buy_view.dart +++ b/lib/pages/buy_view/buy_view.dart @@ -10,23 +10,23 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart'; -import 'package:stackwallet/pages/buy_view/buy_form.dart'; -import 'package:stackwallet/services/event_bus/events/global/tor_connection_status_changed_event.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; -import 'package:stackwallet/widgets/tor_subscription.dart'; +import '../../models/isar/models/ethereum/eth_contract.dart'; +import 'buy_form.dart'; +import '../../services/event_bus/events/global/tor_connection_status_changed_event.dart'; +import '../../services/tor_service.dart'; +import '../../themes/stack_colors.dart'; +import '../../wallets/crypto_currency/crypto_currency.dart'; +import '../../widgets/stack_dialog.dart'; +import '../../widgets/tor_subscription.dart'; class BuyView extends ConsumerStatefulWidget { const BuyView({ - Key? key, + super.key, this.coin, this.tokenContract, - }) : super(key: key); + }); - final Coin? coin; + final CryptoCurrency? coin; final EthContract? tokenContract; static const String routeName = "/stackBuyView"; @@ -36,7 +36,7 @@ class BuyView extends ConsumerStatefulWidget { } class _BuyViewState extends ConsumerState { - Coin? coin; + CryptoCurrency? coin; EthContract? tokenContract; late bool torEnabled; diff --git a/lib/pages/buy_view/sub_widgets/buy_warning_popup.dart b/lib/pages/buy_view/sub_widgets/buy_warning_popup.dart index fa651e7df..c3e1dc4e9 100644 --- a/lib/pages/buy_view/sub_widgets/buy_warning_popup.dart +++ b/lib/pages/buy_view/sub_widgets/buy_warning_popup.dart @@ -13,22 +13,22 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/models/buy/response_objects/order.dart'; -import 'package:stackwallet/models/buy/response_objects/quote.dart'; -import 'package:stackwallet/pages/buy_view/buy_order_details.dart'; -import 'package:stackwallet/services/buy/buy_response.dart'; -import 'package:stackwallet/services/buy/simplex/simplex_api.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../../models/buy/response_objects/order.dart'; +import '../../../models/buy/response_objects/quote.dart'; +import '../buy_order_details.dart'; +import '../../../services/buy/buy_response.dart'; +import '../../../services/buy/simplex/simplex_api.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../themes/theme_providers.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../widgets/desktop/desktop_dialog.dart'; +import '../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../widgets/desktop/primary_button.dart'; +import '../../../widgets/desktop/secondary_button.dart'; +import '../../../widgets/rounded_white_container.dart'; +import '../../../widgets/stack_dialog.dart'; class BuyWarningPopup extends ConsumerStatefulWidget { const BuyWarningPopup({ diff --git a/lib/pages/buy_view/sub_widgets/crypto_selection_view.dart b/lib/pages/buy_view/sub_widgets/crypto_selection_view.dart index b7ae75de0..3bc0b220b 100644 --- a/lib/pages/buy_view/sub_widgets/crypto_selection_view.dart +++ b/lib/pages/buy_view/sub_widgets/crypto_selection_view.dart @@ -13,28 +13,29 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/models/buy/response_objects/crypto.dart'; -import 'package:stackwallet/themes/coin_icon_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; + +import '../../../app_config.dart'; +import '../../../models/buy/response_objects/crypto.dart'; +import '../../../themes/coin_icon_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/logger.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../widgets/background.dart'; +import '../../../widgets/conditional_parent.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/icon_widgets/x_icon.dart'; +import '../../../widgets/rounded_white_container.dart'; +import '../../../widgets/stack_text_field.dart'; +import '../../../widgets/textfield_icon_button.dart'; class CryptoSelectionView extends ConsumerStatefulWidget { const CryptoSelectionView({ - Key? key, + super.key, required this.coins, - }) : super(key: key); + }); final List coins; @@ -53,9 +54,11 @@ class _CryptoSelectionViewState extends ConsumerState { void filter(String text) { setState(() { _coins = [ - ...coins.where((e) => - e.name.toLowerCase().contains(text.toLowerCase()) || - e.ticker.toLowerCase().contains(text.toLowerCase())) + ...coins.where( + (e) => + e.name.toLowerCase().contains(text.toLowerCase()) || + e.ticker.toLowerCase().contains(text.toLowerCase()), + ), ]; }); } @@ -66,10 +69,12 @@ class _CryptoSelectionViewState extends ConsumerState { coins = [...widget.coins]; coins.sort( - (a, b) => a.ticker.toLowerCase().compareTo(b.ticker.toLowerCase())); - for (Coin coin in Coin.values.reversed) { - int index = coins.indexWhere((element) => - element.ticker.toLowerCase() == coin.ticker.toLowerCase()); + (a, b) => a.ticker.toLowerCase().compareTo(b.ticker.toLowerCase()), + ); + for (final coin in AppConfig.coins.reversed) { + final index = coins.indexWhere( + (element) => element.ticker.toLowerCase() == coin.ticker.toLowerCase(), + ); if (index > 0) { final currency = coins.removeAt(index); coins.insert(0, currency); @@ -104,7 +109,8 @@ class _CryptoSelectionViewState extends ConsumerState { if (FocusScope.of(context).hasFocus) { FocusScope.of(context).unfocus(); await Future.delayed( - const Duration(milliseconds: 50)); + const Duration(milliseconds: 50), + ); } if (mounted) { Navigator.of(context).pop(); @@ -261,17 +267,6 @@ class _CryptoSelectionViewState extends ConsumerState { } } -bool isStackCoin(String? ticker) { - if (ticker == null) return false; - - try { - coinFromTickerCaseInsensitive(ticker); - return true; - } on ArgumentError catch (_) { - return false; - } -} - // make a stateless widget that takes in string and double (won't ever be null) // class getIconForTicker extends ConsumerWidget{ // const getIconForTicker({ @@ -289,10 +284,10 @@ bool isStackCoin(String? ticker) { /// caller must ensure [Coin] for ticker exists class CoinIconForTicker extends ConsumerWidget { const CoinIconForTicker({ - Key? key, + super.key, required this.ticker, required this.size, - }) : super(key: key); + }); final String ticker; final double size; @@ -300,7 +295,7 @@ class CoinIconForTicker extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { try { - final coin = coinFromTickerCaseInsensitive(ticker); + final coin = AppConfig.getCryptoCurrencyForTicker(ticker)!; return SvgPicture.file( File( ref.watch(coinIconProvider(coin)), @@ -321,7 +316,7 @@ class CoinIconForTicker extends ConsumerWidget { // }) { // String? iconAsset = /*isStackCoin(ticker) // ?*/ -// Assets.svg.iconFor(coin: coinFromTickerCaseInsensitive(ticker)); +// Assets.svg.iconFor(coin: SupportedAppConfig.getCryptoCurrencyForTicker(ticker)); // // : Assets.svg.buyIconFor(ticker); // return (iconAsset != null) // ? SvgPicture.asset(iconAsset, height: size, width: size) diff --git a/lib/pages/buy_view/sub_widgets/fiat_selection_view.dart b/lib/pages/buy_view/sub_widgets/fiat_selection_view.dart index 555a86b00..87671494e 100644 --- a/lib/pages/buy_view/sub_widgets/fiat_selection_view.dart +++ b/lib/pages/buy_view/sub_widgets/fiat_selection_view.dart @@ -11,20 +11,20 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:intl/intl.dart'; -import 'package:stackwallet/models/buy/response_objects/fiat.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/fiat_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../../models/buy/response_objects/fiat.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/enums/fiat_enum.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../widgets/background.dart'; +import '../../../widgets/conditional_parent.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/icon_widgets/x_icon.dart'; +import '../../../widgets/rounded_white_container.dart'; +import '../../../widgets/stack_text_field.dart'; +import '../../../widgets/textfield_icon_button.dart'; class FiatSelectionView extends StatefulWidget { const FiatSelectionView({ diff --git a/lib/pages/cashfusion/cashfusion_view.dart b/lib/pages/cashfusion/cashfusion_view.dart index 5de0003d9..e8cfaff4d 100644 --- a/lib/pages/cashfusion/cashfusion_view.dart +++ b/lib/pages/cashfusion/cashfusion_view.dart @@ -15,25 +15,25 @@ import 'package:flutter/services.dart'; import 'package:flutter_native_splash/cli_commands.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/pages/cashfusion/fusion_progress_view.dart'; -import 'package:stackwallet/pages/cashfusion/fusion_rounds_selection_sheet.dart'; -import 'package:stackwallet/providers/cash_fusion/fusion_progress_ui_state_provider.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/cash_fusion_interface.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; +import 'fusion_progress_view.dart'; +import 'fusion_rounds_selection_sheet.dart'; +import '../../providers/cash_fusion/fusion_progress_ui_state_provider.dart'; +import '../../providers/global/prefs_provider.dart'; +import '../../providers/global/wallets_provider.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/text_styles.dart'; +import '../../wallets/crypto_currency/crypto_currency.dart'; +import '../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../wallets/wallet/wallet_mixin_interfaces/cash_fusion_interface.dart'; +import '../../widgets/background.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/custom_buttons/blue_text_button.dart'; +import '../../widgets/desktop/primary_button.dart'; +import '../../widgets/rounded_container.dart'; +import '../../widgets/rounded_white_container.dart'; +import '../../widgets/stack_text_field.dart'; class CashFusionView extends ConsumerStatefulWidget { const CashFusionView({ @@ -56,7 +56,7 @@ class _CashFusionViewState extends ConsumerState { late final FocusNode portFocusNode; late final TextEditingController fusionRoundController; late final FocusNode fusionRoundFocusNode; - late final Coin coin; + late final CryptoCurrency coin; bool _enableSSLCheckbox = false; bool _enableStartButton = false; diff --git a/lib/pages/cashfusion/fusion_progress_view.dart b/lib/pages/cashfusion/fusion_progress_view.dart index 78bc9ccc7..6f41f07b7 100644 --- a/lib/pages/cashfusion/fusion_progress_view.dart +++ b/lib/pages/cashfusion/fusion_progress_view.dart @@ -12,23 +12,23 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/pages_desktop_specific/cashfusion/sub_widgets/fusion_progress.dart'; -import 'package:stackwallet/providers/cash_fusion/fusion_progress_ui_state_provider.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/show_loading.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/cash_fusion_interface.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../pages_desktop_specific/cashfusion/sub_widgets/fusion_progress.dart'; +import '../../providers/cash_fusion/fusion_progress_ui_state_provider.dart'; +import '../../providers/global/prefs_provider.dart'; +import '../../providers/global/wallets_provider.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/show_loading.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import '../../wallets/crypto_currency/crypto_currency.dart'; +import '../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../wallets/wallet/wallet_mixin_interfaces/cash_fusion_interface.dart'; +import '../../widgets/background.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/desktop/primary_button.dart'; +import '../../widgets/desktop/secondary_button.dart'; +import '../../widgets/rounded_container.dart'; +import '../../widgets/stack_dialog.dart'; class FusionProgressView extends ConsumerStatefulWidget { const FusionProgressView({ @@ -44,7 +44,7 @@ class FusionProgressView extends ConsumerStatefulWidget { } class _FusionProgressViewState extends ConsumerState { - late final Coin coin; + late final CryptoCurrency coin; Future _requestAndProcessCancel() async { final shouldCancel = await showDialog( diff --git a/lib/pages/cashfusion/fusion_rounds_selection_sheet.dart b/lib/pages/cashfusion/fusion_rounds_selection_sheet.dart index 3b36864ab..1294c0096 100644 --- a/lib/pages/cashfusion/fusion_rounds_selection_sheet.dart +++ b/lib/pages/cashfusion/fusion_rounds_selection_sheet.dart @@ -11,9 +11,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_hooks/flutter_hooks.dart'; import 'package:flutter_native_splash/cli_commands.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/text_styles.dart'; enum FusionOption { continuous, diff --git a/lib/pages/coin_control/coin_control_view.dart b/lib/pages/coin_control/coin_control_view.dart index b57281dd7..4540b6d3f 100644 --- a/lib/pages/coin_control/coin_control_view.dart +++ b/lib/pages/coin_control/coin_control_view.dart @@ -14,32 +14,31 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/db/isar/main_db.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/pages/coin_control/utxo_card.dart'; -import 'package:stackwallet/pages/coin_control/utxo_details_view.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/coin_control_interface.dart'; -import 'package:stackwallet/widgets/animated_widgets/rotate_icon.dart'; -import 'package:stackwallet/widgets/app_bar_field.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/dropdown_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/expandable2.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/toggle.dart'; +import '../../db/isar/main_db.dart'; +import '../../models/isar/models/isar_models.dart'; +import 'utxo_card.dart'; +import 'utxo_details_view.dart'; +import '../../providers/global/wallets_provider.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/amount/amount.dart'; +import '../../utilities/amount/amount_formatter.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/text_styles.dart'; +import '../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../wallets/wallet/wallet_mixin_interfaces/coin_control_interface.dart'; +import '../../widgets/animated_widgets/rotate_icon.dart'; +import '../../widgets/app_bar_field.dart'; +import '../../widgets/background.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/custom_buttons/dropdown_button.dart'; +import '../../widgets/desktop/primary_button.dart'; +import '../../widgets/desktop/secondary_button.dart'; +import '../../widgets/expandable2.dart'; +import '../../widgets/icon_widgets/x_icon.dart'; +import '../../widgets/rounded_container.dart'; +import '../../widgets/rounded_white_container.dart'; +import '../../widgets/toggle.dart'; import 'package:tuple/tuple.dart'; enum CoinControlViewType { @@ -49,12 +48,12 @@ enum CoinControlViewType { class CoinControlView extends ConsumerStatefulWidget { const CoinControlView({ - Key? key, + super.key, required this.walletId, required this.type, this.requestedTotal, this.selectedUTXOs, - }) : super(key: key); + }); static const routeName = "/coinControl"; @@ -128,7 +127,7 @@ class _CoinControlViewState extends ConsumerState { filter: CCFilter.all, sort: _sort, searchTerm: "", - coin: coin, + cryptoCurrency: coin, ); } else { _map = null; @@ -141,7 +140,7 @@ class _CoinControlViewState extends ConsumerState { : CCFilter.available, sort: _sort, searchTerm: _isSearching ? searchController.text : "", - coin: coin, + cryptoCurrency: coin, ); } @@ -682,7 +681,7 @@ class _CoinControlViewState extends ConsumerState { ); final selectedSum = selectedSumInt.toAmountAsRaw( - fractionDigits: coin.decimals, + fractionDigits: coin.fractionDigits, ); return Text( ref diff --git a/lib/pages/coin_control/utxo_card.dart b/lib/pages/coin_control/utxo_card.dart index 74c5d3b82..9dc2bd900 100644 --- a/lib/pages/coin_control/utxo_card.dart +++ b/lib/pages/coin_control/utxo_card.dart @@ -10,30 +10,29 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/db/isar/main_db.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/icon_widgets/utxo_status_icon.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; +import '../../db/isar/main_db.dart'; +import '../../models/isar/models/isar_models.dart'; +import '../../providers/global/wallets_provider.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/amount/amount.dart'; +import '../../utilities/amount/amount_formatter.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/text_styles.dart'; +import '../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../widgets/conditional_parent.dart'; +import '../../widgets/icon_widgets/utxo_status_icon.dart'; +import '../../widgets/rounded_container.dart'; class UtxoCard extends ConsumerStatefulWidget { const UtxoCard({ - Key? key, + super.key, required this.utxo, required this.walletId, required this.onSelectedChanged, required this.initialSelectedState, required this.canSelect, this.onPressed, - }) : super(key: key); + }); final String walletId; final UTXO utxo; @@ -138,7 +137,7 @@ class _UtxoCardState extends ConsumerState { Text( ref.watch(pAmountFormatter(coin)).format( utxo.value.toAmountAsRaw( - fractionDigits: coin.decimals, + fractionDigits: coin.fractionDigits, ), ), style: STextStyles.w600_14(context), diff --git a/lib/pages/coin_control/utxo_details_view.dart b/lib/pages/coin_control/utxo_details_view.dart index 7c32fee2f..f27db669e 100644 --- a/lib/pages/coin_control/utxo_details_view.dart +++ b/lib/pages/coin_control/utxo_details_view.dart @@ -13,34 +13,33 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/db/isar/main_db.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/simple_copy_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/simple_edit_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/utxo_status_icon.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; +import '../../db/isar/main_db.dart'; +import '../../models/isar/models/isar_models.dart'; +import '../wallet_view/transaction_views/transaction_details_view.dart'; +import '../../providers/global/wallets_provider.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/amount/amount.dart'; +import '../../utilities/amount/amount_formatter.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import '../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../widgets/background.dart'; +import '../../widgets/conditional_parent.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/custom_buttons/simple_copy_button.dart'; +import '../../widgets/custom_buttons/simple_edit_button.dart'; +import '../../widgets/desktop/desktop_dialog.dart'; +import '../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../widgets/desktop/secondary_button.dart'; +import '../../widgets/icon_widgets/utxo_status_icon.dart'; +import '../../widgets/rounded_container.dart'; class UtxoDetailsView extends ConsumerStatefulWidget { const UtxoDetailsView({ - Key? key, + super.key, required this.utxoId, required this.walletId, - }) : super(key: key); + }); static const routeName = "/utxoDetails"; @@ -244,7 +243,7 @@ class _UtxoDetailsViewState extends ConsumerState { Text( ref.watch(pAmountFormatter(coin)).format( utxo!.value.toAmountAsRaw( - fractionDigits: coin.decimals, + fractionDigits: coin.fractionDigits, ), ), style: STextStyles.pageTitleH2(context), diff --git a/lib/pages/exchange_view/choose_from_stack_view.dart b/lib/pages/exchange_view/choose_from_stack_view.dart index 553c11628..0e6cc8627 100644 --- a/lib/pages/exchange_view/choose_from_stack_view.dart +++ b/lib/pages/exchange_view/choose_from_stack_view.dart @@ -10,25 +10,25 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/wallet_info_row/sub_widgets/wallet_info_row_balance.dart'; -import 'package:stackwallet/widgets/wallet_info_row/sub_widgets/wallet_info_row_coin_icon.dart'; +import '../../providers/providers.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/text_styles.dart'; +import '../../wallets/crypto_currency/crypto_currency.dart'; +import '../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../widgets/background.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/rounded_white_container.dart'; +import '../../widgets/wallet_info_row/sub_widgets/wallet_info_row_balance.dart'; +import '../../widgets/wallet_info_row/sub_widgets/wallet_info_row_coin_icon.dart'; class ChooseFromStackView extends ConsumerStatefulWidget { const ChooseFromStackView({ - Key? key, + super.key, required this.coin, - }) : super(key: key); + }); - final Coin coin; + final CryptoCurrency coin; static const String routeName = "/chooseFromStack"; @@ -38,7 +38,7 @@ class ChooseFromStackView extends ConsumerStatefulWidget { } class _ChooseFromStackViewState extends ConsumerState { - late final Coin coin; + late final CryptoCurrency coin; @override void initState() { diff --git a/lib/pages/exchange_view/confirm_change_now_send.dart b/lib/pages/exchange_view/confirm_change_now_send.dart index 85072c98c..4e99f9bcf 100644 --- a/lib/pages/exchange_view/confirm_change_now_send.dart +++ b/lib/pages/exchange_view/confirm_change_now_send.dart @@ -12,49 +12,48 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/exchange/response_objects/trade.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/models/trade_wallet_lookup.dart'; -import 'package:stackwallet/pages/pinpad_views/lock_screen_view.dart'; -import 'package:stackwallet/pages/send_view/sub_widgets/sending_transaction_dialog.dart'; -import 'package:stackwallet/pages/wallet_view/wallet_view.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_auth_send.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/route_generator.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/wallets/models/tx_data.dart'; -import 'package:stackwallet/wallets/wallet/impl/firo_wallet.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../models/exchange/response_objects/trade.dart'; +import '../../models/isar/models/isar_models.dart'; +import '../../models/trade_wallet_lookup.dart'; +import '../pinpad_views/lock_screen_view.dart'; +import '../send_view/sub_widgets/sending_transaction_dialog.dart'; +import '../wallet_view/wallet_view.dart'; +import '../../pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_auth_send.dart'; +import '../../providers/db/main_db_provider.dart'; +import '../../providers/providers.dart'; +import '../../route_generator.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/amount/amount.dart'; +import '../../utilities/amount/amount_formatter.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/logger.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import '../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../wallets/models/tx_data.dart'; +import '../../wallets/wallet/impl/firo_wallet.dart'; +import '../../widgets/background.dart'; +import '../../widgets/conditional_parent.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/desktop/desktop_dialog.dart'; +import '../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../widgets/desktop/primary_button.dart'; +import '../../widgets/desktop/secondary_button.dart'; +import '../../widgets/rounded_container.dart'; +import '../../widgets/rounded_white_container.dart'; +import '../../widgets/stack_dialog.dart'; import 'package:uuid/uuid.dart'; class ConfirmChangeNowSendView extends ConsumerStatefulWidget { const ConfirmChangeNowSendView({ - Key? key, + super.key, required this.txData, required this.walletId, this.routeOnSuccessName = WalletView.routeName, required this.trade, this.shouldSendPublicFiroFunds, this.fromDesktopStep4 = false, - }) : super(key: key); + }); static const String routeName = "/confirmChangeNowSend"; diff --git a/lib/pages/exchange_view/edit_trade_note_view.dart b/lib/pages/exchange_view/edit_trade_note_view.dart index 13d152a84..9f6c795ec 100644 --- a/lib/pages/exchange_view/edit_trade_note_view.dart +++ b/lib/pages/exchange_view/edit_trade_note_view.dart @@ -10,16 +10,16 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/providers/exchange/trade_note_service_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../providers/exchange/trade_note_service_provider.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import '../../widgets/background.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/icon_widgets/x_icon.dart'; +import '../../widgets/stack_text_field.dart'; +import '../../widgets/textfield_icon_button.dart'; class EditTradeNoteView extends ConsumerStatefulWidget { const EditTradeNoteView({ diff --git a/lib/pages/exchange_view/exchange_coin_selection/exchange_currency_selection_view.dart b/lib/pages/exchange_view/exchange_coin_selection/exchange_currency_selection_view.dart index 3a23ea331..ad13cebf4 100644 --- a/lib/pages/exchange_view/exchange_coin_selection/exchange_currency_selection_view.dart +++ b/lib/pages/exchange_view/exchange_coin_selection/exchange_currency_selection_view.dart @@ -13,43 +13,44 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/exceptions/exchange/unsupported_currency_exception.dart'; -import 'package:stackwallet/models/isar/exchange_cache/currency.dart'; -import 'package:stackwallet/models/isar/exchange_cache/pair.dart'; -import 'package:stackwallet/pages/buy_view/sub_widgets/crypto_selection_view.dart'; -import 'package:stackwallet/services/exchange/change_now/change_now_exchange.dart'; -import 'package:stackwallet/services/exchange/exchange.dart'; -import 'package:stackwallet/services/exchange/exchange_data_loading_service.dart'; -import 'package:stackwallet/services/exchange/majestic_bank/majestic_bank_exchange.dart'; -import 'package:stackwallet/services/exchange/trocador/trocador_exchange.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/prefs.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_loading_overlay.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/loading_indicator.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; + +import '../../../app_config.dart'; +import '../../../exceptions/exchange/unsupported_currency_exception.dart'; +import '../../../models/isar/exchange_cache/currency.dart'; +import '../../../models/isar/exchange_cache/pair.dart'; +import '../../../services/exchange/change_now/change_now_exchange.dart'; +import '../../../services/exchange/exchange.dart'; +import '../../../services/exchange/exchange_data_loading_service.dart'; +import '../../../services/exchange/majestic_bank/majestic_bank_exchange.dart'; +import '../../../services/exchange/trocador/trocador_exchange.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/prefs.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../widgets/background.dart'; +import '../../../widgets/conditional_parent.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/custom_loading_overlay.dart'; +import '../../../widgets/desktop/primary_button.dart'; +import '../../../widgets/desktop/secondary_button.dart'; +import '../../../widgets/icon_widgets/x_icon.dart'; +import '../../../widgets/loading_indicator.dart'; +import '../../../widgets/rounded_white_container.dart'; +import '../../../widgets/stack_dialog.dart'; +import '../../../widgets/stack_text_field.dart'; +import '../../../widgets/textfield_icon_button.dart'; +import '../../buy_view/sub_widgets/crypto_selection_view.dart'; class ExchangeCurrencySelectionView extends StatefulWidget { const ExchangeCurrencySelectionView({ - Key? key, + super.key, required this.willChangeTicker, required this.pairedTicker, required this.isFixedRate, required this.willChangeIsSend, - }) : super(key: key); + }); final String? willChangeTicker; final String? pairedTicker; @@ -143,7 +144,8 @@ class _ExchangeCurrencySelectionViewState onPressed: () async { Navigator.of(context, rootNavigator: isDesktop).pop(); _currencies = await _showUpdatingCurrencies( - whileFuture: _loadCurrencies()); + whileFuture: _loadCurrencies(), + ); setState(() {}); }, ), @@ -164,15 +166,17 @@ class _ExchangeCurrencySelectionViewState .filter() .isFiatEqualTo(false) .and() - .group((q) => widget.isFixedRate - ? q - .rateTypeEqualTo(SupportedRateType.both) - .or() - .rateTypeEqualTo(SupportedRateType.fixed) - : q - .rateTypeEqualTo(SupportedRateType.both) - .or() - .rateTypeEqualTo(SupportedRateType.estimated)) + .group( + (q) => widget.isFixedRate + ? q + .rateTypeEqualTo(SupportedRateType.both) + .or() + .rateTypeEqualTo(SupportedRateType.fixed) + : q + .rateTypeEqualTo(SupportedRateType.both) + .or() + .rateTypeEqualTo(SupportedRateType.estimated), + ) .sortByIsStackCoin() .thenByName() .findAll(); @@ -180,9 +184,10 @@ class _ExchangeCurrencySelectionViewState // If using Tor, filter exchanges which do not support Tor. if (Prefs.instance.useTor) { if (Exchange.exchangeNamesWithTorSupport.isNotEmpty) { - currencies.removeWhere((element) => !Exchange - .exchangeNamesWithTorSupport - .contains(element.exchangeName)); + currencies.removeWhere( + (element) => !Exchange.exchangeNamesWithTorSupport + .contains(element.exchangeName), + ); } } @@ -193,7 +198,8 @@ class _ExchangeCurrencySelectionViewState final List distinctCurrencies = []; for (final currency in currencies) { if (!distinctCurrencies.any( - (e) => e.ticker.toLowerCase() == currency.ticker.toLowerCase())) { + (e) => e.ticker.toLowerCase() == currency.ticker.toLowerCase(), + )) { distinctCurrencies.add(currency); } } @@ -207,23 +213,29 @@ class _ExchangeCurrencySelectionViewState } return _currencies - .where((e) => - e.name.toLowerCase().contains(text.toLowerCase()) || - e.ticker.toLowerCase().contains(text.toLowerCase())) + .where( + (e) => + e.name.toLowerCase().contains(text.toLowerCase()) || + e.ticker.toLowerCase().contains(text.toLowerCase()), + ) .toList(); } else { if (text.isEmpty) { return _currencies - .where((e) => - e.ticker.toLowerCase() != widget.pairedTicker!.toLowerCase()) + .where( + (e) => + e.ticker.toLowerCase() != widget.pairedTicker!.toLowerCase(), + ) .toList(); } return _currencies - .where((e) => - e.ticker.toLowerCase() != widget.pairedTicker!.toLowerCase() && - (e.name.toLowerCase().contains(text.toLowerCase()) || - e.ticker.toLowerCase().contains(text.toLowerCase()))) + .where( + (e) => + e.ticker.toLowerCase() != widget.pairedTicker!.toLowerCase() && + (e.name.toLowerCase().contains(text.toLowerCase()) || + e.ticker.toLowerCase().contains(text.toLowerCase())), + ) .toList(); } } @@ -266,7 +278,8 @@ class _ExchangeCurrencySelectionViewState if (FocusScope.of(context).hasFocus) { FocusScope.of(context).unfocus(); await Future.delayed( - const Duration(milliseconds: 50)); + const Duration(milliseconds: 50), + ); } if (mounted) { Navigator.of(context).pop(); @@ -353,18 +366,24 @@ class _ExchangeCurrencySelectionViewState Flexible( child: Builder( builder: (context) { - final coins = Coin.values.where((e) => - e.ticker.toLowerCase() != - widget.pairedTicker?.toLowerCase()); + final coins = AppConfig.coins.where( + (e) => + e.ticker.toLowerCase() != + widget.pairedTicker?.toLowerCase(), + ); final items = filter(_searchString); final walletCoins = items - .where((currency) => coins - .where((coin) => - coin.ticker.toLowerCase() == - currency.ticker.toLowerCase()) - .isNotEmpty) + .where( + (currency) => coins + .where( + (coin) => + coin.ticker.toLowerCase() == + currency.ticker.toLowerCase(), + ) + .isNotEmpty, + ) .toList(); // sort alphabetically by name @@ -400,25 +419,28 @@ class _ExchangeCurrencySelectionViewState SizedBox( width: 24, height: 24, - child: isStackCoin(items[index].ticker) - ? CoinIconForTicker( - ticker: items[index].ticker, size: 24) - // ? getIconForTicker( - // items[index].ticker, - // size: 24, - // ) - : hasImageUrl - ? SvgPicture.network( - items[index].image, - width: 24, - height: 24, - placeholderBuilder: (_) => - const LoadingIndicator(), + child: + AppConfig.isStackCoin(items[index].ticker) + ? CoinIconForTicker( + ticker: items[index].ticker, + size: 24, ) - : const SizedBox( - width: 24, - height: 24, - ), + // ? getIconForTicker( + // items[index].ticker, + // size: 24, + // ) + : hasImageUrl + ? SvgPicture.network( + items[index].image, + width: 24, + height: 24, + placeholderBuilder: (_) => + const LoadingIndicator(), + ) + : const SizedBox( + width: 24, + height: 24, + ), ), const SizedBox( width: 10, diff --git a/lib/pages/exchange_view/exchange_form.dart b/lib/pages/exchange_view/exchange_form.dart index a233a35c7..2783e9371 100644 --- a/lib/pages/exchange_view/exchange_form.dart +++ b/lib/pages/exchange_view/exchange_form.dart @@ -16,57 +16,58 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_svg/svg.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/exchange/aggregate_currency.dart'; -import 'package:stackwallet/models/exchange/incomplete_exchange.dart'; -import 'package:stackwallet/models/exchange/response_objects/estimate.dart'; -import 'package:stackwallet/models/exchange/response_objects/range.dart'; -import 'package:stackwallet/models/isar/exchange_cache/currency.dart'; -import 'package:stackwallet/models/isar/exchange_cache/pair.dart'; -import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart'; -import 'package:stackwallet/pages/exchange_view/exchange_coin_selection/exchange_currency_selection_view.dart'; -import 'package:stackwallet/pages/exchange_view/exchange_step_views/step_1_view.dart'; -import 'package:stackwallet/pages/exchange_view/exchange_step_views/step_2_view.dart'; -import 'package:stackwallet/pages/exchange_view/sub_widgets/exchange_provider_options.dart'; -import 'package:stackwallet/pages/exchange_view/sub_widgets/rate_type_toggle.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_exchange/exchange_steps/step_scaffold.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/services/exchange/change_now/change_now_exchange.dart'; -import 'package:stackwallet/services/exchange/exchange.dart'; -import 'package:stackwallet/services/exchange/exchange_data_loading_service.dart'; -import 'package:stackwallet/services/exchange/exchange_response.dart'; -import 'package:stackwallet/services/exchange/majestic_bank/majestic_bank_exchange.dart'; -import 'package:stackwallet/services/exchange/trocador/trocador_exchange.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount_unit.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/exchange_rate_type_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_loading_overlay.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; -import 'package:stackwallet/widgets/textfields/exchange_textfield.dart'; +import '../../models/exchange/aggregate_currency.dart'; +import '../../models/exchange/incomplete_exchange.dart'; +import '../../models/exchange/response_objects/estimate.dart'; +import '../../models/exchange/response_objects/range.dart'; +import '../../models/isar/exchange_cache/currency.dart'; +import '../../models/isar/exchange_cache/pair.dart'; +import '../../models/isar/models/ethereum/eth_contract.dart'; +import 'exchange_coin_selection/exchange_currency_selection_view.dart'; +import 'exchange_step_views/step_1_view.dart'; +import 'exchange_step_views/step_2_view.dart'; +import 'sub_widgets/exchange_provider_options.dart'; +import 'sub_widgets/rate_type_toggle.dart'; +import '../../pages_desktop_specific/desktop_exchange/exchange_steps/step_scaffold.dart'; +import '../../providers/providers.dart'; +import '../../services/exchange/change_now/change_now_exchange.dart'; +import '../../services/exchange/exchange.dart'; +import '../../services/exchange/exchange_data_loading_service.dart'; +import '../../services/exchange/exchange_response.dart'; +import '../../services/exchange/majestic_bank/majestic_bank_exchange.dart'; +import '../../services/exchange/trocador/trocador_exchange.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/amount/amount_unit.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/enums/exchange_rate_type_enum.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import '../../wallets/crypto_currency/coins/bitcoin.dart'; +import '../../wallets/crypto_currency/crypto_currency.dart'; +import '../../widgets/conditional_parent.dart'; +import '../../widgets/custom_loading_overlay.dart'; +import '../../widgets/desktop/desktop_dialog.dart'; +import '../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../widgets/desktop/primary_button.dart'; +import '../../widgets/desktop/secondary_button.dart'; +import '../../widgets/rounded_container.dart'; +import '../../widgets/rounded_white_container.dart'; +import '../../widgets/stack_dialog.dart'; +import '../../widgets/textfields/exchange_textfield.dart'; import 'package:tuple/tuple.dart'; import 'package:uuid/uuid.dart'; class ExchangeForm extends ConsumerStatefulWidget { const ExchangeForm({ - Key? key, + super.key, this.walletId, this.coin, this.contract, - }) : super(key: key); + }); final String? walletId; - final Coin? coin; + final CryptoCurrency? coin; final EthContract? contract; @override @@ -75,7 +76,7 @@ class ExchangeForm extends ConsumerStatefulWidget { class _ExchangeFormState extends ConsumerState { late final String? walletId; - late final Coin? coin; + late final CryptoCurrency? coin; late final bool walletInitiated; List get usableExchanges { @@ -172,7 +173,8 @@ class _ExchangeFormState extends ConsumerState { .tryParse( value, locale: ref.read(localeServiceChangeNotifierProvider).locale, - coin: Coin.bitcoin, // dummy value (not used due to override) + coin: Bitcoin(CryptoCurrencyNetwork + .main), // dummy value (not used due to override) overrideWithDecimalPlacesFromString: true, ) ?.decimal; @@ -607,12 +609,12 @@ class _ExchangeFormState extends ConsumerState { } } - bool isWalletCoin(Coin? coin, bool isSend) { + bool isWalletCoin(CryptoCurrency? coin, bool isSend) { if (coin == null) { return false; } - String? ticker = isSend + final String? ticker = isSend ? ref.read(efCurrencyPairProvider).send?.ticker : ref.read(efCurrencyPairProvider).receive?.ticker; diff --git a/lib/pages/exchange_view/exchange_loading_overlay.dart b/lib/pages/exchange_view/exchange_loading_overlay.dart index 022855a03..b73d22527 100644 --- a/lib/pages/exchange_view/exchange_loading_overlay.dart +++ b/lib/pages/exchange_view/exchange_loading_overlay.dart @@ -10,11 +10,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/providers/exchange/changenow_initial_load_status.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/custom_loading_overlay.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../providers/exchange/changenow_initial_load_status.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/text_styles.dart'; +import '../../widgets/custom_loading_overlay.dart'; +import '../../widgets/stack_dialog.dart'; class ExchangeLoadingOverlayView extends ConsumerStatefulWidget { const ExchangeLoadingOverlayView({ diff --git a/lib/pages/exchange_view/exchange_step_views/step_1_view.dart b/lib/pages/exchange_view/exchange_step_views/step_1_view.dart index 1795519b9..c02647f6e 100644 --- a/lib/pages/exchange_view/exchange_step_views/step_1_view.dart +++ b/lib/pages/exchange_view/exchange_step_views/step_1_view.dart @@ -9,16 +9,16 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/models/exchange/incomplete_exchange.dart'; -import 'package:stackwallet/pages/exchange_view/exchange_step_views/step_2_view.dart'; -import 'package:stackwallet/pages/exchange_view/sub_widgets/step_row.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/clipboard_interface.dart'; -import 'package:stackwallet/utilities/enums/exchange_rate_type_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../models/exchange/incomplete_exchange.dart'; +import 'step_2_view.dart'; +import '../sub_widgets/step_row.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/clipboard_interface.dart'; +import '../../../utilities/enums/exchange_rate_type_enum.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../widgets/background.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/rounded_white_container.dart'; class Step1View extends StatefulWidget { const Step1View({ diff --git a/lib/pages/exchange_view/exchange_step_views/step_2_view.dart b/lib/pages/exchange_view/exchange_step_views/step_2_view.dart index 95734e94c..6071c4556 100644 --- a/lib/pages/exchange_view/exchange_step_views/step_2_view.dart +++ b/lib/pages/exchange_view/exchange_step_views/step_2_view.dart @@ -11,33 +11,34 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/exchange/incomplete_exchange.dart'; -import 'package:stackwallet/pages/address_book_views/address_book_view.dart'; -import 'package:stackwallet/pages/address_book_views/subviews/contact_popup.dart'; -import 'package:stackwallet/pages/exchange_view/choose_from_stack_view.dart'; -import 'package:stackwallet/pages/exchange_view/exchange_step_views/step_3_view.dart'; -import 'package:stackwallet/pages/exchange_view/sub_widgets/step_row.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/services/exchange/majestic_bank/majestic_bank_exchange.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/address_utils.dart'; -import 'package:stackwallet/utilities/barcode_scanner_interface.dart'; -import 'package:stackwallet/utilities/clipboard_interface.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/addressbook_icon.dart'; -import 'package:stackwallet/widgets/icon_widgets/clipboard_icon.dart'; -import 'package:stackwallet/widgets/icon_widgets/qrcode_icon.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; + +import '../../../app_config.dart'; +import '../../../models/exchange/incomplete_exchange.dart'; +import '../../../providers/providers.dart'; +import '../../../services/exchange/majestic_bank/majestic_bank_exchange.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/address_utils.dart'; +import '../../../utilities/barcode_scanner_interface.dart'; +import '../../../utilities/clipboard_interface.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/logger.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../widgets/background.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/custom_buttons/blue_text_button.dart'; +import '../../../widgets/desktop/primary_button.dart'; +import '../../../widgets/icon_widgets/addressbook_icon.dart'; +import '../../../widgets/icon_widgets/clipboard_icon.dart'; +import '../../../widgets/icon_widgets/qrcode_icon.dart'; +import '../../../widgets/icon_widgets/x_icon.dart'; +import '../../../widgets/rounded_white_container.dart'; +import '../../../widgets/stack_text_field.dart'; +import '../../../widgets/textfield_icon_button.dart'; +import '../../address_book_views/address_book_view.dart'; +import '../../address_book_views/subviews/contact_popup.dart'; +import '../choose_from_stack_view.dart'; +import '../sub_widgets/step_row.dart'; +import 'step_3_view.dart'; class Step2View extends ConsumerStatefulWidget { const Step2View({ @@ -70,15 +71,6 @@ class _Step2ViewState extends ConsumerState { bool enableNext = false; - bool isStackCoin(String ticker) { - try { - coinFromTickerCaseInsensitive(ticker); - return true; - } on ArgumentError catch (_) { - return false; - } - } - @override void initState() { model = widget.model; @@ -202,15 +194,17 @@ class _Step2ViewState extends ConsumerState { "Recipient Wallet", style: STextStyles.smallMed12(context), ), - if (isStackCoin(model.receiveTicker)) + if (AppConfig.isStackCoin(model.receiveTicker)) CustomTextButton( text: "Choose from Stack", onTap: () { try { - final coin = - coinFromTickerCaseInsensitive( - model.receiveTicker, + final coin = AppConfig.coins.firstWhere( + (e) => + e.ticker.toLowerCase() == + model.receiveTicker.toLowerCase(), ); + Navigator.of(context) .pushNamed( ChooseFromStackView.routeName, @@ -256,7 +250,8 @@ class _Step2ViewState extends ConsumerState { child: TextField( onTap: () {}, key: const Key( - "recipientExchangeStep2ViewAddressFieldKey"), + "recipientExchangeStep2ViewAddressFieldKey", + ), controller: _toController, readOnly: false, autocorrect: false, @@ -303,7 +298,8 @@ class _Step2ViewState extends ConsumerState { _toController.text.isNotEmpty ? TextFieldIconButton( key: const Key( - "sendViewClearAddressFieldButtonKey"), + "sendViewClearAddressFieldButtonKey", + ), onTap: () { _toController.text = ""; model.recipientAddress = @@ -321,11 +317,13 @@ class _Step2ViewState extends ConsumerState { ) : TextFieldIconButton( key: const Key( - "sendViewPasteAddressFieldButtonKey"), + "sendViewPasteAddressFieldButtonKey", + ), onTap: () async { final ClipboardData? data = await clipboard.getData( - Clipboard.kTextPlain); + Clipboard.kTextPlain, + ); if (data?.text != null && data!.text!.isNotEmpty) { final content = @@ -355,12 +353,14 @@ class _Step2ViewState extends ConsumerState { if (_toController.text.isEmpty) TextFieldIconButton( key: const Key( - "sendViewAddressBookButtonKey"), + "sendViewAddressBookButtonKey", + ), onTap: () { ref .read( - exchangeFlowIsActiveStateProvider - .state) + exchangeFlowIsActiveStateProvider + .state, + ) .state = true; Navigator.of(context) .pushNamed( @@ -369,14 +369,16 @@ class _Step2ViewState extends ConsumerState { .then((_) { ref .read( - exchangeFlowIsActiveStateProvider - .state) + exchangeFlowIsActiveStateProvider + .state, + ) .state = false; final address = ref .read( - exchangeFromAddressBookAddressStateProvider - .state) + exchangeFromAddressBookAddressStateProvider + .state, + ) .state; if (address.isNotEmpty) { _toController.text = address; @@ -384,8 +386,9 @@ class _Step2ViewState extends ConsumerState { _toController.text; ref .read( - exchangeFromAddressBookAddressStateProvider - .state) + exchangeFromAddressBookAddressStateProvider + .state, + ) .state = ""; } setState(() { @@ -402,7 +405,8 @@ class _Step2ViewState extends ConsumerState { if (_toController.text.isEmpty) TextFieldIconButton( key: const Key( - "sendViewScanQrButtonKey"), + "sendViewScanQrButtonKey", + ), onTap: () async { try { final qrResult = @@ -410,7 +414,8 @@ class _Step2ViewState extends ConsumerState { final results = AddressUtils.parseUri( - qrResult.rawContent); + qrResult.rawContent, + ); if (results.isNotEmpty) { // auto fill address _toController.text = @@ -475,15 +480,17 @@ class _Step2ViewState extends ConsumerState { "Refund Wallet (required)", style: STextStyles.smallMed12(context), ), - if (isStackCoin(model.sendTicker)) + if (AppConfig.isStackCoin(model.sendTicker)) CustomTextButton( text: "Choose from Stack", onTap: () { try { - final coin = - coinFromTickerCaseInsensitive( - model.sendTicker, + final coin = AppConfig.coins.firstWhere( + (e) => + e.ticker.toLowerCase() == + model.sendTicker.toLowerCase(), ); + Navigator.of(context) .pushNamed( ChooseFromStackView.routeName, @@ -509,8 +516,10 @@ class _Step2ViewState extends ConsumerState { }); }); } catch (e, s) { - Logging.instance.log("$e\n$s", - level: LogLevel.Info); + Logging.instance.log( + "$e\n$s", + level: LogLevel.Info, + ); } }, ), @@ -527,7 +536,8 @@ class _Step2ViewState extends ConsumerState { ), child: TextField( key: const Key( - "refundExchangeStep2ViewAddressFieldKey"), + "refundExchangeStep2ViewAddressFieldKey", + ), controller: _refundController, readOnly: false, autocorrect: false, @@ -574,7 +584,8 @@ class _Step2ViewState extends ConsumerState { _refundController.text.isNotEmpty ? TextFieldIconButton( key: const Key( - "sendViewClearAddressFieldButtonKey"), + "sendViewClearAddressFieldButtonKey", + ), onTap: () { _refundController.text = ""; model.refundAddress = @@ -592,12 +603,13 @@ class _Step2ViewState extends ConsumerState { ) : TextFieldIconButton( key: const Key( - "sendViewPasteAddressFieldButtonKey"), + "sendViewPasteAddressFieldButtonKey", + ), onTap: () async { final ClipboardData? data = await clipboard.getData( - Clipboard - .kTextPlain); + Clipboard.kTextPlain, + ); if (data?.text != null && data! .text!.isNotEmpty) { @@ -628,12 +640,14 @@ class _Step2ViewState extends ConsumerState { if (_refundController.text.isEmpty) TextFieldIconButton( key: const Key( - "sendViewAddressBookButtonKey"), + "sendViewAddressBookButtonKey", + ), onTap: () { ref .read( - exchangeFlowIsActiveStateProvider - .state) + exchangeFlowIsActiveStateProvider + .state, + ) .state = true; Navigator.of(context) .pushNamed( @@ -642,13 +656,15 @@ class _Step2ViewState extends ConsumerState { .then((_) { ref .read( - exchangeFlowIsActiveStateProvider - .state) + exchangeFlowIsActiveStateProvider + .state, + ) .state = false; final address = ref .read( - exchangeFromAddressBookAddressStateProvider - .state) + exchangeFromAddressBookAddressStateProvider + .state, + ) .state; if (address.isNotEmpty) { _refundController.text = @@ -669,7 +685,8 @@ class _Step2ViewState extends ConsumerState { if (_refundController.text.isEmpty) TextFieldIconButton( key: const Key( - "sendViewScanQrButtonKey"), + "sendViewScanQrButtonKey", + ), onTap: () async { try { final qrResult = @@ -677,7 +694,8 @@ class _Step2ViewState extends ConsumerState { final results = AddressUtils.parseUri( - qrResult.rawContent); + qrResult.rawContent, + ); if (results.isNotEmpty) { // auto fill address _refundController.text = diff --git a/lib/pages/exchange_view/exchange_step_views/step_3_view.dart b/lib/pages/exchange_view/exchange_step_views/step_3_view.dart index 318a5c0e4..2e6b2b237 100644 --- a/lib/pages/exchange_view/exchange_step_views/step_3_view.dart +++ b/lib/pages/exchange_view/exchange_step_views/step_3_view.dart @@ -12,25 +12,25 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/exchange/incomplete_exchange.dart'; -import 'package:stackwallet/models/exchange/response_objects/trade.dart'; -import 'package:stackwallet/pages/exchange_view/exchange_step_views/step_4_view.dart'; -import 'package:stackwallet/pages/exchange_view/sub_widgets/step_row.dart'; -import 'package:stackwallet/providers/global/trades_service_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/services/exchange/exchange_response.dart'; -import 'package:stackwallet/services/exchange/majestic_bank/majestic_bank_exchange.dart'; -import 'package:stackwallet/services/notifications_api.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/clipboard_interface.dart'; -import 'package:stackwallet/utilities/enums/exchange_rate_type_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_loading_overlay.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../../models/exchange/incomplete_exchange.dart'; +import '../../../models/exchange/response_objects/trade.dart'; +import 'step_4_view.dart'; +import '../sub_widgets/step_row.dart'; +import '../../../providers/global/trades_service_provider.dart'; +import '../../../providers/providers.dart'; +import '../../../services/exchange/exchange_response.dart'; +import '../../../services/exchange/majestic_bank/majestic_bank_exchange.dart'; +import '../../../services/notifications_api.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/clipboard_interface.dart'; +import '../../../utilities/enums/exchange_rate_type_enum.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../widgets/background.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/custom_loading_overlay.dart'; +import '../../../widgets/rounded_white_container.dart'; +import '../../../widgets/stack_dialog.dart'; class Step3View extends ConsumerStatefulWidget { const Step3View({ diff --git a/lib/pages/exchange_view/exchange_step_views/step_4_view.dart b/lib/pages/exchange_view/exchange_step_views/step_4_view.dart index 8fa0eedc6..3d0730ee4 100644 --- a/lib/pages/exchange_view/exchange_step_views/step_4_view.dart +++ b/lib/pages/exchange_view/exchange_step_views/step_4_view.dart @@ -15,34 +15,35 @@ import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:qr_flutter/qr_flutter.dart'; -import 'package:stackwallet/models/exchange/incomplete_exchange.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/exchange_view/confirm_change_now_send.dart'; -import 'package:stackwallet/pages/exchange_view/send_from_view.dart'; -import 'package:stackwallet/pages/exchange_view/sub_widgets/step_row.dart'; -import 'package:stackwallet/pages/home_view/home_view.dart'; -import 'package:stackwallet/pages/send_view/sub_widgets/building_transaction_dialog.dart'; -import 'package:stackwallet/pages/wallet_view/wallet_view.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/route_generator.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/clipboard_interface.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/wallets/models/tx_data.dart'; -import 'package:stackwallet/wallets/wallet/impl/firo_wallet.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../../app_config.dart'; +import '../../../models/exchange/incomplete_exchange.dart'; +import '../../../notifications/show_flush_bar.dart'; +import '../confirm_change_now_send.dart'; +import '../send_from_view.dart'; +import '../sub_widgets/step_row.dart'; +import '../../home_view/home_view.dart'; +import '../../send_view/sub_widgets/building_transaction_dialog.dart'; +import '../../wallet_view/wallet_view.dart'; +import '../../../providers/providers.dart'; +import '../../../route_generator.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/amount/amount_formatter.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/clipboard_interface.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/enums/fee_rate_type_enum.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../wallets/models/tx_data.dart'; +import '../../../wallets/wallet/impl/firo_wallet.dart'; +import '../../../widgets/background.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/desktop/secondary_button.dart'; +import '../../../widgets/rounded_container.dart'; +import '../../../widgets/rounded_white_container.dart'; +import '../../../widgets/stack_dialog.dart'; import 'package:tuple/tuple.dart'; class Step4View extends ConsumerStatefulWidget { @@ -71,7 +72,7 @@ class _Step4ViewState extends ConsumerState { bool _isWalletCoinAndHasWallet(String ticker, WidgetRef ref) { try { - final coin = coinFromTickerCaseInsensitive(ticker); + final coin = AppConfig.getCryptoCurrencyForTicker(ticker); return ref .read(pWallets) .wallets @@ -193,9 +194,9 @@ class _Step4ViewState extends ConsumerState { ); } - Future _confirmSend(Tuple2 tuple) async { + Future _confirmSend(Tuple2 tuple) async { final bool firoPublicSend; - if (tuple.item2 == Coin.firo) { + if (tuple.item2 is Firo) { final result = await _showSendFromFiroBalanceSelectSheet(tuple.item1); if (result == null) { return; @@ -209,7 +210,7 @@ class _Step4ViewState extends ConsumerState { final wallet = ref.read(pWallets).getWallet(tuple.item1); final Amount amount = model.sendAmount.toAmount( - fractionDigits: wallet.info.coin.decimals, + fractionDigits: wallet.info.coin.fractionDigits, ); final address = model.trade!.payInAddress; @@ -257,8 +258,7 @@ class _Step4ViewState extends ConsumerState { ), ); } else { - final memo = wallet.info.coin == Coin.stellar || - wallet.info.coin == Coin.stellarTestnet + final memo = wallet.info.coin is Stellar ? model.trade!.payInExtraId.isNotEmpty ? model.trade!.payInExtraId : null @@ -815,7 +815,8 @@ class _Step4ViewState extends ConsumerState { if (isWalletCoin) Builder( builder: (context) { - String buttonTitle = "Send from Stack Wallet"; + String buttonTitle = + "Send from {$AppConfig.appName}"; final tuple = ref .read( @@ -849,16 +850,22 @@ class _Step4ViewState extends ConsumerState { .useMaterialPageRoute, builder: (BuildContext context) { - final coin = - coinFromTickerCaseInsensitive( - model.trade!.payInCurrency, + final coin = AppConfig.coins + .firstWhere( + (e) => + e.ticker + .toLowerCase() == + model.trade! + .payInCurrency + .toLowerCase(), ); + return SendFromView( coin: coin, amount: model.sendAmount .toAmount( fractionDigits: - coin.decimals, + coin.fractionDigits, ), address: model .trade!.payInAddress, diff --git a/lib/pages/exchange_view/exchange_view.dart b/lib/pages/exchange_view/exchange_view.dart index e13f97a8e..b5fe193bd 100644 --- a/lib/pages/exchange_view/exchange_view.dart +++ b/lib/pages/exchange_view/exchange_view.dart @@ -13,19 +13,19 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/db/isar/main_db.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; -import 'package:stackwallet/pages/exchange_view/exchange_form.dart'; -import 'package:stackwallet/pages/exchange_view/trade_details_view.dart'; -import 'package:stackwallet/providers/global/trades_service_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/services/exchange/exchange_data_loading_service.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_loading_overlay.dart'; -import 'package:stackwallet/widgets/trade_card.dart'; +import '../../db/isar/main_db.dart'; +import '../../models/isar/models/blockchain_data/transaction.dart'; +import 'exchange_form.dart'; +import 'trade_details_view.dart'; +import '../../providers/global/trades_service_provider.dart'; +import '../../providers/providers.dart'; +import '../../services/exchange/exchange_data_loading_service.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/text_styles.dart'; +import '../../widgets/conditional_parent.dart'; +import '../../widgets/custom_loading_overlay.dart'; +import '../../widgets/trade_card.dart'; import 'package:tuple/tuple.dart'; class ExchangeView extends ConsumerStatefulWidget { diff --git a/lib/pages/exchange_view/send_from_view.dart b/lib/pages/exchange_view/send_from_view.dart index a97b94a28..bf7e18df2 100644 --- a/lib/pages/exchange_view/send_from_view.dart +++ b/lib/pages/exchange_view/send_from_view.dart @@ -14,34 +14,37 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/models/exchange/response_objects/trade.dart'; -import 'package:stackwallet/pages/exchange_view/confirm_change_now_send.dart'; -import 'package:stackwallet/pages/home_view/home_view.dart'; -import 'package:stackwallet/pages/send_view/sub_widgets/building_transaction_dialog.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_exchange/desktop_exchange_view.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/route_generator.dart'; -import 'package:stackwallet/themes/coin_icon_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/wallets/models/tx_data.dart'; -import 'package:stackwallet/wallets/wallet/impl/firo_wallet.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/expandable.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../models/exchange/response_objects/trade.dart'; +import 'confirm_change_now_send.dart'; +import '../home_view/home_view.dart'; +import '../send_view/sub_widgets/building_transaction_dialog.dart'; +import '../../pages_desktop_specific/desktop_exchange/desktop_exchange_view.dart'; +import '../../providers/providers.dart'; +import '../../route_generator.dart'; +import '../../themes/coin_icon_provider.dart'; +import '../../themes/stack_colors.dart'; +import '../../themes/theme_providers.dart'; +import '../../utilities/amount/amount.dart'; +import '../../utilities/amount/amount_formatter.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/enums/fee_rate_type_enum.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import '../../wallets/crypto_currency/coins/firo.dart'; +import '../../wallets/crypto_currency/coins/stellar.dart'; +import '../../wallets/crypto_currency/crypto_currency.dart'; +import '../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../wallets/models/tx_data.dart'; +import '../../wallets/wallet/impl/firo_wallet.dart'; +import '../../widgets/background.dart'; +import '../../widgets/conditional_parent.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/desktop/desktop_dialog.dart'; +import '../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../widgets/expandable.dart'; +import '../../widgets/rounded_white_container.dart'; +import '../../widgets/stack_dialog.dart'; class SendFromView extends ConsumerStatefulWidget { const SendFromView({ @@ -56,7 +59,7 @@ class SendFromView extends ConsumerStatefulWidget { static const String routeName = "/sendFrom"; - final Coin coin; + final CryptoCurrency coin; final Amount amount; final String address; final Trade trade; @@ -68,7 +71,7 @@ class SendFromView extends ConsumerStatefulWidget { } class _SendFromViewState extends ConsumerState { - late final Coin coin; + late final CryptoCurrency coin; late final Amount amount; late final String address; late final Trade trade; @@ -279,7 +282,7 @@ class _SendFromCardState extends ConsumerState { // if not firo then do normal send if (shouldSendPublicFiroFunds == null) { - final memo = coin == Coin.stellar || coin == Coin.stellarTestnet + final memo = coin is Stellar ? trade.payInExtraId.isNotEmpty ? trade.payInExtraId : null @@ -427,7 +430,7 @@ class _SendFromCardState extends ConsumerState { final coin = ref.watch(pWalletCoin(walletId)); - final isFiro = coin == Coin.firoTestNet || coin == Coin.firo; + final isFiro = coin is Firo; return RoundedWhiteContainer( padding: const EdgeInsets.all(0), @@ -602,10 +605,7 @@ class _SendFromCardState extends ConsumerState { children: [ Container( decoration: BoxDecoration( - color: Theme.of(context) - .extension()! - .colorForCoin(coin) - .withOpacity(0.5), + color: ref.watch(pCoinColor(coin)).withOpacity(0.5), borderRadius: BorderRadius.circular( Constants.size.circularBorderRadius, ), diff --git a/lib/pages/exchange_view/sub_widgets/exchange_provider_option.dart b/lib/pages/exchange_view/sub_widgets/exchange_provider_option.dart index e891f148e..29cbd7f7f 100644 --- a/lib/pages/exchange_view/sub_widgets/exchange_provider_option.dart +++ b/lib/pages/exchange_view/sub_widgets/exchange_provider_option.dart @@ -12,32 +12,34 @@ import 'package:decimal/decimal.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/models/exchange/response_objects/estimate.dart'; -import 'package:stackwallet/providers/exchange/exchange_form_state_provider.dart'; -import 'package:stackwallet/providers/global/locale_provider.dart'; -import 'package:stackwallet/services/exchange/exchange.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/amount/amount_unit.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/exchange_rate_type_enum.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/animated_text.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/exchange/trocador/trocador_kyc_info_button.dart'; -import 'package:stackwallet/widgets/exchange/trocador/trocador_rating_type_enum.dart'; + +import '../../../app_config.dart'; +import '../../../models/exchange/response_objects/estimate.dart'; +import '../../../providers/exchange/exchange_form_state_provider.dart'; +import '../../../providers/global/locale_provider.dart'; +import '../../../services/exchange/exchange.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/amount/amount_formatter.dart'; +import '../../../utilities/amount/amount_unit.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/enums/exchange_rate_type_enum.dart'; +import '../../../utilities/logger.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../widgets/animated_text.dart'; +import '../../../widgets/conditional_parent.dart'; +import '../../../widgets/exchange/trocador/trocador_kyc_info_button.dart'; +import '../../../widgets/exchange/trocador/trocador_rating_type_enum.dart'; class ExchangeOption extends ConsumerStatefulWidget { const ExchangeOption({ - Key? key, + super.key, required this.exchange, required this.fixedRate, required this.reversed, - }) : super(key: key); + }); final Exchange exchange; final bool fixedRate; @@ -92,9 +94,10 @@ class _ExchangeOptionState extends ConsumerState { int decimals; try { - decimals = coinFromTickerCaseInsensitive( - receivingCurrency.ticker) - .decimals; + decimals = AppConfig.getCryptoCurrencyForTicker( + receivingCurrency.ticker, + )! + .fractionDigits; } catch (_) { decimals = 8; // some reasonable alternative } @@ -109,10 +112,11 @@ class _ExchangeOptionState extends ConsumerState { .toAmount(fractionDigits: decimals); } - Coin? coin; + CryptoCurrency? coin; try { - coin = coinFromTickerCaseInsensitive( - receivingCurrency.ticker); + coin = AppConfig.getCryptoCurrencyForTicker( + receivingCurrency.ticker, + ); } catch (_) { coin = null; } @@ -128,7 +132,8 @@ class _ExchangeOptionState extends ConsumerState { localeServiceChangeNotifierProvider .select((value) => value.locale), ), - coin: Coin.bitcoin, // some sane default + coin: Bitcoin(CryptoCurrencyNetwork + .main), // some sane default maxDecimals: 8, // some sane default ); rateString = "1 ${sendCurrency.ticker.toUpperCase()} " diff --git a/lib/pages/exchange_view/sub_widgets/exchange_provider_options.dart b/lib/pages/exchange_view/sub_widgets/exchange_provider_options.dart index 6f0108f66..dd6afa8ed 100644 --- a/lib/pages/exchange_view/sub_widgets/exchange_provider_options.dart +++ b/lib/pages/exchange_view/sub_widgets/exchange_provider_options.dart @@ -10,17 +10,17 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/exchange/aggregate_currency.dart'; -import 'package:stackwallet/pages/exchange_view/sub_widgets/exchange_provider_option.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/services/exchange/change_now/change_now_exchange.dart'; -import 'package:stackwallet/services/exchange/exchange.dart'; -import 'package:stackwallet/services/exchange/majestic_bank/majestic_bank_exchange.dart'; -import 'package:stackwallet/services/exchange/trocador/trocador_exchange.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/prefs.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../models/exchange/aggregate_currency.dart'; +import 'exchange_provider_option.dart'; +import '../../../providers/providers.dart'; +import '../../../services/exchange/change_now/change_now_exchange.dart'; +import '../../../services/exchange/exchange.dart'; +import '../../../services/exchange/majestic_bank/majestic_bank_exchange.dart'; +import '../../../services/exchange/trocador/trocador_exchange.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/prefs.dart'; +import '../../../utilities/util.dart'; +import '../../../widgets/rounded_white_container.dart'; class ExchangeProviderOptions extends ConsumerStatefulWidget { const ExchangeProviderOptions({ diff --git a/lib/pages/exchange_view/sub_widgets/rate_type_toggle.dart b/lib/pages/exchange_view/sub_widgets/rate_type_toggle.dart index e98ed3b37..6840fa139 100644 --- a/lib/pages/exchange_view/sub_widgets/rate_type_toggle.dart +++ b/lib/pages/exchange_view/sub_widgets/rate_type_toggle.dart @@ -10,13 +10,13 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/exchange_rate_type_enum.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/toggle.dart'; +import '../../../providers/providers.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/enums/exchange_rate_type_enum.dart'; +import '../../../utilities/util.dart'; +import '../../../widgets/toggle.dart'; class RateTypeToggle extends ConsumerWidget { const RateTypeToggle({ diff --git a/lib/pages/exchange_view/sub_widgets/step_indicator.dart b/lib/pages/exchange_view/sub_widgets/step_indicator.dart index 3fedfc459..d1d440190 100644 --- a/lib/pages/exchange_view/sub_widgets/step_indicator.dart +++ b/lib/pages/exchange_view/sub_widgets/step_indicator.dart @@ -10,9 +10,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/text_styles.dart'; enum StepIndicatorStatus { current, completed, incomplete } diff --git a/lib/pages/exchange_view/sub_widgets/step_row.dart b/lib/pages/exchange_view/sub_widgets/step_row.dart index 6dc6a4db4..95a8f4a17 100644 --- a/lib/pages/exchange_view/sub_widgets/step_row.dart +++ b/lib/pages/exchange_view/sub_widgets/step_row.dart @@ -9,8 +9,8 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/pages/exchange_view/sub_widgets/step_indicator.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; +import 'step_indicator.dart'; +import '../../../themes/stack_colors.dart'; class StepRow extends StatelessWidget { const StepRow({ diff --git a/lib/pages/exchange_view/trade_details_view.dart b/lib/pages/exchange_view/trade_details_view.dart index ab3aa0b1f..68a75704a 100644 --- a/lib/pages/exchange_view/trade_details_view.dart +++ b/lib/pages/exchange_view/trade_details_view.dart @@ -17,54 +17,56 @@ import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:qr_flutter/qr_flutter.dart'; -import 'package:stackwallet/models/exchange/change_now/exchange_transaction_status.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; -import 'package:stackwallet/models/isar/stack_theme.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/exchange_view/edit_trade_note_view.dart'; -import 'package:stackwallet/pages/exchange_view/send_from_view.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/edit_note_view.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart'; -import 'package:stackwallet/providers/global/trades_service_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/route_generator.dart'; -import 'package:stackwallet/services/exchange/change_now/change_now_exchange.dart'; -import 'package:stackwallet/services/exchange/exchange.dart'; -import 'package:stackwallet/services/exchange/majestic_bank/majestic_bank_exchange.dart'; -import 'package:stackwallet/services/exchange/simpleswap/simpleswap_exchange.dart'; -import 'package:stackwallet/services/exchange/trocador/trocador_exchange.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/clipboard_interface.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/format.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; import 'package:tuple/tuple.dart'; import 'package:url_launcher/url_launcher.dart'; +import '../../app_config.dart'; +import '../../models/exchange/change_now/exchange_transaction_status.dart'; +import '../../models/isar/models/blockchain_data/transaction.dart'; +import '../../models/isar/stack_theme.dart'; +import '../../notifications/show_flush_bar.dart'; +import '../../providers/global/trades_service_provider.dart'; +import '../../providers/providers.dart'; +import '../../route_generator.dart'; +import '../../services/exchange/change_now/change_now_exchange.dart'; +import '../../services/exchange/exchange.dart'; +import '../../services/exchange/majestic_bank/majestic_bank_exchange.dart'; +import '../../services/exchange/simpleswap/simpleswap_exchange.dart'; +import '../../services/exchange/trocador/trocador_exchange.dart'; +import '../../themes/stack_colors.dart'; +import '../../themes/theme_providers.dart'; +import '../../utilities/amount/amount.dart'; +import '../../utilities/amount/amount_formatter.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/clipboard_interface.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/format.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import '../../wallets/crypto_currency/crypto_currency.dart'; +import '../../widgets/background.dart'; +import '../../widgets/conditional_parent.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/custom_buttons/blue_text_button.dart'; +import '../../widgets/desktop/desktop_dialog.dart'; +import '../../widgets/desktop/secondary_button.dart'; +import '../../widgets/rounded_container.dart'; +import '../../widgets/rounded_white_container.dart'; +import '../../widgets/stack_dialog.dart'; +import '../wallet_view/transaction_views/edit_note_view.dart'; +import '../wallet_view/transaction_views/transaction_details_view.dart'; +import 'edit_trade_note_view.dart'; +import 'send_from_view.dart'; + class TradeDetailsView extends ConsumerStatefulWidget { const TradeDetailsView({ - Key? key, + super.key, required this.tradeId, required this.transactionIfSentFromStack, required this.walletId, required this.walletName, this.clipboard = const ClipboardWrapper(), - }) : super(key: key); + }); static const String routeName = "/tradeDetails"; @@ -84,18 +86,6 @@ class _TradeDetailsViewState extends ConsumerState { late final Transaction? transactionIfSentFromStack; late final String? walletId; - bool isStackCoin(String ticker) { - try { - try { - coinFromTickerCaseInsensitive(ticker); - } catch (_) {} - coinFromPrettyName(ticker); - return true; - } on ArgumentError catch (_) { - return false; - } - } - @override initState() { tradeId = widget.tradeId; @@ -167,8 +157,11 @@ class _TradeDetailsViewState extends ConsumerState { final bool sentFromStack = transactionIfSentFromStack != null && walletId != null; - final trade = ref.watch(tradesServiceProvider.select( - (value) => value.trades.firstWhere((e) => e.tradeId == tradeId))); + final trade = ref.watch( + tradesServiceProvider.select( + (value) => value.trades.firstWhere((e) => e.tradeId == tradeId), + ), + ); final bool hasTx = sentFromStack || !(trade.status == "New" || @@ -255,7 +248,7 @@ class _TradeDetailsViewState extends ConsumerState { ), ), if (!hasTx && - isStackCoin(trade.payInCurrency) && + AppConfig.isStackCoin(trade.payInCurrency) && (trade.status == "New" || trade.status == "new" || trade.status == "waiting" || @@ -264,7 +257,7 @@ class _TradeDetailsViewState extends ConsumerState { height: 32, ), if (!hasTx && - isStackCoin(trade.payInCurrency) && + AppConfig.isStackCoin(trade.payInCurrency) && (trade.status == "New" || trade.status == "new" || trade.status == "waiting" || @@ -273,16 +266,19 @@ class _TradeDetailsViewState extends ConsumerState { label: "Send from Stack", buttonHeight: ButtonHeight.l, onPressed: () { - Coin coin; + CryptoCurrency coin; try { - coin = coinFromTickerCaseInsensitive( - trade.payInCurrency); + coin = AppConfig.getCryptoCurrencyForTicker( + trade.payInCurrency, + )!; } catch (_) { - coin = coinFromPrettyName(trade.payInCurrency); + coin = AppConfig.getCryptoCurrencyByPrettyName( + trade.payInCurrency, + ); } final amount = Amount.fromDecimal( sendAmount, - fractionDigits: coin.decimals, + fractionDigits: coin.fractionDigits, ); final address = trade.payInAddress; @@ -368,28 +364,34 @@ class _TradeDetailsViewState extends ConsumerState { const SizedBox( height: 4, ), - Builder(builder: (context) { - String text; - try { - final coin = coinFromTickerCaseInsensitive( - trade.payInCurrency); - final amount = sendAmount.toAmount( - fractionDigits: coin.decimals); - text = ref - .watch(pAmountFormatter(coin)) - .format(amount); - } catch (_) { - text = sendAmount.toStringAsFixed( + Builder( + builder: (context) { + String text; + try { + final coin = + AppConfig.getCryptoCurrencyForTicker( + trade.payInCurrency, + )!; + final amount = sendAmount.toAmount( + fractionDigits: coin.fractionDigits, + ); + text = ref + .watch(pAmountFormatter(coin)) + .format(amount); + } catch (_) { + text = sendAmount.toStringAsFixed( trade.payInCurrency.toLowerCase() == "xmr" ? 12 - : 8); - } + : 8, + ); + } - return SelectableText( - "-$text ${trade.payInCurrency.toUpperCase()}", - style: STextStyles.itemSubtitle(context), - ); - }), + return SelectableText( + "-$text ${trade.payInCurrency.toUpperCase()}", + style: STextStyles.itemSubtitle(context), + ); + }, + ), ], ), if (!isDesktop) @@ -464,7 +466,7 @@ class _TradeDetailsViewState extends ConsumerState { ), ), ], - ) + ), ], ), const SizedBox( @@ -512,7 +514,8 @@ class _TradeDetailsViewState extends ConsumerState { Text( "Amount", style: STextStyles.desktopTextExtraExtraSmall( - context), + context, + ), ), const SizedBox( height: 2, @@ -520,8 +523,8 @@ class _TradeDetailsViewState extends ConsumerState { Text( "${trade.payInAmount} ${trade.payInCurrency.toUpperCase()}", style: STextStyles.desktopTextExtraExtraSmall( - context) - .copyWith( + context, + ).copyWith( color: Theme.of(context) .extension()! .textDark, @@ -542,43 +545,44 @@ class _TradeDetailsViewState extends ConsumerState { ), child: RichText( text: TextSpan( - text: - "You must send at least ${sendAmount.toStringAsFixed( - trade.payInCurrency.toLowerCase() == "xmr" ? 12 : 8, - )} ${trade.payInCurrency.toUpperCase()}. ", - style: isDesktop - ? STextStyles.desktopTextExtraExtraSmall(context) - .copyWith( - color: Theme.of(context) - .extension()! - .accentColorRed) - : STextStyles.label(context).copyWith( - color: Theme.of(context) - .extension()! - .warningForeground, - ), - children: [ - TextSpan( - text: - "If you send less than ${sendAmount.toStringAsFixed( - trade.payInCurrency.toLowerCase() == "xmr" - ? 12 - : 8, - )} ${trade.payInCurrency.toUpperCase()}, your transaction may not be converted and it may not be refunded.", - style: isDesktop - ? STextStyles.desktopTextExtraExtraSmall( - context) - .copyWith( - color: Theme.of(context) - .extension()! - .accentColorRed) - : STextStyles.label(context).copyWith( - color: Theme.of(context) - .extension()! - .warningForeground, - ), - ), - ]), + text: + "You must send at least ${sendAmount.toStringAsFixed( + trade.payInCurrency.toLowerCase() == "xmr" ? 12 : 8, + )} ${trade.payInCurrency.toUpperCase()}. ", + style: isDesktop + ? STextStyles.desktopTextExtraExtraSmall(context) + .copyWith( + color: Theme.of(context) + .extension()! + .accentColorRed, + ) + : STextStyles.label(context).copyWith( + color: Theme.of(context) + .extension()! + .warningForeground, + ), + children: [ + TextSpan( + text: + "If you send less than ${sendAmount.toStringAsFixed( + trade.payInCurrency.toLowerCase() == "xmr" ? 12 : 8, + )} ${trade.payInCurrency.toUpperCase()}, your transaction may not be converted and it may not be refunded.", + style: isDesktop + ? STextStyles.desktopTextExtraExtraSmall( + context, + ).copyWith( + color: Theme.of(context) + .extension()! + .accentColorRed, + ) + : STextStyles.label(context).copyWith( + color: Theme.of(context) + .extension()! + .warningForeground, + ), + ), + ], + ), ), ), ), @@ -613,8 +617,9 @@ class _TradeDetailsViewState extends ConsumerState { CustomTextButton( text: "View transaction", onTap: () { - final Coin coin = - coinFromTickerCaseInsensitive(trade.payInCurrency); + final coin = AppConfig.getCryptoCurrencyForTicker( + trade.payInCurrency, + )!; if (isDesktop) { Navigator.of(context).push( @@ -638,7 +643,10 @@ class _TradeDetailsViewState extends ConsumerState { Navigator.of(context).pushNamed( TransactionDetailsView.routeName, arguments: Tuple3( - transactionIfSentFromStack!, coin, walletId!), + transactionIfSentFromStack!, + coin, + walletId!, + ), ); } }, @@ -717,7 +725,7 @@ class _TradeDetailsViewState extends ConsumerState { text: address, ), ); - if (mounted) { + if (context.mounted) { unawaited( showFloatingFlushBar( type: FlushBarType.info, @@ -787,14 +795,15 @@ class _TradeDetailsViewState extends ConsumerState { width: width + 20, height: width + 20, child: QrImageView( - data: trade.payInAddress, - size: width, - backgroundColor: Theme.of(context) - .extension()! - .popupBG, - foregroundColor: Theme.of(context) - .extension()! - .accentColorDark), + data: trade.payInAddress, + size: width, + backgroundColor: Theme.of(context) + .extension()! + .popupBG, + foregroundColor: Theme.of(context) + .extension()! + .accentColorDark, + ), ), ), ), @@ -812,14 +821,16 @@ class _TradeDetailsViewState extends ConsumerState { style: Theme.of(context) .extension()! .getSecondaryEnabledButtonStyle( - context), + context, + ), child: Text( "Cancel", style: STextStyles.button(context) .copyWith( - color: Theme.of(context) - .extension()! - .accentColorDark), + color: Theme.of(context) + .extension()! + .accentColorDark, + ), ), ), ), @@ -885,7 +896,7 @@ class _TradeDetailsViewState extends ConsumerState { text: address, ), ); - if (mounted) { + if (context.mounted) { unawaited( showFloatingFlushBar( type: FlushBarType.info, @@ -1005,8 +1016,10 @@ class _TradeDetailsViewState extends ConsumerState { height: 4, ), SelectableText( - ref.watch(tradeNoteServiceProvider - .select((value) => value.getNote(tradeId: tradeId))), + ref.watch( + tradeNoteServiceProvider + .select((value) => value.getNote(tradeId: tradeId)), + ), style: STextStyles.itemSubtitle12(context), ), ], @@ -1132,7 +1145,8 @@ class _TradeDetailsViewState extends ConsumerState { if (isDesktop) SelectableText( Format.extractDateFrom( - trade.timestamp.millisecondsSinceEpoch ~/ 1000), + trade.timestamp.millisecondsSinceEpoch ~/ 1000, + ), style: STextStyles.desktopTextExtraExtraSmall(context) .copyWith( color: Theme.of(context) @@ -1145,13 +1159,15 @@ class _TradeDetailsViewState extends ConsumerState { if (!isDesktop) SelectableText( Format.extractDateFrom( - trade.timestamp.millisecondsSinceEpoch ~/ 1000), + trade.timestamp.millisecondsSinceEpoch ~/ 1000, + ), style: STextStyles.itemSubtitle12(context), ), if (isDesktop) IconCopyButton( data: Format.extractDateFrom( - trade.timestamp.millisecondsSinceEpoch ~/ 1000), + trade.timestamp.millisecondsSinceEpoch ~/ 1000, + ), ), ], ), @@ -1248,7 +1264,7 @@ class _TradeDetailsViewState extends ConsumerState { onTap: () async { final data = ClipboardData(text: trade.tradeId); await clipboard.setData(data); - if (mounted) { + if (context.mounted) { unawaited( showFloatingFlushBar( type: FlushBarType.info, @@ -1265,7 +1281,7 @@ class _TradeDetailsViewState extends ConsumerState { .infoItemIcons, width: 12, ), - ) + ), ], ), ], @@ -1344,7 +1360,7 @@ class _TradeDetailsViewState extends ConsumerState { ), if (!isDesktop && !hasTx && - isStackCoin(trade.payInCurrency) && + AppConfig.isStackCoin(trade.payInCurrency) && (trade.status == "New" || trade.status == "new" || trade.status == "waiting" || @@ -1352,15 +1368,19 @@ class _TradeDetailsViewState extends ConsumerState { SecondaryButton( label: "Send from Stack", onPressed: () { - Coin coin; + CryptoCurrency coin; try { - coin = coinFromTickerCaseInsensitive(trade.payInCurrency); + coin = AppConfig.getCryptoCurrencyForTicker( + trade.payInCurrency, + )!; } catch (_) { - coin = coinFromPrettyName(trade.payInCurrency); + coin = AppConfig.getCryptoCurrencyByPrettyName( + trade.payInCurrency, + ); } final amount = Amount.fromDecimal( sendAmount, - fractionDigits: coin.decimals, + fractionDigits: coin.fractionDigits, ); final address = trade.payInAddress; @@ -1383,7 +1403,7 @@ class _TradeDetailsViewState extends ConsumerState { } class _Divider extends StatelessWidget { - const _Divider({Key? key}) : super(key: key); + const _Divider({super.key}); @override Widget build(BuildContext context) { diff --git a/lib/pages/exchange_view/wallet_initiated_exchange_view.dart b/lib/pages/exchange_view/wallet_initiated_exchange_view.dart index 3b6c41093..ac81190bf 100644 --- a/lib/pages/exchange_view/wallet_initiated_exchange_view.dart +++ b/lib/pages/exchange_view/wallet_initiated_exchange_view.dart @@ -12,32 +12,32 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/pages/exchange_view/exchange_form.dart'; -import 'package:stackwallet/pages/exchange_view/sub_widgets/step_row.dart'; -import 'package:stackwallet/providers/exchange/exchange_form_state_provider.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/services/exchange/exchange_data_loading_service.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_loading_overlay.dart'; +import '../../models/isar/models/isar_models.dart'; +import 'exchange_form.dart'; +import 'sub_widgets/step_row.dart'; +import '../../providers/exchange/exchange_form_state_provider.dart'; +import '../../providers/global/prefs_provider.dart'; +import '../../services/exchange/exchange_data_loading_service.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/text_styles.dart'; +import '../../wallets/crypto_currency/crypto_currency.dart'; +import '../../widgets/background.dart'; +import '../../widgets/conditional_parent.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/custom_loading_overlay.dart'; class WalletInitiatedExchangeView extends ConsumerStatefulWidget { const WalletInitiatedExchangeView({ - Key? key, + super.key, required this.walletId, required this.coin, this.contract, - }) : super(key: key); + }); static const String routeName = "/walletInitiatedExchange"; final String walletId; - final Coin coin; + final CryptoCurrency coin; final EthContract? contract; @override @@ -48,7 +48,7 @@ class WalletInitiatedExchangeView extends ConsumerStatefulWidget { class _WalletInitiatedExchangeViewState extends ConsumerState { late final String walletId; - late final Coin coin; + late final CryptoCurrency coin; bool _initialCachePopulationUnderway = false; diff --git a/lib/pages/generic/single_field_edit_view.dart b/lib/pages/generic/single_field_edit_view.dart index 1cd8e33b3..d78f6f599 100644 --- a/lib/pages/generic/single_field_edit_view.dart +++ b/lib/pages/generic/single_field_edit_view.dart @@ -10,19 +10,19 @@ import 'package:flutter/material.dart'; import 'package:flutter_native_splash/cli_commands.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import '../../widgets/background.dart'; +import '../../widgets/conditional_parent.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../widgets/desktop/primary_button.dart'; +import '../../widgets/desktop/secondary_button.dart'; +import '../../widgets/icon_widgets/x_icon.dart'; +import '../../widgets/stack_text_field.dart'; +import '../../widgets/textfield_icon_button.dart'; class SingleFieldEditView extends StatefulWidget { const SingleFieldEditView({ diff --git a/lib/pages/home_view/home_view.dart b/lib/pages/home_view/home_view.dart index 457cbb418..0173064c2 100644 --- a/lib/pages/home_view/home_view.dart +++ b/lib/pages/home_view/home_view.dart @@ -14,30 +14,33 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/pages/buy_view/buy_view.dart'; -import 'package:stackwallet/pages/exchange_view/exchange_view.dart'; -import 'package:stackwallet/pages/home_view/sub_widgets/home_view_button_bar.dart'; -import 'package:stackwallet/pages/notification_views/notifications_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/global_settings_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/hidden_settings.dart'; -import 'package:stackwallet/pages/wallets_view/wallets_view.dart'; -import 'package:stackwallet/providers/global/notifications_provider.dart'; -import 'package:stackwallet/providers/ui/home_view_index_provider.dart'; -import 'package:stackwallet/providers/ui/unread_notifications_provider.dart'; -import 'package:stackwallet/services/event_bus/events/global/tor_connection_status_changed_event.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/animated_widgets/rotate_icon.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/small_tor_icon.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; + +import '../../app_config.dart'; +import '../../providers/global/notifications_provider.dart'; +import '../../providers/ui/home_view_index_provider.dart'; +import '../../providers/ui/unread_notifications_provider.dart'; +import '../../services/event_bus/events/global/tor_connection_status_changed_event.dart'; +import '../../themes/stack_colors.dart'; +import '../../themes/theme_providers.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/text_styles.dart'; +import '../../widgets/animated_widgets/rotate_icon.dart'; +import '../../widgets/app_icon.dart'; +import '../../widgets/background.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/small_tor_icon.dart'; +import '../../widgets/stack_dialog.dart'; +import '../buy_view/buy_view.dart'; +import '../exchange_view/exchange_view.dart'; +import '../notification_views/notifications_view.dart'; +import '../settings_views/global_settings_view/global_settings_view.dart'; +import '../settings_views/global_settings_view/hidden_settings.dart'; +import '../wallets_view/wallets_view.dart'; +import 'sub_widgets/home_view_button_bar.dart'; class HomeView extends ConsumerStatefulWidget { - const HomeView({Key? key}) : super(key: key); + const HomeView({super.key}); static const routeName = "/home"; @@ -182,14 +185,7 @@ class _HomeViewState extends ConsumerState { GestureDetector( onTap: _hiddenOptions, child: RotateIcon( - icon: SvgPicture.file( - File( - ref.watch( - themeProvider.select( - (value) => value.assets.stackIcon, - ), - ), - ), + icon: const AppIcon( width: 24, height: 24, ), @@ -202,7 +198,7 @@ class _HomeViewState extends ConsumerState { width: 16, ), Text( - "My Stack", + "My ${AppConfig.prefix}", style: STextStyles.navBarTitle(context), ) ], diff --git a/lib/pages/home_view/sub_widgets/home_view_button_bar.dart b/lib/pages/home_view/sub_widgets/home_view_button_bar.dart index 098ba4843..e51ecacb7 100644 --- a/lib/pages/home_view/sub_widgets/home_view_button_bar.dart +++ b/lib/pages/home_view/sub_widgets/home_view_button_bar.dart @@ -10,9 +10,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; +import '../../../providers/providers.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/text_styles.dart'; class HomeViewButtonBar extends ConsumerStatefulWidget { const HomeViewButtonBar({Key? key}) : super(key: key); diff --git a/lib/pages/intro_view.dart b/lib/pages/intro_view.dart index 2eecd4983..0f99aabae 100644 --- a/lib/pages/intro_view.dart +++ b/lib/pages/intro_view.dart @@ -14,19 +14,22 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/pages/stack_privacy_calls.dart'; -import 'package:stackwallet/pages_desktop_specific/password/create_password_view.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/utilities/prefs.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; import 'package:url_launcher/url_launcher.dart'; +import '../app_config.dart'; +import '../pages_desktop_specific/password/create_password_view.dart'; +import '../themes/stack_colors.dart'; +import '../themes/theme_providers.dart'; +import '../utilities/prefs.dart'; +import '../utilities/text_styles.dart'; +import '../utilities/util.dart'; +import '../widgets/app_icon.dart'; +import '../widgets/background.dart'; +import '../widgets/desktop/secondary_button.dart'; +import 'stack_privacy_calls.dart'; + class IntroView extends ConsumerStatefulWidget { - const IntroView({Key? key}) : super(key: key); + const IntroView({super.key}); static const String routeName = "/introView"; @@ -131,18 +134,10 @@ class _IntroViewState extends ConsumerState { const Spacer( flex: 2, ), - SizedBox( + const SizedBox( width: 130, height: 130, - child: SvgPicture.file( - File( - ref.watch( - themeProvider.select( - (value) => value.assets.stackIcon, - ), - ), - ), - ), + child: AppIcon(), ), const Spacer( flex: 42, @@ -199,7 +194,10 @@ class AppNameText extends StatelessWidget { @override Widget build(BuildContext context) { return Text( - "Stack Wallet", + AppConfig.appName, + // TODO [prio=high]: appName is now static due to `'appName' can't be + // accessed using static access.`", check that that doesn't cause issues + // elsewhere. textAlign: TextAlign.center, style: !isDesktop ? STextStyles.pageTitleH1(context) @@ -243,7 +241,7 @@ class PrivacyAndTOSText extends StatelessWidget { text: TextSpan( style: STextStyles.label(context).copyWith(fontSize: fontSize), children: [ - const TextSpan(text: "By using Stack Wallet, you agree to the "), + TextSpan(text: "By using ${AppConfig.appName}, you agree to the "), TextSpan( text: "Terms of service", style: STextStyles.richLink(context).copyWith(fontSize: fontSize), diff --git a/lib/pages/loading_view.dart b/lib/pages/loading_view.dart index ef2bba93f..67598d894 100644 --- a/lib/pages/loading_view.dart +++ b/lib/pages/loading_view.dart @@ -14,12 +14,12 @@ import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:lottie/lottie.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; +import '../themes/stack_colors.dart'; +import '../themes/theme_providers.dart'; +import '../utilities/assets.dart'; +import '../widgets/background.dart'; +import '../widgets/conditional_parent.dart'; +import '../widgets/rounded_container.dart'; class LoadingView extends ConsumerWidget { const LoadingView({Key? key}) : super(key: key); diff --git a/lib/pages/manage_favorites_view/manage_favorites_view.dart b/lib/pages/manage_favorites_view/manage_favorites_view.dart index d7f297689..a6fe24401 100644 --- a/lib/pages/manage_favorites_view/manage_favorites_view.dart +++ b/lib/pages/manage_favorites_view/manage_favorites_view.dart @@ -10,16 +10,16 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/favourite_wallets_provider.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/managed_favorite.dart'; +import '../../providers/db/main_db_provider.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import '../../wallets/isar/providers/favourite_wallets_provider.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/desktop/desktop_app_bar.dart'; +import '../../widgets/desktop/desktop_scaffold.dart'; +import '../../widgets/managed_favorite.dart'; class ManageFavoritesView extends StatelessWidget { const ManageFavoritesView({Key? key}) : super(key: key); diff --git a/lib/pages/monkey/monkey_loaded_view.dart b/lib/pages/monkey/monkey_loaded_view.dart index 60f66a0ed..11c277b53 100644 --- a/lib/pages/monkey/monkey_loaded_view.dart +++ b/lib/pages/monkey/monkey_loaded_view.dart @@ -13,7 +13,7 @@ // // import 'package:stackwallet/themes/stack_colors.dart'; // import 'package:stackwallet/utilities/assets.dart'; -// import 'package:stackwallet/utilities/enums/coin_enum.dart'; +// // import 'package:stackwallet/utilities/text_styles.dart'; // import 'package:stackwallet/widgets/background.dart'; // import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; @@ -163,7 +163,7 @@ // // @override // Widget build(BuildContext context) { -// final Coin coin = ref.watch(managerProvider.select((value) => value.coin)); +// final CryptoCurrency coin = ref.watch(managerProvider.select((value) => value.coin)); // final wallet = ref.watch(walletsChangeNotifierProvider // .select((value) => value.getWallet(widget.walletId))); // diff --git a/lib/pages/monkey/monkey_view.dart b/lib/pages/monkey/monkey_view.dart index 9e8bdb090..d2da7026a 100644 --- a/lib/pages/monkey/monkey_view.dart +++ b/lib/pages/monkey/monkey_view.dart @@ -6,27 +6,27 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:path_provider/path_provider.dart'; import 'package:permission_handler/permission_handler.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/services/monkey_service.dart'; -import 'package:stackwallet/themes/coin_icon_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/show_loading.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/wallets/wallet/impl/banano_wallet.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../notifications/show_flush_bar.dart'; +import '../../providers/global/wallets_provider.dart'; +import '../../services/monkey_service.dart'; +import '../../themes/coin_icon_provider.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/show_loading.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import '../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../wallets/wallet/impl/banano_wallet.dart'; +import '../../widgets/background.dart'; +import '../../widgets/conditional_parent.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/desktop/desktop_app_bar.dart'; +import '../../widgets/desktop/desktop_dialog.dart'; +import '../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../widgets/desktop/desktop_scaffold.dart'; +import '../../widgets/desktop/primary_button.dart'; +import '../../widgets/desktop/secondary_button.dart'; +import '../../widgets/stack_dialog.dart'; class MonkeyView extends ConsumerStatefulWidget { const MonkeyView({ diff --git a/lib/pages/monkey/sub_widgets/fetch_monkey_dialog.dart b/lib/pages/monkey/sub_widgets/fetch_monkey_dialog.dart index 94034fb78..ba691645c 100644 --- a/lib/pages/monkey/sub_widgets/fetch_monkey_dialog.dart +++ b/lib/pages/monkey/sub_widgets/fetch_monkey_dialog.dart @@ -9,14 +9,14 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/animated_widgets/rotating_arrows.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../widgets/animated_widgets/rotating_arrows.dart'; +import '../../../widgets/desktop/desktop_dialog.dart'; +import '../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../widgets/desktop/secondary_button.dart'; +import '../../../widgets/stack_dialog.dart'; class FetchMonkeyDialog extends StatefulWidget { const FetchMonkeyDialog({ diff --git a/lib/pages/notification_views/notifications_view.dart b/lib/pages/notification_views/notifications_view.dart index 18af772ba..03fbeb784 100644 --- a/lib/pages/notification_views/notifications_view.dart +++ b/lib/pages/notification_views/notifications_view.dart @@ -10,14 +10,14 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/notifications/notification_card.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/providers/ui/unread_notifications_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../notifications/notification_card.dart'; +import '../../providers/providers.dart'; +import '../../providers/ui/unread_notifications_provider.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/text_styles.dart'; +import '../../widgets/background.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/rounded_white_container.dart'; class NotificationsView extends ConsumerStatefulWidget { const NotificationsView({ diff --git a/lib/pages/ordinals/ordinal_details_view.dart b/lib/pages/ordinals/ordinal_details_view.dart index 590bca266..5fa7cfd25 100644 --- a/lib/pages/ordinals/ordinal_details_view.dart +++ b/lib/pages/ordinals/ordinal_details_view.dart @@ -7,33 +7,32 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:path_provider/path_provider.dart'; import 'package:permission_handler/permission_handler.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/utxo.dart'; -import 'package:stackwallet/models/isar/ordinal.dart'; -import 'package:stackwallet/networking/http.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/show_loading.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../models/isar/models/blockchain_data/utxo.dart'; +import '../../models/isar/ordinal.dart'; +import '../../networking/http.dart'; +import '../../notifications/show_flush_bar.dart'; +import '../../providers/db/main_db_provider.dart'; +import '../../providers/global/prefs_provider.dart'; +import '../../services/tor_service.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/amount/amount.dart'; +import '../../utilities/amount/amount_formatter.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/show_loading.dart'; +import '../../utilities/text_styles.dart'; +import '../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../widgets/background.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/desktop/secondary_button.dart'; +import '../../widgets/rounded_white_container.dart'; class OrdinalDetailsView extends ConsumerStatefulWidget { const OrdinalDetailsView({ - Key? key, + super.key, required this.walletId, required this.ordinal, - }) : super(key: key); + }); final String walletId; final Ordinal ordinal; @@ -113,7 +112,7 @@ class _OrdinalDetailsViewState extends ConsumerState { : ref.watch(pAmountFormatter(coin)).format( Amount( rawValue: BigInt.from(utxo!.value), - fractionDigits: coin.decimals, + fractionDigits: coin.fractionDigits, ), ), ), diff --git a/lib/pages/ordinals/ordinals_filter_view.dart b/lib/pages/ordinals/ordinals_filter_view.dart index 1d2f61695..5f598708f 100644 --- a/lib/pages/ordinals/ordinals_filter_view.dart +++ b/lib/pages/ordinals/ordinals_filter_view.dart @@ -11,23 +11,23 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/format.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/date_picker/date_picker.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../themes/stack_colors.dart'; +import '../../themes/theme_providers.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/format.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import '../../widgets/background.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/date_picker/date_picker.dart'; +import '../../widgets/desktop/desktop_dialog.dart'; +import '../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../widgets/desktop/primary_button.dart'; +import '../../widgets/desktop/secondary_button.dart'; +import '../../widgets/icon_widgets/x_icon.dart'; +import '../../widgets/stack_text_field.dart'; +import '../../widgets/textfield_icon_button.dart'; class OrdinalFilter { // final bool isMoonbird; diff --git a/lib/pages/ordinals/ordinals_view.dart b/lib/pages/ordinals/ordinals_view.dart index c02d450bf..844523110 100644 --- a/lib/pages/ordinals/ordinals_view.dart +++ b/lib/pages/ordinals/ordinals_view.dart @@ -11,15 +11,15 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/pages/ordinals/widgets/ordinals_list.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/show_loading.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/ordinals_interface.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; +import 'widgets/ordinals_list.dart'; +import '../../providers/global/wallets_provider.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/show_loading.dart'; +import '../../utilities/text_styles.dart'; +import '../../wallets/wallet/wallet_mixin_interfaces/ordinals_interface.dart'; +import '../../widgets/background.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; class OrdinalsView extends ConsumerStatefulWidget { const OrdinalsView({ diff --git a/lib/pages/ordinals/widgets/dialogs.dart b/lib/pages/ordinals/widgets/dialogs.dart index ee5b57d33..fca607961 100644 --- a/lib/pages/ordinals/widgets/dialogs.dart +++ b/lib/pages/ordinals/widgets/dialogs.dart @@ -1,10 +1,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../widgets/desktop/primary_button.dart'; +import '../../../widgets/desktop/secondary_button.dart'; +import '../../../widgets/stack_dialog.dart'; class SendOrdinalUnfreezeDialog extends StatelessWidget { const SendOrdinalUnfreezeDialog({super.key}); diff --git a/lib/pages/ordinals/widgets/ordinal_card.dart b/lib/pages/ordinals/widgets/ordinal_card.dart index c74366d74..b5a561f48 100644 --- a/lib/pages/ordinals/widgets/ordinal_card.dart +++ b/lib/pages/ordinals/widgets/ordinal_card.dart @@ -1,11 +1,11 @@ import 'package:flutter/material.dart'; -import 'package:stackwallet/models/isar/ordinal.dart'; -import 'package:stackwallet/pages/ordinals/ordinal_details_view.dart'; -import 'package:stackwallet/pages_desktop_specific/ordinals/desktop_ordinal_details_view.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../models/isar/ordinal.dart'; +import '../ordinal_details_view.dart'; +import '../../../pages_desktop_specific/ordinals/desktop_ordinal_details_view.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../widgets/rounded_white_container.dart'; class OrdinalCard extends StatelessWidget { const OrdinalCard({ diff --git a/lib/pages/ordinals/widgets/ordinals_list.dart b/lib/pages/ordinals/widgets/ordinals_list.dart index 481b0ef0a..0e9516127 100644 --- a/lib/pages/ordinals/widgets/ordinals_list.dart +++ b/lib/pages/ordinals/widgets/ordinals_list.dart @@ -3,13 +3,13 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/isar/ordinal.dart'; -import 'package:stackwallet/pages/ordinals/widgets/ordinal_card.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../models/isar/ordinal.dart'; +import 'ordinal_card.dart'; +import '../../../providers/db/main_db_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../widgets/rounded_white_container.dart'; class OrdinalsList extends ConsumerStatefulWidget { const OrdinalsList({ diff --git a/lib/pages/paynym/add_new_paynym_follow_view.dart b/lib/pages/paynym/add_new_paynym_follow_view.dart index 8a32e21ea..f02089c05 100644 --- a/lib/pages/paynym/add_new_paynym_follow_view.dart +++ b/lib/pages/paynym/add_new_paynym_follow_view.dart @@ -13,30 +13,30 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/paynym/paynym_account.dart'; -import 'package:stackwallet/pages/paynym/subwidgets/featured_paynyms_widget.dart'; -import 'package:stackwallet/pages/paynym/subwidgets/paynym_card.dart'; -import 'package:stackwallet/providers/global/paynym_api_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/barcode_scanner_interface.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/desktop/paynym_search_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/clipboard_icon.dart'; -import 'package:stackwallet/widgets/icon_widgets/qrcode_icon.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/loading_indicator.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../models/paynym/paynym_account.dart'; +import 'subwidgets/featured_paynyms_widget.dart'; +import 'subwidgets/paynym_card.dart'; +import '../../providers/global/paynym_api_provider.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/barcode_scanner_interface.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import '../../widgets/conditional_parent.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/desktop/desktop_dialog.dart'; +import '../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../widgets/desktop/desktop_scaffold.dart'; +import '../../widgets/desktop/paynym_search_button.dart'; +import '../../widgets/desktop/secondary_button.dart'; +import '../../widgets/icon_widgets/clipboard_icon.dart'; +import '../../widgets/icon_widgets/qrcode_icon.dart'; +import '../../widgets/icon_widgets/x_icon.dart'; +import '../../widgets/loading_indicator.dart'; +import '../../widgets/rounded_container.dart'; +import '../../widgets/rounded_white_container.dart'; +import '../../widgets/stack_text_field.dart'; +import '../../widgets/textfield_icon_button.dart'; class AddNewPaynymFollowView extends ConsumerStatefulWidget { const AddNewPaynymFollowView({ diff --git a/lib/pages/paynym/dialogs/claiming_paynym_dialog.dart b/lib/pages/paynym/dialogs/claiming_paynym_dialog.dart index d4652948f..2adad5a69 100644 --- a/lib/pages/paynym/dialogs/claiming_paynym_dialog.dart +++ b/lib/pages/paynym/dialogs/claiming_paynym_dialog.dart @@ -9,14 +9,14 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/animated_widgets/rotating_arrows.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../widgets/animated_widgets/rotating_arrows.dart'; +import '../../../widgets/desktop/desktop_dialog.dart'; +import '../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../widgets/desktop/secondary_button.dart'; +import '../../../widgets/stack_dialog.dart'; class ClaimingPaynymDialog extends StatefulWidget { const ClaimingPaynymDialog({ diff --git a/lib/pages/paynym/dialogs/confirm_paynym_connect_dialog.dart b/lib/pages/paynym/dialogs/confirm_paynym_connect_dialog.dart index ae5bfed00..ee2504d35 100644 --- a/lib/pages/paynym/dialogs/confirm_paynym_connect_dialog.dart +++ b/lib/pages/paynym/dialogs/confirm_paynym_connect_dialog.dart @@ -11,34 +11,34 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/amount/amount_formatter.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../widgets/desktop/desktop_dialog.dart'; +import '../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../widgets/desktop/primary_button.dart'; +import '../../../widgets/desktop/secondary_button.dart'; +import '../../../widgets/stack_dialog.dart'; class ConfirmPaynymConnectDialog extends ConsumerWidget { const ConfirmPaynymConnectDialog({ - Key? key, + super.key, required this.nymName, required this.locale, required this.onConfirmPressed, required this.amount, required this.coin, - }) : super(key: key); + }); final String nymName; final String locale; final VoidCallback onConfirmPressed; final Amount amount; - final Coin coin; + final CryptoCurrency coin; String get title => "Connect to $nymName"; diff --git a/lib/pages/paynym/dialogs/paynym_details_popup.dart b/lib/pages/paynym/dialogs/paynym_details_popup.dart index f5f970d38..aa4774646 100644 --- a/lib/pages/paynym/dialogs/paynym_details_popup.dart +++ b/lib/pages/paynym/dialogs/paynym_details_popup.dart @@ -15,39 +15,38 @@ import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:qr_flutter/qr_flutter.dart'; -import 'package:stackwallet/exceptions/wallet/insufficient_balance_exception.dart'; -import 'package:stackwallet/models/paynym/paynym_account_lite.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/paynym/dialogs/confirm_paynym_connect_dialog.dart'; -import 'package:stackwallet/pages/paynym/paynym_home_view.dart'; -import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart'; -import 'package:stackwallet/pages/send_view/confirm_transaction_view.dart'; -import 'package:stackwallet/pages/send_view/send_view.dart'; -import 'package:stackwallet/providers/global/locale_provider.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/route_generator.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/wallets/models/tx_data.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart'; -import 'package:stackwallet/widgets/custom_buttons/paynym_follow_toggle_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/loading_indicator.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../../exceptions/wallet/insufficient_balance_exception.dart'; +import '../../../models/paynym/paynym_account_lite.dart'; +import '../../../notifications/show_flush_bar.dart'; +import 'confirm_paynym_connect_dialog.dart'; +import '../paynym_home_view.dart'; +import '../subwidgets/paynym_bot.dart'; +import '../../send_view/confirm_transaction_view.dart'; +import '../../send_view/send_view.dart'; +import '../../../providers/global/locale_provider.dart'; +import '../../../providers/global/wallets_provider.dart'; +import '../../../route_generator.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../wallets/models/tx_data.dart'; +import '../../../wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart'; +import '../../../widgets/custom_buttons/paynym_follow_toggle_button.dart'; +import '../../../widgets/desktop/desktop_dialog.dart'; +import '../../../widgets/desktop/primary_button.dart'; +import '../../../widgets/desktop/secondary_button.dart'; +import '../../../widgets/loading_indicator.dart'; +import '../../../widgets/rounded_container.dart'; +import '../../../widgets/stack_dialog.dart'; import 'package:tuple/tuple.dart'; class PaynymDetailsPopup extends ConsumerStatefulWidget { const PaynymDetailsPopup({ - Key? key, + super.key, required this.walletId, required this.accountLite, - }) : super(key: key); + }); final String walletId; final PaynymAccountLite accountLite; diff --git a/lib/pages/paynym/dialogs/paynym_qr_popup.dart b/lib/pages/paynym/dialogs/paynym_qr_popup.dart index 076204950..757761396 100644 --- a/lib/pages/paynym/dialogs/paynym_qr_popup.dart +++ b/lib/pages/paynym/dialogs/paynym_qr_popup.dart @@ -13,16 +13,16 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:qr_flutter/qr_flutter.dart'; -import 'package:stackwallet/models/paynym/paynym_account.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../models/paynym/paynym_account.dart'; +import '../../../notifications/show_flush_bar.dart'; +import '../subwidgets/paynym_bot.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../widgets/custom_buttons/blue_text_button.dart'; +import '../../../widgets/desktop/desktop_dialog.dart'; +import '../../../widgets/desktop/desktop_dialog_close_button.dart'; class PaynymQrPopup extends StatelessWidget { const PaynymQrPopup({ diff --git a/lib/pages/paynym/paynym_claim_view.dart b/lib/pages/paynym/paynym_claim_view.dart index df29c7e1a..457179655 100644 --- a/lib/pages/paynym/paynym_claim_view.dart +++ b/lib/pages/paynym/paynym_claim_view.dart @@ -13,23 +13,23 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/models/paynym/paynym_account.dart'; -import 'package:stackwallet/pages/paynym/dialogs/claiming_paynym_dialog.dart'; -import 'package:stackwallet/pages/paynym/paynym_home_view.dart'; -import 'package:stackwallet/pages/wallet_view/wallet_view.dart'; -import 'package:stackwallet/providers/global/paynym_api_provider.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; +import '../../models/paynym/paynym_account.dart'; +import 'dialogs/claiming_paynym_dialog.dart'; +import 'paynym_home_view.dart'; +import '../wallet_view/wallet_view.dart'; +import '../../providers/global/paynym_api_provider.dart'; +import '../../providers/global/wallets_provider.dart'; +import '../../providers/wallet/my_paynym_account_state_provider.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import '../../wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart'; +import '../../widgets/conditional_parent.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/desktop/desktop_app_bar.dart'; +import '../../widgets/desktop/desktop_scaffold.dart'; +import '../../widgets/desktop/primary_button.dart'; class PaynymClaimView extends ConsumerStatefulWidget { const PaynymClaimView({ diff --git a/lib/pages/paynym/paynym_home_view.dart b/lib/pages/paynym/paynym_home_view.dart index 008ab3cbf..be8e9db4c 100644 --- a/lib/pages/paynym/paynym_home_view.dart +++ b/lib/pages/paynym/paynym_home_view.dart @@ -15,32 +15,32 @@ import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:share_plus/share_plus.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/paynym/add_new_paynym_follow_view.dart'; -import 'package:stackwallet/pages/paynym/dialogs/paynym_qr_popup.dart'; -import 'package:stackwallet/pages/paynym/subwidgets/desktop_paynym_details.dart'; -import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart'; -import 'package:stackwallet/pages/paynym/subwidgets/paynym_followers_list.dart'; -import 'package:stackwallet/pages/paynym/subwidgets/paynym_following_list.dart'; -import 'package:stackwallet/providers/ui/selected_paynym_details_item_Provider.dart'; -import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/format.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/copy_icon.dart'; -import 'package:stackwallet/widgets/icon_widgets/qrcode_icon.dart'; -import 'package:stackwallet/widgets/icon_widgets/share_icon.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/toggle.dart'; +import '../../notifications/show_flush_bar.dart'; +import 'add_new_paynym_follow_view.dart'; +import 'dialogs/paynym_qr_popup.dart'; +import 'subwidgets/desktop_paynym_details.dart'; +import 'subwidgets/paynym_bot.dart'; +import 'subwidgets/paynym_followers_list.dart'; +import 'subwidgets/paynym_following_list.dart'; +import '../../providers/ui/selected_paynym_details_item_Provider.dart'; +import '../../providers/wallet/my_paynym_account_state_provider.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/format.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import '../../widgets/conditional_parent.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/desktop/desktop_app_bar.dart'; +import '../../widgets/desktop/desktop_scaffold.dart'; +import '../../widgets/desktop/secondary_button.dart'; +import '../../widgets/icon_widgets/copy_icon.dart'; +import '../../widgets/icon_widgets/qrcode_icon.dart'; +import '../../widgets/icon_widgets/share_icon.dart'; +import '../../widgets/rounded_container.dart'; +import '../../widgets/rounded_white_container.dart'; +import '../../widgets/toggle.dart'; class PaynymHomeView extends ConsumerStatefulWidget { const PaynymHomeView({ diff --git a/lib/pages/paynym/subwidgets/desktop_paynym_details.dart b/lib/pages/paynym/subwidgets/desktop_paynym_details.dart index c09baca9d..bc2fef85f 100644 --- a/lib/pages/paynym/subwidgets/desktop_paynym_details.dart +++ b/lib/pages/paynym/subwidgets/desktop_paynym_details.dart @@ -15,29 +15,29 @@ import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:qr_flutter/qr_flutter.dart'; -import 'package:stackwallet/exceptions/wallet/insufficient_balance_exception.dart'; -import 'package:stackwallet/models/paynym/paynym_account_lite.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/paynym/dialogs/confirm_paynym_connect_dialog.dart'; -import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart'; -import 'package:stackwallet/pages/send_view/confirm_transaction_view.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/paynym/desktop_paynym_send_dialog.dart'; -import 'package:stackwallet/providers/global/locale_provider.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/wallets/models/tx_data.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/paynym_follow_toggle_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/loading_indicator.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../exceptions/wallet/insufficient_balance_exception.dart'; +import '../../../models/paynym/paynym_account_lite.dart'; +import '../../../notifications/show_flush_bar.dart'; +import '../dialogs/confirm_paynym_connect_dialog.dart'; +import 'paynym_bot.dart'; +import '../../send_view/confirm_transaction_view.dart'; +import '../../../pages_desktop_specific/my_stack_view/paynym/desktop_paynym_send_dialog.dart'; +import '../../../providers/global/locale_provider.dart'; +import '../../../providers/global/wallets_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; + +import '../../../utilities/text_styles.dart'; +import '../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../wallets/models/tx_data.dart'; +import '../../../wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart'; +import '../../../widgets/custom_buttons/blue_text_button.dart'; +import '../../../widgets/custom_buttons/paynym_follow_toggle_button.dart'; +import '../../../widgets/desktop/desktop_dialog.dart'; +import '../../../widgets/desktop/primary_button.dart'; +import '../../../widgets/loading_indicator.dart'; +import '../../../widgets/rounded_container.dart'; +import '../../../widgets/rounded_white_container.dart'; class DesktopPaynymDetails extends ConsumerStatefulWidget { const DesktopPaynymDetails({ diff --git a/lib/pages/paynym/subwidgets/featured_paynyms_widget.dart b/lib/pages/paynym/subwidgets/featured_paynyms_widget.dart index af363945d..645d8cf60 100644 --- a/lib/pages/paynym/subwidgets/featured_paynyms_widget.dart +++ b/lib/pages/paynym/subwidgets/featured_paynyms_widget.dart @@ -9,12 +9,12 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/pages/paynym/subwidgets/paynym_card.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/featured_paynyms.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import 'paynym_card.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/featured_paynyms.dart'; +import '../../../utilities/util.dart'; +import '../../../widgets/conditional_parent.dart'; +import '../../../widgets/rounded_white_container.dart'; class FeaturedPaynymsWidget extends StatelessWidget { const FeaturedPaynymsWidget({ diff --git a/lib/pages/paynym/subwidgets/paynym_bot.dart b/lib/pages/paynym/subwidgets/paynym_bot.dart index 082f7034e..ab72dce24 100644 --- a/lib/pages/paynym/subwidgets/paynym_bot.dart +++ b/lib/pages/paynym/subwidgets/paynym_bot.dart @@ -11,9 +11,9 @@ import 'dart:typed_data'; import 'package:flutter/material.dart'; -import 'package:stackwallet/networking/http.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/utilities/prefs.dart'; +import '../../../networking/http.dart'; +import '../../../services/tor_service.dart'; +import '../../../utilities/prefs.dart'; class PayNymBot extends StatelessWidget { const PayNymBot({ diff --git a/lib/pages/paynym/subwidgets/paynym_card.dart b/lib/pages/paynym/subwidgets/paynym_card.dart index 8dab52869..1a81202a6 100644 --- a/lib/pages/paynym/subwidgets/paynym_card.dart +++ b/lib/pages/paynym/subwidgets/paynym_card.dart @@ -9,12 +9,12 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/format.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/custom_buttons/paynym_follow_toggle_button.dart'; +import 'paynym_bot.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/format.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../widgets/custom_buttons/paynym_follow_toggle_button.dart'; class PaynymCard extends StatefulWidget { const PaynymCard({ diff --git a/lib/pages/paynym/subwidgets/paynym_card_button.dart b/lib/pages/paynym/subwidgets/paynym_card_button.dart index 07a5ece1e..869d6244d 100644 --- a/lib/pages/paynym/subwidgets/paynym_card_button.dart +++ b/lib/pages/paynym/subwidgets/paynym_card_button.dart @@ -10,16 +10,16 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/paynym/paynym_account_lite.dart'; -import 'package:stackwallet/pages/paynym/dialogs/paynym_details_popup.dart'; -import 'package:stackwallet/pages/paynym/subwidgets/paynym_bot.dart'; -import 'package:stackwallet/providers/ui/selected_paynym_details_item_Provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/format.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; +import '../../../models/paynym/paynym_account_lite.dart'; +import '../dialogs/paynym_details_popup.dart'; +import 'paynym_bot.dart'; +import '../../../providers/ui/selected_paynym_details_item_Provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/format.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../widgets/rounded_container.dart'; class PaynymCardButton extends ConsumerStatefulWidget { const PaynymCardButton({ diff --git a/lib/pages/paynym/subwidgets/paynym_followers_list.dart b/lib/pages/paynym/subwidgets/paynym_followers_list.dart index edd6155ff..55ac272f7 100644 --- a/lib/pages/paynym/subwidgets/paynym_followers_list.dart +++ b/lib/pages/paynym/subwidgets/paynym_followers_list.dart @@ -12,18 +12,18 @@ import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/pages/paynym/subwidgets/paynym_card_button.dart'; -import 'package:stackwallet/providers/global/paynym_api_provider.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import 'paynym_card_button.dart'; +import '../../../providers/global/paynym_api_provider.dart'; +import '../../../providers/global/wallets_provider.dart'; +import '../../../providers/wallet/my_paynym_account_state_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/logger.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart'; +import '../../../widgets/conditional_parent.dart'; +import '../../../widgets/rounded_white_container.dart'; class PaynymFollowersList extends ConsumerStatefulWidget { const PaynymFollowersList({ diff --git a/lib/pages/paynym/subwidgets/paynym_following_list.dart b/lib/pages/paynym/subwidgets/paynym_following_list.dart index 069d225bf..3536f5760 100644 --- a/lib/pages/paynym/subwidgets/paynym_following_list.dart +++ b/lib/pages/paynym/subwidgets/paynym_following_list.dart @@ -12,18 +12,18 @@ import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/pages/paynym/subwidgets/paynym_card_button.dart'; -import 'package:stackwallet/providers/global/paynym_api_provider.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import 'paynym_card_button.dart'; +import '../../../providers/global/paynym_api_provider.dart'; +import '../../../providers/global/wallets_provider.dart'; +import '../../../providers/wallet/my_paynym_account_state_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/logger.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart'; +import '../../../widgets/conditional_parent.dart'; +import '../../../widgets/rounded_white_container.dart'; class PaynymFollowingList extends ConsumerStatefulWidget { const PaynymFollowingList({ diff --git a/lib/pages/pinpad_views/create_pin_view.dart b/lib/pages/pinpad_views/create_pin_view.dart index 82c6c8a8e..05231181d 100644 --- a/lib/pages/pinpad_views/create_pin_view.dart +++ b/lib/pages/pinpad_views/create_pin_view.dart @@ -13,18 +13,18 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/home_view/home_view.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/providers/global/secure_store_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/biometrics.dart'; -import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_pin_put/custom_pin_put.dart'; +import '../../notifications/show_flush_bar.dart'; +import '../home_view/home_view.dart'; +import '../../providers/global/prefs_provider.dart'; +import '../../providers/global/secure_store_provider.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/biometrics.dart'; +import '../../utilities/flutter_secure_storage_interface.dart'; +import '../../utilities/text_styles.dart'; +import '../../widgets/background.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/custom_pin_put/custom_pin_put.dart'; class CreatePinView extends ConsumerStatefulWidget { const CreatePinView({ diff --git a/lib/pages/pinpad_views/lock_screen_view.dart b/lib/pages/pinpad_views/lock_screen_view.dart index e4ecb85a4..ec4f7af76 100644 --- a/lib/pages/pinpad_views/lock_screen_view.dart +++ b/lib/pages/pinpad_views/lock_screen_view.dart @@ -12,27 +12,27 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/home_view/home_view.dart'; -import 'package:stackwallet/pages/wallet_view/wallet_view.dart'; +import '../../notifications/show_flush_bar.dart'; +import '../home_view/home_view.dart'; +import '../wallet_view/wallet_view.dart'; // import 'package:stackwallet/providers/global/has_authenticated_start_state_provider.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/providers/global/secure_store_provider.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; +import '../../providers/global/prefs_provider.dart'; +import '../../providers/global/secure_store_provider.dart'; +import '../../providers/global/wallets_provider.dart'; +import '../../themes/stack_colors.dart'; // import 'package:stackwallet/providers/global/should_show_lockscreen_on_resume_state_provider.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/biometrics.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; -import 'package:stackwallet/utilities/show_loading.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/cw_based_interface.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/custom_pin_put/custom_pin_put.dart'; -import 'package:stackwallet/widgets/shake/shake.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/biometrics.dart'; + +import '../../utilities/flutter_secure_storage_interface.dart'; +import '../../utilities/show_loading.dart'; +import '../../utilities/text_styles.dart'; +import '../../wallets/wallet/wallet_mixin_interfaces/cw_based_interface.dart'; +import '../../widgets/background.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/custom_buttons/blue_text_button.dart'; +import '../../widgets/custom_pin_put/custom_pin_put.dart'; +import '../../widgets/shake/shake.dart'; class LockscreenView extends ConsumerStatefulWidget { const LockscreenView({ diff --git a/lib/pages/receive_view/addresses/address_card.dart b/lib/pages/receive_view/addresses/address_card.dart index 51e1402a3..9cd6fbb2f 100644 --- a/lib/pages/receive_view/addresses/address_card.dart +++ b/lib/pages/receive_view/addresses/address_card.dart @@ -22,24 +22,24 @@ import 'package:isar/isar.dart'; import 'package:path_provider/path_provider.dart'; import 'package:qr_flutter/qr_flutter.dart'; import 'package:share_plus/share_plus.dart'; -import 'package:stackwallet/db/isar/main_db.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/themes/coin_icon_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/address_utils.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/clipboard_interface.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/simple_edit_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../../db/isar/main_db.dart'; +import '../../../models/isar/models/isar_models.dart'; +import '../../../notifications/show_flush_bar.dart'; +import '../../../themes/coin_icon_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/address_utils.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/clipboard_interface.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../widgets/conditional_parent.dart'; +import '../../../widgets/custom_buttons/blue_text_button.dart'; +import '../../../widgets/custom_buttons/simple_edit_button.dart'; +import '../../../widgets/desktop/primary_button.dart'; +import '../../../widgets/desktop/secondary_button.dart'; +import '../../../widgets/rounded_white_container.dart'; +import '../../../widgets/stack_dialog.dart'; class AddressCard extends ConsumerStatefulWidget { const AddressCard({ @@ -53,7 +53,7 @@ class AddressCard extends ConsumerStatefulWidget { final int addressId; final String walletId; - final Coin coin; + final CryptoCurrency coin; final ClipboardInterface clipboard; final VoidCallback? onPressed; diff --git a/lib/pages/receive_view/addresses/address_details_view.dart b/lib/pages/receive_view/addresses/address_details_view.dart index 6da7be3c9..268a9bca7 100644 --- a/lib/pages/receive_view/addresses/address_details_view.dart +++ b/lib/pages/receive_view/addresses/address_details_view.dart @@ -12,38 +12,37 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:isar/isar.dart'; import 'package:qr_flutter/qr_flutter.dart'; -import 'package:stackwallet/db/isar/main_db.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/pages/receive_view/addresses/address_tag.dart'; -import 'package:stackwallet/pages/wallet_view/sub_widgets/no_transactions_found.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/transaction_v2_card.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/address_utils.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/simple_copy_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/simple_edit_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/transaction_card.dart'; +import '../../../db/isar/main_db.dart'; +import '../../../models/isar/models/blockchain_data/v2/transaction_v2.dart'; +import '../../../models/isar/models/isar_models.dart'; +import 'address_tag.dart'; +import '../../wallet_view/sub_widgets/no_transactions_found.dart'; +import '../../wallet_view/transaction_views/transaction_details_view.dart'; +import '../../wallet_view/transaction_views/tx_v2/transaction_v2_card.dart'; +import '../../../providers/db/main_db_provider.dart'; +import '../../../providers/global/wallets_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/address_utils.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../widgets/background.dart'; +import '../../../widgets/conditional_parent.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/custom_buttons/blue_text_button.dart'; +import '../../../widgets/custom_buttons/simple_copy_button.dart'; +import '../../../widgets/custom_buttons/simple_edit_button.dart'; +import '../../../widgets/desktop/desktop_dialog.dart'; +import '../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../widgets/rounded_white_container.dart'; +import '../../../widgets/transaction_card.dart'; class AddressDetailsView extends ConsumerStatefulWidget { const AddressDetailsView({ - Key? key, + super.key, required this.addressId, required this.walletId, - }) : super(key: key); + }); static const String routeName = "/addressDetailsView"; @@ -398,7 +397,11 @@ class _AddressDetailsViewState extends ConsumerState { height: 12, ), if (!isDesktop) - coin == Coin.bitcoincash || coin == Coin.bitcoincashTestnet + ref + .watch(pWallets) + .getWallet(widget.walletId) + .isarTransactionVersion == + 2 ? _AddressDetailsTxV2List( walletId: widget.walletId, address: address, @@ -418,10 +421,10 @@ class _AddressDetailsViewState extends ConsumerState { class _AddressDetailsTxList extends StatelessWidget { const _AddressDetailsTxList({ - Key? key, + super.key, required this.walletId, required this.address, - }) : super(key: key); + }); final String walletId; final Address address; diff --git a/lib/pages/receive_view/addresses/address_qr_popup.dart b/lib/pages/receive_view/addresses/address_qr_popup.dart index 6e0c2e15b..202876e26 100644 --- a/lib/pages/receive_view/addresses/address_qr_popup.dart +++ b/lib/pages/receive_view/addresses/address_qr_popup.dart @@ -20,28 +20,28 @@ import 'package:flutter_svg/svg.dart'; import 'package:path_provider/path_provider.dart'; import 'package:qr_flutter/qr_flutter.dart'; import 'package:share_plus/share_plus.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/address_utils.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/clipboard_interface.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../../notifications/show_flush_bar.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/address_utils.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/clipboard_interface.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../widgets/desktop/primary_button.dart'; +import '../../../widgets/desktop/secondary_button.dart'; +import '../../../widgets/stack_dialog.dart'; class AddressQrPopup extends StatefulWidget { const AddressQrPopup({ - Key? key, + super.key, required this.addressString, required this.coin, this.clipboard = const ClipboardWrapper(), - }) : super(key: key); + }); final String addressString; - final Coin coin; + final CryptoCurrency coin; final ClipboardInterface clipboard; @override @@ -54,12 +54,12 @@ class _AddressQrPopupState extends State { Future _capturePng(bool shouldSaveInsteadOfShare) async { try { - RenderRepaintBoundary boundary = + final RenderRepaintBoundary boundary = _qrKey.currentContext?.findRenderObject() as RenderRepaintBoundary; - ui.Image image = await boundary.toImage(); - ByteData? byteData = + final ui.Image image = await boundary.toImage(); + final ByteData? byteData = await image.toByteData(format: ui.ImageByteFormat.png); - Uint8List pngBytes = byteData!.buffer.asUint8List(); + final Uint8List pngBytes = byteData!.buffer.asUint8List(); if (shouldSaveInsteadOfShare) { if (isDesktop) { diff --git a/lib/pages/receive_view/addresses/address_tag.dart b/lib/pages/receive_view/addresses/address_tag.dart index ceb9c35c8..c2258adda 100644 --- a/lib/pages/receive_view/addresses/address_tag.dart +++ b/lib/pages/receive_view/addresses/address_tag.dart @@ -10,9 +10,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_native_splash/cli_commands.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../widgets/rounded_container.dart'; class AddressTag extends StatelessWidget { const AddressTag({Key? key, required this.tag}) : super(key: key); diff --git a/lib/pages/receive_view/addresses/edit_address_label_view.dart b/lib/pages/receive_view/addresses/edit_address_label_view.dart index 75549c807..61c639877 100644 --- a/lib/pages/receive_view/addresses/edit_address_label_view.dart +++ b/lib/pages/receive_view/addresses/edit_address_label_view.dart @@ -11,20 +11,20 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/db/isar/main_db.dart'; -import 'package:stackwallet/models/isar/models/address_label.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../../db/isar/main_db.dart'; +import '../../../models/isar/models/address_label.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../widgets/background.dart'; +import '../../../widgets/conditional_parent.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../widgets/desktop/primary_button.dart'; +import '../../../widgets/icon_widgets/x_icon.dart'; +import '../../../widgets/stack_text_field.dart'; +import '../../../widgets/textfield_icon_button.dart'; class EditAddressLabelView extends ConsumerStatefulWidget { const EditAddressLabelView({ diff --git a/lib/pages/receive_view/addresses/wallet_addresses_view.dart b/lib/pages/receive_view/addresses/wallet_addresses_view.dart index c6cd03215..b0970395b 100644 --- a/lib/pages/receive_view/addresses/wallet_addresses_view.dart +++ b/lib/pages/receive_view/addresses/wallet_addresses_view.dart @@ -11,18 +11,18 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/db/isar/main_db.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/pages/receive_view/addresses/address_card.dart'; -import 'package:stackwallet/pages/receive_view/addresses/address_details_view.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/loading_indicator.dart'; +import '../../../db/isar/main_db.dart'; +import '../../../models/isar/models/isar_models.dart'; +import 'address_card.dart'; +import 'address_details_view.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../widgets/background.dart'; +import '../../../widgets/conditional_parent.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/loading_indicator.dart'; import 'package:tuple/tuple.dart'; class WalletAddressesView extends ConsumerStatefulWidget { diff --git a/lib/pages/receive_view/generate_receiving_uri_qr_code_view.dart b/lib/pages/receive_view/generate_receiving_uri_qr_code_view.dart index 4fd9d0cf1..25c338b96 100644 --- a/lib/pages/receive_view/generate_receiving_uri_qr_code_view.dart +++ b/lib/pages/receive_view/generate_receiving_uri_qr_code_view.dart @@ -22,38 +22,40 @@ import 'package:flutter_svg/svg.dart'; import 'package:path_provider/path_provider.dart'; import 'package:qr_flutter/qr_flutter.dart'; import 'package:share_plus/share_plus.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/address_utils.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/clipboard_interface.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../notifications/show_flush_bar.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/address_utils.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/clipboard_interface.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/logger.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import '../../wallets/crypto_currency/coins/bitcoincash.dart'; +import '../../wallets/crypto_currency/coins/ecash.dart'; +import '../../wallets/crypto_currency/crypto_currency.dart'; +import '../../widgets/background.dart'; +import '../../widgets/conditional_parent.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/desktop/primary_button.dart'; +import '../../widgets/desktop/secondary_button.dart'; +import '../../widgets/icon_widgets/x_icon.dart'; +import '../../widgets/rounded_white_container.dart'; +import '../../widgets/stack_dialog.dart'; +import '../../widgets/stack_text_field.dart'; +import '../../widgets/textfield_icon_button.dart'; class GenerateUriQrCodeView extends StatefulWidget { const GenerateUriQrCodeView({ - Key? key, + super.key, required this.coin, required this.receivingAddress, this.clipboard = const ClipboardWrapper(), - }) : super(key: key); + }); static const String routeName = "/generateUriQrCodeView"; - final Coin coin; + final CryptoCurrency coin; final String receivingAddress; final ClipboardInterface clipboard; @@ -76,12 +78,12 @@ class _GenerateUriQrCodeViewState extends State { Future _capturePng(bool shouldSaveInsteadOfShare) async { try { - RenderRepaintBoundary boundary = + final RenderRepaintBoundary boundary = _qrKey.currentContext?.findRenderObject() as RenderRepaintBoundary; - ui.Image image = await boundary.toImage(); - ByteData? byteData = + final ui.Image image = await boundary.toImage(); + final ByteData? byteData = await image.toByteData(format: ui.ImageByteFormat.png); - Uint8List pngBytes = byteData!.buffer.asUint8List(); + final Uint8List pngBytes = byteData!.buffer.asUint8List(); if (shouldSaveInsteadOfShare) { if (Util.isDesktop) { @@ -149,7 +151,7 @@ class _GenerateUriQrCodeViewState extends State { return null; } - Map queryParams = {}; + final Map queryParams = {}; if (amountString.isNotEmpty) { queryParams["amount"] = amountString; @@ -159,9 +161,7 @@ class _GenerateUriQrCodeViewState extends State { } String receivingAddress = widget.receivingAddress; - if ((widget.coin == Coin.bitcoincash || - widget.coin == Coin.eCash || - widget.coin == Coin.bitcoincashTestnet) && + if ((widget.coin is Bitcoincash || widget.coin is Ecash) && receivingAddress.contains(":")) { // remove cash addr prefix receivingAddress = receivingAddress.split(":").sublist(1).join(); @@ -256,9 +256,7 @@ class _GenerateUriQrCodeViewState extends State { isDesktop = Util.isDesktop; String receivingAddress = widget.receivingAddress; - if ((widget.coin == Coin.bitcoincash || - widget.coin == Coin.eCash || - widget.coin == Coin.bitcoincashTestnet) && + if ((widget.coin is Bitcoincash || widget.coin is Ecash) && receivingAddress.contains(":")) { // remove cash addr prefix receivingAddress = receivingAddress.split(":").sublist(1).join(); diff --git a/lib/pages/receive_view/receive_view.dart b/lib/pages/receive_view/receive_view.dart index f96e83274..e9e85e8d1 100644 --- a/lib/pages/receive_view/receive_view.dart +++ b/lib/pages/receive_view/receive_view.dart @@ -17,35 +17,35 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:isar/isar.dart'; import 'package:qr_flutter/qr_flutter.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/receive_view/addresses/wallet_addresses_view.dart'; -import 'package:stackwallet/pages/receive_view/generate_receiving_uri_qr_code_view.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/route_generator.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/address_utils.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/clipboard_interface.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/wallets/wallet/impl/bitcoin_wallet.dart'; -import 'package:stackwallet/wallets/wallet/intermediate/bip39_hd_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/bcash_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/multi_address_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/custom_loading_overlay.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../models/isar/models/isar_models.dart'; +import '../../notifications/show_flush_bar.dart'; +import 'addresses/wallet_addresses_view.dart'; +import 'generate_receiving_uri_qr_code_view.dart'; +import '../../providers/db/main_db_provider.dart'; +import '../../providers/providers.dart'; +import '../../route_generator.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/address_utils.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/clipboard_interface.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/enums/derive_path_type_enum.dart'; +import '../../utilities/text_styles.dart'; +import '../../wallets/crypto_currency/crypto_currency.dart'; +import '../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../wallets/wallet/impl/bitcoin_wallet.dart'; +import '../../wallets/wallet/intermediate/bip39_hd_wallet.dart'; +import '../../wallets/wallet/wallet_mixin_interfaces/bcash_interface.dart'; +import '../../wallets/wallet/wallet_mixin_interfaces/multi_address_interface.dart'; +import '../../wallets/wallet/wallet_mixin_interfaces/spark_interface.dart'; +import '../../widgets/background.dart'; +import '../../widgets/conditional_parent.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/custom_buttons/blue_text_button.dart'; +import '../../widgets/custom_loading_overlay.dart'; +import '../../widgets/desktop/primary_button.dart'; +import '../../widgets/desktop/secondary_button.dart'; +import '../../widgets/rounded_white_container.dart'; class ReceiveView extends ConsumerStatefulWidget { const ReceiveView({ @@ -66,7 +66,7 @@ class ReceiveView extends ConsumerStatefulWidget { } class _ReceiveViewState extends ConsumerState { - late final Coin coin; + late final CryptoCurrency coin; late final String walletId; late final ClipboardInterface clipboard; late final bool _supportsSpark; diff --git a/lib/pages/send_view/confirm_transaction_view.dart b/lib/pages/send_view/confirm_transaction_view.dart index e9063d328..09237e080 100644 --- a/lib/pages/send_view/confirm_transaction_view.dart +++ b/lib/pages/send_view/confirm_transaction_view.dart @@ -16,46 +16,47 @@ import 'package:flutter/material.dart'; import 'package:flutter_libepiccash/lib.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/models/isar/models/transaction_note.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/pinpad_views/lock_screen_view.dart'; -import 'package:stackwallet/pages/send_view/sub_widgets/sending_transaction_dialog.dart'; -import 'package:stackwallet/pages/wallet_view/wallet_view.dart'; -import 'package:stackwallet/pages_desktop_specific/coin_control/desktop_coin_control_use_dialog.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_auth_send.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/providers/wallet/public_private_balance_state_provider.dart'; -import 'package:stackwallet/route_generator.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/eth/current_token_wallet_provider.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/wallets/models/tx_data.dart'; -import 'package:stackwallet/wallets/wallet/impl/firo_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../models/isar/models/transaction_note.dart'; +import '../../notifications/show_flush_bar.dart'; +import '../pinpad_views/lock_screen_view.dart'; +import 'sub_widgets/sending_transaction_dialog.dart'; +import '../wallet_view/wallet_view.dart'; +import '../../pages_desktop_specific/coin_control/desktop_coin_control_use_dialog.dart'; +import '../../pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_auth_send.dart'; +import '../../providers/db/main_db_provider.dart'; +import '../../providers/providers.dart'; +import '../../providers/wallet/public_private_balance_state_provider.dart'; +import '../../route_generator.dart'; +import '../../themes/stack_colors.dart'; +import '../../themes/theme_providers.dart'; +import '../../utilities/amount/amount.dart'; +import '../../utilities/amount/amount_formatter.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import '../../wallets/crypto_currency/coins/epiccash.dart'; +import '../../wallets/crypto_currency/intermediate/nano_currency.dart'; +import '../../wallets/isar/providers/eth/current_token_wallet_provider.dart'; +import '../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../wallets/models/tx_data.dart'; +import '../../wallets/wallet/impl/firo_wallet.dart'; +import '../../wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart'; +import '../../widgets/background.dart'; +import '../../widgets/conditional_parent.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/desktop/desktop_dialog.dart'; +import '../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../widgets/desktop/primary_button.dart'; +import '../../widgets/icon_widgets/x_icon.dart'; +import '../../widgets/rounded_container.dart'; +import '../../widgets/rounded_white_container.dart'; +import '../../widgets/stack_dialog.dart'; +import '../../widgets/stack_text_field.dart'; +import '../../widgets/textfield_icon_button.dart'; class ConfirmTransactionView extends ConsumerStatefulWidget { const ConfirmTransactionView({ - Key? key, + super.key, required this.txData, required this.walletId, required this.onSuccess, @@ -65,7 +66,7 @@ class ConfirmTransactionView extends ConsumerStatefulWidget { this.isPaynymNotificationTransaction = false, this.isTokenTx = false, this.onSuccessInsteadOfRouteOnSuccess, - }) : super(key: key); + }); static const String routeName = "/confirmTransactionView"; @@ -157,7 +158,7 @@ class _ConfirmTransactionViewState break; } } else { - if (coin == Coin.epicCash) { + if (coin is Epiccash) { txDataFuture = wallet.confirmSend( txData: widget.txData.copyWith( noteOnChain: onChainNoteController.text, @@ -276,7 +277,7 @@ class _ConfirmTransactionViewState ), ), ], - ) + ), ], ), ), @@ -292,9 +293,10 @@ class _ConfirmTransactionViewState child: Text( "Ok", style: STextStyles.button(context).copyWith( - color: Theme.of(context) - .extension()! - .accentColorDark), + color: Theme.of(context) + .extension()! + .accentColorDark, + ), ), onPressed: () { Navigator.of(context).pop(); @@ -340,7 +342,8 @@ class _ConfirmTransactionViewState final String unit; if (widget.isTokenTx) { unit = ref.watch( - pCurrentTokenWallet.select((value) => value!.tokenContract.symbol)); + pCurrentTokenWallet.select((value) => value!.tokenContract.symbol), + ); } else { unit = coin.ticker; } @@ -375,10 +378,12 @@ class _ConfirmTransactionViewState fee = widget.txData.fee; amountWithoutChange = (widget.txData.amountWithoutChange ?? Amount.zeroWith( - fractionDigits: wallet.cryptoCurrency.fractionDigits)) + + fractionDigits: wallet.cryptoCurrency.fractionDigits, + )) + (widget.txData.amountSparkWithoutChange ?? Amount.zeroWith( - fractionDigits: wallet.cryptoCurrency.fractionDigits)); + fractionDigits: wallet.cryptoCurrency.fractionDigits, + )); break; } } else { @@ -526,11 +531,11 @@ class _ConfirmTransactionViewState ], ), ), - if (coin != Coin.banano && coin != Coin.nano) + if (coin is! NanoCurrency) const SizedBox( height: 12, ), - if (coin != Coin.banano && coin != Coin.nano) + if (coin is! NanoCurrency) RoundedWhiteContainer( child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -570,13 +575,11 @@ class _ConfirmTransactionViewState ], ), ), - if (coin == Coin.epicCash && - widget.txData.noteOnChain!.isNotEmpty) + if (coin is Epiccash && widget.txData.noteOnChain!.isNotEmpty) const SizedBox( height: 12, ), - if (coin == Coin.epicCash && - widget.txData.noteOnChain!.isNotEmpty) + if (coin is Epiccash && widget.txData.noteOnChain!.isNotEmpty) RoundedWhiteContainer( child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, @@ -605,7 +608,7 @@ class _ConfirmTransactionViewState crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Text( - (coin == Coin.epicCash) ? "Local Note" : "Note", + (coin is Epiccash) ? "Local Note" : "Note", style: STextStyles.smallMed12(context), ), const SizedBox( @@ -688,7 +691,8 @@ class _ConfirmTransactionViewState Text( "Amount", style: STextStyles.desktopTextExtraExtraSmall( - context), + context, + ), ), const SizedBox( height: 2, @@ -696,15 +700,18 @@ class _ConfirmTransactionViewState Builder( builder: (context) { final externalCalls = ref.watch( - prefsChangeNotifierProvider.select( - (value) => value.externalCalls)); + prefsChangeNotifierProvider.select( + (value) => value.externalCalls, + ), + ); String fiatAmount = "N/A"; if (externalCalls) { final price = widget.isTokenTx ? ref .read( - priceAnd24hChangeNotifierProvider) + priceAnd24hChangeNotifierProvider, + ) .getTokenPrice( ref .read(pCurrentTokenWallet)! @@ -714,7 +721,8 @@ class _ConfirmTransactionViewState .item1 : ref .read( - priceAnd24hChangeNotifierProvider) + priceAnd24hChangeNotifierProvider, + ) .getPrice(coin) .item1; if (price > Decimal.zero) { @@ -724,7 +732,8 @@ class _ConfirmTransactionViewState .fiatString( locale: ref .read( - localeServiceChangeNotifierProvider) + localeServiceChangeNotifierProvider, + ) .locale, ); } @@ -734,14 +743,15 @@ class _ConfirmTransactionViewState children: [ SelectableText( ref.watch(pAmountFormatter(coin)).format( - amountWithoutChange, - ethContract: ref - .read(pCurrentTokenWallet) - ?.tokenContract), + amountWithoutChange, + ethContract: ref + .read(pCurrentTokenWallet) + ?.tokenContract, + ), style: STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( + .desktopTextExtraExtraSmall( + context, + ).copyWith( color: Theme.of(context) .extension()! .textDark, @@ -752,16 +762,20 @@ class _ConfirmTransactionViewState " | ", style: STextStyles .desktopTextExtraExtraSmall( - context), + context, + ), ), if (externalCalls) SelectableText( - "~$fiatAmount ${ref.watch(prefsChangeNotifierProvider.select( - (value) => value.currency, - ))}", + "~$fiatAmount ${ref.watch( + prefsChangeNotifierProvider.select( + (value) => value.currency, + ), + )}", style: STextStyles .desktopTextExtraExtraSmall( - context), + context, + ), ), ], ); @@ -787,7 +801,8 @@ class _ConfirmTransactionViewState ? "PayNym recipient" : "Send to", style: STextStyles.desktopTextExtraExtraSmall( - context), + context, + ), ), const SizedBox( height: 2, @@ -800,13 +815,13 @@ class _ConfirmTransactionViewState widget.txData.sparkRecipients!.first .address, style: STextStyles.desktopTextExtraExtraSmall( - context) - .copyWith( + context, + ).copyWith( color: Theme.of(context) .extension()! .textDark, ), - ) + ), ], ), ), @@ -827,7 +842,8 @@ class _ConfirmTransactionViewState Text( "Transaction fee", style: STextStyles.desktopTextExtraExtraSmall( - context), + context, + ), ), const SizedBox( height: 2, @@ -835,8 +851,8 @@ class _ConfirmTransactionViewState SelectableText( ref.watch(pAmountFormatter(coin)).format(fee!), style: STextStyles.desktopTextExtraExtraSmall( - context) - .copyWith( + context, + ).copyWith( color: Theme.of(context) .extension()! .textDark, @@ -892,17 +908,17 @@ class _ConfirmTransactionViewState mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ - if (coin == Coin.epicCash) + if (coin is Epiccash) Text( "On chain Note (optional)", style: STextStyles.smallMed12(context), textAlign: TextAlign.left, ), - if (coin == Coin.epicCash) + if (coin is Epiccash) const SizedBox( height: 8, ), - if (coin == Coin.epicCash) + if (coin is Epiccash) ClipRRect( borderRadius: BorderRadius.circular( Constants.size.circularBorderRadius, @@ -942,12 +958,12 @@ class _ConfirmTransactionViewState ), ), ), - if (coin == Coin.epicCash) + if (coin is Epiccash) const SizedBox( height: 12, ), SelectableText( - (coin == Coin.epicCash) + (coin is Epiccash) ? "Local Note (optional)" : "Note (optional)", style: @@ -1016,7 +1032,7 @@ class _ConfirmTransactionViewState ), const SizedBox( height: 20, - ) + ), ], ), ), @@ -1221,11 +1237,12 @@ class _ConfirmTransactionViewState } else { unawaited( showFloatingFlushBar( - type: FlushBarType.warning, - message: Util.isDesktop - ? "Invalid passphrase" - : "Invalid PIN", - context: context), + type: FlushBarType.warning, + message: Util.isDesktop + ? "Invalid passphrase" + : "Invalid PIN", + context: context, + ), ); } } diff --git a/lib/pages/send_view/frost_ms/frost_send_view.dart b/lib/pages/send_view/frost_ms/frost_send_view.dart index ccaf5452e..260cf866c 100644 --- a/lib/pages/send_view/frost_ms/frost_send_view.dart +++ b/lib/pages/send_view/frost_ms/frost_send_view.dart @@ -14,38 +14,38 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/frost_route_generator.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/pages/coin_control/coin_control_view.dart'; -import 'package:stackwallet/pages/send_view/frost_ms/recipient.dart'; -import 'package:stackwallet/providers/frost_wallet/frost_wallet_providers.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/coin_icon_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/show_loading.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/wallets/models/tx_data.dart'; -import 'package:stackwallet/wallets/wallet/impl/bitcoin_frost_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/coin_control_interface.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/fee_slider.dart'; -import 'package:stackwallet/widgets/frost_scaffold.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../../frost_route_generator.dart'; +import '../../../models/isar/models/isar_models.dart'; +import '../../coin_control/coin_control_view.dart'; +import 'recipient.dart'; +import '../../../providers/frost_wallet/frost_wallet_providers.dart'; +import '../../../providers/providers.dart'; +import '../../../themes/coin_icon_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/amount/amount_formatter.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/show_loading.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../wallets/models/tx_data.dart'; +import '../../../wallets/wallet/impl/bitcoin_frost_wallet.dart'; +import '../../../wallets/wallet/wallet_mixin_interfaces/coin_control_interface.dart'; +import '../../../widgets/background.dart'; +import '../../../widgets/conditional_parent.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/custom_buttons/blue_text_button.dart'; +import '../../../widgets/desktop/primary_button.dart'; +import '../../../widgets/desktop/secondary_button.dart'; +import '../../../widgets/fee_slider.dart'; +import '../../../widgets/frost_scaffold.dart'; +import '../../../widgets/icon_widgets/x_icon.dart'; +import '../../../widgets/rounded_white_container.dart'; +import '../../../widgets/stack_dialog.dart'; +import '../../../widgets/stack_text_field.dart'; +import '../../../widgets/textfield_icon_button.dart'; import 'package:tuple/tuple.dart'; class FrostSendView extends ConsumerStatefulWidget { @@ -58,7 +58,7 @@ class FrostSendView extends ConsumerStatefulWidget { static const String routeName = "/frostSendView"; final String walletId; - final Coin coin; + final CryptoCurrency coin; @override ConsumerState createState() => _FrostSendViewState(); @@ -69,7 +69,7 @@ class _FrostSendViewState extends ConsumerState { int _greatestWidgetIndex = 0; late final String walletId; - late final Coin coin; + late final CryptoCurrency coin; late TextEditingController noteController; late TextEditingController onChainNoteController; diff --git a/lib/pages/send_view/frost_ms/recipient.dart b/lib/pages/send_view/frost_ms/recipient.dart index 043f080f6..8bb6cbd12 100644 --- a/lib/pages/send_view/frost_ms/recipient.dart +++ b/lib/pages/send_view/frost_ms/recipient.dart @@ -2,27 +2,27 @@ import 'package:decimal/decimal.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/providers/global/locale_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/address_utils.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/amount/amount_input_formatter.dart'; -import 'package:stackwallet/utilities/amount/amount_unit.dart'; -import 'package:stackwallet/utilities/barcode_scanner_interface.dart'; -import 'package:stackwallet/utilities/clipboard_interface.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/clipboard_icon.dart'; -import 'package:stackwallet/widgets/icon_widgets/qrcode_icon.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../../providers/global/locale_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/address_utils.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/amount/amount_formatter.dart'; +import '../../../utilities/amount/amount_input_formatter.dart'; +import '../../../utilities/amount/amount_unit.dart'; +import '../../../utilities/barcode_scanner_interface.dart'; +import '../../../utilities/clipboard_interface.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/logger.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../widgets/custom_buttons/blue_text_button.dart'; +import '../../../widgets/icon_widgets/clipboard_icon.dart'; +import '../../../widgets/icon_widgets/qrcode_icon.dart'; +import '../../../widgets/icon_widgets/x_icon.dart'; +import '../../../widgets/rounded_container.dart'; +import '../../../widgets/stack_text_field.dart'; +import '../../../widgets/textfield_icon_button.dart'; //TODO: move the following two providers elsewhere final pClipboard = @@ -55,7 +55,7 @@ class Recipient extends ConsumerStatefulWidget { final int index; final int displayNumber; - final Coin coin; + final CryptoCurrency coin; final VoidCallback? remove; final VoidCallback? onChanged; @@ -324,7 +324,8 @@ class _RecipientState extends ConsumerState { final Amount amount = Decimal.parse(results["amount"]!) .toAmount( - fractionDigits: widget.coin.decimals, + fractionDigits: + widget.coin.fractionDigits, ); amountController.text = ref .read(pAmountFormatter(widget.coin)) @@ -409,7 +410,7 @@ class _RecipientState extends ConsumerState { textAlign: TextAlign.right, inputFormatters: [ AmountInputFormatter( - decimals: widget.coin.decimals, + decimals: widget.coin.fractionDigits, unit: ref.watch(pAmountUnit(widget.coin)), locale: locale, ), diff --git a/lib/pages/send_view/frost_ms/send_steps/frost_send_step_1a.dart b/lib/pages/send_view/frost_ms/send_steps/frost_send_step_1a.dart index d49474f6d..c25090fca 100644 --- a/lib/pages/send_view/frost_ms/send_steps/frost_send_step_1a.dart +++ b/lib/pages/send_view/frost_ms/send_steps/frost_send_step_1a.dart @@ -1,20 +1,20 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:qr_flutter/qr_flutter.dart'; -import 'package:stackwallet/frost_route_generator.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart'; -import 'package:stackwallet/providers/frost_wallet/frost_wallet_providers.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/wallet/impl/bitcoin_frost_wallet.dart'; -import 'package:stackwallet/widgets/custom_buttons/checkbox_text_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/simple_copy_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/detail_item.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../../frost_route_generator.dart'; +import '../../../wallet_view/transaction_views/transaction_details_view.dart'; +import '../../../../providers/frost_wallet/frost_wallet_providers.dart'; +import '../../../../providers/global/wallets_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/logger.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/wallet/impl/bitcoin_frost_wallet.dart'; +import '../../../../widgets/custom_buttons/checkbox_text_button.dart'; +import '../../../../widgets/custom_buttons/simple_copy_button.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/detail_item.dart'; +import '../../../../widgets/rounded_white_container.dart'; class FrostSendStep1a extends ConsumerStatefulWidget { const FrostSendStep1a({super.key}); diff --git a/lib/pages/send_view/frost_ms/send_steps/frost_send_step_1b.dart b/lib/pages/send_view/frost_ms/send_steps/frost_send_step_1b.dart index 5015110aa..9cac2cabc 100644 --- a/lib/pages/send_view/frost_ms/send_steps/frost_send_step_1b.dart +++ b/lib/pages/send_view/frost_ms/send_steps/frost_send_step_1b.dart @@ -1,22 +1,22 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/frost_route_generator.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/frost_wallet/frost_wallet_providers.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/services/frost.dart'; -import 'package:stackwallet/utilities/format.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/models/tx_data.dart'; -import 'package:stackwallet/wallets/wallet/impl/bitcoin_frost_wallet.dart'; -import 'package:stackwallet/widgets/custom_buttons/checkbox_text_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/frost_step_user_steps.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; -import 'package:stackwallet/widgets/textfields/frost_step_field.dart'; +import '../../../../frost_route_generator.dart'; +import '../../../../models/isar/models/isar_models.dart'; +import '../../../../providers/db/main_db_provider.dart'; +import '../../../../providers/frost_wallet/frost_wallet_providers.dart'; +import '../../../../providers/global/wallets_provider.dart'; +import '../../../../services/frost.dart'; +import '../../../../utilities/format.dart'; +import '../../../../utilities/logger.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/models/tx_data.dart'; +import '../../../../wallets/wallet/impl/bitcoin_frost_wallet.dart'; +import '../../../../widgets/custom_buttons/checkbox_text_button.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/frost_step_user_steps.dart'; +import '../../../../widgets/stack_dialog.dart'; +import '../../../../widgets/textfields/frost_step_field.dart'; class FrostSendStep1b extends ConsumerStatefulWidget { const FrostSendStep1b({super.key}); diff --git a/lib/pages/send_view/frost_ms/send_steps/frost_send_step_2.dart b/lib/pages/send_view/frost_ms/send_steps/frost_send_step_2.dart index 7fbea39da..db198831f 100644 --- a/lib/pages/send_view/frost_ms/send_steps/frost_send_step_2.dart +++ b/lib/pages/send_view/frost_ms/send_steps/frost_send_step_2.dart @@ -1,22 +1,22 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/frost_route_generator.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart'; -import 'package:stackwallet/providers/frost_wallet/frost_wallet_providers.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/services/frost.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/wallet/impl/bitcoin_frost_wallet.dart'; -import 'package:stackwallet/widgets/custom_buttons/frost_qr_dialog_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/simple_copy_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/detail_item.dart'; -import 'package:stackwallet/widgets/dialogs/frost/frost_error_dialog.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/textfields/frost_step_field.dart'; +import '../../../../frost_route_generator.dart'; +import '../../../wallet_view/transaction_views/transaction_details_view.dart'; +import '../../../../providers/frost_wallet/frost_wallet_providers.dart'; +import '../../../../providers/global/wallets_provider.dart'; +import '../../../../services/frost.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/logger.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/wallet/impl/bitcoin_frost_wallet.dart'; +import '../../../../widgets/custom_buttons/frost_qr_dialog_button.dart'; +import '../../../../widgets/custom_buttons/simple_copy_button.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/detail_item.dart'; +import '../../../../widgets/dialogs/frost/frost_error_dialog.dart'; +import '../../../../widgets/rounded_white_container.dart'; +import '../../../../widgets/textfields/frost_step_field.dart'; class FrostSendStep2 extends ConsumerStatefulWidget { const FrostSendStep2({super.key}); diff --git a/lib/pages/send_view/frost_ms/send_steps/frost_send_step_3.dart b/lib/pages/send_view/frost_ms/send_steps/frost_send_step_3.dart index 46bb5cdb0..6b3c40362 100644 --- a/lib/pages/send_view/frost_ms/send_steps/frost_send_step_3.dart +++ b/lib/pages/send_view/frost_ms/send_steps/frost_send_step_3.dart @@ -1,23 +1,23 @@ import 'package:coinlib_flutter/coinlib_flutter.dart' as cl; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/frost_route_generator.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart'; -import 'package:stackwallet/providers/frost_wallet/frost_wallet_providers.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/services/frost.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/wallet/impl/bitcoin_frost_wallet.dart'; -import 'package:stackwallet/widgets/custom_buttons/checkbox_text_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/frost_qr_dialog_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/simple_copy_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/detail_item.dart'; -import 'package:stackwallet/widgets/dialogs/frost/frost_error_dialog.dart'; -import 'package:stackwallet/widgets/frost_step_user_steps.dart'; -import 'package:stackwallet/widgets/textfields/frost_step_field.dart'; +import '../../../../frost_route_generator.dart'; +import '../../../wallet_view/transaction_views/transaction_details_view.dart'; +import '../../../../providers/frost_wallet/frost_wallet_providers.dart'; +import '../../../../providers/global/wallets_provider.dart'; +import '../../../../services/frost.dart'; +import '../../../../utilities/amount/amount.dart'; +import '../../../../utilities/logger.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/wallet/impl/bitcoin_frost_wallet.dart'; +import '../../../../widgets/custom_buttons/checkbox_text_button.dart'; +import '../../../../widgets/custom_buttons/frost_qr_dialog_button.dart'; +import '../../../../widgets/custom_buttons/simple_copy_button.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/detail_item.dart'; +import '../../../../widgets/dialogs/frost/frost_error_dialog.dart'; +import '../../../../widgets/frost_step_user_steps.dart'; +import '../../../../widgets/textfields/frost_step_field.dart'; class FrostSendStep3 extends ConsumerStatefulWidget { const FrostSendStep3({super.key}); diff --git a/lib/pages/send_view/frost_ms/send_steps/frost_send_step_4.dart b/lib/pages/send_view/frost_ms/send_steps/frost_send_step_4.dart index 2267e7226..59596e846 100644 --- a/lib/pages/send_view/frost_ms/send_steps/frost_send_step_4.dart +++ b/lib/pages/send_view/frost_ms/send_steps/frost_send_step_4.dart @@ -2,27 +2,26 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/frost_route_generator.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart'; -import 'package:stackwallet/pages/wallet_view/wallet_view.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/my_stack_view.dart'; -import 'package:stackwallet/providers/frost_wallet/frost_wallet_providers.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/show_loading.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/wallet/impl/bitcoin_frost_wallet.dart'; -import 'package:stackwallet/widgets/custom_buttons/simple_copy_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/detail_item.dart'; -import 'package:stackwallet/widgets/expandable.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../../../frost_route_generator.dart'; +import '../../../wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart'; +import '../../../wallet_view/wallet_view.dart'; +import '../../../../pages_desktop_specific/my_stack_view/my_stack_view.dart'; +import '../../../../providers/frost_wallet/frost_wallet_providers.dart'; +import '../../../../providers/global/wallets_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/amount/amount_formatter.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/logger.dart'; +import '../../../../utilities/show_loading.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../../wallets/wallet/impl/bitcoin_frost_wallet.dart'; +import '../../../../widgets/custom_buttons/simple_copy_button.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/detail_item.dart'; +import '../../../../widgets/expandable.dart'; +import '../../../../widgets/stack_dialog.dart'; class FrostSendStep4 extends ConsumerStatefulWidget { const FrostSendStep4({super.key}); @@ -93,7 +92,7 @@ class _FrostSendStep4State extends ConsumerState { height: 12, ), Text( - "Send ${cryptoCurrency.coin.ticker}", + "Send ${cryptoCurrency.ticker}", style: STextStyles.w600_20(context), ), const SizedBox( @@ -103,7 +102,7 @@ class _FrostSendStep4State extends ConsumerState { ? _Recipient( address: recipients[0].address, amount: ref - .watch(pAmountFormatter(cryptoCurrency.coin)) + .watch(pAmountFormatter(cryptoCurrency)) .format(recipients[0].amount), ) : Column( @@ -143,7 +142,7 @@ class _FrostSendStep4State extends ConsumerState { body: _Recipient( address: recipients[i].address, amount: ref - .watch(pAmountFormatter(cryptoCurrency.coin)) + .watch(pAmountFormatter(cryptoCurrency)) .format(recipients[i].amount), ), ), @@ -156,7 +155,7 @@ class _FrostSendStep4State extends ConsumerState { DetailItem( title: "Transaction fee", detail: ref - .watch(pAmountFormatter(cryptoCurrency.coin)) + .watch(pAmountFormatter(cryptoCurrency)) .format(ref.watch(pFrostTxData)!.fee!), horizontal: true, ), @@ -165,7 +164,7 @@ class _FrostSendStep4State extends ConsumerState { ), DetailItem( title: "Total", - detail: ref.watch(pAmountFormatter(cryptoCurrency.coin)).format( + detail: ref.watch(pAmountFormatter(cryptoCurrency)).format( ref.watch(pFrostTxData)!.fee! + recipients.map((e) => e.amount).reduce((v, e) => v += e)), horizontal: true, diff --git a/lib/pages/send_view/send_view.dart b/lib/pages/send_view/send_view.dart index fc0b89dc3..da10718c9 100644 --- a/lib/pages/send_view/send_view.dart +++ b/lib/pages/send_view/send_view.dart @@ -18,74 +18,80 @@ import 'package:flutter/services.dart'; import 'package:flutter_native_splash/cli_commands.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/models/paynym/paynym_account_lite.dart'; -import 'package:stackwallet/models/send_view_auto_fill_data.dart'; -import 'package:stackwallet/pages/address_book_views/address_book_view.dart'; -import 'package:stackwallet/pages/coin_control/coin_control_view.dart'; -import 'package:stackwallet/pages/send_view/confirm_transaction_view.dart'; -import 'package:stackwallet/pages/send_view/sub_widgets/building_transaction_dialog.dart'; -import 'package:stackwallet/pages/send_view/sub_widgets/firo_balance_selection_sheet.dart'; -import 'package:stackwallet/pages/send_view/sub_widgets/transaction_fee_selection_sheet.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/providers/ui/fee_rate_type_state_provider.dart'; -import 'package:stackwallet/providers/ui/preview_tx_button_state_provider.dart'; -import 'package:stackwallet/providers/wallet/public_private_balance_state_provider.dart'; -import 'package:stackwallet/route_generator.dart'; -import 'package:stackwallet/themes/coin_icon_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/address_utils.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/amount/amount_input_formatter.dart'; -import 'package:stackwallet/utilities/amount/amount_unit.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/barcode_scanner_interface.dart'; -import 'package:stackwallet/utilities/clipboard_interface.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/prefs.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/wallets/models/tx_data.dart'; -import 'package:stackwallet/wallets/wallet/impl/firo_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/coin_control_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart'; -import 'package:stackwallet/widgets/animated_text.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/fee_slider.dart'; -import 'package:stackwallet/widgets/icon_widgets/addressbook_icon.dart'; -import 'package:stackwallet/widgets/icon_widgets/clipboard_icon.dart'; -import 'package:stackwallet/widgets/icon_widgets/qrcode_icon.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../models/isar/models/isar_models.dart'; +import '../../models/paynym/paynym_account_lite.dart'; +import '../../models/send_view_auto_fill_data.dart'; +import '../address_book_views/address_book_view.dart'; +import '../coin_control/coin_control_view.dart'; +import 'confirm_transaction_view.dart'; +import 'sub_widgets/building_transaction_dialog.dart'; +import 'sub_widgets/firo_balance_selection_sheet.dart'; +import 'sub_widgets/transaction_fee_selection_sheet.dart'; +import '../../providers/providers.dart'; +import '../../providers/ui/fee_rate_type_state_provider.dart'; +import '../../providers/ui/preview_tx_button_state_provider.dart'; +import '../../providers/wallet/public_private_balance_state_provider.dart'; +import '../../route_generator.dart'; +import '../../themes/coin_icon_provider.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/address_utils.dart'; +import '../../utilities/amount/amount.dart'; +import '../../utilities/amount/amount_formatter.dart'; +import '../../utilities/amount/amount_input_formatter.dart'; +import '../../utilities/amount/amount_unit.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/barcode_scanner_interface.dart'; +import '../../utilities/clipboard_interface.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/enums/fee_rate_type_enum.dart'; +import '../../utilities/logger.dart'; +import '../../utilities/prefs.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import '../../wallets/crypto_currency/coins/epiccash.dart'; +import '../../wallets/crypto_currency/coins/ethereum.dart'; +import '../../wallets/crypto_currency/coins/firo.dart'; +import '../../wallets/crypto_currency/coins/monero.dart'; +import '../../wallets/crypto_currency/coins/stellar.dart'; +import '../../wallets/crypto_currency/coins/tezos.dart'; +import '../../wallets/crypto_currency/crypto_currency.dart'; +import '../../wallets/crypto_currency/intermediate/nano_currency.dart'; +import '../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../wallets/models/tx_data.dart'; +import '../../wallets/wallet/impl/firo_wallet.dart'; +import '../../wallets/wallet/wallet_mixin_interfaces/coin_control_interface.dart'; +import '../../wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart'; +import '../../wallets/wallet/wallet_mixin_interfaces/spark_interface.dart'; +import '../../widgets/animated_text.dart'; +import '../../widgets/background.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/custom_buttons/blue_text_button.dart'; +import '../../widgets/fee_slider.dart'; +import '../../widgets/icon_widgets/addressbook_icon.dart'; +import '../../widgets/icon_widgets/clipboard_icon.dart'; +import '../../widgets/icon_widgets/qrcode_icon.dart'; +import '../../widgets/icon_widgets/x_icon.dart'; +import '../../widgets/rounded_white_container.dart'; +import '../../widgets/stack_dialog.dart'; +import '../../widgets/stack_text_field.dart'; +import '../../widgets/textfield_icon_button.dart'; import 'package:tuple/tuple.dart'; class SendView extends ConsumerStatefulWidget { const SendView({ - Key? key, + super.key, required this.walletId, required this.coin, this.autoFillData, this.clipboard = const ClipboardWrapper(), this.barcodeScanner = const BarcodeScannerWrapper(), this.accountLite, - }) : super(key: key); + }); static const String routeName = "/sendView"; final String walletId; - final Coin coin; + final CryptoCurrency coin; final SendViewAutoFillData? autoFillData; final ClipboardInterface clipboard; final BarcodeScannerInterface barcodeScanner; @@ -97,7 +103,7 @@ class SendView extends ConsumerStatefulWidget { class _SendViewState extends ConsumerState { late final String walletId; - late final Coin coin; + late final CryptoCurrency coin; late final ClipboardInterface clipboard; late final BarcodeScannerInterface scanner; @@ -178,7 +184,7 @@ class _SendViewState extends ConsumerState { // autofill amount field if (results["amount"] != null) { final Amount amount = Decimal.parse(results["amount"]!).toAmount( - fractionDigits: coin.decimals, + fractionDigits: coin.fractionDigits, ); cryptoAmountController.text = ref.read(pAmountFormatter(coin)).format( amount, @@ -232,15 +238,15 @@ class _SendViewState extends ConsumerState { ref.read(priceAnd24hChangeNotifierProvider).getPrice(coin).item1; if (_price == Decimal.zero) { - amount = 0.toAmountAsRaw(fractionDigits: coin.decimals); + amount = 0.toAmountAsRaw(fractionDigits: coin.fractionDigits); } else { amount = baseAmount <= Amount.zero - ? 0.toAmountAsRaw(fractionDigits: coin.decimals) + ? 0.toAmountAsRaw(fractionDigits: coin.fractionDigits) : (baseAmount.decimal / _price) .toDecimal( - scaleOnInfinitePrecision: coin.decimals, + scaleOnInfinitePrecision: coin.fractionDigits, ) - .toAmount(fractionDigits: coin.decimals); + .toAmount(fractionDigits: coin.fractionDigits); } if (_cachedAmountToSend != null && _cachedAmountToSend == amount) { return; @@ -258,7 +264,7 @@ class _SendViewState extends ConsumerState { cryptoAmountController.text = amountString; _cryptoAmountChangeLock = false; } else { - amount = 0.toAmountAsRaw(fractionDigits: coin.decimals); + amount = 0.toAmountAsRaw(fractionDigits: coin.fractionDigits); _cryptoAmountChangeLock = true; cryptoAmountController.text = ""; _cryptoAmountChangeLock = false; @@ -309,11 +315,11 @@ class _SendViewState extends ConsumerState { _cryptoAmountChangedFeeUpdateTimer?.cancel(); _cryptoAmountChangedFeeUpdateTimer = Timer(updateFeesTimerDuration, () { - if (coin != Coin.epicCash && !_baseFocus.hasFocus) { + if (coin is! Epiccash && !_baseFocus.hasFocus) { setState(() { _calculateFeesFuture = calculateFees( amount == null - ? 0.toAmountAsRaw(fractionDigits: coin.decimals) + ? 0.toAmountAsRaw(fractionDigits: coin.fractionDigits) : amount!, ); }); @@ -330,11 +336,11 @@ class _SendViewState extends ConsumerState { void _baseAmountChanged() { _baseAmountChangedFeeUpdateTimer?.cancel(); _baseAmountChangedFeeUpdateTimer = Timer(updateFeesTimerDuration, () { - if (coin != Coin.epicCash && !_cryptoFocus.hasFocus) { + if (coin is! Epiccash && !_cryptoFocus.hasFocus) { setState(() { _calculateFeesFuture = calculateFees( ref.read(pSendAmount) == null - ? 0.toAmountAsRaw(fractionDigits: coin.decimals) + ? 0.toAmountAsRaw(fractionDigits: coin.fractionDigits) : ref.read(pSendAmount)!, ); }); @@ -356,8 +362,8 @@ class _SendViewState extends ConsumerState { final value = fee.contains(",") ? Decimal.parse(fee.replaceFirst(",", ".")) - .toAmount(fractionDigits: coin.decimals) - : Decimal.parse(fee).toAmount(fractionDigits: coin.decimals); + .toAmount(fractionDigits: coin.fractionDigits) + : Decimal.parse(fee).toAmount(fractionDigits: coin.fractionDigits); if (shouldSetState) { setState(() => _currentFee = value); @@ -455,7 +461,7 @@ class _SendViewState extends ConsumerState { } Amount fee; - if (coin == Coin.monero) { + if (coin is Monero) { MoneroTransactionPriority specialMoneroId; switch (ref.read(feeRateTypeStateProvider.state).state) { case FeeRateType.fast: @@ -552,7 +558,7 @@ class _SendViewState extends ConsumerState { final coinControlEnabled = ref.read(prefsChangeNotifierProvider).enableCoinControl; - if (coin != Coin.ethereum && + if (coin is! Ethereum && !(wallet is CoinControlInterface && coinControlEnabled) || (wallet is CoinControlInterface && coinControlEnabled && @@ -751,9 +757,7 @@ class _SendViewState extends ConsumerState { break; } } else { - final memo = coin == Coin.stellar || coin == Coin.stellarTestnet - ? memoController.text - : null; + final memo = coin is Stellar ? memoController.text : null; txDataFuture = wallet.prepareSend( txData: TxData( recipients: [ @@ -878,16 +882,16 @@ class _SendViewState extends ConsumerState { void initState() { coin = widget.coin; ref.refresh(feeSheetSessionCacheProvider); - _currentFee = 0.toAmountAsRaw(fractionDigits: coin.decimals); + _currentFee = 0.toAmountAsRaw(fractionDigits: coin.fractionDigits); _calculateFeesFuture = - calculateFees(0.toAmountAsRaw(fractionDigits: coin.decimals)); + calculateFees(0.toAmountAsRaw(fractionDigits: coin.fractionDigits)); _data = widget.autoFillData; walletId = widget.walletId; clipboard = widget.clipboard; scanner = widget.barcodeScanner; - isStellar = coin == Coin.stellar || coin == Coin.stellarTestnet; - isFiro = coin == Coin.firo || coin == Coin.firoTestNet; + isStellar = coin is Stellar; + isFiro = coin is Firo; sendToController = TextEditingController(); cryptoAmountController = TextEditingController(); @@ -905,7 +909,7 @@ class _SendViewState extends ConsumerState { if (_data!.amount != null) { final amount = Amount.fromDecimal( _data!.amount!, - fractionDigits: coin.decimals, + fractionDigits: coin.fractionDigits, ); cryptoAmountController.text = ref.read(pAmountFormatter(coin)).format( @@ -927,7 +931,7 @@ class _SendViewState extends ConsumerState { noteController.text = "PayNym send"; } - // if (coin != Coin.epicCash) { + // if (coin is! Epiccash) { // _cryptoFocus.addListener(() { // if (!_cryptoFocus.hasFocus && !_baseFocus.hasFocus) { // if (_amountToSend == null) { @@ -1005,8 +1009,8 @@ class _SendViewState extends ConsumerState { ref.listen(publicPrivateBalanceStateProvider, (previous, next) { if (ref.read(pSendAmount) == null) { setState(() { - _calculateFeesFuture = - calculateFees(0.toAmountAsRaw(fractionDigits: coin.decimals)); + _calculateFeesFuture = calculateFees( + 0.toAmountAsRaw(fractionDigits: coin.fractionDigits)); }); } else { setState(() { @@ -1019,7 +1023,7 @@ class _SendViewState extends ConsumerState { } // add listener for epic cash to strip http:// and https:// prefixes if the address also ocntains an @ symbol (indicating an epicbox address) - if (coin == Coin.epicCash) { + if (coin is Epiccash) { sendToController.addListener(() { _address = sendToController.text.trim(); @@ -1119,8 +1123,7 @@ class _SendViewState extends ConsumerState { style: STextStyles.label(context) .copyWith(fontSize: 10), ), - if (coin != Coin.firo && - coin != Coin.firoTestNet) + if (coin is! Firo) Text( "Available balance", style: STextStyles.label(context) @@ -1233,7 +1236,7 @@ class _SendViewState extends ConsumerState { style: STextStyles.smallMed12(context), textAlign: TextAlign.left, ), - // if (coin == Coin.monero) + // if (coin is Monero) // CustomTextButton( // text: "Use OpenAlias", // onTap: () async { @@ -1359,8 +1362,7 @@ class _SendViewState extends ConsumerState { ); } - if (coin == - Coin.epicCash) { + if (coin is Epiccash) { // strip http:// and https:// if content contains @ content = formatAddress( content, @@ -1433,10 +1435,7 @@ class _SendViewState extends ConsumerState { ), child: TextField( key: const Key("sendViewMemoFieldKey"), - maxLength: (coin == Coin.firo || - coin == Coin.firoTestNet) - ? 31 - : null, + maxLength: (coin is Firo) ? 31 : null, controller: memoController, readOnly: false, autocorrect: false, @@ -1527,7 +1526,8 @@ class _SendViewState extends ConsumerState { _data!.contactLabel == _address) { error = SparkInterface.validateSparkAddress( address: _data!.address, - isTestNet: coin.isTestNet, + isTestNet: coin.network == + CryptoCurrencyNetwork.test, ) ? "Unsupported" : null; @@ -1733,7 +1733,7 @@ class _SendViewState extends ConsumerState { style: STextStyles.smallMed12(context), textAlign: TextAlign.left, ), - if (coin != Coin.ethereum && coin != Coin.tezos) + if (coin is! Ethereum && coin is! Tezos) CustomTextButton( text: "Send all ${coin.ticker}", onTap: () async { @@ -1815,7 +1815,7 @@ class _SendViewState extends ConsumerState { textAlign: TextAlign.right, inputFormatters: [ AmountInputFormatter( - decimals: coin.decimals, + decimals: coin.fractionDigits, unit: ref.watch(pAmountUnit(coin)), locale: locale, ), @@ -1825,7 +1825,7 @@ class _SendViewState extends ConsumerState { // newValue) => // // RegExp(r'^([0-9]*[,.]?[0-9]{0,8}|[,.][0-9]{0,8})$') // // RegExp(r'^\d{1,3}([,\.]\d+)?|[,\.\d]+$') - // getAmountRegex(locale, coin.decimals) + // getAmountRegex(locale, coin.fractionDigits) // .hasMatch(newValue.text) // ? newValue // : oldValue), @@ -2001,17 +2001,17 @@ class _SendViewState extends ConsumerState { const SizedBox( height: 12, ), - if (coin == Coin.epicCash) + if (coin is Epiccash) Text( "On chain Note (optional)", style: STextStyles.smallMed12(context), textAlign: TextAlign.left, ), - if (coin == Coin.epicCash) + if (coin is Epiccash) const SizedBox( height: 8, ), - if (coin == Coin.epicCash) + if (coin is Epiccash) ClipRRect( borderRadius: BorderRadius.circular( Constants.size.circularBorderRadius, @@ -2055,12 +2055,12 @@ class _SendViewState extends ConsumerState { ), ), ), - if (coin == Coin.epicCash) + if (coin is Epiccash) const SizedBox( height: 12, ), Text( - (coin == Coin.epicCash) + (coin is Epiccash) ? "Local Note (optional)" : "Note (optional)", style: STextStyles.smallMed12(context), @@ -2111,26 +2111,23 @@ class _SendViewState extends ConsumerState { const SizedBox( height: 12, ), - if (coin != Coin.epicCash && - coin != Coin.nano && - coin != Coin.banano && - coin != Coin.tezos) + if (coin is! Epiccash && + coin is! NanoCurrency && + coin is! Tezos) Text( "Transaction fee (estimated)", style: STextStyles.smallMed12(context), textAlign: TextAlign.left, ), - if (coin != Coin.epicCash && - coin != Coin.nano && - coin != Coin.banano && - coin != Coin.tezos) + if (coin is! Epiccash && + coin is! NanoCurrency && + coin is! Tezos) const SizedBox( height: 8, ), - if (coin != Coin.epicCash && - coin != Coin.nano && - coin != Coin.banano && - coin != Coin.tezos) + if (coin is! Epiccash && + coin is! NanoCurrency && + coin is! Tezos) Stack( children: [ TextField( @@ -2187,7 +2184,8 @@ class _SendViewState extends ConsumerState { ?.decimal ?? Decimal.zero) .toAmount( - fractionDigits: coin.decimals, + fractionDigits: + coin.fractionDigits, ), updateChosen: (String fee) { if (fee == "custom") { diff --git a/lib/pages/send_view/sub_widgets/building_transaction_dialog.dart b/lib/pages/send_view/sub_widgets/building_transaction_dialog.dart index 8529925d6..f7dc832f8 100644 --- a/lib/pages/send_view/sub_widgets/building_transaction_dialog.dart +++ b/lib/pages/send_view/sub_widgets/building_transaction_dialog.dart @@ -12,14 +12,14 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/themes/coin_image_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/animated_widgets/rotating_arrows.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../../themes/coin_image_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../widgets/animated_widgets/rotating_arrows.dart'; +import '../../../widgets/desktop/secondary_button.dart'; +import '../../../widgets/stack_dialog.dart'; class BuildingTransactionDialog extends ConsumerStatefulWidget { const BuildingTransactionDialog({ @@ -30,7 +30,7 @@ class BuildingTransactionDialog extends ConsumerStatefulWidget { }); final VoidCallback onCancel; - final Coin coin; + final CryptoCurrency coin; final bool isSpark; @override diff --git a/lib/pages/send_view/sub_widgets/firo_balance_selection_sheet.dart b/lib/pages/send_view/sub_widgets/firo_balance_selection_sheet.dart index 6206f13f7..3a890718b 100644 --- a/lib/pages/send_view/sub_widgets/firo_balance_selection_sheet.dart +++ b/lib/pages/send_view/sub_widgets/firo_balance_selection_sheet.dart @@ -10,13 +10,13 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/providers/wallet/public_private_balance_state_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/wallet/impl/firo_wallet.dart'; +import '../../../providers/providers.dart'; +import '../../../providers/wallet/public_private_balance_state_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/amount/amount_formatter.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../wallets/wallet/impl/firo_wallet.dart'; class FiroBalanceSelectionSheet extends ConsumerStatefulWidget { const FiroBalanceSelectionSheet({ diff --git a/lib/pages/send_view/sub_widgets/sending_transaction_dialog.dart b/lib/pages/send_view/sub_widgets/sending_transaction_dialog.dart index 0376e9e3d..bd55b42b1 100644 --- a/lib/pages/send_view/sub_widgets/sending_transaction_dialog.dart +++ b/lib/pages/send_view/sub_widgets/sending_transaction_dialog.dart @@ -13,23 +13,23 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:lottie/lottie.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/themes/coin_image_provider.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../../themes/coin_image_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../widgets/desktop/desktop_dialog.dart'; +import '../../../widgets/stack_dialog.dart'; class SendingTransactionDialog extends ConsumerStatefulWidget { const SendingTransactionDialog({ - Key? key, + super.key, required this.coin, required this.controller, - }) : super(key: key); + }); - final Coin coin; + final CryptoCurrency coin; final ProgressAndSuccessController controller; @override diff --git a/lib/pages/send_view/sub_widgets/transaction_fee_selection_sheet.dart b/lib/pages/send_view/sub_widgets/transaction_fee_selection_sheet.dart index 8572d5037..1202138dd 100644 --- a/lib/pages/send_view/sub_widgets/transaction_fee_selection_sheet.dart +++ b/lib/pages/send_view/sub_widgets/transaction_fee_selection_sheet.dart @@ -11,23 +11,27 @@ import 'package:cw_core/monero_transaction_priority.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/paymint/fee_object_model.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/providers/ui/fee_rate_type_state_provider.dart'; -import 'package:stackwallet/providers/wallet/public_private_balance_state_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/eth/current_token_wallet_provider.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/wallets/wallet/impl/firo_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart'; -import 'package:stackwallet/widgets/animated_text.dart'; +import '../../../models/paymint/fee_object_model.dart'; +import '../../../providers/providers.dart'; +import '../../../providers/ui/fee_rate_type_state_provider.dart'; +import '../../../providers/wallet/public_private_balance_state_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/amount/amount_formatter.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/enums/fee_rate_type_enum.dart'; +import '../../../utilities/logger.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../wallets/crypto_currency/coins/ethereum.dart'; +import '../../../wallets/crypto_currency/coins/firo.dart'; +import '../../../wallets/crypto_currency/coins/monero.dart'; +import '../../../wallets/crypto_currency/coins/wownero.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../wallets/isar/providers/eth/current_token_wallet_provider.dart'; +import '../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../wallets/wallet/impl/firo_wallet.dart'; +import '../../../wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart'; +import '../../../widgets/animated_text.dart'; final feeSheetSessionCacheProvider = ChangeNotifierProvider((ref) { @@ -44,12 +48,12 @@ class FeeSheetSessionCache extends ChangeNotifier { class TransactionFeeSelectionSheet extends ConsumerStatefulWidget { const TransactionFeeSelectionSheet({ - Key? key, + super.key, required this.walletId, required this.amount, required this.updateChosen, this.isToken = false, - }) : super(key: key); + }); final String walletId; final Amount amount; @@ -79,7 +83,7 @@ class _TransactionFeeSelectionSheetState required Amount amount, required FeeRateType feeRateType, required int feeRate, - required Coin coin, + required CryptoCurrency coin, }) async { switch (feeRateType) { case FeeRateType.fast: @@ -87,11 +91,13 @@ class _TransactionFeeSelectionSheetState if (widget.isToken == false) { final wallet = ref.read(pWallets).getWallet(walletId); - if (coin == Coin.monero || coin == Coin.wownero) { + if (coin is Monero || coin is Wownero) { final fee = await wallet.estimateFeeFor( - amount, MoneroTransactionPriority.fast.raw!); + amount, + MoneroTransactionPriority.fast.raw!, + ); ref.read(feeSheetSessionCacheProvider).fast[amount] = fee; - } else if (coin == Coin.firo || coin == Coin.firoTestNet) { + } else if (coin is Firo) { final Amount fee; switch (ref.read(publicPrivateBalanceStateProvider.state).state) { case FiroType.spark: @@ -122,11 +128,13 @@ class _TransactionFeeSelectionSheetState if (ref.read(feeSheetSessionCacheProvider).average[amount] == null) { if (widget.isToken == false) { final wallet = ref.read(pWallets).getWallet(walletId); - if (coin == Coin.monero || coin == Coin.wownero) { + if (coin is Monero || coin is Wownero) { final fee = await wallet.estimateFeeFor( - amount, MoneroTransactionPriority.regular.raw!); + amount, + MoneroTransactionPriority.regular.raw!, + ); ref.read(feeSheetSessionCacheProvider).average[amount] = fee; - } else if (coin == Coin.firo || coin == Coin.firoTestNet) { + } else if (coin is Firo) { final Amount fee; switch (ref.read(publicPrivateBalanceStateProvider.state).state) { case FiroType.spark: @@ -156,11 +164,13 @@ class _TransactionFeeSelectionSheetState if (ref.read(feeSheetSessionCacheProvider).slow[amount] == null) { if (widget.isToken == false) { final wallet = ref.read(pWallets).getWallet(walletId); - if (coin == Coin.monero || coin == Coin.wownero) { + if (coin is Monero || coin is Wownero) { final fee = await wallet.estimateFeeFor( - amount, MoneroTransactionPriority.slow.raw!); + amount, + MoneroTransactionPriority.slow.raw!, + ); ref.read(feeSheetSessionCacheProvider).slow[amount] = fee; - } else if (coin == Coin.firo || coin == Coin.firoTestNet) { + } else if (coin is Firo) { final Amount fee; switch (ref.read(publicPrivateBalanceStateProvider.state).state) { case FiroType.spark: @@ -192,10 +202,12 @@ class _TransactionFeeSelectionSheetState } String estimatedTimeToBeIncludedInNextBlock( - int targetBlockTime, int estimatedNumberOfBlocks) { - int time = targetBlockTime * estimatedNumberOfBlocks; + int targetBlockTime, + int estimatedNumberOfBlocks, + ) { + final int time = targetBlockTime * estimatedNumberOfBlocks; - int hours = (time / 3600).floor(); + final int hours = (time / 3600).floor(); if (hours > 1) { return "~$hours hours"; } else if (hours == 1) { @@ -295,7 +307,7 @@ class _TransactionFeeSelectionSheetState ref.read(feeRateTypeStateProvider.state).state = FeeRateType.fast; } - String? fee = + final String? fee = getAmount(FeeRateType.fast, wallet.info.coin); if (fee != null) { widget.updateChosen(fee); @@ -364,8 +376,10 @@ class _TransactionFeeSelectionSheetState feeRate: feeObject!.fast, amount: amount, ), - builder: (_, - AsyncSnapshot snapshot) { + builder: ( + _, + AsyncSnapshot snapshot, + ) { if (snapshot.connectionState == ConnectionState.done && snapshot.hasData) { @@ -380,7 +394,8 @@ class _TransactionFeeSelectionSheetState false, )})", style: STextStyles.itemSubtitle( - context), + context, + ), textAlign: TextAlign.left, ); } else { @@ -388,7 +403,8 @@ class _TransactionFeeSelectionSheetState stringsToLoopThrough: stringsToLoopThrough, style: STextStyles.itemSubtitle( - context), + context, + ), ); } }, @@ -398,19 +414,16 @@ class _TransactionFeeSelectionSheetState const SizedBox( height: 2, ), - if (feeObject == null && - coin != Coin.ethereum) + if (feeObject == null && coin is! Ethereum) AnimatedText( stringsToLoopThrough: stringsToLoopThrough, style: STextStyles.itemSubtitle(context), ), - if (feeObject != null && - coin != Coin.ethereum) + if (feeObject != null && coin is! Ethereum) Text( estimatedTimeToBeIncludedInNextBlock( - Constants.targetBlockTimeInSeconds( - coin), + coin.targetBlockTimeSeconds, feeObject!.numberOfBlocksFast, ), style: STextStyles.itemSubtitle(context), @@ -418,7 +431,7 @@ class _TransactionFeeSelectionSheetState ), ], ), - ) + ), ], ), ), @@ -434,7 +447,8 @@ class _TransactionFeeSelectionSheetState ref.read(feeRateTypeStateProvider.state).state = FeeRateType.average; } - String? fee = getAmount(FeeRateType.average, coin); + final String? fee = + getAmount(FeeRateType.average, coin); if (fee != null) { widget.updateChosen(fee); } @@ -500,8 +514,10 @@ class _TransactionFeeSelectionSheetState feeRate: feeObject!.medium, amount: amount, ), - builder: (_, - AsyncSnapshot snapshot) { + builder: ( + _, + AsyncSnapshot snapshot, + ) { if (snapshot.connectionState == ConnectionState.done && snapshot.hasData) { @@ -516,7 +532,8 @@ class _TransactionFeeSelectionSheetState false, )})", style: STextStyles.itemSubtitle( - context), + context, + ), textAlign: TextAlign.left, ); } else { @@ -524,7 +541,8 @@ class _TransactionFeeSelectionSheetState stringsToLoopThrough: stringsToLoopThrough, style: STextStyles.itemSubtitle( - context), + context, + ), ); } }, @@ -534,19 +552,16 @@ class _TransactionFeeSelectionSheetState const SizedBox( height: 2, ), - if (feeObject == null && - coin != Coin.ethereum) + if (feeObject == null && coin is! Ethereum) AnimatedText( stringsToLoopThrough: stringsToLoopThrough, style: STextStyles.itemSubtitle(context), ), - if (feeObject != null && - coin != Coin.ethereum) + if (feeObject != null && coin is! Ethereum) Text( estimatedTimeToBeIncludedInNextBlock( - Constants.targetBlockTimeInSeconds( - coin), + coin.targetBlockTimeSeconds, feeObject!.numberOfBlocksAverage, ), style: STextStyles.itemSubtitle(context), @@ -570,7 +585,7 @@ class _TransactionFeeSelectionSheetState ref.read(feeRateTypeStateProvider.state).state = FeeRateType.slow; } - String? fee = getAmount(FeeRateType.slow, coin); + final String? fee = getAmount(FeeRateType.slow, coin); if (fee != null) { widget.updateChosen(fee); } @@ -636,8 +651,10 @@ class _TransactionFeeSelectionSheetState feeRate: feeObject!.slow, amount: amount, ), - builder: (_, - AsyncSnapshot snapshot) { + builder: ( + _, + AsyncSnapshot snapshot, + ) { if (snapshot.connectionState == ConnectionState.done && snapshot.hasData) { @@ -652,7 +669,8 @@ class _TransactionFeeSelectionSheetState false, )})", style: STextStyles.itemSubtitle( - context), + context, + ), textAlign: TextAlign.left, ); } else { @@ -660,7 +678,8 @@ class _TransactionFeeSelectionSheetState stringsToLoopThrough: stringsToLoopThrough, style: STextStyles.itemSubtitle( - context), + context, + ), ); } }, @@ -670,19 +689,16 @@ class _TransactionFeeSelectionSheetState const SizedBox( height: 2, ), - if (feeObject == null && - coin != Coin.ethereum) + if (feeObject == null && coin is! Ethereum) AnimatedText( stringsToLoopThrough: stringsToLoopThrough, style: STextStyles.itemSubtitle(context), ), - if (feeObject != null && - coin != Coin.ethereum) + if (feeObject != null && coin is! Ethereum) Text( estimatedTimeToBeIncludedInNextBlock( - Constants.targetBlockTimeInSeconds( - coin), + coin.targetBlockTimeSeconds, feeObject!.numberOfBlocksSlow, ), style: STextStyles.itemSubtitle(context), @@ -732,7 +748,8 @@ class _TransactionFeeSelectionSheetState onChanged: (x) { ref .read( - feeRateTypeStateProvider.state) + feeRateTypeStateProvider.state, + ) .state = FeeRateType.custom; Navigator.of(context).pop(); }, @@ -781,7 +798,7 @@ class _TransactionFeeSelectionSheetState ); } - String? getAmount(FeeRateType feeRateType, Coin coin) { + String? getAmount(FeeRateType feeRateType, CryptoCurrency coin) { try { switch (feeRateType) { case FeeRateType.fast: diff --git a/lib/pages/send_view/token_send_view.dart b/lib/pages/send_view/token_send_view.dart index 028538d63..40d73c917 100644 --- a/lib/pages/send_view/token_send_view.dart +++ b/lib/pages/send_view/token_send_view.dart @@ -15,46 +15,47 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/models/send_view_auto_fill_data.dart'; -import 'package:stackwallet/pages/address_book_views/address_book_view.dart'; -import 'package:stackwallet/pages/send_view/confirm_transaction_view.dart'; -import 'package:stackwallet/pages/send_view/sub_widgets/building_transaction_dialog.dart'; -import 'package:stackwallet/pages/send_view/sub_widgets/transaction_fee_selection_sheet.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/providers/ui/fee_rate_type_state_provider.dart'; -import 'package:stackwallet/providers/ui/preview_tx_button_state_provider.dart'; -import 'package:stackwallet/route_generator.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/address_utils.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/amount/amount_input_formatter.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/barcode_scanner_interface.dart'; -import 'package:stackwallet/utilities/clipboard_interface.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/prefs.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/eth/current_token_wallet_provider.dart'; -import 'package:stackwallet/wallets/isar/providers/eth/token_balance_provider.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/wallets/models/tx_data.dart'; -import 'package:stackwallet/widgets/animated_text.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/addressbook_icon.dart'; -import 'package:stackwallet/widgets/icon_widgets/clipboard_icon.dart'; -import 'package:stackwallet/widgets/icon_widgets/eth_token_icon.dart'; -import 'package:stackwallet/widgets/icon_widgets/qrcode_icon.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../models/isar/models/isar_models.dart'; +import '../../models/send_view_auto_fill_data.dart'; +import '../address_book_views/address_book_view.dart'; +import 'confirm_transaction_view.dart'; +import 'sub_widgets/building_transaction_dialog.dart'; +import 'sub_widgets/transaction_fee_selection_sheet.dart'; +import '../../providers/providers.dart'; +import '../../providers/ui/fee_rate_type_state_provider.dart'; +import '../../providers/ui/preview_tx_button_state_provider.dart'; +import '../../route_generator.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/address_utils.dart'; +import '../../utilities/amount/amount.dart'; +import '../../utilities/amount/amount_formatter.dart'; +import '../../utilities/amount/amount_input_formatter.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/barcode_scanner_interface.dart'; +import '../../utilities/clipboard_interface.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/enums/fee_rate_type_enum.dart'; +import '../../utilities/logger.dart'; +import '../../utilities/prefs.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import '../../wallets/crypto_currency/coins/epiccash.dart'; +import '../../wallets/crypto_currency/crypto_currency.dart'; +import '../../wallets/isar/providers/eth/current_token_wallet_provider.dart'; +import '../../wallets/isar/providers/eth/token_balance_provider.dart'; +import '../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../wallets/models/tx_data.dart'; +import '../../widgets/animated_text.dart'; +import '../../widgets/background.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/icon_widgets/addressbook_icon.dart'; +import '../../widgets/icon_widgets/clipboard_icon.dart'; +import '../../widgets/icon_widgets/eth_token_icon.dart'; +import '../../widgets/icon_widgets/qrcode_icon.dart'; +import '../../widgets/icon_widgets/x_icon.dart'; +import '../../widgets/stack_dialog.dart'; +import '../../widgets/stack_text_field.dart'; +import '../../widgets/textfield_icon_button.dart'; class TokenSendView extends ConsumerStatefulWidget { const TokenSendView({ @@ -70,7 +71,7 @@ class TokenSendView extends ConsumerStatefulWidget { static const String routeName = "/tokenSendView"; final String walletId; - final Coin coin; + final CryptoCurrency coin; final EthContract tokenContract; final SendViewAutoFillData? autoFillData; final ClipboardInterface clipboard; @@ -82,7 +83,7 @@ class TokenSendView extends ConsumerStatefulWidget { class _TokenSendViewState extends ConsumerState { late final String walletId; - late final Coin coin; + late final CryptoCurrency coin; late final EthContract tokenContract; late final ClipboardInterface clipboard; late final BarcodeScannerInterface scanner; @@ -317,7 +318,7 @@ class _TokenSendViewState extends ConsumerState { _cryptoAmountChangedFeeUpdateTimer?.cancel(); _cryptoAmountChangedFeeUpdateTimer = Timer(updateFeesTimerDuration, () { - if (coin != Coin.epicCash && !_baseFocus.hasFocus) { + if (coin is! Epiccash && !_baseFocus.hasFocus) { setState(() { _calculateFeesFuture = calculateFees(); }); @@ -329,7 +330,7 @@ class _TokenSendViewState extends ConsumerState { void _baseAmountChanged() { _baseAmountChangedFeeUpdateTimer?.cancel(); _baseAmountChangedFeeUpdateTimer = Timer(updateFeesTimerDuration, () { - if (coin != Coin.epicCash && !_cryptoFocus.hasFocus) { + if (coin is! Epiccash && !_cryptoFocus.hasFocus) { setState(() { _calculateFeesFuture = calculateFees(); }); @@ -1161,7 +1162,7 @@ class _TokenSendViewState extends ConsumerState { const SizedBox( height: 12, ), - if (coin != Coin.epicCash) + if (coin is! Epiccash) Text( "Transaction fee (estimated)", style: STextStyles.smallMed12(context), diff --git a/lib/pages/settings_views/global_settings_view/about_view.dart b/lib/pages/settings_views/global_settings_view/about_view.dart index 4f4b3074e..f4c3eb7ec 100644 --- a/lib/pages/settings_views/global_settings_view/about_view.dart +++ b/lib/pages/settings_views/global_settings_view/about_view.dart @@ -8,142 +8,29 @@ * */ -import 'dart:convert'; - import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_libepiccash/git_versions.dart' as EPIC_VERSIONS; -import 'package:flutter_libmonero/git_versions.dart' as MONERO_VERSIONS; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:lelantus/git_versions.dart' as FIRO_VERSIONS; import 'package:package_info_plus/package_info_plus.dart'; -import 'package:stackwallet/networking/http.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/prefs.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; import 'package:url_launcher/url_launcher.dart'; -const kGithubAPI = "https://api.github.com"; -const kGithubSearch = "/search/commits"; -const kGithubHead = "/repos"; - -enum CommitStatus { isHead, isOldCommit, notACommit, notLoaded } - -Future doesCommitExist( - String organization, - String project, - String commit, -) async { - Logging.instance.log("doesCommitExist", level: LogLevel.Info); - // final Client client = Client(); - HTTP client = HTTP(); - try { - final uri = Uri.parse( - "$kGithubAPI$kGithubHead/$organization/$project/commits/$commit"); - - final commitQuery = await client.get( - url: uri, - headers: {'Content-Type': 'application/json'}, - proxyInfo: Prefs.instance.useTor - ? TorService.sharedInstance.getProxyInfo() - : null, - ); - - final response = jsonDecode(commitQuery.body.toString()); - Logging.instance.log("doesCommitExist $project $commit", // $response", - level: LogLevel.Info); - bool isThereCommit; - try { - isThereCommit = response['sha'] == commit; - Logging.instance.log( - "$commit isThereCommit=$isThereCommit", - level: LogLevel.Info, - ); - return isThereCommit; - } catch (_) { - return false; - } - } catch (e, s) { - Logging.instance.log("$e $s", level: LogLevel.Error); - return false; - } -} - -Future isHeadCommit( - String organization, - String project, - String branch, - String commit, -) async { - Logging.instance.log("doesCommitExist", level: LogLevel.Info); - HTTP client = HTTP(); - try { - final uri = Uri.parse( - "$kGithubAPI$kGithubHead/$organization/$project/commits/$branch"); - - final commitQuery = await client.get( - url: uri, - headers: {'Content-Type': 'application/json'}, - proxyInfo: Prefs.instance.useTor - ? TorService.sharedInstance.getProxyInfo() - : null, - ); - - final response = jsonDecode(commitQuery.body.toString()); - Logging.instance.log( - "isHeadCommit $project $commit $branch", //$response", - level: LogLevel.Info, - ); - bool isHead; - try { - isHead = response['sha'] == commit; - Logging.instance.log( - "$commit isHead=$isHead", - level: LogLevel.Info, - ); - return isHead; - } catch (_) { - return false; - } - } catch (e, s) { - Logging.instance.log("$e $s", level: LogLevel.Error); - return false; - } -} +import '../../../app_config.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/git_status.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../widgets/background.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/custom_buttons/blue_text_button.dart'; +import '../../../widgets/rounded_white_container.dart'; class AboutView extends ConsumerWidget { - const AboutView({Key? key}) : super(key: key); + const AboutView({super.key}); static const String routeName = "/about"; @override Widget build(BuildContext context, WidgetRef ref) { - String firoCommit = FIRO_VERSIONS.getPluginVersion(); - String epicCashCommit = EPIC_VERSIONS.getPluginVersion(); - String moneroCommit = MONERO_VERSIONS.getPluginVersion(); - List futureFiroList = [ - doesCommitExist("cypherstack", "flutter_liblelantus", firoCommit), - isHeadCommit("cypherstack", "flutter_liblelantus", "main", firoCommit), - ]; - Future commitFiroFuture = Future.wait(futureFiroList); - List futureEpicList = [ - doesCommitExist("cypherstack", "flutter_libepiccash", epicCashCommit), - isHeadCommit( - "cypherstack", "flutter_libepiccash", "main", epicCashCommit), - ]; - Future commitEpicFuture = Future.wait(futureEpicList); - List futureMoneroList = [ - doesCommitExist("cypherstack", "flutter_libmonero", moneroCommit), - isHeadCommit("cypherstack", "flutter_libmonero", "main", moneroCommit), - ]; - Future commitMoneroFuture = Future.wait(futureMoneroList); - return Background( child: Scaffold( backgroundColor: Theme.of(context).extension()!.background, @@ -247,6 +134,29 @@ class AboutView extends ConsumerWidget { const SizedBox( height: 12, ), + RoundedWhiteContainer( + child: Column( + crossAxisAlignment: + CrossAxisAlignment.stretch, + children: [ + Text( + "Build commit", + style: STextStyles.titleBold12(context), + ), + const SizedBox( + height: 4, + ), + SelectableText( + GitStatus.appCommitHash, + style: + STextStyles.itemSubtitle(context), + ), + ], + ), + ), + const SizedBox( + height: 12, + ), RoundedWhiteContainer( child: Column( crossAxisAlignment: @@ -271,60 +181,24 @@ class AboutView extends ConsumerWidget { ); }, ), - const SizedBox( - height: 12, - ), - FutureBuilder( - future: commitFiroFuture, - builder: - (context, AsyncSnapshot snapshot) { - bool commitExists = false; - bool isHead = false; + if (AppConfig.coins.whereType().isNotEmpty) + const SizedBox( + height: 12, + ), + if (AppConfig.coins.whereType().isNotEmpty) + FutureBuilder( + future: GitStatus.getFiroCommitStatus(), + builder: ( + context, + AsyncSnapshot snapshot, + ) { CommitStatus stateOfCommit = CommitStatus.notLoaded; if (snapshot.connectionState == ConnectionState.done && snapshot.hasData) { - commitExists = snapshot.data![0] as bool; - isHead = snapshot.data![1] as bool; - if (commitExists && isHead) { - stateOfCommit = CommitStatus.isHead; - } else if (commitExists) { - stateOfCommit = CommitStatus.isOldCommit; - } else { - stateOfCommit = CommitStatus.notACommit; - } - } - TextStyle indicationStyle = - STextStyles.itemSubtitle(context); - switch (stateOfCommit) { - case CommitStatus.isHead: - indicationStyle = - STextStyles.itemSubtitle(context) - .copyWith( - color: Theme.of(context) - .extension()! - .accentColorGreen); - break; - case CommitStatus.isOldCommit: - indicationStyle = - STextStyles.itemSubtitle(context) - .copyWith( - color: Theme.of(context) - .extension()! - .accentColorYellow); - break; - case CommitStatus.notACommit: - indicationStyle = - STextStyles.itemSubtitle(context) - .copyWith( - color: Theme.of(context) - .extension()! - .accentColorRed); - break; - default: - break; + stateOfCommit = snapshot.data!; } return RoundedWhiteContainer( child: Column( @@ -339,68 +213,37 @@ class AboutView extends ConsumerWidget { height: 4, ), SelectableText( - firoCommit, - style: indicationStyle, + GitStatus.firoCommit, + style: GitStatus.styleForStatus( + stateOfCommit, + context, + ), ), ], ), ); - }), - const SizedBox( - height: 12, - ), - FutureBuilder( - future: commitEpicFuture, - builder: - (context, AsyncSnapshot snapshot) { - bool commitExists = false; - bool isHead = false; + }, + ), + if (AppConfig.coins.whereType().isNotEmpty) + const SizedBox( + height: 12, + ), + if (AppConfig.coins.whereType().isNotEmpty) + FutureBuilder( + future: GitStatus.getEpicCommitStatus(), + builder: ( + context, + AsyncSnapshot snapshot, + ) { CommitStatus stateOfCommit = CommitStatus.notLoaded; if (snapshot.connectionState == ConnectionState.done && snapshot.hasData) { - commitExists = snapshot.data![0] as bool; - isHead = snapshot.data![1] as bool; - if (commitExists && isHead) { - stateOfCommit = CommitStatus.isHead; - } else if (commitExists) { - stateOfCommit = CommitStatus.isOldCommit; - } else { - stateOfCommit = CommitStatus.notACommit; - } - } - TextStyle indicationStyle = - STextStyles.itemSubtitle(context); - switch (stateOfCommit) { - case CommitStatus.isHead: - indicationStyle = - STextStyles.itemSubtitle(context) - .copyWith( - color: Theme.of(context) - .extension()! - .accentColorGreen); - break; - case CommitStatus.isOldCommit: - indicationStyle = - STextStyles.itemSubtitle(context) - .copyWith( - color: Theme.of(context) - .extension()! - .accentColorYellow); - break; - case CommitStatus.notACommit: - indicationStyle = - STextStyles.itemSubtitle(context) - .copyWith( - color: Theme.of(context) - .extension()! - .accentColorRed); - break; - default: - break; + stateOfCommit = snapshot.data!; } + return RoundedWhiteContainer( child: Column( crossAxisAlignment: @@ -414,67 +257,35 @@ class AboutView extends ConsumerWidget { height: 4, ), SelectableText( - epicCashCommit, - style: indicationStyle, + GitStatus.epicCashCommit, + style: GitStatus.styleForStatus( + stateOfCommit, + context, + ), ), ], ), ); - }), - const SizedBox( - height: 12, - ), - FutureBuilder( - future: commitMoneroFuture, - builder: - (context, AsyncSnapshot snapshot) { - bool commitExists = false; - bool isHead = false; + }, + ), + if (AppConfig.coins.whereType().isNotEmpty) + const SizedBox( + height: 12, + ), + if (AppConfig.coins.whereType().isNotEmpty) + FutureBuilder( + future: GitStatus.getMoneroCommitStatus(), + builder: ( + context, + AsyncSnapshot snapshot, + ) { CommitStatus stateOfCommit = CommitStatus.notLoaded; if (snapshot.connectionState == ConnectionState.done && snapshot.hasData) { - commitExists = snapshot.data![0] as bool; - isHead = snapshot.data![1] as bool; - if (commitExists && isHead) { - stateOfCommit = CommitStatus.isHead; - } else if (commitExists) { - stateOfCommit = CommitStatus.isOldCommit; - } else { - stateOfCommit = CommitStatus.notACommit; - } - } - TextStyle indicationStyle = - STextStyles.itemSubtitle(context); - switch (stateOfCommit) { - case CommitStatus.isHead: - indicationStyle = - STextStyles.itemSubtitle(context) - .copyWith( - color: Theme.of(context) - .extension()! - .accentColorGreen); - break; - case CommitStatus.isOldCommit: - indicationStyle = - STextStyles.itemSubtitle(context) - .copyWith( - color: Theme.of(context) - .extension()! - .accentColorYellow); - break; - case CommitStatus.notACommit: - indicationStyle = - STextStyles.itemSubtitle(context) - .copyWith( - color: Theme.of(context) - .extension()! - .accentColorRed); - break; - default: - break; + stateOfCommit = snapshot.data!; } return RoundedWhiteContainer( child: Column( @@ -489,13 +300,17 @@ class AboutView extends ConsumerWidget { height: 4, ), SelectableText( - moneroCommit, - style: indicationStyle, + GitStatus.moneroCommit, + style: GitStatus.styleForStatus( + stateOfCommit, + context, + ), ), ], ), ); - }), + }, + ), const SizedBox( height: 12, ), @@ -522,32 +337,34 @@ class AboutView extends ConsumerWidget { ], ), ), - const SizedBox( - height: 12, - ), - RoundedWhiteContainer( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "Tezos functionality", - style: STextStyles.titleBold12(context), - ), - const SizedBox( - height: 4, - ), - CustomTextButton( - text: "Powered by TzKT API", - onTap: () { - launchUrl( - Uri.parse("https://tzkt.io"), - mode: LaunchMode.externalApplication, - ); - }, - ), - ], + if (AppConfig.coins.whereType().isNotEmpty) + const SizedBox( + height: 12, + ), + if (AppConfig.coins.whereType().isNotEmpty) + RoundedWhiteContainer( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "Tezos functionality", + style: STextStyles.titleBold12(context), + ), + const SizedBox( + height: 4, + ), + CustomTextButton( + text: "Powered by TzKT API", + onTap: () { + launchUrl( + Uri.parse("https://tzkt.io"), + mode: LaunchMode.externalApplication, + ); + }, + ), + ], + ), ), - ), const SizedBox( height: 12, ), @@ -558,8 +375,9 @@ class AboutView extends ConsumerWidget { style: STextStyles.label(context), children: [ const TextSpan( - text: - "By using Stack Wallet, you agree to the "), + text: + "By using ${AppConfig.appName}, you agree to the ", + ), TextSpan( text: "Terms of service", style: STextStyles.richLink(context), @@ -567,7 +385,8 @@ class AboutView extends ConsumerWidget { ..onTap = () { launchUrl( Uri.parse( - "https://stackwallet.com/terms-of-service.html"), + "https://stackwallet.com/terms-of-service.html", + ), mode: LaunchMode.externalApplication, ); }, @@ -580,7 +399,8 @@ class AboutView extends ConsumerWidget { ..onTap = () { launchUrl( Uri.parse( - "https://stackwallet.com/privacy-policy.html"), + "https://stackwallet.com/privacy-policy.html", + ), mode: LaunchMode.externalApplication, ); }, diff --git a/lib/pages/settings_views/global_settings_view/advanced_views/advanced_settings_view.dart b/lib/pages/settings_views/global_settings_view/advanced_views/advanced_settings_view.dart index dcc3ec5d5..7de750ae3 100644 --- a/lib/pages/settings_views/global_settings_view/advanced_views/advanced_settings_view.dart +++ b/lib/pages/settings_views/global_settings_view/advanced_views/advanced_settings_view.dart @@ -10,19 +10,19 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/advanced_views/debug_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/advanced_views/manage_coin_units/manage_coin_units_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/advanced_views/manage_explorer_view.dart'; -import 'package:stackwallet/pages/stack_privacy_calls.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/choose_coin_view.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/draggable_switch_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import 'debug_view.dart'; +import 'manage_coin_units/manage_coin_units_view.dart'; +import 'manage_explorer_view.dart'; +import '../../../stack_privacy_calls.dart'; +import '../../../../providers/global/prefs_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/choose_coin_view.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/custom_buttons/draggable_switch_button.dart'; +import '../../../../widgets/rounded_white_container.dart'; import 'package:tuple/tuple.dart'; class AdvancedSettingsView extends StatelessWidget { diff --git a/lib/pages/settings_views/global_settings_view/advanced_views/debug_view.dart b/lib/pages/settings_views/global_settings_view/advanced_views/debug_view.dart index 622a4cafe..8bbaf9afd 100644 --- a/lib/pages/settings_views/global_settings_view/advanced_views/debug_view.dart +++ b/lib/pages/settings_views/global_settings_view/advanced_views/debug_view.dart @@ -23,27 +23,27 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:lelantus/git_versions.dart' as FIRO_VERSIONS; import 'package:package_info_plus/package_info_plus.dart'; -import 'package:stackwallet/models/isar/models/log.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/helpers/swb_file_system.dart'; -import 'package:stackwallet/providers/global/debug_service_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/clipboard_interface.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/stack_file_system.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/custom_loading_overlay.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../../../models/isar/models/log.dart'; +import '../../../../notifications/show_flush_bar.dart'; +import '../stack_backup_views/helpers/swb_file_system.dart'; +import '../../../../providers/global/debug_service_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/clipboard_interface.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/logger.dart'; +import '../../../../utilities/stack_file_system.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/custom_buttons/blue_text_button.dart'; +import '../../../../widgets/custom_loading_overlay.dart'; +import '../../../../widgets/icon_widgets/x_icon.dart'; +import '../../../../widgets/rounded_container.dart'; +import '../../../../widgets/stack_dialog.dart'; +import '../../../../widgets/stack_text_field.dart'; +import '../../../../widgets/textfield_icon_button.dart'; class DebugView extends ConsumerStatefulWidget { const DebugView({Key? key}) : super(key: key); diff --git a/lib/pages/settings_views/global_settings_view/advanced_views/manage_coin_units/choose_unit_sheet.dart b/lib/pages/settings_views/global_settings_view/advanced_views/manage_coin_units/choose_unit_sheet.dart index d5ef002b7..e636edcce 100644 --- a/lib/pages/settings_views/global_settings_view/advanced_views/manage_coin_units/choose_unit_sheet.dart +++ b/lib/pages/settings_views/global_settings_view/advanced_views/manage_coin_units/choose_unit_sheet.dart @@ -1,19 +1,19 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/amount/amount_unit.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; +import '../../../../../themes/stack_colors.dart'; +import '../../../../../utilities/amount/amount_formatter.dart'; +import '../../../../../utilities/amount/amount_unit.dart'; +import '../../../../../utilities/constants.dart'; +import '../../../../../utilities/text_styles.dart'; +import '../../../../../wallets/crypto_currency/crypto_currency.dart'; class ChooseUnitSheet extends ConsumerStatefulWidget { const ChooseUnitSheet({ - Key? key, + super.key, required this.coin, - }) : super(key: key); + }); - final Coin coin; + final CryptoCurrency coin; @override ConsumerState createState() => _ChooseUnitSheetState(); diff --git a/lib/pages/settings_views/global_settings_view/advanced_views/manage_coin_units/edit_coin_units_view.dart b/lib/pages/settings_views/global_settings_view/advanced_views/manage_coin_units/edit_coin_units_view.dart index bf06ebd2c..65cf6cbd6 100644 --- a/lib/pages/settings_views/global_settings_view/advanced_views/manage_coin_units/edit_coin_units_view.dart +++ b/lib/pages/settings_views/global_settings_view/advanced_views/manage_coin_units/edit_coin_units_view.dart @@ -2,34 +2,34 @@ import 'package:dropdown_button2/dropdown_button2.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/advanced_views/manage_coin_units/choose_unit_sheet.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/amount/amount_unit.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import 'choose_unit_sheet.dart'; +import '../../../../../providers/global/prefs_provider.dart'; +import '../../../../../themes/stack_colors.dart'; +import '../../../../../utilities/amount/amount_formatter.dart'; +import '../../../../../utilities/amount/amount_unit.dart'; +import '../../../../../utilities/assets.dart'; +import '../../../../../utilities/constants.dart'; +import '../../../../../utilities/text_styles.dart'; +import '../../../../../utilities/util.dart'; +import '../../../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../../../widgets/background.dart'; +import '../../../../../widgets/conditional_parent.dart'; +import '../../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../../../widgets/desktop/primary_button.dart'; +import '../../../../../widgets/desktop/secondary_button.dart'; +import '../../../../../widgets/icon_widgets/x_icon.dart'; +import '../../../../../widgets/stack_text_field.dart'; +import '../../../../../widgets/textfield_icon_button.dart'; class EditCoinUnitsView extends ConsumerStatefulWidget { const EditCoinUnitsView({ - Key? key, + super.key, required this.coin, - }) : super(key: key); + }); - final Coin coin; + final CryptoCurrency coin; static const String routeName = "/editCoinUnitsView"; diff --git a/lib/pages/settings_views/global_settings_view/advanced_views/manage_coin_units/manage_coin_units_view.dart b/lib/pages/settings_views/global_settings_view/advanced_views/manage_coin_units/manage_coin_units_view.dart index f562b911e..cd2f7d231 100644 --- a/lib/pages/settings_views/global_settings_view/advanced_views/manage_coin_units/manage_coin_units_view.dart +++ b/lib/pages/settings_views/global_settings_view/advanced_views/manage_coin_units/manage_coin_units_view.dart @@ -3,27 +3,28 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/advanced_views/manage_coin_units/edit_coin_units_view.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/themes/coin_icon_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import 'edit_coin_units_view.dart'; +import '../../../../../providers/global/prefs_provider.dart'; +import '../../../../../app_config.dart'; +import '../../../../../themes/coin_icon_provider.dart'; +import '../../../../../themes/stack_colors.dart'; +import '../../../../../utilities/assets.dart'; +import '../../../../../utilities/text_styles.dart'; +import '../../../../../utilities/util.dart'; +import '../../../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../../../widgets/background.dart'; +import '../../../../../widgets/conditional_parent.dart'; +import '../../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../../../widgets/rounded_white_container.dart'; class ManageCoinUnitsView extends ConsumerWidget { - const ManageCoinUnitsView({Key? key}) : super(key: key); + const ManageCoinUnitsView({super.key}); static const String routeName = "/manageCoinUnitsView"; - void onEditPressed(Coin coin, BuildContext context) { + void onEditPressed(CryptoCurrency coin, BuildContext context) { if (Util.isDesktop) { showDialog( context: context, @@ -39,14 +40,17 @@ class ManageCoinUnitsView extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { - bool showTestNet = ref.watch( + final showTestNet = ref.watch( prefsChangeNotifierProvider.select((value) => value.showTestNetCoins), ); - final _coins = Coin.values.where((e) => e != Coin.firoTestNet).toList(); + final _coins = AppConfig.coins + .where((e) => e is! Firo && e.network != CryptoCurrencyNetwork.test) + .toList(); - List coins = - showTestNet ? _coins : _coins.where((e) => !e.isTestNet).toList(); + final coins = showTestNet + ? _coins + : _coins.where((e) => e.network != CryptoCurrencyNetwork.test).toList(); return ConditionalParent( condition: Util.isDesktop, diff --git a/lib/pages/settings_views/global_settings_view/advanced_views/manage_explorer_view.dart b/lib/pages/settings_views/global_settings_view/advanced_views/manage_explorer_view.dart index 9242731d1..b688a1f6d 100644 --- a/lib/pages/settings_views/global_settings_view/advanced_views/manage_explorer_view.dart +++ b/lib/pages/settings_views/global_settings_view/advanced_views/manage_explorer_view.dart @@ -10,23 +10,23 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/block_explorers.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/block_explorers.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/rounded_white_container.dart'; class ManageExplorerView extends ConsumerStatefulWidget { const ManageExplorerView({ - Key? key, + super.key, required this.coin, - }) : super(key: key); + }); static const String routeName = "/manageExplorer"; - final Coin coin; + final CryptoCurrency coin; @override ConsumerState createState() => _ManageExplorerViewState(); diff --git a/lib/pages/settings_views/global_settings_view/appearance_settings/appearance_settings_view.dart b/lib/pages/settings_views/global_settings_view/appearance_settings/appearance_settings_view.dart index 126b87060..6981508e6 100644 --- a/lib/pages/settings_views/global_settings_view/appearance_settings/appearance_settings_view.dart +++ b/lib/pages/settings_views/global_settings_view/appearance_settings/appearance_settings_view.dart @@ -10,17 +10,17 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/appearance_settings/manage_themes.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/theme_options_widget.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/draggable_switch_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import 'manage_themes.dart'; +import 'sub_widgets/theme_options_widget.dart'; +import '../../../../providers/providers.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/custom_buttons/draggable_switch_button.dart'; +import '../../../../widgets/desktop/secondary_button.dart'; +import '../../../../widgets/rounded_white_container.dart'; class AppearanceSettingsView extends ConsumerWidget { const AppearanceSettingsView({Key? key}) : super(key: key); diff --git a/lib/pages/settings_views/global_settings_view/appearance_settings/manage_themes.dart b/lib/pages/settings_views/global_settings_view/appearance_settings/manage_themes.dart index 5b14a022c..bea81abba 100644 --- a/lib/pages/settings_views/global_settings_view/appearance_settings/manage_themes.dart +++ b/lib/pages/settings_views/global_settings_view/appearance_settings/manage_themes.dart @@ -13,23 +13,23 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/models/isar/stack_theme.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/install_theme_from_file_dialog.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/stack_theme_card.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/themes/theme_service.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/loading_indicator.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../../models/isar/stack_theme.dart'; +import 'sub_widgets/install_theme_from_file_dialog.dart'; +import 'sub_widgets/stack_theme_card.dart'; +import '../../../../providers/db/main_db_provider.dart'; +import '../../../../providers/global/prefs_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../themes/theme_service.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/conditional_parent.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/desktop/secondary_button.dart'; +import '../../../../widgets/loading_indicator.dart'; +import '../../../../widgets/rounded_white_container.dart'; import 'package:tuple/tuple.dart'; class ManageThemesView extends ConsumerStatefulWidget { diff --git a/lib/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/install_theme_from_file_dialog.dart b/lib/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/install_theme_from_file_dialog.dart index 812fcc94b..1574c3cfe 100644 --- a/lib/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/install_theme_from_file_dialog.dart +++ b/lib/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/install_theme_from_file_dialog.dart @@ -15,16 +15,16 @@ import 'package:file_picker/file_picker.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/themes/theme_service.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/show_loading.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../../../../themes/stack_colors.dart'; +import '../../../../../themes/theme_service.dart'; +import '../../../../../utilities/assets.dart'; +import '../../../../../utilities/logger.dart'; +import '../../../../../utilities/show_loading.dart'; +import '../../../../../utilities/text_styles.dart'; +import '../../../../../utilities/util.dart'; +import '../../../../../widgets/desktop/primary_button.dart'; +import '../../../../../widgets/desktop/secondary_button.dart'; +import '../../../../../widgets/stack_dialog.dart'; class InstallThemeFromFileDialog extends ConsumerStatefulWidget { const InstallThemeFromFileDialog({Key? key}) : super(key: key); diff --git a/lib/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/stack_theme_card.dart b/lib/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/stack_theme_card.dart index 003063bde..5b9c2fe90 100644 --- a/lib/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/stack_theme_card.dart +++ b/lib/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/stack_theme_card.dart @@ -15,22 +15,22 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/isar/stack_theme.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/themes/theme_service.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/show_loading.dart'; -import 'package:stackwallet/utilities/stack_file_system.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/animated_text.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../../../../models/isar/stack_theme.dart'; +import '../../../../../notifications/show_flush_bar.dart'; +import '../../../../../providers/db/main_db_provider.dart'; +import '../../../../../providers/global/prefs_provider.dart'; +import '../../../../../themes/stack_colors.dart'; +import '../../../../../themes/theme_service.dart'; +import '../../../../../utilities/logger.dart'; +import '../../../../../utilities/show_loading.dart'; +import '../../../../../utilities/stack_file_system.dart'; +import '../../../../../utilities/text_styles.dart'; +import '../../../../../utilities/util.dart'; +import '../../../../../widgets/animated_text.dart'; +import '../../../../../widgets/desktop/primary_button.dart'; +import '../../../../../widgets/desktop/secondary_button.dart'; +import '../../../../../widgets/rounded_white_container.dart'; +import '../../../../../widgets/stack_dialog.dart'; class StackThemeCard extends ConsumerStatefulWidget { const StackThemeCard({ diff --git a/lib/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/theme_option.dart b/lib/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/theme_option.dart index a129147e0..57cf428d5 100644 --- a/lib/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/theme_option.dart +++ b/lib/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/theme_option.dart @@ -9,9 +9,9 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; +import '../../../../../themes/stack_colors.dart'; +import '../../../../../utilities/constants.dart'; +import '../../../../../utilities/text_styles.dart'; class ThemeOption extends StatelessWidget { const ThemeOption({ diff --git a/lib/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/theme_options_widget.dart b/lib/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/theme_options_widget.dart index bf8791542..8f3a78678 100644 --- a/lib/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/theme_options_widget.dart +++ b/lib/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/theme_options_widget.dart @@ -12,18 +12,18 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/isar/stack_theme.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/theme_option.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/appearance_settings/system_brightness_theme_selection_view.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/themes/theme_service.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; +import '../../../../../models/isar/stack_theme.dart'; +import 'theme_option.dart'; +import '../system_brightness_theme_selection_view.dart'; +import '../../../../../providers/db/main_db_provider.dart'; +import '../../../../../providers/global/prefs_provider.dart'; +import '../../../../../themes/stack_colors.dart'; +import '../../../../../themes/theme_providers.dart'; +import '../../../../../themes/theme_service.dart'; +import '../../../../../utilities/constants.dart'; +import '../../../../../utilities/text_styles.dart'; +import '../../../../../widgets/conditional_parent.dart'; +import '../../../../../widgets/custom_buttons/blue_text_button.dart'; import 'package:tuple/tuple.dart'; class ThemeOptionsWidget extends ConsumerStatefulWidget { diff --git a/lib/pages/settings_views/global_settings_view/appearance_settings/system_brightness_theme_selection_view.dart b/lib/pages/settings_views/global_settings_view/appearance_settings/system_brightness_theme_selection_view.dart index 5bb416284..85154430e 100644 --- a/lib/pages/settings_views/global_settings_view/appearance_settings/system_brightness_theme_selection_view.dart +++ b/lib/pages/settings_views/global_settings_view/appearance_settings/system_brightness_theme_selection_view.dart @@ -10,15 +10,15 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/theme_option.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/themes/theme_service.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import 'sub_widgets/theme_option.dart'; +import '../../../../providers/global/prefs_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../themes/theme_providers.dart'; +import '../../../../themes/theme_service.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/rounded_white_container.dart'; import 'package:tuple/tuple.dart'; class SystemBrightnessThemeSelectionView extends ConsumerStatefulWidget { diff --git a/lib/pages/settings_views/global_settings_view/currency_view.dart b/lib/pages/settings_views/global_settings_view/currency_view.dart index cb3a3478b..c9b618b1e 100644 --- a/lib/pages/settings_views/global_settings_view/currency_view.dart +++ b/lib/pages/settings_views/global_settings_view/currency_view.dart @@ -11,23 +11,23 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/providers/global/base_currencies_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../../providers/global/base_currencies_provider.dart'; +import '../../../providers/providers.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../widgets/background.dart'; +import '../../../widgets/conditional_parent.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/desktop/primary_button.dart'; +import '../../../widgets/desktop/secondary_button.dart'; +import '../../../widgets/icon_widgets/x_icon.dart'; +import '../../../widgets/rounded_container.dart'; +import '../../../widgets/rounded_white_container.dart'; +import '../../../widgets/stack_text_field.dart'; +import '../../../widgets/textfield_icon_button.dart'; class BaseCurrencySettingsView extends ConsumerStatefulWidget { const BaseCurrencySettingsView({Key? key}) : super(key: key); diff --git a/lib/pages/settings_views/global_settings_view/delete_account_view.dart b/lib/pages/settings_views/global_settings_view/delete_account_view.dart index f6acc0ac8..4294592a3 100644 --- a/lib/pages/settings_views/global_settings_view/delete_account_view.dart +++ b/lib/pages/settings_views/global_settings_view/delete_account_view.dart @@ -9,17 +9,17 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/db/hive/db.dart'; -import 'package:stackwallet/pages/intro_view.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../../db/hive/db.dart'; +import '../../intro_view.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/desktop/desktop_app_bar.dart'; +import '../../../widgets/desktop/desktop_scaffold.dart'; +import '../../../widgets/desktop/primary_button.dart'; +import '../../../widgets/rounded_white_container.dart'; +import '../../../widgets/stack_dialog.dart'; class DeleteAccountView extends StatefulWidget { const DeleteAccountView({Key? key}) : super(key: key); diff --git a/lib/pages/settings_views/global_settings_view/global_settings_view.dart b/lib/pages/settings_views/global_settings_view/global_settings_view.dart index 29984b928..c15d0f8d9 100644 --- a/lib/pages/settings_views/global_settings_view/global_settings_view.dart +++ b/lib/pages/settings_views/global_settings_view/global_settings_view.dart @@ -11,29 +11,29 @@ import 'dart:io'; import 'package:flutter/material.dart'; -import 'package:stackwallet/pages/address_book_views/address_book_view.dart'; -import 'package:stackwallet/pages/pinpad_views/lock_screen_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/about_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/advanced_views/advanced_settings_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/appearance_settings/appearance_settings_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/currency_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/delete_account_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/language_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/manage_nodes_views/manage_nodes_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/security_views/security_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/stack_backup_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/startup_preferences/startup_preferences_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/support_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/syncing_preferences_views/syncing_preferences_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/tor_settings/tor_settings_view.dart'; -import 'package:stackwallet/pages/settings_views/sub_widgets/settings_list_button.dart'; -import 'package:stackwallet/route_generator.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../address_book_views/address_book_view.dart'; +import '../../pinpad_views/lock_screen_view.dart'; +import 'about_view.dart'; +import 'advanced_views/advanced_settings_view.dart'; +import 'appearance_settings/appearance_settings_view.dart'; +import 'currency_view.dart'; +import 'delete_account_view.dart'; +import 'language_view.dart'; +import 'manage_nodes_views/manage_nodes_view.dart'; +import 'security_views/security_view.dart'; +import 'stack_backup_views/stack_backup_view.dart'; +import 'startup_preferences/startup_preferences_view.dart'; +import 'support_view.dart'; +import 'syncing_preferences_views/syncing_preferences_view.dart'; +import 'tor_settings/tor_settings_view.dart'; +import '../sub_widgets/settings_list_button.dart'; +import '../../../route_generator.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../widgets/background.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/rounded_white_container.dart'; class GlobalSettingsView extends StatelessWidget { const GlobalSettingsView({ diff --git a/lib/pages/settings_views/global_settings_view/hidden_settings.dart b/lib/pages/settings_views/global_settings_view/hidden_settings.dart index 6ebafad4a..c1370624e 100644 --- a/lib/pages/settings_views/global_settings_view/hidden_settings.dart +++ b/lib/pages/settings_views/global_settings_view/hidden_settings.dart @@ -13,18 +13,19 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/providers/global/debug_service_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/dialogs/tor_warning_dialog.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../notifications/show_flush_bar.dart'; +import '../../../providers/global/debug_service_provider.dart'; +import '../../../providers/providers.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../wallets/crypto_currency/coins/stellar.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../widgets/background.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/dialogs/tor_warning_dialog.dart'; +import '../../../widgets/rounded_white_container.dart'; class HiddenSettings extends StatelessWidget { const HiddenSettings({super.key}); @@ -74,42 +75,46 @@ class HiddenSettings extends StatelessWidget { child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - Consumer(builder: (_, ref, __) { - return GestureDetector( - onTap: () async { - final notifs = - ref.read(notificationsProvider).notifications; + Consumer( + builder: (_, ref, __) { + return GestureDetector( + onTap: () async { + final notifs = ref + .read(notificationsProvider) + .notifications; - for (final n in notifs) { + for (final n in notifs) { + await ref + .read(notificationsProvider) + .delete(n, false); + } await ref .read(notificationsProvider) - .delete(n, false); - } - await ref - .read(notificationsProvider) - .delete(notifs[0], true); + .delete(notifs[0], true); - if (context.mounted) { - unawaited( - showFloatingFlushBar( - type: FlushBarType.success, - message: "Notification history deleted", - context: context, - ), - ); - } - }, - child: RoundedWhiteContainer( - child: Text( - "Delete notifications", - style: STextStyles.button(context).copyWith( + if (context.mounted) { + unawaited( + showFloatingFlushBar( + type: FlushBarType.success, + message: "Notification history deleted", + context: context, + ), + ); + } + }, + child: RoundedWhiteContainer( + child: Text( + "Delete notifications", + style: STextStyles.button(context).copyWith( color: Theme.of(context) .extension()! - .accentColorDark), + .accentColorDark, + ), + ), ), - ), - ); - }), + ); + }, + ), // const SizedBox( // height: 12, // ), @@ -141,34 +146,37 @@ class HiddenSettings extends StatelessWidget { const SizedBox( height: 12, ), - Consumer(builder: (_, ref, __) { - return GestureDetector( - onTap: () async { - await ref - .read(debugServiceProvider) - .deleteAllLogs(); + Consumer( + builder: (_, ref, __) { + return GestureDetector( + onTap: () async { + await ref + .read(debugServiceProvider) + .deleteAllLogs(); - if (context.mounted) { - unawaited( - showFloatingFlushBar( - type: FlushBarType.success, - message: "Debug Logs deleted", - context: context, - ), - ); - } - }, - child: RoundedWhiteContainer( - child: Text( - "Delete Debug Logs", - style: STextStyles.button(context).copyWith( + if (context.mounted) { + unawaited( + showFloatingFlushBar( + type: FlushBarType.success, + message: "Debug Logs deleted", + context: context, + ), + ); + } + }, + child: RoundedWhiteContainer( + child: Text( + "Delete Debug Logs", + style: STextStyles.button(context).copyWith( color: Theme.of(context) .extension()! - .accentColorDark), + .accentColorDark, + ), + ), ), - ), - ); - }), + ); + }, + ), const SizedBox( height: 12, ), @@ -216,8 +224,10 @@ class HiddenSettings extends StatelessWidget { // ), Consumer( builder: (_, ref, __) { - if (ref.watch(prefsChangeNotifierProvider - .select((value) => value.familiarity)) < + if (ref.watch( + prefsChangeNotifierProvider + .select((value) => value.familiarity), + ) < 6) { return GestureDetector( onTap: () async { @@ -236,9 +246,10 @@ class HiddenSettings extends StatelessWidget { child: Text( "Enable exchange", style: STextStyles.button(context).copyWith( - color: Theme.of(context) - .extension()! - .accentColorDark), + color: Theme.of(context) + .extension()! + .accentColorDark, + ), ), ), ); @@ -257,7 +268,7 @@ class HiddenSettings extends StatelessWidget { await showDialog( context: context, builder: (_) => TorWarningDialog( - coin: Coin.stellar, + coin: Stellar(CryptoCurrencyNetwork.main), ), ); }, @@ -265,9 +276,10 @@ class HiddenSettings extends StatelessWidget { child: Text( "Show Tor warning popup", style: STextStyles.button(context).copyWith( - color: Theme.of(context) - .extension()! - .accentColorDark), + color: Theme.of(context) + .extension()! + .accentColorDark, + ), ), ), ); @@ -286,9 +298,10 @@ class HiddenSettings extends StatelessWidget { child: Text( "Do nothing", style: STextStyles.button(context).copyWith( - color: Theme.of(context) - .extension()! - .accentColorDark), + color: Theme.of(context) + .extension()! + .accentColorDark, + ), ), ), ); diff --git a/lib/pages/settings_views/global_settings_view/language_view.dart b/lib/pages/settings_views/global_settings_view/language_view.dart index ae2cb8c6e..685736409 100644 --- a/lib/pages/settings_views/global_settings_view/language_view.dart +++ b/lib/pages/settings_views/global_settings_view/language_view.dart @@ -11,19 +11,19 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/languages_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../../providers/providers.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/enums/languages_enum.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../widgets/background.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/icon_widgets/x_icon.dart'; +import '../../../widgets/rounded_container.dart'; +import '../../../widgets/stack_text_field.dart'; +import '../../../widgets/textfield_icon_button.dart'; class LanguageSettingsView extends ConsumerStatefulWidget { const LanguageSettingsView({Key? key}) : super(key: key); diff --git a/lib/pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart b/lib/pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart index 7a656c288..e5a1ad049 100644 --- a/lib/pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart +++ b/lib/pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart @@ -14,36 +14,33 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:solana/solana.dart'; -import 'package:stackwallet/models/node_model.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/providers/global/secure_store_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/connection_check/electrum_connection_check.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/test_epic_box_connection.dart'; -import 'package:stackwallet/utilities/test_eth_node_connection.dart'; -import 'package:stackwallet/utilities/test_monero_node_connection.dart'; -import 'package:stackwallet/utilities/test_stellar_node_connection.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/api/tezos/tezos_rpc_api.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../../../models/node_model.dart'; +import '../../../../notifications/show_flush_bar.dart'; +import '../../../../providers/global/secure_store_provider.dart'; +import '../../../../providers/providers.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/flutter_secure_storage_interface.dart'; +import '../../../../utilities/test_node_connection.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/crypto_currency/coins/epiccash.dart'; +import '../../../../wallets/crypto_currency/coins/ethereum.dart'; +import '../../../../wallets/crypto_currency/coins/monero.dart'; +import '../../../../wallets/crypto_currency/coins/wownero.dart'; +import '../../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../../wallets/crypto_currency/intermediate/cryptonote_currency.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/conditional_parent.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/desktop/secondary_button.dart'; +import '../../../../widgets/icon_widgets/x_icon.dart'; +import '../../../../widgets/stack_dialog.dart'; +import '../../../../widgets/stack_text_field.dart'; +import '../../../../widgets/textfield_icon_button.dart'; import 'package:uuid/uuid.dart'; // import 'package:web3dart/web3dart.dart'; @@ -51,17 +48,17 @@ enum AddEditNodeViewType { add, edit } class AddEditNodeView extends ConsumerStatefulWidget { const AddEditNodeView({ - Key? key, + super.key, required this.viewType, required this.coin, required this.nodeId, required this.routeOnSuccessOrDelete, - }) : super(key: key); + }); static const String routeName = "/addEditNode"; final AddEditNodeViewType viewType; - final Coin coin; + final CryptoCurrency coin; final String routeOnSuccessOrDelete; final String? nodeId; @@ -71,192 +68,31 @@ class AddEditNodeView extends ConsumerStatefulWidget { class _AddEditNodeViewState extends ConsumerState { late final AddEditNodeViewType viewType; - late final Coin coin; + late final CryptoCurrency coin; late final String? nodeId; late final bool isDesktop; late bool saveEnabled; late bool testConnectionEnabled; - Future _xmrHelper(String url, int? port) async { - final uri = Uri.parse(url); - - final String path = uri.path.isEmpty ? "/json_rpc" : uri.path; - - final uriString = "${uri.scheme}://${uri.host}:${port ?? 0}$path"; - - ref.read(nodeFormDataProvider).useSSL = true; - - final response = await testMoneroNodeConnection( - Uri.parse(uriString), - false, - ); - - if (response.cert != null) { - if (mounted) { - final shouldAllowBadCert = await showBadX509CertificateDialog( - response.cert!, - response.url!, - response.port!, - context, - ); - - if (shouldAllowBadCert) { - final response = - await testMoneroNodeConnection(Uri.parse(uriString), true); - ref.read(nodeFormDataProvider).host = url; - return response.success; - } - } - } else { - ref.read(nodeFormDataProvider).host = url; - return response.success; + void _onTestSuccess(NodeFormData data) { + if (coin is Epiccash) { + ref.read(nodeFormDataProvider).host = data.host; + ref.read(nodeFormDataProvider).port = data.port; + ref.read(nodeFormDataProvider).useSSL = data.useSSL; + } else if (coin is CryptonoteCurrency) { + ref.read(nodeFormDataProvider).host = data.host; } - - return false; - } - - Future _testConnection({bool showFlushBar = true}) async { - final formData = ref.read(nodeFormDataProvider); - - bool testPassed = false; - - switch (coin) { - case Coin.epicCash: - try { - final data = await testEpicNodeConnection(formData); - - if (data != null) { - testPassed = true; - ref.read(nodeFormDataProvider).host = data.host; - ref.read(nodeFormDataProvider).port = data.port; - ref.read(nodeFormDataProvider).useSSL = data.useSSL; - } - } catch (e, s) { - Logging.instance.log("$e\n$s", level: LogLevel.Warning); - } - break; - - case Coin.monero: - case Coin.wownero: - try { - final url = formData.host!; - final uri = Uri.tryParse(url); - if (uri != null) { - if (!uri.hasScheme) { - // try https first - testPassed = await _xmrHelper("https://$url", formData.port); - - if (testPassed == false) { - // try http - testPassed = await _xmrHelper("http://$url", formData.port); - } - } else { - testPassed = await _xmrHelper(url, formData.port); - } - } - } catch (e, s) { - Logging.instance.log("$e\n$s", level: LogLevel.Warning); - } - - break; - - case Coin.bitcoin: - case Coin.bitcoincash: - case Coin.litecoin: - case Coin.dogecoin: - case Coin.eCash: - case Coin.firo: - case Coin.namecoin: - case Coin.particl: - case Coin.peercoin: - case Coin.peercoinTestNet: - case Coin.bitcoinFrost: - case Coin.bitcoinFrostTestNet: - case Coin.bitcoinTestNet: - case Coin.litecoinTestNet: - case Coin.bitcoincashTestnet: - case Coin.firoTestNet: - case Coin.dogecoinTestNet: - try { - testPassed = await checkElectrumServer( - host: formData.host!, - port: formData.port!, - useSSL: formData.useSSL!, - overridePrefs: ref.read(prefsChangeNotifierProvider), - overrideTorService: ref.read(pTorService), - ); - } catch (_) { - testPassed = false; - } - - break; - - case Coin.ethereum: - try { - testPassed = await testEthNodeConnection(formData.host!); - } catch (_) { - testPassed = false; - } - break; - - case Coin.stellar: - case Coin.stellarTestnet: - try { - testPassed = - await testStellarNodeConnection(formData.host!, formData.port!); - } catch (_) {} - break; - - case Coin.nano: - case Coin.banano: - throw UnimplementedError(); - //TODO: check network/node - case Coin.tezos: - try { - testPassed = await TezosRpcAPI.testNetworkConnection( - nodeInfo: (host: formData.host!, port: formData.port!), - ); - } catch (_) {} - break; - - case Coin.solana: - try { - RpcClient rpcClient; - if (formData.host!.startsWith("http") || - formData.host!.startsWith("https")) { - rpcClient = RpcClient("${formData.host}:${formData.port}"); - } else { - rpcClient = RpcClient("http://${formData.host}:${formData.port}"); - } - await rpcClient.getEpochInfo().then((value) => testPassed = true); - } catch (_) { - testPassed = false; - } - break; - } - - if (showFlushBar && mounted) { - if (testPassed) { - unawaited(showFloatingFlushBar( - type: FlushBarType.success, - message: "Server ping success", - context: context, - )); - } else { - unawaited(showFloatingFlushBar( - type: FlushBarType.warning, - message: "Server unreachable", - context: context, - )); - } - } - - return testPassed; } Future attemptSave() async { - final canConnect = await _testConnection(showFlushBar: false); + final canConnect = await testNodeConnection( + context: context, + onSuccess: _onTestSuccess, + cryptoCurrency: coin, + nodeFormData: ref.read(nodeFormDataProvider), + ref: ref, + ); bool? shouldSave; @@ -387,7 +223,7 @@ class _AddEditNodeViewState extends ConsumerState { // strip unused path String address = formData.host!; - if (coin == Coin.monero || coin == Coin.wownero) { + if (coin is Monero || coin is Wownero) { if (address.startsWith("http")) { final uri = Uri.parse(address); address = "${uri.scheme}://${uri.host}"; @@ -404,7 +240,7 @@ class _AddEditNodeViewState extends ConsumerState { useSSL: formData.useSSL!, loginName: formData.login, enabled: true, - coinName: coin.name, + coinName: coin.identifier, isFailover: formData.isFailover!, trusted: formData.trusted!, isDown: false, @@ -429,7 +265,7 @@ class _AddEditNodeViewState extends ConsumerState { useSSL: formData.useSSL!, loginName: formData.login, enabled: true, - coinName: coin.name, + coinName: coin.identifier, isFailover: formData.isFailover!, trusted: formData.trusted!, isDown: false, @@ -652,7 +488,32 @@ class _AddEditNodeViewState extends ConsumerState { buttonHeight: isDesktop ? ButtonHeight.l : null, onPressed: testConnectionEnabled ? () async { - await _testConnection(); + final testPassed = await testNodeConnection( + context: context, + onSuccess: _onTestSuccess, + cryptoCurrency: coin, + nodeFormData: ref.read(nodeFormDataProvider), + ref: ref, + ); + if (context.mounted) { + if (testPassed) { + unawaited( + showFloatingFlushBar( + type: FlushBarType.success, + message: "Server ping success", + context: context, + ), + ); + } else { + unawaited( + showFloatingFlushBar( + type: FlushBarType.warning, + message: "Server unreachable", + context: context, + ), + ); + } + } } : null, ), @@ -724,7 +585,7 @@ class NodeForm extends ConsumerStatefulWidget { final NodeModel? node; final SecureStorageInterface secureStore; final bool readOnly; - final Coin coin; + final CryptoCurrency coin; final void Function(bool canSave, bool canTestConnection)? onChanged; @override @@ -754,39 +615,15 @@ class _NodeFormState extends ConsumerState { void Function(bool canSave, bool canTestConnection)? onChanged; - bool _checkShouldEnableAuthFields(Coin coin) { + bool _checkShouldEnableAuthFields(CryptoCurrency coin) { // TODO: which coin servers can have username and password? switch (coin) { - case Coin.bitcoin: - case Coin.litecoin: - case Coin.dogecoin: - case Coin.firo: - case Coin.namecoin: - case Coin.bitcoincash: - case Coin.particl: - case Coin.peercoin: - case Coin.peercoinTestNet: - case Coin.tezos: - case Coin.bitcoinTestNet: - case Coin.litecoinTestNet: - case Coin.bitcoincashTestnet: - case Coin.firoTestNet: - case Coin.dogecoinTestNet: - case Coin.epicCash: - case Coin.nano: - case Coin.banano: - case Coin.eCash: - case Coin.solana: - case Coin.stellar: - case Coin.stellarTestnet: - case Coin.bitcoinFrost: - case Coin.bitcoinFrostTestNet: - return false; - - case Coin.ethereum: - case Coin.monero: - case Coin.wownero: + case Ethereum(): + case CryptonoteCurrency(): return true; + + default: + return false; } } @@ -862,7 +699,7 @@ class _NodeFormState extends ConsumerState { _useSSL = node.useSSL; _isFailover = node.isFailover; _trusted = node.trusted ?? false; - if (widget.coin == Coin.epicCash) { + if (widget.coin is Epiccash) { enableSSLCheckbox = !node.host.startsWith("http"); } else { enableSSLCheckbox = true; @@ -961,9 +798,7 @@ class _NodeFormState extends ConsumerState { focusNode: _hostFocusNode, style: STextStyles.field(context), decoration: standardInputDecoration( - (widget.coin != Coin.monero && widget.coin != Coin.wownero) - ? "IP address" - : "Url", + (widget.coin is! CryptonoteCurrency) ? "IP address" : "Url", _hostFocusNode, context, ).copyWith( @@ -987,7 +822,7 @@ class _NodeFormState extends ConsumerState { : null, ), onChanged: (newValue) { - if (widget.coin == Coin.epicCash) { + if (widget.coin is Epiccash) { if (newValue.startsWith("https://")) { _useSSL = true; enableSSLCheckbox = false; @@ -1151,7 +986,7 @@ class _NodeFormState extends ConsumerState { const SizedBox( height: 8, ), - if (widget.coin != Coin.monero && widget.coin != Coin.wownero) + if (widget.coin is! CryptonoteCurrency) Row( children: [ GestureDetector( @@ -1202,7 +1037,7 @@ class _NodeFormState extends ConsumerState { ), ], ), - if (widget.coin == Coin.monero || widget.coin == Coin.wownero) + if (widget.coin is Monero || widget.coin is Wownero) Row( children: [ GestureDetector( @@ -1253,15 +1088,11 @@ class _NodeFormState extends ConsumerState { ), ], ), - if (widget.coin != Coin.monero && - widget.coin != Coin.wownero && - widget.coin != Coin.epicCash) + if (widget.coin is! CryptonoteCurrency && widget.coin is! Epiccash) const SizedBox( height: 8, ), - if (widget.coin != Coin.monero && - widget.coin != Coin.wownero && - widget.coin != Coin.epicCash) + if (widget.coin is! CryptonoteCurrency && widget.coin is! Epiccash) Row( children: [ GestureDetector( diff --git a/lib/pages/settings_views/global_settings_view/manage_nodes_views/coin_nodes_view.dart b/lib/pages/settings_views/global_settings_view/manage_nodes_views/coin_nodes_view.dart index 1bb393246..26f54fc27 100644 --- a/lib/pages/settings_views/global_settings_view/manage_nodes_views/coin_nodes_view.dart +++ b/lib/pages/settings_views/global_settings_view/manage_nodes_views/coin_nodes_view.dart @@ -13,31 +13,31 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart'; -import 'package:stackwallet/pages/settings_views/sub_widgets/nodes_list.dart'; -import 'package:stackwallet/themes/coin_icon_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; +import 'add_edit_node_view.dart'; +import '../../sub_widgets/nodes_list.dart'; +import '../../../../themes/coin_icon_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/custom_buttons/blue_text_button.dart'; +import '../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../widgets/desktop/desktop_dialog_close_button.dart'; import 'package:tuple/tuple.dart'; class CoinNodesView extends ConsumerStatefulWidget { const CoinNodesView({ - Key? key, + super.key, required this.coin, this.rootNavigator = false, - }) : super(key: key); + }); static const String routeName = "/coinNodes"; - final Coin coin; + final CryptoCurrency coin; final bool rootNavigator; @override diff --git a/lib/pages/settings_views/global_settings_view/manage_nodes_views/manage_nodes_view.dart b/lib/pages/settings_views/global_settings_view/manage_nodes_views/manage_nodes_view.dart index c6e59c96c..dd6eed5ee 100644 --- a/lib/pages/settings_views/global_settings_view/manage_nodes_views/manage_nodes_view.dart +++ b/lib/pages/settings_views/global_settings_view/manage_nodes_views/manage_nodes_view.dart @@ -13,21 +13,22 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/manage_nodes_views/coin_nodes_view.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/coin_icon_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import 'coin_nodes_view.dart'; +import '../../../../providers/providers.dart'; +import '../../../../app_config.dart'; +import '../../../../themes/coin_icon_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/rounded_white_container.dart'; class ManageNodesView extends ConsumerStatefulWidget { const ManageNodesView({ - Key? key, - }) : super(key: key); + super.key, + }); static const String routeName = "/manageNodes"; @@ -36,12 +37,14 @@ class ManageNodesView extends ConsumerStatefulWidget { } class _ManageNodesViewState extends ConsumerState { - List _coins = [...Coin.values]; + List _coins = [...AppConfig.coins]; @override void initState() { _coins = _coins.toList(); - _coins.remove(Coin.firoTestNet); + _coins.removeWhere( + (e) => e is Firo && e.network == CryptoCurrencyNetwork.test, + ); super.initState(); } @@ -52,12 +55,13 @@ class _ManageNodesViewState extends ConsumerState { @override Widget build(BuildContext context) { - bool showTestNet = ref.watch( + final showTestNet = ref.watch( prefsChangeNotifierProvider.select((value) => value.showTestNetCoins), ); - List coins = - showTestNet ? _coins : _coins.where((e) => !e.isTestNet).toList(); + final coins = showTestNet + ? _coins + : _coins.where((e) => e.network != CryptoCurrencyNetwork.test).toList(); return Background( child: Scaffold( diff --git a/lib/pages/settings_views/global_settings_view/manage_nodes_views/node_details_view.dart b/lib/pages/settings_views/global_settings_view/manage_nodes_views/node_details_view.dart index 1034d986c..da7f0cfcc 100644 --- a/lib/pages/settings_views/global_settings_view/manage_nodes_views/node_details_view.dart +++ b/lib/pages/settings_views/global_settings_view/manage_nodes_views/node_details_view.dart @@ -13,45 +13,37 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:solana/solana.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart'; -import 'package:stackwallet/providers/global/secure_store_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/connection_check/electrum_connection_check.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/test_epic_box_connection.dart'; -import 'package:stackwallet/utilities/test_eth_node_connection.dart'; -import 'package:stackwallet/utilities/test_monero_node_connection.dart'; -import 'package:stackwallet/utilities/test_stellar_node_connection.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/api/tezos/tezos_rpc_api.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/delete_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; +import '../../../../notifications/show_flush_bar.dart'; +import 'add_edit_node_view.dart'; +import '../../../../providers/global/secure_store_provider.dart'; +import '../../../../providers/providers.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/flutter_secure_storage_interface.dart'; +import '../../../../utilities/test_node_connection.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/conditional_parent.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/desktop/delete_button.dart'; +import '../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/desktop/secondary_button.dart'; import 'package:tuple/tuple.dart'; class NodeDetailsView extends ConsumerStatefulWidget { const NodeDetailsView({ - Key? key, + super.key, required this.coin, required this.nodeId, required this.popRouteName, - }) : super(key: key); + }); static const String routeName = "/nodeDetails"; - final Coin coin; + final CryptoCurrency coin; final String nodeId; final String popRouteName; @@ -61,7 +53,7 @@ class NodeDetailsView extends ConsumerStatefulWidget { class _NodeDetailsViewState extends ConsumerState { late final SecureStorageInterface secureStore; - late final Coin coin; + late final CryptoCurrency coin; late final String nodeId; late final String popRouteName; @@ -76,170 +68,19 @@ class _NodeDetailsViewState extends ConsumerState { super.initState(); } - Future _testConnection(WidgetRef ref, BuildContext context) async { - final node = - ref.watch(nodeServiceChangeNotifierProvider).getNodeById(id: nodeId); - - bool testPassed = false; - - switch (coin) { - case Coin.epicCash: - try { - testPassed = await testEpicNodeConnection( - NodeFormData() - ..host = node!.host - ..useSSL = node.useSSL - ..port = node.port, - ) != - null; - } catch (e, s) { - Logging.instance.log("$e\n$s", level: LogLevel.Warning); - testPassed = false; - } - break; - - case Coin.monero: - case Coin.wownero: - try { - final uri = Uri.parse(node!.host); - if (uri.scheme.startsWith("http")) { - final String path = uri.path.isEmpty ? "/json_rpc" : uri.path; - - String uriString = "${uri.scheme}://${uri.host}:${node.port}$path"; - - final response = await testMoneroNodeConnection( - Uri.parse(uriString), - false, - ); - - if (response.cert != null) { - if (mounted) { - final shouldAllowBadCert = await showBadX509CertificateDialog( - response.cert!, - response.url!, - response.port!, - context, - ); - - if (shouldAllowBadCert) { - final response = await testMoneroNodeConnection( - Uri.parse(uriString), true); - testPassed = response.success; - } - } - } else { - testPassed = response.success; - } - } - } catch (e, s) { - Logging.instance.log("$e\n$s", level: LogLevel.Warning); - } - - break; - - case Coin.bitcoin: - case Coin.litecoin: - case Coin.dogecoin: - case Coin.firo: - case Coin.particl: - case Coin.peercoin: - case Coin.peercoinTestNet: - case Coin.bitcoinTestNet: - case Coin.firoTestNet: - case Coin.dogecoinTestNet: - case Coin.bitcoincash: - case Coin.namecoin: - case Coin.litecoinTestNet: - case Coin.bitcoincashTestnet: - case Coin.eCash: - case Coin.bitcoinFrost: - case Coin.bitcoinFrostTestNet: - try { - testPassed = await checkElectrumServer( - host: node!.host, - port: node.port, - useSSL: node.useSSL, - overridePrefs: ref.read(prefsChangeNotifierProvider), - overrideTorService: ref.read(pTorService), - ); - } catch (_) { - testPassed = false; - } - - break; - - case Coin.ethereum: - try { - testPassed = await testEthNodeConnection(node!.host); - } catch (_) { - testPassed = false; - } - break; - - case Coin.nano: - case Coin.banano: - // TODO: fix this lacking code - throw UnimplementedError(); - //TODO: check network/node - case Coin.tezos: - try { - testPassed = await TezosRpcAPI.testNetworkConnection( - nodeInfo: (host: node!.host, port: node!.port), - ); - } catch (_) {} - break; - case Coin.stellar: - case Coin.stellarTestnet: - try { - testPassed = await testStellarNodeConnection(node!.host, node.port); - } catch (_) { - testPassed = false; - } - break; - - case Coin.solana: - try { - RpcClient rpcClient; - if (node!.host.startsWith("http") || node.host.startsWith("https")) { - rpcClient = RpcClient("${node.host}:${node.port}"); - } else { - rpcClient = RpcClient("http://${node.host}:${node.port}"); - } - await rpcClient.getEpochInfo().then((value) => testPassed = true); - } catch (_) { - testPassed = false; - } - break; - } - - if (testPassed) { - unawaited( - showFloatingFlushBar( - type: FlushBarType.success, - message: "Server ping success", - context: context, - ), - ); - } else { - unawaited( - showFloatingFlushBar( - type: FlushBarType.warning, - message: "Server unreachable", - context: context, - ), - ); - } - } - @override Widget build(BuildContext context) { final isDesktop = Util.isDesktop; - final node = ref.watch(nodeServiceChangeNotifierProvider - .select((value) => value.getNodeById(id: nodeId))); + final node = ref.watch( + nodeServiceChangeNotifierProvider + .select((value) => value.getNodeById(id: nodeId)), + ); - final nodesForCoin = ref.watch(nodeServiceChangeNotifierProvider - .select((value) => value.getNodesFor(coin))); + final nodesForCoin = ref.watch( + nodeServiceChangeNotifierProvider + .select((value) => value.getNodesFor(coin)), + ); final canDelete = nodesForCoin.length > 1; @@ -256,7 +97,7 @@ class _NodeDetailsViewState extends ConsumerState { FocusScope.of(context).unfocus(); await Future.delayed(const Duration(milliseconds: 75)); } - if (mounted) { + if (context.mounted) { Navigator.of(context).pop(); } }, @@ -350,7 +191,7 @@ class _NodeDetailsViewState extends ConsumerState { Text( "Node details", style: STextStyles.desktopH3(context), - ) + ), ], ), Padding( @@ -420,7 +261,52 @@ class _NodeDetailsViewState extends ConsumerState { label: "Test connection", buttonHeight: isDesktop ? ButtonHeight.l : null, onPressed: () async { - await _testConnection(ref, context); + final node = ref + .read(nodeServiceChangeNotifierProvider) + .getNodeById(id: nodeId)!; + + final nodeFormData = NodeFormData() + ..useSSL = node.useSSL + ..trusted = node.trusted + ..name = node.name + ..host = node.host + ..login = node.loginName + ..port = node.port + ..isFailover = node.isFailover; + nodeFormData.password = await node.getPassword( + ref.read(secureStoreProvider), + ); + + if (context.mounted) { + final testPassed = await testNodeConnection( + context: context, + nodeFormData: nodeFormData, + cryptoCurrency: coin, + ref: ref, + ); + + if (testPassed) { + if (context.mounted) { + unawaited( + showFloatingFlushBar( + type: FlushBarType.success, + message: "Server ping success", + context: context, + ), + ); + } + } else { + if (context.mounted) { + unawaited( + showFloatingFlushBar( + type: FlushBarType.warning, + message: "Server unreachable", + context: context, + ), + ); + } + } + } }, ), ), diff --git a/lib/pages/settings_views/global_settings_view/security_views/change_pin_view/change_pin_view.dart b/lib/pages/settings_views/global_settings_view/security_views/change_pin_view/change_pin_view.dart index 76ea1991d..8d442f17f 100644 --- a/lib/pages/settings_views/global_settings_view/security_views/change_pin_view/change_pin_view.dart +++ b/lib/pages/settings_views/global_settings_view/security_views/change_pin_view/change_pin_view.dart @@ -10,17 +10,17 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/security_views/security_view.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/providers/global/secure_store_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_pin_put/custom_pin_put.dart'; +import '../../../../../notifications/show_flush_bar.dart'; +import '../security_view.dart'; +import '../../../../../providers/global/prefs_provider.dart'; +import '../../../../../providers/global/secure_store_provider.dart'; +import '../../../../../themes/stack_colors.dart'; +import '../../../../../utilities/assets.dart'; +import '../../../../../utilities/flutter_secure_storage_interface.dart'; +import '../../../../../utilities/text_styles.dart'; +import '../../../../../widgets/background.dart'; +import '../../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../../widgets/custom_pin_put/custom_pin_put.dart'; class ChangePinView extends ConsumerStatefulWidget { const ChangePinView({ diff --git a/lib/pages/settings_views/global_settings_view/security_views/security_view.dart b/lib/pages/settings_views/global_settings_view/security_views/security_view.dart index 63cbb836e..ef911d4a0 100644 --- a/lib/pages/settings_views/global_settings_view/security_views/security_view.dart +++ b/lib/pages/settings_views/global_settings_view/security_views/security_view.dart @@ -10,17 +10,17 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/pages/pinpad_views/lock_screen_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/security_views/change_pin_view/change_pin_view.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/route_generator.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/draggable_switch_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../pinpad_views/lock_screen_view.dart'; +import 'change_pin_view/change_pin_view.dart'; +import '../../../../providers/global/prefs_provider.dart'; +import '../../../../route_generator.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/custom_buttons/draggable_switch_button.dart'; +import '../../../../widgets/rounded_white_container.dart'; class SecurityView extends StatelessWidget { const SecurityView({ diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/auto_backup_view.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/auto_backup_view.dart index cc76cbf2a..4a6218d2f 100644 --- a/lib/pages/settings_views/global_settings_view/stack_backup_views/auto_backup_view.dart +++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/auto_backup_view.dart @@ -12,23 +12,23 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:intl/intl.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/create_auto_backup_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/edit_auto_backup_view.dart'; -import 'package:stackwallet/providers/global/auto_swb_service_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/backup_frequency_type.dart'; -import 'package:stackwallet/utilities/format.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/draggable_switch_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; +import 'create_auto_backup_view.dart'; +import 'edit_auto_backup_view.dart'; +import '../../../../providers/global/auto_swb_service_provider.dart'; +import '../../../../providers/providers.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/enums/backup_frequency_type.dart'; +import '../../../../utilities/format.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/custom_buttons/blue_text_button.dart'; +import '../../../../widgets/custom_buttons/draggable_switch_button.dart'; +import '../../../../widgets/rounded_white_container.dart'; +import '../../../../widgets/stack_dialog.dart'; +import '../../../../widgets/stack_text_field.dart'; import 'package:url_launcher/url_launcher.dart'; class AutoBackupView extends ConsumerStatefulWidget { diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/create_auto_backup_view.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/create_auto_backup_view.dart index 546c780e9..f7a36bcba 100644 --- a/lib/pages/settings_views/global_settings_view/stack_backup_views/create_auto_backup_view.dart +++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/create_auto_backup_view.dart @@ -16,26 +16,26 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:stack_wallet_backup/stack_wallet_backup.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/auto_backup_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/helpers/swb_file_system.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/sub_views/backup_frequency_type_select_sheet.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/providers/global/secure_store_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; -import 'package:stackwallet/utilities/format.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/progress_bar.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; +import '../../../../notifications/show_flush_bar.dart'; +import 'auto_backup_view.dart'; +import 'helpers/restore_create_backup.dart'; +import 'helpers/swb_file_system.dart'; +import 'sub_views/backup_frequency_type_select_sheet.dart'; +import '../../../../providers/global/prefs_provider.dart'; +import '../../../../providers/global/secure_store_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/flutter_secure_storage_interface.dart'; +import '../../../../utilities/format.dart'; +import '../../../../utilities/logger.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/progress_bar.dart'; +import '../../../../widgets/stack_dialog.dart'; +import '../../../../widgets/stack_text_field.dart'; import 'package:zxcvbn/zxcvbn.dart'; class CreateAutoBackupView extends ConsumerStatefulWidget { diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/create_backup_information_view.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/create_backup_information_view.dart index dd1f34120..ebdf2cac3 100644 --- a/lib/pages/settings_views/global_settings_view/stack_backup_views/create_backup_information_view.dart +++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/create_backup_information_view.dart @@ -9,12 +9,12 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/create_backup_view.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import 'create_backup_view.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/rounded_white_container.dart'; class CreateBackupInfoView extends StatelessWidget { const CreateBackupInfoView({Key? key}) : super(key: key); diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/create_backup_view.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/create_backup_view.dart index 4dfa049d1..118e128e8 100644 --- a/lib/pages/settings_views/global_settings_view/stack_backup_views/create_backup_view.dart +++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/create_backup_view.dart @@ -15,25 +15,25 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/helpers/swb_file_system.dart'; -import 'package:stackwallet/providers/global/secure_store_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/progress_bar.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; +import '../../../../notifications/show_flush_bar.dart'; +import 'helpers/restore_create_backup.dart'; +import 'helpers/swb_file_system.dart'; +import '../../../../providers/global/secure_store_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/logger.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/conditional_parent.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/desktop/secondary_button.dart'; +import '../../../../widgets/progress_bar.dart'; +import '../../../../widgets/stack_dialog.dart'; +import '../../../../widgets/stack_text_field.dart'; import 'package:zxcvbn/zxcvbn.dart'; class CreateBackupView extends StatefulWidget { diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/dialogs/cancel_stack_restore_dialog.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/dialogs/cancel_stack_restore_dialog.dart index 752acdd4a..17c24aed0 100644 --- a/lib/pages/settings_views/global_settings_view/stack_backup_views/dialogs/cancel_stack_restore_dialog.dart +++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/dialogs/cancel_stack_restore_dialog.dart @@ -9,14 +9,14 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../../../../themes/stack_colors.dart'; +import '../../../../../utilities/text_styles.dart'; +import '../../../../../utilities/util.dart'; +import '../../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../../widgets/desktop/primary_button.dart'; +import '../../../../../widgets/desktop/secondary_button.dart'; +import '../../../../../widgets/rounded_container.dart'; +import '../../../../../widgets/stack_dialog.dart'; class CancelStackRestoreDialog extends StatelessWidget { const CancelStackRestoreDialog({ diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/edit_auto_backup_view.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/edit_auto_backup_view.dart index f399c8266..107cefb70 100644 --- a/lib/pages/settings_views/global_settings_view/stack_backup_views/edit_auto_backup_view.dart +++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/edit_auto_backup_view.dart @@ -18,30 +18,30 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:stack_wallet_backup/stack_wallet_backup.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/auto_backup_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/helpers/swb_file_system.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/sub_views/backup_frequency_type_select_sheet.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/providers/global/secure_store_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/backup_frequency_type.dart'; -import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; -import 'package:stackwallet/utilities/format.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/progress_bar.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; +import '../../../../notifications/show_flush_bar.dart'; +import 'auto_backup_view.dart'; +import 'helpers/restore_create_backup.dart'; +import 'helpers/swb_file_system.dart'; +import 'sub_views/backup_frequency_type_select_sheet.dart'; +import '../../../../providers/global/prefs_provider.dart'; +import '../../../../providers/global/secure_store_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/enums/backup_frequency_type.dart'; +import '../../../../utilities/flutter_secure_storage_interface.dart'; +import '../../../../utilities/format.dart'; +import '../../../../utilities/logger.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/conditional_parent.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/desktop/secondary_button.dart'; +import '../../../../widgets/progress_bar.dart'; +import '../../../../widgets/stack_dialog.dart'; +import '../../../../widgets/stack_text_field.dart'; import 'package:zxcvbn/zxcvbn.dart'; class EditAutoBackupView extends ConsumerStatefulWidget { diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart index f6491cf1d..8a635e39a 100644 --- a/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart +++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart @@ -16,45 +16,47 @@ import 'dart:typed_data'; import 'package:frostdart/frostdart.dart' as frost; import 'package:isar/isar.dart'; import 'package:stack_wallet_backup/stack_wallet_backup.dart'; -import 'package:stackwallet/db/hive/db.dart'; -import 'package:stackwallet/db/isar/main_db.dart'; -import 'package:stackwallet/models/exchange/change_now/exchange_transaction.dart'; -import 'package:stackwallet/models/exchange/response_objects/trade.dart'; -import 'package:stackwallet/models/isar/models/contact_entry.dart'; -import 'package:stackwallet/models/isar/models/transaction_note.dart'; -import 'package:stackwallet/models/node_model.dart'; -import 'package:stackwallet/models/stack_restoring_ui_state.dart'; -import 'package:stackwallet/models/trade_wallet_lookup.dart'; -import 'package:stackwallet/models/wallet_restore_state.dart'; -import 'package:stackwallet/services/address_book_service.dart'; -import 'package:stackwallet/services/frost.dart'; -import 'package:stackwallet/services/node_service.dart'; -import 'package:stackwallet/services/trade_notes_service.dart'; -import 'package:stackwallet/services/trade_sent_from_stack_service.dart'; -import 'package:stackwallet/services/trade_service.dart'; -import 'package:stackwallet/services/wallets.dart'; -import 'package:stackwallet/utilities/default_nodes.dart'; -import 'package:stackwallet/utilities/enums/backup_frequency_type.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/stack_restoring_status.dart'; -import 'package:stackwallet/utilities/enums/sync_type_enum.dart'; -import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; -import 'package:stackwallet/utilities/format.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/prefs.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/models/frost_wallet_info.dart'; -import 'package:stackwallet/wallets/isar/models/wallet_info.dart'; -import 'package:stackwallet/wallets/wallet/impl/bitcoin_frost_wallet.dart'; -import 'package:stackwallet/wallets/wallet/impl/epiccash_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/cw_based_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/mnemonic_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/private_key_interface.dart'; import 'package:tuple/tuple.dart'; import 'package:uuid/uuid.dart'; import 'package:wakelock/wakelock.dart'; +import '../../../../../app_config.dart'; +import '../../../../../db/hive/db.dart'; +import '../../../../../db/isar/main_db.dart'; +import '../../../../../models/exchange/change_now/exchange_transaction.dart'; +import '../../../../../models/exchange/response_objects/trade.dart'; +import '../../../../../models/isar/models/contact_entry.dart'; +import '../../../../../models/isar/models/transaction_note.dart'; +import '../../../../../models/node_model.dart'; +import '../../../../../models/stack_restoring_ui_state.dart'; +import '../../../../../models/trade_wallet_lookup.dart'; +import '../../../../../models/wallet_restore_state.dart'; +import '../../../../../services/address_book_service.dart'; +import '../../../../../services/frost.dart'; +import '../../../../../services/node_service.dart'; +import '../../../../../services/trade_notes_service.dart'; +import '../../../../../services/trade_sent_from_stack_service.dart'; +import '../../../../../services/trade_service.dart'; +import '../../../../../services/wallets.dart'; +import '../../../../../utilities/enums/backup_frequency_type.dart'; +import '../../../../../utilities/enums/stack_restoring_status.dart'; +import '../../../../../utilities/enums/sync_type_enum.dart'; +import '../../../../../utilities/flutter_secure_storage_interface.dart'; +import '../../../../../utilities/format.dart'; +import '../../../../../utilities/logger.dart'; +import '../../../../../utilities/prefs.dart'; +import '../../../../../utilities/util.dart'; +import '../../../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../../../wallets/crypto_currency/intermediate/frost_currency.dart'; +import '../../../../../wallets/isar/models/frost_wallet_info.dart'; +import '../../../../../wallets/isar/models/wallet_info.dart'; +import '../../../../../wallets/wallet/impl/bitcoin_frost_wallet.dart'; +import '../../../../../wallets/wallet/impl/epiccash_wallet.dart'; +import '../../../../../wallets/wallet/wallet.dart'; +import '../../../../../wallets/wallet/wallet_mixin_interfaces/cw_based_interface.dart'; +import '../../../../../wallets/wallet/wallet_mixin_interfaces/mnemonic_interface.dart'; +import '../../../../../wallets/wallet/wallet_mixin_interfaces/private_key_interface.dart'; + class PreRestoreState { final Set walletIds; final Map validJSON; @@ -80,7 +82,9 @@ String getErrorMessageFromSWBException(Exception e) { String createAutoBackupFilename(String dirPath, DateTime date) { // this filename structure is important. DO NOT CHANGE - return "$dirPath/stackautobackup_${date.year}_${date.month}_${date.day}_${date.hour}_${date.minute}_${date.second}.swb"; + return "$dirPath/stackautobackup_" + "${date.year}_${date.month}_${date.day}_${date.hour}" + "_${date.minute}_${date.second}.swb"; } abstract class SWB { @@ -95,8 +99,9 @@ abstract class SWB { .log("SWB cancel restore requested", level: LogLevel.Info); } else { Logging.instance.log( - "SWB cancel restore requested while a cancellation request is currently in progress", - level: LogLevel.Warning); + "SWB cancel restore requested while a cancellation request is currently in progress", + level: LogLevel.Warning, + ); } // return completer that will complete on SWBRestoreCancelEventType.completed event @@ -129,11 +134,11 @@ abstract class SWB { String plaintext, ) async { try { - File backupFile = File(fileToSave); + final File backupFile = File(fileToSave); if (!backupFile.existsSync()) { - String jsonBackup = plaintext; - Uint8List content = Uint8List.fromList(utf8.encode(jsonBackup)); - Uint8List encryptedContent = + final String jsonBackup = plaintext; + final Uint8List content = Uint8List.fromList(utf8.encode(jsonBackup)); + final Uint8List encryptedContent = await encryptWithPassphrase(passphrase, content); backupFile .writeAsStringSync(Format.uint8listToString(encryptedContent)); @@ -153,13 +158,15 @@ abstract class SWB { int adkVersion, ) async { try { - File backupFile = File(fileToSave); + final File backupFile = File(fileToSave); if (!backupFile.existsSync()) { - String jsonBackup = plaintext; - Uint8List content = Uint8List.fromList(utf8.encode(jsonBackup)); - Uint8List encryptedContent = await encryptWithAdk( - Format.stringToUint8List(adk), content, - version: adkVersion); + final String jsonBackup = plaintext; + final Uint8List content = Uint8List.fromList(utf8.encode(jsonBackup)); + final Uint8List encryptedContent = await encryptWithAdk( + Format.stringToUint8List(adk), + content, + version: adkVersion, + ); backupFile .writeAsStringSync(Format.uint8listToString(encryptedContent)); } @@ -175,10 +182,10 @@ abstract class SWB { Tuple2 data, ) async { try { - String fileToRestore = data.item1; - String passphrase = data.item2; - File backupFile = File(fileToRestore); - String encryptedText = await backupFile.readAsString(); + final String fileToRestore = data.item1; + final String passphrase = data.item2; + final File backupFile = File(fileToRestore); + final String encryptedText = await backupFile.readAsString(); return await decryptStackWalletStringWithPassphrase( Tuple2(encryptedText, passphrase), ); @@ -192,15 +199,15 @@ abstract class SWB { Tuple2 data, ) async { try { - String encryptedText = data.item1; - String passphrase = data.item2; + final encryptedText = data.item1; + final passphrase = data.item2; - final Uint8List encryptedBytes = Format.stringToUint8List(encryptedText); + final encryptedBytes = Format.stringToUint8List(encryptedText); - Uint8List decryptedContent = + final decryptedContent = await decryptWithPassphrase(passphrase, encryptedBytes); - final String jsonBackup = utf8.decode(decryptedContent); + final jsonBackup = utf8.decode(decryptedContent); return jsonBackup; } catch (e, s) { Logging.instance.log("$e\n$s", level: LogLevel.Error); @@ -215,24 +222,27 @@ abstract class SWB { Logging.instance .log("Starting createStackWalletJSON...", level: LogLevel.Info); final _wallets = Wallets.sharedInstance; - Map backupJson = {}; - NodeService nodeService = + final Map backupJson = {}; + final NodeService nodeService = NodeService(secureStorageInterface: secureStorage); final _secureStore = secureStorage; - Logging.instance.log("createStackWalletJSON awaiting DB.instance.mutex...", - level: LogLevel.Info); + Logging.instance.log( + "createStackWalletJSON awaiting DB.instance.mutex...", + level: LogLevel.Info, + ); // prevent modification of data await DB.instance.mutex.protect(() async { Logging.instance.log( - "...createStackWalletJSON DB.instance.mutex acquired", - level: LogLevel.Info); + "...createStackWalletJSON DB.instance.mutex acquired", + level: LogLevel.Info, + ); Logging.instance.log( "SWB backing up nodes", level: LogLevel.Warning, ); try { - var primaryNodes = nodeService.primaryNodes.map((e) async { + final primaryNodes = nodeService.primaryNodes.map((e) async { final map = e.toMap(); map["password"] = await e.getPassword(_secureStore); return map; @@ -258,7 +268,7 @@ abstract class SWB { level: LogLevel.Warning, ); - Map prefs = {}; + final Map prefs = {}; final _prefs = Prefs.instance; await _prefs.init(); prefs['currency'] = _prefs.currency; @@ -282,8 +292,8 @@ abstract class SWB { level: LogLevel.Warning, ); - AddressBookService addressBookService = AddressBookService(); - var addresses = addressBookService.contacts; + final AddressBookService addressBookService = AddressBookService(); + final addresses = addressBookService.contacts; backupJson['addressBookEntries'] = addresses.map((e) => e.toMap()).toList(); @@ -292,9 +302,9 @@ abstract class SWB { level: LogLevel.Warning, ); - List backupWallets = []; - for (var wallet in _wallets.wallets) { - Map backupWallet = {}; + final List backupWallets = []; + for (final wallet in _wallets.wallets) { + final Map backupWallet = {}; backupWallet['name'] = wallet.info.name; backupWallet['id'] = wallet.walletId; backupWallet['isFavorite'] = wallet.info.isFavourite; @@ -307,10 +317,11 @@ abstract class SWB { } else if (wallet is PrivateKeyInterface) { backupWallet['privateKey'] = await wallet.getPrivateKey(); } else if (wallet is BitcoinFrostWallet) { - String? keys = await wallet.getSerializedKeys(); - String? config = await wallet.getMultisigConfig(); + final String? keys = await wallet.getSerializedKeys(); + final String? config = await wallet.getMultisigConfig(); if (keys == null || config == null) { - String err = "${wallet.info.coin.name} wallet ${wallet.info.name} " + final String err = + "${wallet.info.coin.identifier} wallet ${wallet.info.name} " "has null keys or config"; Logging.instance.log(err, level: LogLevel.Fatal); throw Exception(err); @@ -320,12 +331,12 @@ abstract class SWB { // TODO [prio=low]: solve case in which either keys or config is null. // Format keys & config as a JSON string and set otherDataJsonString. - Map frostData = {}; + final Map frostData = {}; frostData["keys"] = keys; frostData["config"] = config; backupWallet['frostWalletData'] = jsonEncode(frostData); } - backupWallet['coinName'] = wallet.info.coin.name; + backupWallet['coinName'] = wallet.info.coin.identifier; backupWallet['storedChainHeight'] = wallet.info.cachedChainHeight; // backupWallet['txidList'] = DB.instance.get( @@ -377,8 +388,10 @@ abstract class SWB { final tradeNotes = tradeNotesService.all; backupJson["tradeNotes"] = tradeNotes; }); - Logging.instance.log("createStackWalletJSON DB.instance.mutex released", - level: LogLevel.Info); + Logging.instance.log( + "createStackWalletJSON DB.instance.mutex released", + level: LogLevel.Info, + ); // // back up notifications data // final notificationsService = NotificationsService(); @@ -411,9 +424,10 @@ abstract class SWB { } } else { if (walletbackup['mnemonic'] is List) { - List mnemonicList = (walletbackup['mnemonic'] as List) - .map((e) => e as String) - .toList(); + final List mnemonicList = + (walletbackup['mnemonic'] as List) + .map((e) => e as String) + .toList(); mnemonic = mnemonicList.join(" ").trim(); } else { mnemonic = walletbackup['mnemonic'] as String; @@ -432,7 +446,7 @@ abstract class SWB { try { String? serializedKeys; String? multisigConfig; - if (info.coin.isFrost) { + if (info.coin is FrostCurrency) { // Decode info.otherDataJsonString for Frost recovery info. final frostData = jsonDecode(walletbackup["frostWalletData"] as String); serializedKeys = frostData["keys"] as String; @@ -544,8 +558,9 @@ abstract class SWB { await restoringFuture; Logging.instance.log( - "SWB restored: ${info.walletId} ${info.name} ${info.coin.prettyName}", - level: LogLevel.Info); + "SWB restored: ${info.walletId} ${info.name} ${info.coin.prettyName}", + level: LogLevel.Info, + ); final currentAddress = await wallet.getCurrentReceivingAddress(); uiState?.update( @@ -576,15 +591,16 @@ abstract class SWB { Map oldToNewWalletIdMap, SecureStorageInterface secureStorageInterface, ) async { - Map prefs = validJSON["prefs"] as Map; - List? addressBookEntries = + final Map prefs = + validJSON["prefs"] as Map; + final List? addressBookEntries = validJSON["addressBookEntries"] as List?; - List? primaryNodes = validJSON["primaryNodes"] as List?; - List? nodes = validJSON["nodes"] as List?; - List? trades = validJSON["tradeHistory"] as List?; - List? tradeTxidLookupData = + final List? primaryNodes = validJSON["primaryNodes"] as List?; + final List? nodes = validJSON["nodes"] as List?; + final List? trades = validJSON["tradeHistory"] as List?; + final List? tradeTxidLookupData = validJSON["tradeTxidLookupData"] as List?; - Map? tradeNotes = + final Map? tradeNotes = validJSON["tradeNotes"] as Map?; uiState?.preferences = StackRestoringStatus.restoring; @@ -689,7 +705,7 @@ abstract class SWB { level: LogLevel.Warning, ); - List _currentWalletIds = await MainDB.instance.isar.walletInfo + final List _currentWalletIds = await MainDB.instance.isar.walletInfo .where() .walletIdProperty() .findAll(); @@ -697,12 +713,12 @@ abstract class SWB { final preRestoreState = PreRestoreState(_currentWalletIds.toSet(), preRestoreJSON); - Map oldToNewWalletIdMap = {}; + final Map oldToNewWalletIdMap = {}; - Map validJSON = + final Map validJSON = json.decode(jsonBackup) as Map; - List wallets = validJSON["wallets"] as List; + final List wallets = validJSON["wallets"] as List; // check for duplicate walletIds and assign new ones if required for (final wallet in wallets) { @@ -748,9 +764,9 @@ abstract class SWB { final List> managers = []; - Map walletStates = {}; + final Map walletStates = {}; - for (var walletbackup in wallets) { + for (final walletbackup in wallets) { // check if cancel was requested and restore previous state if (_checkShouldCancel( preRestoreState, @@ -759,8 +775,14 @@ abstract class SWB { return false; } - final coin = Coin.values - .firstWhere((element) => element.name == walletbackup['coinName']); + final coin = AppConfig.getCryptoCurrencyFor( + walletbackup['coinName'] as String, + ); + + if (coin == null) { + continue; + } + final walletName = walletbackup['name'] as String; final walletId = oldToNewWalletIdMap[walletbackup["id"] as String]!; @@ -781,7 +803,7 @@ abstract class SWB { ); } - if (coin == Coin.firo) { + if (coin is Firo) { otherData ??= {}; // swb will do a restore so this flag should be set to false so another // rescan/restore isn't done when opening the wallet @@ -789,7 +811,7 @@ abstract class SWB { } final info = WalletInfo( - coinName: coin.name, + coinName: coin.identifier, walletId: walletId, name: walletName, mainAddressType: coin.primaryAddressType, @@ -798,10 +820,10 @@ abstract class SWB { cachedChainHeight: walletbackup['storedChainHeight'] as int? ?? 0, ); - var node = nodeService.getPrimaryNodeFor(coin: coin); + var node = nodeService.getPrimaryNodeFor(currency: coin); if (node == null) { - node = DefaultNodes.getNodeFor(coin); + node = coin.defaultNode; await nodeService.setPrimaryNodeFor(coin: coin, node: node); } @@ -845,7 +867,7 @@ abstract class SWB { // set the states so the ui can display each status as they update during restores uiState?.walletStates = walletStates; - List> restoreStatuses = []; + final List> restoreStatuses = []; // start restoring wallets for (final tuple in managers) { // check if cancel was requested and restore previous state @@ -873,7 +895,7 @@ abstract class SWB { return false; } - for (Future status in restoreStatuses) { + for (final Future status in restoreStatuses) { // check if cancel was requested and restore previous state if (_checkShouldCancel( preRestoreState, @@ -905,17 +927,18 @@ abstract class SWB { PreRestoreState revertToState, SecureStorageInterface secureStorageInterface, ) async { - Map prefs = + final Map prefs = revertToState.validJSON["prefs"] as Map; - List? addressBookEntries = + final List? addressBookEntries = revertToState.validJSON["addressBookEntries"] as List?; - List? primaryNodes = + final List? primaryNodes = revertToState.validJSON["primaryNodes"] as List?; - List? nodes = revertToState.validJSON["nodes"] as List?; - List? trades = revertToState.validJSON["tradeHistory"] as List?; - List? tradeTxidLookupData = + final List? nodes = revertToState.validJSON["nodes"] as List?; + final List? trades = + revertToState.validJSON["tradeHistory"] as List?; + final List? tradeTxidLookupData = revertToState.validJSON["tradeTxidLookupData"] as List?; - Map? tradeNotes = + final Map? tradeNotes = revertToState.validJSON["tradeNotes"] as Map?; // prefs @@ -944,14 +967,23 @@ abstract class SWB { // pre restore state has contact if (contact != null) { // ensure this contact's data matches the pre restore state - List addresses = []; - for (var address in (contact['addresses'] as List)) { + final List addresses = []; + for (final address in (contact['addresses'] as List)) { + final entry = ContactAddressEntry() + ..coinName = address['coin'] as String + ..address = address['address'] as String + ..label = address['label'] as String + ..other = address['other'] as String?; + + try { + entry.coin; + } catch (_) { + // coin not supported so ignore this entry + continue; + } + addresses.add( - ContactAddressEntry() - ..coinName = address['coin'] as String - ..address = address['address'] as String - ..label = address['label'] as String - ..other = address['other'] as String?, + entry, ); } await addressBookService.editContact( @@ -971,7 +1003,7 @@ abstract class SWB { } // nodes - NodeService nodeService = NodeService( + final NodeService nodeService = NodeService( secureStorageInterface: secureStorageInterface, ); final currentNodes = nodeService.nodes; @@ -994,19 +1026,20 @@ abstract class SWB { // node existed before restore attempt // revert to pre restore node await nodeService.edit( - node.copyWith( - host: nodeData['host'] as String, - port: nodeData['port'] as int, - name: nodeData['name'] as String, - useSSL: nodeData['useSSL'] == "false" ? false : true, - enabled: nodeData['enabled'] == "false" ? false : true, - coinName: nodeData['coinName'] as String, - loginName: nodeData['loginName'] as String?, - isFailover: nodeData['isFailover'] as bool, - isDown: nodeData['isDown'] as bool, - ), - nodeData['password'] as String?, - true); + node.copyWith( + host: nodeData['host'] as String, + port: nodeData['port'] as int, + name: nodeData['name'] as String, + useSSL: nodeData['useSSL'] == "false" ? false : true, + enabled: nodeData['enabled'] == "false" ? false : true, + coinName: nodeData['coinName'] as String, + loginName: nodeData['loginName'] as String?, + isFailover: nodeData['isFailover'] as bool, + isDown: nodeData['isDown'] as bool, + ), + nodeData['password'] as String?, + true, + ); } else { await nodeService.delete(node.id, true); } @@ -1015,10 +1048,19 @@ abstract class SWB { // primary nodes if (primaryNodes != null) { - for (var node in primaryNodes) { + for (final node in primaryNodes) { try { + final CryptoCurrency coin; + try { + coin = AppConfig.getCryptoCurrencyByPrettyName( + node['coinName'] as String, + ); + } catch (_) { + continue; + } + await nodeService.setPrimaryNodeFor( - coin: coinFromPrettyName(node['coinName'] as String), + coin: coin, node: nodeService.getNodeById(id: node['id'] as String)!, ); } catch (e, s) { @@ -1050,12 +1092,15 @@ abstract class SWB { // trade existed before attempted restore so we don't delete it, only // revert data to pre restore state await tradesService.edit( - trade: Trade.fromMap(tradeData as Map), - shouldNotifyListeners: true); + trade: Trade.fromMap(tradeData as Map), + shouldNotifyListeners: true, + ); } else { // trade did not exist before so we delete it await tradesService.delete( - trade: tradeTx, shouldNotifyListeners: true); + trade: tradeTx, + shouldNotifyListeners: true, + ); } } } @@ -1093,7 +1138,7 @@ abstract class SWB { if (tradeTxidLookupData != null) { for (int i = 0; i < tradeTxidLookupData.length; i++) { final json = Map.from(tradeTxidLookupData[i] as Map); - TradeWalletLookup lookup = TradeWalletLookup.fromJson(json); + final TradeWalletLookup lookup = TradeWalletLookup.fromJson(json); await tradeTxidLookupDataService.save(tradeWalletLookup: lookup); } } @@ -1137,8 +1182,9 @@ abstract class SWB { _prefs.isAutoBackupEnabled = prefs['isAutoBackupEnabled'] as bool; _prefs.autoBackupLocation = prefs['autoBackupLocation'] as String?; _prefs.backupFrequencyType = BackupFrequencyType.values.firstWhere( - (e) => e.name == (prefs['backupFrequencyType'] as String?), - orElse: () => BackupFrequencyType.everyAppStart); + (e) => e.name == (prefs['backupFrequencyType'] as String?), + orElse: () => BackupFrequencyType.everyAppStart, + ); _prefs.lastAutoBackup = DateTime.tryParse(prefs['lastAutoBackup'] as String? ?? ""); } @@ -1146,27 +1192,38 @@ abstract class SWB { static Future _restoreAddressBook( List addressBookEntries, ) async { - AddressBookService addressBookService = AddressBookService(); - for (var contact in addressBookEntries) { - List addresses = []; - for (var address in (contact['addresses'] as List)) { + final AddressBookService addressBookService = AddressBookService(); + for (final contact in addressBookEntries) { + final List addresses = []; + for (final address in (contact['addresses'] as List)) { + final entry = ContactAddressEntry() + ..coinName = address['coin'] as String + ..address = address['address'] as String + ..label = address['label'] as String + ..other = address['other'] as String?; + + try { + entry.coin; + } catch (_) { + // coin not supported so ignore this entry + continue; + } + addresses.add( - ContactAddressEntry() - ..coinName = address['coin'] as String - ..address = address['address'] as String - ..label = address['label'] as String - ..other = address['other'] as String?, + entry, + ); + } + if (addresses.isNotEmpty) { + await addressBookService.addContact( + ContactEntry( + emojiChar: contact['emoji'] as String?, + name: contact['name'] as String, + addresses: addresses, + isFavorite: contact['isFavorite'] as bool, + customId: contact['id'] as String, + ), ); } - await addressBookService.addContact( - ContactEntry( - emojiChar: contact['emoji'] as String?, - name: contact['name'] as String, - addresses: addresses, - isFavorite: contact['isFavorite'] as bool, - customId: contact['id'] as String, - ), - ); } } @@ -1175,11 +1232,11 @@ abstract class SWB { List? primaryNodes, SecureStorageInterface secureStorageInterface, ) async { - NodeService nodeService = NodeService( + final NodeService nodeService = NodeService( secureStorageInterface: secureStorageInterface, ); if (nodes != null) { - for (var node in nodes) { + for (final node in nodes) { await nodeService.add( NodeModel( host: node['host'] as String, @@ -1199,10 +1256,19 @@ abstract class SWB { } } if (primaryNodes != null) { - for (var node in primaryNodes) { + for (final node in primaryNodes) { + final CryptoCurrency coin; + try { + coin = AppConfig.getCryptoCurrencyByPrettyName( + node['coinName'] as String, + ); + } catch (_) { + continue; + } + try { await nodeService.setPrimaryNodeFor( - coin: coinFromPrettyName(node['coinName'] as String), + coin: coin, node: nodeService.getNodeById(id: node['id'] as String)!, ); } catch (e, s) { @@ -1272,16 +1338,18 @@ abstract class SWB { final json = Map.from(tradeTxidLookupData[i] as Map); TradeWalletLookup lookup = TradeWalletLookup.fromJson(json); // update walletIds - List walletIds = + final List walletIds = lookup.walletIds.map((e) => oldToNewWalletIdMap[e]!).toList(); lookup = lookup.copyWith(walletIds: walletIds); final oldLookup = DB.instance.get( - boxName: DB.boxNameTradeLookup, key: lookup.uuid); + boxName: DB.boxNameTradeLookup, + key: lookup.uuid, + ); if (oldLookup != null) { if (oldLookup.txid == lookup.txid && oldLookup.tradeId == lookup.tradeId) { - List mergedList = oldLookup.walletIds; + final List mergedList = oldLookup.walletIds; for (final id in lookup.walletIds) { if (!mergedList.contains(id)) { mergedList.add(id); @@ -1308,7 +1376,9 @@ abstract class SWB { final tradeNotesService = TradeNotesService(); for (final note in tradeNotes.entries) { await tradeNotesService.set( - tradeId: note.key, note: note.value as String); + tradeId: note.key, + note: note.value as String, + ); } } } diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/swb_file_system.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/swb_file_system.dart index 046e8642f..2b480d59b 100644 --- a/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/swb_file_system.dart +++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/swb_file_system.dart @@ -14,7 +14,7 @@ import 'package:file_picker/file_picker.dart'; import 'package:flutter/material.dart'; import 'package:path_provider/path_provider.dart'; import 'package:permission_handler/permission_handler.dart'; -import 'package:stackwallet/utilities/util.dart'; +import '../../../../../utilities/util.dart'; class SWBFileSystem { Directory? rootPath; diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/restore_from_encrypted_string_view.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/restore_from_encrypted_string_view.dart index d67e2e663..3bbb3cd5e 100644 --- a/lib/pages/settings_views/global_settings_view/stack_backup_views/restore_from_encrypted_string_view.dart +++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/restore_from_encrypted_string_view.dart @@ -12,19 +12,19 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/home_view/home_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/sub_views/stack_restore_progress_view.dart'; -import 'package:stackwallet/route_generator.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/loading_indicator.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; +import '../../../../notifications/show_flush_bar.dart'; +import '../../../home_view/home_view.dart'; +import 'helpers/restore_create_backup.dart'; +import 'sub_views/stack_restore_progress_view.dart'; +import '../../../../route_generator.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/loading_indicator.dart'; +import '../../../../widgets/stack_text_field.dart'; import 'package:tuple/tuple.dart'; class RestoreFromEncryptedStringView extends ConsumerStatefulWidget { diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/restore_from_file_view.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/restore_from_file_view.dart index ccba85e65..5a609acb4 100644 --- a/lib/pages/settings_views/global_settings_view/stack_backup_views/restore_from_file_view.dart +++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/restore_from_file_view.dart @@ -15,26 +15,27 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/helpers/swb_file_system.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/sub_views/stack_restore_progress_view.dart'; -import 'package:stackwallet/route_generator.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/loading_indicator.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; +import '../../../../app_config.dart'; +import '../../../../notifications/show_flush_bar.dart'; +import 'helpers/restore_create_backup.dart'; +import 'helpers/swb_file_system.dart'; +import 'sub_views/stack_restore_progress_view.dart'; +import '../../../../route_generator.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/logger.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/conditional_parent.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/desktop/secondary_button.dart'; +import '../../../../widgets/loading_indicator.dart'; +import '../../../../widgets/stack_text_field.dart'; import 'package:tuple/tuple.dart'; class RestoreFromFileView extends ConsumerStatefulWidget { @@ -533,9 +534,10 @@ class _RestoreFromFileViewState extends ConsumerState { Padding( padding: const EdgeInsets - .all(32), + .all( + 32), child: Text( - "Restore Stack Wallet", + "Restore {$AppConfig.appName}", style: STextStyles .desktopH3( context), @@ -550,7 +552,7 @@ class _RestoreFromFileViewState extends ConsumerState { Padding( padding: const EdgeInsets - .symmetric( + .symmetric( horizontal: 32), child: diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/stack_backup_view.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/stack_backup_view.dart index 7e20dac36..2db8cbc9d 100644 --- a/lib/pages/settings_views/global_settings_view/stack_backup_views/stack_backup_view.dart +++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/stack_backup_view.dart @@ -10,16 +10,16 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/auto_backup_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/create_backup_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/restore_from_file_view.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import 'auto_backup_view.dart'; +import 'create_backup_view.dart'; +import 'restore_from_file_view.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/rounded_white_container.dart'; class StackBackupView extends StatelessWidget { const StackBackupView({ diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/sub_views/backup_frequency_type_select_sheet.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/sub_views/backup_frequency_type_select_sheet.dart index 03a59db95..01203c0ae 100644 --- a/lib/pages/settings_views/global_settings_view/stack_backup_views/sub_views/backup_frequency_type_select_sheet.dart +++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/sub_views/backup_frequency_type_select_sheet.dart @@ -10,11 +10,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/backup_frequency_type.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; +import '../../../../../providers/global/prefs_provider.dart'; +import '../../../../../themes/stack_colors.dart'; +import '../../../../../utilities/constants.dart'; +import '../../../../../utilities/enums/backup_frequency_type.dart'; +import '../../../../../utilities/text_styles.dart'; class BackupFrequencyTypeSelectSheet extends ConsumerWidget { const BackupFrequencyTypeSelectSheet({ diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/sub_views/recovery_phrase_view.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/sub_views/recovery_phrase_view.dart index 7d60a2e55..af533c9c4 100644 --- a/lib/pages/settings_views/global_settings_view/stack_backup_views/sub_views/recovery_phrase_view.dart +++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/sub_views/recovery_phrase_view.dart @@ -11,13 +11,13 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_view/sub_widgets/mnemonic_table.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/clipboard_interface.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../../notifications/show_flush_bar.dart'; +import '../../../../add_wallet_views/new_wallet_recovery_phrase_view/sub_widgets/mnemonic_table.dart'; +import '../../../../../themes/stack_colors.dart'; +import '../../../../../utilities/assets.dart'; +import '../../../../../utilities/clipboard_interface.dart'; +import '../../../../../utilities/text_styles.dart'; +import '../../../../../widgets/custom_buttons/app_bar_icon_button.dart'; class RecoverPhraseView extends StatelessWidget { const RecoverPhraseView({ diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/sub_views/stack_restore_progress_view.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/sub_views/stack_restore_progress_view.dart index 4825fe4cc..0cd60b29c 100644 --- a/lib/pages/settings_views/global_settings_view/stack_backup_views/sub_views/stack_restore_progress_view.dart +++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/sub_views/stack_restore_progress_view.dart @@ -13,32 +13,33 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/pages/home_view/home_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/dialogs/cancel_stack_restore_dialog.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/restore_from_encrypted_string_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/stack_backup_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/sub_widgets/restoring_item_card.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/sub_widgets/restoring_wallet_card.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_home_view.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_menu.dart'; -import 'package:stackwallet/providers/desktop/current_desktop_menu_item.dart'; -import 'package:stackwallet/providers/global/secure_store_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/providers/stack_restore/stack_restoring_ui_state_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/enums/stack_restoring_status.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/addressbook_icon.dart'; -import 'package:stackwallet/widgets/loading_indicator.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; +import '../../../../../app_config.dart'; +import '../../../../home_view/home_view.dart'; +import '../dialogs/cancel_stack_restore_dialog.dart'; +import '../helpers/restore_create_backup.dart'; +import '../restore_from_encrypted_string_view.dart'; +import '../stack_backup_view.dart'; +import '../sub_widgets/restoring_item_card.dart'; +import '../sub_widgets/restoring_wallet_card.dart'; +import '../../../../../pages_desktop_specific/desktop_home_view.dart'; +import '../../../../../pages_desktop_specific/desktop_menu.dart'; +import '../../../../../providers/desktop/current_desktop_menu_item.dart'; +import '../../../../../providers/global/secure_store_provider.dart'; +import '../../../../../providers/providers.dart'; +import '../../../../../providers/stack_restore/stack_restoring_ui_state_provider.dart'; +import '../../../../../themes/stack_colors.dart'; +import '../../../../../utilities/assets.dart'; +import '../../../../../utilities/enums/stack_restoring_status.dart'; +import '../../../../../utilities/logger.dart'; +import '../../../../../utilities/text_styles.dart'; +import '../../../../../utilities/util.dart'; +import '../../../../../widgets/conditional_parent.dart'; +import '../../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../../widgets/desktop/primary_button.dart'; +import '../../../../../widgets/desktop/secondary_button.dart'; +import '../../../../../widgets/icon_widgets/addressbook_icon.dart'; +import '../../../../../widgets/loading_indicator.dart'; +import '../../../../../widgets/rounded_container.dart'; class StackRestoreProgressView extends ConsumerStatefulWidget { const StackRestoreProgressView({ @@ -263,7 +264,7 @@ class _StackRestoreProgressViewState }, ), title: Text( - "Restoring Stack wallet", + "Restoring {$AppConfig.appName}", style: STextStyles.navBarTitle(context), ), ), diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/sub_widgets/restoring_item_card.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/sub_widgets/restoring_item_card.dart index 274c3d846..6e00445ff 100644 --- a/lib/pages/settings_views/global_settings_view/stack_backup_views/sub_widgets/restoring_item_card.dart +++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/sub_widgets/restoring_item_card.dart @@ -9,9 +9,9 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../../../utilities/text_styles.dart'; +import '../../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../../widgets/rounded_white_container.dart'; class RestoringItemCard extends StatelessWidget { const RestoringItemCard({ diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/sub_widgets/restoring_wallet_card.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/sub_widgets/restoring_wallet_card.dart index 36c3d7c81..29bebd5f1 100644 --- a/lib/pages/settings_views/global_settings_view/stack_backup_views/sub_widgets/restoring_wallet_card.dart +++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/sub_widgets/restoring_wallet_card.dart @@ -13,20 +13,20 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/models/wallet_restore_state.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/sub_views/recovery_phrase_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/sub_widgets/restoring_item_card.dart'; -import 'package:stackwallet/providers/stack_restore/stack_restoring_ui_state_provider.dart'; -import 'package:stackwallet/route_generator.dart'; -import 'package:stackwallet/themes/coin_icon_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/stack_restoring_status.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/loading_indicator.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; +import '../../../../../models/wallet_restore_state.dart'; +import '../sub_views/recovery_phrase_view.dart'; +import 'restoring_item_card.dart'; +import '../../../../../providers/stack_restore/stack_restoring_ui_state_provider.dart'; +import '../../../../../route_generator.dart'; +import '../../../../../themes/coin_icon_provider.dart'; +import '../../../../../themes/stack_colors.dart'; +import '../../../../../themes/theme_providers.dart'; +import '../../../../../utilities/assets.dart'; +import '../../../../../utilities/enums/stack_restoring_status.dart'; +import '../../../../../utilities/text_styles.dart'; +import '../../../../../utilities/util.dart'; +import '../../../../../widgets/loading_indicator.dart'; +import '../../../../../widgets/rounded_container.dart'; class RestoringWalletCard extends ConsumerStatefulWidget { const RestoringWalletCard({ @@ -89,9 +89,7 @@ class _RestoringWalletCardState extends ConsumerState { height: 32, child: RoundedContainer( padding: const EdgeInsets.all(0), - color: Theme.of(context) - .extension()! - .colorForCoin(coin), + color: ref.watch(pCoinColor(coin)), child: Center( child: SvgPicture.file( File( @@ -212,9 +210,7 @@ class _RestoringWalletCardState extends ConsumerState { height: 32, child: RoundedContainer( padding: const EdgeInsets.all(0), - color: Theme.of(context) - .extension()! - .colorForCoin(coin), + color: ref.watch(pCoinColor(coin)), child: Center( child: SvgPicture.file( File( @@ -239,7 +235,7 @@ class _RestoringWalletCardState extends ConsumerState { try { // final mnemonicList = await manager.mnemonic; // int maxUnusedAddressGap = 20; - // if (coin == Coin.firo) { + // if (coin is Firo) { // maxUnusedAddressGap = 50; // } // const maxNumberOfIndexesToCheck = 1000; diff --git a/lib/pages/settings_views/global_settings_view/startup_preferences/startup_preferences_view.dart b/lib/pages/settings_views/global_settings_view/startup_preferences/startup_preferences_view.dart index 835d156df..dad06ecb1 100644 --- a/lib/pages/settings_views/global_settings_view/startup_preferences/startup_preferences_view.dart +++ b/lib/pages/settings_views/global_settings_view/startup_preferences/startup_preferences_view.dart @@ -13,16 +13,17 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/startup_preferences/startup_wallet_selection_view.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/coin_icon_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../../app_config.dart'; +import 'startup_wallet_selection_view.dart'; +import '../../../../providers/providers.dart'; +import '../../../../themes/coin_icon_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/rounded_white_container.dart'; class StartupPreferencesView extends ConsumerStatefulWidget { const StartupPreferencesView({Key? key}) : super(key: key); @@ -158,7 +159,7 @@ class _StartupPreferencesViewState textAlign: TextAlign.left, ), Text( - "Stack Wallet home screen", + "${AppConfig.appName} home screen", style: STextStyles.itemSubtitle( context), diff --git a/lib/pages/settings_views/global_settings_view/startup_preferences/startup_wallet_selection_view.dart b/lib/pages/settings_views/global_settings_view/startup_preferences/startup_wallet_selection_view.dart index 6e057eaf4..0be056535 100644 --- a/lib/pages/settings_views/global_settings_view/startup_preferences/startup_wallet_selection_view.dart +++ b/lib/pages/settings_views/global_settings_view/startup_preferences/startup_wallet_selection_view.dart @@ -13,16 +13,17 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/coin_icon_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/draggable_switch_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../../providers/providers.dart'; +import '../../../../themes/coin_icon_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../themes/theme_providers.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/custom_buttons/draggable_switch_button.dart'; +import '../../../../widgets/rounded_white_container.dart'; class StartupWalletSelectionView extends ConsumerStatefulWidget { const StartupWalletSelectionView({Key? key}) : super(key: key); @@ -63,165 +64,181 @@ class _StartupWalletSelectionViewState ), ), ), - body: LayoutBuilder(builder: (context, constraints) { - return Padding( - padding: const EdgeInsets.only( - left: 12, - top: 12, - right: 12, - ), - child: SingleChildScrollView( - child: ConstrainedBox( - constraints: BoxConstraints( - minHeight: constraints.maxHeight - 24, - ), - child: IntrinsicHeight( - child: Padding( - padding: const EdgeInsets.all(4), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - const SizedBox( - height: 4, - ), - Text( - "Select a wallet to load into immediately on startup", - style: STextStyles.smallMed12(context), - ), - const SizedBox( - height: 12, - ), - RoundedWhiteContainer( - padding: const EdgeInsets.all(0), - child: Column( - children: [ - ...wallets.map( - (wallet) => Padding( - padding: const EdgeInsets.all(12), - child: Row( - key: Key( - "startupWalletSelectionGroupKey_${wallet.walletId}"), - children: [ - Container( - decoration: BoxDecoration( - color: Theme.of(context) - .extension()! - .colorForCoin( - ref.watch(pWalletCoin( - wallet.walletId)), - ) - .withOpacity(0.5), - borderRadius: BorderRadius.circular( - Constants.size.circularBorderRadius, + body: LayoutBuilder( + builder: (context, constraints) { + return Padding( + padding: const EdgeInsets.only( + left: 12, + top: 12, + right: 12, + ), + child: SingleChildScrollView( + child: ConstrainedBox( + constraints: BoxConstraints( + minHeight: constraints.maxHeight - 24, + ), + child: IntrinsicHeight( + child: Padding( + padding: const EdgeInsets.all(4), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + const SizedBox( + height: 4, + ), + Text( + "Select a wallet to load into immediately on startup", + style: STextStyles.smallMed12(context), + ), + const SizedBox( + height: 12, + ), + RoundedWhiteContainer( + padding: const EdgeInsets.all(0), + child: Column( + children: [ + ...wallets.map( + (wallet) => Padding( + padding: const EdgeInsets.all(12), + child: Row( + key: Key( + "startupWalletSelectionGroupKey_${wallet.walletId}", + ), + children: [ + Container( + decoration: BoxDecoration( + color: ref + .watch( + pCoinColor( + ref.watch( + pWalletCoin( + wallet.walletId, + ), + ), + ), + ) + .withOpacity(0.5), + borderRadius: BorderRadius.circular( + Constants + .size.circularBorderRadius, + ), ), - ), - child: Padding( - padding: const EdgeInsets.all(4), - child: SvgPicture.file( - File( - ref.watch( - coinIconProvider( - ref.watch(pWalletCoin( - wallet.walletId)), + child: Padding( + padding: const EdgeInsets.all(4), + child: SvgPicture.file( + File( + ref.watch( + coinIconProvider( + ref.watch( + pWalletCoin( + wallet.walletId, + ), + ), + ), ), ), + width: 20, + height: 20, ), - width: 20, - height: 20, ), ), - ), - const SizedBox( - width: 12, - ), - Expanded( - child: Column( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - ref.watch( - pWalletName(wallet.walletId)), - style: STextStyles.titleBold12( - context), - ), - // const SizedBox( - // height: 2, - // ), - // FutureBuilder( - // future: manager.totalBalance, - // builder: (builderContext, - // AsyncSnapshot snapshot) { - // if (snapshot.connectionState == - // ConnectionState.done && - // snapshot.hasData) { - // return Text( - // "${Format.localizedStringAsFixed( - // value: snapshot.data!, - // locale: ref.watch( - // localeServiceChangeNotifierProvider - // .select((value) => - // value.locale)), - // decimalPlaces: 8, - // )} ${manager.coin.ticker}", - // style: STextStyles.itemSubtitle(context), - // ); - // } else { - // return AnimatedText( - // stringsToLoopThrough: const [ - // "Loading balance", - // "Loading balance.", - // "Loading balance..", - // "Loading balance..." - // ], - // style: STextStyles.itemSubtitle(context), - // ); - // } - // }, - // ), - ], + const SizedBox( + width: 12, ), - ), - SizedBox( - height: 20, - width: 20, - child: Radio( - activeColor: Theme.of(context) - .extension()! - .radioButtonIconEnabled, - value: wallet.walletId, - groupValue: ref.watch( - prefsChangeNotifierProvider.select( + Expanded( + child: Column( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + ref.watch( + pWalletName(wallet.walletId), + ), + style: STextStyles.titleBold12( + context, + ), + ), + // const SizedBox( + // height: 2, + // ), + // FutureBuilder( + // future: manager.totalBalance, + // builder: (builderContext, + // AsyncSnapshot snapshot) { + // if (snapshot.connectionState == + // ConnectionState.done && + // snapshot.hasData) { + // return Text( + // "${Format.localizedStringAsFixed( + // value: snapshot.data!, + // locale: ref.watch( + // localeServiceChangeNotifierProvider + // .select((value) => + // value.locale)), + // decimalPlaces: 8, + // )} ${manager.coin.ticker}", + // style: STextStyles.itemSubtitle(context), + // ); + // } else { + // return AnimatedText( + // stringsToLoopThrough: const [ + // "Loading balance", + // "Loading balance.", + // "Loading balance..", + // "Loading balance..." + // ], + // style: STextStyles.itemSubtitle(context), + // ); + // } + // }, + // ), + ], + ), + ), + SizedBox( + height: 20, + width: 20, + child: Radio( + activeColor: Theme.of(context) + .extension()! + .radioButtonIconEnabled, + value: wallet.walletId, + groupValue: ref.watch( + prefsChangeNotifierProvider + .select( (value) => - value.startupWalletId), + value.startupWalletId, + ), + ), + onChanged: (value) { + if (value is String) { + ref + .read( + prefsChangeNotifierProvider, + ) + .startupWalletId = value; + } + }, ), - onChanged: (value) { - if (value is String) { - ref - .read( - prefsChangeNotifierProvider) - .startupWalletId = value; - } - }, ), - ), - ], + ], + ), ), ), - ), - ], + ], + ), ), - ), - ], + ], + ), ), ), ), ), - ), - ); - }), + ); + }, + ), ), ); } diff --git a/lib/pages/settings_views/global_settings_view/support_view.dart b/lib/pages/settings_views/global_settings_view/support_view.dart index d8865a5f3..8c3d14f32 100644 --- a/lib/pages/settings_views/global_settings_view/support_view.dart +++ b/lib/pages/settings_views/global_settings_view/support_view.dart @@ -10,15 +10,16 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../app_config.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../widgets/background.dart'; +import '../../../widgets/conditional_parent.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/rounded_white_container.dart'; import 'package:url_launcher/url_launcher.dart'; class SupportView extends StatelessWidget { @@ -88,7 +89,7 @@ class SupportView extends StatelessWidget { AboutItem( linkUrl: "https://discord.com/invite/mRPZuXx3At", label: "Discord", - buttonText: "Stack Wallet", + buttonText: AppConfig.appName, iconAsset: Assets.socials.discord, isDesktop: isDesktop, ), diff --git a/lib/pages/settings_views/global_settings_view/syncing_preferences_views/syncing_options_view.dart b/lib/pages/settings_views/global_settings_view/syncing_preferences_views/syncing_options_view.dart index 58144b681..d20e9dcbc 100644 --- a/lib/pages/settings_views/global_settings_view/syncing_preferences_views/syncing_options_view.dart +++ b/lib/pages/settings_views/global_settings_view/syncing_preferences_views/syncing_options_view.dart @@ -10,19 +10,19 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/syncing_preferences_views/wallet_syncing_options_view.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/sync_type_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import 'wallet_syncing_options_view.dart'; +import '../../../../providers/providers.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/enums/sync_type_enum.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/conditional_parent.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../../widgets/rounded_white_container.dart'; class SyncingOptionsView extends ConsumerWidget { const SyncingOptionsView({Key? key}) : super(key: key); diff --git a/lib/pages/settings_views/global_settings_view/syncing_preferences_views/syncing_preferences_view.dart b/lib/pages/settings_views/global_settings_view/syncing_preferences_views/syncing_preferences_view.dart index 74fda4510..58a768a70 100644 --- a/lib/pages/settings_views/global_settings_view/syncing_preferences_views/syncing_preferences_view.dart +++ b/lib/pages/settings_views/global_settings_view/syncing_preferences_views/syncing_preferences_view.dart @@ -10,16 +10,16 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/syncing_preferences_views/syncing_options_view.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/sync_type_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/draggable_switch_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import 'syncing_options_view.dart'; +import '../../../../providers/providers.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/enums/sync_type_enum.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/custom_buttons/draggable_switch_button.dart'; +import '../../../../widgets/rounded_white_container.dart'; class SyncingPreferencesView extends ConsumerWidget { const SyncingPreferencesView({Key? key}) : super(key: key); diff --git a/lib/pages/settings_views/global_settings_view/syncing_preferences_views/wallet_syncing_options_view.dart b/lib/pages/settings_views/global_settings_view/syncing_preferences_views/wallet_syncing_options_view.dart index 8ded05dd6..9b22c13ae 100644 --- a/lib/pages/settings_views/global_settings_view/syncing_preferences_views/wallet_syncing_options_view.dart +++ b/lib/pages/settings_views/global_settings_view/syncing_preferences_views/wallet_syncing_options_view.dart @@ -13,19 +13,20 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/coin_icon_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/draggable_switch_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../../providers/providers.dart'; +import '../../../../themes/coin_icon_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../themes/theme_providers.dart'; +import '../../../../utilities/amount/amount_formatter.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/conditional_parent.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/custom_buttons/draggable_switch_button.dart'; +import '../../../../widgets/rounded_white_container.dart'; class WalletSyncingOptionsView extends ConsumerWidget { const WalletSyncingOptionsView({Key? key}) : super(key: key); @@ -117,9 +118,8 @@ class WalletSyncingOptionsView extends ConsumerWidget { children: [ Container( decoration: BoxDecoration( - color: Theme.of(context) - .extension()! - .colorForCoin(info.coin) + color: ref + .watch(pCoinColor(info.coin)) .withOpacity(0.5), borderRadius: BorderRadius.circular( Constants.size.circularBorderRadius, diff --git a/lib/pages/settings_views/global_settings_view/tor_settings/tor_settings_view.dart b/lib/pages/settings_views/global_settings_view/tor_settings/tor_settings_view.dart index c05a519ef..0d6acf41d 100644 --- a/lib/pages/settings_views/global_settings_view/tor_settings/tor_settings_view.dart +++ b/lib/pages/settings_views/global_settings_view/tor_settings/tor_settings_view.dart @@ -14,23 +14,23 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:lottie/lottie.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/services/event_bus/events/global/tor_connection_status_changed_event.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/stack_file_system.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/draggable_switch_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; -import 'package:stackwallet/widgets/tor_subscription.dart'; +import '../../../../providers/global/prefs_provider.dart'; +import '../../../../services/event_bus/events/global/tor_connection_status_changed_event.dart'; +import '../../../../services/tor_service.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/logger.dart'; +import '../../../../utilities/stack_file_system.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/conditional_parent.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/custom_buttons/draggable_switch_button.dart'; +import '../../../../widgets/desktop/secondary_button.dart'; +import '../../../../widgets/rounded_white_container.dart'; +import '../../../../widgets/stack_dialog.dart'; +import '../../../../widgets/tor_subscription.dart'; class TorSettingsView extends ConsumerStatefulWidget { const TorSettingsView({ diff --git a/lib/pages/settings_views/sub_widgets/nodes_list.dart b/lib/pages/settings_views/sub_widgets/nodes_list.dart index 52d9b8861..8d7db8292 100644 --- a/lib/pages/settings_views/sub_widgets/nodes_list.dart +++ b/lib/pages/settings_views/sub_widgets/nodes_list.dart @@ -10,40 +10,40 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/providers/global/node_service_provider.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/widgets/node_card.dart'; +import '../../../providers/global/node_service_provider.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../widgets/node_card.dart'; class NodesList extends ConsumerWidget { const NodesList({ - Key? key, + super.key, required this.coin, required this.popBackToRoute, - }) : super(key: key); + }); - final Coin coin; + final CryptoCurrency coin; final String popBackToRoute; @override Widget build(BuildContext context, WidgetRef ref) { - final nodes = ref.watch(nodeServiceChangeNotifierProvider - .select((value) => value.getNodesFor(coin))); + final nodes = ref.watch( + nodeServiceChangeNotifierProvider + .select((value) => value.getNodesFor(coin)), + ); return Column( children: [ - ...nodes - .map( - (node) => Padding( - padding: const EdgeInsets.symmetric(vertical: 4), - child: NodeCard( - key: Key("${node.id}_card_key"), - nodeId: node.id, - coin: coin, - popBackToRoute: popBackToRoute, - ), - ), - ) - .toList(), + ...nodes.map( + (node) => Padding( + padding: const EdgeInsets.symmetric(vertical: 4), + child: NodeCard( + key: Key("${node.id}_card_key"), + nodeId: node.id, + coin: coin, + popBackToRoute: popBackToRoute, + ), + ), + ), ], ); } diff --git a/lib/pages/settings_views/sub_widgets/settings_list_button.dart b/lib/pages/settings_views/sub_widgets/settings_list_button.dart index 62b4a2aec..399d0b110 100644 --- a/lib/pages/settings_views/sub_widgets/settings_list_button.dart +++ b/lib/pages/settings_views/sub_widgets/settings_list_button.dart @@ -10,9 +10,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/text_styles.dart'; class SettingsListButton extends StatelessWidget { const SettingsListButton({ diff --git a/lib/pages/settings_views/wallet_settings_view/frost_ms/frost_ms_options_view.dart b/lib/pages/settings_views/wallet_settings_view/frost_ms/frost_ms_options_view.dart index 491f96c93..a9bea43be 100644 --- a/lib/pages/settings_views/wallet_settings_view/frost_ms/frost_ms_options_view.dart +++ b/lib/pages/settings_views/wallet_settings_view/frost_ms/frost_ms_options_view.dart @@ -10,27 +10,27 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/frost_route_generator.dart'; -import 'package:stackwallet/pages/settings_views/sub_widgets/settings_list_button.dart'; -import 'package:stackwallet/pages/settings_views/wallet_settings_view/frost_ms/frost_participants_view.dart'; -import 'package:stackwallet/pages/settings_views/wallet_settings_view/frost_ms/initiate_resharing/initiate_resharing_view.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/frost_wallet/frost_wallet_providers.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/models/frost_wallet_info.dart'; -import 'package:stackwallet/wallets/wallet/impl/bitcoin_frost_wallet.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/frost_scaffold.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../../frost_route_generator.dart'; +import '../../sub_widgets/settings_list_button.dart'; +import 'frost_participants_view.dart'; +import 'initiate_resharing/initiate_resharing_view.dart'; +import '../../../../pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart'; +import '../../../../providers/db/main_db_provider.dart'; +import '../../../../providers/frost_wallet/frost_wallet_providers.dart'; +import '../../../../providers/global/wallets_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/isar/models/frost_wallet_info.dart'; +import '../../../../wallets/wallet/impl/bitcoin_frost_wallet.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/conditional_parent.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/desktop/desktop_app_bar.dart'; +import '../../../../widgets/desktop/desktop_scaffold.dart'; +import '../../../../widgets/frost_scaffold.dart'; +import '../../../../widgets/rounded_white_container.dart'; class FrostMSWalletOptionsView extends ConsumerWidget { const FrostMSWalletOptionsView({ diff --git a/lib/pages/settings_views/wallet_settings_view/frost_ms/frost_participants_view.dart b/lib/pages/settings_views/wallet_settings_view/frost_ms/frost_participants_view.dart index 364859ef0..a0b502da2 100644 --- a/lib/pages/settings_views/wallet_settings_view/frost_ms/frost_participants_view.dart +++ b/lib/pages/settings_views/wallet_settings_view/frost_ms/frost_participants_view.dart @@ -1,20 +1,20 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/models/frost_wallet_info.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart'; +import '../../../../pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart'; +import '../../../../providers/db/main_db_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/isar/models/frost_wallet_info.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/conditional_parent.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/desktop/desktop_app_bar.dart'; +import '../../../../widgets/desktop/desktop_scaffold.dart'; +import '../../../../widgets/rounded_white_container.dart'; class FrostParticipantsView extends ConsumerWidget { const FrostParticipantsView({ diff --git a/lib/pages/settings_views/wallet_settings_view/frost_ms/initiate_resharing/complete_reshare_config_view.dart b/lib/pages/settings_views/wallet_settings_view/frost_ms/initiate_resharing/complete_reshare_config_view.dart index 5ac986a6c..b771ef7bd 100644 --- a/lib/pages/settings_views/wallet_settings_view/frost_ms/initiate_resharing/complete_reshare_config_view.dart +++ b/lib/pages/settings_views/wallet_settings_view/frost_ms/initiate_resharing/complete_reshare_config_view.dart @@ -4,28 +4,28 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:frostdart/frostdart.dart'; -import 'package:stackwallet/frost_route_generator.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/frost_wallet/frost_wallet_providers.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/services/frost.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/format.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/models/frost_wallet_info.dart'; -import 'package:stackwallet/wallets/wallet/impl/bitcoin_frost_wallet.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/frost_scaffold.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../../../../frost_route_generator.dart'; +import '../../../../../pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart'; +import '../../../../../providers/db/main_db_provider.dart'; +import '../../../../../providers/frost_wallet/frost_wallet_providers.dart'; +import '../../../../../providers/global/wallets_provider.dart'; +import '../../../../../services/frost.dart'; +import '../../../../../themes/stack_colors.dart'; +import '../../../../../utilities/format.dart'; +import '../../../../../utilities/logger.dart'; +import '../../../../../utilities/text_styles.dart'; +import '../../../../../utilities/util.dart'; +import '../../../../../wallets/isar/models/frost_wallet_info.dart'; +import '../../../../../wallets/wallet/impl/bitcoin_frost_wallet.dart'; +import '../../../../../widgets/background.dart'; +import '../../../../../widgets/conditional_parent.dart'; +import '../../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../../widgets/desktop/desktop_app_bar.dart'; +import '../../../../../widgets/desktop/desktop_scaffold.dart'; +import '../../../../../widgets/desktop/primary_button.dart'; +import '../../../../../widgets/frost_scaffold.dart'; +import '../../../../../widgets/rounded_white_container.dart'; +import '../../../../../widgets/stack_dialog.dart'; final class CompleteReshareConfigView extends ConsumerStatefulWidget { const CompleteReshareConfigView({ diff --git a/lib/pages/settings_views/wallet_settings_view/frost_ms/initiate_resharing/initiate_resharing_view.dart b/lib/pages/settings_views/wallet_settings_view/frost_ms/initiate_resharing/initiate_resharing_view.dart index ca5ab67e7..9fd3a5fc5 100644 --- a/lib/pages/settings_views/wallet_settings_view/frost_ms/initiate_resharing/initiate_resharing_view.dart +++ b/lib/pages/settings_views/wallet_settings_view/frost_ms/initiate_resharing/initiate_resharing_view.dart @@ -1,20 +1,20 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/pages/settings_views/wallet_settings_view/frost_ms/initiate_resharing/complete_reshare_config_view.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/frost_wallet/frost_wallet_providers.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/models/frost_wallet_info.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import 'complete_reshare_config_view.dart'; +import '../../../../../pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart'; +import '../../../../../providers/db/main_db_provider.dart'; +import '../../../../../providers/frost_wallet/frost_wallet_providers.dart'; +import '../../../../../themes/stack_colors.dart'; +import '../../../../../utilities/text_styles.dart'; +import '../../../../../utilities/util.dart'; +import '../../../../../wallets/isar/models/frost_wallet_info.dart'; +import '../../../../../widgets/background.dart'; +import '../../../../../widgets/conditional_parent.dart'; +import '../../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../../widgets/desktop/desktop_app_bar.dart'; +import '../../../../../widgets/desktop/desktop_scaffold.dart'; +import '../../../../../widgets/desktop/primary_button.dart'; +import '../../../../../widgets/rounded_white_container.dart'; final class InitiateResharingView extends ConsumerStatefulWidget { const InitiateResharingView({ diff --git a/lib/pages/settings_views/wallet_settings_view/wallet_backup_views/wallet_backup_view.dart b/lib/pages/settings_views/wallet_settings_view/wallet_backup_views/wallet_backup_view.dart index ab6baf455..102de03f1 100644 --- a/lib/pages/settings_views/wallet_settings_view/wallet_backup_views/wallet_backup_view.dart +++ b/lib/pages/settings_views/wallet_settings_view/wallet_backup_views/wallet_backup_view.dart @@ -15,23 +15,24 @@ import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:qr_flutter/qr_flutter.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_view/sub_widgets/mnemonic_table.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/address_utils.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/clipboard_interface.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/simple_copy_button.dart'; -import 'package:stackwallet/widgets/detail_item.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../../../app_config.dart'; +import '../../../../notifications/show_flush_bar.dart'; +import '../../../add_wallet_views/new_wallet_recovery_phrase_view/sub_widgets/mnemonic_table.dart'; +import '../../../wallet_view/transaction_views/transaction_details_view.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/address_utils.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/clipboard_interface.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/custom_buttons/simple_copy_button.dart'; +import '../../../../widgets/detail_item.dart'; +import '../../../../widgets/rounded_white_container.dart'; +import '../../../../widgets/stack_dialog.dart'; class WalletBackupView extends ConsumerWidget { const WalletBackupView({ @@ -126,7 +127,7 @@ class WalletBackupView extends ConsumerWidget { "Your backup data is the only way you can access your " "funds if you forget your PIN, lose your phone, etc." "\n\n" - "Stack Wallet does not keep nor is able to restore " + "${AppConfig.appName} does not keep nor is able to restore " "your backup data. " "Only you have access to your wallet.", style: STextStyles.label(context), diff --git a/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/sub_widgets/confirm_full_rescan.dart b/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/sub_widgets/confirm_full_rescan.dart index bb47771d6..f5281435b 100644 --- a/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/sub_widgets/confirm_full_rescan.dart +++ b/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/sub_widgets/confirm_full_rescan.dart @@ -9,14 +9,14 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../../../../themes/stack_colors.dart'; +import '../../../../../utilities/text_styles.dart'; +import '../../../../../utilities/util.dart'; +import '../../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../../../widgets/desktop/primary_button.dart'; +import '../../../../../widgets/desktop/secondary_button.dart'; +import '../../../../../widgets/stack_dialog.dart'; class ConfirmFullRescanDialog extends StatelessWidget { const ConfirmFullRescanDialog({Key? key, required this.onConfirm}) diff --git a/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/sub_widgets/rescanning_dialog.dart b/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/sub_widgets/rescanning_dialog.dart index 2c1e3ea53..f243b977f 100644 --- a/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/sub_widgets/rescanning_dialog.dart +++ b/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/sub_widgets/rescanning_dialog.dart @@ -9,11 +9,11 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/animated_widgets/rotating_arrows.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../../../../utilities/util.dart'; +import '../../../../../widgets/animated_widgets/rotating_arrows.dart'; +import '../../../../../widgets/conditional_parent.dart'; +import '../../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../../widgets/stack_dialog.dart'; class RescanningDialog extends StatefulWidget { const RescanningDialog({ diff --git a/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart b/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart index 6fbf8df93..ff80ff3c4 100644 --- a/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart +++ b/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart @@ -15,54 +15,56 @@ import 'package:event_bus/event_bus.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/tor_settings/tor_settings_view.dart'; -import 'package:stackwallet/pages/settings_views/sub_widgets/nodes_list.dart'; -import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_network_settings_view/sub_widgets/confirm_full_rescan.dart'; -import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_network_settings_view/sub_widgets/rescanning_dialog.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/route_generator.dart'; -import 'package:stackwallet/services/event_bus/events/global/blocks_remaining_event.dart'; -import 'package:stackwallet/services/event_bus/events/global/node_connection_status_changed_event.dart'; -import 'package:stackwallet/services/event_bus/events/global/refresh_percent_changed_event.dart'; -import 'package:stackwallet/services/event_bus/events/global/tor_connection_status_changed_event.dart'; -import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart'; -import 'package:stackwallet/services/event_bus/global_event_bus.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/wallets/wallet/impl/epiccash_wallet.dart'; -import 'package:stackwallet/wallets/wallet/impl/monero_wallet.dart'; -import 'package:stackwallet/wallets/wallet/impl/wownero_wallet.dart'; -import 'package:stackwallet/widgets/animated_text.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/expandable.dart'; -import 'package:stackwallet/widgets/progress_bar.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; -import 'package:stackwallet/widgets/tor_subscription.dart'; +import '../../global_settings_view/manage_nodes_views/add_edit_node_view.dart'; +import '../../global_settings_view/tor_settings/tor_settings_view.dart'; +import '../../sub_widgets/nodes_list.dart'; +import 'sub_widgets/confirm_full_rescan.dart'; +import 'sub_widgets/rescanning_dialog.dart'; +import '../../../../providers/providers.dart'; +import '../../../../route_generator.dart'; +import '../../../../services/event_bus/events/global/blocks_remaining_event.dart'; +import '../../../../services/event_bus/events/global/node_connection_status_changed_event.dart'; +import '../../../../services/event_bus/events/global/refresh_percent_changed_event.dart'; +import '../../../../services/event_bus/events/global/tor_connection_status_changed_event.dart'; +import '../../../../services/event_bus/events/global/wallet_sync_status_changed_event.dart'; +import '../../../../services/event_bus/global_event_bus.dart'; +import '../../../../services/tor_service.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/crypto_currency/coins/epiccash.dart'; +import '../../../../wallets/crypto_currency/coins/monero.dart'; +import '../../../../wallets/crypto_currency/coins/wownero.dart'; +import '../../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../../wallets/wallet/impl/epiccash_wallet.dart'; +import '../../../../wallets/wallet/impl/monero_wallet.dart'; +import '../../../../wallets/wallet/impl/wownero_wallet.dart'; +import '../../../../widgets/animated_text.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/conditional_parent.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/custom_buttons/blue_text_button.dart'; +import '../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../widgets/expandable.dart'; +import '../../../../widgets/progress_bar.dart'; +import '../../../../widgets/rounded_container.dart'; +import '../../../../widgets/rounded_white_container.dart'; +import '../../../../widgets/stack_dialog.dart'; +import '../../../../widgets/tor_subscription.dart'; import 'package:tuple/tuple.dart'; import 'package:wakelock/wakelock.dart'; /// [eventBus] should only be set during testing class WalletNetworkSettingsView extends ConsumerStatefulWidget { const WalletNetworkSettingsView({ - Key? key, + super.key, required this.walletId, required this.initialSyncStatus, required this.initialNodeStatus, this.eventBus, - }) : super(key: key); + }); final String walletId; final WalletSyncStatus initialSyncStatus; @@ -260,7 +262,7 @@ class _WalletNetworkSettingsViewState final coin = ref.read(pWalletCoin(widget.walletId)); - if (coin == Coin.monero || coin == Coin.wownero || coin == Coin.epicCash) { + if (coin is Monero || coin is Wownero || coin is Epiccash) { _blocksRemainingSubscription = eventBus.on().listen( (event) async { if (event.walletId == widget.walletId) { @@ -319,22 +321,22 @@ class _WalletNetworkSettingsViewState final coin = ref.watch(pWalletCoin(widget.walletId)); - if (coin == Coin.monero) { - double highestPercent = + if (coin is Monero) { + final double highestPercent = (ref.read(pWallets).getWallet(widget.walletId) as MoneroWallet) .highestPercentCached; if (_percent < highestPercent) { _percent = highestPercent.clamp(0.0, 1.0); } - } else if (coin == Coin.wownero) { - double highestPercent = + } else if (coin is Wownero) { + final double highestPercent = (ref.watch(pWallets).getWallet(widget.walletId) as WowneroWallet) .highestPercentCached; if (_percent < highestPercent) { _percent = highestPercent.clamp(0.0, 1.0); } - } else if (coin == Coin.epicCash) { - double highestPercent = + } else if (coin is Epiccash) { + final double highestPercent = (ref.watch(pWallets).getWallet(widget.walletId) as EpiccashWallet) .highestPercent; if (_percent < highestPercent) { @@ -360,7 +362,7 @@ class _WalletNetworkSettingsViewState style: STextStyles.navBarTitle(context), ), actions: [ - if (ref.watch(pWalletCoin(widget.walletId)) != Coin.epicCash) + if (ref.watch(pWalletCoin(widget.walletId)) is! Epiccash) Padding( padding: const EdgeInsets.only( top: 10, @@ -371,7 +373,8 @@ class _WalletNetworkSettingsViewState aspectRatio: 1, child: AppBarIconButton( key: const Key( - "walletNetworkSettingsAddNewNodeViewButton"), + "walletNetworkSettingsAddNewNodeViewButton", + ), size: 36, shadows: const [], color: Theme.of(context) @@ -402,8 +405,8 @@ class _WalletNetworkSettingsViewState .extension()! .popupBG, borderRadius: BorderRadius.circular( - Constants - .size.circularBorderRadius), + Constants.size.circularBorderRadius, + ), // boxShadow: [CFColors.standardBoxShadow], boxShadow: const [], ), @@ -431,7 +434,8 @@ class _WalletNetworkSettingsViewState child: Text( "Rescan blockchain", style: STextStyles.baseXS( - context), + context, + ), ), ), ), @@ -620,9 +624,9 @@ class _WalletNetworkSettingsViewState .accentColorYellow, ), ), - if (coin == Coin.monero || - coin == Coin.wownero || - coin == Coin.epicCash) + if (coin is Monero || + coin is Wownero || + coin is Epiccash) Text( " (Blocks to go: ${_blocksRemaining == -1 ? "?" : _blocksRemaining})", style: STextStyles.syncPercent(context) @@ -633,7 +637,7 @@ class _WalletNetworkSettingsViewState ), ), ], - ) + ), ], ), ), @@ -768,8 +772,9 @@ class _WalletNetworkSettingsViewState : STextStyles.smallMed12(context), ), CustomTextButton( - text: ref.watch(prefsChangeNotifierProvider - .select((value) => value.useTor)) + text: ref.watch( + prefsChangeNotifierProvider.select((value) => value.useTor), + ) ? "Disconnect" : "Connect", onTap: onTorTapped, @@ -787,8 +792,9 @@ class _WalletNetworkSettingsViewState isDesktop ? const EdgeInsets.all(16) : const EdgeInsets.all(12), child: Row( children: [ - if (ref.watch(prefsChangeNotifierProvider - .select((value) => value.useTor))) + if (ref.watch( + prefsChangeNotifierProvider.select((value) => value.useTor), + )) Container( width: _iconSize, height: _iconSize, @@ -810,8 +816,9 @@ class _WalletNetworkSettingsViewState ), ), ), - if (!ref.watch(prefsChangeNotifierProvider - .select((value) => value.useTor))) + if (!ref.watch( + prefsChangeNotifierProvider.select((value) => value.useTor), + )) Container( width: _iconSize, height: _iconSize, @@ -916,13 +923,11 @@ class _WalletNetworkSettingsViewState coin: ref.watch(pWalletCoin(widget.walletId)), popBackToRoute: WalletNetworkSettingsView.routeName, ), - if (isDesktop && - ref.watch(pWalletCoin(widget.walletId)) != Coin.epicCash) + if (isDesktop && ref.watch(pWalletCoin(widget.walletId)) is! Epiccash) const SizedBox( height: 32, ), - if (isDesktop && - ref.watch(pWalletCoin(widget.walletId)) != Coin.epicCash) + if (isDesktop && ref.watch(pWalletCoin(widget.walletId)) is! Epiccash) Padding( padding: const EdgeInsets.only( bottom: 12, @@ -938,8 +943,7 @@ class _WalletNetworkSettingsViewState ], ), ), - if (isDesktop && - ref.watch(pWalletCoin(widget.walletId)) != Coin.epicCash) + if (isDesktop && ref.watch(pWalletCoin(widget.walletId)) is! Epiccash) RoundedWhiteContainer( borderColor: isDesktop ? Theme.of(context).extension()!.background @@ -987,8 +991,8 @@ class _WalletNetworkSettingsViewState Text( "Advanced", style: STextStyles.desktopTextExtraExtraSmall( - context) - .copyWith( + context, + ).copyWith( color: Theme.of(context) .extension()! .textDark, @@ -997,10 +1001,11 @@ class _WalletNetworkSettingsViewState Text( "Rescan blockchain", style: STextStyles.desktopTextExtraExtraSmall( - context), + context, + ), ), ], - ) + ), ], ), SvgPicture.asset( diff --git a/lib/pages/settings_views/wallet_settings_view/wallet_settings_view.dart b/lib/pages/settings_views/wallet_settings_view/wallet_settings_view.dart index 66dfb8c23..a0cb79f9d 100644 --- a/lib/pages/settings_views/wallet_settings_view/wallet_settings_view.dart +++ b/lib/pages/settings_views/wallet_settings_view/wallet_settings_view.dart @@ -13,41 +13,44 @@ import 'dart:async'; import 'package:event_bus/event_bus.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/db/hive/db.dart'; -import 'package:stackwallet/models/epicbox_config_model.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/address_book_views/address_book_view.dart'; -import 'package:stackwallet/pages/home_view/home_view.dart'; -import 'package:stackwallet/pages/pinpad_views/lock_screen_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/advanced_views/debug_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/syncing_preferences_views/syncing_preferences_view.dart'; -import 'package:stackwallet/pages/settings_views/sub_widgets/settings_list_button.dart'; -import 'package:stackwallet/pages/settings_views/wallet_settings_view/frost_ms/frost_ms_options_view.dart'; -import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_backup_views/wallet_backup_view.dart'; -import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart'; -import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/change_representative_view.dart'; -import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/wallet_settings_wallet_settings_view.dart'; -import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/xpub_view.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/providers/ui/transaction_filter_provider.dart'; -import 'package:stackwallet/route_generator.dart'; -import 'package:stackwallet/services/event_bus/events/global/node_connection_status_changed_event.dart'; -import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart'; -import 'package:stackwallet/services/event_bus/global_event_bus.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/show_loading.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/wallet/impl/bitcoin_frost_wallet.dart'; -import 'package:stackwallet/wallets/wallet/impl/epiccash_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/mnemonic_interface.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../../db/hive/db.dart'; +import '../../../models/epicbox_config_model.dart'; +import '../../../notifications/show_flush_bar.dart'; +import '../../address_book_views/address_book_view.dart'; +import '../../home_view/home_view.dart'; +import '../../pinpad_views/lock_screen_view.dart'; +import '../global_settings_view/advanced_views/debug_view.dart'; +import '../global_settings_view/syncing_preferences_views/syncing_preferences_view.dart'; +import '../sub_widgets/settings_list_button.dart'; +import 'frost_ms/frost_ms_options_view.dart'; +import 'wallet_backup_views/wallet_backup_view.dart'; +import 'wallet_network_settings_view/wallet_network_settings_view.dart'; +import 'wallet_settings_wallet_settings/change_representative_view.dart'; +import 'wallet_settings_wallet_settings/wallet_settings_wallet_settings_view.dart'; +import 'wallet_settings_wallet_settings/xpub_view.dart'; +import '../../../providers/global/wallets_provider.dart'; +import '../../../providers/ui/transaction_filter_provider.dart'; +import '../../../route_generator.dart'; +import '../../../services/event_bus/events/global/node_connection_status_changed_event.dart'; +import '../../../services/event_bus/events/global/wallet_sync_status_changed_event.dart'; +import '../../../services/event_bus/global_event_bus.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/show_loading.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../wallets/crypto_currency/coins/firo.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../wallets/crypto_currency/intermediate/frost_currency.dart'; +import '../../../wallets/crypto_currency/intermediate/nano_currency.dart'; +import '../../../wallets/wallet/impl/bitcoin_frost_wallet.dart'; +import '../../../wallets/wallet/impl/epiccash_wallet.dart'; +import '../../../wallets/wallet/wallet_mixin_interfaces/mnemonic_interface.dart'; +import '../../../widgets/background.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/desktop/secondary_button.dart'; +import '../../../widgets/rounded_white_container.dart'; +import '../../../widgets/stack_dialog.dart'; import 'package:tuple/tuple.dart'; /// [eventBus] should only be set during testing @@ -64,7 +67,7 @@ class WalletSettingsView extends ConsumerStatefulWidget { static const String routeName = "/walletSettings"; final String walletId; - final Coin coin; + final CryptoCurrency coin; final WalletSyncStatus initialSyncStatus; final NodeConnectionStatus initialNodeStatus; final EventBus? eventBus; @@ -75,7 +78,7 @@ class WalletSettingsView extends ConsumerStatefulWidget { class _WalletSettingsViewState extends ConsumerState { late final String walletId; - late final Coin coin; + late final CryptoCurrency coin; late String xpub; late final bool xPubEnabled; @@ -206,11 +209,11 @@ class _WalletSettingsViewState extends ConsumerState { ); }, ), - if (coin.isFrost) + if (coin is FrostCurrency) const SizedBox( height: 8, ), - if (coin.isFrost) + if (coin is FrostCurrency) SettingsListButton( iconAssetName: Assets.svg.addressBook2, iconSize: 16, @@ -376,11 +379,11 @@ class _WalletSettingsViewState extends ConsumerState { ); }, ), - if (coin == Coin.firo) + if (coin is Firo) const SizedBox( height: 8, ), - if (coin == Coin.firo) + if (coin is Firo) Consumer( builder: (_, ref, __) { return SettingsListButton( @@ -419,7 +422,7 @@ class _WalletSettingsViewState extends ConsumerState { ), DB.instance .clearSharedTransactionCache( - coin: coin, + currency: coin, ), ], ), @@ -431,11 +434,11 @@ class _WalletSettingsViewState extends ConsumerState { ); }, ), - if (coin == Coin.nano || coin == Coin.banano) + if (coin is NanoCurrency) const SizedBox( height: 8, ), - if (coin == Coin.nano || coin == Coin.banano) + if (coin is NanoCurrency) Consumer( builder: (_, ref, __) { return SettingsListButton( diff --git a/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/change_representative_view.dart b/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/change_representative_view.dart index 03b131993..23a8c6cd8 100644 --- a/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/change_representative_view.dart +++ b/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/change_representative_view.dart @@ -14,27 +14,27 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/clipboard_interface.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/show_loading.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/nano_interface.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/loading_indicator.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../../../notifications/show_flush_bar.dart'; +import '../../../../providers/global/wallets_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/clipboard_interface.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/show_loading.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/wallet/wallet_mixin_interfaces/nano_interface.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/conditional_parent.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/icon_widgets/x_icon.dart'; +import '../../../../widgets/loading_indicator.dart'; +import '../../../../widgets/rounded_white_container.dart'; +import '../../../../widgets/stack_text_field.dart'; +import '../../../../widgets/textfield_icon_button.dart'; class ChangeRepresentativeView extends ConsumerStatefulWidget { const ChangeRepresentativeView({ diff --git a/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/delete_wallet_recovery_phrase_view.dart b/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/delete_wallet_recovery_phrase_view.dart index 8c7d94fe9..f418ed230 100644 --- a/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/delete_wallet_recovery_phrase_view.dart +++ b/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/delete_wallet_recovery_phrase_view.dart @@ -14,26 +14,27 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_view/sub_widgets/mnemonic_table.dart'; -import 'package:stackwallet/pages/home_view/home_view.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart'; -import 'package:stackwallet/providers/global/secure_store_provider.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/clipboard_interface.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/simple_copy_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/detail_item.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../../../app_config.dart'; +import '../../../../notifications/show_flush_bar.dart'; +import '../../../add_wallet_views/new_wallet_recovery_phrase_view/sub_widgets/mnemonic_table.dart'; +import '../../../home_view/home_view.dart'; +import '../../../wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart'; +import '../../../../providers/global/secure_store_provider.dart'; +import '../../../../providers/global/wallets_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/clipboard_interface.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/custom_buttons/simple_copy_button.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/detail_item.dart'; +import '../../../../widgets/rounded_white_container.dart'; +import '../../../../widgets/stack_dialog.dart'; class DeleteWalletRecoveryPhraseView extends ConsumerStatefulWidget { const DeleteWalletRecoveryPhraseView({ @@ -202,7 +203,7 @@ class _DeleteWalletRecoveryPhraseViewState "Your backup data is the only way you can access your " "funds if you forget your PIN, lose your phone, etc." "\n\n" - "Stack Wallet does not keep nor is able to restore " + "${AppConfig.appName} does not keep nor is able to restore " "your backup data. " "Only you have access to your wallet.", style: STextStyles.label(context), diff --git a/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/delete_wallet_warning_view.dart b/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/delete_wallet_warning_view.dart index 84c4f817b..d03cfe534 100644 --- a/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/delete_wallet_warning_view.dart +++ b/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/delete_wallet_warning_view.dart @@ -10,15 +10,15 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/delete_wallet_recovery_phrase_view.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/wallet/impl/bitcoin_frost_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/mnemonic_interface.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; +import 'delete_wallet_recovery_phrase_view.dart'; +import '../../../../providers/providers.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../wallets/wallet/impl/bitcoin_frost_wallet.dart'; +import '../../../../wallets/wallet/wallet_mixin_interfaces/mnemonic_interface.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/rounded_container.dart'; class DeleteWalletWarningView extends ConsumerWidget { const DeleteWalletWarningView({ diff --git a/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/rename_wallet_view.dart b/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/rename_wallet_view.dart index b4b457c39..a0fb54eed 100644 --- a/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/rename_wallet_view.dart +++ b/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/rename_wallet_view.dart @@ -12,18 +12,18 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../../../notifications/show_flush_bar.dart'; +import '../../../../providers/db/main_db_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/icon_widgets/x_icon.dart'; +import '../../../../widgets/stack_text_field.dart'; +import '../../../../widgets/textfield_icon_button.dart'; class RenameWalletView extends ConsumerStatefulWidget { const RenameWalletView({ diff --git a/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/wallet_settings_wallet_settings_view.dart b/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/wallet_settings_wallet_settings_view.dart index e426c576b..90e79b216 100644 --- a/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/wallet_settings_wallet_settings_view.dart +++ b/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/wallet_settings_wallet_settings_view.dart @@ -10,18 +10,18 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/pages/pinpad_views/lock_screen_view.dart'; -import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/delete_wallet_warning_view.dart'; -import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/rename_wallet_view.dart'; -import 'package:stackwallet/route_generator.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../../pinpad_views/lock_screen_view.dart'; +import 'delete_wallet_warning_view.dart'; +import 'rename_wallet_view.dart'; +import '../../../../route_generator.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/rounded_white_container.dart'; +import '../../../../widgets/stack_dialog.dart'; class WalletSettingsWalletSettingsView extends ConsumerWidget { const WalletSettingsWalletSettingsView({ diff --git a/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/xpub_view.dart b/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/xpub_view.dart index 230e0798e..c07e6b162 100644 --- a/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/xpub_view.dart +++ b/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/xpub_view.dart @@ -15,23 +15,23 @@ import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:qr_flutter/qr_flutter.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/clipboard_interface.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/wallet/wallet.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/loading_indicator.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../../notifications/show_flush_bar.dart'; +import '../../../../providers/global/wallets_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/clipboard_interface.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/wallet/wallet.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/conditional_parent.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/desktop/secondary_button.dart'; +import '../../../../widgets/loading_indicator.dart'; +import '../../../../widgets/rounded_white_container.dart'; class XPubView extends ConsumerStatefulWidget { const XPubView({ diff --git a/lib/pages/special/firo_rescan_recovery_error_dialog.dart b/lib/pages/special/firo_rescan_recovery_error_dialog.dart index 6f23c7a87..fa6b3ff1d 100644 --- a/lib/pages/special/firo_rescan_recovery_error_dialog.dart +++ b/lib/pages/special/firo_rescan_recovery_error_dialog.dart @@ -1,28 +1,28 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/pages/pinpad_views/lock_screen_view.dart'; -import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_backup_views/wallet_backup_view.dart'; -import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/delete_wallet_warning_view.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_delete_wallet_dialog.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/unlock_wallet_keys_desktop.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/route_generator.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/mnemonic_interface.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../pinpad_views/lock_screen_view.dart'; +import '../settings_views/wallet_settings_view/wallet_backup_views/wallet_backup_view.dart'; +import '../settings_views/wallet_settings_view/wallet_settings_wallet_settings/delete_wallet_warning_view.dart'; +import '../../pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_delete_wallet_dialog.dart'; +import '../../pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/unlock_wallet_keys_desktop.dart'; +import '../../providers/global/wallets_provider.dart'; +import '../../route_generator.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import '../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../wallets/wallet/wallet_mixin_interfaces/mnemonic_interface.dart'; +import '../../widgets/background.dart'; +import '../../widgets/conditional_parent.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/custom_buttons/blue_text_button.dart'; +import '../../widgets/desktop/desktop_app_bar.dart'; +import '../../widgets/desktop/desktop_scaffold.dart'; +import '../../widgets/desktop/primary_button.dart'; +import '../../widgets/desktop/secondary_button.dart'; +import '../../widgets/stack_dialog.dart'; enum FiroRescanRecoveryErrorViewOption { retry, diff --git a/lib/pages/stack_privacy_calls.dart b/lib/pages/stack_privacy_calls.dart index e2c604494..ad95b3903 100644 --- a/lib/pages/stack_privacy_calls.dart +++ b/lib/pages/stack_privacy_calls.dart @@ -14,24 +14,24 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/db/hive/db.dart'; -import 'package:stackwallet/pages/pinpad_views/create_pin_view.dart'; -import 'package:stackwallet/pages_desktop_specific/password/create_password_view.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/providers/global/price_provider.dart'; -import 'package:stackwallet/services/exchange/exchange_data_loading_service.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../db/hive/db.dart'; +import 'pinpad_views/create_pin_view.dart'; +import '../pages_desktop_specific/password/create_password_view.dart'; +import '../providers/global/prefs_provider.dart'; +import '../providers/global/price_provider.dart'; +import '../services/exchange/exchange_data_loading_service.dart'; +import '../themes/stack_colors.dart'; +import '../themes/theme_providers.dart'; +import '../utilities/assets.dart'; +import '../utilities/constants.dart'; +import '../utilities/text_styles.dart'; +import '../utilities/util.dart'; +import '../widgets/conditional_parent.dart'; +import '../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../widgets/desktop/desktop_app_bar.dart'; +import '../widgets/desktop/desktop_scaffold.dart'; +import '../widgets/desktop/primary_button.dart'; +import '../widgets/rounded_white_container.dart'; class StackPrivacyCalls extends ConsumerStatefulWidget { const StackPrivacyCalls({ diff --git a/lib/pages/token_view/my_tokens_view.dart b/lib/pages/token_view/my_tokens_view.dart index 35168b9f7..a8b39c9d2 100644 --- a/lib/pages/token_view/my_tokens_view.dart +++ b/lib/pages/token_view/my_tokens_view.dart @@ -13,20 +13,20 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/pages/add_wallet_views/add_token_view/edit_wallet_tokens_view.dart'; -import 'package:stackwallet/pages/token_view/sub_widgets/my_tokens_list.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../add_wallet_views/add_token_view/edit_wallet_tokens_view.dart'; +import 'sub_widgets/my_tokens_list.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import '../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../widgets/background.dart'; +import '../../widgets/conditional_parent.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/icon_widgets/x_icon.dart'; +import '../../widgets/stack_text_field.dart'; +import '../../widgets/textfield_icon_button.dart'; class MyTokensView extends ConsumerStatefulWidget { const MyTokensView({ diff --git a/lib/pages/token_view/sub_widgets/my_token_select_item.dart b/lib/pages/token_view/sub_widgets/my_token_select_item.dart index 2fd42300d..8d8ef8711 100644 --- a/lib/pages/token_view/sub_widgets/my_token_select_item.dart +++ b/lib/pages/token_view/sub_widgets/my_token_select_item.dart @@ -12,29 +12,30 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart'; -import 'package:stackwallet/pages/token_view/token_view.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/desktop_token_view.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/services/ethereum/cached_eth_token_balance.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/show_loading.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/eth/current_token_wallet_provider.dart'; -import 'package:stackwallet/wallets/isar/providers/eth/token_balance_provider.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/wallets/wallet/impl/ethereum_wallet.dart'; -import 'package:stackwallet/wallets/wallet/impl/sub_wallets/eth_token_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/dialogs/basic_dialog.dart'; -import 'package:stackwallet/widgets/icon_widgets/eth_token_icon.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../models/isar/models/ethereum/eth_contract.dart'; +import '../token_view.dart'; +import '../../../pages_desktop_specific/my_stack_view/wallet_view/desktop_token_view.dart'; +import '../../../providers/db/main_db_provider.dart'; +import '../../../providers/providers.dart'; +import '../../../services/ethereum/cached_eth_token_balance.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/amount/amount_formatter.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/show_loading.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../wallets/crypto_currency/coins/ethereum.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../wallets/isar/providers/eth/current_token_wallet_provider.dart'; +import '../../../wallets/isar/providers/eth/token_balance_provider.dart'; +import '../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../wallets/wallet/impl/ethereum_wallet.dart'; +import '../../../wallets/wallet/impl/sub_wallets/eth_token_wallet.dart'; +import '../../../wallets/wallet/wallet.dart'; +import '../../../widgets/desktop/primary_button.dart'; +import '../../../widgets/dialogs/basic_dialog.dart'; +import '../../../widgets/icon_widgets/eth_token_icon.dart'; +import '../../../widgets/rounded_white_container.dart'; class MyTokenSelectItem extends ConsumerStatefulWidget { const MyTokenSelectItem({ @@ -178,7 +179,10 @@ class _MyTokenSelectItemState extends ConsumerState { ), const Spacer(), Text( - ref.watch(pAmountFormatter(Coin.ethereum)).format( + ref + .watch(pAmountFormatter( + Ethereum(CryptoCurrencyNetwork.main))) + .format( ref .watch(pTokenBalance( ( diff --git a/lib/pages/token_view/sub_widgets/my_tokens_list.dart b/lib/pages/token_view/sub_widgets/my_tokens_list.dart index 89655b717..d6c26529d 100644 --- a/lib/pages/token_view/sub_widgets/my_tokens_list.dart +++ b/lib/pages/token_view/sub_widgets/my_tokens_list.dart @@ -11,10 +11,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/db/isar/main_db.dart'; -import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart'; -import 'package:stackwallet/pages/token_view/sub_widgets/my_token_select_item.dart'; -import 'package:stackwallet/utilities/util.dart'; +import '../../../db/isar/main_db.dart'; +import '../../../models/isar/models/ethereum/eth_contract.dart'; +import 'my_token_select_item.dart'; +import '../../../utilities/util.dart'; class MyTokensList extends StatelessWidget { const MyTokensList({ diff --git a/lib/pages/token_view/sub_widgets/no_tokens_found.dart b/lib/pages/token_view/sub_widgets/no_tokens_found.dart index 378235b59..5b7853c39 100644 --- a/lib/pages/token_view/sub_widgets/no_tokens_found.dart +++ b/lib/pages/token_view/sub_widgets/no_tokens_found.dart @@ -9,8 +9,8 @@ */ import 'package:flutter/cupertino.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../widgets/rounded_white_container.dart'; class NoTokensFound extends StatelessWidget { const NoTokensFound({Key? key}) : super(key: key); diff --git a/lib/pages/token_view/sub_widgets/token_summary.dart b/lib/pages/token_view/sub_widgets/token_summary.dart index a852d0954..30f72920d 100644 --- a/lib/pages/token_view/sub_widgets/token_summary.dart +++ b/lib/pages/token_view/sub_widgets/token_summary.dart @@ -14,37 +14,38 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart'; -import 'package:stackwallet/pages/buy_view/buy_in_wallet_view.dart'; -import 'package:stackwallet/pages/exchange_view/wallet_initiated_exchange_view.dart'; -import 'package:stackwallet/pages/receive_view/receive_view.dart'; -import 'package:stackwallet/pages/send_view/token_send_view.dart'; -import 'package:stackwallet/pages/wallet_view/sub_widgets/wallet_refresh_button.dart'; -import 'package:stackwallet/providers/global/locale_provider.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/providers/global/price_provider.dart'; -import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/eth/current_token_wallet_provider.dart'; -import 'package:stackwallet/wallets/isar/providers/eth/token_balance_provider.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; +import '../../../models/isar/models/ethereum/eth_contract.dart'; +import '../../buy_view/buy_in_wallet_view.dart'; +import '../../exchange_view/wallet_initiated_exchange_view.dart'; +import '../../receive_view/receive_view.dart'; +import '../../send_view/token_send_view.dart'; +import '../../wallet_view/sub_widgets/wallet_refresh_button.dart'; +import '../../../providers/global/locale_provider.dart'; +import '../../../providers/global/prefs_provider.dart'; +import '../../../providers/global/price_provider.dart'; +import '../../../services/event_bus/events/global/wallet_sync_status_changed_event.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../themes/theme_providers.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/amount/amount_formatter.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../wallets/crypto_currency/coins/ethereum.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../wallets/isar/providers/eth/current_token_wallet_provider.dart'; +import '../../../wallets/isar/providers/eth/token_balance_provider.dart'; +import '../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../widgets/conditional_parent.dart'; +import '../../../widgets/rounded_container.dart'; import 'package:tuple/tuple.dart'; class TokenSummary extends ConsumerWidget { const TokenSummary({ - Key? key, + super.key, required this.walletId, required this.initialSyncStatus, - }) : super(key: key); + }); final String walletId; final WalletSyncStatus initialSyncStatus; @@ -54,7 +55,8 @@ class TokenSummary extends ConsumerWidget { final token = ref.watch(pCurrentTokenWallet.select((value) => value!.tokenContract)); final balance = ref.watch( - pTokenBalance((walletId: walletId, contractAddress: token.address))); + pTokenBalance((walletId: walletId, contractAddress: token.address)), + ); return Stack( children: [ @@ -96,7 +98,13 @@ class TokenSummary extends ConsumerWidget { mainAxisAlignment: MainAxisAlignment.center, children: [ Text( - ref.watch(pAmountFormatter(Coin.ethereum)).format( + ref + .watch( + pAmountFormatter( + Ethereum(CryptoCurrencyNetwork.main), + ), + ) + .format( balance.total, ethContract: token, ), @@ -173,13 +181,14 @@ class TokenSummary extends ConsumerWidget { class TokenWalletOptions extends ConsumerWidget { const TokenWalletOptions({ - Key? key, + super.key, required this.walletId, required this.tokenContract, - }) : super(key: key); + }); final String walletId; final EthContract tokenContract; + CryptoCurrency get ethereum => Ethereum(CryptoCurrencyNetwork.main); void _onExchangePressed(BuildContext context) async { unawaited( @@ -187,7 +196,7 @@ class TokenWalletOptions extends ConsumerWidget { WalletInitiatedExchangeView.routeName, arguments: Tuple3( walletId, - Coin.ethereum, + ethereum, tokenContract, ), ), @@ -199,7 +208,7 @@ class TokenWalletOptions extends ConsumerWidget { Navigator.of(context).pushNamed( BuyInWalletView.routeName, arguments: Tuple2( - Coin.ethereum, + ethereum, tokenContract, ), ), @@ -233,7 +242,7 @@ class TokenWalletOptions extends ConsumerWidget { TokenSendView.routeName, arguments: Tuple3( walletId, - Coin.ethereum, + ethereum, tokenContract, ), ); @@ -268,11 +277,11 @@ class TokenWalletOptions extends ConsumerWidget { class TokenOptionsButton extends StatelessWidget { const TokenOptionsButton({ - Key? key, + super.key, required this.onPressed, required this.subLabel, required this.iconAssetPathSVG, - }) : super(key: key); + }); final VoidCallback onPressed; final String subLabel; @@ -344,7 +353,7 @@ class TokenOptionsButton extends StatelessWidget { .extension()! .tokenSummaryTextPrimary, ), - ) + ), ], ); } diff --git a/lib/pages/token_view/sub_widgets/token_transaction_list_widget.dart b/lib/pages/token_view/sub_widgets/token_transaction_list_widget.dart index c77eae03c..45f0921f8 100644 --- a/lib/pages/token_view/sub_widgets/token_transaction_list_widget.dart +++ b/lib/pages/token_view/sub_widgets/token_transaction_list_widget.dart @@ -13,16 +13,16 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart'; -import 'package:stackwallet/pages/wallet_view/sub_widgets/no_transactions_found.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/transaction_v2_list_item.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/eth/current_token_wallet_provider.dart'; -import 'package:stackwallet/widgets/loading_indicator.dart'; +import '../../../models/isar/models/blockchain_data/v2/transaction_v2.dart'; +import '../../wallet_view/sub_widgets/no_transactions_found.dart'; +import '../../wallet_view/transaction_views/tx_v2/transaction_v2_list_item.dart'; +import '../../../providers/db/main_db_provider.dart'; +import '../../../providers/global/wallets_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/util.dart'; +import '../../../wallets/isar/providers/eth/current_token_wallet_provider.dart'; +import '../../../widgets/loading_indicator.dart'; class TokenTransactionsList extends ConsumerStatefulWidget { const TokenTransactionsList({ diff --git a/lib/pages/token_view/token_contract_details_view.dart b/lib/pages/token_view/token_contract_details_view.dart index e3c860a43..4553ca537 100644 --- a/lib/pages/token_view/token_contract_details_view.dart +++ b/lib/pages/token_view/token_contract_details_view.dart @@ -11,16 +11,16 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/db/isar/main_db.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/simple_copy_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../db/isar/main_db.dart'; +import '../../models/isar/models/isar_models.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import '../../widgets/background.dart'; +import '../../widgets/conditional_parent.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/custom_buttons/simple_copy_button.dart'; +import '../../widgets/rounded_white_container.dart'; class TokenContractDetailsView extends ConsumerStatefulWidget { const TokenContractDetailsView({ diff --git a/lib/pages/token_view/token_view.dart b/lib/pages/token_view/token_view.dart index 71e8d57b1..c8cbd0e87 100644 --- a/lib/pages/token_view/token_view.dart +++ b/lib/pages/token_view/token_view.dart @@ -12,20 +12,20 @@ import 'package:event_bus/event_bus.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/pages/token_view/sub_widgets/token_summary.dart'; -import 'package:stackwallet/pages/token_view/sub_widgets/token_transaction_list_widget.dart'; -import 'package:stackwallet/pages/token_view/token_contract_details_view.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/all_transactions_v2_view.dart'; -import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/eth/current_token_wallet_provider.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/eth_token_icon.dart'; +import 'sub_widgets/token_summary.dart'; +import 'sub_widgets/token_transaction_list_widget.dart'; +import 'token_contract_details_view.dart'; +import '../wallet_view/transaction_views/tx_v2/all_transactions_v2_view.dart'; +import '../../services/event_bus/events/global/wallet_sync_status_changed_event.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/text_styles.dart'; +import '../../wallets/isar/providers/eth/current_token_wallet_provider.dart'; +import '../../widgets/background.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/custom_buttons/blue_text_button.dart'; +import '../../widgets/icon_widgets/eth_token_icon.dart'; import 'package:tuple/tuple.dart'; /// [eventBus] should only be set during testing diff --git a/lib/pages/wallet_view/sub_widgets/no_transactions_found.dart b/lib/pages/wallet_view/sub_widgets/no_transactions_found.dart index fdf923921..fff5ebf16 100644 --- a/lib/pages/wallet_view/sub_widgets/no_transactions_found.dart +++ b/lib/pages/wallet_view/sub_widgets/no_transactions_found.dart @@ -9,8 +9,8 @@ */ import 'package:flutter/cupertino.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../widgets/rounded_white_container.dart'; class NoTransActionsFound extends StatelessWidget { const NoTransActionsFound({Key? key}) : super(key: key); diff --git a/lib/pages/wallet_view/sub_widgets/transactions_list.dart b/lib/pages/wallet_view/sub_widgets/transactions_list.dart index d3886378e..db97ebcea 100644 --- a/lib/pages/wallet_view/sub_widgets/transactions_list.dart +++ b/lib/pages/wallet_view/sub_widgets/transactions_list.dart @@ -13,32 +13,32 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/pages/exchange_view/trade_details_view.dart'; -import 'package:stackwallet/pages/wallet_view/sub_widgets/no_transactions_found.dart'; -import 'package:stackwallet/pages/wallet_view/wallet_view.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/global/trades_service_provider.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/route_generator.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/loading_indicator.dart'; -import 'package:stackwallet/widgets/trade_card.dart'; -import 'package:stackwallet/widgets/transaction_card.dart'; +import '../../../models/isar/models/isar_models.dart'; +import '../../exchange_view/trade_details_view.dart'; +import 'no_transactions_found.dart'; +import '../wallet_view.dart'; +import '../../../providers/db/main_db_provider.dart'; +import '../../../providers/global/trades_service_provider.dart'; +import '../../../providers/global/wallets_provider.dart'; +import '../../../route_generator.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../widgets/desktop/desktop_dialog.dart'; +import '../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../widgets/loading_indicator.dart'; +import '../../../widgets/trade_card.dart'; +import '../../../widgets/transaction_card.dart'; import 'package:tuple/tuple.dart'; class TransactionsList extends ConsumerStatefulWidget { const TransactionsList({ - Key? key, + super.key, required this.walletId, - }) : super(key: key); + }); final String walletId; @@ -80,7 +80,7 @@ class _TransactionsListState extends ConsumerState { BuildContext context, Transaction tx, BorderRadius? radius, - Coin coin, + CryptoCurrency coin, int chainHeight, ) { final matchingTrades = ref diff --git a/lib/pages/wallet_view/sub_widgets/tx_icon.dart b/lib/pages/wallet_view/sub_widgets/tx_icon.dart index 11920f7c2..94f9b033a 100644 --- a/lib/pages/wallet_view/sub_widgets/tx_icon.dart +++ b/lib/pages/wallet_view/sub_widgets/tx_icon.dart @@ -13,25 +13,25 @@ import 'dart:io'; import 'package:flutter/cupertino.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/models/isar/stack_theme.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import '../../../models/isar/models/blockchain_data/v2/transaction_v2.dart'; +import '../../../models/isar/models/isar_models.dart'; +import '../../../models/isar/stack_theme.dart'; +import '../../../providers/global/wallets_provider.dart'; +import '../../../themes/theme_providers.dart'; +import '../../../utilities/assets.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; class TxIcon extends ConsumerWidget { const TxIcon({ - Key? key, + super.key, required this.transaction, required this.currentHeight, required this.coin, - }) : super(key: key); + }); final Object transaction; final int currentHeight; - final Coin coin; + final CryptoCurrency coin; static const Size size = Size(32, 32); diff --git a/lib/pages/wallet_view/sub_widgets/wallet_balance_toggle_sheet.dart b/lib/pages/wallet_view/sub_widgets/wallet_balance_toggle_sheet.dart index af0eca1c6..d94e183ec 100644 --- a/lib/pages/wallet_view/sub_widgets/wallet_balance_toggle_sheet.dart +++ b/lib/pages/wallet_view/sub_widgets/wallet_balance_toggle_sheet.dart @@ -10,17 +10,18 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/balance.dart'; -import 'package:stackwallet/providers/wallet/public_private_balance_state_provider.dart'; -import 'package:stackwallet/providers/wallet/wallet_balance_toggle_state_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/wallet_balance_toggle_state.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; +import '../../../models/balance.dart'; +import '../../../providers/wallet/public_private_balance_state_provider.dart'; +import '../../../providers/wallet/wallet_balance_toggle_state_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/amount/amount_formatter.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/enums/wallet_balance_toggle_state.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../wallets/crypto_currency/coins/firo.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../wallets/isar/providers/wallet_info_provider.dart'; enum _BalanceType { available, @@ -44,7 +45,7 @@ class WalletBalanceToggleSheet extends ConsumerWidget { final maxHeight = MediaQuery.of(context).size.height * 0.90; final coin = ref.watch(pWalletCoin(walletId)); - final isFiro = coin == Coin.firo || coin == Coin.firoTestNet; + final isFiro = coin is Firo; final balance = ref.watch(pWalletBalance(walletId)); @@ -305,7 +306,7 @@ class BalanceSelector extends ConsumerWidget { }); final String title; - final Coin coin; + final CryptoCurrency coin; final Amount balance; final VoidCallback onPressed; final void Function(T?) onChanged; diff --git a/lib/pages/wallet_view/sub_widgets/wallet_refresh_button.dart b/lib/pages/wallet_view/sub_widgets/wallet_refresh_button.dart index a98985f2a..b9f8c4ca1 100644 --- a/lib/pages/wallet_view/sub_widgets/wallet_refresh_button.dart +++ b/lib/pages/wallet_view/sub_widgets/wallet_refresh_button.dart @@ -13,14 +13,14 @@ import 'dart:async'; import 'package:event_bus/event_bus.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart'; -import 'package:stackwallet/services/event_bus/global_event_bus.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/eth/current_token_wallet_provider.dart'; -import 'package:stackwallet/widgets/animated_widgets/rotating_arrows.dart'; +import '../../../providers/global/wallets_provider.dart'; +import '../../../services/event_bus/events/global/wallet_sync_status_changed_event.dart'; +import '../../../services/event_bus/global_event_bus.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/util.dart'; +import '../../../wallets/isar/providers/eth/current_token_wallet_provider.dart'; +import '../../../widgets/animated_widgets/rotating_arrows.dart'; /// [eventBus] should only be set during testing class WalletRefreshButton extends ConsumerStatefulWidget { diff --git a/lib/pages/wallet_view/sub_widgets/wallet_summary.dart b/lib/pages/wallet_view/sub_widgets/wallet_summary.dart index a33bf7622..2a4dc4b61 100644 --- a/lib/pages/wallet_view/sub_widgets/wallet_summary.dart +++ b/lib/pages/wallet_view/sub_widgets/wallet_summary.dart @@ -9,9 +9,9 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/pages/wallet_view/sub_widgets/wallet_summary_info.dart'; -import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart'; -import 'package:stackwallet/widgets/coin_card.dart'; +import 'wallet_summary_info.dart'; +import '../../../services/event_bus/events/global/wallet_sync_status_changed_event.dart'; +import '../../../widgets/coin_card.dart'; class WalletSummary extends StatelessWidget { const WalletSummary({ diff --git a/lib/pages/wallet_view/sub_widgets/wallet_summary_info.dart b/lib/pages/wallet_view/sub_widgets/wallet_summary_info.dart index fa01d1ac6..7b44e17eb 100644 --- a/lib/pages/wallet_view/sub_widgets/wallet_summary_info.dart +++ b/lib/pages/wallet_view/sub_widgets/wallet_summary_info.dart @@ -15,30 +15,31 @@ import 'package:flutter/material.dart'; import 'package:flutter_native_splash/cli_commands.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/pages/wallet_view/sub_widgets/wallet_balance_toggle_sheet.dart'; -import 'package:stackwallet/pages/wallet_view/sub_widgets/wallet_refresh_button.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/providers/wallet/public_private_balance_state_provider.dart'; -import 'package:stackwallet/providers/wallet/wallet_balance_toggle_state_provider.dart'; -import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart'; -import 'package:stackwallet/themes/coin_icon_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/wallet_balance_toggle_state.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/wallets/wallet/impl/banano_wallet.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; +import 'wallet_balance_toggle_sheet.dart'; +import 'wallet_refresh_button.dart'; +import '../../../providers/providers.dart'; +import '../../../providers/wallet/public_private_balance_state_provider.dart'; +import '../../../providers/wallet/wallet_balance_toggle_state_provider.dart'; +import '../../../services/event_bus/events/global/wallet_sync_status_changed_event.dart'; +import '../../../themes/coin_icon_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/amount/amount_formatter.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/enums/wallet_balance_toggle_state.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../wallets/crypto_currency/coins/banano.dart'; +import '../../../wallets/crypto_currency/coins/firo.dart'; +import '../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../wallets/wallet/impl/banano_wallet.dart'; +import '../../../widgets/conditional_parent.dart'; class WalletSummaryInfo extends ConsumerWidget { const WalletSummaryInfo({ - Key? key, + super.key, required this.walletId, required this.initialSyncStatus, - }) : super(key: key); + }); final String walletId; final WalletSyncStatus initialSyncStatus; @@ -86,7 +87,7 @@ class WalletSummaryInfo extends ConsumerWidget { final Amount balanceToShow; final String title; - if (coin == Coin.firo || coin == Coin.firoTestNet) { + if (coin is Firo) { final type = ref.watch(publicPrivateBalanceStateProvider.state).state; title = "${_showAvailable ? "Available" : "Full"} ${type.name.capitalize()} balance"; @@ -113,7 +114,7 @@ class WalletSummaryInfo extends ConsumerWidget { List? imageBytes; - if (coin == Coin.banano) { + if (coin is Banano) { imageBytes = (ref.watch(pWallets).getWallet(walletId) as BananoWallet) .getMonkeyImageBytes(); } diff --git a/lib/pages/wallet_view/transaction_views/all_transactions_view.dart b/lib/pages/wallet_view/transaction_views/all_transactions_view.dart index a1f177457..e946cf6d5 100644 --- a/lib/pages/wallet_view/transaction_views/all_transactions_view.dart +++ b/lib/pages/wallet_view/transaction_views/all_transactions_view.dart @@ -14,40 +14,41 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; -import 'package:stackwallet/models/isar/models/contact_entry.dart'; -import 'package:stackwallet/models/isar/models/transaction_note.dart'; -import 'package:stackwallet/models/transaction_filter.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/wallet_view/sub_widgets/tx_icon.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_search_filter_view.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/global/address_book_service_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/providers/ui/transaction_filter_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/format.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/loading_indicator.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; -import 'package:stackwallet/widgets/transaction_card.dart'; +import '../../../models/isar/models/blockchain_data/transaction.dart'; +import '../../../models/isar/models/contact_entry.dart'; +import '../../../models/isar/models/transaction_note.dart'; +import '../../../models/transaction_filter.dart'; +import '../../../notifications/show_flush_bar.dart'; +import '../sub_widgets/tx_icon.dart'; +import 'transaction_details_view.dart'; +import 'transaction_search_filter_view.dart'; +import '../../../providers/db/main_db_provider.dart'; +import '../../../providers/global/address_book_service_provider.dart'; +import '../../../providers/providers.dart'; +import '../../../providers/ui/transaction_filter_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/amount/amount_formatter.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/format.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../wallets/crypto_currency/coins/epiccash.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../widgets/conditional_parent.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/desktop/desktop_app_bar.dart'; +import '../../../widgets/desktop/desktop_dialog.dart'; +import '../../../widgets/desktop/desktop_scaffold.dart'; +import '../../../widgets/desktop/secondary_button.dart'; +import '../../../widgets/icon_widgets/x_icon.dart'; +import '../../../widgets/loading_indicator.dart'; +import '../../../widgets/rounded_white_container.dart'; +import '../../../widgets/stack_text_field.dart'; +import '../../../widgets/textfield_icon_button.dart'; +import '../../../widgets/transaction_card.dart'; import 'package:tuple/tuple.dart'; typedef _GroupedTransactions = ({ @@ -58,9 +59,9 @@ typedef _GroupedTransactions = ({ class AllTransactionsView extends ConsumerStatefulWidget { const AllTransactionsView({ - Key? key, + super.key, required this.walletId, - }) : super(key: key); + }); static const String routeName = "/allTransactions"; @@ -830,10 +831,10 @@ class TransactionFilterOptionBarItem extends StatelessWidget { class DesktopTransactionCardRow extends ConsumerStatefulWidget { const DesktopTransactionCardRow({ - Key? key, + super.key, required this.transaction, required this.walletId, - }) : super(key: key); + }); final Transaction transaction; final String walletId; @@ -849,8 +850,8 @@ class _DesktopTransactionCardRowState late final String walletId; late final int minConfirms; - String whatIsIt(TransactionType type, Coin coin, int height) { - if (coin == Coin.epicCash && _transaction.slateId == null) { + String whatIsIt(TransactionType type, CryptoCurrency coin, int height) { + if (coin is Epiccash && _transaction.slateId == null) { return "Restored Funds"; } @@ -934,7 +935,7 @@ class _DesktopTransactionCardRowState ), ), onPressed: () async { - if (coin == Coin.epicCash && _transaction.slateId == null) { + if (coin is Epiccash && _transaction.slateId == null) { unawaited( showFloatingFlushBar( context: context, diff --git a/lib/pages/wallet_view/transaction_views/dialogs/cancelling_transaction_progress_dialog.dart b/lib/pages/wallet_view/transaction_views/dialogs/cancelling_transaction_progress_dialog.dart index 7a94dc28f..0039dc5bb 100644 --- a/lib/pages/wallet_view/transaction_views/dialogs/cancelling_transaction_progress_dialog.dart +++ b/lib/pages/wallet_view/transaction_views/dialogs/cancelling_transaction_progress_dialog.dart @@ -9,8 +9,8 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/widgets/animated_widgets/rotating_arrows.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../../../widgets/animated_widgets/rotating_arrows.dart'; +import '../../../../widgets/stack_dialog.dart'; class CancellingTransactionProgressDialog extends StatefulWidget { const CancellingTransactionProgressDialog({Key? key}) : super(key: key); diff --git a/lib/pages/wallet_view/transaction_views/edit_note_view.dart b/lib/pages/wallet_view/transaction_views/edit_note_view.dart index 4a77955d1..ccae6c3fc 100644 --- a/lib/pages/wallet_view/transaction_views/edit_note_view.dart +++ b/lib/pages/wallet_view/transaction_views/edit_note_view.dart @@ -10,21 +10,21 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/isar/models/transaction_note.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../../models/isar/models/transaction_note.dart'; +import '../../../providers/db/main_db_provider.dart'; +import '../../../providers/providers.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../widgets/background.dart'; +import '../../../widgets/conditional_parent.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../widgets/desktop/primary_button.dart'; +import '../../../widgets/icon_widgets/x_icon.dart'; +import '../../../widgets/stack_text_field.dart'; +import '../../../widgets/textfield_icon_button.dart'; class EditNoteView extends ConsumerStatefulWidget { const EditNoteView({ diff --git a/lib/pages/wallet_view/transaction_views/transaction_details_view.dart b/lib/pages/wallet_view/transaction_views/transaction_details_view.dart index 82a29b087..38fffe56e 100644 --- a/lib/pages/wallet_view/transaction_views/transaction_details_view.dart +++ b/lib/pages/wallet_view/transaction_views/transaction_details_view.dart @@ -15,58 +15,66 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; -import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/receive_view/addresses/address_details_view.dart'; -import 'package:stackwallet/pages/wallet_view/sub_widgets/tx_icon.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/dialogs/cancelling_transaction_progress_dialog.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/edit_note_view.dart'; -import 'package:stackwallet/pages/wallet_view/wallet_view.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/global/address_book_service_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/block_explorers.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/format.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/wallets/wallet/impl/epiccash_wallet.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/copy_icon.dart'; -import 'package:stackwallet/widgets/icon_widgets/pencil_icon.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../../models/isar/models/blockchain_data/transaction.dart'; +import '../../../models/isar/models/ethereum/eth_contract.dart'; +import '../../../notifications/show_flush_bar.dart'; +import '../../receive_view/addresses/address_details_view.dart'; +import '../sub_widgets/tx_icon.dart'; +import 'dialogs/cancelling_transaction_progress_dialog.dart'; +import 'edit_note_view.dart'; +import '../wallet_view.dart'; +import '../../../providers/db/main_db_provider.dart'; +import '../../../providers/global/address_book_service_provider.dart'; +import '../../../providers/providers.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/amount/amount_formatter.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/block_explorers.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/format.dart'; +import '../../../utilities/logger.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../wallets/crypto_currency/coins/bitcoincash.dart'; +import '../../../wallets/crypto_currency/coins/ecash.dart'; +import '../../../wallets/crypto_currency/coins/epiccash.dart'; +import '../../../wallets/crypto_currency/coins/ethereum.dart'; +import '../../../wallets/crypto_currency/coins/firo.dart'; +import '../../../wallets/crypto_currency/coins/monero.dart'; +import '../../../wallets/crypto_currency/coins/wownero.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../wallets/crypto_currency/intermediate/nano_currency.dart'; +import '../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../wallets/wallet/impl/epiccash_wallet.dart'; +import '../../../widgets/background.dart'; +import '../../../widgets/conditional_parent.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/custom_buttons/blue_text_button.dart'; +import '../../../widgets/desktop/desktop_dialog.dart'; +import '../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../widgets/desktop/primary_button.dart'; +import '../../../widgets/desktop/secondary_button.dart'; +import '../../../widgets/icon_widgets/copy_icon.dart'; +import '../../../widgets/icon_widgets/pencil_icon.dart'; +import '../../../widgets/rounded_white_container.dart'; +import '../../../widgets/stack_dialog.dart'; import 'package:tuple/tuple.dart'; import 'package:url_launcher/url_launcher.dart'; class TransactionDetailsView extends ConsumerStatefulWidget { const TransactionDetailsView({ - Key? key, + super.key, required this.transaction, required this.walletId, required this.coin, - }) : super(key: key); + }); static const String routeName = "/transactionDetails"; final Transaction transaction; final String walletId; - final Coin coin; + final CryptoCurrency coin; @override ConsumerState createState() => @@ -79,7 +87,7 @@ class _TransactionDetailsViewState late Transaction _transaction; late final String walletId; - late final Coin coin; + late final CryptoCurrency coin; late final Amount amount; late final Amount fee; late final String amountPrefix; @@ -104,10 +112,9 @@ class _TransactionDetailsViewState .minConfirms; coin = widget.coin; amount = _transaction.realAmount; - fee = _transaction.fee.toAmountAsRaw(fractionDigits: coin.decimals); + fee = _transaction.fee.toAmountAsRaw(fractionDigits: coin.fractionDigits); - if ((coin == Coin.firo || coin == Coin.firoTestNet) && - _transaction.subType == TransactionSubType.mint) { + if ((coin is Firo) && _transaction.subType == TransactionSubType.mint) { amountPrefix = ""; } else { amountPrefix = _transaction.type == TransactionType.outgoing ? "-" : "+"; @@ -119,7 +126,7 @@ class _TransactionDetailsViewState unit = isTokenTx ? ethContract!.symbol : coin.ticker; - // if (coin == Coin.firo || coin == Coin.firoTestNet) { + // if (coin is Firo) { // showFeePending = true; // } else { // showFeePending = false; @@ -134,7 +141,7 @@ class _TransactionDetailsViewState String whatIsIt(Transaction tx, int height) { final type = tx.type; - if (coin == Coin.firo || coin == Coin.firoTestNet) { + if (coin is Firo) { if (tx.subType == TransactionSubType.mint) { if (tx.isConfirmed(height, minConfirms)) { return "Minted"; @@ -144,7 +151,7 @@ class _TransactionDetailsViewState } } - if (coin == Coin.epicCash) { + if (coin is Epiccash) { if (_transaction.isCancelled) { return "Cancelled"; } else if (type == TransactionType.incoming) { @@ -202,9 +209,10 @@ class _TransactionDetailsViewState } try { final contacts = ref.read(addressBookServiceProvider).contacts.where( - (element) => element.addresses - .where((element) => element.address == address) - .isNotEmpty); + (element) => element.addresses + .where((element) => element.address == address) + .isNotEmpty, + ); if (contacts.isNotEmpty) { return contacts.first.name; } else { @@ -218,20 +226,23 @@ class _TransactionDetailsViewState Future showExplorerWarning(String explorer) async { final bool? shouldContinue = await showDialog( - context: context, - barrierDismissible: false, - builder: (_) { - if (!isDesktop) { - return StackDialog( - title: "Attention", - message: - "You are about to view this transaction in a block explorer. The explorer may log your IP address and link it to the transaction. Only proceed if you trust $explorer.", - icon: Row( - children: [ - Consumer(builder: (_, ref, __) { + context: context, + barrierDismissible: false, + builder: (_) { + if (!isDesktop) { + return StackDialog( + title: "Attention", + message: + "You are about to view this transaction in a block explorer. The explorer may log your IP address and link it to the transaction. Only proceed if you trust $explorer.", + icon: Row( + children: [ + Consumer( + builder: (_, ref, __) { return Checkbox( - value: ref.watch(prefsChangeNotifierProvider - .select((value) => value.hideBlockExplorerWarning)), + value: ref.watch( + prefsChangeNotifierProvider + .select((value) => value.hideBlockExplorerWarning), + ), onChanged: (value) { if (value is bool) { ref @@ -241,61 +252,65 @@ class _TransactionDetailsViewState } }, ); - }), - Text( - "Never show again", - style: STextStyles.smallMed14(context), - ) - ], - ), - leftButton: TextButton( - onPressed: () { - Navigator.of(context).pop(false); - }, - child: Text( - "Cancel", - style: STextStyles.button(context).copyWith( - color: Theme.of(context) - .extension()! - .accentColorDark), + }, + ), + Text( + "Never show again", + style: STextStyles.smallMed14(context), + ), + ], + ), + leftButton: TextButton( + onPressed: () { + Navigator.of(context).pop(false); + }, + child: Text( + "Cancel", + style: STextStyles.button(context).copyWith( + color: Theme.of(context) + .extension()! + .accentColorDark, ), ), - rightButton: TextButton( - style: Theme.of(context) - .extension()! - .getPrimaryEnabledButtonStyle(context), - onPressed: () { - Navigator.of(context).pop(true); - }, - child: Text( - "Continue", - style: STextStyles.button(context), - ), + ), + rightButton: TextButton( + style: Theme.of(context) + .extension()! + .getPrimaryEnabledButtonStyle(context), + onPressed: () { + Navigator.of(context).pop(true); + }, + child: Text( + "Continue", + style: STextStyles.button(context), ), - ); - } else { - return DesktopDialog( - maxWidth: 550, - maxHeight: 300, - child: Padding( - padding: - const EdgeInsets.symmetric(horizontal: 32, vertical: 20), - child: Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - "Attention", - style: STextStyles.desktopH2(context), - ), - Row( - children: [ - Consumer(builder: (_, ref, __) { + ), + ); + } else { + return DesktopDialog( + maxWidth: 550, + maxHeight: 300, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 20), + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Attention", + style: STextStyles.desktopH2(context), + ), + Row( + children: [ + Consumer( + builder: (_, ref, __) { return Checkbox( - value: ref.watch(prefsChangeNotifierProvider - .select((value) => - value.hideBlockExplorerWarning)), + value: ref.watch( + prefsChangeNotifierProvider.select( + (value) => value.hideBlockExplorerWarning, + ), + ), onChanged: (value) { if (value is bool) { ref @@ -305,55 +320,57 @@ class _TransactionDetailsViewState } }, ); - }), - Text( - "Never show again", - style: STextStyles.smallMed14(context), - ) - ], - ), - ], - ), - const SizedBox(height: 16), - Text( - "You are about to view this transaction in a block explorer. The explorer may log your IP address and link it to the transaction. Only proceed if you trust $explorer.", - style: STextStyles.desktopTextSmall(context), - ), - const SizedBox(height: 35), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SecondaryButton( - width: 200, - buttonHeight: ButtonHeight.l, - label: "Cancel", - onPressed: () { - Navigator.of( - context, - rootNavigator: true, - ).pop(false); - }, - ), - const SizedBox(width: 20), - PrimaryButton( - width: 200, - buttonHeight: ButtonHeight.l, - label: "Continue", - onPressed: () { - Navigator.of( - context, - rootNavigator: true, - ).pop(true); - }, - ), - ], - ), - ], - ), + }, + ), + Text( + "Never show again", + style: STextStyles.smallMed14(context), + ), + ], + ), + ], + ), + const SizedBox(height: 16), + Text( + "You are about to view this transaction in a block explorer. The explorer may log your IP address and link it to the transaction. Only proceed if you trust $explorer.", + style: STextStyles.desktopTextSmall(context), + ), + const SizedBox(height: 35), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SecondaryButton( + width: 200, + buttonHeight: ButtonHeight.l, + label: "Cancel", + onPressed: () { + Navigator.of( + context, + rootNavigator: true, + ).pop(false); + }, + ), + const SizedBox(width: 20), + PrimaryButton( + width: 200, + buttonHeight: ButtonHeight.l, + label: "Continue", + onPressed: () { + Navigator.of( + context, + rootNavigator: true, + ).pop(true); + }, + ), + ], + ), + ], ), - ); - } - }); + ), + ); + } + }, + ); return shouldContinue ?? false; } @@ -474,7 +491,7 @@ class _TransactionDetailsViewState ), SelectableText( _transaction.isCancelled - ? coin == Coin.ethereum + ? coin is Ethereum ? "Failed" : "Cancelled" : whatIsIt( @@ -483,7 +500,8 @@ class _TransactionDetailsViewState ), style: STextStyles.desktopTextMedium( - context), + context, + ), ), ], ), @@ -496,37 +514,43 @@ class _TransactionDetailsViewState "$amountPrefix${ref.watch(pAmountFormatter(coin)).format(amount, ethContract: ethContract)}", style: isDesktop ? STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( + .desktopTextExtraExtraSmall( + context, + ).copyWith( color: Theme.of(context) .extension< StackColors>()! .textDark, ) : STextStyles.titleBold12( - context), + context, + ), ), const SizedBox( height: 2, ), if (ref.watch( - prefsChangeNotifierProvider - .select((value) => - value.externalCalls))) + prefsChangeNotifierProvider.select( + (value) => value.externalCalls, + ), + )) SelectableText( "$amountPrefix${(amount.decimal * ref.watch( - priceAnd24hChangeNotifierProvider.select( - (value) => isTokenTx - ? value - .getTokenPrice( - _transaction - .otherData!) - .item1 - : value - .getPrice( - coin) - .item1), + priceAnd24hChangeNotifierProvider + .select( + (value) => isTokenTx + ? value + .getTokenPrice( + _transaction + .otherData!, + ) + .item1 + : value + .getPrice( + coin, + ) + .item1, + ), )).toAmount(fractionDigits: 2).fiatString( locale: ref.watch( localeServiceChangeNotifierProvider @@ -543,9 +567,11 @@ class _TransactionDetailsViewState style: isDesktop ? STextStyles .desktopTextExtraExtraSmall( - context) + context, + ) : STextStyles.itemSubtitle( - context), + context, + ), ), ], ), @@ -587,7 +613,7 @@ class _TransactionDetailsViewState // child: SelectableText( _transaction.isCancelled - ? coin == Coin.ethereum + ? coin is Ethereum ? "Failed" : "Cancelled" : whatIsIt( @@ -596,9 +622,9 @@ class _TransactionDetailsViewState ), style: isDesktop ? STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( + .desktopTextExtraExtraSmall( + context, + ).copyWith( color: _transaction.type == TransactionType.outgoing ? Theme.of(context) @@ -615,12 +641,10 @@ class _TransactionDetailsViewState ], ), ), - if (!((coin == Coin.monero || - coin == Coin.wownero) && + if (!((coin is Monero || coin is Wownero) && _transaction.type == TransactionType.outgoing) && - !((coin == Coin.firo || - coin == Coin.firoTestNet) && + !((coin is Firo) && _transaction.subType == TransactionSubType.mint)) isDesktop @@ -628,12 +652,10 @@ class _TransactionDetailsViewState : const SizedBox( height: 12, ), - if (!((coin == Coin.monero || - coin == Coin.wownero) && + if (!((coin is Monero || coin is Wownero) && _transaction.type == TransactionType.outgoing) && - !((coin == Coin.firo || - coin == Coin.firoTestNet) && + !((coin is Firo) && _transaction.subType == TransactionSubType.mint)) RoundedWhiteContainer( @@ -694,7 +716,7 @@ class _TransactionDetailsViewState ); } }, - ) + ), ], ); }, @@ -706,9 +728,11 @@ class _TransactionDetailsViewState style: isDesktop ? STextStyles .desktopTextExtraExtraSmall( - context) + context, + ) : STextStyles.itemSubtitle( - context), + context, + ), ), ), const SizedBox( @@ -718,11 +742,14 @@ class _TransactionDetailsViewState TransactionType.incoming ? FutureBuilder( future: fetchContactNameFor( - _transaction.address - .value!.value), - builder: (builderContext, - AsyncSnapshot - snapshot) { + _transaction + .address.value!.value, + ), + builder: ( + builderContext, + AsyncSnapshot + snapshot, + ) { String addressOrContactName = _transaction.address @@ -738,18 +765,20 @@ class _TransactionDetailsViewState addressOrContactName, style: isDesktop ? STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( + .desktopTextExtraExtraSmall( + context, + ).copyWith( color: Theme.of( - context) + context, + ) .extension< StackColors>()! .textDark, ) : STextStyles .itemSubtitle12( - context), + context, + ), ); }, ) @@ -758,18 +787,20 @@ class _TransactionDetailsViewState .address.value!.value, style: isDesktop ? STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( + .desktopTextExtraExtraSmall( + context, + ).copyWith( color: Theme.of( - context) + context, + ) .extension< StackColors>()! .textDark, ) : STextStyles .itemSubtitle12( - context), + context, + ), ), ], ), @@ -781,13 +812,13 @@ class _TransactionDetailsViewState ], ), ), - if (coin == Coin.epicCash) + if (coin is Epiccash) isDesktop ? const _Divider() : const SizedBox( height: 12, ), - if (coin == Coin.epicCash) + if (coin is Epiccash) RoundedWhiteContainer( padding: isDesktop ? const EdgeInsets.all(16) @@ -807,9 +838,11 @@ class _TransactionDetailsViewState style: isDesktop ? STextStyles .desktopTextExtraExtraSmall( - context) + context, + ) : STextStyles.itemSubtitle( - context), + context, + ), ), const SizedBox( height: 8, @@ -818,16 +851,17 @@ class _TransactionDetailsViewState _transaction.otherData ?? "", style: isDesktop ? STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( + .desktopTextExtraExtraSmall( + context, + ).copyWith( color: Theme.of(context) .extension< StackColors>()! .textDark, ) : STextStyles.itemSubtitle12( - context), + context, + ), ), ], ), @@ -856,13 +890,14 @@ class _TransactionDetailsViewState MainAxisAlignment.spaceBetween, children: [ Text( - (coin == Coin.epicCash) + (coin is Epiccash) ? "Local Note" : "Note ", style: isDesktop ? STextStyles .desktopTextExtraExtraSmall( - context) + context, + ) : STextStyles.itemSubtitle(context), ), isDesktop @@ -910,7 +945,8 @@ class _TransactionDetailsViewState Text( "Edit", style: STextStyles.link2( - context), + context, + ), ), ], ), @@ -934,9 +970,9 @@ class _TransactionDetailsViewState "", style: isDesktop ? STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( + .desktopTextExtraExtraSmall( + context, + ).copyWith( color: Theme.of(context) .extension()! .textDark, @@ -969,7 +1005,8 @@ class _TransactionDetailsViewState style: isDesktop ? STextStyles .desktopTextExtraExtraSmall( - context) + context, + ) : STextStyles.itemSubtitle(context), ), if (isDesktop) @@ -983,15 +1020,16 @@ class _TransactionDetailsViewState ), style: isDesktop ? STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( + .desktopTextExtraExtraSmall( + context, + ).copyWith( color: Theme.of(context) .extension()! .textDark, ) : STextStyles.itemSubtitle12( - context), + context, + ), ), ], ), @@ -1002,9 +1040,9 @@ class _TransactionDetailsViewState ), style: isDesktop ? STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( + .desktopTextExtraExtraSmall( + context, + ).copyWith( color: Theme.of(context) .extension()! .textDark, @@ -1020,36 +1058,138 @@ class _TransactionDetailsViewState ], ), ), - if (coin != Coin.banano && coin != Coin.nano) + if (coin is! NanoCurrency) isDesktop ? const _Divider() : const SizedBox( height: 12, ), - if (coin != Coin.banano && coin != Coin.nano) + if (coin is! NanoCurrency) RoundedWhiteContainer( padding: isDesktop ? const EdgeInsets.all(16) : const EdgeInsets.all(12), - child: Builder(builder: (context) { - String feeString = showFeePending - ? _transaction.isConfirmed( - currentHeight, - minConfirms, - ) - ? ref - .watch(pAmountFormatter(coin)) - .format( - fee, - withUnitName: isTokenTx, - ) - : "Pending" - : ref - .watch(pAmountFormatter(coin)) - .format( - fee, - withUnitName: isTokenTx, - ); + child: Builder( + builder: (context) { + String feeString = showFeePending + ? _transaction.isConfirmed( + currentHeight, + minConfirms, + ) + ? ref + .watch(pAmountFormatter(coin)) + .format( + fee, + withUnitName: isTokenTx, + ) + : "Pending" + : ref + .watch(pAmountFormatter(coin)) + .format( + fee, + withUnitName: isTokenTx, + ); + + return Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + "Transaction fee", + style: isDesktop + ? STextStyles + .desktopTextExtraExtraSmall( + context, + ) + : STextStyles.itemSubtitle( + context, + ), + ), + if (isDesktop) + const SizedBox( + height: 2, + ), + if (isDesktop) + SelectableText( + feeString, + style: isDesktop + ? STextStyles + .desktopTextExtraExtraSmall( + context, + ).copyWith( + color: Theme.of(context) + .extension< + StackColors>()! + .textDark, + ) + : STextStyles + .itemSubtitle12( + context, + ), + ), + ], + ), + if (!isDesktop) + SelectableText( + feeString, + style: isDesktop + ? STextStyles + .desktopTextExtraExtraSmall( + context, + ).copyWith( + color: Theme.of(context) + .extension< + StackColors>()! + .textDark, + ) + : STextStyles.itemSubtitle12( + context, + ), + ), + if (isDesktop) + IconCopyButton(data: feeString), + ], + ); + }, + ), + ), + isDesktop + ? const _Divider() + : const SizedBox( + height: 12, + ), + RoundedWhiteContainer( + padding: isDesktop + ? const EdgeInsets.all(16) + : const EdgeInsets.all(12), + child: Builder( + builder: (context) { + final String height; + + if (widget.coin is Bitcoincash || + widget.coin is Ecash) { + height = + "${_transaction.height != null && _transaction.height! > 0 ? _transaction.height! : "Pending"}"; + } else { + height = widget.coin is! Epiccash && + _transaction.isConfirmed( + currentHeight, + minConfirms, + ) + ? "${_transaction.height == 0 ? "Unknown" : _transaction.height}" + : _transaction.getConfirmations( + currentHeight, + ) > + 0 + ? "${_transaction.height}" + : "Pending"; + } return Row( mainAxisAlignment: @@ -1062,13 +1202,15 @@ class _TransactionDetailsViewState CrossAxisAlignment.start, children: [ Text( - "Transaction fee", + "Block height", style: isDesktop ? STextStyles .desktopTextExtraExtraSmall( - context) + context, + ) : STextStyles.itemSubtitle( - context), + context, + ), ), if (isDesktop) const SizedBox( @@ -1076,141 +1218,53 @@ class _TransactionDetailsViewState ), if (isDesktop) SelectableText( - feeString, + height, style: isDesktop ? STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( + .desktopTextExtraExtraSmall( + context, + ).copyWith( color: Theme.of(context) .extension< StackColors>()! .textDark, ) : STextStyles.itemSubtitle12( - context), + context, + ), ), ], ), if (!isDesktop) SelectableText( - feeString, + height, style: isDesktop ? STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( + .desktopTextExtraExtraSmall( + context, + ).copyWith( color: Theme.of(context) .extension()! .textDark, ) : STextStyles.itemSubtitle12( - context), + context, + ), ), if (isDesktop) - IconCopyButton(data: feeString) + IconCopyButton(data: height), ], ); - }), + }, ), - isDesktop - ? const _Divider() - : const SizedBox( - height: 12, - ), - RoundedWhiteContainer( - padding: isDesktop - ? const EdgeInsets.all(16) - : const EdgeInsets.all(12), - child: Builder(builder: (context) { - final String height; - - if (widget.coin == Coin.bitcoincash || - widget.coin == Coin.eCash || - widget.coin == Coin.bitcoincashTestnet) { - height = - "${_transaction.height != null && _transaction.height! > 0 ? _transaction.height! : "Pending"}"; - } else { - height = widget.coin != Coin.epicCash && - _transaction.isConfirmed( - currentHeight, - minConfirms, - ) - ? "${_transaction.height == 0 ? "Unknown" : _transaction.height}" - : _transaction.getConfirmations( - currentHeight) > - 0 - ? "${_transaction.height}" - : "Pending"; - } - - return Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - "Block height", - style: isDesktop - ? STextStyles - .desktopTextExtraExtraSmall( - context) - : STextStyles.itemSubtitle( - context), - ), - if (isDesktop) - const SizedBox( - height: 2, - ), - if (isDesktop) - SelectableText( - height, - style: isDesktop - ? STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( - color: Theme.of(context) - .extension< - StackColors>()! - .textDark, - ) - : STextStyles.itemSubtitle12( - context), - ), - ], - ), - if (!isDesktop) - SelectableText( - height, - style: isDesktop - ? STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( - color: Theme.of(context) - .extension()! - .textDark, - ) - : STextStyles.itemSubtitle12( - context), - ), - if (isDesktop) IconCopyButton(data: height), - ], - ); - }), ), - if (coin == Coin.ethereum) + if (coin is Ethereum) isDesktop ? const _Divider() : const SizedBox( height: 12, ), - if (coin == Coin.ethereum) + if (coin is Ethereum) RoundedWhiteContainer( padding: isDesktop ? const EdgeInsets.all(16) @@ -1225,16 +1279,17 @@ class _TransactionDetailsViewState style: isDesktop ? STextStyles .desktopTextExtraExtraSmall( - context) + context, + ) : STextStyles.itemSubtitle(context), ), SelectableText( _transaction.nonce.toString(), style: isDesktop ? STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( + .desktopTextExtraExtraSmall( + context, + ).copyWith( color: Theme.of(context) .extension()! .textDark, @@ -1265,16 +1320,17 @@ class _TransactionDetailsViewState style: isDesktop ? STextStyles .desktopTextExtraExtraSmall( - context) + context, + ) : STextStyles.itemSubtitle(context), ), SelectableText( _transaction.subType.toString(), style: isDesktop ? STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( + .desktopTextExtraExtraSmall( + context, + ).copyWith( color: Theme.of(context) .extension()! .textDark, @@ -1308,9 +1364,11 @@ class _TransactionDetailsViewState style: isDesktop ? STextStyles .desktopTextExtraExtraSmall( - context) + context, + ) : STextStyles.itemSubtitle( - context), + context, + ), ), const SizedBox( height: 8, @@ -1323,21 +1381,22 @@ class _TransactionDetailsViewState _transaction.txid, style: isDesktop ? STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( + .desktopTextExtraExtraSmall( + context, + ).copyWith( color: Theme.of(context) .extension()! .textDark, ) : STextStyles.itemSubtitle12( - context), + context, + ), ), - if (coin != Coin.epicCash) + if (coin is! Epiccash) const SizedBox( height: 8, ), - if (coin != Coin.epicCash) + if (coin is! Epiccash) CustomTextButton( text: "Open in block explorer", onTap: () async { @@ -1349,12 +1408,14 @@ class _TransactionDetailsViewState if (ref .read( - prefsChangeNotifierProvider) + prefsChangeNotifierProvider, + ) .hideBlockExplorerWarning == false) { final shouldContinue = await showExplorerWarning( - "${uri.scheme}://${uri.host}"); + "${uri.scheme}://${uri.host}", + ); if (!shouldContinue) { return; @@ -1415,12 +1476,12 @@ class _TransactionDetailsViewState ], ), ), - // if ((coin == Coin.firoTestNet || coin == Coin.firo) && + // if ((coin is FiroTestNet || coin is Firo) && // _transaction.subType == "mint") // const SizedBox( // height: 12, // ), - // if ((coin == Coin.firoTestNet || coin == Coin.firo) && + // if ((coin is FiroTestNet || coin is Firo) && // _transaction.subType == "mint") // RoundedWhiteContainer( // child: Column( @@ -1492,13 +1553,13 @@ class _TransactionDetailsViewState // ], // ), // ), - if (coin == Coin.epicCash) + if (coin is Epiccash) isDesktop ? const _Divider() : const SizedBox( height: 12, ), - if (coin == Coin.epicCash) + if (coin is Epiccash) RoundedWhiteContainer( padding: isDesktop ? const EdgeInsets.all(16) @@ -1517,9 +1578,11 @@ class _TransactionDetailsViewState style: isDesktop ? STextStyles .desktopTextExtraExtraSmall( - context) + context, + ) : STextStyles.itemSubtitle( - context), + context, + ), ), // Flexible( // child: FittedBox( @@ -1529,15 +1592,16 @@ class _TransactionDetailsViewState _transaction.slateId ?? "Unknown", style: isDesktop ? STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( + .desktopTextExtraExtraSmall( + context, + ).copyWith( color: Theme.of(context) .extension()! .textDark, ) : STextStyles.itemSubtitle12( - context), + context, + ), ), // ), // ), @@ -1569,7 +1633,7 @@ class _TransactionDetailsViewState ), ), floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, - floatingActionButton: (coin == Coin.epicCash && + floatingActionButton: (coin is Epiccash && _transaction.getConfirmations(currentHeight) < 1 && _transaction.isCancelled == false) ? ConditionalParent( @@ -1595,20 +1659,24 @@ class _TransactionDetailsViewState if (wallet is EpiccashWallet) { final String? id = _transaction.slateId; if (id == null) { - unawaited(showFloatingFlushBar( - type: FlushBarType.warning, - message: "Could not find Epic transaction ID", - context: context, - )); + unawaited( + showFloatingFlushBar( + type: FlushBarType.warning, + message: "Could not find Epic transaction ID", + context: context, + ), + ); return; } - unawaited(showDialog( - barrierDismissible: false, - context: context, - builder: (_) => - const CancellingTransactionProgressDialog(), - )); + unawaited( + showDialog( + barrierDismissible: false, + context: context, + builder: (_) => + const CancellingTransactionProgressDialog(), + ), + ); final result = await wallet.cancelPendingTransactionAndPost(id); @@ -1624,8 +1692,10 @@ class _TransactionDetailsViewState onOkPressed: (_) { wallet.refresh(); Navigator.of(context).popUntil( - ModalRoute.withName( - WalletView.routeName)); + ModalRoute.withName( + WalletView.routeName, + ), + ); }, ), ); @@ -1640,11 +1710,13 @@ class _TransactionDetailsViewState } } } else { - unawaited(showFloatingFlushBar( - type: FlushBarType.warning, - message: "ERROR: Wallet type is not Epic Cash", - context: context, - )); + unawaited( + showFloatingFlushBar( + type: FlushBarType.warning, + message: "ERROR: Wallet type is not Epic Cash", + context: context, + ), + ); return; } }, diff --git a/lib/pages/wallet_view/transaction_views/transaction_search_filter_view.dart b/lib/pages/wallet_view/transaction_views/transaction_search_filter_view.dart index 10d34771c..5e4244177 100644 --- a/lib/pages/wallet_view/transaction_views/transaction_search_filter_view.dart +++ b/lib/pages/wallet_view/transaction_views/transaction_search_filter_view.dart @@ -12,31 +12,31 @@ import 'package:decimal/decimal.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/models/transaction_filter.dart'; -import 'package:stackwallet/providers/global/locale_provider.dart'; -import 'package:stackwallet/providers/ui/transaction_filter_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/amount/amount_input_formatter.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/format.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/date_picker/date_picker.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../../models/transaction_filter.dart'; +import '../../../providers/global/locale_provider.dart'; +import '../../../providers/ui/transaction_filter_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../themes/theme_providers.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/amount/amount_formatter.dart'; +import '../../../utilities/amount/amount_input_formatter.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/format.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../widgets/background.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/date_picker/date_picker.dart'; +import '../../../widgets/desktop/desktop_dialog.dart'; +import '../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../widgets/desktop/primary_button.dart'; +import '../../../widgets/desktop/secondary_button.dart'; +import '../../../widgets/icon_widgets/x_icon.dart'; +import '../../../widgets/rounded_white_container.dart'; +import '../../../widgets/stack_text_field.dart'; +import '../../../widgets/textfield_icon_button.dart'; class TransactionSearchFilterView extends ConsumerStatefulWidget { const TransactionSearchFilterView({ @@ -46,7 +46,7 @@ class TransactionSearchFilterView extends ConsumerStatefulWidget { static const String routeName = "/transactionSearchFilter"; - final Coin coin; + final CryptoCurrency coin; @override ConsumerState createState() => @@ -665,7 +665,7 @@ class _TransactionSearchViewState ), inputFormatters: [ AmountInputFormatter( - decimals: widget.coin.decimals, + decimals: widget.coin.fractionDigits, unit: ref.watch(pAmountUnit(widget.coin)), locale: ref.watch( localeServiceChangeNotifierProvider @@ -896,9 +896,9 @@ class _TransactionSearchViewState if (amountText.isNotEmpty && !(amountText == "," || amountText == ".")) { amount = amountText.contains(",") ? Decimal.parse(amountText.replaceFirst(",", ".")) - .toAmount(fractionDigits: widget.coin.decimals) + .toAmount(fractionDigits: widget.coin.fractionDigits) : Decimal.parse(amountText) - .toAmount(fractionDigits: widget.coin.decimals); + .toAmount(fractionDigits: widget.coin.fractionDigits); } final TransactionFilter filter = TransactionFilter( diff --git a/lib/pages/wallet_view/transaction_views/tx_v2/all_transactions_v2_view.dart b/lib/pages/wallet_view/transaction_views/tx_v2/all_transactions_v2_view.dart index 50a53291f..e8dfcbc42 100644 --- a/lib/pages/wallet_view/transaction_views/tx_v2/all_transactions_v2_view.dart +++ b/lib/pages/wallet_view/transaction_views/tx_v2/all_transactions_v2_view.dart @@ -15,41 +15,40 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart'; -import 'package:stackwallet/models/isar/models/contact_entry.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/models/transaction_filter.dart'; -import 'package:stackwallet/pages/wallet_view/sub_widgets/tx_icon.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_search_filter_view.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/transaction_v2_card.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/global/address_book_service_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/providers/ui/transaction_filter_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/format.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/eth/current_token_wallet_provider.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/loading_indicator.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../../../models/isar/models/blockchain_data/v2/transaction_v2.dart'; +import '../../../../models/isar/models/contact_entry.dart'; +import '../../../../models/isar/models/isar_models.dart'; +import '../../../../models/transaction_filter.dart'; +import '../../sub_widgets/tx_icon.dart'; +import '../transaction_search_filter_view.dart'; +import 'transaction_v2_card.dart'; +import 'transaction_v2_details_view.dart'; +import '../../../../providers/db/main_db_provider.dart'; +import '../../../../providers/global/address_book_service_provider.dart'; +import '../../../../providers/providers.dart'; +import '../../../../providers/ui/transaction_filter_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/amount/amount.dart'; +import '../../../../utilities/amount/amount_formatter.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/format.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/isar/providers/eth/current_token_wallet_provider.dart'; +import '../../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../../wallets/wallet/wallet_mixin_interfaces/spark_interface.dart'; +import '../../../../widgets/conditional_parent.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/desktop/desktop_app_bar.dart'; +import '../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../widgets/desktop/desktop_scaffold.dart'; +import '../../../../widgets/desktop/secondary_button.dart'; +import '../../../../widgets/icon_widgets/x_icon.dart'; +import '../../../../widgets/loading_indicator.dart'; +import '../../../../widgets/rounded_white_container.dart'; +import '../../../../widgets/stack_text_field.dart'; +import '../../../../widgets/textfield_icon_button.dart'; typedef _GroupedTransactions = ({ String label, @@ -59,10 +58,10 @@ typedef _GroupedTransactions = ({ class AllTransactionsV2View extends ConsumerStatefulWidget { const AllTransactionsV2View({ - Key? key, + super.key, required this.walletId, this.contractAddress, - }) : super(key: key); + }); static const String routeName = "/allTransactionsV2"; @@ -96,8 +95,10 @@ class _AllTransactionsV2ViewState extends ConsumerState { } // TODO: optimise search+filter - List filter( - {required List transactions, TransactionFilter? filter}) { + List filter({ + required List transactions, + TransactionFilter? filter, + }) { if (filter == null) { return transactions; } @@ -159,13 +160,15 @@ class _AllTransactionsV2ViewState extends ConsumerState { // check if address book name contains contains |= contacts - .where((e) => - e.addresses - .map((e) => e.address) - .toSet() - .intersection(tx.associatedAddresses()) - .isNotEmpty && - e.name.toLowerCase().contains(keyword)) + .where( + (e) => + e.addresses + .map((e) => e.address) + .toSet() + .intersection(tx.associatedAddresses()) + .isNotEmpty && + e.name.toLowerCase().contains(keyword), + ) .isNotEmpty; // check if address contains @@ -224,9 +227,9 @@ class _AllTransactionsV2ViewState extends ConsumerState { List<_GroupedTransactions> groupTransactionsByMonth( List transactions, ) { - Map map = {}; + final Map map = {}; - for (var tx in transactions) { + for (final tx in transactions) { final date = DateTime.fromMillisecondsSinceEpoch(tx.timestamp * 1000); final monthYear = "${Constants.monthMap[date.month]} ${date.year}"; if (map[monthYear] == null) { @@ -291,9 +294,10 @@ class _AllTransactionsV2ViewState extends ConsumerState { if (FocusScope.of(context).hasFocus) { FocusScope.of(context).unfocus(); await Future.delayed( - const Duration(milliseconds: 75)); + const Duration(milliseconds: 75), + ); } - if (mounted) { + if (context.mounted) { Navigator.of(context).pop(); } }, @@ -494,32 +498,35 @@ class _AllTransactionsV2ViewState extends ConsumerState { .isar .transactionV2s .buildQuery( - whereClauses: [ - IndexWhereClause.equalTo( - indexName: 'walletId', - value: [widget.walletId], - ) - ], - filter: widget.contractAddress == null - ? ref - .watch(pWallets) - .getWallet(widget.walletId) - .transactionFilterOperation - : ref - .read(pCurrentTokenWallet)! - .transactionFilterOperation, - sortBy: [ - const SortProperty( - property: "timestamp", - sort: Sort.desc, - ), - ]) + whereClauses: [ + IndexWhereClause.equalTo( + indexName: 'walletId', + value: [widget.walletId], + ), + ], + filter: widget.contractAddress == null + ? ref + .watch(pWallets) + .getWallet(widget.walletId) + .transactionFilterOperation + : ref + .read(pCurrentTokenWallet)! + .transactionFilterOperation, + sortBy: [ + const SortProperty( + property: "timestamp", + sort: Sort.desc, + ), + ], + ) .findAll(), builder: (_, AsyncSnapshot> snapshot) { if (snapshot.connectionState == ConnectionState.done && snapshot.hasData) { final filtered = filter( - transactions: snapshot.data!, filter: criteria); + transactions: snapshot.data!, + filter: criteria, + ); final searched = search(_searchString, filtered); searched.sort((a, b) { @@ -571,7 +578,8 @@ class _AllTransactionsV2ViewState extends ConsumerState { padding: const EdgeInsets.all(4), child: DesktopTransactionCardRow( key: Key( - "transactionCard_key_${month.transactions[index].txid}"), + "transactionCard_key_${month.transactions[index].txid}", + ), transaction: month.transactions[index], walletId: walletId, @@ -587,7 +595,8 @@ class _AllTransactionsV2ViewState extends ConsumerState { ...month.transactions.map( (tx) => TransactionCardV2( key: Key( - "transactionCard_key_${tx.txid}"), + "transactionCard_key_${tx.txid}", + ), transaction: tx, ), ), @@ -789,9 +798,10 @@ class TransactionFilterOptionBarItem extends StatelessWidget { child: Container( height: 32, decoration: BoxDecoration( - color: - Theme.of(context).extension()!.buttonBackSecondary, - borderRadius: BorderRadius.circular(1000)), + color: + Theme.of(context).extension()!.buttonBackSecondary, + borderRadius: BorderRadius.circular(1000), + ), child: Padding( padding: const EdgeInsets.symmetric( horizontal: 14, @@ -882,7 +892,8 @@ class _DesktopTransactionCardRowState @override Widget build(BuildContext context) { final locale = ref.watch( - localeServiceChangeNotifierProvider.select((value) => value.locale)); + localeServiceChangeNotifierProvider.select((value) => value.locale), + ); final baseCurrency = ref .watch(prefsChangeNotifierProvider.select((value) => value.currency)); @@ -890,8 +901,10 @@ class _DesktopTransactionCardRowState final coin = ref.watch(pWalletCoin(walletId)); final price = ref - .watch(priceAnd24hChangeNotifierProvider - .select((value) => value.getPrice(coin))) + .watch( + priceAnd24hChangeNotifierProvider + .select((value) => value.getPrice(coin)), + ) .item1; late final String prefix; @@ -910,42 +923,48 @@ class _DesktopTransactionCardRowState final currentHeight = ref.watch(pWalletChainHeight(walletId)); final Amount amount; - final fractionDigits = ethContract?.decimals ?? coin.decimals; + final fractionDigits = ethContract?.decimals ?? coin.fractionDigits; if (_transaction.subType == TransactionSubType.cashFusion) { amount = _transaction.getAmountReceivedInThisWallet( - fractionDigits: fractionDigits); + fractionDigits: fractionDigits, + ); } else { switch (_transaction.type) { case TransactionType.outgoing: amount = _transaction.getAmountSentFromThisWallet( - fractionDigits: fractionDigits); + fractionDigits: fractionDigits, + ); break; case TransactionType.incoming: case TransactionType.sentToSelf: if (_transaction.subType == TransactionSubType.sparkMint) { amount = _transaction.getAmountSparkSelfMinted( - fractionDigits: fractionDigits); + fractionDigits: fractionDigits, + ); } else if (_transaction.subType == TransactionSubType.sparkSpend) { final changeAddress = (ref.watch(pWallets).getWallet(walletId) as SparkInterface) .sparkChangeAddress; amount = Amount( rawValue: _transaction.outputs - .where((e) => - e.walletOwns && !e.addresses.contains(changeAddress)) + .where( + (e) => e.walletOwns && !e.addresses.contains(changeAddress), + ) .fold(BigInt.zero, (p, e) => p + e.value), - fractionDigits: coin.decimals, + fractionDigits: coin.fractionDigits, ); } else { amount = _transaction.getAmountReceivedInThisWallet( - fractionDigits: fractionDigits); + fractionDigits: fractionDigits, + ); } break; case TransactionType.unknown: amount = _transaction.getAmountSentFromThisWallet( - fractionDigits: fractionDigits); + fractionDigits: fractionDigits, + ); break; } } @@ -1043,8 +1062,10 @@ class _DesktopTransactionCardRowState ), ), ), - if (ref.watch(prefsChangeNotifierProvider - .select((value) => value.externalCalls))) + if (ref.watch( + prefsChangeNotifierProvider + .select((value) => value.externalCalls), + )) Expanded( flex: 4, child: Text( diff --git a/lib/pages/wallet_view/transaction_views/tx_v2/fusion_group_details_view.dart b/lib/pages/wallet_view/transaction_views/tx_v2/fusion_group_details_view.dart index 874d1fdba..ef473b3bf 100644 --- a/lib/pages/wallet_view/transaction_views/tx_v2/fusion_group_details_view.dart +++ b/lib/pages/wallet_view/transaction_views/tx_v2/fusion_group_details_view.dart @@ -10,31 +10,31 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/transaction_v2_list_item.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../../models/isar/models/blockchain_data/v2/transaction_v2.dart'; +import 'transaction_v2_list_item.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../../widgets/rounded_white_container.dart'; class FusionGroupDetailsView extends ConsumerStatefulWidget { const FusionGroupDetailsView({ - Key? key, + super.key, required this.transactions, required this.walletId, required this.coin, - }) : super(key: key); + }); static const String routeName = "/fusionGroupDetailsView"; final List transactions; final String walletId; - final Coin coin; + final CryptoCurrency coin; @override ConsumerState createState() => diff --git a/lib/pages/wallet_view/transaction_views/tx_v2/fusion_tx_group_card.dart b/lib/pages/wallet_view/transaction_views/tx_v2/fusion_tx_group_card.dart index e26017b6c..4f3512017 100644 --- a/lib/pages/wallet_view/transaction_views/tx_v2/fusion_tx_group_card.dart +++ b/lib/pages/wallet_view/transaction_views/tx_v2/fusion_tx_group_card.dart @@ -2,16 +2,16 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart'; -import 'package:stackwallet/pages/wallet_view/sub_widgets/tx_icon.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/fusion_group_details_view.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/format.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; +import '../../../../models/isar/models/blockchain_data/v2/transaction_v2.dart'; +import '../../sub_widgets/tx_icon.dart'; +import 'fusion_group_details_view.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/format.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../../widgets/desktop/desktop_dialog.dart'; class FusionTxGroup { final List transactions; diff --git a/lib/pages/wallet_view/transaction_views/tx_v2/transaction_v2_card.dart b/lib/pages/wallet_view/transaction_views/tx_v2/transaction_v2_card.dart index 1401625c9..db18d772c 100644 --- a/lib/pages/wallet_view/transaction_views/tx_v2/transaction_v2_card.dart +++ b/lib/pages/wallet_view/transaction_views/tx_v2/transaction_v2_card.dart @@ -2,32 +2,33 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/pages/wallet_view/sub_widgets/tx_icon.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/global/locale_provider.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/providers/global/price_provider.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/format.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; +import '../../../../models/isar/models/blockchain_data/v2/transaction_v2.dart'; +import '../../../../models/isar/models/isar_models.dart'; +import '../../sub_widgets/tx_icon.dart'; +import 'transaction_v2_details_view.dart'; +import '../../../../providers/db/main_db_provider.dart'; +import '../../../../providers/global/locale_provider.dart'; +import '../../../../providers/global/prefs_provider.dart'; +import '../../../../providers/global/price_provider.dart'; +import '../../../../providers/global/wallets_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/amount/amount.dart'; +import '../../../../utilities/amount/amount_formatter.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/format.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/crypto_currency/coins/ethereum.dart'; +import '../../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../../wallets/wallet/wallet_mixin_interfaces/spark_interface.dart'; +import '../../../../widgets/desktop/desktop_dialog.dart'; class TransactionCardV2 extends ConsumerStatefulWidget { const TransactionCardV2({ - Key? key, + super.key, required this.transaction, - }) : super(key: key); + }); final TransactionV2 transaction; @@ -40,17 +41,17 @@ class _TransactionCardStateV2 extends ConsumerState { late final String walletId; late final String prefix; late final String unit; - late final Coin coin; + late final CryptoCurrency coin; late final TransactionType txType; late final EthContract? tokenContract; bool get isTokenTx => tokenContract != null; String whatIsIt( - Coin coin, + CryptoCurrency coin, int currentHeight, ) => - _transaction.isCancelled && coin == Coin.ethereum + _transaction.isCancelled && coin is Ethereum ? "Failed" : _transaction.statusLabel( currentChainHeight: currentHeight, @@ -112,7 +113,7 @@ class _TransactionCardStateV2 extends ConsumerState { final Amount amount; - final fractionDigits = tokenContract?.decimals ?? coin.decimals; + final fractionDigits = tokenContract?.decimals ?? coin.fractionDigits; if (_transaction.subType == TransactionSubType.cashFusion) { amount = _transaction.getAmountReceivedInThisWallet( @@ -138,7 +139,7 @@ class _TransactionCardStateV2 extends ConsumerState { .where((e) => e.walletOwns && !e.addresses.contains(changeAddress)) .fold(BigInt.zero, (p, e) => p + e.value), - fractionDigits: coin.decimals, + fractionDigits: coin.fractionDigits, ); } else { amount = _transaction.getAmountReceivedInThisWallet( diff --git a/lib/pages/wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart b/lib/pages/wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart index 5a1ae2032..3ed6397d6 100644 --- a/lib/pages/wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart +++ b/lib/pages/wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart @@ -16,60 +16,67 @@ import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart'; -import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/wallet_view/sub_widgets/tx_icon.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/dialogs/cancelling_transaction_progress_dialog.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/edit_note_view.dart'; -import 'package:stackwallet/pages/wallet_view/wallet_view.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/global/address_book_service_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/block_explorers.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/format.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/models/spark_coin.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/wallets/wallet/impl/epiccash_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/copy_icon.dart'; -import 'package:stackwallet/widgets/icon_widgets/pencil_icon.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../../../models/isar/models/blockchain_data/transaction.dart'; +import '../../../../models/isar/models/blockchain_data/v2/transaction_v2.dart'; +import '../../../../models/isar/models/ethereum/eth_contract.dart'; +import '../../../../notifications/show_flush_bar.dart'; +import '../../sub_widgets/tx_icon.dart'; +import '../dialogs/cancelling_transaction_progress_dialog.dart'; +import '../edit_note_view.dart'; +import '../../wallet_view.dart'; +import '../../../../providers/db/main_db_provider.dart'; +import '../../../../providers/global/address_book_service_provider.dart'; +import '../../../../providers/providers.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/amount/amount.dart'; +import '../../../../utilities/amount/amount_formatter.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/block_explorers.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/format.dart'; +import '../../../../utilities/logger.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/crypto_currency/coins/bitcoincash.dart'; +import '../../../../wallets/crypto_currency/coins/ecash.dart'; +import '../../../../wallets/crypto_currency/coins/epiccash.dart'; +import '../../../../wallets/crypto_currency/coins/firo.dart'; +import '../../../../wallets/crypto_currency/coins/monero.dart'; +import '../../../../wallets/crypto_currency/coins/wownero.dart'; +import '../../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../../wallets/crypto_currency/intermediate/nano_currency.dart'; +import '../../../../wallets/isar/models/spark_coin.dart'; +import '../../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../../wallets/wallet/impl/epiccash_wallet.dart'; +import '../../../../wallets/wallet/wallet_mixin_interfaces/spark_interface.dart'; +import '../../../../widgets/background.dart'; +import '../../../../widgets/conditional_parent.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/custom_buttons/blue_text_button.dart'; +import '../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/desktop/secondary_button.dart'; +import '../../../../widgets/icon_widgets/copy_icon.dart'; +import '../../../../widgets/icon_widgets/pencil_icon.dart'; +import '../../../../widgets/rounded_white_container.dart'; +import '../../../../widgets/stack_dialog.dart'; import 'package:tuple/tuple.dart'; import 'package:url_launcher/url_launcher.dart'; class TransactionV2DetailsView extends ConsumerStatefulWidget { const TransactionV2DetailsView({ - Key? key, + super.key, required this.transaction, required this.walletId, required this.coin, - }) : super(key: key); + }); static const String routeName = "/transactionV2Details"; final TransactionV2 transaction; final String walletId; - final Coin coin; + final CryptoCurrency coin; @override ConsumerState createState() => @@ -82,7 +89,7 @@ class _TransactionV2DetailsViewState late TransactionV2 _transaction; late final String walletId; - late final Coin coin; + late final CryptoCurrency coin; late final Amount amount; late final Amount fee; late final String amountPrefix; @@ -120,7 +127,7 @@ class _TransactionV2DetailsViewState minConfirms = ref.read(pWallets).getWallet(walletId).cryptoCurrency.minConfirms; - final fractionDigits = ethContract?.decimals ?? coin.decimals; + final fractionDigits = ethContract?.decimals ?? coin.fractionDigits; fee = _transaction.getFee(fractionDigits: fractionDigits); @@ -136,43 +143,61 @@ class _TransactionV2DetailsViewState case TransactionType.outgoing: case TransactionType.unknown: amount = _transaction.getAmountSentFromThisWallet( - fractionDigits: fractionDigits); + fractionDigits: fractionDigits, + ); break; case TransactionType.incoming: case TransactionType.sentToSelf: amount = _transaction.getAmountReceivedInThisWallet( - fractionDigits: fractionDigits); + fractionDigits: fractionDigits, + ); break; } data = _transaction.outputs - .map((e) => ( - addresses: e.addresses, - amount: Amount(rawValue: e.value, fractionDigits: coin.decimals) - )) + .map( + (e) => ( + addresses: e.addresses, + amount: Amount( + rawValue: e.value, + fractionDigits: coin.fractionDigits, + ) + ), + ) .toList(); } else if (_transaction.subType == TransactionSubType.cashFusion) { amount = _transaction.getAmountReceivedInThisWallet( - fractionDigits: fractionDigits); + fractionDigits: fractionDigits, + ); data = _transaction.outputs .where((e) => e.walletOwns) - .map((e) => ( - addresses: e.addresses, - amount: Amount(rawValue: e.value, fractionDigits: coin.decimals) - )) + .map( + (e) => ( + addresses: e.addresses, + amount: Amount( + rawValue: e.value, + fractionDigits: coin.fractionDigits, + ) + ), + ) .toList(); } else { switch (_transaction.type) { case TransactionType.outgoing: amount = _transaction.getAmountSentFromThisWallet( - fractionDigits: fractionDigits); + fractionDigits: fractionDigits, + ); data = _transaction.outputs .where((e) => !e.walletOwns) - .map((e) => ( - addresses: e.addresses, - amount: - Amount(rawValue: e.value, fractionDigits: coin.decimals) - )) + .map( + (e) => ( + addresses: e.addresses, + amount: Amount( + rawValue: e.value, + fractionDigits: coin.fractionDigits, + ) + ), + ) .toList(); break; @@ -191,56 +216,71 @@ class _TransactionV2DetailsViewState .and() .heightEqualTo(_transaction.height) .anyOf( - _transaction.outputs - .where((e) => + _transaction.outputs + .where( + (e) => e.walletOwns && e.addresses.isEmpty && - e.scriptPubKeyHex.length >= 488) - .map((e) => e.scriptPubKeyHex.substring(2, 488)) - .toList(), - (q, element) => q.serializedCoinB64StartsWith(element)) + e.scriptPubKeyHex.length >= 488, + ) + .map((e) => e.scriptPubKeyHex.substring(2, 488)) + .toList(), + (q, element) => q.serializedCoinB64StartsWith(element), + ) .memoProperty() .findFirstSync(); } if (_transaction.subType == TransactionSubType.sparkMint) { amount = _transaction.getAmountSparkSelfMinted( - fractionDigits: fractionDigits); + fractionDigits: fractionDigits, + ); } else if (_transaction.subType == TransactionSubType.sparkSpend) { final changeAddress = (ref.read(pWallets).getWallet(walletId) as SparkInterface) .sparkChangeAddress; amount = Amount( rawValue: _transaction.outputs - .where((e) => - e.walletOwns && !e.addresses.contains(changeAddress)) + .where( + (e) => e.walletOwns && !e.addresses.contains(changeAddress), + ) .fold(BigInt.zero, (p, e) => p + e.value), - fractionDigits: coin.decimals, + fractionDigits: coin.fractionDigits, ); } else { amount = _transaction.getAmountReceivedInThisWallet( - fractionDigits: fractionDigits); + fractionDigits: fractionDigits, + ); } data = _transaction.outputs .where((e) => e.walletOwns) - .map((e) => ( - addresses: e.addresses, - amount: - Amount(rawValue: e.value, fractionDigits: coin.decimals) - )) + .map( + (e) => ( + addresses: e.addresses, + amount: Amount( + rawValue: e.value, + fractionDigits: coin.fractionDigits, + ) + ), + ) .toList(); break; case TransactionType.unknown: amount = _transaction.getAmountSentFromThisWallet( - fractionDigits: fractionDigits); + fractionDigits: fractionDigits, + ); data = _transaction.inputs .where((e) => e.walletOwns) - .map((e) => ( - addresses: e.addresses, - amount: - Amount(rawValue: e.value, fractionDigits: coin.decimals) - )) + .map( + (e) => ( + addresses: e.addresses, + amount: Amount( + rawValue: e.value, + fractionDigits: coin.fractionDigits, + ) + ), + ) .toList(); break; } @@ -265,9 +305,10 @@ class _TransactionV2DetailsViewState } try { final contacts = ref.read(addressBookServiceProvider).contacts.where( - (element) => element.addresses - .where((element) => element.address == address) - .isNotEmpty); + (element) => element.addresses + .where((element) => element.address == address) + .isNotEmpty, + ); if (contacts.isNotEmpty) { return contacts.first.name; } else { @@ -281,20 +322,23 @@ class _TransactionV2DetailsViewState Future showExplorerWarning(String explorer) async { final bool? shouldContinue = await showDialog( - context: context, - barrierDismissible: false, - builder: (_) { - if (!isDesktop) { - return StackDialog( - title: "Attention", - message: - "You are about to view this transaction in a block explorer. The explorer may log your IP address and link it to the transaction. Only proceed if you trust $explorer.", - icon: Row( - children: [ - Consumer(builder: (_, ref, __) { + context: context, + barrierDismissible: false, + builder: (_) { + if (!isDesktop) { + return StackDialog( + title: "Attention", + message: + "You are about to view this transaction in a block explorer. The explorer may log your IP address and link it to the transaction. Only proceed if you trust $explorer.", + icon: Row( + children: [ + Consumer( + builder: (_, ref, __) { return Checkbox( - value: ref.watch(prefsChangeNotifierProvider - .select((value) => value.hideBlockExplorerWarning)), + value: ref.watch( + prefsChangeNotifierProvider + .select((value) => value.hideBlockExplorerWarning), + ), onChanged: (value) { if (value is bool) { ref @@ -304,61 +348,65 @@ class _TransactionV2DetailsViewState } }, ); - }), - Text( - "Never show again", - style: STextStyles.smallMed14(context), - ) - ], - ), - leftButton: TextButton( - onPressed: () { - Navigator.of(context).pop(false); - }, - child: Text( - "Cancel", - style: STextStyles.button(context).copyWith( - color: Theme.of(context) - .extension()! - .accentColorDark), + }, + ), + Text( + "Never show again", + style: STextStyles.smallMed14(context), + ), + ], + ), + leftButton: TextButton( + onPressed: () { + Navigator.of(context).pop(false); + }, + child: Text( + "Cancel", + style: STextStyles.button(context).copyWith( + color: Theme.of(context) + .extension()! + .accentColorDark, ), ), - rightButton: TextButton( - style: Theme.of(context) - .extension()! - .getPrimaryEnabledButtonStyle(context), - onPressed: () { - Navigator.of(context).pop(true); - }, - child: Text( - "Continue", - style: STextStyles.button(context), - ), + ), + rightButton: TextButton( + style: Theme.of(context) + .extension()! + .getPrimaryEnabledButtonStyle(context), + onPressed: () { + Navigator.of(context).pop(true); + }, + child: Text( + "Continue", + style: STextStyles.button(context), ), - ); - } else { - return DesktopDialog( - maxWidth: 550, - maxHeight: 300, - child: Padding( - padding: - const EdgeInsets.symmetric(horizontal: 32, vertical: 20), - child: Column( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - "Attention", - style: STextStyles.desktopH2(context), - ), - Row( - children: [ - Consumer(builder: (_, ref, __) { + ), + ); + } else { + return DesktopDialog( + maxWidth: 550, + maxHeight: 300, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 32, vertical: 20), + child: Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Attention", + style: STextStyles.desktopH2(context), + ), + Row( + children: [ + Consumer( + builder: (_, ref, __) { return Checkbox( - value: ref.watch(prefsChangeNotifierProvider - .select((value) => - value.hideBlockExplorerWarning)), + value: ref.watch( + prefsChangeNotifierProvider.select( + (value) => value.hideBlockExplorerWarning, + ), + ), onChanged: (value) { if (value is bool) { ref @@ -368,55 +416,57 @@ class _TransactionV2DetailsViewState } }, ); - }), - Text( - "Never show again", - style: STextStyles.smallMed14(context), - ) - ], - ), - ], - ), - const SizedBox(height: 16), - Text( - "You are about to view this transaction in a block explorer. The explorer may log your IP address and link it to the transaction. Only proceed if you trust $explorer.", - style: STextStyles.desktopTextSmall(context), - ), - const SizedBox(height: 35), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SecondaryButton( - width: 200, - buttonHeight: ButtonHeight.l, - label: "Cancel", - onPressed: () { - Navigator.of( - context, - rootNavigator: true, - ).pop(false); - }, - ), - const SizedBox(width: 20), - PrimaryButton( - width: 200, - buttonHeight: ButtonHeight.l, - label: "Continue", - onPressed: () { - Navigator.of( - context, - rootNavigator: true, - ).pop(true); - }, - ), - ], - ), - ], - ), + }, + ), + Text( + "Never show again", + style: STextStyles.smallMed14(context), + ), + ], + ), + ], + ), + const SizedBox(height: 16), + Text( + "You are about to view this transaction in a block explorer. The explorer may log your IP address and link it to the transaction. Only proceed if you trust $explorer.", + style: STextStyles.desktopTextSmall(context), + ), + const SizedBox(height: 35), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SecondaryButton( + width: 200, + buttonHeight: ButtonHeight.l, + label: "Cancel", + onPressed: () { + Navigator.of( + context, + rootNavigator: true, + ).pop(false); + }, + ), + const SizedBox(width: 20), + PrimaryButton( + width: 200, + buttonHeight: ButtonHeight.l, + label: "Continue", + onPressed: () { + Navigator.of( + context, + rootNavigator: true, + ).pop(true); + }, + ), + ], + ), + ], ), - ); - } - }); + ), + ); + } + }, + ); return shouldContinue ?? false; } @@ -558,7 +608,8 @@ class _TransactionV2DetailsViewState ), style: STextStyles.desktopTextMedium( - context), + context, + ), ), ], ), @@ -571,32 +622,36 @@ class _TransactionV2DetailsViewState "$amountPrefix${ref.watch(pAmountFormatter(coin)).format(amount, ethContract: ethContract)}", style: isDesktop ? STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( + .desktopTextExtraExtraSmall( + context, + ).copyWith( color: Theme.of(context) .extension< StackColors>()! .textDark, ) : STextStyles.titleBold12( - context), + context, + ), ), const SizedBox( height: 2, ), if (ref.watch( - prefsChangeNotifierProvider - .select((value) => - value.externalCalls))) + prefsChangeNotifierProvider.select( + (value) => value.externalCalls, + ), + )) SelectableText( "$amountPrefix${(amount.decimal * ref.watch( priceAnd24hChangeNotifierProvider - .select((value) => - value - .getPrice( - coin) - .item1), + .select( + (value) => value + .getPrice( + coin, + ) + .item1, + ), )).toAmount(fractionDigits: 2).fiatString( locale: ref.watch( localeServiceChangeNotifierProvider @@ -613,9 +668,11 @@ class _TransactionV2DetailsViewState style: isDesktop ? STextStyles .desktopTextExtraExtraSmall( - context) + context, + ) : STextStyles.itemSubtitle( - context), + context, + ), ), ], ), @@ -662,9 +719,9 @@ class _TransactionV2DetailsViewState ), style: isDesktop ? STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( + .desktopTextExtraExtraSmall( + context, + ).copyWith( color: _transaction.type == TransactionType .outgoing && @@ -685,12 +742,10 @@ class _TransactionV2DetailsViewState ], ), ), - if (!((coin == Coin.monero || - coin == Coin.wownero) && + if (!((coin is Monero || coin is Wownero) && _transaction.type == TransactionType.outgoing) && - !((coin == Coin.firo || - coin == Coin.firoTestNet) && + !((coin is Firo) && _transaction.subType == TransactionSubType.mint)) isDesktop @@ -698,12 +753,10 @@ class _TransactionV2DetailsViewState : const SizedBox( height: 12, ), - if (!((coin == Coin.monero || - coin == Coin.wownero) && + if (!((coin is Monero || coin is Wownero) && _transaction.type == TransactionType.outgoing) && - !((coin == Coin.firo || - coin == Coin.firoTestNet) && + !((coin is Firo) && _transaction.subType == TransactionSubType.mint)) RoundedWhiteContainer( @@ -778,9 +831,11 @@ class _TransactionV2DetailsViewState style: isDesktop ? STextStyles .desktopTextExtraExtraSmall( - context) + context, + ) : STextStyles.itemSubtitle( - context), + context, + ), ), ), const SizedBox( @@ -795,11 +850,13 @@ class _TransactionV2DetailsViewState 1) FutureBuilder( future: fetchContactNameFor( - data.first.addresses - .first), - builder: (builderContext, - AsyncSnapshot - snapshot) { + data.first.addresses.first, + ), + builder: ( + builderContext, + AsyncSnapshot + snapshot, + ) { String addressOrContactName = data.first.addresses @@ -815,18 +872,20 @@ class _TransactionV2DetailsViewState addressOrContactName, style: isDesktop ? STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( + .desktopTextExtraExtraSmall( + context, + ).copyWith( color: Theme.of( - context) + context, + ) .extension< StackColors>()! .textDark, ) : STextStyles .itemSubtitle12( - context), + context, + ), ); }, ) @@ -848,7 +907,8 @@ class _TransactionV2DetailsViewState child: Padding( padding: const EdgeInsets.all( - 8.0), + 8.0, + ), child: Column( crossAxisAlignment: CrossAxisAlignment @@ -861,11 +921,14 @@ class _TransactionV2DetailsViewState return FutureBuilder( future: fetchContactNameFor( - e), - builder: (builderContext, - AsyncSnapshot< - String> - snapshot) { + e, + ), + builder: ( + builderContext, + AsyncSnapshot< + String> + snapshot, + ) { final String addressOrContactName; if (snapshot.connectionState == @@ -909,29 +972,31 @@ class _TransactionV2DetailsViewState ], ), ), - if (coin == Coin.epicCash) + if (coin is Epiccash) RoundedWhiteContainer( padding: isDesktop ? const EdgeInsets.all(16) : const EdgeInsets.all(12), child: Row( mainAxisAlignment: - MainAxisAlignment.spaceBetween, + MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.start, children: [ Expanded( child: Column( crossAxisAlignment: - CrossAxisAlignment.start, + CrossAxisAlignment.start, children: [ Text( "On chain note", style: isDesktop ? STextStyles - .desktopTextExtraExtraSmall( - context) + .desktopTextExtraExtraSmall( + context, + ) : STextStyles.itemSubtitle( - context), + context, + ), ), const SizedBox( height: 8, @@ -940,16 +1005,17 @@ class _TransactionV2DetailsViewState _transaction.onChainNote ?? "", style: isDesktop ? STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( - color: Theme.of(context) - .extension< - StackColors>()! - .textDark, - ) + .desktopTextExtraExtraSmall( + context, + ).copyWith( + color: Theme.of(context) + .extension< + StackColors>()! + .textDark, + ) : STextStyles.itemSubtitle12( - context), + context, + ), ), ], ), @@ -978,13 +1044,14 @@ class _TransactionV2DetailsViewState MainAxisAlignment.spaceBetween, children: [ Text( - (coin == Coin.epicCash) + (coin is Epiccash) ? "Local Note" : "Note ", style: isDesktop ? STextStyles .desktopTextExtraExtraSmall( - context) + context, + ) : STextStyles.itemSubtitle(context), ), isDesktop @@ -1032,7 +1099,8 @@ class _TransactionV2DetailsViewState Text( "Edit", style: STextStyles.link2( - context), + context, + ), ), ], ), @@ -1047,8 +1115,9 @@ class _TransactionV2DetailsViewState .watch( pTransactionNote( ( - txid: (coin == Coin.epicCash) ? - _transaction.slateId.toString() + txid: (coin is Epiccash) + ? _transaction.slateId + .toString() : _transaction.txid, walletId: walletId ), @@ -1058,9 +1127,9 @@ class _TransactionV2DetailsViewState "", style: isDesktop ? STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( + .desktopTextExtraExtraSmall( + context, + ).copyWith( color: Theme.of(context) .extension()! .textDark, @@ -1091,9 +1160,11 @@ class _TransactionV2DetailsViewState style: isDesktop ? STextStyles .desktopTextExtraExtraSmall( - context) + context, + ) : STextStyles.itemSubtitle( - context), + context, + ), ), ], ), @@ -1104,9 +1175,9 @@ class _TransactionV2DetailsViewState _sparkMemo!, style: isDesktop ? STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( + .desktopTextExtraExtraSmall( + context, + ).copyWith( color: Theme.of(context) .extension()! .textDark, @@ -1139,7 +1210,8 @@ class _TransactionV2DetailsViewState style: isDesktop ? STextStyles .desktopTextExtraExtraSmall( - context) + context, + ) : STextStyles.itemSubtitle(context), ), if (isDesktop) @@ -1153,15 +1225,16 @@ class _TransactionV2DetailsViewState ), style: isDesktop ? STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( + .desktopTextExtraExtraSmall( + context, + ).copyWith( color: Theme.of(context) .extension()! .textDark, ) : STextStyles.itemSubtitle12( - context), + context, + ), ), ], ), @@ -1172,9 +1245,9 @@ class _TransactionV2DetailsViewState ), style: isDesktop ? STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( + .desktopTextExtraExtraSmall( + context, + ).copyWith( color: Theme.of(context) .extension()! .textDark, @@ -1190,34 +1263,136 @@ class _TransactionV2DetailsViewState ], ), ), - if (coin != Coin.banano && coin != Coin.nano) + if (coin is! NanoCurrency) isDesktop ? const _Divider() : const SizedBox( height: 12, ), - if (coin != Coin.banano && coin != Coin.nano) + if (coin is! NanoCurrency) RoundedWhiteContainer( padding: isDesktop ? const EdgeInsets.all(16) : const EdgeInsets.all(12), - child: Builder(builder: (context) { - String feeString = showFeePending - ? _transaction.isConfirmed( - currentHeight, - minConfirms, - ) - ? ref - .watch(pAmountFormatter(coin)) - .format( - fee, - ) - : "Pending" - : ref - .watch(pAmountFormatter(coin)) - .format( - fee, - ); + child: Builder( + builder: (context) { + String feeString = showFeePending + ? _transaction.isConfirmed( + currentHeight, + minConfirms, + ) + ? ref + .watch(pAmountFormatter(coin)) + .format( + fee, + ) + : "Pending" + : ref + .watch(pAmountFormatter(coin)) + .format( + fee, + ); + + return Row( + mainAxisAlignment: + MainAxisAlignment.spaceBetween, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Column( + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + "Transaction fee", + style: isDesktop + ? STextStyles + .desktopTextExtraExtraSmall( + context, + ) + : STextStyles.itemSubtitle( + context, + ), + ), + if (isDesktop) + const SizedBox( + height: 2, + ), + if (isDesktop) + SelectableText( + feeString, + style: isDesktop + ? STextStyles + .desktopTextExtraExtraSmall( + context, + ).copyWith( + color: Theme.of(context) + .extension< + StackColors>()! + .textDark, + ) + : STextStyles + .itemSubtitle12( + context, + ), + ), + ], + ), + if (!isDesktop) + SelectableText( + feeString, + style: isDesktop + ? STextStyles + .desktopTextExtraExtraSmall( + context, + ).copyWith( + color: Theme.of(context) + .extension< + StackColors>()! + .textDark, + ) + : STextStyles.itemSubtitle12( + context, + ), + ), + if (isDesktop) + IconCopyButton(data: feeString), + ], + ); + }, + ), + ), + isDesktop + ? const _Divider() + : const SizedBox( + height: 12, + ), + RoundedWhiteContainer( + padding: isDesktop + ? const EdgeInsets.all(16) + : const EdgeInsets.all(12), + child: Builder( + builder: (context) { + final String height; + + if (widget.coin is Bitcoincash || + widget.coin is Ecash) { + height = + "${_transaction.height != null && _transaction.height! > 0 ? _transaction.height! : "Pending"}"; + } else { + height = widget.coin is! Epiccash && + _transaction.isConfirmed( + currentHeight, + minConfirms, + ) + ? "${_transaction.height == 0 ? "Unknown" : _transaction.height}" + : _transaction.getConfirmations( + currentHeight, + ) > + 0 + ? "${_transaction.height}" + : "Pending"; + } return Row( mainAxisAlignment: @@ -1230,13 +1405,15 @@ class _TransactionV2DetailsViewState CrossAxisAlignment.start, children: [ Text( - "Transaction fee", + "Block height", style: isDesktop ? STextStyles .desktopTextExtraExtraSmall( - context) + context, + ) : STextStyles.itemSubtitle( - context), + context, + ), ), if (isDesktop) const SizedBox( @@ -1244,133 +1421,45 @@ class _TransactionV2DetailsViewState ), if (isDesktop) SelectableText( - feeString, + height, style: isDesktop ? STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( + .desktopTextExtraExtraSmall( + context, + ).copyWith( color: Theme.of(context) .extension< StackColors>()! .textDark, ) : STextStyles.itemSubtitle12( - context), + context, + ), ), ], ), if (!isDesktop) SelectableText( - feeString, + height, style: isDesktop ? STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( + .desktopTextExtraExtraSmall( + context, + ).copyWith( color: Theme.of(context) .extension()! .textDark, ) : STextStyles.itemSubtitle12( - context), + context, + ), ), if (isDesktop) - IconCopyButton(data: feeString) + IconCopyButton(data: height), ], ); - }), + }, ), - isDesktop - ? const _Divider() - : const SizedBox( - height: 12, - ), - RoundedWhiteContainer( - padding: isDesktop - ? const EdgeInsets.all(16) - : const EdgeInsets.all(12), - child: Builder(builder: (context) { - final String height; - - if (widget.coin == Coin.bitcoincash || - widget.coin == Coin.eCash || - widget.coin == Coin.bitcoincashTestnet) { - height = - "${_transaction.height != null && _transaction.height! > 0 ? _transaction.height! : "Pending"}"; - } else { - height = widget.coin != Coin.epicCash && - _transaction.isConfirmed( - currentHeight, - minConfirms, - ) - ? "${_transaction.height == 0 ? "Unknown" : _transaction.height}" - : _transaction.getConfirmations( - currentHeight) > - 0 - ? "${_transaction.height}" - : "Pending"; - } - - return Row( - mainAxisAlignment: - MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Column( - crossAxisAlignment: - CrossAxisAlignment.start, - children: [ - Text( - "Block height", - style: isDesktop - ? STextStyles - .desktopTextExtraExtraSmall( - context) - : STextStyles.itemSubtitle( - context), - ), - if (isDesktop) - const SizedBox( - height: 2, - ), - if (isDesktop) - SelectableText( - height, - style: isDesktop - ? STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( - color: Theme.of(context) - .extension< - StackColors>()! - .textDark, - ) - : STextStyles.itemSubtitle12( - context), - ), - ], - ), - if (!isDesktop) - SelectableText( - height, - style: isDesktop - ? STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( - color: Theme.of(context) - .extension()! - .textDark, - ) - : STextStyles.itemSubtitle12( - context), - ), - if (isDesktop) IconCopyButton(data: height), - ], - ); - }), ), if (kDebugMode) @@ -1394,16 +1483,17 @@ class _TransactionV2DetailsViewState style: isDesktop ? STextStyles .desktopTextExtraExtraSmall( - context) + context, + ) : STextStyles.itemSubtitle(context), ), SelectableText( _transaction.subType.toString(), style: isDesktop ? STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( + .desktopTextExtraExtraSmall( + context, + ).copyWith( color: Theme.of(context) .extension()! .textDark, @@ -1437,9 +1527,11 @@ class _TransactionV2DetailsViewState style: isDesktop ? STextStyles .desktopTextExtraExtraSmall( - context) + context, + ) : STextStyles.itemSubtitle( - context), + context, + ), ), const SizedBox( height: 8, @@ -1452,21 +1544,22 @@ class _TransactionV2DetailsViewState _transaction.txid, style: isDesktop ? STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( + .desktopTextExtraExtraSmall( + context, + ).copyWith( color: Theme.of(context) .extension()! .textDark, ) : STextStyles.itemSubtitle12( - context), + context, + ), ), - if (coin != Coin.epicCash) + if (coin is! Epiccash) const SizedBox( height: 8, ), - if (coin != Coin.epicCash) + if (coin is! Epiccash) CustomTextButton( text: "Open in block explorer", onTap: () async { @@ -1478,12 +1571,14 @@ class _TransactionV2DetailsViewState if (ref .read( - prefsChangeNotifierProvider) + prefsChangeNotifierProvider, + ) .hideBlockExplorerWarning == false) { final shouldContinue = await showExplorerWarning( - "${uri.scheme}://${uri.host}"); + "${uri.scheme}://${uri.host}", + ); if (!shouldContinue) { return; @@ -1544,12 +1639,12 @@ class _TransactionV2DetailsViewState ], ), ), - // if ((coin == Coin.firoTestNet || coin == Coin.firo) && + // if ((coin is FiroTestNet || coin is Firo) && // _transaction.subType == "mint") // const SizedBox( // height: 12, // ), - // if ((coin == Coin.firoTestNet || coin == Coin.firo) && + // if ((coin is FiroTestNet || coin is Firo) && // _transaction.subType == "mint") // RoundedWhiteContainer( // child: Column( @@ -1621,13 +1716,13 @@ class _TransactionV2DetailsViewState // ], // ), // ), - if (coin == Coin.epicCash) + if (coin is Epiccash) isDesktop ? const _Divider() : const SizedBox( height: 12, ), - if (coin == Coin.epicCash) + if (coin is Epiccash) RoundedWhiteContainer( padding: isDesktop ? const EdgeInsets.all(16) @@ -1646,9 +1741,11 @@ class _TransactionV2DetailsViewState style: isDesktop ? STextStyles .desktopTextExtraExtraSmall( - context) + context, + ) : STextStyles.itemSubtitle( - context), + context, + ), ), // Flexible( // child: FittedBox( @@ -1658,15 +1755,16 @@ class _TransactionV2DetailsViewState _transaction.slateId ?? "Unknown", style: isDesktop ? STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( + .desktopTextExtraExtraSmall( + context, + ).copyWith( color: Theme.of(context) .extension()! .textDark, ) : STextStyles.itemSubtitle12( - context), + context, + ), ), // ), // ), @@ -1698,7 +1796,7 @@ class _TransactionV2DetailsViewState ), ), floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, - floatingActionButton: (coin == Coin.epicCash && + floatingActionButton: (coin is Epiccash && _transaction.getConfirmations(currentHeight) < 1 && _transaction.isCancelled == false) ? ConditionalParent( @@ -1724,11 +1822,13 @@ class _TransactionV2DetailsViewState if (wallet is EpiccashWallet) { final String? id = _transaction.slateId; if (id == null) { - unawaited(showFloatingFlushBar( - type: FlushBarType.warning, - message: "Could not find Epic transaction ID", - context: context, - )); + unawaited( + showFloatingFlushBar( + type: FlushBarType.warning, + message: "Could not find Epic transaction ID", + context: context, + ), + ); return; } @@ -1773,11 +1873,13 @@ class _TransactionV2DetailsViewState } } } else { - unawaited(showFloatingFlushBar( - type: FlushBarType.warning, - message: "ERROR: Wallet type is not Epic Cash", - context: context, - )); + unawaited( + showFloatingFlushBar( + type: FlushBarType.warning, + message: "ERROR: Wallet type is not Epic Cash", + context: context, + ), + ); return; } }, @@ -1804,7 +1906,7 @@ class OutputCard extends ConsumerWidget { final String address; final Amount amount; - final Coin coin; + final CryptoCurrency coin; @override Widget build(BuildContext context, WidgetRef ref) { @@ -1847,14 +1949,14 @@ class OutputCard extends ConsumerWidget { : STextStyles.itemSubtitle12(context), ), ], - ) + ), ], ); } } class _Divider extends StatelessWidget { - const _Divider({Key? key}) : super(key: key); + const _Divider({super.key}); @override Widget build(BuildContext context) { @@ -1867,9 +1969,9 @@ class _Divider extends StatelessWidget { class IconCopyButton extends StatelessWidget { const IconCopyButton({ - Key? key, + super.key, required this.data, - }) : super(key: key); + }); final String data; @@ -1913,9 +2015,9 @@ class IconCopyButton extends StatelessWidget { class IconPencilButton extends StatelessWidget { const IconPencilButton({ - Key? key, + super.key, this.onPressed, - }) : super(key: key); + }); final VoidCallback? onPressed; diff --git a/lib/pages/wallet_view/transaction_views/tx_v2/transaction_v2_list.dart b/lib/pages/wallet_view/transaction_views/tx_v2/transaction_v2_list.dart index ac868aee9..859285eac 100644 --- a/lib/pages/wallet_view/transaction_views/tx_v2/transaction_v2_list.dart +++ b/lib/pages/wallet_view/transaction_views/tx_v2/transaction_v2_list.dart @@ -13,19 +13,19 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart'; -import 'package:stackwallet/pages/wallet_view/sub_widgets/no_transactions_found.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/fusion_tx_group_card.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/transaction_v2_list_item.dart'; -import 'package:stackwallet/pages/wallet_view/wallet_view.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/loading_indicator.dart'; +import '../../../../models/isar/models/blockchain_data/transaction.dart'; +import '../../../../models/isar/models/blockchain_data/v2/transaction_v2.dart'; +import '../../sub_widgets/no_transactions_found.dart'; +import 'fusion_tx_group_card.dart'; +import 'transaction_v2_list_item.dart'; +import '../../wallet_view.dart'; +import '../../../../providers/db/main_db_provider.dart'; +import '../../../../providers/global/wallets_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../../widgets/loading_indicator.dart'; class TransactionsV2List extends ConsumerStatefulWidget { const TransactionsV2List({ @@ -45,7 +45,7 @@ class _TransactionsV2ListState extends ConsumerState { late final StreamSubscription> _subscription; late final Query _query; - late final Coin coin; + late final CryptoCurrency coin; BorderRadius get _borderRadiusFirst { return BorderRadius.only( diff --git a/lib/pages/wallet_view/transaction_views/tx_v2/transaction_v2_list_item.dart b/lib/pages/wallet_view/transaction_views/tx_v2/transaction_v2_list_item.dart index ec5c50183..ccaae32cc 100644 --- a/lib/pages/wallet_view/transaction_views/tx_v2/transaction_v2_list_item.dart +++ b/lib/pages/wallet_view/transaction_views/tx_v2/transaction_v2_list_item.dart @@ -2,21 +2,21 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/pages/exchange_view/trade_details_view.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/fusion_tx_group_card.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/transaction_v2_card.dart'; -import 'package:stackwallet/providers/global/trades_service_provider.dart'; -import 'package:stackwallet/route_generator.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/trade_card.dart'; +import '../../../../models/isar/models/blockchain_data/v2/transaction_v2.dart'; +import '../../../../models/isar/models/isar_models.dart'; +import '../../../exchange_view/trade_details_view.dart'; +import 'fusion_tx_group_card.dart'; +import 'transaction_v2_card.dart'; +import '../../../../providers/global/trades_service_provider.dart'; +import '../../../../route_generator.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../../widgets/trade_card.dart'; import 'package:tuple/tuple.dart'; class TxListItem extends ConsumerWidget { @@ -29,7 +29,7 @@ class TxListItem extends ConsumerWidget { final Object tx; final BorderRadius? radius; - final Coin coin; + final CryptoCurrency coin; @override Widget build(BuildContext context, WidgetRef ref) { diff --git a/lib/pages/wallet_view/wallet_view.dart b/lib/pages/wallet_view/wallet_view.dart index 8abbd4d16..2f2eb334f 100644 --- a/lib/pages/wallet_view/wallet_view.dart +++ b/lib/pages/wallet_view/wallet_view.dart @@ -16,84 +16,88 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/frost_route_generator.dart'; -import 'package:stackwallet/models/isar/exchange_cache/currency.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/buy_view/buy_in_wallet_view.dart'; -import 'package:stackwallet/pages/cashfusion/cashfusion_view.dart'; -import 'package:stackwallet/pages/coin_control/coin_control_view.dart'; -import 'package:stackwallet/pages/exchange_view/wallet_initiated_exchange_view.dart'; -import 'package:stackwallet/pages/home_view/home_view.dart'; -import 'package:stackwallet/pages/monkey/monkey_view.dart'; -import 'package:stackwallet/pages/notification_views/notifications_view.dart'; -import 'package:stackwallet/pages/ordinals/ordinals_view.dart'; -import 'package:stackwallet/pages/paynym/paynym_claim_view.dart'; -import 'package:stackwallet/pages/paynym/paynym_home_view.dart'; -import 'package:stackwallet/pages/receive_view/receive_view.dart'; -import 'package:stackwallet/pages/send_view/frost_ms/frost_send_view.dart'; -import 'package:stackwallet/pages/send_view/send_view.dart'; -import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart'; -import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_settings_view.dart'; -import 'package:stackwallet/pages/special/firo_rescan_recovery_error_dialog.dart'; -import 'package:stackwallet/pages/token_view/my_tokens_view.dart'; -import 'package:stackwallet/pages/wallet_view/sub_widgets/transactions_list.dart'; -import 'package:stackwallet/pages/wallet_view/sub_widgets/wallet_summary.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/all_transactions_view.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/all_transactions_v2_view.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/transaction_v2_list.dart'; -import 'package:stackwallet/providers/global/active_wallet_provider.dart'; -import 'package:stackwallet/providers/global/auto_swb_service_provider.dart'; -import 'package:stackwallet/providers/global/paynym_api_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/providers/ui/transaction_filter_provider.dart'; -import 'package:stackwallet/providers/ui/unread_notifications_provider.dart'; -import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.dart'; -import 'package:stackwallet/services/event_bus/events/global/node_connection_status_changed_event.dart'; -import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart'; -import 'package:stackwallet/services/event_bus/global_event_bus.dart'; -import 'package:stackwallet/services/exchange/exchange_data_loading_service.dart'; -import 'package:stackwallet/themes/coin_icon_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/clipboard_interface.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/backup_frequency_type.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/sync_type_enum.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/show_loading.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/wallets/wallet/impl/bitcoin_frost_wallet.dart'; -import 'package:stackwallet/wallets/wallet/impl/firo_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/cash_fusion_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/coin_control_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/ordinals_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/custom_loading_overlay.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/frost_scaffold.dart'; -import 'package:stackwallet/widgets/loading_indicator.dart'; -import 'package:stackwallet/widgets/small_tor_icon.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; -import 'package:stackwallet/widgets/wallet_navigation_bar/components/icons/buy_nav_icon.dart'; -import 'package:stackwallet/widgets/wallet_navigation_bar/components/icons/coin_control_nav_icon.dart'; -import 'package:stackwallet/widgets/wallet_navigation_bar/components/icons/exchange_nav_icon.dart'; -import 'package:stackwallet/widgets/wallet_navigation_bar/components/icons/frost_sign_nav_icon.dart'; -import 'package:stackwallet/widgets/wallet_navigation_bar/components/icons/fusion_nav_icon.dart'; -import 'package:stackwallet/widgets/wallet_navigation_bar/components/icons/ordinals_nav_icon.dart'; -import 'package:stackwallet/widgets/wallet_navigation_bar/components/icons/paynym_nav_icon.dart'; -import 'package:stackwallet/widgets/wallet_navigation_bar/components/icons/receive_nav_icon.dart'; -import 'package:stackwallet/widgets/wallet_navigation_bar/components/icons/send_nav_icon.dart'; -import 'package:stackwallet/widgets/wallet_navigation_bar/components/wallet_navigation_bar_item.dart'; -import 'package:stackwallet/widgets/wallet_navigation_bar/wallet_navigation_bar.dart'; +import '../../frost_route_generator.dart'; +import '../../models/isar/exchange_cache/currency.dart'; +import '../../notifications/show_flush_bar.dart'; +import '../buy_view/buy_in_wallet_view.dart'; +import '../cashfusion/cashfusion_view.dart'; +import '../coin_control/coin_control_view.dart'; +import '../exchange_view/wallet_initiated_exchange_view.dart'; +import '../home_view/home_view.dart'; +import '../monkey/monkey_view.dart'; +import '../notification_views/notifications_view.dart'; +import '../ordinals/ordinals_view.dart'; +import '../paynym/paynym_claim_view.dart'; +import '../paynym/paynym_home_view.dart'; +import '../receive_view/receive_view.dart'; +import '../send_view/frost_ms/frost_send_view.dart'; +import '../send_view/send_view.dart'; +import '../settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart'; +import '../settings_views/wallet_settings_view/wallet_settings_view.dart'; +import '../special/firo_rescan_recovery_error_dialog.dart'; +import '../token_view/my_tokens_view.dart'; +import 'sub_widgets/transactions_list.dart'; +import 'sub_widgets/wallet_summary.dart'; +import 'transaction_views/all_transactions_view.dart'; +import 'transaction_views/tx_v2/all_transactions_v2_view.dart'; +import 'transaction_views/tx_v2/transaction_v2_list.dart'; +import '../../providers/global/active_wallet_provider.dart'; +import '../../providers/global/auto_swb_service_provider.dart'; +import '../../providers/global/paynym_api_provider.dart'; +import '../../providers/providers.dart'; +import '../../providers/ui/transaction_filter_provider.dart'; +import '../../providers/ui/unread_notifications_provider.dart'; +import '../../providers/wallet/my_paynym_account_state_provider.dart'; +import '../../services/event_bus/events/global/node_connection_status_changed_event.dart'; +import '../../services/event_bus/events/global/wallet_sync_status_changed_event.dart'; +import '../../services/event_bus/global_event_bus.dart'; +import '../../services/exchange/exchange_data_loading_service.dart'; +import '../../themes/coin_icon_provider.dart'; +import '../../themes/stack_colors.dart'; +import '../../themes/theme_providers.dart'; +import '../../utilities/amount/amount.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/clipboard_interface.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/enums/backup_frequency_type.dart'; +import '../../utilities/enums/sync_type_enum.dart'; +import '../../utilities/logger.dart'; +import '../../utilities/show_loading.dart'; +import '../../utilities/text_styles.dart'; +import '../../wallets/crypto_currency/coins/banano.dart'; +import '../../wallets/crypto_currency/coins/bitcoin.dart'; +import '../../wallets/crypto_currency/coins/firo.dart'; +import '../../wallets/crypto_currency/crypto_currency.dart'; +import '../../wallets/crypto_currency/intermediate/frost_currency.dart'; +import '../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../wallets/wallet/impl/bitcoin_frost_wallet.dart'; +import '../../wallets/wallet/impl/firo_wallet.dart'; +import '../../wallets/wallet/wallet_mixin_interfaces/cash_fusion_interface.dart'; +import '../../wallets/wallet/wallet_mixin_interfaces/coin_control_interface.dart'; +import '../../wallets/wallet/wallet_mixin_interfaces/ordinals_interface.dart'; +import '../../wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart'; +import '../../wallets/wallet/wallet_mixin_interfaces/spark_interface.dart'; +import '../../widgets/background.dart'; +import '../../widgets/conditional_parent.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/custom_buttons/blue_text_button.dart'; +import '../../widgets/custom_loading_overlay.dart'; +import '../../widgets/desktop/secondary_button.dart'; +import '../../widgets/frost_scaffold.dart'; +import '../../widgets/loading_indicator.dart'; +import '../../widgets/small_tor_icon.dart'; +import '../../widgets/stack_dialog.dart'; +import '../../widgets/wallet_navigation_bar/components/icons/buy_nav_icon.dart'; +import '../../widgets/wallet_navigation_bar/components/icons/coin_control_nav_icon.dart'; +import '../../widgets/wallet_navigation_bar/components/icons/exchange_nav_icon.dart'; +import '../../widgets/wallet_navigation_bar/components/icons/frost_sign_nav_icon.dart'; +import '../../widgets/wallet_navigation_bar/components/icons/fusion_nav_icon.dart'; +import '../../widgets/wallet_navigation_bar/components/icons/ordinals_nav_icon.dart'; +import '../../widgets/wallet_navigation_bar/components/icons/paynym_nav_icon.dart'; +import '../../widgets/wallet_navigation_bar/components/icons/receive_nav_icon.dart'; +import '../../widgets/wallet_navigation_bar/components/icons/send_nav_icon.dart'; +import '../../widgets/wallet_navigation_bar/components/wallet_navigation_bar_item.dart'; +import '../../widgets/wallet_navigation_bar/wallet_navigation_bar.dart'; import 'package:tuple/tuple.dart'; /// [eventBus] should only be set during testing @@ -120,7 +124,7 @@ class WalletView extends ConsumerStatefulWidget { class _WalletViewState extends ConsumerState { late final EventBus eventBus; late final String walletId; - late final Coin coin; + late final CryptoCurrency coin; late final bool isSparkWallet; @@ -184,8 +188,7 @@ class _WalletViewState extends ConsumerState { isSparkWallet = wallet is SparkInterface; - if (coin == Coin.firo && - (wallet as FiroWallet).lelantusCoinIsarRescanRequired) { + if (coin is Firo && (wallet as FiroWallet).lelantusCoinIsarRescanRequired) { _rescanningOnOpen = true; _lelantusRescanRecovery = true; _firoRescanRecovery(); @@ -384,9 +387,9 @@ class _WalletViewState extends ConsumerState { } Future _onExchangePressed(BuildContext context) async { - final Coin coin = ref.read(pWalletCoin(walletId)); + final CryptoCurrency coin = ref.read(pWalletCoin(walletId)); - if (coin.isTestNet) { + if (coin.network == CryptoCurrencyNetwork.test) { await showDialog( context: context, builder: (_) => const StackOkDialog( @@ -421,7 +424,7 @@ class _WalletViewState extends ConsumerState { WalletInitiatedExchangeView.routeName, arguments: Tuple2( walletId, - currency == null ? Coin.bitcoin : coin, + currency == null ? Bitcoin(CryptoCurrencyNetwork.main) : coin, ), ), ); @@ -430,9 +433,9 @@ class _WalletViewState extends ConsumerState { } Future _onBuyPressed(BuildContext context) async { - final Coin coin = ref.read(pWalletCoin(walletId)); + final CryptoCurrency coin = ref.read(pWalletCoin(walletId)); - if (coin.isTestNet) { + if (coin.network == CryptoCurrencyNetwork.test) { await showDialog( context: context, builder: (_) => const StackOkDialog( @@ -444,7 +447,8 @@ class _WalletViewState extends ConsumerState { unawaited( Navigator.of(context).pushNamed( BuyInWalletView.routeName, - arguments: coin.hasBuySupport ? coin : Coin.bitcoin, + arguments: + coin.hasBuySupport ? coin : Bitcoin(CryptoCurrencyNetwork.main), ), ); } @@ -1020,7 +1024,7 @@ class _WalletViewState extends ConsumerState { } }, ), - if (ref.watch(pWalletCoin(walletId)).isFrost) + if (ref.watch(pWalletCoin(walletId)) is FrostCurrency) WalletNavigationBarItemData( label: "Sign", icon: const FrostSignNavIcon(), @@ -1058,14 +1062,14 @@ class _WalletViewState extends ConsumerState { }, ), if (Constants.enableExchange && - !ref.watch(pWalletCoin(walletId)).isFrost) + ref.watch(pWalletCoin(walletId)) is! FrostCurrency) WalletNavigationBarItemData( label: "Swap", icon: const ExchangeNavIcon(), onTap: () => _onExchangePressed(context), ), if (Constants.enableExchange && - !ref.watch(pWalletCoin(walletId)).isFrost) + ref.watch(pWalletCoin(walletId)) is! FrostCurrency) WalletNavigationBarItemData( label: "Buy", icon: const BuyNavIcon(), @@ -1091,7 +1095,7 @@ class _WalletViewState extends ConsumerState { ); }, ), - if (coin == Coin.banano) + if (coin is Banano) WalletNavigationBarItemData( icon: SvgPicture.asset( Assets.svg.monkey, diff --git a/lib/pages/wallets_view/sub_widgets/all_wallets.dart b/lib/pages/wallets_view/sub_widgets/all_wallets.dart index 9f12d367d..a69d2bd13 100644 --- a/lib/pages/wallets_view/sub_widgets/all_wallets.dart +++ b/lib/pages/wallets_view/sub_widgets/all_wallets.dart @@ -10,12 +10,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/pages/add_wallet_views/add_wallet_view/add_wallet_view.dart'; -import 'package:stackwallet/pages/wallets_view/sub_widgets/wallet_list_item.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/all_wallets_info_provider.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; +import '../../add_wallet_views/add_wallet_view/add_wallet_view.dart'; +import 'wallet_list_item.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../wallets/isar/providers/all_wallets_info_provider.dart'; +import '../../../widgets/custom_buttons/blue_text_button.dart'; class AllWallets extends StatelessWidget { const AllWallets({Key? key}) : super(key: key); diff --git a/lib/pages/wallets_view/sub_widgets/empty_wallets.dart b/lib/pages/wallets_view/sub_widgets/empty_wallets.dart index c4e89c720..530c27e54 100644 --- a/lib/pages/wallets_view/sub_widgets/empty_wallets.dart +++ b/lib/pages/wallets_view/sub_widgets/empty_wallets.dart @@ -13,12 +13,12 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/pages/add_wallet_views/add_wallet_view/add_wallet_view.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; +import '../../add_wallet_views/add_wallet_view/add_wallet_view.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../themes/theme_providers.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; class EmptyWallets extends ConsumerWidget { const EmptyWallets({Key? key}) : super(key: key); diff --git a/lib/pages/wallets_view/sub_widgets/favorite_card.dart b/lib/pages/wallets_view/sub_widgets/favorite_card.dart index 4ef59bf0b..6f3dd84bb 100644 --- a/lib/pages/wallets_view/sub_widgets/favorite_card.dart +++ b/lib/pages/wallets_view/sub_widgets/favorite_card.dart @@ -13,30 +13,30 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/pages/wallet_view/wallet_view.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/desktop_wallet_view.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/coin_icon_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/show_loading.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/cw_based_interface.dart'; -import 'package:stackwallet/widgets/coin_card.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; +import '../../wallet_view/wallet_view.dart'; +import '../../../pages_desktop_specific/my_stack_view/wallet_view/desktop_wallet_view.dart'; +import '../../../providers/providers.dart'; +import '../../../themes/coin_icon_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/amount/amount_formatter.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/show_loading.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../wallets/crypto_currency/coins/firo.dart'; +import '../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../wallets/wallet/wallet_mixin_interfaces/cw_based_interface.dart'; +import '../../../widgets/coin_card.dart'; +import '../../../widgets/conditional_parent.dart'; class FavoriteCard extends ConsumerStatefulWidget { const FavoriteCard({ - Key? key, + super.key, required this.walletId, required this.width, required this.height, - }) : super(key: key); + }); final String walletId; final double width; @@ -192,7 +192,7 @@ class _FavoriteCardState extends ConsumerState { ); Amount total = balance.total; - if (coin == Coin.firo || coin == Coin.firoTestNet) { + if (coin is Firo) { total += ref .watch( pWalletBalanceSecondary(walletId), diff --git a/lib/pages/wallets_view/sub_widgets/favorite_wallets.dart b/lib/pages/wallets_view/sub_widgets/favorite_wallets.dart index d43eda2a2..b46e84b87 100644 --- a/lib/pages/wallets_view/sub_widgets/favorite_wallets.dart +++ b/lib/pages/wallets_view/sub_widgets/favorite_wallets.dart @@ -13,14 +13,14 @@ import 'dart:ui'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/pages/manage_favorites_view/manage_favorites_view.dart'; -import 'package:stackwallet/pages/wallets_view/sub_widgets/favorite_card.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/favourite_wallets_provider.dart'; -import 'package:stackwallet/widgets/custom_page_view/custom_page_view.dart' +import '../../manage_favorites_view/manage_favorites_view.dart'; +import 'favorite_card.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../wallets/isar/providers/favourite_wallets_provider.dart'; +import '../../../widgets/custom_page_view/custom_page_view.dart' as cpv; class FavoriteWallets extends ConsumerStatefulWidget { diff --git a/lib/pages/wallets_view/sub_widgets/wallet_list_item.dart b/lib/pages/wallets_view/sub_widgets/wallet_list_item.dart index a708267a9..d7ec6037b 100644 --- a/lib/pages/wallets_view/sub_widgets/wallet_list_item.dart +++ b/lib/pages/wallets_view/sub_widgets/wallet_list_item.dart @@ -14,30 +14,30 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/pages/wallet_view/wallet_view.dart'; -import 'package:stackwallet/pages/wallets_view/wallets_overview.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/supported_coins.dart'; -import 'package:stackwallet/themes/coin_icon_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/show_loading.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/cw_based_interface.dart'; -import 'package:stackwallet/widgets/dialogs/tor_warning_dialog.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../wallet_view/wallet_view.dart'; +import '../wallets_overview.dart'; +import '../../../providers/providers.dart'; +import '../../../themes/coin_icon_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/show_loading.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../wallets/crypto_currency/coins/ethereum.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../wallets/wallet/wallet_mixin_interfaces/cw_based_interface.dart'; +import '../../../widgets/dialogs/tor_warning_dialog.dart'; +import '../../../widgets/rounded_white_container.dart'; class WalletListItem extends ConsumerWidget { const WalletListItem({ - Key? key, + super.key, required this.coin, required this.walletCount, - }) : super(key: key); + }); - final Coin coin; + final CryptoCurrency coin; final int walletCount; @override @@ -52,7 +52,7 @@ class WalletListItem extends ConsumerWidget { padding: const EdgeInsets.all(0), child: MaterialButton( // splashColor: Theme.of(context).extension()!.highlight, - key: Key("walletListItemButtonKey_${coin.name}"), + key: Key("walletListItemButtonKey_${coin.identifier}"), padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 13), materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, shape: RoundedRectangleBorder( @@ -63,8 +63,7 @@ class WalletListItem extends ConsumerWidget { // Check if Tor is enabled... if (ref.read(prefsChangeNotifierProvider).useTor) { // ... and if the coin supports Tor. - final cryptocurrency = SupportedCoins.getCryptoCurrencyFor(coin); - if (!cryptocurrency.torSupport) { + if (!coin.torSupport) { // If not, show a Tor warning dialog. final shouldContinue = await showDialog( context: context, @@ -79,7 +78,7 @@ class WalletListItem extends ConsumerWidget { } } - if (walletCount == 1 && coin != Coin.ethereum) { + if (walletCount == 1 && coin is! Ethereum) { final wallet = ref .read(pWallets) .wallets diff --git a/lib/pages/wallets_view/wallets_overview.dart b/lib/pages/wallets_view/wallets_overview.dart index 0f6cef1a6..ebd4931f7 100644 --- a/lib/pages/wallets_view/wallets_overview.dart +++ b/lib/pages/wallets_view/wallets_overview.dart @@ -12,40 +12,41 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/add_wallet_list_entity/sub_classes/coin_entity.dart'; -import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart'; -import 'package:stackwallet/pages/add_wallet_views/create_or_restore_wallet_view/create_or_restore_wallet_view.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/dialogs/desktop_expanding_wallet_card.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/models/wallet_info.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/wallets/wallet/wallet.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/master_wallet_card.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; -import 'package:stackwallet/widgets/wallet_card.dart'; +import '../../models/add_wallet_list_entity/sub_classes/coin_entity.dart'; +import '../../models/isar/models/ethereum/eth_contract.dart'; +import '../add_wallet_views/create_or_restore_wallet_view/create_or_restore_wallet_view.dart'; +import '../../pages_desktop_specific/my_stack_view/dialogs/desktop_expanding_wallet_card.dart'; +import '../../providers/db/main_db_provider.dart'; +import '../../providers/providers.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import '../../wallets/crypto_currency/coins/ethereum.dart'; +import '../../wallets/crypto_currency/crypto_currency.dart'; +import '../../wallets/isar/models/wallet_info.dart'; +import '../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../wallets/wallet/wallet.dart'; +import '../../widgets/background.dart'; +import '../../widgets/conditional_parent.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/icon_widgets/x_icon.dart'; +import '../../widgets/master_wallet_card.dart'; +import '../../widgets/rounded_white_container.dart'; +import '../../widgets/stack_text_field.dart'; +import '../../widgets/textfield_icon_button.dart'; +import '../../widgets/wallet_card.dart'; import 'package:tuple/tuple.dart'; class WalletsOverview extends ConsumerStatefulWidget { const WalletsOverview({ - Key? key, + super.key, required this.coin, this.navigatorState, - }) : super(key: key); + }); - final Coin coin; + final CryptoCurrency coin; final NavigatorState? navigatorState; static const routeName = "/walletsOverview"; @@ -116,7 +117,7 @@ class _EthWalletsOverviewState extends ConsumerState { ref.read(mainDBProvider).isar.walletInfo.where().findAllSync(); walletsData.removeWhere((e) => e.coin != widget.coin); - if (widget.coin == Coin.ethereum) { + if (widget.coin is Ethereum) { for (final data in walletsData) { final List contracts = []; final contractAddresses = diff --git a/lib/pages/wallets_view/wallets_view.dart b/lib/pages/wallets_view/wallets_view.dart index be33af927..76298c595 100644 --- a/lib/pages/wallets_view/wallets_view.dart +++ b/lib/pages/wallets_view/wallets_view.dart @@ -11,12 +11,12 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/pages/wallets_view/sub_widgets/all_wallets.dart'; -import 'package:stackwallet/pages/wallets_view/sub_widgets/empty_wallets.dart'; -import 'package:stackwallet/pages/wallets_view/sub_widgets/favorite_wallets.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/wallets/isar/providers/all_wallets_info_provider.dart'; +import 'sub_widgets/all_wallets.dart'; +import 'sub_widgets/empty_wallets.dart'; +import 'sub_widgets/favorite_wallets.dart'; +import '../../providers/providers.dart'; +import '../../themes/theme_providers.dart'; +import '../../wallets/isar/providers/all_wallets_info_provider.dart'; class WalletsView extends ConsumerWidget { const WalletsView({Key? key}) : super(key: key); diff --git a/lib/pages_desktop_specific/address_book_view/desktop_address_book.dart b/lib/pages_desktop_specific/address_book_view/desktop_address_book.dart index aba315c64..af09985df 100644 --- a/lib/pages_desktop_specific/address_book_view/desktop_address_book.dart +++ b/lib/pages_desktop_specific/address_book_view/desktop_address_book.dart @@ -1,4 +1,4 @@ -/* +/* * This file is part of Stack Wallet. * * Copyright (c) 2023 Cypher Stack @@ -11,34 +11,36 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/models/isar/models/contact_entry.dart'; -import 'package:stackwallet/pages/address_book_views/subviews/add_address_book_entry_view.dart'; -import 'package:stackwallet/pages/address_book_views/subviews/address_book_filter_view.dart'; -import 'package:stackwallet/pages_desktop_specific/address_book_view/subwidgets/desktop_address_book_scaffold.dart'; -import 'package:stackwallet/pages_desktop_specific/address_book_view/subwidgets/desktop_contact_details.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/global/address_book_service_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/providers/ui/address_book_providers/address_book_filter_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart'; -import 'package:stackwallet/widgets/address_book_card.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../app_config.dart'; +import '../../models/isar/models/blockchain_data/address.dart'; +import '../../models/isar/models/contact_entry.dart'; +import '../../pages/address_book_views/subviews/add_address_book_entry_view.dart'; +import '../../pages/address_book_views/subviews/address_book_filter_view.dart'; +import 'subwidgets/desktop_address_book_scaffold.dart'; +import 'subwidgets/desktop_contact_details.dart'; +import '../../providers/db/main_db_provider.dart'; +import '../../providers/global/address_book_service_provider.dart'; +import '../../providers/providers.dart'; +import '../../providers/ui/address_book_providers/address_book_filter_provider.dart'; +import '../../app_config.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import '../../wallets/crypto_currency/crypto_currency.dart'; +import '../../wallets/wallet/wallet_mixin_interfaces/spark_interface.dart'; +import '../../widgets/address_book_card.dart'; +import '../../widgets/desktop/desktop_app_bar.dart'; +import '../../widgets/desktop/desktop_dialog.dart'; +import '../../widgets/desktop/desktop_scaffold.dart'; +import '../../widgets/desktop/primary_button.dart'; +import '../../widgets/desktop/secondary_button.dart'; +import '../../widgets/icon_widgets/x_icon.dart'; +import '../../widgets/rounded_container.dart'; +import '../../widgets/rounded_white_container.dart'; +import '../../widgets/stack_text_field.dart'; +import '../../widgets/textfield_icon_button.dart'; class DesktopAddressBook extends ConsumerStatefulWidget { const DesktopAddressBook({super.key}); @@ -96,8 +98,10 @@ class _DesktopAddressBook extends ConsumerState { ref.refresh(addressBookFilterProvider); // if (widget.coin == null) { - final List coins = Coin.values.toList(); - coins.remove(Coin.firoTestNet); + final coins = AppConfig.coins.toList(); + coins.removeWhere( + (e) => e is Firo && e.network == CryptoCurrencyNetwork.test, + ); final bool showTestNet = ref.read(prefsChangeNotifierProvider).showTestNetCoins; @@ -105,9 +109,10 @@ class _DesktopAddressBook extends ConsumerState { if (showTestNet) { ref.read(addressBookFilterProvider).addAll(coins, false); } else { - ref - .read(addressBookFilterProvider) - .addAll(coins.where((e) => !e.isTestNet), false); + ref.read(addressBookFilterProvider).addAll( + coins.where((e) => e.network != CryptoCurrencyNetwork.test), + false, + ); } // } else { // ref.read(addressBookFilterProvider).add(widget.coin!, false); @@ -132,14 +137,14 @@ class _DesktopAddressBook extends ConsumerState { addresses.add( ContactAddressEntry() - ..coinName = wallet.info.coin.name + ..coinName = wallet.info.coin.identifier ..address = addressString ..label = "Current Receiving" ..other = wallet.info.name, ); } final self = ContactEntry( - name: "My Stack", + name: "My ${AppConfig.prefix}", addresses: addresses, isFavorite: true, customId: "default", diff --git a/lib/pages_desktop_specific/address_book_view/subwidgets/desktop_address_card.dart b/lib/pages_desktop_specific/address_book_view/subwidgets/desktop_address_card.dart index 13cdc24e4..509653aba 100644 --- a/lib/pages_desktop_specific/address_book_view/subwidgets/desktop_address_card.dart +++ b/lib/pages_desktop_specific/address_book_view/subwidgets/desktop_address_card.dart @@ -14,19 +14,19 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/models/isar/models/contact_entry.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/address_book_views/subviews/edit_contact_address_view.dart'; -import 'package:stackwallet/providers/ui/address_book_providers/address_entry_data_provider.dart'; -import 'package:stackwallet/themes/coin_icon_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/clipboard_interface.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; +import '../../../models/isar/models/contact_entry.dart'; +import '../../../notifications/show_flush_bar.dart'; +import '../../../pages/address_book_views/subviews/edit_contact_address_view.dart'; +import '../../../providers/ui/address_book_providers/address_entry_data_provider.dart'; +import '../../../themes/coin_icon_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/clipboard_interface.dart'; + +import '../../../utilities/text_styles.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/custom_buttons/blue_text_button.dart'; +import '../../../widgets/desktop/desktop_dialog.dart'; class DesktopAddressCard extends ConsumerWidget { const DesktopAddressCard({ diff --git a/lib/pages_desktop_specific/address_book_view/subwidgets/desktop_contact_details.dart b/lib/pages_desktop_specific/address_book_view/subwidgets/desktop_contact_details.dart index 4ce624db2..d38d171d3 100644 --- a/lib/pages_desktop_specific/address_book_view/subwidgets/desktop_contact_details.dart +++ b/lib/pages_desktop_specific/address_book_view/subwidgets/desktop_contact_details.dart @@ -8,38 +8,37 @@ * */ -import 'dart:io'; - import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/isar/models/contact_entry.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/pages/address_book_views/subviews/add_new_contact_address_view.dart'; -import 'package:stackwallet/pages_desktop_specific/address_book_view/subwidgets/desktop_address_card.dart'; -import 'package:stackwallet/pages_desktop_specific/address_book_view/subwidgets/desktop_contact_options_menu_popup.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/global/address_book_service_provider.dart'; -import 'package:stackwallet/providers/ui/address_book_providers/address_entry_data_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/loading_indicator.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/transaction_card.dart'; import 'package:tuple/tuple.dart'; +import '../../../models/isar/models/contact_entry.dart'; +import '../../../models/isar/models/isar_models.dart'; +import '../../../pages/address_book_views/subviews/add_new_contact_address_view.dart'; +import '../../../providers/db/main_db_provider.dart'; +import '../../../providers/global/address_book_service_provider.dart'; +import '../../../providers/ui/address_book_providers/address_entry_data_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../widgets/app_icon.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/custom_buttons/blue_text_button.dart'; +import '../../../widgets/desktop/desktop_dialog.dart'; +import '../../../widgets/desktop/secondary_button.dart'; +import '../../../widgets/loading_indicator.dart'; +import '../../../widgets/rounded_white_container.dart'; +import '../../../widgets/transaction_card.dart'; +import 'desktop_address_card.dart'; +import 'desktop_contact_options_menu_popup.dart'; + class DesktopContactDetails extends ConsumerStatefulWidget { const DesktopContactDetails({ - Key? key, + super.key, required this.contactId, - }) : super(key: key); + }); final String contactId; @@ -120,15 +119,8 @@ class _DesktopContactDetailsState extends ConsumerState { borderRadius: BorderRadius.circular(32), ), child: contact.customId == "default" - ? Center( - child: SvgPicture.file( - File( - ref.watch( - themeProvider.select( - (value) => value.assets.stackIcon, - ), - ), - ), + ? const Center( + child: AppIcon( width: 32, ), ) diff --git a/lib/pages_desktop_specific/address_book_view/subwidgets/desktop_contact_options_menu_popup.dart b/lib/pages_desktop_specific/address_book_view/subwidgets/desktop_contact_options_menu_popup.dart index fff2c337c..61b0de815 100644 --- a/lib/pages_desktop_specific/address_book_view/subwidgets/desktop_contact_options_menu_popup.dart +++ b/lib/pages_desktop_specific/address_book_view/subwidgets/desktop_contact_options_menu_popup.dart @@ -11,16 +11,16 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/address_book_views/subviews/edit_contact_name_emoji_view.dart'; -import 'package:stackwallet/providers/global/address_book_service_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; +import '../../../notifications/show_flush_bar.dart'; +import '../../../pages/address_book_views/subviews/edit_contact_name_emoji_view.dart'; +import '../../../providers/global/address_book_service_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../widgets/desktop/desktop_dialog.dart'; +import '../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../widgets/desktop/primary_button.dart'; +import '../../../widgets/desktop/secondary_button.dart'; class DesktopContactOptionsMenuPopup extends ConsumerStatefulWidget { const DesktopContactOptionsMenuPopup({Key? key, required this.contactId}) diff --git a/lib/pages_desktop_specific/addresses/desktop_wallet_addresses_view.dart b/lib/pages_desktop_specific/addresses/desktop_wallet_addresses_view.dart index d9e9c2763..cf6c7c424 100644 --- a/lib/pages_desktop_specific/addresses/desktop_wallet_addresses_view.dart +++ b/lib/pages_desktop_specific/addresses/desktop_wallet_addresses_view.dart @@ -12,16 +12,16 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/pages/receive_view/addresses/address_details_view.dart'; -import 'package:stackwallet/pages_desktop_specific/addresses/sub_widgets/desktop_address_list.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; +import '../../models/isar/models/isar_models.dart'; +import '../../pages/receive_view/addresses/address_details_view.dart'; +import 'sub_widgets/desktop_address_list.dart'; +import '../../providers/db/main_db_provider.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/text_styles.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/desktop/desktop_app_bar.dart'; +import '../../widgets/desktop/desktop_scaffold.dart'; final desktopSelectedAddressId = StateProvider.autoDispose((ref) => null); diff --git a/lib/pages_desktop_specific/addresses/sub_widgets/desktop_address_list.dart b/lib/pages_desktop_specific/addresses/sub_widgets/desktop_address_list.dart index 7b94575b4..3da33f220 100644 --- a/lib/pages_desktop_specific/addresses/sub_widgets/desktop_address_list.dart +++ b/lib/pages_desktop_specific/addresses/sub_widgets/desktop_address_list.dart @@ -12,20 +12,20 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/pages/receive_view/addresses/address_card.dart'; -import 'package:stackwallet/pages_desktop_specific/addresses/desktop_wallet_addresses_view.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../../models/isar/models/isar_models.dart'; +import '../../../pages/receive_view/addresses/address_card.dart'; +import '../desktop_wallet_addresses_view.dart'; +import '../../../providers/db/main_db_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../widgets/icon_widgets/x_icon.dart'; +import '../../../widgets/rounded_white_container.dart'; +import '../../../widgets/stack_text_field.dart'; +import '../../../widgets/textfield_icon_button.dart'; class DesktopAddressList extends ConsumerStatefulWidget { const DesktopAddressList({ diff --git a/lib/pages_desktop_specific/cashfusion/desktop_cashfusion_view.dart b/lib/pages_desktop_specific/cashfusion/desktop_cashfusion_view.dart index e8aa2436a..9d674c585 100644 --- a/lib/pages_desktop_specific/cashfusion/desktop_cashfusion_view.dart +++ b/lib/pages_desktop_specific/cashfusion/desktop_cashfusion_view.dart @@ -17,27 +17,27 @@ import 'package:flutter/services.dart'; import 'package:flutter_native_splash/cli_commands.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/pages/cashfusion/fusion_rounds_selection_sheet.dart'; -import 'package:stackwallet/pages_desktop_specific/cashfusion/sub_widgets/fusion_dialog.dart'; -import 'package:stackwallet/providers/cash_fusion/fusion_progress_ui_state_provider.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/cash_fusion_interface.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; +import '../../pages/cashfusion/fusion_rounds_selection_sheet.dart'; +import 'sub_widgets/fusion_dialog.dart'; +import '../../providers/cash_fusion/fusion_progress_ui_state_provider.dart'; +import '../../providers/global/prefs_provider.dart'; +import '../../providers/global/wallets_provider.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/text_styles.dart'; +import '../../wallets/crypto_currency/crypto_currency.dart'; +import '../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../wallets/wallet/wallet_mixin_interfaces/cash_fusion_interface.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/custom_buttons/blue_text_button.dart'; +import '../../widgets/desktop/desktop_app_bar.dart'; +import '../../widgets/desktop/desktop_dialog.dart'; +import '../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../widgets/desktop/desktop_scaffold.dart'; +import '../../widgets/desktop/primary_button.dart'; +import '../../widgets/rounded_white_container.dart'; +import '../../widgets/stack_text_field.dart'; class DesktopCashFusionView extends ConsumerStatefulWidget { const DesktopCashFusionView({ @@ -60,7 +60,7 @@ class _DesktopCashFusion extends ConsumerState { late final FocusNode portFocusNode; late final TextEditingController fusionRoundController; late final FocusNode fusionRoundFocusNode; - late final Coin coin; + late final CryptoCurrency coin; bool _enableStartButton = false; bool _enableSSLCheckbox = false; diff --git a/lib/pages_desktop_specific/cashfusion/sub_widgets/fusion_dialog.dart b/lib/pages_desktop_specific/cashfusion/sub_widgets/fusion_dialog.dart index 6d4225fab..437c61a55 100644 --- a/lib/pages_desktop_specific/cashfusion/sub_widgets/fusion_dialog.dart +++ b/lib/pages_desktop_specific/cashfusion/sub_widgets/fusion_dialog.dart @@ -2,22 +2,22 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/pages_desktop_specific/cashfusion/sub_widgets/fusion_progress.dart'; -import 'package:stackwallet/providers/cash_fusion/fusion_progress_ui_state_provider.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/show_loading.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/cash_fusion_interface.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import 'fusion_progress.dart'; +import '../../../providers/cash_fusion/fusion_progress_ui_state_provider.dart'; +import '../../../providers/global/prefs_provider.dart'; +import '../../../providers/global/wallets_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/show_loading.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../wallets/wallet/wallet_mixin_interfaces/cash_fusion_interface.dart'; +import '../../../widgets/desktop/desktop_dialog.dart'; +import '../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../widgets/desktop/primary_button.dart'; +import '../../../widgets/desktop/secondary_button.dart'; +import '../../../widgets/rounded_container.dart'; +import '../../../widgets/rounded_white_container.dart'; enum CashFusionStatus { waiting, running, success, failed } @@ -30,9 +30,9 @@ class CashFusionState { class FusionDialogView extends ConsumerStatefulWidget { const FusionDialogView({ - Key? key, + super.key, required this.walletId, - }) : super(key: key); + }); final String walletId; @@ -41,13 +41,13 @@ class FusionDialogView extends ConsumerStatefulWidget { } class _FusionDialogViewState extends ConsumerState { - late final Coin coin; + late final CryptoCurrency coin; Future _requestAndProcessCancel() async { if (!ref.read(fusionProgressUIStateProvider(widget.walletId)).running) { return true; } else { - bool? shouldCancel = await showDialog( + final bool? shouldCancel = await showDialog( context: context, barrierDismissible: false, builder: (_) => DesktopDialog( diff --git a/lib/pages_desktop_specific/cashfusion/sub_widgets/fusion_progress.dart b/lib/pages_desktop_specific/cashfusion/sub_widgets/fusion_progress.dart index a976c225d..8487ce863 100644 --- a/lib/pages_desktop_specific/cashfusion/sub_widgets/fusion_progress.dart +++ b/lib/pages_desktop_specific/cashfusion/sub_widgets/fusion_progress.dart @@ -1,15 +1,15 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/sub_widgets/restoring_item_card.dart'; -import 'package:stackwallet/pages_desktop_specific/cashfusion/sub_widgets/fusion_dialog.dart'; -import 'package:stackwallet/providers/cash_fusion/fusion_progress_ui_state_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; +import '../../../pages/settings_views/global_settings_view/stack_backup_views/sub_widgets/restoring_item_card.dart'; +import 'fusion_dialog.dart'; +import '../../../providers/cash_fusion/fusion_progress_ui_state_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../widgets/conditional_parent.dart'; +import '../../../widgets/rounded_container.dart'; class FusionProgress extends ConsumerWidget { const FusionProgress({super.key, required this.walletId}); diff --git a/lib/pages_desktop_specific/coin_control/desktop_coin_control_use_dialog.dart b/lib/pages_desktop_specific/coin_control/desktop_coin_control_use_dialog.dart index 3ef549e83..a76851278 100644 --- a/lib/pages_desktop_specific/coin_control/desktop_coin_control_use_dialog.dart +++ b/lib/pages_desktop_specific/coin_control/desktop_coin_control_use_dialog.dart @@ -14,39 +14,39 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/db/isar/main_db.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/utxo.dart'; -import 'package:stackwallet/pages_desktop_specific/coin_control/utxo_row.dart'; -import 'package:stackwallet/themes/coin_icon_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/widgets/animated_widgets/rotate_icon.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/dropdown_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/expandable2.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; -import 'package:stackwallet/widgets/toggle.dart'; +import '../../db/isar/main_db.dart'; +import '../../models/isar/models/blockchain_data/utxo.dart'; +import 'utxo_row.dart'; +import '../../themes/coin_icon_provider.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/amount/amount.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/text_styles.dart'; +import '../../wallets/crypto_currency/crypto_currency.dart'; +import '../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../widgets/animated_widgets/rotate_icon.dart'; +import '../../widgets/conditional_parent.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/custom_buttons/dropdown_button.dart'; +import '../../widgets/desktop/desktop_dialog.dart'; +import '../../widgets/desktop/primary_button.dart'; +import '../../widgets/desktop/secondary_button.dart'; +import '../../widgets/expandable2.dart'; +import '../../widgets/icon_widgets/x_icon.dart'; +import '../../widgets/rounded_container.dart'; +import '../../widgets/stack_text_field.dart'; +import '../../widgets/textfield_icon_button.dart'; +import '../../widgets/toggle.dart'; final desktopUseUTXOs = StateProvider((ref) => {}); class DesktopCoinControlUseDialog extends ConsumerStatefulWidget { const DesktopCoinControlUseDialog({ - Key? key, + super.key, required this.walletId, this.amountToSend, - }) : super(key: key); + }); final String walletId; final Amount? amountToSend; @@ -59,7 +59,7 @@ class DesktopCoinControlUseDialog extends ConsumerStatefulWidget { class _DesktopCoinControlUseDialogState extends ConsumerState { late final TextEditingController _searchController; - late final Coin coin; + late final CryptoCurrency coin; final searchFieldFocusNode = FocusNode(); final Set _selectedUTXOsData = {}; @@ -110,7 +110,7 @@ class _DesktopCoinControlUseDialogState filter: _filter, sort: _sort, searchTerm: _searchString, - coin: coin, + cryptoCurrency: coin, ); } else { _map = null; @@ -119,18 +119,18 @@ class _DesktopCoinControlUseDialogState filter: _filter, sort: _sort, searchTerm: _searchString, - coin: coin, + cryptoCurrency: coin, ); } final Amount selectedSum = _selectedUTXOs.map((e) => e.value).fold( Amount( rawValue: BigInt.zero, - fractionDigits: coin.decimals, + fractionDigits: coin.fractionDigits, ), (value, element) => value += Amount( rawValue: BigInt.from(element), - fractionDigits: coin.decimals, + fractionDigits: coin.fractionDigits, ), ); @@ -486,7 +486,7 @@ class _DesktopCoinControlUseDialogState ), Text( "${widget.amountToSend!.decimal.toStringAsFixed( - coin.decimals, + coin.fractionDigits, )}" " ${coin.ticker}", style: @@ -521,7 +521,7 @@ class _DesktopCoinControlUseDialogState ), Text( "${selectedSum.decimal.toStringAsFixed( - coin.decimals, + coin.fractionDigits, )} ${coin.ticker}", style: STextStyles.desktopTextExtraExtraSmall( context) diff --git a/lib/pages_desktop_specific/coin_control/desktop_coin_control_view.dart b/lib/pages_desktop_specific/coin_control/desktop_coin_control_view.dart index 2b58652a7..957cfacdb 100644 --- a/lib/pages_desktop_specific/coin_control/desktop_coin_control_view.dart +++ b/lib/pages_desktop_specific/coin_control/desktop_coin_control_view.dart @@ -14,28 +14,28 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/db/isar/main_db.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/utxo.dart'; -import 'package:stackwallet/pages_desktop_specific/coin_control/freeze_button.dart'; -import 'package:stackwallet/pages_desktop_specific/coin_control/utxo_row.dart'; -import 'package:stackwallet/themes/coin_icon_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/widgets/animated_widgets/rotate_icon.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/dropdown_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/expandable2.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../db/isar/main_db.dart'; +import '../../models/isar/models/blockchain_data/utxo.dart'; +import 'freeze_button.dart'; +import 'utxo_row.dart'; +import '../../themes/coin_icon_provider.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/text_styles.dart'; +import '../../wallets/crypto_currency/crypto_currency.dart'; +import '../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../widgets/animated_widgets/rotate_icon.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/custom_buttons/dropdown_button.dart'; +import '../../widgets/desktop/desktop_app_bar.dart'; +import '../../widgets/desktop/desktop_scaffold.dart'; +import '../../widgets/desktop/secondary_button.dart'; +import '../../widgets/expandable2.dart'; +import '../../widgets/icon_widgets/x_icon.dart'; +import '../../widgets/rounded_container.dart'; +import '../../widgets/stack_text_field.dart'; +import '../../widgets/textfield_icon_button.dart'; class DesktopCoinControlView extends ConsumerStatefulWidget { const DesktopCoinControlView({ @@ -55,7 +55,7 @@ class DesktopCoinControlView extends ConsumerStatefulWidget { class _DesktopCoinControlViewState extends ConsumerState { late final TextEditingController _searchController; - late final Coin coin; + late final CryptoCurrency coin; final searchFieldFocusNode = FocusNode(); final Set _selectedUTXOs = {}; @@ -93,7 +93,7 @@ class _DesktopCoinControlViewState filter: _filter, sort: _sort, searchTerm: _searchString, - coin: coin, + cryptoCurrency: coin, ); } else { _map = null; @@ -102,7 +102,7 @@ class _DesktopCoinControlViewState filter: _filter, sort: _sort, searchTerm: _searchString, - coin: coin, + cryptoCurrency: coin, ); } diff --git a/lib/pages_desktop_specific/coin_control/freeze_button.dart b/lib/pages_desktop_specific/coin_control/freeze_button.dart index 935fe3f94..0f4d6d4e8 100644 --- a/lib/pages_desktop_specific/coin_control/freeze_button.dart +++ b/lib/pages_desktop_specific/coin_control/freeze_button.dart @@ -11,11 +11,11 @@ import 'package:async/async.dart'; import 'package:flutter/material.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/db/isar/main_db.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/utxo.dart'; -import 'package:stackwallet/pages_desktop_specific/coin_control/utxo_row.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; +import '../../db/isar/main_db.dart'; +import '../../models/isar/models/blockchain_data/utxo.dart'; +import 'utxo_row.dart'; +import '../../utilities/logger.dart'; +import '../../widgets/desktop/primary_button.dart'; class FreezeButton extends StatefulWidget { const FreezeButton({ diff --git a/lib/pages_desktop_specific/coin_control/utxo_row.dart b/lib/pages_desktop_specific/coin_control/utxo_row.dart index dbb2d8afe..c414f1b4f 100644 --- a/lib/pages_desktop_specific/coin_control/utxo_row.dart +++ b/lib/pages_desktop_specific/coin_control/utxo_row.dart @@ -11,21 +11,20 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/db/isar/main_db.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/pages/coin_control/utxo_details_view.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/utxo_status_icon.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; +import '../../db/isar/main_db.dart'; +import '../../models/isar/models/isar_models.dart'; +import '../../pages/coin_control/utxo_details_view.dart'; +import '../../providers/global/wallets_provider.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/amount/amount.dart'; +import '../../utilities/amount/amount_formatter.dart'; +import '../../utilities/text_styles.dart'; +import '../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../widgets/conditional_parent.dart'; +import '../../widgets/custom_buttons/blue_text_button.dart'; +import '../../widgets/desktop/secondary_button.dart'; +import '../../widgets/icon_widgets/utxo_status_icon.dart'; +import '../../widgets/rounded_container.dart'; class UtxoRowData { UtxoRowData(this.utxoId, this.selected); @@ -158,7 +157,7 @@ class _UtxoRowState extends ConsumerState { ref.watch(pAmountFormatter(coin)).format( Amount( rawValue: BigInt.from(utxo.value), - fractionDigits: coin.decimals, + fractionDigits: coin.fractionDigits, ), ), textAlign: TextAlign.right, @@ -180,7 +179,7 @@ class _UtxoRowState extends ConsumerState { ref.watch(pAmountFormatter(coin)).format( Amount( rawValue: BigInt.from(utxo.value), - fractionDigits: coin.decimals, + fractionDigits: coin.fractionDigits, ), ), textAlign: TextAlign.right, diff --git a/lib/pages_desktop_specific/desktop_buy/desktop_buy_view.dart b/lib/pages_desktop_specific/desktop_buy/desktop_buy_view.dart index b9c00c762..f2d0e9bef 100644 --- a/lib/pages_desktop_specific/desktop_buy/desktop_buy_view.dart +++ b/lib/pages_desktop_specific/desktop_buy/desktop_buy_view.dart @@ -10,16 +10,16 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/pages/buy_view/buy_form.dart'; -import 'package:stackwallet/services/event_bus/events/global/tor_connection_status_changed_event.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/tor_subscription.dart'; +import '../../pages/buy_view/buy_form.dart'; +import '../../services/event_bus/events/global/tor_connection_status_changed_event.dart'; +import '../../services/tor_service.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/text_styles.dart'; +import '../../widgets/desktop/desktop_app_bar.dart'; +import '../../widgets/desktop/desktop_dialog.dart'; +import '../../widgets/desktop/desktop_scaffold.dart'; +import '../../widgets/rounded_white_container.dart'; +import '../../widgets/tor_subscription.dart'; class DesktopBuyView extends ConsumerStatefulWidget { const DesktopBuyView({Key? key}) : super(key: key); diff --git a/lib/pages_desktop_specific/desktop_exchange/desktop_all_trades_view.dart b/lib/pages_desktop_specific/desktop_exchange/desktop_all_trades_view.dart index 112cd97eb..e4a6129bf 100644 --- a/lib/pages_desktop_specific/desktop_exchange/desktop_all_trades_view.dart +++ b/lib/pages_desktop_specific/desktop_exchange/desktop_all_trades_view.dart @@ -16,31 +16,31 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/db/isar/main_db.dart'; -import 'package:stackwallet/models/exchange/change_now/exchange_transaction_status.dart'; -import 'package:stackwallet/models/exchange/response_objects/trade.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/models/isar/stack_theme.dart'; -import 'package:stackwallet/pages/exchange_view/trade_details_view.dart'; -import 'package:stackwallet/providers/exchange/trade_sent_from_stack_lookup_provider.dart'; -import 'package:stackwallet/providers/global/trades_service_provider.dart'; -import 'package:stackwallet/route_generator.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/format.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../db/isar/main_db.dart'; +import '../../models/exchange/change_now/exchange_transaction_status.dart'; +import '../../models/exchange/response_objects/trade.dart'; +import '../../models/isar/models/isar_models.dart'; +import '../../models/isar/stack_theme.dart'; +import '../../pages/exchange_view/trade_details_view.dart'; +import '../../providers/exchange/trade_sent_from_stack_lookup_provider.dart'; +import '../../providers/global/trades_service_provider.dart'; +import '../../route_generator.dart'; +import '../../themes/stack_colors.dart'; +import '../../themes/theme_providers.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/format.dart'; +import '../../utilities/text_styles.dart'; +import '../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/desktop/desktop_app_bar.dart'; +import '../../widgets/desktop/desktop_dialog.dart'; +import '../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../widgets/desktop/desktop_scaffold.dart'; +import '../../widgets/icon_widgets/x_icon.dart'; +import '../../widgets/rounded_white_container.dart'; +import '../../widgets/stack_text_field.dart'; +import '../../widgets/textfield_icon_button.dart'; import 'package:tuple/tuple.dart'; class DesktopAllTradesView extends ConsumerStatefulWidget { diff --git a/lib/pages_desktop_specific/desktop_exchange/desktop_exchange_view.dart b/lib/pages_desktop_specific/desktop_exchange/desktop_exchange_view.dart index 22cb046cf..1476d5d72 100644 --- a/lib/pages_desktop_specific/desktop_exchange/desktop_exchange_view.dart +++ b/lib/pages_desktop_specific/desktop_exchange/desktop_exchange_view.dart @@ -10,20 +10,20 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/pages/exchange_view/exchange_form.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_exchange/desktop_all_trades_view.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_exchange/subwidgets/desktop_trade_history.dart'; -import 'package:stackwallet/providers/exchange/exchange_form_state_provider.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/services/exchange/exchange_data_loading_service.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/custom_loading_overlay.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../pages/exchange_view/exchange_form.dart'; +import 'desktop_all_trades_view.dart'; +import 'subwidgets/desktop_trade_history.dart'; +import '../../providers/exchange/exchange_form_state_provider.dart'; +import '../../providers/global/prefs_provider.dart'; +import '../../services/exchange/exchange_data_loading_service.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/text_styles.dart'; +import '../../widgets/conditional_parent.dart'; +import '../../widgets/custom_buttons/blue_text_button.dart'; +import '../../widgets/custom_loading_overlay.dart'; +import '../../widgets/desktop/desktop_app_bar.dart'; +import '../../widgets/desktop/desktop_scaffold.dart'; +import '../../widgets/rounded_white_container.dart'; class DesktopExchangeView extends ConsumerStatefulWidget { const DesktopExchangeView({Key? key}) : super(key: key); diff --git a/lib/pages_desktop_specific/desktop_exchange/exchange_steps/step_scaffold.dart b/lib/pages_desktop_specific/desktop_exchange/exchange_steps/step_scaffold.dart index b1a3e3327..103280f88 100644 --- a/lib/pages_desktop_specific/desktop_exchange/exchange_steps/step_scaffold.dart +++ b/lib/pages_desktop_specific/desktop_exchange/exchange_steps/step_scaffold.dart @@ -14,45 +14,47 @@ import 'package:decimal/decimal.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:qr_flutter/qr_flutter.dart'; -import 'package:stackwallet/models/exchange/incomplete_exchange.dart'; -import 'package:stackwallet/models/exchange/response_objects/trade.dart'; -import 'package:stackwallet/pages/exchange_view/send_from_view.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_1.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_2.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_3.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_4.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_exchange/subwidgets/desktop_exchange_steps_indicator.dart'; -import 'package:stackwallet/providers/exchange/exchange_form_state_provider.dart'; -import 'package:stackwallet/providers/global/trades_service_provider.dart'; -import 'package:stackwallet/route_generator.dart'; -import 'package:stackwallet/services/exchange/exchange_response.dart'; -import 'package:stackwallet/services/notifications_api.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/exchange_rate_type_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_loading_overlay.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/desktop/simple_desktop_dialog.dart'; -import 'package:stackwallet/widgets/fade_stack.dart'; + +import '../../../app_config.dart'; +import '../../../models/exchange/incomplete_exchange.dart'; +import '../../../models/exchange/response_objects/trade.dart'; +import '../../../pages/exchange_view/send_from_view.dart'; +import '../../../providers/exchange/exchange_form_state_provider.dart'; +import '../../../providers/global/trades_service_provider.dart'; +import '../../../route_generator.dart'; +import '../../../services/exchange/exchange_response.dart'; +import '../../../services/notifications_api.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/enums/exchange_rate_type_enum.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/custom_loading_overlay.dart'; +import '../../../widgets/desktop/desktop_dialog.dart'; +import '../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../widgets/desktop/primary_button.dart'; +import '../../../widgets/desktop/secondary_button.dart'; +import '../../../widgets/desktop/simple_desktop_dialog.dart'; +import '../../../widgets/fade_stack.dart'; +import '../subwidgets/desktop_exchange_steps_indicator.dart'; +import 'subwidgets/desktop_step_1.dart'; +import 'subwidgets/desktop_step_2.dart'; +import 'subwidgets/desktop_step_3.dart'; +import 'subwidgets/desktop_step_4.dart'; final ssss = StateProvider((_) => null); final desktopExchangeModelProvider = ChangeNotifierProvider( - (ref) => ref.watch(ssss.state).state); + (ref) => ref.watch(ssss.state).state, +); class StepScaffold extends ConsumerStatefulWidget { const StepScaffold({ - Key? key, + super.key, required this.initialStep, - }) : super(key: key); + }); final int initialStep; @@ -120,8 +122,9 @@ class _StepScaffoldState extends ConsumerState { context: context, barrierDismissible: true, builder: (_) => SimpleDesktopDialog( - title: "Failed to create trade", - message: response.exception?.toString() ?? ""), + title: "Failed to create trade", + message: response.exception?.toString() ?? "", + ), ), ); } @@ -193,9 +196,9 @@ class _StepScaffoldState extends ConsumerState { void sendFromStack() { final trade = ref.read(desktopExchangeModelProvider)!.trade!; final address = trade.payInAddress; - final coin = coinFromTickerCaseInsensitive(trade.payInCurrency); + final coin = AppConfig.getCryptoCurrencyForTicker(trade.payInCurrency)!; final amount = Decimal.parse(trade.payInAmount).toAmount( - fractionDigits: coin.decimals, + fractionDigits: coin.fractionDigits, ); showDialog( @@ -316,7 +319,7 @@ class _StepScaffoldState extends ConsumerState { onPressed: onBack, ), secondChild: SecondaryButton( - label: "Send from Stack Wallet", + label: "Send from {$AppConfig.appName}", buttonHeight: ButtonHeight.l, onPressed: sendFromStack, ), @@ -387,9 +390,11 @@ class _StepScaffoldState extends ConsumerState { child: QrImageView( // TODO: grab coin uri scheme from somewhere // data: "${coin.uriScheme}:$receivingAddress", - data: ref.watch(desktopExchangeModelProvider - .select((value) => - value!.trade!.payInAddress)), + data: ref.watch( + desktopExchangeModelProvider.select( + (value) => value!.trade!.payInAddress, + ), + ), size: 290, foregroundColor: Theme.of(context) .extension()! diff --git a/lib/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_1.dart b/lib/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_1.dart index 049ec20b3..afa894500 100644 --- a/lib/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_1.dart +++ b/lib/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_1.dart @@ -10,13 +10,13 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_exchange/exchange_steps/step_scaffold.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_item.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/enums/exchange_rate_type_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../step_scaffold.dart'; +import 'desktop_step_item.dart'; +import '../../../../providers/providers.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/enums/exchange_rate_type_enum.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../widgets/rounded_white_container.dart'; class DesktopStep1 extends ConsumerWidget { const DesktopStep1({ diff --git a/lib/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_2.dart b/lib/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_2.dart index c3178b809..a1ff7fb8d 100644 --- a/lib/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_2.dart +++ b/lib/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_2.dart @@ -11,29 +11,30 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/contact_address_entry.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_exchange/exchange_steps/step_scaffold.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_exchange/subwidgets/desktop_choose_from_stack.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/address_book_address_chooser/address_book_address_chooser.dart'; -import 'package:stackwallet/providers/exchange/exchange_send_from_wallet_id_provider.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/clipboard_interface.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/addressbook_icon.dart'; -import 'package:stackwallet/widgets/icon_widgets/clipboard_icon.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; import 'package:tuple/tuple.dart'; +import '../../../../app_config.dart'; +import '../../../../models/contact_address_entry.dart'; +import '../../../../providers/exchange/exchange_send_from_wallet_id_provider.dart'; +import '../../../../providers/global/wallets_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/clipboard_interface.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/logger.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../widgets/custom_buttons/blue_text_button.dart'; +import '../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../../widgets/icon_widgets/addressbook_icon.dart'; +import '../../../../widgets/icon_widgets/clipboard_icon.dart'; +import '../../../../widgets/icon_widgets/x_icon.dart'; +import '../../../../widgets/rounded_white_container.dart'; +import '../../../../widgets/stack_text_field.dart'; +import '../../../../widgets/textfield_icon_button.dart'; +import '../../../my_stack_view/wallet_view/sub_widgets/address_book_address_chooser/address_book_address_chooser.dart'; +import '../../subwidgets/desktop_choose_from_stack.dart'; +import '../step_scaffold.dart'; + class DesktopStep2 extends ConsumerStatefulWidget { const DesktopStep2({ Key? key, @@ -57,20 +58,11 @@ class _DesktopStep2State extends ConsumerState { late final FocusNode _toFocusNode; late final FocusNode _refundFocusNode; - bool isStackCoin(String ticker) { - try { - coinFromTickerCaseInsensitive(ticker); - return true; - } on ArgumentError catch (_) { - return false; - } - } - void selectRecipientAddressFromStack() async { try { - final coin = coinFromTickerCaseInsensitive( + final coin = AppConfig.getCryptoCurrencyForTicker( ref.read(desktopExchangeModelProvider)!.receiveTicker, - ); + )!; final info = await showDialog?>( context: context, @@ -96,14 +88,15 @@ class _DesktopStep2State extends ConsumerState { } widget.enableNextChanged.call( - _toController.text.isNotEmpty && _refundController.text.isNotEmpty); + _toController.text.isNotEmpty && _refundController.text.isNotEmpty, + ); } void selectRefundAddressFromStack() async { try { - final coin = coinFromTickerCaseInsensitive( + final coin = AppConfig.getCryptoCurrencyForTicker( ref.read(desktopExchangeModelProvider)!.sendTicker, - ); + )!; final info = await showDialog?>( context: context, @@ -127,11 +120,12 @@ class _DesktopStep2State extends ConsumerState { Logging.instance.log("$e\n$s", level: LogLevel.Info); } widget.enableNextChanged.call( - _toController.text.isNotEmpty && _refundController.text.isNotEmpty); + _toController.text.isNotEmpty && _refundController.text.isNotEmpty, + ); } void selectRecipientFromAddressBook() async { - final coin = coinFromTickerCaseInsensitive( + final coin = AppConfig.getCryptoCurrencyForTicker( ref.read(desktopExchangeModelProvider)!.receiveTicker, ); @@ -173,12 +167,13 @@ class _DesktopStep2State extends ConsumerState { _toController.text = entry.address; ref.read(desktopExchangeModelProvider)!.recipientAddress = entry.address; widget.enableNextChanged.call( - _toController.text.isNotEmpty && _refundController.text.isNotEmpty); + _toController.text.isNotEmpty && _refundController.text.isNotEmpty, + ); } } void selectRefundFromAddressBook() async { - final coin = coinFromTickerCaseInsensitive( + final coin = AppConfig.getCryptoCurrencyForTicker( ref.read(desktopExchangeModelProvider)!.sendTicker, ); @@ -220,7 +215,8 @@ class _DesktopStep2State extends ConsumerState { _refundController.text = entry.address; ref.read(desktopExchangeModelProvider)!.refundAddress = entry.address; widget.enableNextChanged.call( - _toController.text.isNotEmpty && _refundController.text.isNotEmpty); + _toController.text.isNotEmpty && _refundController.text.isNotEmpty, + ); } } @@ -301,12 +297,17 @@ class _DesktopStep2State extends ConsumerState { Text( "Recipient Wallet", style: STextStyles.desktopTextExtraExtraSmall(context).copyWith( - color: Theme.of(context) - .extension()! - .textFieldActiveSearchIconRight), + color: Theme.of(context) + .extension()! + .textFieldActiveSearchIconRight, + ), ), - if (isStackCoin(ref.watch(desktopExchangeModelProvider - .select((value) => value!.receiveTicker)))) + if (AppConfig.isStackCoin( + ref.watch( + desktopExchangeModelProvider + .select((value) => value!.receiveTicker), + ), + )) CustomTextButton( text: "Choose from Stack", onTap: selectRecipientAddressFromStack, @@ -339,8 +340,10 @@ class _DesktopStep2State extends ConsumerState { focusNode: _toFocusNode, style: STextStyles.field(context), onChanged: (value) { - widget.enableNextChanged.call(_toController.text.isNotEmpty && - _refundController.text.isNotEmpty); + widget.enableNextChanged.call( + _toController.text.isNotEmpty && + _refundController.text.isNotEmpty, + ); }, decoration: standardInputDecoration( "Enter the ${ref.watch(desktopExchangeModelProvider.select((value) => value!.receiveTicker.toUpperCase()))} payout address", @@ -365,21 +368,24 @@ class _DesktopStep2State extends ConsumerState { _toController.text.isNotEmpty ? TextFieldIconButton( key: const Key( - "sendViewClearAddressFieldButtonKey"), + "sendViewClearAddressFieldButtonKey", + ), onTap: () { _toController.text = ""; ref .read(desktopExchangeModelProvider)! .recipientAddress = _toController.text; widget.enableNextChanged.call( - _toController.text.isNotEmpty && - _refundController.text.isNotEmpty); + _toController.text.isNotEmpty && + _refundController.text.isNotEmpty, + ); }, child: const XIcon(), ) : TextFieldIconButton( key: const Key( - "sendViewPasteAddressFieldButtonKey"), + "sendViewPasteAddressFieldButtonKey", + ), onTap: () async { final ClipboardData? data = await clipboard .getData(Clipboard.kTextPlain); @@ -391,8 +397,9 @@ class _DesktopStep2State extends ConsumerState { .read(desktopExchangeModelProvider)! .recipientAddress = _toController.text; widget.enableNextChanged.call( - _toController.text.isNotEmpty && - _refundController.text.isNotEmpty); + _toController.text.isNotEmpty && + _refundController.text.isNotEmpty, + ); } }, child: _toController.text.isEmpty @@ -400,8 +407,12 @@ class _DesktopStep2State extends ConsumerState { : const XIcon(), ), if (_toController.text.isEmpty && - isStackCoin(ref.watch(desktopExchangeModelProvider - .select((value) => value!.receiveTicker)))) + AppConfig.isStackCoin( + ref.watch( + desktopExchangeModelProvider + .select((value) => value!.receiveTicker), + ), + )) TextFieldIconButton( key: const Key("sendViewAddressBookButtonKey"), onTap: selectRecipientFromAddressBook, @@ -433,12 +444,17 @@ class _DesktopStep2State extends ConsumerState { Text( "Refund Wallet (required)", style: STextStyles.desktopTextExtraExtraSmall(context).copyWith( - color: Theme.of(context) - .extension()! - .textFieldActiveSearchIconRight), + color: Theme.of(context) + .extension()! + .textFieldActiveSearchIconRight, + ), ), - if (isStackCoin(ref.watch(desktopExchangeModelProvider - .select((value) => value!.sendTicker)))) + if (AppConfig.isStackCoin( + ref.watch( + desktopExchangeModelProvider + .select((value) => value!.sendTicker), + ), + )) CustomTextButton( text: "Choose from Stack", onTap: selectRefundAddressFromStack, @@ -470,8 +486,10 @@ class _DesktopStep2State extends ConsumerState { focusNode: _refundFocusNode, style: STextStyles.field(context), onChanged: (value) { - widget.enableNextChanged.call(_toController.text.isNotEmpty && - _refundController.text.isNotEmpty); + widget.enableNextChanged.call( + _toController.text.isNotEmpty && + _refundController.text.isNotEmpty, + ); }, decoration: standardInputDecoration( "Enter ${ref.watch(desktopExchangeModelProvider.select((value) => value!.sendTicker.toUpperCase()))} refund address", @@ -496,7 +514,8 @@ class _DesktopStep2State extends ConsumerState { _refundController.text.isNotEmpty ? TextFieldIconButton( key: const Key( - "sendViewClearAddressFieldButtonKey"), + "sendViewClearAddressFieldButtonKey", + ), onTap: () { _refundController.text = ""; ref @@ -504,14 +523,16 @@ class _DesktopStep2State extends ConsumerState { .refundAddress = _refundController.text; widget.enableNextChanged.call( - _toController.text.isNotEmpty && - _refundController.text.isNotEmpty); + _toController.text.isNotEmpty && + _refundController.text.isNotEmpty, + ); }, child: const XIcon(), ) : TextFieldIconButton( key: const Key( - "sendViewPasteAddressFieldButtonKey"), + "sendViewPasteAddressFieldButtonKey", + ), onTap: () async { final ClipboardData? data = await clipboard .getData(Clipboard.kTextPlain); @@ -525,8 +546,9 @@ class _DesktopStep2State extends ConsumerState { .refundAddress = _refundController.text; widget.enableNextChanged.call( - _toController.text.isNotEmpty && - _refundController.text.isNotEmpty); + _toController.text.isNotEmpty && + _refundController.text.isNotEmpty, + ); } }, child: _refundController.text.isEmpty @@ -534,8 +556,12 @@ class _DesktopStep2State extends ConsumerState { : const XIcon(), ), if (_refundController.text.isEmpty && - isStackCoin(ref.watch(desktopExchangeModelProvider - .select((value) => value!.sendTicker)))) + AppConfig.isStackCoin( + ref.watch( + desktopExchangeModelProvider + .select((value) => value!.sendTicker), + ), + )) TextFieldIconButton( key: const Key("sendViewAddressBookButtonKey"), onTap: selectRefundFromAddressBook, diff --git a/lib/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_3.dart b/lib/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_3.dart index 5bd59ce49..d60a552ce 100644 --- a/lib/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_3.dart +++ b/lib/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_3.dart @@ -10,13 +10,13 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_exchange/exchange_steps/step_scaffold.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_item.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/enums/exchange_rate_type_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../step_scaffold.dart'; +import 'desktop_step_item.dart'; +import '../../../../providers/providers.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/enums/exchange_rate_type_enum.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../widgets/rounded_white_container.dart'; class DesktopStep3 extends ConsumerStatefulWidget { const DesktopStep3({ diff --git a/lib/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_4.dart b/lib/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_4.dart index 1787f1add..b831653a9 100644 --- a/lib/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_4.dart +++ b/lib/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_4.dart @@ -12,14 +12,14 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_exchange/exchange_steps/step_scaffold.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_item.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../../app_config.dart'; +import '../step_scaffold.dart'; +import 'desktop_step_item.dart'; +import '../../../../providers/providers.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../widgets/rounded_container.dart'; +import '../../../../widgets/rounded_white_container.dart'; class DesktopStep4 extends ConsumerStatefulWidget { const DesktopStep4({ @@ -37,7 +37,7 @@ class _DesktopStep4State extends ConsumerState { bool _isWalletCoinAndHasWallet(String ticker) { try { - final coin = coinFromTickerCaseInsensitive(ticker); + final coin = AppConfig.getCryptoCurrencyForTicker(ticker); return ref .read(pWallets) .wallets diff --git a/lib/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_item.dart b/lib/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_item.dart index d49d9053c..6b169f573 100644 --- a/lib/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_item.dart +++ b/lib/pages_desktop_specific/desktop_exchange/exchange_steps/subwidgets/desktop_step_item.dart @@ -9,9 +9,9 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../widgets/conditional_parent.dart'; class DesktopStepItem extends StatelessWidget { const DesktopStepItem( diff --git a/lib/pages_desktop_specific/desktop_exchange/subwidgets/desktop_choose_from_stack.dart b/lib/pages_desktop_specific/desktop_exchange/subwidgets/desktop_choose_from_stack.dart index f1ffa7fed..bf9f9ffc6 100644 --- a/lib/pages_desktop_specific/desktop_exchange/subwidgets/desktop_choose_from_stack.dart +++ b/lib/pages_desktop_specific/desktop_exchange/subwidgets/desktop_choose_from_stack.dart @@ -11,31 +11,32 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; -import 'package:stackwallet/widgets/wallet_info_row/sub_widgets/wallet_info_row_coin_icon.dart'; +import '../../../providers/providers.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/amount/amount_formatter.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../wallets/crypto_currency/coins/firo.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../widgets/custom_buttons/blue_text_button.dart'; +import '../../../widgets/desktop/secondary_button.dart'; +import '../../../widgets/icon_widgets/x_icon.dart'; +import '../../../widgets/rounded_white_container.dart'; +import '../../../widgets/stack_text_field.dart'; +import '../../../widgets/textfield_icon_button.dart'; +import '../../../widgets/wallet_info_row/sub_widgets/wallet_info_row_coin_icon.dart'; import 'package:tuple/tuple.dart'; class DesktopChooseFromStack extends ConsumerStatefulWidget { const DesktopChooseFromStack({ - Key? key, + super.key, required this.coin, - }) : super(key: key); + }); - final Coin coin; + final CryptoCurrency coin; @override ConsumerState createState() => @@ -282,9 +283,9 @@ class _DesktopChooseFromStackState class _BalanceDisplay extends ConsumerWidget { const _BalanceDisplay({ - Key? key, + super.key, required this.walletId, - }) : super(key: key); + }); final String walletId; @@ -292,7 +293,7 @@ class _BalanceDisplay extends ConsumerWidget { Widget build(BuildContext context, WidgetRef ref) { final coin = ref.watch(pWalletCoin(walletId)); Amount total = ref.watch(pWalletBalance(walletId)).total; - if (coin == Coin.firo || coin == Coin.firoTestNet) { + if (coin is Firo) { total += ref.watch(pWalletBalanceSecondary(walletId)).total; total += ref.watch(pWalletBalanceTertiary(walletId)).total; } diff --git a/lib/pages_desktop_specific/desktop_exchange/subwidgets/desktop_exchange_steps_indicator.dart b/lib/pages_desktop_specific/desktop_exchange/subwidgets/desktop_exchange_steps_indicator.dart index 426a69811..6d2c677cb 100644 --- a/lib/pages_desktop_specific/desktop_exchange/subwidgets/desktop_exchange_steps_indicator.dart +++ b/lib/pages_desktop_specific/desktop_exchange/subwidgets/desktop_exchange_steps_indicator.dart @@ -9,9 +9,9 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../widgets/rounded_container.dart'; class DesktopExchangeStepsIndicator extends StatelessWidget { const DesktopExchangeStepsIndicator({Key? key, required this.currentStep}) diff --git a/lib/pages_desktop_specific/desktop_exchange/subwidgets/desktop_trade_history.dart b/lib/pages_desktop_specific/desktop_exchange/subwidgets/desktop_trade_history.dart index 9584533ac..86240e37c 100644 --- a/lib/pages_desktop_specific/desktop_exchange/subwidgets/desktop_trade_history.dart +++ b/lib/pages_desktop_specific/desktop_exchange/subwidgets/desktop_trade_history.dart @@ -13,19 +13,19 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; -import 'package:stackwallet/pages/exchange_view/trade_details_view.dart'; -import 'package:stackwallet/providers/exchange/trade_sent_from_stack_lookup_provider.dart'; -import 'package:stackwallet/providers/global/trades_service_provider.dart'; -import 'package:stackwallet/route_generator.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/trade_card.dart'; +import '../../../models/isar/models/blockchain_data/transaction.dart'; +import '../../../pages/exchange_view/trade_details_view.dart'; +import '../../../providers/exchange/trade_sent_from_stack_lookup_provider.dart'; +import '../../../providers/global/trades_service_provider.dart'; +import '../../../route_generator.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../widgets/desktop/desktop_dialog.dart'; +import '../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../widgets/rounded_white_container.dart'; +import '../../../widgets/trade_card.dart'; import '../../../db/isar/main_db.dart'; diff --git a/lib/pages_desktop_specific/desktop_home_view.dart b/lib/pages_desktop_specific/desktop_home_view.dart index 11270d587..80ca02051 100644 --- a/lib/pages_desktop_specific/desktop_home_view.dart +++ b/lib/pages_desktop_specific/desktop_home_view.dart @@ -10,27 +10,27 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/pages_desktop_specific/address_book_view/desktop_address_book.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_buy/desktop_buy_view.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_exchange/desktop_exchange_view.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_menu.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/my_stack_view.dart'; -import 'package:stackwallet/pages_desktop_specific/notifications/desktop_notifications_view.dart'; -import 'package:stackwallet/pages_desktop_specific/settings/desktop_settings_view.dart'; -import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/desktop_about_view.dart'; -import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/desktop_support_view.dart'; -import 'package:stackwallet/providers/desktop/current_desktop_menu_item.dart'; -import 'package:stackwallet/providers/global/active_wallet_provider.dart'; -import 'package:stackwallet/providers/global/auto_swb_service_provider.dart'; -import 'package:stackwallet/providers/global/notifications_provider.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/providers/ui/transaction_filter_provider.dart'; -import 'package:stackwallet/providers/ui/unread_notifications_provider.dart'; -import 'package:stackwallet/route_generator.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/enums/backup_frequency_type.dart'; -import 'package:stackwallet/widgets/background.dart'; +import 'address_book_view/desktop_address_book.dart'; +import 'desktop_buy/desktop_buy_view.dart'; +import 'desktop_exchange/desktop_exchange_view.dart'; +import 'desktop_menu.dart'; +import 'my_stack_view/my_stack_view.dart'; +import 'notifications/desktop_notifications_view.dart'; +import 'settings/desktop_settings_view.dart'; +import 'settings/settings_menu/desktop_about_view.dart'; +import 'settings/settings_menu/desktop_support_view.dart'; +import '../providers/desktop/current_desktop_menu_item.dart'; +import '../providers/global/active_wallet_provider.dart'; +import '../providers/global/auto_swb_service_provider.dart'; +import '../providers/global/notifications_provider.dart'; +import '../providers/global/prefs_provider.dart'; +import '../providers/global/wallets_provider.dart'; +import '../providers/ui/transaction_filter_provider.dart'; +import '../providers/ui/unread_notifications_provider.dart'; +import '../route_generator.dart'; +import '../themes/stack_colors.dart'; +import '../utilities/enums/backup_frequency_type.dart'; +import '../widgets/background.dart'; class DesktopHomeView extends ConsumerStatefulWidget { const DesktopHomeView({Key? key}) : super(key: key); diff --git a/lib/pages_desktop_specific/desktop_menu.dart b/lib/pages_desktop_specific/desktop_menu.dart index 64faa0d16..7ff4714a4 100644 --- a/lib/pages_desktop_specific/desktop_menu.dart +++ b/lib/pages_desktop_specific/desktop_menu.dart @@ -14,14 +14,15 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_menu_item.dart'; -import 'package:stackwallet/pages_desktop_specific/settings/settings_menu.dart'; -import 'package:stackwallet/providers/desktop/current_desktop_menu_item.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/desktop/desktop_tor_status_button.dart'; -import 'package:stackwallet/widgets/desktop/living_stack_icon.dart'; +import '../app_config.dart'; +import 'desktop_menu_item.dart'; +import 'settings/settings_menu.dart'; +import '../providers/desktop/current_desktop_menu_item.dart'; +import '../themes/stack_colors.dart'; +import '../utilities/assets.dart'; +import '../utilities/text_styles.dart'; +import '../widgets/desktop/desktop_tor_status_button.dart'; +import '../widgets/desktop/living_stack_icon.dart'; enum DesktopMenuItemId { myStack, @@ -138,7 +139,7 @@ class _DesktopMenuState extends ConsumerState { child: SizedBox( height: 28, child: Text( - "Stack Wallet", + AppConfig.appName, style: STextStyles.desktopH2(context).copyWith( fontSize: 18, height: 23.4 / 18, @@ -180,7 +181,7 @@ class _DesktopMenuState extends ConsumerState { DesktopMenuItem( duration: duration, icon: const DesktopMyStackIcon(), - label: "My Stack", + label: "My ${AppConfig.prefix}", value: DesktopMenuItemId.myStack, onChanged: updateSelectedMenuItem, controller: controllers[0], diff --git a/lib/pages_desktop_specific/desktop_menu_item.dart b/lib/pages_desktop_specific/desktop_menu_item.dart index 1a7a533a9..c7eee9020 100644 --- a/lib/pages_desktop_specific/desktop_menu_item.dart +++ b/lib/pages_desktop_specific/desktop_menu_item.dart @@ -13,13 +13,13 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_menu.dart'; -import 'package:stackwallet/providers/desktop/current_desktop_menu_item.dart'; -import 'package:stackwallet/providers/global/notifications_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; +import 'desktop_menu.dart'; +import '../providers/desktop/current_desktop_menu_item.dart'; +import '../providers/global/notifications_provider.dart'; +import '../themes/stack_colors.dart'; +import '../themes/theme_providers.dart'; +import '../utilities/assets.dart'; +import '../utilities/text_styles.dart'; class DMIController { VoidCallback? toggle; diff --git a/lib/pages_desktop_specific/lelantus_coins/lelantus_coins_view.dart b/lib/pages_desktop_specific/lelantus_coins/lelantus_coins_view.dart index 2602cfee7..12b118cba 100644 --- a/lib/pages_desktop_specific/lelantus_coins/lelantus_coins_view.dart +++ b/lib/pages_desktop_specific/lelantus_coins/lelantus_coins_view.dart @@ -12,15 +12,15 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../models/isar/models/isar_models.dart'; +import '../../providers/db/main_db_provider.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/text_styles.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/desktop/desktop_app_bar.dart'; +import '../../widgets/desktop/desktop_scaffold.dart'; +import '../../widgets/rounded_white_container.dart'; class LelantusCoinsView extends ConsumerStatefulWidget { const LelantusCoinsView({ diff --git a/lib/pages_desktop_specific/my_stack_view/coin_wallets_table.dart b/lib/pages_desktop_specific/my_stack_view/coin_wallets_table.dart index 94cdf75f8..70c11546c 100644 --- a/lib/pages_desktop_specific/my_stack_view/coin_wallets_table.dart +++ b/lib/pages_desktop_specific/my_stack_view/coin_wallets_table.dart @@ -10,25 +10,25 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/desktop_wallet_view.dart'; -import 'package:stackwallet/providers/global/active_wallet_provider.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/show_loading.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/cw_based_interface.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/wallet_info_row/wallet_info_row.dart'; +import 'wallet_view/desktop_wallet_view.dart'; +import '../../providers/global/active_wallet_provider.dart'; +import '../../providers/global/wallets_provider.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/show_loading.dart'; +import '../../utilities/util.dart'; +import '../../wallets/crypto_currency/crypto_currency.dart'; +import '../../wallets/wallet/wallet_mixin_interfaces/cw_based_interface.dart'; +import '../../widgets/rounded_container.dart'; +import '../../widgets/wallet_info_row/wallet_info_row.dart'; class CoinWalletsTable extends ConsumerWidget { const CoinWalletsTable({ - Key? key, + super.key, required this.coin, - }) : super(key: key); + }); - final Coin coin; + final CryptoCurrency coin; @override Widget build(BuildContext context, WidgetRef ref) { @@ -57,7 +57,7 @@ class CoinWalletsTable extends ConsumerWidget { children: [ for (int i = 0; i < walletIds.length; i++) Column( - key: Key("${coin.name}_$runtimeType${walletIds[i]}_key"), + key: Key("${coin.identifier}_$runtimeType${walletIds[i]}_key"), children: [ if (i != 0) const SizedBox( diff --git a/lib/pages_desktop_specific/my_stack_view/desktop_favorite_wallets.dart b/lib/pages_desktop_specific/my_stack_view/desktop_favorite_wallets.dart index fa3970f98..994a5f949 100644 --- a/lib/pages_desktop_specific/my_stack_view/desktop_favorite_wallets.dart +++ b/lib/pages_desktop_specific/my_stack_view/desktop_favorite_wallets.dart @@ -11,14 +11,14 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/pages/manage_favorites_view/manage_favorites_view.dart'; -import 'package:stackwallet/pages/wallets_view/sub_widgets/favorite_card.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/favourite_wallets_provider.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; +import '../../pages/manage_favorites_view/manage_favorites_view.dart'; +import '../../pages/wallets_view/sub_widgets/favorite_card.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/text_styles.dart'; +import '../../wallets/isar/providers/favourite_wallets_provider.dart'; +import '../../widgets/custom_buttons/blue_text_button.dart'; class DesktopFavoriteWallets extends ConsumerWidget { const DesktopFavoriteWallets({Key? key}) : super(key: key); diff --git a/lib/pages_desktop_specific/my_stack_view/dialogs/desktop_expanding_wallet_card.dart b/lib/pages_desktop_specific/my_stack_view/dialogs/desktop_expanding_wallet_card.dart index 9cee94e50..22fe2250f 100644 --- a/lib/pages_desktop_specific/my_stack_view/dialogs/desktop_expanding_wallet_card.dart +++ b/lib/pages_desktop_specific/my_stack_view/dialogs/desktop_expanding_wallet_card.dart @@ -11,18 +11,18 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/wallet/wallet.dart'; -import 'package:stackwallet/widgets/animated_widgets/rotate_icon.dart'; -import 'package:stackwallet/widgets/expandable.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/wallet_card.dart'; -import 'package:stackwallet/widgets/wallet_info_row/sub_widgets/wallet_info_row_balance.dart'; -import 'package:stackwallet/widgets/wallet_info_row/sub_widgets/wallet_info_row_coin_icon.dart'; +import '../../../models/isar/models/ethereum/eth_contract.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../wallets/wallet/wallet.dart'; +import '../../../widgets/animated_widgets/rotate_icon.dart'; +import '../../../widgets/expandable.dart'; +import '../../../widgets/rounded_white_container.dart'; +import '../../../widgets/wallet_card.dart'; +import '../../../widgets/wallet_info_row/sub_widgets/wallet_info_row_balance.dart'; +import '../../../widgets/wallet_info_row/sub_widgets/wallet_info_row_coin_icon.dart'; import 'package:tuple/tuple.dart'; class DesktopExpandingWalletCard extends StatefulWidget { diff --git a/lib/pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart b/lib/pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart index 3b91e24f5..57848404b 100644 --- a/lib/pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart +++ b/lib/pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart @@ -9,9 +9,10 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_home_view.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; +import '../../app_config.dart'; +import '../desktop_home_view.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/text_styles.dart'; class ExitToMyStackButton extends StatelessWidget { const ExitToMyStackButton({ @@ -44,7 +45,7 @@ class ExitToMyStackButton extends StatelessWidget { horizontal: 30, ), child: Text( - "Exit to My Stack", + "Exit to My ${AppConfig.prefix}", style: STextStyles.desktopButtonSmallSecondaryEnabled(context), ), ), diff --git a/lib/pages_desktop_specific/my_stack_view/my_stack_view.dart b/lib/pages_desktop_specific/my_stack_view/my_stack_view.dart index bb9f9a646..e981979db 100644 --- a/lib/pages_desktop_specific/my_stack_view/my_stack_view.dart +++ b/lib/pages_desktop_specific/my_stack_view/my_stack_view.dart @@ -8,23 +8,22 @@ * */ -import 'dart:io'; - import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/hidden_settings.dart'; -import 'package:stackwallet/pages/wallets_view/sub_widgets/empty_wallets.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/my_wallets.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/all_wallets_info_provider.dart'; -import 'package:stackwallet/widgets/animated_widgets/rotate_icon.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; + +import '../../app_config.dart'; +import '../../pages/settings_views/global_settings_view/hidden_settings.dart'; +import '../../pages/wallets_view/sub_widgets/empty_wallets.dart'; +import '../../utilities/text_styles.dart'; +import '../../wallets/isar/providers/all_wallets_info_provider.dart'; +import '../../widgets/animated_widgets/rotate_icon.dart'; +import '../../widgets/app_icon.dart'; +import '../../widgets/background.dart'; +import '../../widgets/desktop/desktop_app_bar.dart'; +import 'my_wallets.dart'; class MyStackView extends ConsumerStatefulWidget { - const MyStackView({Key? key}) : super(key: key); + const MyStackView({super.key}); static const String routeName = "/myStackDesktop"; @@ -109,18 +108,10 @@ class _DesktopMyStackTitleState extends ConsumerState { GestureDetector( onTap: _hiddenOptions, child: RotateIcon( - icon: SizedBox( + icon: const SizedBox( width: 32, height: 32, - child: SvgPicture.file( - File( - ref.watch( - themeProvider.select( - (value) => value.assets.stackIcon, - ), - ), - ), - ), + child: AppIcon(), ), curve: Curves.easeInOutCubic, rotationPercent: 1.0, @@ -131,7 +122,7 @@ class _DesktopMyStackTitleState extends ConsumerState { width: 12, ), Text( - "My Stack", + "My ${AppConfig.prefix}", style: STextStyles.desktopH3(context), ) ], diff --git a/lib/pages_desktop_specific/my_stack_view/my_wallets.dart b/lib/pages_desktop_specific/my_stack_view/my_wallets.dart index d83a188be..1e8789239 100644 --- a/lib/pages_desktop_specific/my_stack_view/my_wallets.dart +++ b/lib/pages_desktop_specific/my_stack_view/my_wallets.dart @@ -10,13 +10,13 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/pages/add_wallet_views/add_wallet_view/add_wallet_view.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/desktop_favorite_wallets.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_summary_table.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; +import '../../pages/add_wallet_views/add_wallet_view/add_wallet_view.dart'; +import 'desktop_favorite_wallets.dart'; +import 'wallet_summary_table.dart'; +import '../../providers/providers.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/text_styles.dart'; +import '../../widgets/custom_buttons/blue_text_button.dart'; class MyWallets extends ConsumerStatefulWidget { const MyWallets({Key? key}) : super(key: key); diff --git a/lib/pages_desktop_specific/my_stack_view/paynym/desktop_paynym_send_dialog.dart b/lib/pages_desktop_specific/my_stack_view/paynym/desktop_paynym_send_dialog.dart index b77135f96..4aef6a2ba 100644 --- a/lib/pages_desktop_specific/my_stack_view/paynym/desktop_paynym_send_dialog.dart +++ b/lib/pages_desktop_specific/my_stack_view/paynym/desktop_paynym_send_dialog.dart @@ -13,24 +13,23 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/models/paynym/paynym_account_lite.dart'; -import 'package:stackwallet/models/send_view_auto_fill_data.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart'; -import 'package:stackwallet/providers/global/locale_provider.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/providers/global/price_provider.dart'; -import 'package:stackwallet/themes/coin_icon_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/barcode_scanner_interface.dart'; -import 'package:stackwallet/utilities/clipboard_interface.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../models/paynym/paynym_account_lite.dart'; +import '../../../models/send_view_auto_fill_data.dart'; +import '../wallet_view/sub_widgets/desktop_send.dart'; +import '../../../providers/global/locale_provider.dart'; +import '../../../providers/global/prefs_provider.dart'; +import '../../../providers/global/price_provider.dart'; +import '../../../themes/coin_icon_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/amount/amount_formatter.dart'; +import '../../../utilities/barcode_scanner_interface.dart'; +import '../../../utilities/clipboard_interface.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../widgets/desktop/desktop_dialog.dart'; +import '../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../widgets/rounded_white_container.dart'; class DesktopPaynymSendDialog extends ConsumerStatefulWidget { const DesktopPaynymSendDialog({ diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_summary_table.dart b/lib/pages_desktop_specific/my_stack_view/wallet_summary_table.dart index 3b3c6f32f..762e0f58f 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_summary_table.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_summary_table.dart @@ -13,20 +13,19 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/pages/wallets_view/wallets_overview.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/supported_coins.dart'; -import 'package:stackwallet/themes/coin_icon_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/all_wallets_info_provider.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/dialogs/tor_warning_dialog.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../pages/wallets_view/wallets_overview.dart'; +import '../../providers/providers.dart'; +import '../../themes/coin_icon_provider.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/amount/amount.dart'; +import '../../utilities/text_styles.dart'; +import '../../wallets/crypto_currency/crypto_currency.dart'; +import '../../wallets/isar/providers/all_wallets_info_provider.dart'; +import '../../widgets/conditional_parent.dart'; +import '../../widgets/desktop/desktop_dialog.dart'; +import '../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../widgets/dialogs/tor_warning_dialog.dart'; +import '../../widgets/rounded_white_container.dart'; class WalletSummaryTable extends ConsumerStatefulWidget { const WalletSummaryTable({super.key}); @@ -54,7 +53,7 @@ class _WalletTableState extends ConsumerState { child: child, ), child: DesktopWalletSummaryRow( - key: Key("DesktopWalletSummaryRow_key_${coin.name}"), + key: Key("DesktopWalletSummaryRow_key_${coin.identifier}"), coin: coin, walletCount: walletsByCoin[index].wallets.length, ), @@ -75,7 +74,7 @@ class DesktopWalletSummaryRow extends ConsumerStatefulWidget { required this.walletCount, }); - final Coin coin; + final CryptoCurrency coin; final int walletCount; @override @@ -91,8 +90,7 @@ class _DesktopWalletSummaryRowState // Check if Tor is enabled... if (ref.read(prefsChangeNotifierProvider).useTor) { // ... and if the coin supports Tor. - final cryptocurrency = SupportedCoins.getCryptoCurrencyFor(widget.coin); - if (!cryptocurrency.torSupport) { + if (!widget.coin.torSupport) { // If not, show a Tor warning dialog. final shouldContinue = await showDialog( context: context, @@ -222,7 +220,7 @@ class _DesktopWalletSummaryRowState class TablePriceInfo extends ConsumerWidget { const TablePriceInfo({Key? key, required this.coin}) : super(key: key); - final Coin coin; + final CryptoCurrency coin; @override Widget build(BuildContext context, WidgetRef ref) { diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/desktop_token_view.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/desktop_token_view.dart index bb8bc4262..9f4c17780 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/desktop_token_view.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/desktop_token_view.dart @@ -12,26 +12,26 @@ import 'package:event_bus/event_bus.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/pages/send_view/sub_widgets/transaction_fee_selection_sheet.dart'; -import 'package:stackwallet/pages/token_view/sub_widgets/token_summary.dart'; -import 'package:stackwallet/pages/token_view/sub_widgets/token_transaction_list_widget.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/all_transactions_v2_view.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_features.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_summary.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/my_wallet.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/eth/current_token_wallet_provider.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/eth_token_icon.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../pages/send_view/sub_widgets/transaction_fee_selection_sheet.dart'; +import '../../../pages/token_view/sub_widgets/token_summary.dart'; +import '../../../pages/token_view/sub_widgets/token_transaction_list_widget.dart'; +import '../../../pages/wallet_view/transaction_views/tx_v2/all_transactions_v2_view.dart'; +import 'sub_widgets/desktop_wallet_features.dart'; +import 'sub_widgets/desktop_wallet_summary.dart'; +import 'sub_widgets/my_wallet.dart'; +import '../../../providers/providers.dart'; +import '../../../services/event_bus/events/global/wallet_sync_status_changed_event.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../wallets/isar/providers/eth/current_token_wallet_provider.dart'; +import '../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../widgets/custom_buttons/blue_text_button.dart'; +import '../../../widgets/desktop/desktop_app_bar.dart'; +import '../../../widgets/desktop/desktop_scaffold.dart'; +import '../../../widgets/desktop/secondary_button.dart'; +import '../../../widgets/icon_widgets/eth_token_icon.dart'; +import '../../../widgets/rounded_white_container.dart'; /// [eventBus] should only be set during testing class DesktopTokenView extends ConsumerStatefulWidget { diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/desktop_wallet_view.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/desktop_wallet_view.dart index 146f596d7..58ae825ff 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/desktop_wallet_view.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/desktop_wallet_view.dart @@ -16,38 +16,38 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/pages/add_wallet_views/add_token_view/edit_wallet_tokens_view.dart'; -import 'package:stackwallet/pages/token_view/my_tokens_view.dart'; -import 'package:stackwallet/pages/wallet_view/sub_widgets/transactions_list.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/all_transactions_view.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/all_transactions_v2_view.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/transaction_v2_list.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_features.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_summary.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/my_wallet.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/network_info_button.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/wallet_keys_button.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/wallet_options_button.dart'; -import 'package:stackwallet/providers/global/active_wallet_provider.dart'; -import 'package:stackwallet/providers/global/auto_swb_service_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/providers/ui/transaction_filter_provider.dart'; -import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart'; -import 'package:stackwallet/services/event_bus/global_event_bus.dart'; -import 'package:stackwallet/themes/coin_icon_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/enums/backup_frequency_type.dart'; -import 'package:stackwallet/utilities/enums/sync_type_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/wallets/wallet/impl/banano_wallet.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/hover_text_field.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../pages/add_wallet_views/add_token_view/edit_wallet_tokens_view.dart'; +import '../../../pages/token_view/my_tokens_view.dart'; +import '../../../pages/wallet_view/sub_widgets/transactions_list.dart'; +import '../../../pages/wallet_view/transaction_views/all_transactions_view.dart'; +import '../../../pages/wallet_view/transaction_views/tx_v2/all_transactions_v2_view.dart'; +import '../../../pages/wallet_view/transaction_views/tx_v2/transaction_v2_list.dart'; +import 'sub_widgets/desktop_wallet_features.dart'; +import 'sub_widgets/desktop_wallet_summary.dart'; +import 'sub_widgets/my_wallet.dart'; +import 'sub_widgets/network_info_button.dart'; +import 'sub_widgets/wallet_keys_button.dart'; +import 'sub_widgets/wallet_options_button.dart'; +import '../../../providers/global/active_wallet_provider.dart'; +import '../../../providers/global/auto_swb_service_provider.dart'; +import '../../../providers/providers.dart'; +import '../../../providers/ui/transaction_filter_provider.dart'; +import '../../../services/event_bus/events/global/wallet_sync_status_changed_event.dart'; +import '../../../services/event_bus/global_event_bus.dart'; +import '../../../themes/coin_icon_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/enums/backup_frequency_type.dart'; +import '../../../utilities/enums/sync_type_enum.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../wallets/wallet/impl/banano_wallet.dart'; +import '../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../widgets/custom_buttons/blue_text_button.dart'; +import '../../../widgets/desktop/desktop_app_bar.dart'; +import '../../../widgets/desktop/desktop_scaffold.dart'; +import '../../../widgets/hover_text_field.dart'; +import '../../../widgets/rounded_white_container.dart'; /// [eventBus] should only be set during testing class DesktopWalletView extends ConsumerStatefulWidget { diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/address_book_address_chooser/address_book_address_chooser.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/address_book_address_chooser/address_book_address_chooser.dart index ee10acb54..a3132262b 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/address_book_address_chooser/address_book_address_chooser.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/address_book_address_chooser/address_book_address_chooser.dart @@ -11,26 +11,26 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/models/isar/models/contact_entry.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/address_book_address_chooser/sub_widgets/contact_list_item.dart'; -import 'package:stackwallet/providers/global/address_book_service_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../../../../models/isar/models/contact_entry.dart'; +import 'sub_widgets/contact_list_item.dart'; +import '../../../../../providers/global/address_book_service_provider.dart'; +import '../../../../../themes/stack_colors.dart'; +import '../../../../../utilities/assets.dart'; +import '../../../../../utilities/constants.dart'; +import '../../../../../utilities/text_styles.dart'; +import '../../../../../utilities/util.dart'; +import '../../../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../../../widgets/icon_widgets/x_icon.dart'; +import '../../../../../widgets/stack_text_field.dart'; +import '../../../../../widgets/textfield_icon_button.dart'; class AddressBookAddressChooser extends StatefulWidget { const AddressBookAddressChooser({ - Key? key, + super.key, this.coin, - }) : super(key: key); + }); - final Coin? coin; + final CryptoCurrency? coin; @override State createState() => @@ -92,7 +92,7 @@ class _AddressBookAddressChooserState extends State { } for (int i = 0; i < contact.addresses.length; i++) { if (contact.addresses[i].label.toLowerCase().contains(text) || - contact.addresses[i].coin.name.toLowerCase().contains(text) || + contact.addresses[i].coin.identifier.toLowerCase().contains(text) || contact.addresses[i].coin.prettyName.toLowerCase().contains(text) || contact.addresses[i].coin.ticker.toLowerCase().contains(text) || contact.addresses[i].address.toLowerCase().contains(text)) { diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/address_book_address_chooser/sub_widgets/contact_list_item.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/address_book_address_chooser/sub_widgets/contact_list_item.dart index 7d0be498e..be7d7d138 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/address_book_address_chooser/sub_widgets/contact_list_item.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/address_book_address_chooser/sub_widgets/contact_list_item.dart @@ -10,25 +10,25 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/providers/global/address_book_service_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/address_book_card.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/expandable.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/wallet_info_row/sub_widgets/wallet_info_row_coin_icon.dart'; +import '../../../../../../providers/global/address_book_service_provider.dart'; +import '../../../../../../themes/stack_colors.dart'; +import '../../../../../../utilities/text_styles.dart'; +import '../../../../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../../../../widgets/address_book_card.dart'; +import '../../../../../../widgets/custom_buttons/blue_text_button.dart'; +import '../../../../../../widgets/expandable.dart'; +import '../../../../../../widgets/rounded_white_container.dart'; +import '../../../../../../widgets/wallet_info_row/sub_widgets/wallet_info_row_coin_icon.dart'; class ContactListItem extends ConsumerStatefulWidget { const ContactListItem({ - Key? key, + super.key, required this.contactId, this.filterByCoin, - }) : super(key: key); + }); final String contactId; - final Coin? filterByCoin; + final CryptoCurrency? filterByCoin; @override ConsumerState createState() => _ContactListItemState(); @@ -36,7 +36,7 @@ class ContactListItem extends ConsumerStatefulWidget { class _ContactListItemState extends ConsumerState { late final String contactId; - late final Coin? filterByCoin; + late final CryptoCurrency? filterByCoin; ExpandableState _state = ExpandableState.collapsed; diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/delete_wallet_keys_popup.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/delete_wallet_keys_popup.dart index 6085e90e2..fd5349380 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/delete_wallet_keys_popup.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/delete_wallet_keys_popup.dart @@ -13,20 +13,20 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_view/sub_widgets/mnemonic_table.dart'; -import 'package:stackwallet/providers/global/secure_store_provider.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/route_generator.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/clipboard_interface.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; +import '../../../../notifications/show_flush_bar.dart'; +import '../../../../pages/add_wallet_views/new_wallet_recovery_phrase_view/sub_widgets/mnemonic_table.dart'; +import '../../../../providers/global/secure_store_provider.dart'; +import '../../../../providers/global/wallets_provider.dart'; +import '../../../../route_generator.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/clipboard_interface.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/desktop/secondary_button.dart'; class DeleteWalletKeysPopup extends ConsumerStatefulWidget { const DeleteWalletKeysPopup({ diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_attention_delete_wallet.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_attention_delete_wallet.dart index a5353fffa..21d4bfbf5 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_attention_delete_wallet.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_attention_delete_wallet.dart @@ -10,23 +10,24 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/delete_wallet_keys_popup.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/mnemonic_interface.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; +import '../../../../app_config.dart'; +import 'delete_wallet_keys_popup.dart'; +import '../../../../providers/global/wallets_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../wallets/wallet/wallet_mixin_interfaces/mnemonic_interface.dart'; +import '../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/desktop/secondary_button.dart'; +import '../../../../widgets/rounded_container.dart'; import 'package:tuple/tuple.dart'; class DesktopAttentionDeleteWallet extends ConsumerStatefulWidget { const DesktopAttentionDeleteWallet({ - Key? key, + super.key, required this.walletId, - }) : super(key: key); + }); final String walletId; @@ -79,7 +80,7 @@ class _DesktopAttentionDeleteWallet child: Text( "You are going to permanently delete your wallet.\n\nIf you delete your wallet, " "the only way you can have access to your funds is by using your backup key." - "\n\nStack Wallet does not keep nor is able to restore your backup key or your wallet." + "\n\n${AppConfig.appName} does not keep nor is able to restore your backup key or your wallet." "\n\nPLEASE SAVE YOUR BACKUP KEY.", style: STextStyles.desktopTextExtraExtraSmall(context) .copyWith( @@ -118,7 +119,7 @@ class _DesktopAttentionDeleteWallet if (wallet is MnemonicInterface) { final words = await wallet.getMnemonicAsWords(); - if (mounted) { + if (context.mounted) { await Navigator.of(context).pushNamed( DeleteWalletKeysPopup.routeName, arguments: Tuple2( @@ -131,7 +132,7 @@ class _DesktopAttentionDeleteWallet }, ), ], - ) + ), ], ), ), diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_auth_send.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_auth_send.dart index aba28300b..f4dffdb00 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_auth_send.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_auth_send.dart @@ -13,16 +13,16 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/providers/desktop/storage_crypto_handler_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/loading_indicator.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; +import '../../../../providers/desktop/storage_crypto_handler_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/desktop/secondary_button.dart'; +import '../../../../widgets/loading_indicator.dart'; +import '../../../../widgets/stack_text_field.dart'; class DesktopAuthSend extends ConsumerStatefulWidget { const DesktopAuthSend({ @@ -30,7 +30,7 @@ class DesktopAuthSend extends ConsumerStatefulWidget { required this.coin, }); - final Coin coin; + final CryptoCurrency coin; @override ConsumerState createState() => _DesktopAuthSendState(); diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_balance_toggle_button.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_balance_toggle_button.dart index 1b2b01dd0..e873843b1 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_balance_toggle_button.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_balance_toggle_button.dart @@ -11,13 +11,13 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/providers/wallet/public_private_balance_state_provider.dart'; -import 'package:stackwallet/providers/wallet/wallet_balance_toggle_state_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/wallet_balance_toggle_state.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; +import '../../../../providers/wallet/public_private_balance_state_provider.dart'; +import '../../../../providers/wallet/wallet_balance_toggle_state_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/enums/wallet_balance_toggle_state.dart'; +import '../../../../utilities/text_styles.dart'; class DesktopBalanceToggleButton extends ConsumerWidget { const DesktopBalanceToggleButton({ diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_delete_wallet_dialog.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_delete_wallet_dialog.dart index 6e1c8e3c4..ddad5fd55 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_delete_wallet_dialog.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_delete_wallet_dialog.dart @@ -13,19 +13,19 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_attention_delete_wallet.dart'; -import 'package:stackwallet/providers/desktop/storage_crypto_handler_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/loading_indicator.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; +import '../../../../notifications/show_flush_bar.dart'; +import 'desktop_attention_delete_wallet.dart'; +import '../../../../providers/desktop/storage_crypto_handler_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/desktop/secondary_button.dart'; +import '../../../../widgets/loading_indicator.dart'; +import '../../../../widgets/stack_text_field.dart'; class DesktopDeleteWalletDialog extends ConsumerStatefulWidget { const DesktopDeleteWalletDialog({ diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_fee_dropdown.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_fee_dropdown.dart index 255d64c63..a592d60bb 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_fee_dropdown.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_fee_dropdown.dart @@ -13,23 +13,27 @@ import 'package:dropdown_button2/dropdown_button2.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/models/models.dart'; -import 'package:stackwallet/pages/send_view/sub_widgets/transaction_fee_selection_sheet.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/providers/ui/fee_rate_type_state_provider.dart'; -import 'package:stackwallet/providers/wallet/public_private_balance_state_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/eth/current_token_wallet_provider.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/wallets/wallet/impl/firo_wallet.dart'; -import 'package:stackwallet/widgets/animated_text.dart'; +import '../../../../models/models.dart'; +import '../../../../pages/send_view/sub_widgets/transaction_fee_selection_sheet.dart'; +import '../../../../providers/global/wallets_provider.dart'; +import '../../../../providers/ui/fee_rate_type_state_provider.dart'; +import '../../../../providers/wallet/public_private_balance_state_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/amount/amount.dart'; +import '../../../../utilities/amount/amount_formatter.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/enums/fee_rate_type_enum.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../wallets/crypto_currency/coins/ethereum.dart'; +import '../../../../wallets/crypto_currency/coins/firo.dart'; +import '../../../../wallets/crypto_currency/coins/monero.dart'; +import '../../../../wallets/crypto_currency/coins/wownero.dart'; +import '../../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../../wallets/isar/providers/eth/current_token_wallet_provider.dart'; +import '../../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../../wallets/wallet/impl/firo_wallet.dart'; +import '../../../../widgets/animated_text.dart'; final tokenFeeSessionCacheProvider = ChangeNotifierProvider((ref) { @@ -38,10 +42,10 @@ final tokenFeeSessionCacheProvider = class DesktopFeeDropDown extends ConsumerStatefulWidget { const DesktopFeeDropDown({ - Key? key, + super.key, required this.walletId, this.isToken = false, - }) : super(key: key); + }); final String walletId; final bool isToken; @@ -67,7 +71,7 @@ class _DesktopFeeDropDownState extends ConsumerState { required Amount amount, required FeeRateType feeRateType, required int feeRate, - required Coin coin, + required CryptoCurrency coin, }) async { switch (feeRateType) { case FeeRateType.fast: @@ -80,11 +84,11 @@ class _DesktopFeeDropDownState extends ConsumerState { if (widget.isToken == false) { final wallet = ref.read(pWallets).getWallet(walletId); - if (coin == Coin.monero || coin == Coin.wownero) { + if (coin is Monero || coin is Wownero) { final fee = await wallet.estimateFeeFor( amount, MoneroTransactionPriority.fast.raw!); ref.read(feeSheetSessionCacheProvider).fast[amount] = fee; - } else if (coin == Coin.firo || coin == Coin.firoTestNet) { + } else if (coin is Firo) { final Amount fee; switch (ref.read(publicPrivateBalanceStateProvider.state).state) { case FiroType.spark: @@ -124,11 +128,11 @@ class _DesktopFeeDropDownState extends ConsumerState { if (widget.isToken == false) { final wallet = ref.read(pWallets).getWallet(walletId); - if (coin == Coin.monero || coin == Coin.wownero) { + if (coin is Monero || coin is Wownero) { final fee = await wallet.estimateFeeFor( amount, MoneroTransactionPriority.regular.raw!); ref.read(feeSheetSessionCacheProvider).average[amount] = fee; - } else if (coin == Coin.firo || coin == Coin.firoTestNet) { + } else if (coin is Firo) { final Amount fee; switch (ref.read(publicPrivateBalanceStateProvider.state).state) { case FiroType.spark: @@ -168,11 +172,11 @@ class _DesktopFeeDropDownState extends ConsumerState { if (widget.isToken == false) { final wallet = ref.read(pWallets).getWallet(walletId); - if (coin == Coin.monero || coin == Coin.wownero) { + if (coin is Monero || coin is Wownero) { final fee = await wallet.estimateFeeFor( amount, MoneroTransactionPriority.slow.raw!); ref.read(feeSheetSessionCacheProvider).slow[amount] = fee; - } else if (coin == Coin.firo || coin == Coin.firoTestNet) { + } else if (coin is Firo) { final Amount fee; switch (ref.read(publicPrivateBalanceStateProvider.state).state) { case FiroType.spark: @@ -306,7 +310,7 @@ class FeeDropDownChild extends ConsumerWidget { required Amount amount, required FeeRateType feeRateType, required int feeRate, - required Coin coin, + required CryptoCurrency coin, }) feeFor; final bool isSelected; @@ -390,10 +394,10 @@ class FeeDropDownChild extends ConsumerWidget { ), if (feeObject != null) Text( - coin == Coin.ethereum + coin is Ethereum ? "" : estimatedTimeToBeIncludedInNextBlock( - Constants.targetBlockTimeInSeconds(coin), + coin.targetBlockTimeSeconds, feeRateType == FeeRateType.fast ? feeObject!.numberOfBlocksFast : feeRateType == FeeRateType.slow diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_receive.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_receive.dart index 6250dfd8e..974e1f7f2 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_receive.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_receive.dart @@ -17,39 +17,39 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:isar/isar.dart'; import 'package:qr_flutter/qr_flutter.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/receive_view/generate_receiving_uri_qr_code_view.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/route_generator.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/address_utils.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/clipboard_interface.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/eth/current_token_wallet_provider.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/multi_address_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/custom_loading_overlay.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../../models/isar/models/isar_models.dart'; +import '../../../../notifications/show_flush_bar.dart'; +import '../../../../pages/receive_view/generate_receiving_uri_qr_code_view.dart'; +import '../../../../providers/db/main_db_provider.dart'; +import '../../../../providers/providers.dart'; +import '../../../../route_generator.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/address_utils.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/clipboard_interface.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../../wallets/isar/providers/eth/current_token_wallet_provider.dart'; +import '../../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../../wallets/wallet/wallet_mixin_interfaces/multi_address_interface.dart'; +import '../../../../wallets/wallet/wallet_mixin_interfaces/spark_interface.dart'; +import '../../../../widgets/conditional_parent.dart'; +import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../../../widgets/custom_loading_overlay.dart'; +import '../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../widgets/desktop/secondary_button.dart'; +import '../../../../widgets/rounded_white_container.dart'; import 'package:tuple/tuple.dart'; class DesktopReceive extends ConsumerStatefulWidget { const DesktopReceive({ - Key? key, + super.key, required this.walletId, this.contractAddress, this.clipboard = const ClipboardWrapper(), - }) : super(key: key); + }); final String walletId; final String? contractAddress; @@ -60,7 +60,7 @@ class DesktopReceive extends ConsumerStatefulWidget { } class _DesktopReceiveState extends ConsumerState { - late final Coin coin; + late final CryptoCurrency coin; late final String walletId; late final ClipboardInterface clipboard; late final bool supportsSpark; diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart index 2614a58d4..afa38b49a 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart @@ -17,69 +17,76 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/models/isar/models/contact_entry.dart'; -import 'package:stackwallet/models/paynym/paynym_account_lite.dart'; -import 'package:stackwallet/models/send_view_auto_fill_data.dart'; -import 'package:stackwallet/pages/send_view/confirm_transaction_view.dart'; -import 'package:stackwallet/pages/send_view/sub_widgets/building_transaction_dialog.dart'; -import 'package:stackwallet/pages/send_view/sub_widgets/transaction_fee_selection_sheet.dart'; -import 'package:stackwallet/pages_desktop_specific/coin_control/desktop_coin_control_use_dialog.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_home_view.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/address_book_address_chooser/address_book_address_chooser.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_fee_dropdown.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/providers/ui/fee_rate_type_state_provider.dart'; -import 'package:stackwallet/providers/ui/preview_tx_button_state_provider.dart'; -import 'package:stackwallet/providers/wallet/public_private_balance_state_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/address_utils.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/amount/amount_input_formatter.dart'; -import 'package:stackwallet/utilities/amount/amount_unit.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/barcode_scanner_interface.dart'; -import 'package:stackwallet/utilities/clipboard_interface.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/prefs.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/wallets/models/tx_data.dart'; -import 'package:stackwallet/wallets/wallet/impl/firo_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/coin_control_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart'; -import 'package:stackwallet/widgets/animated_text.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_fee_dialog.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/fee_slider.dart'; -import 'package:stackwallet/widgets/icon_widgets/addressbook_icon.dart'; -import 'package:stackwallet/widgets/icon_widgets/clipboard_icon.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../../../models/isar/models/contact_entry.dart'; +import '../../../../models/paynym/paynym_account_lite.dart'; +import '../../../../models/send_view_auto_fill_data.dart'; +import '../../../../pages/send_view/confirm_transaction_view.dart'; +import '../../../../pages/send_view/sub_widgets/building_transaction_dialog.dart'; +import '../../../../pages/send_view/sub_widgets/transaction_fee_selection_sheet.dart'; +import '../../../coin_control/desktop_coin_control_use_dialog.dart'; +import '../../../desktop_home_view.dart'; +import 'address_book_address_chooser/address_book_address_chooser.dart'; +import 'desktop_fee_dropdown.dart'; +import '../../../../providers/providers.dart'; +import '../../../../providers/ui/fee_rate_type_state_provider.dart'; +import '../../../../providers/ui/preview_tx_button_state_provider.dart'; +import '../../../../providers/wallet/public_private_balance_state_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/address_utils.dart'; +import '../../../../utilities/amount/amount.dart'; +import '../../../../utilities/amount/amount_formatter.dart'; +import '../../../../utilities/amount/amount_input_formatter.dart'; +import '../../../../utilities/amount/amount_unit.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/barcode_scanner_interface.dart'; +import '../../../../utilities/clipboard_interface.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/enums/fee_rate_type_enum.dart'; +import '../../../../utilities/logger.dart'; +import '../../../../utilities/prefs.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/crypto_currency/coins/epiccash.dart'; +import '../../../../wallets/crypto_currency/coins/ethereum.dart'; +import '../../../../wallets/crypto_currency/coins/firo.dart'; +import '../../../../wallets/crypto_currency/coins/monero.dart'; +import '../../../../wallets/crypto_currency/coins/stellar.dart'; +import '../../../../wallets/crypto_currency/coins/tezos.dart'; +import '../../../../wallets/crypto_currency/coins/wownero.dart'; +import '../../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../../wallets/crypto_currency/intermediate/nano_currency.dart'; +import '../../../../wallets/isar/providers/wallet_info_provider.dart'; +import '../../../../wallets/models/tx_data.dart'; +import '../../../../wallets/wallet/impl/firo_wallet.dart'; +import '../../../../wallets/wallet/wallet_mixin_interfaces/coin_control_interface.dart'; +import '../../../../wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart'; +import '../../../../wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart'; +import '../../../../wallets/wallet/wallet_mixin_interfaces/spark_interface.dart'; +import '../../../../widgets/animated_text.dart'; +import '../../../../widgets/conditional_parent.dart'; +import '../../../../widgets/custom_buttons/blue_text_button.dart'; +import '../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../../widgets/desktop/desktop_fee_dialog.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/desktop/secondary_button.dart'; +import '../../../../widgets/fee_slider.dart'; +import '../../../../widgets/icon_widgets/addressbook_icon.dart'; +import '../../../../widgets/icon_widgets/clipboard_icon.dart'; +import '../../../../widgets/icon_widgets/x_icon.dart'; +import '../../../../widgets/rounded_container.dart'; +import '../../../../widgets/stack_text_field.dart'; +import '../../../../widgets/textfield_icon_button.dart'; class DesktopSend extends ConsumerStatefulWidget { const DesktopSend({ - Key? key, + super.key, required this.walletId, this.autoFillData, this.clipboard = const ClipboardWrapper(), this.barcodeScanner = const BarcodeScannerWrapper(), this.accountLite, - }) : super(key: key); + }); final String walletId; final SendViewAutoFillData? autoFillData; @@ -93,7 +100,7 @@ class DesktopSend extends ConsumerStatefulWidget { class _DesktopSendState extends ConsumerState { late final String walletId; - late final Coin coin; + late final CryptoCurrency coin; late final ClipboardInterface clipboard; late final BarcodeScannerInterface scanner; @@ -141,7 +148,7 @@ class _DesktopSendState extends ConsumerState { final Amount amount = ref.read(pSendAmount)!; final Amount availableBalance; - if ((coin == Coin.firo || coin == Coin.firoTestNet)) { + if ((coin is Firo)) { switch (ref.read(publicPrivateBalanceStateProvider.state).state) { case FiroType.public: availableBalance = wallet.info.cachedBalance.spendable; @@ -447,7 +454,7 @@ class _DesktopSendState extends ConsumerState { txData = txData.copyWith( note: _note ?? "", ); - if (coin == Coin.epicCash) { + if (coin is Epiccash) { txData = txData.copyWith( noteOnChain: _onChainNote ?? "", ); @@ -658,7 +665,7 @@ class _DesktopSendState extends ConsumerState { // autofill amount field if (results["amount"] != null) { final amount = Decimal.parse(results["amount"]!).toAmount( - fractionDigits: coin.decimals, + fractionDigits: coin.fractionDigits, ); cryptoAmountController.text = ref .read(pAmountFormatter(coin)) @@ -721,7 +728,7 @@ class _DesktopSendState extends ConsumerState { content = content.substring(0, content.indexOf("\n")); } - if (coin == Coin.epicCash) { + if (coin is Epiccash) { // strip http:// and https:// if content contains @ content = formatAddress(content); } @@ -764,13 +771,13 @@ class _DesktopSendState extends ConsumerState { ref.read(priceAnd24hChangeNotifierProvider).getPrice(coin).item1; if (_price == Decimal.zero) { - amount = Decimal.zero.toAmount(fractionDigits: coin.decimals); + amount = Decimal.zero.toAmount(fractionDigits: coin.fractionDigits); } else { amount = baseAmount <= Amount.zero - ? Decimal.zero.toAmount(fractionDigits: coin.decimals) + ? Decimal.zero.toAmount(fractionDigits: coin.fractionDigits) : (baseAmount.decimal / _price) - .toDecimal(scaleOnInfinitePrecision: coin.decimals) - .toAmount(fractionDigits: coin.decimals); + .toDecimal(scaleOnInfinitePrecision: coin.fractionDigits) + .toAmount(fractionDigits: coin.fractionDigits); } if (_cachedAmountToSend != null && _cachedAmountToSend == amount) { return; @@ -788,7 +795,7 @@ class _DesktopSendState extends ConsumerState { cryptoAmountController.text = amountString; _cryptoAmountChangeLock = false; } else { - amount = Decimal.zero.toAmount(fractionDigits: coin.decimals); + amount = Decimal.zero.toAmount(fractionDigits: coin.fractionDigits); _cryptoAmountChangeLock = true; cryptoAmountController.text = ""; _cryptoAmountChangeLock = false; @@ -804,26 +811,26 @@ class _DesktopSendState extends ConsumerState { Future sendAllTapped() async { final info = ref.read(pWalletInfo(walletId)); - if (coin == Coin.firo || coin == Coin.firoTestNet) { + if (coin is Firo) { switch (ref.read(publicPrivateBalanceStateProvider.state).state) { case FiroType.public: cryptoAmountController.text = info.cachedBalance.spendable.decimal - .toStringAsFixed(coin.decimals); + .toStringAsFixed(coin.fractionDigits); break; case FiroType.lelantus: cryptoAmountController.text = info .cachedBalanceSecondary.spendable.decimal - .toStringAsFixed(coin.decimals); + .toStringAsFixed(coin.fractionDigits); break; case FiroType.spark: cryptoAmountController.text = info .cachedBalanceTertiary.spendable.decimal - .toStringAsFixed(coin.decimals); + .toStringAsFixed(coin.fractionDigits); break; } } else { - cryptoAmountController.text = - info.cachedBalance.spendable.decimal.toStringAsFixed(coin.decimals); + cryptoAmountController.text = info.cachedBalance.spendable.decimal + .toStringAsFixed(coin.fractionDigits); } } @@ -852,7 +859,7 @@ class _DesktopSendState extends ConsumerState { coin = ref.read(pWalletInfo(walletId)).coin; clipboard = widget.clipboard; scanner = widget.barcodeScanner; - isStellar = coin == Coin.stellar || coin == Coin.stellarTestnet; + isStellar = coin is Stellar; sendToController = TextEditingController(); cryptoAmountController = TextEditingController(); @@ -927,7 +934,7 @@ class _DesktopSendState extends ConsumerState { ); // add listener for epic cash to strip http:// and https:// prefixes if the address also ocntains an @ symbol (indicating an epicbox address) - if (coin == Coin.epicCash) { + if (coin is Epiccash) { sendToController.addListener(() { _address = sendToController.text; @@ -955,7 +962,7 @@ class _DesktopSendState extends ConsumerState { const SizedBox( height: 4, ), - if (coin == Coin.firo || coin == Coin.firoTestNet) + if (coin is Firo) Text( "Send from", style: STextStyles.desktopTextExtraSmall(context).copyWith( @@ -965,11 +972,11 @@ class _DesktopSendState extends ConsumerState { ), textAlign: TextAlign.left, ), - if (coin == Coin.firo || coin == Coin.firoTestNet) + if (coin is Firo) const SizedBox( height: 10, ), - if (coin == Coin.firo || coin == Coin.firoTestNet) + if (coin is Firo) DropdownButtonHideUnderline( child: DropdownButton2( isExpanded: true, @@ -1076,7 +1083,7 @@ class _DesktopSendState extends ConsumerState { ), ), ), - if (coin == Coin.firo || coin == Coin.firoTestNet) + if (coin is Firo) const SizedBox( height: 20, ), @@ -1122,7 +1129,7 @@ class _DesktopSendState extends ConsumerState { ), textAlign: TextAlign.left, ), - if (coin != Coin.ethereum && coin != Coin.tezos) + if (coin is! Ethereum && coin is! Tezos) CustomTextButton( text: "Send all ${coin.ticker}", onTap: sendAllTapped, @@ -1150,7 +1157,7 @@ class _DesktopSendState extends ConsumerState { textAlign: TextAlign.right, inputFormatters: [ AmountInputFormatter( - decimals: coin.decimals, + decimals: coin.fractionDigits, unit: ref.watch(pAmountUnit(coin)), locale: locale, ), @@ -1455,13 +1462,13 @@ class _DesktopSendState extends ConsumerState { if (_address == null || _address!.isEmpty) { error = null; - } else if (coin == Coin.firo || coin == Coin.firoTestNet) { + } else if (coin is Firo) { if (ref.watch(publicPrivateBalanceStateProvider) == FiroType.lelantus) { if (_data != null && _data!.contactLabel == _address) { error = SparkInterface.validateSparkAddress( address: _data!.address, - isTestNet: coin.isTestNet, + isTestNet: coin.network == CryptoCurrencyNetwork.test, ) ? "Lelantus to Spark not supported" : null; @@ -1532,8 +1539,7 @@ class _DesktopSendState extends ConsumerState { Constants.size.circularBorderRadius, ), child: TextField( - maxLength: - (coin == Coin.firo || coin == Coin.firoTestNet) ? 31 : null, + maxLength: (coin is Firo) ? 31 : null, minLines: 1, maxLines: 5, key: const Key("sendViewMemoFieldKey"), @@ -1590,12 +1596,11 @@ class _DesktopSendState extends ConsumerState { const SizedBox( height: 20, ), - if (!([Coin.nano, Coin.banano, Coin.epicCash, Coin.tezos] - .contains(coin))) + if (coin is! NanoCurrency && coin is! Epiccash && coin is! Tezos) ConditionalParent( condition: ref.watch(pWallets).getWallet(walletId) is ElectrumXInterface && - !(((coin == Coin.firo || coin == Coin.firoTestNet) && + !(((coin is Firo) && (ref.watch(publicPrivateBalanceStateProvider.state).state == FiroType.lelantus || ref @@ -1638,7 +1643,7 @@ class _DesktopSendState extends ConsumerState { ), child: Text( "Transaction fee" - "${isCustomFee ? "" : " (${coin == Coin.ethereum ? "max" : "estimated"})"}", + "${isCustomFee ? "" : " (${coin is Ethereum ? "max" : "estimated"})"}", style: STextStyles.desktopTextExtraSmall(context).copyWith( color: Theme.of(context) .extension()! @@ -1647,13 +1652,11 @@ class _DesktopSendState extends ConsumerState { textAlign: TextAlign.left, ), ), - if (!([Coin.nano, Coin.banano, Coin.epicCash, Coin.tezos] - .contains(coin))) + if (coin is! NanoCurrency && coin is! Epiccash && coin is! Tezos) const SizedBox( height: 10, ), - if (!([Coin.nano, Coin.banano, Coin.epicCash, Coin.tezos] - .contains(coin))) + if (coin is! NanoCurrency && coin is! Epiccash && coin is! Tezos) if (!isCustomFee) Padding( padding: const EdgeInsets.all(10), @@ -1676,7 +1679,7 @@ class _DesktopSendState extends ConsumerState { required Amount amount, required FeeRateType feeRateType, required int feeRate, - required Coin coin, + required CryptoCurrency coin, }) async { if (ref .read(feeSheetSessionCacheProvider) @@ -1685,8 +1688,7 @@ class _DesktopSendState extends ConsumerState { final wallet = ref.read(pWallets).getWallet(walletId); - if (coin == Coin.monero || - coin == Coin.wownero) { + if (coin is Monero || coin is Wownero) { final fee = await wallet.estimateFeeFor( amount, MoneroTransactionPriority.regular.raw!, @@ -1694,8 +1696,7 @@ class _DesktopSendState extends ConsumerState { ref .read(feeSheetSessionCacheProvider) .average[amount] = fee; - } else if ((coin == Coin.firo || - coin == Coin.firoTestNet) && + } else if ((coin is Firo) && ref .read( publicPrivateBalanceStateProvider @@ -1764,7 +1765,7 @@ class _DesktopSendState extends ConsumerState { } }, ) - : (coin == Coin.firo || coin == Coin.firoTestNet) && + : (coin is Firo) && ref .watch( publicPrivateBalanceStateProvider.state, @@ -1775,7 +1776,7 @@ class _DesktopSendState extends ConsumerState { "~${ref.watch(pAmountFormatter(coin)).format( Amount( rawValue: BigInt.parse("3794"), - fractionDigits: coin.decimals, + fractionDigits: coin.fractionDigits, ), indicatePrecisionLoss: false, )}", diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_token_send.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_token_send.dart index eef67e694..8272999c8 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_token_send.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_token_send.dart @@ -14,43 +14,44 @@ import 'package:decimal/decimal.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/isar/models/contact_entry.dart'; -import 'package:stackwallet/models/paynym/paynym_account_lite.dart'; -import 'package:stackwallet/models/send_view_auto_fill_data.dart'; -import 'package:stackwallet/pages/send_view/confirm_transaction_view.dart'; -import 'package:stackwallet/pages/send_view/sub_widgets/building_transaction_dialog.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_home_view.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/address_book_address_chooser/address_book_address_chooser.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_fee_dropdown.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/providers/ui/fee_rate_type_state_provider.dart'; -import 'package:stackwallet/providers/ui/preview_tx_button_state_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/address_utils.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/amount/amount_input_formatter.dart'; -import 'package:stackwallet/utilities/barcode_scanner_interface.dart'; -import 'package:stackwallet/utilities/clipboard_interface.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/prefs.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/eth/current_token_wallet_provider.dart'; -import 'package:stackwallet/wallets/isar/providers/eth/token_balance_provider.dart'; -import 'package:stackwallet/wallets/models/tx_data.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/addressbook_icon.dart'; -import 'package:stackwallet/widgets/icon_widgets/clipboard_icon.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../../../models/isar/models/contact_entry.dart'; +import '../../../../models/paynym/paynym_account_lite.dart'; +import '../../../../models/send_view_auto_fill_data.dart'; +import '../../../../pages/send_view/confirm_transaction_view.dart'; +import '../../../../pages/send_view/sub_widgets/building_transaction_dialog.dart'; +import '../../../desktop_home_view.dart'; +import 'address_book_address_chooser/address_book_address_chooser.dart'; +import 'desktop_fee_dropdown.dart'; +import '../../../../providers/providers.dart'; +import '../../../../providers/ui/fee_rate_type_state_provider.dart'; +import '../../../../providers/ui/preview_tx_button_state_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/address_utils.dart'; +import '../../../../utilities/amount/amount.dart'; +import '../../../../utilities/amount/amount_formatter.dart'; +import '../../../../utilities/amount/amount_input_formatter.dart'; +import '../../../../utilities/barcode_scanner_interface.dart'; +import '../../../../utilities/clipboard_interface.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/logger.dart'; +import '../../../../utilities/prefs.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../wallets/crypto_currency/coins/firo.dart'; +import '../../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../../wallets/isar/providers/eth/current_token_wallet_provider.dart'; +import '../../../../wallets/isar/providers/eth/token_balance_provider.dart'; +import '../../../../wallets/models/tx_data.dart'; +import '../../../../widgets/custom_buttons/blue_text_button.dart'; +import '../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/desktop/secondary_button.dart'; +import '../../../../widgets/icon_widgets/addressbook_icon.dart'; +import '../../../../widgets/icon_widgets/clipboard_icon.dart'; +import '../../../../widgets/icon_widgets/x_icon.dart'; +import '../../../../widgets/stack_text_field.dart'; +import '../../../../widgets/textfield_icon_button.dart'; // const _kCryptoAmountRegex = r'^([0-9]*[,.]?[0-9]{0,8}|[,.][0-9]{0,8})$'; @@ -76,7 +77,7 @@ class DesktopTokenSend extends ConsumerStatefulWidget { class _DesktopTokenSendState extends ConsumerState { late final String walletId; - late final Coin coin; + late final CryptoCurrency coin; late final ClipboardInterface clipboard; late final BarcodeScannerInterface scanner; @@ -224,7 +225,7 @@ class _DesktopTokenSendState extends ConsumerState { child: Padding( padding: const EdgeInsets.all(32), child: BuildingTransactionDialog( - coin: tokenWallet.cryptoCurrency.coin, + coin: tokenWallet.cryptoCurrency, isSpark: false, onCancel: () { wasCancelled = true; @@ -719,7 +720,7 @@ class _DesktopTokenSendState extends ConsumerState { const SizedBox( height: 4, ), - if (coin == Coin.firo) + if (coin is Firo) Text( "Send from", style: STextStyles.desktopTextExtraSmall(context).copyWith( diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_features.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_features.dart index d655879e8..0f55a7c70 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_features.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_features.dart @@ -15,44 +15,45 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/monkey/monkey_view.dart'; -import 'package:stackwallet/pages/paynym/paynym_claim_view.dart'; -import 'package:stackwallet/pages/paynym/paynym_home_view.dart'; -import 'package:stackwallet/pages_desktop_specific/cashfusion/desktop_cashfusion_view.dart'; -import 'package:stackwallet/pages_desktop_specific/coin_control/desktop_coin_control_view.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_menu.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/desktop_wallet_view.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/more_features/more_features_dialog.dart'; -import 'package:stackwallet/pages_desktop_specific/ordinals/desktop_ordinals_view.dart'; -import 'package:stackwallet/providers/desktop/current_desktop_menu_item.dart'; -import 'package:stackwallet/providers/global/paynym_api_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/wallet/impl/firo_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/cash_fusion_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/coin_control_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/ordinals_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart'; -import 'package:stackwallet/widgets/custom_loading_overlay.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/loading_indicator.dart'; +import '../../../../notifications/show_flush_bar.dart'; +import '../../../../pages/monkey/monkey_view.dart'; +import '../../../../pages/paynym/paynym_claim_view.dart'; +import '../../../../pages/paynym/paynym_home_view.dart'; +import '../../../cashfusion/desktop_cashfusion_view.dart'; +import '../../../coin_control/desktop_coin_control_view.dart'; +import '../../../desktop_menu.dart'; +import '../desktop_wallet_view.dart'; +import 'more_features/more_features_dialog.dart'; +import '../../../ordinals/desktop_ordinals_view.dart'; +import '../../../../providers/desktop/current_desktop_menu_item.dart'; +import '../../../../providers/global/paynym_api_provider.dart'; +import '../../../../providers/providers.dart'; +import '../../../../providers/wallet/my_paynym_account_state_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../themes/theme_providers.dart'; +import '../../../../utilities/amount/amount.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/logger.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../wallets/crypto_currency/coins/banano.dart'; +import '../../../../wallets/crypto_currency/coins/firo.dart'; +import '../../../../wallets/wallet/impl/firo_wallet.dart'; +import '../../../../wallets/wallet/wallet_mixin_interfaces/cash_fusion_interface.dart'; +import '../../../../wallets/wallet/wallet_mixin_interfaces/coin_control_interface.dart'; +import '../../../../wallets/wallet/wallet_mixin_interfaces/ordinals_interface.dart'; +import '../../../../wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart'; +import '../../../../widgets/custom_loading_overlay.dart'; +import '../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/desktop/secondary_button.dart'; +import '../../../../widgets/loading_indicator.dart'; class DesktopWalletFeatures extends ConsumerStatefulWidget { const DesktopWalletFeatures({ - Key? key, + super.key, required this.walletId, - }) : super(key: key); + }); final String walletId; @@ -357,10 +358,9 @@ class _DesktopWalletFeaturesState extends ConsumerState { (value) => value.enableCoinControl, ), )) || - coin == Coin.firo || - coin == Coin.firoTestNet || + coin is Firo || // manager.hasWhirlpoolSupport || - coin == Coin.banano || + coin is Banano || wallet is OrdinalsInterface || wallet is CashFusionInterface; diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_summary.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_summary.dart index 77a5f0f5f..ee2c69156 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_summary.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_summary.dart @@ -10,22 +10,22 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/balance.dart'; -import 'package:stackwallet/pages/wallet_view/sub_widgets/wallet_refresh_button.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_balance_toggle_button.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/providers/wallet/public_private_balance_state_provider.dart'; -import 'package:stackwallet/providers/wallet/wallet_balance_toggle_state_provider.dart'; -import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/wallet_balance_toggle_state.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/eth/current_token_wallet_provider.dart'; -import 'package:stackwallet/wallets/isar/providers/eth/token_balance_provider.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; +import '../../../../models/balance.dart'; +import '../../../../pages/wallet_view/sub_widgets/wallet_refresh_button.dart'; +import 'desktop_balance_toggle_button.dart'; +import '../../../../providers/providers.dart'; +import '../../../../providers/wallet/public_private_balance_state_provider.dart'; +import '../../../../providers/wallet/wallet_balance_toggle_state_provider.dart'; +import '../../../../services/event_bus/events/global/wallet_sync_status_changed_event.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/amount/amount.dart'; +import '../../../../utilities/amount/amount_formatter.dart'; +import '../../../../utilities/enums/wallet_balance_toggle_state.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../wallets/crypto_currency/coins/firo.dart'; +import '../../../../wallets/isar/providers/eth/current_token_wallet_provider.dart'; +import '../../../../wallets/isar/providers/eth/token_balance_provider.dart'; +import '../../../../wallets/isar/providers/wallet_info_provider.dart'; class DesktopWalletSummary extends ConsumerStatefulWidget { const DesktopWalletSummary({ @@ -63,7 +63,7 @@ class _WDesktopWalletSummaryState extends ConsumerState { ), ); final coin = ref.watch(pWalletCoin(widget.walletId)); - final isFiro = coin == Coin.firo || coin == Coin.firoTestNet; + final isFiro = coin is Firo; final locale = ref.watch( localeServiceChangeNotifierProvider.select((value) => value.locale)); @@ -154,12 +154,11 @@ class _WDesktopWalletSummaryState extends ConsumerState { ? ref.watch(pCurrentTokenWallet)!.tokenContract.address : null, ), - if (coin == Coin.firo || coin == Coin.firoTestNet) + if (coin is Firo) const SizedBox( width: 8, ), - if (coin == Coin.firo || coin == Coin.firoTestNet) - const DesktopPrivateBalanceToggleButton(), + if (coin is Firo) const DesktopPrivateBalanceToggleButton(), const SizedBox( width: 8, ), diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/more_features/more_features_dialog.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/more_features/more_features_dialog.dart index 1eaccd885..29507d545 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/more_features/more_features_dialog.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/more_features/more_features_dialog.dart @@ -11,19 +11,20 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/cash_fusion_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/coin_control_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/ordinals_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; +import '../../../../../providers/global/prefs_provider.dart'; +import '../../../../../providers/global/wallets_provider.dart'; +import '../../../../../themes/stack_colors.dart'; +import '../../../../../utilities/assets.dart'; +import '../../../../../utilities/text_styles.dart'; +import '../../../../../wallets/crypto_currency/coins/banano.dart'; +import '../../../../../wallets/crypto_currency/coins/firo.dart'; +import '../../../../../wallets/wallet/wallet_mixin_interfaces/cash_fusion_interface.dart'; +import '../../../../../wallets/wallet/wallet_mixin_interfaces/coin_control_interface.dart'; +import '../../../../../wallets/wallet/wallet_mixin_interfaces/ordinals_interface.dart'; +import '../../../../../wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart'; +import '../../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../../../widgets/rounded_container.dart'; class MoreFeaturesDialog extends ConsumerStatefulWidget { const MoreFeaturesDialog({ @@ -85,8 +86,7 @@ class _MoreFeaturesDialogState extends ConsumerState { const DesktopDialogCloseButton(), ], ), - if (wallet.info.coin == Coin.firo || - wallet.info.coin == Coin.firoTestNet) + if (wallet.info.coin is Firo) _MoreFeaturesItem( label: "Anonymize funds", detail: "Anonymize funds", @@ -122,7 +122,7 @@ class _MoreFeaturesDialogState extends ConsumerState { iconAsset: Assets.svg.ordinal, onPressed: () => widget.onOrdinalsPressed?.call(), ), - if (wallet.info.coin == Coin.banano) + if (wallet.info.coin is Banano) _MoreFeaturesItem( label: "MonKey", detail: "Generate Banano MonKey", @@ -147,12 +147,12 @@ class _MoreFeaturesDialogState extends ConsumerState { class _MoreFeaturesItem extends StatelessWidget { const _MoreFeaturesItem({ - Key? key, + super.key, required this.label, required this.detail, required this.iconAsset, this.onPressed, - }) : super(key: key); + }); static const double iconSizeBG = 46; static const double iconSize = 24; @@ -209,7 +209,7 @@ class _MoreFeaturesItem extends StatelessWidget { style: STextStyles.desktopTextExtraExtraSmall(context), ), ], - ) + ), ], ), ), diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/my_wallet.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/my_wallet.dart index 63974518b..df81592c9 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/my_wallet.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/my_wallet.dart @@ -10,20 +10,21 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/frost_route_generator.dart'; -import 'package:stackwallet/pages/send_view/frost_ms/frost_send_view.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/transaction_v2_list.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/my_stack_view.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_receive.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_token_send.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/wallets/wallet/impl/bitcoin_frost_wallet.dart'; -import 'package:stackwallet/widgets/custom_tab_view.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/frost_scaffold.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../../frost_route_generator.dart'; +import '../../../../pages/send_view/frost_ms/frost_send_view.dart'; +import '../../../../pages/wallet_view/transaction_views/tx_v2/transaction_v2_list.dart'; +import '../../my_stack_view.dart'; +import 'desktop_receive.dart'; +import 'desktop_send.dart'; +import 'desktop_token_send.dart'; +import '../../../../providers/global/wallets_provider.dart'; +import '../../../../wallets/crypto_currency/coins/ethereum.dart'; +import '../../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../../wallets/wallet/impl/bitcoin_frost_wallet.dart'; +import '../../../../widgets/custom_tab_view.dart'; +import '../../../../widgets/desktop/secondary_button.dart'; +import '../../../../widgets/frost_scaffold.dart'; +import '../../../../widgets/rounded_white_container.dart'; class MyWallet extends ConsumerStatefulWidget { const MyWallet({ @@ -46,7 +47,7 @@ class _MyWalletState extends ConsumerState { ]; late final bool isEth; - late final Coin coin; + late final CryptoCurrency coin; late final bool isFrost; @override @@ -54,7 +55,7 @@ class _MyWalletState extends ConsumerState { final wallet = ref.read(pWallets).getWallet(widget.walletId); coin = wallet.info.coin; isFrost = wallet is BitcoinFrostWallet; - isEth = coin == Coin.ethereum; + isEth = coin is Ethereum; if (isEth && widget.contractAddress == null) { titles.add("Transactions"); diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/network_info_button.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/network_info_button.dart index 1ba70a0e9..488f3ac4d 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/network_info_button.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/network_info_button.dart @@ -14,18 +14,18 @@ import 'package:event_bus/event_bus.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/route_generator.dart'; -import 'package:stackwallet/services/event_bus/events/global/node_connection_status_changed_event.dart'; -import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart'; -import 'package:stackwallet/services/event_bus/global_event_bus.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../../pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart'; +import '../../../../providers/providers.dart'; +import '../../../../route_generator.dart'; +import '../../../../services/event_bus/events/global/node_connection_status_changed_event.dart'; +import '../../../../services/event_bus/events/global/wallet_sync_status_changed_event.dart'; +import '../../../../services/event_bus/global_event_bus.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../widgets/desktop/desktop_dialog_close_button.dart'; import 'package:tuple/tuple.dart'; class NetworkInfoButton extends ConsumerStatefulWidget { diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/qr_code_desktop_popup_content.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/qr_code_desktop_popup_content.dart index 4ba42d4b2..af3d18683 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/qr_code_desktop_popup_content.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/qr_code_desktop_popup_content.dart @@ -10,9 +10,9 @@ import 'package:flutter/material.dart'; import 'package:qr_flutter/qr_flutter.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../widgets/desktop/desktop_dialog_close_button.dart'; class QRCodeDesktopPopupContent extends StatelessWidget { const QRCodeDesktopPopupContent({ diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/unlock_wallet_keys_desktop.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/unlock_wallet_keys_desktop.dart index 52fe50a4f..dddf74318 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/unlock_wallet_keys_desktop.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/unlock_wallet_keys_desktop.dart @@ -13,22 +13,22 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/wallet_keys_desktop_popup.dart'; -import 'package:stackwallet/providers/desktop/storage_crypto_handler_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/wallet/impl/bitcoin_frost_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/mnemonic_interface.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/loading_indicator.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; +import '../../../../notifications/show_flush_bar.dart'; +import 'wallet_keys_desktop_popup.dart'; +import '../../../../providers/desktop/storage_crypto_handler_provider.dart'; +import '../../../../providers/providers.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../wallets/wallet/impl/bitcoin_frost_wallet.dart'; +import '../../../../wallets/wallet/wallet_mixin_interfaces/mnemonic_interface.dart'; +import '../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/desktop/secondary_button.dart'; +import '../../../../widgets/loading_indicator.dart'; +import '../../../../widgets/stack_text_field.dart'; class UnlockWalletKeysDesktop extends ConsumerStatefulWidget { const UnlockWalletKeysDesktop({ diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/wallet_keys_button.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/wallet_keys_button.dart index 464f3371a..838e2c363 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/wallet_keys_button.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/wallet_keys_button.dart @@ -10,11 +10,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/unlock_wallet_keys_desktop.dart'; -import 'package:stackwallet/route_generator.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; +import 'unlock_wallet_keys_desktop.dart'; +import '../../../../route_generator.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/text_styles.dart'; class WalletKeysButton extends StatelessWidget { const WalletKeysButton({ diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/wallet_keys_desktop_popup.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/wallet_keys_desktop_popup.dart index 606ae21f4..61bfcfebf 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/wallet_keys_desktop_popup.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/wallet_keys_desktop_popup.dart @@ -12,20 +12,20 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_view/sub_widgets/mnemonic_table.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/qr_code_desktop_popup_content.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/address_utils.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/clipboard_interface.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../../notifications/show_flush_bar.dart'; +import '../../../../pages/add_wallet_views/new_wallet_recovery_phrase_view/sub_widgets/mnemonic_table.dart'; +import '../../../../pages/wallet_view/transaction_views/transaction_details_view.dart'; +import 'qr_code_desktop_popup_content.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/address_utils.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/clipboard_interface.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/desktop/secondary_button.dart'; +import '../../../../widgets/rounded_white_container.dart'; class WalletKeysDesktopPopup extends StatelessWidget { const WalletKeysDesktopPopup({ diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/wallet_options_button.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/wallet_options_button.dart index c27b7855d..23922cd2e 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/wallet_options_button.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/wallet_options_button.dart @@ -14,20 +14,22 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/pages/settings_views/wallet_settings_view/frost_ms/frost_ms_options_view.dart'; -import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/change_representative_view.dart'; -import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/xpub_view.dart'; -import 'package:stackwallet/pages_desktop_specific/addresses/desktop_wallet_addresses_view.dart'; -import 'package:stackwallet/pages_desktop_specific/lelantus_coins/lelantus_coins_view.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_delete_wallet_dialog.dart'; -import 'package:stackwallet/pages_desktop_specific/spark_coins/spark_coins_view.dart'; -import 'package:stackwallet/route_generator.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; +import '../../../../pages/settings_views/wallet_settings_view/frost_ms/frost_ms_options_view.dart'; +import '../../../../pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/change_representative_view.dart'; +import '../../../../pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/xpub_view.dart'; +import '../../../addresses/desktop_wallet_addresses_view.dart'; +import '../../../lelantus_coins/lelantus_coins_view.dart'; +import 'desktop_delete_wallet_dialog.dart'; +import '../../../spark_coins/spark_coins_view.dart'; +import '../../../../route_generator.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../wallets/crypto_currency/coins/firo.dart'; +import '../../../../wallets/crypto_currency/intermediate/frost_currency.dart'; +import '../../../../wallets/crypto_currency/intermediate/nano_currency.dart'; +import '../../../../wallets/isar/providers/wallet_info_provider.dart'; enum _WalletOptions { addressList, @@ -60,9 +62,9 @@ enum _WalletOptions { class WalletOptionsButton extends StatelessWidget { const WalletOptionsButton({ - Key? key, + super.key, required this.walletId, - }) : super(key: key); + }); final String walletId; @@ -250,7 +252,7 @@ class WalletOptionsButton extends StatelessWidget { class WalletOptionsPopupMenu extends ConsumerWidget { const WalletOptionsPopupMenu({ - Key? key, + super.key, required this.onDeletePressed, required this.onAddressListPressed, required this.onShowXpubPressed, @@ -259,7 +261,7 @@ class WalletOptionsPopupMenu extends ConsumerWidget { required this.onFiroShowSparkCoins, required this.onFrostMSWalletOptionsPressed, required this.walletId, - }) : super(key: key); + }); final VoidCallback onDeletePressed; final VoidCallback onAddressListPressed; @@ -274,17 +276,15 @@ class WalletOptionsPopupMenu extends ConsumerWidget { Widget build(BuildContext context, WidgetRef ref) { final coin = ref.watch(pWalletCoin(walletId)); - final firoDebug = - kDebugMode && (coin == Coin.firo || coin == Coin.firoTestNet); + final firoDebug = kDebugMode && (coin is Firo); // TODO: [prio=low] // final bool xpubEnabled = manager.hasXPub; final bool xpubEnabled = false; - final bool canChangeRep = coin == Coin.nano || coin == Coin.banano; + final bool canChangeRep = coin is NanoCurrency; - final bool isFrost = - coin == Coin.bitcoinFrost || coin == Coin.bitcoinFrostTestNet; + final bool isFrost = coin is FrostCurrency; return Stack( children: [ diff --git a/lib/pages_desktop_specific/notifications/desktop_notifications_view.dart b/lib/pages_desktop_specific/notifications/desktop_notifications_view.dart index eeb90e92c..bc05bafa6 100644 --- a/lib/pages_desktop_specific/notifications/desktop_notifications_view.dart +++ b/lib/pages_desktop_specific/notifications/desktop_notifications_view.dart @@ -10,14 +10,14 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/notifications/notification_card.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/providers/ui/unread_notifications_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../notifications/notification_card.dart'; +import '../../providers/providers.dart'; +import '../../providers/ui/unread_notifications_provider.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/text_styles.dart'; +import '../../widgets/desktop/desktop_app_bar.dart'; +import '../../widgets/desktop/desktop_scaffold.dart'; +import '../../widgets/rounded_white_container.dart'; class DesktopNotificationsView extends ConsumerStatefulWidget { const DesktopNotificationsView({Key? key}) : super(key: key); diff --git a/lib/pages_desktop_specific/ordinals/desktop_ordinal_details_view.dart b/lib/pages_desktop_specific/ordinals/desktop_ordinal_details_view.dart index b258d0a5e..83a865e1e 100644 --- a/lib/pages_desktop_specific/ordinals/desktop_ordinal_details_view.dart +++ b/lib/pages_desktop_specific/ordinals/desktop_ordinal_details_view.dart @@ -5,28 +5,27 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:path_provider/path_provider.dart'; import 'package:permission_handler/permission_handler.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/utxo.dart'; -import 'package:stackwallet/models/isar/ordinal.dart'; -import 'package:stackwallet/networking/http.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/prefs.dart'; -import 'package:stackwallet/utilities/show_loading.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../models/isar/models/blockchain_data/utxo.dart'; +import '../../models/isar/ordinal.dart'; +import '../../networking/http.dart'; +import '../../notifications/show_flush_bar.dart'; +import '../../pages/wallet_view/transaction_views/transaction_details_view.dart'; +import '../../providers/db/main_db_provider.dart'; +import '../../providers/global/wallets_provider.dart'; +import '../../services/tor_service.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/amount/amount.dart'; +import '../../utilities/amount/amount_formatter.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/prefs.dart'; +import '../../utilities/show_loading.dart'; +import '../../utilities/text_styles.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/desktop/desktop_app_bar.dart'; +import '../../widgets/desktop/desktop_scaffold.dart'; +import '../../widgets/desktop/secondary_button.dart'; +import '../../widgets/rounded_white_container.dart'; class DesktopOrdinalDetailsView extends ConsumerStatefulWidget { const DesktopOrdinalDetailsView({ @@ -298,7 +297,7 @@ class _DesktopOrdinalDetailsViewState : ref.watch(pAmountFormatter(coin)).format( Amount( rawValue: BigInt.from(utxo!.value), - fractionDigits: coin.decimals, + fractionDigits: coin.fractionDigits, ), ), ); diff --git a/lib/pages_desktop_specific/ordinals/desktop_ordinals_view.dart b/lib/pages_desktop_specific/ordinals/desktop_ordinals_view.dart index c710a4d10..3ab866f27 100644 --- a/lib/pages_desktop_specific/ordinals/desktop_ordinals_view.dart +++ b/lib/pages_desktop_specific/ordinals/desktop_ordinals_view.dart @@ -11,17 +11,17 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/pages/ordinals/widgets/ordinals_list.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/show_loading.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/ordinals_interface.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; +import '../../pages/ordinals/widgets/ordinals_list.dart'; +import '../../providers/providers.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/show_loading.dart'; +import '../../utilities/text_styles.dart'; +import '../../wallets/wallet/wallet_mixin_interfaces/ordinals_interface.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/desktop/desktop_app_bar.dart'; +import '../../widgets/desktop/desktop_scaffold.dart'; +import '../../widgets/desktop/secondary_button.dart'; class DesktopOrdinalsView extends ConsumerStatefulWidget { const DesktopOrdinalsView({ diff --git a/lib/pages_desktop_specific/password/create_password_view.dart b/lib/pages_desktop_specific/password/create_password_view.dart index a8c129f90..31f070982 100644 --- a/lib/pages_desktop_specific/password/create_password_view.dart +++ b/lib/pages_desktop_specific/password/create_password_view.dart @@ -13,22 +13,22 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_home_view.dart'; -import 'package:stackwallet/pages_desktop_specific/password/forgotten_passphrase_restore_from_swb.dart'; -import 'package:stackwallet/providers/desktop/storage_crypto_handler_provider.dart'; -import 'package:stackwallet/providers/global/secure_store_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/progress_bar.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; +import '../../notifications/show_flush_bar.dart'; +import '../desktop_home_view.dart'; +import 'forgotten_passphrase_restore_from_swb.dart'; +import '../../providers/desktop/storage_crypto_handler_provider.dart'; +import '../../providers/global/secure_store_provider.dart'; +import '../../providers/providers.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/flutter_secure_storage_interface.dart'; +import '../../utilities/text_styles.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/desktop/desktop_app_bar.dart'; +import '../../widgets/desktop/desktop_scaffold.dart'; +import '../../widgets/progress_bar.dart'; +import '../../widgets/stack_text_field.dart'; import 'package:zxcvbn/zxcvbn.dart'; class CreatePasswordView extends ConsumerStatefulWidget { diff --git a/lib/pages_desktop_specific/password/delete_password_warning_view.dart b/lib/pages_desktop_specific/password/delete_password_warning_view.dart index 22fb801c7..7708c2230 100644 --- a/lib/pages_desktop_specific/password/delete_password_warning_view.dart +++ b/lib/pages_desktop_specific/password/delete_password_warning_view.dart @@ -13,27 +13,27 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:flutter_svg/svg.dart'; import 'package:hive/hive.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/db/hive/db.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/intro_view.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/stack_file_system.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; + +import '../../db/hive/db.dart'; +import '../../notifications/show_flush_bar.dart'; +import '../../pages/intro_view.dart'; +import '../../utilities/logger.dart'; +import '../../utilities/stack_file_system.dart'; +import '../../utilities/text_styles.dart'; +import '../../widgets/app_icon.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/desktop/desktop_app_bar.dart'; +import '../../widgets/desktop/desktop_scaffold.dart'; +import '../../widgets/desktop/primary_button.dart'; +import '../../widgets/desktop/secondary_button.dart'; class DeletePasswordWarningView extends ConsumerStatefulWidget { const DeletePasswordWarningView({ - Key? key, + super.key, required this.shouldCreateNew, - }) : super(key: key); + }); static const String routeName = "/deletePasswordWarning"; @@ -119,14 +119,7 @@ class _ForgotPasswordDesktopViewState child: Column( mainAxisSize: MainAxisSize.min, children: [ - SvgPicture.file( - File( - ref.watch( - themeProvider.select( - (value) => value.assets.stackIcon, - ), - ), - ), + const AppIcon( width: 100, ), const SizedBox( diff --git a/lib/pages_desktop_specific/password/desktop_login_view.dart b/lib/pages_desktop_specific/password/desktop_login_view.dart index 2597704fe..62e3b70fe 100644 --- a/lib/pages_desktop_specific/password/desktop_login_view.dart +++ b/lib/pages_desktop_specific/password/desktop_login_view.dart @@ -9,39 +9,40 @@ */ import 'dart:async'; -import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/db/db_version_migration.dart'; -import 'package:stackwallet/db/hive/db.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_home_view.dart'; -import 'package:stackwallet/pages_desktop_specific/password/forgot_password_desktop_view.dart'; -import 'package:stackwallet/providers/desktop/storage_crypto_handler_provider.dart'; -import 'package:stackwallet/providers/global/secure_store_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/loading_indicator.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; + +import '../../app_config.dart'; +import '../../db/db_version_migration.dart'; +import '../../db/hive/db.dart'; +import '../../notifications/show_flush_bar.dart'; +import '../../providers/desktop/storage_crypto_handler_provider.dart'; +import '../../providers/global/secure_store_provider.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/flutter_secure_storage_interface.dart'; +import '../../utilities/logger.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import '../../widgets/app_icon.dart'; +import '../../widgets/custom_buttons/blue_text_button.dart'; +import '../../widgets/desktop/desktop_scaffold.dart'; +import '../../widgets/desktop/primary_button.dart'; +import '../../widgets/loading_indicator.dart'; +import '../../widgets/rounded_container.dart'; +import '../../widgets/stack_text_field.dart'; +import '../desktop_home_view.dart'; +import 'forgot_password_desktop_view.dart'; class DesktopLoginView extends ConsumerStatefulWidget { const DesktopLoginView({ - Key? key, + super.key, this.startupWalletId, this.load, - }) : super(key: key); + }); static const String routeName = "/desktopLogin"; @@ -186,21 +187,14 @@ class _DesktopLoginViewState extends ConsumerState { child: Column( mainAxisSize: MainAxisSize.min, children: [ - SvgPicture.file( - File( - ref.watch( - themeProvider.select( - (value) => value.assets.stackIcon, - ), - ), - ), + const AppIcon( width: 100, ), const SizedBox( height: 42, ), Text( - "Stack Wallet", + AppConfig.appName, style: STextStyles.desktopH1(context), ), const SizedBox( diff --git a/lib/pages_desktop_specific/password/forgot_password_desktop_view.dart b/lib/pages_desktop_specific/password/forgot_password_desktop_view.dart index 0de5069e8..235f14563 100644 --- a/lib/pages_desktop_specific/password/forgot_password_desktop_view.dart +++ b/lib/pages_desktop_specific/password/forgot_password_desktop_view.dart @@ -8,25 +8,24 @@ * */ -import 'dart:io'; - import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/pages_desktop_specific/password/delete_password_warning_view.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; + +import '../../app_config.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/text_styles.dart'; +import '../../widgets/app_icon.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/desktop/desktop_app_bar.dart'; +import '../../widgets/desktop/desktop_scaffold.dart'; +import '../../widgets/desktop/primary_button.dart'; +import '../../widgets/desktop/secondary_button.dart'; +import 'delete_password_warning_view.dart'; class ForgotPasswordDesktopView extends ConsumerStatefulWidget { const ForgotPasswordDesktopView({ - Key? key, - }) : super(key: key); + super.key, + }); static const String routeName = "/forgotPasswordDesktop"; @@ -59,21 +58,14 @@ class _ForgotPasswordDesktopViewState child: Column( mainAxisSize: MainAxisSize.min, children: [ - SvgPicture.file( - File( - ref.watch( - themeProvider.select( - (value) => value.assets.stackIcon, - ), - ), - ), + const AppIcon( width: 100, ), const SizedBox( height: 42, ), Text( - "Stack Wallet", + AppConfig.appName, style: STextStyles.desktopH1(context), ), const SizedBox( @@ -82,7 +74,7 @@ class _ForgotPasswordDesktopViewState SizedBox( width: 400, child: Text( - "Stack Wallet does not store your password. Create new wallet or use a Stack backup file to restore your wallet.", + "${AppConfig.appName} does not store your password. Create new wallet or use a Stack backup file to restore your wallet.", textAlign: TextAlign.center, style: STextStyles.desktopTextSmall(context).copyWith( color: Theme.of(context) diff --git a/lib/pages_desktop_specific/password/forgotten_passphrase_restore_from_swb.dart b/lib/pages_desktop_specific/password/forgotten_passphrase_restore_from_swb.dart index e61f4ee24..b1efe30f1 100644 --- a/lib/pages_desktop_specific/password/forgotten_passphrase_restore_from_swb.dart +++ b/lib/pages_desktop_specific/password/forgotten_passphrase_restore_from_swb.dart @@ -15,28 +15,29 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/db/hive/db.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/helpers/swb_file_system.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/sub_views/stack_restore_progress_view.dart'; -import 'package:stackwallet/pages_desktop_specific/password/create_password_view.dart'; -import 'package:stackwallet/providers/desktop/storage_crypto_handler_provider.dart'; -import 'package:stackwallet/providers/global/secure_store_provider.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/loading_indicator.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; +import '../../app_config.dart'; +import '../../db/hive/db.dart'; +import '../../notifications/show_flush_bar.dart'; +import '../../pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart'; +import '../../pages/settings_views/global_settings_view/stack_backup_views/helpers/swb_file_system.dart'; +import '../../pages/settings_views/global_settings_view/stack_backup_views/sub_views/stack_restore_progress_view.dart'; +import 'create_password_view.dart'; +import '../../providers/desktop/storage_crypto_handler_provider.dart'; +import '../../providers/global/secure_store_provider.dart'; +import '../../providers/global/wallets_provider.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/flutter_secure_storage_interface.dart'; +import '../../utilities/logger.dart'; +import '../../utilities/text_styles.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/desktop/desktop_app_bar.dart'; +import '../../widgets/desktop/desktop_dialog.dart'; +import '../../widgets/desktop/desktop_scaffold.dart'; +import '../../widgets/desktop/primary_button.dart'; +import '../../widgets/loading_indicator.dart'; +import '../../widgets/stack_text_field.dart'; import 'package:tuple/tuple.dart'; class ForgottenPassphraseRestoreFromSWB extends ConsumerStatefulWidget { @@ -117,7 +118,7 @@ class _ForgottenPassphraseRestoreFromSWBState final String? jsonString = await compute( SWB.decryptStackWalletWithPassphrase, Tuple2(fileToRestore, passphrase), - debugLabel: "stack wallet decryption compute", + debugLabel: "${AppConfig.appName} decryption compute", ); if (mounted) { @@ -154,7 +155,7 @@ class _ForgottenPassphraseRestoreFromSWBState mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text( - "Restoring Stack wallet", + "Restoring {$AppConfig.appName}", style: STextStyles.desktopH3(context), ), ], diff --git a/lib/pages_desktop_specific/settings/desktop_settings_view.dart b/lib/pages_desktop_specific/settings/desktop_settings_view.dart index 5d95cd960..3ecf30375 100644 --- a/lib/pages_desktop_specific/settings/desktop_settings_view.dart +++ b/lib/pages_desktop_specific/settings/desktop_settings_view.dart @@ -10,21 +10,21 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/pages_desktop_specific/settings/settings_menu.dart'; -import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/advanced_settings/advanced_settings.dart'; -import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/appearance_settings/appearance_settings.dart'; -import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/backup_and_restore/backup_and_restore_settings.dart'; -import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/currency_settings/currency_settings.dart'; -import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/language_settings/language_settings.dart'; -import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/nodes_settings.dart'; -import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/security_settings.dart'; -import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/syncing_preferences_settings.dart'; -import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/tor_settings/tor_settings.dart'; -import 'package:stackwallet/route_generator.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; +import 'settings_menu.dart'; +import 'settings_menu/advanced_settings/advanced_settings.dart'; +import 'settings_menu/appearance_settings/appearance_settings.dart'; +import 'settings_menu/backup_and_restore/backup_and_restore_settings.dart'; +import 'settings_menu/currency_settings/currency_settings.dart'; +import 'settings_menu/language_settings/language_settings.dart'; +import 'settings_menu/nodes_settings.dart'; +import 'settings_menu/security_settings.dart'; +import 'settings_menu/syncing_preferences_settings.dart'; +import 'settings_menu/tor_settings/tor_settings.dart'; +import '../../route_generator.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/text_styles.dart'; +import '../../widgets/desktop/desktop_app_bar.dart'; +import '../../widgets/desktop/desktop_scaffold.dart'; class DesktopSettingsView extends ConsumerStatefulWidget { const DesktopSettingsView({Key? key}) : super(key: key); diff --git a/lib/pages_desktop_specific/settings/settings_menu.dart b/lib/pages_desktop_specific/settings/settings_menu.dart index ba2c21781..d12cdea34 100644 --- a/lib/pages_desktop_specific/settings/settings_menu.dart +++ b/lib/pages_desktop_specific/settings/settings_menu.dart @@ -11,9 +11,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/pages_desktop_specific/settings/settings_menu_item.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; +import 'settings_menu_item.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; final selectedSettingsMenuItemStateProvider = StateProvider((_) => 0); diff --git a/lib/pages_desktop_specific/settings/settings_menu/advanced_settings/advanced_settings.dart b/lib/pages_desktop_specific/settings/settings_menu/advanced_settings/advanced_settings.dart index 102a547d6..69661e04c 100644 --- a/lib/pages_desktop_specific/settings/settings_menu/advanced_settings/advanced_settings.dart +++ b/lib/pages_desktop_specific/settings/settings_menu/advanced_settings/advanced_settings.dart @@ -11,17 +11,17 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/advanced_views/manage_coin_units/manage_coin_units_view.dart'; -import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/advanced_settings/debug_info_dialog.dart'; -import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/advanced_settings/desktop_manage_block_explorers_dialog.dart'; -import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/advanced_settings/stack_privacy_dialog.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/custom_buttons/draggable_switch_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../../pages/settings_views/global_settings_view/advanced_views/manage_coin_units/manage_coin_units_view.dart'; +import 'debug_info_dialog.dart'; +import 'desktop_manage_block_explorers_dialog.dart'; +import 'stack_privacy_dialog.dart'; +import '../../../../providers/global/prefs_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../widgets/custom_buttons/draggable_switch_button.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/rounded_white_container.dart'; class AdvancedSettings extends ConsumerStatefulWidget { const AdvancedSettings({Key? key}) : super(key: key); diff --git a/lib/pages_desktop_specific/settings/settings_menu/advanced_settings/debug_info_dialog.dart b/lib/pages_desktop_specific/settings/settings_menu/advanced_settings/debug_info_dialog.dart index c9a476d04..9ce77873e 100644 --- a/lib/pages_desktop_specific/settings/settings_menu/advanced_settings/debug_info_dialog.dart +++ b/lib/pages_desktop_specific/settings/settings_menu/advanced_settings/debug_info_dialog.dart @@ -13,23 +13,23 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/models/isar/models/log.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/providers/global/debug_service_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/log_level_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../../../models/isar/models/log.dart'; +import '../../../../notifications/show_flush_bar.dart'; +import '../../../../providers/global/debug_service_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/enums/log_level_enum.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/desktop/secondary_button.dart'; +import '../../../../widgets/icon_widgets/x_icon.dart'; +import '../../../../widgets/rounded_container.dart'; +import '../../../../widgets/stack_text_field.dart'; +import '../../../../widgets/textfield_icon_button.dart'; class DebugInfoDialog extends ConsumerStatefulWidget { const DebugInfoDialog({Key? key}) : super(key: key); diff --git a/lib/pages_desktop_specific/settings/settings_menu/advanced_settings/desktop_manage_block_explorers_dialog.dart b/lib/pages_desktop_specific/settings/settings_menu/advanced_settings/desktop_manage_block_explorers_dialog.dart index 2fd6431c1..45eed9054 100644 --- a/lib/pages_desktop_specific/settings/settings_menu/advanced_settings/desktop_manage_block_explorers_dialog.dart +++ b/lib/pages_desktop_specific/settings/settings_menu/advanced_settings/desktop_manage_block_explorers_dialog.dart @@ -13,34 +13,37 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/themes/coin_icon_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/block_explorers.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../../providers/global/prefs_provider.dart'; +import '../../../../app_config.dart'; +import '../../../../themes/coin_icon_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/block_explorers.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/desktop/secondary_button.dart'; +import '../../../../widgets/rounded_white_container.dart'; class DesktopManageBlockExplorersDialog extends ConsumerWidget { const DesktopManageBlockExplorersDialog({ - Key? key, - }) : super(key: key); + super.key, + }); @override Widget build(BuildContext context, WidgetRef ref) { - bool showTestNet = ref.watch( + final bool showTestNet = ref.watch( prefsChangeNotifierProvider.select((value) => value.showTestNetCoins), ); - final List coins = showTestNet - ? Coin.values - : Coin.values.where((e) => !e.isTestNet).toList(); + final coins = AppConfig.coins + .where( + (e) => showTestNet || e.network == CryptoCurrencyNetwork.main, + ) + .toList(); return DesktopDialog( maxHeight: 850, @@ -139,7 +142,7 @@ class _DesktopEditBlockExplorerDialog extends ConsumerStatefulWidget { const _DesktopEditBlockExplorerDialog({Key? key, required this.coin}) : super(key: key); - final Coin coin; + final CryptoCurrency coin; @override ConsumerState<_DesktopEditBlockExplorerDialog> createState() => diff --git a/lib/pages_desktop_specific/settings/settings_menu/advanced_settings/stack_privacy_dialog.dart b/lib/pages_desktop_specific/settings/settings_menu/advanced_settings/stack_privacy_dialog.dart index 2b3009dc0..8ebf89c70 100644 --- a/lib/pages_desktop_specific/settings/settings_menu/advanced_settings/stack_privacy_dialog.dart +++ b/lib/pages_desktop_specific/settings/settings_menu/advanced_settings/stack_privacy_dialog.dart @@ -14,21 +14,21 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/db/hive/db.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/providers/global/price_provider.dart'; -import 'package:stackwallet/services/exchange/exchange_data_loading_service.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../../db/hive/db.dart'; +import '../../../../providers/global/prefs_provider.dart'; +import '../../../../providers/global/price_provider.dart'; +import '../../../../services/exchange/exchange_data_loading_service.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../themes/theme_providers.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/desktop/secondary_button.dart'; +import '../../../../widgets/rounded_white_container.dart'; class StackPrivacyDialog extends ConsumerStatefulWidget { const StackPrivacyDialog({Key? key}) : super(key: key); diff --git a/lib/pages_desktop_specific/settings/settings_menu/appearance_settings/appearance_settings.dart b/lib/pages_desktop_specific/settings/settings_menu/appearance_settings/appearance_settings.dart index d71dba011..8fa05124b 100644 --- a/lib/pages_desktop_specific/settings/settings_menu/appearance_settings/appearance_settings.dart +++ b/lib/pages_desktop_specific/settings/settings_menu/appearance_settings/appearance_settings.dart @@ -14,22 +14,23 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/models/isar/stack_theme.dart'; -import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/appearance_settings/sub_widgets/desktop_manage_themes.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/themes/theme_service.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/custom_buttons/draggable_switch_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../../app_config.dart'; +import '../../../../models/isar/stack_theme.dart'; +import 'sub_widgets/desktop_manage_themes.dart'; +import '../../../../providers/db/main_db_provider.dart'; +import '../../../../providers/global/prefs_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../themes/theme_providers.dart'; +import '../../../../themes/theme_service.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../widgets/custom_buttons/draggable_switch_button.dart'; +import '../../../../widgets/rounded_white_container.dart'; import 'package:tuple/tuple.dart'; class AppearanceOptionSettings extends ConsumerStatefulWidget { - const AppearanceOptionSettings({Key? key}) : super(key: key); + const AppearanceOptionSettings({super.key}); static const String routeName = "/settingsMenuAppearance"; @@ -44,132 +45,139 @@ class _AppearanceOptionSettings Widget build(BuildContext context) { debugPrint("BUILD: $runtimeType"); return SingleChildScrollView( - child: Column( - children: [ - Padding( - padding: const EdgeInsets.only( - right: 30, - ), - child: RoundedWhiteContainer( - radiusMultiplier: 2, - child: Wrap( - children: [ - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Padding( - padding: const EdgeInsets.all(8.0), - child: SvgPicture.asset( - Assets.svg.circleSun, - width: 48, - height: 48, - ), - ), - Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Padding( - padding: const EdgeInsets.all(10), - child: RichText( - textAlign: TextAlign.left, - text: TextSpan( - children: [ - TextSpan( - text: "Appearances", - style: STextStyles.desktopTextSmall(context), - ), - TextSpan( - text: - "\n\nCustomize how your Stack Wallet looks according to your preferences.", - style: STextStyles.desktopTextExtraExtraSmall( - context), - ), - ], - ), - ), + child: Column( + children: [ + Padding( + padding: const EdgeInsets.only( + right: 30, + ), + child: RoundedWhiteContainer( + radiusMultiplier: 2, + child: Wrap( + children: [ + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: SvgPicture.asset( + Assets.svg.circleSun, + width: 48, + height: 48, ), - ], - ), - const Padding( - padding: EdgeInsets.all(10.0), - child: Divider( - thickness: 0.5, ), - ), - Padding( - padding: const EdgeInsets.all(10.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, + Column( + crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - Text( - "Display favorite wallets", - style: STextStyles.desktopTextExtraSmall(context) - .copyWith( - color: Theme.of(context) - .extension()! - .textDark), - textAlign: TextAlign.left, - ), - SizedBox( - height: 20, - width: 40, - child: DraggableSwitchButton( - isOn: ref.watch( - prefsChangeNotifierProvider.select( - (value) => value.showFavoriteWallets), + Padding( + padding: const EdgeInsets.all(10), + child: RichText( + textAlign: TextAlign.left, + text: TextSpan( + children: [ + TextSpan( + text: "Appearances", + style: + STextStyles.desktopTextSmall(context), + ), + TextSpan( + text: + "\n\nCustomize how your ${AppConfig.appName} looks according to your preferences.", + style: + STextStyles.desktopTextExtraExtraSmall( + context, + ), + ), + ], ), - onValueChanged: (newValue) { - ref - .read(prefsChangeNotifierProvider) - .showFavoriteWallets = newValue; - }, ), - ) - ], - ), - ), - const Padding( - padding: EdgeInsets.all(10.0), - child: Divider( - thickness: 0.5, - ), - ), - Padding( - padding: const EdgeInsets.all(10.0), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - "Choose theme", - style: STextStyles.desktopTextExtraSmall(context) - .copyWith( - color: Theme.of(context) - .extension()! - .textDark), - textAlign: TextAlign.left, ), ], ), - ), - const Padding( - padding: EdgeInsets.all(2), - child: ThemeToggle(), - ), - ], - ), - ], + const Padding( + padding: EdgeInsets.all(10.0), + child: Divider( + thickness: 0.5, + ), + ), + Padding( + padding: const EdgeInsets.all(10.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Display favorite wallets", + style: STextStyles.desktopTextExtraSmall(context) + .copyWith( + color: Theme.of(context) + .extension()! + .textDark, + ), + textAlign: TextAlign.left, + ), + SizedBox( + height: 20, + width: 40, + child: DraggableSwitchButton( + isOn: ref.watch( + prefsChangeNotifierProvider.select( + (value) => value.showFavoriteWallets, + ), + ), + onValueChanged: (newValue) { + ref + .read(prefsChangeNotifierProvider) + .showFavoriteWallets = newValue; + }, + ), + ), + ], + ), + ), + const Padding( + padding: EdgeInsets.all(10.0), + child: Divider( + thickness: 0.5, + ), + ), + Padding( + padding: const EdgeInsets.all(10.0), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + "Choose theme", + style: STextStyles.desktopTextExtraSmall(context) + .copyWith( + color: Theme.of(context) + .extension()! + .textDark, + ), + textAlign: TextAlign.left, + ), + ], + ), + ), + const Padding( + padding: EdgeInsets.all(2), + child: ThemeToggle(), + ), + ], + ), + ], + ), ), ), - ), - ], - )); + ], + ), + ); } } class ThemeToggle extends ConsumerStatefulWidget { const ThemeToggle({ - Key? key, - }) : super(key: key); + super.key, + }); @override ConsumerState createState() => _ThemeToggle(); diff --git a/lib/pages_desktop_specific/settings/settings_menu/appearance_settings/sub_widgets/desktop_install_theme.dart b/lib/pages_desktop_specific/settings/settings_menu/appearance_settings/sub_widgets/desktop_install_theme.dart index 243f2e570..1126cbbfe 100644 --- a/lib/pages_desktop_specific/settings/settings_menu/appearance_settings/sub_widgets/desktop_install_theme.dart +++ b/lib/pages_desktop_specific/settings/settings_menu/appearance_settings/sub_widgets/desktop_install_theme.dart @@ -14,15 +14,15 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:share_plus/share_plus.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/themes/theme_service.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/show_loading.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/desktop/outline_blue_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; +import '../../../../../themes/stack_colors.dart'; +import '../../../../../themes/theme_service.dart'; +import '../../../../../utilities/assets.dart'; +import '../../../../../utilities/logger.dart'; +import '../../../../../utilities/show_loading.dart'; +import '../../../../../utilities/text_styles.dart'; +import '../../../../../widgets/desktop/outline_blue_button.dart'; +import '../../../../../widgets/desktop/primary_button.dart'; +import '../../../../../widgets/rounded_container.dart'; class DesktopInstallTheme extends ConsumerStatefulWidget { const DesktopInstallTheme({Key? key}) : super(key: key); diff --git a/lib/pages_desktop_specific/settings/settings_menu/appearance_settings/sub_widgets/desktop_manage_themes.dart b/lib/pages_desktop_specific/settings/settings_menu/appearance_settings/sub_widgets/desktop_manage_themes.dart index d4e6ec20b..bf04e48f1 100644 --- a/lib/pages_desktop_specific/settings/settings_menu/appearance_settings/sub_widgets/desktop_manage_themes.dart +++ b/lib/pages_desktop_specific/settings/settings_menu/appearance_settings/sub_widgets/desktop_manage_themes.dart @@ -10,14 +10,14 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/appearance_settings/sub_widgets/desktop_install_theme.dart'; -import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/appearance_settings/sub_widgets/desktop_themes_gallery.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/toggle.dart'; +import 'desktop_install_theme.dart'; +import 'desktop_themes_gallery.dart'; +import '../../../../../themes/stack_colors.dart'; +import '../../../../../utilities/constants.dart'; +import '../../../../../utilities/text_styles.dart'; +import '../../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../../../widgets/toggle.dart'; class DesktopManageThemesDialog extends ConsumerStatefulWidget { const DesktopManageThemesDialog({Key? key}) : super(key: key); diff --git a/lib/pages_desktop_specific/settings/settings_menu/appearance_settings/sub_widgets/desktop_themes_gallery.dart b/lib/pages_desktop_specific/settings/settings_menu/appearance_settings/sub_widgets/desktop_themes_gallery.dart index 41e33fb3a..160fd67f5 100644 --- a/lib/pages_desktop_specific/settings/settings_menu/appearance_settings/sub_widgets/desktop_themes_gallery.dart +++ b/lib/pages_desktop_specific/settings/settings_menu/appearance_settings/sub_widgets/desktop_themes_gallery.dart @@ -12,15 +12,15 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/appearance_settings/manage_themes.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/appearance_settings/sub_widgets/stack_theme_card.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/themes/theme_service.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/loading_indicator.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../../../pages/settings_views/global_settings_view/appearance_settings/manage_themes.dart'; +import '../../../../../pages/settings_views/global_settings_view/appearance_settings/sub_widgets/stack_theme_card.dart'; +import '../../../../../providers/global/prefs_provider.dart'; +import '../../../../../themes/stack_colors.dart'; +import '../../../../../themes/theme_service.dart'; +import '../../../../../utilities/text_styles.dart'; +import '../../../../../widgets/desktop/primary_button.dart'; +import '../../../../../widgets/loading_indicator.dart'; +import '../../../../../widgets/rounded_white_container.dart'; class DesktopThemeGallery extends ConsumerStatefulWidget { const DesktopThemeGallery({ diff --git a/lib/pages_desktop_specific/settings/settings_menu/backup_and_restore/backup_and_restore_settings.dart b/lib/pages_desktop_specific/settings/settings_menu/backup_and_restore/backup_and_restore_settings.dart index 51a82619c..7453e5063 100644 --- a/lib/pages_desktop_specific/settings/settings_menu/backup_and_restore/backup_and_restore_settings.dart +++ b/lib/pages_desktop_specific/settings/settings_menu/backup_and_restore/backup_and_restore_settings.dart @@ -13,32 +13,33 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:intl/intl.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/create_backup_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/edit_auto_backup_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/restore_from_file_view.dart'; -import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/backup_and_restore/create_auto_backup.dart'; -import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/backup_and_restore/enable_backup_dialog.dart'; -import 'package:stackwallet/providers/global/auto_swb_service_provider.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/enums/backup_frequency_type.dart'; -import 'package:stackwallet/utilities/format.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/custom_buttons/draggable_switch_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../../../app_config.dart'; +import '../../../../pages/settings_views/global_settings_view/stack_backup_views/create_backup_view.dart'; +import '../../../../pages/settings_views/global_settings_view/stack_backup_views/edit_auto_backup_view.dart'; +import '../../../../pages/settings_views/global_settings_view/stack_backup_views/restore_from_file_view.dart'; +import 'create_auto_backup.dart'; +import 'enable_backup_dialog.dart'; +import '../../../../providers/global/auto_swb_service_provider.dart'; +import '../../../../providers/global/prefs_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/enums/backup_frequency_type.dart'; +import '../../../../utilities/format.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../widgets/custom_buttons/blue_text_button.dart'; +import '../../../../widgets/custom_buttons/draggable_switch_button.dart'; +import '../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/desktop/secondary_button.dart'; +import '../../../../widgets/rounded_container.dart'; +import '../../../../widgets/rounded_white_container.dart'; +import '../../../../widgets/stack_dialog.dart'; import 'package:url_launcher/url_launcher.dart'; class BackupRestoreSettings extends ConsumerStatefulWidget { - const BackupRestoreSettings({Key? key}) : super(key: key); + const BackupRestoreSettings({super.key}); static const String routeName = "/settingsMenuBackupRestore"; @@ -299,7 +300,8 @@ class _BackupRestoreSettings extends ConsumerState { fileLocationController.text = ref.read(prefsChangeNotifierProvider).autoBackupLocation ?? " "; frequencyController.text = Format.prettyFrequencyType( - ref.read(prefsChangeNotifierProvider).backupFrequencyType); + ref.read(prefsChangeNotifierProvider).backupFrequencyType, + ); fileLocationFocusNode = FocusNode(); passwordFocusNode = FocusNode(); @@ -324,8 +326,9 @@ class _BackupRestoreSettings extends ConsumerState { Widget build(BuildContext context) { debugPrint("BUILD: $runtimeType"); - bool isEnabledAutoBackup = ref.watch(prefsChangeNotifierProvider - .select((value) => value.isAutoBackupEnabled)); + final bool isEnabledAutoBackup = ref.watch( + prefsChangeNotifierProvider.select((value) => value.isAutoBackupEnabled), + ); ref.listen( prefsChangeNotifierProvider @@ -334,8 +337,9 @@ class _BackupRestoreSettings extends ConsumerState { frequencyController.text = Format.prettyFrequencyType(next); }); - return LayoutBuilder(builder: (context, constraints) { - return SingleChildScrollView( + return LayoutBuilder( + builder: (context, constraints) { + return SingleChildScrollView( scrollDirection: Axis.vertical, child: ConstrainedBox( constraints: BoxConstraints( @@ -386,23 +390,26 @@ class _BackupRestoreSettings extends ConsumerState { TextSpan( text: "Auto Backup", style: STextStyles.desktopTextSmall( - context), + context, + ), ), TextSpan( text: - "\n\nAuto backup is a custom Stack Wallet feature that offers a convenient backup of your data." + "\n\nAuto backup is a custom ${AppConfig.appName} feature that offers a convenient backup of your data." "To ensure maximum security, we recommend using a unique password that you haven't used anywhere " "else on the internet before. Your password is not stored.", style: STextStyles .desktopTextExtraExtraSmall( - context), + context, + ), ), TextSpan( text: "\n\nFor more information, please see our website ", style: STextStyles .desktopTextExtraExtraSmall( - context), + context, + ), ), TextSpan( text: "stackwallet.com", @@ -412,7 +419,8 @@ class _BackupRestoreSettings extends ConsumerState { ..onTap = () { launchUrl( Uri.parse( - "https://stackwallet.com/"), + "https://stackwallet.com/", + ), mode: LaunchMode .externalApplication, ); @@ -458,14 +466,16 @@ class _BackupRestoreSettings extends ConsumerState { "Backed up ${prettySinceLastBackupString(ref.watch(prefsChangeNotifierProvider.select((value) => value.lastAutoBackup)))}", style: STextStyles.itemSubtitle( - context), + context, + ), ), CustomTextButton( text: "Back up now", onTap: () { ref .read( - autoSWBServiceProvider) + autoSWBServiceProvider, + ) .doBackup(); }, ), @@ -495,7 +505,7 @@ class _BackupRestoreSettings extends ConsumerState { }, ), ], - ) + ), ], ), ), @@ -539,7 +549,8 @@ class _BackupRestoreSettings extends ConsumerState { TextSpan( text: "Manual Backup", style: STextStyles.desktopTextSmall( - context), + context, + ), ), TextSpan( text: @@ -548,7 +559,8 @@ class _BackupRestoreSettings extends ConsumerState { "Use a strong password to encrypt your data.", style: STextStyles .desktopTextExtraExtraSmall( - context), + context, + ), ), ], ), @@ -622,15 +634,17 @@ class _BackupRestoreSettings extends ConsumerState { TextSpan( text: "Restore Backup", style: STextStyles.desktopTextSmall( - context), + context, + ), ), TextSpan( text: - "\n\nUse your Stack Wallet backup file to restore your wallets, address book " + "\n\nUse your ${AppConfig.appName} backup file to restore your wallets, address book " "and wallet preferences.", style: STextStyles .desktopTextExtraExtraSmall( - context), + context, + ), ), ], ), @@ -672,7 +686,9 @@ class _BackupRestoreSettings extends ConsumerState { ], ), ), - )); - }); + ), + ); + }, + ); } } diff --git a/lib/pages_desktop_specific/settings/settings_menu/backup_and_restore/create_auto_backup.dart b/lib/pages_desktop_specific/settings/settings_menu/backup_and_restore/create_auto_backup.dart index 2e27798bb..80b6faea3 100644 --- a/lib/pages_desktop_specific/settings/settings_menu/backup_and_restore/create_auto_backup.dart +++ b/lib/pages_desktop_specific/settings/settings_menu/backup_and_restore/create_auto_backup.dart @@ -18,27 +18,27 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:stack_wallet_backup/stack_wallet_backup.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/helpers/swb_file_system.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/providers/global/secure_store_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/backup_frequency_type.dart'; -import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; -import 'package:stackwallet/utilities/format.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/progress_bar.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; +import '../../../../notifications/show_flush_bar.dart'; +import '../../../../pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart'; +import '../../../../pages/settings_views/global_settings_view/stack_backup_views/helpers/swb_file_system.dart'; +import '../../../../providers/global/prefs_provider.dart'; +import '../../../../providers/global/secure_store_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/enums/backup_frequency_type.dart'; +import '../../../../utilities/flutter_secure_storage_interface.dart'; +import '../../../../utilities/format.dart'; +import '../../../../utilities/logger.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/desktop/secondary_button.dart'; +import '../../../../widgets/progress_bar.dart'; +import '../../../../widgets/stack_dialog.dart'; +import '../../../../widgets/stack_text_field.dart'; import 'package:zxcvbn/zxcvbn.dart'; class CreateAutoBackup extends ConsumerStatefulWidget { diff --git a/lib/pages_desktop_specific/settings/settings_menu/backup_and_restore/enable_backup_dialog.dart b/lib/pages_desktop_specific/settings/settings_menu/backup_and_restore/enable_backup_dialog.dart index d52b035dc..fcd05c57b 100644 --- a/lib/pages_desktop_specific/settings/settings_menu/backup_and_restore/enable_backup_dialog.dart +++ b/lib/pages_desktop_specific/settings/settings_menu/backup_and_restore/enable_backup_dialog.dart @@ -9,13 +9,13 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/backup_and_restore/create_auto_backup.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; +import 'create_auto_backup.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/desktop/secondary_button.dart'; class EnableBackupDialog extends StatelessWidget { const EnableBackupDialog({Key? key}) : super(key: key); diff --git a/lib/pages_desktop_specific/settings/settings_menu/currency_settings/currency_settings.dart b/lib/pages_desktop_specific/settings/settings_menu/currency_settings/currency_settings.dart index e163d7b6b..c9faa8182 100644 --- a/lib/pages_desktop_specific/settings/settings_menu/currency_settings/currency_settings.dart +++ b/lib/pages_desktop_specific/settings/settings_menu/currency_settings/currency_settings.dart @@ -11,13 +11,13 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/currency_view.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../../pages/settings_views/global_settings_view/currency_view.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/rounded_white_container.dart'; class CurrencySettings extends ConsumerStatefulWidget { const CurrencySettings({Key? key}) : super(key: key); diff --git a/lib/pages_desktop_specific/settings/settings_menu/desktop_about_view.dart b/lib/pages_desktop_specific/settings/settings_menu/desktop_about_view.dart index eb197ebac..7cd74d3af 100644 --- a/lib/pages_desktop_specific/settings/settings_menu/desktop_about_view.dart +++ b/lib/pages_desktop_specific/settings/settings_menu/desktop_about_view.dart @@ -8,126 +8,29 @@ * */ -import 'dart:convert'; - import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_libepiccash/git_versions.dart' as EPIC_VERSIONS; -import 'package:flutter_libmonero/git_versions.dart' as MONERO_VERSIONS; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:http/http.dart'; -import 'package:lelantus/git_versions.dart' as FIRO_VERSIONS; import 'package:package_info_plus/package_info_plus.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; import 'package:url_launcher/url_launcher.dart'; -const kGithubAPI = "https://api.github.com"; -const kGithubSearch = "/search/commits"; -const kGithubHead = "/repos"; - -enum CommitStatus { isHead, isOldCommit, notACommit, notLoaded } - -Future doesCommitExist( - String organization, - String project, - String commit, -) async { - Logging.instance.log("doesCommitExist", level: LogLevel.Info); - final Client client = Client(); - try { - final uri = Uri.parse( - "$kGithubAPI$kGithubHead/$organization/$project/commits/$commit"); - - final commitQuery = await client.get( - uri, - headers: {'Content-Type': 'application/json'}, - ); - - final response = jsonDecode(commitQuery.body.toString()); - Logging.instance.log("doesCommitExist $project $commit $response", - level: LogLevel.Info); - bool isThereCommit; - try { - isThereCommit = response['sha'] == commit; - Logging.instance - .log("isThereCommit $isThereCommit", level: LogLevel.Info); - return isThereCommit; - } catch (e, s) { - return false; - } - } catch (e, s) { - Logging.instance.log("$e $s", level: LogLevel.Error); - return false; - } -} - -Future isHeadCommit( - String organization, - String project, - String branch, - String commit, -) async { - Logging.instance.log("doesCommitExist", level: LogLevel.Info); - final Client client = Client(); - try { - final uri = Uri.parse( - "$kGithubAPI$kGithubHead/$organization/$project/commits/$branch"); - - final commitQuery = await client.get( - uri, - headers: {'Content-Type': 'application/json'}, - ); - - final response = jsonDecode(commitQuery.body.toString()); - Logging.instance.log("isHeadCommit $project $commit $branch $response", - level: LogLevel.Info); - bool isHead; - try { - isHead = response['sha'] == commit; - Logging.instance.log("isHead $isHead", level: LogLevel.Info); - return isHead; - } catch (e, s) { - return false; - } - } catch (e, s) { - Logging.instance.log("$e $s", level: LogLevel.Error); - return false; - } -} +import '../../../app_config.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/git_status.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../widgets/custom_buttons/blue_text_button.dart'; +import '../../../widgets/desktop/desktop_app_bar.dart'; +import '../../../widgets/desktop/desktop_scaffold.dart'; +import '../../../widgets/rounded_white_container.dart'; class DesktopAboutView extends ConsumerWidget { - const DesktopAboutView({Key? key}) : super(key: key); + const DesktopAboutView({super.key}); static const String routeName = "/desktopAboutView"; @override Widget build(BuildContext context, WidgetRef ref) { - String firoCommit = FIRO_VERSIONS.getPluginVersion(); - String epicCashCommit = EPIC_VERSIONS.getPluginVersion(); - String moneroCommit = MONERO_VERSIONS.getPluginVersion(); - List futureFiroList = [ - doesCommitExist("cypherstack", "flutter_liblelantus", firoCommit), - isHeadCommit("cypherstack", "flutter_liblelantus", "main", firoCommit), - ]; - Future commitFiroFuture = Future.wait(futureFiroList); - List futureEpicList = [ - doesCommitExist("cypherstack", "flutter_libepiccash", epicCashCommit), - isHeadCommit( - "cypherstack", "flutter_libepiccash", "main", epicCashCommit), - ]; - Future commitEpicFuture = Future.wait(futureEpicList); - List futureMoneroList = [ - doesCommitExist("cypherstack", "flutter_libmonero", moneroCommit), - isHeadCommit("cypherstack", "flutter_libmonero", "main", moneroCommit), - ]; - Future commitMoneroFuture = Future.wait(futureMoneroList); - debugPrint("BUILD: $runtimeType"); return DesktopScaffold( background: Theme.of(context).extension()!.background, @@ -142,11 +45,12 @@ class DesktopAboutView extends ConsumerWidget { Text( "About", style: STextStyles.desktopH3(context), - ) + ), ], ), ), body: Column( + mainAxisSize: MainAxisSize.min, children: [ Padding( padding: const EdgeInsets.fromLTRB(24, 10, 24, 35), @@ -154,18 +58,17 @@ class DesktopAboutView extends ConsumerWidget { children: [ Expanded( child: RoundedWhiteContainer( - width: 929, - height: 451, child: Padding( padding: const EdgeInsets.only(left: 10, top: 10), child: Column( + mainAxisSize: MainAxisSize.min, // mainAxisAlignment: MainAxisAlignment.start, children: [ Row( mainAxisAlignment: MainAxisAlignment.start, children: [ Text( - "Stack Wallet", + AppConfig.appName, style: STextStyles.desktopH3(context), textAlign: TextAlign.start, ), @@ -181,14 +84,15 @@ class DesktopAboutView extends ConsumerWidget { children: [ TextSpan( text: - "By using Stack Wallet, you agree to the ", + "By using ${AppConfig.appName}, you agree to the ", style: STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( - color: Theme.of(context) - .extension()! - .textDark3), + .desktopTextExtraExtraSmall( + context, + ).copyWith( + color: Theme.of(context) + .extension()! + .textDark3, + ), ), TextSpan( text: "Terms of service", @@ -198,7 +102,8 @@ class DesktopAboutView extends ConsumerWidget { ..onTap = () { launchUrl( Uri.parse( - "https://stackwallet.com/terms-of-service.html"), + "https://stackwallet.com/terms-of-service.html", + ), mode: LaunchMode.externalApplication, ); @@ -207,12 +112,13 @@ class DesktopAboutView extends ConsumerWidget { TextSpan( text: " and ", style: STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( - color: Theme.of(context) - .extension()! - .textDark3), + .desktopTextExtraExtraSmall( + context, + ).copyWith( + color: Theme.of(context) + .extension()! + .textDark3, + ), ), TextSpan( text: "Privacy policy", @@ -222,7 +128,8 @@ class DesktopAboutView extends ConsumerWidget { ..onTap = () { launchUrl( Uri.parse( - "https://stackwallet.com/privacy-policy.html"), + "https://stackwallet.com/privacy-policy.html", + ), mode: LaunchMode.externalApplication, ); @@ -238,11 +145,15 @@ class DesktopAboutView extends ConsumerWidget { padding: const EdgeInsets.only(right: 10, bottom: 10), child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, children: [ FutureBuilder( future: PackageInfo.fromPlatform(), - builder: (context, - AsyncSnapshot snapshot) { + builder: ( + context, + AsyncSnapshot snapshot, + ) { String version = ""; String signature = ""; String build = ""; @@ -256,26 +167,32 @@ class DesktopAboutView extends ConsumerWidget { } return Column( + mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: + CrossAxisAlignment.start, children: [ Row( children: [ Column( + mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "Version", style: STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( - color: Theme.of( - context) - .extension< - StackColors>()! - .textDark), + .desktopTextExtraExtraSmall( + context, + ).copyWith( + color: Theme.of( + context, + ) + .extension< + StackColors>()! + .textDark, + ), ), const SizedBox( height: 2, @@ -284,28 +201,32 @@ class DesktopAboutView extends ConsumerWidget { version, style: STextStyles.itemSubtitle( - context), + context, + ), ), ], ), const SizedBox( - width: 400, + width: 16, ), Column( + mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "Build number", style: STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( - color: Theme.of( - context) - .extension< - StackColors>()! - .textDark), + .desktopTextExtraExtraSmall( + context, + ).copyWith( + color: Theme.of( + context, + ) + .extension< + StackColors>()! + .textDark, + ), ), const SizedBox( height: 2, @@ -314,7 +235,42 @@ class DesktopAboutView extends ConsumerWidget { build, style: STextStyles.itemSubtitle( - context), + context, + ), + ), + ], + ), + const SizedBox( + width: 16, + ), + Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: + CrossAxisAlignment.start, + children: [ + Text( + "Build commit", + style: STextStyles + .desktopTextExtraExtraSmall( + context, + ).copyWith( + color: Theme.of( + context, + ) + .extension< + StackColors>()! + .textDark, + ), + ), + const SizedBox( + height: 2, + ), + SelectableText( + GitStatus.appCommitHash, + style: + STextStyles.itemSubtitle( + context, + ), ), ], ), @@ -324,20 +280,23 @@ class DesktopAboutView extends ConsumerWidget { Row( children: [ Column( + mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( "Build signature", style: STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( - color: Theme.of( - context) - .extension< - StackColors>()! - .textDark), + .desktopTextExtraExtraSmall( + context, + ).copyWith( + color: Theme.of( + context, + ) + .extension< + StackColors>()! + .textDark, + ), ), const SizedBox( height: 2, @@ -346,20 +305,29 @@ class DesktopAboutView extends ConsumerWidget { signature, style: STextStyles.itemSubtitle( - context), + context, + ), ), ], ), - const SizedBox( - width: 350, - ), - FutureBuilder( - future: commitFiroFuture, - builder: (context, - AsyncSnapshot - snapshot) { - bool commitExists = false; - bool isHead = false; + ], + ), + const SizedBox(height: 32), + Wrap( + spacing: 64, + runSpacing: 32, + children: [ + if (AppConfig.coins + .whereType() + .isNotEmpty) + FutureBuilder( + future: GitStatus + .getFiroCommitStatus(), + builder: ( + context, + AsyncSnapshot + snapshot, + ) { CommitStatus stateOfCommit = CommitStatus.notLoaded; @@ -367,67 +335,13 @@ class DesktopAboutView extends ConsumerWidget { ConnectionState .done && snapshot.hasData) { - commitExists = snapshot - .data![0] as bool; - isHead = snapshot.data![1] - as bool; - if (commitExists && - isHead) { - stateOfCommit = - CommitStatus.isHead; - } else if (commitExists) { - stateOfCommit = - CommitStatus - .isOldCommit; - } else { - stateOfCommit = - CommitStatus - .notACommit; - } - } - TextStyle indicationStyle = - STextStyles.itemSubtitle( - context); - switch (stateOfCommit) { - case CommitStatus.isHead: - indicationStyle = STextStyles - .itemSubtitle( - context) - .copyWith( - color: Theme.of( - context) - .extension< - StackColors>()! - .accentColorGreen); - break; - case CommitStatus - .isOldCommit: - indicationStyle = STextStyles - .itemSubtitle( - context) - .copyWith( - color: Theme.of( - context) - .extension< - StackColors>()! - .accentColorYellow); - break; - case CommitStatus - .notACommit: - indicationStyle = STextStyles - .itemSubtitle( - context) - .copyWith( - color: Theme.of( - context) - .extension< - StackColors>()! - .accentColorRed); - break; - default: - break; + stateOfCommit = + snapshot.data!; } + return Column( + mainAxisSize: + MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment .start, @@ -435,37 +349,43 @@ class DesktopAboutView extends ConsumerWidget { Text( "Firo Build Commit", style: STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( - color: Theme.of( - context) - .extension< - StackColors>()! - .textDark), + .desktopTextExtraExtraSmall( + context, + ).copyWith( + color: Theme.of( + context, + ) + .extension< + StackColors>()! + .textDark, + ), ), const SizedBox( height: 2, ), SelectableText( - firoCommit, - style: indicationStyle, + GitStatus.firoCommit, + style: GitStatus + .styleForStatus( + stateOfCommit, + context, + ), ), ], ); - }), - ], - ), - const SizedBox(height: 35), - Row( - children: [ - FutureBuilder( - future: commitEpicFuture, - builder: (context, - AsyncSnapshot - snapshot) { - bool commitExists = false; - bool isHead = false; + }, + ), + if (AppConfig.coins + .whereType() + .isNotEmpty) + FutureBuilder( + future: GitStatus + .getEpicCommitStatus(), + builder: ( + context, + AsyncSnapshot + snapshot, + ) { CommitStatus stateOfCommit = CommitStatus.notLoaded; @@ -473,67 +393,13 @@ class DesktopAboutView extends ConsumerWidget { ConnectionState .done && snapshot.hasData) { - commitExists = snapshot - .data![0] as bool; - isHead = snapshot.data![1] - as bool; - if (commitExists && - isHead) { - stateOfCommit = - CommitStatus.isHead; - } else if (commitExists) { - stateOfCommit = - CommitStatus - .isOldCommit; - } else { - stateOfCommit = - CommitStatus - .notACommit; - } - } - TextStyle indicationStyle = - STextStyles.itemSubtitle( - context); - switch (stateOfCommit) { - case CommitStatus.isHead: - indicationStyle = STextStyles - .itemSubtitle( - context) - .copyWith( - color: Theme.of( - context) - .extension< - StackColors>()! - .accentColorGreen); - break; - case CommitStatus - .isOldCommit: - indicationStyle = STextStyles - .itemSubtitle( - context) - .copyWith( - color: Theme.of( - context) - .extension< - StackColors>()! - .accentColorYellow); - break; - case CommitStatus - .notACommit: - indicationStyle = STextStyles - .itemSubtitle( - context) - .copyWith( - color: Theme.of( - context) - .extension< - StackColors>()! - .accentColorRed); - break; - default: - break; + stateOfCommit = + snapshot.data!; } + return Column( + mainAxisSize: + MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment .start, @@ -541,35 +407,44 @@ class DesktopAboutView extends ConsumerWidget { Text( "Epic Cash Build Commit", style: STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( - color: Theme.of( - context) - .extension< - StackColors>()! - .textDark), + .desktopTextExtraExtraSmall( + context, + ).copyWith( + color: Theme.of( + context, + ) + .extension< + StackColors>()! + .textDark, + ), ), const SizedBox( height: 2, ), SelectableText( - epicCashCommit, - style: indicationStyle, + GitStatus + .epicCashCommit, + style: GitStatus + .styleForStatus( + stateOfCommit, + context, + ), ), ], ); - }), - const SizedBox( - width: 105, - ), - FutureBuilder( - future: commitMoneroFuture, - builder: (context, - AsyncSnapshot - snapshot) { - bool commitExists = false; - bool isHead = false; + }, + ), + if (AppConfig.coins + .whereType() + .isNotEmpty) + FutureBuilder( + future: GitStatus + .getMoneroCommitStatus(), + builder: ( + context, + AsyncSnapshot + snapshot, + ) { CommitStatus stateOfCommit = CommitStatus.notLoaded; @@ -577,67 +452,12 @@ class DesktopAboutView extends ConsumerWidget { ConnectionState .done && snapshot.hasData) { - commitExists = snapshot - .data![0] as bool; - isHead = snapshot.data![1] - as bool; - if (commitExists && - isHead) { - stateOfCommit = - CommitStatus.isHead; - } else if (commitExists) { - stateOfCommit = - CommitStatus - .isOldCommit; - } else { - stateOfCommit = - CommitStatus - .notACommit; - } - } - TextStyle indicationStyle = - STextStyles.itemSubtitle( - context); - switch (stateOfCommit) { - case CommitStatus.isHead: - indicationStyle = STextStyles - .itemSubtitle( - context) - .copyWith( - color: Theme.of( - context) - .extension< - StackColors>()! - .accentColorGreen); - break; - case CommitStatus - .isOldCommit: - indicationStyle = STextStyles - .itemSubtitle( - context) - .copyWith( - color: Theme.of( - context) - .extension< - StackColors>()! - .accentColorYellow); - break; - case CommitStatus - .notACommit: - indicationStyle = STextStyles - .itemSubtitle( - context) - .copyWith( - color: Theme.of( - context) - .extension< - StackColors>()! - .accentColorRed); - break; - default: - break; + stateOfCommit = + snapshot.data!; } return Column( + mainAxisSize: + MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment .start, @@ -645,25 +465,32 @@ class DesktopAboutView extends ConsumerWidget { Text( "Monero Build Commit", style: STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( - color: Theme.of( - context) - .extension< - StackColors>()! - .textDark), + .desktopTextExtraExtraSmall( + context, + ).copyWith( + color: Theme.of( + context, + ) + .extension< + StackColors>()! + .textDark, + ), ), const SizedBox( height: 2, ), SelectableText( - moneroCommit, - style: indicationStyle, + GitStatus.moneroCommit, + style: GitStatus + .styleForStatus( + stateOfCommit, + context, + ), ), ], ); - }), + }, + ), ], ), const SizedBox(height: 35), @@ -672,46 +499,21 @@ class DesktopAboutView extends ConsumerWidget { Text( "Website:", style: STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( - color: Theme.of(context) - .extension< - StackColors>()! - .textDark), + .desktopTextExtraExtraSmall( + context, + ).copyWith( + color: Theme.of(context) + .extension()! + .textDark, + ), ), CustomTextButton( text: "https://stackwallet.com", onTap: () { launchUrl( Uri.parse( - "https://stackwallet.com"), - mode: LaunchMode - .externalApplication, - ); - }, - ), - ], - ), - const SizedBox(height: 25), - Row( - children: [ - Text( - "Tezos functionality:", - style: STextStyles - .desktopTextExtraExtraSmall( - context) - .copyWith( - color: Theme.of(context) - .extension< - StackColors>()! - .textDark), - ), - CustomTextButton( - text: "Powered by TzKT API", - onTap: () { - launchUrl( - Uri.parse("https://tzkt.io"), + "https://stackwallet.com", + ), mode: LaunchMode .externalApplication, ); @@ -719,13 +521,46 @@ class DesktopAboutView extends ConsumerWidget { ), ], ), + if (AppConfig.coins + .whereType() + .isNotEmpty) + const SizedBox(height: 25), + if (AppConfig.coins + .whereType() + .isNotEmpty) + Row( + children: [ + Text( + "Tezos functionality:", + style: STextStyles + .desktopTextExtraExtraSmall( + context, + ).copyWith( + color: Theme.of(context) + .extension()! + .textDark, + ), + ), + CustomTextButton( + text: "Powered by TzKT API", + onTap: () { + launchUrl( + Uri.parse( + "https://tzkt.io"), + mode: LaunchMode + .externalApplication, + ); + }, + ), + ], + ), ], ); }, - ) + ), ], ), - ) + ), ], ), ), diff --git a/lib/pages_desktop_specific/settings/settings_menu/desktop_support_view.dart b/lib/pages_desktop_specific/settings/settings_menu/desktop_support_view.dart index d2dc00f3b..2d9060e3a 100644 --- a/lib/pages_desktop_specific/settings/settings_menu/desktop_support_view.dart +++ b/lib/pages_desktop_specific/settings/settings_menu/desktop_support_view.dart @@ -10,11 +10,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/support_view.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; +import '../../../pages/settings_views/global_settings_view/support_view.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../widgets/desktop/desktop_app_bar.dart'; +import '../../../widgets/desktop/desktop_scaffold.dart'; class DesktopSupportView extends ConsumerStatefulWidget { const DesktopSupportView({Key? key}) : super(key: key); diff --git a/lib/pages_desktop_specific/settings/settings_menu/language_settings/language_dialog.dart b/lib/pages_desktop_specific/settings/settings_menu/language_settings/language_dialog.dart index e3bb58526..c24762da6 100644 --- a/lib/pages_desktop_specific/settings/settings_menu/language_settings/language_dialog.dart +++ b/lib/pages_desktop_specific/settings/settings_menu/language_settings/language_dialog.dart @@ -11,20 +11,20 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/languages_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../../../providers/global/prefs_provider.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/constants.dart'; +import '../../../../utilities/enums/languages_enum.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/desktop/secondary_button.dart'; +import '../../../../widgets/icon_widgets/x_icon.dart'; +import '../../../../widgets/rounded_container.dart'; +import '../../../../widgets/stack_text_field.dart'; +import '../../../../widgets/textfield_icon_button.dart'; class LanguageDialog extends ConsumerStatefulWidget { const LanguageDialog({Key? key}) : super(key: key); diff --git a/lib/pages_desktop_specific/settings/settings_menu/language_settings/language_settings.dart b/lib/pages_desktop_specific/settings/settings_menu/language_settings/language_settings.dart index 4dab186b0..795fbbf8b 100644 --- a/lib/pages_desktop_specific/settings/settings_menu/language_settings/language_settings.dart +++ b/lib/pages_desktop_specific/settings/settings_menu/language_settings/language_settings.dart @@ -11,11 +11,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/language_settings/language_dialog.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import 'language_dialog.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../widgets/desktop/primary_button.dart'; +import '../../../../widgets/rounded_white_container.dart'; class LanguageOptionSettings extends ConsumerStatefulWidget { const LanguageOptionSettings({Key? key}) : super(key: key); diff --git a/lib/pages_desktop_specific/settings/settings_menu/nodes_settings.dart b/lib/pages_desktop_specific/settings/settings_menu/nodes_settings.dart index eec6e1a5f..0471caf73 100644 --- a/lib/pages_desktop_specific/settings/settings_menu/nodes_settings.dart +++ b/lib/pages_desktop_specific/settings/settings_menu/nodes_settings.dart @@ -13,23 +13,24 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/manage_nodes_views/coin_nodes_view.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/route_generator.dart'; -import 'package:stackwallet/themes/coin_icon_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../../pages/settings_views/global_settings_view/manage_nodes_views/coin_nodes_view.dart'; +import '../../../providers/providers.dart'; +import '../../../route_generator.dart'; +import '../../../app_config.dart'; +import '../../../themes/coin_icon_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; +import '../../../widgets/icon_widgets/x_icon.dart'; +import '../../../widgets/rounded_white_container.dart'; +import '../../../widgets/stack_text_field.dart'; +import '../../../widgets/textfield_icon_button.dart'; class NodesSettings extends ConsumerStatefulWidget { - const NodesSettings({Key? key}) : super(key: key); + const NodesSettings({super.key}); static const String routeName = "/settingsMenuNodes"; @@ -38,7 +39,7 @@ class NodesSettings extends ConsumerStatefulWidget { } class _NodesSettings extends ConsumerState { - List _coins = [...Coin.values]; + List _coins = [...AppConfig.coins]; late final TextEditingController searchNodeController; late final FocusNode searchNodeFocusNode; @@ -47,15 +48,17 @@ class _NodesSettings extends ConsumerState { String filter = ""; - List _search(String filter, List coins) { + List _search(String filter, List coins) { if (filter.isEmpty) { return coins; } return coins - .where((coin) => - coin.prettyName.contains(filter) || - coin.name.contains(filter) || - coin.ticker.toLowerCase().contains(filter.toLowerCase())) + .where( + (coin) => + coin.prettyName.contains(filter) || + coin.identifier.contains(filter) || + coin.ticker.toLowerCase().contains(filter.toLowerCase()), + ) .toList(); } @@ -64,12 +67,15 @@ class _NodesSettings extends ConsumerState { @override void initState() { _coins = _coins.toList(); - _coins.remove(Coin.firoTestNet); + _coins.removeWhere( + (e) => e is Firo && e.network == CryptoCurrencyNetwork.test, + ); if (Platform.isWindows) { - _coins.remove(Coin.monero); - _coins.remove(Coin.wownero); + _coins.removeWhere( + (e) => e is Monero && e is Wownero, + ); } else if (Platform.isLinux) { - _coins.remove(Coin.wownero); + _coins.removeWhere((e) => e is Wownero); } searchNodeController = TextEditingController(); @@ -93,12 +99,17 @@ class _NodesSettings extends ConsumerState { Widget build(BuildContext context) { debugPrint("BUILD: $runtimeType"); - bool showTestNet = ref.watch( + final bool showTestNet = ref.watch( prefsChangeNotifierProvider.select((value) => value.showTestNetCoins), ); - List coins = - showTestNet ? _coins : _coins.where((e) => !e.isTestNet).toList(); + List coins = showTestNet + ? _coins + : _coins + .where( + (e) => e.network == CryptoCurrencyNetwork.main, + ) + .toList(); coins = _search(filter, coins); @@ -215,8 +226,10 @@ class _NodesSettings extends ConsumerState { itemBuilder: (context, index) { final coin = coins[index]; final count = ref - .watch(nodeServiceChangeNotifierProvider - .select((value) => value.getNodesFor(coin))) + .watch( + nodeServiceChangeNotifierProvider + .select((value) => value.getNodesFor(coin)), + ) .length; return Padding( @@ -278,7 +291,8 @@ class _NodesSettings extends ConsumerState { Text( "${coin.prettyName} nodes", style: STextStyles.titleBold12( - context), + context, + ), ), Text( count > 1 diff --git a/lib/pages_desktop_specific/settings/settings_menu/security_settings.dart b/lib/pages_desktop_specific/settings/settings_menu/security_settings.dart index 1d24a74f3..524686732 100644 --- a/lib/pages_desktop_specific/settings/settings_menu/security_settings.dart +++ b/lib/pages_desktop_specific/settings/settings_menu/security_settings.dart @@ -13,20 +13,21 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/providers/desktop/storage_crypto_handler_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/progress_bar.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; +import '../../../app_config.dart'; +import '../../../notifications/show_flush_bar.dart'; +import '../../../providers/desktop/storage_crypto_handler_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/constants.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../widgets/desktop/primary_button.dart'; +import '../../../widgets/progress_bar.dart'; +import '../../../widgets/rounded_white_container.dart'; +import '../../../widgets/stack_text_field.dart'; import 'package:zxcvbn/zxcvbn.dart'; class SecuritySettings extends ConsumerStatefulWidget { - const SecuritySettings({Key? key}) : super(key: key); + const SecuritySettings({super.key}); static const String routeName = "/settingsMenuSecurity"; @@ -186,7 +187,7 @@ class _SecuritySettings extends ConsumerState { height: 16, ), Text( - "Protect your Stack Wallet with a strong password. Stack Wallet does not store " + "Protect your ${AppConfig.appName} with a strong password. ${AppConfig.appName} does not store " "your password, and is therefore NOT able to restore it. Keep your password safe and secure.", style: STextStyles.desktopTextExtraExtraSmall(context), ), diff --git a/lib/pages_desktop_specific/settings/settings_menu/syncing_preferences_settings.dart b/lib/pages_desktop_specific/settings/settings_menu/syncing_preferences_settings.dart index 0522d1ed7..d1b03d83e 100644 --- a/lib/pages_desktop_specific/settings/settings_menu/syncing_preferences_settings.dart +++ b/lib/pages_desktop_specific/settings/settings_menu/syncing_preferences_settings.dart @@ -11,15 +11,15 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/syncing_preferences_views/syncing_options_view.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/enums/sync_type_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../pages/settings_views/global_settings_view/syncing_preferences_views/syncing_options_view.dart'; +import '../../../providers/global/prefs_provider.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/enums/sync_type_enum.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../widgets/desktop/primary_button.dart'; +import '../../../widgets/rounded_container.dart'; +import '../../../widgets/rounded_white_container.dart'; class SyncingPreferencesSettings extends ConsumerStatefulWidget { const SyncingPreferencesSettings({Key? key}) : super(key: key); diff --git a/lib/pages_desktop_specific/settings/settings_menu/tor_settings/tor_settings.dart b/lib/pages_desktop_specific/settings/settings_menu/tor_settings/tor_settings.dart index 6d74abed0..4cbce2c5e 100644 --- a/lib/pages_desktop_specific/settings/settings_menu/tor_settings/tor_settings.dart +++ b/lib/pages_desktop_specific/settings/settings_menu/tor_settings/tor_settings.dart @@ -15,21 +15,21 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/services/event_bus/events/global/tor_connection_status_changed_event.dart'; -import 'package:stackwallet/services/event_bus/global_event_bus.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/stack_file_system.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/custom_buttons/draggable_switch_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../../providers/global/prefs_provider.dart'; +import '../../../../services/event_bus/events/global/tor_connection_status_changed_event.dart'; +import '../../../../services/event_bus/global_event_bus.dart'; +import '../../../../services/tor_service.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; +import '../../../../utilities/logger.dart'; +import '../../../../utilities/stack_file_system.dart'; +import '../../../../utilities/text_styles.dart'; +import '../../../../utilities/util.dart'; +import '../../../../widgets/custom_buttons/draggable_switch_button.dart'; +import '../../../../widgets/desktop/desktop_dialog.dart'; +import '../../../../widgets/desktop/desktop_dialog_close_button.dart'; +import '../../../../widgets/desktop/secondary_button.dart'; +import '../../../../widgets/rounded_white_container.dart'; class TorSettings extends ConsumerStatefulWidget { const TorSettings({Key? key}) : super(key: key); diff --git a/lib/pages_desktop_specific/settings/settings_menu_item.dart b/lib/pages_desktop_specific/settings/settings_menu_item.dart index 673d3e318..a1cc79d98 100644 --- a/lib/pages_desktop_specific/settings/settings_menu_item.dart +++ b/lib/pages_desktop_specific/settings/settings_menu_item.dart @@ -9,8 +9,8 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/text_styles.dart'; class SettingsMenuItem extends StatelessWidget { const SettingsMenuItem({ diff --git a/lib/pages_desktop_specific/spark_coins/spark_coins_view.dart b/lib/pages_desktop_specific/spark_coins/spark_coins_view.dart index 6c2736628..42053b155 100644 --- a/lib/pages_desktop_specific/spark_coins/spark_coins_view.dart +++ b/lib/pages_desktop_specific/spark_coins/spark_coins_view.dart @@ -12,15 +12,15 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/models/spark_coin.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart'; -import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../providers/db/main_db_provider.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/text_styles.dart'; +import '../../wallets/isar/models/spark_coin.dart'; +import '../../widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../widgets/desktop/desktop_app_bar.dart'; +import '../../widgets/desktop/desktop_scaffold.dart'; +import '../../widgets/rounded_white_container.dart'; class SparkCoinsView extends ConsumerStatefulWidget { const SparkCoinsView({ diff --git a/lib/providers/buy/buy_form_state_provider.dart b/lib/providers/buy/buy_form_state_provider.dart index 3e8d7cdf1..5a2a79ed1 100644 --- a/lib/providers/buy/buy_form_state_provider.dart +++ b/lib/providers/buy/buy_form_state_provider.dart @@ -9,7 +9,7 @@ */ import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/buy/buy_form_state.dart'; +import '../../models/buy/buy_form_state.dart'; final buyFormStateProvider = ChangeNotifierProvider( (ref) => BuyFormState(), diff --git a/lib/providers/buy/simplex_provider.dart b/lib/providers/buy/simplex_provider.dart index e8e075455..cb598d29d 100644 --- a/lib/providers/buy/simplex_provider.dart +++ b/lib/providers/buy/simplex_provider.dart @@ -9,7 +9,7 @@ */ import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/buy/simplex/simplex.dart'; +import '../../models/buy/simplex/simplex.dart'; final simplexProvider = Provider( (ref) => Simplex(), diff --git a/lib/providers/cash_fusion/fusion_progress_ui_state_provider.dart b/lib/providers/cash_fusion/fusion_progress_ui_state_provider.dart index 872b6586a..588cff031 100644 --- a/lib/providers/cash_fusion/fusion_progress_ui_state_provider.dart +++ b/lib/providers/cash_fusion/fusion_progress_ui_state_provider.dart @@ -9,7 +9,7 @@ */ import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/fusion_progress_ui_state.dart'; +import '../../models/fusion_progress_ui_state.dart'; final fusionProgressUIStateProvider = ChangeNotifierProvider.family( diff --git a/lib/providers/db/main_db_provider.dart b/lib/providers/db/main_db_provider.dart index c86ebf93c..2544c74fc 100644 --- a/lib/providers/db/main_db_provider.dart +++ b/lib/providers/db/main_db_provider.dart @@ -9,6 +9,6 @@ */ import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/db/isar/main_db.dart'; +import '../../db/isar/main_db.dart'; final mainDBProvider = Provider((ref) => MainDB.instance); diff --git a/lib/providers/desktop/current_desktop_menu_item.dart b/lib/providers/desktop/current_desktop_menu_item.dart index 409a48a40..683ac73a8 100644 --- a/lib/providers/desktop/current_desktop_menu_item.dart +++ b/lib/providers/desktop/current_desktop_menu_item.dart @@ -9,7 +9,7 @@ */ import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_menu.dart'; +import '../../pages_desktop_specific/desktop_menu.dart'; final currentDesktopMenuItemProvider = StateProvider((ref) => DesktopMenuItemId.myStack); diff --git a/lib/providers/desktop/storage_crypto_handler_provider.dart b/lib/providers/desktop/storage_crypto_handler_provider.dart index 6f25571a6..65b55178a 100644 --- a/lib/providers/desktop/storage_crypto_handler_provider.dart +++ b/lib/providers/desktop/storage_crypto_handler_provider.dart @@ -9,6 +9,6 @@ */ import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/utilities/desktop_password_service.dart'; +import '../../utilities/desktop_password_service.dart'; final storageCryptoHandlerProvider = Provider((ref) => DPS()); diff --git a/lib/providers/exchange/exchange_form_state_provider.dart b/lib/providers/exchange/exchange_form_state_provider.dart index b4a923b78..ab1515653 100644 --- a/lib/providers/exchange/exchange_form_state_provider.dart +++ b/lib/providers/exchange/exchange_form_state_provider.dart @@ -10,16 +10,18 @@ import 'package:decimal/decimal.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/exchange/active_pair.dart'; -import 'package:stackwallet/models/exchange/response_objects/estimate.dart'; -import 'package:stackwallet/models/exchange/response_objects/range.dart'; -import 'package:stackwallet/providers/global/locale_provider.dart'; -import 'package:stackwallet/services/exchange/exchange.dart'; -import 'package:stackwallet/services/exchange/exchange_response.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_unit.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/exchange_rate_type_enum.dart'; +import '../../models/exchange/active_pair.dart'; +import '../../models/exchange/response_objects/estimate.dart'; +import '../../models/exchange/response_objects/range.dart'; +import '../global/locale_provider.dart'; +import '../../services/exchange/exchange.dart'; +import '../../services/exchange/exchange_response.dart'; +import '../../utilities/amount/amount.dart'; +import '../../utilities/amount/amount_unit.dart'; + +import '../../utilities/enums/exchange_rate_type_enum.dart'; +import '../../wallets/crypto_currency/coins/nano.dart'; +import '../../wallets/crypto_currency/crypto_currency.dart'; import 'package:tuple/tuple.dart'; final efEstimatesListProvider = StateProvider.family< @@ -56,8 +58,9 @@ final efSendAmountStringProvider = StateProvider((ref) { string = AmountUnit.normal.displayAmount( amount: amount, locale: locale, - coin: Coin - .nano, // use nano just to ensure decimal.scale < Coin.value.decimals + coin: Nano( + CryptoCurrencyNetwork.main, + ), // use nano just to ensure decimal.scale < Coin.value.decimals withUnitName: false, maxDecimalPlaces: decimal.scale, ); @@ -81,8 +84,9 @@ final efReceiveAmountStringProvider = StateProvider((ref) { string = AmountUnit.normal.displayAmount( amount: amount, locale: locale, - coin: Coin - .nano, // use nano just to ensure decimal.scale < Coin.value.decimals + coin: Nano( + CryptoCurrencyNetwork.main, + ), // use nano just to ensure decimal.scale < Coin.value.decimals withUnitName: false, maxDecimalPlaces: decimal.scale, ); diff --git a/lib/providers/exchange/exchange_send_from_wallet_id_provider.dart b/lib/providers/exchange/exchange_send_from_wallet_id_provider.dart index b2fbec990..bc43ceca7 100644 --- a/lib/providers/exchange/exchange_send_from_wallet_id_provider.dart +++ b/lib/providers/exchange/exchange_send_from_wallet_id_provider.dart @@ -9,8 +9,8 @@ */ import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import '../../wallets/crypto_currency/crypto_currency.dart'; import 'package:tuple/tuple.dart'; final exchangeSendFromWalletIdStateProvider = - StateProvider?>((ref) => null); + StateProvider?>((ref) => null); diff --git a/lib/providers/exchange/trade_note_service_provider.dart b/lib/providers/exchange/trade_note_service_provider.dart index 6d54eba8b..433a07ddf 100644 --- a/lib/providers/exchange/trade_note_service_provider.dart +++ b/lib/providers/exchange/trade_note_service_provider.dart @@ -9,7 +9,7 @@ */ import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/services/trade_notes_service.dart'; +import '../../services/trade_notes_service.dart'; final tradeNoteServiceProvider = ChangeNotifierProvider((ref) => TradeNotesService()); diff --git a/lib/providers/exchange/trade_sent_from_stack_lookup_provider.dart b/lib/providers/exchange/trade_sent_from_stack_lookup_provider.dart index d443ac390..5eb808e3c 100644 --- a/lib/providers/exchange/trade_sent_from_stack_lookup_provider.dart +++ b/lib/providers/exchange/trade_sent_from_stack_lookup_provider.dart @@ -9,7 +9,7 @@ */ import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/services/trade_sent_from_stack_service.dart'; +import '../../services/trade_sent_from_stack_service.dart'; final tradeSentFromStackLookupProvider = ChangeNotifierProvider( diff --git a/lib/providers/frost_wallet/frost_wallet_providers.dart b/lib/providers/frost_wallet/frost_wallet_providers.dart index 7b3ee3eda..c5b934e8e 100644 --- a/lib/providers/frost_wallet/frost_wallet_providers.dart +++ b/lib/providers/frost_wallet/frost_wallet_providers.dart @@ -3,9 +3,9 @@ import 'dart:typed_data'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:frostdart/frostdart_bindings_generated.dart'; -import 'package:stackwallet/services/frost.dart'; -import 'package:stackwallet/wallets/models/incomplete_frost_wallet.dart'; -import 'package:stackwallet/wallets/models/tx_data.dart'; +import '../../services/frost.dart'; +import '../../wallets/models/incomplete_frost_wallet.dart'; +import '../../wallets/models/tx_data.dart'; // =================== wallet creation ========================================= final pFrostMultisigConfig = StateProvider((ref) => null); diff --git a/lib/providers/global/address_book_service_provider.dart b/lib/providers/global/address_book_service_provider.dart index efb0b7a1d..e61f6960a 100644 --- a/lib/providers/global/address_book_service_provider.dart +++ b/lib/providers/global/address_book_service_provider.dart @@ -9,7 +9,7 @@ */ import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/services/address_book_service.dart'; +import '../../services/address_book_service.dart'; final addressBookServiceProvider = ChangeNotifierProvider((ref) => AddressBookService()); diff --git a/lib/providers/global/auto_swb_service_provider.dart b/lib/providers/global/auto_swb_service_provider.dart index a37f52061..ba67fef94 100644 --- a/lib/providers/global/auto_swb_service_provider.dart +++ b/lib/providers/global/auto_swb_service_provider.dart @@ -9,8 +9,8 @@ */ import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/providers/global/secure_store_provider.dart'; -import 'package:stackwallet/services/auto_swb_service.dart'; +import 'secure_store_provider.dart'; +import '../../services/auto_swb_service.dart'; final autoSWBServiceProvider = ChangeNotifierProvider( (ref) => AutoSWBService( diff --git a/lib/providers/global/base_currencies_provider.dart b/lib/providers/global/base_currencies_provider.dart index 88086fde4..341ebf2c1 100644 --- a/lib/providers/global/base_currencies_provider.dart +++ b/lib/providers/global/base_currencies_provider.dart @@ -10,7 +10,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/services/price.dart'; +import '../../services/price.dart'; final baseCurrenciesProvider = ChangeNotifierProvider<_BaseCurrencies>((_) => _BaseCurrencies()); diff --git a/lib/providers/global/debug_service_provider.dart b/lib/providers/global/debug_service_provider.dart index 15868959b..4d666cdcf 100644 --- a/lib/providers/global/debug_service_provider.dart +++ b/lib/providers/global/debug_service_provider.dart @@ -9,7 +9,7 @@ */ import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/services/debug_service.dart'; +import '../../services/debug_service.dart'; final debugServiceProvider = ChangeNotifierProvider((ref) => DebugService.instance); diff --git a/lib/providers/global/http_provider.dart b/lib/providers/global/http_provider.dart index 84f8793c0..7aabea1b2 100644 --- a/lib/providers/global/http_provider.dart +++ b/lib/providers/global/http_provider.dart @@ -1,4 +1,4 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/networking/http.dart'; +import '../../networking/http.dart'; final pHTTP = Provider((ref) => HTTP()); diff --git a/lib/providers/global/locale_provider.dart b/lib/providers/global/locale_provider.dart index 903bab614..429e513eb 100644 --- a/lib/providers/global/locale_provider.dart +++ b/lib/providers/global/locale_provider.dart @@ -10,7 +10,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/services/locale_service.dart'; +import '../../services/locale_service.dart'; int _count = 0; final localeServiceChangeNotifierProvider = diff --git a/lib/providers/global/node_service_provider.dart b/lib/providers/global/node_service_provider.dart index c8ef578ab..008cd33aa 100644 --- a/lib/providers/global/node_service_provider.dart +++ b/lib/providers/global/node_service_provider.dart @@ -10,8 +10,8 @@ import 'package:flutter/foundation.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/providers/global/secure_store_provider.dart'; -import 'package:stackwallet/services/node_service.dart'; +import 'secure_store_provider.dart'; +import '../../services/node_service.dart'; int _count = 0; final nodeServiceChangeNotifierProvider = diff --git a/lib/providers/global/notifications_provider.dart b/lib/providers/global/notifications_provider.dart index 56eb18dd8..3cadbce3c 100644 --- a/lib/providers/global/notifications_provider.dart +++ b/lib/providers/global/notifications_provider.dart @@ -9,7 +9,7 @@ */ import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/services/notifications_service.dart'; +import '../../services/notifications_service.dart'; final notificationsProvider = ChangeNotifierProvider((_) => NotificationsService.instance); diff --git a/lib/providers/global/paynym_api_provider.dart b/lib/providers/global/paynym_api_provider.dart index 310d7da43..bae3800f1 100644 --- a/lib/providers/global/paynym_api_provider.dart +++ b/lib/providers/global/paynym_api_provider.dart @@ -9,6 +9,6 @@ */ import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/utilities/paynym_is_api.dart'; +import '../../utilities/paynym_is_api.dart'; final paynymAPIProvider = Provider((_) => PaynymIsApi()); diff --git a/lib/providers/global/prefs_provider.dart b/lib/providers/global/prefs_provider.dart index bc61d44ed..abe6653d2 100644 --- a/lib/providers/global/prefs_provider.dart +++ b/lib/providers/global/prefs_provider.dart @@ -10,7 +10,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/utilities/prefs.dart'; +import '../../utilities/prefs.dart'; int _count = 0; final prefsChangeNotifierProvider = ChangeNotifierProvider((_) { diff --git a/lib/providers/global/price_provider.dart b/lib/providers/global/price_provider.dart index a2a91f49e..5c2bbf670 100644 --- a/lib/providers/global/price_provider.dart +++ b/lib/providers/global/price_provider.dart @@ -10,8 +10,8 @@ import 'package:flutter/foundation.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/services/price_service.dart'; +import 'prefs_provider.dart'; +import '../../services/price_service.dart'; int _count = 0; diff --git a/lib/providers/global/secure_store_provider.dart b/lib/providers/global/secure_store_provider.dart index 6f4a9e602..284ee2745 100644 --- a/lib/providers/global/secure_store_provider.dart +++ b/lib/providers/global/secure_store_provider.dart @@ -10,9 +10,9 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; -import 'package:stackwallet/providers/desktop/storage_crypto_handler_provider.dart'; -import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; -import 'package:stackwallet/utilities/util.dart'; +import '../desktop/storage_crypto_handler_provider.dart'; +import '../../utilities/flutter_secure_storage_interface.dart'; +import '../../utilities/util.dart'; final secureStoreProvider = Provider((ref) { if (Util.isDesktop) { diff --git a/lib/providers/global/trades_service_provider.dart b/lib/providers/global/trades_service_provider.dart index 252333c54..5f872d048 100644 --- a/lib/providers/global/trades_service_provider.dart +++ b/lib/providers/global/trades_service_provider.dart @@ -9,7 +9,7 @@ */ import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/services/trade_service.dart'; +import '../../services/trade_service.dart'; final tradesServiceProvider = ChangeNotifierProvider((ref) => TradesService()); diff --git a/lib/providers/global/wallets_provider.dart b/lib/providers/global/wallets_provider.dart index 5a63fd230..34ad65fb5 100644 --- a/lib/providers/global/wallets_provider.dart +++ b/lib/providers/global/wallets_provider.dart @@ -9,9 +9,9 @@ */ import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/global/node_service_provider.dart'; -import 'package:stackwallet/services/wallets.dart'; +import '../db/main_db_provider.dart'; +import 'node_service_provider.dart'; +import '../../services/wallets.dart'; final pWallets = Provider((ref) { final mainDB = ref.read(mainDBProvider); diff --git a/lib/providers/stack_restore/stack_restoring_ui_state_provider.dart b/lib/providers/stack_restore/stack_restoring_ui_state_provider.dart index 60db49575..a618d34e5 100644 --- a/lib/providers/stack_restore/stack_restoring_ui_state_provider.dart +++ b/lib/providers/stack_restore/stack_restoring_ui_state_provider.dart @@ -9,7 +9,7 @@ */ import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/stack_restoring_ui_state.dart'; +import '../../models/stack_restoring_ui_state.dart'; final stackRestoringUIStateProvider = ChangeNotifierProvider( diff --git a/lib/providers/ui/add_wallet_selected_coin_provider.dart b/lib/providers/ui/add_wallet_selected_coin_provider.dart index e7f006f37..be0a1581d 100644 --- a/lib/providers/ui/add_wallet_selected_coin_provider.dart +++ b/lib/providers/ui/add_wallet_selected_coin_provider.dart @@ -9,7 +9,7 @@ */ import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/add_wallet_list_entity/add_wallet_list_entity.dart'; +import '../../models/add_wallet_list_entity/add_wallet_list_entity.dart'; final addWalletSelectedEntityStateProvider = StateProvider.autoDispose((_) => null); diff --git a/lib/providers/ui/address_book_providers/address_book_filter_provider.dart b/lib/providers/ui/address_book_providers/address_book_filter_provider.dart index 51fe8c07d..39d3d0ba8 100644 --- a/lib/providers/ui/address_book_providers/address_book_filter_provider.dart +++ b/lib/providers/ui/address_book_providers/address_book_filter_provider.dart @@ -9,7 +9,7 @@ */ import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/address_book_filter.dart'; +import '../../../models/address_book_filter.dart'; final addressBookFilterProvider = ChangeNotifierProvider((ref) => AddressBookFilter({})); diff --git a/lib/providers/ui/address_book_providers/address_entry_data_provider.dart b/lib/providers/ui/address_book_providers/address_entry_data_provider.dart index 3df3af34f..b4aeb157a 100644 --- a/lib/providers/ui/address_book_providers/address_entry_data_provider.dart +++ b/lib/providers/ui/address_book_providers/address_entry_data_provider.dart @@ -9,7 +9,7 @@ */ import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/contact_address_entry_data.dart'; +import '../../../models/contact_address_entry_data.dart'; // workaround to refresh entire family final addressEntryDataProviderFamilyRefresher = Provider((_) => DateTime.now()); diff --git a/lib/providers/ui/address_book_providers/valid_contact_state_provider.dart b/lib/providers/ui/address_book_providers/valid_contact_state_provider.dart index 16845149f..1bdba9729 100644 --- a/lib/providers/ui/address_book_providers/valid_contact_state_provider.dart +++ b/lib/providers/ui/address_book_providers/valid_contact_state_provider.dart @@ -9,7 +9,7 @@ */ import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/providers/ui/address_book_providers/address_entry_data_provider.dart'; +import 'address_entry_data_provider.dart'; final validContactStateProvider = StateProvider.autoDispose.family>((ref, ids) { diff --git a/lib/providers/ui/fee_rate_type_state_provider.dart b/lib/providers/ui/fee_rate_type_state_provider.dart index f78b21f9e..3e1421c14 100644 --- a/lib/providers/ui/fee_rate_type_state_provider.dart +++ b/lib/providers/ui/fee_rate_type_state_provider.dart @@ -9,7 +9,7 @@ */ import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart'; +import '../../utilities/enums/fee_rate_type_enum.dart'; final feeRateTypeStateProvider = StateProvider.autoDispose((_) => FeeRateType.average); diff --git a/lib/providers/ui/preview_tx_button_state_provider.dart b/lib/providers/ui/preview_tx_button_state_provider.dart index 768edf301..283c7c2c8 100644 --- a/lib/providers/ui/preview_tx_button_state_provider.dart +++ b/lib/providers/ui/preview_tx_button_state_provider.dart @@ -9,20 +9,20 @@ */ import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/providers/wallet/public_private_balance_state_provider.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import '../wallet/public_private_balance_state_provider.dart'; +import '../../utilities/amount/amount.dart'; +import '../../wallets/crypto_currency/coins/firo.dart'; +import '../../wallets/crypto_currency/crypto_currency.dart'; final pSendAmount = StateProvider.autoDispose((_) => null); final pValidSendToAddress = StateProvider.autoDispose((_) => false); final pValidSparkSendToAddress = StateProvider.autoDispose((_) => false); final pPreviewTxButtonEnabled = - Provider.autoDispose.family((ref, coin) { + Provider.autoDispose.family((ref, coin) { final amount = ref.watch(pSendAmount) ?? Amount.zero; - // TODO [prio=low]: move away from Coin - if (coin == Coin.firo || coin == Coin.firoTestNet) { + if (coin is Firo) { if (ref.watch(publicPrivateBalanceStateProvider) == FiroType.lelantus) { return ref.watch(pValidSendToAddress) && !ref.watch(pValidSparkSendToAddress) && diff --git a/lib/providers/ui/selected_paynym_details_item_Provider.dart b/lib/providers/ui/selected_paynym_details_item_Provider.dart index 4d160fde1..fe934990c 100644 --- a/lib/providers/ui/selected_paynym_details_item_Provider.dart +++ b/lib/providers/ui/selected_paynym_details_item_Provider.dart @@ -9,7 +9,7 @@ */ import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/paynym/paynym_account_lite.dart'; +import '../../models/paynym/paynym_account_lite.dart'; final selectedPaynymDetailsItemProvider = StateProvider.autoDispose((_) => null); diff --git a/lib/providers/ui/transaction_filter_provider.dart b/lib/providers/ui/transaction_filter_provider.dart index 69b4ea650..965e81706 100644 --- a/lib/providers/ui/transaction_filter_provider.dart +++ b/lib/providers/ui/transaction_filter_provider.dart @@ -9,7 +9,7 @@ */ import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/transaction_filter.dart'; +import '../../models/transaction_filter.dart'; final transactionFilterProvider = StateProvider((_) => null); diff --git a/lib/providers/wallet/my_paynym_account_state_provider.dart b/lib/providers/wallet/my_paynym_account_state_provider.dart index 9ee4cc89e..796bd8f03 100644 --- a/lib/providers/wallet/my_paynym_account_state_provider.dart +++ b/lib/providers/wallet/my_paynym_account_state_provider.dart @@ -9,7 +9,7 @@ */ import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/paynym/paynym_account.dart'; +import '../../models/paynym/paynym_account.dart'; final myPaynymAccountStateProvider = StateProvider((ref) => null); diff --git a/lib/providers/wallet/transaction_note_provider.dart b/lib/providers/wallet/transaction_note_provider.dart index b1c8b67e8..050dfe841 100644 --- a/lib/providers/wallet/transaction_note_provider.dart +++ b/lib/providers/wallet/transaction_note_provider.dart @@ -13,8 +13,8 @@ import 'dart:async'; import 'package:flutter/foundation.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/isar/models/transaction_note.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; +import '../../models/isar/models/transaction_note.dart'; +import '../db/main_db_provider.dart'; class _TransactionNoteWatcher extends ChangeNotifier { final ({String walletId, String txid}) key; diff --git a/lib/providers/wallet/wallet_balance_toggle_state_provider.dart b/lib/providers/wallet/wallet_balance_toggle_state_provider.dart index 2a6dc41fd..31860c052 100644 --- a/lib/providers/wallet/wallet_balance_toggle_state_provider.dart +++ b/lib/providers/wallet/wallet_balance_toggle_state_provider.dart @@ -9,7 +9,7 @@ */ import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/utilities/enums/wallet_balance_toggle_state.dart'; +import '../../utilities/enums/wallet_balance_toggle_state.dart'; final walletBalanceToggleStateProvider = StateProvider.autoDispose( diff --git a/lib/route_generator.dart b/lib/route_generator.dart index 62bae2bbd..dd22e8ccd 100644 --- a/lib/route_generator.dart +++ b/lib/route_generator.dart @@ -11,189 +11,189 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/add_wallet_list_entity/add_wallet_list_entity.dart'; -import 'package:stackwallet/models/add_wallet_list_entity/sub_classes/eth_token_entity.dart'; -import 'package:stackwallet/models/buy/response_objects/quote.dart'; -import 'package:stackwallet/models/exchange/incomplete_exchange.dart'; -import 'package:stackwallet/models/exchange/response_objects/trade.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart'; -import 'package:stackwallet/models/isar/models/contact_entry.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/models/isar/ordinal.dart'; -import 'package:stackwallet/models/paynym/paynym_account_lite.dart'; -import 'package:stackwallet/models/send_view_auto_fill_data.dart'; -import 'package:stackwallet/pages/add_wallet_views/add_token_view/add_custom_token_view.dart'; -import 'package:stackwallet/pages/add_wallet_views/add_token_view/edit_wallet_tokens_view.dart'; -import 'package:stackwallet/pages/add_wallet_views/add_wallet_view/add_wallet_view.dart'; -import 'package:stackwallet/pages/add_wallet_views/create_or_restore_wallet_view/create_or_restore_wallet_view.dart'; -import 'package:stackwallet/pages/add_wallet_views/frost_ms/new/create_new_frost_ms_wallet_view.dart'; -import 'package:stackwallet/pages/add_wallet_views/frost_ms/new/select_new_frost_import_type_view.dart'; -import 'package:stackwallet/pages/add_wallet_views/frost_ms/restore/restore_frost_ms_wallet_view.dart'; -import 'package:stackwallet/pages/add_wallet_views/name_your_wallet_view/name_your_wallet_view.dart'; -import 'package:stackwallet/pages/add_wallet_views/new_wallet_options/new_wallet_options_view.dart'; -import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_view/new_wallet_recovery_phrase_view.dart'; -import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart'; -import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/restore_options_view/restore_options_view.dart'; -import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/restore_wallet_view.dart'; -import 'package:stackwallet/pages/add_wallet_views/select_wallet_for_token_view.dart'; -import 'package:stackwallet/pages/add_wallet_views/verify_recovery_phrase_view/verify_recovery_phrase_view.dart'; -import 'package:stackwallet/pages/address_book_views/address_book_view.dart'; -import 'package:stackwallet/pages/address_book_views/subviews/add_address_book_entry_view.dart'; -import 'package:stackwallet/pages/address_book_views/subviews/add_new_contact_address_view.dart'; -import 'package:stackwallet/pages/address_book_views/subviews/address_book_filter_view.dart'; -import 'package:stackwallet/pages/address_book_views/subviews/contact_details_view.dart'; -import 'package:stackwallet/pages/address_book_views/subviews/edit_contact_address_view.dart'; -import 'package:stackwallet/pages/address_book_views/subviews/edit_contact_name_emoji_view.dart'; -import 'package:stackwallet/pages/buy_view/buy_in_wallet_view.dart'; -import 'package:stackwallet/pages/buy_view/buy_quote_preview.dart'; -import 'package:stackwallet/pages/buy_view/buy_view.dart'; -import 'package:stackwallet/pages/cashfusion/cashfusion_view.dart'; -import 'package:stackwallet/pages/cashfusion/fusion_progress_view.dart'; -import 'package:stackwallet/pages/coin_control/coin_control_view.dart'; -import 'package:stackwallet/pages/coin_control/utxo_details_view.dart'; -import 'package:stackwallet/pages/exchange_view/choose_from_stack_view.dart'; -import 'package:stackwallet/pages/exchange_view/edit_trade_note_view.dart'; -import 'package:stackwallet/pages/exchange_view/exchange_step_views/step_1_view.dart'; -import 'package:stackwallet/pages/exchange_view/exchange_step_views/step_2_view.dart'; -import 'package:stackwallet/pages/exchange_view/exchange_step_views/step_3_view.dart'; -import 'package:stackwallet/pages/exchange_view/exchange_step_views/step_4_view.dart'; -import 'package:stackwallet/pages/exchange_view/send_from_view.dart'; -import 'package:stackwallet/pages/exchange_view/trade_details_view.dart'; -import 'package:stackwallet/pages/exchange_view/wallet_initiated_exchange_view.dart'; -import 'package:stackwallet/pages/generic/single_field_edit_view.dart'; -import 'package:stackwallet/pages/home_view/home_view.dart'; -import 'package:stackwallet/pages/intro_view.dart'; -import 'package:stackwallet/pages/manage_favorites_view/manage_favorites_view.dart'; -import 'package:stackwallet/pages/monkey/monkey_view.dart'; -import 'package:stackwallet/pages/notification_views/notifications_view.dart'; -import 'package:stackwallet/pages/ordinals/ordinal_details_view.dart'; -import 'package:stackwallet/pages/ordinals/ordinals_filter_view.dart'; -import 'package:stackwallet/pages/ordinals/ordinals_view.dart'; -import 'package:stackwallet/pages/paynym/add_new_paynym_follow_view.dart'; -import 'package:stackwallet/pages/paynym/paynym_claim_view.dart'; -import 'package:stackwallet/pages/paynym/paynym_home_view.dart'; -import 'package:stackwallet/pages/pinpad_views/create_pin_view.dart'; -import 'package:stackwallet/pages/receive_view/addresses/address_details_view.dart'; -import 'package:stackwallet/pages/receive_view/addresses/edit_address_label_view.dart'; -import 'package:stackwallet/pages/receive_view/addresses/wallet_addresses_view.dart'; -import 'package:stackwallet/pages/receive_view/generate_receiving_uri_qr_code_view.dart'; -import 'package:stackwallet/pages/receive_view/receive_view.dart'; -import 'package:stackwallet/pages/send_view/confirm_transaction_view.dart'; -import 'package:stackwallet/pages/send_view/frost_ms/frost_send_view.dart'; -import 'package:stackwallet/pages/send_view/send_view.dart'; -import 'package:stackwallet/pages/send_view/token_send_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/about_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/advanced_views/advanced_settings_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/advanced_views/debug_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/advanced_views/manage_coin_units/edit_coin_units_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/advanced_views/manage_coin_units/manage_coin_units_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/advanced_views/manage_explorer_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/appearance_settings/appearance_settings_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/appearance_settings/manage_themes.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/appearance_settings/system_brightness_theme_selection_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/currency_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/delete_account_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/global_settings_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/hidden_settings.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/language_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/manage_nodes_views/coin_nodes_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/manage_nodes_views/manage_nodes_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/manage_nodes_views/node_details_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/security_views/change_pin_view/change_pin_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/security_views/security_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/auto_backup_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/create_auto_backup_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/create_backup_information_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/create_backup_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/edit_auto_backup_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/restore_from_encrypted_string_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/restore_from_file_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/stack_backup_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/startup_preferences/startup_preferences_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/startup_preferences/startup_wallet_selection_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/support_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/syncing_preferences_views/syncing_options_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/syncing_preferences_views/syncing_preferences_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/syncing_preferences_views/wallet_syncing_options_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/tor_settings/tor_settings_view.dart'; -import 'package:stackwallet/pages/settings_views/wallet_settings_view/frost_ms/frost_ms_options_view.dart'; -import 'package:stackwallet/pages/settings_views/wallet_settings_view/frost_ms/frost_participants_view.dart'; -import 'package:stackwallet/pages/settings_views/wallet_settings_view/frost_ms/initiate_resharing/complete_reshare_config_view.dart'; -import 'package:stackwallet/pages/settings_views/wallet_settings_view/frost_ms/initiate_resharing/initiate_resharing_view.dart'; -import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_backup_views/wallet_backup_view.dart'; -import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart'; -import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_settings_view.dart'; -import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/change_representative_view.dart'; -import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/delete_wallet_recovery_phrase_view.dart'; -import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/delete_wallet_warning_view.dart'; -import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/rename_wallet_view.dart'; -import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/wallet_settings_wallet_settings_view.dart'; -import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/xpub_view.dart'; -import 'package:stackwallet/pages/special/firo_rescan_recovery_error_dialog.dart'; -import 'package:stackwallet/pages/stack_privacy_calls.dart'; -import 'package:stackwallet/pages/token_view/my_tokens_view.dart'; -import 'package:stackwallet/pages/token_view/token_contract_details_view.dart'; -import 'package:stackwallet/pages/token_view/token_view.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/all_transactions_view.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/edit_note_view.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_search_filter_view.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/all_transactions_v2_view.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/fusion_group_details_view.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart'; -import 'package:stackwallet/pages/wallet_view/wallet_view.dart'; -import 'package:stackwallet/pages/wallets_view/wallets_overview.dart'; -import 'package:stackwallet/pages/wallets_view/wallets_view.dart'; -import 'package:stackwallet/pages_desktop_specific/address_book_view/desktop_address_book.dart'; -import 'package:stackwallet/pages_desktop_specific/addresses/desktop_wallet_addresses_view.dart'; -import 'package:stackwallet/pages_desktop_specific/cashfusion/desktop_cashfusion_view.dart'; -import 'package:stackwallet/pages_desktop_specific/coin_control/desktop_coin_control_view.dart'; +import 'models/add_wallet_list_entity/add_wallet_list_entity.dart'; +import 'models/add_wallet_list_entity/sub_classes/eth_token_entity.dart'; +import 'models/buy/response_objects/quote.dart'; +import 'models/exchange/incomplete_exchange.dart'; +import 'models/exchange/response_objects/trade.dart'; +import 'models/isar/models/blockchain_data/v2/transaction_v2.dart'; +import 'models/isar/models/contact_entry.dart'; +import 'models/isar/models/isar_models.dart'; +import 'models/isar/ordinal.dart'; +import 'models/paynym/paynym_account_lite.dart'; +import 'models/send_view_auto_fill_data.dart'; +import 'pages/add_wallet_views/add_token_view/add_custom_token_view.dart'; +import 'pages/add_wallet_views/add_token_view/edit_wallet_tokens_view.dart'; +import 'pages/add_wallet_views/add_wallet_view/add_wallet_view.dart'; +import 'pages/add_wallet_views/create_or_restore_wallet_view/create_or_restore_wallet_view.dart'; +import 'pages/add_wallet_views/frost_ms/new/create_new_frost_ms_wallet_view.dart'; +import 'pages/add_wallet_views/frost_ms/new/select_new_frost_import_type_view.dart'; +import 'pages/add_wallet_views/frost_ms/restore/restore_frost_ms_wallet_view.dart'; +import 'pages/add_wallet_views/name_your_wallet_view/name_your_wallet_view.dart'; +import 'pages/add_wallet_views/new_wallet_options/new_wallet_options_view.dart'; +import 'pages/add_wallet_views/new_wallet_recovery_phrase_view/new_wallet_recovery_phrase_view.dart'; +import 'pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart'; +import 'pages/add_wallet_views/restore_wallet_view/restore_options_view/restore_options_view.dart'; +import 'pages/add_wallet_views/restore_wallet_view/restore_wallet_view.dart'; +import 'pages/add_wallet_views/select_wallet_for_token_view.dart'; +import 'pages/add_wallet_views/verify_recovery_phrase_view/verify_recovery_phrase_view.dart'; +import 'pages/address_book_views/address_book_view.dart'; +import 'pages/address_book_views/subviews/add_address_book_entry_view.dart'; +import 'pages/address_book_views/subviews/add_new_contact_address_view.dart'; +import 'pages/address_book_views/subviews/address_book_filter_view.dart'; +import 'pages/address_book_views/subviews/contact_details_view.dart'; +import 'pages/address_book_views/subviews/edit_contact_address_view.dart'; +import 'pages/address_book_views/subviews/edit_contact_name_emoji_view.dart'; +import 'pages/buy_view/buy_in_wallet_view.dart'; +import 'pages/buy_view/buy_quote_preview.dart'; +import 'pages/buy_view/buy_view.dart'; +import 'pages/cashfusion/cashfusion_view.dart'; +import 'pages/cashfusion/fusion_progress_view.dart'; +import 'pages/coin_control/coin_control_view.dart'; +import 'pages/coin_control/utxo_details_view.dart'; +import 'pages/exchange_view/choose_from_stack_view.dart'; +import 'pages/exchange_view/edit_trade_note_view.dart'; +import 'pages/exchange_view/exchange_step_views/step_1_view.dart'; +import 'pages/exchange_view/exchange_step_views/step_2_view.dart'; +import 'pages/exchange_view/exchange_step_views/step_3_view.dart'; +import 'pages/exchange_view/exchange_step_views/step_4_view.dart'; +import 'pages/exchange_view/send_from_view.dart'; +import 'pages/exchange_view/trade_details_view.dart'; +import 'pages/exchange_view/wallet_initiated_exchange_view.dart'; +import 'pages/generic/single_field_edit_view.dart'; +import 'pages/home_view/home_view.dart'; +import 'pages/intro_view.dart'; +import 'pages/manage_favorites_view/manage_favorites_view.dart'; +import 'pages/monkey/monkey_view.dart'; +import 'pages/notification_views/notifications_view.dart'; +import 'pages/ordinals/ordinal_details_view.dart'; +import 'pages/ordinals/ordinals_filter_view.dart'; +import 'pages/ordinals/ordinals_view.dart'; +import 'pages/paynym/add_new_paynym_follow_view.dart'; +import 'pages/paynym/paynym_claim_view.dart'; +import 'pages/paynym/paynym_home_view.dart'; +import 'pages/pinpad_views/create_pin_view.dart'; +import 'pages/receive_view/addresses/address_details_view.dart'; +import 'pages/receive_view/addresses/edit_address_label_view.dart'; +import 'pages/receive_view/addresses/wallet_addresses_view.dart'; +import 'pages/receive_view/generate_receiving_uri_qr_code_view.dart'; +import 'pages/receive_view/receive_view.dart'; +import 'pages/send_view/confirm_transaction_view.dart'; +import 'pages/send_view/frost_ms/frost_send_view.dart'; +import 'pages/send_view/send_view.dart'; +import 'pages/send_view/token_send_view.dart'; +import 'pages/settings_views/global_settings_view/about_view.dart'; +import 'pages/settings_views/global_settings_view/advanced_views/advanced_settings_view.dart'; +import 'pages/settings_views/global_settings_view/advanced_views/debug_view.dart'; +import 'pages/settings_views/global_settings_view/advanced_views/manage_coin_units/edit_coin_units_view.dart'; +import 'pages/settings_views/global_settings_view/advanced_views/manage_coin_units/manage_coin_units_view.dart'; +import 'pages/settings_views/global_settings_view/advanced_views/manage_explorer_view.dart'; +import 'pages/settings_views/global_settings_view/appearance_settings/appearance_settings_view.dart'; +import 'pages/settings_views/global_settings_view/appearance_settings/manage_themes.dart'; +import 'pages/settings_views/global_settings_view/appearance_settings/system_brightness_theme_selection_view.dart'; +import 'pages/settings_views/global_settings_view/currency_view.dart'; +import 'pages/settings_views/global_settings_view/delete_account_view.dart'; +import 'pages/settings_views/global_settings_view/global_settings_view.dart'; +import 'pages/settings_views/global_settings_view/hidden_settings.dart'; +import 'pages/settings_views/global_settings_view/language_view.dart'; +import 'pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart'; +import 'pages/settings_views/global_settings_view/manage_nodes_views/coin_nodes_view.dart'; +import 'pages/settings_views/global_settings_view/manage_nodes_views/manage_nodes_view.dart'; +import 'pages/settings_views/global_settings_view/manage_nodes_views/node_details_view.dart'; +import 'pages/settings_views/global_settings_view/security_views/change_pin_view/change_pin_view.dart'; +import 'pages/settings_views/global_settings_view/security_views/security_view.dart'; +import 'pages/settings_views/global_settings_view/stack_backup_views/auto_backup_view.dart'; +import 'pages/settings_views/global_settings_view/stack_backup_views/create_auto_backup_view.dart'; +import 'pages/settings_views/global_settings_view/stack_backup_views/create_backup_information_view.dart'; +import 'pages/settings_views/global_settings_view/stack_backup_views/create_backup_view.dart'; +import 'pages/settings_views/global_settings_view/stack_backup_views/edit_auto_backup_view.dart'; +import 'pages/settings_views/global_settings_view/stack_backup_views/restore_from_encrypted_string_view.dart'; +import 'pages/settings_views/global_settings_view/stack_backup_views/restore_from_file_view.dart'; +import 'pages/settings_views/global_settings_view/stack_backup_views/stack_backup_view.dart'; +import 'pages/settings_views/global_settings_view/startup_preferences/startup_preferences_view.dart'; +import 'pages/settings_views/global_settings_view/startup_preferences/startup_wallet_selection_view.dart'; +import 'pages/settings_views/global_settings_view/support_view.dart'; +import 'pages/settings_views/global_settings_view/syncing_preferences_views/syncing_options_view.dart'; +import 'pages/settings_views/global_settings_view/syncing_preferences_views/syncing_preferences_view.dart'; +import 'pages/settings_views/global_settings_view/syncing_preferences_views/wallet_syncing_options_view.dart'; +import 'pages/settings_views/global_settings_view/tor_settings/tor_settings_view.dart'; +import 'pages/settings_views/wallet_settings_view/frost_ms/frost_ms_options_view.dart'; +import 'pages/settings_views/wallet_settings_view/frost_ms/frost_participants_view.dart'; +import 'pages/settings_views/wallet_settings_view/frost_ms/initiate_resharing/complete_reshare_config_view.dart'; +import 'pages/settings_views/wallet_settings_view/frost_ms/initiate_resharing/initiate_resharing_view.dart'; +import 'pages/settings_views/wallet_settings_view/wallet_backup_views/wallet_backup_view.dart'; +import 'pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart'; +import 'pages/settings_views/wallet_settings_view/wallet_settings_view.dart'; +import 'pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/change_representative_view.dart'; +import 'pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/delete_wallet_recovery_phrase_view.dart'; +import 'pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/delete_wallet_warning_view.dart'; +import 'pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/rename_wallet_view.dart'; +import 'pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/wallet_settings_wallet_settings_view.dart'; +import 'pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/xpub_view.dart'; +import 'pages/special/firo_rescan_recovery_error_dialog.dart'; +import 'pages/stack_privacy_calls.dart'; +import 'pages/token_view/my_tokens_view.dart'; +import 'pages/token_view/token_contract_details_view.dart'; +import 'pages/token_view/token_view.dart'; +import 'pages/wallet_view/transaction_views/all_transactions_view.dart'; +import 'pages/wallet_view/transaction_views/edit_note_view.dart'; +import 'pages/wallet_view/transaction_views/transaction_details_view.dart'; +import 'pages/wallet_view/transaction_views/transaction_search_filter_view.dart'; +import 'pages/wallet_view/transaction_views/tx_v2/all_transactions_v2_view.dart'; +import 'pages/wallet_view/transaction_views/tx_v2/fusion_group_details_view.dart'; +import 'pages/wallet_view/transaction_views/tx_v2/transaction_v2_details_view.dart'; +import 'pages/wallet_view/wallet_view.dart'; +import 'pages/wallets_view/wallets_overview.dart'; +import 'pages/wallets_view/wallets_view.dart'; +import 'pages_desktop_specific/address_book_view/desktop_address_book.dart'; +import 'pages_desktop_specific/addresses/desktop_wallet_addresses_view.dart'; +import 'pages_desktop_specific/cashfusion/desktop_cashfusion_view.dart'; +import 'pages_desktop_specific/coin_control/desktop_coin_control_view.dart'; // import 'package:stackwallet/pages_desktop_specific/desktop_exchange/desktop_all_buys_view.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_buy/desktop_buy_view.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_exchange/desktop_all_trades_view.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_exchange/desktop_exchange_view.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_home_view.dart'; -import 'package:stackwallet/pages_desktop_specific/lelantus_coins/lelantus_coins_view.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/my_stack_view.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/desktop_token_view.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/desktop_wallet_view.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/delete_wallet_keys_popup.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_attention_delete_wallet.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_delete_wallet_dialog.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/qr_code_desktop_popup_content.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/unlock_wallet_keys_desktop.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/wallet_keys_desktop_popup.dart'; -import 'package:stackwallet/pages_desktop_specific/notifications/desktop_notifications_view.dart'; -import 'package:stackwallet/pages_desktop_specific/ordinals/desktop_ordinal_details_view.dart'; -import 'package:stackwallet/pages_desktop_specific/ordinals/desktop_ordinals_view.dart'; -import 'package:stackwallet/pages_desktop_specific/password/create_password_view.dart'; -import 'package:stackwallet/pages_desktop_specific/password/delete_password_warning_view.dart'; -import 'package:stackwallet/pages_desktop_specific/password/forgot_password_desktop_view.dart'; -import 'package:stackwallet/pages_desktop_specific/password/forgotten_passphrase_restore_from_swb.dart'; -import 'package:stackwallet/pages_desktop_specific/settings/desktop_settings_view.dart'; -import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/advanced_settings/advanced_settings.dart'; -import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/appearance_settings/appearance_settings.dart'; -import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/backup_and_restore/backup_and_restore_settings.dart'; -import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/currency_settings/currency_settings.dart'; -import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/desktop_about_view.dart'; -import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/desktop_support_view.dart'; -import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/language_settings/language_settings.dart'; -import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/nodes_settings.dart'; -import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/security_settings.dart'; -import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/syncing_preferences_settings.dart'; -import 'package:stackwallet/pages_desktop_specific/settings/settings_menu/tor_settings/tor_settings.dart'; -import 'package:stackwallet/pages_desktop_specific/spark_coins/spark_coins_view.dart'; -import 'package:stackwallet/services/event_bus/events/global/node_connection_status_changed_event.dart'; -import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/enums/add_wallet_type_enum.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/frost_currency.dart'; -import 'package:stackwallet/wallets/models/tx_data.dart'; -import 'package:stackwallet/wallets/wallet/wallet.dart'; -import 'package:stackwallet/widgets/choose_coin_view.dart'; -import 'package:stackwallet/widgets/frost_scaffold.dart'; +import 'pages_desktop_specific/desktop_buy/desktop_buy_view.dart'; +import 'pages_desktop_specific/desktop_exchange/desktop_all_trades_view.dart'; +import 'pages_desktop_specific/desktop_exchange/desktop_exchange_view.dart'; +import 'pages_desktop_specific/desktop_home_view.dart'; +import 'pages_desktop_specific/lelantus_coins/lelantus_coins_view.dart'; +import 'pages_desktop_specific/my_stack_view/my_stack_view.dart'; +import 'pages_desktop_specific/my_stack_view/wallet_view/desktop_token_view.dart'; +import 'pages_desktop_specific/my_stack_view/wallet_view/desktop_wallet_view.dart'; +import 'pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/delete_wallet_keys_popup.dart'; +import 'pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_attention_delete_wallet.dart'; +import 'pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_delete_wallet_dialog.dart'; +import 'pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/qr_code_desktop_popup_content.dart'; +import 'pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/unlock_wallet_keys_desktop.dart'; +import 'pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/wallet_keys_desktop_popup.dart'; +import 'pages_desktop_specific/notifications/desktop_notifications_view.dart'; +import 'pages_desktop_specific/ordinals/desktop_ordinal_details_view.dart'; +import 'pages_desktop_specific/ordinals/desktop_ordinals_view.dart'; +import 'pages_desktop_specific/password/create_password_view.dart'; +import 'pages_desktop_specific/password/delete_password_warning_view.dart'; +import 'pages_desktop_specific/password/forgot_password_desktop_view.dart'; +import 'pages_desktop_specific/password/forgotten_passphrase_restore_from_swb.dart'; +import 'pages_desktop_specific/settings/desktop_settings_view.dart'; +import 'pages_desktop_specific/settings/settings_menu/advanced_settings/advanced_settings.dart'; +import 'pages_desktop_specific/settings/settings_menu/appearance_settings/appearance_settings.dart'; +import 'pages_desktop_specific/settings/settings_menu/backup_and_restore/backup_and_restore_settings.dart'; +import 'pages_desktop_specific/settings/settings_menu/currency_settings/currency_settings.dart'; +import 'pages_desktop_specific/settings/settings_menu/desktop_about_view.dart'; +import 'pages_desktop_specific/settings/settings_menu/desktop_support_view.dart'; +import 'pages_desktop_specific/settings/settings_menu/language_settings/language_settings.dart'; +import 'pages_desktop_specific/settings/settings_menu/nodes_settings.dart'; +import 'pages_desktop_specific/settings/settings_menu/security_settings.dart'; +import 'pages_desktop_specific/settings/settings_menu/syncing_preferences_settings.dart'; +import 'pages_desktop_specific/settings/settings_menu/tor_settings/tor_settings.dart'; +import 'pages_desktop_specific/spark_coins/spark_coins_view.dart'; +import 'services/event_bus/events/global/node_connection_status_changed_event.dart'; +import 'services/event_bus/events/global/wallet_sync_status_changed_event.dart'; +import 'utilities/amount/amount.dart'; +import 'utilities/enums/add_wallet_type_enum.dart'; +import 'wallets/crypto_currency/crypto_currency.dart'; +import 'wallets/crypto_currency/intermediate/frost_currency.dart'; +import 'wallets/models/tx_data.dart'; +import 'wallets/wallet/wallet.dart'; +import 'widgets/choose_coin_view.dart'; +import 'widgets/frost_scaffold.dart'; import 'package:tuple/tuple.dart'; /* @@ -211,21 +211,24 @@ class RouteGenerator { switch (settings.name) { case IntroView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const IntroView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const IntroView(), + settings: RouteSettings(name: settings.name), + ); case DeleteAccountView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const DeleteAccountView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const DeleteAccountView(), + settings: RouteSettings(name: settings.name), + ); case HomeView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const HomeView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const HomeView(), + settings: RouteSettings(name: settings.name), + ); case CreatePinView.routeName: if (args is bool) { @@ -240,9 +243,10 @@ class RouteGenerator { ); } return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const CreatePinView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const CreatePinView(), + settings: RouteSettings(name: settings.name), + ); case StackPrivacyCalls.routeName: if (args is bool) { @@ -253,9 +257,10 @@ class RouteGenerator { ); } return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const StackPrivacyCalls(isSettings: false), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const StackPrivacyCalls(isSettings: false), + settings: RouteSettings(name: settings.name), + ); case ChooseCoinView.routeName: if (args is Tuple3) { @@ -274,7 +279,7 @@ class RouteGenerator { return _routeError("${settings.name} invalid args: ${args.toString()}"); case ManageExplorerView.routeName: - if (args is Coin) { + if (args is CryptoCurrency) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, builder: (_) => ManageExplorerView( @@ -303,15 +308,17 @@ class RouteGenerator { case WalletsView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const WalletsView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const WalletsView(), + settings: RouteSettings(name: settings.name), + ); case AddWalletView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const AddWalletView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const AddWalletView(), + settings: RouteSettings(name: settings.name), + ); case EditWalletTokensView.routeName: if (args is String) { @@ -376,7 +383,7 @@ class RouteGenerator { ); case WalletsOverview.routeName: - if (args is Coin) { + if (args is CryptoCurrency) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, builder: (_) => WalletsOverview( @@ -556,7 +563,7 @@ class RouteGenerator { case FrostSendView.routeName: if (args is ({ String walletId, - Coin coin, + CryptoCurrency coin, })) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, @@ -675,9 +682,10 @@ class RouteGenerator { case OrdinalsFilterView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const OrdinalsFilterView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const OrdinalsFilterView(), + settings: RouteSettings(name: settings.name), + ); case UtxoDetailsView.routeName: if (args is Tuple2) { @@ -780,12 +788,13 @@ class RouteGenerator { case GlobalSettingsView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const GlobalSettingsView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const GlobalSettingsView(), + settings: RouteSettings(name: settings.name), + ); case AddressBookView.routeName: - if (args is Coin) { + if (args is CryptoCurrency) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, builder: (_) => AddressBookView( @@ -797,87 +806,101 @@ class RouteGenerator { ); } return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const AddressBookView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const AddressBookView(), + settings: RouteSettings(name: settings.name), + ); case AddressBookFilterView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const AddressBookFilterView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const AddressBookFilterView(), + settings: RouteSettings(name: settings.name), + ); case StackBackupView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const StackBackupView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const StackBackupView(), + settings: RouteSettings(name: settings.name), + ); case AutoBackupView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const AutoBackupView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const AutoBackupView(), + settings: RouteSettings(name: settings.name), + ); case EditAutoBackupView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const EditAutoBackupView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const EditAutoBackupView(), + settings: RouteSettings(name: settings.name), + ); case CreateAutoBackupView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const CreateAutoBackupView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const CreateAutoBackupView(), + settings: RouteSettings(name: settings.name), + ); case SecurityView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const SecurityView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const SecurityView(), + settings: RouteSettings(name: settings.name), + ); case ChangePinView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const ChangePinView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const ChangePinView(), + settings: RouteSettings(name: settings.name), + ); case BaseCurrencySettingsView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const BaseCurrencySettingsView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const BaseCurrencySettingsView(), + settings: RouteSettings(name: settings.name), + ); case LanguageSettingsView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const LanguageSettingsView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const LanguageSettingsView(), + settings: RouteSettings(name: settings.name), + ); case TorSettingsView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const TorSettingsView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const TorSettingsView(), + settings: RouteSettings(name: settings.name), + ); case TorSettings.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const TorSettings(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const TorSettings(), + settings: RouteSettings(name: settings.name), + ); case AboutView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const AboutView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const AboutView(), + settings: RouteSettings(name: settings.name), + ); case DebugView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const DebugView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const DebugView(), + settings: RouteSettings(name: settings.name), + ); case XPubView.routeName: if (args is String) { @@ -909,69 +932,80 @@ class RouteGenerator { case AppearanceSettingsView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const AppearanceSettingsView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const AppearanceSettingsView(), + settings: RouteSettings(name: settings.name), + ); case SyncingPreferencesView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const SyncingPreferencesView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const SyncingPreferencesView(), + settings: RouteSettings(name: settings.name), + ); case StartupPreferencesView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const StartupPreferencesView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const StartupPreferencesView(), + settings: RouteSettings(name: settings.name), + ); case StartupWalletSelectionView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const StartupWalletSelectionView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const StartupWalletSelectionView(), + settings: RouteSettings(name: settings.name), + ); case ManageNodesView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const ManageNodesView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const ManageNodesView(), + settings: RouteSettings(name: settings.name), + ); case SyncingOptionsView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const SyncingOptionsView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const SyncingOptionsView(), + settings: RouteSettings(name: settings.name), + ); case WalletSyncingOptionsView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const WalletSyncingOptionsView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const WalletSyncingOptionsView(), + settings: RouteSettings(name: settings.name), + ); case AdvancedSettingsView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const AdvancedSettingsView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const AdvancedSettingsView(), + settings: RouteSettings(name: settings.name), + ); case SupportView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const SupportView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const SupportView(), + settings: RouteSettings(name: settings.name), + ); case AddAddressBookEntryView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const AddAddressBookEntryView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const AddAddressBookEntryView(), + settings: RouteSettings(name: settings.name), + ); case RestoreFromFileView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const RestoreFromFileView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const RestoreFromFileView(), + settings: RouteSettings(name: settings.name), + ); case RestoreFromEncryptedStringView.routeName: if (args is String) { @@ -989,12 +1023,13 @@ class RouteGenerator { case ManageCoinUnitsView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const ManageCoinUnitsView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const ManageCoinUnitsView(), + settings: RouteSettings(name: settings.name), + ); case EditCoinUnitsView.routeName: - if (args is Coin) { + if (args is CryptoCurrency) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, builder: (_) => EditCoinUnitsView( @@ -1009,24 +1044,27 @@ class RouteGenerator { case CreateBackupInfoView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const CreateBackupInfoView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const CreateBackupInfoView(), + settings: RouteSettings(name: settings.name), + ); case CreateBackupView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const CreateBackupView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const CreateBackupView(), + settings: RouteSettings(name: settings.name), + ); case HiddenSettings.routeName: return getRoute( - shouldUseMaterialRoute: false, - builder: (_) => const HiddenSettings(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: false, + builder: (_) => const HiddenSettings(), + settings: RouteSettings(name: settings.name), + ); case CoinNodesView.routeName: - if (args is Coin) { + if (args is CryptoCurrency) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, builder: (_) => CoinNodesView( @@ -1040,7 +1078,7 @@ class RouteGenerator { return _routeError("${settings.name} invalid args: ${args.toString()}"); case NodeDetailsView.routeName: - if (args is Tuple3) { + if (args is Tuple3) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, builder: (_) => NodeDetailsView( @@ -1100,7 +1138,8 @@ class RouteGenerator { return _routeError("${settings.name} invalid args: ${args.toString()}"); case AddEditNodeView.routeName: - if (args is Tuple4) { + if (args + is Tuple4) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, builder: (_) => AddEditNodeView( @@ -1291,7 +1330,7 @@ class RouteGenerator { return _routeError("${settings.name} invalid args: ${args.toString()}"); case NameYourWalletView.routeName: - if (args is Tuple2) { + if (args is Tuple2) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, builder: (_) => NameYourWalletView( @@ -1306,7 +1345,7 @@ class RouteGenerator { return _routeError("${settings.name} invalid args: ${args.toString()}"); case NewWalletRecoveryPhraseWarningView.routeName: - if (args is Tuple2) { + if (args is Tuple2) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, builder: (_) => NewWalletRecoveryPhraseWarningView( @@ -1321,7 +1360,7 @@ class RouteGenerator { return _routeError("${settings.name} invalid args: ${args.toString()}"); case RestoreOptionsView.routeName: - if (args is Tuple2) { + if (args is Tuple2) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, builder: (_) => RestoreOptionsView( @@ -1336,7 +1375,7 @@ class RouteGenerator { return _routeError("${settings.name} invalid args: ${args.toString()}"); case NewWalletOptionsView.routeName: - if (args is Tuple2) { + if (args is Tuple2) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, builder: (_) => NewWalletOptionsView( @@ -1351,15 +1390,16 @@ class RouteGenerator { return _routeError("${settings.name} invalid args: ${args.toString()}"); case RestoreWalletView.routeName: - if (args is Tuple5) { + if (args is Tuple5) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, builder: (_) => RestoreWalletView( - walletName: args.item1, - coin: args.item2, - seedWordsLength: args.item3, - restoreFromDate: args.item4, - mnemonicPassphrase: args.item5), + walletName: args.item1, + coin: args.item2, + seedWordsLength: args.item3, + restoreFromDate: args.item4, + mnemonicPassphrase: args.item5, + ), settings: RouteSettings( name: settings.name, ), @@ -1399,8 +1439,9 @@ class RouteGenerator { case ManageFavoritesView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const ManageFavoritesView()); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const ManageFavoritesView(), + ); case WalletView.routeName: if (args is String) { @@ -1417,7 +1458,7 @@ class RouteGenerator { return _routeError("${settings.name} invalid args: ${args.toString()}"); case TransactionDetailsView.routeName: - if (args is Tuple3) { + if (args is Tuple3) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, builder: (_) => TransactionDetailsView( @@ -1433,7 +1474,11 @@ class RouteGenerator { return _routeError("${settings.name} invalid args: ${args.toString()}"); case TransactionV2DetailsView.routeName: - if (args is ({TransactionV2 tx, Coin coin, String walletId})) { + if (args is ({ + TransactionV2 tx, + CryptoCurrency coin, + String walletId + })) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, builder: (_) => TransactionV2DetailsView( @@ -1451,7 +1496,7 @@ class RouteGenerator { case FusionGroupDetailsView.routeName: if (args is ({ List transactions, - Coin coin, + CryptoCurrency coin, String walletId })) { return getRoute( @@ -1509,7 +1554,7 @@ class RouteGenerator { return _routeError("${settings.name} invalid args: ${args.toString()}"); case TransactionSearchFilterView.routeName: - if (args is Coin) { + if (args is CryptoCurrency) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, builder: (_) => TransactionSearchFilterView( @@ -1577,7 +1622,7 @@ class RouteGenerator { return _routeError("${settings.name} invalid args: ${args.toString()}"); case SendView.routeName: - if (args is Tuple2) { + if (args is Tuple2) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, builder: (_) => SendView( @@ -1588,7 +1633,8 @@ class RouteGenerator { name: settings.name, ), ); - } else if (args is Tuple3) { + } else if (args + is Tuple3) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, builder: (_) => SendView( @@ -1600,7 +1646,7 @@ class RouteGenerator { name: settings.name, ), ); - } else if (args is Tuple3) { + } else if (args is Tuple3) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, builder: (_) => SendView( @@ -1612,7 +1658,7 @@ class RouteGenerator { name: settings.name, ), ); - } else if (args is ({Coin coin, String walletId})) { + } else if (args is ({CryptoCurrency coin, String walletId})) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, builder: (_) => SendView( @@ -1628,7 +1674,7 @@ class RouteGenerator { return _routeError("${settings.name} invalid args: ${args.toString()}"); case TokenSendView.routeName: - if (args is Tuple3) { + if (args is Tuple3) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, builder: (_) => TokenSendView( @@ -1660,7 +1706,7 @@ class RouteGenerator { return _routeError("${settings.name} invalid args: ${args.toString()}"); case WalletInitiatedExchangeView.routeName: - if (args is Tuple2) { + if (args is Tuple2) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, builder: (_) => Stack( @@ -1679,7 +1725,7 @@ class RouteGenerator { ), ); } - if (args is Tuple3) { + if (args is Tuple3) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, builder: (_) => Stack( @@ -1716,8 +1762,8 @@ class RouteGenerator { return _routeError("${settings.name} invalid args: ${args.toString()}"); case WalletSettingsView.routeName: - if (args - is Tuple4) { + if (args is Tuple4) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, builder: (_) => WalletSettingsView( @@ -1845,7 +1891,7 @@ class RouteGenerator { return _routeError("${settings.name} invalid args: ${args.toString()}"); case ChooseFromStackView.routeName: - if (args is Coin) { + if (args is CryptoCurrency) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, builder: (_) => ChooseFromStackView( @@ -1859,7 +1905,7 @@ class RouteGenerator { return _routeError("${settings.name} invalid args: ${args.toString()}"); case SendFromView.routeName: - if (args is Tuple4) { + if (args is Tuple4) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, builder: (_) => SendFromView( @@ -1876,7 +1922,7 @@ class RouteGenerator { return _routeError("${settings.name} invalid args: ${args.toString()}"); case GenerateUriQrCodeView.routeName: - if (args is Tuple2) { + if (args is Tuple2) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, builder: (_) => GenerateUriQrCodeView( @@ -1918,21 +1964,24 @@ class RouteGenerator { ); } return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const CreatePasswordView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const CreatePasswordView(), + settings: RouteSettings(name: settings.name), + ); case ForgotPasswordDesktopView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const ForgotPasswordDesktopView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const ForgotPasswordDesktopView(), + settings: RouteSettings(name: settings.name), + ); case ForgottenPassphraseRestoreFromSWB.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const ForgottenPassphraseRestoreFromSWB(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const ForgottenPassphraseRestoreFromSWB(), + settings: RouteSettings(name: settings.name), + ); case DeletePasswordWarningView.routeName: if (args is bool) { @@ -1950,30 +1999,34 @@ class RouteGenerator { case DesktopHomeView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const DesktopHomeView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const DesktopHomeView(), + settings: RouteSettings(name: settings.name), + ); case DesktopNotificationsView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const DesktopNotificationsView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const DesktopNotificationsView(), + settings: RouteSettings(name: settings.name), + ); case DesktopExchangeView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const DesktopExchangeView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const DesktopExchangeView(), + settings: RouteSettings(name: settings.name), + ); case BuyView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const BuyView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const BuyView(), + settings: RouteSettings(name: settings.name), + ); case BuyInWalletView.routeName: - if (args is Coin) { + if (args is CryptoCurrency) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, builder: (_) => BuyInWalletView(coin: args), @@ -1982,7 +2035,7 @@ class RouteGenerator { ), ); } - if (args is Tuple2) { + if (args is Tuple2) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, builder: (_) => BuyInWalletView( @@ -1998,27 +2051,31 @@ class RouteGenerator { case DesktopBuyView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const DesktopBuyView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const DesktopBuyView(), + settings: RouteSettings(name: settings.name), + ); case DesktopAllTradesView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const DesktopAllTradesView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const DesktopAllTradesView(), + settings: RouteSettings(name: settings.name), + ); case DesktopSettingsView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const DesktopSettingsView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const DesktopSettingsView(), + settings: RouteSettings(name: settings.name), + ); case MyStackView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const MyStackView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const MyStackView(), + settings: RouteSettings(name: settings.name), + ); case DesktopWalletView.routeName: if (args is String) { @@ -2092,75 +2149,87 @@ class RouteGenerator { case BackupRestoreSettings.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const BackupRestoreSettings(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const BackupRestoreSettings(), + settings: RouteSettings(name: settings.name), + ); case SecuritySettings.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const SecuritySettings(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const SecuritySettings(), + settings: RouteSettings(name: settings.name), + ); case CurrencySettings.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const CurrencySettings(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const CurrencySettings(), + settings: RouteSettings(name: settings.name), + ); case LanguageOptionSettings.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const LanguageOptionSettings(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const LanguageOptionSettings(), + settings: RouteSettings(name: settings.name), + ); case NodesSettings.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const NodesSettings(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const NodesSettings(), + settings: RouteSettings(name: settings.name), + ); case SyncingPreferencesSettings.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const SyncingPreferencesSettings(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const SyncingPreferencesSettings(), + settings: RouteSettings(name: settings.name), + ); case AppearanceOptionSettings.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const AppearanceOptionSettings(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const AppearanceOptionSettings(), + settings: RouteSettings(name: settings.name), + ); case ManageThemesView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const ManageThemesView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const ManageThemesView(), + settings: RouteSettings(name: settings.name), + ); case AdvancedSettings.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const AdvancedSettings(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const AdvancedSettings(), + settings: RouteSettings(name: settings.name), + ); case DesktopSupportView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const DesktopSupportView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const DesktopSupportView(), + settings: RouteSettings(name: settings.name), + ); case DesktopAboutView.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const DesktopAboutView(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const DesktopAboutView(), + settings: RouteSettings(name: settings.name), + ); case DesktopAddressBook.routeName: return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => const DesktopAddressBook(), - settings: RouteSettings(name: settings.name)); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => const DesktopAddressBook(), + settings: RouteSettings(name: settings.name), + ); case WalletKeysDesktopPopup.routeName: if (args is ({ @@ -2413,13 +2482,15 @@ class RouteGenerator { ), body: Center( child: Text( - 'Error handling route, this is not supposed to happen. Try restarting the app.\n$message'), + 'Error handling route, this is not supposed to happen. Try restarting the app.\n$message', + ), ), ); return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => errorView); + shouldUseMaterialRoute: useMaterialPageRoute, + builder: (_) => errorView, + ); } } diff --git a/lib/services/address_book_service.dart b/lib/services/address_book_service.dart index d925a3b0d..f49d9e664 100644 --- a/lib/services/address_book_service.dart +++ b/lib/services/address_book_service.dart @@ -10,13 +10,12 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart'; -import 'package:stackwallet/db/isar/main_db.dart'; -import 'package:stackwallet/models/isar/models/contact_entry.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import '../db/isar/main_db.dart'; +import '../models/isar/models/contact_entry.dart'; class AddressBookService extends ChangeNotifier { ContactEntry getContactById(String id) { - ContactEntry? contactEntry = MainDB.instance.getContactEntry(id: id); + final ContactEntry? contactEntry = MainDB.instance.getContactEntry(id: id); if (contactEntry == null) { throw Exception('Contact ID "$id" not found!'); } else { @@ -30,7 +29,7 @@ class AddressBookService extends ChangeNotifier { //TODO search using isar queries Future> search(String text) async { if (text.isEmpty) return contacts; - var results = contacts.toList(); + final results = contacts.toList(); results.retainWhere((contact) => matches(text, contact)); @@ -47,7 +46,7 @@ class AddressBookService extends ChangeNotifier { } for (int i = 0; i < contact.addresses.length; i++) { if (contact.addresses[i].label.toLowerCase().contains(text) || - contact.addresses[i].coin.name.toLowerCase().contains(text) || + contact.addresses[i].coin.identifier.toLowerCase().contains(text) || contact.addresses[i].coin.prettyName.toLowerCase().contains(text) || contact.addresses[i].coin.ticker.toLowerCase().contains(text) || contact.addresses[i].address.toLowerCase().contains(text)) { diff --git a/lib/services/auto_swb_service.dart b/lib/services/auto_swb_service.dart index 7dcb5e421..d1f5d5499 100644 --- a/lib/services/auto_swb_service.dart +++ b/lib/services/auto_swb_service.dart @@ -13,10 +13,10 @@ import 'dart:convert'; import 'dart:io'; import 'package:flutter/foundation.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart'; -import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/prefs.dart'; +import '../pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart'; +import '../utilities/flutter_secure_storage_interface.dart'; +import '../utilities/logger.dart'; +import '../utilities/prefs.dart'; import 'package:tuple/tuple.dart'; enum AutoSWBStatus { diff --git a/lib/services/buy/simplex/simplex_api.dart b/lib/services/buy/simplex/simplex_api.dart index 6ab2736e4..5bbb82c1c 100644 --- a/lib/services/buy/simplex/simplex_api.dart +++ b/lib/services/buy/simplex/simplex_api.dart @@ -12,19 +12,20 @@ import 'dart:async'; import 'dart:convert'; import 'package:decimal/decimal.dart'; -import 'package:stackwallet/models/buy/response_objects/crypto.dart'; -import 'package:stackwallet/models/buy/response_objects/fiat.dart'; -import 'package:stackwallet/models/buy/response_objects/order.dart'; -import 'package:stackwallet/models/buy/response_objects/quote.dart'; -import 'package:stackwallet/networking/http.dart'; -import 'package:stackwallet/services/buy/buy_response.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/fiat_enum.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/prefs.dart'; import 'package:url_launcher/url_launcher.dart'; +import '../../../app_config.dart'; +import '../../../models/buy/response_objects/crypto.dart'; +import '../../../models/buy/response_objects/fiat.dart'; +import '../../../models/buy/response_objects/order.dart'; +import '../../../models/buy/response_objects/quote.dart'; +import '../../../networking/http.dart'; +import '../../../utilities/enums/fiat_enum.dart'; +import '../../../utilities/logger.dart'; +import '../../../utilities/prefs.dart'; +import '../../tor_service.dart'; +import '../buy_response.dart'; + class SimplexAPI { static const String authority = "buycrypto.stackwallet.com"; // static const String authority = "localhost"; // For development purposes @@ -47,30 +48,34 @@ class SimplexAPI { Future>> getSupportedCryptos() async { try { - Map headers = { + final Map headers = { 'Content-Type': 'application/x-www-form-urlencoded', }; - Map data = { + final Map data = { 'ROUTE': 'supported_cryptos', }; - Uri url = _buildUri('api.php', data); + final Uri url = _buildUri('api.php', data); - var res = await client.post( + final res = await client.post( url: url, headers: headers, - proxyInfo: - Prefs.instance.useTor ? TorService.sharedInstance.getProxyInfo() : null, + proxyInfo: Prefs.instance.useTor + ? TorService.sharedInstance.getProxyInfo() + : null, ); if (res.code != 200) { throw Exception( - 'getAvailableCurrencies exception: statusCode= ${res.code}'); + 'getAvailableCurrencies exception: statusCode= ${res.code}', + ); } final jsonArray = jsonDecode(res.body); // TODO handle if invalid json return _parseSupportedCryptos(jsonArray); } catch (e, s) { - Logging.instance.log("getAvailableCurrencies exception: $e\n$s", - level: LogLevel.Error); + Logging.instance.log( + "getAvailableCurrencies exception: $e\n$s", + level: LogLevel.Error, + ); return BuyResponse( exception: BuyException( e.toString(), @@ -82,19 +87,20 @@ class SimplexAPI { BuyResponse> _parseSupportedCryptos(dynamic jsonArray) { try { - List cryptos = []; - List fiats = []; + final List cryptos = []; for (final crypto in jsonArray as List) { // TODO validate jsonArray - if (isStackCoin("${crypto['ticker_symbol']}")) { - cryptos.add(Crypto.fromJson({ - 'ticker': "${crypto['ticker_symbol']}", - 'name': crypto['name'], - 'network': "${crypto['network']}", - 'contractAddress': "${crypto['contractAddress']}", - 'image': "", - })); + if (AppConfig.isStackCoin("${crypto['ticker_symbol']}")) { + cryptos.add( + Crypto.fromJson({ + 'ticker': "${crypto['ticker_symbol']}", + 'name': crypto['name'], + 'network': "${crypto['network']}", + 'contractAddress': "${crypto['contractAddress']}", + 'image': "", + }), + ); } } @@ -113,30 +119,34 @@ class SimplexAPI { Future>> getSupportedFiats() async { try { - Map headers = { + final Map headers = { 'Content-Type': 'application/x-www-form-urlencoded', }; - Map data = { + final Map data = { 'ROUTE': 'supported_fiats', }; - Uri url = _buildUri('api.php', data); + final Uri url = _buildUri('api.php', data); - var res = await client.post( + final res = await client.post( url: url, headers: headers, - proxyInfo: - Prefs.instance.useTor ? TorService.sharedInstance.getProxyInfo() : null, + proxyInfo: Prefs.instance.useTor + ? TorService.sharedInstance.getProxyInfo() + : null, ); if (res.code != 200) { throw Exception( - 'getAvailableCurrencies exception: statusCode= ${res.code}'); + 'getAvailableCurrencies exception: statusCode= ${res.code}', + ); } final jsonArray = jsonDecode(res.body); // TODO validate json return _parseSupportedFiats(jsonArray); } catch (e, s) { - Logging.instance.log("getAvailableCurrencies exception: $e\n$s", - level: LogLevel.Error); + Logging.instance.log( + "getAvailableCurrencies exception: $e\n$s", + level: LogLevel.Error, + ); return BuyResponse( exception: BuyException( e.toString(), @@ -148,20 +158,22 @@ class SimplexAPI { BuyResponse> _parseSupportedFiats(dynamic jsonArray) { try { - List cryptos = []; - List fiats = []; + final List cryptos = []; + final List fiats = []; for (final fiat in jsonArray as List) { if (isSimplexFiat("${fiat['ticker_symbol']}")) { // TODO validate list - fiats.add(Fiat.fromJson({ - 'ticker': "${fiat['ticker_symbol']}", - 'name': fiatFromTickerCaseInsensitive("${fiat['ticker_symbol']}") - .prettyName, - 'minAmount': "${fiat['min_amount']}", - 'maxAmount': "${fiat['max_amount']}", - 'image': "", - })); + fiats.add( + Fiat.fromJson({ + 'ticker': "${fiat['ticker_symbol']}", + 'name': fiatFromTickerCaseInsensitive("${fiat['ticker_symbol']}") + .prettyName, + 'minAmount': "${fiat['min_amount']}", + 'maxAmount': "${fiat['max_amount']}", + 'image': "", + }), + ); } // TODO handle else } @@ -181,12 +193,12 @@ class SimplexAPI { Future> getQuote(SimplexQuote quote) async { try { await _prefs.init(); - String? userID = _prefs.userID; + final String? userID = _prefs.userID; - Map headers = { + final Map headers = { 'Content-Type': 'application/x-www-form-urlencoded', }; - Map data = { + final Map data = { 'ROUTE': 'quote', 'CRYPTO_TICKER': quote.crypto.ticker.toUpperCase(), 'FIAT_TICKER': quote.fiat.ticker.toUpperCase(), @@ -200,13 +212,14 @@ class SimplexAPI { if (userID != null) { data['USER_ID'] = userID; } - Uri url = _buildUri('api.php', data); + final Uri url = _buildUri('api.php', data); - var res = await client.get( + final res = await client.get( url: url, headers: headers, - proxyInfo: - Prefs.instance.useTor ? TorService.sharedInstance.getProxyInfo() : null, + proxyInfo: Prefs.instance.useTor + ? TorService.sharedInstance.getProxyInfo() + : null, ); if (res.code != 200) { throw Exception('getQuote exception: statusCode= ${res.code}'); @@ -238,10 +251,11 @@ class SimplexAPI { // final Map lol = // Map.from(jsonArray as Map); - double? cryptoAmount = jsonArray['digital_money']?['amount'] as double?; + final double? cryptoAmount = + jsonArray['digital_money']?['amount'] as double?; if (cryptoAmount == null) { - String error = jsonArray['error'] as String; + final String error = jsonArray['error'] as String; return BuyResponse( exception: BuyException( error, @@ -250,7 +264,7 @@ class SimplexAPI { ); } - SimplexQuote quote = jsonArray['quote'] as SimplexQuote; + final SimplexQuote quote = jsonArray['quote'] as SimplexQuote; final SimplexQuote _quote = SimplexQuote( crypto: quote.crypto, fiat: quote.fiat, @@ -287,13 +301,13 @@ class SimplexAPI { // -d '{"account_details": {"app_provider_id": "$publicKey", "app_version_id": "123", "app_end_user_id": "01e7a0b9-8dfc-4988-a28d-84a34e5f0a63", "signup_login": {"timestamp": "1994-11-05T08:15:30-05:00", "ip": "207.66.86.226"}}, "transaction_details": {"payment_details": {"quote_id": "3b58f4b4-ed6f-447c-b96a-ffe97d7b6803", "payment_id": "baaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", "order_id": "789", "original_http_ref_url": "https://stackwallet.com/simplex", "destination_wallet": {"currency": "BTC", "address": "bc1qjvj9ca8gdsv3g58yrzrk6jycvgnjh9uj35rja2"}}}}' try { await _prefs.init(); - String? userID = _prefs.userID; - int? signupEpoch = _prefs.signupEpoch; + final String? userID = _prefs.userID; + final int? signupEpoch = _prefs.signupEpoch; - Map headers = { + final Map headers = { 'Content-Type': 'application/x-www-form-urlencoded', }; - Map data = { + final Map data = { 'ROUTE': 'order', 'QUOTE_ID': quote.id, 'ADDRESS': quote.receivingAddress, @@ -303,17 +317,19 @@ class SimplexAPI { data['USER_ID'] = userID; } if (signupEpoch != null && signupEpoch != 0) { - DateTime date = DateTime.fromMillisecondsSinceEpoch(signupEpoch * 1000); + final DateTime date = + DateTime.fromMillisecondsSinceEpoch(signupEpoch * 1000); data['SIGNUP_TIMESTAMP'] = date.toIso8601String() + timeZoneFormatter(date.timeZoneOffset); } - Uri url = _buildUri('api.php', data); + final Uri url = _buildUri('api.php', data); - var res = await client.get( + final res = await client.get( url: url, headers: headers, - proxyInfo: - Prefs.instance.useTor ? TorService.sharedInstance.getProxyInfo() : null, + proxyInfo: Prefs.instance.useTor + ? TorService.sharedInstance.getProxyInfo() + : null, ); if (res.code != 200) { throw Exception('newOrder exception: statusCode= ${res.code}'); @@ -325,7 +341,7 @@ class SimplexAPI { } } - SimplexOrder _order = SimplexOrder( + final SimplexOrder _order = SimplexOrder( quote: quote, paymentId: "${jsonArray['paymentId']}", orderId: "${jsonArray['orderId']}", @@ -346,16 +362,16 @@ class SimplexAPI { Future> redirect(SimplexOrder order) async { try { - Map headers = { + final Map headers = { 'Content-Type': 'application/x-www-form-urlencoded', }; - Map data = { + final Map data = { 'ROUTE': 'redirect', 'PAYMENT_ID': order.paymentId, }; - Uri url = _buildUri('api.php', data); + final Uri url = _buildUri('api.php', data); - bool status = await launchUrl( + final bool status = await launchUrl( url, mode: LaunchMode.externalApplication, ); @@ -364,10 +380,11 @@ class SimplexAPI { } catch (e, s) { Logging.instance.log("newOrder exception: $e\n$s", level: LogLevel.Error); return BuyResponse( - exception: BuyException( - e.toString(), - BuyExceptionType.generic, - )); + exception: BuyException( + e.toString(), + BuyExceptionType.generic, + ), + ); } } @@ -384,14 +401,3 @@ class SimplexAPI { String timeZoneFormatter(Duration offset) => "${offset.isNegative ? "-" : "+"}${offset.inHours.abs().toString().padLeft(2, "0")}:${(offset.inMinutes - offset.inHours * 60).abs().toString().padLeft(2, "0")}"; } - -bool isStackCoin(String? ticker) { - if (ticker == null) return false; - - try { - coinFromTickerCaseInsensitive(ticker); - return true; - } on ArgumentError catch (_) { - return false; - } -} diff --git a/lib/services/coins/bitcoincash/bch_utils.dart b/lib/services/coins/bitcoincash/bch_utils.dart index dfe78a2e8..43b0ac35c 100644 --- a/lib/services/coins/bitcoincash/bch_utils.dart +++ b/lib/services/coins/bitcoincash/bch_utils.dart @@ -2,7 +2,7 @@ import 'dart:typed_data'; import 'package:bitcoindart/src/utils/constants/op.dart' as op; import 'package:bitcoindart/src/utils/script.dart' as bscript; -import 'package:stackwallet/utilities/extensions/impl/string.dart'; +import '../../../utilities/extensions/impl/string.dart'; abstract final class BchUtils { static const FUSE_ID = 'FUZ\x00'; diff --git a/lib/services/coins/tezos/api/tezos_api.dart b/lib/services/coins/tezos/api/tezos_api.dart index ac8399327..bf102ef34 100644 --- a/lib/services/coins/tezos/api/tezos_api.dart +++ b/lib/services/coins/tezos/api/tezos_api.dart @@ -1,11 +1,11 @@ import 'dart:convert'; -import 'package:stackwallet/networking/http.dart'; -import 'package:stackwallet/services/coins/tezos/api/tezos_account.dart'; -import 'package:stackwallet/services/coins/tezos/api/tezos_transaction.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/prefs.dart'; +import '../../../../networking/http.dart'; +import 'tezos_account.dart'; +import 'tezos_transaction.dart'; +import '../../../tor_service.dart'; +import '../../../../utilities/logger.dart'; +import '../../../../utilities/prefs.dart'; abstract final class TezosAPI { static final HTTP _client = HTTP(); diff --git a/lib/services/coins/tezos/api/tezos_rpc_api.dart b/lib/services/coins/tezos/api/tezos_rpc_api.dart index d5faa060f..fe6f1ddea 100644 --- a/lib/services/coins/tezos/api/tezos_rpc_api.dart +++ b/lib/services/coins/tezos/api/tezos_rpc_api.dart @@ -1,9 +1,9 @@ import 'dart:convert'; -import 'package:stackwallet/networking/http.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/prefs.dart'; +import '../../../../networking/http.dart'; +import '../../../tor_service.dart'; +import '../../../../utilities/logger.dart'; +import '../../../../utilities/prefs.dart'; abstract final class TezosRpcAPI { static final HTTP _client = HTTP(); diff --git a/lib/services/debug_service.dart b/lib/services/debug_service.dart index a0d2efac1..a8d7dd963 100644 --- a/lib/services/debug_service.dart +++ b/lib/services/debug_service.dart @@ -14,8 +14,8 @@ import 'dart:io'; import 'package:event_bus/event_bus.dart'; import 'package:flutter/material.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/isar/models/log.dart'; -import 'package:stackwallet/utilities/logger.dart'; +import '../models/isar/models/log.dart'; +import '../utilities/logger.dart'; class DebugService extends ChangeNotifier { DebugService._(); diff --git a/lib/services/ethereum/cached_eth_token_balance.dart b/lib/services/ethereum/cached_eth_token_balance.dart index dbcda1131..c241f7231 100644 --- a/lib/services/ethereum/cached_eth_token_balance.dart +++ b/lib/services/ethereum/cached_eth_token_balance.dart @@ -9,13 +9,13 @@ */ import 'package:isar/isar.dart'; -import 'package:stackwallet/db/isar/main_db.dart'; -import 'package:stackwallet/models/balance.dart'; -import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart'; -import 'package:stackwallet/services/ethereum/ethereum_api.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/wallets/isar/models/token_wallet_info.dart'; +import '../../db/isar/main_db.dart'; +import '../../models/balance.dart'; +import '../../models/isar/models/ethereum/eth_contract.dart'; +import 'ethereum_api.dart'; +import '../../utilities/amount/amount.dart'; +import '../../utilities/logger.dart'; +import '../../wallets/isar/models/token_wallet_info.dart'; class CachedEthTokenBalance { final String walletId; diff --git a/lib/services/ethereum/ethereum_api.dart b/lib/services/ethereum/ethereum_api.dart index 3931b4573..d2ead5aeb 100644 --- a/lib/services/ethereum/ethereum_api.dart +++ b/lib/services/ethereum/ethereum_api.dart @@ -11,20 +11,21 @@ import 'dart:convert'; import 'package:http/http.dart'; -import 'package:stackwallet/dto/ethereum/eth_token_tx_dto.dart'; -import 'package:stackwallet/dto/ethereum/eth_token_tx_extra_dto.dart'; -import 'package:stackwallet/dto/ethereum/eth_tx_dto.dart'; -import 'package:stackwallet/dto/ethereum/pending_eth_tx_dto.dart'; -import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart'; -import 'package:stackwallet/models/paymint/fee_object_model.dart'; -import 'package:stackwallet/networking/http.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/default_nodes.dart'; -import 'package:stackwallet/utilities/eth_commons.dart'; -import 'package:stackwallet/utilities/extensions/extensions.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/prefs.dart'; +import '../../dto/ethereum/eth_token_tx_dto.dart'; +import '../../dto/ethereum/eth_token_tx_extra_dto.dart'; +import '../../dto/ethereum/eth_tx_dto.dart'; +import '../../dto/ethereum/pending_eth_tx_dto.dart'; +import '../../models/isar/models/ethereum/eth_contract.dart'; +import '../../models/paymint/fee_object_model.dart'; +import '../../networking/http.dart'; +import '../tor_service.dart'; +import '../../utilities/amount/amount.dart'; +import '../../utilities/eth_commons.dart'; +import '../../utilities/extensions/extensions.dart'; +import '../../utilities/logger.dart'; +import '../../utilities/prefs.dart'; +import '../../wallets/crypto_currency/coins/ethereum.dart'; +import '../../wallets/crypto_currency/crypto_currency.dart'; import 'package:tuple/tuple.dart'; class EthApiException implements Exception { @@ -47,7 +48,8 @@ class EthereumResponse { } abstract class EthereumAPI { - static String get stackBaseServer => DefaultNodes.ethereum.host; + static String get stackBaseServer => + Ethereum(CryptoCurrencyNetwork.main).defaultNode.host; static HTTP client = HTTP(); diff --git a/lib/services/event_bus/events/global/balance_refreshed_event.dart b/lib/services/event_bus/events/global/balance_refreshed_event.dart index 5dce5f7d5..5b7a5028a 100644 --- a/lib/services/event_bus/events/global/balance_refreshed_event.dart +++ b/lib/services/event_bus/events/global/balance_refreshed_event.dart @@ -8,7 +8,7 @@ * */ -import 'package:stackwallet/utilities/logger.dart'; +import '../../../../utilities/logger.dart'; class BalanceRefreshedEvent { final String walletId; diff --git a/lib/services/event_bus/events/global/blocks_remaining_event.dart b/lib/services/event_bus/events/global/blocks_remaining_event.dart index 14f25a058..9a9c71c81 100644 --- a/lib/services/event_bus/events/global/blocks_remaining_event.dart +++ b/lib/services/event_bus/events/global/blocks_remaining_event.dart @@ -8,7 +8,7 @@ * */ -import 'package:stackwallet/utilities/logger.dart'; +import '../../../../utilities/logger.dart'; class BlocksRemainingEvent { int blocksRemaining; diff --git a/lib/services/event_bus/events/global/node_connection_status_changed_event.dart b/lib/services/event_bus/events/global/node_connection_status_changed_event.dart index 0361f3720..7d3ca2fca 100644 --- a/lib/services/event_bus/events/global/node_connection_status_changed_event.dart +++ b/lib/services/event_bus/events/global/node_connection_status_changed_event.dart @@ -8,19 +8,20 @@ * */ -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/logger.dart'; +import '../../../../utilities/logger.dart'; +import '../../../../wallets/crypto_currency/crypto_currency.dart'; enum NodeConnectionStatus { disconnected, connected } class NodeConnectionStatusChangedEvent { NodeConnectionStatus newStatus; String walletId; - Coin coin; + CryptoCurrency coin; NodeConnectionStatusChangedEvent(this.newStatus, this.walletId, this.coin) { Logging.instance.log( - "NodeConnectionStatusChangedEvent fired in $walletId with arg newStatus = $newStatus", - level: LogLevel.Info); + "NodeConnectionStatusChangedEvent fired in $walletId with arg newStatus = $newStatus", + level: LogLevel.Info, + ); } } diff --git a/lib/services/event_bus/events/global/refresh_percent_changed_event.dart b/lib/services/event_bus/events/global/refresh_percent_changed_event.dart index abb5b75e4..bbe9027b1 100644 --- a/lib/services/event_bus/events/global/refresh_percent_changed_event.dart +++ b/lib/services/event_bus/events/global/refresh_percent_changed_event.dart @@ -8,7 +8,7 @@ * */ -import 'package:stackwallet/utilities/logger.dart'; +import '../../../../utilities/logger.dart'; class RefreshPercentChangedEvent { double percent; diff --git a/lib/services/event_bus/events/global/tor_connection_status_changed_event.dart b/lib/services/event_bus/events/global/tor_connection_status_changed_event.dart index 0a395b6a5..640bdc1fb 100644 --- a/lib/services/event_bus/events/global/tor_connection_status_changed_event.dart +++ b/lib/services/event_bus/events/global/tor_connection_status_changed_event.dart @@ -7,7 +7,7 @@ * Generated by Cypher Stack on 2023-05-26 * */ -import 'package:stackwallet/utilities/logger.dart'; +import '../../../../utilities/logger.dart'; enum TorConnectionStatus { disconnected, connecting, connected } diff --git a/lib/services/event_bus/events/global/tor_status_changed_event.dart b/lib/services/event_bus/events/global/tor_status_changed_event.dart index 6f974bf75..140e01607 100644 --- a/lib/services/event_bus/events/global/tor_status_changed_event.dart +++ b/lib/services/event_bus/events/global/tor_status_changed_event.dart @@ -8,7 +8,7 @@ * */ -import 'package:stackwallet/utilities/logger.dart'; +import '../../../../utilities/logger.dart'; enum TorStatus { enabled, disabled } diff --git a/lib/services/event_bus/events/global/updated_in_background_event.dart b/lib/services/event_bus/events/global/updated_in_background_event.dart index a7345a731..c492a837f 100644 --- a/lib/services/event_bus/events/global/updated_in_background_event.dart +++ b/lib/services/event_bus/events/global/updated_in_background_event.dart @@ -8,7 +8,7 @@ * */ -import 'package:stackwallet/utilities/logger.dart'; +import '../../../../utilities/logger.dart'; class UpdatedInBackgroundEvent { String message; diff --git a/lib/services/event_bus/events/global/wallet_sync_status_changed_event.dart b/lib/services/event_bus/events/global/wallet_sync_status_changed_event.dart index fb2a47614..0f92fb272 100644 --- a/lib/services/event_bus/events/global/wallet_sync_status_changed_event.dart +++ b/lib/services/event_bus/events/global/wallet_sync_status_changed_event.dart @@ -8,19 +8,20 @@ * */ -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/logger.dart'; +import '../../../../utilities/logger.dart'; +import '../../../../wallets/crypto_currency/crypto_currency.dart'; enum WalletSyncStatus { unableToSync, synced, syncing } class WalletSyncStatusChangedEvent { WalletSyncStatus newStatus; String walletId; - Coin coin; + CryptoCurrency coin; WalletSyncStatusChangedEvent(this.newStatus, this.walletId, this.coin) { Logging.instance.log( - "WalletSyncStatusChangedEvent fired in $walletId with arg newStatus = $newStatus", - level: LogLevel.Info); + "WalletSyncStatusChangedEvent fired in $walletId with arg newStatus = $newStatus", + level: LogLevel.Info, + ); } } diff --git a/lib/services/exchange/change_now/change_now_api.dart b/lib/services/exchange/change_now/change_now_api.dart index b847482a4..4ee3e5502 100644 --- a/lib/services/exchange/change_now/change_now_api.dart +++ b/lib/services/exchange/change_now/change_now_api.dart @@ -12,25 +12,25 @@ import 'dart:convert'; import 'package:decimal/decimal.dart'; import 'package:flutter/foundation.dart'; -import 'package:stackwallet/exceptions/exchange/exchange_exception.dart'; -import 'package:stackwallet/exceptions/exchange/pair_unavailable_exception.dart'; -import 'package:stackwallet/exceptions/exchange/unsupported_currency_exception.dart'; -import 'package:stackwallet/external_api_keys.dart'; -import 'package:stackwallet/models/exchange/change_now/cn_exchange_estimate.dart'; -import 'package:stackwallet/models/exchange/change_now/estimated_exchange_amount.dart'; -import 'package:stackwallet/models/exchange/change_now/exchange_transaction.dart'; -import 'package:stackwallet/models/exchange/change_now/exchange_transaction_status.dart'; -import 'package:stackwallet/models/exchange/response_objects/estimate.dart'; -import 'package:stackwallet/models/exchange/response_objects/fixed_rate_market.dart'; -import 'package:stackwallet/models/exchange/response_objects/range.dart'; -import 'package:stackwallet/models/isar/exchange_cache/currency.dart'; -import 'package:stackwallet/models/isar/exchange_cache/pair.dart'; -import 'package:stackwallet/networking/http.dart'; -import 'package:stackwallet/services/exchange/change_now/change_now_exchange.dart'; -import 'package:stackwallet/services/exchange/exchange_response.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/prefs.dart'; +import '../../../exceptions/exchange/exchange_exception.dart'; +import '../../../exceptions/exchange/pair_unavailable_exception.dart'; +import '../../../exceptions/exchange/unsupported_currency_exception.dart'; +import '../../../external_api_keys.dart'; +import '../../../models/exchange/change_now/cn_exchange_estimate.dart'; +import '../../../models/exchange/change_now/estimated_exchange_amount.dart'; +import '../../../models/exchange/change_now/exchange_transaction.dart'; +import '../../../models/exchange/change_now/exchange_transaction_status.dart'; +import '../../../models/exchange/response_objects/estimate.dart'; +import '../../../models/exchange/response_objects/fixed_rate_market.dart'; +import '../../../models/exchange/response_objects/range.dart'; +import '../../../models/isar/exchange_cache/currency.dart'; +import '../../../models/isar/exchange_cache/pair.dart'; +import '../../../networking/http.dart'; +import 'change_now_exchange.dart'; +import '../exchange_response.dart'; +import '../../tor_service.dart'; +import '../../../utilities/logger.dart'; +import '../../../utilities/prefs.dart'; import 'package:tuple/tuple.dart'; class ChangeNowAPI { diff --git a/lib/services/exchange/change_now/change_now_exchange.dart b/lib/services/exchange/change_now/change_now_exchange.dart index 63c99cc40..35e8e30b2 100644 --- a/lib/services/exchange/change_now/change_now_exchange.dart +++ b/lib/services/exchange/change_now/change_now_exchange.dart @@ -9,15 +9,15 @@ */ import 'package:decimal/decimal.dart'; -import 'package:stackwallet/models/exchange/change_now/exchange_transaction.dart'; -import 'package:stackwallet/models/exchange/response_objects/estimate.dart'; -import 'package:stackwallet/models/exchange/response_objects/range.dart'; -import 'package:stackwallet/models/exchange/response_objects/trade.dart'; -import 'package:stackwallet/models/isar/exchange_cache/currency.dart'; -import 'package:stackwallet/models/isar/exchange_cache/pair.dart'; -import 'package:stackwallet/services/exchange/change_now/change_now_api.dart'; -import 'package:stackwallet/services/exchange/exchange.dart'; -import 'package:stackwallet/services/exchange/exchange_response.dart'; +import '../../../models/exchange/change_now/exchange_transaction.dart'; +import '../../../models/exchange/response_objects/estimate.dart'; +import '../../../models/exchange/response_objects/range.dart'; +import '../../../models/exchange/response_objects/trade.dart'; +import '../../../models/isar/exchange_cache/currency.dart'; +import '../../../models/isar/exchange_cache/pair.dart'; +import 'change_now_api.dart'; +import '../exchange.dart'; +import '../exchange_response.dart'; import 'package:uuid/uuid.dart'; class ChangeNowExchange extends Exchange { diff --git a/lib/services/exchange/exchange.dart b/lib/services/exchange/exchange.dart index a8553854c..b5a2c4180 100644 --- a/lib/services/exchange/exchange.dart +++ b/lib/services/exchange/exchange.dart @@ -9,16 +9,16 @@ */ import 'package:decimal/decimal.dart'; -import 'package:stackwallet/models/exchange/response_objects/estimate.dart'; -import 'package:stackwallet/models/exchange/response_objects/range.dart'; -import 'package:stackwallet/models/exchange/response_objects/trade.dart'; -import 'package:stackwallet/models/isar/exchange_cache/currency.dart'; -import 'package:stackwallet/models/isar/exchange_cache/pair.dart'; -import 'package:stackwallet/services/exchange/change_now/change_now_exchange.dart'; -import 'package:stackwallet/services/exchange/exchange_response.dart'; -import 'package:stackwallet/services/exchange/majestic_bank/majestic_bank_exchange.dart'; -import 'package:stackwallet/services/exchange/simpleswap/simpleswap_exchange.dart'; -import 'package:stackwallet/services/exchange/trocador/trocador_exchange.dart'; +import '../../models/exchange/response_objects/estimate.dart'; +import '../../models/exchange/response_objects/range.dart'; +import '../../models/exchange/response_objects/trade.dart'; +import '../../models/isar/exchange_cache/currency.dart'; +import '../../models/isar/exchange_cache/pair.dart'; +import 'change_now/change_now_exchange.dart'; +import 'exchange_response.dart'; +import 'majestic_bank/majestic_bank_exchange.dart'; +import 'simpleswap/simpleswap_exchange.dart'; +import 'trocador/trocador_exchange.dart'; abstract class Exchange { static Exchange get defaultExchange => ChangeNowExchange.instance; diff --git a/lib/services/exchange/exchange_data_loading_service.dart b/lib/services/exchange/exchange_data_loading_service.dart index 47bbefe79..40d1e16bf 100644 --- a/lib/services/exchange/exchange_data_loading_service.dart +++ b/lib/services/exchange/exchange_data_loading_service.dart @@ -10,18 +10,18 @@ import 'package:flutter/foundation.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/db/hive/db.dart'; -import 'package:stackwallet/models/exchange/active_pair.dart'; -import 'package:stackwallet/models/exchange/aggregate_currency.dart'; -import 'package:stackwallet/models/isar/exchange_cache/currency.dart'; -import 'package:stackwallet/models/isar/exchange_cache/pair.dart'; -import 'package:stackwallet/services/exchange/change_now/change_now_exchange.dart'; -import 'package:stackwallet/services/exchange/majestic_bank/majestic_bank_exchange.dart'; -import 'package:stackwallet/services/exchange/trocador/trocador_exchange.dart'; -import 'package:stackwallet/utilities/enums/exchange_rate_type_enum.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/prefs.dart'; -import 'package:stackwallet/utilities/stack_file_system.dart'; +import '../../db/hive/db.dart'; +import '../../models/exchange/active_pair.dart'; +import '../../models/exchange/aggregate_currency.dart'; +import '../../models/isar/exchange_cache/currency.dart'; +import '../../models/isar/exchange_cache/pair.dart'; +import 'change_now/change_now_exchange.dart'; +import 'majestic_bank/majestic_bank_exchange.dart'; +import 'trocador/trocador_exchange.dart'; +import '../../utilities/enums/exchange_rate_type_enum.dart'; +import '../../utilities/logger.dart'; +import '../../utilities/prefs.dart'; +import '../../utilities/stack_file_system.dart'; import 'package:tuple/tuple.dart'; class ExchangeDataLoadingService { diff --git a/lib/services/exchange/exchange_response.dart b/lib/services/exchange/exchange_response.dart index eafb63453..8ffb44d4c 100644 --- a/lib/services/exchange/exchange_response.dart +++ b/lib/services/exchange/exchange_response.dart @@ -8,7 +8,7 @@ * */ -import 'package:stackwallet/exceptions/exchange/exchange_exception.dart'; +import '../../exceptions/exchange/exchange_exception.dart'; class ExchangeResponse { late final T? value; diff --git a/lib/services/exchange/majestic_bank/majestic_bank_api.dart b/lib/services/exchange/majestic_bank/majestic_bank_api.dart index 695bfeb08..c69d6ebe7 100644 --- a/lib/services/exchange/majestic_bank/majestic_bank_api.dart +++ b/lib/services/exchange/majestic_bank/majestic_bank_api.dart @@ -11,19 +11,19 @@ import 'dart:convert'; import 'package:decimal/decimal.dart'; -import 'package:stackwallet/exceptions/exchange/exchange_exception.dart'; -import 'package:stackwallet/exceptions/exchange/majestic_bank/mb_exception.dart'; -import 'package:stackwallet/exceptions/exchange/pair_unavailable_exception.dart'; -import 'package:stackwallet/models/exchange/majestic_bank/mb_limit.dart'; -import 'package:stackwallet/models/exchange/majestic_bank/mb_order.dart'; -import 'package:stackwallet/models/exchange/majestic_bank/mb_order_calculation.dart'; -import 'package:stackwallet/models/exchange/majestic_bank/mb_order_status.dart'; -import 'package:stackwallet/models/exchange/majestic_bank/mb_rate.dart'; -import 'package:stackwallet/networking/http.dart'; -import 'package:stackwallet/services/exchange/exchange_response.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/prefs.dart'; +import '../../../exceptions/exchange/exchange_exception.dart'; +import '../../../exceptions/exchange/majestic_bank/mb_exception.dart'; +import '../../../exceptions/exchange/pair_unavailable_exception.dart'; +import '../../../models/exchange/majestic_bank/mb_limit.dart'; +import '../../../models/exchange/majestic_bank/mb_order.dart'; +import '../../../models/exchange/majestic_bank/mb_order_calculation.dart'; +import '../../../models/exchange/majestic_bank/mb_order_status.dart'; +import '../../../models/exchange/majestic_bank/mb_rate.dart'; +import '../../../networking/http.dart'; +import '../exchange_response.dart'; +import '../../tor_service.dart'; +import '../../../utilities/logger.dart'; +import '../../../utilities/prefs.dart'; class MajesticBankAPI { static const String scheme = "https"; diff --git a/lib/services/exchange/majestic_bank/majestic_bank_exchange.dart b/lib/services/exchange/majestic_bank/majestic_bank_exchange.dart index 3ba914fb9..351608759 100644 --- a/lib/services/exchange/majestic_bank/majestic_bank_exchange.dart +++ b/lib/services/exchange/majestic_bank/majestic_bank_exchange.dart @@ -9,19 +9,21 @@ */ import 'package:decimal/decimal.dart'; -import 'package:stackwallet/exceptions/exchange/exchange_exception.dart'; -import 'package:stackwallet/exceptions/exchange/majestic_bank/mb_exception.dart'; -import 'package:stackwallet/models/exchange/majestic_bank/mb_order.dart'; -import 'package:stackwallet/models/exchange/response_objects/estimate.dart'; -import 'package:stackwallet/models/exchange/response_objects/range.dart'; -import 'package:stackwallet/models/exchange/response_objects/trade.dart'; -import 'package:stackwallet/models/isar/exchange_cache/currency.dart'; -import 'package:stackwallet/models/isar/exchange_cache/pair.dart'; -import 'package:stackwallet/services/exchange/exchange.dart'; -import 'package:stackwallet/services/exchange/exchange_response.dart'; -import 'package:stackwallet/services/exchange/majestic_bank/majestic_bank_api.dart'; import 'package:uuid/uuid.dart'; +import '../../../app_config.dart'; +import '../../../exceptions/exchange/exchange_exception.dart'; +import '../../../exceptions/exchange/majestic_bank/mb_exception.dart'; +import '../../../models/exchange/majestic_bank/mb_order.dart'; +import '../../../models/exchange/response_objects/estimate.dart'; +import '../../../models/exchange/response_objects/range.dart'; +import '../../../models/exchange/response_objects/trade.dart'; +import '../../../models/isar/exchange_cache/currency.dart'; +import '../../../models/isar/exchange_cache/pair.dart'; +import '../exchange.dart'; +import '../exchange_response.dart'; +import 'majestic_bank_api.dart'; + class MajesticBankExchange extends Exchange { MajesticBankExchange._(); @@ -140,7 +142,7 @@ class MajesticBankExchange extends Exchange { isFiat: false, rateType: SupportedRateType.both, isAvailable: true, - isStackCoin: Currency.checkIsStackCoin(limit.currency), + isStackCoin: AppConfig.isStackCoin(limit.currency), tokenContract: null, ); currencies.add(currency); diff --git a/lib/services/exchange/simpleswap/simpleswap_api.dart b/lib/services/exchange/simpleswap/simpleswap_api.dart index 816c57a01..509977bb1 100644 --- a/lib/services/exchange/simpleswap/simpleswap_api.dart +++ b/lib/services/exchange/simpleswap/simpleswap_api.dart @@ -12,19 +12,19 @@ import 'dart:convert'; import 'package:decimal/decimal.dart'; import 'package:flutter/foundation.dart'; -import 'package:stackwallet/exceptions/exchange/exchange_exception.dart'; -import 'package:stackwallet/external_api_keys.dart'; -import 'package:stackwallet/models/exchange/response_objects/fixed_rate_market.dart'; -import 'package:stackwallet/models/exchange/response_objects/range.dart'; -import 'package:stackwallet/models/exchange/response_objects/trade.dart'; -import 'package:stackwallet/models/exchange/simpleswap/sp_currency.dart'; -import 'package:stackwallet/models/isar/exchange_cache/pair.dart'; -import 'package:stackwallet/networking/http.dart'; -import 'package:stackwallet/services/exchange/exchange_response.dart'; -import 'package:stackwallet/services/exchange/simpleswap/simpleswap_exchange.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/prefs.dart'; +import '../../../exceptions/exchange/exchange_exception.dart'; +import '../../../external_api_keys.dart'; +import '../../../models/exchange/response_objects/fixed_rate_market.dart'; +import '../../../models/exchange/response_objects/range.dart'; +import '../../../models/exchange/response_objects/trade.dart'; +import '../../../models/exchange/simpleswap/sp_currency.dart'; +import '../../../models/isar/exchange_cache/pair.dart'; +import '../../../networking/http.dart'; +import '../exchange_response.dart'; +import 'simpleswap_exchange.dart'; +import '../../tor_service.dart'; +import '../../../utilities/logger.dart'; +import '../../../utilities/prefs.dart'; import 'package:tuple/tuple.dart'; import 'package:uuid/uuid.dart'; diff --git a/lib/services/exchange/simpleswap/simpleswap_exchange.dart b/lib/services/exchange/simpleswap/simpleswap_exchange.dart index 80ffb7601..13d8029d5 100644 --- a/lib/services/exchange/simpleswap/simpleswap_exchange.dart +++ b/lib/services/exchange/simpleswap/simpleswap_exchange.dart @@ -9,14 +9,16 @@ */ import 'package:decimal/decimal.dart'; -import 'package:stackwallet/models/exchange/response_objects/estimate.dart'; -import 'package:stackwallet/models/exchange/response_objects/range.dart'; -import 'package:stackwallet/models/exchange/response_objects/trade.dart'; -import 'package:stackwallet/models/isar/exchange_cache/currency.dart'; -import 'package:stackwallet/models/isar/exchange_cache/pair.dart'; -import 'package:stackwallet/services/exchange/exchange.dart'; -import 'package:stackwallet/services/exchange/exchange_response.dart'; -import 'package:stackwallet/services/exchange/simpleswap/simpleswap_api.dart'; + +import '../../../app_config.dart'; +import '../../../models/exchange/response_objects/estimate.dart'; +import '../../../models/exchange/response_objects/range.dart'; +import '../../../models/exchange/response_objects/trade.dart'; +import '../../../models/isar/exchange_cache/currency.dart'; +import '../../../models/isar/exchange_cache/pair.dart'; +import '../exchange.dart'; +import '../exchange_response.dart'; +import 'simpleswap_api.dart'; class SimpleSwapExchange extends Exchange { SimpleSwapExchange._(); @@ -76,7 +78,7 @@ class SimpleSwapExchange extends Exchange { ? SupportedRateType.both : SupportedRateType.estimated, isAvailable: true, - isStackCoin: Currency.checkIsStackCoin(e.symbol), + isStackCoin: AppConfig.isStackCoin(e.symbol), tokenContract: null, ), ) diff --git a/lib/services/exchange/trocador/response_objects/trocador_rate.dart b/lib/services/exchange/trocador/response_objects/trocador_rate.dart index 229487bbd..25f9413fa 100644 --- a/lib/services/exchange/trocador/response_objects/trocador_rate.dart +++ b/lib/services/exchange/trocador/response_objects/trocador_rate.dart @@ -9,7 +9,7 @@ */ import 'package:decimal/decimal.dart'; -import 'package:stackwallet/services/exchange/trocador/response_objects/trocador_quote.dart'; +import 'trocador_quote.dart'; class TrocadorRate { final String tradeId; diff --git a/lib/services/exchange/trocador/trocador_api.dart b/lib/services/exchange/trocador/trocador_api.dart index 2d780ccd0..7ef259186 100644 --- a/lib/services/exchange/trocador/trocador_api.dart +++ b/lib/services/exchange/trocador/trocador_api.dart @@ -12,16 +12,16 @@ import 'dart:convert'; import 'package:flutter/foundation.dart'; import 'package:flutter_native_splash/cli_commands.dart'; -import 'package:stackwallet/exceptions/exchange/exchange_exception.dart'; -import 'package:stackwallet/networking/http.dart'; -import 'package:stackwallet/services/exchange/exchange_response.dart'; -import 'package:stackwallet/services/exchange/trocador/response_objects/trocador_coin.dart'; -import 'package:stackwallet/services/exchange/trocador/response_objects/trocador_rate.dart'; -import 'package:stackwallet/services/exchange/trocador/response_objects/trocador_trade.dart'; -import 'package:stackwallet/services/exchange/trocador/response_objects/trocador_trade_new.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/prefs.dart'; +import '../../../exceptions/exchange/exchange_exception.dart'; +import '../../../networking/http.dart'; +import '../exchange_response.dart'; +import 'response_objects/trocador_coin.dart'; +import 'response_objects/trocador_rate.dart'; +import 'response_objects/trocador_trade.dart'; +import 'response_objects/trocador_trade_new.dart'; +import '../../tor_service.dart'; +import '../../../utilities/logger.dart'; +import '../../../utilities/prefs.dart'; const kTrocadorApiKey = "8rFqf7QLxX1mUBiNPEMaLUpV2biz6n"; const kTrocadorRefCode = "9eHm9BkQfS"; diff --git a/lib/services/exchange/trocador/trocador_exchange.dart b/lib/services/exchange/trocador/trocador_exchange.dart index d5a819b46..701bca7cb 100644 --- a/lib/services/exchange/trocador/trocador_exchange.dart +++ b/lib/services/exchange/trocador/trocador_exchange.dart @@ -11,19 +11,21 @@ import 'dart:math'; import 'package:decimal/decimal.dart'; -import 'package:stackwallet/exceptions/exchange/exchange_exception.dart'; -import 'package:stackwallet/models/exchange/response_objects/estimate.dart'; -import 'package:stackwallet/models/exchange/response_objects/range.dart'; -import 'package:stackwallet/models/exchange/response_objects/trade.dart'; -import 'package:stackwallet/models/isar/exchange_cache/currency.dart'; -import 'package:stackwallet/models/isar/exchange_cache/pair.dart'; -import 'package:stackwallet/services/exchange/exchange.dart'; -import 'package:stackwallet/services/exchange/exchange_response.dart'; -import 'package:stackwallet/services/exchange/trocador/response_objects/trocador_coin.dart'; -import 'package:stackwallet/services/exchange/trocador/response_objects/trocador_quote.dart'; -import 'package:stackwallet/services/exchange/trocador/trocador_api.dart'; import 'package:uuid/uuid.dart'; +import '../../../app_config.dart'; +import '../../../exceptions/exchange/exchange_exception.dart'; +import '../../../models/exchange/response_objects/estimate.dart'; +import '../../../models/exchange/response_objects/range.dart'; +import '../../../models/exchange/response_objects/trade.dart'; +import '../../../models/isar/exchange_cache/currency.dart'; +import '../../../models/isar/exchange_cache/pair.dart'; +import '../exchange.dart'; +import '../exchange_response.dart'; +import 'response_objects/trocador_coin.dart'; +import 'response_objects/trocador_quote.dart'; +import 'trocador_api.dart'; + class TrocadorExchange extends Exchange { TrocadorExchange._(); @@ -117,7 +119,8 @@ class TrocadorExchange extends Exchange { @override Future>> getAllCurrencies( - bool fixedRate) async { + bool fixedRate, + ) async { _cachedCurrencies ??= (await TrocadorAPI.getCoins(isOnion: false)).value; _cachedCurrencies?.removeWhere((e) => e.network != onlySupportedNetwork); @@ -132,7 +135,7 @@ class TrocadorExchange extends Exchange { image: e.image, isFiat: false, rateType: SupportedRateType.both, - isStackCoin: Currency.checkIsStackCoin(e.ticker), + isStackCoin: AppConfig.isStackCoin(e.ticker), tokenContract: null, isAvailable: true, ), @@ -267,7 +270,9 @@ class TrocadorExchange extends Exchange { @override Future>> getPairedCurrencies( - String forCurrency, bool fixedRate) async { + String forCurrency, + bool fixedRate, + ) async { // TODO: implement getPairedCurrencies throw UnimplementedError(); } diff --git a/lib/services/frost.dart b/lib/services/frost.dart index adf88695a..932ee61ed 100644 --- a/lib/services/frost.dart +++ b/lib/services/frost.dart @@ -6,11 +6,11 @@ import 'package:frostdart/frostdart.dart'; import 'package:frostdart/frostdart_bindings_generated.dart'; import 'package:frostdart/output.dart'; import 'package:frostdart/util.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/utxo.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/extensions/extensions.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; +import '../models/isar/models/blockchain_data/utxo.dart'; +import '../utilities/amount/amount.dart'; +import '../utilities/extensions/extensions.dart'; +import '../utilities/logger.dart'; +import '../wallets/crypto_currency/crypto_currency.dart'; abstract class Frost { //==================== utility =============================================== diff --git a/lib/services/fusion_tor_service.dart b/lib/services/fusion_tor_service.dart index eb8914e30..0d5b29f59 100644 --- a/lib/services/fusion_tor_service.dart +++ b/lib/services/fusion_tor_service.dart @@ -1,6 +1,6 @@ import 'dart:io'; -import 'package:stackwallet/utilities/logger.dart'; +import '../utilities/logger.dart'; import 'package:tor_ffi_plugin/tor_ffi_plugin.dart'; class FusionTorService { diff --git a/lib/services/litescribe_api.dart b/lib/services/litescribe_api.dart index 65f1783d1..a4d9a8a42 100644 --- a/lib/services/litescribe_api.dart +++ b/lib/services/litescribe_api.dart @@ -1,10 +1,10 @@ import 'dart:convert'; -import 'package:stackwallet/dto/ordinals/inscription_data.dart'; -import 'package:stackwallet/dto/ordinals/litescribe_response.dart'; -import 'package:stackwallet/networking/http.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/utilities/prefs.dart'; +import '../dto/ordinals/inscription_data.dart'; +import '../dto/ordinals/litescribe_response.dart'; +import '../networking/http.dart'; +import 'tor_service.dart'; +import '../utilities/prefs.dart'; class LitescribeAPI { static final LitescribeAPI _instance = LitescribeAPI._internal(); diff --git a/lib/services/mixins/wallet_db.dart b/lib/services/mixins/wallet_db.dart index 3c17bf3e9..34aa99ceb 100644 --- a/lib/services/mixins/wallet_db.dart +++ b/lib/services/mixins/wallet_db.dart @@ -8,7 +8,7 @@ * */ -import 'package:stackwallet/db/isar/main_db.dart'; +import '../../db/isar/main_db.dart'; @Deprecated("Legacy support") mixin WalletDB { diff --git a/lib/services/monkey_service.dart b/lib/services/monkey_service.dart index f6f804cb3..f921135c1 100644 --- a/lib/services/monkey_service.dart +++ b/lib/services/monkey_service.dart @@ -1,10 +1,10 @@ import 'dart:typed_data'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/networking/http.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/prefs.dart'; +import '../networking/http.dart'; +import 'tor_service.dart'; +import '../utilities/logger.dart'; +import '../utilities/prefs.dart'; final pMonKeyService = Provider((ref) => MonKeyService()); diff --git a/lib/services/nano_api.dart b/lib/services/nano_api.dart index e9035c8e9..c364f1f4a 100644 --- a/lib/services/nano_api.dart +++ b/lib/services/nano_api.dart @@ -1,9 +1,9 @@ import 'dart:convert'; import 'package:nanodart/nanodart.dart'; -import 'package:stackwallet/networking/http.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/utilities/prefs.dart'; +import '../networking/http.dart'; +import 'tor_service.dart'; +import '../utilities/prefs.dart'; class NanoAPI { static Future< diff --git a/lib/services/node_service.dart b/lib/services/node_service.dart index 88d032940..f2e640a67 100644 --- a/lib/services/node_service.dart +++ b/lib/services/node_service.dart @@ -12,12 +12,13 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:http/http.dart'; -import 'package:stackwallet/db/hive/db.dart'; -import 'package:stackwallet/models/node_model.dart'; -import 'package:stackwallet/utilities/default_nodes.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; -import 'package:stackwallet/utilities/logger.dart'; +import '../app_config.dart'; +import '../db/hive/db.dart'; +import '../models/node_model.dart'; +import '../utilities/default_nodes.dart'; +import '../utilities/flutter_secure_storage_interface.dart'; +import '../utilities/logger.dart'; +import '../wallets/crypto_currency/crypto_currency.dart'; const kStackCommunityNodesEndpoint = "https://extras.stackwallet.com"; @@ -30,12 +31,18 @@ class NodeService extends ChangeNotifier { }); Future updateDefaults() async { - for (final defaultNode in DefaultNodes.all) { + for (final defaultNode in AppConfig.coins.map( + (e) => e.defaultNode, + )) { final savedNode = DB.instance .get(boxName: DB.boxNameNodeModels, key: defaultNode.id); if (savedNode == null) { // save the default node to hive only if no other nodes for the specific coin exist - if (getNodesFor(coinFromPrettyName(defaultNode.coinName)).isEmpty) { + if (getNodesFor( + AppConfig.getCryptoCurrencyByPrettyName( + defaultNode.coinName, + ), + ).isEmpty) { await DB.instance.put( boxName: DB.boxNameNodeModels, key: defaultNode.id, @@ -45,19 +52,21 @@ class NodeService extends ChangeNotifier { } else { // update all fields but copy over previously set enabled and trusted states await DB.instance.put( - boxName: DB.boxNameNodeModels, - key: savedNode.id, - value: defaultNode.copyWith( - enabled: savedNode.enabled, - isFailover: savedNode.isFailover, - trusted: savedNode.trusted, - )); + boxName: DB.boxNameNodeModels, + key: savedNode.id, + value: defaultNode.copyWith( + enabled: savedNode.enabled, + isFailover: savedNode.isFailover, + trusted: savedNode.trusted, + ), + ); } // check if a default node is the primary node for the crypto currency // and update it if needed - final coin = coinFromPrettyName(defaultNode.coinName); - final primaryNode = getPrimaryNodeFor(coin: coin); + final coin = + AppConfig.getCryptoCurrencyByPrettyName(defaultNode.coinName); + final primaryNode = getPrimaryNodeFor(currency: coin); if (primaryNode != null && primaryNode.id == defaultNode.id) { await setPrimaryNodeFor( coin: coin, @@ -72,20 +81,25 @@ class NodeService extends ChangeNotifier { } Future setPrimaryNodeFor({ - required Coin coin, + required CryptoCurrency coin, required NodeModel node, bool shouldNotifyListeners = false, }) async { await DB.instance.put( - boxName: DB.boxNamePrimaryNodes, key: coin.name, value: node); + boxName: DB.boxNamePrimaryNodes, + key: coin.identifier, + value: node, + ); if (shouldNotifyListeners) { notifyListeners(); } } - NodeModel? getPrimaryNodeFor({required Coin coin}) { - return DB.instance - .get(boxName: DB.boxNamePrimaryNodes, key: coin.name); + NodeModel? getPrimaryNodeFor({required CryptoCurrency currency}) { + return DB.instance.get( + boxName: DB.boxNamePrimaryNodes, + key: currency.identifier, + ); } List get primaryNodes { @@ -96,21 +110,27 @@ class NodeService extends ChangeNotifier { return DB.instance.values(boxName: DB.boxNameNodeModels); } - List getNodesFor(Coin coin) { + List getNodesFor(CryptoCurrency coin) { final list = DB.instance .values(boxName: DB.boxNameNodeModels) - .where((e) => - e.coinName == coin.name && - !e.id.startsWith(DefaultNodes.defaultNodeIdPrefix)) + .where( + (e) => + e.coinName == coin.identifier && + !e.id.startsWith(DefaultNodes.defaultNodeIdPrefix), + ) .toList(); // add default to end of list - list.addAll(DB.instance - .values(boxName: DB.boxNameNodeModels) - .where((e) => - e.coinName == coin.name && - e.id.startsWith(DefaultNodes.defaultNodeIdPrefix)) - .toList()); + list.addAll( + DB.instance + .values(boxName: DB.boxNameNodeModels) + .where( + (e) => + e.coinName == coin.identifier && + e.id.startsWith(DefaultNodes.defaultNodeIdPrefix), + ) + .toList(), + ); // return reversed list so default node appears at beginning return list.reversed.toList(); @@ -120,8 +140,10 @@ class NodeService extends ChangeNotifier { return DB.instance.get(boxName: DB.boxNameNodeModels, key: id); } - List failoverNodesFor({required Coin coin}) { - return getNodesFor(coin).where((e) => e.isFailover && !e.isDown).toList(); + List failoverNodesFor({required CryptoCurrency currency}) { + return getNodesFor(currency) + .where((e) => e.isFailover && !e.isDown) + .toList(); } // should probably just combine this and edit into a save() func at some point @@ -133,11 +155,16 @@ class NodeService extends ChangeNotifier { bool shouldNotifyListeners, ) async { await DB.instance.put( - boxName: DB.boxNameNodeModels, key: node.id, value: node); + boxName: DB.boxNameNodeModels, + key: node.id, + value: node, + ); if (password != null) { await secureStorageInterface.write( - key: "${node.id}_nodePW", value: password); + key: "${node.id}_nodePW", + value: password, + ); } if (shouldNotifyListeners) { notifyListeners(); @@ -163,9 +190,10 @@ class NodeService extends ChangeNotifier { key: id, )!; await DB.instance.put( - boxName: DB.boxNameNodeModels, - key: model.id, - value: model.copyWith(enabled: enabled)); + boxName: DB.boxNameNodeModels, + key: model.id, + value: model.copyWith(enabled: enabled), + ); if (shouldNotifyListeners) { notifyListeners(); } @@ -178,8 +206,8 @@ class NodeService extends ChangeNotifier { bool shouldNotifyListeners, ) async { // check if the node being edited is the primary one; if it is, setPrimaryNodeFor coin - final coin = coinFromPrettyName(editedNode.coinName); - var primaryNode = getPrimaryNodeFor(coin: coin); + final coin = AppConfig.getCryptoCurrencyByPrettyName(editedNode.coinName); + final primaryNode = getPrimaryNodeFor(currency: coin); if (primaryNode?.id == editedNode.id) { await setPrimaryNodeFor( coin: coin, @@ -211,9 +239,10 @@ class NodeService extends ChangeNotifier { final map = jsonDecode(result as String); Logging.instance.log(map, level: LogLevel.Info); - for (final coin in Coin.values) { + for (final coin in AppConfig.coins) { final nodeList = List>.from( - map["nodes"][coin.name] as List? ?? []); + map["nodes"][coin.identifier] as List? ?? [], + ); for (final nodeMap in nodeList) { NodeModel node = NodeModel( host: nodeMap["host"] as String, @@ -222,7 +251,7 @@ class NodeService extends ChangeNotifier { id: nodeMap["id"] as String, useSSL: nodeMap["useSSL"] == "true", enabled: true, - coinName: coin.name, + coinName: coin.identifier, isFailover: true, isDown: nodeMap["isDown"] == "true", ); diff --git a/lib/services/notifications_api.dart b/lib/services/notifications_api.dart index 010e3c220..f614952fc 100644 --- a/lib/services/notifications_api.dart +++ b/lib/services/notifications_api.dart @@ -9,9 +9,9 @@ */ import 'package:flutter_local_notifications/flutter_local_notifications.dart'; -import 'package:stackwallet/models/notification_model.dart'; -import 'package:stackwallet/services/notifications_service.dart'; -import 'package:stackwallet/utilities/prefs.dart'; +import '../models/notification_model.dart'; +import 'notifications_service.dart'; +import '../utilities/prefs.dart'; class NotificationApi { static final _notifications = FlutterLocalNotificationsPlugin(); diff --git a/lib/services/notifications_service.dart b/lib/services/notifications_service.dart index 182de8747..5df8cad4d 100644 --- a/lib/services/notifications_service.dart +++ b/lib/services/notifications_service.dart @@ -11,20 +11,21 @@ import 'dart:async'; import 'package:flutter/foundation.dart'; -import 'package:stackwallet/db/hive/db.dart'; -import 'package:stackwallet/electrumx_rpc/electrumx_client.dart'; -import 'package:stackwallet/exceptions/electrumx/no_such_transaction.dart'; -import 'package:stackwallet/models/exchange/response_objects/trade.dart'; -import 'package:stackwallet/models/notification_model.dart'; -import 'package:stackwallet/services/exchange/exchange_response.dart'; -import 'package:stackwallet/services/node_service.dart'; -import 'package:stackwallet/services/notifications_api.dart'; -import 'package:stackwallet/services/trade_service.dart'; -import 'package:stackwallet/services/wallets.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/prefs.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart'; +import '../app_config.dart'; +import '../db/hive/db.dart'; +import '../electrumx_rpc/electrumx_client.dart'; +import '../exceptions/electrumx/no_such_transaction.dart'; +import '../models/exchange/response_objects/trade.dart'; +import '../models/notification_model.dart'; +import 'exchange/exchange_response.dart'; +import 'node_service.dart'; +import 'notifications_api.dart'; +import 'trade_service.dart'; +import 'wallets.dart'; +import '../utilities/logger.dart'; +import '../utilities/prefs.dart'; +import '../wallets/crypto_currency/crypto_currency.dart'; +import '../wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart'; import 'exchange/exchange.dart'; @@ -55,15 +56,19 @@ class NotificationsService extends ChangeNotifier { Future _addWatchedTxNotification(NotificationModel notification) async { await DB.instance.put( - boxName: DB.boxNameWatchedTransactions, - key: notification.id, - value: notification); + boxName: DB.boxNameWatchedTransactions, + key: notification.id, + value: notification, + ); } Future _deleteWatchedTxNotification( - NotificationModel notification) async { + NotificationModel notification, + ) async { await DB.instance.delete( - boxName: DB.boxNameWatchedTransactions, key: notification.id); + boxName: DB.boxNameWatchedTransactions, + key: notification.id, + ); } // watched trades @@ -73,17 +78,22 @@ class NotificationsService extends ChangeNotifier { } Future _addWatchedTradeNotification( - NotificationModel notification) async { + NotificationModel notification, + ) async { await DB.instance.put( - boxName: DB.boxNameWatchedTrades, - key: notification.id, - value: notification); + boxName: DB.boxNameWatchedTrades, + key: notification.id, + value: notification, + ); } Future _deleteWatchedTradeNotification( - NotificationModel notification) async { + NotificationModel notification, + ) async { await DB.instance.delete( - boxName: DB.boxNameWatchedTrades, key: notification.id); + boxName: DB.boxNameWatchedTrades, + key: notification.id, + ); } static Timer? _timer; @@ -118,11 +128,12 @@ class NotificationsService extends ChangeNotifier { void _checkTransactions() async { for (final notification in _watchedTransactionNotifications) { try { - final Coin coin = coinFromPrettyName(notification.coinName); + final CryptoCurrency coin = + AppConfig.getCryptoCurrencyByPrettyName(notification.coinName); final txid = notification.txid!; final wallet = Wallets.sharedInstance.getWallet(notification.walletId); - final node = nodeService.getPrimaryNodeFor(coin: coin); + final node = nodeService.getPrimaryNodeFor(currency: coin); if (node != null) { if (wallet is ElectrumXInterface) { final eNode = ElectrumXNode( @@ -133,14 +144,16 @@ class NotificationsService extends ChangeNotifier { useSSL: node.useSSL, ); final failovers = nodeService - .failoverNodesFor(coin: coin) - .map((e) => ElectrumXNode( - address: e.host, - port: e.port, - name: e.name, - id: e.id, - useSSL: e.useSSL, - )) + .failoverNodesFor(currency: coin) + .map( + (e) => ElectrumXNode( + address: e.host, + port: e.port, + name: e.name, + id: e.id, + useSSL: e.useSSL, + ), + ) .toList(); final client = ElectrumXClient.from( @@ -280,7 +293,8 @@ class NotificationsService extends ChangeNotifier { return DB.instance .values(boxName: DB.boxNameNotifications) .where( - (element) => element.read == false && element.walletId == walletId) + (element) => element.read == false && element.walletId == walletId, + ) .isNotEmpty; } @@ -320,7 +334,9 @@ class NotificationsService extends ChangeNotifier { bool shouldNotifyListeners, ) async { await DB.instance.delete( - boxName: DB.boxNameNotifications, key: notification.id); + boxName: DB.boxNameNotifications, + key: notification.id, + ); await _deleteWatchedTradeNotification(notification); await _deleteWatchedTxNotification(notification); diff --git a/lib/services/price.dart b/lib/services/price.dart index 281372dcd..83470c125 100644 --- a/lib/services/price.dart +++ b/lib/services/price.dart @@ -13,15 +13,40 @@ import 'dart:convert'; import 'package:decimal/decimal.dart'; import 'package:flutter/foundation.dart'; -import 'package:stackwallet/db/hive/db.dart'; -import 'package:stackwallet/networking/http.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/prefs.dart'; import 'package:tuple/tuple.dart'; +import '../app_config.dart'; +import '../db/hive/db.dart'; +import '../networking/http.dart'; +import '../utilities/logger.dart'; +import '../utilities/prefs.dart'; +import '../wallets/crypto_currency/crypto_currency.dart'; +import 'tor_service.dart'; + class PriceAPI { + // coingecko coin ids + static const Map _coinToIdMap = { + Bitcoin: "bitcoin", + BitcoinFrost: "bitcoin", + Litecoin: "litecoin", + Bitcoincash: "bitcoin-cash", + Dogecoin: "dogecoin", + Epiccash: "epic-cash", + Ecash: "ecash", + Ethereum: "ethereum", + Firo: "zcoin", + Monero: "monero", + Particl: "particl", + Peercoin: "peercoin", + Solana: "solana", + Stellar: "stellar", + Tezos: "tezos", + Wownero: "wownero", + Namecoin: "namecoin", + Nano: "nano", + Banano: "banano", + }; + static const refreshInterval = 60; // initialize to older than current time minus at least refreshInterval @@ -43,10 +68,11 @@ class PriceAPI { } Future _updateCachedPrices( - Map> data) async { + Map> data, + ) async { final Map map = {}; - for (final coin in Coin.values) { + for (final coin in AppConfig.coins) { final entry = data[coin]; if (entry == null) { map[coin.prettyName] = ["0", 0.0]; @@ -59,26 +85,37 @@ class PriceAPI { .put(boxName: DB.boxNamePriceCache, key: 'cache', value: map); } - Map> get _cachedPrices { + Map> get _cachedPrices { final map = DB.instance.get(boxName: DB.boxNamePriceCache, key: 'cache') as Map? ?? {}; // init with 0 final result = { - for (final coin in Coin.values) coin: Tuple2(Decimal.zero, 0.0) + for (final coin in AppConfig.coins) coin: Tuple2(Decimal.zero, 0.0), }; for (final entry in map.entries) { - result[coinFromPrettyName(entry.key as String)] = Tuple2( - Decimal.parse(entry.value[0] as String), entry.value[1] as double); + result[AppConfig.getCryptoCurrencyByPrettyName( + entry.key as String, + )] = Tuple2( + Decimal.parse(entry.value[0] as String), + entry.value[1] as double, + ); } return result; } - Future>> getPricesAnd24hChange( - {required String baseCurrency}) async { + String get _coinIds => AppConfig.coins + .where((e) => e.network == CryptoCurrencyNetwork.main) + .map((e) => _coinToIdMap[e.runtimeType]) + .where((e) => e != null) + .join(","); + + Future>> getPricesAnd24hChange({ + required String baseCurrency, + }) async { final now = DateTime.now(); if (_lastUsedBaseCurrency != baseCurrency || now.difference(_lastCalled) > refreshIntervalDuration) { @@ -91,18 +128,19 @@ class PriceAPI { final externalCalls = Prefs.instance.externalCalls; if ((!Logger.isTestEnv && !externalCalls) || !(await Prefs.instance.isExternalCallsSet())) { - Logging.instance.log("User does not want to use external calls", - level: LogLevel.Info); + Logging.instance.log( + "User does not want to use external calls", + level: LogLevel.Info, + ); return _cachedPrices; } - Map> result = {}; + final Map> result = {}; try { final uri = Uri.parse( - "https://api.coingecko.com/api/v3/coins/markets?vs_currency" - "=${baseCurrency.toLowerCase()}" - "&ids=monero,bitcoin,litecoin,ecash,epic-cash,zcoin,dogecoin," - "bitcoin-cash,namecoin,wownero,ethereum,particl,nano,banano,stellar,tezos,solana" - "&order=market_cap_desc&per_page=50&page=1&sparkline=false"); + "https://api.coingecko.com/api/v3/coins/markets?vs_currency" + "=${baseCurrency.toLowerCase()}&ids=$_coinIds&order=market_cap_desc" + "&per_page=50&page=1&sparkline=false", + ); final coinGeckoResponse = await client.get( url: uri, @@ -116,7 +154,7 @@ class PriceAPI { for (final map in coinGeckoData) { final String coinName = map["name"] as String; - final coin = coinFromPrettyName(coinName); + final coin = AppConfig.getCryptoCurrencyByPrettyName(coinName); final price = Decimal.parse(map["current_price"].toString()); final change24h = map["price_change_percentage_24h"] != null @@ -131,8 +169,10 @@ class PriceAPI { return _cachedPrices; } catch (e, s) { - Logging.instance.log("getPricesAnd24hChange($baseCurrency): $e\n$s", - level: LogLevel.Error); + Logging.instance.log( + "getPricesAnd24hChange($baseCurrency): $e\n$s", + level: LogLevel.Error, + ); // return previous cached values return _cachedPrices; } @@ -140,12 +180,14 @@ class PriceAPI { static Future?> availableBaseCurrencies() async { final externalCalls = Prefs.instance.externalCalls; - HTTP client = HTTP(); + final HTTP client = HTTP(); if ((!Logger.isTestEnv && !externalCalls) || !(await Prefs.instance.isExternalCallsSet())) { - Logging.instance.log("User does not want to use external calls", - level: LogLevel.Info); + Logging.instance.log( + "User does not want to use external calls", + level: LogLevel.Info, + ); return null; } const uriString = @@ -163,8 +205,10 @@ class PriceAPI { final json = jsonDecode(response.body) as List; return List.from(json); } catch (e, s) { - Logging.instance.log("availableBaseCurrencies() using $uriString: $e\n$s", - level: LogLevel.Error); + Logging.instance.log( + "availableBaseCurrencies() using $uriString: $e\n$s", + level: LogLevel.Error, + ); return null; } } @@ -176,13 +220,16 @@ class PriceAPI { }) async { final Map> tokenPrices = {}; - if (contractAddresses.isEmpty) return tokenPrices; + if (AppConfig.coins.whereType().isEmpty || + contractAddresses.isEmpty) return tokenPrices; final externalCalls = Prefs.instance.externalCalls; if ((!Logger.isTestEnv && !externalCalls) || !(await Prefs.instance.isExternalCallsSet())) { - Logging.instance.log("User does not want to use external calls", - level: LogLevel.Info); + Logging.instance.log( + "User does not want to use external calls", + level: LogLevel.Info, + ); return tokenPrices; } diff --git a/lib/services/price_service.dart b/lib/services/price_service.dart index 561aa184c..fb30c8477 100644 --- a/lib/services/price_service.dart +++ b/lib/services/price_service.dart @@ -13,11 +13,12 @@ import 'dart:async'; import 'package:decimal/decimal.dart'; import 'package:flutter/foundation.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/db/isar/main_db.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/networking/http.dart'; -import 'package:stackwallet/services/price.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import '../db/isar/main_db.dart'; +import '../models/isar/models/isar_models.dart'; +import '../networking/http.dart'; +import 'price.dart'; +import '../app_config.dart'; +import '../wallets/crypto_currency/crypto_currency.dart'; import 'package:tuple/tuple.dart'; class PriceService extends ChangeNotifier { @@ -28,15 +29,15 @@ class PriceService extends ChangeNotifier { final Duration updateInterval = const Duration(seconds: 60); Timer? _timer; - final Map> _cachedPrices = { - for (final coin in Coin.values) coin: Tuple2(Decimal.zero, 0.0) + final Map> _cachedPrices = { + for (final coin in AppConfig.coins) coin: Tuple2(Decimal.zero, 0.0), }; final Map> _cachedTokenPrices = {}; final _priceAPI = PriceAPI(HTTP()); - Tuple2 getPrice(Coin coin) => _cachedPrices[coin]!; + Tuple2 getPrice(CryptoCurrency coin) => _cachedPrices[coin]!; Tuple2 getTokenPrice(String contractAddress) => _cachedTokenPrices[contractAddress.toLowerCase()] ?? diff --git a/lib/services/tor_service.dart b/lib/services/tor_service.dart index 3458f1612..8c4ce5e6d 100644 --- a/lib/services/tor_service.dart +++ b/lib/services/tor_service.dart @@ -1,9 +1,9 @@ import 'dart:io'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/services/event_bus/events/global/tor_connection_status_changed_event.dart'; -import 'package:stackwallet/services/event_bus/global_event_bus.dart'; -import 'package:stackwallet/utilities/logger.dart'; +import 'event_bus/events/global/tor_connection_status_changed_event.dart'; +import 'event_bus/global_event_bus.dart'; +import '../utilities/logger.dart'; import 'package:tor_ffi_plugin/tor_ffi_plugin.dart'; final pTorService = Provider((_) => TorService.sharedInstance); diff --git a/lib/services/trade_notes_service.dart b/lib/services/trade_notes_service.dart index 7d92d4a2b..c29009a3c 100644 --- a/lib/services/trade_notes_service.dart +++ b/lib/services/trade_notes_service.dart @@ -9,7 +9,7 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/db/hive/db.dart'; +import '../db/hive/db.dart'; class TradeNotesService extends ChangeNotifier { Map get all { diff --git a/lib/services/trade_sent_from_stack_service.dart b/lib/services/trade_sent_from_stack_service.dart index 7f5140abe..84832a345 100644 --- a/lib/services/trade_sent_from_stack_service.dart +++ b/lib/services/trade_sent_from_stack_service.dart @@ -9,8 +9,8 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/db/hive/db.dart'; -import 'package:stackwallet/models/trade_wallet_lookup.dart'; +import '../db/hive/db.dart'; +import '../models/trade_wallet_lookup.dart'; class TradeSentFromStackService extends ChangeNotifier { List get all => diff --git a/lib/services/trade_service.dart b/lib/services/trade_service.dart index c960c9f2a..7fd3dcf05 100644 --- a/lib/services/trade_service.dart +++ b/lib/services/trade_service.dart @@ -9,8 +9,8 @@ */ import 'package:flutter/cupertino.dart'; -import 'package:stackwallet/db/hive/db.dart'; -import 'package:stackwallet/models/exchange/response_objects/trade.dart'; +import '../db/hive/db.dart'; +import '../models/exchange/response_objects/trade.dart'; class TradesService extends ChangeNotifier { List get trades { diff --git a/lib/services/transaction_notification_tracker.dart b/lib/services/transaction_notification_tracker.dart index 440246d0a..328ca8753 100644 --- a/lib/services/transaction_notification_tracker.dart +++ b/lib/services/transaction_notification_tracker.dart @@ -8,7 +8,7 @@ * */ -import 'package:stackwallet/db/hive/db.dart'; +import '../db/hive/db.dart'; class TransactionNotificationTracker { final String walletId; diff --git a/lib/services/wallets.dart b/lib/services/wallets.dart index bba7bfe90..43f0af396 100644 --- a/lib/services/wallets.dart +++ b/lib/services/wallets.dart @@ -10,23 +10,24 @@ import 'dart:async'; -import 'package:flutter_libmonero/monero/monero.dart'; -import 'package:flutter_libmonero/wownero/wownero.dart'; +import 'package:flutter_libmonero/monero/monero.dart' as monero; +import 'package:flutter_libmonero/wownero/wownero.dart' as wownero; import 'package:isar/isar.dart'; -import 'package:stackwallet/db/hive/db.dart'; -import 'package:stackwallet/db/isar/main_db.dart'; -import 'package:stackwallet/services/node_service.dart'; -import 'package:stackwallet/services/notifications_service.dart'; -import 'package:stackwallet/services/trade_sent_from_stack_service.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/sync_type_enum.dart'; -import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/prefs.dart'; -import 'package:stackwallet/wallets/isar/models/wallet_info.dart'; -import 'package:stackwallet/wallets/wallet/impl/epiccash_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/cw_based_interface.dart'; +import '../db/hive/db.dart'; +import '../db/isar/main_db.dart'; +import 'node_service.dart'; +import 'notifications_service.dart'; +import 'trade_sent_from_stack_service.dart'; +import '../app_config.dart'; +import '../utilities/enums/sync_type_enum.dart'; +import '../utilities/flutter_secure_storage_interface.dart'; +import '../utilities/logger.dart'; +import '../utilities/prefs.dart'; +import '../wallets/crypto_currency/crypto_currency.dart'; +import '../wallets/isar/models/wallet_info.dart'; +import '../wallets/wallet/impl/epiccash_wallet.dart'; +import '../wallets/wallet/wallet.dart'; +import '../wallets/wallet/wallet_mixin_interfaces/cw_based_interface.dart'; class Wallets { Wallets._private(); @@ -76,27 +77,31 @@ class Wallets { await secureStorage.delete(key: Wallet.mnemonicKey(walletId: walletId)); await secureStorage.delete( - key: Wallet.mnemonicPassphraseKey(walletId: walletId)); + key: Wallet.mnemonicPassphraseKey(walletId: walletId), + ); await secureStorage.delete(key: Wallet.privateKeyKey(walletId: walletId)); - if (info.coin == Coin.wownero) { - final wowService = - wownero.createWowneroWalletService(DB.instance.moneroWalletInfoBox); + if (info.coin is Wownero) { + final wowService = wownero.wownero + .createWowneroWalletService(DB.instance.moneroWalletInfoBox); await wowService.remove(walletId); Logging.instance .log("monero wallet: $walletId deleted", level: LogLevel.Info); - } else if (info.coin == Coin.monero) { - final xmrService = - monero.createMoneroWalletService(DB.instance.moneroWalletInfoBox); + } else if (info.coin is Monero) { + final xmrService = monero.monero + .createMoneroWalletService(DB.instance.moneroWalletInfoBox); await xmrService.remove(walletId); Logging.instance .log("monero wallet: $walletId deleted", level: LogLevel.Info); - } else if (info.coin == Coin.epicCash) { + } else if (info.coin is Epiccash) { final deleteResult = await deleteEpicWallet( - walletId: walletId, secureStore: secureStorage); + walletId: walletId, + secureStore: secureStorage, + ); Logging.instance.log( - "epic wallet: $walletId deleted with result: $deleteResult", - level: LogLevel.Info); + "epic wallet: $walletId deleted with result: $deleteResult", + level: LogLevel.Info, + ); } // delete wallet data in main db @@ -108,7 +113,9 @@ class Wallets { // when delete was requested so instead of deleting now we mark the wallet // as needs delete by adding it's id to a list which gets checked on app start await DB.instance.add( - boxName: DB.boxNameWalletsToDeleteOnStart, value: walletId); + boxName: DB.boxNameWalletsToDeleteOnStart, + value: walletId, + ); final lookupService = TradeSentFromStackService(); for (final lookup in lookupService.all) { @@ -149,10 +156,12 @@ class Wallets { // clear out any wallet hive boxes where the wallet was deleted in previous app run for (final walletId in DB.instance .values(boxName: DB.boxNameWalletsToDeleteOnStart)) { - await mainDB.isar.writeTxn(() async => await mainDB.isar.walletInfo - .where() - .walletIdEqualTo(walletId) - .deleteAll()); + await mainDB.isar.writeTxn( + () async => await mainDB.isar.walletInfo + .where() + .walletIdEqualTo(walletId) + .deleteAll(), + ); } // clear list await DB.instance @@ -210,11 +219,13 @@ class Wallets { if (wallet is CwBasedInterface) { // walletsToInitLinearly.add(Tuple2(manager, shouldSetAutoSync)); } else { - walletInitFutures.add(wallet.init().then((_) { - if (shouldSetAutoSync) { - wallet.shouldAutoSync = true; - } - })); + walletInitFutures.add( + wallet.init().then((_) { + if (shouldSetAutoSync) { + wallet.shouldAutoSync = true; + } + }), + ); } _wallets[wallet.walletId] = wallet; @@ -251,10 +262,12 @@ class Wallets { // clear out any wallet hive boxes where the wallet was deleted in previous app run for (final walletId in DB.instance .values(boxName: DB.boxNameWalletsToDeleteOnStart)) { - await mainDB.isar.writeTxn(() async => await mainDB.isar.walletInfo - .where() - .walletIdEqualTo(walletId) - .deleteAll()); + await mainDB.isar.writeTxn( + () async => await mainDB.isar.walletInfo + .where() + .walletIdEqualTo(walletId) + .deleteAll(), + ); } // clear list await DB.instance @@ -346,10 +359,12 @@ class Wallets { .toList(); if (walletInitFutures.isNotEmpty && walletsToInitLinearly.isNotEmpty) { - unawaited(Future.wait([ - _initLinearly(walletsToInitLinearly), - ...walletInitFutures, - ])); + unawaited( + Future.wait([ + _initLinearly(walletsToInitLinearly), + ...walletInitFutures, + ]), + ); } else if (walletInitFutures.isNotEmpty) { unawaited(Future.wait(walletInitFutures)); } else if (walletsToInitLinearly.isNotEmpty) { @@ -370,16 +385,25 @@ class Wallets { // clear out any wallet hive boxes where the wallet was deleted in previous app run for (final walletId in DB.instance .values(boxName: DB.boxNameWalletsToDeleteOnStart)) { - await mainDB.isar.writeTxn(() async => await mainDB.isar.walletInfo - .where() - .walletIdEqualTo(walletId) - .deleteAll()); + await mainDB.isar.writeTxn( + () async => await mainDB.isar.walletInfo + .where() + .walletIdEqualTo(walletId) + .deleteAll(), + ); } // clear list await DB.instance .deleteAll(boxName: DB.boxNameWalletsToDeleteOnStart); - final walletInfoList = await mainDB.isar.walletInfo.where().findAll(); + final walletInfoList = await mainDB.isar.walletInfo + .where() + .filter() + .anyOf( + AppConfig.coins.map((e) => e.identifier), + (q, element) => q.coinNameMatches(element), + ) + .findAll(); if (walletInfoList.isEmpty) { return; } @@ -552,11 +576,13 @@ class Wallets { if (wallet is CwBasedInterface) { // walletsToInitLinearly.add(Tuple2(manager, shouldSetAutoSync)); } else { - walletInitFutures.add(wallet.init().then((_) { - // if (shouldSetAutoSync) { - // wallet.shouldAutoSync = true; - // } - })); + walletInitFutures.add( + wallet.init().then((_) { + // if (shouldSetAutoSync) { + // wallet.shouldAutoSync = true; + // } + }), + ); } } @@ -596,6 +622,7 @@ class Wallets { Future _deleteWallet(String walletId) async { // TODO proper clean up of other wallet data in addition to the following await mainDB.isar.writeTxn( - () async => await mainDB.isar.walletInfo.deleteByWalletId(walletId)); + () async => await mainDB.isar.walletInfo.deleteByWalletId(walletId), + ); } } diff --git a/lib/services/wallets_service.dart b/lib/services/wallets_service.dart index 738c9d6c6..744b327d1 100644 --- a/lib/services/wallets_service.dart +++ b/lib/services/wallets_service.dart @@ -11,19 +11,19 @@ import 'dart:convert'; import 'package:flutter/material.dart'; -import 'package:stackwallet/db/hive/db.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/logger.dart'; +import '../app_config.dart'; +import '../db/hive/db.dart'; +import '../utilities/logger.dart'; @Deprecated("Legacy support only. Do not use.") class WalletInfo { - final Coin coin; + final String coinIdentifier; final String walletId; final String name; @Deprecated("Legacy support only. Do not use.") const WalletInfo({ - required this.coin, + required this.coinIdentifier, required this.walletId, required this.name, }); @@ -31,7 +31,7 @@ class WalletInfo { @Deprecated("Legacy support only. Do not use.") factory WalletInfo.fromJson(Map jsonObject) { return WalletInfo( - coin: Coin.values.byName(jsonObject["coin"] as String), + coinIdentifier: jsonObject["coin"] as String, walletId: jsonObject["id"] as String, name: jsonObject["name"] as String, ); @@ -42,7 +42,7 @@ class WalletInfo { return { "name": name, "id": walletId, - "coin": coin.name, + "coin": coinIdentifier, }; } @@ -75,12 +75,14 @@ class WalletsService extends ChangeNotifier { .get(boxName: DB.boxNameAllWalletsData, key: 'names') as Map?; if (names == null) { Logging.instance.log( - "Fetched wallet 'names' returned null. Setting initializing 'names'", - level: LogLevel.Info); + "Fetched wallet 'names' returned null. Setting initializing 'names'", + level: LogLevel.Info, + ); await DB.instance.put( - boxName: DB.boxNameAllWalletsData, - key: 'names', - value: {}); + boxName: DB.boxNameAllWalletsData, + key: 'names', + value: {}, + ); return {}; } Logging.instance.log("Fetched wallet names: $names", level: LogLevel.Info); @@ -88,16 +90,22 @@ class WalletsService extends ChangeNotifier { mapped.removeWhere((name, dyn) { final jsonObject = Map.from(dyn as Map); try { - Coin.values.byName(jsonObject["coin"] as String); + AppConfig.getCryptoCurrencyFor(jsonObject["coin"] as String); return false; } catch (e, s) { - Logging.instance.log("Error, ${jsonObject["coin"]} does not exist", - level: LogLevel.Error); + Logging.instance.log( + "Error, ${jsonObject["coin"]} does not exist", + level: LogLevel.Error, + ); return true; } }); - return mapped.map((name, dyn) => MapEntry( - name, WalletInfo.fromJson(Map.from(dyn as Map)))); + return mapped.map( + (name, dyn) => MapEntry( + name, + WalletInfo.fromJson(Map.from(dyn as Map)), + ), + ); } } diff --git a/lib/supported_coins.dart b/lib/supported_coins.dart deleted file mode 100644 index 70ee44ad8..000000000 --- a/lib/supported_coins.dart +++ /dev/null @@ -1,90 +0,0 @@ -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/banano.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/bitcoin.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/bitcoin_frost.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/bitcoincash.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/dogecoin.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/ecash.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/epiccash.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/ethereum.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/firo.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/litecoin.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/monero.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/namecoin.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/nano.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/particl.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/peercoin.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/solana.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/stellar.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/tezos.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/wownero.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; - -/// The supported coins. Eventually move away from the Coin enum -class SupportedCoins { - /// A List of our supported coins. Piggy back on [Coin] for now - static final List cryptocurrencies = - Coin.values.map((e) => getCryptoCurrencyFor(e)).toList(growable: false); - - /// A getter function linking a [CryptoCurrency] with its associated [Coin]. - /// - /// Temporary: Remove when the Coin enum is removed. - static CryptoCurrency getCryptoCurrencyFor(Coin coin) { - switch (coin) { - case Coin.bitcoin: - return Bitcoin(CryptoCurrencyNetwork.main); - case Coin.bitcoinFrost: - return BitcoinFrost(CryptoCurrencyNetwork.main); - case Coin.litecoin: - return Litecoin(CryptoCurrencyNetwork.main); - case Coin.bitcoincash: - return Bitcoincash(CryptoCurrencyNetwork.main); - case Coin.dogecoin: - return Dogecoin(CryptoCurrencyNetwork.main); - case Coin.epicCash: - return Epiccash(CryptoCurrencyNetwork.main); - case Coin.eCash: - return Ecash(CryptoCurrencyNetwork.main); - case Coin.ethereum: - return Ethereum(CryptoCurrencyNetwork.main); - case Coin.firo: - return Firo(CryptoCurrencyNetwork.main); - case Coin.monero: - return Monero(CryptoCurrencyNetwork.main); - case Coin.particl: - return Particl(CryptoCurrencyNetwork.main); - case Coin.peercoin: - return Peercoin(CryptoCurrencyNetwork.main); - case Coin.solana: - return Solana(CryptoCurrencyNetwork.main); - case Coin.stellar: - return Stellar(CryptoCurrencyNetwork.main); - case Coin.tezos: - return Tezos(CryptoCurrencyNetwork.main); - case Coin.wownero: - return Wownero(CryptoCurrencyNetwork.main); - case Coin.namecoin: - return Namecoin(CryptoCurrencyNetwork.main); - case Coin.nano: - return Nano(CryptoCurrencyNetwork.main); - case Coin.banano: - return Banano(CryptoCurrencyNetwork.main); - case Coin.bitcoinTestNet: - return Bitcoin(CryptoCurrencyNetwork.test); - case Coin.bitcoinFrostTestNet: - return BitcoinFrost(CryptoCurrencyNetwork.test); - case Coin.litecoinTestNet: - return Litecoin(CryptoCurrencyNetwork.test); - case Coin.bitcoincashTestnet: - return Bitcoincash(CryptoCurrencyNetwork.test); - case Coin.firoTestNet: - return Firo(CryptoCurrencyNetwork.test); - case Coin.dogecoinTestNet: - return Dogecoin(CryptoCurrencyNetwork.test); - case Coin.stellarTestnet: - return Stellar(CryptoCurrencyNetwork.test); - case Coin.peercoinTestNet: - return Peercoin(CryptoCurrencyNetwork.test); - } - } -} diff --git a/lib/themes/coin_card_provider.dart b/lib/themes/coin_card_provider.dart index b34e9e6f1..bb7d11052 100644 --- a/lib/themes/coin_card_provider.dart +++ b/lib/themes/coin_card_provider.dart @@ -9,26 +9,27 @@ */ import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/isar/stack_theme.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import '../models/isar/stack_theme.dart'; +import 'theme_providers.dart'; +import '../wallets/crypto_currency/crypto_currency.dart'; -final coinCardProvider = Provider.family((ref, coin) { +final coinCardProvider = Provider.family((ref, coin) { final assets = ref.watch(themeAssetsProvider); if (assets is ThemeAssetsV3) { - return assets.coinCardImages?[coin.mainNetVersion]; + return assets.coinCardImages?[coin.mainNetId]; } else { return null; } }); -final coinCardFavoritesProvider = Provider.family((ref, coin) { +final coinCardFavoritesProvider = + Provider.family((ref, coin) { final assets = ref.watch(themeAssetsProvider); if (assets is ThemeAssetsV3) { - return assets.coinCardFavoritesImages?[coin.mainNetVersion] ?? - assets.coinCardImages?[coin.mainNetVersion]; + return assets.coinCardFavoritesImages?[coin.mainNetId] ?? + assets.coinCardImages?[coin.mainNetId]; } else { return null; } diff --git a/lib/themes/coin_icon_provider.dart b/lib/themes/coin_icon_provider.dart index 9bd3990bb..afb47672f 100644 --- a/lib/themes/coin_icon_provider.dart +++ b/lib/themes/coin_icon_provider.dart @@ -9,48 +9,54 @@ */ import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/isar/stack_theme.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import '../models/isar/stack_theme.dart'; +import 'theme_providers.dart'; +import '../wallets/crypto_currency/coins/bitcoin.dart'; +import '../wallets/crypto_currency/coins/bitcoincash.dart'; +import '../wallets/crypto_currency/coins/dogecoin.dart'; +import '../wallets/crypto_currency/coins/epiccash.dart'; +import '../wallets/crypto_currency/coins/ethereum.dart'; +import '../wallets/crypto_currency/coins/firo.dart'; +import '../wallets/crypto_currency/coins/litecoin.dart'; +import '../wallets/crypto_currency/coins/monero.dart'; +import '../wallets/crypto_currency/coins/namecoin.dart'; +import '../wallets/crypto_currency/coins/particl.dart'; +import '../wallets/crypto_currency/coins/wownero.dart'; +import '../wallets/crypto_currency/crypto_currency.dart'; -final coinIconProvider = Provider.family((ref, coin) { +final coinIconProvider = Provider.family((ref, coin) { final assets = ref.watch(themeAssetsProvider); if (assets is ThemeAssets) { - switch (coin) { - case Coin.bitcoin: - case Coin.bitcoinTestNet: + switch (coin.runtimeType) { + case const (Bitcoin): return assets.bitcoin; - case Coin.litecoin: - case Coin.litecoinTestNet: + case const (Litecoin): return assets.litecoin; - case Coin.bitcoincash: - case Coin.bitcoincashTestnet: + case const (Bitcoincash): return assets.bitcoincash; - case Coin.dogecoin: - case Coin.dogecoinTestNet: + case const (Dogecoin): return assets.dogecoin; - case Coin.epicCash: + case const (Epiccash): return assets.epicCash; - case Coin.firo: - case Coin.firoTestNet: + case const (Firo): return assets.firo; - case Coin.monero: + case const (Monero): return assets.monero; - case Coin.wownero: + case const (Wownero): return assets.wownero; - case Coin.namecoin: + case const (Namecoin): return assets.namecoin; - case Coin.particl: + case const (Particl): return assets.particl; - case Coin.ethereum: + case const (Ethereum): return assets.ethereum; default: return assets.stackIcon; } } else if (assets is ThemeAssetsV2) { - return (assets).coinIcons[coin.mainNetVersion]!; + return (assets).coinIcons[coin.mainNetId]!; } else { - return (assets as ThemeAssetsV3).coinIcons[coin.mainNetVersion]!; + return (assets as ThemeAssetsV3).coinIcons[coin.mainNetId]!; } }); diff --git a/lib/themes/coin_image_provider.dart b/lib/themes/coin_image_provider.dart index 6ca839fb9..ed162a473 100644 --- a/lib/themes/coin_image_provider.dart +++ b/lib/themes/coin_image_provider.dart @@ -9,103 +9,33 @@ */ import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/isar/stack_theme.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import '../models/isar/stack_theme.dart'; +import 'theme_providers.dart'; +import '../wallets/crypto_currency/crypto_currency.dart'; -final coinImageProvider = Provider.family((ref, coin) { +final coinImageProvider = Provider.family((ref, coin) { final assets = ref.watch(themeAssetsProvider); if (assets is ThemeAssets) { - switch (coin) { - case Coin.bitcoin: - return assets.bitcoinImage; - case Coin.litecoin: - case Coin.litecoinTestNet: - return assets.litecoinImage; - case Coin.bitcoincash: - return assets.bitcoincashImage; - case Coin.dogecoin: - return assets.dogecoinImage; - case Coin.eCash: - return assets.bitcoinImage; - case Coin.epicCash: - return assets.epicCashImage; - case Coin.firo: - return assets.firoImage; - case Coin.monero: - return assets.moneroImage; - case Coin.wownero: - return assets.wowneroImage; - case Coin.namecoin: - return assets.namecoinImage; - case Coin.particl: - return assets.particlImage; - case Coin.bitcoinTestNet: - return assets.bitcoinImage; - case Coin.bitcoincashTestnet: - return assets.bitcoincashImage; - case Coin.firoTestNet: - return assets.firoImage; - case Coin.dogecoinTestNet: - return assets.dogecoinImage; - case Coin.ethereum: - return assets.ethereumImage; - default: - return assets.stackIcon; - } + // just update your wallet or theme + return assets.stackIcon; } else if (assets is ThemeAssetsV2) { - return (assets).coinImages[coin.mainNetVersion]!; + return (assets).coinImages[coin.mainNetId]!; } else { - return (assets as ThemeAssetsV3).coinImages[coin.mainNetVersion]!; + return (assets as ThemeAssetsV3).coinImages[coin.mainNetId]!; } }); -final coinImageSecondaryProvider = Provider.family((ref, coin) { +final coinImageSecondaryProvider = + Provider.family((ref, coin) { final assets = ref.watch(themeAssetsProvider); if (assets is ThemeAssets) { - switch (coin) { - case Coin.bitcoin: - return assets.bitcoinImageSecondary; - case Coin.litecoin: - case Coin.litecoinTestNet: - return assets.litecoinImageSecondary; - case Coin.bitcoincash: - return assets.bitcoincashImageSecondary; - case Coin.dogecoin: - return assets.dogecoinImageSecondary; - case Coin.eCash: - return assets.bitcoinImageSecondary; - case Coin.epicCash: - return assets.epicCashImageSecondary; - case Coin.firo: - return assets.firoImageSecondary; - case Coin.monero: - return assets.moneroImageSecondary; - case Coin.wownero: - return assets.wowneroImageSecondary; - case Coin.namecoin: - return assets.namecoinImageSecondary; - case Coin.particl: - return assets.particlImageSecondary; - case Coin.bitcoinTestNet: - return assets.bitcoinImageSecondary; - case Coin.bitcoincashTestnet: - return assets.bitcoincashImageSecondary; - case Coin.firoTestNet: - return assets.firoImageSecondary; - case Coin.dogecoinTestNet: - return assets.dogecoinImageSecondary; - case Coin.ethereum: - return assets.ethereumImageSecondary; - - default: - return assets.stackIcon; - } + // just update your wallet or theme + return assets.stackIcon; } else if (assets is ThemeAssetsV2) { - return (assets).coinSecondaryImages[coin.mainNetVersion]!; + return (assets).coinSecondaryImages[coin.mainNetId]!; } else { - return (assets as ThemeAssetsV3).coinSecondaryImages[coin.mainNetVersion]!; + return (assets as ThemeAssetsV3).coinSecondaryImages[coin.mainNetId]!; } }); diff --git a/lib/themes/color_theme.dart b/lib/themes/color_theme.dart deleted file mode 100644 index e4dbcabc3..000000000 --- a/lib/themes/color_theme.dart +++ /dev/null @@ -1,88 +0,0 @@ -/* - * This file is part of Stack Wallet. - * - * Copyright (c) 2023 Cypher Stack - * All Rights Reserved. - * The code is distributed under GPLv3 license, see LICENSE file for details. - * Generated by Cypher Stack on 2023-05-26 - * - */ - -import 'package:flutter/material.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; - -const kCoinThemeColorDefaults = CoinThemeColorDefault(); - -class CoinThemeColorDefault { - const CoinThemeColorDefault(); - - Color get bitcoin => const Color(0xFFFCC17B); - Color get litecoin => const Color(0xFF7FA6E1); - Color get bitcoincash => const Color(0xFF7BCFB8); - Color get firo => const Color(0xFFFF897A); - Color get dogecoin => const Color(0xFFFFE079); - Color get epicCash => const Color(0xFFC5C7CB); - Color get eCash => const Color(0xFFC5C7CB); - Color get ethereum => const Color(0xFFA7ADE9); - Color get monero => const Color(0xFFFF9E6B); - Color get namecoin => const Color(0xFF91B1E1); - Color get wownero => const Color(0xFFED80C1); - Color get particl => const Color(0xFF8175BD); - Color get peercoin => const Color(0xFF3CB054); - Color get solana => const Color(0xFFC696FF); - Color get stellar => const Color(0xFF6600FF); - Color get nano => const Color(0xFF209CE9); - Color get banano => const Color(0xFFFBDD11); - Color get tezos => const Color(0xFF0F61FF); - - Color forCoin(Coin coin) { - switch (coin) { - case Coin.bitcoin: - case Coin.bitcoinTestNet: - case Coin.bitcoinFrost: - case Coin.bitcoinFrostTestNet: - return bitcoin; - case Coin.litecoin: - case Coin.litecoinTestNet: - return litecoin; - case Coin.bitcoincash: - case Coin.bitcoincashTestnet: - return bitcoincash; - case Coin.dogecoin: - case Coin.dogecoinTestNet: - return dogecoin; - case Coin.eCash: - return eCash; - case Coin.epicCash: - return epicCash; - case Coin.ethereum: - return ethereum; - case Coin.firo: - case Coin.firoTestNet: - return firo; - case Coin.monero: - return monero; - case Coin.namecoin: - return namecoin; - case Coin.wownero: - return wownero; - case Coin.particl: - return particl; - case Coin.peercoin: - return peercoin; - case Coin.peercoinTestNet: - return peercoin; - case Coin.solana: - return solana; - case Coin.stellar: - case Coin.stellarTestnet: - return stellar; - case Coin.nano: - return nano; - case Coin.banano: - return banano; - case Coin.tezos: - return tezos; - } - } -} diff --git a/lib/themes/stack_colors.dart b/lib/themes/stack_colors.dart index 11e146d1b..20b60e3b1 100644 --- a/lib/themes/stack_colors.dart +++ b/lib/themes/stack_colors.dart @@ -9,9 +9,7 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/models/isar/stack_theme.dart'; -import 'package:stackwallet/themes/color_theme.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import '../models/isar/stack_theme.dart'; class StackColors extends ThemeExtension { final String themeId; @@ -1676,58 +1674,6 @@ class StackColors extends ThemeExtension { ); } - Color colorForCoin(Coin coin) { - switch (coin) { - case Coin.bitcoin: - case Coin.bitcoinTestNet: - case Coin.bitcoinFrost: - case Coin.bitcoinFrostTestNet: - return _coin.bitcoin; - case Coin.litecoin: - case Coin.litecoinTestNet: - return _coin.litecoin; - case Coin.bitcoincash: - case Coin.bitcoincashTestnet: - return _coin.bitcoincash; - case Coin.dogecoin: - case Coin.dogecoinTestNet: - return _coin.dogecoin; - case Coin.epicCash: - return _coin.epicCash; - case Coin.eCash: - return _coin.eCash; - case Coin.ethereum: - return _coin.ethereum; - case Coin.firo: - case Coin.firoTestNet: - return _coin.firo; - case Coin.monero: - return _coin.monero; - case Coin.namecoin: - return _coin.namecoin; - case Coin.wownero: - return _coin.wownero; - case Coin.particl: - return _coin.particl; - case Coin.peercoin: - case Coin.peercoinTestNet: - return _coin.peercoin; - case Coin.solana: - return _coin.solana; - case Coin.stellar: - case Coin.stellarTestnet: - return _coin.stellar; - case Coin.nano: - return _coin.nano; - case Coin.banano: - return _coin.banano; - case Coin.tezos: - return _coin.tezos; - } - } - - static const _coin = CoinThemeColorDefault(); - Color colorForStatus(String status) { switch (status) { case "New": diff --git a/lib/themes/theme_providers.dart b/lib/themes/theme_providers.dart index eb622e8cc..103ffd217 100644 --- a/lib/themes/theme_providers.dart +++ b/lib/themes/theme_providers.dart @@ -10,10 +10,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/isar/stack_theme.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/themes/theme_service.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; + +import '../models/isar/stack_theme.dart'; +import '../wallets/crypto_currency/crypto_currency.dart'; +import 'stack_colors.dart'; +import 'theme_service.dart'; final applicationThemesDirectoryPathProvider = StateProvider((ref) => ""); @@ -41,10 +42,10 @@ final themeAssetsProvider = StateProvider( ), ); -final pCoinColor = StateProvider.family( +final pCoinColor = StateProvider.family( (ref, coin) => ref.watch( - themeProvider.select((value) => value.coinColors[coin.mainNetVersion]), + themeProvider.select((value) => value.coinColors[coin.mainNetId]), ) ?? Colors.deepOrangeAccent, ); diff --git a/lib/themes/theme_service.dart b/lib/themes/theme_service.dart index c71a336a4..68344ea43 100644 --- a/lib/themes/theme_service.dart +++ b/lib/themes/theme_service.dart @@ -16,13 +16,13 @@ import 'package:crypto/crypto.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/db/isar/main_db.dart'; -import 'package:stackwallet/models/isar/stack_theme.dart'; -import 'package:stackwallet/networking/http.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/prefs.dart'; -import 'package:stackwallet/utilities/stack_file_system.dart'; +import '../db/isar/main_db.dart'; +import '../models/isar/stack_theme.dart'; +import '../networking/http.dart'; +import '../services/tor_service.dart'; +import '../utilities/logger.dart'; +import '../utilities/prefs.dart'; +import '../utilities/stack_file_system.dart'; final pThemeService = Provider((ref) { return ThemeService.instance; diff --git a/lib/utilities/address_utils.dart b/lib/utilities/address_utils.dart index 65e0231fe..2bb721fe0 100644 --- a/lib/utilities/address_utils.dart +++ b/lib/utilities/address_utils.dart @@ -10,191 +10,172 @@ import 'dart:convert'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/banano.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/bitcoin.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/bitcoin_frost.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/bitcoincash.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/dogecoin.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/ecash.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/epiccash.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/ethereum.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/firo.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/litecoin.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/monero.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/namecoin.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/nano.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/particl.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/solana.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/stellar.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/tezos.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/wownero.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; - -import '../wallets/crypto_currency/coins/peercoin.dart'; +import 'logger.dart'; +import '../wallets/crypto_currency/coins/bitcoincash.dart'; +import '../wallets/crypto_currency/coins/ecash.dart'; +import '../wallets/crypto_currency/crypto_currency.dart'; class AddressUtils { static String condenseAddress(String address) { return '${address.substring(0, 5)}...${address.substring(address.length - 5)}'; } - static bool validateAddress(String address, Coin coin) { - //This calls the validate address for each crypto coin, validateAddress is - //only used in 2 places, so I just replaced the old functionality here - switch (coin) { - case Coin.bitcoin: - return Bitcoin(CryptoCurrencyNetwork.main).validateAddress(address); - case Coin.bitcoinFrost: - return BitcoinFrost(CryptoCurrencyNetwork.main) - .validateAddress(address); - case Coin.litecoin: - return Litecoin(CryptoCurrencyNetwork.main).validateAddress(address); - case Coin.bitcoincash: - return Bitcoincash(CryptoCurrencyNetwork.main).validateAddress(address); - case Coin.dogecoin: - return Dogecoin(CryptoCurrencyNetwork.main).validateAddress(address); - case Coin.epicCash: - return Epiccash(CryptoCurrencyNetwork.main).validateAddress(address); - case Coin.ethereum: - return Ethereum(CryptoCurrencyNetwork.main).validateAddress(address); - case Coin.firo: - return Firo(CryptoCurrencyNetwork.main).validateAddress(address); - case Coin.eCash: - return Ecash(CryptoCurrencyNetwork.main).validateAddress(address); - case Coin.monero: - return Monero(CryptoCurrencyNetwork.main).validateAddress(address); - case Coin.wownero: - return Wownero(CryptoCurrencyNetwork.main).validateAddress(address); - case Coin.namecoin: - return Namecoin(CryptoCurrencyNetwork.main).validateAddress(address); - case Coin.particl: - return Particl(CryptoCurrencyNetwork.main).validateAddress(address); - case Coin.peercoin: - return Peercoin(CryptoCurrencyNetwork.main).validateAddress(address); - case Coin.solana: - return Solana(CryptoCurrencyNetwork.main).validateAddress(address); - case Coin.stellar: - return Stellar(CryptoCurrencyNetwork.main).validateAddress(address); - case Coin.nano: - return Nano(CryptoCurrencyNetwork.main).validateAddress(address); - case Coin.banano: - return Banano(CryptoCurrencyNetwork.main).validateAddress(address); - case Coin.tezos: - return Tezos(CryptoCurrencyNetwork.main).validateAddress(address); - case Coin.bitcoinTestNet: - return Bitcoin(CryptoCurrencyNetwork.test).validateAddress(address); - case Coin.bitcoinFrostTestNet: - return BitcoinFrost(CryptoCurrencyNetwork.test) - .validateAddress(address); - case Coin.litecoinTestNet: - return Litecoin(CryptoCurrencyNetwork.test).validateAddress(address); - case Coin.bitcoincashTestnet: - return Bitcoincash(CryptoCurrencyNetwork.test).validateAddress(address); - case Coin.firoTestNet: - return Firo(CryptoCurrencyNetwork.test).validateAddress(address); - case Coin.dogecoinTestNet: - return Dogecoin(CryptoCurrencyNetwork.test).validateAddress(address); - case Coin.peercoinTestNet: - return Peercoin(CryptoCurrencyNetwork.test).validateAddress(address); - case Coin.stellarTestnet: - return Stellar(CryptoCurrencyNetwork.test).validateAddress(address); - } - // throw Exception("moved"); - // switch (coin) { - // case Coin.bitcoin: - // return Address.validateAddress(address, bitcoin); - // case Coin.litecoin: - // return Address.validateAddress(address, litecoin); - // case Coin.bitcoincash: - // try { - // // 0 for bitcoincash: address scheme, 1 for legacy address - // final format = bitbox.Address.detectFormat(address); - // - // if (coin == Coin.bitcoincashTestnet) { - // return true; - // } - // - // if (format == bitbox.Address.formatCashAddr) { - // String addr = address; - // if (addr.contains(":")) { - // addr = addr.split(":").last; - // } - // - // return addr.startsWith("q"); - // } else { - // return address.startsWith("1"); - // } - // } catch (e) { - // return false; - // } - // case Coin.dogecoin: - // return Address.validateAddress(address, dogecoin); - // case Coin.epicCash: - // return validateSendAddress(address) == "1"; - // case Coin.ethereum: - // return true; //TODO - validate ETH address - // case Coin.firo: - // return Address.validateAddress(address, firoNetwork); - // case Coin.eCash: - // return Address.validateAddress(address, eCashNetwork); - // case Coin.monero: - // return RegExp("[a-zA-Z0-9]{95}").hasMatch(address) || - // RegExp("[a-zA-Z0-9]{106}").hasMatch(address); - // case Coin.wownero: - // return RegExp("[a-zA-Z0-9]{95}").hasMatch(address) || - // RegExp("[a-zA-Z0-9]{106}").hasMatch(address); - // case Coin.namecoin: - // return Address.validateAddress(address, namecoin, namecoin.bech32!); - // case Coin.particl: - // return Address.validateAddress(address, particl); - // case Coin.stellar: - // return RegExp(r"^[G][A-Z0-9]{55}$").hasMatch(address); - // case Coin.nano: - // return NanoAccounts.isValid(NanoAccountType.NANO, address); - // case Coin.banano: - // return NanoAccounts.isValid(NanoAccountType.BANANO, address); - // case Coin.tezos: - // return RegExp(r"^tz[1-9A-HJ-NP-Za-km-z]{34}$").hasMatch(address); - // case Coin.bitcoinTestNet: - // return Address.validateAddress(address, testnet); - // case Coin.litecoinTestNet: - // return Address.validateAddress(address, litecointestnet); - // case Coin.bitcoincashTestnet: - // try { - // // 0 for bitcoincash: address scheme, 1 for legacy address - // final format = bitbox.Address.detectFormat(address); - // - // if (coin == Coin.bitcoincashTestnet) { - // return true; - // } - // - // if (format == bitbox.Address.formatCashAddr) { - // String addr = address; - // if (addr.contains(":")) { - // addr = addr.split(":").last; - // } - // - // return addr.startsWith("q"); - // } else { - // return address.startsWith("1"); - // } - // } catch (e) { - // return false; - // } - // case Coin.firoTestNet: - // return Address.validateAddress(address, firoTestNetwork); - // case Coin.dogecoinTestNet: - // return Address.validateAddress(address, dogecointestnet); - // case Coin.stellarTestnet: - // return RegExp(r"^[G][A-Z0-9]{55}$").hasMatch(address); - // } - } + // static bool validateAddress(String address, Coin coin) { + // //This calls the validate address for each crypto coin, validateAddress is + // //only used in 2 places, so I just replaced the old functionality here + // switch (coin) { + // case Coin.bitcoin: + // return Bitcoin(CryptoCurrencyNetwork.main).validateAddress(address); + // case Coin.bitcoinFrost: + // return BitcoinFrost(CryptoCurrencyNetwork.main) + // .validateAddress(address); + // case Coin.litecoin: + // return Litecoin(CryptoCurrencyNetwork.main).validateAddress(address); + // case Coin.bitcoincash: + // return Bitcoincash(CryptoCurrencyNetwork.main).validateAddress(address); + // case Coin.dogecoin: + // return Dogecoin(CryptoCurrencyNetwork.main).validateAddress(address); + // case Coin.epicCash: + // return Epiccash(CryptoCurrencyNetwork.main).validateAddress(address); + // case Coin.ethereum: + // return Ethereum(CryptoCurrencyNetwork.main).validateAddress(address); + // case Coin.firo: + // return Firo(CryptoCurrencyNetwork.main).validateAddress(address); + // case Coin.eCash: + // return Ecash(CryptoCurrencyNetwork.main).validateAddress(address); + // case Coin.monero: + // return Monero(CryptoCurrencyNetwork.main).validateAddress(address); + // case Coin.wownero: + // return Wownero(CryptoCurrencyNetwork.main).validateAddress(address); + // case Coin.namecoin: + // return Namecoin(CryptoCurrencyNetwork.main).validateAddress(address); + // case Coin.particl: + // return Particl(CryptoCurrencyNetwork.main).validateAddress(address); + // case Coin.peercoin: + // return Peercoin(CryptoCurrencyNetwork.main).validateAddress(address); + // case Coin.solana: + // return Solana(CryptoCurrencyNetwork.main).validateAddress(address); + // case Coin.stellar: + // return Stellar(CryptoCurrencyNetwork.main).validateAddress(address); + // case Coin.nano: + // return Nano(CryptoCurrencyNetwork.main).validateAddress(address); + // case Coin.banano: + // return Banano(CryptoCurrencyNetwork.main).validateAddress(address); + // case Coin.tezos: + // return Tezos(CryptoCurrencyNetwork.main).validateAddress(address); + // case Coin.bitcoinTestNet: + // return Bitcoin(CryptoCurrencyNetwork.test).validateAddress(address); + // case Coin.bitcoinFrostTestNet: + // return BitcoinFrost(CryptoCurrencyNetwork.test) + // .validateAddress(address); + // case Coin.litecoinTestNet: + // return Litecoin(CryptoCurrencyNetwork.test).validateAddress(address); + // case Coin.bitcoincashTestnet: + // return Bitcoincash(CryptoCurrencyNetwork.test).validateAddress(address); + // case Coin.firoTestNet: + // return Firo(CryptoCurrencyNetwork.test).validateAddress(address); + // case Coin.dogecoinTestNet: + // return Dogecoin(CryptoCurrencyNetwork.test).validateAddress(address); + // case Coin.peercoinTestNet: + // return Peercoin(CryptoCurrencyNetwork.test).validateAddress(address); + // case Coin.stellarTestnet: + // return Stellar(CryptoCurrencyNetwork.test).validateAddress(address); + // } + // // throw Exception("moved"); + // // switch (coin) { + // // case Coin.bitcoin: + // // return Address.validateAddress(address, bitcoin); + // // case Coin.litecoin: + // // return Address.validateAddress(address, litecoin); + // // case Coin.bitcoincash: + // // try { + // // // 0 for bitcoincash: address scheme, 1 for legacy address + // // final format = bitbox.Address.detectFormat(address); + // // + // // if (coin == Coin.bitcoincashTestnet) { + // // return true; + // // } + // // + // // if (format == bitbox.Address.formatCashAddr) { + // // String addr = address; + // // if (addr.contains(":")) { + // // addr = addr.split(":").last; + // // } + // // + // // return addr.startsWith("q"); + // // } else { + // // return address.startsWith("1"); + // // } + // // } catch (e) { + // // return false; + // // } + // // case Coin.dogecoin: + // // return Address.validateAddress(address, dogecoin); + // // case Coin.epicCash: + // // return validateSendAddress(address) == "1"; + // // case Coin.ethereum: + // // return true; //TODO - validate ETH address + // // case Coin.firo: + // // return Address.validateAddress(address, firoNetwork); + // // case Coin.eCash: + // // return Address.validateAddress(address, eCashNetwork); + // // case Coin.monero: + // // return RegExp("[a-zA-Z0-9]{95}").hasMatch(address) || + // // RegExp("[a-zA-Z0-9]{106}").hasMatch(address); + // // case Coin.wownero: + // // return RegExp("[a-zA-Z0-9]{95}").hasMatch(address) || + // // RegExp("[a-zA-Z0-9]{106}").hasMatch(address); + // // case Coin.namecoin: + // // return Address.validateAddress(address, namecoin, namecoin.bech32!); + // // case Coin.particl: + // // return Address.validateAddress(address, particl); + // // case Coin.stellar: + // // return RegExp(r"^[G][A-Z0-9]{55}$").hasMatch(address); + // // case Coin.nano: + // // return NanoAccounts.isValid(NanoAccountType.NANO, address); + // // case Coin.banano: + // // return NanoAccounts.isValid(NanoAccountType.BANANO, address); + // // case Coin.tezos: + // // return RegExp(r"^tz[1-9A-HJ-NP-Za-km-z]{34}$").hasMatch(address); + // // case Coin.bitcoinTestNet: + // // return Address.validateAddress(address, testnet); + // // case Coin.litecoinTestNet: + // // return Address.validateAddress(address, litecointestnet); + // // case Coin.bitcoincashTestnet: + // // try { + // // // 0 for bitcoincash: address scheme, 1 for legacy address + // // final format = bitbox.Address.detectFormat(address); + // // + // // if (coin == Coin.bitcoincashTestnet) { + // // return true; + // // } + // // + // // if (format == bitbox.Address.formatCashAddr) { + // // String addr = address; + // // if (addr.contains(":")) { + // // addr = addr.split(":").last; + // // } + // // + // // return addr.startsWith("q"); + // // } else { + // // return address.startsWith("1"); + // // } + // // } catch (e) { + // // return false; + // // } + // // case Coin.firoTestNet: + // // return Address.validateAddress(address, firoTestNetwork); + // // case Coin.dogecoinTestNet: + // // return Address.validateAddress(address, dogecointestnet); + // // case Coin.stellarTestnet: + // // return RegExp(r"^[G][A-Z0-9]{55}$").hasMatch(address); + // // } + // } /// parse an address uri /// returns an empty map if the input string does not begin with "firo:" static Map parseUri(String uri) { - Map result = {}; + final Map result = {}; try { final u = Uri.parse(uri); if (u.hasScheme) { @@ -211,15 +192,13 @@ class AddressUtils { /// builds a uri string with the given address and query parameters if any static String buildUriString( - Coin coin, + CryptoCurrency coin, String address, Map params, ) { // TODO: other sanitation as well ? String sanitizedAddress = address; - if (coin == Coin.bitcoincash || - coin == Coin.bitcoincashTestnet || - coin == Coin.eCash) { + if (coin is Bitcoincash || coin is Ecash) { final prefix = "${coin.uriScheme}:"; if (address.startsWith(prefix)) { sanitizedAddress = address.replaceFirst(prefix, ""); diff --git a/lib/utilities/amount/amount.dart b/lib/utilities/amount/amount.dart index 2ce3fbd56..e388020e1 100644 --- a/lib/utilities/amount/amount.dart +++ b/lib/utilities/amount/amount.dart @@ -11,7 +11,7 @@ import 'dart:convert'; import 'package:decimal/decimal.dart'; -import 'package:stackwallet/utilities/util.dart'; +import '../util.dart'; class Amount { Amount({ diff --git a/lib/utilities/amount/amount_formatter.dart b/lib/utilities/amount/amount_formatter.dart index 1ae577507..44746b8cd 100644 --- a/lib/utilities/amount/amount_formatter.dart +++ b/lib/utilities/amount/amount_formatter.dart @@ -1,19 +1,19 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart'; -import 'package:stackwallet/providers/global/locale_provider.dart'; -import 'package:stackwallet/providers/global/prefs_provider.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_unit.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import '../../models/isar/models/ethereum/eth_contract.dart'; +import '../../providers/global/locale_provider.dart'; +import '../../providers/global/prefs_provider.dart'; +import 'amount.dart'; +import 'amount_unit.dart'; +import '../../wallets/crypto_currency/crypto_currency.dart'; -final pAmountUnit = Provider.family( +final pAmountUnit = Provider.family( (ref, coin) => ref.watch( prefsChangeNotifierProvider.select( (value) => value.amountUnit(coin), ), ), ); -final pMaxDecimals = Provider.family( +final pMaxDecimals = Provider.family( (ref, coin) => ref.watch( prefsChangeNotifierProvider.select( (value) => value.maxDecimals(coin), @@ -21,7 +21,8 @@ final pMaxDecimals = Provider.family( ), ); -final pAmountFormatter = Provider.family((ref, coin) { +final pAmountFormatter = + Provider.family((ref, coin) { final locale = ref.watch( localeServiceChangeNotifierProvider.select((value) => value.locale), ); @@ -37,7 +38,7 @@ final pAmountFormatter = Provider.family((ref, coin) { class AmountFormatter { final AmountUnit unit; final String locale; - final Coin coin; + final CryptoCurrency coin; final int maxDecimals; AmountFormatter({ diff --git a/lib/utilities/amount/amount_input_formatter.dart b/lib/utilities/amount/amount_input_formatter.dart index 2ac5d7871..f09100ad7 100644 --- a/lib/utilities/amount/amount_input_formatter.dart +++ b/lib/utilities/amount/amount_input_formatter.dart @@ -1,8 +1,8 @@ import 'dart:math'; import 'package:flutter/services.dart'; -import 'package:stackwallet/utilities/amount/amount_unit.dart'; -import 'package:stackwallet/utilities/util.dart'; +import 'amount_unit.dart'; +import '../util.dart'; class AmountInputFormatter extends TextInputFormatter { final int decimals; diff --git a/lib/utilities/amount/amount_unit.dart b/lib/utilities/amount/amount_unit.dart index e74de6510..9911e5961 100644 --- a/lib/utilities/amount/amount_unit.dart +++ b/lib/utilities/amount/amount_unit.dart @@ -11,10 +11,14 @@ import 'dart:math' as math; import 'package:decimal/decimal.dart'; -import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/util.dart'; +import '../../models/isar/models/ethereum/eth_contract.dart'; +import 'amount.dart'; +import '../util.dart'; +import '../../wallets/crypto_currency/coins/ethereum.dart'; +import '../../wallets/crypto_currency/coins/monero.dart'; +import '../../wallets/crypto_currency/coins/wownero.dart'; +import '../../wallets/crypto_currency/crypto_currency.dart'; +import '../../wallets/crypto_currency/intermediate/nano_currency.dart'; // preserve index order as index is used to store value in preferences enum AmountUnit { @@ -34,48 +38,56 @@ enum AmountUnit { const AmountUnit(this.shift); final int shift; - static List valuesForCoin(Coin coin) { - switch (coin) { - case Coin.firo: - case Coin.litecoin: - case Coin.particl: - case Coin.peercoin: - case Coin.namecoin: - case Coin.bitcoinFrost: - case Coin.bitcoinFrostTestNet: - case Coin.bitcoinTestNet: - case Coin.litecoinTestNet: - case Coin.bitcoincashTestnet: - case Coin.dogecoinTestNet: - case Coin.firoTestNet: - case Coin.peercoinTestNet: - case Coin.bitcoin: - case Coin.bitcoincash: - case Coin.dogecoin: - case Coin.eCash: - case Coin.epicCash: - case Coin.stellar: // TODO: check if this is correct - case Coin.stellarTestnet: - case Coin.tezos: - case Coin.solana: - return AmountUnit.values.sublist(0, 4); - - case Coin.monero: - case Coin.wownero: - return AmountUnit.values.sublist(0, 5); - - case Coin.ethereum: - return AmountUnit.values.sublist(0, 7); - - case Coin.nano: - case Coin.banano: - return AmountUnit.values; + static List valuesForCoin(CryptoCurrency coin) { + final remainder = coin.fractionDigits % 3; + int n = (coin.fractionDigits ~/ 3) + 1; + if (remainder > 0) { + n++; } + + return AmountUnit.values.sublist(0, n); + // + // switch (coin) { + // case Coin.firo: + // case Coin.litecoin: + // case Coin.particl: + // case Coin.peercoin: + // case Coin.namecoin: + // case Coin.bitcoinFrost: + // case Coin.bitcoinFrostTestNet: + // case Coin.bitcoinTestNet: + // case Coin.litecoinTestNet: + // case Coin.bitcoincashTestnet: + // case Coin.dogecoinTestNet: + // case Coin.firoTestNet: + // case Coin.peercoinTestNet: + // case Coin.bitcoin: + // case Coin.bitcoincash: + // case Coin.dogecoin: + // case Coin.eCash: + // case Coin.epicCash: + // case Coin.stellar: // TODO: check if this is correct + // case Coin.stellarTestnet: + // case Coin.tezos: + // case Coin.solana: + // return AmountUnit.values.sublist(0, 4); + // + // case Coin.monero: + // case Coin.wownero: + // return AmountUnit.values.sublist(0, 5); + // + // case Coin.ethereum: + // return AmountUnit.values.sublist(0, 7); + // + // case Coin.nano: + // case Coin.banano: + // return AmountUnit.values; + // } } } extension AmountUnitExt on AmountUnit { - String unitForCoin(Coin coin) { + String unitForCoin(CryptoCurrency coin) { switch (this) { case AmountUnit.normal: return coin.ticker; @@ -84,63 +96,57 @@ extension AmountUnitExt on AmountUnit { case AmountUnit.micro: return "µ${coin.ticker}"; case AmountUnit.nano: - if (coin == Coin.ethereum) { + if (coin is Ethereum) { return "gwei"; - } else if (coin == Coin.wownero || - coin == Coin.monero || - coin == Coin.nano || - coin == Coin.banano) { + } else if (coin is Wownero || coin is Monero || coin is NanoCurrency) { return "n${coin.ticker}"; } else { return "sats"; } case AmountUnit.pico: - if (coin == Coin.ethereum) { + if (coin is Ethereum) { return "mwei"; - } else if (coin == Coin.wownero || - coin == Coin.monero || - coin == Coin.nano || - coin == Coin.banano) { + } else if (coin is Wownero || coin is Monero || coin is NanoCurrency) { return "p${coin.ticker}"; } else { return "invalid"; } case AmountUnit.femto: - if (coin == Coin.ethereum) { + if (coin is Ethereum) { return "kwei"; - } else if (coin == Coin.nano || coin == Coin.banano) { + } else if (coin is NanoCurrency) { return "f${coin.ticker}"; } else { return "invalid"; } case AmountUnit.atto: - if (coin == Coin.ethereum) { + if (coin is Ethereum) { return "wei"; - } else if (coin == Coin.nano || coin == Coin.banano) { + } else if (coin is NanoCurrency) { return "a${coin.ticker}"; } else { return "invalid"; } case AmountUnit.zepto: - if (coin == Coin.nano || coin == Coin.banano) { + if (coin is NanoCurrency) { return "z${coin.ticker}"; } else { return "invalid"; } case AmountUnit.yocto: - if (coin == Coin.nano || coin == Coin.banano) { + if (coin is NanoCurrency) { return "y${coin.ticker}"; } else { return "invalid"; } case AmountUnit.ronto: - if (coin == Coin.nano || coin == Coin.banano) { + if (coin is NanoCurrency) { return "r${coin.ticker}"; } else { return "invalid"; } case AmountUnit.quecto: - if (coin == Coin.nano || coin == Coin.banano) { + if (coin is NanoCurrency) { return "q${coin.ticker}"; } else { return "invalid"; @@ -174,7 +180,7 @@ extension AmountUnitExt on AmountUnit { Amount? tryParse( String value, { required String locale, - required Coin coin, + required CryptoCurrency coin, EthContract? tokenContract, bool overrideWithDecimalPlacesFromString = false, }) { @@ -212,7 +218,7 @@ extension AmountUnitExt on AmountUnit { final decimalPlaces = overrideWithDecimalPlacesFromString ? decimal.scale - : tokenContract?.decimals ?? coin.decimals; + : tokenContract?.decimals ?? coin.fractionDigits; final realShift = math.min(shift, decimalPlaces); return decimal.shift(0 - realShift).toAmount(fractionDigits: decimalPlaces); @@ -221,7 +227,7 @@ extension AmountUnitExt on AmountUnit { String displayAmount({ required Amount amount, required String locale, - required Coin coin, + required CryptoCurrency coin, required int maxDecimalPlaces, bool withUnitName = true, bool indicatePrecisionLoss = true, @@ -271,8 +277,9 @@ extension AmountUnitExt on AmountUnit { ? tokenContract.decimals : maxDecimalPlaces; } else { - updatedMax = - maxDecimalPlaces > coin.decimals ? coin.decimals : maxDecimalPlaces; + updatedMax = maxDecimalPlaces > coin.fractionDigits + ? coin.fractionDigits + : maxDecimalPlaces; } final int actualDecimalPlaces = math.min(places, updatedMax); diff --git a/lib/utilities/assets.dart b/lib/utilities/assets.dart index 9213fd1b2..84dad9ae6 100644 --- a/lib/utilities/assets.dart +++ b/lib/utilities/assets.dart @@ -9,10 +9,10 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/services/exchange/change_now/change_now_exchange.dart'; -import 'package:stackwallet/services/exchange/majestic_bank/majestic_bank_exchange.dart'; -import 'package:stackwallet/services/exchange/simpleswap/simpleswap_exchange.dart'; -import 'package:stackwallet/services/exchange/trocador/trocador_exchange.dart'; +import '../services/exchange/change_now/change_now_exchange.dart'; +import '../services/exchange/majestic_bank/majestic_bank_exchange.dart'; +import '../services/exchange/simpleswap/simpleswap_exchange.dart'; +import '../services/exchange/trocador/trocador_exchange.dart'; abstract class Assets { static const svg = _SVG(); @@ -254,8 +254,6 @@ class _SVG { class _PNG { const _PNG(); - String get splash => "assets/images/splash.png"; - String get glasses => "assets/images/glasses.png"; String get glassesHidden => "assets/images/glasses-hidden.png"; String get mascot => "assets/images/mascot.png"; @@ -264,7 +262,7 @@ class _PNG { class _ANIMATIONS { const _ANIMATIONS(); - String get test2 => "assets/lottie/test2.json"; + String get test2 => "assets/lottie/loader.json"; String get iconSend => "assets/lottie/icon_send.json"; String get loaderAndCheckmark => "assets/lottie/loader_and_checkmark.json"; String get arrowRotate => "assets/lottie/arrow_rotate.json"; diff --git a/lib/utilities/biometrics.dart b/lib/utilities/biometrics.dart index 13262fadb..8be9edb24 100644 --- a/lib/utilities/biometrics.dart +++ b/lib/utilities/biometrics.dart @@ -13,7 +13,7 @@ import 'dart:io'; import 'package:flutter/cupertino.dart'; import 'package:local_auth/auth_strings.dart'; import 'package:local_auth/local_auth.dart'; -import 'package:stackwallet/utilities/logger.dart'; +import 'logger.dart'; class Biometrics { static const integrationTestFlag = diff --git a/lib/utilities/bip47_utils.dart b/lib/utilities/bip47_utils.dart index 87730f0df..80b393dff 100644 --- a/lib/utilities/bip47_utils.dart +++ b/lib/utilities/bip47_utils.dart @@ -11,8 +11,8 @@ import 'dart:typed_data'; import 'package:bip47/src/util.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/output_v2.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart'; +import '../models/isar/models/blockchain_data/v2/output_v2.dart'; +import '../models/isar/models/blockchain_data/v2/transaction_v2.dart'; abstract class Bip47Utils { /// looks at tx outputs and returns a blinded payment code if found diff --git a/lib/utilities/block_explorers.dart b/lib/utilities/block_explorers.dart index cf67697b6..b7f55b4b4 100644 --- a/lib/utilities/block_explorers.dart +++ b/lib/utilities/block_explorers.dart @@ -8,77 +8,13 @@ * */ -import 'package:stackwallet/db/isar/main_db.dart'; -import 'package:stackwallet/models/isar/models/block_explorer.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; - -// Returns the default block explorer URL for the given coin and txid -Uri getDefaultBlockExplorerUrlFor({ - required Coin coin, - required String txid, -}) { - switch (coin) { - case Coin.bitcoinFrost: - case Coin.bitcoin: - return Uri.parse("https://mempool.space/tx/$txid"); - case Coin.litecoin: - return Uri.parse("https://chain.so/tx/LTC/$txid"); - case Coin.litecoinTestNet: - return Uri.parse("https://chain.so/tx/LTCTEST/$txid"); - case Coin.bitcoinTestNet: - case Coin.bitcoinFrostTestNet: - return Uri.parse("https://mempool.space/testnet/tx/$txid"); - case Coin.dogecoin: - return Uri.parse("https://chain.so/tx/DOGE/$txid"); - case Coin.eCash: - return Uri.parse("https://explorer.e.cash/tx/$txid"); - case Coin.dogecoinTestNet: - return Uri.parse("https://chain.so/tx/DOGETEST/$txid"); - case Coin.epicCash: - // TODO: Handle this case. - throw UnimplementedError("missing block explorer for epic cash"); - case Coin.ethereum: - return Uri.parse("https://etherscan.io/tx/$txid"); - case Coin.monero: - return Uri.parse("https://xmrchain.net/tx/$txid"); - case Coin.wownero: - return Uri.parse("https://explore.wownero.com/search?value=$txid"); - case Coin.firo: - return Uri.parse("https://explorer.firo.org/tx/$txid"); - case Coin.firoTestNet: - return Uri.parse("https://testexplorer.firo.org/tx/$txid"); - case Coin.bitcoincash: - return Uri.parse("https://blockchair.com/bitcoin-cash/transaction/$txid"); - case Coin.bitcoincashTestnet: - return Uri.parse( - "https://blockexplorer.one/bitcoin-cash/testnet/tx/$txid"); - case Coin.namecoin: - return Uri.parse("https://chainz.cryptoid.info/nmc/tx.dws?$txid.htm"); - case Coin.particl: - return Uri.parse("https://chainz.cryptoid.info/part/tx.dws?$txid.htm"); - case Coin.stellar: - return Uri.parse("https://stellarchain.io/tx/$txid"); - case Coin.nano: - return Uri.parse("https://www.nanolooker.com/block/$txid"); - case Coin.banano: - return Uri.parse("https://www.bananolooker.com/block/$txid"); - case Coin.stellarTestnet: - return Uri.parse("https://testnet.stellarchain.io/transactions/$txid"); - case Coin.tezos: - return Uri.parse("https://tzstats.com/$txid"); - case Coin.solana: - return Uri.parse("https://explorer.solana.com/tx/$txid"); - case Coin.peercoin: - return Uri.parse("https://chainz.cryptoid.info/ppc/tx.dws?$txid.htm"); - case Coin.peercoinTestNet: - return Uri.parse( - "https://chainz.cryptoid.info/ppc-test/search.dws?q=$txid.htm"); - } -} +import '../db/isar/main_db.dart'; +import '../models/isar/models/block_explorer.dart'; +import '../wallets/crypto_currency/crypto_currency.dart'; // Returns internal Isar ID for the inserted object/record Future setBlockExplorerForCoin({ - required Coin coin, + required CryptoCurrency coin, required Uri url, }) async { return await MainDB.instance.putTransactionBlockExplorer( @@ -91,12 +27,13 @@ Future setBlockExplorerForCoin({ // Returns the block explorer URL for the given coin and txid Uri getBlockExplorerTransactionUrlFor({ - required Coin coin, + required CryptoCurrency coin, required String txid, }) { - String? url = MainDB.instance.getTransactionBlockExplorer(coin: coin)?.url; + String? url = + MainDB.instance.getTransactionBlockExplorer(cryptoCurrency: coin)?.url; if (url == null) { - return getDefaultBlockExplorerUrlFor(coin: coin, txid: txid); + return coin.defaultBlockExplorer(txid); } else { url = url.replaceAll("%5BTXID%5D", txid); return Uri.parse(url); diff --git a/lib/utilities/connection_check/electrum_connection_check.dart b/lib/utilities/connection_check/electrum_connection_check.dart index 1dbc003c8..a78075246 100644 --- a/lib/utilities/connection_check/electrum_connection_check.dart +++ b/lib/utilities/connection_check/electrum_connection_check.dart @@ -1,10 +1,10 @@ import 'dart:io'; import 'package:electrum_adapter/electrum_adapter.dart'; -import 'package:stackwallet/services/event_bus/events/global/tor_connection_status_changed_event.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/prefs.dart'; +import '../../services/event_bus/events/global/tor_connection_status_changed_event.dart'; +import '../../services/tor_service.dart'; +import '../logger.dart'; +import '../prefs.dart'; Future checkElectrumServer({ required String host, diff --git a/lib/utilities/constants.dart b/lib/utilities/constants.dart index d3fedc666..d68760139 100644 --- a/lib/utilities/constants.dart +++ b/lib/utilities/constants.dart @@ -10,8 +10,7 @@ import 'dart:io'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/util.dart'; +import 'util.dart'; class _LayoutSizing { const _LayoutSizing(); @@ -34,31 +33,6 @@ abstract class Constants { // just use enable exchange flag // static bool enableBuy = enableExchange; // // true; // true for development, - static final BigInt _satsPerCoinECash = BigInt.from(100); - static final BigInt _satsPerCoinEthereum = BigInt.from(1000000000000000000); - static final BigInt _satsPerCoinMonero = BigInt.from(1000000000000); - static final BigInt _satsPerCoinWownero = BigInt.from(100000000000); - static final BigInt _satsPerCoinNano = - BigInt.parse("1000000000000000000000000000000"); // 1*10^30 - static final BigInt _satsPerCoinBanano = - BigInt.parse("100000000000000000000000000000"); // 1*10^29 - static final BigInt _satsPerCoinStellar = BigInt.from( - 10000000); // https://developers.stellar.org/docs/fundamentals-and-concepts/stellar-data-structures/assets#amount-precision - static final BigInt _satsPerCoin = BigInt.from(100000000); - static final BigInt _satsPerCoinTezos = BigInt.from(1000000); - static final BigInt _satsPerCoinSolana = BigInt.from(1000000000); - static final BigInt _satsPerCoinPeercoin = BigInt.from(1000000); // 1*10^6. - static const int _decimalPlaces = 8; - static const int _decimalPlacesNano = 30; - static const int _decimalPlacesBanano = 29; - static const int _decimalPlacesWownero = 11; - static const int _decimalPlacesMonero = 12; - static const int _decimalPlacesEthereum = 18; - static const int _decimalPlacesECash = 2; - static const int _decimalPlacesStellar = 7; - static const int _decimalPlacesTezos = 6; - static const int _decimalPlacesSolana = 9; - static const int _decimalPlacesPeercoin = 6; static const int notificationsMax = 0xFFFFFFFF; static const Duration networkAliveTimerDuration = Duration(seconds: 10); @@ -70,264 +44,6 @@ abstract class Constants { static const int rescanV1 = 1; - static BigInt satsPerCoin(Coin coin) { - switch (coin) { - case Coin.bitcoin: - case Coin.bitcoinFrost: - case Coin.litecoin: - case Coin.litecoinTestNet: - case Coin.bitcoincash: - case Coin.bitcoincashTestnet: - case Coin.dogecoin: - case Coin.firo: - case Coin.bitcoinTestNet: - case Coin.bitcoinFrostTestNet: - case Coin.dogecoinTestNet: - case Coin.firoTestNet: - case Coin.epicCash: - case Coin.namecoin: - case Coin.particl: - return _satsPerCoin; - - case Coin.nano: - return _satsPerCoinNano; - - case Coin.banano: - return _satsPerCoinBanano; - - case Coin.wownero: - return _satsPerCoinWownero; - - case Coin.monero: - return _satsPerCoinMonero; - - case Coin.ethereum: - return _satsPerCoinEthereum; - - case Coin.eCash: - return _satsPerCoinECash; - - case Coin.stellar: - case Coin.stellarTestnet: - return _satsPerCoinStellar; - - case Coin.tezos: - return _satsPerCoinTezos; - - case Coin.solana: - return _satsPerCoinSolana; - - case Coin.peercoin: - case Coin.peercoinTestNet: - return _satsPerCoinPeercoin; - } - } - - static int decimalPlacesForCoin(Coin coin) { - switch (coin) { - case Coin.bitcoin: - case Coin.bitcoinFrost: - case Coin.litecoin: - case Coin.litecoinTestNet: - case Coin.bitcoincash: - case Coin.bitcoincashTestnet: - case Coin.dogecoin: - case Coin.firo: - case Coin.bitcoinTestNet: - case Coin.bitcoinFrostTestNet: - case Coin.dogecoinTestNet: - case Coin.firoTestNet: - case Coin.epicCash: - case Coin.namecoin: - case Coin.particl: - return _decimalPlaces; - - case Coin.nano: - return _decimalPlacesNano; - - case Coin.banano: - return _decimalPlacesBanano; - - case Coin.wownero: - return _decimalPlacesWownero; - - case Coin.monero: - return _decimalPlacesMonero; - - case Coin.ethereum: - return _decimalPlacesEthereum; - - case Coin.eCash: - return _decimalPlacesECash; - - case Coin.stellar: - case Coin.stellarTestnet: - return _decimalPlacesStellar; - - case Coin.tezos: - return _decimalPlacesTezos; - - case Coin.solana: - return _decimalPlacesSolana; - - case Coin.peercoin: - case Coin.peercoinTestNet: - return _decimalPlacesPeercoin; - } - } - - static List possibleLengthsForCoin(Coin coin) { - final List values = []; - switch (coin) { - case Coin.bitcoin: - case Coin.litecoin: - case Coin.litecoinTestNet: - case Coin.bitcoincash: - case Coin.bitcoincashTestnet: - case Coin.dogecoin: - case Coin.firo: - case Coin.bitcoinTestNet: - case Coin.dogecoinTestNet: - case Coin.firoTestNet: - case Coin.eCash: - case Coin.epicCash: - case Coin.ethereum: - case Coin.namecoin: - case Coin.particl: - values.addAll([12, 24]); - break; - case Coin.solana: - case Coin.nano: - case Coin.stellar: - case Coin.stellarTestnet: - values.addAll([24, 12]); - break; - case Coin.banano: - values.addAll([24, 12]); - break; - case Coin.tezos: - values.addAll([24, 12]); - - case Coin.monero: - values.addAll([25]); - break; - case Coin.wownero: - values.addAll([14, 25]); - break; - - case Coin.bitcoinFrost: - case Coin.bitcoinFrostTestNet: - throw ArgumentError("Frost mnemonic lengths unsupported"); - case Coin.peercoin: - case Coin.peercoinTestNet: - values.addAll([12, /*15, 18, 21,*/ 24]); // TODO [prio=low]: Test rest. - break; - } - return values; - } - - static int targetBlockTimeInSeconds(Coin coin) { - // TODO verify values - switch (coin) { - case Coin.bitcoin: - case Coin.bitcoinTestNet: - case Coin.bitcoinFrost: - case Coin.bitcoinFrostTestNet: - case Coin.bitcoincash: - case Coin.bitcoincashTestnet: - case Coin.eCash: - case Coin.peercoin: - case Coin.peercoinTestNet: - return 600; - - case Coin.dogecoin: - case Coin.dogecoinTestNet: - return 60; - - case Coin.litecoin: - case Coin.litecoinTestNet: - return 150; - - case Coin.firo: - case Coin.firoTestNet: - return 150; - - case Coin.epicCash: - return 60; - - case Coin.ethereum: - return 15; - - case Coin.monero: - return 120; - - case Coin.wownero: - return 120; - - case Coin.namecoin: - return 600; - - case Coin.particl: - return 600; - - case Coin.nano: // TODO: Verify this - case Coin.banano: // TODO: Verify this - case Coin.solana: - return 1; - - case Coin.stellar: - case Coin.stellarTestnet: - return 5; - - case Coin.tezos: - return 60; - } - } - - static int defaultSeedPhraseLengthFor({required Coin coin}) { - switch (coin) { - case Coin.bitcoin: - case Coin.bitcoinTestNet: - case Coin.bitcoincash: - case Coin.bitcoincashTestnet: - case Coin.eCash: - case Coin.dogecoin: - case Coin.dogecoinTestNet: - case Coin.litecoin: - case Coin.litecoinTestNet: - case Coin.firo: - case Coin.firoTestNet: - case Coin.namecoin: - case Coin.particl: - case Coin.ethereum: - case Coin.solana: - return 12; - - case Coin.wownero: - return 14; - - case Coin.nano: - case Coin.banano: - case Coin.epicCash: - case Coin.peercoin: // TODO [prio=low]: Verify default seed length. - case Coin.peercoinTestNet: - case Coin.stellar: - case Coin.stellarTestnet: - case Coin.tezos: - return 24; - - case Coin.monero: - return 25; - - case Coin.bitcoinFrost: - case Coin.bitcoinFrostTestNet: - throw ArgumentError("Frost mnemonic length unsupported"); - // - // default: - // -1; - } - } - static const Map monthMapShort = { 1: 'Jan', 2: 'Feb', diff --git a/lib/utilities/default_epicboxes.dart b/lib/utilities/default_epicboxes.dart index f83f84cf5..a2c9b01f0 100644 --- a/lib/utilities/default_epicboxes.dart +++ b/lib/utilities/default_epicboxes.dart @@ -8,7 +8,7 @@ * */ -import 'package:stackwallet/models/epicbox_server_model.dart'; +import '../models/epicbox_server_model.dart'; abstract class DefaultEpicBoxes { static const String defaultName = "Default"; diff --git a/lib/utilities/default_eth_tokens.dart b/lib/utilities/default_eth_tokens.dart index 2383a24a2..63cd7f62b 100644 --- a/lib/utilities/default_eth_tokens.dart +++ b/lib/utilities/default_eth_tokens.dart @@ -8,7 +8,7 @@ * */ -import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart'; +import '../models/isar/models/ethereum/eth_contract.dart'; abstract class DefaultTokens { static List list = [ diff --git a/lib/utilities/default_nodes.dart b/lib/utilities/default_nodes.dart index 2e2bd71cc..93872aeef 100644 --- a/lib/utilities/default_nodes.dart +++ b/lib/utilities/default_nodes.dart @@ -8,401 +8,11 @@ * */ -import 'package:stackwallet/models/node_model.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import '../wallets/crypto_currency/crypto_currency.dart'; abstract class DefaultNodes { static const String defaultNodeIdPrefix = "default_"; - static String buildId(Coin coin) => "$defaultNodeIdPrefix${coin.name}"; + static String buildId(CryptoCurrency cryptoCurrency) => + "$defaultNodeIdPrefix${cryptoCurrency.identifier}"; static const String defaultName = "Stack Default"; - - @Deprecated("old and decrepit") - static List get all => Coin.values - .map((e) => DefaultNodes.getNodeFor(e)) - .toList(growable: false); - - static NodeModel get bitcoin => NodeModel( - host: "bitcoin.stackwallet.com", - port: 50002, - name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.bitcoin), - useSSL: true, - enabled: true, - coinName: Coin.bitcoin.name, - isFailover: true, - isDown: false, - ); - - static NodeModel get litecoin => NodeModel( - host: "litecoin.stackwallet.com", - port: 20063, - name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.litecoin), - useSSL: true, - enabled: true, - coinName: Coin.litecoin.name, - isFailover: true, - isDown: false, - ); - - static NodeModel get litecoinTestNet => NodeModel( - host: "litecoin.stackwallet.com", - port: 51002, - name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.litecoinTestNet), - useSSL: true, - enabled: true, - coinName: Coin.litecoinTestNet.name, - isFailover: true, - isDown: false, - ); - - static NodeModel get bitcoincash => NodeModel( - host: "bitcoincash.stackwallet.com", - port: 50002, - name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.bitcoincash), - useSSL: true, - enabled: true, - coinName: Coin.bitcoincash.name, - isFailover: true, - isDown: false, - ); - - static NodeModel get dogecoin => NodeModel( - host: "dogecoin.stackwallet.com", - port: 50022, - name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.dogecoin), - useSSL: true, - enabled: true, - coinName: Coin.dogecoin.name, - isFailover: true, - isDown: false, - ); - - static NodeModel get firo => NodeModel( - host: "firo.stackwallet.com", - port: 50002, - name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.firo), - useSSL: true, - enabled: true, - coinName: Coin.firo.name, - isFailover: true, - isDown: false, - ); - - static NodeModel get monero => NodeModel( - host: "https://monero.stackwallet.com", - port: 18081, - name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.monero), - useSSL: true, - enabled: true, - coinName: Coin.monero.name, - isFailover: true, - isDown: false, - trusted: true, - ); - - static NodeModel get wownero => NodeModel( - host: "https://wownero.stackwallet.com", - port: 34568, - name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.wownero), - useSSL: true, - enabled: true, - coinName: Coin.wownero.name, - isFailover: true, - isDown: false, - trusted: true, - ); - - static NodeModel get epicCash => NodeModel( - host: "http://epiccash.stackwallet.com", - port: 3413, - name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.epicCash), - useSSL: false, - enabled: true, - coinName: Coin.epicCash.name, - isFailover: true, - isDown: false, - ); - - static NodeModel get ethereum => NodeModel( - host: "https://eth.stackwallet.com", - port: 443, - name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.ethereum), - useSSL: true, - enabled: true, - coinName: Coin.ethereum.name, - isFailover: true, - isDown: false, - ); - - static NodeModel get namecoin => NodeModel( - host: "namecoin.stackwallet.com", - port: 57002, - name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.namecoin), - useSSL: true, - enabled: true, - coinName: Coin.namecoin.name, - isFailover: true, - isDown: false, - ); - - static NodeModel get particl => NodeModel( - host: "particl.stackwallet.com", - port: 58002, - name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.particl), - useSSL: true, - enabled: true, - coinName: Coin.particl.name, - isFailover: true, - isDown: false, - ); - - static NodeModel get peercoin => NodeModel( - host: "electrum.peercoinexplorer.net", - port: 50002, - name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.peercoin), - useSSL: true, - enabled: true, - coinName: Coin.peercoin.name, - isFailover: true, - isDown: false, - ); - - static NodeModel get solana => NodeModel( - host: - "https://api.mainnet-beta.solana.com", // TODO: Change this to stack wallet one - port: 443, - name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.solana), - useSSL: true, - enabled: true, - coinName: Coin.solana.name, - isFailover: true, - isDown: false, - ); - - static NodeModel get stellar => NodeModel( - host: "https://horizon.stellar.org", - port: 443, - name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.stellar), - useSSL: false, - enabled: true, - coinName: Coin.stellar.name, - isFailover: true, - isDown: false, - ); - - static NodeModel get tezos => NodeModel( - // TODO: Change this to stack wallet one - host: "https://mainnet.api.tez.ie", - port: 443, - name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.tezos), - useSSL: true, - enabled: true, - coinName: Coin.tezos.name, - isFailover: true, - isDown: false, - ); - - static NodeModel get nano => NodeModel( - host: "https://rainstorm.city/api", - port: 443, - name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.nano), - useSSL: true, - enabled: true, - coinName: Coin.nano.name, - isFailover: true, - isDown: false, - ); - - static NodeModel get banano => NodeModel( - host: "https://kaliumapi.appditto.com/api", - port: 443, - name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.banano), - useSSL: true, - enabled: true, - coinName: Coin.banano.name, - isFailover: true, - isDown: false, - ); - - static NodeModel get bitcoinTestnet => NodeModel( - host: "bitcoin-testnet.stackwallet.com", - port: 51002, - name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.bitcoinTestNet), - useSSL: true, - enabled: true, - coinName: Coin.bitcoinTestNet.name, - isFailover: true, - isDown: false, - ); - - static NodeModel get firoTestnet => NodeModel( - host: "firo-testnet.stackwallet.com", - port: 50002, - name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.firoTestNet), - useSSL: true, - enabled: true, - coinName: Coin.firoTestNet.name, - isFailover: true, - isDown: false, - ); - - static NodeModel get dogecoinTestnet => NodeModel( - host: "dogecoin-testnet.stackwallet.com", - port: 50022, - name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.dogecoinTestNet), - useSSL: true, - enabled: true, - coinName: Coin.dogecoinTestNet.name, - isFailover: true, - isDown: false, - ); - - static NodeModel get bitcoincashTestnet => NodeModel( - host: "bitcoincash-testnet.stackwallet.com", - port: 60002, - name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.bitcoincashTestnet), - useSSL: true, - enabled: true, - coinName: Coin.bitcoincashTestnet.name, - isFailover: true, - isDown: false, - ); - - static NodeModel get eCash => NodeModel( - host: "ecash.stackwallet.com", - port: 59002, - name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.eCash), - useSSL: true, - enabled: true, - coinName: Coin.eCash.name, - isFailover: true, - isDown: false, - ); - - static NodeModel get peercoinTestNet => NodeModel( - host: "testnet-electrum.peercoinexplorer.net", - port: 50002, - name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.peercoinTestNet), - useSSL: true, - enabled: true, - coinName: Coin.peercoinTestNet.name, - isFailover: true, - isDown: false, - ); - - static NodeModel get stellarTestnet => NodeModel( - host: "https://horizon-testnet.stellar.org/", - port: 50022, - name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.stellarTestnet), - useSSL: true, - enabled: true, - coinName: Coin.stellarTestnet.name, - isFailover: true, - isDown: false, - ); - - static NodeModel getNodeFor(Coin coin) { - switch (coin) { - case Coin.bitcoin: - case Coin.bitcoinFrost: - return bitcoin; - - case Coin.litecoin: - return litecoin; - - case Coin.bitcoincash: - return bitcoincash; - - case Coin.dogecoin: - return dogecoin; - - case Coin.eCash: - return eCash; - - case Coin.epicCash: - return epicCash; - - case Coin.ethereum: - return ethereum; - - case Coin.firo: - return firo; - - case Coin.monero: - return monero; - - case Coin.wownero: - return wownero; - - case Coin.namecoin: - return namecoin; - - case Coin.particl: - return particl; - - case Coin.peercoin: - return peercoin; - - case Coin.peercoinTestNet: - return peercoinTestNet; - - case Coin.solana: - return solana; - - case Coin.stellar: - return stellar; - - case Coin.nano: - return nano; - - case Coin.banano: - return banano; - - case Coin.tezos: - return tezos; - - case Coin.bitcoinTestNet: - case Coin.bitcoinFrostTestNet: - return bitcoinTestnet; - - case Coin.litecoinTestNet: - return litecoinTestNet; - - case Coin.bitcoincashTestnet: - return bitcoincashTestnet; - - case Coin.firoTestNet: - return firoTestnet; - - case Coin.dogecoinTestNet: - return dogecoinTestnet; - - case Coin.stellarTestnet: - return stellarTestnet; - } - } } diff --git a/lib/utilities/desktop_password_service.dart b/lib/utilities/desktop_password_service.dart index edf1059a6..e563d453e 100644 --- a/lib/utilities/desktop_password_service.dart +++ b/lib/utilities/desktop_password_service.dart @@ -10,7 +10,7 @@ import 'package:hive/hive.dart'; import 'package:stack_wallet_backup/secure_storage.dart'; -import 'package:stackwallet/utilities/logger.dart'; +import 'logger.dart'; const String kBoxNameDesktopData = "desktopData"; const String _kKeyBlobKey = "swbKeyBlobKeyStringID"; diff --git a/lib/utilities/enums/coin_enum.dart b/lib/utilities/enums/coin_enum.dart deleted file mode 100644 index 903054b09..000000000 --- a/lib/utilities/enums/coin_enum.dart +++ /dev/null @@ -1,632 +0,0 @@ -/* - * This file is part of Stack Wallet. - * - * Copyright (c) 2023 Cypher Stack - * All Rights Reserved. - * The code is distributed under GPLv3 license, see LICENSE file for details. - * Generated by Cypher Stack on 2023-05-26 - * - */ - -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/utilities/constants.dart'; - -enum Coin { - bitcoin, - monero, - banano, - bitcoincash, - bitcoinFrost, - dogecoin, - eCash, - epicCash, - ethereum, - firo, - litecoin, - namecoin, - nano, - particl, - peercoin, - solana, - stellar, - tezos, - wownero, - - /// - - /// - /// - - bitcoinTestNet, - bitcoincashTestnet, - bitcoinFrostTestNet, - dogecoinTestNet, - firoTestNet, - litecoinTestNet, - peercoinTestNet, - stellarTestnet, -} - -extension CoinExt on Coin { - String get prettyName { - switch (this) { - case Coin.bitcoin: - return "Bitcoin"; - case Coin.bitcoinFrost: - return "Bitcoin Frost"; - case Coin.litecoin: - return "Litecoin"; - case Coin.bitcoincash: - return "Bitcoin Cash"; - case Coin.dogecoin: - return "Dogecoin"; - case Coin.epicCash: - return "Epic Cash"; - case Coin.eCash: - return "eCash"; - case Coin.ethereum: - return "Ethereum"; - case Coin.firo: - return "Firo"; - case Coin.monero: - return "Monero"; - case Coin.particl: - return "Particl"; - case Coin.peercoin: - return "Peercoin"; - case Coin.solana: - return "Solana"; - case Coin.stellar: - return "Stellar"; - case Coin.tezos: - return "Tezos"; - case Coin.wownero: - return "Wownero"; - case Coin.namecoin: - return "Namecoin"; - case Coin.nano: - return "Nano"; - case Coin.banano: - return "Banano"; - case Coin.bitcoinTestNet: - return "tBitcoin"; - case Coin.bitcoinFrostTestNet: - return "tBitcoin Frost"; - case Coin.litecoinTestNet: - return "tLitecoin"; - case Coin.bitcoincashTestnet: - return "tBitcoin Cash"; - case Coin.firoTestNet: - return "tFiro"; - case Coin.dogecoinTestNet: - return "tDogecoin"; - case Coin.peercoinTestNet: - return "tPeercoin"; - case Coin.stellarTestnet: - return "tStellar"; - } - } - - String get ticker { - switch (this) { - case Coin.bitcoin: - case Coin.bitcoinFrost: - return "BTC"; - case Coin.litecoin: - return "LTC"; - case Coin.bitcoincash: - return "BCH"; - case Coin.dogecoin: - return "DOGE"; - case Coin.epicCash: - return "EPIC"; - case Coin.ethereum: - return "ETH"; - case Coin.eCash: - return "XEC"; - case Coin.firo: - return "FIRO"; - case Coin.monero: - return "XMR"; - case Coin.particl: - return "PART"; - case Coin.peercoin: - return "PPC"; - case Coin.solana: - return "SOL"; - case Coin.stellar: - return "XLM"; - case Coin.tezos: - return "XTZ"; - case Coin.wownero: - return "WOW"; - case Coin.namecoin: - return "NMC"; - case Coin.nano: - return "XNO"; - case Coin.banano: - return "BAN"; - case Coin.bitcoinTestNet: - case Coin.bitcoinFrostTestNet: - return "tBTC"; - case Coin.litecoinTestNet: - return "tLTC"; - case Coin.bitcoincashTestnet: - return "tBCH"; - case Coin.firoTestNet: - return "tFIRO"; - case Coin.dogecoinTestNet: - return "tDOGE"; - case Coin.peercoinTestNet: - return "tPPC"; - case Coin.stellarTestnet: - return "tXLM"; - } - } - - String get uriScheme { - switch (this) { - case Coin.bitcoin: - case Coin.bitcoinFrost: - return "bitcoin"; - case Coin.litecoin: - return "litecoin"; - case Coin.bitcoincash: - return "bitcoincash"; - case Coin.dogecoin: - return "dogecoin"; - case Coin.epicCash: - // TODO: is this actually the right one? - return "epic"; - case Coin.ethereum: - return "ethereum"; - case Coin.eCash: - return "ecash"; - case Coin.firo: - return "firo"; - case Coin.monero: - return "monero"; - case Coin.particl: - return "particl"; - case Coin.peercoin: - return "peercoin"; - case Coin.solana: - return "solana"; - case Coin.stellar: - return "stellar"; - case Coin.tezos: - return "tezos"; - case Coin.wownero: - return "wownero"; - case Coin.namecoin: - return "namecoin"; - case Coin.nano: - return "nano"; - case Coin.banano: - return "ban"; - case Coin.bitcoinTestNet: - case Coin.bitcoinFrostTestNet: - return "bitcoin"; - case Coin.litecoinTestNet: - return "litecoin"; - case Coin.bitcoincashTestnet: - return "bchtest"; - case Coin.firoTestNet: - return "firo"; - case Coin.dogecoinTestNet: - return "dogecoin"; - case Coin.peercoinTestNet: - return "peercoin"; - case Coin.stellarTestnet: - return "stellar"; - } - } - - bool get hasMnemonicPassphraseSupport { - switch (this) { - case Coin.bitcoin: - case Coin.bitcoinTestNet: - case Coin.litecoin: - case Coin.litecoinTestNet: - case Coin.bitcoincash: - case Coin.bitcoincashTestnet: - case Coin.dogecoin: - case Coin.dogecoinTestNet: - case Coin.firo: - case Coin.firoTestNet: - case Coin.namecoin: - case Coin.particl: - case Coin.peercoin: - case Coin.peercoinTestNet: - case Coin.ethereum: - case Coin.eCash: - case Coin.stellar: - case Coin.stellarTestnet: - return true; - - case Coin.bitcoinFrost: - case Coin.bitcoinFrostTestNet: - case Coin.epicCash: - case Coin.monero: - case Coin.wownero: - case Coin.nano: - case Coin.banano: - case Coin.tezos: - case Coin.solana: - return false; - } - } - - bool get hasBuySupport { - switch (this) { - case Coin.bitcoin: - case Coin.litecoin: - case Coin.bitcoincash: - case Coin.dogecoin: - case Coin.ethereum: - return true; - - case Coin.bitcoinFrost: - case Coin.bitcoinFrostTestNet: - case Coin.firo: - case Coin.namecoin: - case Coin.particl: - case Coin.peercoin: - case Coin.peercoinTestNet: - case Coin.eCash: - case Coin.epicCash: - case Coin.monero: - case Coin.tezos: - case Coin.wownero: - case Coin.dogecoinTestNet: - case Coin.bitcoinTestNet: - case Coin.litecoinTestNet: - case Coin.bitcoincashTestnet: - case Coin.firoTestNet: - case Coin.nano: - case Coin.banano: - case Coin.solana: - case Coin.stellar: - case Coin.stellarTestnet: - return false; - } - } - - bool get isTestNet { - switch (this) { - case Coin.bitcoin: - case Coin.bitcoinFrost: - case Coin.litecoin: - case Coin.bitcoincash: - case Coin.dogecoin: - case Coin.firo: - case Coin.namecoin: - case Coin.particl: - case Coin.peercoin: - case Coin.epicCash: - case Coin.ethereum: - case Coin.monero: - case Coin.tezos: - case Coin.wownero: - case Coin.nano: - case Coin.banano: - case Coin.eCash: - case Coin.stellar: - case Coin.solana: - return false; - - case Coin.dogecoinTestNet: - case Coin.bitcoinTestNet: - case Coin.bitcoinFrostTestNet: - case Coin.litecoinTestNet: - case Coin.bitcoincashTestnet: - case Coin.firoTestNet: - case Coin.peercoinTestNet: - case Coin.stellarTestnet: - return true; - } - } - - bool get isFrost { - switch (this) { - case Coin.bitcoinFrost: - case Coin.bitcoinFrostTestNet: - return true; - - default: - return false; - } - } - - Coin get mainNetVersion { - switch (this) { - case Coin.bitcoin: - case Coin.bitcoinFrost: - case Coin.litecoin: - case Coin.bitcoincash: - case Coin.dogecoin: - case Coin.firo: - case Coin.namecoin: - case Coin.particl: - case Coin.peercoin: - case Coin.epicCash: - case Coin.ethereum: - case Coin.monero: - case Coin.tezos: - case Coin.wownero: - case Coin.nano: - case Coin.banano: - case Coin.eCash: - case Coin.stellar: - case Coin.solana: - return this; - - case Coin.dogecoinTestNet: - return Coin.dogecoin; - - case Coin.bitcoinTestNet: - return Coin.bitcoin; - - case Coin.bitcoinFrostTestNet: - return Coin.bitcoinFrost; - - case Coin.litecoinTestNet: - return Coin.litecoin; - - case Coin.bitcoincashTestnet: - return Coin.bitcoincash; - - case Coin.firoTestNet: - return Coin.firo; - - case Coin.peercoinTestNet: - return Coin.peercoin; - - case Coin.stellarTestnet: - return Coin.stellar; - } - } - - int get decimals => Constants.decimalPlacesForCoin(this); - - // Note: this must relate to DerivePathType for certain coins! - AddressType get primaryAddressType { - switch (this) { - case Coin.bitcoin: - case Coin.bitcoinTestNet: - case Coin.litecoin: - case Coin.litecoinTestNet: - case Coin.namecoin: - case Coin.particl: - case Coin.peercoin: - case Coin.peercoinTestNet: - return AddressType.p2wpkh; - - case Coin.bitcoinFrost: - case Coin.bitcoinFrostTestNet: - return AddressType.frostMS; - - case Coin.eCash: - case Coin.bitcoincash: - case Coin.bitcoincashTestnet: - case Coin.dogecoin: - case Coin.firo: - case Coin.firoTestNet: - case Coin.dogecoinTestNet: - return AddressType.p2pkh; - - case Coin.monero: - case Coin.wownero: - return AddressType.cryptonote; - - case Coin.epicCash: - return AddressType.mimbleWimble; - - case Coin.ethereum: - return AddressType.ethereum; - - case Coin.tezos: - return AddressType.tezos; - - case Coin.nano: - return AddressType.nano; - - case Coin.banano: - return AddressType.banano; - - case Coin.stellar: - case Coin.stellarTestnet: - return AddressType.stellar; - - case Coin.solana: - return AddressType.solana; - } - } -} - -Coin coinFromPrettyName(String name) { - switch (name) { - case "Bitcoin": - case "bitcoin": - return Coin.bitcoin; - - case "Litecoin": - case "litecoin": - return Coin.litecoin; - - case "Bitcoincash": - case "bitcoincash": - case "Bitcoin Cash": - return Coin.bitcoincash; - - case "Dogecoin": - case "dogecoin": - return Coin.dogecoin; - - case "Epic Cash": - case "epicCash": - return Coin.epicCash; - - case "Ethereum": - case "ethereum": - return Coin.ethereum; - - case "Firo": - case "firo": - return Coin.firo; - - case "E-Cash": - case "ecash": - case "eCash": - return Coin.eCash; - - case "Monero": - case "monero": - return Coin.monero; - - case "Particl": - case "particl": - return Coin.particl; - - case "Peercoin": - case "peercoin": - return Coin.peercoin; - - case "tPeercoin": - case "Peercoin Testnet": - case "peercoinTestNet": - return Coin.peercoinTestNet; - - case "Solana": - case "solana": - return Coin.solana; - - case "Stellar": - case "stellar": - return Coin.stellar; - - case "Tezos": - case "tezos": - return Coin.tezos; - - case "Namecoin": - case "namecoin": - return Coin.namecoin; - - case "Bitcoin Testnet": - case "tBitcoin": - case "bitcoinTestNet": - return Coin.bitcoinTestNet; - - case "Litecoin Testnet": - case "tlitecoin": - case "litecoinTestNet": - case "tLitecoin": - return Coin.litecoinTestNet; - - case "Bitcoincash Testnet": - case "tBitcoin Cash": - case "Bitcoin Cash Testnet": - case "bitcoincashTestnet": - return Coin.bitcoincashTestnet; - - case "Firo Testnet": - case "tFiro": - case "firoTestNet": - return Coin.firoTestNet; - - case "Dogecoin Testnet": - case "tDogecoin": - case "dogecoinTestNet": - return Coin.dogecoinTestNet; - - case "Wownero": - case "tWownero": - case "wownero": - return Coin.wownero; - - case "Nano": - case "nano": - return Coin.nano; - - case "Banano": - case "banano": - return Coin.banano; - - case "Stellar Testnet": - case "stellarTestnet": - case "stellarTestNet": - case "tStellar": - return Coin.stellarTestnet; - - case "Bitcoin Frost": - case "bitcoinFrost": - return Coin.bitcoinFrost; - - case "Bitcoin Frost Testnet": - case "tBitcoin Frost": - case "bitcoinFrostTestNet": - return Coin.bitcoinFrostTestNet; - - default: - throw ArgumentError.value( - name, - "name", - "No Coin enum value with that prettyName", - ); - } -} - -Coin coinFromTickerCaseInsensitive(String ticker) { - switch (ticker.toLowerCase()) { - case "btc": - return Coin.bitcoin; - case "ltc": - return Coin.litecoin; - case "bch": - return Coin.bitcoincash; - case "doge": - return Coin.dogecoin; - case "epic": - return Coin.epicCash; - case "xec": - return Coin.eCash; - case "eth": - return Coin.ethereum; - case "firo": - return Coin.firo; - case "xmr": - return Coin.monero; - case "nmc": - return Coin.namecoin; - case "part": - return Coin.particl; - case "sol": - return Coin.solana; - case "xlm": - return Coin.stellar; - case "xtz": - return Coin.tezos; - case "tltc": - return Coin.litecoinTestNet; - case "tbtc": - return Coin.bitcoinTestNet; - case "tbch": - return Coin.bitcoincashTestnet; - case "tfiro": - return Coin.firoTestNet; - case "tdoge": - return Coin.dogecoinTestNet; - case "wow": - return Coin.wownero; - case "xno": - return Coin.nano; - case "ban": - return Coin.banano; - case "txlm": - return Coin.stellarTestnet; - default: - throw ArgumentError.value( - ticker, "name", "No Coin enum value with that ticker"); - } -} diff --git a/lib/utilities/enums/derive_path_type_enum.dart b/lib/utilities/enums/derive_path_type_enum.dart index 4dcaef022..8981cf1c3 100644 --- a/lib/utilities/enums/derive_path_type_enum.dart +++ b/lib/utilities/enums/derive_path_type_enum.dart @@ -8,8 +8,7 @@ * */ -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import '../../models/isar/models/blockchain_data/address.dart'; enum DerivePathType { bip44, @@ -45,49 +44,3 @@ enum DerivePathType { } } } - -extension DerivePathTypeExt on DerivePathType { - static DerivePathType primaryFor(Coin coin) { - switch (coin) { - case Coin.bitcoincash: - case Coin.bitcoincashTestnet: - case Coin.dogecoin: - case Coin.dogecoinTestNet: - case Coin.firo: - case Coin.firoTestNet: - return DerivePathType.bip44; - - case Coin.bitcoin: - case Coin.bitcoinTestNet: - case Coin.litecoin: - case Coin.litecoinTestNet: - case Coin.namecoin: - case Coin.particl: - case Coin.peercoin: - case Coin.peercoinTestNet: - return DerivePathType.bip84; - - case Coin.eCash: - return DerivePathType.eCash44; - - case Coin.ethereum: // TODO: do we need something here? - return DerivePathType.eth; - - case Coin.solana: - return DerivePathType.solana; - - case Coin.bitcoinFrost: - case Coin.bitcoinFrostTestNet: - case Coin.epicCash: - case Coin.monero: - case Coin.wownero: - case Coin.nano: - case Coin.banano: - case Coin.stellar: - case Coin.stellarTestnet: - case Coin.tezos: // TODO: Is this true? - throw UnsupportedError( - "$coin does not use bitcoin style derivation paths"); - } - } -} diff --git a/lib/utilities/eth_commons.dart b/lib/utilities/eth_commons.dart index f6561c8d5..b7f936c58 100644 --- a/lib/utilities/eth_commons.dart +++ b/lib/utilities/eth_commons.dart @@ -12,8 +12,8 @@ import 'package:bip32/bip32.dart' as bip32; import 'package:bip39/bip39.dart' as bip39; import 'package:decimal/decimal.dart'; import "package:hex/hex.dart"; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import '../wallets/crypto_currency/coins/ethereum.dart'; +import '../wallets/crypto_currency/crypto_currency.dart'; class GasTracker { final Decimal average; @@ -37,7 +37,8 @@ class GasTracker { }); factory GasTracker.fromJson(Map json) { - final targetTime = Constants.targetBlockTimeInSeconds(Coin.ethereum); + final targetTime = + Ethereum(CryptoCurrencyNetwork.main).targetBlockTimeSeconds; return GasTracker( fast: Decimal.parse(json["FastGasPrice"].toString()), average: Decimal.parse(json["ProposeGasPrice"].toString()), diff --git a/lib/utilities/extensions/impl/contract_abi.dart b/lib/utilities/extensions/impl/contract_abi.dart index ad091bb18..f34e33970 100644 --- a/lib/utilities/extensions/impl/contract_abi.dart +++ b/lib/utilities/extensions/impl/contract_abi.dart @@ -10,7 +10,7 @@ import 'dart:convert'; -import 'package:stackwallet/utilities/logger.dart'; +import '../../logger.dart'; import 'package:web3dart/web3dart.dart'; extension ContractAbiExtensions on ContractAbi { diff --git a/lib/utilities/extensions/impl/gradient.dart b/lib/utilities/extensions/impl/gradient.dart index 1e1058de5..6efb36e88 100644 --- a/lib/utilities/extensions/impl/gradient.dart +++ b/lib/utilities/extensions/impl/gradient.dart @@ -9,7 +9,7 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/utilities/extensions/impl/string.dart'; +import 'string.dart'; extension GradientExt on Gradient { static Gradient fromJson(Map json) { diff --git a/lib/utilities/extensions/impl/string.dart b/lib/utilities/extensions/impl/string.dart index 3b214205d..d3e50fa78 100644 --- a/lib/utilities/extensions/impl/string.dart +++ b/lib/utilities/extensions/impl/string.dart @@ -14,7 +14,7 @@ import 'dart:typed_data'; import 'package:dart_bs58/dart_bs58.dart'; import 'package:dart_bs58check/dart_bs58check.dart'; import 'package:hex/hex.dart'; -import 'package:stackwallet/utilities/extensions/extensions.dart'; +import '../extensions.dart'; extension StringExtensions on String { Uint8List get toUint8ListFromUtf8 => Uint8List.fromList(utf8.encode(this)); diff --git a/lib/utilities/featured_paynyms.dart b/lib/utilities/featured_paynyms.dart index a5231144d..83b6c7281 100644 --- a/lib/utilities/featured_paynyms.dart +++ b/lib/utilities/featured_paynyms.dart @@ -8,6 +8,8 @@ * */ +import '../app_config.dart'; + abstract class FeaturedPaynyms { // TODO: replace with actual value // static const String samouraiWalletDevFund = @@ -16,7 +18,7 @@ abstract class FeaturedPaynyms { "PM8TJdQcNk27JpxGRtNR7Hnh8VkJk4Nf17BthLx89fM3iX3UL2YshyaiTAvKgTCVvpgsAgY1DbojkAaUd3Rcn48NEn4uUBuqkaSddgKL8TPAAEQXNuE6"; static Map get featured => { - "Stack Wallet": stackWallet, + AppConfig.appName: stackWallet, // "Samourai Wallet Dev Fund": samouraiWalletDevFund, }; } diff --git a/lib/utilities/flutter_secure_storage_interface.dart b/lib/utilities/flutter_secure_storage_interface.dart index a1d159c6b..26adefaaa 100644 --- a/lib/utilities/flutter_secure_storage_interface.dart +++ b/lib/utilities/flutter_secure_storage_interface.dart @@ -11,8 +11,8 @@ import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:isar/isar.dart'; import 'package:stack_wallet_backup/secure_storage.dart'; -import 'package:stackwallet/models/isar/models/encrypted_string_value.dart'; -import 'package:stackwallet/utilities/stack_file_system.dart'; +import '../models/isar/models/encrypted_string_value.dart'; +import 'stack_file_system.dart'; abstract class SecureStorageInterface { dynamic get store; diff --git a/lib/utilities/format.dart b/lib/utilities/format.dart index 216be7099..b11e98e1e 100644 --- a/lib/utilities/format.dart +++ b/lib/utilities/format.dart @@ -10,8 +10,8 @@ import 'dart:typed_data'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/backup_frequency_type.dart'; +import 'constants.dart'; +import 'enums/backup_frequency_type.dart'; abstract class Format { static String shorten(String value, int beginCount, int endCount) { diff --git a/lib/utilities/git_status.dart b/lib/utilities/git_status.dart new file mode 100644 index 000000000..818660427 --- /dev/null +++ b/lib/utilities/git_status.dart @@ -0,0 +1,209 @@ +import 'dart:convert'; + +import 'package:flutter/material.dart'; +import 'package:flutter_libepiccash/git_versions.dart' as epic_versions; +import 'package:flutter_libmonero/git_versions.dart' as monero_versions; +import 'package:http/http.dart'; +import 'package:lelantus/git_versions.dart' as firo_versions; + +import '../../../themes/stack_colors.dart'; +import '../../../utilities/logger.dart'; +import '../../../utilities/text_styles.dart'; +import '../app_config.dart'; + +const kGithubAPI = "https://api.github.com"; +const kGithubSearch = "/search/commits"; +const kGithubHead = "/repos"; + +enum CommitStatus { isHead, isOldCommit, notACommit, notLoaded } + +abstract class GitStatus { + static String get firoCommit => firo_versions.getPluginVersion(); + static String get epicCashCommit => epic_versions.getPluginVersion(); + static String get moneroCommit => monero_versions.getPluginVersion(); + + static String get appCommitHash => AppConfig.commitHash; + + static CommitStatus? _cachedFiroStatus; + static Future getFiroCommitStatus() async { + if (_cachedFiroStatus != null) { + return _cachedFiroStatus!; + } + + final List results = await Future.wait([ + _doesCommitExist("cypherstack", "flutter_liblelantus", firoCommit), + _isHeadCommit("cypherstack", "flutter_liblelantus", "main", firoCommit), + ]); + + final commitExists = results[0]; + final commitIsHead = results[1]; + + if (commitExists && commitIsHead) { + _cachedFiroStatus = CommitStatus.isHead; + } else if (commitExists) { + _cachedFiroStatus = CommitStatus.isOldCommit; + } else { + _cachedFiroStatus = CommitStatus.notACommit; + } + + return _cachedFiroStatus!; + } + + static CommitStatus? _cachedEpicStatus; + static Future getEpicCommitStatus() async { + if (_cachedEpicStatus != null) { + return _cachedEpicStatus!; + } + + final List results = await Future.wait([ + _doesCommitExist("cypherstack", "flutter_libepiccash", epicCashCommit), + _isHeadCommit( + "cypherstack", + "flutter_libepiccash", + "main", + epicCashCommit, + ), + ]); + + final commitExists = results[0]; + final commitIsHead = results[1]; + + if (commitExists && commitIsHead) { + _cachedEpicStatus = CommitStatus.isHead; + } else if (commitExists) { + _cachedEpicStatus = CommitStatus.isOldCommit; + } else { + _cachedEpicStatus = CommitStatus.notACommit; + } + + return _cachedEpicStatus!; + } + + static CommitStatus? _cachedMoneroStatus; + static Future getMoneroCommitStatus() async { + if (_cachedMoneroStatus != null) { + return _cachedMoneroStatus!; + } + + final List results = await Future.wait([ + _doesCommitExist("cypherstack", "flutter_libmonero", moneroCommit), + _isHeadCommit("cypherstack", "flutter_libmonero", "main", moneroCommit), + ]); + + final commitExists = results[0]; + final commitIsHead = results[1]; + + if (commitExists && commitIsHead) { + _cachedMoneroStatus = CommitStatus.isHead; + } else if (commitExists) { + _cachedMoneroStatus = CommitStatus.isOldCommit; + } else { + _cachedMoneroStatus = CommitStatus.notACommit; + } + + return _cachedMoneroStatus!; + } + + static TextStyle styleForStatus(CommitStatus status, BuildContext context) { + final Color color; + switch (status) { + case CommitStatus.isHead: + color = Theme.of( + context, + ).extension()!.accentColorGreen; + break; + case CommitStatus.isOldCommit: + color = Theme.of( + context, + ).extension()!.accentColorYellow; + break; + case CommitStatus.notACommit: + color = Theme.of( + context, + ).extension()!.accentColorRed; + break; + default: + return STextStyles.itemSubtitle( + context, + ); + } + + return STextStyles.itemSubtitle( + context, + ).copyWith(color: color); + } + + static Future _doesCommitExist( + String organization, + String project, + String commit, + ) async { + Logging.instance.log("doesCommitExist", level: LogLevel.Info); + final Client client = Client(); + try { + final uri = Uri.parse( + "$kGithubAPI$kGithubHead/$organization/$project/commits/$commit", + ); + + final commitQuery = await client.get( + uri, + headers: {'Content-Type': 'application/json'}, + ); + + final response = jsonDecode(commitQuery.body.toString()); + Logging.instance.log( + "doesCommitExist $project $commit $response", + level: LogLevel.Info, + ); + bool isThereCommit; + try { + isThereCommit = response['sha'] == commit; + Logging.instance + .log("isThereCommit $isThereCommit", level: LogLevel.Info); + return isThereCommit; + } catch (e, s) { + return false; + } + } catch (e, s) { + Logging.instance.log("$e $s", level: LogLevel.Error); + return false; + } + } + + static Future _isHeadCommit( + String organization, + String project, + String branch, + String commit, + ) async { + Logging.instance.log("doesCommitExist", level: LogLevel.Info); + final Client client = Client(); + try { + final uri = Uri.parse( + "$kGithubAPI$kGithubHead/$organization/$project/commits/$branch", + ); + + final commitQuery = await client.get( + uri, + headers: {'Content-Type': 'application/json'}, + ); + + final response = jsonDecode(commitQuery.body.toString()); + Logging.instance.log( + "isHeadCommit $project $commit $branch $response", + level: LogLevel.Info, + ); + bool isHead; + try { + isHead = response['sha'] == commit; + Logging.instance.log("isHead $isHead", level: LogLevel.Info); + return isHead; + } catch (e, s) { + return false; + } + } catch (e, s) { + Logging.instance.log("$e $s", level: LogLevel.Error); + return false; + } + } +} diff --git a/lib/utilities/logger.dart b/lib/utilities/logger.dart index 7eb6095de..9574db009 100644 --- a/lib/utilities/logger.dart +++ b/lib/utilities/logger.dart @@ -14,9 +14,9 @@ import 'dart:io'; import 'package:flutter/foundation.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/isar/models/log.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/log_level_enum.dart'; +import '../models/isar/models/log.dart'; +import 'constants.dart'; +import 'enums/log_level_enum.dart'; export 'enums/log_level_enum.dart'; diff --git a/lib/utilities/paynym_is_api.dart b/lib/utilities/paynym_is_api.dart index 3d02e67d1..1ed94d751 100644 --- a/lib/utilities/paynym_is_api.dart +++ b/lib/utilities/paynym_is_api.dart @@ -10,15 +10,15 @@ import 'dart:convert'; -import 'package:stackwallet/models/paynym/created_paynym.dart'; -import 'package:stackwallet/models/paynym/paynym_account.dart'; -import 'package:stackwallet/models/paynym/paynym_claim.dart'; -import 'package:stackwallet/models/paynym/paynym_follow.dart'; -import 'package:stackwallet/models/paynym/paynym_response.dart'; -import 'package:stackwallet/models/paynym/paynym_unfollow.dart'; -import 'package:stackwallet/networking/http.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/utilities/prefs.dart'; +import '../models/paynym/created_paynym.dart'; +import '../models/paynym/paynym_account.dart'; +import '../models/paynym/paynym_claim.dart'; +import '../models/paynym/paynym_follow.dart'; +import '../models/paynym/paynym_response.dart'; +import '../models/paynym/paynym_unfollow.dart'; +import '../networking/http.dart'; +import '../services/tor_service.dart'; +import 'prefs.dart'; import 'package:tuple/tuple.dart'; // todo: better error message parsing (from response itself?) diff --git a/lib/utilities/prefs.dart b/lib/utilities/prefs.dart index 07726bdf1..abd236416 100644 --- a/lib/utilities/prefs.dart +++ b/lib/utilities/prefs.dart @@ -11,16 +11,17 @@ import 'dart:async'; import 'package:flutter/cupertino.dart'; -import 'package:stackwallet/db/hive/db.dart'; -import 'package:stackwallet/services/event_bus/events/global/tor_status_changed_event.dart'; -import 'package:stackwallet/services/event_bus/global_event_bus.dart'; -import 'package:stackwallet/utilities/amount/amount_unit.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/backup_frequency_type.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/languages_enum.dart'; -import 'package:stackwallet/utilities/enums/sync_type_enum.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/cash_fusion_interface.dart'; +import '../db/hive/db.dart'; +import '../services/event_bus/events/global/tor_status_changed_event.dart'; +import '../services/event_bus/global_event_bus.dart'; +import '../app_config.dart'; +import 'amount/amount_unit.dart'; +import 'constants.dart'; +import 'enums/backup_frequency_type.dart'; +import 'enums/languages_enum.dart'; +import 'enums/sync_type_enum.dart'; +import '../wallets/crypto_currency/crypto_currency.dart'; +import '../wallets/wallet/wallet_mixin_interfaces/cash_fusion_interface.dart'; import 'package:uuid/uuid.dart'; class Prefs extends ChangeNotifier { @@ -82,9 +83,10 @@ class Prefs extends ChangeNotifier { set lastUnlockedTimeout(int lastUnlockedTimeout) { if (_lastUnlockedTimeout != lastUnlockedTimeout) { DB.instance.put( - boxName: DB.boxNamePrefs, - key: "lastUnlockedTimeout", - value: lastUnlockedTimeout); + boxName: DB.boxNamePrefs, + key: "lastUnlockedTimeout", + value: lastUnlockedTimeout, + ); _lastUnlockedTimeout = lastUnlockedTimeout; notifyListeners(); } @@ -92,7 +94,9 @@ class Prefs extends ChangeNotifier { Future _getLastUnlockedTimeout() async { return (DB.instance.get( - boxName: DB.boxNamePrefs, key: "lastUnlockedTimeout")) as int? ?? + boxName: DB.boxNamePrefs, + key: "lastUnlockedTimeout", + )) as int? ?? 60; } @@ -105,7 +109,10 @@ class Prefs extends ChangeNotifier { set lastUnlocked(int lastUnlocked) { if (_lastUnlocked != lastUnlocked) { DB.instance.put( - boxName: DB.boxNamePrefs, key: "lastUnlocked", value: lastUnlocked); + boxName: DB.boxNamePrefs, + key: "lastUnlocked", + value: lastUnlocked, + ); _lastUnlocked = lastUnlocked; notifyListeners(); } @@ -113,7 +120,9 @@ class Prefs extends ChangeNotifier { Future _getLastUnlocked() async { return await DB.instance.get( - boxName: DB.boxNamePrefs, key: "lastUnlocked") as int? ?? + boxName: DB.boxNamePrefs, + key: "lastUnlocked", + ) as int? ?? 0; } @@ -130,15 +139,18 @@ class Prefs extends ChangeNotifier { _currentNotificationId = 0; } await DB.instance.put( - boxName: DB.boxNamePrefs, - key: "currentNotificationId", - value: _currentNotificationId); + boxName: DB.boxNamePrefs, + key: "currentNotificationId", + value: _currentNotificationId, + ); notifyListeners(); } Future _getCurrentNotificationIndex() async { return await DB.instance.get( - boxName: DB.boxNamePrefs, key: "currentNotificationId") as int? ?? + boxName: DB.boxNamePrefs, + key: "currentNotificationId", + ) as int? ?? 0; } @@ -151,9 +163,10 @@ class Prefs extends ChangeNotifier { set walletIdsSyncOnStartup(List walletIdsSyncOnStartup) { if (_walletIdsSyncOnStartup != walletIdsSyncOnStartup) { DB.instance.put( - boxName: DB.boxNamePrefs, - key: "walletIdsSyncOnStartup", - value: walletIdsSyncOnStartup); + boxName: DB.boxNamePrefs, + key: "walletIdsSyncOnStartup", + value: walletIdsSyncOnStartup, + ); _walletIdsSyncOnStartup = walletIdsSyncOnStartup; notifyListeners(); } @@ -161,7 +174,9 @@ class Prefs extends ChangeNotifier { Future> _getWalletIdsSyncOnStartup() async { final list = await DB.instance.get( - boxName: DB.boxNamePrefs, key: "walletIdsSyncOnStartup") as List? ?? + boxName: DB.boxNamePrefs, + key: "walletIdsSyncOnStartup", + ) as List? ?? []; return List.from(list); } @@ -175,9 +190,10 @@ class Prefs extends ChangeNotifier { set syncType(SyncingType syncType) { if (_syncType != syncType) { DB.instance.put( - boxName: DB.boxNamePrefs, - key: "syncTypeIndex", - value: syncType.index); + boxName: DB.boxNamePrefs, + key: "syncTypeIndex", + value: syncType.index, + ); _syncType = syncType; notifyListeners(); } @@ -185,7 +201,9 @@ class Prefs extends ChangeNotifier { Future _getSyncType() async { final int index = await DB.instance.get( - boxName: DB.boxNamePrefs, key: "syncTypeIndex") as int? ?? + boxName: DB.boxNamePrefs, + key: "syncTypeIndex", + ) as int? ?? SyncingType.allWalletsOnStartup.index; return SyncingType.values[index]; } @@ -199,7 +217,10 @@ class Prefs extends ChangeNotifier { set wifiOnly(bool wifiOnly) { if (_wifiOnly != wifiOnly) { DB.instance.put( - boxName: DB.boxNamePrefs, key: "wifiOnly", value: wifiOnly); + boxName: DB.boxNamePrefs, + key: "wifiOnly", + value: wifiOnly, + ); _wifiOnly = wifiOnly; notifyListeners(); } @@ -220,9 +241,10 @@ class Prefs extends ChangeNotifier { set showFavoriteWallets(bool showFavoriteWallets) { if (_showFavoriteWallets != showFavoriteWallets) { DB.instance.put( - boxName: DB.boxNamePrefs, - key: "showFavoriteWallets", - value: showFavoriteWallets); + boxName: DB.boxNamePrefs, + key: "showFavoriteWallets", + value: showFavoriteWallets, + ); _showFavoriteWallets = showFavoriteWallets; notifyListeners(); } @@ -230,7 +252,9 @@ class Prefs extends ChangeNotifier { Future _getShowFavoriteWallets() async { return await DB.instance.get( - boxName: DB.boxNamePrefs, key: "showFavoriteWallets") as bool? ?? + boxName: DB.boxNamePrefs, + key: "showFavoriteWallets", + ) as bool? ?? true; } @@ -243,7 +267,10 @@ class Prefs extends ChangeNotifier { set language(String newLanguage) { if (_language != newLanguage) { DB.instance.put( - boxName: DB.boxNamePrefs, key: "language", value: newLanguage); + boxName: DB.boxNamePrefs, + key: "language", + value: newLanguage, + ); _language = newLanguage; notifyListeners(); } @@ -251,7 +278,9 @@ class Prefs extends ChangeNotifier { Future _getPreferredLanguage() async { return await DB.instance.get( - boxName: DB.boxNamePrefs, key: "language") as String? ?? + boxName: DB.boxNamePrefs, + key: "language", + ) as String? ?? Language.englishUS.description; } @@ -264,7 +293,10 @@ class Prefs extends ChangeNotifier { set currency(String newCurrency) { if (currency != newCurrency) { DB.instance.put( - boxName: DB.boxNamePrefs, key: "currency", value: newCurrency); + boxName: DB.boxNamePrefs, + key: "currency", + value: newCurrency, + ); _currency = newCurrency; notifyListeners(); } @@ -272,7 +304,9 @@ class Prefs extends ChangeNotifier { Future _getPreferredCurrency() async { return await DB.instance.get( - boxName: DB.boxNamePrefs, key: "currency") as String? ?? + boxName: DB.boxNamePrefs, + key: "currency", + ) as String? ?? "USD"; } @@ -326,7 +360,10 @@ class Prefs extends ChangeNotifier { set randomizePIN(bool randomizePIN) { if (_randomizePIN != randomizePIN) { DB.instance.put( - boxName: DB.boxNamePrefs, key: "randomizePIN", value: randomizePIN); + boxName: DB.boxNamePrefs, + key: "randomizePIN", + value: randomizePIN, + ); _randomizePIN = randomizePIN; notifyListeners(); } @@ -334,7 +371,9 @@ class Prefs extends ChangeNotifier { Future _getRandomizePIN() async { return await DB.instance.get( - boxName: DB.boxNamePrefs, key: "randomizePIN") as bool? ?? + boxName: DB.boxNamePrefs, + key: "randomizePIN", + ) as bool? ?? false; } @@ -347,7 +386,10 @@ class Prefs extends ChangeNotifier { set useBiometrics(bool useBiometrics) { if (_useBiometrics != useBiometrics) { DB.instance.put( - boxName: DB.boxNamePrefs, key: "useBiometrics", value: useBiometrics); + boxName: DB.boxNamePrefs, + key: "useBiometrics", + value: useBiometrics, + ); _useBiometrics = useBiometrics; notifyListeners(); } @@ -355,7 +397,9 @@ class Prefs extends ChangeNotifier { Future _getUseBiometrics() async { return await DB.instance.get( - boxName: DB.boxNamePrefs, key: "useBiometrics") as bool? ?? + boxName: DB.boxNamePrefs, + key: "useBiometrics", + ) as bool? ?? false; } @@ -389,7 +433,10 @@ class Prefs extends ChangeNotifier { set familiarity(int familiarity) { if (_familiarity != familiarity) { DB.instance.put( - boxName: DB.boxNamePrefs, key: "familiarity", value: familiarity); + boxName: DB.boxNamePrefs, + key: "familiarity", + value: familiarity, + ); _familiarity = familiarity; notifyListeners(); } @@ -397,7 +444,9 @@ class Prefs extends ChangeNotifier { Future _getHasFamiliarity() async { return await DB.instance.get( - boxName: DB.boxNamePrefs, key: "familiarity") as int? ?? + boxName: DB.boxNamePrefs, + key: "familiarity", + ) as int? ?? 0; } @@ -436,9 +485,10 @@ class Prefs extends ChangeNotifier { set showTestNetCoins(bool showTestNetCoins) { if (_showTestNetCoins != showTestNetCoins) { DB.instance.put( - boxName: DB.boxNamePrefs, - key: "showTestNetCoins", - value: showTestNetCoins); + boxName: DB.boxNamePrefs, + key: "showTestNetCoins", + value: showTestNetCoins, + ); _showTestNetCoins = showTestNetCoins; notifyListeners(); } @@ -446,7 +496,9 @@ class Prefs extends ChangeNotifier { Future _getShowTestNetCoins() async { return await DB.instance.get( - boxName: DB.boxNamePrefs, key: "showTestNetCoins") as bool? ?? + boxName: DB.boxNamePrefs, + key: "showTestNetCoins", + ) as bool? ?? false; } @@ -460,9 +512,10 @@ class Prefs extends ChangeNotifier { if (_isAutoBackupEnabled != isAutoBackupEnabled) { DB.instance .put( - boxName: DB.boxNamePrefs, - key: "isAutoBackupEnabled", - value: isAutoBackupEnabled) + boxName: DB.boxNamePrefs, + key: "isAutoBackupEnabled", + value: isAutoBackupEnabled, + ) .then((_) { _isAutoBackupEnabled = isAutoBackupEnabled; notifyListeners(); @@ -472,7 +525,9 @@ class Prefs extends ChangeNotifier { Future _getIsAutoBackupEnabled() async { return await DB.instance.get( - boxName: DB.boxNamePrefs, key: "isAutoBackupEnabled") as bool? ?? + boxName: DB.boxNamePrefs, + key: "isAutoBackupEnabled", + ) as bool? ?? false; } @@ -485,9 +540,10 @@ class Prefs extends ChangeNotifier { set autoBackupLocation(String? autoBackupLocation) { if (this.autoBackupLocation != autoBackupLocation) { DB.instance.put( - boxName: DB.boxNamePrefs, - key: "autoBackupLocation", - value: autoBackupLocation); + boxName: DB.boxNamePrefs, + key: "autoBackupLocation", + value: autoBackupLocation, + ); _autoBackupLocation = autoBackupLocation; notifyListeners(); } @@ -495,7 +551,9 @@ class Prefs extends ChangeNotifier { Future _getAutoBackupLocation() async { return await DB.instance.get( - boxName: DB.boxNamePrefs, key: "autoBackupLocation") as String?; + boxName: DB.boxNamePrefs, + key: "autoBackupLocation", + ) as String?; } // auto backup frequency type @@ -510,21 +568,24 @@ class Prefs extends ChangeNotifier { switch (backupFrequencyType) { case BackupFrequencyType.everyTenMinutes: DB.instance.put( - boxName: DB.boxNamePrefs, - key: "backupFrequencyType", - value: "10Min"); + boxName: DB.boxNamePrefs, + key: "backupFrequencyType", + value: "10Min", + ); break; case BackupFrequencyType.everyAppStart: DB.instance.put( - boxName: DB.boxNamePrefs, - key: "backupFrequencyType", - value: "onStart"); + boxName: DB.boxNamePrefs, + key: "backupFrequencyType", + value: "onStart", + ); break; case BackupFrequencyType.afterClosingAWallet: DB.instance.put( - boxName: DB.boxNamePrefs, - key: "backupFrequencyType", - value: "onWalletClose"); + boxName: DB.boxNamePrefs, + key: "backupFrequencyType", + value: "onWalletClose", + ); break; } _backupFrequencyType = backupFrequencyType; @@ -534,7 +595,9 @@ class Prefs extends ChangeNotifier { Future _getBackupFrequencyType() async { String? rate = await DB.instance.get( - boxName: DB.boxNamePrefs, key: "backupFrequencyType") as String?; + boxName: DB.boxNamePrefs, + key: "backupFrequencyType", + ) as String?; rate ??= "10Min"; switch (rate) { case "10Min": @@ -557,9 +620,10 @@ class Prefs extends ChangeNotifier { set lastAutoBackup(DateTime? lastAutoBackup) { if (this.lastAutoBackup != lastAutoBackup) { DB.instance.put( - boxName: DB.boxNamePrefs, - key: "lastAutoBackup", - value: lastAutoBackup); + boxName: DB.boxNamePrefs, + key: "lastAutoBackup", + value: lastAutoBackup, + ); _lastAutoBackup = lastAutoBackup; notifyListeners(); } @@ -567,7 +631,9 @@ class Prefs extends ChangeNotifier { Future _getLastAutoBackup() async { return await DB.instance.get( - boxName: DB.boxNamePrefs, key: "autoBackupFileUri") as DateTime?; + boxName: DB.boxNamePrefs, + key: "autoBackupFileUri", + ) as DateTime?; } // auto backup @@ -580,9 +646,10 @@ class Prefs extends ChangeNotifier { if (_hideBlockExplorerWarning != hideBlockExplorerWarning) { DB.instance .put( - boxName: DB.boxNamePrefs, - key: "hideBlockExplorerWarning", - value: hideBlockExplorerWarning) + boxName: DB.boxNamePrefs, + key: "hideBlockExplorerWarning", + value: hideBlockExplorerWarning, + ) .then((_) { _hideBlockExplorerWarning = hideBlockExplorerWarning; notifyListeners(); @@ -592,8 +659,9 @@ class Prefs extends ChangeNotifier { Future _getHideBlockExplorerWarning() async { return await DB.instance.get( - boxName: DB.boxNamePrefs, - key: "hideBlockExplorerWarning") as bool? ?? + boxName: DB.boxNamePrefs, + key: "hideBlockExplorerWarning", + ) as bool? ?? false; } @@ -607,9 +675,10 @@ class Prefs extends ChangeNotifier { if (_gotoWalletOnStartup != gotoWalletOnStartup) { DB.instance .put( - boxName: DB.boxNamePrefs, - key: "gotoWalletOnStartup", - value: gotoWalletOnStartup) + boxName: DB.boxNamePrefs, + key: "gotoWalletOnStartup", + value: gotoWalletOnStartup, + ) .then((_) { _gotoWalletOnStartup = gotoWalletOnStartup; notifyListeners(); @@ -619,7 +688,9 @@ class Prefs extends ChangeNotifier { Future _getGotoWalletOnStartup() async { return await DB.instance.get( - boxName: DB.boxNamePrefs, key: "gotoWalletOnStartup") as bool? ?? + boxName: DB.boxNamePrefs, + key: "gotoWalletOnStartup", + ) as bool? ?? false; } @@ -632,9 +703,10 @@ class Prefs extends ChangeNotifier { set startupWalletId(String? startupWalletId) { if (this.startupWalletId != startupWalletId) { DB.instance.put( - boxName: DB.boxNamePrefs, - key: "startupWalletId", - value: startupWalletId); + boxName: DB.boxNamePrefs, + key: "startupWalletId", + value: startupWalletId, + ); _startupWalletId = startupWalletId; notifyListeners(); } @@ -642,7 +714,9 @@ class Prefs extends ChangeNotifier { Future _getStartupWalletId() async { return await DB.instance.get( - boxName: DB.boxNamePrefs, key: "startupWalletId") as String?; + boxName: DB.boxNamePrefs, + key: "startupWalletId", + ) as String?; } // incognito mode off by default @@ -655,9 +729,10 @@ class Prefs extends ChangeNotifier { if (_externalCalls != externalCalls) { DB.instance .put( - boxName: DB.boxNamePrefs, - key: "externalCalls", - value: externalCalls) + boxName: DB.boxNamePrefs, + key: "externalCalls", + value: externalCalls, + ) .then((_) { _externalCalls = externalCalls; notifyListeners(); @@ -667,7 +742,9 @@ class Prefs extends ChangeNotifier { Future _getHasExternalCalls() async { return await DB.instance.get( - boxName: DB.boxNamePrefs, key: "externalCalls") as bool? ?? + boxName: DB.boxNamePrefs, + key: "externalCalls", + ) as bool? ?? true; } @@ -717,7 +794,10 @@ class Prefs extends ChangeNotifier { Future saveSignupEpoch(int signupEpoch) async { _signupEpoch = signupEpoch; await DB.instance.put( - boxName: DB.boxNamePrefs, key: "signupEpoch", value: _signupEpoch); + boxName: DB.boxNamePrefs, + key: "signupEpoch", + value: _signupEpoch, + ); // notifyListeners(); } @@ -730,9 +810,10 @@ class Prefs extends ChangeNotifier { set enableCoinControl(bool enableCoinControl) { if (_enableCoinControl != enableCoinControl) { DB.instance.put( - boxName: DB.boxNamePrefs, - key: "enableCoinControl", - value: enableCoinControl); + boxName: DB.boxNamePrefs, + key: "enableCoinControl", + value: enableCoinControl, + ); _enableCoinControl = enableCoinControl; notifyListeners(); } @@ -740,7 +821,9 @@ class Prefs extends ChangeNotifier { Future _getEnableCoinControl() async { return await DB.instance.get( - boxName: DB.boxNamePrefs, key: "enableCoinControl") as bool? ?? + boxName: DB.boxNamePrefs, + key: "enableCoinControl", + ) as bool? ?? false; } @@ -753,9 +836,10 @@ class Prefs extends ChangeNotifier { set enableSystemBrightness(bool enableSystemBrightness) { if (_enableSystemBrightness != enableSystemBrightness) { DB.instance.put( - boxName: DB.boxNamePrefs, - key: "enableSystemBrightness", - value: enableSystemBrightness); + boxName: DB.boxNamePrefs, + key: "enableSystemBrightness", + value: enableSystemBrightness, + ); _enableSystemBrightness = enableSystemBrightness; notifyListeners(); } @@ -763,7 +847,9 @@ class Prefs extends ChangeNotifier { Future _getEnableSystemBrightness() async { return await DB.instance.get( - boxName: DB.boxNamePrefs, key: "enableSystemBrightness") as bool? ?? + boxName: DB.boxNamePrefs, + key: "enableSystemBrightness", + ) as bool? ?? false; } @@ -847,15 +933,19 @@ class Prefs extends ChangeNotifier { // coin amount unit settings - final Map _amountUnits = {}; + final Map _amountUnits = {}; - AmountUnit amountUnit(Coin coin) => _amountUnits[coin] ?? AmountUnit.normal; + AmountUnit amountUnit(CryptoCurrency coin) => + _amountUnits[coin] ?? AmountUnit.normal; - void updateAmountUnit({required Coin coin, required AmountUnit amountUnit}) { + void updateAmountUnit({ + required CryptoCurrency coin, + required AmountUnit amountUnit, + }) { if (this.amountUnit(coin) != amountUnit) { DB.instance.put( boxName: DB.boxNamePrefs, - key: "amountUnitFor${coin.name}", + key: "amountUnitFor${coin.identifier}", value: amountUnit.index, ); _amountUnits[coin] = amountUnit; @@ -864,10 +954,10 @@ class Prefs extends ChangeNotifier { } Future _setAmountUnits() async { - for (final coin in Coin.values) { + for (final coin in AppConfig.coins) { final unitIndex = await DB.instance.get( boxName: DB.boxNamePrefs, - key: "amountUnitFor${coin.name}", + key: "amountUnitFor${coin.identifier}", ) as int? ?? 0; // 0 is "normal" _amountUnits[coin] = AmountUnit.values[unitIndex]; @@ -876,31 +966,35 @@ class Prefs extends ChangeNotifier { // coin precision setting (max decimal places to show) - final Map _amountDecimals = {}; + final Map _amountDecimals = {}; - int maxDecimals(Coin coin) => _amountDecimals[coin] ?? coin.decimals; + int maxDecimals(CryptoCurrency coin) => + _amountDecimals[coin.identifier] ?? coin.fractionDigits; - void updateMaxDecimals({required Coin coin, required int maxDecimals}) { + void updateMaxDecimals({ + required CryptoCurrency coin, + required int maxDecimals, + }) { if (this.maxDecimals(coin) != maxDecimals) { DB.instance.put( boxName: DB.boxNamePrefs, - key: "maxDecimalsFor${coin.name}", + key: "maxDecimalsFor${coin.identifier}", value: maxDecimals, ); - _amountDecimals[coin] = maxDecimals; + _amountDecimals[coin.identifier] = maxDecimals; notifyListeners(); } } Future _setMaxDecimals() async { - for (final coin in Coin.values) { + for (final coin in AppConfig.coins) { final decimals = await DB.instance.get( boxName: DB.boxNamePrefs, - key: "maxDecimalsFor${coin.name}", + key: "maxDecimalsFor${coin.identifier}", ) as int? ?? - (coin.decimals > 18 ? 18 : coin.decimals); + (coin.fractionDigits > 18 ? 18 : coin.fractionDigits); // use some sane max rather than up to 30 that nano uses - _amountDecimals[coin] = decimals; + _amountDecimals[coin.identifier] = decimals; } } @@ -938,22 +1032,23 @@ class Prefs extends ChangeNotifier { // fusion server info - Map _fusionServerInfo = {}; + Map _fusionServerInfo = {}; - FusionInfo getFusionServerInfo(Coin coin) { - return _fusionServerInfo[coin] ?? kFusionServerInfoDefaults[coin]!; + FusionInfo getFusionServerInfo(CryptoCurrency coin) { + return _fusionServerInfo[coin.identifier] ?? + kFusionServerInfoDefaults[coin.identifier]!; } - void setFusionServerInfo(Coin coin, FusionInfo fusionServerInfo) { - if (_fusionServerInfo[coin] != fusionServerInfo) { - _fusionServerInfo[coin] = fusionServerInfo; + void setFusionServerInfo(CryptoCurrency coin, FusionInfo fusionServerInfo) { + if (_fusionServerInfo[coin.identifier] != fusionServerInfo) { + _fusionServerInfo[coin.identifier] = fusionServerInfo; DB.instance.put( boxName: DB.boxNamePrefs, key: "fusionServerInfoMap", value: _fusionServerInfo.map( (key, value) => MapEntry( - key.name, + key, value.toJsonString(), ), ), @@ -962,7 +1057,7 @@ class Prefs extends ChangeNotifier { } } - Future> _getFusionServerInfo() async { + Future> _getFusionServerInfo() async { final map = await DB.instance.get( boxName: DB.boxNamePrefs, key: "fusionServerInfoMap", @@ -974,14 +1069,14 @@ class Prefs extends ChangeNotifier { final actualMap = Map.from(map).map( (key, value) => MapEntry( - coinFromPrettyName(key), + key, FusionInfo.fromJsonString(value), ), ); // legacy bch check - if (actualMap[Coin.bitcoincash] == null || - actualMap[Coin.bitcoincashTestnet] == null) { + if (actualMap["bitcoincash"] == null || + actualMap["bitcoincashTestnet"] == null) { final saved = await DB.instance.get( boxName: DB.boxNamePrefs, key: "fusionServerInfo", @@ -989,15 +1084,15 @@ class Prefs extends ChangeNotifier { if (saved != null) { final bchInfo = FusionInfo.fromJsonString(saved); - actualMap[Coin.bitcoincash] = bchInfo; - actualMap[Coin.bitcoincashTestnet] = bchInfo; + actualMap["bitcoincash"] = bchInfo; + actualMap["bitcoincashTestnet"] = bchInfo; unawaited( DB.instance.put( boxName: DB.boxNamePrefs, key: "fusionServerInfoMap", value: actualMap.map( (key, value) => MapEntry( - key.name, + key, value.toJsonString(), ), ), diff --git a/lib/utilities/show_loading.dart b/lib/utilities/show_loading.dart index e01a86441..1730df83d 100644 --- a/lib/utilities/show_loading.dart +++ b/lib/utilities/show_loading.dart @@ -11,9 +11,9 @@ import 'dart:async'; import 'package:flutter/material.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/widgets/custom_loading_overlay.dart'; +import '../themes/stack_colors.dart'; +import 'logger.dart'; +import '../widgets/custom_loading_overlay.dart'; Future showLoading({ required Future whileFuture, diff --git a/lib/utilities/stack_file_system.dart b/lib/utilities/stack_file_system.dart index 56e55fe40..b5f28e48a 100644 --- a/lib/utilities/stack_file_system.dart +++ b/lib/utilities/stack_file_system.dart @@ -11,40 +11,52 @@ import 'dart:io'; import 'package:path_provider/path_provider.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/util.dart'; + +import '../app_config.dart'; +import 'logger.dart'; +import 'util.dart'; abstract class StackFileSystem { - static String? overrideDir; + static String? _overrideDesktopDirPath; + static bool _overrideDirSet = false; + static void setDesktopOverrideDir(String dirPath) { + if (_overrideDirSet) { + throw Exception( + "Attempted to change StackFileSystem._overrideDir unexpectedly", + ); + } + _overrideDesktopDirPath = dirPath; + _overrideDirSet = true; + } static Future applicationRootDirectory() async { Directory appDirectory; - // if this is changed, the directories in libmonero must also be changed!!!!! - const dirName = "stackwallet"; - // todo: can merge and do same as regular linux home dir? if (Logging.isArmLinux) { appDirectory = await getApplicationDocumentsDirectory(); - appDirectory = Directory("${appDirectory.path}/.$dirName"); + appDirectory = + Directory("${appDirectory.path}/.${AppConfig.appDefaultDataDirName}"); } else if (Platform.isLinux) { - if (overrideDir != null) { - appDirectory = Directory(overrideDir!); + if (_overrideDesktopDirPath != null) { + appDirectory = Directory(_overrideDesktopDirPath!); } else { - appDirectory = Directory("${Platform.environment['HOME']}/.$dirName"); + appDirectory = Directory( + "${Platform.environment['HOME']}/.${AppConfig.appDefaultDataDirName}"); } } else if (Platform.isWindows) { - if (overrideDir != null) { - appDirectory = Directory(overrideDir!); + if (_overrideDesktopDirPath != null) { + appDirectory = Directory(_overrideDesktopDirPath!); } else { appDirectory = await getApplicationSupportDirectory(); } } else if (Platform.isMacOS) { - if (overrideDir != null) { - appDirectory = Directory(overrideDir!); + if (_overrideDesktopDirPath != null) { + appDirectory = Directory(_overrideDesktopDirPath!); } else { appDirectory = await getLibraryDirectory(); - appDirectory = Directory("${appDirectory.path}/$dirName"); + appDirectory = Directory( + "${appDirectory.path}/${AppConfig.appDefaultDataDirName}"); } } else if (Platform.isIOS) { // todo: check if we need different behaviour here diff --git a/lib/utilities/test_epic_box_connection.dart b/lib/utilities/test_epic_box_connection.dart index 600438451..471d6fcce 100644 --- a/lib/utilities/test_epic_box_connection.dart +++ b/lib/utilities/test_epic_box_connection.dart @@ -10,11 +10,11 @@ import 'dart:convert'; -import 'package:stackwallet/networking/http.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/prefs.dart'; +import '../networking/http.dart'; +import '../pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart'; +import '../services/tor_service.dart'; +import 'logger.dart'; +import 'prefs.dart'; Future _testEpicBoxNodeConnection(Uri uri) async { HTTP client = HTTP(); diff --git a/lib/utilities/test_monero_node_connection.dart b/lib/utilities/test_monero_node_connection.dart index f63ff57fb..d6fe05cd5 100644 --- a/lib/utilities/test_monero_node_connection.dart +++ b/lib/utilities/test_monero_node_connection.dart @@ -12,11 +12,11 @@ import 'dart:convert'; import 'dart:io'; import 'package:flutter/material.dart'; -import 'package:stackwallet/utilities/format.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import 'format.dart'; +import 'logger.dart'; +import '../widgets/desktop/primary_button.dart'; +import '../widgets/desktop/secondary_button.dart'; +import '../widgets/stack_dialog.dart'; class MoneroNodeConnectionResponse { final X509Certificate? cert; diff --git a/lib/utilities/test_node_connection.dart b/lib/utilities/test_node_connection.dart new file mode 100644 index 000000000..c47fb49ac --- /dev/null +++ b/lib/utilities/test_node_connection.dart @@ -0,0 +1,198 @@ +import 'dart:async'; + +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:solana/solana.dart'; +import '../pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart'; +import '../providers/global/prefs_provider.dart'; +import '../services/tor_service.dart'; +import 'connection_check/electrum_connection_check.dart'; +import 'logger.dart'; +import 'test_epic_box_connection.dart'; +import 'test_eth_node_connection.dart'; +import 'test_monero_node_connection.dart'; +import 'test_stellar_node_connection.dart'; +import '../wallets/api/tezos/tezos_rpc_api.dart'; +import '../wallets/crypto_currency/coins/bitcoin_frost.dart'; +import '../wallets/crypto_currency/coins/epiccash.dart'; +import '../wallets/crypto_currency/coins/ethereum.dart'; +import '../wallets/crypto_currency/coins/solana.dart'; +import '../wallets/crypto_currency/coins/stellar.dart'; +import '../wallets/crypto_currency/coins/tezos.dart'; +import '../wallets/crypto_currency/crypto_currency.dart'; +import '../wallets/crypto_currency/interfaces/electrumx_currency_interface.dart'; +import '../wallets/crypto_currency/intermediate/cryptonote_currency.dart'; +import '../wallets/crypto_currency/intermediate/nano_currency.dart'; + +Future _xmrHelper( + NodeFormData nodeFormData, + BuildContext context, + void Function(NodeFormData)? onSuccess, +) async { + final data = nodeFormData; + final url = data.host!; + final port = data.port; + + final uri = Uri.parse(url); + + final String path = uri.path.isEmpty ? "/json_rpc" : uri.path; + + final uriString = "${uri.scheme}://${uri.host}:${port ?? 0}$path"; + + final response = await testMoneroNodeConnection( + Uri.parse(uriString), + false, + ); + + if (response.cert != null) { + if (context.mounted) { + final shouldAllowBadCert = await showBadX509CertificateDialog( + response.cert!, + response.url!, + response.port!, + context, + ); + + if (shouldAllowBadCert) { + final response = + await testMoneroNodeConnection(Uri.parse(uriString), true); + onSuccess?.call(data..host = url); + return response.success; + } + } + } else { + onSuccess?.call(data..host = url); + return response.success; + } + + return false; +} + +// TODO: probably pull this into each coin's functionality otherwise updating this separately will get irritating +Future testNodeConnection({ + required BuildContext context, + required NodeFormData nodeFormData, + required CryptoCurrency cryptoCurrency, + required WidgetRef ref, + void Function(NodeFormData)? onSuccess, +}) async { + final formData = nodeFormData; + + bool testPassed = false; + + switch (cryptoCurrency) { + case Epiccash(): + try { + final data = await testEpicNodeConnection(formData); + + if (data != null) { + testPassed = true; + onSuccess?.call(data); + } + } catch (e, s) { + Logging.instance.log("$e\n$s", level: LogLevel.Warning); + } + break; + + case CryptonoteCurrency(): + try { + final url = formData.host!; + final uri = Uri.tryParse(url); + if (uri != null) { + if (!uri.hasScheme) { + // try https first + testPassed = await _xmrHelper( + formData + ..host = "https://$url" + ..useSSL = true, + context, + onSuccess, + ); + + if (testPassed == false) { + // try http + testPassed = await _xmrHelper( + formData + ..host = "http://$url" + ..useSSL = false, + context, + onSuccess, + ); + } + } else { + testPassed = await _xmrHelper( + formData + ..host = url + ..useSSL = true, + context, + onSuccess, + ); + } + } + } catch (e, s) { + Logging.instance.log("$e\n$s", level: LogLevel.Warning); + } + + break; + + case ElectrumXCurrencyInterface(): + case BitcoinFrost(): + try { + testPassed = await checkElectrumServer( + host: formData.host!, + port: formData.port!, + useSSL: formData.useSSL!, + overridePrefs: ref.read(prefsChangeNotifierProvider), + overrideTorService: ref.read(pTorService), + ); + } catch (_) { + testPassed = false; + } + + break; + + case Ethereum(): + try { + testPassed = await testEthNodeConnection(formData.host!); + } catch (_) { + testPassed = false; + } + break; + + case Stellar(): + try { + testPassed = + await testStellarNodeConnection(formData.host!, formData.port!); + } catch (_) {} + break; + + case NanoCurrency(): + //TODO: check network/node + throw UnimplementedError(); + + case Tezos(): + try { + testPassed = await TezosRpcAPI.testNetworkConnection( + nodeInfo: (host: formData.host!, port: formData.port!), + ); + } catch (_) {} + break; + + case Solana(): + try { + RpcClient rpcClient; + if (formData.host!.startsWith("http") || + formData.host!.startsWith("https")) { + rpcClient = RpcClient("${formData.host}:${formData.port}"); + } else { + rpcClient = RpcClient("http://${formData.host}:${formData.port}"); + } + await rpcClient.getEpochInfo().then((value) => testPassed = true); + } catch (_) { + testPassed = false; + } + break; + } + + return testPassed; +} diff --git a/lib/utilities/test_stellar_node_connection.dart b/lib/utilities/test_stellar_node_connection.dart index 73d20a8aa..7b580e85c 100644 --- a/lib/utilities/test_stellar_node_connection.dart +++ b/lib/utilities/test_stellar_node_connection.dart @@ -1,8 +1,8 @@ import 'dart:convert'; -import 'package:stackwallet/networking/http.dart' as http; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/utilities/prefs.dart'; +import '../networking/http.dart' as http; +import '../services/tor_service.dart'; +import 'prefs.dart'; import 'package:stellar_flutter_sdk/stellar_flutter_sdk.dart'; Future testStellarNodeConnection(String host, int port) async { diff --git a/lib/utilities/text_styles.dart b/lib/utilities/text_styles.dart index 0a7383e9f..2337a6622 100644 --- a/lib/utilities/text_styles.dart +++ b/lib/utilities/text_styles.dart @@ -10,7 +10,7 @@ import 'package:flutter/material.dart'; import 'package:google_fonts/google_fonts.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; +import '../themes/stack_colors.dart'; class STextStyles { static StackColors _theme(BuildContext context) => diff --git a/lib/wallets/api/lelantus_ffi_wrapper.dart b/lib/wallets/api/lelantus_ffi_wrapper.dart index ef70b801f..e6037bedb 100644 --- a/lib/wallets/api/lelantus_ffi_wrapper.dart +++ b/lib/wallets/api/lelantus_ffi_wrapper.dart @@ -2,17 +2,17 @@ import 'package:bip32/bip32.dart'; import 'package:bitcoindart/bitcoindart.dart' as bitcoindart; import 'package:flutter/foundation.dart'; import 'package:lelantus/lelantus.dart' as lelantus; -import 'package:stackwallet/models/isar/models/isar_models.dart' as isar_models; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/models/lelantus_fee_data.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/extensions/impl/string.dart'; -import 'package:stackwallet/utilities/extensions/impl/uint8_list.dart'; -import 'package:stackwallet/utilities/format.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_hd_currency.dart'; -import 'package:stackwallet/wallets/models/tx_data.dart'; +import '../../models/isar/models/isar_models.dart' as isar_models; +import '../../models/isar/models/isar_models.dart'; +import '../../models/lelantus_fee_data.dart'; +import '../../utilities/amount/amount.dart'; +import '../../utilities/extensions/impl/string.dart'; +import '../../utilities/extensions/impl/uint8_list.dart'; +import '../../utilities/format.dart'; +import '../../utilities/logger.dart'; +import '../crypto_currency/crypto_currency.dart'; +import '../crypto_currency/intermediate/bip39_hd_currency.dart'; +import '../models/tx_data.dart'; abstract final class LelantusFfiWrapper { static const MINT_LIMIT = 5001 * 100000000; diff --git a/lib/wallets/api/tezos/tezos_api.dart b/lib/wallets/api/tezos/tezos_api.dart index a798fb01b..754fc17aa 100644 --- a/lib/wallets/api/tezos/tezos_api.dart +++ b/lib/wallets/api/tezos/tezos_api.dart @@ -1,11 +1,11 @@ import 'dart:convert'; -import 'package:stackwallet/networking/http.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/prefs.dart'; -import 'package:stackwallet/wallets/api/tezos/tezos_account.dart'; -import 'package:stackwallet/wallets/api/tezos/tezos_transaction.dart'; +import '../../../networking/http.dart'; +import '../../../services/tor_service.dart'; +import '../../../utilities/logger.dart'; +import '../../../utilities/prefs.dart'; +import 'tezos_account.dart'; +import 'tezos_transaction.dart'; abstract final class TezosAPI { static final HTTP _client = HTTP(); diff --git a/lib/wallets/api/tezos/tezos_rpc_api.dart b/lib/wallets/api/tezos/tezos_rpc_api.dart index d5faa060f..201cd3b9b 100644 --- a/lib/wallets/api/tezos/tezos_rpc_api.dart +++ b/lib/wallets/api/tezos/tezos_rpc_api.dart @@ -1,9 +1,9 @@ import 'dart:convert'; -import 'package:stackwallet/networking/http.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/prefs.dart'; +import '../../../networking/http.dart'; +import '../../../services/tor_service.dart'; +import '../../../utilities/logger.dart'; +import '../../../utilities/prefs.dart'; abstract final class TezosRpcAPI { static final HTTP _client = HTTP(); diff --git a/lib/wallets/crypto_currency/coins/banano.dart b/lib/wallets/crypto_currency/coins/banano.dart index dfae1b78c..2dec17825 100644 --- a/lib/wallets/crypto_currency/coins/banano.dart +++ b/lib/wallets/crypto_currency/coins/banano.dart @@ -1,23 +1,59 @@ import 'package:nanodart/nanodart.dart'; -import 'package:stackwallet/models/node_model.dart'; -import 'package:stackwallet/utilities/default_nodes.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/nano_currency.dart'; +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../../models/node_model.dart'; +import '../../../utilities/default_nodes.dart'; +import '../../../utilities/enums/derive_path_type_enum.dart'; +import '../crypto_currency.dart'; +import '../intermediate/nano_currency.dart'; class Banano extends NanoCurrency { Banano(super.network) { switch (network) { case CryptoCurrencyNetwork.main: - coin = Coin.banano; + _id = "banano"; + _idMain = "banano"; + _name = "Banano"; + _uriScheme = "ban"; + _ticker = "BAN"; default: throw Exception("Unsupported network: $network"); } } + late final String _id; + @override + String get identifier => _id; + + late final String _idMain; + @override + String get mainNetId => _idMain; + + late final String _name; + @override + String get prettyName => _name; + + late final String _uriScheme; + @override + String get uriScheme => _uriScheme; + + late final String _ticker; + @override + String get ticker => _ticker; + + @override + int get fractionDigits => 29; + + @override + BigInt get satsPerCoin => BigInt.parse( + "100000000000000000000000000000", + ); // 1*10^29 + @override int get minConfirms => 1; + @override + AddressType get primaryAddressType => AddressType.banano; + @override String get defaultRepresentative => "ban_1ka1ium4pfue3uxtntqsrib8mumxgazsjf58gidh1xeo5te3whsq8z476goo"; @@ -33,10 +69,10 @@ class Banano extends NanoCurrency { host: "https://kaliumapi.appditto.com/api", port: 443, name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.banano), + id: DefaultNodes.buildId(this), useSSL: true, enabled: true, - coinName: Coin.banano.name, + coinName: identifier, isFailover: true, isDown: false, ); @@ -47,10 +83,19 @@ class Banano extends NanoCurrency { } @override - bool operator ==(Object other) { - return other is Banano && other.network == network; + Uri defaultBlockExplorer(String txid) { + switch (network) { + case CryptoCurrencyNetwork.main: + return Uri.parse("https://www.bananolooker.com/block/$txid"); + default: + throw Exception( + "Unsupported network for defaultBlockExplorer(): $network", + ); + } } @override - int get hashCode => Object.hash(Banano, network); + DerivePathType get primaryDerivePathType => throw UnsupportedError( + "$runtimeType does not use bitcoin style derivation paths", + ); } diff --git a/lib/wallets/crypto_currency/coins/bitcoin.dart b/lib/wallets/crypto_currency/coins/bitcoin.dart index e0126ede1..118d61f24 100644 --- a/lib/wallets/crypto_currency/coins/bitcoin.dart +++ b/lib/wallets/crypto_currency/coins/bitcoin.dart @@ -1,26 +1,53 @@ import 'package:coinlib_flutter/coinlib_flutter.dart' as coinlib; -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/models/node_model.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/default_nodes.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/crypto_currency/interfaces/paynym_currency_interface.dart'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_hd_currency.dart'; +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../../models/node_model.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/default_nodes.dart'; +import '../../../utilities/enums/derive_path_type_enum.dart'; +import '../crypto_currency.dart'; +import '../interfaces/electrumx_currency_interface.dart'; +import '../interfaces/paynym_currency_interface.dart'; +import '../intermediate/bip39_hd_currency.dart'; -class Bitcoin extends Bip39HDCurrency with PaynymCurrencyInterface { +class Bitcoin extends Bip39HDCurrency + with ElectrumXCurrencyInterface, PaynymCurrencyInterface { Bitcoin(super.network) { + _idMain = "bitcoin"; + _uriScheme = "bitcoin"; switch (network) { case CryptoCurrencyNetwork.main: - coin = Coin.bitcoin; + _id = _idMain; + _name = "Bitcoin"; + _ticker = "BTC"; case CryptoCurrencyNetwork.test: - coin = Coin.bitcoinTestNet; + _id = "bitcoinTestNet"; + _name = "tBitcoin"; + _ticker = "tBTC"; default: throw Exception("Unsupported network: $network"); } } + late final String _id; + @override + String get identifier => _id; + + late final String _idMain; + @override + String get mainNetId => _idMain; + + late final String _name; + @override + String get prettyName => _name; + + late final String _uriScheme; + @override + String get uriScheme => _uriScheme; + + late final String _ticker; + @override + String get ticker => _ticker; + @override // change this to change the number of confirms a tx needs in order to show as confirmed int get minConfirms => 1; @@ -194,10 +221,30 @@ class Bitcoin extends Bip39HDCurrency with PaynymCurrencyInterface { NodeModel get defaultNode { switch (network) { case CryptoCurrencyNetwork.main: - return DefaultNodes.bitcoin; + return NodeModel( + host: "bitcoin.stackwallet.com", + port: 50002, + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(this), + useSSL: true, + enabled: true, + coinName: identifier, + isFailover: true, + isDown: false, + ); case CryptoCurrencyNetwork.test: - return DefaultNodes.bitcoinTestnet; + return NodeModel( + host: "bitcoin-testnet.stackwallet.com", + port: 51002, + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(this), + useSSL: true, + enabled: true, + coinName: identifier, + isFailover: true, + isDown: false, + ); default: throw UnimplementedError(); @@ -205,10 +252,43 @@ class Bitcoin extends Bip39HDCurrency with PaynymCurrencyInterface { } @override - bool operator ==(Object other) { - return other is Bitcoin && other.network == network; - } + int get defaultSeedPhraseLength => 12; @override - int get hashCode => Object.hash(Bitcoin, network); + int get fractionDigits => 8; + + @override + bool get hasBuySupport => true; + + @override + bool get hasMnemonicPassphraseSupport => true; + + @override + List get possibleMnemonicLengths => [defaultSeedPhraseLength, 24]; + + @override + AddressType get primaryAddressType => AddressType.p2wpkh; + + @override + BigInt get satsPerCoin => BigInt.from(100000000); + + @override + int get targetBlockTimeSeconds => 600; + + @override + DerivePathType get primaryDerivePathType => DerivePathType.bip84; + + @override + Uri defaultBlockExplorer(String txid) { + switch (network) { + case CryptoCurrencyNetwork.main: + return Uri.parse("https://mempool.space/tx/$txid"); + case CryptoCurrencyNetwork.test: + return Uri.parse("https://mempool.space/testnet/tx/$txid"); + default: + throw Exception( + "Unsupported network for defaultBlockExplorer(): $network", + ); + } + } } diff --git a/lib/wallets/crypto_currency/coins/bitcoin_frost.dart b/lib/wallets/crypto_currency/coins/bitcoin_frost.dart index bd5216350..ed55766c8 100644 --- a/lib/wallets/crypto_currency/coins/bitcoin_frost.dart +++ b/lib/wallets/crypto_currency/coins/bitcoin_frost.dart @@ -1,25 +1,53 @@ import 'dart:typed_data'; -import 'package:stackwallet/models/node_model.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/default_nodes.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_hd_currency.dart'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/frost_currency.dart'; +import 'package:coinlib_flutter/coinlib_flutter.dart' as coinlib; +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../../models/node_model.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/default_nodes.dart'; +import '../../../utilities/enums/derive_path_type_enum.dart'; +import '../crypto_currency.dart'; +import '../intermediate/bip39_hd_currency.dart'; +import '../intermediate/frost_currency.dart'; class BitcoinFrost extends FrostCurrency { BitcoinFrost(super.network) { + _idMain = "bitcoinFrost"; + _uriScheme = "bitcoin"; switch (network) { case CryptoCurrencyNetwork.main: - coin = Coin.bitcoinFrost; + _id = _idMain; + _name = "Bitcoin Frost"; + _ticker = "BTC"; case CryptoCurrencyNetwork.test: - coin = Coin.bitcoinFrostTestNet; + _id = "bitcoinFrostTestNet"; + _name = "tBitcoin Frost"; + _ticker = "tBTC"; default: throw Exception("Unsupported network: $network"); } } + late final String _id; + @override + String get identifier => _id; + + late final String _idMain; + @override + String get mainNetId => _idMain; + + late final String _name; + @override + String get prettyName => _name; + + late final String _uriScheme; + @override + String get uriScheme => _uriScheme; + + late final String _ticker; + @override + String get ticker => _ticker; + @override int get minConfirms => 1; @@ -30,10 +58,30 @@ class BitcoinFrost extends FrostCurrency { NodeModel get defaultNode { switch (network) { case CryptoCurrencyNetwork.main: - return DefaultNodes.bitcoin; + return NodeModel( + host: "bitcoin.stackwallet.com", + port: 50002, + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(this), + useSSL: true, + enabled: true, + coinName: identifier, + isFailover: true, + isDown: false, + ); case CryptoCurrencyNetwork.test: - return DefaultNodes.bitcoinTestnet; + return NodeModel( + host: "bitcoin-testnet.stackwallet.com", + port: 51002, + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(this), + useSSL: true, + enabled: true, + coinName: identifier, + isFailover: true, + isDown: false, + ); default: throw UnimplementedError(); @@ -67,17 +115,89 @@ class BitcoinFrost extends FrostCurrency { } } + coinlib.Network get networkParams { + switch (network) { + case CryptoCurrencyNetwork.main: + return coinlib.Network( + wifPrefix: 0x80, + p2pkhPrefix: 0x00, + p2shPrefix: 0x05, + privHDPrefix: 0x0488ade4, + pubHDPrefix: 0x0488b21e, + bech32Hrp: "bc", + messagePrefix: '\x18Bitcoin Signed Message:\n', + minFee: BigInt.from(1), // TODO [prio=high]. + minOutput: dustLimit.raw, // TODO. + feePerKb: BigInt.from(1), // TODO. + ); + case CryptoCurrencyNetwork.test: + return coinlib.Network( + wifPrefix: 0xef, + p2pkhPrefix: 0x6f, + p2shPrefix: 0xc4, + privHDPrefix: 0x04358394, + pubHDPrefix: 0x043587cf, + bech32Hrp: "tb", + messagePrefix: "\x18Bitcoin Signed Message:\n", + minFee: BigInt.from(1), // TODO [prio=high]. + minOutput: dustLimit.raw, // TODO. + feePerKb: BigInt.from(1), // TODO. + ); + default: + throw Exception("Unsupported network: $network"); + } + } + @override bool validateAddress(String address) { - // TODO: implement validateAddress for frost addresses - return true; + try { + coinlib.Address.fromString(address, networkParams); + return true; + } catch (_) { + return false; + } } @override - bool operator ==(Object other) { - return other is BitcoinFrost && other.network == network; - } + int get defaultSeedPhraseLength => 0; @override - int get hashCode => Object.hash(BitcoinFrost, network); + int get fractionDigits => 8; + + @override + bool get hasBuySupport => false; + + @override + bool get hasMnemonicPassphraseSupport => false; + + @override + List get possibleMnemonicLengths => []; + + @override + AddressType get primaryAddressType => AddressType.frostMS; + + @override + BigInt get satsPerCoin => BigInt.from(100000000); + + @override + int get targetBlockTimeSeconds => 600; + + @override + DerivePathType get primaryDerivePathType => throw UnsupportedError( + "$runtimeType does not use bitcoin style derivation paths", + ); + + @override + Uri defaultBlockExplorer(String txid) { + switch (network) { + case CryptoCurrencyNetwork.main: + return Uri.parse("https://mempool.space/tx/$txid"); + case CryptoCurrencyNetwork.test: + return Uri.parse("https://mempool.space/testnet/tx/$txid"); + default: + throw Exception( + "Unsupported network for defaultBlockExplorer(): $network", + ); + } + } } diff --git a/lib/wallets/crypto_currency/coins/bitcoincash.dart b/lib/wallets/crypto_currency/coins/bitcoincash.dart index 168e0223a..e713dd417 100644 --- a/lib/wallets/crypto_currency/coins/bitcoincash.dart +++ b/lib/wallets/crypto_currency/coins/bitcoincash.dart @@ -4,27 +4,54 @@ import 'package:bech32/bech32.dart'; import 'package:bitbox/bitbox.dart' as bitbox; import 'package:bs58check/bs58check.dart' as bs58check; import 'package:coinlib_flutter/coinlib_flutter.dart' as coinlib; -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/models/node_model.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/default_nodes.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_hd_currency.dart'; +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../../models/node_model.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/default_nodes.dart'; +import '../../../utilities/enums/derive_path_type_enum.dart'; +import '../crypto_currency.dart'; +import '../interfaces/electrumx_currency_interface.dart'; +import '../intermediate/bip39_hd_currency.dart'; -class Bitcoincash extends Bip39HDCurrency { +class Bitcoincash extends Bip39HDCurrency with ElectrumXCurrencyInterface { Bitcoincash(super.network) { + _idMain = "bitcoincash"; switch (network) { case CryptoCurrencyNetwork.main: - coin = Coin.bitcoincash; + _id = _idMain; + _name = "Bitcoin Cash"; + _ticker = "BCH"; + _uriScheme = "bitcoincash"; case CryptoCurrencyNetwork.test: - coin = Coin.bitcoincashTestnet; + _id = "bitcoincashTestnet"; + _name = "tBitcoin Cash"; + _ticker = "tBCH"; + _uriScheme = "bchtest"; default: throw Exception("Unsupported network: $network"); } } + late final String _id; + @override + String get identifier => _id; + + late final String _idMain; + @override + String get mainNetId => _idMain; + + late final String _name; + @override + String get prettyName => _name; + + late final String _uriScheme; + @override + String get uriScheme => _uriScheme; + + late final String _ticker; + @override + String get ticker => _ticker; + @override int get maxUnusedAddressGap => 50; @override @@ -40,7 +67,7 @@ class Bitcoincash extends Bip39HDCurrency { @override List get supportedDerivationPathTypes => [ DerivePathType.bip44, - if (coin != Coin.bitcoincashTestnet) DerivePathType.bch44, + if (network != CryptoCurrencyNetwork.test) DerivePathType.bch44, ]; @override @@ -181,7 +208,7 @@ class Bitcoincash extends Bip39HDCurrency { // 0 for bitcoincash: address scheme, 1 for legacy address final format = bitbox.Address.detectFormat(address); - if (coin == Coin.bitcoincashTestnet) { + if (network == CryptoCurrencyNetwork.test) { return true; } @@ -264,10 +291,10 @@ class Bitcoincash extends Bip39HDCurrency { host: "bitcoincash.stackwallet.com", port: 50002, name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.bitcoincash), + id: DefaultNodes.buildId(this), useSSL: true, enabled: true, - coinName: Coin.bitcoincash.name, + coinName: identifier, isFailover: true, isDown: false, ); @@ -277,10 +304,10 @@ class Bitcoincash extends Bip39HDCurrency { host: "bitcoincash-testnet.stackwallet.com", port: 60002, name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.bitcoincashTestnet), + id: DefaultNodes.buildId(this), useSSL: true, enabled: true, - coinName: Coin.bitcoincashTestnet.name, + coinName: identifier, isFailover: true, isDown: false, ); @@ -291,10 +318,47 @@ class Bitcoincash extends Bip39HDCurrency { } @override - bool operator ==(Object other) { - return other is Bitcoincash && other.network == network; - } + int get defaultSeedPhraseLength => 12; @override - int get hashCode => Object.hash(Bitcoincash, network); + int get fractionDigits => 8; + + @override + bool get hasBuySupport => true; + + @override + bool get hasMnemonicPassphraseSupport => true; + + @override + List get possibleMnemonicLengths => [defaultSeedPhraseLength, 24]; + + @override + AddressType get primaryAddressType => AddressType.p2pkh; + + @override + BigInt get satsPerCoin => BigInt.from(100000000); + + @override + int get targetBlockTimeSeconds => 600; + + @override + DerivePathType get primaryDerivePathType => DerivePathType.bip44; + + @override + Uri defaultBlockExplorer(String txid) { + switch (network) { + case CryptoCurrencyNetwork.main: + return Uri.parse( + "https://blockchair.com/bitcoin-cash/transaction/$txid", + ); + case CryptoCurrencyNetwork.test: + return Uri.parse( + "https://blockexplorer.one/bitcoin-cash/testnet/tx/$txid", + ); + default: + throw Exception( + "Unsupported network for defaultBlockExplorer(): $network", + ); + } + } } diff --git a/lib/wallets/crypto_currency/coins/dogecoin.dart b/lib/wallets/crypto_currency/coins/dogecoin.dart index 26abdaa85..3e1824e48 100644 --- a/lib/wallets/crypto_currency/coins/dogecoin.dart +++ b/lib/wallets/crypto_currency/coins/dogecoin.dart @@ -1,25 +1,51 @@ import 'package:coinlib_flutter/coinlib_flutter.dart' as coinlib; -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/models/node_model.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/default_nodes.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_hd_currency.dart'; +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../../models/node_model.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/default_nodes.dart'; +import '../../../utilities/enums/derive_path_type_enum.dart'; +import '../crypto_currency.dart'; +import '../interfaces/electrumx_currency_interface.dart'; +import '../intermediate/bip39_hd_currency.dart'; -class Dogecoin extends Bip39HDCurrency { +class Dogecoin extends Bip39HDCurrency with ElectrumXCurrencyInterface { Dogecoin(super.network) { + _idMain = "dogecoin"; + _uriScheme = "dogecoin"; switch (network) { case CryptoCurrencyNetwork.main: - coin = Coin.dogecoin; + _id = _idMain; + _name = "Dogecoin"; + _ticker = "DOGE"; case CryptoCurrencyNetwork.test: - coin = Coin.dogecoinTestNet; + _id = "dogecoinTestNet"; + _name = "tDogecoin"; + _ticker = "tDOGE"; default: throw Exception("Unsupported network: $network"); } } + late final String _id; + @override + String get identifier => _id; + + late final String _idMain; + @override + String get mainNetId => _idMain; + + late final String _name; + @override + String get prettyName => _name; + + late final String _uriScheme; + @override + String get uriScheme => _uriScheme; + + late final String _ticker; + @override + String get ticker => _ticker; + @override bool get torSupport => true; @@ -64,7 +90,7 @@ class Dogecoin extends Bip39HDCurrency { @override Amount get dustLimit => Amount( rawValue: BigInt.from(1000000), - fractionDigits: Coin.particl.decimals, + fractionDigits: fractionDigits, ); @override @@ -156,10 +182,10 @@ class Dogecoin extends Bip39HDCurrency { host: "dogecoin.stackwallet.com", port: 50022, name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.dogecoin), + id: DefaultNodes.buildId(this), useSSL: true, enabled: true, - coinName: Coin.dogecoin.name, + coinName: identifier, isFailover: true, isDown: false, ); @@ -169,10 +195,10 @@ class Dogecoin extends Bip39HDCurrency { host: "dogecoin-testnet.stackwallet.com", port: 50022, name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.dogecoinTestNet), + id: DefaultNodes.buildId(this), useSSL: true, enabled: true, - coinName: Coin.dogecoinTestNet.name, + coinName: identifier, isFailover: true, isDown: false, ); @@ -183,10 +209,43 @@ class Dogecoin extends Bip39HDCurrency { } @override - bool operator ==(Object other) { - return other is Dogecoin && other.network == network; - } + int get defaultSeedPhraseLength => 12; @override - int get hashCode => Object.hash(Dogecoin, network); + int get fractionDigits => 8; + + @override + bool get hasBuySupport => true; + + @override + bool get hasMnemonicPassphraseSupport => true; + + @override + List get possibleMnemonicLengths => [defaultSeedPhraseLength, 24]; + + @override + AddressType get primaryAddressType => AddressType.p2pkh; + + @override + BigInt get satsPerCoin => BigInt.from(100000000); + + @override + int get targetBlockTimeSeconds => 60; + + @override + DerivePathType get primaryDerivePathType => DerivePathType.bip44; + + @override + Uri defaultBlockExplorer(String txid) { + switch (network) { + case CryptoCurrencyNetwork.main: + return Uri.parse("https://chain.so/tx/DOGE/$txid"); + case CryptoCurrencyNetwork.test: + return Uri.parse("https://chain.so/tx/DOGETEST/$txid"); + default: + throw Exception( + "Unsupported network for defaultBlockExplorer(): $network", + ); + } + } } diff --git a/lib/wallets/crypto_currency/coins/ecash.dart b/lib/wallets/crypto_currency/coins/ecash.dart index 6c068ed4d..bf173fe67 100644 --- a/lib/wallets/crypto_currency/coins/ecash.dart +++ b/lib/wallets/crypto_currency/coins/ecash.dart @@ -4,25 +4,49 @@ import 'package:bech32/bech32.dart'; import 'package:bitbox/bitbox.dart' as bitbox; import 'package:bs58check/bs58check.dart' as bs58check; import 'package:coinlib_flutter/coinlib_flutter.dart' as coinlib; -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/models/node_model.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/default_nodes.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_hd_currency.dart'; +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../../models/node_model.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/default_nodes.dart'; +import '../../../utilities/enums/derive_path_type_enum.dart'; +import '../crypto_currency.dart'; +import '../interfaces/electrumx_currency_interface.dart'; +import '../intermediate/bip39_hd_currency.dart'; -class Ecash extends Bip39HDCurrency { +class Ecash extends Bip39HDCurrency with ElectrumXCurrencyInterface { Ecash(super.network) { + _idMain = "eCash"; switch (network) { case CryptoCurrencyNetwork.main: - coin = Coin.eCash; + _id = _idMain; + _name = "eCash"; + _ticker = "XEC"; + _uriScheme = "ecash"; default: throw Exception("Unsupported network: $network"); } } + late final String _id; + @override + String get identifier => _id; + + late final String _idMain; + @override + String get mainNetId => _idMain; + + late final String _name; + @override + String get prettyName => _name; + + late final String _uriScheme; + @override + String get uriScheme => _uriScheme; + + late final String _ticker; + @override + String get ticker => _ticker; + @override int get maxUnusedAddressGap => 50; @override @@ -254,13 +278,15 @@ class Ecash extends Bip39HDCurrency { switch (network) { case CryptoCurrencyNetwork.main: return NodeModel( + // host: "ecash.stackwallet.com", + // port: 59002, host: "electrum.bitcoinabc.org", port: 50002, name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.eCash), + id: DefaultNodes.buildId(this), useSSL: true, enabled: true, - coinName: Coin.eCash.name, + coinName: identifier, isFailover: true, isDown: false, ); @@ -271,10 +297,41 @@ class Ecash extends Bip39HDCurrency { } @override - bool operator ==(Object other) { - return other is Ecash && other.network == network; - } + int get defaultSeedPhraseLength => 12; @override - int get hashCode => Object.hash(Ecash, network); + int get fractionDigits => 2; + + @override + bool get hasBuySupport => false; + + @override + bool get hasMnemonicPassphraseSupport => true; + + @override + List get possibleMnemonicLengths => [defaultSeedPhraseLength, 24]; + + @override + AddressType get primaryAddressType => AddressType.p2pkh; + + @override + BigInt get satsPerCoin => BigInt.from(100); + + @override + int get targetBlockTimeSeconds => 600; + + @override + DerivePathType get primaryDerivePathType => DerivePathType.eCash44; + + @override + Uri defaultBlockExplorer(String txid) { + switch (network) { + case CryptoCurrencyNetwork.main: + return Uri.parse("https://explorer.e.cash/tx/$txid"); + default: + throw Exception( + "Unsupported network for defaultBlockExplorer(): $network", + ); + } + } } diff --git a/lib/wallets/crypto_currency/coins/epiccash.dart b/lib/wallets/crypto_currency/coins/epiccash.dart index 49d7a7a7f..f90832473 100644 --- a/lib/wallets/crypto_currency/coins/epiccash.dart +++ b/lib/wallets/crypto_currency/coins/epiccash.dart @@ -1,20 +1,45 @@ import 'package:flutter_libepiccash/lib.dart' as epic; -import 'package:stackwallet/models/node_model.dart'; -import 'package:stackwallet/utilities/default_nodes.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_currency.dart'; +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../../models/node_model.dart'; +import '../../../utilities/default_nodes.dart'; +import '../../../utilities/enums/derive_path_type_enum.dart'; +import '../crypto_currency.dart'; +import '../intermediate/bip39_currency.dart'; class Epiccash extends Bip39Currency { Epiccash(super.network) { + _idMain = "epicCash"; + _uriScheme = "epic"; // ? switch (network) { case CryptoCurrencyNetwork.main: - coin = Coin.epicCash; + _id = _idMain; + _name = "Epic Cash"; + _ticker = "EPIC"; default: throw Exception("Unsupported network: $network"); } } + late final String _id; + @override + String get identifier => _id; + + late final String _idMain; + @override + String get mainNetId => _idMain; + + late final String _name; + @override + String get prettyName => _name; + + late final String _uriScheme; + @override + String get uriScheme => _uriScheme; + + late final String _ticker; + @override + String get ticker => _ticker; + @override String get genesisHash { return "not used in epiccash"; @@ -45,16 +70,15 @@ class Epiccash extends Bip39Currency { switch (network) { case CryptoCurrencyNetwork.main: return NodeModel( - host: "https://wownero.stackwallet.com", - port: 34568, + host: "http://epiccash.stackwallet.com", + port: 3413, name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.wownero), - useSSL: true, + id: DefaultNodes.buildId(this), + useSSL: false, enabled: true, - coinName: Coin.wownero.name, + coinName: identifier, isFailover: true, isDown: false, - trusted: true, ); default: @@ -63,10 +87,41 @@ class Epiccash extends Bip39Currency { } @override - bool operator ==(Object other) { - return other is Epiccash && other.network == network; - } + int get defaultSeedPhraseLength => 24; @override - int get hashCode => Object.hash(Epiccash, network); + int get fractionDigits => 8; + + @override + bool get hasBuySupport => false; + + @override + bool get hasMnemonicPassphraseSupport => false; + + @override + List get possibleMnemonicLengths => [defaultSeedPhraseLength, 12]; + + @override + AddressType get primaryAddressType => AddressType.mimbleWimble; + + @override + BigInt get satsPerCoin => BigInt.from(100000000); + + @override + int get targetBlockTimeSeconds => 60; + + @override + DerivePathType get primaryDerivePathType => throw UnsupportedError( + "$runtimeType does not use bitcoin style derivation paths", + ); + + @override + Uri defaultBlockExplorer(String txid) { + switch (network) { + default: + throw Exception( + "Unsupported network for defaultBlockExplorer(): $network", + ); + } + } } diff --git a/lib/wallets/crypto_currency/coins/ethereum.dart b/lib/wallets/crypto_currency/coins/ethereum.dart index a9bc81380..eb20d05e3 100644 --- a/lib/wallets/crypto_currency/coins/ethereum.dart +++ b/lib/wallets/crypto_currency/coins/ethereum.dart @@ -1,31 +1,66 @@ import 'package:ethereum_addresses/ethereum_addresses.dart'; -import 'package:stackwallet/models/node_model.dart'; -import 'package:stackwallet/utilities/default_nodes.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_currency.dart'; +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../../models/node_model.dart'; +import '../../../utilities/default_nodes.dart'; +import '../../../utilities/enums/derive_path_type_enum.dart'; +import '../crypto_currency.dart'; +import '../intermediate/bip39_currency.dart'; class Ethereum extends Bip39Currency { Ethereum(super.network) { + _idMain = "ethereum"; + _uriScheme = "ethereum"; switch (network) { case CryptoCurrencyNetwork.main: - coin = Coin.ethereum; + _id = _idMain; + _name = "Ethereum"; + _ticker = "ETH"; default: throw Exception("Unsupported network: $network"); } } + late final String _id; + @override + String get identifier => _id; + + late final String _idMain; + @override + String get mainNetId => _idMain; + + late final String _name; + @override + String get prettyName => _name; + + late final String _uriScheme; + @override + String get uriScheme => _uriScheme; + + late final String _ticker; + @override + String get ticker => _ticker; + int get gasLimit => 21000; @override bool get hasTokenSupport => true; @override - NodeModel get defaultNode => DefaultNodes.ethereum; + NodeModel get defaultNode => NodeModel( + host: "https://eth.stackwallet.com", + port: 443, + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(this), + useSSL: true, + enabled: true, + coinName: identifier, + isFailover: true, + isDown: false, + ); @override // Not used for eth - String get genesisHash => throw UnimplementedError(); + String get genesisHash => throw UnimplementedError("Not used for eth"); @override int get minConfirms => 3; @@ -36,10 +71,41 @@ class Ethereum extends Bip39Currency { } @override - bool operator ==(Object other) { - return other is Ethereum && other.network == network; - } + int get defaultSeedPhraseLength => 12; @override - int get hashCode => Object.hash(Ethereum, network); + int get fractionDigits => 18; + + @override + bool get hasBuySupport => true; + + @override + bool get hasMnemonicPassphraseSupport => true; + + @override + List get possibleMnemonicLengths => [defaultSeedPhraseLength, 24]; + + @override + AddressType get primaryAddressType => AddressType.ethereum; + + @override + BigInt get satsPerCoin => BigInt.from(1000000000000000000); + + @override + int get targetBlockTimeSeconds => 15; + + @override + DerivePathType get primaryDerivePathType => DerivePathType.eth; + + @override + Uri defaultBlockExplorer(String txid) { + switch (network) { + case CryptoCurrencyNetwork.main: + return Uri.parse("https://etherscan.io/tx/$txid"); + default: + throw Exception( + "Unsupported network for defaultBlockExplorer(): $network", + ); + } + } } diff --git a/lib/wallets/crypto_currency/coins/firo.dart b/lib/wallets/crypto_currency/coins/firo.dart index 36ad7d763..d9dbe3e65 100644 --- a/lib/wallets/crypto_currency/coins/firo.dart +++ b/lib/wallets/crypto_currency/coins/firo.dart @@ -1,26 +1,52 @@ import 'package:coinlib_flutter/coinlib_flutter.dart' as coinlib; -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/models/node_model.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/default_nodes.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_hd_currency.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart'; +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../../models/node_model.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/default_nodes.dart'; +import '../../../utilities/enums/derive_path_type_enum.dart'; +import '../crypto_currency.dart'; +import '../interfaces/electrumx_currency_interface.dart'; +import '../intermediate/bip39_hd_currency.dart'; +import '../../wallet/wallet_mixin_interfaces/spark_interface.dart'; -class Firo extends Bip39HDCurrency { +class Firo extends Bip39HDCurrency with ElectrumXCurrencyInterface { Firo(super.network) { + _idMain = "firo"; + _uriScheme = "firo"; switch (network) { case CryptoCurrencyNetwork.main: - coin = Coin.firo; + _id = _idMain; + _name = "Firo"; + _ticker = "FIRO"; case CryptoCurrencyNetwork.test: - coin = Coin.firoTestNet; + _id = "firoTestNet"; + _name = "tFiro"; + _ticker = "tFIRO"; default: throw Exception("Unsupported network: $network"); } } + late final String _id; + @override + String get identifier => _id; + + late final String _idMain; + @override + String get mainNetId => _idMain; + + late final String _name; + @override + String get prettyName => _name; + + late final String _uriScheme; + @override + String get uriScheme => _uriScheme; + + late final String _ticker; + @override + String get ticker => _ticker; + @override int get minConfirms => 1; @@ -161,10 +187,10 @@ class Firo extends Bip39HDCurrency { host: "firo.stackwallet.com", port: 50002, name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.firo), + id: DefaultNodes.buildId(this), useSSL: true, enabled: true, - coinName: Coin.firo.name, + coinName: identifier, isFailover: true, isDown: false, ); @@ -187,10 +213,10 @@ class Firo extends Bip39HDCurrency { host: "95.179.164.13", port: 51002, name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.firoTestNet), + id: DefaultNodes.buildId(this), useSSL: true, enabled: true, - coinName: Coin.firoTestNet.name, + coinName: identifier, isFailover: true, isDown: false, ); @@ -201,10 +227,43 @@ class Firo extends Bip39HDCurrency { } @override - bool operator ==(Object other) { - return other is Firo && other.network == network; - } + int get defaultSeedPhraseLength => 12; @override - int get hashCode => Object.hash(Firo, network); + int get fractionDigits => 8; + + @override + bool get hasBuySupport => false; + + @override + bool get hasMnemonicPassphraseSupport => true; + + @override + List get possibleMnemonicLengths => [defaultSeedPhraseLength, 24]; + + @override + AddressType get primaryAddressType => AddressType.p2pkh; + + @override + BigInt get satsPerCoin => BigInt.from(100000000); + + @override + int get targetBlockTimeSeconds => 150; + + @override + DerivePathType get primaryDerivePathType => DerivePathType.bip44; + + @override + Uri defaultBlockExplorer(String txid) { + switch (network) { + case CryptoCurrencyNetwork.main: + return Uri.parse("https://explorer.firo.org/tx/$txid"); + case CryptoCurrencyNetwork.test: + return Uri.parse("https://testexplorer.firo.org/tx/$txid"); + default: + throw Exception( + "Unsupported network for defaultBlockExplorer(): $network", + ); + } + } } diff --git a/lib/wallets/crypto_currency/coins/litecoin.dart b/lib/wallets/crypto_currency/coins/litecoin.dart index efccbb3de..89346e509 100644 --- a/lib/wallets/crypto_currency/coins/litecoin.dart +++ b/lib/wallets/crypto_currency/coins/litecoin.dart @@ -1,25 +1,51 @@ import 'package:coinlib_flutter/coinlib_flutter.dart' as coinlib; -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/models/node_model.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/default_nodes.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_hd_currency.dart'; +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../../models/node_model.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/default_nodes.dart'; +import '../../../utilities/enums/derive_path_type_enum.dart'; +import '../crypto_currency.dart'; +import '../interfaces/electrumx_currency_interface.dart'; +import '../intermediate/bip39_hd_currency.dart'; -class Litecoin extends Bip39HDCurrency { +class Litecoin extends Bip39HDCurrency with ElectrumXCurrencyInterface { Litecoin(super.network) { + _idMain = "litecoin"; + _uriScheme = "litecoin"; switch (network) { case CryptoCurrencyNetwork.main: - coin = Coin.litecoin; + _id = _idMain; + _name = "Litecoin"; + _ticker = "LTC"; case CryptoCurrencyNetwork.test: - coin = Coin.litecoinTestNet; + _id = "litecoinTestNet"; + _name = "tLitecoin"; + _ticker = "tLTC"; default: throw Exception("Unsupported network: $network"); } } + late final String _id; + @override + String get identifier => _id; + + late final String _idMain; + @override + String get mainNetId => _idMain; + + late final String _name; + @override + String get prettyName => _name; + + late final String _uriScheme; + @override + String get uriScheme => _uriScheme; + + late final String _ticker; + @override + String get ticker => _ticker; + @override // change this to change the number of confirms a tx needs in order to show as confirmed int get minConfirms => 1; @@ -187,10 +213,10 @@ class Litecoin extends Bip39HDCurrency { host: "litecoin.stackwallet.com", port: 20063, name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.litecoin), + id: DefaultNodes.buildId(this), useSSL: true, enabled: true, - coinName: Coin.litecoin.name, + coinName: identifier, isFailover: true, isDown: false, ); @@ -200,10 +226,10 @@ class Litecoin extends Bip39HDCurrency { host: "litecoin.stackwallet.com", port: 51002, name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.litecoinTestNet), + id: DefaultNodes.buildId(this), useSSL: true, enabled: true, - coinName: Coin.litecoinTestNet.name, + coinName: identifier, isFailover: true, isDown: false, ); @@ -214,10 +240,43 @@ class Litecoin extends Bip39HDCurrency { } @override - bool operator ==(Object other) { - return other is Litecoin && other.network == network; - } + int get defaultSeedPhraseLength => 12; @override - int get hashCode => Object.hash(Litecoin, network); + int get fractionDigits => 8; + + @override + bool get hasBuySupport => true; + + @override + bool get hasMnemonicPassphraseSupport => true; + + @override + List get possibleMnemonicLengths => [defaultSeedPhraseLength, 24]; + + @override + AddressType get primaryAddressType => AddressType.p2wpkh; + + @override + BigInt get satsPerCoin => BigInt.from(100000000); + + @override + int get targetBlockTimeSeconds => 150; + + @override + DerivePathType get primaryDerivePathType => DerivePathType.bip84; + + @override + Uri defaultBlockExplorer(String txid) { + switch (network) { + case CryptoCurrencyNetwork.main: + return Uri.parse("https://chain.so/tx/LTC/$txid"); + case CryptoCurrencyNetwork.test: + return Uri.parse("https://chain.so/tx/LTCTEST/$txid"); + default: + throw Exception( + "Unsupported network for defaultBlockExplorer(): $network", + ); + } + } } diff --git a/lib/wallets/crypto_currency/coins/monero.dart b/lib/wallets/crypto_currency/coins/monero.dart index 34eff8203..47deb80ab 100644 --- a/lib/wallets/crypto_currency/coins/monero.dart +++ b/lib/wallets/crypto_currency/coins/monero.dart @@ -1,20 +1,44 @@ import 'package:cw_monero/api/wallet.dart' as monero_wallet; -import 'package:stackwallet/models/node_model.dart'; -import 'package:stackwallet/utilities/default_nodes.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/cryptonote_currency.dart'; +import '../../../models/node_model.dart'; +import '../../../utilities/default_nodes.dart'; +import '../../../utilities/enums/derive_path_type_enum.dart'; +import '../crypto_currency.dart'; +import '../intermediate/cryptonote_currency.dart'; class Monero extends CryptonoteCurrency { Monero(super.network) { + _idMain = "monero"; + _uriScheme = "monero"; switch (network) { case CryptoCurrencyNetwork.main: - coin = Coin.monero; + _id = _idMain; + _name = "Monero"; + _ticker = "XMR"; default: throw Exception("Unsupported network: $network"); } } + late final String _id; + @override + String get identifier => _id; + + late final String _idMain; + @override + String get mainNetId => _idMain; + + late final String _name; + @override + String get prettyName => _name; + + late final String _uriScheme; + @override + String get uriScheme => _uriScheme; + + late final String _ticker; + @override + String get ticker => _ticker; + @override int get minConfirms => 10; @@ -31,10 +55,10 @@ class Monero extends CryptonoteCurrency { host: "https://monero.stackwallet.com", port: 18081, name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.monero), + id: DefaultNodes.buildId(this), useSSL: true, enabled: true, - coinName: Coin.monero.name, + coinName: identifier, isFailover: true, isDown: false, trusted: true, @@ -46,10 +70,40 @@ class Monero extends CryptonoteCurrency { } @override - bool operator ==(Object other) { - return other is Monero && other.network == network; - } + int get defaultSeedPhraseLength => 25; @override - int get hashCode => Object.hash(Monero, network); + int get fractionDigits => 12; + + @override + bool get hasBuySupport => false; + + @override + bool get hasMnemonicPassphraseSupport => false; + + @override + List get possibleMnemonicLengths => [defaultSeedPhraseLength]; + + @override + BigInt get satsPerCoin => BigInt.from(1000000000000); + + @override + int get targetBlockTimeSeconds => 120; + + @override + DerivePathType get primaryDerivePathType => throw UnsupportedError( + "$runtimeType does not use bitcoin style derivation paths", + ); + + @override + Uri defaultBlockExplorer(String txid) { + switch (network) { + case CryptoCurrencyNetwork.main: + return Uri.parse("https://xmrchain.net/tx/$txid"); + default: + throw Exception( + "Unsupported network for defaultBlockExplorer(): $network", + ); + } + } } diff --git a/lib/wallets/crypto_currency/coins/namecoin.dart b/lib/wallets/crypto_currency/coins/namecoin.dart index c2cff8e57..557644b84 100644 --- a/lib/wallets/crypto_currency/coins/namecoin.dart +++ b/lib/wallets/crypto_currency/coins/namecoin.dart @@ -1,23 +1,47 @@ import 'package:coinlib_flutter/coinlib_flutter.dart' as coinlib; -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/models/node_model.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/default_nodes.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_hd_currency.dart'; +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../../models/node_model.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/default_nodes.dart'; +import '../../../utilities/enums/derive_path_type_enum.dart'; +import '../crypto_currency.dart'; +import '../interfaces/electrumx_currency_interface.dart'; +import '../intermediate/bip39_hd_currency.dart'; -class Namecoin extends Bip39HDCurrency { +class Namecoin extends Bip39HDCurrency with ElectrumXCurrencyInterface { Namecoin(super.network) { + _idMain = "namecoin"; + _uriScheme = "namecoin"; switch (network) { case CryptoCurrencyNetwork.main: - coin = Coin.namecoin; + _id = _idMain; + _name = "Namecoin"; + _ticker = "NMC"; default: throw Exception("Unsupported network: $network"); } } + late final String _id; + @override + String get identifier => _id; + + late final String _idMain; + @override + String get mainNetId => _idMain; + + late final String _name; + @override + String get prettyName => _name; + + late final String _uriScheme; + @override + String get uriScheme => _uriScheme; + + late final String _ticker; + @override + String get ticker => _ticker; + @override // See https://github.com/cypherstack/stack_wallet/blob/621aff47969761014e0a6c4e699cb637d5687ab3/lib/services/coins/namecoin/namecoin_wallet.dart#L58 int get minConfirms => 2; @@ -71,10 +95,10 @@ class Namecoin extends Bip39HDCurrency { host: "namecoin.stackwallet.com", port: 57002, name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.namecoin), + id: DefaultNodes.buildId(this), useSSL: true, enabled: true, - coinName: Coin.namecoin.name, + coinName: identifier, isFailover: true, isDown: false, ); @@ -87,8 +111,10 @@ class Namecoin extends Bip39HDCurrency { @override // See https://github.com/cypherstack/stack_wallet/blob/621aff47969761014e0a6c4e699cb637d5687ab3/lib/services/coins/namecoin/namecoin_wallet.dart#L60 - Amount get dustLimit => - Amount(rawValue: BigInt.from(546), fractionDigits: Coin.particl.decimals); + Amount get dustLimit => Amount( + rawValue: BigInt.from(546), + fractionDigits: fractionDigits, + ); @override // See https://github.com/cypherstack/stack_wallet/blob/621aff47969761014e0a6c4e699cb637d5687ab3/lib/services/coins/namecoin/namecoin_wallet.dart#L6 @@ -187,10 +213,41 @@ class Namecoin extends Bip39HDCurrency { } @override - bool operator ==(Object other) { - return other is Namecoin && other.network == network; - } + int get defaultSeedPhraseLength => 12; @override - int get hashCode => Object.hash(Namecoin, network); + int get fractionDigits => 8; + + @override + bool get hasBuySupport => false; + + @override + bool get hasMnemonicPassphraseSupport => true; + + @override + List get possibleMnemonicLengths => [defaultSeedPhraseLength, 12]; + + @override + AddressType get primaryAddressType => AddressType.p2wpkh; + + @override + BigInt get satsPerCoin => BigInt.from(100000000); + + @override + int get targetBlockTimeSeconds => 600; + + @override + DerivePathType get primaryDerivePathType => DerivePathType.bip84; + + @override + Uri defaultBlockExplorer(String txid) { + switch (network) { + case CryptoCurrencyNetwork.main: + return Uri.parse("https://chainz.cryptoid.info/nmc/tx.dws?$txid.htm"); + default: + throw Exception( + "Unsupported network for defaultBlockExplorer(): $network", + ); + } + } } diff --git a/lib/wallets/crypto_currency/coins/nano.dart b/lib/wallets/crypto_currency/coins/nano.dart index 277a4601f..b14992812 100644 --- a/lib/wallets/crypto_currency/coins/nano.dart +++ b/lib/wallets/crypto_currency/coins/nano.dart @@ -1,23 +1,59 @@ import 'package:nanodart/nanodart.dart'; -import 'package:stackwallet/models/node_model.dart'; -import 'package:stackwallet/utilities/default_nodes.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/nano_currency.dart'; +import '../../../models/isar/models/isar_models.dart'; +import '../../../models/node_model.dart'; +import '../../../utilities/default_nodes.dart'; +import '../../../utilities/enums/derive_path_type_enum.dart'; +import '../crypto_currency.dart'; +import '../intermediate/nano_currency.dart'; class Nano extends NanoCurrency { Nano(super.network) { switch (network) { case CryptoCurrencyNetwork.main: - coin = Coin.nano; + _id = "nano"; + _idMain = "nano"; + _name = "Nano"; + _uriScheme = "nano"; + _ticker = "XNO"; default: throw Exception("Unsupported network: $network"); } } + late final String _id; + @override + String get identifier => _id; + + late final String _idMain; + @override + String get mainNetId => _idMain; + + late final String _name; + @override + String get prettyName => _name; + + late final String _uriScheme; + @override + String get uriScheme => _uriScheme; + + late final String _ticker; + @override + String get ticker => _ticker; + + @override + int get fractionDigits => 30; + + @override + BigInt get satsPerCoin => BigInt.parse( + "1000000000000000000000000000000", + ); // 1*10^30 + @override int get minConfirms => 1; + @override + AddressType get primaryAddressType => AddressType.nano; + @override String get defaultRepresentative => "nano_38713x95zyjsqzx6nm1dsom1jmm668owkeb9913ax6nfgj15az3nu8xkx579"; @@ -33,10 +69,10 @@ class Nano extends NanoCurrency { host: "https://rainstorm.city/api", port: 443, name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.nano), + id: DefaultNodes.buildId(this), useSSL: true, enabled: true, - coinName: Coin.nano.name, + coinName: identifier, isFailover: true, isDown: false, ); @@ -47,10 +83,19 @@ class Nano extends NanoCurrency { } @override - bool operator ==(Object other) { - return other is Nano && other.network == network; - } + DerivePathType get primaryDerivePathType => throw UnsupportedError( + "$runtimeType does not use bitcoin style derivation paths", + ); @override - int get hashCode => Object.hash(Nano, network); + Uri defaultBlockExplorer(String txid) { + switch (network) { + case CryptoCurrencyNetwork.main: + return Uri.parse("https://www.nanolooker.com/block/$txid"); + default: + throw Exception( + "Unsupported network for defaultBlockExplorer(): $network", + ); + } + } } diff --git a/lib/wallets/crypto_currency/coins/particl.dart b/lib/wallets/crypto_currency/coins/particl.dart index ae73d46e5..9fb53ab1f 100644 --- a/lib/wallets/crypto_currency/coins/particl.dart +++ b/lib/wallets/crypto_currency/coins/particl.dart @@ -1,23 +1,47 @@ import 'package:coinlib_flutter/coinlib_flutter.dart' as coinlib; -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/models/node_model.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/default_nodes.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_hd_currency.dart'; +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../../models/node_model.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/default_nodes.dart'; +import '../../../utilities/enums/derive_path_type_enum.dart'; +import '../crypto_currency.dart'; +import '../interfaces/electrumx_currency_interface.dart'; +import '../intermediate/bip39_hd_currency.dart'; -class Particl extends Bip39HDCurrency { +class Particl extends Bip39HDCurrency with ElectrumXCurrencyInterface { Particl(super.network) { + _idMain = "particl"; + _uriScheme = "particl"; switch (network) { case CryptoCurrencyNetwork.main: - coin = Coin.particl; + _id = _idMain; + _name = "Particl"; + _ticker = "PART"; default: throw Exception("Unsupported network: $network"); } } + late final String _id; + @override + String get identifier => _id; + + late final String _idMain; + @override + String get mainNetId => _idMain; + + late final String _name; + @override + String get prettyName => _name; + + late final String _uriScheme; + @override + String get uriScheme => _uriScheme; + + late final String _ticker; + @override + String get ticker => _ticker; + @override // See https://github.com/cypherstack/stack_wallet/blob/d08b5c9b22b58db800ad07b2ceeb44c6d05f9cf3/lib/services/coins/particl/particl_wallet.dart#L57 int get minConfirms => 1; @@ -65,10 +89,10 @@ class Particl extends Bip39HDCurrency { host: "particl.stackwallet.com", port: 58002, name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.particl), + id: DefaultNodes.buildId(this), useSSL: true, enabled: true, - coinName: Coin.particl.name, + coinName: identifier, isFailover: true, isDown: false, ); @@ -83,7 +107,7 @@ class Particl extends Bip39HDCurrency { // See https://github.com/cypherstack/stack_wallet/blob/d08b5c9b22b58db800ad07b2ceeb44c6d05f9cf3/lib/services/coins/particl/particl_wallet.dart#L58 Amount get dustLimit => Amount( rawValue: BigInt.from(294), - fractionDigits: Coin.particl.decimals, + fractionDigits: fractionDigits, ); @override @@ -167,10 +191,41 @@ class Particl extends Bip39HDCurrency { } @override - bool operator ==(Object other) { - return other is Particl && other.network == network; - } + int get defaultSeedPhraseLength => 12; @override - int get hashCode => Object.hash(Particl, network); + int get fractionDigits => 8; + + @override + bool get hasBuySupport => false; + + @override + bool get hasMnemonicPassphraseSupport => true; + + @override + List get possibleMnemonicLengths => [defaultSeedPhraseLength, 24]; + + @override + AddressType get primaryAddressType => AddressType.p2wpkh; + + @override + BigInt get satsPerCoin => BigInt.from(100000000); + + @override + int get targetBlockTimeSeconds => 600; + + @override + DerivePathType get primaryDerivePathType => DerivePathType.bip84; + + @override + Uri defaultBlockExplorer(String txid) { + switch (network) { + case CryptoCurrencyNetwork.main: + return Uri.parse("https://chainz.cryptoid.info/part/tx.dws?$txid.htm"); + default: + throw Exception( + "Unsupported network for defaultBlockExplorer(): $network", + ); + } + } } diff --git a/lib/wallets/crypto_currency/coins/peercoin.dart b/lib/wallets/crypto_currency/coins/peercoin.dart index 4e54329de..3287b38ed 100644 --- a/lib/wallets/crypto_currency/coins/peercoin.dart +++ b/lib/wallets/crypto_currency/coins/peercoin.dart @@ -1,26 +1,52 @@ import 'package:coinlib/src/network.dart'; import 'package:coinlib_flutter/coinlib_flutter.dart' as coinlib; -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/models/node_model.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/default_nodes.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_hd_currency.dart'; +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../../models/node_model.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/default_nodes.dart'; +import '../../../utilities/enums/derive_path_type_enum.dart'; +import '../crypto_currency.dart'; +import '../interfaces/electrumx_currency_interface.dart'; +import '../intermediate/bip39_hd_currency.dart'; -class Peercoin extends Bip39HDCurrency { +class Peercoin extends Bip39HDCurrency with ElectrumXCurrencyInterface { Peercoin(super.network) { + _idMain = "peercoin"; + _uriScheme = "peercoin"; switch (network) { case CryptoCurrencyNetwork.main: - coin = Coin.peercoin; + _id = "peercoin"; + _name = "Peercoin"; + _ticker = "PPC"; case CryptoCurrencyNetwork.test: - coin = Coin.peercoinTestNet; + _id = "peercoinTestNet"; + _name = "tPeercoin"; + _ticker = "tPPC"; default: throw Exception("Unsupported network: $network"); } } + late final String _id; + @override + String get identifier => _id; + + late final String _idMain; + @override + String get mainNetId => _idMain; + + late final String _name; + @override + String get prettyName => _name; + + late final String _uriScheme; + @override + String get uriScheme => _uriScheme; + + late final String _ticker; + @override + String get ticker => _ticker; + @override int get minConfirms => 1; @@ -66,9 +92,31 @@ class Peercoin extends Bip39HDCurrency { NodeModel get defaultNode { switch (network) { case CryptoCurrencyNetwork.main: - return DefaultNodes.peercoin; + return NodeModel( + host: "electrum.peercoinexplorer.net", + port: 50002, + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(this), + useSSL: true, + enabled: true, + coinName: identifier, + isFailover: true, + isDown: false, + ); + case CryptoCurrencyNetwork.test: - return DefaultNodes.peercoinTestNet; + return NodeModel( + host: "testnet-electrum.peercoinexplorer.net", + port: 50002, + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(this), + useSSL: true, + enabled: true, + coinName: identifier, + isFailover: true, + isDown: false, + ); + default: throw UnimplementedError(); } @@ -76,8 +124,9 @@ class Peercoin extends Bip39HDCurrency { @override Amount get dustLimit => Amount( + // TODO should this be 10000 instead of 294 for peercoin? rawValue: BigInt.from(294), - fractionDigits: Coin.peercoin.decimals, + fractionDigits: fractionDigits, ); @override @@ -162,10 +211,45 @@ class Peercoin extends Bip39HDCurrency { } @override - bool operator ==(Object other) { - return other is Peercoin && other.network == network; - } + int get defaultSeedPhraseLength => 12; @override - int get hashCode => Object.hash(Peercoin, network); + int get fractionDigits => 6; + + @override + bool get hasBuySupport => false; + + @override + bool get hasMnemonicPassphraseSupport => true; + + @override + List get possibleMnemonicLengths => [defaultSeedPhraseLength, 24]; + + @override + AddressType get primaryAddressType => AddressType.p2wpkh; + + @override + BigInt get satsPerCoin => BigInt.from(1000000); // 1*10^6. + + @override + int get targetBlockTimeSeconds => 600; + + @override + DerivePathType get primaryDerivePathType => DerivePathType.bip84; + + @override + Uri defaultBlockExplorer(String txid) { + switch (network) { + case CryptoCurrencyNetwork.main: + return Uri.parse("https://chainz.cryptoid.info/ppc/tx.dws?$txid.htm"); + case CryptoCurrencyNetwork.test: + return Uri.parse( + "https://chainz.cryptoid.info/ppc-test/search.dws?q=$txid.htm", + ); + default: + throw Exception( + "Unsupported network for defaultBlockExplorer(): $network", + ); + } + } } diff --git a/lib/wallets/crypto_currency/coins/solana.dart b/lib/wallets/crypto_currency/coins/solana.dart index 6b01b5b6d..96ff3f2ae 100644 --- a/lib/wallets/crypto_currency/coins/solana.dart +++ b/lib/wallets/crypto_currency/coins/solana.dart @@ -1,20 +1,45 @@ import 'package:solana/solana.dart'; -import 'package:stackwallet/models/node_model.dart'; -import 'package:stackwallet/utilities/default_nodes.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_currency.dart'; +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../../models/node_model.dart'; +import '../../../utilities/default_nodes.dart'; +import '../../../utilities/enums/derive_path_type_enum.dart'; +import '../crypto_currency.dart'; +import '../intermediate/bip39_currency.dart'; class Solana extends Bip39Currency { Solana(super.network) { + _idMain = "solana"; + _uriScheme = "solana"; switch (network) { case CryptoCurrencyNetwork.main: - coin = Coin.solana; + _id = _idMain; + _name = "Solana"; + _ticker = "SOL"; default: throw Exception("Unsupported network: $network"); } } + late final String _id; + @override + String get identifier => _id; + + late final String _idMain; + @override + String get mainNetId => _idMain; + + late final String _name; + @override + String get prettyName => _name; + + late final String _uriScheme; + @override + String get uriScheme => _uriScheme; + + late final String _ticker; + @override + String get ticker => _ticker; + @override NodeModel get defaultNode { switch (network) { @@ -24,10 +49,10 @@ class Solana extends Bip39Currency { "https://api.mainnet-beta.solana.com/", // TODO: Change this to stack wallet one port: 443, name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.solana), + id: DefaultNodes.buildId(this), useSSL: true, enabled: true, - coinName: Coin.solana.name, + coinName: identifier, isFailover: true, isDown: false, ); @@ -52,10 +77,41 @@ class Solana extends Bip39Currency { String get genesisHash => throw UnimplementedError(); @override - bool operator ==(Object other) { - return other is Solana && other.network == network; - } + int get defaultSeedPhraseLength => 12; @override - int get hashCode => Object.hash(Solana, network); + int get fractionDigits => 9; + + @override + bool get hasBuySupport => false; + + @override + bool get hasMnemonicPassphraseSupport => false; + + @override + List get possibleMnemonicLengths => [defaultSeedPhraseLength, 24]; + + @override + AddressType get primaryAddressType => AddressType.solana; + + @override + BigInt get satsPerCoin => BigInt.from(1000000000); + + @override + int get targetBlockTimeSeconds => 1; + + @override + DerivePathType get primaryDerivePathType => DerivePathType.solana; + + @override + Uri defaultBlockExplorer(String txid) { + switch (network) { + case CryptoCurrencyNetwork.main: + return Uri.parse("https://explorer.solana.com/tx/$txid"); + default: + throw Exception( + "Unsupported network for defaultBlockExplorer(): $network", + ); + } + } } diff --git a/lib/wallets/crypto_currency/coins/stellar.dart b/lib/wallets/crypto_currency/coins/stellar.dart index e9a7e605b..dfcb37fce 100644 --- a/lib/wallets/crypto_currency/coins/stellar.dart +++ b/lib/wallets/crypto_currency/coins/stellar.dart @@ -1,21 +1,48 @@ -import 'package:stackwallet/models/node_model.dart'; -import 'package:stackwallet/utilities/default_nodes.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_currency.dart'; +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../../models/node_model.dart'; +import '../../../utilities/default_nodes.dart'; +import '../../../utilities/enums/derive_path_type_enum.dart'; +import '../crypto_currency.dart'; +import '../intermediate/bip39_currency.dart'; class Stellar extends Bip39Currency { Stellar(super.network) { + _idMain = "stellar"; + _uriScheme = "stellar"; switch (network) { case CryptoCurrencyNetwork.main: - coin = Coin.stellar; + _id = _idMain; + _name = "Stellar"; + _ticker = "XLM"; case CryptoCurrencyNetwork.test: - coin = Coin.stellarTestnet; + _id = "stellarTestnet"; + _name = "tStellar"; + _ticker = "tXLM"; default: throw Exception("Unsupported network: $network"); } } + late final String _id; + @override + String get identifier => _id; + + late final String _idMain; + @override + String get mainNetId => _idMain; + + late final String _name; + @override + String get prettyName => _name; + + late final String _uriScheme; + @override + String get uriScheme => _uriScheme; + + late final String _ticker; + @override + String get ticker => _ticker; + @override int get minConfirms => 1; @@ -31,9 +58,31 @@ class Stellar extends Bip39Currency { NodeModel get defaultNode { switch (network) { case CryptoCurrencyNetwork.main: - return DefaultNodes.stellar; + return NodeModel( + host: "https://horizon.stellar.org", + port: 443, + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(this), + useSSL: false, + enabled: true, + coinName: identifier, + isFailover: true, + isDown: false, + ); + case CryptoCurrencyNetwork.test: - return DefaultNodes.stellarTestnet; + return NodeModel( + host: "https://horizon-testnet.stellar.org/", + port: 50022, + name: DefaultNodes.defaultName, + id: DefaultNodes.buildId(this), + useSSL: true, + enabled: true, + coinName: identifier, + isFailover: true, + isDown: false, + ); + default: throw Exception("Unsupported network"); } @@ -44,10 +93,46 @@ class Stellar extends Bip39Currency { RegExp(r"^[G][A-Z0-9]{55}$").hasMatch(address); @override - bool operator ==(Object other) { - return other is Stellar && other.network == network; - } + int get defaultSeedPhraseLength => 24; @override - int get hashCode => Object.hash(Stellar, network); + int get fractionDigits => 7; + + @override + bool get hasBuySupport => false; + + @override + bool get hasMnemonicPassphraseSupport => true; + + @override + List get possibleMnemonicLengths => [defaultSeedPhraseLength, 12]; + + @override + AddressType get primaryAddressType => AddressType.stellar; + + @override + BigInt get satsPerCoin => BigInt.from( + 10000000, + ); // https://developers.stellar.org/docs/fundamentals-and-concepts/stellar-data-structures/assets#amount-precision + + @override + int get targetBlockTimeSeconds => 5; + + @override + DerivePathType get primaryDerivePathType => throw UnsupportedError( + "$runtimeType does not use bitcoin style derivation paths",); + + @override + Uri defaultBlockExplorer(String txid) { + switch (network) { + case CryptoCurrencyNetwork.main: + return Uri.parse("https://stellarchain.io/tx/$txid"); + case CryptoCurrencyNetwork.test: + return Uri.parse("https://testnet.stellarchain.io/transactions/$txid"); + default: + throw Exception( + "Unsupported network for defaultBlockExplorer(): $network", + ); + } + } } diff --git a/lib/wallets/crypto_currency/coins/tezos.dart b/lib/wallets/crypto_currency/coins/tezos.dart index efb982867..0cf344993 100644 --- a/lib/wallets/crypto_currency/coins/tezos.dart +++ b/lib/wallets/crypto_currency/coins/tezos.dart @@ -3,25 +3,49 @@ import 'dart:typed_data'; import 'package:bip39/bip39.dart' as bip39; import 'package:coinlib_flutter/coinlib_flutter.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/models/node_model.dart'; -import 'package:stackwallet/utilities/default_nodes.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_currency.dart'; +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../../models/node_model.dart'; +import '../../../utilities/default_nodes.dart'; +import '../../../utilities/enums/derive_path_type_enum.dart'; +import '../crypto_currency.dart'; +import '../intermediate/bip39_currency.dart'; import 'package:tezart/src/crypto/crypto.dart'; import 'package:tezart/tezart.dart'; class Tezos extends Bip39Currency { Tezos(super.network) { + _idMain = "tezos"; + _uriScheme = "tezos"; switch (network) { case CryptoCurrencyNetwork.main: - coin = Coin.tezos; + _id = _idMain; + _name = "Tezos"; + _ticker = "XTZ"; default: throw Exception("Unsupported network: $network"); } } + late final String _id; + @override + String get identifier => _id; + + late final String _idMain; + @override + String get mainNetId => _idMain; + + late final String _name; + @override + String get prettyName => _name; + + late final String _uriScheme; + @override + String get uriScheme => _uriScheme; + + late final String _ticker; + @override + String get ticker => _ticker; + // =========================================================================== // =========== Public ======================================================== @@ -83,13 +107,14 @@ class Tezos extends Bip39Currency { switch (network) { case CryptoCurrencyNetwork.main: return NodeModel( + // TODO: ?Change this to stack wallet one? host: "https://mainnet.api.tez.ie", port: 443, name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.tezos), + id: DefaultNodes.buildId(this), useSSL: true, enabled: true, - coinName: Coin.tezos.name, + coinName: identifier, isFailover: true, isDown: false, ); @@ -148,13 +173,43 @@ class Tezos extends Bip39Currency { }).toList(); } - // =========================================================================== + @override + int get defaultSeedPhraseLength => 24; @override - bool operator ==(Object other) { - return other is Tezos && other.network == network; + int get fractionDigits => 6; + + @override + bool get hasBuySupport => false; + + @override + bool get hasMnemonicPassphraseSupport => false; + + @override + List get possibleMnemonicLengths => [defaultSeedPhraseLength, 12]; + + @override + AddressType get primaryAddressType => AddressType.tezos; + + @override + BigInt get satsPerCoin => BigInt.from(1000000); + + @override + int get targetBlockTimeSeconds => 60; + + @override + DerivePathType get primaryDerivePathType => + throw UnsupportedError("Is this even used?"); + + @override + Uri defaultBlockExplorer(String txid) { + switch (network) { + case CryptoCurrencyNetwork.main: + return Uri.parse("https://tzstats.com/$txid"); + default: + throw Exception( + "Unsupported network for defaultBlockExplorer(): $network", + ); + } } - - @override - int get hashCode => Object.hash(Tezos, network); } diff --git a/lib/wallets/crypto_currency/coins/wownero.dart b/lib/wallets/crypto_currency/coins/wownero.dart index 549d1739f..9b83b9481 100644 --- a/lib/wallets/crypto_currency/coins/wownero.dart +++ b/lib/wallets/crypto_currency/coins/wownero.dart @@ -1,20 +1,44 @@ import 'package:cw_wownero/api/wallet.dart' as wownero_wallet; -import 'package:stackwallet/models/node_model.dart'; -import 'package:stackwallet/utilities/default_nodes.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/cryptonote_currency.dart'; +import '../../../models/node_model.dart'; +import '../../../utilities/default_nodes.dart'; +import '../../../utilities/enums/derive_path_type_enum.dart'; +import '../crypto_currency.dart'; +import '../intermediate/cryptonote_currency.dart'; class Wownero extends CryptonoteCurrency { Wownero(super.network) { + _idMain = "wownero"; + _uriScheme = "wownero"; switch (network) { case CryptoCurrencyNetwork.main: - coin = Coin.wownero; + _id = _idMain; + _name = "Wownero"; + _ticker = "WOW"; default: throw Exception("Unsupported network: $network"); } } + late final String _id; + @override + String get identifier => _id; + + late final String _idMain; + @override + String get mainNetId => _idMain; + + late final String _name; + @override + String get prettyName => _name; + + late final String _uriScheme; + @override + String get uriScheme => _uriScheme; + + late final String _ticker; + @override + String get ticker => _ticker; + @override int get minConfirms => 15; @@ -31,10 +55,10 @@ class Wownero extends CryptonoteCurrency { host: "https://wownero.stackwallet.com", port: 34568, name: DefaultNodes.defaultName, - id: DefaultNodes.buildId(Coin.wownero), + id: DefaultNodes.buildId(this), useSSL: true, enabled: true, - coinName: Coin.wownero.name, + coinName: identifier, isFailover: true, isDown: false, trusted: true, @@ -46,10 +70,40 @@ class Wownero extends CryptonoteCurrency { } @override - bool operator ==(Object other) { - return other is Wownero && other.network == network; - } + int get defaultSeedPhraseLength => 14; @override - int get hashCode => Object.hash(Wownero, network); + int get fractionDigits => 11; + + @override + bool get hasBuySupport => false; + + @override + bool get hasMnemonicPassphraseSupport => false; + + @override + List get possibleMnemonicLengths => [defaultSeedPhraseLength, 25]; + + @override + BigInt get satsPerCoin => BigInt.from(100000000000); + + @override + int get targetBlockTimeSeconds => 120; + + @override + DerivePathType get primaryDerivePathType => throw UnsupportedError( + "$runtimeType does not use bitcoin style derivation paths", + ); + + @override + Uri defaultBlockExplorer(String txid) { + switch (network) { + case CryptoCurrencyNetwork.main: + return Uri.parse("https://explore.wownero.com/search?value=$txid"); + default: + throw Exception( + "Unsupported network for defaultBlockExplorer(): $network", + ); + } + } } diff --git a/lib/wallets/crypto_currency/crypto_currency.dart b/lib/wallets/crypto_currency/crypto_currency.dart index 8b6f5cdb6..7b30c85fe 100644 --- a/lib/wallets/crypto_currency/crypto_currency.dart +++ b/lib/wallets/crypto_currency/crypto_currency.dart @@ -1,6 +1,26 @@ -import 'package:stackwallet/models/node_model.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import '../../models/isar/models/blockchain_data/address.dart'; +import '../../models/node_model.dart'; +import '../../utilities/enums/derive_path_type_enum.dart'; + +export 'coins/banano.dart'; +export 'coins/bitcoin.dart'; +export 'coins/bitcoin_frost.dart'; +export 'coins/bitcoincash.dart'; +export 'coins/dogecoin.dart'; +export 'coins/ecash.dart'; +export 'coins/epiccash.dart'; +export 'coins/ethereum.dart'; +export 'coins/firo.dart'; +export 'coins/litecoin.dart'; +export 'coins/monero.dart'; +export 'coins/namecoin.dart'; +export 'coins/nano.dart'; +export 'coins/particl.dart'; +export 'coins/peercoin.dart'; +export 'coins/solana.dart'; +export 'coins/stellar.dart'; +export 'coins/tezos.dart'; +export 'coins/wownero.dart'; enum CryptoCurrencyNetwork { main, @@ -9,13 +29,26 @@ enum CryptoCurrencyNetwork { } abstract class CryptoCurrency { - @Deprecated("[prio=low] Should eventually move away from Coin enum") - late final Coin coin; + // @Deprecated("[prio=low] Should eventually move away from Coin enum") + // late final CryptoCurrency coin; final CryptoCurrencyNetwork network; CryptoCurrency(this.network); + // Identifier should be unique. + /// This [identifier] should also match the old `Coin` enum name for each + /// respective coin as it is used to differentiate between coins in persistent + /// storage. + String get identifier; + + /// Should be the [identifier] of the main net version of the currency + String get mainNetId; + + String get ticker; + String get prettyName; + String get uriScheme; + // override in subclass if the currency has tokens on it's network // (used for eth currently) bool get hasTokenSupport => false; @@ -23,10 +56,6 @@ abstract class CryptoCurrency { // Override in subclass if the currency has Tor support: bool get torSupport => false; - // TODO: [prio=low] require these be overridden in concrete implementations to remove reliance on [coin] - int get fractionDigits => coin.decimals; - BigInt get satsPerCoin => Constants.satsPerCoin(coin); - int get minConfirms; // TODO: [prio=low] could be handled differently as (at least) epiccash does not use this @@ -35,4 +64,26 @@ abstract class CryptoCurrency { bool validateAddress(String address); NodeModel get defaultNode; + + int get defaultSeedPhraseLength; + int get fractionDigits; + bool get hasBuySupport; + bool get hasMnemonicPassphraseSupport; + List get possibleMnemonicLengths; + AddressType get primaryAddressType; + BigInt get satsPerCoin; + int get targetBlockTimeSeconds; + DerivePathType get primaryDerivePathType; + + Uri defaultBlockExplorer(String txid); + + @override + bool operator ==(Object other) { + return other is CryptoCurrency && + other.runtimeType == runtimeType && + other.network == network; + } + + @override + int get hashCode => Object.hash(runtimeType, network); } diff --git a/lib/wallets/crypto_currency/interfaces/electrumx_currency_interface.dart b/lib/wallets/crypto_currency/interfaces/electrumx_currency_interface.dart new file mode 100644 index 000000000..4dd224aed --- /dev/null +++ b/lib/wallets/crypto_currency/interfaces/electrumx_currency_interface.dart @@ -0,0 +1,5 @@ +import '../intermediate/bip39_hd_currency.dart'; + +mixin ElectrumXCurrencyInterface on Bip39HDCurrency { + // +} diff --git a/lib/wallets/crypto_currency/interfaces/paynym_currency_interface.dart b/lib/wallets/crypto_currency/interfaces/paynym_currency_interface.dart index 6f5571009..3a5350be6 100644 --- a/lib/wallets/crypto_currency/interfaces/paynym_currency_interface.dart +++ b/lib/wallets/crypto_currency/interfaces/paynym_currency_interface.dart @@ -1,7 +1,8 @@ -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_hd_currency.dart'; +import '../../../utilities/amount/amount.dart'; +import 'electrumx_currency_interface.dart'; +import '../intermediate/bip39_hd_currency.dart'; -mixin PaynymCurrencyInterface on Bip39HDCurrency { +mixin PaynymCurrencyInterface on ElectrumXCurrencyInterface, Bip39HDCurrency { Amount get dustLimitP2PKH => Amount( rawValue: BigInt.from(546), fractionDigits: fractionDigits, diff --git a/lib/wallets/crypto_currency/intermediate/bip39_currency.dart b/lib/wallets/crypto_currency/intermediate/bip39_currency.dart index 566c033ea..d9c61c77e 100644 --- a/lib/wallets/crypto_currency/intermediate/bip39_currency.dart +++ b/lib/wallets/crypto_currency/intermediate/bip39_currency.dart @@ -1,4 +1,4 @@ -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; +import '../crypto_currency.dart'; abstract class Bip39Currency extends CryptoCurrency { Bip39Currency(super.network); diff --git a/lib/wallets/crypto_currency/intermediate/bip39_hd_currency.dart b/lib/wallets/crypto_currency/intermediate/bip39_hd_currency.dart index 62be12f20..bbe5bd2ab 100644 --- a/lib/wallets/crypto_currency/intermediate/bip39_hd_currency.dart +++ b/lib/wallets/crypto_currency/intermediate/bip39_hd_currency.dart @@ -1,10 +1,10 @@ import 'package:coinlib_flutter/coinlib_flutter.dart' as coinlib; import 'package:crypto/crypto.dart'; import 'package:flutter/foundation.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_currency.dart'; +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/enums/derive_path_type_enum.dart'; +import 'bip39_currency.dart'; abstract class Bip39HDCurrency extends Bip39Currency { Bip39HDCurrency(super.network); diff --git a/lib/wallets/crypto_currency/intermediate/cryptonote_currency.dart b/lib/wallets/crypto_currency/intermediate/cryptonote_currency.dart index 79d1f4de4..b7bf7c645 100644 --- a/lib/wallets/crypto_currency/intermediate/cryptonote_currency.dart +++ b/lib/wallets/crypto_currency/intermediate/cryptonote_currency.dart @@ -1,4 +1,5 @@ -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../crypto_currency.dart'; abstract class CryptonoteCurrency extends CryptoCurrency { CryptonoteCurrency(super.network); @@ -7,4 +8,7 @@ abstract class CryptonoteCurrency extends CryptoCurrency { String get genesisHash { return "not used in stack's cryptonote coins"; } + + @override + AddressType get primaryAddressType => AddressType.cryptonote; } diff --git a/lib/wallets/crypto_currency/intermediate/frost_currency.dart b/lib/wallets/crypto_currency/intermediate/frost_currency.dart index 0c10937fa..fd452bb62 100644 --- a/lib/wallets/crypto_currency/intermediate/frost_currency.dart +++ b/lib/wallets/crypto_currency/intermediate/frost_currency.dart @@ -1,7 +1,7 @@ import 'dart:typed_data'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; +import '../../../utilities/amount/amount.dart'; +import '../crypto_currency.dart'; abstract class FrostCurrency extends CryptoCurrency { FrostCurrency(super.network); diff --git a/lib/wallets/crypto_currency/intermediate/nano_currency.dart b/lib/wallets/crypto_currency/intermediate/nano_currency.dart index 617f8d952..a04cd57a0 100644 --- a/lib/wallets/crypto_currency/intermediate/nano_currency.dart +++ b/lib/wallets/crypto_currency/intermediate/nano_currency.dart @@ -1,5 +1,5 @@ import 'package:nanodart/nanodart.dart'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_currency.dart'; +import 'bip39_currency.dart'; abstract class NanoCurrency extends Bip39Currency { NanoCurrency(super.network); @@ -8,6 +8,21 @@ abstract class NanoCurrency extends Bip39Currency { int get nanoAccountType; + @override + bool get hasMnemonicPassphraseSupport => false; + + @override + int get targetBlockTimeSeconds => 1; // TODO: Verify this + + @override + bool get hasBuySupport => false; + + @override + int get defaultSeedPhraseLength => 24; + + @override + List get possibleMnemonicLengths => [defaultSeedPhraseLength, 12]; + @override bool validateAddress(String address) => NanoAccounts.isValid( nanoAccountType, diff --git a/lib/wallets/isar/models/frost_wallet_info.dart b/lib/wallets/isar/models/frost_wallet_info.dart index b5c7476d2..fd3d1a11a 100644 --- a/lib/wallets/isar/models/frost_wallet_info.dart +++ b/lib/wallets/isar/models/frost_wallet_info.dart @@ -1,5 +1,5 @@ import 'package:isar/isar.dart'; -import 'package:stackwallet/wallets/isar/isar_id_interface.dart'; +import '../isar_id_interface.dart'; part 'frost_wallet_info.g.dart'; diff --git a/lib/wallets/isar/models/token_wallet_info.dart b/lib/wallets/isar/models/token_wallet_info.dart index 4725a29a6..f14491b32 100644 --- a/lib/wallets/isar/models/token_wallet_info.dart +++ b/lib/wallets/isar/models/token_wallet_info.dart @@ -1,8 +1,8 @@ import 'package:isar/isar.dart'; -import 'package:stackwallet/models/balance.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/wallets/isar/isar_id_interface.dart'; +import '../../../models/balance.dart'; +import '../../../models/isar/models/isar_models.dart'; +import '../../../utilities/amount/amount.dart'; +import '../isar_id_interface.dart'; part 'token_wallet_info.g.dart'; diff --git a/lib/wallets/isar/models/wallet_info.dart b/lib/wallets/isar/models/wallet_info.dart index 0ceaa6b83..60a7a1b30 100644 --- a/lib/wallets/isar/models/wallet_info.dart +++ b/lib/wallets/isar/models/wallet_info.dart @@ -1,13 +1,15 @@ import 'dart:convert'; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/balance.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/wallets/isar/isar_id_interface.dart'; -import 'package:stackwallet/wallets/isar/models/wallet_info_meta.dart'; import 'package:uuid/uuid.dart'; +import '../../../app_config.dart'; +import '../../../models/balance.dart'; +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../crypto_currency/crypto_currency.dart'; +import '../isar_id_interface.dart'; +import 'wallet_info_meta.dart'; + part 'wallet_info.g.dart'; @Collection(accessor: "walletInfo", inheritance: false) @@ -76,9 +78,10 @@ class WalletInfo implements IsarId { @ignore Balance get cachedBalanceSecondary { if (cachedBalanceSecondaryString == null) { - return Balance.zeroForCoin(coin: coin); + return Balance.zeroFor(currency: coin); } else { - return Balance.fromJson(cachedBalanceSecondaryString!, coin.decimals); + return Balance.fromJson( + cachedBalanceSecondaryString!, coin.fractionDigits); } } @@ -86,21 +89,22 @@ class WalletInfo implements IsarId { @ignore Balance get cachedBalanceTertiary { if (cachedBalanceTertiaryString == null) { - return Balance.zeroForCoin(coin: coin); + return Balance.zeroFor(currency: coin); } else { - return Balance.fromJson(cachedBalanceTertiaryString!, coin.decimals); + return Balance.fromJson( + cachedBalanceTertiaryString!, coin.fractionDigits); } } @ignore - Coin get coin => Coin.values.byName(coinName); + CryptoCurrency get coin => AppConfig.getCryptoCurrencyFor(coinName)!; @ignore Balance get cachedBalance { if (cachedBalanceString == null) { - return Balance.zeroForCoin(coin: coin); + return Balance.zeroFor(currency: coin); } else { - return Balance.fromJson(cachedBalanceString!, coin.decimals); + return Balance.fromJson(cachedBalanceString!, coin.fractionDigits); } } @@ -404,7 +408,7 @@ class WalletInfo implements IsarId { this.cachedBalanceTertiaryString, this.otherDataJsonString, }) : assert( - Coin.values.map((e) => e.name).contains(coinName), + AppConfig.coins.map((e) => e.identifier).contains(coinName), ); WalletInfo copyWith({ @@ -440,14 +444,14 @@ class WalletInfo implements IsarId { } static WalletInfo createNew({ - required Coin coin, + required CryptoCurrency coin, required String name, int restoreHeight = 0, String? walletIdOverride, String? otherDataJsonString, }) { return WalletInfo( - coinName: coin.name, + coinName: coin.identifier, walletId: walletIdOverride ?? const Uuid().v1(), name: name, mainAddressType: coin.primaryAddressType, @@ -461,9 +465,11 @@ class WalletInfo implements IsarId { Map jsonObject, AddressType mainAddressType, ) { - final coin = Coin.values.byName(jsonObject["coin"] as String); + final coin = AppConfig.getCryptoCurrencyFor( + jsonObject["coin"] as String, + )!; return WalletInfo( - coinName: coin.name, + coinName: coin.identifier, walletId: jsonObject["id"] as String, name: jsonObject["name"] as String, mainAddressType: mainAddressType, @@ -475,7 +481,7 @@ class WalletInfo implements IsarId { return { "name": name, "id": walletId, - "coin": coin.name, + "coin": coin.identifier, }; } diff --git a/lib/wallets/isar/models/wallet_info_meta.dart b/lib/wallets/isar/models/wallet_info_meta.dart index 3d7fbf851..62d37b7d4 100644 --- a/lib/wallets/isar/models/wallet_info_meta.dart +++ b/lib/wallets/isar/models/wallet_info_meta.dart @@ -1,5 +1,5 @@ import 'package:isar/isar.dart'; -import 'package:stackwallet/wallets/isar/isar_id_interface.dart'; +import '../isar_id_interface.dart'; part 'wallet_info_meta.g.dart'; diff --git a/lib/wallets/isar/providers/all_wallets_info_provider.dart b/lib/wallets/isar/providers/all_wallets_info_provider.dart index bca6f417f..0acbae46c 100644 --- a/lib/wallets/isar/providers/all_wallets_info_provider.dart +++ b/lib/wallets/isar/providers/all_wallets_info_provider.dart @@ -3,9 +3,10 @@ import 'dart:async'; import 'package:flutter/foundation.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/wallets/isar/models/wallet_info.dart'; +import '../../../providers/db/main_db_provider.dart'; +import '../../../app_config.dart'; +import '../../crypto_currency/crypto_currency.dart'; +import '../models/wallet_info.dart'; final pAllWalletsInfo = Provider((ref) { return ref.watch(_pAllWalletsInfo.select((value) => value.value)); @@ -14,7 +15,8 @@ final pAllWalletsInfo = Provider((ref) { final pAllWalletsInfoByCoin = Provider((ref) { final infos = ref.watch(pAllWalletsInfo); - final Map wallets})> map = {}; + final Map wallets})> + map = {}; for (final info in infos) { if (map[info.coin] == null) { @@ -24,8 +26,8 @@ final pAllWalletsInfoByCoin = Provider((ref) { map[info.coin]!.wallets.add(info); } - final List<({Coin coin, List wallets})> results = []; - for (final coin in Coin.values) { + final List<({CryptoCurrency coin, List wallets})> results = []; + for (final coin in AppConfig.coins) { if (map[coin] != null) { results.add(map[coin]!); } @@ -40,7 +42,14 @@ final _pAllWalletsInfo = ChangeNotifierProvider((ref) { if (_globalInstance == null) { final isar = ref.watch(mainDBProvider).isar; _globalInstance = _WalletInfoWatcher( - isar.walletInfo.where().findAllSync(), + isar.walletInfo + .where() + .filter() + .anyOf( + AppConfig.coins.map((e) => e.identifier), + (q, element) => q.coinNameMatches(element), + ) + .findAllSync(), isar, ); } @@ -58,7 +67,15 @@ class _WalletInfoWatcher extends ChangeNotifier { _WalletInfoWatcher(this._value, Isar isar) { _streamSubscription = isar.walletInfo.watchLazy(fireImmediately: true).listen((event) { - isar.walletInfo.where().findAll().then((value) { + isar.walletInfo + .where() + .filter() + .anyOf( + AppConfig.coins.map((e) => e.identifier), + (q, element) => q.coinNameMatches(element), + ) + .findAll() + .then((value) { _value = value; notifyListeners(); }); diff --git a/lib/wallets/isar/providers/eth/current_token_wallet_provider.dart b/lib/wallets/isar/providers/eth/current_token_wallet_provider.dart index 78015afea..08bcf6a62 100644 --- a/lib/wallets/isar/providers/eth/current_token_wallet_provider.dart +++ b/lib/wallets/isar/providers/eth/current_token_wallet_provider.dart @@ -1,5 +1,5 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/wallets/wallet/impl/sub_wallets/eth_token_wallet.dart'; +import '../../../wallet/impl/sub_wallets/eth_token_wallet.dart'; final tokenServiceStateProvider = StateProvider((ref) => null); diff --git a/lib/wallets/isar/providers/eth/token_balance_provider.dart b/lib/wallets/isar/providers/eth/token_balance_provider.dart index 617a11b44..741092387 100644 --- a/lib/wallets/isar/providers/eth/token_balance_provider.dart +++ b/lib/wallets/isar/providers/eth/token_balance_provider.dart @@ -1,10 +1,10 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/balance.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/wallets/isar/models/token_wallet_info.dart'; -import 'package:stackwallet/wallets/isar/providers/util/watcher.dart'; +import '../../../../models/balance.dart'; +import '../../../../models/isar/models/isar_models.dart'; +import '../../../../providers/db/main_db_provider.dart'; +import '../../models/token_wallet_info.dart'; +import '../util/watcher.dart'; final _twiProvider = ChangeNotifierProvider.family( diff --git a/lib/wallets/isar/providers/favourite_wallets_provider.dart b/lib/wallets/isar/providers/favourite_wallets_provider.dart index 650b57d64..1f7eb798e 100644 --- a/lib/wallets/isar/providers/favourite_wallets_provider.dart +++ b/lib/wallets/isar/providers/favourite_wallets_provider.dart @@ -3,8 +3,10 @@ import 'dart:async'; import 'package:flutter/foundation.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/wallets/isar/models/wallet_info.dart'; +import '../../../providers/db/main_db_provider.dart'; +import '../../../app_config.dart'; +import '../../crypto_currency/crypto_currency.dart'; +import '../models/wallet_info.dart'; class _Watcher extends ChangeNotifier { final bool isFavourite; @@ -17,6 +19,10 @@ class _Watcher extends ChangeNotifier { _Watcher(this._value, this.isFavourite, Isar isar) { _streamSubscription = isar.walletInfo .filter() + .anyOf( + AppConfig.coins.map((e) => e.identifier), + (q, element) => q.coinNameMatches(element), + ) .isFavouriteEqualTo(isFavourite) .sortByFavouriteOrderIndex() .watch(fireImmediately: true) @@ -40,6 +46,10 @@ final _wiProvider = ChangeNotifierProvider.family<_Watcher, bool>( final watcher = _Watcher( isar.walletInfo .filter() + .anyOf( + AppConfig.coins.map((e) => e.identifier), + (q, element) => q.coinNameMatches(element), + ) .isFavouriteEqualTo(isFavourite) .sortByFavouriteOrderIndex() .findAllSync(), diff --git a/lib/wallets/isar/providers/util/watcher.dart b/lib/wallets/isar/providers/util/watcher.dart index 2a6ab50e3..0208baca0 100644 --- a/lib/wallets/isar/providers/util/watcher.dart +++ b/lib/wallets/isar/providers/util/watcher.dart @@ -2,7 +2,7 @@ import 'dart:async'; import 'package:flutter/foundation.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/wallets/isar/isar_id_interface.dart'; +import '../../isar_id_interface.dart'; class Watcher extends ChangeNotifier { late final StreamSubscription _streamSubscription; diff --git a/lib/wallets/isar/providers/wallet_info_provider.dart b/lib/wallets/isar/providers/wallet_info_provider.dart index b2c39ec21..a3ec30e49 100644 --- a/lib/wallets/isar/providers/wallet_info_provider.dart +++ b/lib/wallets/isar/providers/wallet_info_provider.dart @@ -1,10 +1,10 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/balance.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/wallets/isar/models/wallet_info.dart'; -import 'package:stackwallet/wallets/isar/providers/util/watcher.dart'; +import '../../../models/balance.dart'; +import '../../../providers/db/main_db_provider.dart'; +import '../../crypto_currency/crypto_currency.dart'; +import '../models/wallet_info.dart'; +import 'util/watcher.dart'; final _wiProvider = ChangeNotifierProvider.family( (ref, walletId) { @@ -27,65 +27,81 @@ final pWalletInfo = Provider.family( }, ); -final pWalletCoin = Provider.family( +final pWalletCoin = Provider.family( (ref, walletId) { - return ref.watch(_wiProvider(walletId) - .select((value) => (value.value as WalletInfo).coin)); + return ref.watch( + _wiProvider(walletId).select((value) => (value.value as WalletInfo).coin), + ); }, ); final pWalletBalance = Provider.family( (ref, walletId) { - return ref.watch(_wiProvider(walletId) - .select((value) => (value.value as WalletInfo).cachedBalance)); + return ref.watch( + _wiProvider(walletId) + .select((value) => (value.value as WalletInfo).cachedBalance), + ); }, ); final pWalletBalanceSecondary = Provider.family( (ref, walletId) { - return ref.watch(_wiProvider(walletId) - .select((value) => (value.value as WalletInfo).cachedBalanceSecondary)); + return ref.watch( + _wiProvider(walletId).select( + (value) => (value.value as WalletInfo).cachedBalanceSecondary), + ); }, ); final pWalletBalanceTertiary = Provider.family( (ref, walletId) { - return ref.watch(_wiProvider(walletId) - .select((value) => (value.value as WalletInfo).cachedBalanceTertiary)); + return ref.watch( + _wiProvider(walletId) + .select((value) => (value.value as WalletInfo).cachedBalanceTertiary), + ); }, ); final pWalletChainHeight = Provider.family( (ref, walletId) { - return ref.watch(_wiProvider(walletId) - .select((value) => (value.value as WalletInfo).cachedChainHeight)); + return ref.watch( + _wiProvider(walletId) + .select((value) => (value.value as WalletInfo).cachedChainHeight), + ); }, ); final pWalletIsFavourite = Provider.family( (ref, walletId) { - return ref.watch(_wiProvider(walletId) - .select((value) => (value.value as WalletInfo).isFavourite)); + return ref.watch( + _wiProvider(walletId) + .select((value) => (value.value as WalletInfo).isFavourite), + ); }, ); final pWalletName = Provider.family( (ref, walletId) { - return ref.watch(_wiProvider(walletId) - .select((value) => (value.value as WalletInfo).name)); + return ref.watch( + _wiProvider(walletId).select((value) => (value.value as WalletInfo).name), + ); }, ); final pWalletReceivingAddress = Provider.family( (ref, walletId) { - return ref.watch(_wiProvider(walletId) - .select((value) => (value.value as WalletInfo).cachedReceivingAddress)); + return ref.watch( + _wiProvider(walletId).select( + (value) => (value.value as WalletInfo).cachedReceivingAddress), + ); }, ); final pWalletTokenAddresses = Provider.family, String>( (ref, walletId) { - return ref.watch(_wiProvider(walletId) - .select((value) => (value.value as WalletInfo).tokenContractAddresses)); + return ref.watch( + _wiProvider(walletId).select( + (value) => (value.value as WalletInfo).tokenContractAddresses), + ); }, ); diff --git a/lib/wallets/models/incomplete_frost_wallet.dart b/lib/wallets/models/incomplete_frost_wallet.dart index 015ca9fb9..0a8e67325 100644 --- a/lib/wallets/models/incomplete_frost_wallet.dart +++ b/lib/wallets/models/incomplete_frost_wallet.dart @@ -1,11 +1,11 @@ -import 'package:stackwallet/db/isar/main_db.dart'; -import 'package:stackwallet/services/node_service.dart'; -import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; -import 'package:stackwallet/utilities/prefs.dart'; -import 'package:stackwallet/wallets/isar/models/frost_wallet_info.dart'; -import 'package:stackwallet/wallets/isar/models/wallet_info.dart'; -import 'package:stackwallet/wallets/wallet/impl/bitcoin_frost_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet.dart'; +import '../../db/isar/main_db.dart'; +import '../../services/node_service.dart'; +import '../../utilities/flutter_secure_storage_interface.dart'; +import '../../utilities/prefs.dart'; +import '../isar/models/frost_wallet_info.dart'; +import '../isar/models/wallet_info.dart'; +import '../wallet/impl/bitcoin_frost_wallet.dart'; +import '../wallet/wallet.dart'; class IncompleteFrostWallet { WalletInfo? info; diff --git a/lib/wallets/models/tx_data.dart b/lib/wallets/models/tx_data.dart index d98dd088e..6a6008742 100644 --- a/lib/wallets/models/tx_data.dart +++ b/lib/wallets/models/tx_data.dart @@ -1,11 +1,11 @@ import 'package:cw_monero/pending_monero_transaction.dart'; import 'package:cw_wownero/pending_wownero_transaction.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/models/paynym/paynym_account_lite.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart'; -import 'package:stackwallet/wallets/isar/models/spark_coin.dart'; +import '../../models/isar/models/blockchain_data/v2/transaction_v2.dart'; +import '../../models/isar/models/isar_models.dart'; +import '../../models/paynym/paynym_account_lite.dart'; +import '../../utilities/amount/amount.dart'; +import '../../utilities/enums/fee_rate_type_enum.dart'; +import '../isar/models/spark_coin.dart'; import 'package:tezart/tezart.dart' as tezart; import 'package:web3dart/web3dart.dart' as web3dart; diff --git a/lib/wallets/models/tx_recipient.dart b/lib/wallets/models/tx_recipient.dart index 92703caa8..8c5e9a9d4 100644 --- a/lib/wallets/models/tx_recipient.dart +++ b/lib/wallets/models/tx_recipient.dart @@ -1,4 +1,4 @@ -import 'package:stackwallet/utilities/amount/amount.dart'; +import '../../utilities/amount/amount.dart'; class TxRecipient { final String address; diff --git a/lib/wallets/wallet/impl/banano_wallet.dart b/lib/wallets/wallet/impl/banano_wallet.dart index 88e076660..044e31efd 100644 --- a/lib/wallets/wallet/impl/banano_wallet.dart +++ b/lib/wallets/wallet/impl/banano_wallet.dart @@ -1,9 +1,9 @@ -import 'package:stackwallet/wallets/crypto_currency/coins/banano.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/nano_currency.dart'; -import 'package:stackwallet/wallets/isar/models/wallet_info.dart'; -import 'package:stackwallet/wallets/wallet/intermediate/bip39_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/nano_interface.dart'; +import '../../crypto_currency/coins/banano.dart'; +import '../../crypto_currency/crypto_currency.dart'; +import '../../crypto_currency/intermediate/nano_currency.dart'; +import '../../isar/models/wallet_info.dart'; +import '../intermediate/bip39_wallet.dart'; +import '../wallet_mixin_interfaces/nano_interface.dart'; class BananoWallet extends Bip39Wallet with NanoInterface { BananoWallet(CryptoCurrencyNetwork network) : super(Banano(network)); diff --git a/lib/wallets/wallet/impl/bitcoin_frost_wallet.dart b/lib/wallets/wallet/impl/bitcoin_frost_wallet.dart index 5d0bb3ffc..953a1f0cf 100644 --- a/lib/wallets/wallet/impl/bitcoin_frost_wallet.dart +++ b/lib/wallets/wallet/impl/bitcoin_frost_wallet.dart @@ -5,28 +5,28 @@ import 'package:flutter/foundation.dart'; import 'package:frostdart/frostdart.dart' as frost; import 'package:frostdart/frostdart_bindings_generated.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/electrumx_rpc/cached_electrumx_client.dart'; -import 'package:stackwallet/electrumx_rpc/electrumx_client.dart'; -import 'package:stackwallet/models/balance.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/utxo.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/input_v2.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/output_v2.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart'; -import 'package:stackwallet/models/paymint/fee_object_model.dart'; -import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart'; -import 'package:stackwallet/services/event_bus/global_event_bus.dart'; -import 'package:stackwallet/services/frost.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/extensions/extensions.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/bitcoin_frost.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/frost_currency.dart'; -import 'package:stackwallet/wallets/isar/models/frost_wallet_info.dart'; -import 'package:stackwallet/wallets/models/tx_data.dart'; -import 'package:stackwallet/wallets/wallet/wallet.dart'; +import '../../../electrumx_rpc/cached_electrumx_client.dart'; +import '../../../electrumx_rpc/electrumx_client.dart'; +import '../../../models/balance.dart'; +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../../models/isar/models/blockchain_data/transaction.dart'; +import '../../../models/isar/models/blockchain_data/utxo.dart'; +import '../../../models/isar/models/blockchain_data/v2/input_v2.dart'; +import '../../../models/isar/models/blockchain_data/v2/output_v2.dart'; +import '../../../models/isar/models/blockchain_data/v2/transaction_v2.dart'; +import '../../../models/paymint/fee_object_model.dart'; +import '../../../services/event_bus/events/global/wallet_sync_status_changed_event.dart'; +import '../../../services/event_bus/global_event_bus.dart'; +import '../../../services/frost.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/extensions/extensions.dart'; +import '../../../utilities/logger.dart'; +import '../../crypto_currency/coins/bitcoin_frost.dart'; +import '../../crypto_currency/crypto_currency.dart'; +import '../../crypto_currency/intermediate/frost_currency.dart'; +import '../../isar/models/frost_wallet_info.dart'; +import '../../models/tx_data.dart'; +import '../wallet.dart'; class BitcoinFrostWallet extends Wallet { BitcoinFrostWallet(CryptoCurrencyNetwork network) @@ -351,7 +351,7 @@ class BitcoinFrostWallet extends Wallet { final tx = await electrumXCachedClient.getTransaction( txHash: txHash["tx_hash"] as String, verbose: true, - coin: coin, + cryptoCurrency: coin, ); if (!_duplicateTxCheck(allTransactions, tx["txid"] as String)) { @@ -389,7 +389,7 @@ class BitcoinFrostWallet extends Wallet { final inputTx = await electrumXCachedClient.getTransaction( txHash: txid, - coin: cryptoCurrency.coin, + cryptoCurrency: cryptoCurrency, ); final prevOutJson = Map.from( @@ -724,7 +724,9 @@ class BitcoinFrostWallet extends Wallet { await _updateKnownSalts(updatedKnownSalts); } else { // clear cache - await electrumXCachedClient.clearSharedTransactionCache(coin: coin); + await electrumXCachedClient.clearSharedTransactionCache( + cryptoCurrency: coin, + ); await mainDB.deleteWalletBlockchainData(walletId); } @@ -1082,7 +1084,7 @@ class BitcoinFrostWallet extends Wallet { // TODO [prio=low]: Use ElectrumXInterface method. Future _updateElectrumX() async { final failovers = nodeService - .failoverNodesFor(coin: cryptoCurrency.coin) + .failoverNodesFor(currency: cryptoCurrency) .map( (e) => ElectrumXNode( address: e.host, @@ -1137,7 +1139,7 @@ class BitcoinFrostWallet extends Wallet { final txn = await electrumXCachedClient.getTransaction( txHash: jsonUTXO["tx_hash"] as String, verbose: true, - coin: cryptoCurrency.coin, + cryptoCurrency: cryptoCurrency, ); final vout = jsonUTXO["tx_pos"] as int; diff --git a/lib/wallets/wallet/impl/bitcoin_wallet.dart b/lib/wallets/wallet/impl/bitcoin_wallet.dart index 15fd58fcc..207ca30fc 100644 --- a/lib/wallets/wallet/impl/bitcoin_wallet.dart +++ b/lib/wallets/wallet/impl/bitcoin_wallet.dart @@ -1,13 +1,13 @@ import 'package:isar/isar.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/bitcoin.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/crypto_currency/interfaces/paynym_currency_interface.dart'; -import 'package:stackwallet/wallets/wallet/intermediate/bip39_hd_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/coin_control_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart'; +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../crypto_currency/coins/bitcoin.dart'; +import '../../crypto_currency/crypto_currency.dart'; +import '../../crypto_currency/interfaces/paynym_currency_interface.dart'; +import '../intermediate/bip39_hd_wallet.dart'; +import '../wallet_mixin_interfaces/coin_control_interface.dart'; +import '../wallet_mixin_interfaces/electrumx_interface.dart'; +import '../wallet_mixin_interfaces/paynym_interface.dart'; class BitcoinWallet extends Bip39HDWallet with ElectrumXInterface, CoinControlInterface, PaynymInterface { diff --git a/lib/wallets/wallet/impl/bitcoincash_wallet.dart b/lib/wallets/wallet/impl/bitcoincash_wallet.dart index 2b9355e2d..45a81afd2 100644 --- a/lib/wallets/wallet/impl/bitcoincash_wallet.dart +++ b/lib/wallets/wallet/impl/bitcoincash_wallet.dart @@ -1,37 +1,38 @@ import 'package:bitbox/bitbox.dart' as bitbox; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/input_v2.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/output_v2.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart'; -import 'package:stackwallet/services/coins/bitcoincash/bch_utils.dart'; -import 'package:stackwallet/services/coins/bitcoincash/cashtokens.dart' +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../../models/isar/models/blockchain_data/transaction.dart'; +import '../../../models/isar/models/blockchain_data/v2/input_v2.dart'; +import '../../../models/isar/models/blockchain_data/v2/output_v2.dart'; +import '../../../models/isar/models/blockchain_data/v2/transaction_v2.dart'; +import '../../../services/coins/bitcoincash/bch_utils.dart'; +import '../../../services/coins/bitcoincash/cashtokens.dart' as cash_tokens; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart'; -import 'package:stackwallet/utilities/extensions/extensions.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/bitcoincash.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/wallet/intermediate/bip39_hd_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/bcash_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/cash_fusion_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/coin_control_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/enums/derive_path_type_enum.dart'; +import '../../../utilities/extensions/extensions.dart'; +import '../../../utilities/logger.dart'; +import '../../crypto_currency/coins/bitcoincash.dart'; +import '../../crypto_currency/crypto_currency.dart'; +import '../../crypto_currency/interfaces/electrumx_currency_interface.dart'; +import '../intermediate/bip39_hd_wallet.dart'; +import '../wallet_mixin_interfaces/bcash_interface.dart'; +import '../wallet_mixin_interfaces/cash_fusion_interface.dart'; +import '../wallet_mixin_interfaces/coin_control_interface.dart'; +import '../wallet_mixin_interfaces/electrumx_interface.dart'; -class BitcoincashWallet extends Bip39HDWallet +class BitcoincashWallet + extends Bip39HDWallet with - ElectrumXInterface, - BCashInterface, - CoinControlInterface, - CashFusionInterface { + ElectrumXInterface, + BCashInterface, + CoinControlInterface, + CashFusionInterface { @override int get isarTransactionVersion => 2; BitcoincashWallet(CryptoCurrencyNetwork network) - : super(Bitcoincash(network)); + : super(Bitcoincash(network) as T); @override FilterOperation? get changeAddressFilterOperation => FilterGroup.and( @@ -130,7 +131,7 @@ class BitcoincashWallet extends Bip39HDWallet final tx = await electrumXCachedClient.getTransaction( txHash: txHash["tx_hash"] as String, verbose: true, - coin: cryptoCurrency.coin, + cryptoCurrency: cryptoCurrency, ); // check for duplicates before adding to list @@ -171,7 +172,7 @@ class BitcoincashWallet extends Bip39HDWallet final inputTx = await electrumXCachedClient.getTransaction( txHash: txid, - coin: cryptoCurrency.coin, + cryptoCurrency: cryptoCurrency, ); try { @@ -361,7 +362,7 @@ class BitcoincashWallet extends Bip39HDWallet return Amount( rawValue: BigInt.from(((181 * inputCount) + (34 * outputCount) + 10) * (feeRatePerKB / 1000).ceil()), - fractionDigits: info.coin.decimals, + fractionDigits: info.coin.fractionDigits, ); } diff --git a/lib/wallets/wallet/impl/dogecoin_wallet.dart b/lib/wallets/wallet/impl/dogecoin_wallet.dart index 210ca64cd..f91cda4e5 100644 --- a/lib/wallets/wallet/impl/dogecoin_wallet.dart +++ b/lib/wallets/wallet/impl/dogecoin_wallet.dart @@ -1,21 +1,22 @@ import 'package:isar/isar.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/input_v2.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/output_v2.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/extensions/extensions.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/dogecoin.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/wallet/intermediate/bip39_hd_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/coin_control_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart'; +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../../models/isar/models/blockchain_data/transaction.dart'; +import '../../../models/isar/models/blockchain_data/v2/input_v2.dart'; +import '../../../models/isar/models/blockchain_data/v2/output_v2.dart'; +import '../../../models/isar/models/blockchain_data/v2/transaction_v2.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/extensions/extensions.dart'; +import '../../../utilities/logger.dart'; +import '../../crypto_currency/coins/dogecoin.dart'; +import '../../crypto_currency/crypto_currency.dart'; +import '../../crypto_currency/interfaces/electrumx_currency_interface.dart'; +import '../intermediate/bip39_hd_wallet.dart'; +import '../wallet_mixin_interfaces/coin_control_interface.dart'; +import '../wallet_mixin_interfaces/electrumx_interface.dart'; -class DogecoinWallet extends Bip39HDWallet - with ElectrumXInterface, CoinControlInterface { - DogecoinWallet(CryptoCurrencyNetwork network) : super(Dogecoin(network)); +class DogecoinWallet + extends Bip39HDWallet with ElectrumXInterface, CoinControlInterface { + DogecoinWallet(CryptoCurrencyNetwork network) : super(Dogecoin(network) as T); @override int get maximumFeerate => 2500000; // 1000x default value @@ -89,7 +90,7 @@ class DogecoinWallet extends Bip39HDWallet final tx = await electrumXCachedClient.getTransaction( txHash: txHash["tx_hash"] as String, verbose: true, - coin: cryptoCurrency.coin, + cryptoCurrency: cryptoCurrency, ); // Only tx to list once. @@ -131,7 +132,7 @@ class DogecoinWallet extends Bip39HDWallet final inputTx = await electrumXCachedClient.getTransaction( txHash: txid, - coin: cryptoCurrency.coin, + cryptoCurrency: cryptoCurrency, ); final prevOutJson = Map.from( diff --git a/lib/wallets/wallet/impl/ecash_wallet.dart b/lib/wallets/wallet/impl/ecash_wallet.dart index 2946c6069..2a0eeb1e8 100644 --- a/lib/wallets/wallet/impl/ecash_wallet.dart +++ b/lib/wallets/wallet/impl/ecash_wallet.dart @@ -1,36 +1,36 @@ import 'package:bitbox/bitbox.dart' as bitbox; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/input_v2.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/output_v2.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart'; -import 'package:stackwallet/services/coins/bitcoincash/bch_utils.dart'; -import 'package:stackwallet/services/coins/bitcoincash/cashtokens.dart' +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../../models/isar/models/blockchain_data/transaction.dart'; +import '../../../models/isar/models/blockchain_data/v2/input_v2.dart'; +import '../../../models/isar/models/blockchain_data/v2/output_v2.dart'; +import '../../../models/isar/models/blockchain_data/v2/transaction_v2.dart'; +import '../../../services/coins/bitcoincash/bch_utils.dart'; +import '../../../services/coins/bitcoincash/cashtokens.dart' as cash_tokens; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart'; -import 'package:stackwallet/utilities/extensions/extensions.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/ecash.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/wallet/intermediate/bip39_hd_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/bcash_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/cash_fusion_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/coin_control_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/enums/derive_path_type_enum.dart'; +import '../../../utilities/extensions/extensions.dart'; +import '../../../utilities/logger.dart'; +import '../../crypto_currency/coins/ecash.dart'; +import '../../crypto_currency/crypto_currency.dart'; +import '../../crypto_currency/interfaces/electrumx_currency_interface.dart'; +import '../intermediate/bip39_hd_wallet.dart'; +import '../wallet_mixin_interfaces/bcash_interface.dart'; +import '../wallet_mixin_interfaces/cash_fusion_interface.dart'; +import '../wallet_mixin_interfaces/coin_control_interface.dart'; +import '../wallet_mixin_interfaces/electrumx_interface.dart'; -class EcashWallet extends Bip39HDWallet +class EcashWallet extends Bip39HDWallet with - ElectrumXInterface, - BCashInterface, - CoinControlInterface, - CashFusionInterface { + ElectrumXInterface, + BCashInterface, + CoinControlInterface, + CashFusionInterface { @override int get isarTransactionVersion => 2; - EcashWallet(CryptoCurrencyNetwork network) : super(Ecash(network)); + EcashWallet(CryptoCurrencyNetwork network) : super(Ecash(network) as T); @override FilterOperation? get changeAddressFilterOperation => FilterGroup.and( @@ -123,7 +123,7 @@ class EcashWallet extends Bip39HDWallet final tx = await electrumXCachedClient.getTransaction( txHash: txHash["tx_hash"] as String, verbose: true, - coin: cryptoCurrency.coin, + cryptoCurrency: cryptoCurrency, ); // check for duplicates before adding to list @@ -164,7 +164,7 @@ class EcashWallet extends Bip39HDWallet final inputTx = await electrumXCachedClient.getTransaction( txHash: txid, - coin: cryptoCurrency.coin, + cryptoCurrency: cryptoCurrency, ); final prevOutJson = Map.from( @@ -353,7 +353,7 @@ class EcashWallet extends Bip39HDWallet return Amount( rawValue: BigInt.from(((181 * inputCount) + (34 * outputCount) + 10) * (feeRatePerKB / 1000).ceil()), - fractionDigits: info.coin.decimals, + fractionDigits: info.coin.fractionDigits, ); } diff --git a/lib/wallets/wallet/impl/epiccash_wallet.dart b/lib/wallets/wallet/impl/epiccash_wallet.dart index b2e5ad3f1..62b43ff1d 100644 --- a/lib/wallets/wallet/impl/epiccash_wallet.dart +++ b/lib/wallets/wallet/impl/epiccash_wallet.dart @@ -9,33 +9,32 @@ import 'package:flutter_libepiccash/models/transaction.dart' as epic_models; import 'package:isar/isar.dart'; import 'package:mutex/mutex.dart'; import 'package:stack_wallet_backup/generate_password.dart'; -import 'package:stackwallet/models/balance.dart'; -import 'package:stackwallet/models/epicbox_config_model.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/input_v2.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/output_v2.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart'; -import 'package:stackwallet/models/node_model.dart'; -import 'package:stackwallet/models/paymint/fee_object_model.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart'; -import 'package:stackwallet/services/event_bus/events/global/blocks_remaining_event.dart'; -import 'package:stackwallet/services/event_bus/events/global/node_connection_status_changed_event.dart'; -import 'package:stackwallet/services/event_bus/events/global/refresh_percent_changed_event.dart'; -import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart'; -import 'package:stackwallet/services/event_bus/global_event_bus.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/default_epicboxes.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/stack_file_system.dart'; -import 'package:stackwallet/utilities/test_epic_box_connection.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/epiccash.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/models/tx_data.dart'; -import 'package:stackwallet/wallets/wallet/intermediate/bip39_wallet.dart'; -import 'package:stackwallet/wallets/wallet/supporting/epiccash_wallet_info_extension.dart'; +import '../../../models/balance.dart'; +import '../../../models/epicbox_config_model.dart'; +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../../models/isar/models/blockchain_data/transaction.dart'; +import '../../../models/isar/models/blockchain_data/v2/input_v2.dart'; +import '../../../models/isar/models/blockchain_data/v2/output_v2.dart'; +import '../../../models/isar/models/blockchain_data/v2/transaction_v2.dart'; +import '../../../models/node_model.dart'; +import '../../../models/paymint/fee_object_model.dart'; +import '../../../pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart'; +import '../../../services/event_bus/events/global/blocks_remaining_event.dart'; +import '../../../services/event_bus/events/global/node_connection_status_changed_event.dart'; +import '../../../services/event_bus/events/global/refresh_percent_changed_event.dart'; +import '../../../services/event_bus/events/global/wallet_sync_status_changed_event.dart'; +import '../../../services/event_bus/global_event_bus.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/default_epicboxes.dart'; +import '../../../utilities/flutter_secure_storage_interface.dart'; +import '../../../utilities/logger.dart'; +import '../../../utilities/stack_file_system.dart'; +import '../../../utilities/test_epic_box_connection.dart'; +import '../../crypto_currency/coins/epiccash.dart'; +import '../../crypto_currency/crypto_currency.dart'; +import '../../models/tx_data.dart'; +import '../intermediate/bip39_wallet.dart'; +import '../supporting/epiccash_wallet_info_extension.dart'; import 'package:web_socket_channel/web_socket_channel.dart'; // @@ -543,7 +542,7 @@ class EpiccashWallet extends Bip39Wallet { } else { try { Logging.instance.log( - "initializeExisting() ${cryptoCurrency.coin.prettyName} wallet", + "initializeExisting() ${cryptoCurrency.prettyName} wallet", level: LogLevel.Info); final config = await _getRealConfig(); @@ -774,7 +773,7 @@ class EpiccashWallet extends Bip39Wallet { WalletSyncStatusChangedEvent( WalletSyncStatus.syncing, walletId, - cryptoCurrency.coin, + cryptoCurrency, ), ); @@ -831,7 +830,7 @@ class EpiccashWallet extends Bip39Wallet { WalletSyncStatusChangedEvent( WalletSyncStatus.synced, walletId, - cryptoCurrency.coin, + cryptoCurrency, ), ); @@ -853,14 +852,14 @@ class EpiccashWallet extends Bip39Wallet { NodeConnectionStatusChangedEvent( NodeConnectionStatus.disconnected, walletId, - cryptoCurrency.coin, + cryptoCurrency, ), ); GlobalEventBus.instance.fire( WalletSyncStatusChangedEvent( WalletSyncStatus.unableToSync, walletId, - cryptoCurrency.coin, + cryptoCurrency, ), ); Logging.instance.log( @@ -1072,7 +1071,7 @@ class EpiccashWallet extends Bip39Wallet { @override Future pingCheck() async { try { - final node = nodeService.getPrimaryNodeFor(coin: cryptoCurrency.coin); + final node = nodeService.getPrimaryNodeFor(currency: cryptoCurrency); // force unwrap optional as we want connection test to fail if wallet // wasn't initialized or epicbox node was set to null diff --git a/lib/wallets/wallet/impl/ethereum_wallet.dart b/lib/wallets/wallet/impl/ethereum_wallet.dart index a4ad1b341..05b075868 100644 --- a/lib/wallets/wallet/impl/ethereum_wallet.dart +++ b/lib/wallets/wallet/impl/ethereum_wallet.dart @@ -5,26 +5,25 @@ import 'package:decimal/decimal.dart'; import 'package:ethereum_addresses/ethereum_addresses.dart'; import 'package:http/http.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/balance.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/input_v2.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/output_v2.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart'; -import 'package:stackwallet/models/paymint/fee_object_model.dart'; -import 'package:stackwallet/services/ethereum/ethereum_api.dart'; -import 'package:stackwallet/services/event_bus/events/global/updated_in_background_event.dart'; -import 'package:stackwallet/services/event_bus/global_event_bus.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart'; -import 'package:stackwallet/utilities/eth_commons.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/ethereum.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/models/tx_data.dart'; -import 'package:stackwallet/wallets/wallet/intermediate/bip39_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/private_key_interface.dart'; +import '../../../models/balance.dart'; +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../../models/isar/models/blockchain_data/transaction.dart'; +import '../../../models/isar/models/blockchain_data/v2/input_v2.dart'; +import '../../../models/isar/models/blockchain_data/v2/output_v2.dart'; +import '../../../models/isar/models/blockchain_data/v2/transaction_v2.dart'; +import '../../../models/paymint/fee_object_model.dart'; +import '../../../services/ethereum/ethereum_api.dart'; +import '../../../services/event_bus/events/global/updated_in_background_event.dart'; +import '../../../services/event_bus/global_event_bus.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/enums/fee_rate_type_enum.dart'; +import '../../../utilities/eth_commons.dart'; +import '../../../utilities/logger.dart'; +import '../../crypto_currency/coins/ethereum.dart'; +import '../../crypto_currency/crypto_currency.dart'; +import '../../models/tx_data.dart'; +import '../intermediate/bip39_wallet.dart'; +import '../wallet_mixin_interfaces/private_key_interface.dart'; import 'package:web3dart/web3dart.dart' as web3; // Eth can not use tor with web3dart @@ -239,7 +238,7 @@ class EthereumWallet extends Bip39Wallet with PrivateKeyInterface { if (response.value == null) { Logging.instance.log( - "Failed to refresh transactions for ${cryptoCurrency.coin.prettyName} ${info.name} " + "Failed to refresh transactions for ${cryptoCurrency.prettyName} ${info.name} " "$walletId: ${response.exception}", level: LogLevel.Warning, ); @@ -349,7 +348,7 @@ class EthereumWallet extends Bip39Wallet with PrivateKeyInterface { await mainDB.updateOrPutTransactionV2s(txns); } else { Logging.instance.log( - "Failed to refresh transactions with nonces for ${cryptoCurrency.coin.prettyName} " + "Failed to refresh transactions with nonces for ${cryptoCurrency.prettyName} " "${info.name} $walletId: ${txsResponse.exception}", level: LogLevel.Warning, ); diff --git a/lib/wallets/wallet/impl/firo_wallet.dart b/lib/wallets/wallet/impl/firo_wallet.dart index ea109fe61..0be178086 100644 --- a/lib/wallets/wallet/impl/firo_wallet.dart +++ b/lib/wallets/wallet/impl/firo_wallet.dart @@ -5,32 +5,33 @@ import 'dart:math'; import 'package:decimal/decimal.dart'; import 'package:flutter_libsparkmobile/flutter_libsparkmobile.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/input_v2.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/output_v2.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/extensions/extensions.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/firo.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/isar/models/spark_coin.dart'; -import 'package:stackwallet/wallets/isar/models/wallet_info.dart'; -import 'package:stackwallet/wallets/models/tx_data.dart'; -import 'package:stackwallet/wallets/wallet/intermediate/bip39_hd_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/lelantus_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart'; +import '../../../models/isar/models/blockchain_data/v2/input_v2.dart'; +import '../../../models/isar/models/blockchain_data/v2/output_v2.dart'; +import '../../../models/isar/models/blockchain_data/v2/transaction_v2.dart'; +import '../../../models/isar/models/isar_models.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/extensions/extensions.dart'; +import '../../../utilities/logger.dart'; +import '../../../utilities/util.dart'; +import '../../crypto_currency/coins/firo.dart'; +import '../../crypto_currency/crypto_currency.dart'; +import '../../crypto_currency/interfaces/electrumx_currency_interface.dart'; +import '../../isar/models/spark_coin.dart'; +import '../../isar/models/wallet_info.dart'; +import '../../models/tx_data.dart'; +import '../intermediate/bip39_hd_wallet.dart'; +import '../wallet_mixin_interfaces/electrumx_interface.dart'; +import '../wallet_mixin_interfaces/lelantus_interface.dart'; +import '../wallet_mixin_interfaces/spark_interface.dart'; const sparkStartBlock = 819300; // (approx 18 Jan 2024) -class FiroWallet extends Bip39HDWallet - with ElectrumXInterface, LelantusInterface, SparkInterface { +class FiroWallet extends Bip39HDWallet + with ElectrumXInterface, LelantusInterface, SparkInterface { // IMPORTANT: The order of the above mixins matters. // SparkInterface MUST come after LelantusInterface. - FiroWallet(CryptoCurrencyNetwork network) : super(Firo(network)); + FiroWallet(CryptoCurrencyNetwork network) : super(Firo(network) as T); @override int get isarTransactionVersion => 2; @@ -112,7 +113,7 @@ class FiroWallet extends Bip39HDWallet final txn = await electrumXCachedClient.getTransaction( txHash: tx.txid, verbose: true, - coin: info.coin, + cryptoCurrency: info.coin, ); final height = txn["height"] as int?; @@ -146,7 +147,7 @@ class FiroWallet extends Bip39HDWallet tx = await electrumXCachedClient.getTransaction( txHash: txHash["tx_hash"] as String, verbose: true, - coin: info.coin, + cryptoCurrency: info.coin, ); } catch (_) { continue; @@ -379,7 +380,7 @@ class FiroWallet extends Bip39HDWallet } else if (coinbase == null && txid != null && vout != null) { final inputTx = await electrumXCachedClient.getTransaction( txHash: txid, - coin: cryptoCurrency.coin, + cryptoCurrency: cryptoCurrency, ); final prevOutJson = Map.from( @@ -603,7 +604,7 @@ class FiroWallet extends Bip39HDWallet if (isRescan) { // clear cache await electrumXCachedClient.clearSharedTransactionCache( - coin: info.coin); + cryptoCurrency: info.coin); // clear blockchain info await mainDB.deleteWalletBlockchainData(walletId); } @@ -613,19 +614,19 @@ class FiroWallet extends Bip39HDWallet final setDataMapFuture = getSetDataMap(latestSetId); final usedSerialNumbersFuture = electrumXCachedClient.getUsedCoinSerials( - coin: info.coin, + cryptoCurrency: info.coin, ); // spark final latestSparkCoinId = await electrumXClient.getSparkLatestCoinId(); final sparkAnonSetFuture = electrumXCachedClient.getSparkAnonymitySet( groupId: latestSparkCoinId.toString(), - coin: info.coin, + cryptoCurrency: info.coin, useOnlyCacheIfNotEmpty: false, ); final sparkUsedCoinTagsFuture = electrumXCachedClient.getSparkUsedCoinsTags( - coin: info.coin, + cryptoCurrency: info.coin, ); // receiving addresses diff --git a/lib/wallets/wallet/impl/litecoin_wallet.dart b/lib/wallets/wallet/impl/litecoin_wallet.dart index a2c6b00c3..0cce6fd8d 100644 --- a/lib/wallets/wallet/impl/litecoin_wallet.dart +++ b/lib/wallets/wallet/impl/litecoin_wallet.dart @@ -1,25 +1,27 @@ import 'package:isar/isar.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/input_v2.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/output_v2.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart'; -import 'package:stackwallet/models/isar/ordinal.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/litecoin.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/wallet/intermediate/bip39_hd_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/coin_control_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/ordinals_interface.dart'; +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../../models/isar/models/blockchain_data/transaction.dart'; +import '../../../models/isar/models/blockchain_data/v2/input_v2.dart'; +import '../../../models/isar/models/blockchain_data/v2/output_v2.dart'; +import '../../../models/isar/models/blockchain_data/v2/transaction_v2.dart'; +import '../../../models/isar/ordinal.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/logger.dart'; +import '../../crypto_currency/coins/litecoin.dart'; +import '../../crypto_currency/crypto_currency.dart'; +import '../../crypto_currency/interfaces/electrumx_currency_interface.dart'; +import '../intermediate/bip39_hd_wallet.dart'; +import '../wallet_mixin_interfaces/coin_control_interface.dart'; +import '../wallet_mixin_interfaces/electrumx_interface.dart'; +import '../wallet_mixin_interfaces/ordinals_interface.dart'; -class LitecoinWallet extends Bip39HDWallet - with ElectrumXInterface, CoinControlInterface, OrdinalsInterface { +class LitecoinWallet + extends Bip39HDWallet + with ElectrumXInterface, CoinControlInterface, OrdinalsInterface { @override int get isarTransactionVersion => 2; - LitecoinWallet(CryptoCurrencyNetwork network) : super(Litecoin(network)); + LitecoinWallet(CryptoCurrencyNetwork network) : super(Litecoin(network) as T); @override FilterOperation? get changeAddressFilterOperation => @@ -91,7 +93,7 @@ class LitecoinWallet extends Bip39HDWallet final tx = await electrumXCachedClient.getTransaction( txHash: txHash["tx_hash"] as String, verbose: true, - coin: cryptoCurrency.coin, + cryptoCurrency: cryptoCurrency, ); // Only tx to list once. @@ -135,7 +137,7 @@ class LitecoinWallet extends Bip39HDWallet final inputTx = await electrumXCachedClient.getTransaction( txHash: txid, - coin: cryptoCurrency.coin, + cryptoCurrency: cryptoCurrency, ); final prevOutJson = Map.from( diff --git a/lib/wallets/wallet/impl/monero_wallet.dart b/lib/wallets/wallet/impl/monero_wallet.dart index e0d70db36..7c1007064 100644 --- a/lib/wallets/wallet/impl/monero_wallet.dart +++ b/lib/wallets/wallet/impl/monero_wallet.dart @@ -18,18 +18,18 @@ import 'package:flutter_libmonero/core/wallet_creation_service.dart'; import 'package:flutter_libmonero/monero/monero.dart' as xmr_dart; import 'package:flutter_libmonero/view_model/send/output.dart' as monero_output; import 'package:isar/isar.dart'; -import 'package:stackwallet/db/hive/db.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/monero.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/models/tx_data.dart'; -import 'package:stackwallet/wallets/wallet/intermediate/cryptonote_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/cw_based_interface.dart'; +import '../../../db/hive/db.dart'; +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../../models/isar/models/blockchain_data/transaction.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/enums/fee_rate_type_enum.dart'; +import '../../../utilities/logger.dart'; +import '../../crypto_currency/coins/monero.dart'; +import '../../crypto_currency/crypto_currency.dart'; +import '../../models/tx_data.dart'; +import '../intermediate/cryptonote_wallet.dart'; +import '../wallet.dart'; +import '../wallet_mixin_interfaces/cw_based_interface.dart'; import 'package:tuple/tuple.dart'; class MoneroWallet extends CryptonoteWallet with CwBasedInterface { diff --git a/lib/wallets/wallet/impl/namecoin_wallet.dart b/lib/wallets/wallet/impl/namecoin_wallet.dart index c921b34b8..48321a888 100644 --- a/lib/wallets/wallet/impl/namecoin_wallet.dart +++ b/lib/wallets/wallet/impl/namecoin_wallet.dart @@ -1,23 +1,24 @@ import 'package:isar/isar.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/input_v2.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/output_v2.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/namecoin.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/wallet/intermediate/bip39_hd_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/coin_control_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart'; +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../../models/isar/models/blockchain_data/transaction.dart'; +import '../../../models/isar/models/blockchain_data/v2/input_v2.dart'; +import '../../../models/isar/models/blockchain_data/v2/output_v2.dart'; +import '../../../models/isar/models/blockchain_data/v2/transaction_v2.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/logger.dart'; +import '../../crypto_currency/coins/namecoin.dart'; +import '../../crypto_currency/crypto_currency.dart'; +import '../../crypto_currency/interfaces/electrumx_currency_interface.dart'; +import '../intermediate/bip39_hd_wallet.dart'; +import '../wallet_mixin_interfaces/coin_control_interface.dart'; +import '../wallet_mixin_interfaces/electrumx_interface.dart'; -class NamecoinWallet extends Bip39HDWallet - with ElectrumXInterface, CoinControlInterface { +class NamecoinWallet extends Bip39HDWallet + with ElectrumXInterface, CoinControlInterface { @override int get isarTransactionVersion => 2; - NamecoinWallet(CryptoCurrencyNetwork network) : super(Namecoin(network)); + NamecoinWallet(CryptoCurrencyNetwork network) : super(Namecoin(network) as T); @override FilterOperation? get changeAddressFilterOperation => @@ -117,7 +118,7 @@ class NamecoinWallet extends Bip39HDWallet final tx = await electrumXCachedClient.getTransaction( txHash: txHash["tx_hash"] as String, verbose: true, - coin: cryptoCurrency.coin, + cryptoCurrency: cryptoCurrency, ); // Only tx to list once. @@ -159,7 +160,7 @@ class NamecoinWallet extends Bip39HDWallet final inputTx = await electrumXCachedClient.getTransaction( txHash: txid, - coin: cryptoCurrency.coin, + cryptoCurrency: cryptoCurrency, ); final prevOutJson = Map.from( diff --git a/lib/wallets/wallet/impl/nano_wallet.dart b/lib/wallets/wallet/impl/nano_wallet.dart index c53d6cede..e541ad1f7 100644 --- a/lib/wallets/wallet/impl/nano_wallet.dart +++ b/lib/wallets/wallet/impl/nano_wallet.dart @@ -1,8 +1,8 @@ -import 'package:stackwallet/wallets/crypto_currency/coins/nano.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/nano_currency.dart'; -import 'package:stackwallet/wallets/wallet/intermediate/bip39_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/nano_interface.dart'; +import '../../crypto_currency/coins/nano.dart'; +import '../../crypto_currency/crypto_currency.dart'; +import '../../crypto_currency/intermediate/nano_currency.dart'; +import '../intermediate/bip39_wallet.dart'; +import '../wallet_mixin_interfaces/nano_interface.dart'; class NanoWallet extends Bip39Wallet with NanoInterface { NanoWallet(CryptoCurrencyNetwork network) : super(Nano(network)); diff --git a/lib/wallets/wallet/impl/particl_wallet.dart b/lib/wallets/wallet/impl/particl_wallet.dart index 8c4a12a28..760c88e97 100644 --- a/lib/wallets/wallet/impl/particl_wallet.dart +++ b/lib/wallets/wallet/impl/particl_wallet.dart @@ -2,29 +2,31 @@ import 'dart:typed_data'; import 'package:bitcoindart/bitcoindart.dart' as bitcoindart; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/input_v2.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/output_v2.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart'; -import 'package:stackwallet/models/signing_data.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart'; -import 'package:stackwallet/utilities/extensions/impl/uint8_list.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/particl.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/models/tx_data.dart'; -import 'package:stackwallet/wallets/wallet/intermediate/bip39_hd_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/coin_control_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart'; +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../../models/isar/models/blockchain_data/transaction.dart'; +import '../../../models/isar/models/blockchain_data/v2/input_v2.dart'; +import '../../../models/isar/models/blockchain_data/v2/output_v2.dart'; +import '../../../models/isar/models/blockchain_data/v2/transaction_v2.dart'; +import '../../../models/signing_data.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/enums/derive_path_type_enum.dart'; +import '../../../utilities/extensions/impl/uint8_list.dart'; +import '../../../utilities/logger.dart'; +import '../../crypto_currency/coins/particl.dart'; +import '../../crypto_currency/crypto_currency.dart'; +import '../../crypto_currency/interfaces/electrumx_currency_interface.dart'; +import '../../models/tx_data.dart'; +import '../intermediate/bip39_hd_wallet.dart'; +import '../wallet_mixin_interfaces/coin_control_interface.dart'; +import '../wallet_mixin_interfaces/electrumx_interface.dart'; -class ParticlWallet extends Bip39HDWallet - with ElectrumXInterface, CoinControlInterface { +class ParticlWallet + extends Bip39HDWallet + with ElectrumXInterface, CoinControlInterface { @override int get isarTransactionVersion => 2; - ParticlWallet(CryptoCurrencyNetwork network) : super(Particl(network)); + ParticlWallet(CryptoCurrencyNetwork network) : super(Particl(network) as T); // TODO: double check these filter operations are correct and do not require additional parameters @override @@ -162,7 +164,7 @@ class ParticlWallet extends Bip39HDWallet final tx = await electrumXCachedClient.getTransaction( txHash: txHash["tx_hash"] as String, verbose: true, - coin: cryptoCurrency.coin, + cryptoCurrency: cryptoCurrency, ); // Only tx to list once. @@ -204,7 +206,7 @@ class ParticlWallet extends Bip39HDWallet final inputTx = await electrumXCachedClient.getTransaction( txHash: txid, - coin: cryptoCurrency.coin, + cryptoCurrency: cryptoCurrency, ); final prevOutJson = Map.from( diff --git a/lib/wallets/wallet/impl/peercoin_wallet.dart b/lib/wallets/wallet/impl/peercoin_wallet.dart index e08566f45..b7297dd47 100644 --- a/lib/wallets/wallet/impl/peercoin_wallet.dart +++ b/lib/wallets/wallet/impl/peercoin_wallet.dart @@ -1,23 +1,25 @@ import 'package:isar/isar.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/input_v2.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/output_v2.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/peercoin.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/wallet/intermediate/bip39_hd_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/coin_control_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart'; +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../../models/isar/models/blockchain_data/transaction.dart'; +import '../../../models/isar/models/blockchain_data/v2/input_v2.dart'; +import '../../../models/isar/models/blockchain_data/v2/output_v2.dart'; +import '../../../models/isar/models/blockchain_data/v2/transaction_v2.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/logger.dart'; +import '../../crypto_currency/coins/peercoin.dart'; +import '../../crypto_currency/crypto_currency.dart'; +import '../../crypto_currency/interfaces/electrumx_currency_interface.dart'; +import '../intermediate/bip39_hd_wallet.dart'; +import '../wallet_mixin_interfaces/coin_control_interface.dart'; +import '../wallet_mixin_interfaces/electrumx_interface.dart'; -class PeercoinWallet extends Bip39HDWallet - with ElectrumXInterface, CoinControlInterface { +class PeercoinWallet + extends Bip39HDWallet + with ElectrumXInterface, CoinControlInterface { @override int get isarTransactionVersion => 2; - PeercoinWallet(CryptoCurrencyNetwork network) : super(Peercoin(network)); + PeercoinWallet(CryptoCurrencyNetwork network) : super(Peercoin(network) as T); @override FilterOperation? get changeAddressFilterOperation => @@ -123,7 +125,7 @@ class PeercoinWallet extends Bip39HDWallet final tx = await electrumXCachedClient.getTransaction( txHash: txHash["tx_hash"] as String, verbose: true, - coin: cryptoCurrency.coin, + cryptoCurrency: cryptoCurrency, ); // Only tx to list once. @@ -165,7 +167,7 @@ class PeercoinWallet extends Bip39HDWallet final inputTx = await electrumXCachedClient.getTransaction( txHash: txid, - coin: cryptoCurrency.coin, + cryptoCurrency: cryptoCurrency, ); final prevOutJson = Map.from( diff --git a/lib/wallets/wallet/impl/solana_wallet.dart b/lib/wallets/wallet/impl/solana_wallet.dart index d2f3582c9..f194dcfee 100644 --- a/lib/wallets/wallet/impl/solana_wallet.dart +++ b/lib/wallets/wallet/impl/solana_wallet.dart @@ -7,22 +7,20 @@ import 'package:isar/isar.dart'; import 'package:socks5_proxy/socks_client.dart'; import 'package:solana/dto.dart'; import 'package:solana/solana.dart'; -import 'package:stackwallet/models/balance.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart' +import '../../../models/balance.dart'; +import '../../../models/isar/models/blockchain_data/transaction.dart' as isar; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/models/node_model.dart'; -import 'package:stackwallet/models/paymint/fee_object_model.dart'; -import 'package:stackwallet/services/node_service.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/default_nodes.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/solana.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/models/tx_data.dart'; -import 'package:stackwallet/wallets/wallet/intermediate/bip39_wallet.dart'; +import '../../../models/isar/models/isar_models.dart'; +import '../../../models/node_model.dart'; +import '../../../models/paymint/fee_object_model.dart'; +import '../../../services/node_service.dart'; +import '../../../services/tor_service.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/logger.dart'; +import '../../crypto_currency/coins/solana.dart'; +import '../../crypto_currency/crypto_currency.dart'; +import '../../models/tx_data.dart'; +import '../intermediate/bip39_wallet.dart'; import 'package:tuple/tuple.dart'; class SolanaWallet extends Bip39Wallet { @@ -49,7 +47,7 @@ class SolanaWallet extends Bip39Wallet { publicKey: List.empty(), derivationIndex: 0, derivationPath: DerivationPath()..value = _addressDerivationPath, - type: cryptoCurrency.coin.primaryAddressType, + type: cryptoCurrency.primaryAddressType, subType: AddressSubType.receiving, ); return addressStruct; @@ -302,19 +300,19 @@ class SolanaWallet extends Bip39Wallet { final newBalance = Balance( total: Amount( rawValue: BigInt.from(balance.value), - fractionDigits: Coin.solana.decimals, + fractionDigits: cryptoCurrency.fractionDigits, ), spendable: Amount( rawValue: BigInt.from(spendableBalance), - fractionDigits: Coin.solana.decimals, + fractionDigits: cryptoCurrency.fractionDigits, ), blockedTotal: Amount( rawValue: BigInt.from(minimumRent), - fractionDigits: Coin.solana.decimals, + fractionDigits: cryptoCurrency.fractionDigits, ), pendingSpendable: Amount( rawValue: BigInt.zero, - fractionDigits: Coin.solana.decimals, + fractionDigits: cryptoCurrency.fractionDigits, ), ); @@ -358,8 +356,8 @@ class SolanaWallet extends Bip39Wallet { NodeModel getCurrentNode() { return _solNode ?? NodeService(secureStorageInterface: secureStorageInterface) - .getPrimaryNodeFor(coin: info.coin) ?? - DefaultNodes.getNodeFor(info.coin); + .getPrimaryNodeFor(currency: info.coin) ?? + info.coin.defaultNode; } @override diff --git a/lib/wallets/wallet/impl/stellar_wallet.dart b/lib/wallets/wallet/impl/stellar_wallet.dart index 657fd7676..3742bc992 100644 --- a/lib/wallets/wallet/impl/stellar_wallet.dart +++ b/lib/wallets/wallet/impl/stellar_wallet.dart @@ -5,25 +5,25 @@ import 'dart:io'; import 'package:isar/isar.dart'; import 'package:mutex/mutex.dart'; import 'package:socks5_proxy/socks.dart'; -import 'package:stackwallet/models/balance.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/input_v2.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/output_v2.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart'; -import 'package:stackwallet/models/paymint/fee_object_model.dart'; -import 'package:stackwallet/services/event_bus/events/global/tor_connection_status_changed_event.dart'; -import 'package:stackwallet/services/event_bus/events/global/tor_status_changed_event.dart'; -import 'package:stackwallet/services/event_bus/global_event_bus.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/test_stellar_node_connection.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/stellar.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/models/tx_data.dart'; -import 'package:stackwallet/wallets/wallet/intermediate/bip39_wallet.dart'; +import '../../../models/balance.dart'; +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../../models/isar/models/blockchain_data/transaction.dart'; +import '../../../models/isar/models/blockchain_data/v2/input_v2.dart'; +import '../../../models/isar/models/blockchain_data/v2/output_v2.dart'; +import '../../../models/isar/models/blockchain_data/v2/transaction_v2.dart'; +import '../../../models/paymint/fee_object_model.dart'; +import '../../../services/event_bus/events/global/tor_connection_status_changed_event.dart'; +import '../../../services/event_bus/events/global/tor_status_changed_event.dart'; +import '../../../services/event_bus/global_event_bus.dart'; +import '../../../services/tor_service.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/enums/fee_rate_type_enum.dart'; +import '../../../utilities/logger.dart'; +import '../../../utilities/test_stellar_node_connection.dart'; +import '../../crypto_currency/coins/stellar.dart'; +import '../../crypto_currency/crypto_currency.dart'; +import '../../models/tx_data.dart'; +import '../intermediate/bip39_wallet.dart'; import 'package:stellar_flutter_sdk/stellar_flutter_sdk.dart' as stellar; class StellarWallet extends Bip39Wallet { diff --git a/lib/wallets/wallet/impl/sub_wallets/eth_token_wallet.dart b/lib/wallets/wallet/impl/sub_wallets/eth_token_wallet.dart index bede12bab..3be7b8edb 100644 --- a/lib/wallets/wallet/impl/sub_wallets/eth_token_wallet.dart +++ b/lib/wallets/wallet/impl/sub_wallets/eth_token_wallet.dart @@ -2,27 +2,28 @@ import 'dart:convert'; import 'package:ethereum_addresses/ethereum_addresses.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/dto/ethereum/eth_token_tx_dto.dart'; -import 'package:stackwallet/dto/ethereum/eth_token_tx_extra_dto.dart'; -import 'package:stackwallet/models/balance.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/input_v2.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/output_v2.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart'; -import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart'; -import 'package:stackwallet/models/paymint/fee_object_model.dart'; -import 'package:stackwallet/services/ethereum/ethereum_api.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart'; -import 'package:stackwallet/utilities/eth_commons.dart'; -import 'package:stackwallet/utilities/extensions/extensions.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/wallets/isar/models/token_wallet_info.dart'; -import 'package:stackwallet/wallets/models/tx_data.dart'; -import 'package:stackwallet/wallets/wallet/impl/ethereum_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet.dart'; import 'package:web3dart/web3dart.dart' as web3dart; +import '../../../../dto/ethereum/eth_token_tx_dto.dart'; +import '../../../../dto/ethereum/eth_token_tx_extra_dto.dart'; +import '../../../../models/balance.dart'; +import '../../../../models/isar/models/blockchain_data/transaction.dart'; +import '../../../../models/isar/models/blockchain_data/v2/input_v2.dart'; +import '../../../../models/isar/models/blockchain_data/v2/output_v2.dart'; +import '../../../../models/isar/models/blockchain_data/v2/transaction_v2.dart'; +import '../../../../models/isar/models/ethereum/eth_contract.dart'; +import '../../../../models/paymint/fee_object_model.dart'; +import '../../../../services/ethereum/ethereum_api.dart'; +import '../../../../utilities/amount/amount.dart'; +import '../../../../utilities/enums/fee_rate_type_enum.dart'; +import '../../../../utilities/eth_commons.dart'; +import '../../../../utilities/extensions/extensions.dart'; +import '../../../../utilities/logger.dart'; +import '../../../isar/models/token_wallet_info.dart'; +import '../../../models/tx_data.dart'; +import '../../wallet.dart'; +import '../ethereum_wallet.dart'; + class EthTokenWallet extends Wallet { @override int get isarTransactionVersion => 2; diff --git a/lib/wallets/wallet/impl/tezos_wallet.dart b/lib/wallets/wallet/impl/tezos_wallet.dart index bdf3374a8..ead0247aa 100644 --- a/lib/wallets/wallet/impl/tezos_wallet.dart +++ b/lib/wallets/wallet/impl/tezos_wallet.dart @@ -1,26 +1,24 @@ import 'dart:io'; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/balance.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; -import 'package:stackwallet/models/node_model.dart'; -import 'package:stackwallet/models/paymint/fee_object_model.dart'; -import 'package:stackwallet/services/node_service.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/default_nodes.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/extensions/impl/string.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/wallets/api/tezos/tezos_account.dart'; -import 'package:stackwallet/wallets/api/tezos/tezos_api.dart'; -import 'package:stackwallet/wallets/api/tezos/tezos_rpc_api.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/tezos.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/isar/models/wallet_info.dart'; -import 'package:stackwallet/wallets/models/tx_data.dart'; -import 'package:stackwallet/wallets/wallet/intermediate/bip39_wallet.dart'; +import '../../../models/balance.dart'; +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../../models/isar/models/blockchain_data/transaction.dart'; +import '../../../models/node_model.dart'; +import '../../../models/paymint/fee_object_model.dart'; +import '../../../services/node_service.dart'; +import '../../../services/tor_service.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/extensions/impl/string.dart'; +import '../../../utilities/logger.dart'; +import '../../api/tezos/tezos_account.dart'; +import '../../api/tezos/tezos_api.dart'; +import '../../api/tezos/tezos_rpc_api.dart'; +import '../../crypto_currency/coins/tezos.dart'; +import '../../crypto_currency/crypto_currency.dart'; +import '../../isar/models/wallet_info.dart'; +import '../../models/tx_data.dart'; +import '../intermediate/bip39_wallet.dart'; import 'package:tezart/tezart.dart' as tezart; import 'package:tuple/tuple.dart'; @@ -108,12 +106,14 @@ class TezosWallet extends Bip39Wallet { // print("COUNTER: $counter"); // print("customFee: $customFee"); // } - ({InternetAddress host, int port})? proxyInfo = + final ({InternetAddress host, int port})? proxyInfo = prefs.useTor ? TorService.sharedInstance.getProxyInfo() : null; - final tezartClient = tezart.TezartClient(server, - proxy: proxyInfo != null - ? "socks5://${proxyInfo.host}:${proxyInfo.port};" - : null); + final tezartClient = tezart.TezartClient( + server, + proxy: proxyInfo != null + ? "socks5://${proxyInfo.host}:${proxyInfo.port};" + : null, + ); final opList = await tezartClient.transferOperation( source: sourceKeyStore, @@ -182,7 +182,7 @@ class TezosWallet extends Bip39Wallet { throw Exception("$runtimeType prepareSend requires 1 recipient"); } - Amount sendAmount = txData.amount!; + final Amount sendAmount = txData.amount!; if (sendAmount > info.cachedBalance.spendable) { throw Exception("Insufficient available balance"); @@ -249,7 +249,7 @@ class TezosWallet extends Bip39Wallet { amount: sendAmount, address: txData.recipients!.first.address, isChange: txData.recipients!.first.isChange, - ) + ), ], // fee: fee, fee: Amount( @@ -522,8 +522,8 @@ class TezosWallet extends Bip39Wallet { @override Future updateNode() async { _xtzNode = NodeService(secureStorageInterface: secureStorageInterface) - .getPrimaryNodeFor(coin: info.coin) ?? - DefaultNodes.getNodeFor(info.coin); + .getPrimaryNodeFor(currency: info.coin) ?? + info.coin.defaultNode; await refresh(); } @@ -532,8 +532,8 @@ class TezosWallet extends Bip39Wallet { NodeModel getCurrentNode() { return _xtzNode ?? NodeService(secureStorageInterface: secureStorageInterface) - .getPrimaryNodeFor(coin: info.coin) ?? - DefaultNodes.getNodeFor(info.coin); + .getPrimaryNodeFor(currency: info.coin) ?? + info.coin.defaultNode; } @override @@ -547,7 +547,7 @@ class TezosWallet extends Bip39Wallet { return; } - List> transactions = []; + final List> transactions = []; for (final theTx in txs) { final TransactionType txType; @@ -563,7 +563,7 @@ class TezosWallet extends Bip39Wallet { txType = TransactionType.unknown; } - var transaction = Transaction( + final transaction = Transaction( walletId: walletId, txid: theTx.hash, timestamp: theTx.timestamp, diff --git a/lib/wallets/wallet/impl/wownero_wallet.dart b/lib/wallets/wallet/impl/wownero_wallet.dart index 6d39f5cfa..48e2c8508 100644 --- a/lib/wallets/wallet/impl/wownero_wallet.dart +++ b/lib/wallets/wallet/impl/wownero_wallet.dart @@ -20,18 +20,18 @@ import 'package:flutter_libmonero/view_model/send/output.dart' as wownero_output; import 'package:flutter_libmonero/wownero/wownero.dart' as wow_dart; import 'package:isar/isar.dart'; -import 'package:stackwallet/db/hive/db.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/wownero.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/models/tx_data.dart'; -import 'package:stackwallet/wallets/wallet/intermediate/cryptonote_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/cw_based_interface.dart'; +import '../../../db/hive/db.dart'; +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../../models/isar/models/blockchain_data/transaction.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/enums/fee_rate_type_enum.dart'; +import '../../../utilities/logger.dart'; +import '../../crypto_currency/coins/wownero.dart'; +import '../../crypto_currency/crypto_currency.dart'; +import '../../models/tx_data.dart'; +import '../intermediate/cryptonote_wallet.dart'; +import '../wallet.dart'; +import '../wallet_mixin_interfaces/cw_based_interface.dart'; import 'package:tuple/tuple.dart'; class WowneroWallet extends CryptonoteWallet with CwBasedInterface { diff --git a/lib/wallets/wallet/intermediate/bip39_hd_wallet.dart b/lib/wallets/wallet/intermediate/bip39_hd_wallet.dart index ffb927713..c276d758a 100644 --- a/lib/wallets/wallet/intermediate/bip39_hd_wallet.dart +++ b/lib/wallets/wallet/intermediate/bip39_hd_wallet.dart @@ -1,13 +1,13 @@ import 'package:bip39/bip39.dart' as bip39; import 'package:coinlib_flutter/coinlib_flutter.dart' as coinlib; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/balance.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_hd_currency.dart'; -import 'package:stackwallet/wallets/wallet/intermediate/bip39_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/multi_address_interface.dart'; +import '../../../models/balance.dart'; +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/enums/derive_path_type_enum.dart'; +import '../../crypto_currency/intermediate/bip39_hd_currency.dart'; +import 'bip39_wallet.dart'; +import '../wallet_mixin_interfaces/multi_address_interface.dart'; abstract class Bip39HDWallet extends Bip39Wallet with MultiAddressInterface { @@ -66,7 +66,7 @@ abstract class Bip39HDWallet extends Bip39Wallet final address = await _generateAddress( chain: chain, index: index, - derivePathType: DerivePathTypeExt.primaryFor(info.coin), + derivePathType: info.coin.primaryDerivePathType, ); await mainDB.updateOrPutAddresses([address]); @@ -88,7 +88,7 @@ abstract class Bip39HDWallet extends Bip39Wallet final address = await _generateAddress( chain: chain, index: index, - derivePathType: DerivePathTypeExt.primaryFor(info.coin), + derivePathType: info.coin.primaryDerivePathType, ); await mainDB.updateOrPutAddresses([address]); @@ -101,7 +101,7 @@ abstract class Bip39HDWallet extends Bip39Wallet final address = await _generateAddress( chain: 0, // receiving index: 0, // initial index - derivePathType: DerivePathTypeExt.primaryFor(info.coin), + derivePathType: info.coin.primaryDerivePathType, ); await mainDB.updateOrPutAddresses([address]); diff --git a/lib/wallets/wallet/intermediate/bip39_wallet.dart b/lib/wallets/wallet/intermediate/bip39_wallet.dart index 0ab794bdd..0d302d0a9 100644 --- a/lib/wallets/wallet/intermediate/bip39_wallet.dart +++ b/lib/wallets/wallet/intermediate/bip39_wallet.dart @@ -1,12 +1,12 @@ import 'package:isar/isar.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_currency.dart'; -import 'package:stackwallet/wallets/wallet/wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/mnemonic_interface.dart'; +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../crypto_currency/intermediate/bip39_currency.dart'; +import '../wallet.dart'; +import '../wallet_mixin_interfaces/mnemonic_interface.dart'; abstract class Bip39Wallet extends Wallet with MnemonicInterface { - Bip39Wallet(T currency) : super(currency); + Bip39Wallet(super.currency); List get standardReceivingAddressFilters => [ FilterCondition.equalTo( diff --git a/lib/wallets/wallet/intermediate/cryptonote_wallet.dart b/lib/wallets/wallet/intermediate/cryptonote_wallet.dart index 61a86aece..95790a169 100644 --- a/lib/wallets/wallet/intermediate/cryptonote_wallet.dart +++ b/lib/wallets/wallet/intermediate/cryptonote_wallet.dart @@ -1,9 +1,9 @@ import 'dart:async'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/cryptonote_currency.dart'; -import 'package:stackwallet/wallets/models/tx_data.dart'; -import 'package:stackwallet/wallets/wallet/wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/mnemonic_interface.dart'; +import '../../crypto_currency/intermediate/cryptonote_currency.dart'; +import '../../models/tx_data.dart'; +import '../wallet.dart'; +import '../wallet_mixin_interfaces/mnemonic_interface.dart'; abstract class CryptonoteWallet extends Wallet with MnemonicInterface { diff --git a/lib/wallets/wallet/supporting/epiccash_wallet_info_extension.dart b/lib/wallets/wallet/supporting/epiccash_wallet_info_extension.dart index 8d71c655f..d913df779 100644 --- a/lib/wallets/wallet/supporting/epiccash_wallet_info_extension.dart +++ b/lib/wallets/wallet/supporting/epiccash_wallet_info_extension.dart @@ -1,8 +1,8 @@ import 'dart:convert'; import 'package:isar/isar.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/wallets/isar/models/wallet_info.dart'; +import '../../../utilities/logger.dart'; +import '../../isar/models/wallet_info.dart'; extension EpiccashWalletInfoExtension on WalletInfo { ExtraEpiccashWalletInfo? get epicData { diff --git a/lib/wallets/wallet/wallet.dart b/lib/wallets/wallet/wallet.dart index 549bfefb2..36d9130b3 100644 --- a/lib/wallets/wallet/wallet.dart +++ b/lib/wallets/wallet/wallet.dart @@ -3,56 +3,73 @@ import 'dart:async'; import 'package:isar/isar.dart'; import 'package:meta/meta.dart'; import 'package:mutex/mutex.dart'; -import 'package:stackwallet/db/isar/main_db.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart'; -import 'package:stackwallet/models/node_model.dart'; -import 'package:stackwallet/models/paymint/fee_object_model.dart'; -import 'package:stackwallet/services/event_bus/events/global/node_connection_status_changed_event.dart'; -import 'package:stackwallet/services/event_bus/events/global/refresh_percent_changed_event.dart'; -import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart'; -import 'package:stackwallet/services/event_bus/global_event_bus.dart'; -import 'package:stackwallet/services/node_service.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/default_nodes.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/sync_type_enum.dart'; -import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/paynym_is_api.dart'; -import 'package:stackwallet/utilities/prefs.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/isar/models/wallet_info.dart'; -import 'package:stackwallet/wallets/models/tx_data.dart'; -import 'package:stackwallet/wallets/wallet/impl/banano_wallet.dart'; -import 'package:stackwallet/wallets/wallet/impl/bitcoin_frost_wallet.dart'; -import 'package:stackwallet/wallets/wallet/impl/bitcoin_wallet.dart'; -import 'package:stackwallet/wallets/wallet/impl/bitcoincash_wallet.dart'; -import 'package:stackwallet/wallets/wallet/impl/dogecoin_wallet.dart'; -import 'package:stackwallet/wallets/wallet/impl/ecash_wallet.dart'; -import 'package:stackwallet/wallets/wallet/impl/epiccash_wallet.dart'; -import 'package:stackwallet/wallets/wallet/impl/ethereum_wallet.dart'; -import 'package:stackwallet/wallets/wallet/impl/firo_wallet.dart'; -import 'package:stackwallet/wallets/wallet/impl/litecoin_wallet.dart'; -import 'package:stackwallet/wallets/wallet/impl/monero_wallet.dart'; -import 'package:stackwallet/wallets/wallet/impl/namecoin_wallet.dart'; -import 'package:stackwallet/wallets/wallet/impl/nano_wallet.dart'; -import 'package:stackwallet/wallets/wallet/impl/particl_wallet.dart'; -import 'package:stackwallet/wallets/wallet/impl/peercoin_wallet.dart'; -import 'package:stackwallet/wallets/wallet/impl/solana_wallet.dart'; -import 'package:stackwallet/wallets/wallet/impl/stellar_wallet.dart'; -import 'package:stackwallet/wallets/wallet/impl/sub_wallets/eth_token_wallet.dart'; -import 'package:stackwallet/wallets/wallet/impl/tezos_wallet.dart'; -import 'package:stackwallet/wallets/wallet/impl/wownero_wallet.dart'; -import 'package:stackwallet/wallets/wallet/intermediate/cryptonote_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/lelantus_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/mnemonic_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/multi_address_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/private_key_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart'; +import '../../db/isar/main_db.dart'; +import '../../models/isar/models/blockchain_data/address.dart'; +import '../../models/isar/models/ethereum/eth_contract.dart'; +import '../../models/node_model.dart'; +import '../../models/paymint/fee_object_model.dart'; +import '../../services/event_bus/events/global/node_connection_status_changed_event.dart'; +import '../../services/event_bus/events/global/refresh_percent_changed_event.dart'; +import '../../services/event_bus/events/global/wallet_sync_status_changed_event.dart'; +import '../../services/event_bus/global_event_bus.dart'; +import '../../services/node_service.dart'; +import '../../utilities/amount/amount.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/enums/sync_type_enum.dart'; +import '../../utilities/flutter_secure_storage_interface.dart'; +import '../../utilities/logger.dart'; +import '../../utilities/paynym_is_api.dart'; +import '../../utilities/prefs.dart'; +import '../crypto_currency/coins/banano.dart'; +import '../crypto_currency/coins/bitcoin.dart'; +import '../crypto_currency/coins/bitcoin_frost.dart'; +import '../crypto_currency/coins/bitcoincash.dart'; +import '../crypto_currency/coins/dogecoin.dart'; +import '../crypto_currency/coins/ecash.dart'; +import '../crypto_currency/coins/epiccash.dart'; +import '../crypto_currency/coins/ethereum.dart'; +import '../crypto_currency/coins/firo.dart'; +import '../crypto_currency/coins/litecoin.dart'; +import '../crypto_currency/coins/monero.dart'; +import '../crypto_currency/coins/namecoin.dart'; +import '../crypto_currency/coins/nano.dart'; +import '../crypto_currency/coins/particl.dart'; +import '../crypto_currency/coins/peercoin.dart'; +import '../crypto_currency/coins/solana.dart'; +import '../crypto_currency/coins/stellar.dart'; +import '../crypto_currency/coins/tezos.dart'; +import '../crypto_currency/coins/wownero.dart'; +import '../crypto_currency/crypto_currency.dart'; +import '../isar/models/wallet_info.dart'; +import '../models/tx_data.dart'; +import 'impl/banano_wallet.dart'; +import 'impl/bitcoin_frost_wallet.dart'; +import 'impl/bitcoin_wallet.dart'; +import 'impl/bitcoincash_wallet.dart'; +import 'impl/dogecoin_wallet.dart'; +import 'impl/ecash_wallet.dart'; +import 'impl/epiccash_wallet.dart'; +import 'impl/ethereum_wallet.dart'; +import 'impl/firo_wallet.dart'; +import 'impl/litecoin_wallet.dart'; +import 'impl/monero_wallet.dart'; +import 'impl/namecoin_wallet.dart'; +import 'impl/nano_wallet.dart'; +import 'impl/particl_wallet.dart'; +import 'impl/peercoin_wallet.dart'; +import 'impl/solana_wallet.dart'; +import 'impl/stellar_wallet.dart'; +import 'impl/sub_wallets/eth_token_wallet.dart'; +import 'impl/tezos_wallet.dart'; +import 'impl/wownero_wallet.dart'; +import 'intermediate/cryptonote_wallet.dart'; +import 'wallet_mixin_interfaces/electrumx_interface.dart'; +import 'wallet_mixin_interfaces/lelantus_interface.dart'; +import 'wallet_mixin_interfaces/mnemonic_interface.dart'; +import 'wallet_mixin_interfaces/multi_address_interface.dart'; +import 'wallet_mixin_interfaces/paynym_interface.dart'; +import 'wallet_mixin_interfaces/private_key_interface.dart'; +import 'wallet_mixin_interfaces/spark_interface.dart'; abstract class Wallet { // default to Transaction class. For TransactionV2 set to 2 @@ -309,79 +326,64 @@ abstract class Wallet { static Wallet _loadWallet({ required WalletInfo walletInfo, }) { - switch (walletInfo.coin) { - case Coin.banano: - return BananoWallet(CryptoCurrencyNetwork.main); + final net = walletInfo.coin.network; + switch (walletInfo.coin.runtimeType) { + case const (Banano): + return BananoWallet(net); - case Coin.bitcoin: - return BitcoinWallet(CryptoCurrencyNetwork.main); - case Coin.bitcoinTestNet: - return BitcoinWallet(CryptoCurrencyNetwork.test); + case const (Bitcoin): + return BitcoinWallet(net); - case Coin.bitcoinFrost: - return BitcoinFrostWallet(CryptoCurrencyNetwork.main); - case Coin.bitcoinFrostTestNet: - return BitcoinFrostWallet(CryptoCurrencyNetwork.test); + case const (BitcoinFrost): + return BitcoinFrostWallet(net); - case Coin.bitcoincash: - return BitcoincashWallet(CryptoCurrencyNetwork.main); - case Coin.bitcoincashTestnet: - return BitcoincashWallet(CryptoCurrencyNetwork.test); + case const (Bitcoincash): + return BitcoincashWallet(net); - case Coin.dogecoin: - return DogecoinWallet(CryptoCurrencyNetwork.main); - case Coin.dogecoinTestNet: - return DogecoinWallet(CryptoCurrencyNetwork.test); + case const (Dogecoin): + return DogecoinWallet(net); - case Coin.eCash: - return EcashWallet(CryptoCurrencyNetwork.main); + case const (Ecash): + return EcashWallet(net); - case Coin.epicCash: - return EpiccashWallet(CryptoCurrencyNetwork.main); + case const (Epiccash): + return EpiccashWallet(net); - case Coin.ethereum: - return EthereumWallet(CryptoCurrencyNetwork.main); + case const (Ethereum): + return EthereumWallet(net); - case Coin.firo: - return FiroWallet(CryptoCurrencyNetwork.main); - case Coin.firoTestNet: - return FiroWallet(CryptoCurrencyNetwork.test); + case const (Firo): + return FiroWallet(net); - case Coin.litecoin: - return LitecoinWallet(CryptoCurrencyNetwork.main); - case Coin.litecoinTestNet: - return LitecoinWallet(CryptoCurrencyNetwork.test); + case const (Litecoin): + return LitecoinWallet(net); - case Coin.monero: - return MoneroWallet(CryptoCurrencyNetwork.main); + case const (Monero): + return MoneroWallet(net); - case Coin.namecoin: - return NamecoinWallet(CryptoCurrencyNetwork.main); + case const (Namecoin): + return NamecoinWallet(net); - case Coin.nano: - return NanoWallet(CryptoCurrencyNetwork.main); + case const (Nano): + return NanoWallet(net); - case Coin.particl: - return ParticlWallet(CryptoCurrencyNetwork.main); + case const (Particl): + return ParticlWallet(net); - case Coin.peercoin: - return PeercoinWallet(CryptoCurrencyNetwork.main); - case Coin.peercoinTestNet: - return PeercoinWallet(CryptoCurrencyNetwork.test); + case const (Peercoin): + return PeercoinWallet(net); - case Coin.solana: - return SolanaWallet(CryptoCurrencyNetwork.main); + case const (Solana): + return SolanaWallet(net); - case Coin.stellar: - return StellarWallet(CryptoCurrencyNetwork.main); - case Coin.stellarTestnet: - return StellarWallet(CryptoCurrencyNetwork.test); + case const (Stellar): + return StellarWallet(net); - case Coin.tezos: - return TezosWallet(CryptoCurrencyNetwork.main); + case const (Tezos): + return TezosWallet(net); - case Coin.wownero: - return WowneroWallet(CryptoCurrencyNetwork.main); + case const (Wownero): + return WowneroWallet(net); default: // should never hit in reality @@ -413,7 +415,7 @@ abstract class Wallet { NodeConnectionStatusChangedEvent( status, walletId, - cryptoCurrency.coin, + cryptoCurrency, ), ); @@ -475,8 +477,8 @@ abstract class Wallet { } NodeModel getCurrentNode() { - final node = nodeService.getPrimaryNodeFor(coin: cryptoCurrency.coin) ?? - DefaultNodes.getNodeFor(cryptoCurrency.coin); + final node = nodeService.getPrimaryNodeFor(currency: cryptoCurrency) ?? + cryptoCurrency.defaultNode; return node; } @@ -498,7 +500,7 @@ abstract class Wallet { WalletSyncStatusChangedEvent( WalletSyncStatus.syncing, walletId, - cryptoCurrency.coin, + cryptoCurrency, ), ); @@ -584,7 +586,7 @@ abstract class Wallet { WalletSyncStatusChangedEvent( WalletSyncStatus.synced, walletId, - cryptoCurrency.coin, + cryptoCurrency, ), ); @@ -607,14 +609,14 @@ abstract class Wallet { NodeConnectionStatusChangedEvent( NodeConnectionStatus.disconnected, walletId, - cryptoCurrency.coin, + cryptoCurrency, ), ); GlobalEventBus.instance.fire( WalletSyncStatusChangedEvent( WalletSyncStatus.unableToSync, walletId, - cryptoCurrency.coin, + cryptoCurrency, ), ); Logging.instance.log( @@ -637,7 +639,7 @@ abstract class Wallet { case SyncingType.currentWalletOnly: // Close the subscription for this coin's chain height. // NOTE: This does not work now that the subscription is shared - // await (await ChainHeightServiceManager.getService(cryptoCurrency.coin)) + // await (await ChainHeightServiceManager.getService(cryptoCurrency)) // ?.cancelListen(); case SyncingType.selectedWalletsAtStartup: // Close the subscription if this wallet is not in the list to be synced. @@ -650,7 +652,7 @@ abstract class Wallet { .walletIdEqualTo(id) .findFirstSync()!; - if (wallet.coin == cryptoCurrency.coin) { + if (wallet.coin == cryptoCurrency) { walletIds.add(id); } } @@ -660,7 +662,7 @@ abstract class Wallet { if (walletIds.isEmpty) { // NOTE: This does not work now that the subscription is shared // await (await ChainHeightServiceManager.getService( - // cryptoCurrency.coin)) + // cryptoCurrency)) // ?.cancelListen(); } } diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/bcash_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/bcash_interface.dart index c94fd15f9..a7a75e397 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/bcash_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/bcash_interface.dart @@ -1,18 +1,20 @@ import 'package:bitbox/bitbox.dart' as bitbox; import 'package:bitbox/src/utils/network.dart' as bitbox_utils; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/input_v2.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/output_v2.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/models/signing_data.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/models/tx_data.dart'; -import 'package:stackwallet/wallets/wallet/intermediate/bip39_hd_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart'; +import '../../../models/isar/models/blockchain_data/v2/input_v2.dart'; +import '../../../models/isar/models/blockchain_data/v2/output_v2.dart'; +import '../../../models/isar/models/blockchain_data/v2/transaction_v2.dart'; +import '../../../models/isar/models/isar_models.dart'; +import '../../../models/signing_data.dart'; +import '../../../utilities/logger.dart'; +import '../../crypto_currency/crypto_currency.dart'; +import '../../crypto_currency/interfaces/electrumx_currency_interface.dart'; +import '../../models/tx_data.dart'; +import '../intermediate/bip39_hd_wallet.dart'; +import 'electrumx_interface.dart'; -mixin BCashInterface on Bip39HDWallet, ElectrumXInterface { +mixin BCashInterface + on Bip39HDWallet, ElectrumXInterface { @override Future buildTransaction({ required TxData txData, diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/cash_fusion_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/cash_fusion_interface.dart index 1a7d424a2..4858c8bdc 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/cash_fusion_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/cash_fusion_interface.dart @@ -5,22 +5,25 @@ import 'package:bitbox/bitbox.dart' as bitbox; import 'package:flutter/foundation.dart'; import 'package:fusiondart/fusiondart.dart' as fusion; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/fusion_progress_ui_state.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/utxo.dart'; -import 'package:stackwallet/pages_desktop_specific/cashfusion/sub_widgets/fusion_dialog.dart'; -import 'package:stackwallet/services/fusion_tor_service.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/stack_file_system.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/coin_control_interface.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart'; +import '../../../models/fusion_progress_ui_state.dart'; +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../../models/isar/models/blockchain_data/transaction.dart'; +import '../../../models/isar/models/blockchain_data/utxo.dart'; +import '../../../pages_desktop_specific/cashfusion/sub_widgets/fusion_dialog.dart'; +import '../../../services/fusion_tor_service.dart'; +import '../../../utilities/logger.dart'; +import '../../../utilities/stack_file_system.dart'; +import '../../crypto_currency/coins/bitcoincash.dart'; +import '../../crypto_currency/coins/ecash.dart'; +import '../../crypto_currency/crypto_currency.dart'; +import '../../crypto_currency/interfaces/electrumx_currency_interface.dart'; +import 'coin_control_interface.dart'; +import 'electrumx_interface.dart'; const String kReservedFusionAddress = "reserved_fusion_address"; -final kFusionServerInfoDefaults = Map.unmodifiable(const { - Coin.bitcoincash: FusionInfo( +final kFusionServerInfoDefaults = Map.unmodifiable({ + Bitcoincash(CryptoCurrencyNetwork.main).identifier: const FusionInfo( host: "fusion.servo.cash", port: 8789, ssl: true, @@ -29,7 +32,7 @@ final kFusionServerInfoDefaults = Map.unmodifiable(const { // ssl: false, rounds: 0, // 0 is continuous ), - Coin.bitcoincashTestnet: FusionInfo( + Bitcoincash(CryptoCurrencyNetwork.test).identifier: const FusionInfo( host: "fusion.servo.cash", port: 8789, ssl: true, @@ -38,7 +41,7 @@ final kFusionServerInfoDefaults = Map.unmodifiable(const { // ssl: false, rounds: 0, // 0 is continuous ), - Coin.eCash: FusionInfo( + Ecash(CryptoCurrencyNetwork.main).identifier: const FusionInfo( host: "fusion.tokamak.cash", port: 8788, ssl: true, @@ -109,7 +112,8 @@ class FusionInfo { } } -mixin CashFusionInterface on CoinControlInterface, ElectrumXInterface { +mixin CashFusionInterface + on CoinControlInterface, ElectrumXInterface { final _torService = FusionTorService.sharedInstance; // setting values on this should notify any listeners (the GUI) @@ -307,7 +311,7 @@ mixin CashFusionInterface on CoinControlInterface, ElectrumXInterface { final futures = txidList.map( (e) => electrumXCachedClient.getTransaction( txHash: e, - coin: info.coin, + cryptoCurrency: info.coin, ), ); @@ -589,7 +593,7 @@ mixin CashFusionInterface on CoinControlInterface, ElectrumXInterface { checkUtxoExists: _checkUtxoExists, getTransactionJson: (String txid) async => await electrumXCachedClient.getTransaction( - coin: info.coin, + cryptoCurrency: info.coin, txHash: txid, ), getPrivateKeyForPubKey: _getPrivateKeyForPubKey, diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/coin_control_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/coin_control_interface.dart index 6cd810ba7..36cd710fd 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/coin_control_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/coin_control_interface.dart @@ -1,5 +1,5 @@ -import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_hd_currency.dart'; -import 'package:stackwallet/wallets/wallet/intermediate/bip39_hd_wallet.dart'; +import '../../crypto_currency/intermediate/bip39_hd_currency.dart'; +import '../intermediate/bip39_hd_wallet.dart'; mixin CoinControlInterface on Bip39HDWallet { // any required here? diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/cw_based_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/cw_based_interface.dart index 585d79bf1..80a7f6d31 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/cw_based_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/cw_based_interface.dart @@ -11,20 +11,20 @@ import 'package:cw_core/wallet_type.dart'; import 'package:flutter_libmonero/core/key_service.dart'; import 'package:isar/isar.dart'; import 'package:mutex/mutex.dart'; -import 'package:stackwallet/models/balance.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/models/paymint/fee_object_model.dart'; -import 'package:stackwallet/services/event_bus/events/global/blocks_remaining_event.dart'; -import 'package:stackwallet/services/event_bus/events/global/refresh_percent_changed_event.dart'; -import 'package:stackwallet/services/event_bus/events/global/updated_in_background_event.dart'; -import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart'; -import 'package:stackwallet/services/event_bus/global_event_bus.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/stack_file_system.dart'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/cryptonote_currency.dart'; -import 'package:stackwallet/wallets/wallet/intermediate/cryptonote_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/multi_address_interface.dart'; +import '../../../models/balance.dart'; +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../../models/paymint/fee_object_model.dart'; +import '../../../services/event_bus/events/global/blocks_remaining_event.dart'; +import '../../../services/event_bus/events/global/refresh_percent_changed_event.dart'; +import '../../../services/event_bus/events/global/updated_in_background_event.dart'; +import '../../../services/event_bus/events/global/wallet_sync_status_changed_event.dart'; +import '../../../services/event_bus/global_event_bus.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/logger.dart'; +import '../../../utilities/stack_file_system.dart'; +import '../../crypto_currency/intermediate/cryptonote_currency.dart'; +import '../intermediate/cryptonote_wallet.dart'; +import 'multi_address_interface.dart'; mixin CwBasedInterface on CryptonoteWallet implements MultiAddressInterface { diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart index 026e9f5fc..eda467a6a 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart @@ -4,31 +4,31 @@ import 'dart:typed_data'; import 'package:coinlib_flutter/coinlib_flutter.dart' as coinlib; import 'package:isar/isar.dart'; -import 'package:stackwallet/electrumx_rpc/cached_electrumx_client.dart'; -import 'package:stackwallet/electrumx_rpc/client_manager.dart'; -import 'package:stackwallet/electrumx_rpc/electrumx_client.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/input_v2.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/output_v2.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/models/paymint/fee_object_model.dart'; -import 'package:stackwallet/models/signing_data.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart'; -import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart'; -import 'package:stackwallet/utilities/extensions/extensions.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/paynym_is_api.dart'; -import 'package:stackwallet/wallets/crypto_currency/coins/firo.dart'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/bip39_hd_currency.dart'; -import 'package:stackwallet/wallets/models/tx_data.dart'; -import 'package:stackwallet/wallets/wallet/impl/bitcoin_wallet.dart'; -import 'package:stackwallet/wallets/wallet/impl/peercoin_wallet.dart'; -import 'package:stackwallet/wallets/wallet/intermediate/bip39_hd_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart'; +import '../../../electrumx_rpc/cached_electrumx_client.dart'; +import '../../../electrumx_rpc/client_manager.dart'; +import '../../../electrumx_rpc/electrumx_client.dart'; +import '../../../models/isar/models/blockchain_data/v2/input_v2.dart'; +import '../../../models/isar/models/blockchain_data/v2/output_v2.dart'; +import '../../../models/isar/models/blockchain_data/v2/transaction_v2.dart'; +import '../../../models/isar/models/isar_models.dart'; +import '../../../models/paymint/fee_object_model.dart'; +import '../../../models/signing_data.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/enums/derive_path_type_enum.dart'; +import '../../../utilities/enums/fee_rate_type_enum.dart'; +import '../../../utilities/extensions/extensions.dart'; +import '../../../utilities/logger.dart'; +import '../../../utilities/paynym_is_api.dart'; +import '../../crypto_currency/coins/firo.dart'; +import '../../crypto_currency/interfaces/electrumx_currency_interface.dart'; +import '../../models/tx_data.dart'; +import '../impl/bitcoin_wallet.dart'; +import '../impl/peercoin_wallet.dart'; +import '../intermediate/bip39_hd_wallet.dart'; +import 'paynym_interface.dart'; -mixin ElectrumXInterface on Bip39HDWallet { +mixin ElectrumXInterface + on Bip39HDWallet { late ElectrumXClient electrumXClient; late CachedElectrumXClient electrumXCachedClient; @@ -43,9 +43,11 @@ mixin ElectrumXInterface on Bip39HDWallet { } try { - _serverVersion ??= _parseServerVersion((await electrumXClient - .getServerFeatures() - .timeout(const Duration(seconds: 2)))["server_version"] as String); + _serverVersion ??= _parseServerVersion( + (await electrumXClient + .getServerFeatures() + .timeout(const Duration(seconds: 2)))["server_version"] as String, + ); } catch (_) { // ignore failure as it doesn't matter } @@ -133,22 +135,30 @@ mixin ElectrumXInterface on Bip39HDWallet { // don't care about sorting if using all utxos if (!coinControl) { // sort spendable by age (oldest first) - spendableOutputs.sort((a, b) => (b.blockTime ?? currentChainHeight) - .compareTo((a.blockTime ?? currentChainHeight))); + spendableOutputs.sort( + (a, b) => (b.blockTime ?? currentChainHeight) + .compareTo((a.blockTime ?? currentChainHeight)), + ); // Null check operator changed to null assignment in order to resolve a // `Null check operator used on a null value` error. currentChainHeight // used in order to sort these unconfirmed outputs as the youngest, but we // could just as well use currentChainHeight + 1. } - Logging.instance.log("spendableOutputs.length: ${spendableOutputs.length}", - level: LogLevel.Info); - Logging.instance.log("availableOutputs.length: ${availableOutputs.length}", - level: LogLevel.Info); + Logging.instance.log( + "spendableOutputs.length: ${spendableOutputs.length}", + level: LogLevel.Info, + ); + Logging.instance.log( + "availableOutputs.length: ${availableOutputs.length}", + level: LogLevel.Info, + ); Logging.instance .log("spendableOutputs: $spendableOutputs", level: LogLevel.Info); - Logging.instance.log("spendableSatoshiValue: $spendableSatoshiValue", - level: LogLevel.Info); + Logging.instance.log( + "spendableSatoshiValue: $spendableSatoshiValue", + level: LogLevel.Info, + ); Logging.instance .log("satoshiAmountToSend: $satoshiAmountToSend", level: LogLevel.Info); // If the amount the user is trying to send is smaller than the amount that they have spendable, @@ -299,7 +309,7 @@ mixin ElectrumXInterface on Bip39HDWallet { [recipientAddress, (await getCurrentChangeAddress())!.value], [ satoshiAmountToSend, - max(0, satoshisBeingUsed - satoshiAmountToSend - 1) + max(0, satoshisBeingUsed - satoshiAmountToSend - 1), ], ), ), @@ -358,13 +368,18 @@ mixin ElectrumXInterface on Bip39HDWallet { Logging.instance.log('2 outputs in tx', level: LogLevel.Info); Logging.instance .log('Input size: $satoshisBeingUsed', level: LogLevel.Info); - Logging.instance.log('Recipient output size: $satoshiAmountToSend', - level: LogLevel.Info); - Logging.instance.log('Change Output Size: $changeOutputSize', - level: LogLevel.Info); Logging.instance.log( - 'Difference (fee being paid): $feeBeingPaid sats', - level: LogLevel.Info); + 'Recipient output size: $satoshiAmountToSend', + level: LogLevel.Info, + ); + Logging.instance.log( + 'Change Output Size: $changeOutputSize', + level: LogLevel.Info, + ); + Logging.instance.log( + 'Difference (fee being paid): $feeBeingPaid sats', + level: LogLevel.Info, + ); Logging.instance .log('Estimated fee: $feeForTwoOutputs', level: LogLevel.Info); @@ -386,19 +401,26 @@ mixin ElectrumXInterface on Bip39HDWallet { satoshisBeingUsed - satoshiAmountToSend - changeOutputSize; recipientsAmtArray.removeLast(); recipientsAmtArray.add(changeOutputSize); - Logging.instance.log('Adjusted Input size: $satoshisBeingUsed', - level: LogLevel.Info); Logging.instance.log( - 'Adjusted Recipient output size: $satoshiAmountToSend', - level: LogLevel.Info); + 'Adjusted Input size: $satoshisBeingUsed', + level: LogLevel.Info, + ); Logging.instance.log( - 'Adjusted Change Output Size: $changeOutputSize', - level: LogLevel.Info); + 'Adjusted Recipient output size: $satoshiAmountToSend', + level: LogLevel.Info, + ); Logging.instance.log( - 'Adjusted Difference (fee being paid): $feeBeingPaid sats', - level: LogLevel.Info); - Logging.instance.log('Adjusted Estimated fee: $feeForTwoOutputs', - level: LogLevel.Info); + 'Adjusted Change Output Size: $changeOutputSize', + level: LogLevel.Info, + ); + Logging.instance.log( + 'Adjusted Difference (fee being paid): $feeBeingPaid sats', + level: LogLevel.Info, + ); + Logging.instance.log( + 'Adjusted Estimated fee: $feeForTwoOutputs', + level: LogLevel.Info, + ); txn = await buildTransaction( utxoSigningData: utxoSigningData, txData: txData.copyWith( @@ -423,11 +445,14 @@ mixin ElectrumXInterface on Bip39HDWallet { Logging.instance.log('1 output in tx', level: LogLevel.Info); Logging.instance .log('Input size: $satoshisBeingUsed', level: LogLevel.Info); - Logging.instance.log('Recipient output size: $satoshiAmountToSend', - level: LogLevel.Info); Logging.instance.log( - 'Difference (fee being paid): ${satoshisBeingUsed - satoshiAmountToSend} sats', - level: LogLevel.Info); + 'Recipient output size: $satoshiAmountToSend', + level: LogLevel.Info, + ); + Logging.instance.log( + 'Difference (fee being paid): ${satoshisBeingUsed - satoshiAmountToSend} sats', + level: LogLevel.Info, + ); Logging.instance .log('Estimated fee: $feeForOneOutput', level: LogLevel.Info); final txn = await buildTransaction( @@ -455,11 +480,14 @@ mixin ElectrumXInterface on Bip39HDWallet { Logging.instance.log('1 output in tx', level: LogLevel.Info); Logging.instance .log('Input size: $satoshisBeingUsed', level: LogLevel.Info); - Logging.instance.log('Recipient output size: $satoshiAmountToSend', - level: LogLevel.Info); Logging.instance.log( - 'Difference (fee being paid): ${satoshisBeingUsed - satoshiAmountToSend} sats', - level: LogLevel.Info); + 'Recipient output size: $satoshiAmountToSend', + level: LogLevel.Info, + ); + Logging.instance.log( + 'Difference (fee being paid): ${satoshisBeingUsed - satoshiAmountToSend} sats', + level: LogLevel.Info, + ); Logging.instance .log('Estimated fee: $feeForOneOutput', level: LogLevel.Info); final txn = await buildTransaction( @@ -487,11 +515,14 @@ mixin ElectrumXInterface on Bip39HDWallet { Logging.instance.log('1 output in tx', level: LogLevel.Info); Logging.instance .log('Input size: $satoshisBeingUsed', level: LogLevel.Info); - Logging.instance.log('Recipient output size: $satoshiAmountToSend', - level: LogLevel.Info); Logging.instance.log( - 'Fee being paid: ${satoshisBeingUsed - satoshiAmountToSend} sats', - level: LogLevel.Info); + 'Recipient output size: $satoshiAmountToSend', + level: LogLevel.Info, + ); + Logging.instance.log( + 'Fee being paid: ${satoshisBeingUsed - satoshiAmountToSend} sats', + level: LogLevel.Info, + ); Logging.instance .log('Estimated fee: $feeForOneOutput', level: LogLevel.Info); final txn = await buildTransaction( @@ -515,8 +546,9 @@ mixin ElectrumXInterface on Bip39HDWallet { // pay for the transaction fee. Ideally, at this stage, we should check if the user has any // additional outputs they're able to spend and then recalculate fees. Logging.instance.log( - 'Cannot pay tx fee - checking for more outputs and trying again', - level: LogLevel.Warning); + 'Cannot pay tx fee - checking for more outputs and trying again', + level: LogLevel.Warning, + ); // try adding more outputs if (spendableOutputs.length > inputsBeingConsumed) { return coinSelection( @@ -589,7 +621,8 @@ mixin ElectrumXInterface on Bip39HDWallet { if (keys == null) { throw Exception( - "Failed to fetch signing data. Local db corrupt. Rescan wallet."); + "Failed to fetch signing data. Local db corrupt. Rescan wallet.", + ); } sd.keyPair = keys; @@ -762,8 +795,10 @@ mixin ElectrumXInterface on Bip39HDWallet { ); } } catch (e, s) { - Logging.instance.log("Caught exception while signing transaction: $e\n$s", - level: LogLevel.Error); + Logging.instance.log( + "Caught exception while signing transaction: $e\n$s", + level: LogLevel.Error, + ); rethrow; } @@ -799,8 +834,9 @@ mixin ElectrumXInterface on Bip39HDWallet { ); } catch (e, s) { Logging.instance.log( - "Exception rethrown in fetchChainHeight\nError: $e\nStack trace: $s", - level: LogLevel.Error); + "Exception rethrown in fetchChainHeight\nError: $e\nStack trace: $s", + level: LogLevel.Error, + ); // completer.completeError(e, s); // return Future.error(e, s); rethrow; @@ -819,9 +855,10 @@ mixin ElectrumXInterface on Bip39HDWallet { }) async { try { final response = await electrumXClient.getBatchHistory( - args: addresses - .map((e) => [cryptoCurrency.addressToScriptHash(address: e)]) - .toList(growable: false)); + args: addresses + .map((e) => [cryptoCurrency.addressToScriptHash(address: e)]) + .toList(growable: false), + ); final List result = []; for (final entry in response) { @@ -830,8 +867,9 @@ mixin ElectrumXInterface on Bip39HDWallet { return result; } catch (e, s) { Logging.instance.log( - "Exception rethrown in _getBatchTxCount(address: $addresses: $e\n$s", - level: LogLevel.Error); + "Exception rethrown in _getBatchTxCount(address: $addresses: $e\n$s", + level: LogLevel.Error, + ); rethrow; } } @@ -850,14 +888,16 @@ mixin ElectrumXInterface on Bip39HDWallet { Future updateElectrumX() async { final failovers = nodeService - .failoverNodesFor(coin: cryptoCurrency.coin) - .map((e) => ElectrumXNode( - address: e.host, - port: e.port, - name: e.name, - id: e.id, - useSSL: e.useSSL, - )) + .failoverNodesFor(currency: cryptoCurrency) + .map( + (e) => ElectrumXNode( + address: e.host, + port: e.port, + name: e.name, + id: e.id, + useSSL: e.useSSL, + ), + ) .toList(); final newNode = await _getCurrentElectrumXNode(); @@ -899,8 +939,9 @@ mixin ElectrumXInterface on Bip39HDWallet { gapCounter < cryptoCurrency.maxUnusedAddressGap; index += txCountBatchSize) { Logging.instance.log( - "index: $index, \t GapCounter $chain ${type.name}: $gapCounter", - level: LogLevel.Info); + "index: $index, \t GapCounter $chain ${type.name}: $gapCounter", + level: LogLevel.Info, + ); final List txCountCallArgs = []; @@ -979,8 +1020,9 @@ mixin ElectrumXInterface on Bip39HDWallet { gapCounter < cryptoCurrency.maxUnusedAddressGap; index++) { Logging.instance.log( - "index: $index, \t GapCounter chain=$chain ${type.name}: $gapCounter", - level: LogLevel.Info); + "index: $index, \t GapCounter chain=$chain ${type.name}: $gapCounter", + level: LogLevel.Info, + ); final derivePath = cryptoCurrency.constructDerivePath( derivePathType: type, @@ -1107,7 +1149,7 @@ mixin ElectrumXInterface on Bip39HDWallet { final txn = await electrumXCachedClient.getTransaction( txHash: jsonUTXO["tx_hash"] as String, verbose: true, - coin: cryptoCurrency.coin, + cryptoCurrency: cryptoCurrency, ); final vout = jsonUTXO["tx_pos"] as int; @@ -1194,15 +1236,15 @@ mixin ElectrumXInterface on Bip39HDWallet { numberOfBlocksSlow: s, fast: Amount.fromDecimal( fast, - fractionDigits: info.coin.decimals, + fractionDigits: info.coin.fractionDigits, ).raw.toInt(), medium: Amount.fromDecimal( medium, - fractionDigits: info.coin.decimals, + fractionDigits: info.coin.fractionDigits, ).raw.toInt(), slow: Amount.fromDecimal( slow, - fractionDigits: info.coin.decimals, + fractionDigits: info.coin.fractionDigits, ).raw.toInt(), ); @@ -1235,14 +1277,14 @@ mixin ElectrumXInterface on Bip39HDWallet { Amount runningBalance = Amount( rawValue: BigInt.zero, - fractionDigits: info.coin.decimals, + fractionDigits: info.coin.fractionDigits, ); int inputCount = 0; for (final output in utxos) { if (!output.isBlocked) { runningBalance += Amount( rawValue: BigInt.from(output.value), - fractionDigits: info.coin.decimals, + fractionDigits: info.coin.fractionDigits, ); inputCount++; if (runningBalance > amount) { @@ -1366,7 +1408,8 @@ mixin ElectrumXInterface on Bip39HDWallet { if (isRescan) { // clear cache await electrumXCachedClient.clearSharedTransactionCache( - coin: info.coin); + cryptoCurrency: info.coin, + ); // clear blockchain info await mainDB.deleteWalletBlockchainData(walletId); } @@ -1459,12 +1502,16 @@ mixin ElectrumXInterface on Bip39HDWallet { } // remove extra addresses to help minimize risk of creating a large gap - addressesToStore.removeWhere((e) => - e.subType == AddressSubType.change && - e.derivationIndex > highestChangeIndexWithHistory); - addressesToStore.removeWhere((e) => - e.subType == AddressSubType.receiving && - e.derivationIndex > highestReceivingIndexWithHistory); + addressesToStore.removeWhere( + (e) => + e.subType == AddressSubType.change && + e.derivationIndex > highestChangeIndexWithHistory, + ); + addressesToStore.removeWhere( + (e) => + e.subType == AddressSubType.receiving && + e.derivationIndex > highestReceivingIndexWithHistory, + ); await mainDB.updateOrPutAddresses(addressesToStore); @@ -1512,8 +1559,9 @@ mixin ElectrumXInterface on Bip39HDWallet { unawaited(refresh()); } catch (e, s) { Logging.instance.log( - "Exception rethrown from electrumx_mixin recover(): $e\n$s", - level: LogLevel.Info); + "Exception rethrown from electrumx_mixin recover(): $e\n$s", + level: LogLevel.Info, + ); rethrow; } @@ -1609,8 +1657,10 @@ mixin ElectrumXInterface on Bip39HDWallet { return await updateSentCachedTxData(txData: txData); } catch (e, s) { - Logging.instance.log("Exception rethrown from confirmSend(): $e\n$s", - level: LogLevel.Error); + Logging.instance.log( + "Exception rethrown from confirmSend(): $e\n$s", + level: LogLevel.Error, + ); rethrow; } } @@ -1644,7 +1694,8 @@ mixin ElectrumXInterface on Bip39HDWallet { if (result.fee!.raw.toInt() < result.vSize!) { throw Exception( - "Error in fee calculation: Transaction fee cannot be less than vSize"); + "Error in fee calculation: Transaction fee cannot be less than vSize", + ); } return result; @@ -1700,8 +1751,10 @@ mixin ElectrumXInterface on Bip39HDWallet { throw ArgumentError("Invalid fee rate argument provided!"); } } catch (e, s) { - Logging.instance.log("Exception rethrown from prepareSend(): $e\n$s", - level: LogLevel.Error); + Logging.instance.log( + "Exception rethrown from prepareSend(): $e\n$s", + level: LogLevel.Error, + ); rethrow; } } @@ -1777,7 +1830,7 @@ mixin ElectrumXInterface on Bip39HDWallet { return Amount( rawValue: available, - fractionDigits: info.coin.decimals, + fractionDigits: info.coin.fractionDigits, ) - estimatedFee; } diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/lelantus_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/lelantus_interface.dart index ce8c5064d..26410c526 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/lelantus_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/lelantus_interface.dart @@ -6,25 +6,27 @@ import 'package:bitcoindart/bitcoindart.dart' as bitcoindart; import 'package:decimal/decimal.dart'; import 'package:isar/isar.dart'; import 'package:lelantus/lelantus.dart' as lelantus; -import 'package:stackwallet/models/balance.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/models/lelantus_fee_data.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart'; -import 'package:stackwallet/utilities/extensions/impl/uint8_list.dart'; -import 'package:stackwallet/utilities/format.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/wallets/api/lelantus_ffi_wrapper.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/models/tx_data.dart'; -import 'package:stackwallet/wallets/wallet/intermediate/bip39_hd_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart'; +import '../../../models/balance.dart'; +import '../../../models/isar/models/isar_models.dart'; +import '../../../models/lelantus_fee_data.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/enums/derive_path_type_enum.dart'; +import '../../../utilities/extensions/impl/uint8_list.dart'; +import '../../../utilities/format.dart'; +import '../../../utilities/logger.dart'; +import '../../api/lelantus_ffi_wrapper.dart'; +import '../../crypto_currency/crypto_currency.dart'; +import '../../crypto_currency/interfaces/electrumx_currency_interface.dart'; +import '../../models/tx_data.dart'; +import '../intermediate/bip39_hd_wallet.dart'; +import 'electrumx_interface.dart'; import 'package:tuple/tuple.dart'; -mixin LelantusInterface on Bip39HDWallet, ElectrumXInterface { +mixin LelantusInterface + on Bip39HDWallet, ElectrumXInterface { Future estimateFeeForLelantus(Amount amount) async { final lelantusEntries = await _getLelantusEntry(); - int spendAmount = amount.raw.toInt(); + final int spendAmount = amount.raw.toInt(); if (spendAmount == 0 || lelantusEntries.isEmpty) { return Amount( rawValue: BigInt.from(LelantusFeeData(0, 0, []).fee), @@ -52,10 +54,12 @@ mixin LelantusInterface on Bip39HDWallet, ElectrumXInterface { .filter() .isUsedEqualTo(false) .not() - .group((q) => q - .valueEqualTo("0") - .or() - .anonymitySetIdEqualTo(LelantusFfiWrapper.ANONYMITY_SET_EMPTY_ID)) + .group( + (q) => q + .valueEqualTo("0") + .or() + .anonymitySetIdEqualTo(LelantusFfiWrapper.ANONYMITY_SET_EMPTY_ID), + ) .findAll(); final root = await getRootHDNode(); @@ -156,12 +160,15 @@ mixin LelantusInterface on Bip39HDWallet, ElectrumXInterface { // fee should never be less than vSize sanity check if (result.fee!.raw.toInt() < result.vSize!) { throw Exception( - "Error in fee calculation: Transaction fee cannot be less than vSize"); + "Error in fee calculation: Transaction fee cannot be less than vSize", + ); } return result; } catch (e, s) { - Logging.instance.log("Exception rethrown in firo prepareSend(): $e\n$s", - level: LogLevel.Error); + Logging.instance.log( + "Exception rethrown in firo prepareSend(): $e\n$s", + level: LogLevel.Error, + ); rethrow; } } @@ -316,17 +323,17 @@ mixin LelantusInterface on Bip39HDWallet, ElectrumXInterface { } Future>> fastFetch(List allTxHashes) async { - List> allTransactions = []; + final List> allTransactions = []; const futureLimit = 30; - List>> transactionFutures = []; + final List>> transactionFutures = []; int currentFutureCount = 0; for (final txHash in allTxHashes) { - Future> transactionFuture = + final Future> transactionFuture = electrumXCachedClient.getTransaction( txHash: txHash, verbose: true, - coin: cryptoCurrency.coin, + cryptoCurrency: cryptoCurrency, ); transactionFutures.add(transactionFuture); currentFutureCount++; @@ -362,8 +369,8 @@ mixin LelantusInterface on Bip39HDWallet, ElectrumXInterface { List transactions, ) async { try { - Map txs = {}; - List> allTransactions = + final Map txs = {}; + final List> allTransactions = await fastFetch(transactions); for (int i = 0; i < allTransactions.length; i++) { @@ -426,16 +433,18 @@ mixin LelantusInterface on Bip39HDWallet, ElectrumXInterface { txs[address] = txn; } catch (e, s) { Logging.instance.log( - "Exception caught in getJMintTransactions(): $e\n$s", - level: LogLevel.Info); + "Exception caught in getJMintTransactions(): $e\n$s", + level: LogLevel.Info, + ); rethrow; } } return txs; } catch (e, s) { Logging.instance.log( - "Exception rethrown in getJMintTransactions(): $e\n$s", - level: LogLevel.Info); + "Exception rethrown in getJMintTransactions(): $e\n$s", + level: LogLevel.Info, + ); rethrow; } } @@ -445,25 +454,26 @@ mixin LelantusInterface on Bip39HDWallet, ElectrumXInterface { final latestSetId = await electrumXClient.getLelantusLatestCoinId(); final List> sets = []; - List>> anonFutures = []; + final List>> anonFutures = []; for (int i = 1; i <= latestSetId; i++) { final set = electrumXCachedClient.getAnonymitySet( groupId: "$i", - coin: info.coin, + cryptoCurrency: info.coin, ); anonFutures.add(set); } await Future.wait(anonFutures); for (int i = 1; i <= latestSetId; i++) { - Map set = (await anonFutures[i - 1]); + final Map set = (await anonFutures[i - 1]); set["setId"] = i; sets.add(set); } return sets; } catch (e, s) { Logging.instance.log( - "Exception rethrown from refreshAnonymitySets: $e\n$s", - level: LogLevel.Error); + "Exception rethrown from refreshAnonymitySets: $e\n$s", + level: LogLevel.Error, + ); rethrow; } } @@ -497,7 +507,7 @@ mixin LelantusInterface on Bip39HDWallet, ElectrumXInterface { final usedSerialNumbersSet = (await electrumXCachedClient.getUsedCoinSerials( - coin: info.coin, + cryptoCurrency: info.coin, )) .toSet(); @@ -598,10 +608,10 @@ mixin LelantusInterface on Bip39HDWallet, ElectrumXInterface { // TODO: [prio=high] shouldn't these be v2? If it doesn't matter than we can get rid of this logic // Edit the receive transactions with the mint fees. - List editedTransactions = []; + final List editedTransactions = []; for (final coin in result.lelantusCoins) { - String txid = coin.txid; + final String txid = coin.txid; Transaction? tx; try { tx = txns.firstWhere((e) => e.txid == txid); @@ -614,7 +624,7 @@ mixin LelantusInterface on Bip39HDWallet, ElectrumXInterface { continue; } - List inputTxns = []; + final List inputTxns = []; for (final input in tx.inputs) { Transaction? inputTx; try { @@ -635,8 +645,8 @@ mixin LelantusInterface on Bip39HDWallet, ElectrumXInterface { continue; } - int mintFee = tx.fee; - int sharedFee = mintFee ~/ inputTxns.length; + final int mintFee = tx.fee; + final int sharedFee = mintFee ~/ inputTxns.length; for (final inputTx in inputTxns) { final edited = Transaction( walletId: inputTx.walletId, @@ -665,7 +675,7 @@ mixin LelantusInterface on Bip39HDWallet, ElectrumXInterface { } // Logging.instance.log(editedTransactions, addToDebugMessagesDB: false); - Map transactionMap = {}; + final Map transactionMap = {}; for (final e in txns) { transactionMap[e.txid] = e; } @@ -676,10 +686,12 @@ mixin LelantusInterface on Bip39HDWallet, ElectrumXInterface { transactionMap[tx.txid] = tx; } - transactionMap.removeWhere((key, value) => - result.lelantusCoins.any((element) => element.txid == key) || - ((value.height == -1 || value.height == null) && - !value.isConfirmed(currentHeight, cryptoCurrency.minConfirms))); + transactionMap.removeWhere( + (key, value) => + result.lelantusCoins.any((element) => element.txid == key) || + ((value.height == -1 || value.height == null) && + !value.isConfirmed(currentHeight, cryptoCurrency.minConfirms)), + ); try { await mainDB.isar.writeTxn(() async { @@ -694,7 +706,7 @@ mixin LelantusInterface on Bip39HDWallet, ElectrumXInterface { throw Exception("e=$e & s=$s"); } - Map> data = {}; + final Map> data = {}; for (final entry in transactionMap.entries) { data[entry.key] = Tuple2(entry.value.address.value, entry.value); @@ -730,9 +742,12 @@ mixin LelantusInterface on Bip39HDWallet, ElectrumXInterface { value.item2.outputs.where((_) => true).toList(growable: false); final ins = value.item2.inputs.where((_) => true).toList(growable: false); - txnsData.add(Tuple2( + txnsData.add( + Tuple2( value.item2.copyWith(inputs: ins, outputs: outs).item1, - transactionAddress)); + transactionAddress, + ), + ); } await mainDB.addNewTransactionData(txnsData, walletId); @@ -827,7 +842,7 @@ mixin LelantusInterface on Bip39HDWallet, ElectrumXInterface { for (var mintsElement in txData.mintsMapLelantus!) { Logging.instance.log("using $mintsElement", level: LogLevel.Info); - Uint8List mintu8 = + final Uint8List mintu8 = Format.stringToUint8List(mintsElement['script'] as String); txb.addOutput(mintu8, mintsElement['value'] as int); } @@ -843,12 +858,12 @@ mixin LelantusInterface on Bip39HDWallet, ElectrumXInterface { witnessValue: signingData[i].utxo.value, ); } - var incomplete = txb.buildIncomplete(); - var txId = incomplete.getId(); - var txHex = incomplete.toHex(); - int fee = amount - incomplete.outs[0].value!; + final incomplete = txb.buildIncomplete(); + final txId = incomplete.getId(); + final txHex = incomplete.toHex(); + final int fee = amount - incomplete.outs[0].value!; - var builtHex = txb.build(); + final builtHex = txb.build(); return txData.copyWith( recipients: [ @@ -859,7 +874,7 @@ mixin LelantusInterface on Bip39HDWallet, ElectrumXInterface { ), address: "no address for lelantus mints", isChange: false, - ) + ), ], vSize: builtHex.virtualSize(), txid: txId, @@ -880,14 +895,14 @@ mixin LelantusInterface on Bip39HDWallet, ElectrumXInterface { // "value": amount - fee, // "fees": Amount( // rawValue: BigInt.from(fee), - // fractionDigits: coin.decimals, + // fractionDigits: coin.fractionDigits, // ).decimal.toDouble(), // "height": height, // "txType": "Sent", // "confirmed_status": false, // "amount": Amount( // rawValue: BigInt.from(amount), - // fractionDigits: coin.decimals, + // fractionDigits: coin.fractionDigits, // ).decimal.toDouble(), // "timestamp": DateTime.now().millisecondsSinceEpoch ~/ 1000, // "subType": "mint", @@ -908,7 +923,9 @@ mixin LelantusInterface on Bip39HDWallet, ElectrumXInterface { // Build list of spendable outputs and totaling their satoshi amount for (var i = 0; i < availableOutputs.length; i++) { if (availableOutputs[i].isConfirmed( - currentChainHeight, cryptoCurrency.minConfirms) == + currentChainHeight, + cryptoCurrency.minConfirms, + ) == true && !(availableOutputs[i].isCoinbase && availableOutputs[i].getConfirmations(currentChainHeight) <= @@ -938,8 +955,9 @@ mixin LelantusInterface on Bip39HDWallet, ElectrumXInterface { for (var element in value.inputs) { if (lelantusCoins.any((e) => e.txid == value.txid) && spendableOutputs.firstWhere( - (output) => output?.txid == element.txid, - orElse: () => null) != + (output) => output?.txid == element.txid, + orElse: () => null, + ) != null) { spendableOutputs .removeWhere((output) => output!.txid == element.txid); @@ -954,7 +972,7 @@ mixin LelantusInterface on Bip39HDWallet, ElectrumXInterface { } int satoshisBeingUsed = 0; - Set utxoObjectsToUse = {}; + final Set utxoObjectsToUse = {}; for (var i = 0; i < spendableOutputs.length; i++) { final spendable = spendableOutputs[i]; @@ -964,7 +982,7 @@ mixin LelantusInterface on Bip39HDWallet, ElectrumXInterface { } } - var mintsWithoutFee = await _createMintsFromAmount(satoshisBeingUsed); + final mintsWithoutFee = await _createMintsFromAmount(satoshisBeingUsed); TxData txData = await buildMintTransaction( txData: TxData( @@ -1005,7 +1023,8 @@ mixin LelantusInterface on Bip39HDWallet, ElectrumXInterface { Future>> _createMintsFromAmount(int total) async { if (total > LelantusFfiWrapper.MINT_LIMIT) { throw Exception( - "Lelantus mints of more than 5001 are currently disabled"); + "Lelantus mints of more than 5001 are currently disabled", + ); } int tmpTotal = total; @@ -1075,10 +1094,11 @@ mixin LelantusInterface on Bip39HDWallet, ElectrumXInterface { if (!isUsedMintTag) { final mintValue = min( - tmpTotal, - (isTestnet - ? LelantusFfiWrapper.MINT_LIMIT_TESTNET - : LelantusFfiWrapper.MINT_LIMIT)); + tmpTotal, + (isTestnet + ? LelantusFfiWrapper.MINT_LIMIT_TESTNET + : LelantusFfiWrapper.MINT_LIMIT), + ); final mint = await LelantusFfiWrapper.getMintScript( amount: Amount( rawValue: BigInt.from(mintValue), diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/mnemonic_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/mnemonic_interface.dart index 2f7db193c..dc756bd33 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/mnemonic_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/mnemonic_interface.dart @@ -1,6 +1,6 @@ -import 'package:stackwallet/exceptions/sw_exception.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/wallet/wallet.dart'; +import '../../../exceptions/sw_exception.dart'; +import '../../crypto_currency/crypto_currency.dart'; +import '../wallet.dart'; mixin MnemonicInterface on Wallet { Future getMnemonic() async { diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/multi_address_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/multi_address_interface.dart index 7de2293be..42a663167 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/multi_address_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/multi_address_interface.dart @@ -1,5 +1,5 @@ -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/wallet/wallet.dart'; +import '../../crypto_currency/crypto_currency.dart'; +import '../wallet.dart'; mixin MultiAddressInterface on Wallet { Future generateNewReceivingAddress(); diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/nano_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/nano_interface.dart index dd52da8de..9287fe261 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/nano_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/nano_interface.dart @@ -3,23 +3,21 @@ import 'dart:convert'; import 'package:isar/isar.dart'; import 'package:nanodart/nanodart.dart'; -import 'package:stackwallet/models/balance.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart'; -import 'package:stackwallet/models/node_model.dart'; -import 'package:stackwallet/models/paymint/fee_object_model.dart'; -import 'package:stackwallet/networking/http.dart'; -import 'package:stackwallet/services/nano_api.dart'; -import 'package:stackwallet/services/node_service.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/default_nodes.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/extensions/impl/string.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/wallets/crypto_currency/intermediate/nano_currency.dart'; -import 'package:stackwallet/wallets/models/tx_data.dart'; -import 'package:stackwallet/wallets/wallet/intermediate/bip39_wallet.dart'; +import '../../../models/balance.dart'; +import '../../../models/isar/models/blockchain_data/address.dart'; +import '../../../models/isar/models/blockchain_data/transaction.dart'; +import '../../../models/node_model.dart'; +import '../../../models/paymint/fee_object_model.dart'; +import '../../../networking/http.dart'; +import '../../../services/nano_api.dart'; +import '../../../services/node_service.dart'; +import '../../../services/tor_service.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/extensions/impl/string.dart'; +import '../../../utilities/logger.dart'; +import '../../crypto_currency/intermediate/nano_currency.dart'; +import '../../models/tx_data.dart'; +import '../intermediate/bip39_wallet.dart'; import 'package:tuple/tuple.dart'; const _kWorkServer = "https://rpc.nano.to"; @@ -81,7 +79,7 @@ mixin NanoInterface on Bip39Wallet { publicKey: publicKey.toUint8ListFromHex, derivationIndex: 0, derivationPath: null, - type: cryptoCurrency.coin.primaryAddressType, + type: cryptoCurrency.primaryAddressType, subType: AddressSubType.receiving, ); } @@ -138,7 +136,7 @@ mixin NanoInterface on Bip39Wallet { final BigInt txAmount = BigInt.parse(amountRaw); final BigInt balanceAfterTx = currentBalance + txAmount; - String frontier = infoData["frontier"].toString(); + final String frontier = infoData["frontier"].toString(); String representative = infoData["representative"].toString(); if (openBlock) { @@ -153,7 +151,7 @@ mixin NanoInterface on Bip39Wallet { NanoAccounts.createAccount(NanoAccountType.BANANO, blockHash); // construct the receive block: - Map receiveBlock = { + final Map receiveBlock = { "type": "state", "account": publicAddress, "previous": openBlock @@ -300,8 +298,8 @@ mixin NanoInterface on Bip39Wallet { @override Future updateNode() async { _cachedNode = NodeService(secureStorageInterface: secureStorageInterface) - .getPrimaryNodeFor(coin: info.coin) ?? - DefaultNodes.getNodeFor(info.coin); + .getPrimaryNodeFor(currency: info.coin) ?? + info.coin.defaultNode; unawaited(refresh()); } @@ -310,8 +308,8 @@ mixin NanoInterface on Bip39Wallet { NodeModel getCurrentNode() { return _cachedNode ?? NodeService(secureStorageInterface: secureStorageInterface) - .getPrimaryNodeFor(coin: info.coin) ?? - DefaultNodes.getNodeFor(info.coin); + .getPrimaryNodeFor(currency: info.coin) ?? + info.coin.defaultNode; } @override @@ -407,7 +405,7 @@ mixin NanoInterface on Bip39Wallet { final String link = NanoAccounts.extractPublicKey(linkAsAccount); // construct the send block: - Map sendBlock = { + final Map sendBlock = { "type": "state", "account": publicAddress, "previous": frontier, @@ -505,14 +503,15 @@ mixin NanoInterface on Bip39Wallet { proxyInfo: prefs.useTor ? TorService.sharedInstance.getProxyInfo() : null, ); final data = await jsonDecode(response.body); - final transactions = - data["history"] is List ? data["history"] as List : []; + final transactions = data["history"] is List + ? data["history"] as List + : []; if (transactions.isEmpty) { return; } else { - List> transactionList = []; - for (var tx in transactions) { - var typeString = tx["type"].toString(); + final List> transactionList = []; + for (final tx in transactions) { + final typeString = tx["type"].toString(); TransactionType transactionType = TransactionType.unknown; if (typeString == "send") { transactionType = TransactionType.outgoing; @@ -524,7 +523,7 @@ mixin NanoInterface on Bip39Wallet { fractionDigits: cryptoCurrency.fractionDigits, ); - var transaction = Transaction( + final transaction = Transaction( walletId: walletId, txid: tx["hash"].toString(), timestamp: int.parse(tx["local_timestamp"].toString()), @@ -544,7 +543,7 @@ mixin NanoInterface on Bip39Wallet { numberOfMessages: null, ); - Address address = transactionType == TransactionType.incoming + final Address address = transactionType == TransactionType.incoming ? receivingAddress : Address( walletId: walletId, @@ -555,7 +554,7 @@ mixin NanoInterface on Bip39Wallet { type: info.coin.primaryAddressType, subType: AddressSubType.nonWallet, ); - Tuple2 tuple = Tuple2(transaction, address); + final Tuple2 tuple = Tuple2(transaction, address); transactionList.add(tuple); } diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/ordinals_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/ordinals_interface.dart index 5b6299f12..da0a36c70 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/ordinals_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/ordinals_interface.dart @@ -1,12 +1,14 @@ import 'package:isar/isar.dart'; -import 'package:stackwallet/dto/ordinals/inscription_data.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/utxo.dart'; -import 'package:stackwallet/models/isar/ordinal.dart'; -import 'package:stackwallet/services/litescribe_api.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart'; +import '../../../dto/ordinals/inscription_data.dart'; +import '../../../models/isar/models/blockchain_data/utxo.dart'; +import '../../../models/isar/ordinal.dart'; +import '../../../services/litescribe_api.dart'; +import '../../../utilities/logger.dart'; +import '../../crypto_currency/interfaces/electrumx_currency_interface.dart'; +import 'electrumx_interface.dart'; -mixin OrdinalsInterface on ElectrumXInterface { +mixin OrdinalsInterface + on ElectrumXInterface { final LitescribeAPI _litescribeAPI = LitescribeAPI(baseUrl: 'https://litescribe.io/api'); diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart index 202b22943..b2114b09b 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart @@ -10,25 +10,26 @@ import 'package:bitcoindart/src/utils/script.dart' as bscript; import 'package:coinlib_flutter/coinlib_flutter.dart' as coinlib; import 'package:isar/isar.dart'; import 'package:pointycastle/digests/sha256.dart'; -import 'package:stackwallet/exceptions/wallet/insufficient_balance_exception.dart'; -import 'package:stackwallet/exceptions/wallet/paynym_send_exception.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/input_v2.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/output_v2.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/models/signing_data.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/bip32_utils.dart'; -import 'package:stackwallet/utilities/bip47_utils.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart'; -import 'package:stackwallet/utilities/extensions/extensions.dart'; -import 'package:stackwallet/utilities/format.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/wallets/crypto_currency/interfaces/paynym_currency_interface.dart'; -import 'package:stackwallet/wallets/models/tx_data.dart'; -import 'package:stackwallet/wallets/wallet/intermediate/bip39_hd_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart'; +import '../../../exceptions/wallet/insufficient_balance_exception.dart'; +import '../../../exceptions/wallet/paynym_send_exception.dart'; +import '../../../models/isar/models/blockchain_data/v2/input_v2.dart'; +import '../../../models/isar/models/blockchain_data/v2/output_v2.dart'; +import '../../../models/isar/models/blockchain_data/v2/transaction_v2.dart'; +import '../../../models/isar/models/isar_models.dart'; +import '../../../models/signing_data.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/bip32_utils.dart'; +import '../../../utilities/bip47_utils.dart'; +import '../../../utilities/enums/derive_path_type_enum.dart'; +import '../../../utilities/extensions/extensions.dart'; +import '../../../utilities/format.dart'; +import '../../../utilities/logger.dart'; +import '../../crypto_currency/coins/dogecoin.dart'; +import '../../crypto_currency/crypto_currency.dart'; +import '../../crypto_currency/interfaces/paynym_currency_interface.dart'; +import '../../models/tx_data.dart'; +import '../intermediate/bip39_hd_wallet.dart'; +import 'electrumx_interface.dart'; import 'package:tuple/tuple.dart'; const String kPCodeKeyPrefix = "pCode_key_"; @@ -67,7 +68,7 @@ mixin PaynymInterface final root = await _getRootNode(); final node = root.derivePath( _basePaynymDerivePath( - testnet: info.coin.isTestNet, + testnet: info.coin.network == CryptoCurrencyNetwork.test, ), ); return node; @@ -158,7 +159,7 @@ mixin PaynymInterface final root = await _getRootNode(); final node = root.derivePath( _basePaynymDerivePath( - testnet: info.coin.isTestNet, + testnet: info.coin.network == CryptoCurrencyNetwork.test, ), ); @@ -181,7 +182,7 @@ mixin PaynymInterface derivationPath: DerivationPath() ..value = _receivingPaynymAddressDerivationPath( index, - testnet: info.coin.isTestNet, + testnet: info.coin.network == CryptoCurrencyNetwork.test, ), type: generateSegwitAddress ? AddressType.p2wpkh : AddressType.p2pkh, subType: AddressSubType.paynymReceive, @@ -218,7 +219,7 @@ mixin PaynymInterface derivationPath: DerivationPath() ..value = _sendPaynymAddressDerivationPath( index, - testnet: info.coin.isTestNet, + testnet: info.coin.network == CryptoCurrencyNetwork.test, ), type: AddressType.nonWallet, subType: AddressSubType.paynymSend, @@ -275,14 +276,18 @@ mixin PaynymInterface final codes = await getAllPaymentCodesFromNotificationTransactions(); final List> futures = []; for (final code in codes) { - futures.add(checkCurrentPaynymReceivingAddressForTransactions( - sender: code, - isSegwit: true, - )); - futures.add(checkCurrentPaynymReceivingAddressForTransactions( - sender: code, - isSegwit: false, - )); + futures.add( + checkCurrentPaynymReceivingAddressForTransactions( + sender: code, + isSegwit: true, + ), + ); + futures.add( + checkCurrentPaynymReceivingAddressForTransactions( + sender: code, + isSegwit: false, + ), + ); } await Future.wait(futures); } @@ -309,7 +314,7 @@ mixin PaynymInterface final node = root .derivePath( _basePaynymDerivePath( - testnet: info.coin.isTestNet, + testnet: info.coin.network == CryptoCurrencyNetwork.test, ), ) .derive(0); @@ -323,7 +328,11 @@ mixin PaynymInterface final node = await _getRootNode(); final paymentCode = PaymentCode.fromBip32Node( - node.derivePath(_basePaynymDerivePath(testnet: info.coin.isTestNet)), + node.derivePath( + _basePaynymDerivePath( + testnet: info.coin.network == CryptoCurrencyNetwork.test, + ), + ), networkType: networkType, shouldSetSegwitBit: isSegwit, ); @@ -333,8 +342,10 @@ mixin PaynymInterface Future signWithNotificationKey(Uint8List data) async { final myPrivateKeyNode = await deriveNotificationBip32Node(); - final pair = btc_dart.ECPair.fromPrivateKey(myPrivateKeyNode.privateKey!, - network: networkType); + final pair = btc_dart.ECPair.fromPrivateKey( + myPrivateKeyNode.privateKey!, + network: networkType, + ); final signed = pair.sign(SHA256Digest().process(data)); return signed; } @@ -363,7 +374,8 @@ mixin PaynymInterface if (!(await hasConnected(txData.paynymAccountLite!.code.toString()))) { throw PaynymSendException( - "No notification transaction sent to $paymentCode,"); + "No notification transaction sent to $paymentCode,", + ); } else { final myPrivateKeyNode = await deriveNotificationBip32Node(); final sendToAddress = await nextUnusedSendAddressFrom( @@ -465,7 +477,9 @@ mixin PaynymInterface for (var i = 0; i < availableOutputs.length; i++) { if (availableOutputs[i].isBlocked == false && availableOutputs[i].isConfirmed( - await fetchChainHeight(), cryptoCurrency.minConfirms) == + await fetchChainHeight(), + cryptoCurrency.minConfirms, + ) == true) { spendableOutputs.add(availableOutputs[i]); spendableSatoshiValue += BigInt.from(availableOutputs[i].value); @@ -475,11 +489,13 @@ mixin PaynymInterface if (spendableSatoshiValue < amountToSend.raw) { // insufficient balance throw InsufficientBalanceException( - "Spendable balance is less than the minimum required for a notification transaction."); + "Spendable balance is less than the minimum required for a notification transaction.", + ); } else if (spendableSatoshiValue == amountToSend.raw) { // insufficient balance due to missing amount to cover fee throw InsufficientBalanceException( - "Remaining balance does not cover the network fee."); + "Remaining balance does not cover the network fee.", + ); } // sort spendable by age (oldest first) @@ -487,7 +503,7 @@ mixin PaynymInterface BigInt satoshisBeingUsed = BigInt.zero; int outputsBeingUsed = 0; - List utxoObjectsToUse = []; + final List utxoObjectsToUse = []; for (int i = 0; satoshisBeingUsed < amountToSend.raw && i < spendableOutputs.length; @@ -546,7 +562,7 @@ mixin PaynymInterface ), ); - if (info.coin == Coin.dogecoin || info.coin == Coin.dogecoinTestNet) { + if (info.coin is Dogecoin) { if (feeForNoChange < vSizeForNoChange * BigInt.from(1000)) { feeForNoChange = vSizeForNoChange * BigInt.from(1000); } @@ -587,21 +603,22 @@ mixin PaynymInterface } final txData = TxData( - raw: txn.item1, - recipients: [ - ( - address: targetPaymentCodeString, - amount: amountToSend, - isChange: false, - ), - ], - fee: Amount( - rawValue: feeBeingPaid, - fractionDigits: cryptoCurrency.fractionDigits, + raw: txn.item1, + recipients: [ + ( + address: targetPaymentCodeString, + amount: amountToSend, + isChange: false, ), - vSize: txn.item2, - utxos: utxoSigningData.map((e) => e.utxo).toSet(), - note: "PayNym connect"); + ], + fee: Amount( + rawValue: feeBeingPaid, + fractionDigits: cryptoCurrency.fractionDigits, + ), + vSize: txn.item2, + utxos: utxoSigningData.map((e) => e.utxo).toSet(), + note: "PayNym connect", + ); return txData; } else { @@ -613,24 +630,25 @@ mixin PaynymInterface change: BigInt.zero, ); - BigInt feeBeingPaid = satoshisBeingUsed - amountToSend.raw; + final BigInt feeBeingPaid = satoshisBeingUsed - amountToSend.raw; final txData = TxData( - raw: txn.item1, - recipients: [ - ( - address: targetPaymentCodeString, - amount: amountToSend, - isChange: false, - ) - ], - fee: Amount( - rawValue: feeBeingPaid, - fractionDigits: cryptoCurrency.fractionDigits, + raw: txn.item1, + recipients: [ + ( + address: targetPaymentCodeString, + amount: amountToSend, + isChange: false, ), - vSize: txn.item2, - utxos: utxoSigningData.map((e) => e.utxo).toSet(), - note: "PayNym connect"); + ], + fee: Amount( + rawValue: feeBeingPaid, + fractionDigits: cryptoCurrency.fractionDigits, + ), + vSize: txn.item2, + utxos: utxoSigningData.map((e) => e.utxo).toSet(), + note: "PayNym connect", + ); return txData; } @@ -643,24 +661,25 @@ mixin PaynymInterface change: BigInt.zero, ); - BigInt feeBeingPaid = satoshisBeingUsed - amountToSend.raw; + final BigInt feeBeingPaid = satoshisBeingUsed - amountToSend.raw; final txData = TxData( - raw: txn.item1, - recipients: [ - ( - address: targetPaymentCodeString, - amount: amountToSend, - isChange: false, - ) - ], - fee: Amount( - rawValue: feeBeingPaid, - fractionDigits: cryptoCurrency.fractionDigits, + raw: txn.item1, + recipients: [ + ( + address: targetPaymentCodeString, + amount: amountToSend, + isChange: false, ), - vSize: txn.item2, - utxos: utxoSigningData.map((e) => e.utxo).toSet(), - note: "PayNym connect"); + ], + fee: Amount( + rawValue: feeBeingPaid, + fractionDigits: cryptoCurrency.fractionDigits, + ), + vSize: txn.item2, + utxos: utxoSigningData.map((e) => e.utxo).toSet(), + note: "PayNym connect", + ); return txData; } else { @@ -674,7 +693,8 @@ mixin PaynymInterface ); } else { throw InsufficientBalanceException( - "Remaining balance does not cover the network fee."); + "Remaining balance does not cover the network fee.", + ); } } } catch (e) { @@ -900,8 +920,10 @@ mixin PaynymInterface txHash: txHash, ); } catch (e, s) { - Logging.instance.log("Exception rethrown from confirmSend(): $e\n$s", - level: LogLevel.Error); + Logging.instance.log( + "Exception rethrown from confirmSend(): $e\n$s", + level: LogLevel.Error, + ); rethrow; } } @@ -1143,7 +1165,7 @@ mixin PaynymInterface .subTypeEqualTo(TransactionSubType.bip47Notification) .findAll(); - List codes = []; + final List codes = []; for (final tx in txns) { // tx is sent so we can check the address's otherData for the code String @@ -1201,7 +1223,8 @@ mixin PaynymInterface } Future checkForNotificationTransactionsTo( - Set otherCodeStrings) async { + Set otherCodeStrings, + ) async { final sentNotificationTransactions = await mainDB.isar.transactionV2s .where() .walletIdEqualTo(walletId) @@ -1214,7 +1237,8 @@ mixin PaynymInterface final List codes = []; for (final codeString in otherCodeStrings) { codes.add( - PaymentCode.fromPaymentCode(codeString, networkType: networkType)); + PaymentCode.fromPaymentCode(codeString, networkType: networkType), + ); } for (final tx in sentNotificationTransactions) { @@ -1303,7 +1327,7 @@ mixin PaynymInterface final mySendBip32Node = await deriveNotificationBip32Node(); - List
addresses = []; + final List
addresses = []; int receivingGapCounter = 0; int outgoingGapCounter = 0; @@ -1445,7 +1469,7 @@ mixin PaynymInterface final root = await _getRootNode(); final node = root.derivePath( _basePaynymDerivePath( - testnet: info.coin.isTestNet, + testnet: info.coin.network == CryptoCurrencyNetwork.test, ), ); final paymentCode = PaymentCode.fromBip32Node( @@ -1473,7 +1497,7 @@ mixin PaynymInterface derivationIndex: 0, derivationPath: DerivationPath() ..value = _notificationDerivationPath( - testnet: info.coin.isTestNet, + testnet: info.coin.network == CryptoCurrencyNetwork.test, ), type: AddressType.p2pkh, subType: AddressSubType.paynymNotification, @@ -1559,7 +1583,8 @@ mixin PaynymInterface Uint8List _randomBytes(int n) { final Random rng = Random.secure(); return Uint8List.fromList( - List.generate(n, (_) => rng.nextInt(0xFF + 1))); + List.generate(n, (_) => rng.nextInt(0xFF + 1)), + ); } // ================== Overrides ============================================== @@ -1567,18 +1592,20 @@ mixin PaynymInterface @override Future updateTransactions({List
? overrideAddresses}) async { // Get all addresses. - List
allAddressesOld = + final List
allAddressesOld = overrideAddresses ?? await fetchAddressesForElectrumXScan(); // Separate receiving and change addresses. - Set receivingAddresses = allAddressesOld - .where((e) => - e.subType == AddressSubType.receiving || - e.subType == AddressSubType.paynymNotification || - e.subType == AddressSubType.paynymReceive) + final Set receivingAddresses = allAddressesOld + .where( + (e) => + e.subType == AddressSubType.receiving || + e.subType == AddressSubType.paynymNotification || + e.subType == AddressSubType.paynymReceive, + ) .map((e) => e.value) .toSet(); - Set changeAddresses = allAddressesOld + final Set changeAddresses = allAddressesOld .where((e) => e.subType == AddressSubType.change) .map((e) => e.value) .toSet(); @@ -1591,7 +1618,7 @@ mixin PaynymInterface await fetchHistory(allAddressesSet); // Only parse new txs (not in db yet). - List> allTransactions = []; + final List> allTransactions = []; for (final txHash in allTxHashes) { // Check for duplicates by searching for tx by tx_hash in db. // final storedTx = await mainDB.isar.transactionV2s @@ -1606,7 +1633,7 @@ mixin PaynymInterface final tx = await electrumXCachedClient.getTransaction( txHash: txHash["tx_hash"] as String, verbose: true, - coin: cryptoCurrency.coin, + cryptoCurrency: cryptoCurrency, ); // Only tx to list once. @@ -1648,12 +1675,12 @@ mixin PaynymInterface final inputTx = await electrumXCachedClient.getTransaction( txHash: txid, - coin: cryptoCurrency.coin, + cryptoCurrency: cryptoCurrency, ); final prevOutJson = Map.from( - (inputTx["vout"] as List).firstWhere((e) => e["n"] == vout) - as Map); + (inputTx["vout"] as List).firstWhere((e) => e["n"] == vout) as Map, + ); final prevOut = OutputV2.fromElectrumXJson( prevOutJson, @@ -1726,7 +1753,8 @@ mixin PaynymInterface TransactionSubType subType = TransactionSubType.none; if (outputs.length > 1 && inputs.isNotEmpty) { for (int i = 0; i < outputs.length; i++) { - List? scriptChunks = outputs[i].scriptPubKeyAsm?.split(" "); + final List? scriptChunks = + outputs[i].scriptPubKeyAsm?.split(" "); if (scriptChunks?.length == 2 && scriptChunks?[0] == "OP_RETURN") { final blindedPaymentCode = scriptChunks![1]; final bytes = blindedPaymentCode.toUint8ListFromHex; @@ -1809,7 +1837,7 @@ mixin PaynymInterface final outputs = jsonTX["vout"] as List; for (int i = 0; i < outputs.length; i++) { final output = outputs[i]; - List? scriptChunks = + final List? scriptChunks = (output['scriptPubKey']?['asm'] as String?)?.split(" "); if (scriptChunks?.length == 2 && scriptChunks?[0] == "OP_RETURN") { final blindedPaymentCode = scriptChunks![1]; diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/private_key_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/private_key_interface.dart index b5095cda1..eee42842a 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/private_key_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/private_key_interface.dart @@ -1,6 +1,6 @@ -import 'package:stackwallet/exceptions/sw_exception.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/wallet/wallet.dart'; +import '../../../exceptions/sw_exception.dart'; +import '../../crypto_currency/crypto_currency.dart'; +import '../wallet.dart'; mixin PrivateKeyInterface on Wallet { Future getPrivateKey() async { diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart index 7aaa1d3ed..08131fabf 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart @@ -6,21 +6,22 @@ import 'package:decimal/decimal.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter_libsparkmobile/flutter_libsparkmobile.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/balance.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/input_v2.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/output_v2.dart'; -import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/models/signing_data.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart'; -import 'package:stackwallet/utilities/extensions/extensions.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; -import 'package:stackwallet/wallets/isar/models/spark_coin.dart'; -import 'package:stackwallet/wallets/models/tx_data.dart'; -import 'package:stackwallet/wallets/wallet/intermediate/bip39_hd_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/electrumx_interface.dart'; +import '../../../models/balance.dart'; +import '../../../models/isar/models/blockchain_data/v2/input_v2.dart'; +import '../../../models/isar/models/blockchain_data/v2/output_v2.dart'; +import '../../../models/isar/models/blockchain_data/v2/transaction_v2.dart'; +import '../../../models/isar/models/isar_models.dart'; +import '../../../models/signing_data.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/enums/derive_path_type_enum.dart'; +import '../../../utilities/extensions/extensions.dart'; +import '../../../utilities/logger.dart'; +import '../../crypto_currency/crypto_currency.dart'; +import '../../crypto_currency/interfaces/electrumx_currency_interface.dart'; +import '../../isar/models/spark_coin.dart'; +import '../../models/tx_data.dart'; +import '../intermediate/bip39_hd_wallet.dart'; +import 'electrumx_interface.dart'; const kDefaultSparkIndex = 1; @@ -34,7 +35,8 @@ const OP_SPARKMINT = 0xd1; const OP_SPARKSMINT = 0xd2; const OP_SPARKSPEND = 0xd3; -mixin SparkInterface on Bip39HDWallet, ElectrumXInterface { +mixin SparkInterface + on Bip39HDWallet, ElectrumXInterface { String? _sparkChangeAddressCached; /// Spark change address. Should generally not be exposed to end users. @@ -258,7 +260,7 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface { for (int i = 1; i <= currentId; i++) { final set = await electrumXCachedClient.getSparkAnonymitySet( groupId: i.toString(), - coin: info.coin, + cryptoCurrency: info.coin, useOnlyCacheIfNotEmpty: true, ); set["coinGroupID"] = i; @@ -619,12 +621,12 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface { final anonymitySetFuture = electrumXCachedClient.getSparkAnonymitySet( groupId: latestSparkCoinId.toString(), - coin: info.coin, + cryptoCurrency: info.coin, useOnlyCacheIfNotEmpty: false, ); - final spentCoinTagsFuture = - electrumXCachedClient.getSparkUsedCoinsTags(coin: info.coin); + final spentCoinTagsFuture = electrumXCachedClient.getSparkUsedCoinsTags( + cryptoCurrency: info.coin); final futureResults = await Future.wait([ anonymitySetFuture, @@ -1600,7 +1602,7 @@ mixin SparkInterface on Bip39HDWallet, ElectrumXInterface { for (final coin in coinsToCheck) { final tx = await electrumXCachedClient.getTransaction( txHash: coin.txHash, - coin: info.coin, + cryptoCurrency: info.coin, ); if (tx["height"] is int) { updatedCoins.add(coin.copyWith(height: tx["height"] as int)); diff --git a/lib/widgets/address_book_card.dart b/lib/widgets/address_book_card.dart index f40f4f432..51a9fe134 100644 --- a/lib/widgets/address_book_card.dart +++ b/lib/widgets/address_book_card.dart @@ -8,32 +8,32 @@ * */ -import 'dart:io'; - import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/models/isar/models/contact_entry.dart'; -import 'package:stackwallet/pages/address_book_views/subviews/contact_popup.dart'; -import 'package:stackwallet/providers/global/address_book_service_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/expandable.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; + +import '../app_config.dart'; +import '../models/isar/models/contact_entry.dart'; +import '../pages/address_book_views/subviews/contact_popup.dart'; +import '../providers/global/address_book_service_provider.dart'; +import '../themes/stack_colors.dart'; +import '../utilities/assets.dart'; +import '../utilities/constants.dart'; +import '../utilities/text_styles.dart'; +import '../utilities/util.dart'; +import '../wallets/crypto_currency/crypto_currency.dart'; +import 'app_icon.dart'; +import 'conditional_parent.dart'; +import 'expandable.dart'; +import 'rounded_white_container.dart'; class AddressBookCard extends ConsumerStatefulWidget { const AddressBookCard({ - Key? key, + super.key, required this.contactId, this.indicatorDown, this.desktopSendFrom = true, - }) : super(key: key); + }); final String contactId; final ExpandableState? indicatorDown; @@ -69,9 +69,9 @@ class _AddressBookCardState extends ConsumerState { final contact = _contact!; - final List coins = []; + final List coins = []; - for (final coin in Coin.values) { + for (final coin in AppConfig.coins) { if (contact.addresses.where((e) => e.coin == coin).isNotEmpty) { coins.add(coin); } @@ -103,15 +103,8 @@ class _AddressBookCardState extends ConsumerState { borderRadius: BorderRadius.circular(32), ), child: contact.customId == "default" - ? Center( - child: SvgPicture.file( - File( - ref.watch( - themeProvider.select( - (value) => value.assets.stackIcon, - ), - ), - ), + ? const Center( + child: AppIcon( width: 20, ), ) diff --git a/lib/widgets/animated_widgets/rotating_arrows.dart b/lib/widgets/animated_widgets/rotating_arrows.dart index df7c72897..c0025a45a 100644 --- a/lib/widgets/animated_widgets/rotating_arrows.dart +++ b/lib/widgets/animated_widgets/rotating_arrows.dart @@ -10,8 +10,8 @@ import 'package:flutter/material.dart'; import 'package:lottie/lottie.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; class RotatingArrowsController { VoidCallback? forward; diff --git a/lib/widgets/app_bar_field.dart b/lib/widgets/app_bar_field.dart index 53a226865..d48b20ee9 100644 --- a/lib/widgets/app_bar_field.dart +++ b/lib/widgets/app_bar_field.dart @@ -9,7 +9,7 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; +import '../utilities/text_styles.dart'; class AppBarSearchField extends StatefulWidget { const AppBarSearchField({ diff --git a/lib/widgets/app_icon.dart b/lib/widgets/app_icon.dart new file mode 100644 index 000000000..dbdeaaf3d --- /dev/null +++ b/lib/widgets/app_icon.dart @@ -0,0 +1,75 @@ +import 'dart:io'; + +import 'package:flutter/material.dart'; +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:flutter_svg/flutter_svg.dart'; + +import '../app_config.dart'; +import '../themes/theme_providers.dart'; + +enum _SvgType { + file, + asset; +} + +final _pAppIcon = Provider.autoDispose<({_SvgType svgType, String svg})>((ref) { + if (AppConfig.appIconAsset != null) { + final brightness = ref.watch( + themeProvider.select( + (value) => value.brightness, + ), + ); + final String asset; + + switch (brightness) { + case Brightness.dark: + asset = AppConfig.appIconAsset!.dark; + break; + + case Brightness.light: + asset = AppConfig.appIconAsset!.light; + break; + } + + return (svgType: _SvgType.asset, svg: asset); + } else { + final file = ref.watch( + themeAssetsProvider.select( + (value) => value.stackIcon, + ), + ); + return (svgType: _SvgType.file, svg: file); + } +}); + +class AppIcon extends ConsumerWidget { + const AppIcon({ + super.key, + this.width, + this.height, + }); + + final double? width; + final double? height; + + @override + Widget build(BuildContext context, WidgetRef ref) { + final iconInfo = ref.watch(_pAppIcon); + switch (iconInfo.svgType) { + case _SvgType.file: + return SvgPicture.file( + File( + iconInfo.svg, + ), + width: width, + height: height, + ); + case _SvgType.asset: + return SvgPicture.asset( + iconInfo.svg, + width: width, + height: height, + ); + } + } +} diff --git a/lib/widgets/background.dart b/lib/widgets/background.dart index 3f13f96a2..3d27b24b1 100644 --- a/lib/widgets/background.dart +++ b/lib/widgets/background.dart @@ -13,9 +13,9 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; +import '../themes/stack_colors.dart'; +import '../themes/theme_providers.dart'; +import 'conditional_parent.dart'; class Background extends ConsumerWidget { const Background({ diff --git a/lib/widgets/choose_coin_view.dart b/lib/widgets/choose_coin_view.dart index 52ff990f2..b1238fb6a 100644 --- a/lib/widgets/choose_coin_view.dart +++ b/lib/widgets/choose_coin_view.dart @@ -13,15 +13,16 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/coin_icon_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../providers/providers.dart'; +import '../app_config.dart'; +import '../themes/coin_icon_provider.dart'; +import '../themes/stack_colors.dart'; +import '../utilities/constants.dart'; +import '../utilities/text_styles.dart'; +import '../wallets/crypto_currency/crypto_currency.dart'; +import 'background.dart'; +import 'custom_buttons/app_bar_icon_button.dart'; +import 'rounded_white_container.dart'; /* * This widget is used to choose a coin from a list of coins. @@ -33,11 +34,11 @@ import 'package:stackwallet/widgets/rounded_white_container.dart'; class ChooseCoinView extends ConsumerStatefulWidget { const ChooseCoinView({ - Key? key, + super.key, required this.title, required this.coinAdditional, required this.nextRouteName, - }) : super(key: key); + }); static const String routeName = "/chooseCoin"; @@ -50,12 +51,14 @@ class ChooseCoinView extends ConsumerStatefulWidget { } class _ChooseCoinViewState extends ConsumerState { - List _coins = [...Coin.values]; + List _coins = [...AppConfig.coins]; @override void initState() { _coins = _coins.toList(); - _coins.remove(Coin.firoTestNet); + _coins.removeWhere( + (e) => e.identifier == Firo(CryptoCurrencyNetwork.test).identifier, + ); super.initState(); } @@ -66,12 +69,17 @@ class _ChooseCoinViewState extends ConsumerState { @override Widget build(BuildContext context) { - bool showTestNet = ref.watch( + final bool showTestNet = ref.watch( prefsChangeNotifierProvider.select((value) => value.showTestNetCoins), ); - List coins = - showTestNet ? _coins : _coins.where((e) => !e.isTestNet).toList(); + final List coins = showTestNet + ? _coins + : _coins + .where( + (e) => e.network == CryptoCurrencyNetwork.main, + ) + .toList(); return Background( child: Scaffold( diff --git a/lib/widgets/coin_card.dart b/lib/widgets/coin_card.dart index b4a88e80d..375a27357 100644 --- a/lib/widgets/coin_card.dart +++ b/lib/widgets/coin_card.dart @@ -13,11 +13,11 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/themes/coin_card_provider.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; +import '../themes/coin_card_provider.dart'; +import '../themes/theme_providers.dart'; +import '../utilities/assets.dart'; +import '../utilities/constants.dart'; +import '../wallets/isar/providers/wallet_info_provider.dart'; class CoinCard extends ConsumerWidget { const CoinCard({ diff --git a/lib/widgets/crypto_notifications.dart b/lib/widgets/crypto_notifications.dart index b570ae4f9..ba6eb6792 100644 --- a/lib/widgets/crypto_notifications.dart +++ b/lib/widgets/crypto_notifications.dart @@ -13,10 +13,10 @@ import 'dart:async'; import 'package:event_bus/event_bus.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/services/notifications_api.dart'; -import 'package:stackwallet/themes/coin_icon_provider.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import '../providers/providers.dart'; +import '../services/notifications_api.dart'; +import '../themes/coin_icon_provider.dart'; +import '../wallets/crypto_currency/crypto_currency.dart'; abstract class CryptoNotificationsEventBus { static final instance = EventBus(); @@ -28,7 +28,7 @@ class CryptoNotificationEvent { final String walletName; final DateTime date; final bool shouldWatchForUpdates; - final Coin coin; + final CryptoCurrency coin; final String? txid; final int? confirmations; final int? requiredConfirmations; @@ -52,9 +52,9 @@ class CryptoNotificationEvent { class CryptoNotifications extends ConsumerStatefulWidget { const CryptoNotifications({ - Key? key, + super.key, required this.child, - }) : super(key: key); + }); final Widget child; @@ -74,7 +74,7 @@ class _CryptoNotificationsState extends ConsumerState { iconAssetName: ref.read(coinIconProvider(event.coin)), date: event.date, shouldWatchForUpdates: event.shouldWatchForUpdates, - coinName: event.coin.name, + coinName: event.coin.identifier, txid: event.txid, confirmations: event.confirmations, requiredConfirmations: event.requiredConfirmations, diff --git a/lib/widgets/custom_buttons/app_bar_icon_button.dart b/lib/widgets/custom_buttons/app_bar_icon_button.dart index 96bd533ea..5327d298f 100644 --- a/lib/widgets/custom_buttons/app_bar_icon_button.dart +++ b/lib/widgets/custom_buttons/app_bar_icon_button.dart @@ -10,9 +10,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/util.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/util.dart'; class AppBarIconButton extends StatelessWidget { const AppBarIconButton({ diff --git a/lib/widgets/custom_buttons/blue_text_button.dart b/lib/widgets/custom_buttons/blue_text_button.dart index e0432caeb..8639fc1b1 100644 --- a/lib/widgets/custom_buttons/blue_text_button.dart +++ b/lib/widgets/custom_buttons/blue_text_button.dart @@ -10,11 +10,11 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import '../conditional_parent.dart'; +import '../rounded_container.dart'; class _CustomTextButton extends StatefulWidget { const _CustomTextButton({ diff --git a/lib/widgets/custom_buttons/checkbox_text_button.dart b/lib/widgets/custom_buttons/checkbox_text_button.dart index 8ad254ae9..29e6c5ada 100644 --- a/lib/widgets/custom_buttons/checkbox_text_button.dart +++ b/lib/widgets/custom_buttons/checkbox_text_button.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; +import '../../utilities/text_styles.dart'; class CheckboxTextButton extends StatefulWidget { const CheckboxTextButton({super.key, required this.label, this.onChanged}); diff --git a/lib/widgets/custom_buttons/draggable_switch_button.dart b/lib/widgets/custom_buttons/draggable_switch_button.dart index a3e8a9926..6d77e720c 100644 --- a/lib/widgets/custom_buttons/draggable_switch_button.dart +++ b/lib/widgets/custom_buttons/draggable_switch_button.dart @@ -9,7 +9,7 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; +import '../../themes/stack_colors.dart'; class DraggableSwitchButton extends StatefulWidget { const DraggableSwitchButton({ diff --git a/lib/widgets/custom_buttons/dropdown_button.dart b/lib/widgets/custom_buttons/dropdown_button.dart index df6ef56f8..6ee148a22 100644 --- a/lib/widgets/custom_buttons/dropdown_button.dart +++ b/lib/widgets/custom_buttons/dropdown_button.dart @@ -10,14 +10,14 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/animated_widgets/rotate_icon.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/text_styles.dart'; +import '../animated_widgets/rotate_icon.dart'; +import 'app_bar_icon_button.dart'; +import '../desktop/secondary_button.dart'; +import '../rounded_white_container.dart'; class JDropdownButton extends StatefulWidget { const JDropdownButton({ diff --git a/lib/widgets/custom_buttons/favorite_toggle.dart b/lib/widgets/custom_buttons/favorite_toggle.dart index 7dcb204ea..6014767c6 100644 --- a/lib/widgets/custom_buttons/favorite_toggle.dart +++ b/lib/widgets/custom_buttons/favorite_toggle.dart @@ -11,9 +11,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/utilities/assets.dart'; +import '../../themes/stack_colors.dart'; +import '../../themes/theme_providers.dart'; +import '../../utilities/assets.dart'; class FavoriteToggle extends ConsumerStatefulWidget { const FavoriteToggle({ diff --git a/lib/widgets/custom_buttons/frost_qr_dialog_button.dart b/lib/widgets/custom_buttons/frost_qr_dialog_button.dart index 0b63f097e..8c673d9d4 100644 --- a/lib/widgets/custom_buttons/frost_qr_dialog_button.dart +++ b/lib/widgets/custom_buttons/frost_qr_dialog_button.dart @@ -1,12 +1,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/frost_route_generator.dart'; -import 'package:stackwallet/providers/frost_wallet/frost_wallet_providers.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/dialogs/frost/frost_step_qr_dialog.dart'; +import '../../frost_route_generator.dart'; +import '../../providers/frost_wallet/frost_wallet_providers.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; +import '../desktop/secondary_button.dart'; +import '../dialogs/frost/frost_step_qr_dialog.dart'; class FrostQrDialogPopupButton extends ConsumerWidget { const FrostQrDialogPopupButton({super.key, required this.data}); diff --git a/lib/widgets/custom_buttons/paynym_follow_toggle_button.dart b/lib/widgets/custom_buttons/paynym_follow_toggle_button.dart index 58121e3a5..ad5e80e30 100644 --- a/lib/widgets/custom_buttons/paynym_follow_toggle_button.dart +++ b/lib/widgets/custom_buttons/paynym_follow_toggle_button.dart @@ -13,19 +13,19 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/models/paynym/paynym_account_lite.dart'; -import 'package:stackwallet/models/paynym/paynym_response.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/providers/global/paynym_api_provider.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/loading_indicator.dart'; +import '../../models/paynym/paynym_account_lite.dart'; +import '../../models/paynym/paynym_response.dart'; +import '../../notifications/show_flush_bar.dart'; +import '../../providers/global/paynym_api_provider.dart'; +import '../../providers/global/wallets_provider.dart'; +import '../../providers/wallet/my_paynym_account_state_provider.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/util.dart'; +import '../../wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart'; +import '../desktop/primary_button.dart'; +import '../desktop/secondary_button.dart'; +import '../loading_indicator.dart'; enum PaynymFollowToggleButtonStyle { primary, diff --git a/lib/widgets/custom_buttons/simple_copy_button.dart b/lib/widgets/custom_buttons/simple_copy_button.dart index 5bd7c5501..e8bcc560c 100644 --- a/lib/widgets/custom_buttons/simple_copy_button.dart +++ b/lib/widgets/custom_buttons/simple_copy_button.dart @@ -13,10 +13,10 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; +import '../../notifications/show_flush_bar.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/text_styles.dart'; class SimpleCopyButton extends StatelessWidget { const SimpleCopyButton({ diff --git a/lib/widgets/custom_buttons/simple_edit_button.dart b/lib/widgets/custom_buttons/simple_edit_button.dart index 99d470fe3..2913ce5ae 100644 --- a/lib/widgets/custom_buttons/simple_edit_button.dart +++ b/lib/widgets/custom_buttons/simple_edit_button.dart @@ -10,13 +10,13 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/pages/generic/single_field_edit_view.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/icon_widgets/pencil_icon.dart'; +import '../../pages/generic/single_field_edit_view.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import '../desktop/desktop_dialog.dart'; +import '../icon_widgets/pencil_icon.dart'; import 'package:tuple/tuple.dart'; class SimpleEditButton extends StatelessWidget { diff --git a/lib/widgets/custom_loading_overlay.dart b/lib/widgets/custom_loading_overlay.dart index cd9dac032..f5c326d01 100644 --- a/lib/widgets/custom_loading_overlay.dart +++ b/lib/widgets/custom_loading_overlay.dart @@ -13,11 +13,11 @@ import 'dart:async'; import 'package:event_bus/event_bus.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/loading_indicator.dart'; +import '../themes/stack_colors.dart'; +import '../utilities/text_styles.dart'; +import '../utilities/util.dart'; +import 'conditional_parent.dart'; +import 'loading_indicator.dart'; class CustomLoadingOverlay extends ConsumerStatefulWidget { const CustomLoadingOverlay({ diff --git a/lib/widgets/custom_page_view/custom_page_view.dart b/lib/widgets/custom_page_view/custom_page_view.dart index 825abac26..5540820fe 100644 --- a/lib/widgets/custom_page_view/custom_page_view.dart +++ b/lib/widgets/custom_page_view/custom_page_view.dart @@ -18,7 +18,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/foundation.dart' show precisionErrorTolerance; import 'package:flutter/gestures.dart' show DragStartBehavior; import 'package:flutter/rendering.dart'; -import 'package:stackwallet/widgets/custom_page_view/custom_sliver_fill_viewport.dart'; +import 'custom_sliver_fill_viewport.dart'; /// A controller for [CustomPageView]. /// diff --git a/lib/widgets/custom_pin_put/custom_pin_put.dart b/lib/widgets/custom_pin_put/custom_pin_put.dart index d49391ac1..7d978076b 100644 --- a/lib/widgets/custom_pin_put/custom_pin_put.dart +++ b/lib/widgets/custom_pin_put/custom_pin_put.dart @@ -10,8 +10,8 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:stackwallet/widgets/custom_pin_put/custom_pin_put_state.dart'; -import 'package:stackwallet/widgets/custom_pin_put/pin_keyboard.dart'; +import 'custom_pin_put_state.dart'; +import 'pin_keyboard.dart'; class CustomPinPut extends StatefulWidget { const CustomPinPut({ diff --git a/lib/widgets/custom_pin_put/custom_pin_put_state.dart b/lib/widgets/custom_pin_put/custom_pin_put_state.dart index 4f37d2147..39087695f 100644 --- a/lib/widgets/custom_pin_put/custom_pin_put_state.dart +++ b/lib/widgets/custom_pin_put/custom_pin_put_state.dart @@ -11,8 +11,8 @@ import 'dart:math'; import 'package:flutter/material.dart'; -import 'package:stackwallet/widgets/custom_pin_put/custom_pin_put.dart'; -import 'package:stackwallet/widgets/custom_pin_put/pin_keyboard.dart'; +import 'custom_pin_put.dart'; +import 'pin_keyboard.dart'; class CustomPinPutState extends State with WidgetsBindingObserver, SingleTickerProviderStateMixin { diff --git a/lib/widgets/custom_pin_put/pin_keyboard.dart b/lib/widgets/custom_pin_put/pin_keyboard.dart index 71bbbcc0e..274287a17 100644 --- a/lib/widgets/custom_pin_put/pin_keyboard.dart +++ b/lib/widgets/custom_pin_put/pin_keyboard.dart @@ -12,9 +12,9 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/text_styles.dart'; class NumberKey extends StatefulWidget { const NumberKey({ diff --git a/lib/widgets/custom_tab_view.dart b/lib/widgets/custom_tab_view.dart index 0931aecce..db69a47a5 100644 --- a/lib/widgets/custom_tab_view.dart +++ b/lib/widgets/custom_tab_view.dart @@ -9,8 +9,8 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; +import '../themes/stack_colors.dart'; +import '../utilities/text_styles.dart'; class CustomTabView extends StatefulWidget { const CustomTabView({ diff --git a/lib/widgets/date_picker/date_picker.dart b/lib/widgets/date_picker/date_picker.dart index 054f89ee5..cd843e542 100644 --- a/lib/widgets/date_picker/date_picker.dart +++ b/lib/widgets/date_picker/date_picker.dart @@ -2,12 +2,12 @@ import 'dart:math'; import 'package:calendar_date_picker2/calendar_date_picker2.dart'; import 'package:flutter/material.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/util.dart'; +import '../conditional_parent.dart'; +import '../desktop/primary_button.dart'; +import '../desktop/secondary_button.dart'; part 'sw_date_picker.dart'; diff --git a/lib/widgets/desktop/custom_text_button.dart b/lib/widgets/desktop/custom_text_button.dart index c2908842e..a868ff9ff 100644 --- a/lib/widgets/desktop/custom_text_button.dart +++ b/lib/widgets/desktop/custom_text_button.dart @@ -9,7 +9,7 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/utilities/util.dart'; +import '../../utilities/util.dart'; enum ButtonHeight { xxs, diff --git a/lib/widgets/desktop/delete_button.dart b/lib/widgets/desktop/delete_button.dart index fe0a29ba1..897a4f8fe 100644 --- a/lib/widgets/desktop/delete_button.dart +++ b/lib/widgets/desktop/delete_button.dart @@ -10,11 +10,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/desktop/custom_text_button.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import 'custom_text_button.dart'; class DeleteButton extends StatelessWidget { const DeleteButton({ diff --git a/lib/widgets/desktop/desktop_app_bar.dart b/lib/widgets/desktop/desktop_app_bar.dart index e39af59d1..2c6b39763 100644 --- a/lib/widgets/desktop/desktop_app_bar.dart +++ b/lib/widgets/desktop/desktop_app_bar.dart @@ -9,7 +9,7 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; +import '../conditional_parent.dart'; const double kDesktopAppBarHeight = 96.0; const double kDesktopAppBarHeightCompact = 82.0; diff --git a/lib/widgets/desktop/desktop_dialog.dart b/lib/widgets/desktop/desktop_dialog.dart index 5e8a4a548..d01fb3d77 100644 --- a/lib/widgets/desktop/desktop_dialog.dart +++ b/lib/widgets/desktop/desktop_dialog.dart @@ -9,7 +9,7 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; +import '../../themes/stack_colors.dart'; class DesktopDialog extends StatelessWidget { const DesktopDialog({ diff --git a/lib/widgets/desktop/desktop_dialog_close_button.dart b/lib/widgets/desktop/desktop_dialog_close_button.dart index b7a945233..a9b258737 100644 --- a/lib/widgets/desktop/desktop_dialog_close_button.dart +++ b/lib/widgets/desktop/desktop_dialog_close_button.dart @@ -10,9 +10,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; +import '../custom_buttons/app_bar_icon_button.dart'; class DesktopDialogCloseButton extends StatelessWidget { const DesktopDialogCloseButton({ diff --git a/lib/widgets/desktop/desktop_fee_dialog.dart b/lib/widgets/desktop/desktop_fee_dialog.dart index a4a5a9abc..08597b9eb 100644 --- a/lib/widgets/desktop/desktop_fee_dialog.dart +++ b/lib/widgets/desktop/desktop_fee_dialog.dart @@ -1,31 +1,34 @@ import 'package:cw_core/monero_transaction_priority.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/models.dart'; -import 'package:stackwallet/pages/send_view/sub_widgets/transaction_fee_selection_sheet.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_fee_dropdown.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/providers/wallet/public_private_balance_state_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/wallets/isar/providers/eth/current_token_wallet_provider.dart'; -import 'package:stackwallet/wallets/wallet/impl/firo_wallet.dart'; -import 'package:stackwallet/widgets/animated_text.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; +import '../../models/models.dart'; +import '../../pages/send_view/sub_widgets/transaction_fee_selection_sheet.dart'; +import '../../pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_fee_dropdown.dart'; +import '../../providers/global/wallets_provider.dart'; +import '../../providers/wallet/public_private_balance_state_provider.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/amount/amount.dart'; +import '../../utilities/amount/amount_formatter.dart'; +import '../../utilities/enums/fee_rate_type_enum.dart'; +import '../../utilities/text_styles.dart'; +import '../../wallets/crypto_currency/coins/ethereum.dart'; +import '../../wallets/crypto_currency/coins/firo.dart'; +import '../../wallets/crypto_currency/coins/monero.dart'; +import '../../wallets/crypto_currency/coins/wownero.dart'; +import '../../wallets/crypto_currency/crypto_currency.dart'; +import '../../wallets/isar/providers/eth/current_token_wallet_provider.dart'; +import '../../wallets/wallet/impl/firo_wallet.dart'; +import '../animated_text.dart'; +import '../conditional_parent.dart'; +import 'desktop_dialog.dart'; +import 'desktop_dialog_close_button.dart'; class DesktopFeeDialog extends ConsumerStatefulWidget { const DesktopFeeDialog({ - Key? key, + super.key, required this.walletId, this.isToken = false, - }) : super(key: key); + }); final String walletId; final bool isToken; @@ -44,24 +47,28 @@ class _DesktopFeeDialogState extends ConsumerState { required Amount amount, required FeeRateType feeRateType, required int feeRate, - required Coin coin, + required CryptoCurrency coin, }) async { switch (feeRateType) { case FeeRateType.fast: if (ref - .read(widget.isToken - ? tokenFeeSessionCacheProvider - : feeSheetSessionCacheProvider) + .read( + widget.isToken + ? tokenFeeSessionCacheProvider + : feeSheetSessionCacheProvider, + ) .fast[amount] == null) { if (widget.isToken == false) { final wallet = ref.read(pWallets).getWallet(walletId); - if (coin == Coin.monero || coin == Coin.wownero) { + if (coin is Monero || coin is Wownero) { final fee = await wallet.estimateFeeFor( - amount, MoneroTransactionPriority.fast.raw!); + amount, + MoneroTransactionPriority.fast.raw!, + ); ref.read(feeSheetSessionCacheProvider).fast[amount] = fee; - } else if (coin == Coin.firo || coin == Coin.firoTestNet) { + } else if (coin is Firo) { final Amount fee; switch (ref.read(publicPrivateBalanceStateProvider.state).state) { case FiroType.spark: @@ -86,26 +93,32 @@ class _DesktopFeeDialogState extends ConsumerState { } } return ref - .read(widget.isToken - ? tokenFeeSessionCacheProvider - : feeSheetSessionCacheProvider) + .read( + widget.isToken + ? tokenFeeSessionCacheProvider + : feeSheetSessionCacheProvider, + ) .fast[amount]!; case FeeRateType.average: if (ref - .read(widget.isToken - ? tokenFeeSessionCacheProvider - : feeSheetSessionCacheProvider) + .read( + widget.isToken + ? tokenFeeSessionCacheProvider + : feeSheetSessionCacheProvider, + ) .average[amount] == null) { if (widget.isToken == false) { final wallet = ref.read(pWallets).getWallet(walletId); - if (coin == Coin.monero || coin == Coin.wownero) { + if (coin is Monero || coin is Wownero) { final fee = await wallet.estimateFeeFor( - amount, MoneroTransactionPriority.regular.raw!); + amount, + MoneroTransactionPriority.regular.raw!, + ); ref.read(feeSheetSessionCacheProvider).average[amount] = fee; - } else if (coin == Coin.firo || coin == Coin.firoTestNet) { + } else if (coin is Firo) { final Amount fee; switch (ref.read(publicPrivateBalanceStateProvider.state).state) { case FiroType.spark: @@ -130,26 +143,32 @@ class _DesktopFeeDialogState extends ConsumerState { } } return ref - .read(widget.isToken - ? tokenFeeSessionCacheProvider - : feeSheetSessionCacheProvider) + .read( + widget.isToken + ? tokenFeeSessionCacheProvider + : feeSheetSessionCacheProvider, + ) .average[amount]!; case FeeRateType.slow: if (ref - .read(widget.isToken - ? tokenFeeSessionCacheProvider - : feeSheetSessionCacheProvider) + .read( + widget.isToken + ? tokenFeeSessionCacheProvider + : feeSheetSessionCacheProvider, + ) .slow[amount] == null) { if (widget.isToken == false) { final wallet = ref.read(pWallets).getWallet(walletId); - if (coin == Coin.monero || coin == Coin.wownero) { + if (coin is Monero || coin is Wownero) { final fee = await wallet.estimateFeeFor( - amount, MoneroTransactionPriority.slow.raw!); + amount, + MoneroTransactionPriority.slow.raw!, + ); ref.read(feeSheetSessionCacheProvider).slow[amount] = fee; - } else if (coin == Coin.firo || coin == Coin.firoTestNet) { + } else if (coin is Firo) { final Amount fee; switch (ref.read(publicPrivateBalanceStateProvider.state).state) { case FiroType.spark: @@ -174,9 +193,11 @@ class _DesktopFeeDialogState extends ConsumerState { } } return ref - .read(widget.isToken - ? tokenFeeSessionCacheProvider - : feeSheetSessionCacheProvider) + .read( + widget.isToken + ? tokenFeeSessionCacheProvider + : feeSheetSessionCacheProvider, + ) .slow[amount]!; default: return Amount.zero; @@ -250,14 +271,14 @@ class _DesktopFeeDialogState extends ConsumerState { class DesktopFeeItem extends ConsumerStatefulWidget { const DesktopFeeItem({ - Key? key, + super.key, required this.feeObject, required this.feeRateType, required this.walletId, required this.feeFor, required this.isSelected, this.isButton = true, - }) : super(key: key); + }); final FeeObject? feeObject; final FeeRateType feeRateType; @@ -266,7 +287,7 @@ class DesktopFeeItem extends ConsumerStatefulWidget { required Amount amount, required FeeRateType feeRateType, required int feeRate, - required Coin coin, + required CryptoCurrency coin, }) feeFor; final bool isSelected; final bool isButton; @@ -287,7 +308,9 @@ class _DesktopFeeItemState extends ConsumerState { ]; String estimatedTimeToBeIncludedInNextBlock( - int targetBlockTime, int estimatedNumberOfBlocks) { + int targetBlockTime, + int estimatedNumberOfBlocks, + ) { int time = targetBlockTime * estimatedNumberOfBlocks; int hours = (time / 3600).floor(); @@ -338,14 +361,14 @@ class _DesktopFeeItemState extends ConsumerState { (value) => value.getWallet(widget.walletId).info.coin, ), ); - if ((coin == Coin.firo || coin == Coin.firoTestNet) && + if ((coin is Firo) && ref.watch(publicPrivateBalanceStateProvider.state).state == "Private") { return Text( "~${ref.watch(pAmountFormatter(coin)).format( Amount( rawValue: BigInt.parse("3794"), - fractionDigits: coin.decimals, + fractionDigits: coin.fractionDigits, ), indicatePrecisionLoss: false, )}", @@ -378,7 +401,8 @@ class _DesktopFeeItemState extends ConsumerState { } final wallet = ref.watch( - pWallets.select((value) => value.getWallet(widget.walletId))); + pWallets.select((value) => value.getWallet(widget.walletId)), + ); if (widget.feeObject == null) { return AnimatedText( @@ -410,10 +434,10 @@ class _DesktopFeeItemState extends ConsumerState { indicatePrecisionLoss: false, )})"; - timeString = wallet.info.coin == Coin.ethereum + timeString = wallet.info.coin is Ethereum ? "" : estimatedTimeToBeIncludedInNextBlock( - Constants.targetBlockTimeInSeconds(wallet.info.coin), + wallet.info.coin.targetBlockTimeSeconds, widget.feeRateType == FeeRateType.fast ? widget.feeObject!.numberOfBlocksFast : widget.feeRateType == FeeRateType.slow diff --git a/lib/widgets/desktop/desktop_scaffold.dart b/lib/widgets/desktop/desktop_scaffold.dart index 1f6bc2a70..f3913b094 100644 --- a/lib/widgets/desktop/desktop_scaffold.dart +++ b/lib/widgets/desktop/desktop_scaffold.dart @@ -9,8 +9,8 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/widgets/background.dart'; +import '../../themes/stack_colors.dart'; +import '../background.dart'; class DesktopScaffold extends StatelessWidget { const DesktopScaffold({ diff --git a/lib/widgets/desktop/desktop_tor_status_button.dart b/lib/widgets/desktop/desktop_tor_status_button.dart index da429e9ec..45d82d9ab 100644 --- a/lib/widgets/desktop/desktop_tor_status_button.dart +++ b/lib/widgets/desktop/desktop_tor_status_button.dart @@ -5,13 +5,13 @@ import 'package:flutter/material.dart'; import 'package:flutter_native_splash/cli_commands.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/pages_desktop_specific/desktop_menu_item.dart'; -import 'package:stackwallet/services/event_bus/events/global/tor_connection_status_changed_event.dart'; -import 'package:stackwallet/services/event_bus/global_event_bus.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; +import '../../pages_desktop_specific/desktop_menu_item.dart'; +import '../../services/event_bus/events/global/tor_connection_status_changed_event.dart'; +import '../../services/event_bus/global_event_bus.dart'; +import '../../services/tor_service.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/text_styles.dart'; class DesktopTorStatusButton extends ConsumerStatefulWidget { const DesktopTorStatusButton({ diff --git a/lib/widgets/desktop/living_stack_icon.dart b/lib/widgets/desktop/living_stack_icon.dart index 58568c0e0..aa1595b1f 100644 --- a/lib/widgets/desktop/living_stack_icon.dart +++ b/lib/widgets/desktop/living_stack_icon.dart @@ -8,18 +8,16 @@ * */ -import 'dart:io'; - import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; + +import '../app_icon.dart'; class LivingStackIcon extends ConsumerStatefulWidget { const LivingStackIcon({ - Key? key, + super.key, this.onPressed, - }) : super(key: key); + }); final VoidCallback? onPressed; @@ -59,15 +57,7 @@ class _LivingStackIconState extends ConsumerState { child: AnimatedScale( duration: const Duration(milliseconds: 200), scale: _hovering ? 1.2 : 1, - child: SvgPicture.file( - File( - ref.watch( - themeProvider.select( - (value) => value.assets.stackIcon, - ), - ), - ), - ), + child: const AppIcon(), ), ), ), diff --git a/lib/widgets/desktop/outline_blue_button.dart b/lib/widgets/desktop/outline_blue_button.dart index 356336ae0..6073db347 100644 --- a/lib/widgets/desktop/outline_blue_button.dart +++ b/lib/widgets/desktop/outline_blue_button.dart @@ -9,12 +9,13 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/desktop/custom_text_button.dart'; -export 'package:stackwallet/widgets/desktop/custom_text_button.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import 'custom_text_button.dart'; + +export 'custom_text_button.dart'; class OutlineBlueButton extends StatelessWidget { const OutlineBlueButton({ diff --git a/lib/widgets/desktop/paynym_search_button.dart b/lib/widgets/desktop/paynym_search_button.dart index d49d1e7dd..48d8134a3 100644 --- a/lib/widgets/desktop/paynym_search_button.dart +++ b/lib/widgets/desktop/paynym_search_button.dart @@ -10,9 +10,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; +import '../rounded_container.dart'; class PaynymSearchButton extends StatefulWidget { const PaynymSearchButton({ diff --git a/lib/widgets/desktop/primary_button.dart b/lib/widgets/desktop/primary_button.dart index edf70b493..e9d555700 100644 --- a/lib/widgets/desktop/primary_button.dart +++ b/lib/widgets/desktop/primary_button.dart @@ -9,12 +9,13 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/desktop/custom_text_button.dart'; -export 'package:stackwallet/widgets/desktop/custom_text_button.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import 'custom_text_button.dart'; + +export 'custom_text_button.dart'; class PrimaryButton extends StatelessWidget { const PrimaryButton({ diff --git a/lib/widgets/desktop/secondary_button.dart b/lib/widgets/desktop/secondary_button.dart index 5f4e9d63a..eba9a59f3 100644 --- a/lib/widgets/desktop/secondary_button.dart +++ b/lib/widgets/desktop/secondary_button.dart @@ -9,12 +9,13 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/desktop/custom_text_button.dart'; -export 'package:stackwallet/widgets/desktop/custom_text_button.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import 'custom_text_button.dart'; + +export 'custom_text_button.dart'; class SecondaryButton extends StatelessWidget { const SecondaryButton({ diff --git a/lib/widgets/desktop/simple_desktop_dialog.dart b/lib/widgets/desktop/simple_desktop_dialog.dart index 6fa12c8c7..4b342c060 100644 --- a/lib/widgets/desktop/simple_desktop_dialog.dart +++ b/lib/widgets/desktop/simple_desktop_dialog.dart @@ -9,10 +9,10 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; +import '../../utilities/text_styles.dart'; +import 'desktop_dialog.dart'; +import 'desktop_dialog_close_button.dart'; +import 'primary_button.dart'; class SimpleDesktopDialog extends StatelessWidget { const SimpleDesktopDialog({ diff --git a/lib/widgets/detail_item.dart b/lib/widgets/detail_item.dart index ee3694d0a..b3b1552a2 100644 --- a/lib/widgets/detail_item.dart +++ b/lib/widgets/detail_item.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../themes/stack_colors.dart'; +import '../utilities/text_styles.dart'; +import '../utilities/util.dart'; +import 'conditional_parent.dart'; +import 'rounded_white_container.dart'; class DetailItem extends StatelessWidget { const DetailItem({ diff --git a/lib/widgets/dialogs/basic_dialog.dart b/lib/widgets/dialogs/basic_dialog.dart index d2c5e39eb..fcb54d2eb 100644 --- a/lib/widgets/dialogs/basic_dialog.dart +++ b/lib/widgets/dialogs/basic_dialog.dart @@ -9,11 +9,11 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import '../desktop/desktop_dialog.dart'; +import '../desktop/desktop_dialog_close_button.dart'; +import '../stack_dialog.dart'; class BasicDialog extends StatelessWidget { const BasicDialog({ diff --git a/lib/widgets/dialogs/frost/frost_error_dialog.dart b/lib/widgets/dialogs/frost/frost_error_dialog.dart index 8b1e56e15..a972d529e 100644 --- a/lib/widgets/dialogs/frost/frost_error_dialog.dart +++ b/lib/widgets/dialogs/frost/frost_error_dialog.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/frost_route_generator.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../../frost_route_generator.dart'; +import '../../../utilities/text_styles.dart'; +import '../../desktop/primary_button.dart'; +import '../../stack_dialog.dart'; class FrostErrorDialog extends ConsumerWidget { const FrostErrorDialog({ diff --git a/lib/widgets/dialogs/frost/frost_step_explanation_dialog.dart b/lib/widgets/dialogs/frost/frost_step_explanation_dialog.dart index 102bab1e5..fc8be900c 100644 --- a/lib/widgets/dialogs/frost/frost_step_explanation_dialog.dart +++ b/lib/widgets/dialogs/frost/frost_step_explanation_dialog.dart @@ -9,9 +9,9 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../../utilities/text_styles.dart'; +import '../../desktop/secondary_button.dart'; +import '../../stack_dialog.dart'; class FrostStepExplanationDialog extends StatelessWidget { final String title; diff --git a/lib/widgets/dialogs/frost/frost_step_qr_dialog.dart b/lib/widgets/dialogs/frost/frost_step_qr_dialog.dart index af33383ef..2de302720 100644 --- a/lib/widgets/dialogs/frost/frost_step_qr_dialog.dart +++ b/lib/widgets/dialogs/frost/frost_step_qr_dialog.dart @@ -9,16 +9,16 @@ import 'package:flutter_svg/flutter_svg.dart'; import 'package:path_provider/path_provider.dart'; import 'package:qr_flutter/qr_flutter.dart'; import 'package:share_plus/share_plus.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/dialogs/simple_mobile_dialog.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../../../notifications/show_flush_bar.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../conditional_parent.dart'; +import '../../desktop/secondary_button.dart'; +import '../simple_mobile_dialog.dart'; +import '../../rounded_container.dart'; +import '../../rounded_white_container.dart'; class FrostStepQrDialog extends StatefulWidget { const FrostStepQrDialog({ diff --git a/lib/widgets/dialogs/simple_mobile_dialog.dart b/lib/widgets/dialogs/simple_mobile_dialog.dart index 1e07e22ae..34a94ef26 100644 --- a/lib/widgets/dialogs/simple_mobile_dialog.dart +++ b/lib/widgets/dialogs/simple_mobile_dialog.dart @@ -1,6 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; +import '../../themes/stack_colors.dart'; +import '../desktop/secondary_button.dart'; class SimpleMobileDialog extends StatelessWidget { const SimpleMobileDialog({ diff --git a/lib/widgets/dialogs/tor_warning_dialog.dart b/lib/widgets/dialogs/tor_warning_dialog.dart index d4bd7dc81..d02d2ec1d 100644 --- a/lib/widgets/dialogs/tor_warning_dialog.dart +++ b/lib/widgets/dialogs/tor_warning_dialog.dart @@ -1,20 +1,20 @@ import 'package:flutter/cupertino.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/dialogs/basic_dialog.dart'; +import '../../wallets/crypto_currency/crypto_currency.dart'; +import '../desktop/primary_button.dart'; +import '../desktop/secondary_button.dart'; +import 'basic_dialog.dart'; class TorWarningDialog extends StatelessWidget { - final Coin coin; + final CryptoCurrency coin; final VoidCallback? onContinue; final VoidCallback? onCancel; - TorWarningDialog({ - Key? key, + const TorWarningDialog({ + super.key, required this.coin, this.onContinue, this.onCancel, - }) : super(key: key); + }); @override Widget build(BuildContext context) { diff --git a/lib/widgets/emoji_select_sheet.dart b/lib/widgets/emoji_select_sheet.dart index 01a9f8478..b4330a232 100644 --- a/lib/widgets/emoji_select_sheet.dart +++ b/lib/widgets/emoji_select_sheet.dart @@ -12,16 +12,16 @@ import 'package:emojis/emoji.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/stack_text_field.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../themes/stack_colors.dart'; +import '../utilities/assets.dart'; +import '../utilities/constants.dart'; +import '../utilities/text_styles.dart'; +import '../utilities/util.dart'; +import 'conditional_parent.dart'; +import 'desktop/secondary_button.dart'; +import 'icon_widgets/x_icon.dart'; +import 'stack_text_field.dart'; +import 'textfield_icon_button.dart'; class EmojiSelectSheet extends ConsumerStatefulWidget { const EmojiSelectSheet({ diff --git a/lib/widgets/eth_wallet_radio.dart b/lib/widgets/eth_wallet_radio.dart index 389d7ff61..a164d85ba 100644 --- a/lib/widgets/eth_wallet_radio.dart +++ b/lib/widgets/eth_wallet_radio.dart @@ -10,11 +10,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/wallet_info_row/sub_widgets/wallet_info_row_balance.dart'; -import 'package:stackwallet/widgets/wallet_info_row/sub_widgets/wallet_info_row_coin_icon.dart'; +import '../providers/providers.dart'; +import '../themes/stack_colors.dart'; +import '../utilities/text_styles.dart'; +import 'wallet_info_row/sub_widgets/wallet_info_row_balance.dart'; +import 'wallet_info_row/sub_widgets/wallet_info_row_coin_icon.dart'; class EthWalletRadio extends ConsumerStatefulWidget { const EthWalletRadio({ diff --git a/lib/widgets/exchange/trocador/trocador_kyc_icon.dart b/lib/widgets/exchange/trocador/trocador_kyc_icon.dart index 9a63523de..dc7b75a26 100644 --- a/lib/widgets/exchange/trocador/trocador_kyc_icon.dart +++ b/lib/widgets/exchange/trocador/trocador_kyc_icon.dart @@ -10,9 +10,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/widgets/exchange/trocador/trocador_rating_type_enum.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/assets.dart'; +import 'trocador_rating_type_enum.dart'; class TrocadorKYCIcon extends StatelessWidget { const TrocadorKYCIcon({ diff --git a/lib/widgets/exchange/trocador/trocador_kyc_info_button.dart b/lib/widgets/exchange/trocador/trocador_kyc_info_button.dart index e9c0caad6..91fc2f732 100644 --- a/lib/widgets/exchange/trocador/trocador_kyc_info_button.dart +++ b/lib/widgets/exchange/trocador/trocador_kyc_info_button.dart @@ -9,9 +9,9 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/widgets/exchange/trocador/trocador_kyc_icon.dart'; -import 'package:stackwallet/widgets/exchange/trocador/trocador_rating_type_enum.dart'; -import 'package:stackwallet/widgets/trocador_kyc_rating_info.dart'; +import 'trocador_kyc_icon.dart'; +import 'trocador_rating_type_enum.dart'; +import '../../trocador_kyc_rating_info.dart'; class TrocadorKYCInfoButton extends StatelessWidget { const TrocadorKYCInfoButton({ diff --git a/lib/widgets/expandable2.dart b/lib/widgets/expandable2.dart index 6baf055e3..c806217df 100644 --- a/lib/widgets/expandable2.dart +++ b/lib/widgets/expandable2.dart @@ -9,8 +9,8 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; +import '../themes/stack_colors.dart'; +import '../utilities/constants.dart'; enum Expandable2State { collapsed, diff --git a/lib/widgets/fee_slider.dart b/lib/widgets/fee_slider.dart index 64e3af12b..806e9306f 100644 --- a/lib/widgets/fee_slider.dart +++ b/lib/widgets/fee_slider.dart @@ -1,8 +1,9 @@ import 'dart:math'; import 'package:flutter/material.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; +import '../utilities/text_styles.dart'; +import '../wallets/crypto_currency/coins/dogecoin.dart'; +import '../wallets/crypto_currency/crypto_currency.dart'; class FeeSlider extends StatefulWidget { const FeeSlider({ @@ -12,7 +13,7 @@ class FeeSlider extends StatefulWidget { this.showWU = false, }); - final Coin coin; + final CryptoCurrency coin; final bool showWU; final void Function(int) onSatVByteChanged; @@ -51,12 +52,10 @@ class _FeeSliderState extends State { setState(() { sliderValue = value; final number = pow(sliderValue * (max - min) + min, 4).toDouble(); - switch (widget.coin) { - case Coin.dogecoin: - case Coin.dogecoinTestNet: - rate = (number * 1000).toInt(); - default: - rate = number.toInt(); + if (widget.coin is Dogecoin) { + rate = (number * 1000).toInt(); + } else { + rate = number.toInt(); } }); widget.onSatVByteChanged(rate); diff --git a/lib/widgets/frost_mascot.dart b/lib/widgets/frost_mascot.dart index 17743efcc..182743ddd 100644 --- a/lib/widgets/frost_mascot.dart +++ b/lib/widgets/frost_mascot.dart @@ -9,8 +9,8 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/widgets/dialogs/frost/frost_step_explanation_dialog.dart'; +import '../utilities/assets.dart'; +import 'dialogs/frost/frost_step_explanation_dialog.dart'; class FrostMascot extends StatelessWidget { final String title; diff --git a/lib/widgets/frost_scaffold.dart b/lib/widgets/frost_scaffold.dart index e5d83e088..6ce59ce1d 100644 --- a/lib/widgets/frost_scaffold.dart +++ b/lib/widgets/frost_scaffold.dart @@ -1,16 +1,16 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/frost_route_generator.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/background.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/progress_bar.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../frost_route_generator.dart'; +import '../themes/stack_colors.dart'; +import '../utilities/text_styles.dart'; +import '../utilities/util.dart'; +import 'background.dart'; +import 'conditional_parent.dart'; +import 'custom_buttons/blue_text_button.dart'; +import 'desktop/primary_button.dart'; +import 'desktop/secondary_button.dart'; +import 'progress_bar.dart'; +import 'stack_dialog.dart'; class FrostStepScaffold extends ConsumerStatefulWidget { const FrostStepScaffold({super.key}); diff --git a/lib/widgets/frost_step_user_steps.dart b/lib/widgets/frost_step_user_steps.dart index 729264344..e10fa28af 100644 --- a/lib/widgets/frost_step_user_steps.dart +++ b/lib/widgets/frost_step_user_steps.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../utilities/text_styles.dart'; +import 'conditional_parent.dart'; +import 'rounded_white_container.dart'; class FrostStepUserSteps extends StatelessWidget { const FrostStepUserSteps({super.key, required this.userSteps}); diff --git a/lib/widgets/hover_text_field.dart b/lib/widgets/hover_text_field.dart index 679104537..9ade4d63d 100644 --- a/lib/widgets/hover_text_field.dart +++ b/lib/widgets/hover_text_field.dart @@ -12,13 +12,13 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/global/wallets_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; +import '../notifications/show_flush_bar.dart'; +import '../providers/db/main_db_provider.dart'; +import '../providers/global/wallets_provider.dart'; +import '../themes/stack_colors.dart'; +import '../utilities/constants.dart'; +import '../utilities/text_styles.dart'; +import '../utilities/util.dart'; class DesktopWalletNameField extends ConsumerStatefulWidget { const DesktopWalletNameField({ diff --git a/lib/widgets/icon_widgets/addressbook_icon.dart b/lib/widgets/icon_widgets/addressbook_icon.dart index 7c564d59a..f373c9dbf 100644 --- a/lib/widgets/icon_widgets/addressbook_icon.dart +++ b/lib/widgets/icon_widgets/addressbook_icon.dart @@ -10,8 +10,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; class AddressBookIcon extends StatelessWidget { const AddressBookIcon({ diff --git a/lib/widgets/icon_widgets/clipboard_icon.dart b/lib/widgets/icon_widgets/clipboard_icon.dart index 38228b751..062b3c70d 100644 --- a/lib/widgets/icon_widgets/clipboard_icon.dart +++ b/lib/widgets/icon_widgets/clipboard_icon.dart @@ -10,8 +10,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; class ClipboardIcon extends StatelessWidget { const ClipboardIcon({ diff --git a/lib/widgets/icon_widgets/copy_icon.dart b/lib/widgets/icon_widgets/copy_icon.dart index 91d3647bc..7d5bd4af9 100644 --- a/lib/widgets/icon_widgets/copy_icon.dart +++ b/lib/widgets/icon_widgets/copy_icon.dart @@ -10,8 +10,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; class CopyIcon extends StatelessWidget { const CopyIcon({ diff --git a/lib/widgets/icon_widgets/dice_icon.dart b/lib/widgets/icon_widgets/dice_icon.dart index e71f398a7..27b88a684 100644 --- a/lib/widgets/icon_widgets/dice_icon.dart +++ b/lib/widgets/icon_widgets/dice_icon.dart @@ -10,8 +10,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; class DiceIcon extends StatelessWidget { const DiceIcon({ diff --git a/lib/widgets/icon_widgets/eth_token_icon.dart b/lib/widgets/icon_widgets/eth_token_icon.dart index dbc2d6794..2e0e83a2a 100644 --- a/lib/widgets/icon_widgets/eth_token_icon.dart +++ b/lib/widgets/icon_widgets/eth_token_icon.dart @@ -12,17 +12,18 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/isar/exchange_cache/currency.dart'; -import 'package:stackwallet/services/exchange/exchange_data_loading_service.dart'; -import 'package:stackwallet/themes/coin_icon_provider.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import '../../models/isar/exchange_cache/currency.dart'; +import '../../services/exchange/exchange_data_loading_service.dart'; +import '../../themes/coin_icon_provider.dart'; +import '../../wallets/crypto_currency/coins/ethereum.dart'; +import '../../wallets/crypto_currency/crypto_currency.dart'; class EthTokenIcon extends ConsumerStatefulWidget { const EthTokenIcon({ - Key? key, + super.key, required this.contractAddress, this.size = 22, - }) : super(key: key); + }); final String contractAddress; final double size; @@ -49,7 +50,7 @@ class _EthTokenIconState extends ConsumerState { Widget build(BuildContext context) { if (imageUrl == null || imageUrl!.isEmpty) { return SvgPicture.asset( - ref.watch(coinIconProvider(Coin.ethereum)), + ref.watch(coinIconProvider(Ethereum(CryptoCurrencyNetwork.main))), width: widget.size, height: widget.size, ); diff --git a/lib/widgets/icon_widgets/pencil_icon.dart b/lib/widgets/icon_widgets/pencil_icon.dart index a12c0d0a6..1389207a2 100644 --- a/lib/widgets/icon_widgets/pencil_icon.dart +++ b/lib/widgets/icon_widgets/pencil_icon.dart @@ -10,8 +10,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; class PencilIcon extends StatelessWidget { const PencilIcon({ diff --git a/lib/widgets/icon_widgets/qrcode_icon.dart b/lib/widgets/icon_widgets/qrcode_icon.dart index f7e417ad8..cc84ff39a 100644 --- a/lib/widgets/icon_widgets/qrcode_icon.dart +++ b/lib/widgets/icon_widgets/qrcode_icon.dart @@ -10,8 +10,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; class QrCodeIcon extends StatelessWidget { const QrCodeIcon({ diff --git a/lib/widgets/icon_widgets/share_icon.dart b/lib/widgets/icon_widgets/share_icon.dart index b61f0860a..449f04ae1 100644 --- a/lib/widgets/icon_widgets/share_icon.dart +++ b/lib/widgets/icon_widgets/share_icon.dart @@ -10,8 +10,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; class ShareIcon extends StatelessWidget { const ShareIcon({ diff --git a/lib/widgets/icon_widgets/utxo_status_icon.dart b/lib/widgets/icon_widgets/utxo_status_icon.dart index b409fcebf..3c78308df 100644 --- a/lib/widgets/icon_widgets/utxo_status_icon.dart +++ b/lib/widgets/icon_widgets/utxo_status_icon.dart @@ -10,10 +10,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; +import '../conditional_parent.dart'; +import '../rounded_container.dart'; enum UTXOStatusIconStatus { confirmed, diff --git a/lib/widgets/icon_widgets/x_icon.dart b/lib/widgets/icon_widgets/x_icon.dart index b0730d472..03a536e51 100644 --- a/lib/widgets/icon_widgets/x_icon.dart +++ b/lib/widgets/icon_widgets/x_icon.dart @@ -10,8 +10,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; class XIcon extends StatelessWidget { const XIcon({ diff --git a/lib/widgets/loading_indicator.dart b/lib/widgets/loading_indicator.dart index a535fb251..e42216fae 100644 --- a/lib/widgets/loading_indicator.dart +++ b/lib/widgets/loading_indicator.dart @@ -13,8 +13,8 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:lottie/lottie.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/utilities/assets.dart'; +import '../themes/theme_providers.dart'; +import '../utilities/assets.dart'; class LoadingIndicator extends ConsumerWidget { const LoadingIndicator({ diff --git a/lib/widgets/managed_favorite.dart b/lib/widgets/managed_favorite.dart index b5266ea2a..c89bc483b 100644 --- a/lib/widgets/managed_favorite.dart +++ b/lib/widgets/managed_favorite.dart @@ -13,24 +13,25 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/themes/coin_icon_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/widgets/custom_buttons/favorite_toggle.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../providers/db/main_db_provider.dart'; +import '../themes/coin_icon_provider.dart'; +import '../themes/stack_colors.dart'; +import '../themes/theme_providers.dart'; +import '../utilities/amount/amount.dart'; +import '../utilities/amount/amount_formatter.dart'; +import '../utilities/constants.dart'; +import '../utilities/text_styles.dart'; +import '../utilities/util.dart'; +import '../wallets/crypto_currency/coins/firo.dart'; +import '../wallets/isar/providers/wallet_info_provider.dart'; +import 'custom_buttons/favorite_toggle.dart'; +import 'rounded_white_container.dart'; class ManagedFavorite extends ConsumerStatefulWidget { const ManagedFavorite({ - Key? key, + super.key, required this.walletId, - }) : super(key: key); + }); final String walletId; @@ -50,7 +51,7 @@ class _ManagedFavoriteCardState extends ConsumerState { final coin = ref.watch(pWalletCoin(walletId)); Amount total = ref.watch(pWalletBalance(walletId)).total; - if (coin == Coin.firo || coin == Coin.firoTestNet) { + if (coin is Firo) { final balancePrivate = ref.watch(pWalletBalanceSecondary(walletId)).total + ref.watch(pWalletBalanceTertiary(walletId)).total; @@ -85,10 +86,7 @@ class _ManagedFavoriteCardState extends ConsumerState { children: [ Container( decoration: BoxDecoration( - color: Theme.of(context) - .extension()! - .colorForCoin(coin) - .withOpacity(0.5), + color: ref.watch(pCoinColor(coin)).withOpacity(0.5), borderRadius: BorderRadius.circular( Constants.size.circularBorderRadius, ), @@ -141,7 +139,7 @@ class _ManagedFavoriteCardState extends ConsumerState { .extension()! .buttonTextBorderless, ), - ) + ), ], ), ), diff --git a/lib/widgets/master_wallet_card.dart b/lib/widgets/master_wallet_card.dart index f6d37d27a..3eb07a6db 100644 --- a/lib/widgets/master_wallet_card.dart +++ b/lib/widgets/master_wallet_card.dart @@ -11,16 +11,16 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; -import 'package:stackwallet/widgets/animated_widgets/rotate_icon.dart'; -import 'package:stackwallet/widgets/expandable.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/wallet_card.dart'; -import 'package:stackwallet/widgets/wallet_info_row/wallet_info_row.dart'; +import '../themes/stack_colors.dart'; +import '../utilities/assets.dart'; +import '../utilities/constants.dart'; +import '../utilities/util.dart'; +import '../wallets/isar/providers/wallet_info_provider.dart'; +import 'animated_widgets/rotate_icon.dart'; +import 'expandable.dart'; +import 'rounded_white_container.dart'; +import 'wallet_card.dart'; +import 'wallet_info_row/wallet_info_row.dart'; class MasterWalletCard extends ConsumerStatefulWidget { const MasterWalletCard({ diff --git a/lib/widgets/node_card.dart b/lib/widgets/node_card.dart index a6ac18302..b8a6f9cad 100644 --- a/lib/widgets/node_card.dart +++ b/lib/widgets/node_card.dart @@ -13,45 +13,37 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:solana/solana.dart'; -import 'package:stackwallet/models/node_model.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/manage_nodes_views/node_details_view.dart'; -import 'package:stackwallet/providers/global/active_wallet_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/connection_check/electrum_connection_check.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/default_nodes.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/sync_type_enum.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/test_epic_box_connection.dart'; -import 'package:stackwallet/utilities/test_eth_node_connection.dart'; -import 'package:stackwallet/utilities/test_monero_node_connection.dart'; -import 'package:stackwallet/utilities/test_stellar_node_connection.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/api/tezos/tezos_rpc_api.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/expandable.dart'; -import 'package:stackwallet/widgets/node_options_sheet.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../notifications/show_flush_bar.dart'; +import '../pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart'; +import '../pages/settings_views/global_settings_view/manage_nodes_views/node_details_view.dart'; +import '../providers/global/active_wallet_provider.dart'; +import '../providers/global/secure_store_provider.dart'; +import '../providers/providers.dart'; +import '../themes/stack_colors.dart'; +import '../utilities/assets.dart'; +import '../utilities/constants.dart'; +import '../utilities/default_nodes.dart'; +import '../utilities/enums/sync_type_enum.dart'; +import '../utilities/test_node_connection.dart'; +import '../utilities/text_styles.dart'; +import '../utilities/util.dart'; +import '../wallets/crypto_currency/crypto_currency.dart'; +import 'conditional_parent.dart'; +import 'custom_buttons/blue_text_button.dart'; +import 'expandable.dart'; +import 'node_options_sheet.dart'; +import 'rounded_white_container.dart'; import 'package:tuple/tuple.dart'; class NodeCard extends ConsumerStatefulWidget { const NodeCard({ - Key? key, + super.key, required this.nodeId, required this.coin, required this.popBackToRoute, - }) : super(key: key); + }); - final Coin coin; + final CryptoCurrency coin; final String nodeId; final String popBackToRoute; @@ -97,161 +89,6 @@ class _NodeCardState extends ConsumerState { } } - Future _testConnection( - NodeModel node, - BuildContext context, - WidgetRef ref, - ) async { - bool testPassed = false; - - switch (widget.coin) { - case Coin.epicCash: - try { - testPassed = await testEpicNodeConnection( - NodeFormData() - ..host = node.host - ..useSSL = node.useSSL - ..port = node.port, - ) != - null; - } catch (e, s) { - Logging.instance.log("$e\n$s", level: LogLevel.Warning); - } - break; - - case Coin.monero: - case Coin.wownero: - try { - final uri = Uri.parse(node.host); - if (uri.scheme.startsWith("http")) { - final String path = uri.path.isEmpty ? "/json_rpc" : uri.path; - - String uriString = "${uri.scheme}://${uri.host}:${node.port}$path"; - - final response = await testMoneroNodeConnection( - Uri.parse(uriString), - false, - ); - - if (response.cert != null) { - if (mounted) { - final shouldAllowBadCert = await showBadX509CertificateDialog( - response.cert!, - response.url!, - response.port!, - context, - ); - - if (shouldAllowBadCert) { - final response = await testMoneroNodeConnection( - Uri.parse(uriString), true); - testPassed = response.success; - } - } - } else { - testPassed = response.success; - } - } - } catch (e, s) { - Logging.instance.log("$e\n$s", level: LogLevel.Warning); - } - - break; - - case Coin.bitcoin: - case Coin.litecoin: - case Coin.dogecoin: - case Coin.firo: - case Coin.particl: - case Coin.bitcoinTestNet: - case Coin.firoTestNet: - case Coin.dogecoinTestNet: - case Coin.bitcoincash: - case Coin.litecoinTestNet: - case Coin.namecoin: - case Coin.bitcoincashTestnet: - case Coin.eCash: - case Coin.bitcoinFrost: - case Coin.bitcoinFrostTestNet: - case Coin.peercoin: - case Coin.peercoinTestNet: - try { - testPassed = await checkElectrumServer( - host: node.host, - port: node.port, - useSSL: node.useSSL, - overridePrefs: ref.read(prefsChangeNotifierProvider), - overrideTorService: ref.read(pTorService), - ); - } catch (_) { - testPassed = false; - } - - break; - - case Coin.ethereum: - try { - testPassed = await testEthNodeConnection(node.host); - } catch (_) { - testPassed = false; - } - break; - - case Coin.nano: - case Coin.banano: - throw UnimplementedError(); - //TODO: check network/node - case Coin.tezos: - try { - testPassed = await TezosRpcAPI.testNetworkConnection( - nodeInfo: (host: node.host, port: node.port), - ); - } catch (_) {} - break; - case Coin.stellar: - case Coin.stellarTestnet: - try { - testPassed = await testStellarNodeConnection(node.host, node.port); - } catch (_) { - testPassed = false; - } - break; - - case Coin.solana: - try { - RpcClient rpcClient; - if (node.host.startsWith("http") || node.host.startsWith("https")) { - rpcClient = RpcClient("${node.host}:${node.port}"); - } else { - rpcClient = RpcClient("http://${node.host}:${node.port}"); - } - await rpcClient.getEpochInfo().then((value) => testPassed = true); - } catch (_) { - testPassed = false; - } - break; - } - - if (testPassed) { - // showFloatingFlushBar( - // type: FlushBarType.success, - // message: "Server ping success", - // context: context, - // ); - } else { - unawaited( - showFloatingFlushBar( - type: FlushBarType.warning, - iconAsset: Assets.svg.circleAlert, - message: "Could not connect to node", - context: context, - ), - ); - } - - return testPassed; - } - @override void initState() { nodeId = widget.nodeId; @@ -260,10 +97,14 @@ class _NodeCardState extends ConsumerState { @override Widget build(BuildContext context) { - final node = ref.watch(nodeServiceChangeNotifierProvider - .select((value) => value.getPrimaryNodeFor(coin: widget.coin))); - final _node = ref.watch(nodeServiceChangeNotifierProvider - .select((value) => value.getNodeById(id: nodeId)))!; + final node = ref.watch( + nodeServiceChangeNotifierProvider + .select((value) => value.getPrimaryNodeFor(currency: widget.coin)), + ); + final _node = ref.watch( + nodeServiceChangeNotifierProvider + .select((value) => value.getNodeById(id: nodeId)), + )!; if (node?.name == _node.name) { _status = "Connected"; @@ -324,21 +165,50 @@ class _NodeCardState extends ConsumerState { text: "Connect", enabled: _status == "Disconnected", onTap: () async { - final canConnect = - await _testConnection(_node, context, ref); - if (!canConnect) { - return; + final nodeFormData = NodeFormData() + ..useSSL = _node.useSSL + ..trusted = _node.trusted + ..name = _node.name + ..host = _node.host + ..login = _node.loginName + ..port = _node.port + ..isFailover = _node.isFailover; + nodeFormData.password = await _node.getPassword( + ref.read(secureStoreProvider), + ); + + if (context.mounted) { + final canConnect = await testNodeConnection( + context: context, + nodeFormData: nodeFormData, + cryptoCurrency: widget.coin, + ref: ref, + ); + + if (!canConnect) { + if (context.mounted) { + unawaited( + showFloatingFlushBar( + type: FlushBarType.warning, + iconAsset: Assets.svg.circleAlert, + message: "Could not connect to node", + context: context, + ), + ); + } + return; + } + + await ref + .read(nodeServiceChangeNotifierProvider) + .setPrimaryNodeFor( + coin: widget.coin, + node: _node, + shouldNotifyListeners: true, + ); + + await _notifyWalletsOfUpdatedNode(ref); } - - await ref - .read(nodeServiceChangeNotifierProvider) - .setPrimaryNodeFor( - coin: widget.coin, - node: _node, - shouldNotifyListeners: true, - ); - - await _notifyWalletsOfUpdatedNode(ref); }, ), const SizedBox( diff --git a/lib/widgets/node_options_sheet.dart b/lib/widgets/node_options_sheet.dart index 31bdec456..37316dd05 100644 --- a/lib/widgets/node_options_sheet.dart +++ b/lib/widgets/node_options_sheet.dart @@ -14,38 +14,38 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:solana/solana.dart'; -import 'package:stackwallet/models/node_model.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/manage_nodes_views/node_details_view.dart'; -import 'package:stackwallet/providers/global/active_wallet_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/connection_check/electrum_connection_check.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/default_nodes.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/sync_type_enum.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/test_epic_box_connection.dart'; -import 'package:stackwallet/utilities/test_eth_node_connection.dart'; -import 'package:stackwallet/utilities/test_monero_node_connection.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../models/node_model.dart'; +import '../notifications/show_flush_bar.dart'; +import '../pages/settings_views/global_settings_view/manage_nodes_views/add_edit_node_view.dart'; +import '../pages/settings_views/global_settings_view/manage_nodes_views/node_details_view.dart'; +import '../providers/global/active_wallet_provider.dart'; +import '../providers/providers.dart'; +import '../services/tor_service.dart'; +import '../themes/stack_colors.dart'; +import '../utilities/assets.dart'; +import '../utilities/connection_check/electrum_connection_check.dart'; +import '../utilities/constants.dart'; +import '../utilities/default_nodes.dart'; +import '../utilities/enums/sync_type_enum.dart'; +import '../utilities/logger.dart'; +import '../utilities/test_epic_box_connection.dart'; +import '../utilities/test_eth_node_connection.dart'; +import '../utilities/test_monero_node_connection.dart'; +import '../utilities/text_styles.dart'; +import '../wallets/crypto_currency/crypto_currency.dart'; +import 'rounded_white_container.dart'; import 'package:tuple/tuple.dart'; class NodeOptionsSheet extends ConsumerWidget { const NodeOptionsSheet({ - Key? key, + super.key, required this.nodeId, required this.coin, required this.popBackToRoute, - }) : super(key: key); + }); final String nodeId; - final Coin coin; + final CryptoCurrency coin; final String popBackToRoute; Future _notifyWalletsOfUpdatedNode(WidgetRef ref) async { @@ -82,11 +82,14 @@ class NodeOptionsSheet extends ConsumerWidget { } Future _testConnection( - NodeModel node, BuildContext context, WidgetRef ref) async { + NodeModel node, + BuildContext context, + WidgetRef ref, + ) async { bool testPassed = false; - switch (coin) { - case Coin.epicCash: + switch (coin.runtimeType) { + case const (Epiccash): try { testPassed = await testEpicNodeConnection( NodeFormData() @@ -100,14 +103,15 @@ class NodeOptionsSheet extends ConsumerWidget { } break; - case Coin.monero: - case Coin.wownero: + case const (Monero): + case const (Wownero): try { final uri = Uri.parse(node.host); if (uri.scheme.startsWith("http")) { final String path = uri.path.isEmpty ? "/json_rpc" : uri.path; - String uriString = "${uri.scheme}://${uri.host}:${node.port}$path"; + final String uriString = + "${uri.scheme}://${uri.host}:${node.port}$path"; final response = await testMoneroNodeConnection( Uri.parse(uriString), @@ -139,23 +143,16 @@ class NodeOptionsSheet extends ConsumerWidget { break; - case Coin.bitcoin: - case Coin.litecoin: - case Coin.dogecoin: - case Coin.firo: - case Coin.particl: - case Coin.bitcoinTestNet: - case Coin.firoTestNet: - case Coin.dogecoinTestNet: - case Coin.bitcoincash: - case Coin.litecoinTestNet: - case Coin.namecoin: - case Coin.bitcoincashTestnet: - case Coin.eCash: - case Coin.bitcoinFrost: - case Coin.bitcoinFrostTestNet: - case Coin.peercoin: - case Coin.peercoinTestNet: + case const (Bitcoin): + case const (Litecoin): + case const (Dogecoin): + case const (Firo): + case const (Particl): + case const (Bitcoincash): + case const (Namecoin): + case const (Ecash): + case const (BitcoinFrost): + case const (Peercoin): try { testPassed = await checkElectrumServer( host: node.host, @@ -170,7 +167,7 @@ class NodeOptionsSheet extends ConsumerWidget { break; - case Coin.ethereum: + case const (Ethereum): try { testPassed = await testEthNodeConnection(node.host); } catch (_) { @@ -178,15 +175,14 @@ class NodeOptionsSheet extends ConsumerWidget { } break; - case Coin.nano: - case Coin.banano: - case Coin.tezos: - case Coin.stellar: - case Coin.stellarTestnet: + case const (Nano): + case const (Banano): + case const (Tezos): + case const (Stellar): throw UnimplementedError(); //TODO: check network/node - case Coin.solana: + case const (Solana): try { RpcClient rpcClient; if (node.host.startsWith("http") || node.host.startsWith("https")) { @@ -208,12 +204,14 @@ class NodeOptionsSheet extends ConsumerWidget { // context: context, // ); } else { - unawaited(showFloatingFlushBar( - type: FlushBarType.warning, - iconAsset: Assets.svg.circleAlert, - message: "Could not connect to node", - context: context, - )); + unawaited( + showFloatingFlushBar( + type: FlushBarType.warning, + iconAsset: Assets.svg.circleAlert, + message: "Could not connect to node", + context: context, + ), + ); } return testPassed; @@ -222,12 +220,16 @@ class NodeOptionsSheet extends ConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { final maxHeight = MediaQuery.of(context).size.height * 0.60; - final node = ref.watch(nodeServiceChangeNotifierProvider - .select((value) => value.getNodeById(id: nodeId)))!; + final node = ref.watch( + nodeServiceChangeNotifierProvider + .select((value) => value.getNodeById(id: nodeId)), + )!; final status = ref - .watch(nodeServiceChangeNotifierProvider - .select((value) => value.getPrimaryNodeFor(coin: coin))) + .watch( + nodeServiceChangeNotifierProvider.select( + (value) => value.getPrimaryNodeFor(currency: coin)), + ) ?.id != nodeId ? "Disconnected" @@ -301,7 +303,8 @@ class NodeOptionsSheet extends ConsumerWidget { height: 15, width: 19, color: node.id.startsWith( - DefaultNodes.defaultNodeIdPrefix) + DefaultNodes.defaultNodeIdPrefix, + ) ? Theme.of(context) .extension()! .accentColorDark @@ -367,9 +370,10 @@ class NodeOptionsSheet extends ConsumerWidget { child: Text( "Details", style: STextStyles.button(context).copyWith( - color: Theme.of(context) - .extension()! - .accentColorDark), + color: Theme.of(context) + .extension()! + .accentColorDark, + ), ), ), ), diff --git a/lib/widgets/onetime_popups/tor_has_been_add_dialog.dart b/lib/widgets/onetime_popups/tor_has_been_add_dialog.dart index 2e265024f..0c189cf63 100644 --- a/lib/widgets/onetime_popups/tor_has_been_add_dialog.dart +++ b/lib/widgets/onetime_popups/tor_has_been_add_dialog.dart @@ -1,14 +1,14 @@ import 'package:flutter/material.dart'; import 'package:hive_flutter/hive_flutter.dart'; -import 'package:stackwallet/db/hive/db.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../../db/hive/db.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import '../conditional_parent.dart'; +import '../desktop/desktop_dialog.dart'; +import '../desktop/desktop_dialog_close_button.dart'; +import '../desktop/primary_button.dart'; +import '../stack_dialog.dart'; const _kOneTimeTorHasBeenAddedDialogWasShown = "oneTimeTorHasBeenAddedDialogWasShown"; diff --git a/lib/widgets/rounded_container.dart b/lib/widgets/rounded_container.dart index 8a29ca7ad..d75dc6966 100644 --- a/lib/widgets/rounded_container.dart +++ b/lib/widgets/rounded_container.dart @@ -9,8 +9,8 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; +import '../utilities/constants.dart'; +import 'conditional_parent.dart'; class RoundedContainer extends StatelessWidget { const RoundedContainer({ diff --git a/lib/widgets/rounded_white_container.dart b/lib/widgets/rounded_white_container.dart index 93efb63ec..0097397e8 100644 --- a/lib/widgets/rounded_white_container.dart +++ b/lib/widgets/rounded_white_container.dart @@ -9,8 +9,8 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; +import '../themes/stack_colors.dart'; +import 'rounded_container.dart'; class RoundedWhiteContainer extends StatelessWidget { const RoundedWhiteContainer({ diff --git a/lib/widgets/small_tor_icon.dart b/lib/widgets/small_tor_icon.dart index 711a77ba5..ed5486069 100644 --- a/lib/widgets/small_tor_icon.dart +++ b/lib/widgets/small_tor_icon.dart @@ -1,13 +1,13 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/pages/settings_views/global_settings_view/tor_settings/tor_settings_view.dart'; -import 'package:stackwallet/services/event_bus/events/global/tor_connection_status_changed_event.dart'; -import 'package:stackwallet/services/tor_service.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; -import 'package:stackwallet/widgets/tor_subscription.dart'; +import '../pages/settings_views/global_settings_view/tor_settings/tor_settings_view.dart'; +import '../services/event_bus/events/global/tor_connection_status_changed_event.dart'; +import '../services/tor_service.dart'; +import '../themes/stack_colors.dart'; +import '../utilities/assets.dart'; +import 'custom_buttons/app_bar_icon_button.dart'; +import 'tor_subscription.dart'; class SmallTorIcon extends ConsumerStatefulWidget { const SmallTorIcon({super.key}); diff --git a/lib/widgets/stack_dialog.dart b/lib/widgets/stack_dialog.dart index bc247c2f2..58fb69ea2 100644 --- a/lib/widgets/stack_dialog.dart +++ b/lib/widgets/stack_dialog.dart @@ -9,9 +9,9 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; +import '../themes/stack_colors.dart'; +import '../utilities/text_styles.dart'; +import '../utilities/util.dart'; class StackDialogBase extends StatelessWidget { const StackDialogBase({ diff --git a/lib/widgets/stack_text_field.dart b/lib/widgets/stack_text_field.dart index 5cd0691d5..359f5c0d3 100644 --- a/lib/widgets/stack_text_field.dart +++ b/lib/widgets/stack_text_field.dart @@ -9,9 +9,9 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; +import '../themes/stack_colors.dart'; +import '../utilities/text_styles.dart'; +import '../utilities/util.dart'; InputDecoration standardInputDecoration( String? labelText, diff --git a/lib/widgets/table_view/table_view_row.dart b/lib/widgets/table_view/table_view_row.dart index 548d829ad..3f8bd826d 100644 --- a/lib/widgets/table_view/table_view_row.dart +++ b/lib/widgets/table_view/table_view_row.dart @@ -9,9 +9,9 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/widgets/expandable.dart'; -import 'package:stackwallet/widgets/table_view/table_view_cell.dart'; +import '../../themes/stack_colors.dart'; +import '../expandable.dart'; +import 'table_view_cell.dart'; class TableViewRow extends StatefulWidget { const TableViewRow({ diff --git a/lib/widgets/textfields/exchange_textfield.dart b/lib/widgets/textfields/exchange_textfield.dart index 4abcb6671..0266d6637 100644 --- a/lib/widgets/textfields/exchange_textfield.dart +++ b/lib/widgets/textfields/exchange_textfield.dart @@ -11,15 +11,17 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/models/exchange/aggregate_currency.dart'; -import 'package:stackwallet/pages/buy_view/sub_widgets/crypto_selection_view.dart'; -import 'package:stackwallet/providers/global/locale_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount_input_formatter.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/loading_indicator.dart'; + +import '../../app_config.dart'; +import '../../models/exchange/aggregate_currency.dart'; +import '../../pages/buy_view/sub_widgets/crypto_selection_view.dart'; +import '../../providers/global/locale_provider.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/amount/amount_input_formatter.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import '../loading_indicator.dart'; class ExchangeTextField extends ConsumerStatefulWidget { const ExchangeTextField({ @@ -173,7 +175,8 @@ class _ExchangeTextFieldState extends ConsumerState { ), child: Builder( builder: (context) { - if (isStackCoin(widget.currency?.ticker)) { + if (AppConfig.isStackCoin( + widget.currency?.ticker)) { return Center( child: CoinIconForTicker( size: 18, diff --git a/lib/widgets/textfields/frost_step_field.dart b/lib/widgets/textfields/frost_step_field.dart index 7fd19ba3b..8ce64b089 100644 --- a/lib/widgets/textfields/frost_step_field.dart +++ b/lib/widgets/textfields/frost_step_field.dart @@ -1,16 +1,16 @@ import 'package:barcode_scan2/barcode_scan2.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/icon_widgets/clipboard_icon.dart'; -import 'package:stackwallet/widgets/icon_widgets/qrcode_icon.dart'; -import 'package:stackwallet/widgets/icon_widgets/x_icon.dart'; -import 'package:stackwallet/widgets/textfield_icon_button.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/constants.dart'; +import '../../utilities/logger.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import '../conditional_parent.dart'; +import '../icon_widgets/clipboard_icon.dart'; +import '../icon_widgets/qrcode_icon.dart'; +import '../icon_widgets/x_icon.dart'; +import '../textfield_icon_button.dart'; class FrostStepField extends StatefulWidget { const FrostStepField({ diff --git a/lib/widgets/toggle.dart b/lib/widgets/toggle.dart index 1a5591eab..dec082d5f 100644 --- a/lib/widgets/toggle.dart +++ b/lib/widgets/toggle.dart @@ -10,9 +10,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; +import '../themes/stack_colors.dart'; +import '../utilities/text_styles.dart'; +import '../utilities/util.dart'; class Toggle extends StatefulWidget { const Toggle({ diff --git a/lib/widgets/tor_subscription.dart b/lib/widgets/tor_subscription.dart index 30904e9f4..d849ff51b 100644 --- a/lib/widgets/tor_subscription.dart +++ b/lib/widgets/tor_subscription.dart @@ -3,8 +3,8 @@ import 'dart:async'; import 'package:event_bus/event_bus.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/services/event_bus/events/global/tor_connection_status_changed_event.dart'; -import 'package:stackwallet/services/event_bus/global_event_bus.dart'; +import '../services/event_bus/events/global/tor_connection_status_changed_event.dart'; +import '../services/event_bus/global_event_bus.dart'; class TorSubscription extends ConsumerStatefulWidget { const TorSubscription({ diff --git a/lib/widgets/trade_card.dart b/lib/widgets/trade_card.dart index ae6197070..5305ad584 100644 --- a/lib/widgets/trade_card.dart +++ b/lib/widgets/trade_card.dart @@ -14,15 +14,15 @@ import 'package:decimal/decimal.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/models/exchange/change_now/exchange_transaction_status.dart'; -import 'package:stackwallet/models/exchange/response_objects/trade.dart'; -import 'package:stackwallet/models/isar/stack_theme.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; -import 'package:stackwallet/utilities/format.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; +import '../models/exchange/change_now/exchange_transaction_status.dart'; +import '../models/exchange/response_objects/trade.dart'; +import '../models/isar/stack_theme.dart'; +import '../themes/theme_providers.dart'; +import '../utilities/format.dart'; +import '../utilities/text_styles.dart'; +import '../utilities/util.dart'; +import 'conditional_parent.dart'; +import 'rounded_white_container.dart'; class TradeCard extends ConsumerWidget { const TradeCard({ diff --git a/lib/widgets/transaction_card.dart b/lib/widgets/transaction_card.dart index 6f3995002..323fb7ebe 100644 --- a/lib/widgets/transaction_card.dart +++ b/lib/widgets/transaction_card.dart @@ -12,21 +12,23 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/isar/models/isar_models.dart'; -import 'package:stackwallet/notifications/show_flush_bar.dart'; -import 'package:stackwallet/pages/wallet_view/sub_widgets/tx_icon.dart'; -import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/format.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; +import '../models/isar/models/isar_models.dart'; +import '../notifications/show_flush_bar.dart'; +import '../pages/wallet_view/sub_widgets/tx_icon.dart'; +import '../pages/wallet_view/transaction_views/transaction_details_view.dart'; +import '../providers/db/main_db_provider.dart'; +import '../providers/providers.dart'; +import '../themes/stack_colors.dart'; +import '../utilities/amount/amount.dart'; +import '../utilities/amount/amount_formatter.dart'; +import '../utilities/constants.dart'; +import '../utilities/format.dart'; +import '../utilities/text_styles.dart'; +import '../utilities/util.dart'; +import '../wallets/crypto_currency/coins/epiccash.dart'; +import '../wallets/crypto_currency/coins/ethereum.dart'; +import '../wallets/crypto_currency/crypto_currency.dart'; +import 'desktop/desktop_dialog.dart'; import 'package:tuple/tuple.dart'; class TransactionCard extends ConsumerStatefulWidget { @@ -49,16 +51,16 @@ class _TransactionCardState extends ConsumerState { late final bool isTokenTx; late final String prefix; late final String unit; - late final Coin coin; + late final CryptoCurrency coin; late final EthContract? tokenContract; late final int minConfirms; String whatIsIt( TransactionType type, - Coin coin, + CryptoCurrency coin, int currentHeight, ) { - if (coin == Coin.epicCash && _transaction.slateId == null) { + if (coin is Epiccash && _transaction.slateId == null) { return "Restored Funds"; } @@ -169,7 +171,7 @@ class _TransactionCardState extends ConsumerState { ), ), onPressed: () async { - if (coin == Coin.epicCash && _transaction.slateId == null) { + if (coin is Epiccash && _transaction.slateId == null) { unawaited(showFloatingFlushBar( context: context, message: @@ -230,7 +232,7 @@ class _TransactionCardState extends ConsumerState { fit: BoxFit.scaleDown, child: Text( _transaction.isCancelled - ? coin == Coin.ethereum + ? coin is Ethereum ? "Failed" : "Cancelled" : whatIsIt( diff --git a/lib/widgets/trocador_kyc_rating_info.dart b/lib/widgets/trocador_kyc_rating_info.dart index a35c03fcc..9c5b04c9f 100644 --- a/lib/widgets/trocador_kyc_rating_info.dart +++ b/lib/widgets/trocador_kyc_rating_info.dart @@ -9,15 +9,15 @@ */ import 'package:flutter/material.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; -import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/desktop/secondary_button.dart'; -import 'package:stackwallet/widgets/exchange/trocador/trocador_kyc_icon.dart'; -import 'package:stackwallet/widgets/exchange/trocador/trocador_rating_type_enum.dart'; -import 'package:stackwallet/widgets/stack_dialog.dart'; +import '../utilities/text_styles.dart'; +import 'conditional_parent.dart'; +import 'desktop/desktop_dialog.dart'; +import 'desktop/desktop_dialog_close_button.dart'; +import 'desktop/primary_button.dart'; +import 'desktop/secondary_button.dart'; +import 'exchange/trocador/trocador_kyc_icon.dart'; +import 'exchange/trocador/trocador_rating_type_enum.dart'; +import 'stack_dialog.dart'; class TrocadorKYCRatingInfo extends StatelessWidget { const TrocadorKYCRatingInfo({Key? key}) : super(key: key); diff --git a/lib/widgets/wallet_card.dart b/lib/widgets/wallet_card.dart index 9345cf271..98c5fbeac 100644 --- a/lib/widgets/wallet_card.dart +++ b/lib/widgets/wallet_card.dart @@ -12,27 +12,27 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart'; -import 'package:stackwallet/pages/token_view/token_view.dart'; -import 'package:stackwallet/pages/wallet_view/wallet_view.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/desktop_token_view.dart'; -import 'package:stackwallet/pages_desktop_specific/my_stack_view/wallet_view/desktop_wallet_view.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/logger.dart'; -import 'package:stackwallet/utilities/show_loading.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/eth/current_token_wallet_provider.dart'; -import 'package:stackwallet/wallets/wallet/impl/ethereum_wallet.dart'; -import 'package:stackwallet/wallets/wallet/impl/sub_wallets/eth_token_wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet.dart'; -import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/cw_based_interface.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/desktop/primary_button.dart'; -import 'package:stackwallet/widgets/dialogs/basic_dialog.dart'; -import 'package:stackwallet/widgets/rounded_white_container.dart'; -import 'package:stackwallet/widgets/wallet_info_row/wallet_info_row.dart'; +import '../models/isar/models/ethereum/eth_contract.dart'; +import '../pages/token_view/token_view.dart'; +import '../pages/wallet_view/wallet_view.dart'; +import '../pages_desktop_specific/my_stack_view/wallet_view/desktop_token_view.dart'; +import '../pages_desktop_specific/my_stack_view/wallet_view/desktop_wallet_view.dart'; +import '../providers/db/main_db_provider.dart'; +import '../providers/providers.dart'; +import '../utilities/constants.dart'; +import '../utilities/logger.dart'; +import '../utilities/show_loading.dart'; +import '../utilities/util.dart'; +import '../wallets/isar/providers/eth/current_token_wallet_provider.dart'; +import '../wallets/wallet/impl/ethereum_wallet.dart'; +import '../wallets/wallet/impl/sub_wallets/eth_token_wallet.dart'; +import '../wallets/wallet/wallet.dart'; +import '../wallets/wallet/wallet_mixin_interfaces/cw_based_interface.dart'; +import 'conditional_parent.dart'; +import 'desktop/primary_button.dart'; +import 'dialogs/basic_dialog.dart'; +import 'rounded_white_container.dart'; +import 'wallet_info_row/wallet_info_row.dart'; class SimpleWalletCard extends ConsumerWidget { const SimpleWalletCard({ diff --git a/lib/widgets/wallet_info_row/sub_widgets/wallet_info_row_balance.dart b/lib/widgets/wallet_info_row/sub_widgets/wallet_info_row_balance.dart index 55a897255..e88737d4e 100644 --- a/lib/widgets/wallet_info_row/sub_widgets/wallet_info_row_balance.dart +++ b/lib/widgets/wallet_info_row/sub_widgets/wallet_info_row_balance.dart @@ -10,15 +10,15 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/db/isar/main_db.dart'; -import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/amount/amount.dart'; -import 'package:stackwallet/utilities/amount/amount_formatter.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/wallets/isar/providers/eth/token_balance_provider.dart'; -import 'package:stackwallet/wallets/isar/providers/wallet_info_provider.dart'; +import '../../../db/isar/main_db.dart'; +import '../../../models/isar/models/ethereum/eth_contract.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/amount/amount.dart'; +import '../../../utilities/amount/amount_formatter.dart'; +import '../../../utilities/text_styles.dart'; +import '../../../utilities/util.dart'; +import '../../../wallets/isar/providers/eth/token_balance_provider.dart'; +import '../../../wallets/isar/providers/wallet_info_provider.dart'; class WalletInfoRowBalance extends ConsumerWidget { const WalletInfoRowBalance({ diff --git a/lib/widgets/wallet_info_row/sub_widgets/wallet_info_row_coin_icon.dart b/lib/widgets/wallet_info_row/sub_widgets/wallet_info_row_coin_icon.dart index 1da53d402..0212d89d6 100644 --- a/lib/widgets/wallet_info_row/sub_widgets/wallet_info_row_coin_icon.dart +++ b/lib/widgets/wallet_info_row/sub_widgets/wallet_info_row_coin_icon.dart @@ -14,23 +14,23 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; import 'package:isar/isar.dart'; -import 'package:stackwallet/models/isar/exchange_cache/currency.dart'; -import 'package:stackwallet/services/exchange/change_now/change_now_exchange.dart'; -import 'package:stackwallet/services/exchange/exchange_data_loading_service.dart'; -import 'package:stackwallet/themes/coin_icon_provider.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import '../../../models/isar/exchange_cache/currency.dart'; +import '../../../services/exchange/change_now/change_now_exchange.dart'; +import '../../../services/exchange/exchange_data_loading_service.dart'; +import '../../../themes/coin_icon_provider.dart'; +import '../../../themes/theme_providers.dart'; +import '../../../utilities/constants.dart'; +import '../../../wallets/crypto_currency/crypto_currency.dart'; class WalletInfoCoinIcon extends ConsumerWidget { const WalletInfoCoinIcon({ - Key? key, + super.key, required this.coin, this.size = 32, this.contractAddress, - }) : super(key: key); + }); - final Coin coin; + final CryptoCurrency coin; final String? contractAddress; final double size; @@ -55,10 +55,7 @@ class WalletInfoCoinIcon extends ConsumerWidget { width: size, height: size, decoration: BoxDecoration( - color: Theme.of(context) - .extension()! - .colorForCoin(coin) - .withOpacity(0.4), + color: ref.watch(pCoinColor(coin)).withOpacity(0.4), borderRadius: BorderRadius.circular( Constants.size.circularBorderRadius, ), diff --git a/lib/widgets/wallet_info_row/wallet_info_row.dart b/lib/widgets/wallet_info_row/wallet_info_row.dart index bed25d102..3510e389f 100644 --- a/lib/widgets/wallet_info_row/wallet_info_row.dart +++ b/lib/widgets/wallet_info_row/wallet_info_row.dart @@ -10,16 +10,16 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart'; -import 'package:stackwallet/pages/token_view/sub_widgets/token_summary.dart'; -import 'package:stackwallet/providers/db/main_db_provider.dart'; -import 'package:stackwallet/providers/providers.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/utilities/util.dart'; -import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart'; -import 'package:stackwallet/widgets/wallet_info_row/sub_widgets/wallet_info_row_balance.dart'; -import 'package:stackwallet/widgets/wallet_info_row/sub_widgets/wallet_info_row_coin_icon.dart'; +import '../../models/isar/models/ethereum/eth_contract.dart'; +import '../../pages/token_view/sub_widgets/token_summary.dart'; +import '../../providers/db/main_db_provider.dart'; +import '../../providers/providers.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/text_styles.dart'; +import '../../utilities/util.dart'; +import '../custom_buttons/blue_text_button.dart'; +import 'sub_widgets/wallet_info_row_balance.dart'; +import 'sub_widgets/wallet_info_row_coin_icon.dart'; class WalletInfoRow extends ConsumerWidget { const WalletInfoRow({ diff --git a/lib/widgets/wallet_navigation_bar/components/icons/buy_nav_icon.dart b/lib/widgets/wallet_navigation_bar/components/icons/buy_nav_icon.dart index 84800acba..586fae900 100644 --- a/lib/widgets/wallet_navigation_bar/components/icons/buy_nav_icon.dart +++ b/lib/widgets/wallet_navigation_bar/components/icons/buy_nav_icon.dart @@ -13,7 +13,7 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; +import '../../../../themes/theme_providers.dart'; class BuyNavIcon extends ConsumerWidget { const BuyNavIcon({Key? key}) : super(key: key); diff --git a/lib/widgets/wallet_navigation_bar/components/icons/coin_control_nav_icon.dart b/lib/widgets/wallet_navigation_bar/components/icons/coin_control_nav_icon.dart index a95b36015..94c5bae23 100644 --- a/lib/widgets/wallet_navigation_bar/components/icons/coin_control_nav_icon.dart +++ b/lib/widgets/wallet_navigation_bar/components/icons/coin_control_nav_icon.dart @@ -10,8 +10,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; class CoinControlNavIcon extends StatelessWidget { const CoinControlNavIcon({Key? key}) : super(key: key); diff --git a/lib/widgets/wallet_navigation_bar/components/icons/exchange_nav_icon.dart b/lib/widgets/wallet_navigation_bar/components/icons/exchange_nav_icon.dart index 25a71c7b7..25e4c0122 100644 --- a/lib/widgets/wallet_navigation_bar/components/icons/exchange_nav_icon.dart +++ b/lib/widgets/wallet_navigation_bar/components/icons/exchange_nav_icon.dart @@ -13,7 +13,7 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/themes/theme_providers.dart'; +import '../../../../themes/theme_providers.dart'; class ExchangeNavIcon extends ConsumerWidget { const ExchangeNavIcon({Key? key}) : super(key: key); diff --git a/lib/widgets/wallet_navigation_bar/components/icons/frost_sign_nav_icon.dart b/lib/widgets/wallet_navigation_bar/components/icons/frost_sign_nav_icon.dart index b91542a8e..e9fb99e95 100644 --- a/lib/widgets/wallet_navigation_bar/components/icons/frost_sign_nav_icon.dart +++ b/lib/widgets/wallet_navigation_bar/components/icons/frost_sign_nav_icon.dart @@ -11,8 +11,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; class FrostSignNavIcon extends ConsumerWidget { const FrostSignNavIcon({super.key}); diff --git a/lib/widgets/wallet_navigation_bar/components/icons/fusion_nav_icon.dart b/lib/widgets/wallet_navigation_bar/components/icons/fusion_nav_icon.dart index ce1d4bef0..07b0b16bc 100644 --- a/lib/widgets/wallet_navigation_bar/components/icons/fusion_nav_icon.dart +++ b/lib/widgets/wallet_navigation_bar/components/icons/fusion_nav_icon.dart @@ -10,8 +10,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; class FusionNavIcon extends StatelessWidget { const FusionNavIcon({Key? key}) : super(key: key); diff --git a/lib/widgets/wallet_navigation_bar/components/icons/ordinals_nav_icon.dart b/lib/widgets/wallet_navigation_bar/components/icons/ordinals_nav_icon.dart index 4c23bf20a..98bfecb4f 100644 --- a/lib/widgets/wallet_navigation_bar/components/icons/ordinals_nav_icon.dart +++ b/lib/widgets/wallet_navigation_bar/components/icons/ordinals_nav_icon.dart @@ -10,8 +10,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; class OrdinalsNavIcon extends StatelessWidget { const OrdinalsNavIcon({Key? key}) : super(key: key); diff --git a/lib/widgets/wallet_navigation_bar/components/icons/paynym_nav_icon.dart b/lib/widgets/wallet_navigation_bar/components/icons/paynym_nav_icon.dart index cdf881432..9f11d4136 100644 --- a/lib/widgets/wallet_navigation_bar/components/icons/paynym_nav_icon.dart +++ b/lib/widgets/wallet_navigation_bar/components/icons/paynym_nav_icon.dart @@ -10,8 +10,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; class PaynymNavIcon extends StatelessWidget { const PaynymNavIcon({Key? key}) : super(key: key); diff --git a/lib/widgets/wallet_navigation_bar/components/icons/receive_nav_icon.dart b/lib/widgets/wallet_navigation_bar/components/icons/receive_nav_icon.dart index 832899aa4..96be35a96 100644 --- a/lib/widgets/wallet_navigation_bar/components/icons/receive_nav_icon.dart +++ b/lib/widgets/wallet_navigation_bar/components/icons/receive_nav_icon.dart @@ -10,8 +10,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; class ReceiveNavIcon extends StatelessWidget { const ReceiveNavIcon({Key? key}) : super(key: key); diff --git a/lib/widgets/wallet_navigation_bar/components/icons/send_nav_icon.dart b/lib/widgets/wallet_navigation_bar/components/icons/send_nav_icon.dart index 122cc4d17..3d388f3a2 100644 --- a/lib/widgets/wallet_navigation_bar/components/icons/send_nav_icon.dart +++ b/lib/widgets/wallet_navigation_bar/components/icons/send_nav_icon.dart @@ -10,8 +10,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; class SendNavIcon extends StatelessWidget { const SendNavIcon({Key? key}) : super(key: key); diff --git a/lib/widgets/wallet_navigation_bar/components/icons/whirlpool_nav_icon.dart b/lib/widgets/wallet_navigation_bar/components/icons/whirlpool_nav_icon.dart index 6be7a1953..02c9aaf80 100644 --- a/lib/widgets/wallet_navigation_bar/components/icons/whirlpool_nav_icon.dart +++ b/lib/widgets/wallet_navigation_bar/components/icons/whirlpool_nav_icon.dart @@ -10,8 +10,8 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; +import '../../../../themes/stack_colors.dart'; +import '../../../../utilities/assets.dart'; class WhirlpoolNavIcon extends StatelessWidget { const WhirlpoolNavIcon({Key? key}) : super(key: key); diff --git a/lib/widgets/wallet_navigation_bar/components/wallet_navigation_bar_item.dart b/lib/widgets/wallet_navigation_bar/components/wallet_navigation_bar_item.dart index 4394cef92..6cf3c2601 100644 --- a/lib/widgets/wallet_navigation_bar/components/wallet_navigation_bar_item.dart +++ b/lib/widgets/wallet_navigation_bar/components/wallet_navigation_bar_item.dart @@ -10,10 +10,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/rounded_container.dart'; -import 'package:stackwallet/widgets/wallet_navigation_bar/wallet_navigation_bar.dart'; +import '../../../themes/stack_colors.dart'; +import '../../../utilities/text_styles.dart'; +import '../../rounded_container.dart'; +import '../wallet_navigation_bar.dart'; class WalletNavigationBarItemData { WalletNavigationBarItemData({ diff --git a/lib/widgets/wallet_navigation_bar/wallet_navigation_bar.dart b/lib/widgets/wallet_navigation_bar/wallet_navigation_bar.dart index a462f9927..b272048c3 100644 --- a/lib/widgets/wallet_navigation_bar/wallet_navigation_bar.dart +++ b/lib/widgets/wallet_navigation_bar/wallet_navigation_bar.dart @@ -11,11 +11,11 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/text_styles.dart'; -import 'package:stackwallet/widgets/conditional_parent.dart'; -import 'package:stackwallet/widgets/wallet_navigation_bar/components/wallet_navigation_bar_item.dart'; +import '../../themes/stack_colors.dart'; +import '../../utilities/assets.dart'; +import '../../utilities/text_styles.dart'; +import '../conditional_parent.dart'; +import 'components/wallet_navigation_bar_item.dart'; final walletNavBarMore = StateProvider.autoDispose((ref) => false); diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png deleted file mode 100644 index 65564e63b..000000000 Binary files a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png and /dev/null differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png deleted file mode 100644 index 998750358..000000000 Binary files a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png and /dev/null differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png deleted file mode 100644 index 7d6531e39..000000000 Binary files a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png and /dev/null differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png deleted file mode 100644 index e81fc06dc..000000000 Binary files a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png and /dev/null differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png deleted file mode 100644 index 5ff3261b8..000000000 Binary files a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png and /dev/null differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png deleted file mode 100644 index 6ae00a8d2..000000000 Binary files a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png and /dev/null differ diff --git a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png b/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png deleted file mode 100644 index 1f195abc4..000000000 Binary files a/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png and /dev/null differ diff --git a/scripts/android/build_all.sh b/scripts/android/build_all.sh index 5da88e0e3..861f02cb5 100755 --- a/scripts/android/build_all.sh +++ b/scripts/android/build_all.sh @@ -1,6 +1,6 @@ #!/bin/bash -set -e +set -x -e # libepiccash requires old rust source ../rust_version.sh diff --git a/scripts/android/build_all_duo.sh b/scripts/android/build_all_duo.sh new file mode 100755 index 000000000..bca175541 --- /dev/null +++ b/scripts/android/build_all_duo.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +set -x -e + +# todo: revisit following at some point + +# libepiccash requires old rust +source ../rust_version.sh +set_rust_to_1671 + +mkdir -p build +. ./config.sh +./install_ndk.sh + +PLUGINS_DIR=../../crypto_plugins + +(cd "${PLUGINS_DIR}"/flutter_liblelantus/scripts/android && ./build_all.sh ) & +(cd "${PLUGINS_DIR}"/flutter_libepiccash/scripts/android && ./build_all.sh ) & +(cd "${PLUGINS_DIR}"/flutter_libmonero/scripts/android/ && ./build_all.sh ) && +set_rust_to_1720 && +(cd "${PLUGINS_DIR}"/frostdart/scripts/android && ./build_all.sh ) & + +wait +echo "Done building" diff --git a/scripts/app_config/configure_stack_duo.sh b/scripts/app_config/configure_stack_duo.sh new file mode 100755 index 000000000..16b68a030 --- /dev/null +++ b/scripts/app_config/configure_stack_duo.sh @@ -0,0 +1,56 @@ +#!/bin/bash + +set -x -e + +# Configure files for Duo. + +export NEW_NAME="Stack Duo" +export NEW_APP_ID="com.cypherstack.stackduo" +export NEW_APP_ID_CAMEL="com.cypherstack.stackDuo" +export NEW_APP_ID_SNAKE="com.cypherstack.stack_duo" +export NEW_BASIC_NAME="stack_duo" + +NEW_PUBSPEC_NAME="stackduo" +PUBSPEC_FILE="${APP_PROJECT_ROOT_DIR}/pubspec.yaml" + +# String replacements. +if [[ "$(uname)" == 'Darwin' ]]; then + # macos specific sed + sed -i '' "s/name: PLACEHOLDER/name: ${NEW_PUBSPEC_NAME}/g" "${PUBSPEC_FILE}" + sed -i '' "s/description: PLACEHOLDER/description: ${NEW_NAME}/g" "${PUBSPEC_FILE}" +else + sed -i "s/name: PLACEHOLDER/name: ${NEW_PUBSPEC_NAME}/g" "${PUBSPEC_FILE}" + sed -i "s/description: PLACEHOLDER/description: ${NEW_NAME}/g" "${PUBSPEC_FILE}" +fi + +pushd "${APP_PROJECT_ROOT_DIR}" +BUILT_COMMIT_HASH=$(git log -1 --pretty=format:"%H") +popd + +APP_CONFIG_DART_FILE="${APP_PROJECT_ROOT_DIR}/lib/app_config.g.dart" +rm -f "$APP_CONFIG_DART_FILE" +cat << EOF > "$APP_CONFIG_DART_FILE" +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'app_config.dart'; + +const _prefix = "Stack"; +const _separator = " "; +const _suffix = "Duo"; +const _appDataDirName = "stackduo"; +const _commitHash = "$BUILT_COMMIT_HASH"; + +const ({String light, String dark})? _appIconAsset = ( + light: "assets/in_app_logo_icons/stack-duo-icon_light.svg", + dark: "assets/in_app_logo_icons/stack-duo-icon_dark.svg", +); + +final List _supportedCoins = List.unmodifiable([ + Bitcoin(CryptoCurrencyNetwork.main), + Monero(CryptoCurrencyNetwork.main), + BitcoinFrost(CryptoCurrencyNetwork.main), + Bitcoin(CryptoCurrencyNetwork.test), + BitcoinFrost(CryptoCurrencyNetwork.test), +]); + +EOF \ No newline at end of file diff --git a/scripts/app_config/configure_stack_wallet.sh b/scripts/app_config/configure_stack_wallet.sh new file mode 100755 index 000000000..cd0b463b5 --- /dev/null +++ b/scripts/app_config/configure_stack_wallet.sh @@ -0,0 +1,75 @@ +#!/bin/bash + +set -x -e + +# Configure files for Stack Wallet. + +export NEW_NAME="Stack Wallet" +export NEW_APP_ID="com.cypherstack.stackwallet" +export NEW_APP_ID_CAMEL="com.cypherstack.stackWallet" +export NEW_APP_ID_SNAKE="com.cypherstack.stack_wallet" +export NEW_BASIC_NAME="stack_wallet" + +NEW_PUBSPEC_NAME="stackwallet" +PUBSPEC_FILE="${APP_PROJECT_ROOT_DIR}/pubspec.yaml" + +# String replacements. +if [[ "$(uname)" == 'Darwin' ]]; then + # macos specific sed + sed -i '' "s/name: PLACEHOLDER/name: ${NEW_PUBSPEC_NAME}/g" "${PUBSPEC_FILE}" + sed -i '' "s/description: PLACEHOLDER/description: ${NEW_NAME}/g" "${PUBSPEC_FILE}" +else + sed -i "s/name: PLACEHOLDER/name: ${NEW_PUBSPEC_NAME}/g" "${PUBSPEC_FILE}" + sed -i "s/description: PLACEHOLDER/description: ${NEW_NAME}/g" "${PUBSPEC_FILE}" +fi + +pushd "${APP_PROJECT_ROOT_DIR}" +BUILT_COMMIT_HASH=$(git log -1 --pretty=format:"%H") +popd + +APP_CONFIG_DART_FILE="${APP_PROJECT_ROOT_DIR}/lib/app_config.g.dart" +rm -f "$APP_CONFIG_DART_FILE" +cat << EOF > "$APP_CONFIG_DART_FILE" +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'app_config.dart'; + +const _prefix = "Stack"; +const _separator = " "; +const _suffix = "Wallet"; +const _appDataDirName = "stackwallet"; +const _commitHash = "$BUILT_COMMIT_HASH"; + +const ({String light, String dark})? _appIconAsset = null; + +final List _supportedCoins = List.unmodifiable([ + Bitcoin(CryptoCurrencyNetwork.main), + BitcoinFrost(CryptoCurrencyNetwork.main), + Litecoin(CryptoCurrencyNetwork.main), + Bitcoincash(CryptoCurrencyNetwork.main), + Dogecoin(CryptoCurrencyNetwork.main), + Epiccash(CryptoCurrencyNetwork.main), + Ecash(CryptoCurrencyNetwork.main), + Ethereum(CryptoCurrencyNetwork.main), + Firo(CryptoCurrencyNetwork.main), + Monero(CryptoCurrencyNetwork.main), + Particl(CryptoCurrencyNetwork.main), + Peercoin(CryptoCurrencyNetwork.main), + Solana(CryptoCurrencyNetwork.main), + Stellar(CryptoCurrencyNetwork.main), + Tezos(CryptoCurrencyNetwork.main), + Wownero(CryptoCurrencyNetwork.main), + Namecoin(CryptoCurrencyNetwork.main), + Nano(CryptoCurrencyNetwork.main), + Banano(CryptoCurrencyNetwork.main), + Bitcoin(CryptoCurrencyNetwork.test), + BitcoinFrost(CryptoCurrencyNetwork.test), + Litecoin(CryptoCurrencyNetwork.test), + Bitcoincash(CryptoCurrencyNetwork.test), + Firo(CryptoCurrencyNetwork.test), + Dogecoin(CryptoCurrencyNetwork.test), + Stellar(CryptoCurrencyNetwork.test), + Peercoin(CryptoCurrencyNetwork.test), +]); + +EOF \ No newline at end of file diff --git a/scripts/app_config/platforms/android/flutter_launcher_icons.yaml b/scripts/app_config/platforms/android/flutter_launcher_icons.yaml new file mode 100644 index 000000000..c47ed7cc4 --- /dev/null +++ b/scripts/app_config/platforms/android/flutter_launcher_icons.yaml @@ -0,0 +1,21 @@ +# flutter pub run flutter_launcher_icons +flutter_launcher_icons: + image_path: "assets/icon/icon.png" + + android: true + image_path_android: "assets/icon/macos-icon.png" + min_sdk_android: 21 # android min sdk min:16, default 21 + # adaptive_icon_background: "assets/icon/background.png" + # adaptive_icon_foreground: "assets/icon/foreground.png" + adaptive_icon_monochrome: "assets/icon/app_icon_alpha.png" + + ios: false + + web: + generate: false + + windows: + generate: false + + macos: + generate: false diff --git a/scripts/app_config/platforms/android/platform_config.sh b/scripts/app_config/platforms/android/platform_config.sh new file mode 100755 index 000000000..e9dc04cc1 --- /dev/null +++ b/scripts/app_config/platforms/android/platform_config.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +set -x -e + +for (( i=0; i<=5; i++ )); do + VAR="ANDROID_TF_${i}" + FILE="${APP_PROJECT_ROOT_DIR}/${!VAR}" + TEMPLATE="${TEMPLATES_DIR}/${!VAR}" + if cmp -s "${TEMPLATE}" "${FILE}"; then + rm "${FILE}" + cp -rp "${TEMPLATE}" "${FILE}" + fi +done + + +sed -i "s/${APP_ID_PLACEHOLDER}/${NEW_APP_ID}/g" "${APP_PROJECT_ROOT_DIR}/${ANDROID_TF_0}" +sed -i "s/${APP_ID_PLACEHOLDER}/${NEW_APP_ID}/g" "${APP_PROJECT_ROOT_DIR}/${ANDROID_TF_1}" +sed -i "s/${APP_ID_PLACEHOLDER}/${NEW_APP_ID}/g" "${APP_PROJECT_ROOT_DIR}/${ANDROID_TF_2}" +sed -i "s/${APP_ID_PLACEHOLDER}/${NEW_APP_ID}/g" "${APP_PROJECT_ROOT_DIR}/${ANDROID_TF_3}" +sed -i "s/${APP_NAME_PLACEHOLDER}/${NEW_NAME}/g" "${APP_PROJECT_ROOT_DIR}/${ANDROID_TF_3}" +sed -i "s/${APP_ID_PLACEHOLDER}/${NEW_APP_ID}/g" "${APP_PROJECT_ROOT_DIR}/${ANDROID_TF_4}" +sed -i "s/${APP_ID_PLACEHOLDER}/${NEW_APP_ID}/g" "${APP_PROJECT_ROOT_DIR}/${ANDROID_TF_5}" diff --git a/scripts/app_config/platforms/ios/flutter_launcher_icons.yaml b/scripts/app_config/platforms/ios/flutter_launcher_icons.yaml new file mode 100644 index 000000000..c7b437b93 --- /dev/null +++ b/scripts/app_config/platforms/ios/flutter_launcher_icons.yaml @@ -0,0 +1,17 @@ +# flutter pub run flutter_launcher_icons +flutter_launcher_icons: + + android: false + + ios: true + image_path_ios: "assets/icon/icon.png" + remove_alpha_ios: true + + web: + generate: false + + windows: + generate: false + + macos: + generate: false diff --git a/scripts/app_config/platforms/ios/platform_config.sh b/scripts/app_config/platforms/ios/platform_config.sh new file mode 100755 index 000000000..b60d3615c --- /dev/null +++ b/scripts/app_config/platforms/ios/platform_config.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +set -x -e + +for (( i=0; i<=1; i++ )); do + VAR="IOS_TF_${i}" + FILE="${APP_PROJECT_ROOT_DIR}/${!VAR}" + TEMPLATE="${TEMPLATES_DIR}/${!VAR}" + if cmp -s "${TEMPLATE}" "${FILE}"; then + rm "${FILE}" + cp -rp "${TEMPLATE}" "${FILE}" + fi +done + +# Configure ios for Duo. +sed -i '' "s/${APP_NAME_PLACEHOLDER}/${NEW_NAME}/g" "${APP_PROJECT_ROOT_DIR}/${IOS_TF_0}" +sed -i '' "s/${APP_ID_PLACEHOLDER}/${NEW_APP_ID}/g" "${APP_PROJECT_ROOT_DIR}/${IOS_TF_1}" diff --git a/scripts/app_config/platforms/linux/platform_config.sh b/scripts/app_config/platforms/linux/platform_config.sh new file mode 100755 index 000000000..018f80def --- /dev/null +++ b/scripts/app_config/platforms/linux/platform_config.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +set -x -e + +for (( i=0; i<=1; i++ )); do + VAR="LINUX_TF_${i}" + FILE="${APP_PROJECT_ROOT_DIR}/${!VAR}" + TEMPLATE="${TEMPLATES_DIR}/${!VAR}" + if cmp -s "${TEMPLATE}" "${FILE}"; then + rm "${FILE}" + cp -rp "${TEMPLATE}" "${FILE}" + fi +done + +# Configure Linux for Duo. +sed -i "s/${APP_BASIC_NAME_PLACEHOLDER}/${NEW_BASIC_NAME}/g" "${APP_PROJECT_ROOT_DIR}/${LINUX_TF_0}" +sed -i "s/${APP_NAME_PLACEHOLDER}/${NEW_NAME}/g" "${APP_PROJECT_ROOT_DIR}/${LINUX_TF_1}" diff --git a/scripts/app_config/platforms/macos/flutter_launcher_icons.yaml b/scripts/app_config/platforms/macos/flutter_launcher_icons.yaml new file mode 100644 index 000000000..c485f1e4e --- /dev/null +++ b/scripts/app_config/platforms/macos/flutter_launcher_icons.yaml @@ -0,0 +1,15 @@ +# flutter pub run flutter_launcher_icons +flutter_launcher_icons: + android: false + + ios: false + + web: + generate: false + + windows: + generate: false + + macos: + generate: true + image_path: assets/icon/macos-icon.png diff --git a/scripts/app_config/platforms/macos/platform_config.sh b/scripts/app_config/platforms/macos/platform_config.sh new file mode 100755 index 000000000..c54ba32a6 --- /dev/null +++ b/scripts/app_config/platforms/macos/platform_config.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +set -x -e + +for (( i=0; i<=2; i++ )); do + VAR="MAC_TF_${i}" + FILE="${APP_PROJECT_ROOT_DIR}/${!VAR}" + TEMPLATE="${TEMPLATES_DIR}/${!VAR}" + if cmp -s "${TEMPLATE}" "${FILE}"; then + rm "${FILE}" + cp -rp "${TEMPLATE}" "${FILE}" + fi +done + +# Configure macOS for Duo. +sed -i '' "s/${APP_ID_PLACEHOLDER_CAMEL}/${NEW_APP_ID_CAMEL}/g" "${APP_PROJECT_ROOT_DIR}/${MAC_TF_0}" +sed -i '' "s/${APP_NAME_PLACEHOLDER}/${NEW_NAME}/g" "${APP_PROJECT_ROOT_DIR}/${MAC_TF_0}" +sed -i '' "s/${APP_NAME_PLACEHOLDER}/${NEW_NAME}/g" "${APP_PROJECT_ROOT_DIR}/${MAC_TF_1}" +sed -i '' "s/${APP_NAME_PLACEHOLDER}/${NEW_NAME}/g" "${APP_PROJECT_ROOT_DIR}/${MAC_TF_2}" +sed -i '' "s/${APP_ID_PLACEHOLDER_SNAKE}/${NEW_APP_ID_SNAKE}/g" "${APP_PROJECT_ROOT_DIR}/${MAC_TF_2}" diff --git a/scripts/app_config/platforms/windows/flutter_launcher_icons.yaml b/scripts/app_config/platforms/windows/flutter_launcher_icons.yaml new file mode 100644 index 000000000..62b1f8c18 --- /dev/null +++ b/scripts/app_config/platforms/windows/flutter_launcher_icons.yaml @@ -0,0 +1,17 @@ +# flutter pub run flutter_launcher_icons +flutter_launcher_icons: + + android: false + + ios: false + + web: + generate: false + + windows: + generate: true + image_path: "assets/icon/icon.png" + icon_size: 48 # min:48, max:256, default: 48 + + macos: + generate: false diff --git a/scripts/app_config/platforms/windows/platform_config.sh b/scripts/app_config/platforms/windows/platform_config.sh new file mode 100755 index 000000000..4a0158c80 --- /dev/null +++ b/scripts/app_config/platforms/windows/platform_config.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +set -x -e + +for (( i=0; i<=2; i++ )); do + VAR="WIN_TF_${i}" + FILE="${APP_PROJECT_ROOT_DIR}/${!VAR}" + TEMPLATE="${TEMPLATES_DIR}/${!VAR}" + if cmp -s "${TEMPLATE}" "${FILE}"; then + rm "${FILE}" + cp -rp "${TEMPLATE}" "${FILE}" + fi +done + +# Configure Windows for Duo. +sed -i "s/${APP_NAME_PLACEHOLDER}/${NEW_NAME}/g" "${APP_PROJECT_ROOT_DIR}/${WIN_TF_0}" +sed -i "s/${APP_NAME_PLACEHOLDER}/${NEW_NAME}/g" "${APP_PROJECT_ROOT_DIR}/${WIN_TF_1}" +sed -i "s/${APP_BASIC_NAME_PLACEHOLDER}/${NEW_BASIC_NAME}/g" "${APP_PROJECT_ROOT_DIR}/${WIN_TF_2}" diff --git a/scripts/app_config/shared/asset_generators.sh b/scripts/app_config/shared/asset_generators.sh new file mode 100755 index 000000000..a0150866a --- /dev/null +++ b/scripts/app_config/shared/asset_generators.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +set -x -e + +if [ $# -ne 1 ]; then + echo "Usage: $0 " + exit 1 +fi + +APP_BUILD_PLATFORM=$1 + +# run icon and image generators +pushd "${APP_PROJECT_ROOT_DIR}" +flutter pub get +#native splash screen not used +#dart run flutter_native_splash:create +dart run flutter_launcher_icons -f "${APP_PROJECT_ROOT_DIR}/scripts/app_config/platforms/${APP_BUILD_PLATFORM}/flutter_launcher_icons.yaml" +popd \ No newline at end of file diff --git a/scripts/app_config/shared/link_assets.sh b/scripts/app_config/shared/link_assets.sh new file mode 100755 index 000000000..c443b1262 --- /dev/null +++ b/scripts/app_config/shared/link_assets.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +set -x -e + +if [ $# -ne 1 ]; then + echo "Usage: $0 " + exit 1 +fi + +SELECT_ASSETS_DIR=$1 + +# declare full paths +ASSET_SOURCES_DIR="${APP_PROJECT_ROOT_DIR}/asset_sources" +ASSETS_DIR="${APP_PROJECT_ROOT_DIR}/assets" + + +# finally update symlinks + +rm -f "${ASSETS_DIR}/default_themes" +ln -s "${ASSET_SOURCES_DIR}/bundled_themes/${SELECT_ASSETS_DIR}" "${ASSETS_DIR}/default_themes" + +rm -f "${ASSETS_DIR}/icon" +ln -s "${ASSET_SOURCES_DIR}/icon/${SELECT_ASSETS_DIR}" "${ASSETS_DIR}/icon" + +rm -f "${ASSETS_DIR}/lottie" +ln -s "${ASSET_SOURCES_DIR}/lottie/${SELECT_ASSETS_DIR}" "${ASSETS_DIR}/lottie" + +rm -f "${ASSETS_DIR}/in_app_logo_icons" +ln -s "${ASSET_SOURCES_DIR}/in_app_logo_icons/${SELECT_ASSETS_DIR}" "${ASSETS_DIR}/in_app_logo_icons" diff --git a/scripts/app_config/shared/update_version.sh b/scripts/app_config/shared/update_version.sh new file mode 100755 index 000000000..d056b9b73 --- /dev/null +++ b/scripts/app_config/shared/update_version.sh @@ -0,0 +1,46 @@ +#!/bin/bash + +set -x -e + +# Function to display usage. +usage() { + echo "Usage: $0 [-v ] [-b ]" + exit 1 +} + +unset -v VERSION +unset -v BUILD_NUMBER + +# Check if no arguments are provided. +if [ $# -ne 4 ]; then # if [ -z "$VERSION" ] || [ -z "$BUILD_NUMBER" ]; then + usage +fi + +# Parse command-line arguments. +while getopts "v:b:" opt; do + case "$opt" in + v) VERSION="$OPTARG" ;; + b) BUILD_NUMBER="$OPTARG" ;; + *) usage ;; + esac +done + +# Define the pubspec.yaml file path. +PUBSPEC_FILE="${APP_PROJECT_ROOT_DIR}/pubspec.yaml" + +# Ensure the pubspec.yaml file exists. +if [ ! -f "$PUBSPEC_FILE" ]; then + echo "Error: $PUBSPEC_FILE not found!" + exit 1 +fi + +if [[ "$(uname)" == 'Darwin' ]]; then + # macos specific sed + sed -i '' "s/PLACEHOLDER_V/$VERSION/g" "${PUBSPEC_FILE}" + sed -i '' "s/PLACEHOLDER_B/$BUILD_NUMBER/g" "${PUBSPEC_FILE}" +else + sed -i "s/PLACEHOLDER_V/$VERSION/g" "${PUBSPEC_FILE}" + sed -i "s/PLACEHOLDER_B/$BUILD_NUMBER/g" "${PUBSPEC_FILE}" +fi + +echo "Updated $PUBSPEC_FILE with version: $VERSION and build number: $BUILD_NUMBER" diff --git a/android/app/build.gradle b/scripts/app_config/templates/android/app/build.gradle similarity index 94% rename from android/app/build.gradle rename to scripts/app_config/templates/android/app/build.gradle index ae9570217..4d134796a 100644 --- a/android/app/build.gradle +++ b/scripts/app_config/templates/android/app/build.gradle @@ -47,8 +47,7 @@ android { } defaultConfig { - // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). - applicationId "com.cypherstack.stackwallet" + applicationId "com.place.holder" minSdkVersion 23 targetSdkVersion 33 // ndkVersion = "21.1.6352462" diff --git a/android/app/src/debug/AndroidManifest.xml b/scripts/app_config/templates/android/app/src/debug/AndroidManifest.xml similarity index 87% rename from android/app/src/debug/AndroidManifest.xml rename to scripts/app_config/templates/android/app/src/debug/AndroidManifest.xml index e461d6136..9aa98e2e8 100644 --- a/android/app/src/debug/AndroidManifest.xml +++ b/scripts/app_config/templates/android/app/src/debug/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.place.holder"> diff --git a/android/app/src/main/AndroidManifest.xml b/scripts/app_config/templates/android/app/src/main/AndroidManifest.xml similarity index 96% rename from android/app/src/main/AndroidManifest.xml rename to scripts/app_config/templates/android/app/src/main/AndroidManifest.xml index 3f1a56aa8..bfcdf171f 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/scripts/app_config/templates/android/app/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.place.holder"> diff --git a/android/app/src/profile/AndroidManifest.xml b/scripts/app_config/templates/android/app/src/profile/AndroidManifest.xml similarity index 87% rename from android/app/src/profile/AndroidManifest.xml rename to scripts/app_config/templates/android/app/src/profile/AndroidManifest.xml index e461d6136..9aa98e2e8 100644 --- a/android/app/src/profile/AndroidManifest.xml +++ b/scripts/app_config/templates/android/app/src/profile/AndroidManifest.xml @@ -1,5 +1,5 @@ + package="com.place.holder"> diff --git a/scripts/app_config/templates/configure_template_files.sh b/scripts/app_config/templates/configure_template_files.sh new file mode 100755 index 000000000..9acf5b6f4 --- /dev/null +++ b/scripts/app_config/templates/configure_template_files.sh @@ -0,0 +1,66 @@ +#!/usr/bin/env bash + +set -x -e + +export TEMPLATES_DIR="${APP_PROJECT_ROOT_DIR}/scripts/app_config/templates" + +export T_PUBSPEC="${TEMPLATES_DIR}/pubspec.template" +export ACTUAL_PUBSPEC="${APP_PROJECT_ROOT_DIR}/pubspec.yaml" + +export ANDROID_TF_0="android/app/build.gradle" +export ANDROID_TF_1="android/app/src/debug/AndroidManifest.xml" +export ANDROID_TF_2="android/app/src/profile/AndroidManifest.xml" +export ANDROID_TF_3="android/app/src/main/AndroidManifest.xml" +export ANDROID_TF_4="android/app/src/main/profile/AndroidManifest.xml" +export ANDROID_TF_5="android/app/src/main/kotlin/com/cypherstack/stackwallet/MainActivity.kt" +export IOS_TF_0="ios/Runner/Info.plist" +export IOS_TF_1="ios/Runner.xcodeproj/project.pbxproj" +export LINUX_TF_0="linux/CMakeLists.txt" +export LINUX_TF_1="linux/my_application.cc" +export MAC_TF_0="macos/Runner.xcodeproj/project.pbxproj" +export MAC_TF_1="macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme" +export MAC_TF_2="macos/Runner/Configs/AppInfo.xcconfig" +export WIN_TF_0="windows/runner/Runner.rc" +export WIN_TF_1="windows/runner/main.cpp" +export WIN_TF_2="windows/CMakeLists.txt" + +mkdir -p "${APP_PROJECT_ROOT_DIR}/android/app/src/debug" +mkdir -p "${APP_PROJECT_ROOT_DIR}/android/app/src/profile" +mkdir -p "${APP_PROJECT_ROOT_DIR}/android/app/src/main/profile" +mkdir -p "${APP_PROJECT_ROOT_DIR}/android/app/src/main/kotlin/com/cypherstack/stackwallet" +mkdir -p "${APP_PROJECT_ROOT_DIR}/ios/Runner" +mkdir -p "${APP_PROJECT_ROOT_DIR}/ios/Runner.xcodeproj" +mkdir -p "${APP_PROJECT_ROOT_DIR}/macos/Runner.xcodeproj" +mkdir -p "${APP_PROJECT_ROOT_DIR}/macos/Runner.xcodeproj/xcshareddata/xcschemes" +mkdir -p "${APP_PROJECT_ROOT_DIR}/macos/Runner/Configs" +mkdir -p "${APP_PROJECT_ROOT_DIR}/windows/runner" + +TEMPLATE_FILES=( + "${ANDROID_TF_0}" + "${ANDROID_TF_1}" + "${ANDROID_TF_2}" + "${ANDROID_TF_3}" + "${ANDROID_TF_4}" + "${ANDROID_TF_5}" + "${IOS_TF_0}" + "${IOS_TF_1}" + "${LINUX_TF_0}" + "${LINUX_TF_1}" + "${MAC_TF_0}" + "${MAC_TF_1}" + "${MAC_TF_2}" + "${WIN_TF_0}" + "${WIN_TF_1}" + "${WIN_TF_2}" +) + +if [ ! -f "${ACTUAL_PUBSPEC}" ]; then + cp "${T_PUBSPEC}" "${ACTUAL_PUBSPEC}" +fi + +for TF in "${TEMPLATE_FILES[@]}"; do + FILE="${APP_PROJECT_ROOT_DIR}/${TF}" + if [ ! -f "${FILE}" ]; then + cp -rp "${TEMPLATES_DIR}/${TF}" "${FILE}" + fi +done \ No newline at end of file diff --git a/ios/Runner.xcodeproj/project.pbxproj b/scripts/app_config/templates/ios/Runner.xcodeproj/project.pbxproj similarity index 99% rename from ios/Runner.xcodeproj/project.pbxproj rename to scripts/app_config/templates/ios/Runner.xcodeproj/project.pbxproj index 7a1d5f01e..c793dd2fe 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/scripts/app_config/templates/ios/Runner.xcodeproj/project.pbxproj @@ -525,7 +525,7 @@ ); MARKETING_VERSION = "$(FLUTTER_BUILD_NAME)"; ONLY_ACTIVE_ARCH = NO; - PRODUCT_BUNDLE_IDENTIFIER = com.cypherstack.stackwallet; + PRODUCT_BUNDLE_IDENTIFIER = com.place.holder; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; STRIP_INSTALLED_PRODUCT = NO; @@ -716,7 +716,7 @@ ); MARKETING_VERSION = "$(FLUTTER_BUILD_NAME)"; ONLY_ACTIVE_ARCH = NO; - PRODUCT_BUNDLE_IDENTIFIER = com.cypherstack.stackwallet; + PRODUCT_BUNDLE_IDENTIFIER = com.place.holder; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; STRIP_INSTALLED_PRODUCT = NO; @@ -799,7 +799,7 @@ ); MARKETING_VERSION = "$(FLUTTER_BUILD_NAME)"; ONLY_ACTIVE_ARCH = NO; - PRODUCT_BUNDLE_IDENTIFIER = com.cypherstack.stackwallet; + PRODUCT_BUNDLE_IDENTIFIER = com.place.holder; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; STRIP_INSTALLED_PRODUCT = NO; diff --git a/ios/Runner/Info.plist b/scripts/app_config/templates/ios/Runner/Info.plist similarity index 98% rename from ios/Runner/Info.plist rename to scripts/app_config/templates/ios/Runner/Info.plist index 6b8be59a8..ea8af9f9f 100644 --- a/ios/Runner/Info.plist +++ b/scripts/app_config/templates/ios/Runner/Info.plist @@ -15,7 +15,7 @@ CFBundleInfoDictionaryVersion 6.0 CFBundleName - Stack Wallet + PlaceHolderName CFBundlePackageType APPL CFBundleShortVersionString diff --git a/linux/CMakeLists.txt b/scripts/app_config/templates/linux/CMakeLists.txt similarity index 98% rename from linux/CMakeLists.txt rename to scripts/app_config/templates/linux/CMakeLists.txt index 53391e7ad..bd1d1690b 100644 --- a/linux/CMakeLists.txt +++ b/scripts/app_config/templates/linux/CMakeLists.txt @@ -4,10 +4,10 @@ project(runner LANGUAGES CXX) # The name of the executable created for the application. Change this to change # the on-disk name of your application. -set(BINARY_NAME "stack_wallet") +set(BINARY_NAME "place_holder") # The unique GTK application identifier for this application. See: # https://wiki.gnome.org/HowDoI/ChooseApplicationID -set(APPLICATION_ID "com.cypherstack.stackwallet") +set(APPLICATION_ID "com.place.holder") # Explicitly opt in to modern CMake behaviors to avoid warnings with recent # versions of CMake. diff --git a/linux/my_application.cc b/scripts/app_config/templates/linux/my_application.cc similarity index 96% rename from linux/my_application.cc rename to scripts/app_config/templates/linux/my_application.cc index d342c1506..a6eec3956 100644 --- a/linux/my_application.cc +++ b/scripts/app_config/templates/linux/my_application.cc @@ -40,11 +40,11 @@ static void my_application_activate(GApplication* application) { if (use_header_bar) { GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); gtk_widget_show(GTK_WIDGET(header_bar)); - gtk_header_bar_set_title(header_bar, "Stack Wallet"); + gtk_header_bar_set_title(header_bar, "PlaceHolderName"); gtk_header_bar_set_show_close_button(header_bar, TRUE); gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); } else { - gtk_window_set_title(window, "Stack Wallet"); + gtk_window_set_title(window, "PlaceHolderName"); } gtk_window_set_default_size(window, 1220, 500); diff --git a/macos/Runner.xcodeproj/project.pbxproj b/scripts/app_config/templates/macos/Runner.xcodeproj/project.pbxproj similarity index 97% rename from macos/Runner.xcodeproj/project.pbxproj rename to scripts/app_config/templates/macos/Runner.xcodeproj/project.pbxproj index eccafe6ba..3e8ffdabb 100644 --- a/macos/Runner.xcodeproj/project.pbxproj +++ b/scripts/app_config/templates/macos/Runner.xcodeproj/project.pbxproj @@ -77,7 +77,7 @@ 331C80D7294CF71000263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = ""; }; 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; - 33CC10ED2044A3C60003C045 /* Stack Wallet.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Stack Wallet.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 33CC10ED2044A3C60003C045 /* PlaceHolderName.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "PlaceHolderName.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 33CC10F02044A3C60003C045 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 33CC10F22044A3C60003C045 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = Runner/Assets.xcassets; sourceTree = ""; }; 33CC10F52044A3C60003C045 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/MainMenu.xib; sourceTree = ""; }; @@ -160,7 +160,7 @@ 33CC10EE2044A3C60003C045 /* Products */ = { isa = PBXGroup; children = ( - 33CC10ED2044A3C60003C045 /* Stack Wallet.app */, + 33CC10ED2044A3C60003C045 /* PlaceHolderName.app */, 331C80D5294CF71000263BE5 /* RunnerTests.xctest */, ); name = Products; @@ -267,7 +267,7 @@ ); name = Runner; productName = Runner; - productReference = 33CC10ED2044A3C60003C045 /* Stack Wallet.app */; + productReference = 33CC10ED2044A3C60003C045 /* PlaceHolderName.app */; productType = "com.apple.product-type.application"; }; /* End PBXNativeTarget section */ @@ -497,10 +497,10 @@ CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.cypherstack.stackWallet.RunnerTests; + PRODUCT_BUNDLE_IDENTIFIER = com.place.holderCamel.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Stack Wallet.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/stack_wallet"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PlaceHolderName.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/stack_wallet"; }; name = Debug; }; @@ -512,10 +512,10 @@ CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.cypherstack.stackWallet.RunnerTests; + PRODUCT_BUNDLE_IDENTIFIER = com.place.holderCamel.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Stack Wallet.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/stack_wallet"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PlaceHolderName.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/stack_wallet"; }; name = Release; }; @@ -527,10 +527,10 @@ CURRENT_PROJECT_VERSION = 1; GENERATE_INFOPLIST_FILE = YES; MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = com.cypherstack.stackWallet.RunnerTests; + PRODUCT_BUNDLE_IDENTIFIER = com.place.holderCamel.RunnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 5.0; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/Stack Wallet.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/stack_wallet"; + TEST_HOST = "$(BUILT_PRODUCTS_DIR)/PlaceHolderName.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/stack_wallet"; }; name = Profile; }; diff --git a/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/scripts/app_config/templates/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme similarity index 94% rename from macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme rename to scripts/app_config/templates/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 73f65e0e3..4baf48207 100644 --- a/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/scripts/app_config/templates/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -15,7 +15,7 @@ @@ -31,7 +31,7 @@ @@ -65,7 +65,7 @@ @@ -82,7 +82,7 @@ diff --git a/macos/Runner/Configs/AppInfo.xcconfig b/scripts/app_config/templates/macos/Runner/Configs/AppInfo.xcconfig similarity index 86% rename from macos/Runner/Configs/AppInfo.xcconfig rename to scripts/app_config/templates/macos/Runner/Configs/AppInfo.xcconfig index 391513c54..1a3350d22 100644 --- a/macos/Runner/Configs/AppInfo.xcconfig +++ b/scripts/app_config/templates/macos/Runner/Configs/AppInfo.xcconfig @@ -5,10 +5,10 @@ // 'flutter create' template. // The application's name. By default this is also the title of the Flutter window. -PRODUCT_NAME = Stack Wallet +PRODUCT_NAME = PlaceHolderName // The application's bundle identifier -PRODUCT_BUNDLE_IDENTIFIER = com.cypherstack.stack_wallet +PRODUCT_BUNDLE_IDENTIFIER = com.place.holder_snake // The copyright displayed in application information PRODUCT_COPYRIGHT = Copyright © 2023 com.cypherstack. All rights reserved. diff --git a/pubspec.yaml b/scripts/app_config/templates/pubspec.template similarity index 94% rename from pubspec.yaml rename to scripts/app_config/templates/pubspec.template index a3fdcdf9d..d7e07cc1a 100644 --- a/pubspec.yaml +++ b/scripts/app_config/templates/pubspec.template @@ -1,5 +1,5 @@ -name: stackwallet -description: Stack Wallet +name: PLACEHOLDER +description: PLACEHOLDER # The following defines the version and build number for your application. # A version number is three numbers separated by dots, like 1.2.43 @@ -11,7 +11,7 @@ description: Stack Wallet # 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.0.0+222 +version: PLACEHOLDER_V+PLACEHOLDER_B environment: sdk: ">=3.3.4 <4.0.0" @@ -197,23 +197,8 @@ dev_dependencies: flutter_lints: ^3.0.1 isar_generator: 3.0.5 -flutter_launcher_icons: - android: true - ios: true - image_path: assets/icon/icon.png - image_path_android: assets/icon/app_icon_alpha.png - image_path_ios: assets/icon/icon.png - remove_alpha_ios: true - windows: - generate: true - image_path: assets/icon/icon.png - icon_size: 48 # min:48, max:256, default: 48 - macos: - generate: true - image_path: assets/icon/macos-icon.png - flutter_native_splash: - image: assets/images/splash.png + image: assets/icon/splash.png color: "F7F7F7" android_disable_fullscreen: true @@ -269,6 +254,7 @@ flutter: # - images/a_dot_burr.jpeg # - images/a_dot_ham.jpeg assets: + - assets/in_app_logo_icons/ - assets/images/ - assets/icon/ - google_fonts/ @@ -291,7 +277,7 @@ flutter: # lottie animations # basic - - assets/lottie/test2.json + - assets/lottie/loader.json - assets/lottie/icon_send.json - assets/lottie/loader_and_checkmark.json - assets/lottie/arrow_rotate.json diff --git a/windows/CMakeLists.txt b/scripts/app_config/templates/windows/CMakeLists.txt similarity index 98% rename from windows/CMakeLists.txt rename to scripts/app_config/templates/windows/CMakeLists.txt index eddd46e4d..b9add856d 100644 --- a/windows/CMakeLists.txt +++ b/scripts/app_config/templates/windows/CMakeLists.txt @@ -1,10 +1,10 @@ # Project-level configuration. cmake_minimum_required(VERSION 3.14) -project(stack_wallet LANGUAGES CXX) +project(place_holder LANGUAGES CXX) # The name of the executable created for the application. Change this to change # the on-disk name of your application. -set(BINARY_NAME "stack_wallet") +set(BINARY_NAME "place_holder") # Explicitly opt in to modern CMake behaviors to avoid warnings with recent # versions of CMake. diff --git a/windows/runner/Runner.rc b/scripts/app_config/templates/windows/runner/Runner.rc similarity index 92% rename from windows/runner/Runner.rc rename to scripts/app_config/templates/windows/runner/Runner.rc index d23cd8ce6..ac822d092 100644 --- a/windows/runner/Runner.rc +++ b/scripts/app_config/templates/windows/runner/Runner.rc @@ -90,12 +90,12 @@ BEGIN BLOCK "040904e4" BEGIN VALUE "CompanyName", "com.cypherstack" "\0" - VALUE "FileDescription", "Stack Wallet" "\0" + VALUE "FileDescription", "PlaceHolderName" "\0" VALUE "FileVersion", VERSION_AS_STRING "\0" - VALUE "InternalName", "Stack Wallet" "\0" + VALUE "InternalName", "PlaceHolderName" "\0" VALUE "LegalCopyright", "Copyright (C) 2022 com.cypherstack. All rights reserved." "\0" - VALUE "OriginalFilename", "Stack Wallet.exe" "\0" - VALUE "ProductName", "Stack Wallet" "\0" + VALUE "OriginalFilename", "PlaceHolderName.exe" "\0" + VALUE "ProductName", "PlaceHolderName" "\0" VALUE "ProductVersion", VERSION_AS_STRING "\0" END END diff --git a/windows/runner/main.cpp b/scripts/app_config/templates/windows/runner/main.cpp similarity index 94% rename from windows/runner/main.cpp rename to scripts/app_config/templates/windows/runner/main.cpp index 7369685a2..a960708f3 100644 --- a/windows/runner/main.cpp +++ b/scripts/app_config/templates/windows/runner/main.cpp @@ -27,7 +27,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, FlutterWindow window(project); Win32Window::Point origin(10, 10); Win32Window::Size size(1280, 720); - if (!window.CreateAndShow(L"Stack Wallet", origin, size)) { + if (!window.CreateAndShow(L"PlaceHolderName", origin, size)) { return EXIT_FAILURE; } window.SetQuitOnClose(true); diff --git a/scripts/build_app.sh b/scripts/build_app.sh new file mode 100755 index 000000000..7f89a202f --- /dev/null +++ b/scripts/build_app.sh @@ -0,0 +1,120 @@ +#!/usr/bin/env bash + +set -e + +source ./env.sh + +APP_PLATFORMS=("android" "ios" "macos" "linux" "windows") +APP_NAMED_IDS=("stack_wallet" "stack_duo") + +# Function to display usage. +usage() { + echo "Usage: $0 -v -b -p -a " + exit 1 +} + +confirmDisclaimer() { + while true; do + # shellcheck disable=SC2162 + read -p "Please confirm you understand that when using certain values for and there is a chance that the resulting app WILL DELETE CRITICAL WALLET DATA. Are you sure you want to continue? (yes/no): " response + case $response in + [Yy][Ee][Ss] ) echo "Continuing..."; break;; + [Nn][Oo] ) exit 0;; + * ) echo "Invalid response";; + esac + done +} + +# required args +unset -v APP_VERSION_STRING +unset -v APP_BUILD_NUMBER +unset -v APP_BUILD_PLATFORM +unset -v APP_NAMED_ID + +# optional args (with defaults) +BUILD_CRYPTO_PLUGINS=0 + +# Parse command-line arguments. +while getopts "v:b:p:a:i" opt; do + case "${opt}" in + v) APP_VERSION_STRING="$OPTARG" ;; + b) APP_BUILD_NUMBER="$OPTARG" ;; + p) APP_BUILD_PLATFORM="$OPTARG" ;; + a) APP_NAMED_ID="$OPTARG" ;; + i) BUILD_CRYPTO_PLUGINS=1 ;; + *) usage ;; + esac +done + +if [ -z "$APP_VERSION_STRING" ]; then + echo "Missing -v option" + usage +fi + +if [ -z "$APP_BUILD_NUMBER" ]; then + echo "Missing -b option" + usage +fi + +if [ -z "$APP_BUILD_PLATFORM" ]; then + echo "Missing -p option" + usage +fi + +if [ -z "$APP_NAMED_ID" ]; then + echo "Missing -a option" + usage +fi + +confirmDisclaimer +set -x + +source "${APP_PROJECT_ROOT_DIR}/scripts/app_config/templates/configure_template_files.sh" + +# checks for the correct platform dir and pushes it for later +if printf '%s\0' "${APP_PLATFORMS[@]}" | grep -Fxqz -- "${APP_BUILD_PLATFORM}"; then + pushd "${APP_PROJECT_ROOT_DIR}/scripts/${APP_BUILD_PLATFORM}" +else + echo "Invalid platform: ${APP_BUILD_PLATFORM}" + usage +fi + +PLAY_STORE_ICON_FILE="${APP_PROJECT_ROOT_DIR}/android/app/src/main/app_icon-playstore.png" +if [ -f "${PLAY_STORE_ICON_FILE}" ]; then + rm "${PLAY_STORE_ICON_FILE}" +fi +cp -rp "${APP_PROJECT_ROOT_DIR}/asset_sources/other/playstore_icon/${APP_NAMED_ID}/app_icon-playstore.png" "${PLAY_STORE_ICON_FILE}" + +# apply config project wide change changes +if printf '%s\0' "${APP_NAMED_IDS[@]}" | grep -Fxqz -- "${APP_NAMED_ID}"; then + if cmp -s "${ACTUAL_PUBSPEC}" "${T_PUBSPEC}"; then + rm "${ACTUAL_PUBSPEC}" + cp "${T_PUBSPEC}" "${ACTUAL_PUBSPEC}" + fi + "${APP_PROJECT_ROOT_DIR}/scripts/app_config/shared/update_version.sh" -v "${APP_VERSION_STRING}" -b "${APP_BUILD_NUMBER}" + "${APP_PROJECT_ROOT_DIR}/scripts/app_config/shared/link_assets.sh" "${APP_NAMED_ID}" + # shellcheck disable=SC1090 + source "${APP_PROJECT_ROOT_DIR}/scripts/app_config/configure_${APP_NAMED_ID}.sh" + "${APP_PROJECT_ROOT_DIR}/scripts/app_config/platforms/${APP_BUILD_PLATFORM}/platform_config.sh" + + if [[ "$APP_BUILD_PLATFORM" != "linux" ]]; then + # run icon and image generators after project config has completed for non linux + "${APP_PROJECT_ROOT_DIR}/scripts/app_config/shared/asset_generators.sh" "${APP_BUILD_PLATFORM}" + fi +else + echo "Invalid app id: ${APP_NAMED_ID}" + exit 1 +fi + +if [ "$BUILD_CRYPTO_PLUGINS" -eq 0 ]; then + if [[ "$APP_NAMED_ID" = "stack_wallet" ]]; then + ./build_all.sh + elif [[ "$APP_NAMED_ID" = "stack_duo" ]]; then + ./build_all_duo.sh + else + echo "Invalid app id: ${APP_NAMED_ID}" + exit 1 + fi +fi + +popd diff --git a/scripts/build_runner.sh b/scripts/build_runner.sh deleted file mode 100755 index a8951f144..000000000 --- a/scripts/build_runner.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -dart run build_runner build --delete-conflicting-outputs diff --git a/scripts/env.sh b/scripts/env.sh new file mode 100755 index 000000000..d938356c4 --- /dev/null +++ b/scripts/env.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash + +set -e + +# set project root +THIS_SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +pushd "${THIS_SCRIPT_DIR}/../" +export APP_PROJECT_ROOT_DIR="$(pwd)" +popd + +export APP_NAME_PLACEHOLDER="PlaceHolderName" +export APP_ID_PLACEHOLDER="com.place.holder" +export APP_ID_PLACEHOLDER_CAMEL="com.place.holderCamel" +export APP_ID_PLACEHOLDER_SNAKE="com.place.holder_snake" +export APP_BASIC_NAME_PLACEHOLDER="place_holder" diff --git a/scripts/ios/build_all.sh b/scripts/ios/build_all.sh index 8b03d1b6f..595d6aba1 100755 --- a/scripts/ios/build_all.sh +++ b/scripts/ios/build_all.sh @@ -1,6 +1,6 @@ #!/bin/bash -set -e +set -x -e # libepiccash requires old rust source ../rust_version.sh diff --git a/scripts/ios/build_all_duo.sh b/scripts/ios/build_all_duo.sh new file mode 100755 index 000000000..c16884680 --- /dev/null +++ b/scripts/ios/build_all_duo.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +set -x -e + +# todo: revisit following at some point + +# libepiccash requires old rust +source ../rust_version.sh +set_rust_to_1671 + +# ensure ios rust triples are there +rustup target add aarch64-apple-ios +rustup target add x86_64-apple-ios + +# ensure ios rust triples are there +rustup target add aarch64-apple-ios +rustup target add x86_64-apple-ios + +(cd ../../crypto_plugins/flutter_liblelantus/scripts/ios && ./build_all.sh ) & +(cd ../../crypto_plugins/flutter_libepiccash/scripts/ios && ./build_all.sh ) & +(cd ../../crypto_plugins/flutter_libmonero/scripts/ios/ && ./build_all.sh ) && +set_rust_to_1720 && +(cd ../../crypto_plugins/frostdart/scripts/ios && ./build_all.sh ) & + +wait +echo "Done building" + +# ensure ios rust triples are there +rustup target add aarch64-apple-ios +rustup target add x86_64-apple-ios diff --git a/scripts/linux/build_all.sh b/scripts/linux/build_all.sh index d7c29e1b1..775d6fa9d 100755 --- a/scripts/linux/build_all.sh +++ b/scripts/linux/build_all.sh @@ -1,6 +1,6 @@ #!/bin/bash -set -e +set -x -e # libepiccash requires old rust source ../rust_version.sh diff --git a/scripts/linux/build_all_duo.sh b/scripts/linux/build_all_duo.sh new file mode 100755 index 000000000..77ccdf592 --- /dev/null +++ b/scripts/linux/build_all_duo.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +set -x -e + +# todo: revisit following at some point + +# libepiccash requires old rust +source ../rust_version.sh +set_rust_to_1671 + +# for arm +# flutter-elinux clean +# flutter-elinux pub get +# flutter-elinux build linux --dart-define="IS_ARM=true" +mkdir -p build +./build_secure_storage_deps.sh & +(cd ../../crypto_plugins/flutter_liblelantus/scripts/linux && ./build_all.sh ) & +(cd ../../crypto_plugins/flutter_libepiccash/scripts/linux && ./build_all.sh ) & +(cd ../../crypto_plugins/flutter_libmonero/scripts/linux && ./build_monero_all.sh && ./build_sharedfile.sh ) +set_rust_to_1720 +(cd ../../crypto_plugins/frostdart/scripts/linux && ./build_all.sh ) & + +./build_secp256k1.sh + +wait +echo "Done building" diff --git a/scripts/macos/build_all.sh b/scripts/macos/build_all.sh index 59d1425c9..8841de2ed 100755 --- a/scripts/macos/build_all.sh +++ b/scripts/macos/build_all.sh @@ -1,6 +1,6 @@ #!/bin/bash -set -e +set -x -e # libepiccash requires old rust source ../rust_version.sh diff --git a/scripts/macos/build_all_duo.sh b/scripts/macos/build_all_duo.sh new file mode 100755 index 000000000..f5cfbeeb1 --- /dev/null +++ b/scripts/macos/build_all_duo.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +set -x -e + +# todo: revisit following at some point + +# libepiccash requires old rust +source ../rust_version.sh +set_rust_to_1671 + +(cd ../../crypto_plugins/flutter_liblelantus/scripts/macos && ./build_all.sh ) & +(cd ../../crypto_plugins/flutter_libepiccash/scripts/macos && ./build_all.sh ) & +(cd ../../crypto_plugins/flutter_libmonero/scripts/macos/ && ./build_all.sh ) && +set_rust_to_1720 && +(cd ../../crypto_plugins/frostdart/scripts/macos && ./build_all.sh ) & + +wait +echo "Done building" + +# set rust (back) to a more recent stable release to allow stack wallet to build tor +set_rust_to_1720 diff --git a/scripts/windows/build_all.sh b/scripts/windows/build_all.sh index c055cb6c3..bf418a0ae 100755 --- a/scripts/windows/build_all.sh +++ b/scripts/windows/build_all.sh @@ -1,6 +1,6 @@ #!/bin/bash -set -e +set -x -e # libepiccash requires old rust source ../rust_version.sh diff --git a/scripts/windows/build_all_duo.sh b/scripts/windows/build_all_duo.sh new file mode 100755 index 000000000..6262793dd --- /dev/null +++ b/scripts/windows/build_all_duo.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +set -x -e + +# todo: revisit following at some point + +# libepiccash requires old rust +source ../rust_version.sh +set_rust_to_1671 + +mkdir -p build +(cd ../../crypto_plugins/flutter_libepiccash/scripts/windows && ./build_all.sh ) & +(cd ../../crypto_plugins/flutter_liblelantus/scripts/windows && ./build_all.sh ) & +(cd ../../crypto_plugins/flutter_libmonero/scripts/windows && ./build_all.sh) +set_rust_to_1720 +(cd ../../crypto_plugins/frostdart/scripts/windows && ./build_all.sh ) & + +./build_secp256k1_wsl.sh + +wait +echo "Done building" diff --git a/test/address_utils_test.dart b/test/address_utils_test.dart index f1dcf1260..42ab1a45b 100644 --- a/test/address_utils_test.dart +++ b/test/address_utils_test.dart @@ -1,6 +1,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:stackwallet/utilities/address_utils.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import 'package:stackwallet/wallets/crypto_currency/coins/firo.dart'; +import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; void main() { const String firoAddress = "a6ESWKz7szru5syLtYAPRhHLdKvMq3Yt1j"; @@ -39,7 +40,7 @@ void main() { "scheme": "bitcoin", "address": firoAddress, "amount": "50.1", - "message": "eggs are good!" + "message": "eggs are good!", }); }); @@ -67,11 +68,13 @@ void main() { "something", "who", "green", - "seven" + "seven", ]; final result = AddressUtils.encodeQRSeedData(list); - expect(result, - '{"mnemonic":["hello","word","something","who","green","seven"]}'); + expect( + result, + '{"mnemonic":["hello","word","something","who","green","seven"]}', + ); }); test("decode a valid json string to Map", () { @@ -79,7 +82,7 @@ void main() { '{"mnemonic":["hello","word","something","who","green","seven"]}'; final result = AddressUtils.decodeQRSeedData(jsonString); expect(result, { - "mnemonic": ["hello", "word", "something", "who", "green", "seven"] + "mnemonic": ["hello", "word", "something", "who", "green", "seven"], }); }); @@ -91,21 +94,32 @@ void main() { }); test("build a uri string with empty params", () { - expect(AddressUtils.buildUriString(Coin.firo, firoAddress, {}), - "firo:$firoAddress"); + expect( + AddressUtils.buildUriString( + Firo(CryptoCurrencyNetwork.main), firoAddress, {}), + "firo:$firoAddress", + ); }); test("build a uri string with one param", () { expect( - AddressUtils.buildUriString( - Coin.firo, firoAddress, {"amount": "10.0123"}), - "firo:$firoAddress?amount=10.0123"); + AddressUtils.buildUriString( + Firo(CryptoCurrencyNetwork.main), + firoAddress, + {"amount": "10.0123"}, + ), + "firo:$firoAddress?amount=10.0123", + ); }); test("build a uri string with some params", () { expect( - AddressUtils.buildUriString(Coin.firo, firoAddress, - {"amount": "10.0123", "message": "Some kind of message!"}), - "firo:$firoAddress?amount=10.0123&message=Some+kind+of+message%21"); + AddressUtils.buildUriString( + Firo(CryptoCurrencyNetwork.main), + firoAddress, + {"amount": "10.0123", "message": "Some kind of message!"}, + ), + "firo:$firoAddress?amount=10.0123&message=Some+kind+of+message%21", + ); }); } diff --git a/test/cached_electrumx_test.dart b/test/cached_electrumx_test.dart index 46466163b..5f0ae68f1 100644 --- a/test/cached_electrumx_test.dart +++ b/test/cached_electrumx_test.dart @@ -4,8 +4,9 @@ import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx_client.dart'; import 'package:stackwallet/electrumx_rpc/electrumx_client.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/prefs.dart'; +import 'package:stackwallet/wallets/crypto_currency/coins/firo.dart'; +import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; import 'cached_electrumx_test.mocks.dart'; // import 'sample_data/get_anonymity_set_sample_data.dart'; @@ -130,7 +131,9 @@ void main() { expect( () async => await cachedClient.getTransaction( txHash: "some hash", - coin: Coin.firo, + cryptoCurrency: Firo( + CryptoCurrencyNetwork.main, + ), ), throwsA(isA())); }); @@ -142,7 +145,11 @@ void main() { bool didThrow = false; try { - await cachedClient.clearSharedTransactionCache(coin: Coin.firo); + await cachedClient.clearSharedTransactionCache( + cryptoCurrency: Firo( + CryptoCurrencyNetwork.main, + ), + ); } catch (_) { didThrow = true; } diff --git a/test/cached_electrumx_test.mocks.dart b/test/cached_electrumx_test.mocks.dart index cb1317096..b00b89db4 100644 --- a/test/cached_electrumx_test.mocks.dart +++ b/test/cached_electrumx_test.mocks.dart @@ -4,14 +4,13 @@ // ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:async' as _i6; -import 'dart:ui' as _i12; +import 'dart:ui' as _i11; import 'package:decimal/decimal.dart' as _i3; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/electrumx_rpc/electrumx_client.dart' as _i5; import 'package:stackwallet/utilities/amount/amount_unit.dart' as _i10; import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i9; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i11; import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i8; import 'package:stackwallet/utilities/prefs.dart' as _i7; import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart' @@ -933,7 +932,7 @@ class MockPrefs extends _i1.Mock implements _i7.Prefs { returnValueForMissingStub: _i6.Future.value(), ) as _i6.Future); @override - _i10.AmountUnit amountUnit(_i11.Coin? coin) => (super.noSuchMethod( + _i10.AmountUnit amountUnit(_i2.CryptoCurrency? coin) => (super.noSuchMethod( Invocation.method( #amountUnit, [coin], @@ -942,7 +941,7 @@ class MockPrefs extends _i1.Mock implements _i7.Prefs { ) as _i10.AmountUnit); @override void updateAmountUnit({ - required _i11.Coin? coin, + required _i2.CryptoCurrency? coin, required _i10.AmountUnit? amountUnit, }) => super.noSuchMethod( @@ -957,7 +956,7 @@ class MockPrefs extends _i1.Mock implements _i7.Prefs { returnValueForMissingStub: null, ); @override - int maxDecimals(_i11.Coin? coin) => (super.noSuchMethod( + int maxDecimals(_i2.CryptoCurrency? coin) => (super.noSuchMethod( Invocation.method( #maxDecimals, [coin], @@ -966,7 +965,7 @@ class MockPrefs extends _i1.Mock implements _i7.Prefs { ) as int); @override void updateMaxDecimals({ - required _i11.Coin? coin, + required _i2.CryptoCurrency? coin, required int? maxDecimals, }) => super.noSuchMethod( @@ -981,7 +980,8 @@ class MockPrefs extends _i1.Mock implements _i7.Prefs { returnValueForMissingStub: null, ); @override - _i4.FusionInfo getFusionServerInfo(_i11.Coin? coin) => (super.noSuchMethod( + _i4.FusionInfo getFusionServerInfo(_i2.CryptoCurrency? coin) => + (super.noSuchMethod( Invocation.method( #getFusionServerInfo, [coin], @@ -996,7 +996,7 @@ class MockPrefs extends _i1.Mock implements _i7.Prefs { ) as _i4.FusionInfo); @override void setFusionServerInfo( - _i11.Coin? coin, + _i2.CryptoCurrency? coin, _i4.FusionInfo? fusionServerInfo, ) => super.noSuchMethod( @@ -1010,7 +1010,7 @@ class MockPrefs extends _i1.Mock implements _i7.Prefs { returnValueForMissingStub: null, ); @override - void addListener(_i12.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i11.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -1018,7 +1018,7 @@ class MockPrefs extends _i1.Mock implements _i7.Prefs { returnValueForMissingStub: null, ); @override - void removeListener(_i12.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i11.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], diff --git a/test/global_events_test.dart b/test/global_events_test.dart index b5bb10a22..c7d68bdcc 100644 --- a/test/global_events_test.dart +++ b/test/global_events_test.dart @@ -4,7 +4,8 @@ import 'package:stackwallet/services/event_bus/events/global/refresh_percent_cha import 'package:stackwallet/services/event_bus/events/global/updated_in_background_event.dart'; import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart'; import 'package:stackwallet/services/event_bus/global_event_bus.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import 'package:stackwallet/wallets/crypto_currency/coins/bitcoin.dart'; +import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; void main() { test("NodeConnectionStatusChangedEvent", () async { @@ -13,12 +14,18 @@ void main() { .listen((event) { expect(event.newStatus, NodeConnectionStatus.connected); expect(event.walletId, "some wallet ID"); - expect(event.coin, Coin.bitcoin); + expect(event.coin, Bitcoin(CryptoCurrencyNetwork.main)); }); expect( - () => GlobalEventBus.instance.fire(NodeConnectionStatusChangedEvent( - NodeConnectionStatus.connected, "some wallet ID", Coin.bitcoin)), - returnsNormally); + () => GlobalEventBus.instance.fire( + NodeConnectionStatusChangedEvent( + NodeConnectionStatus.connected, + "some wallet ID", + Bitcoin(CryptoCurrencyNetwork.main), + ), + ), + returnsNormally, + ); listener.cancel(); }); @@ -30,9 +37,10 @@ void main() { expect(event.walletId, "some id"); }); expect( - () => GlobalEventBus.instance - .fire(RefreshPercentChangedEvent(0.5, "some id")), - returnsNormally); + () => GlobalEventBus.instance + .fire(RefreshPercentChangedEvent(0.5, "some id")), + returnsNormally, + ); listener.cancel(); }); @@ -43,9 +51,10 @@ void main() { expect(event.walletId, "wallet Id"); }); expect( - () => GlobalEventBus.instance - .fire(UpdatedInBackgroundEvent("some message string", "wallet Id")), - returnsNormally); + () => GlobalEventBus.instance + .fire(UpdatedInBackgroundEvent("some message string", "wallet Id")), + returnsNormally, + ); listener.cancel(); }); @@ -55,12 +64,18 @@ void main() { .listen((event) { expect(event.newStatus, WalletSyncStatus.syncing); expect(event.walletId, "wallet Id"); - expect(event.coin, Coin.bitcoin); + expect(event.coin, Bitcoin(CryptoCurrencyNetwork.main)); }); expect( - () => GlobalEventBus.instance.fire(WalletSyncStatusChangedEvent( - WalletSyncStatus.syncing, "wallet Id", Coin.bitcoin)), - returnsNormally); + () => GlobalEventBus.instance.fire( + WalletSyncStatusChangedEvent( + WalletSyncStatus.syncing, + "wallet Id", + Bitcoin(CryptoCurrencyNetwork.main), + ), + ), + returnsNormally, + ); listener.cancel(); }); } diff --git a/test/pages/send_view/send_view_test.mocks.dart b/test/pages/send_view/send_view_test.mocks.dart index fba574b15..bf71bbcf2 100644 --- a/test/pages/send_view/send_view_test.mocks.dart +++ b/test/pages/send_view/send_view_test.mocks.dart @@ -4,22 +4,21 @@ // ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:async' as _i10; -import 'dart:typed_data' as _i19; -import 'dart:ui' as _i15; +import 'dart:typed_data' as _i18; +import 'dart:ui' as _i14; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/db/isar/main_db.dart' as _i3; -import 'package:stackwallet/models/isar/stack_theme.dart' as _i18; +import 'package:stackwallet/models/isar/stack_theme.dart' as _i17; import 'package:stackwallet/models/node_model.dart' as _i13; import 'package:stackwallet/networking/http.dart' as _i7; -import 'package:stackwallet/services/locale_service.dart' as _i16; +import 'package:stackwallet/services/locale_service.dart' as _i15; import 'package:stackwallet/services/node_service.dart' as _i2; import 'package:stackwallet/services/wallets.dart' as _i9; -import 'package:stackwallet/themes/theme_service.dart' as _i17; -import 'package:stackwallet/utilities/amount/amount_unit.dart' as _i22; -import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i21; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i14; -import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i20; +import 'package:stackwallet/themes/theme_service.dart' as _i16; +import 'package:stackwallet/utilities/amount/amount_unit.dart' as _i21; +import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i20; +import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i19; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' as _i6; import 'package:stackwallet/utilities/prefs.dart' as _i12; @@ -265,7 +264,7 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService { ) as _i10.Future); @override _i10.Future setPrimaryNodeFor({ - required _i14.Coin? coin, + required _i4.CryptoCurrency? coin, required _i13.NodeModel? node, bool? shouldNotifyListeners = false, }) => @@ -283,14 +282,15 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService { returnValueForMissingStub: _i10.Future.value(), ) as _i10.Future); @override - _i13.NodeModel? getPrimaryNodeFor({required _i14.Coin? coin}) => + _i13.NodeModel? getPrimaryNodeFor({required _i4.CryptoCurrency? currency}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], - {#coin: coin}, + {#currency: currency}, )) as _i13.NodeModel?); @override - List<_i13.NodeModel> getNodesFor(_i14.Coin? coin) => (super.noSuchMethod( + List<_i13.NodeModel> getNodesFor(_i4.CryptoCurrency? coin) => + (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], @@ -305,12 +305,13 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService { {#id: id}, )) as _i13.NodeModel?); @override - List<_i13.NodeModel> failoverNodesFor({required _i14.Coin? coin}) => + List<_i13.NodeModel> failoverNodesFor( + {required _i4.CryptoCurrency? currency}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], - {#coin: coin}, + {#currency: currency}, ), returnValue: <_i13.NodeModel>[], ) as List<_i13.NodeModel>); @@ -394,7 +395,7 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService { returnValueForMissingStub: _i10.Future.value(), ) as _i10.Future); @override - void addListener(_i15.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i14.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -402,7 +403,7 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService { returnValueForMissingStub: null, ); @override - void removeListener(_i15.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i14.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -430,7 +431,7 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService { /// A class which mocks [LocaleService]. /// /// See the documentation for Mockito's code generation for more information. -class MockLocaleService extends _i1.Mock implements _i16.LocaleService { +class MockLocaleService extends _i1.Mock implements _i15.LocaleService { MockLocaleService() { _i1.throwOnMissingStub(this); } @@ -456,7 +457,7 @@ class MockLocaleService extends _i1.Mock implements _i16.LocaleService { returnValueForMissingStub: _i10.Future.value(), ) as _i10.Future); @override - void addListener(_i15.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i14.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -464,7 +465,7 @@ class MockLocaleService extends _i1.Mock implements _i16.LocaleService { returnValueForMissingStub: null, ); @override - void removeListener(_i15.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i14.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -492,7 +493,7 @@ class MockLocaleService extends _i1.Mock implements _i16.LocaleService { /// A class which mocks [ThemeService]. /// /// See the documentation for Mockito's code generation for more information. -class MockThemeService extends _i1.Mock implements _i17.ThemeService { +class MockThemeService extends _i1.Mock implements _i16.ThemeService { MockThemeService() { _i1.throwOnMissingStub(this); } @@ -522,10 +523,10 @@ class MockThemeService extends _i1.Mock implements _i17.ThemeService { ), ) as _i3.MainDB); @override - List<_i18.StackTheme> get installedThemes => (super.noSuchMethod( + List<_i17.StackTheme> get installedThemes => (super.noSuchMethod( Invocation.getter(#installedThemes), - returnValue: <_i18.StackTheme>[], - ) as List<_i18.StackTheme>); + returnValue: <_i17.StackTheme>[], + ) as List<_i17.StackTheme>); @override void init(_i3.MainDB? db) => super.noSuchMethod( Invocation.method( @@ -535,7 +536,7 @@ class MockThemeService extends _i1.Mock implements _i17.ThemeService { returnValueForMissingStub: null, ); @override - _i10.Future install({required _i19.Uint8List? themeArchiveData}) => + _i10.Future install({required _i18.Uint8List? themeArchiveData}) => (super.noSuchMethod( Invocation.method( #install, @@ -575,33 +576,33 @@ class MockThemeService extends _i1.Mock implements _i17.ThemeService { returnValue: _i10.Future.value(false), ) as _i10.Future); @override - _i10.Future> fetchThemes() => + _i10.Future> fetchThemes() => (super.noSuchMethod( Invocation.method( #fetchThemes, [], ), - returnValue: _i10.Future>.value( - <_i17.StackThemeMetaData>[]), - ) as _i10.Future>); + returnValue: _i10.Future>.value( + <_i16.StackThemeMetaData>[]), + ) as _i10.Future>); @override - _i10.Future<_i19.Uint8List> fetchTheme( - {required _i17.StackThemeMetaData? themeMetaData}) => + _i10.Future<_i18.Uint8List> fetchTheme( + {required _i16.StackThemeMetaData? themeMetaData}) => (super.noSuchMethod( Invocation.method( #fetchTheme, [], {#themeMetaData: themeMetaData}, ), - returnValue: _i10.Future<_i19.Uint8List>.value(_i19.Uint8List(0)), - ) as _i10.Future<_i19.Uint8List>); + returnValue: _i10.Future<_i18.Uint8List>.value(_i18.Uint8List(0)), + ) as _i10.Future<_i18.Uint8List>); @override - _i18.StackTheme? getTheme({required String? themeId}) => + _i17.StackTheme? getTheme({required String? themeId}) => (super.noSuchMethod(Invocation.method( #getTheme, [], {#themeId: themeId}, - )) as _i18.StackTheme?); + )) as _i17.StackTheme?); } /// A class which mocks [Prefs]. @@ -663,12 +664,12 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs { returnValueForMissingStub: null, ); @override - _i20.SyncingType get syncType => (super.noSuchMethod( + _i19.SyncingType get syncType => (super.noSuchMethod( Invocation.getter(#syncType), - returnValue: _i20.SyncingType.currentWalletOnly, - ) as _i20.SyncingType); + returnValue: _i19.SyncingType.currentWalletOnly, + ) as _i19.SyncingType); @override - set syncType(_i20.SyncingType? syncType) => super.noSuchMethod( + set syncType(_i19.SyncingType? syncType) => super.noSuchMethod( Invocation.setter( #syncType, syncType, @@ -827,12 +828,12 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs { returnValueForMissingStub: null, ); @override - _i21.BackupFrequencyType get backupFrequencyType => (super.noSuchMethod( + _i20.BackupFrequencyType get backupFrequencyType => (super.noSuchMethod( Invocation.getter(#backupFrequencyType), - returnValue: _i21.BackupFrequencyType.everyTenMinutes, - ) as _i21.BackupFrequencyType); + returnValue: _i20.BackupFrequencyType.everyTenMinutes, + ) as _i20.BackupFrequencyType); @override - set backupFrequencyType(_i21.BackupFrequencyType? backupFrequencyType) => + set backupFrequencyType(_i20.BackupFrequencyType? backupFrequencyType) => super.noSuchMethod( Invocation.setter( #backupFrequencyType, @@ -1027,17 +1028,17 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs { returnValueForMissingStub: _i10.Future.value(), ) as _i10.Future); @override - _i22.AmountUnit amountUnit(_i14.Coin? coin) => (super.noSuchMethod( + _i21.AmountUnit amountUnit(_i4.CryptoCurrency? coin) => (super.noSuchMethod( Invocation.method( #amountUnit, [coin], ), - returnValue: _i22.AmountUnit.normal, - ) as _i22.AmountUnit); + returnValue: _i21.AmountUnit.normal, + ) as _i21.AmountUnit); @override void updateAmountUnit({ - required _i14.Coin? coin, - required _i22.AmountUnit? amountUnit, + required _i4.CryptoCurrency? coin, + required _i21.AmountUnit? amountUnit, }) => super.noSuchMethod( Invocation.method( @@ -1051,7 +1052,7 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs { returnValueForMissingStub: null, ); @override - int maxDecimals(_i14.Coin? coin) => (super.noSuchMethod( + int maxDecimals(_i4.CryptoCurrency? coin) => (super.noSuchMethod( Invocation.method( #maxDecimals, [coin], @@ -1060,7 +1061,7 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs { ) as int); @override void updateMaxDecimals({ - required _i14.Coin? coin, + required _i4.CryptoCurrency? coin, required int? maxDecimals, }) => super.noSuchMethod( @@ -1075,7 +1076,8 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs { returnValueForMissingStub: null, ); @override - _i8.FusionInfo getFusionServerInfo(_i14.Coin? coin) => (super.noSuchMethod( + _i8.FusionInfo getFusionServerInfo(_i4.CryptoCurrency? coin) => + (super.noSuchMethod( Invocation.method( #getFusionServerInfo, [coin], @@ -1090,7 +1092,7 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs { ) as _i8.FusionInfo); @override void setFusionServerInfo( - _i14.Coin? coin, + _i4.CryptoCurrency? coin, _i8.FusionInfo? fusionServerInfo, ) => super.noSuchMethod( @@ -1104,7 +1106,7 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs { returnValueForMissingStub: null, ); @override - void addListener(_i15.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i14.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -1112,7 +1114,7 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs { returnValueForMissingStub: null, ); @override - void removeListener(_i15.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i14.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], diff --git a/test/screen_tests/exchange/exchange_view_test.mocks.dart b/test/screen_tests/exchange/exchange_view_test.mocks.dart index 1d97e1d48..2691281c4 100644 --- a/test/screen_tests/exchange/exchange_view_test.mocks.dart +++ b/test/screen_tests/exchange/exchange_view_test.mocks.dart @@ -32,9 +32,10 @@ import 'package:stackwallet/services/trade_notes_service.dart' as _i14; import 'package:stackwallet/services/trade_service.dart' as _i12; import 'package:stackwallet/utilities/amount/amount_unit.dart' as _i9; import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i7; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i10; import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i6; import 'package:stackwallet/utilities/prefs.dart' as _i5; +import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart' + as _i10; import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/cash_fusion_interface.dart' as _i2; @@ -503,7 +504,7 @@ class MockPrefs extends _i1.Mock implements _i5.Prefs { returnValueForMissingStub: _i8.Future.value(), ) as _i8.Future); @override - _i9.AmountUnit amountUnit(_i10.Coin? coin) => (super.noSuchMethod( + _i9.AmountUnit amountUnit(_i10.CryptoCurrency? coin) => (super.noSuchMethod( Invocation.method( #amountUnit, [coin], @@ -512,7 +513,7 @@ class MockPrefs extends _i1.Mock implements _i5.Prefs { ) as _i9.AmountUnit); @override void updateAmountUnit({ - required _i10.Coin? coin, + required _i10.CryptoCurrency? coin, required _i9.AmountUnit? amountUnit, }) => super.noSuchMethod( @@ -527,7 +528,7 @@ class MockPrefs extends _i1.Mock implements _i5.Prefs { returnValueForMissingStub: null, ); @override - int maxDecimals(_i10.Coin? coin) => (super.noSuchMethod( + int maxDecimals(_i10.CryptoCurrency? coin) => (super.noSuchMethod( Invocation.method( #maxDecimals, [coin], @@ -536,7 +537,7 @@ class MockPrefs extends _i1.Mock implements _i5.Prefs { ) as int); @override void updateMaxDecimals({ - required _i10.Coin? coin, + required _i10.CryptoCurrency? coin, required int? maxDecimals, }) => super.noSuchMethod( @@ -551,7 +552,8 @@ class MockPrefs extends _i1.Mock implements _i5.Prefs { returnValueForMissingStub: null, ); @override - _i2.FusionInfo getFusionServerInfo(_i10.Coin? coin) => (super.noSuchMethod( + _i2.FusionInfo getFusionServerInfo(_i10.CryptoCurrency? coin) => + (super.noSuchMethod( Invocation.method( #getFusionServerInfo, [coin], @@ -566,7 +568,7 @@ class MockPrefs extends _i1.Mock implements _i5.Prefs { ) as _i2.FusionInfo); @override void setFusionServerInfo( - _i10.Coin? coin, + _i10.CryptoCurrency? coin, _i2.FusionInfo? fusionServerInfo, ) => super.noSuchMethod( diff --git a/test/screen_tests/lockscreen_view_screen_test.mocks.dart b/test/screen_tests/lockscreen_view_screen_test.mocks.dart index 0a4b9c09d..a76f5c498 100644 --- a/test/screen_tests/lockscreen_view_screen_test.mocks.dart +++ b/test/screen_tests/lockscreen_view_screen_test.mocks.dart @@ -10,9 +10,10 @@ import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/node_model.dart' as _i7; import 'package:stackwallet/services/node_service.dart' as _i6; import 'package:stackwallet/services/wallets_service.dart' as _i3; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' as _i2; +import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart' + as _i8; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -124,7 +125,7 @@ class MockNodeService extends _i1.Mock implements _i6.NodeService { ) as _i4.Future); @override _i4.Future setPrimaryNodeFor({ - required _i8.Coin? coin, + required _i8.CryptoCurrency? coin, required _i7.NodeModel? node, bool? shouldNotifyListeners = false, }) => @@ -142,14 +143,15 @@ class MockNodeService extends _i1.Mock implements _i6.NodeService { returnValueForMissingStub: _i4.Future.value(), ) as _i4.Future); @override - _i7.NodeModel? getPrimaryNodeFor({required _i8.Coin? coin}) => + _i7.NodeModel? getPrimaryNodeFor({required _i8.CryptoCurrency? currency}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], - {#coin: coin}, + {#currency: currency}, )) as _i7.NodeModel?); @override - List<_i7.NodeModel> getNodesFor(_i8.Coin? coin) => (super.noSuchMethod( + List<_i7.NodeModel> getNodesFor(_i8.CryptoCurrency? coin) => + (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], @@ -164,12 +166,13 @@ class MockNodeService extends _i1.Mock implements _i6.NodeService { {#id: id}, )) as _i7.NodeModel?); @override - List<_i7.NodeModel> failoverNodesFor({required _i8.Coin? coin}) => + List<_i7.NodeModel> failoverNodesFor( + {required _i8.CryptoCurrency? currency}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], - {#coin: coin}, + {#currency: currency}, ), returnValue: <_i7.NodeModel>[], ) as List<_i7.NodeModel>); diff --git a/test/screen_tests/onboarding/create_pin_view_screen_test.mocks.dart b/test/screen_tests/onboarding/create_pin_view_screen_test.mocks.dart index 877fab27b..3f7fd0767 100644 --- a/test/screen_tests/onboarding/create_pin_view_screen_test.mocks.dart +++ b/test/screen_tests/onboarding/create_pin_view_screen_test.mocks.dart @@ -10,9 +10,10 @@ import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/node_model.dart' as _i7; import 'package:stackwallet/services/node_service.dart' as _i6; import 'package:stackwallet/services/wallets_service.dart' as _i3; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i8; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' as _i2; +import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart' + as _i8; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -124,7 +125,7 @@ class MockNodeService extends _i1.Mock implements _i6.NodeService { ) as _i4.Future); @override _i4.Future setPrimaryNodeFor({ - required _i8.Coin? coin, + required _i8.CryptoCurrency? coin, required _i7.NodeModel? node, bool? shouldNotifyListeners = false, }) => @@ -142,14 +143,15 @@ class MockNodeService extends _i1.Mock implements _i6.NodeService { returnValueForMissingStub: _i4.Future.value(), ) as _i4.Future); @override - _i7.NodeModel? getPrimaryNodeFor({required _i8.Coin? coin}) => + _i7.NodeModel? getPrimaryNodeFor({required _i8.CryptoCurrency? currency}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], - {#coin: coin}, + {#currency: currency}, )) as _i7.NodeModel?); @override - List<_i7.NodeModel> getNodesFor(_i8.Coin? coin) => (super.noSuchMethod( + List<_i7.NodeModel> getNodesFor(_i8.CryptoCurrency? coin) => + (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], @@ -164,12 +166,13 @@ class MockNodeService extends _i1.Mock implements _i6.NodeService { {#id: id}, )) as _i7.NodeModel?); @override - List<_i7.NodeModel> failoverNodesFor({required _i8.Coin? coin}) => + List<_i7.NodeModel> failoverNodesFor( + {required _i8.CryptoCurrency? currency}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], - {#coin: coin}, + {#currency: currency}, ), returnValue: <_i7.NodeModel>[], ) as List<_i7.NodeModel>); diff --git a/test/screen_tests/onboarding/restore_wallet_view_screen_test.mocks.dart b/test/screen_tests/onboarding/restore_wallet_view_screen_test.mocks.dart index b9acc5cfa..58c717a5b 100644 --- a/test/screen_tests/onboarding/restore_wallet_view_screen_test.mocks.dart +++ b/test/screen_tests/onboarding/restore_wallet_view_screen_test.mocks.dart @@ -12,9 +12,10 @@ import 'package:stackwallet/models/node_model.dart' as _i9; import 'package:stackwallet/services/node_service.dart' as _i8; import 'package:stackwallet/services/wallets_service.dart' as _i6; import 'package:stackwallet/utilities/barcode_scanner_interface.dart' as _i4; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i10; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' as _i3; +import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart' + as _i10; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -165,7 +166,7 @@ class MockNodeService extends _i1.Mock implements _i8.NodeService { ) as _i5.Future); @override _i5.Future setPrimaryNodeFor({ - required _i10.Coin? coin, + required _i10.CryptoCurrency? coin, required _i9.NodeModel? node, bool? shouldNotifyListeners = false, }) => @@ -183,14 +184,15 @@ class MockNodeService extends _i1.Mock implements _i8.NodeService { returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); @override - _i9.NodeModel? getPrimaryNodeFor({required _i10.Coin? coin}) => + _i9.NodeModel? getPrimaryNodeFor({required _i10.CryptoCurrency? currency}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], - {#coin: coin}, + {#currency: currency}, )) as _i9.NodeModel?); @override - List<_i9.NodeModel> getNodesFor(_i10.Coin? coin) => (super.noSuchMethod( + List<_i9.NodeModel> getNodesFor(_i10.CryptoCurrency? coin) => + (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], @@ -205,12 +207,13 @@ class MockNodeService extends _i1.Mock implements _i8.NodeService { {#id: id}, )) as _i9.NodeModel?); @override - List<_i9.NodeModel> failoverNodesFor({required _i10.Coin? coin}) => + List<_i9.NodeModel> failoverNodesFor( + {required _i10.CryptoCurrency? currency}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], - {#coin: coin}, + {#currency: currency}, ), returnValue: <_i9.NodeModel>[], ) as List<_i9.NodeModel>); diff --git a/test/screen_tests/settings_view/settings_subviews/network_settings_subviews/add_custom_node_view_screen_test.mocks.dart b/test/screen_tests/settings_view/settings_subviews/network_settings_subviews/add_custom_node_view_screen_test.mocks.dart index 0a7c9e214..ab3c043d3 100644 --- a/test/screen_tests/settings_view/settings_subviews/network_settings_subviews/add_custom_node_view_screen_test.mocks.dart +++ b/test/screen_tests/settings_view/settings_subviews/network_settings_subviews/add_custom_node_view_screen_test.mocks.dart @@ -9,9 +9,10 @@ import 'dart:ui' as _i7; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/node_model.dart' as _i4; import 'package:stackwallet/services/node_service.dart' as _i3; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i6; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' as _i2; +import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart' + as _i6; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -73,7 +74,7 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { ) as _i5.Future); @override _i5.Future setPrimaryNodeFor({ - required _i6.Coin? coin, + required _i6.CryptoCurrency? coin, required _i4.NodeModel? node, bool? shouldNotifyListeners = false, }) => @@ -91,14 +92,15 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); @override - _i4.NodeModel? getPrimaryNodeFor({required _i6.Coin? coin}) => + _i4.NodeModel? getPrimaryNodeFor({required _i6.CryptoCurrency? currency}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], - {#coin: coin}, + {#currency: currency}, )) as _i4.NodeModel?); @override - List<_i4.NodeModel> getNodesFor(_i6.Coin? coin) => (super.noSuchMethod( + List<_i4.NodeModel> getNodesFor(_i6.CryptoCurrency? coin) => + (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], @@ -113,12 +115,13 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { {#id: id}, )) as _i4.NodeModel?); @override - List<_i4.NodeModel> failoverNodesFor({required _i6.Coin? coin}) => + List<_i4.NodeModel> failoverNodesFor( + {required _i6.CryptoCurrency? currency}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], - {#coin: coin}, + {#currency: currency}, ), returnValue: <_i4.NodeModel>[], ) as List<_i4.NodeModel>); diff --git a/test/screen_tests/settings_view/settings_subviews/network_settings_subviews/node_details_view_screen_test.mocks.dart b/test/screen_tests/settings_view/settings_subviews/network_settings_subviews/node_details_view_screen_test.mocks.dart index 37ee08673..f203b112b 100644 --- a/test/screen_tests/settings_view/settings_subviews/network_settings_subviews/node_details_view_screen_test.mocks.dart +++ b/test/screen_tests/settings_view/settings_subviews/network_settings_subviews/node_details_view_screen_test.mocks.dart @@ -9,9 +9,10 @@ import 'dart:ui' as _i7; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/node_model.dart' as _i4; import 'package:stackwallet/services/node_service.dart' as _i3; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i6; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' as _i2; +import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart' + as _i6; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -73,7 +74,7 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { ) as _i5.Future); @override _i5.Future setPrimaryNodeFor({ - required _i6.Coin? coin, + required _i6.CryptoCurrency? coin, required _i4.NodeModel? node, bool? shouldNotifyListeners = false, }) => @@ -91,14 +92,15 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); @override - _i4.NodeModel? getPrimaryNodeFor({required _i6.Coin? coin}) => + _i4.NodeModel? getPrimaryNodeFor({required _i6.CryptoCurrency? currency}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], - {#coin: coin}, + {#currency: currency}, )) as _i4.NodeModel?); @override - List<_i4.NodeModel> getNodesFor(_i6.Coin? coin) => (super.noSuchMethod( + List<_i4.NodeModel> getNodesFor(_i6.CryptoCurrency? coin) => + (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], @@ -113,12 +115,13 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { {#id: id}, )) as _i4.NodeModel?); @override - List<_i4.NodeModel> failoverNodesFor({required _i6.Coin? coin}) => + List<_i4.NodeModel> failoverNodesFor( + {required _i6.CryptoCurrency? currency}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], - {#coin: coin}, + {#currency: currency}, ), returnValue: <_i4.NodeModel>[], ) as List<_i4.NodeModel>); diff --git a/test/screen_tests/settings_view/settings_subviews/network_settings_view_screen_test.mocks.dart b/test/screen_tests/settings_view/settings_subviews/network_settings_view_screen_test.mocks.dart index d364e457c..217f88d9f 100644 --- a/test/screen_tests/settings_view/settings_subviews/network_settings_view_screen_test.mocks.dart +++ b/test/screen_tests/settings_view/settings_subviews/network_settings_view_screen_test.mocks.dart @@ -9,9 +9,10 @@ import 'dart:ui' as _i7; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/node_model.dart' as _i4; import 'package:stackwallet/services/node_service.dart' as _i3; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i6; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' as _i2; +import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart' + as _i6; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -73,7 +74,7 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { ) as _i5.Future); @override _i5.Future setPrimaryNodeFor({ - required _i6.Coin? coin, + required _i6.CryptoCurrency? coin, required _i4.NodeModel? node, bool? shouldNotifyListeners = false, }) => @@ -91,14 +92,15 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); @override - _i4.NodeModel? getPrimaryNodeFor({required _i6.Coin? coin}) => + _i4.NodeModel? getPrimaryNodeFor({required _i6.CryptoCurrency? currency}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], - {#coin: coin}, + {#currency: currency}, )) as _i4.NodeModel?); @override - List<_i4.NodeModel> getNodesFor(_i6.Coin? coin) => (super.noSuchMethod( + List<_i4.NodeModel> getNodesFor(_i6.CryptoCurrency? coin) => + (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], @@ -113,12 +115,13 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { {#id: id}, )) as _i4.NodeModel?); @override - List<_i4.NodeModel> failoverNodesFor({required _i6.Coin? coin}) => + List<_i4.NodeModel> failoverNodesFor( + {required _i6.CryptoCurrency? currency}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], - {#coin: coin}, + {#currency: currency}, ), returnValue: <_i4.NodeModel>[], ) as List<_i4.NodeModel>); diff --git a/test/screen_tests/settings_view/settings_subviews/wallet_settings_view_screen_test.mocks.dart b/test/screen_tests/settings_view/settings_subviews/wallet_settings_view_screen_test.mocks.dart index 5bc43e816..63c207931 100644 --- a/test/screen_tests/settings_view/settings_subviews/wallet_settings_view_screen_test.mocks.dart +++ b/test/screen_tests/settings_view/settings_subviews/wallet_settings_view_screen_test.mocks.dart @@ -13,7 +13,8 @@ import 'package:stackwallet/electrumx_rpc/cached_electrumx_client.dart' as _i3; import 'package:stackwallet/electrumx_rpc/electrumx_client.dart' as _i2; import 'package:stackwallet/services/wallets_service.dart' as _i9; import 'package:stackwallet/utilities/biometrics.dart' as _i8; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i5; +import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart' + as _i5; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -58,7 +59,7 @@ class MockCachedElectrumXClient extends _i1.Mock _i4.Future> getAnonymitySet({ required String? groupId, String? blockhash = r'', - required _i5.Coin? coin, + required _i5.CryptoCurrency? cryptoCurrency, }) => (super.noSuchMethod( Invocation.method( @@ -67,7 +68,7 @@ class MockCachedElectrumXClient extends _i1.Mock { #groupId: groupId, #blockhash: blockhash, - #coin: coin, + #cryptoCurrency: cryptoCurrency, }, ), returnValue: @@ -77,7 +78,7 @@ class MockCachedElectrumXClient extends _i1.Mock _i4.Future> getSparkAnonymitySet({ required String? groupId, String? blockhash = r'', - required _i5.Coin? coin, + required _i5.CryptoCurrency? cryptoCurrency, required bool? useOnlyCacheIfNotEmpty, }) => (super.noSuchMethod( @@ -87,7 +88,7 @@ class MockCachedElectrumXClient extends _i1.Mock { #groupId: groupId, #blockhash: blockhash, - #coin: coin, + #cryptoCurrency: cryptoCurrency, #useOnlyCacheIfNotEmpty: useOnlyCacheIfNotEmpty, }, ), @@ -113,7 +114,7 @@ class MockCachedElectrumXClient extends _i1.Mock @override _i4.Future> getTransaction({ required String? txHash, - required _i5.Coin? coin, + required _i5.CryptoCurrency? cryptoCurrency, bool? verbose = true, }) => (super.noSuchMethod( @@ -122,7 +123,7 @@ class MockCachedElectrumXClient extends _i1.Mock [], { #txHash: txHash, - #coin: coin, + #cryptoCurrency: cryptoCurrency, #verbose: verbose, }, ), @@ -131,7 +132,7 @@ class MockCachedElectrumXClient extends _i1.Mock ) as _i4.Future>); @override _i4.Future> getUsedCoinSerials({ - required _i5.Coin? coin, + required _i5.CryptoCurrency? cryptoCurrency, int? startNumber = 0, }) => (super.noSuchMethod( @@ -139,29 +140,31 @@ class MockCachedElectrumXClient extends _i1.Mock #getUsedCoinSerials, [], { - #coin: coin, + #cryptoCurrency: cryptoCurrency, #startNumber: startNumber, }, ), returnValue: _i4.Future>.value([]), ) as _i4.Future>); @override - _i4.Future> getSparkUsedCoinsTags({required _i5.Coin? coin}) => + _i4.Future> getSparkUsedCoinsTags( + {required _i5.CryptoCurrency? cryptoCurrency}) => (super.noSuchMethod( Invocation.method( #getSparkUsedCoinsTags, [], - {#coin: coin}, + {#cryptoCurrency: cryptoCurrency}, ), returnValue: _i4.Future>.value({}), ) as _i4.Future>); @override - _i4.Future clearSharedTransactionCache({required _i5.Coin? coin}) => + _i4.Future clearSharedTransactionCache( + {required _i5.CryptoCurrency? cryptoCurrency}) => (super.noSuchMethod( Invocation.method( #clearSharedTransactionCache, [], - {#coin: coin}, + {#cryptoCurrency: cryptoCurrency}, ), returnValue: _i4.Future.value(), returnValueForMissingStub: _i4.Future.value(), diff --git a/test/services/coins/bitcoin/bitcoin_wallet_test.mocks.dart b/test/services/coins/bitcoin/bitcoin_wallet_test.mocks.dart index 999e3f135..efcb9f626 100644 --- a/test/services/coins/bitcoin/bitcoin_wallet_test.mocks.dart +++ b/test/services/coins/bitcoin/bitcoin_wallet_test.mocks.dart @@ -10,8 +10,7 @@ import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/electrumx_rpc/cached_electrumx_client.dart' as _i6; import 'package:stackwallet/electrumx_rpc/electrumx_client.dart' as _i4; import 'package:stackwallet/services/transaction_notification_tracker.dart' - as _i8; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; + as _i7; import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart' as _i2; @@ -528,7 +527,7 @@ class MockCachedElectrumXClient extends _i1.Mock _i5.Future> getAnonymitySet({ required String? groupId, String? blockhash = r'', - required _i7.Coin? coin, + required _i2.CryptoCurrency? cryptoCurrency, }) => (super.noSuchMethod( Invocation.method( @@ -537,7 +536,7 @@ class MockCachedElectrumXClient extends _i1.Mock { #groupId: groupId, #blockhash: blockhash, - #coin: coin, + #cryptoCurrency: cryptoCurrency, }, ), returnValue: @@ -547,7 +546,7 @@ class MockCachedElectrumXClient extends _i1.Mock _i5.Future> getSparkAnonymitySet({ required String? groupId, String? blockhash = r'', - required _i7.Coin? coin, + required _i2.CryptoCurrency? cryptoCurrency, required bool? useOnlyCacheIfNotEmpty, }) => (super.noSuchMethod( @@ -557,7 +556,7 @@ class MockCachedElectrumXClient extends _i1.Mock { #groupId: groupId, #blockhash: blockhash, - #coin: coin, + #cryptoCurrency: cryptoCurrency, #useOnlyCacheIfNotEmpty: useOnlyCacheIfNotEmpty, }, ), @@ -583,7 +582,7 @@ class MockCachedElectrumXClient extends _i1.Mock @override _i5.Future> getTransaction({ required String? txHash, - required _i7.Coin? coin, + required _i2.CryptoCurrency? cryptoCurrency, bool? verbose = true, }) => (super.noSuchMethod( @@ -592,7 +591,7 @@ class MockCachedElectrumXClient extends _i1.Mock [], { #txHash: txHash, - #coin: coin, + #cryptoCurrency: cryptoCurrency, #verbose: verbose, }, ), @@ -601,7 +600,7 @@ class MockCachedElectrumXClient extends _i1.Mock ) as _i5.Future>); @override _i5.Future> getUsedCoinSerials({ - required _i7.Coin? coin, + required _i2.CryptoCurrency? cryptoCurrency, int? startNumber = 0, }) => (super.noSuchMethod( @@ -609,29 +608,31 @@ class MockCachedElectrumXClient extends _i1.Mock #getUsedCoinSerials, [], { - #coin: coin, + #cryptoCurrency: cryptoCurrency, #startNumber: startNumber, }, ), returnValue: _i5.Future>.value([]), ) as _i5.Future>); @override - _i5.Future> getSparkUsedCoinsTags({required _i7.Coin? coin}) => + _i5.Future> getSparkUsedCoinsTags( + {required _i2.CryptoCurrency? cryptoCurrency}) => (super.noSuchMethod( Invocation.method( #getSparkUsedCoinsTags, [], - {#coin: coin}, + {#cryptoCurrency: cryptoCurrency}, ), returnValue: _i5.Future>.value({}), ) as _i5.Future>); @override - _i5.Future clearSharedTransactionCache({required _i7.Coin? coin}) => + _i5.Future clearSharedTransactionCache( + {required _i2.CryptoCurrency? cryptoCurrency}) => (super.noSuchMethod( Invocation.method( #clearSharedTransactionCache, [], - {#coin: coin}, + {#cryptoCurrency: cryptoCurrency}, ), returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), @@ -642,7 +643,7 @@ class MockCachedElectrumXClient extends _i1.Mock /// /// See the documentation for Mockito's code generation for more information. class MockTransactionNotificationTracker extends _i1.Mock - implements _i8.TransactionNotificationTracker { + implements _i7.TransactionNotificationTracker { MockTransactionNotificationTracker() { _i1.throwOnMissingStub(this); } diff --git a/test/services/coins/bitcoincash/bitcoincash_wallet_test.mocks.dart b/test/services/coins/bitcoincash/bitcoincash_wallet_test.mocks.dart index 9886b150a..7cfef5ab4 100644 --- a/test/services/coins/bitcoincash/bitcoincash_wallet_test.mocks.dart +++ b/test/services/coins/bitcoincash/bitcoincash_wallet_test.mocks.dart @@ -10,8 +10,7 @@ import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/electrumx_rpc/cached_electrumx_client.dart' as _i6; import 'package:stackwallet/electrumx_rpc/electrumx_client.dart' as _i4; import 'package:stackwallet/services/transaction_notification_tracker.dart' - as _i8; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; + as _i7; import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart' as _i2; @@ -528,7 +527,7 @@ class MockCachedElectrumXClient extends _i1.Mock _i5.Future> getAnonymitySet({ required String? groupId, String? blockhash = r'', - required _i7.Coin? coin, + required _i2.CryptoCurrency? cryptoCurrency, }) => (super.noSuchMethod( Invocation.method( @@ -537,7 +536,7 @@ class MockCachedElectrumXClient extends _i1.Mock { #groupId: groupId, #blockhash: blockhash, - #coin: coin, + #cryptoCurrency: cryptoCurrency, }, ), returnValue: @@ -547,7 +546,7 @@ class MockCachedElectrumXClient extends _i1.Mock _i5.Future> getSparkAnonymitySet({ required String? groupId, String? blockhash = r'', - required _i7.Coin? coin, + required _i2.CryptoCurrency? cryptoCurrency, required bool? useOnlyCacheIfNotEmpty, }) => (super.noSuchMethod( @@ -557,7 +556,7 @@ class MockCachedElectrumXClient extends _i1.Mock { #groupId: groupId, #blockhash: blockhash, - #coin: coin, + #cryptoCurrency: cryptoCurrency, #useOnlyCacheIfNotEmpty: useOnlyCacheIfNotEmpty, }, ), @@ -583,7 +582,7 @@ class MockCachedElectrumXClient extends _i1.Mock @override _i5.Future> getTransaction({ required String? txHash, - required _i7.Coin? coin, + required _i2.CryptoCurrency? cryptoCurrency, bool? verbose = true, }) => (super.noSuchMethod( @@ -592,7 +591,7 @@ class MockCachedElectrumXClient extends _i1.Mock [], { #txHash: txHash, - #coin: coin, + #cryptoCurrency: cryptoCurrency, #verbose: verbose, }, ), @@ -601,7 +600,7 @@ class MockCachedElectrumXClient extends _i1.Mock ) as _i5.Future>); @override _i5.Future> getUsedCoinSerials({ - required _i7.Coin? coin, + required _i2.CryptoCurrency? cryptoCurrency, int? startNumber = 0, }) => (super.noSuchMethod( @@ -609,29 +608,31 @@ class MockCachedElectrumXClient extends _i1.Mock #getUsedCoinSerials, [], { - #coin: coin, + #cryptoCurrency: cryptoCurrency, #startNumber: startNumber, }, ), returnValue: _i5.Future>.value([]), ) as _i5.Future>); @override - _i5.Future> getSparkUsedCoinsTags({required _i7.Coin? coin}) => + _i5.Future> getSparkUsedCoinsTags( + {required _i2.CryptoCurrency? cryptoCurrency}) => (super.noSuchMethod( Invocation.method( #getSparkUsedCoinsTags, [], - {#coin: coin}, + {#cryptoCurrency: cryptoCurrency}, ), returnValue: _i5.Future>.value({}), ) as _i5.Future>); @override - _i5.Future clearSharedTransactionCache({required _i7.Coin? coin}) => + _i5.Future clearSharedTransactionCache( + {required _i2.CryptoCurrency? cryptoCurrency}) => (super.noSuchMethod( Invocation.method( #clearSharedTransactionCache, [], - {#coin: coin}, + {#cryptoCurrency: cryptoCurrency}, ), returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), @@ -642,7 +643,7 @@ class MockCachedElectrumXClient extends _i1.Mock /// /// See the documentation for Mockito's code generation for more information. class MockTransactionNotificationTracker extends _i1.Mock - implements _i8.TransactionNotificationTracker { + implements _i7.TransactionNotificationTracker { MockTransactionNotificationTracker() { _i1.throwOnMissingStub(this); } diff --git a/test/services/coins/dogecoin/dogecoin_wallet_test.mocks.dart b/test/services/coins/dogecoin/dogecoin_wallet_test.mocks.dart index f9cc4af74..eb9afea89 100644 --- a/test/services/coins/dogecoin/dogecoin_wallet_test.mocks.dart +++ b/test/services/coins/dogecoin/dogecoin_wallet_test.mocks.dart @@ -10,8 +10,7 @@ import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/electrumx_rpc/cached_electrumx_client.dart' as _i6; import 'package:stackwallet/electrumx_rpc/electrumx_client.dart' as _i4; import 'package:stackwallet/services/transaction_notification_tracker.dart' - as _i8; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; + as _i7; import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart' as _i2; @@ -528,7 +527,7 @@ class MockCachedElectrumXClient extends _i1.Mock _i5.Future> getAnonymitySet({ required String? groupId, String? blockhash = r'', - required _i7.Coin? coin, + required _i2.CryptoCurrency? cryptoCurrency, }) => (super.noSuchMethod( Invocation.method( @@ -537,7 +536,7 @@ class MockCachedElectrumXClient extends _i1.Mock { #groupId: groupId, #blockhash: blockhash, - #coin: coin, + #cryptoCurrency: cryptoCurrency, }, ), returnValue: @@ -547,7 +546,7 @@ class MockCachedElectrumXClient extends _i1.Mock _i5.Future> getSparkAnonymitySet({ required String? groupId, String? blockhash = r'', - required _i7.Coin? coin, + required _i2.CryptoCurrency? cryptoCurrency, required bool? useOnlyCacheIfNotEmpty, }) => (super.noSuchMethod( @@ -557,7 +556,7 @@ class MockCachedElectrumXClient extends _i1.Mock { #groupId: groupId, #blockhash: blockhash, - #coin: coin, + #cryptoCurrency: cryptoCurrency, #useOnlyCacheIfNotEmpty: useOnlyCacheIfNotEmpty, }, ), @@ -583,7 +582,7 @@ class MockCachedElectrumXClient extends _i1.Mock @override _i5.Future> getTransaction({ required String? txHash, - required _i7.Coin? coin, + required _i2.CryptoCurrency? cryptoCurrency, bool? verbose = true, }) => (super.noSuchMethod( @@ -592,7 +591,7 @@ class MockCachedElectrumXClient extends _i1.Mock [], { #txHash: txHash, - #coin: coin, + #cryptoCurrency: cryptoCurrency, #verbose: verbose, }, ), @@ -601,7 +600,7 @@ class MockCachedElectrumXClient extends _i1.Mock ) as _i5.Future>); @override _i5.Future> getUsedCoinSerials({ - required _i7.Coin? coin, + required _i2.CryptoCurrency? cryptoCurrency, int? startNumber = 0, }) => (super.noSuchMethod( @@ -609,29 +608,31 @@ class MockCachedElectrumXClient extends _i1.Mock #getUsedCoinSerials, [], { - #coin: coin, + #cryptoCurrency: cryptoCurrency, #startNumber: startNumber, }, ), returnValue: _i5.Future>.value([]), ) as _i5.Future>); @override - _i5.Future> getSparkUsedCoinsTags({required _i7.Coin? coin}) => + _i5.Future> getSparkUsedCoinsTags( + {required _i2.CryptoCurrency? cryptoCurrency}) => (super.noSuchMethod( Invocation.method( #getSparkUsedCoinsTags, [], - {#coin: coin}, + {#cryptoCurrency: cryptoCurrency}, ), returnValue: _i5.Future>.value({}), ) as _i5.Future>); @override - _i5.Future clearSharedTransactionCache({required _i7.Coin? coin}) => + _i5.Future clearSharedTransactionCache( + {required _i2.CryptoCurrency? cryptoCurrency}) => (super.noSuchMethod( Invocation.method( #clearSharedTransactionCache, [], - {#coin: coin}, + {#cryptoCurrency: cryptoCurrency}, ), returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), @@ -642,7 +643,7 @@ class MockCachedElectrumXClient extends _i1.Mock /// /// See the documentation for Mockito's code generation for more information. class MockTransactionNotificationTracker extends _i1.Mock - implements _i8.TransactionNotificationTracker { + implements _i7.TransactionNotificationTracker { MockTransactionNotificationTracker() { _i1.throwOnMissingStub(this); } diff --git a/test/services/coins/namecoin/namecoin_wallet_test.mocks.dart b/test/services/coins/namecoin/namecoin_wallet_test.mocks.dart index c5ed61ed5..a8a5fb3c2 100644 --- a/test/services/coins/namecoin/namecoin_wallet_test.mocks.dart +++ b/test/services/coins/namecoin/namecoin_wallet_test.mocks.dart @@ -10,8 +10,7 @@ import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/electrumx_rpc/cached_electrumx_client.dart' as _i6; import 'package:stackwallet/electrumx_rpc/electrumx_client.dart' as _i4; import 'package:stackwallet/services/transaction_notification_tracker.dart' - as _i8; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; + as _i7; import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart' as _i2; @@ -528,7 +527,7 @@ class MockCachedElectrumXClient extends _i1.Mock _i5.Future> getAnonymitySet({ required String? groupId, String? blockhash = r'', - required _i7.Coin? coin, + required _i2.CryptoCurrency? cryptoCurrency, }) => (super.noSuchMethod( Invocation.method( @@ -537,7 +536,7 @@ class MockCachedElectrumXClient extends _i1.Mock { #groupId: groupId, #blockhash: blockhash, - #coin: coin, + #cryptoCurrency: cryptoCurrency, }, ), returnValue: @@ -547,7 +546,7 @@ class MockCachedElectrumXClient extends _i1.Mock _i5.Future> getSparkAnonymitySet({ required String? groupId, String? blockhash = r'', - required _i7.Coin? coin, + required _i2.CryptoCurrency? cryptoCurrency, required bool? useOnlyCacheIfNotEmpty, }) => (super.noSuchMethod( @@ -557,7 +556,7 @@ class MockCachedElectrumXClient extends _i1.Mock { #groupId: groupId, #blockhash: blockhash, - #coin: coin, + #cryptoCurrency: cryptoCurrency, #useOnlyCacheIfNotEmpty: useOnlyCacheIfNotEmpty, }, ), @@ -583,7 +582,7 @@ class MockCachedElectrumXClient extends _i1.Mock @override _i5.Future> getTransaction({ required String? txHash, - required _i7.Coin? coin, + required _i2.CryptoCurrency? cryptoCurrency, bool? verbose = true, }) => (super.noSuchMethod( @@ -592,7 +591,7 @@ class MockCachedElectrumXClient extends _i1.Mock [], { #txHash: txHash, - #coin: coin, + #cryptoCurrency: cryptoCurrency, #verbose: verbose, }, ), @@ -601,7 +600,7 @@ class MockCachedElectrumXClient extends _i1.Mock ) as _i5.Future>); @override _i5.Future> getUsedCoinSerials({ - required _i7.Coin? coin, + required _i2.CryptoCurrency? cryptoCurrency, int? startNumber = 0, }) => (super.noSuchMethod( @@ -609,29 +608,31 @@ class MockCachedElectrumXClient extends _i1.Mock #getUsedCoinSerials, [], { - #coin: coin, + #cryptoCurrency: cryptoCurrency, #startNumber: startNumber, }, ), returnValue: _i5.Future>.value([]), ) as _i5.Future>); @override - _i5.Future> getSparkUsedCoinsTags({required _i7.Coin? coin}) => + _i5.Future> getSparkUsedCoinsTags( + {required _i2.CryptoCurrency? cryptoCurrency}) => (super.noSuchMethod( Invocation.method( #getSparkUsedCoinsTags, [], - {#coin: coin}, + {#cryptoCurrency: cryptoCurrency}, ), returnValue: _i5.Future>.value({}), ) as _i5.Future>); @override - _i5.Future clearSharedTransactionCache({required _i7.Coin? coin}) => + _i5.Future clearSharedTransactionCache( + {required _i2.CryptoCurrency? cryptoCurrency}) => (super.noSuchMethod( Invocation.method( #clearSharedTransactionCache, [], - {#coin: coin}, + {#cryptoCurrency: cryptoCurrency}, ), returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), @@ -642,7 +643,7 @@ class MockCachedElectrumXClient extends _i1.Mock /// /// See the documentation for Mockito's code generation for more information. class MockTransactionNotificationTracker extends _i1.Mock - implements _i8.TransactionNotificationTracker { + implements _i7.TransactionNotificationTracker { MockTransactionNotificationTracker() { _i1.throwOnMissingStub(this); } diff --git a/test/services/coins/particl/particl_wallet_test.mocks.dart b/test/services/coins/particl/particl_wallet_test.mocks.dart index 587dbe42e..aac19401c 100644 --- a/test/services/coins/particl/particl_wallet_test.mocks.dart +++ b/test/services/coins/particl/particl_wallet_test.mocks.dart @@ -10,8 +10,7 @@ import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/electrumx_rpc/cached_electrumx_client.dart' as _i6; import 'package:stackwallet/electrumx_rpc/electrumx_client.dart' as _i4; import 'package:stackwallet/services/transaction_notification_tracker.dart' - as _i8; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i7; + as _i7; import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart' as _i2; @@ -528,7 +527,7 @@ class MockCachedElectrumXClient extends _i1.Mock _i5.Future> getAnonymitySet({ required String? groupId, String? blockhash = r'', - required _i7.Coin? coin, + required _i2.CryptoCurrency? cryptoCurrency, }) => (super.noSuchMethod( Invocation.method( @@ -537,7 +536,7 @@ class MockCachedElectrumXClient extends _i1.Mock { #groupId: groupId, #blockhash: blockhash, - #coin: coin, + #cryptoCurrency: cryptoCurrency, }, ), returnValue: @@ -547,7 +546,7 @@ class MockCachedElectrumXClient extends _i1.Mock _i5.Future> getSparkAnonymitySet({ required String? groupId, String? blockhash = r'', - required _i7.Coin? coin, + required _i2.CryptoCurrency? cryptoCurrency, required bool? useOnlyCacheIfNotEmpty, }) => (super.noSuchMethod( @@ -557,7 +556,7 @@ class MockCachedElectrumXClient extends _i1.Mock { #groupId: groupId, #blockhash: blockhash, - #coin: coin, + #cryptoCurrency: cryptoCurrency, #useOnlyCacheIfNotEmpty: useOnlyCacheIfNotEmpty, }, ), @@ -583,7 +582,7 @@ class MockCachedElectrumXClient extends _i1.Mock @override _i5.Future> getTransaction({ required String? txHash, - required _i7.Coin? coin, + required _i2.CryptoCurrency? cryptoCurrency, bool? verbose = true, }) => (super.noSuchMethod( @@ -592,7 +591,7 @@ class MockCachedElectrumXClient extends _i1.Mock [], { #txHash: txHash, - #coin: coin, + #cryptoCurrency: cryptoCurrency, #verbose: verbose, }, ), @@ -601,7 +600,7 @@ class MockCachedElectrumXClient extends _i1.Mock ) as _i5.Future>); @override _i5.Future> getUsedCoinSerials({ - required _i7.Coin? coin, + required _i2.CryptoCurrency? cryptoCurrency, int? startNumber = 0, }) => (super.noSuchMethod( @@ -609,29 +608,31 @@ class MockCachedElectrumXClient extends _i1.Mock #getUsedCoinSerials, [], { - #coin: coin, + #cryptoCurrency: cryptoCurrency, #startNumber: startNumber, }, ), returnValue: _i5.Future>.value([]), ) as _i5.Future>); @override - _i5.Future> getSparkUsedCoinsTags({required _i7.Coin? coin}) => + _i5.Future> getSparkUsedCoinsTags( + {required _i2.CryptoCurrency? cryptoCurrency}) => (super.noSuchMethod( Invocation.method( #getSparkUsedCoinsTags, [], - {#coin: coin}, + {#cryptoCurrency: cryptoCurrency}, ), returnValue: _i5.Future>.value({}), ) as _i5.Future>); @override - _i5.Future clearSharedTransactionCache({required _i7.Coin? coin}) => + _i5.Future clearSharedTransactionCache( + {required _i2.CryptoCurrency? cryptoCurrency}) => (super.noSuchMethod( Invocation.method( #clearSharedTransactionCache, [], - {#coin: coin}, + {#cryptoCurrency: cryptoCurrency}, ), returnValue: _i5.Future.value(), returnValueForMissingStub: _i5.Future.value(), @@ -642,7 +643,7 @@ class MockCachedElectrumXClient extends _i1.Mock /// /// See the documentation for Mockito's code generation for more information. class MockTransactionNotificationTracker extends _i1.Mock - implements _i8.TransactionNotificationTracker { + implements _i7.TransactionNotificationTracker { MockTransactionNotificationTracker() { _i1.throwOnMissingStub(this); } diff --git a/test/services/node_service_test.dart b/test/services/node_service_test.dart index 2bd889b6e..5b4f1e635 100644 --- a/test/services/node_service_test.dart +++ b/test/services/node_service_test.dart @@ -4,9 +4,9 @@ import 'package:hive_test/hive_test.dart'; import 'package:stackwallet/db/hive/db.dart'; import 'package:stackwallet/models/node_model.dart'; import 'package:stackwallet/services/node_service.dart'; -import 'package:stackwallet/utilities/default_nodes.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import 'package:stackwallet/app_config.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; +import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; void main() { bool wasRegistered = false; @@ -24,7 +24,9 @@ void main() { test("getPrimaryNodeFor", () { final fakeStore = FakeSecureStorage(); final service = NodeService(secureStorageInterface: fakeStore); - final node = service.getPrimaryNodeFor(coin: Coin.bitcoin); + final node = service.getPrimaryNodeFor( + currency: Bitcoin(CryptoCurrencyNetwork.main), + ); expect(node, null); expect(fakeStore.interactions, 0); }); @@ -32,7 +34,9 @@ void main() { test("setPrimaryNodeFor", () async { final fakeStore = FakeSecureStorage(); final service = NodeService(secureStorageInterface: fakeStore); - final node = service.getPrimaryNodeFor(coin: Coin.bitcoin); + final node = service.getPrimaryNodeFor( + currency: Bitcoin(CryptoCurrencyNetwork.main), + ); expect(node, null); final node1 = NodeModel( host: "host", @@ -46,20 +50,24 @@ void main() { isDown: false, ); await service.setPrimaryNodeFor( - coin: Coin.bitcoin, + coin: Bitcoin(CryptoCurrencyNetwork.main), node: node1, shouldNotifyListeners: true, ); - expect(service.getPrimaryNodeFor(coin: Coin.bitcoin).toString(), - node1.toString()); + expect( + service + .getPrimaryNodeFor(currency: Bitcoin(CryptoCurrencyNetwork.main)) + .toString(), + node1.toString(), + ); expect(fakeStore.interactions, 0); }); test("getNodesFor", () { final fakeStore = FakeSecureStorage(); final service = NodeService(secureStorageInterface: fakeStore); - final nodes = service.getNodesFor(Coin.bitcoin); + final nodes = service.getNodesFor(Bitcoin(CryptoCurrencyNetwork.main)); expect(nodes.isEmpty, true); expect(fakeStore.interactions, 0); }); @@ -83,7 +91,9 @@ void main() { test("get failover nodes", () { final fakeStore = FakeSecureStorage(); final service = NodeService(secureStorageInterface: fakeStore); - final nodes = service.failoverNodesFor(coin: Coin.bitcoin); + final nodes = service.failoverNodesFor( + currency: Bitcoin(CryptoCurrencyNetwork.main), + ); expect(nodes.isEmpty, true); expect(fakeStore.interactions, 0); }); @@ -100,7 +110,10 @@ void main() { final fakeStore = FakeSecureStorage(); final service = NodeService(secureStorageInterface: fakeStore); await service.updateDefaults(); - expect(service.nodes.length, DefaultNodes.all.length); + expect( + service.nodes.length, + AppConfig.coins.map((e) => e.defaultNode).length, + ); expect(fakeStore.interactions, 0); }); }); @@ -148,11 +161,22 @@ void main() { test("setPrimaryNodeFor and getPrimaryNodeFor", () async { final fakeStore = FakeSecureStorage(); final service = NodeService(secureStorageInterface: fakeStore); - expect(service.getPrimaryNodeFor(coin: Coin.bitcoin), null); + expect( + service.getPrimaryNodeFor( + currency: Bitcoin(CryptoCurrencyNetwork.main), + ), + null, + ); await service.setPrimaryNodeFor( - coin: Coin.bitcoin, node: DefaultNodes.bitcoin); - expect(service.getPrimaryNodeFor(coin: Coin.bitcoin).toString(), - DefaultNodes.bitcoin.toString()); + coin: Bitcoin(CryptoCurrencyNetwork.main), + node: Bitcoin(CryptoCurrencyNetwork.main).defaultNode, + ); + expect( + service + .getPrimaryNodeFor(currency: Bitcoin(CryptoCurrencyNetwork.main)) + .toString(), + Bitcoin(CryptoCurrencyNetwork.main).defaultNode.toString(), + ); expect(fakeStore.interactions, 0); }); @@ -160,11 +184,20 @@ void main() { final fakeStore = FakeSecureStorage(); final service = NodeService(secureStorageInterface: fakeStore); await service.setPrimaryNodeFor( - coin: Coin.bitcoin, node: DefaultNodes.bitcoin); + coin: Bitcoin(CryptoCurrencyNetwork.main), + node: Bitcoin(CryptoCurrencyNetwork.main).defaultNode, + ); await service.setPrimaryNodeFor( - coin: Coin.monero, node: DefaultNodes.monero); - expect(service.primaryNodes.toString(), - [DefaultNodes.bitcoin, DefaultNodes.monero].toString()); + coin: Monero(CryptoCurrencyNetwork.main), + node: Monero(CryptoCurrencyNetwork.main).defaultNode, + ); + expect( + service.primaryNodes.toString(), + [ + Bitcoin(CryptoCurrencyNetwork.main).defaultNode, + Monero(CryptoCurrencyNetwork.main).defaultNode, + ].toString(), + ); expect(fakeStore.interactions, 0); }); @@ -172,10 +205,10 @@ void main() { final fakeStore = FakeSecureStorage(); final service = NodeService(secureStorageInterface: fakeStore); final nodes = service.nodes; - final defaults = DefaultNodes.all; + final defaults = AppConfig.coins.map((e) => e.defaultNode).toList(); - nodes.sort((a, b) => a.host.compareTo(b.host)); - defaults.sort((a, b) => a.host.compareTo(b.host)); + nodes.sort((a, b) => a.id.compareTo(b.id)); + defaults.sort((a, b) => a.id.compareTo(b.id)); expect(nodes.length, defaults.length); expect(nodes.toString(), defaults.toString()); @@ -186,7 +219,10 @@ void main() { final fakeStore = FakeSecureStorage(); final service = NodeService(secureStorageInterface: fakeStore); await service.add(nodeA, null, true); - expect(service.nodes.length, DefaultNodes.all.length + 1); + expect( + service.nodes.length, + AppConfig.coins.map((e) => e.defaultNode).length + 1, + ); expect(fakeStore.interactions, 0); }); @@ -194,7 +230,10 @@ void main() { final fakeStore = FakeSecureStorage(); final service = NodeService(secureStorageInterface: fakeStore); await service.add(nodeA, "some password", true); - expect(service.nodes.length, DefaultNodes.all.length + 1); + expect( + service.nodes.length, + AppConfig.coins.map((e) => e.defaultNode).length + 1, + ); expect(fakeStore.interactions, 1); expect(fakeStore.writes, 1); }); @@ -202,11 +241,20 @@ void main() { group("Additional nodes in storage tests", () { setUp(() async { await DB.instance.put( - boxName: DB.boxNameNodeModels, key: nodeA.id, value: nodeA); + boxName: DB.boxNameNodeModels, + key: nodeA.id, + value: nodeA, + ); await DB.instance.put( - boxName: DB.boxNameNodeModels, key: nodeB.id, value: nodeB); + boxName: DB.boxNameNodeModels, + key: nodeB.id, + value: nodeB, + ); await DB.instance.put( - boxName: DB.boxNameNodeModels, key: nodeC.id, value: nodeC); + boxName: DB.boxNameNodeModels, + key: nodeC.id, + value: nodeC, + ); }); test("edit a node with a password", () async { @@ -220,11 +268,14 @@ void main() { expect(service.nodes.length, currentLength); - expect(service.getNodeById(id: nodeA.id).toString(), - editedNode.toString()); expect( - (await service.getNodeById(id: nodeA.id)!.getPassword(fakeStore))!, - "123456"); + service.getNodeById(id: nodeA.id).toString(), + editedNode.toString(), + ); + expect( + (await service.getNodeById(id: nodeA.id)!.getPassword(fakeStore))!, + "123456", + ); expect(fakeStore.interactions, 2); expect(fakeStore.reads, 1); @@ -237,9 +288,14 @@ void main() { await service.delete(nodeB.id, true); - expect(service.nodes.length, DefaultNodes.all.length + 2); expect( - service.nodes.where((element) => element.id == nodeB.id).length, 0); + service.nodes.length, + AppConfig.coins.map((e) => e.defaultNode).length + 2, + ); + expect( + service.nodes.where((element) => element.id == nodeB.id).length, + 0, + ); expect(fakeStore.interactions, 1); expect(fakeStore.deletes, 1); diff --git a/test/utilities/amount/amount_unit_test.dart b/test/utilities/amount/amount_unit_test.dart index 7591473b5..e4ecb33dd 100644 --- a/test/utilities/amount/amount_unit_test.dart +++ b/test/utilities/amount/amount_unit_test.dart @@ -2,7 +2,9 @@ import 'package:decimal/decimal.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:stackwallet/utilities/amount/amount.dart'; import 'package:stackwallet/utilities/amount/amount_unit.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; +import 'package:stackwallet/wallets/crypto_currency/coins/bitcoin.dart'; +import 'package:stackwallet/wallets/crypto_currency/coins/ethereum.dart'; +import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; void main() { test("displayAmount BTC", () { @@ -15,7 +17,7 @@ void main() { AmountUnit.normal.displayAmount( amount: amount, locale: "en_US", - coin: Coin.bitcoin, + coin: Bitcoin(CryptoCurrencyNetwork.main), maxDecimalPlaces: 8, ), "10.12345678 BTC", @@ -25,7 +27,7 @@ void main() { AmountUnit.milli.displayAmount( amount: amount, locale: "en_US", - coin: Coin.bitcoin, + coin: Bitcoin(CryptoCurrencyNetwork.main), maxDecimalPlaces: 8, ), "10,123.45678 mBTC", @@ -35,7 +37,7 @@ void main() { AmountUnit.micro.displayAmount( amount: amount, locale: "en_US", - coin: Coin.bitcoin, + coin: Bitcoin(CryptoCurrencyNetwork.main), maxDecimalPlaces: 8, ), "10,123,456.78 µBTC", @@ -45,7 +47,7 @@ void main() { AmountUnit.nano.displayAmount( amount: amount, locale: "en_US", - coin: Coin.bitcoin, + coin: Bitcoin(CryptoCurrencyNetwork.main), maxDecimalPlaces: 8, ), "1,012,345,678 sats", @@ -56,16 +58,18 @@ void main() { }); test("displayAmount ETH", () { + final eth = Ethereum(CryptoCurrencyNetwork.main); + final Amount amount = Amount.fromDecimal( Decimal.parse("10.123456789123456789"), - fractionDigits: Coin.ethereum.decimals, + fractionDigits: eth.fractionDigits, ); expect( AmountUnit.normal.displayAmount( amount: amount, locale: "en_US", - coin: Coin.ethereum, + coin: eth, maxDecimalPlaces: 8, ), "~10.12345678 ETH", @@ -75,7 +79,7 @@ void main() { AmountUnit.normal.displayAmount( amount: amount, locale: "en_US", - coin: Coin.ethereum, + coin: eth, maxDecimalPlaces: 4, ), "~10.1234 ETH", @@ -85,7 +89,7 @@ void main() { AmountUnit.normal.displayAmount( amount: amount, locale: "en_US", - coin: Coin.ethereum, + coin: eth, maxDecimalPlaces: 18, ), "10.123456789123456789 ETH", @@ -95,7 +99,7 @@ void main() { AmountUnit.milli.displayAmount( amount: amount, locale: "en_US", - coin: Coin.ethereum, + coin: eth, maxDecimalPlaces: 9, ), "~10,123.456789123 mETH", @@ -105,7 +109,7 @@ void main() { AmountUnit.micro.displayAmount( amount: amount, locale: "en_US", - coin: Coin.ethereum, + coin: eth, maxDecimalPlaces: 8, ), "~10,123,456.78912345 µETH", @@ -115,7 +119,7 @@ void main() { AmountUnit.nano.displayAmount( amount: amount, locale: "en_US", - coin: Coin.ethereum, + coin: eth, maxDecimalPlaces: 1, ), "~10,123,456,789.1 gwei", @@ -125,7 +129,7 @@ void main() { AmountUnit.pico.displayAmount( amount: amount, locale: "en_US", - coin: Coin.ethereum, + coin: eth, maxDecimalPlaces: 18, ), "10,123,456,789,123.456789 mwei", @@ -135,7 +139,7 @@ void main() { AmountUnit.femto.displayAmount( amount: amount, locale: "en_US", - coin: Coin.ethereum, + coin: eth, maxDecimalPlaces: 4, ), "10,123,456,789,123,456.789 kwei", @@ -145,7 +149,7 @@ void main() { AmountUnit.atto.displayAmount( amount: amount, locale: "en_US", - coin: Coin.ethereum, + coin: eth, maxDecimalPlaces: 1, ), "10,123,456,789,123,456,789 wei", @@ -153,20 +157,21 @@ void main() { }); test("parse eth string to amount", () { + final eth = Ethereum(CryptoCurrencyNetwork.main); final Amount amount = Amount.fromDecimal( Decimal.parse("10.123456789123456789"), - fractionDigits: Coin.ethereum.decimals, + fractionDigits: eth.fractionDigits, ); expect( AmountUnit.nano.tryParse( "~10,123,456,789.1 gwei", locale: "en_US", - coin: Coin.ethereum, + coin: eth, ), Amount.fromDecimal( Decimal.parse("10.1234567891"), - fractionDigits: Coin.ethereum.decimals, + fractionDigits: eth.fractionDigits, ), ); @@ -174,7 +179,7 @@ void main() { AmountUnit.atto.tryParse( "10,123,456,789,123,456,789 wei", locale: "en_US", - coin: Coin.ethereum, + coin: eth, ), amount, ); @@ -190,7 +195,7 @@ void main() { AmountUnit.normal.tryParse( "10.12345678 BTC", locale: "en_US", - coin: Coin.bitcoin, + coin: Bitcoin(CryptoCurrencyNetwork.main), ), amount, ); @@ -199,7 +204,7 @@ void main() { AmountUnit.milli.tryParse( "10,123.45678 mBTC", locale: "en_US", - coin: Coin.bitcoin, + coin: Bitcoin(CryptoCurrencyNetwork.main), ), amount, ); @@ -208,7 +213,7 @@ void main() { AmountUnit.micro.tryParse( "10,123,456.7822 µBTC", locale: "en_US", - coin: Coin.bitcoin, + coin: Bitcoin(CryptoCurrencyNetwork.main), ), amount, ); @@ -217,7 +222,7 @@ void main() { AmountUnit.nano.tryParse( "1,012,345,678 sats", locale: "en_US", - coin: Coin.bitcoin, + coin: Bitcoin(CryptoCurrencyNetwork.main), ), amount, ); diff --git a/test/widget_tests/address_book_card_test.dart b/test/widget_tests/address_book_card_test.dart index 1d38e6c95..674a259af 100644 --- a/test/widget_tests/address_book_card_test.dart +++ b/test/widget_tests/address_book_card_test.dart @@ -11,8 +11,9 @@ import 'package:stackwallet/pages/address_book_views/subviews/contact_popup.dart import 'package:stackwallet/providers/global/address_book_service_provider.dart'; import 'package:stackwallet/services/address_book_service.dart'; import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/util.dart'; +import 'package:stackwallet/wallets/crypto_currency/coins/bitcoincash.dart'; +import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; import 'package:stackwallet/widgets/address_book_card.dart'; import '../sample_data/theme_json.dart'; @@ -33,10 +34,10 @@ void main() { name: "John Doe", addresses: [ ContactAddressEntry() - ..coinName = Coin.bitcoincash.name + ..coinName = Bitcoincash(CryptoCurrencyNetwork.main).identifier ..address = "some bch address" ..label = "Bills" - ..other = null + ..other = null, ], isFavorite: true, customId: '', @@ -69,7 +70,10 @@ void main() { expect(find.text("John Doe"), findsOneWidget); expect(find.text("BCH"), findsOneWidget); - expect(find.text(Coin.bitcoincash.ticker), findsOneWidget); + expect( + find.text(Bitcoincash(CryptoCurrencyNetwork.main).ticker), + findsOneWidget, + ); if (Platform.isIOS || Platform.isAndroid) { await widgetTester.tap(find.byType(RawMaterialButton)); diff --git a/test/widget_tests/managed_favorite_test.mocks.dart b/test/widget_tests/managed_favorite_test.mocks.dart index e78909a96..ce01550b6 100644 --- a/test/widget_tests/managed_favorite_test.mocks.dart +++ b/test/widget_tests/managed_favorite_test.mocks.dart @@ -5,20 +5,19 @@ // ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:async' as _i10; import 'dart:typed_data' as _i15; -import 'dart:ui' as _i20; +import 'dart:ui' as _i19; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/db/isar/main_db.dart' as _i3; import 'package:stackwallet/models/isar/stack_theme.dart' as _i14; -import 'package:stackwallet/models/node_model.dart' as _i22; +import 'package:stackwallet/models/node_model.dart' as _i21; import 'package:stackwallet/networking/http.dart' as _i6; -import 'package:stackwallet/services/locale_service.dart' as _i21; +import 'package:stackwallet/services/locale_service.dart' as _i20; import 'package:stackwallet/services/node_service.dart' as _i2; import 'package:stackwallet/services/wallets.dart' as _i9; import 'package:stackwallet/themes/theme_service.dart' as _i13; import 'package:stackwallet/utilities/amount/amount_unit.dart' as _i18; import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i17; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i19; import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i16; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' as _i8; @@ -761,7 +760,7 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs { returnValueForMissingStub: _i10.Future.value(), ) as _i10.Future); @override - _i18.AmountUnit amountUnit(_i19.Coin? coin) => (super.noSuchMethod( + _i18.AmountUnit amountUnit(_i4.CryptoCurrency? coin) => (super.noSuchMethod( Invocation.method( #amountUnit, [coin], @@ -770,7 +769,7 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs { ) as _i18.AmountUnit); @override void updateAmountUnit({ - required _i19.Coin? coin, + required _i4.CryptoCurrency? coin, required _i18.AmountUnit? amountUnit, }) => super.noSuchMethod( @@ -785,7 +784,7 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs { returnValueForMissingStub: null, ); @override - int maxDecimals(_i19.Coin? coin) => (super.noSuchMethod( + int maxDecimals(_i4.CryptoCurrency? coin) => (super.noSuchMethod( Invocation.method( #maxDecimals, [coin], @@ -794,7 +793,7 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs { ) as int); @override void updateMaxDecimals({ - required _i19.Coin? coin, + required _i4.CryptoCurrency? coin, required int? maxDecimals, }) => super.noSuchMethod( @@ -809,7 +808,8 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs { returnValueForMissingStub: null, ); @override - _i7.FusionInfo getFusionServerInfo(_i19.Coin? coin) => (super.noSuchMethod( + _i7.FusionInfo getFusionServerInfo(_i4.CryptoCurrency? coin) => + (super.noSuchMethod( Invocation.method( #getFusionServerInfo, [coin], @@ -824,7 +824,7 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs { ) as _i7.FusionInfo); @override void setFusionServerInfo( - _i19.Coin? coin, + _i4.CryptoCurrency? coin, _i7.FusionInfo? fusionServerInfo, ) => super.noSuchMethod( @@ -838,7 +838,7 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs { returnValueForMissingStub: null, ); @override - void addListener(_i20.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -846,7 +846,7 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs { returnValueForMissingStub: null, ); @override - void removeListener(_i20.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -874,7 +874,7 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs { /// A class which mocks [LocaleService]. /// /// See the documentation for Mockito's code generation for more information. -class MockLocaleService extends _i1.Mock implements _i21.LocaleService { +class MockLocaleService extends _i1.Mock implements _i20.LocaleService { MockLocaleService() { _i1.throwOnMissingStub(this); } @@ -900,7 +900,7 @@ class MockLocaleService extends _i1.Mock implements _i21.LocaleService { returnValueForMissingStub: _i10.Future.value(), ) as _i10.Future); @override - void addListener(_i20.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -908,7 +908,7 @@ class MockLocaleService extends _i1.Mock implements _i21.LocaleService { returnValueForMissingStub: null, ); @override - void removeListener(_i20.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -946,15 +946,15 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService { ), ) as _i8.SecureStorageInterface); @override - List<_i22.NodeModel> get primaryNodes => (super.noSuchMethod( + List<_i21.NodeModel> get primaryNodes => (super.noSuchMethod( Invocation.getter(#primaryNodes), - returnValue: <_i22.NodeModel>[], - ) as List<_i22.NodeModel>); + returnValue: <_i21.NodeModel>[], + ) as List<_i21.NodeModel>); @override - List<_i22.NodeModel> get nodes => (super.noSuchMethod( + List<_i21.NodeModel> get nodes => (super.noSuchMethod( Invocation.getter(#nodes), - returnValue: <_i22.NodeModel>[], - ) as List<_i22.NodeModel>); + returnValue: <_i21.NodeModel>[], + ) as List<_i21.NodeModel>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), @@ -971,8 +971,8 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService { ) as _i10.Future); @override _i10.Future setPrimaryNodeFor({ - required _i19.Coin? coin, - required _i22.NodeModel? node, + required _i4.CryptoCurrency? coin, + required _i21.NodeModel? node, bool? shouldNotifyListeners = false, }) => (super.noSuchMethod( @@ -989,40 +989,42 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService { returnValueForMissingStub: _i10.Future.value(), ) as _i10.Future); @override - _i22.NodeModel? getPrimaryNodeFor({required _i19.Coin? coin}) => + _i21.NodeModel? getPrimaryNodeFor({required _i4.CryptoCurrency? currency}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], - {#coin: coin}, - )) as _i22.NodeModel?); + {#currency: currency}, + )) as _i21.NodeModel?); @override - List<_i22.NodeModel> getNodesFor(_i19.Coin? coin) => (super.noSuchMethod( + List<_i21.NodeModel> getNodesFor(_i4.CryptoCurrency? coin) => + (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], ), - returnValue: <_i22.NodeModel>[], - ) as List<_i22.NodeModel>); + returnValue: <_i21.NodeModel>[], + ) as List<_i21.NodeModel>); @override - _i22.NodeModel? getNodeById({required String? id}) => + _i21.NodeModel? getNodeById({required String? id}) => (super.noSuchMethod(Invocation.method( #getNodeById, [], {#id: id}, - )) as _i22.NodeModel?); + )) as _i21.NodeModel?); @override - List<_i22.NodeModel> failoverNodesFor({required _i19.Coin? coin}) => + List<_i21.NodeModel> failoverNodesFor( + {required _i4.CryptoCurrency? currency}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], - {#coin: coin}, + {#currency: currency}, ), - returnValue: <_i22.NodeModel>[], - ) as List<_i22.NodeModel>); + returnValue: <_i21.NodeModel>[], + ) as List<_i21.NodeModel>); @override _i10.Future add( - _i22.NodeModel? node, + _i21.NodeModel? node, String? password, bool? shouldNotifyListeners, ) => @@ -1074,7 +1076,7 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService { ) as _i10.Future); @override _i10.Future edit( - _i22.NodeModel? editedNode, + _i21.NodeModel? editedNode, String? password, bool? shouldNotifyListeners, ) => @@ -1100,7 +1102,7 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService { returnValueForMissingStub: _i10.Future.value(), ) as _i10.Future); @override - void addListener(_i20.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -1108,7 +1110,7 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService { returnValueForMissingStub: null, ); @override - void removeListener(_i20.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i19.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], diff --git a/test/widget_tests/node_card_test.dart b/test/widget_tests/node_card_test.dart index b8e126696..f98814b58 100644 --- a/test/widget_tests/node_card_test.dart +++ b/test/widget_tests/node_card_test.dart @@ -9,8 +9,9 @@ import 'package:stackwallet/models/node_model.dart'; import 'package:stackwallet/providers/providers.dart'; import 'package:stackwallet/services/node_service.dart'; import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/util.dart'; +import 'package:stackwallet/wallets/crypto_currency/coins/bitcoin.dart'; +import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; import 'package:stackwallet/widgets/node_card.dart'; import 'package:stackwallet/widgets/node_options_sheet.dart'; @@ -22,29 +23,37 @@ void main() { testWidgets("NodeCard builds inactive node correctly", (tester) async { final nodeService = MockNodeService(); - when(nodeService.getPrimaryNodeFor(coin: Coin.bitcoin)).thenAnswer( - (realInvocation) => NodeModel( - host: "127.0.0.1", - port: 2000, - name: "Stack Default", - id: "node id", - useSSL: true, - enabled: true, - coinName: "Bitcoin", - isFailover: false, - isDown: false)); + when( + nodeService.getPrimaryNodeFor( + currency: Bitcoin(CryptoCurrencyNetwork.main), + ), + ).thenAnswer( + (realInvocation) => NodeModel( + host: "127.0.0.1", + port: 2000, + name: "Stack Default", + id: "node id", + useSSL: true, + enabled: true, + coinName: "Bitcoin", + isFailover: false, + isDown: false, + ), + ); - when(nodeService.getNodeById(id: "node id")).thenAnswer((realInvocation) => - NodeModel( - host: "127.0.0.1", - port: 2000, - name: "some other name", - id: "node id", - useSSL: true, - enabled: true, - coinName: "Bitcoin", - isFailover: false, - isDown: false)); + when(nodeService.getNodeById(id: "node id")).thenAnswer( + (realInvocation) => NodeModel( + host: "127.0.0.1", + port: 2000, + name: "some other name", + id: "node id", + useSSL: true, + enabled: true, + coinName: "Bitcoin", + isFailover: false, + isDown: false, + ), + ); await tester.pumpWidget( ProviderScope( @@ -61,8 +70,11 @@ void main() { ), ], ), - home: const NodeCard( - nodeId: "node id", coin: Coin.bitcoin, popBackToRoute: ""), + home: NodeCard( + nodeId: "node id", + coin: Bitcoin(CryptoCurrencyNetwork.main), + popBackToRoute: "", + ), ), ), ); @@ -73,7 +85,11 @@ void main() { expect(find.text("Disconnected"), findsOneWidget); expect(find.byType(SvgPicture), findsWidgets); - verify(nodeService.getPrimaryNodeFor(coin: Coin.bitcoin)).called(1); + verify( + nodeService.getPrimaryNodeFor( + currency: Bitcoin(CryptoCurrencyNetwork.main), + ), + ).called(1); verify(nodeService.getNodeById(id: "node id")).called(1); verify(nodeService.addListener(any)).called(1); verifyNoMoreInteractions(nodeService); @@ -82,29 +98,37 @@ void main() { testWidgets("NodeCard builds active node correctly", (tester) async { final nodeService = MockNodeService(); - when(nodeService.getPrimaryNodeFor(coin: Coin.bitcoin)).thenAnswer( - (realInvocation) => NodeModel( - host: "127.0.0.1", - port: 2000, - name: "Some other node name", - id: "node id", - useSSL: true, - enabled: true, - coinName: "Bitcoin", - isFailover: false, - isDown: false)); + when( + nodeService.getPrimaryNodeFor( + currency: Bitcoin(CryptoCurrencyNetwork.main), + ), + ).thenAnswer( + (realInvocation) => NodeModel( + host: "127.0.0.1", + port: 2000, + name: "Some other node name", + id: "node id", + useSSL: true, + enabled: true, + coinName: "Bitcoin", + isFailover: false, + isDown: false, + ), + ); - when(nodeService.getNodeById(id: "node id")).thenAnswer((realInvocation) => - NodeModel( - host: "127.0.0.1", - port: 2000, - name: "Some other node name", - id: "node id", - useSSL: true, - enabled: true, - coinName: "Bitcoin", - isFailover: false, - isDown: false)); + when(nodeService.getNodeById(id: "node id")).thenAnswer( + (realInvocation) => NodeModel( + host: "127.0.0.1", + port: 2000, + name: "Some other node name", + id: "node id", + useSSL: true, + enabled: true, + coinName: "Bitcoin", + isFailover: false, + isDown: false, + ), + ); await tester.pumpWidget( ProviderScope( @@ -121,8 +145,11 @@ void main() { ), ], ), - home: const NodeCard( - nodeId: "node id", coin: Coin.bitcoin, popBackToRoute: ""), + home: NodeCard( + nodeId: "node id", + coin: Bitcoin(CryptoCurrencyNetwork.main), + popBackToRoute: "", + ), ), ), ); @@ -133,7 +160,11 @@ void main() { expect(find.byType(Text), findsNWidgets(2)); expect(find.byType(SvgPicture), findsWidgets); - verify(nodeService.getPrimaryNodeFor(coin: Coin.bitcoin)).called(1); + verify( + nodeService.getPrimaryNodeFor( + currency: Bitcoin(CryptoCurrencyNetwork.main), + ), + ).called(1); verify(nodeService.getNodeById(id: "node id")).called(1); verify(nodeService.addListener(any)).called(1); @@ -143,29 +174,37 @@ void main() { testWidgets("tap to open context menu on default node", (tester) async { final nodeService = MockNodeService(); - when(nodeService.getPrimaryNodeFor(coin: Coin.bitcoin)).thenAnswer( - (realInvocation) => NodeModel( - host: "127.0.0.1", - port: 2000, - name: "Stack Default", - id: "node id", - useSSL: true, - enabled: true, - coinName: "Bitcoin", - isFailover: false, - isDown: false)); + when( + nodeService.getPrimaryNodeFor( + currency: Bitcoin(CryptoCurrencyNetwork.main), + ), + ).thenAnswer( + (realInvocation) => NodeModel( + host: "127.0.0.1", + port: 2000, + name: "Stack Default", + id: "node id", + useSSL: true, + enabled: true, + coinName: "Bitcoin", + isFailover: false, + isDown: false, + ), + ); - when(nodeService.getNodeById(id: "node id")).thenAnswer((realInvocation) => - NodeModel( - host: "127.0.0.1", - port: 2000, - name: "Stack Default", - id: "node id", - useSSL: true, - enabled: true, - coinName: "Bitcoin", - isFailover: false, - isDown: false)); + when(nodeService.getNodeById(id: "node id")).thenAnswer( + (realInvocation) => NodeModel( + host: "127.0.0.1", + port: 2000, + name: "Stack Default", + id: "node id", + useSSL: true, + enabled: true, + coinName: "Bitcoin", + isFailover: false, + isDown: false, + ), + ); await tester.pumpWidget( ProviderScope( @@ -182,8 +221,11 @@ void main() { ), ], ), - home: const NodeCard( - nodeId: "node id", coin: Coin.bitcoin, popBackToRoute: ""), + home: NodeCard( + nodeId: "node id", + coin: Bitcoin(CryptoCurrencyNetwork.main), + popBackToRoute: "", + ), ), ), ); @@ -202,7 +244,11 @@ void main() { expect(find.text("Connect"), findsNothing); expect(find.text("Details"), findsNothing); - verify(nodeService.getPrimaryNodeFor(coin: Coin.bitcoin)).called(1); + verify( + nodeService.getPrimaryNodeFor( + currency: Bitcoin(CryptoCurrencyNetwork.main), + ), + ).called(1); verify(nodeService.getNodeById(id: "node id")).called(1); } else { expect(find.text("Connect"), findsOneWidget); @@ -210,7 +256,11 @@ void main() { expect(find.byType(NodeOptionsSheet), findsOneWidget); expect(find.byType(Text), findsNWidgets(7)); - verify(nodeService.getPrimaryNodeFor(coin: Coin.bitcoin)).called(2); + verify( + nodeService.getPrimaryNodeFor( + currency: Bitcoin(CryptoCurrencyNetwork.main), + ), + ).called(2); verify(nodeService.getNodeById(id: "node id")).called(2); } diff --git a/test/widget_tests/node_card_test.mocks.dart b/test/widget_tests/node_card_test.mocks.dart index 0b5f8128b..ec802d4e8 100644 --- a/test/widget_tests/node_card_test.mocks.dart +++ b/test/widget_tests/node_card_test.mocks.dart @@ -9,9 +9,10 @@ import 'dart:ui' as _i7; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/models/node_model.dart' as _i4; import 'package:stackwallet/services/node_service.dart' as _i3; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i6; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' as _i2; +import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart' + as _i6; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -77,7 +78,7 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { ) as _i5.Future); @override _i5.Future setPrimaryNodeFor({ - required _i6.Coin? coin, + required _i6.CryptoCurrency? coin, required _i4.NodeModel? node, bool? shouldNotifyListeners = false, }) => @@ -95,14 +96,15 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { returnValueForMissingStub: _i5.Future.value(), ) as _i5.Future); @override - _i4.NodeModel? getPrimaryNodeFor({required _i6.Coin? coin}) => + _i4.NodeModel? getPrimaryNodeFor({required _i6.CryptoCurrency? currency}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], - {#coin: coin}, + {#currency: currency}, )) as _i4.NodeModel?); @override - List<_i4.NodeModel> getNodesFor(_i6.Coin? coin) => (super.noSuchMethod( + List<_i4.NodeModel> getNodesFor(_i6.CryptoCurrency? coin) => + (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], @@ -117,12 +119,13 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { {#id: id}, )) as _i4.NodeModel?); @override - List<_i4.NodeModel> failoverNodesFor({required _i6.Coin? coin}) => + List<_i4.NodeModel> failoverNodesFor( + {required _i6.CryptoCurrency? currency}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], - {#coin: coin}, + {#currency: currency}, ), returnValue: <_i4.NodeModel>[], ) as List<_i4.NodeModel>); diff --git a/test/widget_tests/node_options_sheet_test.dart b/test/widget_tests/node_options_sheet_test.dart index a0d5690d3..94121acf2 100644 --- a/test/widget_tests/node_options_sheet_test.dart +++ b/test/widget_tests/node_options_sheet_test.dart @@ -11,8 +11,9 @@ import 'package:stackwallet/services/node_service.dart'; import 'package:stackwallet/services/tor_service.dart'; import 'package:stackwallet/services/wallets.dart'; import 'package:stackwallet/themes/stack_colors.dart'; -import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/prefs.dart'; +import 'package:stackwallet/wallets/crypto_currency/coins/bitcoin.dart'; +import 'package:stackwallet/wallets/crypto_currency/crypto_currency.dart'; import 'package:stackwallet/widgets/node_options_sheet.dart'; import '../sample_data/theme_json.dart'; @@ -37,8 +38,9 @@ void main() { isFailover: false, isDown: false)); - when(mockNodeService.getPrimaryNodeFor(coin: Coin.bitcoin)).thenAnswer( - (realInvocation) => NodeModel( + when(mockNodeService.getPrimaryNodeFor( + currency: Bitcoin(CryptoCurrencyNetwork.main))) + .thenAnswer((realInvocation) => NodeModel( host: "127.0.0.1", port: 2000, name: "Some other name", @@ -66,8 +68,10 @@ void main() { ), ], ), - home: const NodeOptionsSheet( - nodeId: "node id", coin: Coin.bitcoin, popBackToRoute: ""), + home: NodeOptionsSheet( + nodeId: "node id", + coin: Bitcoin(CryptoCurrencyNetwork.main), + popBackToRoute: ""), ), ), ); @@ -80,7 +84,9 @@ void main() { expect(find.text("Details"), findsOneWidget); expect(find.text("Connect"), findsOneWidget); - verify(mockNodeService.getPrimaryNodeFor(coin: Coin.bitcoin)).called(1); + verify(mockNodeService.getPrimaryNodeFor( + currency: Bitcoin(CryptoCurrencyNetwork.main))) + .called(1); verify(mockNodeService.getNodeById(id: "node id")).called(1); verify(mockNodeService.addListener(any)).called(1); verifyNoMoreInteractions(mockNodeService); @@ -107,7 +113,9 @@ void main() { ), ); - when(mockNodeService.getPrimaryNodeFor(coin: Coin.bitcoin)).thenAnswer( + when(mockNodeService.getPrimaryNodeFor( + currency: Bitcoin(CryptoCurrencyNetwork.main))) + .thenAnswer( (_) => NodeModel( host: "127.0.0.1", port: 2000, @@ -146,9 +154,9 @@ void main() { } return null; }, - home: const NodeOptionsSheet( + home: NodeOptionsSheet( nodeId: "node id", - coin: Coin.bitcoin, + coin: Bitcoin(CryptoCurrencyNetwork.main), popBackToRoute: "coinNodes", ), ), @@ -182,7 +190,9 @@ void main() { ), ); - when(mockNodeService.getPrimaryNodeFor(coin: Coin.bitcoin)).thenAnswer( + when(mockNodeService.getPrimaryNodeFor( + currency: Bitcoin(CryptoCurrencyNetwork.main))) + .thenAnswer( (_) => NodeModel( host: "127.0.0.1", port: 2000, @@ -214,9 +224,9 @@ void main() { ), ], ), - home: const NodeOptionsSheet( + home: NodeOptionsSheet( nodeId: "node id", - coin: Coin.bitcoin, + coin: Bitcoin(CryptoCurrencyNetwork.main), popBackToRoute: "", ), ), diff --git a/test/widget_tests/node_options_sheet_test.mocks.dart b/test/widget_tests/node_options_sheet_test.mocks.dart index 3d0a10b68..ff15b6330 100644 --- a/test/widget_tests/node_options_sheet_test.mocks.dart +++ b/test/widget_tests/node_options_sheet_test.mocks.dart @@ -5,19 +5,18 @@ // ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:async' as _i10; import 'dart:io' as _i8; -import 'dart:ui' as _i17; +import 'dart:ui' as _i16; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/db/isar/main_db.dart' as _i3; -import 'package:stackwallet/models/node_model.dart' as _i18; +import 'package:stackwallet/models/node_model.dart' as _i17; import 'package:stackwallet/services/event_bus/events/global/tor_connection_status_changed_event.dart' - as _i20; + as _i19; import 'package:stackwallet/services/node_service.dart' as _i2; -import 'package:stackwallet/services/tor_service.dart' as _i19; +import 'package:stackwallet/services/tor_service.dart' as _i18; import 'package:stackwallet/services/wallets.dart' as _i9; import 'package:stackwallet/utilities/amount/amount_unit.dart' as _i15; import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i14; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i16; import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i13; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' as _i7; @@ -28,7 +27,7 @@ import 'package:stackwallet/wallets/isar/models/wallet_info.dart' as _i11; import 'package:stackwallet/wallets/wallet/wallet.dart' as _i5; import 'package:stackwallet/wallets/wallet/wallet_mixin_interfaces/cash_fusion_interface.dart' as _i6; -import 'package:tor_ffi_plugin/tor_ffi_plugin.dart' as _i21; +import 'package:tor_ffi_plugin/tor_ffi_plugin.dart' as _i20; // ignore_for_file: type=lint // ignore_for_file: avoid_redundant_argument_values @@ -647,7 +646,7 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs { returnValueForMissingStub: _i10.Future.value(), ) as _i10.Future); @override - _i15.AmountUnit amountUnit(_i16.Coin? coin) => (super.noSuchMethod( + _i15.AmountUnit amountUnit(_i4.CryptoCurrency? coin) => (super.noSuchMethod( Invocation.method( #amountUnit, [coin], @@ -656,7 +655,7 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs { ) as _i15.AmountUnit); @override void updateAmountUnit({ - required _i16.Coin? coin, + required _i4.CryptoCurrency? coin, required _i15.AmountUnit? amountUnit, }) => super.noSuchMethod( @@ -671,7 +670,7 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs { returnValueForMissingStub: null, ); @override - int maxDecimals(_i16.Coin? coin) => (super.noSuchMethod( + int maxDecimals(_i4.CryptoCurrency? coin) => (super.noSuchMethod( Invocation.method( #maxDecimals, [coin], @@ -680,7 +679,7 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs { ) as int); @override void updateMaxDecimals({ - required _i16.Coin? coin, + required _i4.CryptoCurrency? coin, required int? maxDecimals, }) => super.noSuchMethod( @@ -695,7 +694,8 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs { returnValueForMissingStub: null, ); @override - _i6.FusionInfo getFusionServerInfo(_i16.Coin? coin) => (super.noSuchMethod( + _i6.FusionInfo getFusionServerInfo(_i4.CryptoCurrency? coin) => + (super.noSuchMethod( Invocation.method( #getFusionServerInfo, [coin], @@ -710,7 +710,7 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs { ) as _i6.FusionInfo); @override void setFusionServerInfo( - _i16.Coin? coin, + _i4.CryptoCurrency? coin, _i6.FusionInfo? fusionServerInfo, ) => super.noSuchMethod( @@ -724,7 +724,7 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs { returnValueForMissingStub: null, ); @override - void addListener(_i17.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i16.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -732,7 +732,7 @@ class MockPrefs extends _i1.Mock implements _i12.Prefs { returnValueForMissingStub: null, ); @override - void removeListener(_i17.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i16.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -774,15 +774,15 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService { ), ) as _i7.SecureStorageInterface); @override - List<_i18.NodeModel> get primaryNodes => (super.noSuchMethod( + List<_i17.NodeModel> get primaryNodes => (super.noSuchMethod( Invocation.getter(#primaryNodes), - returnValue: <_i18.NodeModel>[], - ) as List<_i18.NodeModel>); + returnValue: <_i17.NodeModel>[], + ) as List<_i17.NodeModel>); @override - List<_i18.NodeModel> get nodes => (super.noSuchMethod( + List<_i17.NodeModel> get nodes => (super.noSuchMethod( Invocation.getter(#nodes), - returnValue: <_i18.NodeModel>[], - ) as List<_i18.NodeModel>); + returnValue: <_i17.NodeModel>[], + ) as List<_i17.NodeModel>); @override bool get hasListeners => (super.noSuchMethod( Invocation.getter(#hasListeners), @@ -799,8 +799,8 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService { ) as _i10.Future); @override _i10.Future setPrimaryNodeFor({ - required _i16.Coin? coin, - required _i18.NodeModel? node, + required _i4.CryptoCurrency? coin, + required _i17.NodeModel? node, bool? shouldNotifyListeners = false, }) => (super.noSuchMethod( @@ -817,40 +817,42 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService { returnValueForMissingStub: _i10.Future.value(), ) as _i10.Future); @override - _i18.NodeModel? getPrimaryNodeFor({required _i16.Coin? coin}) => + _i17.NodeModel? getPrimaryNodeFor({required _i4.CryptoCurrency? currency}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], - {#coin: coin}, - )) as _i18.NodeModel?); + {#currency: currency}, + )) as _i17.NodeModel?); @override - List<_i18.NodeModel> getNodesFor(_i16.Coin? coin) => (super.noSuchMethod( + List<_i17.NodeModel> getNodesFor(_i4.CryptoCurrency? coin) => + (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], ), - returnValue: <_i18.NodeModel>[], - ) as List<_i18.NodeModel>); + returnValue: <_i17.NodeModel>[], + ) as List<_i17.NodeModel>); @override - _i18.NodeModel? getNodeById({required String? id}) => + _i17.NodeModel? getNodeById({required String? id}) => (super.noSuchMethod(Invocation.method( #getNodeById, [], {#id: id}, - )) as _i18.NodeModel?); + )) as _i17.NodeModel?); @override - List<_i18.NodeModel> failoverNodesFor({required _i16.Coin? coin}) => + List<_i17.NodeModel> failoverNodesFor( + {required _i4.CryptoCurrency? currency}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], - {#coin: coin}, + {#currency: currency}, ), - returnValue: <_i18.NodeModel>[], - ) as List<_i18.NodeModel>); + returnValue: <_i17.NodeModel>[], + ) as List<_i17.NodeModel>); @override _i10.Future add( - _i18.NodeModel? node, + _i17.NodeModel? node, String? password, bool? shouldNotifyListeners, ) => @@ -902,7 +904,7 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService { ) as _i10.Future); @override _i10.Future edit( - _i18.NodeModel? editedNode, + _i17.NodeModel? editedNode, String? password, bool? shouldNotifyListeners, ) => @@ -928,7 +930,7 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService { returnValueForMissingStub: _i10.Future.value(), ) as _i10.Future); @override - void addListener(_i17.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i16.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -936,7 +938,7 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService { returnValueForMissingStub: null, ); @override - void removeListener(_i17.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i16.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], @@ -964,16 +966,16 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService { /// A class which mocks [TorService]. /// /// See the documentation for Mockito's code generation for more information. -class MockTorService extends _i1.Mock implements _i19.TorService { +class MockTorService extends _i1.Mock implements _i18.TorService { MockTorService() { _i1.throwOnMissingStub(this); } @override - _i20.TorConnectionStatus get status => (super.noSuchMethod( + _i19.TorConnectionStatus get status => (super.noSuchMethod( Invocation.getter(#status), - returnValue: _i20.TorConnectionStatus.disconnected, - ) as _i20.TorConnectionStatus); + returnValue: _i19.TorConnectionStatus.disconnected, + ) as _i19.TorConnectionStatus); @override ({_i8.InternetAddress host, int port}) getProxyInfo() => (super.noSuchMethod( Invocation.method( @@ -994,7 +996,7 @@ class MockTorService extends _i1.Mock implements _i19.TorService { @override void init({ required String? torDataDirPath, - _i21.Tor? mockableOverride, + _i20.Tor? mockableOverride, }) => super.noSuchMethod( Invocation.method( diff --git a/test/widget_tests/transaction_card_test.mocks.dart b/test/widget_tests/transaction_card_test.mocks.dart index e3880f1b6..6d3d98e0f 100644 --- a/test/widget_tests/transaction_card_test.mocks.dart +++ b/test/widget_tests/transaction_card_test.mocks.dart @@ -4,28 +4,27 @@ // ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:async' as _i11; -import 'dart:typed_data' as _i25; +import 'dart:typed_data' as _i24; import 'dart:ui' as _i16; -import 'package:decimal/decimal.dart' as _i22; +import 'package:decimal/decimal.dart' as _i21; import 'package:isar/isar.dart' as _i9; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/db/isar/main_db.dart' as _i3; -import 'package:stackwallet/models/isar/models/block_explorer.dart' as _i27; +import 'package:stackwallet/models/isar/models/block_explorer.dart' as _i26; import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart' - as _i29; -import 'package:stackwallet/models/isar/models/contact_entry.dart' as _i26; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i28; -import 'package:stackwallet/models/isar/stack_theme.dart' as _i24; + as _i28; +import 'package:stackwallet/models/isar/models/contact_entry.dart' as _i25; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i27; +import 'package:stackwallet/models/isar/stack_theme.dart' as _i23; import 'package:stackwallet/networking/http.dart' as _i8; import 'package:stackwallet/services/locale_service.dart' as _i15; import 'package:stackwallet/services/node_service.dart' as _i2; -import 'package:stackwallet/services/price_service.dart' as _i21; +import 'package:stackwallet/services/price_service.dart' as _i20; import 'package:stackwallet/services/wallets.dart' as _i10; -import 'package:stackwallet/themes/theme_service.dart' as _i23; +import 'package:stackwallet/themes/theme_service.dart' as _i22; import 'package:stackwallet/utilities/amount/amount_unit.dart' as _i19; import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i18; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i20; import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i17; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' as _i13; @@ -747,7 +746,7 @@ class MockPrefs extends _i1.Mock implements _i14.Prefs { returnValueForMissingStub: _i11.Future.value(), ) as _i11.Future); @override - _i19.AmountUnit amountUnit(_i20.Coin? coin) => (super.noSuchMethod( + _i19.AmountUnit amountUnit(_i4.CryptoCurrency? coin) => (super.noSuchMethod( Invocation.method( #amountUnit, [coin], @@ -756,7 +755,7 @@ class MockPrefs extends _i1.Mock implements _i14.Prefs { ) as _i19.AmountUnit); @override void updateAmountUnit({ - required _i20.Coin? coin, + required _i4.CryptoCurrency? coin, required _i19.AmountUnit? amountUnit, }) => super.noSuchMethod( @@ -771,7 +770,7 @@ class MockPrefs extends _i1.Mock implements _i14.Prefs { returnValueForMissingStub: null, ); @override - int maxDecimals(_i20.Coin? coin) => (super.noSuchMethod( + int maxDecimals(_i4.CryptoCurrency? coin) => (super.noSuchMethod( Invocation.method( #maxDecimals, [coin], @@ -780,7 +779,7 @@ class MockPrefs extends _i1.Mock implements _i14.Prefs { ) as int); @override void updateMaxDecimals({ - required _i20.Coin? coin, + required _i4.CryptoCurrency? coin, required int? maxDecimals, }) => super.noSuchMethod( @@ -795,7 +794,8 @@ class MockPrefs extends _i1.Mock implements _i14.Prefs { returnValueForMissingStub: null, ); @override - _i6.FusionInfo getFusionServerInfo(_i20.Coin? coin) => (super.noSuchMethod( + _i6.FusionInfo getFusionServerInfo(_i4.CryptoCurrency? coin) => + (super.noSuchMethod( Invocation.method( #getFusionServerInfo, [coin], @@ -810,7 +810,7 @@ class MockPrefs extends _i1.Mock implements _i14.Prefs { ) as _i6.FusionInfo); @override void setFusionServerInfo( - _i20.Coin? coin, + _i4.CryptoCurrency? coin, _i6.FusionInfo? fusionServerInfo, ) => super.noSuchMethod( @@ -860,7 +860,7 @@ class MockPrefs extends _i1.Mock implements _i14.Prefs { /// A class which mocks [PriceService]. /// /// See the documentation for Mockito's code generation for more information. -class MockPriceService extends _i1.Mock implements _i21.PriceService { +class MockPriceService extends _i1.Mock implements _i20.PriceService { MockPriceService() { _i1.throwOnMissingStub(this); } @@ -898,35 +898,35 @@ class MockPriceService extends _i1.Mock implements _i21.PriceService { returnValue: false, ) as bool); @override - _i7.Tuple2<_i22.Decimal, double> getPrice(_i20.Coin? coin) => + _i7.Tuple2<_i21.Decimal, double> getPrice(_i4.CryptoCurrency? coin) => (super.noSuchMethod( Invocation.method( #getPrice, [coin], ), - returnValue: _FakeTuple2_5<_i22.Decimal, double>( + returnValue: _FakeTuple2_5<_i21.Decimal, double>( this, Invocation.method( #getPrice, [coin], ), ), - ) as _i7.Tuple2<_i22.Decimal, double>); + ) as _i7.Tuple2<_i21.Decimal, double>); @override - _i7.Tuple2<_i22.Decimal, double> getTokenPrice(String? contractAddress) => + _i7.Tuple2<_i21.Decimal, double> getTokenPrice(String? contractAddress) => (super.noSuchMethod( Invocation.method( #getTokenPrice, [contractAddress], ), - returnValue: _FakeTuple2_5<_i22.Decimal, double>( + returnValue: _FakeTuple2_5<_i21.Decimal, double>( this, Invocation.method( #getTokenPrice, [contractAddress], ), ), - ) as _i7.Tuple2<_i22.Decimal, double>); + ) as _i7.Tuple2<_i21.Decimal, double>); @override _i11.Future updatePrice() => (super.noSuchMethod( Invocation.method( @@ -989,7 +989,7 @@ class MockPriceService extends _i1.Mock implements _i21.PriceService { /// A class which mocks [ThemeService]. /// /// See the documentation for Mockito's code generation for more information. -class MockThemeService extends _i1.Mock implements _i23.ThemeService { +class MockThemeService extends _i1.Mock implements _i22.ThemeService { MockThemeService() { _i1.throwOnMissingStub(this); } @@ -1019,10 +1019,10 @@ class MockThemeService extends _i1.Mock implements _i23.ThemeService { ), ) as _i3.MainDB); @override - List<_i24.StackTheme> get installedThemes => (super.noSuchMethod( + List<_i23.StackTheme> get installedThemes => (super.noSuchMethod( Invocation.getter(#installedThemes), - returnValue: <_i24.StackTheme>[], - ) as List<_i24.StackTheme>); + returnValue: <_i23.StackTheme>[], + ) as List<_i23.StackTheme>); @override void init(_i3.MainDB? db) => super.noSuchMethod( Invocation.method( @@ -1032,7 +1032,7 @@ class MockThemeService extends _i1.Mock implements _i23.ThemeService { returnValueForMissingStub: null, ); @override - _i11.Future install({required _i25.Uint8List? themeArchiveData}) => + _i11.Future install({required _i24.Uint8List? themeArchiveData}) => (super.noSuchMethod( Invocation.method( #install, @@ -1072,33 +1072,33 @@ class MockThemeService extends _i1.Mock implements _i23.ThemeService { returnValue: _i11.Future.value(false), ) as _i11.Future); @override - _i11.Future> fetchThemes() => + _i11.Future> fetchThemes() => (super.noSuchMethod( Invocation.method( #fetchThemes, [], ), - returnValue: _i11.Future>.value( - <_i23.StackThemeMetaData>[]), - ) as _i11.Future>); + returnValue: _i11.Future>.value( + <_i22.StackThemeMetaData>[]), + ) as _i11.Future>); @override - _i11.Future<_i25.Uint8List> fetchTheme( - {required _i23.StackThemeMetaData? themeMetaData}) => + _i11.Future<_i24.Uint8List> fetchTheme( + {required _i22.StackThemeMetaData? themeMetaData}) => (super.noSuchMethod( Invocation.method( #fetchTheme, [], {#themeMetaData: themeMetaData}, ), - returnValue: _i11.Future<_i25.Uint8List>.value(_i25.Uint8List(0)), - ) as _i11.Future<_i25.Uint8List>); + returnValue: _i11.Future<_i24.Uint8List>.value(_i24.Uint8List(0)), + ) as _i11.Future<_i24.Uint8List>); @override - _i24.StackTheme? getTheme({required String? themeId}) => + _i23.StackTheme? getTheme({required String? themeId}) => (super.noSuchMethod(Invocation.method( #getTheme, [], {#themeId: themeId}, - )) as _i24.StackTheme?); + )) as _i23.StackTheme?); } /// A class which mocks [MainDB]. @@ -1147,13 +1147,13 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { returnValueForMissingStub: _i11.Future.value(), ) as _i11.Future); @override - List<_i26.ContactEntry> getContactEntries() => (super.noSuchMethod( + List<_i25.ContactEntry> getContactEntries() => (super.noSuchMethod( Invocation.method( #getContactEntries, [], ), - returnValue: <_i26.ContactEntry>[], - ) as List<_i26.ContactEntry>); + returnValue: <_i25.ContactEntry>[], + ) as List<_i25.ContactEntry>); @override _i11.Future deleteContactEntry({required String? id}) => (super.noSuchMethod( @@ -1175,15 +1175,15 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { returnValue: _i11.Future.value(false), ) as _i11.Future); @override - _i26.ContactEntry? getContactEntry({required String? id}) => + _i25.ContactEntry? getContactEntry({required String? id}) => (super.noSuchMethod(Invocation.method( #getContactEntry, [], {#id: id}, - )) as _i26.ContactEntry?); + )) as _i25.ContactEntry?); @override _i11.Future putContactEntry( - {required _i26.ContactEntry? contactEntry}) => + {required _i25.ContactEntry? contactEntry}) => (super.noSuchMethod( Invocation.method( #putContactEntry, @@ -1193,16 +1193,16 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { returnValue: _i11.Future.value(false), ) as _i11.Future); @override - _i27.TransactionBlockExplorer? getTransactionBlockExplorer( - {required _i20.Coin? coin}) => + _i26.TransactionBlockExplorer? getTransactionBlockExplorer( + {required _i4.CryptoCurrency? cryptoCurrency}) => (super.noSuchMethod(Invocation.method( #getTransactionBlockExplorer, [], - {#coin: coin}, - )) as _i27.TransactionBlockExplorer?); + {#cryptoCurrency: cryptoCurrency}, + )) as _i26.TransactionBlockExplorer?); @override _i11.Future putTransactionBlockExplorer( - _i27.TransactionBlockExplorer? explorer) => + _i26.TransactionBlockExplorer? explorer) => (super.noSuchMethod( Invocation.method( #putTransactionBlockExplorer, @@ -1211,13 +1211,13 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { returnValue: _i11.Future.value(0), ) as _i11.Future); @override - _i9.QueryBuilder<_i28.Address, _i28.Address, _i9.QAfterWhereClause> + _i9.QueryBuilder<_i27.Address, _i27.Address, _i9.QAfterWhereClause> getAddresses(String? walletId) => (super.noSuchMethod( Invocation.method( #getAddresses, [walletId], ), - returnValue: _FakeQueryBuilder_8<_i28.Address, _i28.Address, + returnValue: _FakeQueryBuilder_8<_i27.Address, _i27.Address, _i9.QAfterWhereClause>( this, Invocation.method( @@ -1226,9 +1226,9 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { ), ), ) as _i9 - .QueryBuilder<_i28.Address, _i28.Address, _i9.QAfterWhereClause>); + .QueryBuilder<_i27.Address, _i27.Address, _i9.QAfterWhereClause>); @override - _i11.Future putAddress(_i28.Address? address) => (super.noSuchMethod( + _i11.Future putAddress(_i27.Address? address) => (super.noSuchMethod( Invocation.method( #putAddress, [address], @@ -1236,7 +1236,7 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { returnValue: _i11.Future.value(0), ) as _i11.Future); @override - _i11.Future> putAddresses(List<_i28.Address>? addresses) => + _i11.Future> putAddresses(List<_i27.Address>? addresses) => (super.noSuchMethod( Invocation.method( #putAddresses, @@ -1245,7 +1245,7 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { returnValue: _i11.Future>.value([]), ) as _i11.Future>); @override - _i11.Future> updateOrPutAddresses(List<_i28.Address>? addresses) => + _i11.Future> updateOrPutAddresses(List<_i27.Address>? addresses) => (super.noSuchMethod( Invocation.method( #updateOrPutAddresses, @@ -1254,7 +1254,7 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { returnValue: _i11.Future>.value([]), ) as _i11.Future>); @override - _i11.Future<_i28.Address?> getAddress( + _i11.Future<_i27.Address?> getAddress( String? walletId, String? address, ) => @@ -1266,12 +1266,12 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { address, ], ), - returnValue: _i11.Future<_i28.Address?>.value(), - ) as _i11.Future<_i28.Address?>); + returnValue: _i11.Future<_i27.Address?>.value(), + ) as _i11.Future<_i27.Address?>); @override _i11.Future updateAddress( - _i28.Address? oldAddress, - _i28.Address? newAddress, + _i27.Address? oldAddress, + _i27.Address? newAddress, ) => (super.noSuchMethod( Invocation.method( @@ -1284,13 +1284,13 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { returnValue: _i11.Future.value(0), ) as _i11.Future); @override - _i9.QueryBuilder<_i28.Transaction, _i28.Transaction, _i9.QAfterWhereClause> + _i9.QueryBuilder<_i27.Transaction, _i27.Transaction, _i9.QAfterWhereClause> getTransactions(String? walletId) => (super.noSuchMethod( Invocation.method( #getTransactions, [walletId], ), - returnValue: _FakeQueryBuilder_8<_i28.Transaction, _i28.Transaction, + returnValue: _FakeQueryBuilder_8<_i27.Transaction, _i27.Transaction, _i9.QAfterWhereClause>( this, Invocation.method( @@ -1298,10 +1298,10 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { [walletId], ), ), - ) as _i9.QueryBuilder<_i28.Transaction, _i28.Transaction, + ) as _i9.QueryBuilder<_i27.Transaction, _i27.Transaction, _i9.QAfterWhereClause>); @override - _i11.Future putTransaction(_i28.Transaction? transaction) => + _i11.Future putTransaction(_i27.Transaction? transaction) => (super.noSuchMethod( Invocation.method( #putTransaction, @@ -1311,7 +1311,7 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { ) as _i11.Future); @override _i11.Future> putTransactions( - List<_i28.Transaction>? transactions) => + List<_i27.Transaction>? transactions) => (super.noSuchMethod( Invocation.method( #putTransactions, @@ -1320,7 +1320,7 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { returnValue: _i11.Future>.value([]), ) as _i11.Future>); @override - _i11.Future<_i28.Transaction?> getTransaction( + _i11.Future<_i27.Transaction?> getTransaction( String? walletId, String? txid, ) => @@ -1332,10 +1332,10 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { txid, ], ), - returnValue: _i11.Future<_i28.Transaction?>.value(), - ) as _i11.Future<_i28.Transaction?>); + returnValue: _i11.Future<_i27.Transaction?>.value(), + ) as _i11.Future<_i27.Transaction?>); @override - _i11.Stream<_i28.Transaction?> watchTransaction({ + _i11.Stream<_i27.Transaction?> watchTransaction({ required int? id, bool? fireImmediately = false, }) => @@ -1348,10 +1348,10 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { #fireImmediately: fireImmediately, }, ), - returnValue: _i11.Stream<_i28.Transaction?>.empty(), - ) as _i11.Stream<_i28.Transaction?>); + returnValue: _i11.Stream<_i27.Transaction?>.empty(), + ) as _i11.Stream<_i27.Transaction?>); @override - _i9.QueryBuilder<_i28.UTXO, _i28.UTXO, _i9.QAfterWhereClause> getUTXOs( + _i9.QueryBuilder<_i27.UTXO, _i27.UTXO, _i9.QAfterWhereClause> getUTXOs( String? walletId) => (super.noSuchMethod( Invocation.method( @@ -1359,16 +1359,16 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { [walletId], ), returnValue: - _FakeQueryBuilder_8<_i28.UTXO, _i28.UTXO, _i9.QAfterWhereClause>( + _FakeQueryBuilder_8<_i27.UTXO, _i27.UTXO, _i9.QAfterWhereClause>( this, Invocation.method( #getUTXOs, [walletId], ), ), - ) as _i9.QueryBuilder<_i28.UTXO, _i28.UTXO, _i9.QAfterWhereClause>); + ) as _i9.QueryBuilder<_i27.UTXO, _i27.UTXO, _i9.QAfterWhereClause>); @override - _i9.QueryBuilder<_i28.UTXO, _i28.UTXO, _i9.QAfterFilterCondition> + _i9.QueryBuilder<_i27.UTXO, _i27.UTXO, _i9.QAfterFilterCondition> getUTXOsByAddress( String? walletId, String? address, @@ -1381,7 +1381,7 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { address, ], ), - returnValue: _FakeQueryBuilder_8<_i28.UTXO, _i28.UTXO, + returnValue: _FakeQueryBuilder_8<_i27.UTXO, _i27.UTXO, _i9.QAfterFilterCondition>( this, Invocation.method( @@ -1393,9 +1393,9 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { ), ), ) as _i9 - .QueryBuilder<_i28.UTXO, _i28.UTXO, _i9.QAfterFilterCondition>); + .QueryBuilder<_i27.UTXO, _i27.UTXO, _i9.QAfterFilterCondition>); @override - _i11.Future putUTXO(_i28.UTXO? utxo) => (super.noSuchMethod( + _i11.Future putUTXO(_i27.UTXO? utxo) => (super.noSuchMethod( Invocation.method( #putUTXO, [utxo], @@ -1404,7 +1404,7 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { returnValueForMissingStub: _i11.Future.value(), ) as _i11.Future); @override - _i11.Future putUTXOs(List<_i28.UTXO>? utxos) => (super.noSuchMethod( + _i11.Future putUTXOs(List<_i27.UTXO>? utxos) => (super.noSuchMethod( Invocation.method( #putUTXOs, [utxos], @@ -1415,7 +1415,7 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { @override _i11.Future updateUTXOs( String? walletId, - List<_i28.UTXO>? utxos, + List<_i27.UTXO>? utxos, ) => (super.noSuchMethod( Invocation.method( @@ -1428,7 +1428,7 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { returnValue: _i11.Future.value(false), ) as _i11.Future); @override - _i11.Stream<_i28.UTXO?> watchUTXO({ + _i11.Stream<_i27.UTXO?> watchUTXO({ required int? id, bool? fireImmediately = false, }) => @@ -1441,10 +1441,10 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { #fireImmediately: fireImmediately, }, ), - returnValue: _i11.Stream<_i28.UTXO?>.empty(), - ) as _i11.Stream<_i28.UTXO?>); + returnValue: _i11.Stream<_i27.UTXO?>.empty(), + ) as _i11.Stream<_i27.UTXO?>); @override - _i9.QueryBuilder<_i28.TransactionNote, _i28.TransactionNote, + _i9.QueryBuilder<_i27.TransactionNote, _i27.TransactionNote, _i9.QAfterWhereClause> getTransactionNotes( String? walletId) => (super.noSuchMethod( @@ -1452,18 +1452,18 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { #getTransactionNotes, [walletId], ), - returnValue: _FakeQueryBuilder_8<_i28.TransactionNote, - _i28.TransactionNote, _i9.QAfterWhereClause>( + returnValue: _FakeQueryBuilder_8<_i27.TransactionNote, + _i27.TransactionNote, _i9.QAfterWhereClause>( this, Invocation.method( #getTransactionNotes, [walletId], ), ), - ) as _i9.QueryBuilder<_i28.TransactionNote, _i28.TransactionNote, + ) as _i9.QueryBuilder<_i27.TransactionNote, _i27.TransactionNote, _i9.QAfterWhereClause>); @override - _i11.Future putTransactionNote(_i28.TransactionNote? transactionNote) => + _i11.Future putTransactionNote(_i27.TransactionNote? transactionNote) => (super.noSuchMethod( Invocation.method( #putTransactionNote, @@ -1474,7 +1474,7 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { ) as _i11.Future); @override _i11.Future putTransactionNotes( - List<_i28.TransactionNote>? transactionNotes) => + List<_i27.TransactionNote>? transactionNotes) => (super.noSuchMethod( Invocation.method( #putTransactionNotes, @@ -1484,7 +1484,7 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { returnValueForMissingStub: _i11.Future.value(), ) as _i11.Future); @override - _i11.Future<_i28.TransactionNote?> getTransactionNote( + _i11.Future<_i27.TransactionNote?> getTransactionNote( String? walletId, String? txid, ) => @@ -1496,10 +1496,10 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { txid, ], ), - returnValue: _i11.Future<_i28.TransactionNote?>.value(), - ) as _i11.Future<_i28.TransactionNote?>); + returnValue: _i11.Future<_i27.TransactionNote?>.value(), + ) as _i11.Future<_i27.TransactionNote?>); @override - _i11.Stream<_i28.TransactionNote?> watchTransactionNote({ + _i11.Stream<_i27.TransactionNote?> watchTransactionNote({ required int? id, bool? fireImmediately = false, }) => @@ -1512,27 +1512,27 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { #fireImmediately: fireImmediately, }, ), - returnValue: _i11.Stream<_i28.TransactionNote?>.empty(), - ) as _i11.Stream<_i28.TransactionNote?>); + returnValue: _i11.Stream<_i27.TransactionNote?>.empty(), + ) as _i11.Stream<_i27.TransactionNote?>); @override - _i9.QueryBuilder<_i28.AddressLabel, _i28.AddressLabel, _i9.QAfterWhereClause> + _i9.QueryBuilder<_i27.AddressLabel, _i27.AddressLabel, _i9.QAfterWhereClause> getAddressLabels(String? walletId) => (super.noSuchMethod( Invocation.method( #getAddressLabels, [walletId], ), - returnValue: _FakeQueryBuilder_8<_i28.AddressLabel, - _i28.AddressLabel, _i9.QAfterWhereClause>( + returnValue: _FakeQueryBuilder_8<_i27.AddressLabel, + _i27.AddressLabel, _i9.QAfterWhereClause>( this, Invocation.method( #getAddressLabels, [walletId], ), ), - ) as _i9.QueryBuilder<_i28.AddressLabel, _i28.AddressLabel, + ) as _i9.QueryBuilder<_i27.AddressLabel, _i27.AddressLabel, _i9.QAfterWhereClause>); @override - _i11.Future putAddressLabel(_i28.AddressLabel? addressLabel) => + _i11.Future putAddressLabel(_i27.AddressLabel? addressLabel) => (super.noSuchMethod( Invocation.method( #putAddressLabel, @@ -1541,7 +1541,7 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { returnValue: _i11.Future.value(0), ) as _i11.Future); @override - int putAddressLabelSync(_i28.AddressLabel? addressLabel) => + int putAddressLabelSync(_i27.AddressLabel? addressLabel) => (super.noSuchMethod( Invocation.method( #putAddressLabelSync, @@ -1550,7 +1550,7 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { returnValue: 0, ) as int); @override - _i11.Future putAddressLabels(List<_i28.AddressLabel>? addressLabels) => + _i11.Future putAddressLabels(List<_i27.AddressLabel>? addressLabels) => (super.noSuchMethod( Invocation.method( #putAddressLabels, @@ -1560,7 +1560,7 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { returnValueForMissingStub: _i11.Future.value(), ) as _i11.Future); @override - _i11.Future<_i28.AddressLabel?> getAddressLabel( + _i11.Future<_i27.AddressLabel?> getAddressLabel( String? walletId, String? addressString, ) => @@ -1572,10 +1572,10 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { addressString, ], ), - returnValue: _i11.Future<_i28.AddressLabel?>.value(), - ) as _i11.Future<_i28.AddressLabel?>); + returnValue: _i11.Future<_i27.AddressLabel?>.value(), + ) as _i11.Future<_i27.AddressLabel?>); @override - _i28.AddressLabel? getAddressLabelSync( + _i27.AddressLabel? getAddressLabelSync( String? walletId, String? addressString, ) => @@ -1585,9 +1585,9 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { walletId, addressString, ], - )) as _i28.AddressLabel?); + )) as _i27.AddressLabel?); @override - _i11.Stream<_i28.AddressLabel?> watchAddressLabel({ + _i11.Stream<_i27.AddressLabel?> watchAddressLabel({ required int? id, bool? fireImmediately = false, }) => @@ -1600,10 +1600,10 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { #fireImmediately: fireImmediately, }, ), - returnValue: _i11.Stream<_i28.AddressLabel?>.empty(), - ) as _i11.Stream<_i28.AddressLabel?>); + returnValue: _i11.Stream<_i27.AddressLabel?>.empty(), + ) as _i11.Stream<_i27.AddressLabel?>); @override - _i11.Future updateAddressLabel(_i28.AddressLabel? addressLabel) => + _i11.Future updateAddressLabel(_i27.AddressLabel? addressLabel) => (super.noSuchMethod( Invocation.method( #updateAddressLabel, @@ -1643,7 +1643,7 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { ) as _i11.Future); @override _i11.Future addNewTransactionData( - List<_i7.Tuple2<_i28.Transaction, _i28.Address?>>? transactionsData, + List<_i7.Tuple2<_i27.Transaction, _i27.Address?>>? transactionsData, String? walletId, ) => (super.noSuchMethod( @@ -1659,7 +1659,7 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { ) as _i11.Future); @override _i11.Future> updateOrPutTransactionV2s( - List<_i29.TransactionV2>? transactions) => + List<_i28.TransactionV2>? transactions) => (super.noSuchMethod( Invocation.method( #updateOrPutTransactionV2s, @@ -1668,13 +1668,13 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { returnValue: _i11.Future>.value([]), ) as _i11.Future>); @override - _i9.QueryBuilder<_i28.EthContract, _i28.EthContract, _i9.QWhere> + _i9.QueryBuilder<_i27.EthContract, _i27.EthContract, _i9.QWhere> getEthContracts() => (super.noSuchMethod( Invocation.method( #getEthContracts, [], ), - returnValue: _FakeQueryBuilder_8<_i28.EthContract, _i28.EthContract, + returnValue: _FakeQueryBuilder_8<_i27.EthContract, _i27.EthContract, _i9.QWhere>( this, Invocation.method( @@ -1683,24 +1683,24 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { ), ), ) as _i9 - .QueryBuilder<_i28.EthContract, _i28.EthContract, _i9.QWhere>); + .QueryBuilder<_i27.EthContract, _i27.EthContract, _i9.QWhere>); @override - _i11.Future<_i28.EthContract?> getEthContract(String? contractAddress) => + _i11.Future<_i27.EthContract?> getEthContract(String? contractAddress) => (super.noSuchMethod( Invocation.method( #getEthContract, [contractAddress], ), - returnValue: _i11.Future<_i28.EthContract?>.value(), - ) as _i11.Future<_i28.EthContract?>); + returnValue: _i11.Future<_i27.EthContract?>.value(), + ) as _i11.Future<_i27.EthContract?>); @override - _i28.EthContract? getEthContractSync(String? contractAddress) => + _i27.EthContract? getEthContractSync(String? contractAddress) => (super.noSuchMethod(Invocation.method( #getEthContractSync, [contractAddress], - )) as _i28.EthContract?); + )) as _i27.EthContract?); @override - _i11.Future putEthContract(_i28.EthContract? contract) => + _i11.Future putEthContract(_i27.EthContract? contract) => (super.noSuchMethod( Invocation.method( #putEthContract, @@ -1709,7 +1709,7 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { returnValue: _i11.Future.value(0), ) as _i11.Future); @override - _i11.Future putEthContracts(List<_i28.EthContract>? contracts) => + _i11.Future putEthContracts(List<_i27.EthContract>? contracts) => (super.noSuchMethod( Invocation.method( #putEthContracts, @@ -1733,7 +1733,7 @@ class MockMainDB extends _i1.Mock implements _i3.MainDB { /// A class which mocks [IThemeAssets]. /// /// See the documentation for Mockito's code generation for more information. -class MockIThemeAssets extends _i1.Mock implements _i24.IThemeAssets { +class MockIThemeAssets extends _i1.Mock implements _i23.IThemeAssets { MockIThemeAssets() { _i1.throwOnMissingStub(this); } diff --git a/test/widget_tests/wallet_info_row/sub_widgets/wallet_info_row_balance_future_test.mocks.dart b/test/widget_tests/wallet_info_row/sub_widgets/wallet_info_row_balance_future_test.mocks.dart index e02c41ec5..b94f2e713 100644 --- a/test/widget_tests/wallet_info_row/sub_widgets/wallet_info_row_balance_future_test.mocks.dart +++ b/test/widget_tests/wallet_info_row/sub_widgets/wallet_info_row_balance_future_test.mocks.dart @@ -4,14 +4,13 @@ // ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:async' as _i8; -import 'dart:ui' as _i13; +import 'dart:ui' as _i12; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/db/isar/main_db.dart' as _i3; import 'package:stackwallet/models/node_model.dart' as _i11; import 'package:stackwallet/services/node_service.dart' as _i2; import 'package:stackwallet/services/wallets.dart' as _i7; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i12; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' as _i6; import 'package:stackwallet/utilities/prefs.dart' as _i10; @@ -231,7 +230,7 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService { ) as _i8.Future); @override _i8.Future setPrimaryNodeFor({ - required _i12.Coin? coin, + required _i4.CryptoCurrency? coin, required _i11.NodeModel? node, bool? shouldNotifyListeners = false, }) => @@ -249,14 +248,15 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService { returnValueForMissingStub: _i8.Future.value(), ) as _i8.Future); @override - _i11.NodeModel? getPrimaryNodeFor({required _i12.Coin? coin}) => + _i11.NodeModel? getPrimaryNodeFor({required _i4.CryptoCurrency? currency}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], - {#coin: coin}, + {#currency: currency}, )) as _i11.NodeModel?); @override - List<_i11.NodeModel> getNodesFor(_i12.Coin? coin) => (super.noSuchMethod( + List<_i11.NodeModel> getNodesFor(_i4.CryptoCurrency? coin) => + (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], @@ -271,12 +271,13 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService { {#id: id}, )) as _i11.NodeModel?); @override - List<_i11.NodeModel> failoverNodesFor({required _i12.Coin? coin}) => + List<_i11.NodeModel> failoverNodesFor( + {required _i4.CryptoCurrency? currency}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], - {#coin: coin}, + {#currency: currency}, ), returnValue: <_i11.NodeModel>[], ) as List<_i11.NodeModel>); @@ -360,7 +361,7 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService { returnValueForMissingStub: _i8.Future.value(), ) as _i8.Future); @override - void addListener(_i13.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i12.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -368,7 +369,7 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService { returnValueForMissingStub: null, ); @override - void removeListener(_i13.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i12.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener], diff --git a/test/widget_tests/wallet_info_row/wallet_info_row_test.mocks.dart b/test/widget_tests/wallet_info_row/wallet_info_row_test.mocks.dart index eec63a4fd..9c90bcdcd 100644 --- a/test/widget_tests/wallet_info_row/wallet_info_row_test.mocks.dart +++ b/test/widget_tests/wallet_info_row/wallet_info_row_test.mocks.dart @@ -5,7 +5,7 @@ // ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:async' as _i9; import 'dart:typed_data' as _i14; -import 'dart:ui' as _i17; +import 'dart:ui' as _i16; import 'package:mockito/mockito.dart' as _i1; import 'package:stackwallet/db/isar/main_db.dart' as _i3; @@ -15,7 +15,6 @@ import 'package:stackwallet/networking/http.dart' as _i6; import 'package:stackwallet/services/node_service.dart' as _i2; import 'package:stackwallet/services/wallets.dart' as _i8; import 'package:stackwallet/themes/theme_service.dart' as _i12; -import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i16; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' as _i7; import 'package:stackwallet/utilities/prefs.dart' as _i11; @@ -360,7 +359,7 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService { ) as _i9.Future); @override _i9.Future setPrimaryNodeFor({ - required _i16.Coin? coin, + required _i4.CryptoCurrency? coin, required _i15.NodeModel? node, bool? shouldNotifyListeners = false, }) => @@ -378,14 +377,15 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService { returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); @override - _i15.NodeModel? getPrimaryNodeFor({required _i16.Coin? coin}) => + _i15.NodeModel? getPrimaryNodeFor({required _i4.CryptoCurrency? currency}) => (super.noSuchMethod(Invocation.method( #getPrimaryNodeFor, [], - {#coin: coin}, + {#currency: currency}, )) as _i15.NodeModel?); @override - List<_i15.NodeModel> getNodesFor(_i16.Coin? coin) => (super.noSuchMethod( + List<_i15.NodeModel> getNodesFor(_i4.CryptoCurrency? coin) => + (super.noSuchMethod( Invocation.method( #getNodesFor, [coin], @@ -400,12 +400,13 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService { {#id: id}, )) as _i15.NodeModel?); @override - List<_i15.NodeModel> failoverNodesFor({required _i16.Coin? coin}) => + List<_i15.NodeModel> failoverNodesFor( + {required _i4.CryptoCurrency? currency}) => (super.noSuchMethod( Invocation.method( #failoverNodesFor, [], - {#coin: coin}, + {#currency: currency}, ), returnValue: <_i15.NodeModel>[], ) as List<_i15.NodeModel>); @@ -489,7 +490,7 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService { returnValueForMissingStub: _i9.Future.value(), ) as _i9.Future); @override - void addListener(_i17.VoidCallback? listener) => super.noSuchMethod( + void addListener(_i16.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #addListener, [listener], @@ -497,7 +498,7 @@ class MockNodeService extends _i1.Mock implements _i2.NodeService { returnValueForMissingStub: null, ); @override - void removeListener(_i17.VoidCallback? listener) => super.noSuchMethod( + void removeListener(_i16.VoidCallback? listener) => super.noSuchMethod( Invocation.method( #removeListener, [listener],