From b30ccf13da201a5f49c719c041fe5fda52a1eeca Mon Sep 17 00:00:00 2001 From: Eduardo Menges Mattje Date: Wed, 1 Oct 2025 14:08:51 -0300 Subject: [PATCH 1/6] Removed unused files --- lib/components/wallet_agreement.g.dart | 87 ----------- .../wallet_button/type_type2.g.dart | 66 -------- lib/web/web_view_linux.dart | 146 ------------------ lib/web/web_view_screen.dart | 4 - 4 files changed, 303 deletions(-) delete mode 100644 lib/components/wallet_agreement.g.dart delete mode 100644 lib/components/wallet_button/type_type2.g.dart delete mode 100644 lib/web/web_view_linux.dart diff --git a/lib/components/wallet_agreement.g.dart b/lib/components/wallet_agreement.g.dart deleted file mode 100644 index 70fccdfd..00000000 --- a/lib/components/wallet_agreement.g.dart +++ /dev/null @@ -1,87 +0,0 @@ -// ********************************************************************************* -// PARABEAC-GENERATED CODE. DO NOT MODIFY. -// -// FOR MORE INFORMATION ON HOW TO USE PARABEAC, PLEASE VISIT docs.parabeac.com -// ********************************************************************************* - -import 'package:flutter/material.dart'; -import 'package:genius_wallet/components/custom/wallet_agreement_custom.dart'; -import 'package:auto_size_text/auto_size_text.dart'; - -class WalletAgreement extends StatefulWidget { - final BoxConstraints constraints; - final String? ovrIvereadandaccepttheTermsofServiceandPrivacyPolicy; - const WalletAgreement( - this.constraints, { - Key? key, - this.ovrIvereadandaccepttheTermsofServiceandPrivacyPolicy, - }) : super(key: key); - @override - _WalletAgreement createState() => _WalletAgreement(); -} - -class _WalletAgreement extends State { - _WalletAgreement(); - - @override - Widget build(BuildContext context) { - return Container( - decoration: BoxDecoration(), - child: WalletAgreementCustom( - child: Stack(children: [ - Positioned( - left: 0, - width: widget.constraints.maxWidth * 1.0, - top: 0, - height: widget.constraints.maxHeight * 1.0, - child: Stack(children: [ - Positioned( - left: 29.0, - right: 2.0, - top: 0, - height: 34.0, - child: Container( - height: 34.0, - width: widget.constraints.maxWidth * 0.9051987767584098, - child: AutoSizeText( - widget.ovrIvereadandaccepttheTermsofServiceandPrivacyPolicy ?? - 'I’ve read and accept the Terms of Service and Privacy Policy', - style: TextStyle( - fontFamily: 'Roboto', - fontSize: 12.0, - fontWeight: FontWeight.w400, - letterSpacing: 0.0, - color: Colors.white, - ), - textAlign: TextAlign.left, - )), - ), - Positioned( - left: 0, - width: 14.0, - top: widget.constraints.maxHeight * 0.294, - height: widget.constraints.maxHeight * 0.412, - child: Center( - child: Container( - height: 14.0, - width: 14.0, - decoration: BoxDecoration( - color: Color(0xff18191d), - borderRadius: BorderRadius.all(Radius.circular(1.0)), - border: Border.all( - color: Color(0xff0068ef), - width: 1.0, - ), - ), - )), - ), - ]), - ), - ]))); - } - - @override - void dispose() { - super.dispose(); - } -} diff --git a/lib/components/wallet_button/type_type2.g.dart b/lib/components/wallet_button/type_type2.g.dart deleted file mode 100644 index d3f4768c..00000000 --- a/lib/components/wallet_button/type_type2.g.dart +++ /dev/null @@ -1,66 +0,0 @@ -// ********************************************************************************* -// PARABEAC-GENERATED CODE. DO NOT MODIFY. -// -// FOR MORE INFORMATION ON HOW TO USE PARABEAC, PLEASE VISIT docs.parabeac.com -// ********************************************************************************* - -import 'package:flutter/material.dart'; -import 'package:genius_wallet/components/custom/type_type2_custom.dart'; -import 'package:auto_size_text/auto_size_text.dart'; - -class TypeType2 extends StatefulWidget { - final BoxConstraints constraints; - final String? ovrIalreadyhaveawallet; - const TypeType2( - this.constraints, { - Key? key, - this.ovrIalreadyhaveawallet, - }) : super(key: key); - @override - _TypeType2 createState() => _TypeType2(); -} - -class _TypeType2 extends State { - _TypeType2(); - - @override - Widget build(BuildContext context) { - return Container( - decoration: BoxDecoration( - border: Border.all( - color: Color(0xff0068ef), - width: 1.0, - ), - ), - child: TypeType2Custom( - child: Stack(children: [ - Positioned( - left: widget.constraints.maxWidth * 0.324, - width: widget.constraints.maxWidth * 0.352, - top: 17.0, - height: 13.0, - child: Center( - child: Container( - height: 13.0, - width: 111.0, - child: AutoSizeText( - widget.ovrIalreadyhaveawallet ?? - 'I already have a wallet', - style: TextStyle( - fontFamily: 'Roboto', - fontSize: 11.0, - fontWeight: FontWeight.w400, - letterSpacing: 0.13750000298023224, - color: Colors.white, - ), - textAlign: TextAlign.center, - ))), - ), - ]))); - } - - @override - void dispose() { - super.dispose(); - } -} diff --git a/lib/web/web_view_linux.dart b/lib/web/web_view_linux.dart deleted file mode 100644 index 9f5b2961..00000000 --- a/lib/web/web_view_linux.dart +++ /dev/null @@ -1,146 +0,0 @@ -/// * We are not using this as of now there will be no native support for the wallet for linux - -// import 'package:flutter/material.dart'; -// import 'package:desktop_webview_window/desktop_webview_window.dart'; -// import 'package:genius_wallet/theme/genius_wallet_colors.dart'; - -// class WebViewLinux extends StatefulWidget { -// final String url; - -// const WebViewLinux({Key? key, required this.url}) : super(key: key); - -// @override -// WebViewLinuxState createState() => WebViewLinuxState(); -// } - -// class WebViewLinuxState extends State { -// Webview? _webView; -// final TextEditingController _urlController = TextEditingController(); - -// @override -// void initState() { -// super.initState(); -// _initializeLinuxWebView(widget.url); -// } - -// /// **Initialize or Relaunch WebView** -// Future _initializeLinuxWebView(String url) async { -// if (_webView == null) { -// _webView = await WebviewWindow.create(); -// _webView?.onClose.whenComplete(() { -// _webView = null; // Reset WebView when closed -// }); -// } -// _webView?.launch(url); -// _urlController.text = url; - -// // Listen for URL changes & update search bar -// _webView?.addOnUrlRequestCallback((newUrl) { -// setState(() { -// _urlController.text = newUrl; -// }); -// }); -// } - -// /// **Load a new URL and relaunch if necessary** -// void _loadUrl() { -// String url = _urlController.text.trim(); -// if (url.isNotEmpty && !url.startsWith("http")) { -// url = "https://$url"; -// } - -// if (_webView == null) { -// _initializeLinuxWebView(url); // Relaunch if closed -// } else { -// _webView?.launch(url); -// } -// } - -// @override -// void dispose() { -// _webView?.close(); -// super.dispose(); -// } - -// @override -// Widget build(BuildContext context) { -// return Scaffold( -// backgroundColor: -// GeniusWalletColors.deepBlueTertiary, // Dark blue background -// body: Column( -// children: [ -// const SizedBox(height: 8), // Space at the top -// _buildSearchBar(), // Search bar -// const Expanded( -// child: Center( -// child: Text( -// "Browser Launched in Separate Window...", -// style: TextStyle(fontSize: 16, color: Colors.white70), -// ), -// ), -// ), -// ], -// ), -// ); -// } - -// /// **Search Bar with Navigation Buttons** -// Widget _buildSearchBar() { -// return Padding( -// padding: const EdgeInsets.symmetric( -// horizontal: 20, vertical: 10), // Padding outside search bar -// child: Container( -// padding: const EdgeInsets.symmetric( -// horizontal: 10, vertical: 8), // Padding inside search bar -// decoration: BoxDecoration( -// color: GeniusWalletColors.deepBlueCardColor, // Search bar background -// borderRadius: BorderRadius.circular(20), -// ), -// child: Row( -// mainAxisAlignment: MainAxisAlignment.center, -// children: [ -// _buildIconButton(Icons.arrow_back, () { -// _webView?.back(); -// }), -// _buildIconButton(Icons.arrow_forward, () { -// _webView?.forward(); -// }), -// _buildIconButton(Icons.refresh, () { -// _webView?.launch(_urlController.text); // Reload URL -// }), -// const SizedBox(width: 8), -// Expanded( -// child: TextField( -// controller: _urlController, -// style: -// const TextStyle(color: Colors.white), // White text in input -// decoration: InputDecoration( -// hintText: "Enter URL...", -// hintStyle: const TextStyle(color: Colors.white70), -// filled: true, -// fillColor: GeniusWalletColors -// .deepBlueTertiary, // Darker blue input background -// border: OutlineInputBorder( -// borderRadius: BorderRadius.circular(10), -// borderSide: BorderSide.none, -// ), -// ), -// onSubmitted: (_) => _loadUrl(), -// ), -// ), -// ], -// ), -// ), -// ); -// } - -// /// **Reusable Icon Button** -// Widget _buildIconButton(IconData icon, VoidCallback onPressed) { -// return IconButton( -// icon: Icon(icon), -// color: GeniusWalletColors.lightGreenPrimary, // Default color -// iconSize: 24, // Standard icon size -// onPressed: onPressed, -// ); -// } -// } diff --git a/lib/web/web_view_screen.dart b/lib/web/web_view_screen.dart index e43c83b8..d60f91f3 100644 --- a/lib/web/web_view_screen.dart +++ b/lib/web/web_view_screen.dart @@ -2,7 +2,6 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'web_view_mobile.dart'; import 'web_view_windows.dart'; -//import 'web_view_linux.dart'; class WebViewScreen extends StatelessWidget { final String? url; @@ -18,9 +17,6 @@ class WebViewScreen extends StatelessWidget { url: url ?? "https://www.duckduckgo.com", includeBackButton: includeBackButton); } - //else if (Platform.isLinux) { - //return WebViewLinux(url: url ?? "https://www.duckduckgo.com"); - //} else { return WebViewMobile( url: url ?? "https://www.duckduckgo.com", From ad5ab6f22ea3e2b792dbb69064502000a62abe44 Mon Sep 17 00:00:00 2001 From: Eduardo Menges Mattje Date: Wed, 1 Oct 2025 14:57:13 -0300 Subject: [PATCH 2/6] Cleaned CMake files --- cmake/CommonBuildParameters.cmake | 124 ++++++++---------------------- cmake/CommonCompilerOptions.cmake | 104 ++++++++++++------------- 2 files changed, 82 insertions(+), 146 deletions(-) diff --git a/cmake/CommonBuildParameters.cmake b/cmake/CommonBuildParameters.cmake index ef86c4b8..11e4a32e 100755 --- a/cmake/CommonBuildParameters.cmake +++ b/cmake/CommonBuildParameters.cmake @@ -34,8 +34,6 @@ if(NOT CMAKE_SKIP_THIRD_PARTY) set(WALLET_CORE_TREZOR_CRYPTO_LIBRARY ${WALLET_CORE_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}TrezorCrypto${CMAKE_STATIC_LIBRARY_SUFFIX} CACHE PATH "Path to TrezorCrypto lib") set(WALLET_CORE_RUST_LIBRARY ${WALLET_CORE_LIB_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}wallet_core_rs${CMAKE_STATIC_LIBRARY_SUFFIX} CACHE PATH "Path to WalletCore rust lib") - #message(FATAL_ERROR "${WALLET_CORE_RUST_LIBRARY}") - include_directories(${WALLET_CORE_INCLUDE_DIR}) add_library(TrustWalletCore STATIC IMPORTED) set_target_properties(TrustWalletCore PROPERTIES IMPORTED_LOCATION ${WALLET_CORE_LIBRARY}) add_library(wallet_core_rs STATIC IMPORTED) @@ -61,8 +59,7 @@ if(NOT CMAKE_SKIP_THIRD_PARTY) set(utf8_range_DIR "${THIRDPARTY_BUILD_DIR}/grpc/lib/cmake/utf8_range") endif() - # -------------------------------------------------------- - # Set config of protobuf project + # protobuf project if(NOT DEFINED Protobuf_DIR) if (NOT DEFINED PROTOBUF_CONFIG_LOCATION) set(PROTOBUF_CONFIG_LOCATION "/grpc/lib/cmake/protobuf") @@ -84,15 +81,12 @@ if(NOT CMAKE_SKIP_THIRD_PARTY) set(OPENSSL_CRYPTO_LIBRARY ${OPENSSL_LIBRARIES}/libcrypto${CMAKE_STATIC_LIBRARY_SUFFIX} CACHE PATH "Path to OpenSSL crypto lib") set(OPENSSL_SSL_LIBRARY ${OPENSSL_LIBRARIES}/libssl${CMAKE_STATIC_LIBRARY_SUFFIX} CACHE PATH "Path to OpenSSL ssl lib") find_package(OpenSSL REQUIRED) - include_directories(${OPENSSL_INCLUDE_DIR}) - # -------------------------------------------------------- - # Set config of rocksdb + # rocksdb message(STATUS "ROCKSDB ${THIRDPARTY_BUILD_DIR}") set(RocksDB_DIR "${THIRDPARTY_BUILD_DIR}/rocksdb/lib/cmake/rocksdb") set(RocksDB_INCLUDE_DIR "${THIRDPARTY_BUILD_DIR}/rocksdb/include") find_package(RocksDB CONFIG REQUIRED) - include_directories(${RocksDB_INCLUDE_DIR}) #Find VUlkan if(APPLE) @@ -115,67 +109,52 @@ if(NOT CMAKE_SKIP_THIRD_PARTY) find_package(Vulkan REQUIRED) endif() - # Set config of MNN + + # MNN set(MNN_INCLUDE_DIR "${THIRDPARTY_BUILD_DIR}/MNN/include") set(MNN_DIR "${THIRDPARTY_BUILD_DIR}/MNN/lib/cmake/MNN") find_package(MNN CONFIG REQUIRED) include_directories(${MNN_INCLUDE_DIR}) - # -------------------------------------------------------- - # Set config of stb + # stb include_directories(${THIRDPARTY_BUILD_DIR}/stb/include) - # -------------------------------------------------------- - # Set config of Microsoft.GSL + # Microsoft.GSL set(GSL_INCLUDE_DIR "${THIRDPARTY_BUILD_DIR}/Microsoft.GSL/include") - include_directories(${GSL_INCLUDE_DIR}) - # -------------------------------------------------------- - # Set config of fmt + # fmt set(fmt_DIR "${THIRDPARTY_BUILD_DIR}/fmt/lib/cmake/fmt") set(fmt_INCLUDE_DIR "${THIRDPARTY_BUILD_DIR}/fmt/include") find_package(fmt CONFIG REQUIRED) - include_directories(${fmt_INCLUDE_DIR}) - # -------------------------------------------------------- - # Set config of spdlog v1.4.2 + # spdlog v1.4.2 set(spdlog_DIR "${THIRDPARTY_BUILD_DIR}/spdlog/lib/cmake/spdlog") set(spdlog_INCLUDE_DIR "${THIRDPARTY_BUILD_DIR}/spdlog/include") find_package(spdlog CONFIG REQUIRED) - include_directories(${spdlog_INCLUDE_DIR}) add_compile_definitions("SPDLOG_FMT_EXTERNAL") - # -------------------------------------------------------- - # Set config of soralog + # soralog set(soralog_DIR "${THIRDPARTY_BUILD_DIR}/soralog/lib/cmake/soralog") set(soralog_INCLUDE_DIR "${THIRDPARTY_BUILD_DIR}/soralog/include") find_package(soralog CONFIG REQUIRED) - include_directories(${soralog_INCLUDE_DIR}) - # -------------------------------------------------------- - # Set config of yaml-cpp + # yaml-cpp set(yaml-cpp_DIR "${THIRDPARTY_BUILD_DIR}/yaml-cpp/lib/cmake/yaml-cpp") set(yaml-cpp_INCLUDE_DIR "${THIRDPARTY_BUILD_DIR}/yaml-cpp/include") find_package(yaml-cpp CONFIG REQUIRED) - include_directories(${yaml-cpp_INCLUDE_DIR}) - # -------------------------------------------------------- - # Set config of tsl_hat_trie + # tsl_hat_trie set(tsl_hat_trie_DIR "${THIRDPARTY_BUILD_DIR}/tsl_hat_trie/lib/cmake/tsl_hat_trie") set(tsl_hat_trie_INCLUDE_DIR "${THIRDPARTY_BUILD_DIR}/tsl_hat_trie/include") find_package(tsl_hat_trie CONFIG REQUIRED) - include_directories(${tsl_hat_trie_INCLUDE_DIR}) - # -------------------------------------------------------- - # Set config of Boost.DI + # Boost.DI set(Boost.DI_INCLUDE_DIR "${THIRDPARTY_BUILD_DIR}/Boost.DI/include") set(Boost.DI_DIR "${THIRDPARTY_BUILD_DIR}/Boost.DI/lib/cmake/Boost.DI") find_package(Boost.DI CONFIG REQUIRED) - include_directories(${Boost.DI_INCLUDE_DIR}) # Boost should be loaded before libp2p v0.1.2 - # -------------------------------------------------------- - # Set config of Boost project + # Boost project set(_BOOST_ROOT "${THIRDPARTY_BUILD_DIR}/boost/build") message(STATUS "BOOST ROOT ${_BOOST_ROOT}") set(Boost_LIB_DIR "${_BOOST_ROOT}/lib") @@ -217,128 +196,97 @@ if(NOT CMAKE_SKIP_THIRD_PARTY) # header only libraries must not be added here find_package(Boost REQUIRED COMPONENTS date_time filesystem random regex system thread log log_setup program_options unit_test_framework json) - include_directories(${Boost_INCLUDE_DIRS}) - # -------------------------------------------------------- - # Set config of SQLiteModernCpp project + # SQLiteModernCpp project set(SQLiteModernCpp_ROOT_DIR "${THIRDPARTY_BUILD_DIR}/SQLiteModernCpp") set(SQLiteModernCpp_DIR "${SQLiteModernCpp_ROOT_DIR}/lib/cmake/SQLiteModernCpp") set(SQLiteModernCpp_LIB_DIR "${SQLiteModernCpp_ROOT_DIR}/lib") set(SQLiteModernCpp_INCLUDE_DIR "${SQLiteModernCpp_ROOT_DIR}/include") - # -------------------------------------------------------- - # Set config of SQLiteModernCpp project + # SQLiteModernCpp project set(sqlite3_ROOT_DIR "${THIRDPARTY_BUILD_DIR}/sqlite3") set(sqlite3_DIR "${sqlite3_ROOT_DIR}/lib/cmake/sqlite3") set(sqlite3_LIB_DIR "${sqlite3_ROOT_DIR}/lib") set(sqlite3_INCLUDE_DIR "${sqlite3_ROOT_DIR}/include") - # -------------------------------------------------------- - # Set config of cares + # cares set(c-ares_DIR "${THIRDPARTY_BUILD_DIR}/cares/lib/cmake/c-ares" CACHE PATH "Path to c-ares install folder") set(c-ares_INCLUDE_DIR "${THIRDPARTY_BUILD_DIR}/cares/include" CACHE PATH "Path to c-ares include folder") - # -------------------------------------------------------- - # Set config of libp2p + # libp2p set(libp2p_DIR "${THIRDPARTY_BUILD_DIR}/libp2p/lib/cmake/libp2p") set(libp2p_LIBRARY_DIR "${THIRDPARTY_BUILD_DIR}/libp2p/lib") set(libp2p_INCLUDE_DIR "${THIRDPARTY_BUILD_DIR}/libp2p/include") find_package(libp2p CONFIG REQUIRED) - include_directories(${libp2p_INCLUDE_DIR}) - # -------------------------------------------------------- # Find and include cares if libp2p have not included it if(NOT TARGET c-ares::cares_static) find_package(c-ares CONFIG REQUIRED) endif() - include_directories(${c-ares_INCLUDE_DIR}) - - # -------------------------------------------------------- - # Set config of ipfs-lite-cpp + # ipfs-lite-cpp set(ipfs-lite-cpp_DIR "${THIRDPARTY_BUILD_DIR}/ipfs-lite-cpp/lib/cmake/ipfs-lite-cpp") set(ipfs-lite-cpp_INCLUDE_DIR "${THIRDPARTY_BUILD_DIR}/ipfs-lite-cpp/include") set(ipfs-lite-cpp_LIB_DIR "${THIRDPARTY_BUILD_DIR}/ipfs-lite-cpp/lib") set(CBOR_INCLUDE_DIR "${THIRDPARTY_BUILD_DIR}/ipfs-lite-cpp/include/deps/tinycbor/src") find_package(ipfs-lite-cpp CONFIG REQUIRED) - include_directories(${ipfs-lite-cpp_INCLUDE_DIR} ${CBOR_INCLUDE_DIR}) - # -------------------------------------------------------- - # Set config of ipfs-pubsub + # ipfs-pubsub set(ipfs-pubsub_INCLUDE_DIR "${THIRDPARTY_BUILD_DIR}/ipfs-pubsub/include") set(ipfs-pubsub_DIR "${THIRDPARTY_BUILD_DIR}/ipfs-pubsub/lib/cmake/ipfs-pubsub") find_package(ipfs-pubsub CONFIG REQUIRED) - include_directories(${ipfs-pubsub_INCLUDE_DIR}) - # -------------------------------------------------------- - # Set config of ipfs-bitswap-cpp + # ipfs-bitswap-cpp set(ipfs-bitswap-cpp_INCLUDE_DIR "${THIRDPARTY_BUILD_DIR}/ipfs-bitswap-cpp/include") set(ipfs-bitswap-cpp_DIR "${THIRDPARTY_BUILD_DIR}/ipfs-bitswap-cpp/lib/cmake/ipfs-bitswap-cpp") find_package(ipfs-bitswap-cpp CONFIG REQUIRED) - include_directories(${ipfs-bitswap-cpp_INCLUDE_DIR}) - # -------------------------------------------------------- - # Set config of ed25519 + # ed25519 set(ed25519_DIR "${THIRDPARTY_BUILD_DIR}/ed25519/lib/cmake/ed25519") set(ed25519_INCLUDE_DIR "${THIRDPARTY_BUILD_DIR}/ed25519/include") find_package(ed25519 CONFIG REQUIRED) - include_directories(${ed25519_INCLUDE_DIR}) - # -------------------------------------------------------- - # Set config of sr25519-donna + # sr25519-donna set(sr25519-donna_DIR "${THIRDPARTY_BUILD_DIR}/sr25519-donna/lib/cmake/sr25519-donna") set(sr25519-donna_INCLUDE_DIR "${THIRDPARTY_BUILD_DIR}/sr25519-donna/include") find_package(sr25519-donna CONFIG REQUIRED) - include_directories(${sr25519-donna_INCLUDE_DIR}) - # -------------------------------------------------------- # Set RapidJSON config path set(RapidJSON_DIR "${THIRDPARTY_BUILD_DIR}/rapidjson/lib/cmake/RapidJSON") set(RapidJSON_INCLUDE_DIR "${THIRDPARTY_BUILD_DIR}/rapidjson/include") find_package(RapidJSON CONFIG REQUIRED) - include_directories(${RapidJSON_INCLUDE_DIR}) - # -------------------------------------------------------- - # Set config of secp256k1 + # secp256k1 set(libsecp256k1_INCLUDE_DIR "${THIRDPARTY_BUILD_DIR}/libsecp256k1/include") set(libsecp256k1_LIBRARY_DIR "${THIRDPARTY_BUILD_DIR}/libsecp256k1/lib") set(libsecp256k1_DIR "${THIRDPARTY_BUILD_DIR}/libsecp256k1/lib/cmake/libsecp256k1") find_package(libsecp256k1 CONFIG REQUIRED) - include_directories(${libsecp256k1_INCLUDE_DIR}) - # -------------------------------------------------------- - # Set config of xxhash + # xxhash set(xxHash_INCLUDE_DIR "${THIRDPARTY_BUILD_DIR}/xxHash/include") set(xxHash_LIBRARY_DIR "${THIRDPARTY_BUILD_DIR}/xxHash/lib") set(xxHash_DIR "${THIRDPARTY_BUILD_DIR}/xxhash/lib/cmake/xxHash") find_package(xxHash CONFIG REQUIRED) - include_directories(${xxHash_INCLUDE_DIR}) - # -------------------------------------------------------- - # Set config of libssh2 + # libssh2 set(Libssh2_DIR "${THIRDPARTY_BUILD_DIR}/libssh2/lib/cmake/libssh2") set(Libssh2_LIBRARY_DIR "${THIRDPARTY_BUILD_DIR}/libssh2/lib") set(Libssh2_INCLUDE_DIR "${THIRDPARTY_BUILD_DIR}/libssh2/include") find_package(Libssh2 CONFIG REQUIRED) - include_directories(${LIBSSH2_INCLUDE_DIR}) - # -------------------------------------------------------- - # Set config of AsyncIOManager + # AsyncIOManager set(AsyncIOManager_INCLUDE_DIR "${THIRDPARTY_BUILD_DIR}/AsyncIOManager/include") set(AsyncIOManager_LIBRARY_DIR "${THIRDPARTY_BUILD_DIR}/AsyncIOManager/lib") set(AsyncIOManager_DIR "${THIRDPARTY_BUILD_DIR}/AsyncIOManager/lib/cmake/AsyncIOManager") find_package(AsyncIOManager CONFIG REQUIRED) - # -------------------------------------------------------- - # Set config of gnus_upnp + # gnus_upnp set(gnus_upnp_INCLUDE_DIR "${THIRDPARTY_BUILD_DIR}/gnus_upnp/include") set(gnus_upnp_LIBRARY_DIR "${THIRDPARTY_BUILD_DIR}/gnus_upnp/lib") set(gnus_upnp_DIR "${THIRDPARTY_BUILD_DIR}/gnus_upnp/lib/cmake/gnus_upnp") find_package(gnus_upnp CONFIG REQUIRED) - include_directories(${gnus_upnp_INCLUDE_DIR}) - # -------------------------------------------------------- - # Set config of crypto3 + # crypto3 add_library(crypto3::algebra INTERFACE IMPORTED) add_library(crypto3::block INTERFACE IMPORTED) add_library(crypto3::blueprint INTERFACE IMPORTED) @@ -399,7 +347,7 @@ if(NOT CMAKE_SKIP_THIRD_PARTY) # zkLLVM set(zkLLVM_INCLUDE_DIR "${ZKLLVM_BUILD_DIR}/zkLLVM/include") - # Set config of llvm + # llvm set(LLVM_DIR "${ZKLLVM_BUILD_DIR}/zkLLVM/lib/cmake/llvm") find_package(LLVM CONFIG REQUIRED) @@ -410,31 +358,19 @@ if(NOT CMAKE_SKIP_THIRD_PARTY) message(STATUS "SUPERGENIUS_BUILD_DIR DIR: ${SUPERGENIUS_BUILD_DIR}") find_package(ProofSystem CONFIG REQUIRED) find_package(SuperGenius CONFIG REQUIRED) - include_directories(${SuperGenius_INCLUDE_DIR}) set(GENIUSSDK_BUILD_DIR ${GENIUSSDK_SRC_DIR}${ARCH_OUTPUT_DIR}) set(GeniusSDK_DIR "${GENIUSSDK_BUILD_DIR}/GeniusSDK/lib/cmake/GeniusSDK/") find_package(GeniusSDK CONFIG REQUIRED) - include_directories(${GeniusSDK_INCLUDE_DIR}) set(CMAKE_OSX_DEPLOYMENT_TARGET 12.1) set(BUILD_SHARED_LIBS ON) + if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows") add_library( GeniusWallet SHARED ${CMAKE_CURRENT_LIST_DIR}/null.cpp ) - - #set_target_properties(GeniusWallet PROPERTIES - # FRAMEWORK TRUE - # MACOSX_FRAMEWORK_IDENTIFIER GeniusWallet - # MACOSX_FRAMEWORK_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/GeniusWallet_Info.plist - # XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET "12.0" - # MACHO_OUTPUT_TYPE "mh_dylib" - # MACOSX_RPATH TRUE - # LINKER_LANGUAGE CXX - # XCODE_ATTRIBUTE_EMBEDDED_CONTENT_CONTAINS_SWIFT YES - #) if(SET_NAME_UNIX_FORCE) set_target_properties(GeniusWallet PROPERTIES SUFFIX ".so") diff --git a/cmake/CommonCompilerOptions.cmake b/cmake/CommonCompilerOptions.cmake index 96a96cfa..f291cd08 100644 --- a/cmake/CommonCompilerOptions.cmake +++ b/cmake/CommonCompilerOptions.cmake @@ -4,59 +4,59 @@ set(CMAKE_CXX_EXTENSIONS OFF) if(NOT CMAKE_SKIP_THIRD_PARTY) - if (DEFINED SANITIZE_CODE AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") - add_compile_options("-fsanitize=${SANITIZE_CODE}") - add_link_options("-fsanitize=${SANITIZE_CODE}") - endif() - - - if(NOT DEFINED ZKLLVM_DIR) - if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/../../zkLLVM") - message(STATUS "Setting default zkLLVM directory") - set(ZKLLVM_DIR "${CMAKE_CURRENT_LIST_DIR}/../../zkLLVM" CACHE STRING "Default zkLLVM Library") - cmake_path(SET ZKLLVM_DIR NORMALIZE "${ZKLLVM_DIR}") - else() - message(FATAL_ERROR "Cannot find zkLLVM directory required to build") - endif() - endif() - - # -------------------------------------------------------- - # define third party directory - if (NOT DEFINED THIRDPARTY_DIR) - if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/../../thirdparty") - message("Setting default third party directory") - set(THIRDPARTY_DIR "${CMAKE_CURRENT_LIST_DIR}/../../thirdparty") - ## get absolute path - cmake_path(SET THIRDPARTY_DIR NORMALIZE "${THIRDPARTY_DIR}") # Doesn't work in Cmake 3.18 (Android SDK's installed version here) - else() - message( FATAL_ERROR "Cannot find thirdparty directory required to build" ) + if(DEFINED SANITIZE_CODE AND "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + add_compile_options("-fsanitize=${SANITIZE_CODE}") + add_link_options("-fsanitize=${SANITIZE_CODE}") endif() - endif() - - # -------------------------------------------------------- - # Set config of SuperGenius project - if (NOT DEFINED SUPERGENIUS_SRC_DIR) - if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/../../SuperGenius") - message("Setting default SuperGenius directory") - set(SUPERGENIUS_SRC_DIR "${CMAKE_CURRENT_LIST_DIR}/../../SuperGenius" CACHE STRING "Default SuperGenius Library") - ## get absolute path - #cmake_path(SET SUPERGENIUS_SRC_DIR NORMALIZE "${SUPERGENIUS_SRC_DIR}") - else() - message( FATAL_ERROR "Cannot find SuperGenius directory required to build" ) + + + if(NOT DEFINED ZKLLVM_DIR) + if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/../../zkLLVM") + message(STATUS "Setting default zkLLVM directory") + set(ZKLLVM_DIR "${CMAKE_CURRENT_LIST_DIR}/../../zkLLVM" CACHE STRING "Default zkLLVM Library") + cmake_path(SET ZKLLVM_DIR NORMALIZE "${ZKLLVM_DIR}") + else() + message(FATAL_ERROR "Cannot find zkLLVM directory required to build") + endif() + endif() + + # -------------------------------------------------------- + # define third party directory + if(NOT DEFINED THIRDPARTY_DIR) + if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/../../thirdparty") + message("Setting default third party directory") + set(THIRDPARTY_DIR "${CMAKE_CURRENT_LIST_DIR}/../../thirdparty") + ## get absolute path + cmake_path(SET THIRDPARTY_DIR NORMALIZE "${THIRDPARTY_DIR}") # Doesn't work in Cmake 3.18 (Android SDK's installed version here) + else() + message(FATAL_ERROR "Cannot find thirdparty directory required to build") + endif() endif() - endif() - - # -------------------------------------------------------- - # Set config of SuperGenius project - if (NOT DEFINED GENIUSSDK_SRC_DIR) - if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/../../GeniusSDK") - message("Setting default GeniusSDK directory") - set(GENIUSSDK_SRC_DIR "${CMAKE_CURRENT_LIST_DIR}/../../GeniusSDK" CACHE STRING "Default GeniusSDK Library") - ## get absolute path - #cmake_path(SET GENIUSSDK_SRC_DIR NORMALIZE "${GENIUSSDK_SRC_DIR}") - else() - message( FATAL_ERROR "Cannot find GeniusSDK directory required to build" ) + + # -------------------------------------------------------- + # Set config of SuperGenius project + if(NOT DEFINED SUPERGENIUS_SRC_DIR) + if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/../../SuperGenius") + message("Setting default SuperGenius directory") + set(SUPERGENIUS_SRC_DIR "${CMAKE_CURRENT_LIST_DIR}/../../SuperGenius" CACHE STRING "Default SuperGenius Library") + ## get absolute path + #cmake_path(SET SUPERGENIUS_SRC_DIR NORMALIZE "${SUPERGENIUS_SRC_DIR}") + else() + message(FATAL_ERROR "Cannot find SuperGenius directory required to build") + endif() + endif() + + # -------------------------------------------------------- + # Set config of SuperGenius project + if(NOT DEFINED GENIUSSDK_SRC_DIR) + if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/../../GeniusSDK") + message("Setting default GeniusSDK directory") + set(GENIUSSDK_SRC_DIR "${CMAKE_CURRENT_LIST_DIR}/../../GeniusSDK" CACHE STRING "Default GeniusSDK Library") + ## get absolute path + #cmake_path(SET GENIUSSDK_SRC_DIR NORMALIZE "${GENIUSSDK_SRC_DIR}") + else() + message(FATAL_ERROR "Cannot find GeniusSDK directory required to build") + endif() endif() - endif() -endif() \ No newline at end of file +endif() From bbe56bd2dcf8dfbfd3deb4a5f677830d95b9efc0 Mon Sep 17 00:00:00 2001 From: Eduardo Menges Mattje Date: Wed, 1 Oct 2025 14:58:24 -0300 Subject: [PATCH 3/6] Regenerated freezed packages --- packages/genius_api/lib/models/account.dart | 2 +- .../lib/models/account.freezed.dart | 389 +++++++------ packages/genius_api/lib/models/account.g.dart | 28 +- packages/genius_api/lib/models/coin.dart | 2 +- .../genius_api/lib/models/coin.freezed.dart | 532 +++++++++-------- packages/genius_api/lib/models/coin.g.dart | 41 +- packages/genius_api/lib/models/currency.dart | 2 +- .../lib/models/currency.freezed.dart | 488 ++++++++-------- .../genius_api/lib/models/currency.g.dart | 34 +- packages/genius_api/lib/models/network.dart | 2 +- .../lib/models/network.freezed.dart | 509 ++++++++--------- packages/genius_api/lib/models/network.g.dart | 38 +- packages/genius_api/lib/models/news.dart | 10 +- .../genius_api/lib/models/news.freezed.dart | 428 ++++++++------ packages/genius_api/lib/models/token.dart | 2 +- .../genius_api/lib/models/token.freezed.dart | 433 ++++++++------ packages/genius_api/lib/models/token.g.dart | 25 +- packages/genius_api/lib/models/user.dart | 2 +- .../genius_api/lib/models/user.freezed.dart | 535 +++++++++--------- packages/genius_api/lib/models/user.g.dart | 41 +- packages/genius_api/lib/models/wallet.dart | 2 +- .../genius_api/lib/models/wallet.freezed.dart | 499 ++++++++-------- packages/genius_api/lib/models/wallet.g.dart | 33 +- packages/genius_api/pubspec.yaml | 3 +- 24 files changed, 2149 insertions(+), 1931 deletions(-) diff --git a/packages/genius_api/lib/models/account.dart b/packages/genius_api/lib/models/account.dart index 0ae975a9..c7710df5 100644 --- a/packages/genius_api/lib/models/account.dart +++ b/packages/genius_api/lib/models/account.dart @@ -4,7 +4,7 @@ part 'account.freezed.dart'; part 'account.g.dart'; @unfreezed -class Account with _$Account { +sealed class Account with _$Account { factory Account( {String? name, double? balance, diff --git a/packages/genius_api/lib/models/account.freezed.dart b/packages/genius_api/lib/models/account.freezed.dart index a4ec8862..8a3b0ffc 100644 --- a/packages/genius_api/lib/models/account.freezed.dart +++ b/packages/genius_api/lib/models/account.freezed.dart @@ -1,5 +1,5 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file // ignore_for_file: type=lint // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark @@ -9,182 +9,255 @@ part of 'account.dart'; // FreezedGenerator // ************************************************************************** +// dart format off T _$identity(T value) => value; -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); - -Account _$AccountFromJson(Map json) { - return _Account.fromJson(json); -} - /// @nodoc mixin _$Account { - String? get name => throw _privateConstructorUsedError; - set name(String? value) => throw _privateConstructorUsedError; - double? get balance => throw _privateConstructorUsedError; - set balance(double? value) => throw _privateConstructorUsedError; - DateTime? get lastBalanceRetrievalDate => throw _privateConstructorUsedError; - set lastBalanceRetrievalDate(DateTime? value) => - throw _privateConstructorUsedError; + + String? get name; set name(String? value); double? get balance; set balance(double? value); DateTime? get lastBalanceRetrievalDate; set lastBalanceRetrievalDate(DateTime? value); +/// Create a copy of Account +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$AccountCopyWith get copyWith => _$AccountCopyWithImpl(this as Account, _$identity); /// Serializes this Account to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + + + - /// Create a copy of Account - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $AccountCopyWith get copyWith => throw _privateConstructorUsedError; +@override +String toString() { + return 'Account(name: $name, balance: $balance, lastBalanceRetrievalDate: $lastBalanceRetrievalDate)'; } -/// @nodoc -abstract class $AccountCopyWith<$Res> { - factory $AccountCopyWith(Account value, $Res Function(Account) then) = - _$AccountCopyWithImpl<$Res, Account>; - @useResult - $Res call( - {String? name, double? balance, DateTime? lastBalanceRetrievalDate}); + } /// @nodoc -class _$AccountCopyWithImpl<$Res, $Val extends Account> +abstract mixin class $AccountCopyWith<$Res> { + factory $AccountCopyWith(Account value, $Res Function(Account) _then) = _$AccountCopyWithImpl; +@useResult +$Res call({ + String? name, double? balance, DateTime? lastBalanceRetrievalDate +}); + + + + +} +/// @nodoc +class _$AccountCopyWithImpl<$Res> implements $AccountCopyWith<$Res> { - _$AccountCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of Account - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? name = freezed, - Object? balance = freezed, - Object? lastBalanceRetrievalDate = freezed, - }) { - return _then(_value.copyWith( - name: freezed == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String?, - balance: freezed == balance - ? _value.balance - : balance // ignore: cast_nullable_to_non_nullable - as double?, - lastBalanceRetrievalDate: freezed == lastBalanceRetrievalDate - ? _value.lastBalanceRetrievalDate - : lastBalanceRetrievalDate // ignore: cast_nullable_to_non_nullable - as DateTime?, - ) as $Val); - } + _$AccountCopyWithImpl(this._self, this._then); + + final Account _self; + final $Res Function(Account) _then; + +/// Create a copy of Account +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? name = freezed,Object? balance = freezed,Object? lastBalanceRetrievalDate = freezed,}) { + return _then(_self.copyWith( +name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String?,balance: freezed == balance ? _self.balance : balance // ignore: cast_nullable_to_non_nullable +as double?,lastBalanceRetrievalDate: freezed == lastBalanceRetrievalDate ? _self.lastBalanceRetrievalDate : lastBalanceRetrievalDate // ignore: cast_nullable_to_non_nullable +as DateTime?, + )); } -/// @nodoc -abstract class _$$AccountImplCopyWith<$Res> implements $AccountCopyWith<$Res> { - factory _$$AccountImplCopyWith( - _$AccountImpl value, $Res Function(_$AccountImpl) then) = - __$$AccountImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {String? name, double? balance, DateTime? lastBalanceRetrievalDate}); } -/// @nodoc -class __$$AccountImplCopyWithImpl<$Res> - extends _$AccountCopyWithImpl<$Res, _$AccountImpl> - implements _$$AccountImplCopyWith<$Res> { - __$$AccountImplCopyWithImpl( - _$AccountImpl _value, $Res Function(_$AccountImpl) _then) - : super(_value, _then); - - /// Create a copy of Account - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? name = freezed, - Object? balance = freezed, - Object? lastBalanceRetrievalDate = freezed, - }) { - return _then(_$AccountImpl( - name: freezed == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String?, - balance: freezed == balance - ? _value.balance - : balance // ignore: cast_nullable_to_non_nullable - as double?, - lastBalanceRetrievalDate: freezed == lastBalanceRetrievalDate - ? _value.lastBalanceRetrievalDate - : lastBalanceRetrievalDate // ignore: cast_nullable_to_non_nullable - as DateTime?, - )); - } + +/// Adds pattern-matching-related methods to [Account]. +extension AccountPatterns on Account { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _Account value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Account() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _Account value) $default,){ +final _that = this; +switch (_that) { +case _Account(): +return $default(_that);} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _Account value)? $default,){ +final _that = this; +switch (_that) { +case _Account() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( String? name, double? balance, DateTime? lastBalanceRetrievalDate)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Account() when $default != null: +return $default(_that.name,_that.balance,_that.lastBalanceRetrievalDate);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( String? name, double? balance, DateTime? lastBalanceRetrievalDate) $default,) {final _that = this; +switch (_that) { +case _Account(): +return $default(_that.name,_that.balance,_that.lastBalanceRetrievalDate);} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String? name, double? balance, DateTime? lastBalanceRetrievalDate)? $default,) {final _that = this; +switch (_that) { +case _Account() when $default != null: +return $default(_that.name,_that.balance,_that.lastBalanceRetrievalDate);case _: + return null; + +} +} + } /// @nodoc @JsonSerializable() -class _$AccountImpl implements _Account { - _$AccountImpl({this.name, this.balance, this.lastBalanceRetrievalDate}); - - factory _$AccountImpl.fromJson(Map json) => - _$$AccountImplFromJson(json); - - @override - String? name; - @override - double? balance; - @override - DateTime? lastBalanceRetrievalDate; - - @override - String toString() { - return 'Account(name: $name, balance: $balance, lastBalanceRetrievalDate: $lastBalanceRetrievalDate)'; - } - - /// Create a copy of Account - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$AccountImplCopyWith<_$AccountImpl> get copyWith => - __$$AccountImplCopyWithImpl<_$AccountImpl>(this, _$identity); - - @override - Map toJson() { - return _$$AccountImplToJson( - this, - ); - } -} - -abstract class _Account implements Account { - factory _Account( - {String? name, - double? balance, - DateTime? lastBalanceRetrievalDate}) = _$AccountImpl; - - factory _Account.fromJson(Map json) = _$AccountImpl.fromJson; - - @override - String? get name; - set name(String? value); - @override - double? get balance; - set balance(double? value); - @override - DateTime? get lastBalanceRetrievalDate; - set lastBalanceRetrievalDate(DateTime? value); - - /// Create a copy of Account - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$AccountImplCopyWith<_$AccountImpl> get copyWith => - throw _privateConstructorUsedError; + +class _Account implements Account { + _Account({this.name, this.balance, this.lastBalanceRetrievalDate}); + factory _Account.fromJson(Map json) => _$AccountFromJson(json); + +@override String? name; +@override double? balance; +@override DateTime? lastBalanceRetrievalDate; + +/// Create a copy of Account +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$AccountCopyWith<_Account> get copyWith => __$AccountCopyWithImpl<_Account>(this, _$identity); + +@override +Map toJson() { + return _$AccountToJson(this, ); +} + + + +@override +String toString() { + return 'Account(name: $name, balance: $balance, lastBalanceRetrievalDate: $lastBalanceRetrievalDate)'; +} + + +} + +/// @nodoc +abstract mixin class _$AccountCopyWith<$Res> implements $AccountCopyWith<$Res> { + factory _$AccountCopyWith(_Account value, $Res Function(_Account) _then) = __$AccountCopyWithImpl; +@override @useResult +$Res call({ + String? name, double? balance, DateTime? lastBalanceRetrievalDate +}); + + + + } +/// @nodoc +class __$AccountCopyWithImpl<$Res> + implements _$AccountCopyWith<$Res> { + __$AccountCopyWithImpl(this._self, this._then); + + final _Account _self; + final $Res Function(_Account) _then; + +/// Create a copy of Account +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? name = freezed,Object? balance = freezed,Object? lastBalanceRetrievalDate = freezed,}) { + return _then(_Account( +name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String?,balance: freezed == balance ? _self.balance : balance // ignore: cast_nullable_to_non_nullable +as double?,lastBalanceRetrievalDate: freezed == lastBalanceRetrievalDate ? _self.lastBalanceRetrievalDate : lastBalanceRetrievalDate // ignore: cast_nullable_to_non_nullable +as DateTime?, + )); +} + + +} + +// dart format on diff --git a/packages/genius_api/lib/models/account.g.dart b/packages/genius_api/lib/models/account.g.dart index a577cbfb..bf3f210a 100644 --- a/packages/genius_api/lib/models/account.g.dart +++ b/packages/genius_api/lib/models/account.g.dart @@ -6,19 +6,17 @@ part of 'account.dart'; // JsonSerializableGenerator // ************************************************************************** -_$AccountImpl _$$AccountImplFromJson(Map json) => - _$AccountImpl( - name: json['name'] as String?, - balance: (json['balance'] as num?)?.toDouble(), - lastBalanceRetrievalDate: json['lastBalanceRetrievalDate'] == null - ? null - : DateTime.parse(json['lastBalanceRetrievalDate'] as String), - ); +_Account _$AccountFromJson(Map json) => _Account( + name: json['name'] as String?, + balance: (json['balance'] as num?)?.toDouble(), + lastBalanceRetrievalDate: json['lastBalanceRetrievalDate'] == null + ? null + : DateTime.parse(json['lastBalanceRetrievalDate'] as String), +); -Map _$$AccountImplToJson(_$AccountImpl instance) => - { - 'name': instance.name, - 'balance': instance.balance, - 'lastBalanceRetrievalDate': - instance.lastBalanceRetrievalDate?.toIso8601String(), - }; +Map _$AccountToJson(_Account instance) => { + 'name': instance.name, + 'balance': instance.balance, + 'lastBalanceRetrievalDate': instance.lastBalanceRetrievalDate + ?.toIso8601String(), +}; diff --git a/packages/genius_api/lib/models/coin.dart b/packages/genius_api/lib/models/coin.dart index 0118554f..b71d2494 100644 --- a/packages/genius_api/lib/models/coin.dart +++ b/packages/genius_api/lib/models/coin.dart @@ -4,7 +4,7 @@ part 'coin.freezed.dart'; part 'coin.g.dart'; @freezed -class Coin with _$Coin { +sealed class Coin with _$Coin { const factory Coin( {String? name, String? symbol, diff --git a/packages/genius_api/lib/models/coin.freezed.dart b/packages/genius_api/lib/models/coin.freezed.dart index 92b3b557..e1da1ba0 100644 --- a/packages/genius_api/lib/models/coin.freezed.dart +++ b/packages/genius_api/lib/models/coin.freezed.dart @@ -1,5 +1,5 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file // ignore_for_file: type=lint // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark @@ -9,300 +9,284 @@ part of 'coin.dart'; // FreezedGenerator // ************************************************************************** +// dart format off T _$identity(T value) => value; -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); - -Coin _$CoinFromJson(Map json) { - return _Coin.fromJson(json); -} - /// @nodoc mixin _$Coin { - String? get name => throw _privateConstructorUsedError; - String? get symbol => throw _privateConstructorUsedError; - String? get address => throw _privateConstructorUsedError; - double? get balance => throw _privateConstructorUsedError; - String? get networkSymbol => throw _privateConstructorUsedError; - String? get decimals => throw _privateConstructorUsedError; - String? get iconPath => throw _privateConstructorUsedError; - String? get coinGeckoId => throw _privateConstructorUsedError; + + String? get name; String? get symbol; String? get address; double? get balance; String? get networkSymbol; String? get decimals; String? get iconPath; String? get coinGeckoId; +/// Create a copy of Coin +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$CoinCopyWith get copyWith => _$CoinCopyWithImpl(this as Coin, _$identity); /// Serializes this Coin to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + - /// Create a copy of Coin - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $CoinCopyWith get copyWith => throw _privateConstructorUsedError; +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is Coin&&(identical(other.name, name) || other.name == name)&&(identical(other.symbol, symbol) || other.symbol == symbol)&&(identical(other.address, address) || other.address == address)&&(identical(other.balance, balance) || other.balance == balance)&&(identical(other.networkSymbol, networkSymbol) || other.networkSymbol == networkSymbol)&&(identical(other.decimals, decimals) || other.decimals == decimals)&&(identical(other.iconPath, iconPath) || other.iconPath == iconPath)&&(identical(other.coinGeckoId, coinGeckoId) || other.coinGeckoId == coinGeckoId)); } -/// @nodoc -abstract class $CoinCopyWith<$Res> { - factory $CoinCopyWith(Coin value, $Res Function(Coin) then) = - _$CoinCopyWithImpl<$Res, Coin>; - @useResult - $Res call( - {String? name, - String? symbol, - String? address, - double? balance, - String? networkSymbol, - String? decimals, - String? iconPath, - String? coinGeckoId}); +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,name,symbol,address,balance,networkSymbol,decimals,iconPath,coinGeckoId); + +@override +String toString() { + return 'Coin(name: $name, symbol: $symbol, address: $address, balance: $balance, networkSymbol: $networkSymbol, decimals: $decimals, iconPath: $iconPath, coinGeckoId: $coinGeckoId)'; } + +} + +/// @nodoc +abstract mixin class $CoinCopyWith<$Res> { + factory $CoinCopyWith(Coin value, $Res Function(Coin) _then) = _$CoinCopyWithImpl; +@useResult +$Res call({ + String? name, String? symbol, String? address, double? balance, String? networkSymbol, String? decimals, String? iconPath, String? coinGeckoId +}); + + + + +} /// @nodoc -class _$CoinCopyWithImpl<$Res, $Val extends Coin> +class _$CoinCopyWithImpl<$Res> implements $CoinCopyWith<$Res> { - _$CoinCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of Coin - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? name = freezed, - Object? symbol = freezed, - Object? address = freezed, - Object? balance = freezed, - Object? networkSymbol = freezed, - Object? decimals = freezed, - Object? iconPath = freezed, - Object? coinGeckoId = freezed, - }) { - return _then(_value.copyWith( - name: freezed == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String?, - symbol: freezed == symbol - ? _value.symbol - : symbol // ignore: cast_nullable_to_non_nullable - as String?, - address: freezed == address - ? _value.address - : address // ignore: cast_nullable_to_non_nullable - as String?, - balance: freezed == balance - ? _value.balance - : balance // ignore: cast_nullable_to_non_nullable - as double?, - networkSymbol: freezed == networkSymbol - ? _value.networkSymbol - : networkSymbol // ignore: cast_nullable_to_non_nullable - as String?, - decimals: freezed == decimals - ? _value.decimals - : decimals // ignore: cast_nullable_to_non_nullable - as String?, - iconPath: freezed == iconPath - ? _value.iconPath - : iconPath // ignore: cast_nullable_to_non_nullable - as String?, - coinGeckoId: freezed == coinGeckoId - ? _value.coinGeckoId - : coinGeckoId // ignore: cast_nullable_to_non_nullable - as String?, - ) as $Val); - } + _$CoinCopyWithImpl(this._self, this._then); + + final Coin _self; + final $Res Function(Coin) _then; + +/// Create a copy of Coin +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? name = freezed,Object? symbol = freezed,Object? address = freezed,Object? balance = freezed,Object? networkSymbol = freezed,Object? decimals = freezed,Object? iconPath = freezed,Object? coinGeckoId = freezed,}) { + return _then(_self.copyWith( +name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String?,symbol: freezed == symbol ? _self.symbol : symbol // ignore: cast_nullable_to_non_nullable +as String?,address: freezed == address ? _self.address : address // ignore: cast_nullable_to_non_nullable +as String?,balance: freezed == balance ? _self.balance : balance // ignore: cast_nullable_to_non_nullable +as double?,networkSymbol: freezed == networkSymbol ? _self.networkSymbol : networkSymbol // ignore: cast_nullable_to_non_nullable +as String?,decimals: freezed == decimals ? _self.decimals : decimals // ignore: cast_nullable_to_non_nullable +as String?,iconPath: freezed == iconPath ? _self.iconPath : iconPath // ignore: cast_nullable_to_non_nullable +as String?,coinGeckoId: freezed == coinGeckoId ? _self.coinGeckoId : coinGeckoId // ignore: cast_nullable_to_non_nullable +as String?, + )); } -/// @nodoc -abstract class _$$CoinImplCopyWith<$Res> implements $CoinCopyWith<$Res> { - factory _$$CoinImplCopyWith( - _$CoinImpl value, $Res Function(_$CoinImpl) then) = - __$$CoinImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {String? name, - String? symbol, - String? address, - double? balance, - String? networkSymbol, - String? decimals, - String? iconPath, - String? coinGeckoId}); } -/// @nodoc -class __$$CoinImplCopyWithImpl<$Res> - extends _$CoinCopyWithImpl<$Res, _$CoinImpl> - implements _$$CoinImplCopyWith<$Res> { - __$$CoinImplCopyWithImpl(_$CoinImpl _value, $Res Function(_$CoinImpl) _then) - : super(_value, _then); - - /// Create a copy of Coin - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? name = freezed, - Object? symbol = freezed, - Object? address = freezed, - Object? balance = freezed, - Object? networkSymbol = freezed, - Object? decimals = freezed, - Object? iconPath = freezed, - Object? coinGeckoId = freezed, - }) { - return _then(_$CoinImpl( - name: freezed == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String?, - symbol: freezed == symbol - ? _value.symbol - : symbol // ignore: cast_nullable_to_non_nullable - as String?, - address: freezed == address - ? _value.address - : address // ignore: cast_nullable_to_non_nullable - as String?, - balance: freezed == balance - ? _value.balance - : balance // ignore: cast_nullable_to_non_nullable - as double?, - networkSymbol: freezed == networkSymbol - ? _value.networkSymbol - : networkSymbol // ignore: cast_nullable_to_non_nullable - as String?, - decimals: freezed == decimals - ? _value.decimals - : decimals // ignore: cast_nullable_to_non_nullable - as String?, - iconPath: freezed == iconPath - ? _value.iconPath - : iconPath // ignore: cast_nullable_to_non_nullable - as String?, - coinGeckoId: freezed == coinGeckoId - ? _value.coinGeckoId - : coinGeckoId // ignore: cast_nullable_to_non_nullable - as String?, - )); - } + +/// Adds pattern-matching-related methods to [Coin]. +extension CoinPatterns on Coin { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _Coin value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Coin() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _Coin value) $default,){ +final _that = this; +switch (_that) { +case _Coin(): +return $default(_that);} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _Coin value)? $default,){ +final _that = this; +switch (_that) { +case _Coin() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( String? name, String? symbol, String? address, double? balance, String? networkSymbol, String? decimals, String? iconPath, String? coinGeckoId)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Coin() when $default != null: +return $default(_that.name,_that.symbol,_that.address,_that.balance,_that.networkSymbol,_that.decimals,_that.iconPath,_that.coinGeckoId);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( String? name, String? symbol, String? address, double? balance, String? networkSymbol, String? decimals, String? iconPath, String? coinGeckoId) $default,) {final _that = this; +switch (_that) { +case _Coin(): +return $default(_that.name,_that.symbol,_that.address,_that.balance,_that.networkSymbol,_that.decimals,_that.iconPath,_that.coinGeckoId);} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String? name, String? symbol, String? address, double? balance, String? networkSymbol, String? decimals, String? iconPath, String? coinGeckoId)? $default,) {final _that = this; +switch (_that) { +case _Coin() when $default != null: +return $default(_that.name,_that.symbol,_that.address,_that.balance,_that.networkSymbol,_that.decimals,_that.iconPath,_that.coinGeckoId);case _: + return null; + +} +} + } /// @nodoc @JsonSerializable() -class _$CoinImpl implements _Coin { - const _$CoinImpl( - {this.name, - this.symbol, - this.address, - this.balance, - this.networkSymbol, - this.decimals, - this.iconPath, - this.coinGeckoId}); - - factory _$CoinImpl.fromJson(Map json) => - _$$CoinImplFromJson(json); - - @override - final String? name; - @override - final String? symbol; - @override - final String? address; - @override - final double? balance; - @override - final String? networkSymbol; - @override - final String? decimals; - @override - final String? iconPath; - @override - final String? coinGeckoId; - - @override - String toString() { - return 'Coin(name: $name, symbol: $symbol, address: $address, balance: $balance, networkSymbol: $networkSymbol, decimals: $decimals, iconPath: $iconPath, coinGeckoId: $coinGeckoId)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$CoinImpl && - (identical(other.name, name) || other.name == name) && - (identical(other.symbol, symbol) || other.symbol == symbol) && - (identical(other.address, address) || other.address == address) && - (identical(other.balance, balance) || other.balance == balance) && - (identical(other.networkSymbol, networkSymbol) || - other.networkSymbol == networkSymbol) && - (identical(other.decimals, decimals) || - other.decimals == decimals) && - (identical(other.iconPath, iconPath) || - other.iconPath == iconPath) && - (identical(other.coinGeckoId, coinGeckoId) || - other.coinGeckoId == coinGeckoId)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, name, symbol, address, balance, - networkSymbol, decimals, iconPath, coinGeckoId); - - /// Create a copy of Coin - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$CoinImplCopyWith<_$CoinImpl> get copyWith => - __$$CoinImplCopyWithImpl<_$CoinImpl>(this, _$identity); - - @override - Map toJson() { - return _$$CoinImplToJson( - this, - ); - } + +class _Coin implements Coin { + const _Coin({this.name, this.symbol, this.address, this.balance, this.networkSymbol, this.decimals, this.iconPath, this.coinGeckoId}); + factory _Coin.fromJson(Map json) => _$CoinFromJson(json); + +@override final String? name; +@override final String? symbol; +@override final String? address; +@override final double? balance; +@override final String? networkSymbol; +@override final String? decimals; +@override final String? iconPath; +@override final String? coinGeckoId; + +/// Create a copy of Coin +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$CoinCopyWith<_Coin> get copyWith => __$CoinCopyWithImpl<_Coin>(this, _$identity); + +@override +Map toJson() { + return _$CoinToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Coin&&(identical(other.name, name) || other.name == name)&&(identical(other.symbol, symbol) || other.symbol == symbol)&&(identical(other.address, address) || other.address == address)&&(identical(other.balance, balance) || other.balance == balance)&&(identical(other.networkSymbol, networkSymbol) || other.networkSymbol == networkSymbol)&&(identical(other.decimals, decimals) || other.decimals == decimals)&&(identical(other.iconPath, iconPath) || other.iconPath == iconPath)&&(identical(other.coinGeckoId, coinGeckoId) || other.coinGeckoId == coinGeckoId)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,name,symbol,address,balance,networkSymbol,decimals,iconPath,coinGeckoId); + +@override +String toString() { + return 'Coin(name: $name, symbol: $symbol, address: $address, balance: $balance, networkSymbol: $networkSymbol, decimals: $decimals, iconPath: $iconPath, coinGeckoId: $coinGeckoId)'; } -abstract class _Coin implements Coin { - const factory _Coin( - {final String? name, - final String? symbol, - final String? address, - final double? balance, - final String? networkSymbol, - final String? decimals, - final String? iconPath, - final String? coinGeckoId}) = _$CoinImpl; - - factory _Coin.fromJson(Map json) = _$CoinImpl.fromJson; - - @override - String? get name; - @override - String? get symbol; - @override - String? get address; - @override - double? get balance; - @override - String? get networkSymbol; - @override - String? get decimals; - @override - String? get iconPath; - @override - String? get coinGeckoId; - - /// Create a copy of Coin - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$CoinImplCopyWith<_$CoinImpl> get copyWith => - throw _privateConstructorUsedError; + +} + +/// @nodoc +abstract mixin class _$CoinCopyWith<$Res> implements $CoinCopyWith<$Res> { + factory _$CoinCopyWith(_Coin value, $Res Function(_Coin) _then) = __$CoinCopyWithImpl; +@override @useResult +$Res call({ + String? name, String? symbol, String? address, double? balance, String? networkSymbol, String? decimals, String? iconPath, String? coinGeckoId +}); + + + + } +/// @nodoc +class __$CoinCopyWithImpl<$Res> + implements _$CoinCopyWith<$Res> { + __$CoinCopyWithImpl(this._self, this._then); + + final _Coin _self; + final $Res Function(_Coin) _then; + +/// Create a copy of Coin +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? name = freezed,Object? symbol = freezed,Object? address = freezed,Object? balance = freezed,Object? networkSymbol = freezed,Object? decimals = freezed,Object? iconPath = freezed,Object? coinGeckoId = freezed,}) { + return _then(_Coin( +name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String?,symbol: freezed == symbol ? _self.symbol : symbol // ignore: cast_nullable_to_non_nullable +as String?,address: freezed == address ? _self.address : address // ignore: cast_nullable_to_non_nullable +as String?,balance: freezed == balance ? _self.balance : balance // ignore: cast_nullable_to_non_nullable +as double?,networkSymbol: freezed == networkSymbol ? _self.networkSymbol : networkSymbol // ignore: cast_nullable_to_non_nullable +as String?,decimals: freezed == decimals ? _self.decimals : decimals // ignore: cast_nullable_to_non_nullable +as String?,iconPath: freezed == iconPath ? _self.iconPath : iconPath // ignore: cast_nullable_to_non_nullable +as String?,coinGeckoId: freezed == coinGeckoId ? _self.coinGeckoId : coinGeckoId // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + + +} + +// dart format on diff --git a/packages/genius_api/lib/models/coin.g.dart b/packages/genius_api/lib/models/coin.g.dart index a04414cf..615f79c3 100644 --- a/packages/genius_api/lib/models/coin.g.dart +++ b/packages/genius_api/lib/models/coin.g.dart @@ -6,25 +6,24 @@ part of 'coin.dart'; // JsonSerializableGenerator // ************************************************************************** -_$CoinImpl _$$CoinImplFromJson(Map json) => _$CoinImpl( - name: json['name'] as String?, - symbol: json['symbol'] as String?, - address: json['address'] as String?, - balance: (json['balance'] as num?)?.toDouble(), - networkSymbol: json['networkSymbol'] as String?, - decimals: json['decimals'] as String?, - iconPath: json['iconPath'] as String?, - coinGeckoId: json['coinGeckoId'] as String?, - ); +_Coin _$CoinFromJson(Map json) => _Coin( + name: json['name'] as String?, + symbol: json['symbol'] as String?, + address: json['address'] as String?, + balance: (json['balance'] as num?)?.toDouble(), + networkSymbol: json['networkSymbol'] as String?, + decimals: json['decimals'] as String?, + iconPath: json['iconPath'] as String?, + coinGeckoId: json['coinGeckoId'] as String?, +); -Map _$$CoinImplToJson(_$CoinImpl instance) => - { - 'name': instance.name, - 'symbol': instance.symbol, - 'address': instance.address, - 'balance': instance.balance, - 'networkSymbol': instance.networkSymbol, - 'decimals': instance.decimals, - 'iconPath': instance.iconPath, - 'coinGeckoId': instance.coinGeckoId, - }; +Map _$CoinToJson(_Coin instance) => { + 'name': instance.name, + 'symbol': instance.symbol, + 'address': instance.address, + 'balance': instance.balance, + 'networkSymbol': instance.networkSymbol, + 'decimals': instance.decimals, + 'iconPath': instance.iconPath, + 'coinGeckoId': instance.coinGeckoId, +}; diff --git a/packages/genius_api/lib/models/currency.dart b/packages/genius_api/lib/models/currency.dart index ca100acc..fe887f08 100644 --- a/packages/genius_api/lib/models/currency.dart +++ b/packages/genius_api/lib/models/currency.dart @@ -4,7 +4,7 @@ part 'currency.freezed.dart'; part 'currency.g.dart'; @freezed -class Currency with _$Currency { +sealed class Currency with _$Currency { const factory Currency({ required String symbol, required String name, diff --git a/packages/genius_api/lib/models/currency.freezed.dart b/packages/genius_api/lib/models/currency.freezed.dart index 54c60532..a23a26f0 100644 --- a/packages/genius_api/lib/models/currency.freezed.dart +++ b/packages/genius_api/lib/models/currency.freezed.dart @@ -1,5 +1,5 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file // ignore_for_file: type=lint // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark @@ -9,262 +9,278 @@ part of 'currency.dart'; // FreezedGenerator // ************************************************************************** +// dart format off T _$identity(T value) => value; -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); - -Currency _$CurrencyFromJson(Map json) { - return _Currency.fromJson(json); -} - /// @nodoc mixin _$Currency { - String get symbol => throw _privateConstructorUsedError; - String get name => throw _privateConstructorUsedError; - String? get price => throw _privateConstructorUsedError; - String? get priceCurrency => throw _privateConstructorUsedError; - String? get logoUrl => throw _privateConstructorUsedError; - String? get priceDate => throw _privateConstructorUsedError; + + String get symbol; String get name; String? get price; String? get priceCurrency; String? get logoUrl; String? get priceDate; +/// Create a copy of Currency +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$CurrencyCopyWith get copyWith => _$CurrencyCopyWithImpl(this as Currency, _$identity); /// Serializes this Currency to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + - /// Create a copy of Currency - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $CurrencyCopyWith get copyWith => - throw _privateConstructorUsedError; +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is Currency&&(identical(other.symbol, symbol) || other.symbol == symbol)&&(identical(other.name, name) || other.name == name)&&(identical(other.price, price) || other.price == price)&&(identical(other.priceCurrency, priceCurrency) || other.priceCurrency == priceCurrency)&&(identical(other.logoUrl, logoUrl) || other.logoUrl == logoUrl)&&(identical(other.priceDate, priceDate) || other.priceDate == priceDate)); } -/// @nodoc -abstract class $CurrencyCopyWith<$Res> { - factory $CurrencyCopyWith(Currency value, $Res Function(Currency) then) = - _$CurrencyCopyWithImpl<$Res, Currency>; - @useResult - $Res call( - {String symbol, - String name, - String? price, - String? priceCurrency, - String? logoUrl, - String? priceDate}); +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,symbol,name,price,priceCurrency,logoUrl,priceDate); + +@override +String toString() { + return 'Currency(symbol: $symbol, name: $name, price: $price, priceCurrency: $priceCurrency, logoUrl: $logoUrl, priceDate: $priceDate)'; } -/// @nodoc -class _$CurrencyCopyWithImpl<$Res, $Val extends Currency> - implements $CurrencyCopyWith<$Res> { - _$CurrencyCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of Currency - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? symbol = null, - Object? name = null, - Object? price = freezed, - Object? priceCurrency = freezed, - Object? logoUrl = freezed, - Object? priceDate = freezed, - }) { - return _then(_value.copyWith( - symbol: null == symbol - ? _value.symbol - : symbol // ignore: cast_nullable_to_non_nullable - as String, - name: null == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String, - price: freezed == price - ? _value.price - : price // ignore: cast_nullable_to_non_nullable - as String?, - priceCurrency: freezed == priceCurrency - ? _value.priceCurrency - : priceCurrency // ignore: cast_nullable_to_non_nullable - as String?, - logoUrl: freezed == logoUrl - ? _value.logoUrl - : logoUrl // ignore: cast_nullable_to_non_nullable - as String?, - priceDate: freezed == priceDate - ? _value.priceDate - : priceDate // ignore: cast_nullable_to_non_nullable - as String?, - ) as $Val); - } + } /// @nodoc -abstract class _$$CurrencyImplCopyWith<$Res> +abstract mixin class $CurrencyCopyWith<$Res> { + factory $CurrencyCopyWith(Currency value, $Res Function(Currency) _then) = _$CurrencyCopyWithImpl; +@useResult +$Res call({ + String symbol, String name, String? price, String? priceCurrency, String? logoUrl, String? priceDate +}); + + + + +} +/// @nodoc +class _$CurrencyCopyWithImpl<$Res> implements $CurrencyCopyWith<$Res> { - factory _$$CurrencyImplCopyWith( - _$CurrencyImpl value, $Res Function(_$CurrencyImpl) then) = - __$$CurrencyImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {String symbol, - String name, - String? price, - String? priceCurrency, - String? logoUrl, - String? priceDate}); + _$CurrencyCopyWithImpl(this._self, this._then); + + final Currency _self; + final $Res Function(Currency) _then; + +/// Create a copy of Currency +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? symbol = null,Object? name = null,Object? price = freezed,Object? priceCurrency = freezed,Object? logoUrl = freezed,Object? priceDate = freezed,}) { + return _then(_self.copyWith( +symbol: null == symbol ? _self.symbol : symbol // ignore: cast_nullable_to_non_nullable +as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String,price: freezed == price ? _self.price : price // ignore: cast_nullable_to_non_nullable +as String?,priceCurrency: freezed == priceCurrency ? _self.priceCurrency : priceCurrency // ignore: cast_nullable_to_non_nullable +as String?,logoUrl: freezed == logoUrl ? _self.logoUrl : logoUrl // ignore: cast_nullable_to_non_nullable +as String?,priceDate: freezed == priceDate ? _self.priceDate : priceDate // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [Currency]. +extension CurrencyPatterns on Currency { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _Currency value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Currency() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _Currency value) $default,){ +final _that = this; +switch (_that) { +case _Currency(): +return $default(_that);} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _Currency value)? $default,){ +final _that = this; +switch (_that) { +case _Currency() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( String symbol, String name, String? price, String? priceCurrency, String? logoUrl, String? priceDate)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Currency() when $default != null: +return $default(_that.symbol,_that.name,_that.price,_that.priceCurrency,_that.logoUrl,_that.priceDate);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( String symbol, String name, String? price, String? priceCurrency, String? logoUrl, String? priceDate) $default,) {final _that = this; +switch (_that) { +case _Currency(): +return $default(_that.symbol,_that.name,_that.price,_that.priceCurrency,_that.logoUrl,_that.priceDate);} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String symbol, String name, String? price, String? priceCurrency, String? logoUrl, String? priceDate)? $default,) {final _that = this; +switch (_that) { +case _Currency() when $default != null: +return $default(_that.symbol,_that.name,_that.price,_that.priceCurrency,_that.logoUrl,_that.priceDate);case _: + return null; + +} } -/// @nodoc -class __$$CurrencyImplCopyWithImpl<$Res> - extends _$CurrencyCopyWithImpl<$Res, _$CurrencyImpl> - implements _$$CurrencyImplCopyWith<$Res> { - __$$CurrencyImplCopyWithImpl( - _$CurrencyImpl _value, $Res Function(_$CurrencyImpl) _then) - : super(_value, _then); - - /// Create a copy of Currency - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? symbol = null, - Object? name = null, - Object? price = freezed, - Object? priceCurrency = freezed, - Object? logoUrl = freezed, - Object? priceDate = freezed, - }) { - return _then(_$CurrencyImpl( - symbol: null == symbol - ? _value.symbol - : symbol // ignore: cast_nullable_to_non_nullable - as String, - name: null == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String, - price: freezed == price - ? _value.price - : price // ignore: cast_nullable_to_non_nullable - as String?, - priceCurrency: freezed == priceCurrency - ? _value.priceCurrency - : priceCurrency // ignore: cast_nullable_to_non_nullable - as String?, - logoUrl: freezed == logoUrl - ? _value.logoUrl - : logoUrl // ignore: cast_nullable_to_non_nullable - as String?, - priceDate: freezed == priceDate - ? _value.priceDate - : priceDate // ignore: cast_nullable_to_non_nullable - as String?, - )); - } } /// @nodoc @JsonSerializable() -class _$CurrencyImpl implements _Currency { - const _$CurrencyImpl( - {required this.symbol, - required this.name, - this.price, - this.priceCurrency, - this.logoUrl, - this.priceDate}); - - factory _$CurrencyImpl.fromJson(Map json) => - _$$CurrencyImplFromJson(json); - - @override - final String symbol; - @override - final String name; - @override - final String? price; - @override - final String? priceCurrency; - @override - final String? logoUrl; - @override - final String? priceDate; - - @override - String toString() { - return 'Currency(symbol: $symbol, name: $name, price: $price, priceCurrency: $priceCurrency, logoUrl: $logoUrl, priceDate: $priceDate)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$CurrencyImpl && - (identical(other.symbol, symbol) || other.symbol == symbol) && - (identical(other.name, name) || other.name == name) && - (identical(other.price, price) || other.price == price) && - (identical(other.priceCurrency, priceCurrency) || - other.priceCurrency == priceCurrency) && - (identical(other.logoUrl, logoUrl) || other.logoUrl == logoUrl) && - (identical(other.priceDate, priceDate) || - other.priceDate == priceDate)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, symbol, name, price, priceCurrency, logoUrl, priceDate); - - /// Create a copy of Currency - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$CurrencyImplCopyWith<_$CurrencyImpl> get copyWith => - __$$CurrencyImplCopyWithImpl<_$CurrencyImpl>(this, _$identity); - - @override - Map toJson() { - return _$$CurrencyImplToJson( - this, - ); - } + +class _Currency implements Currency { + const _Currency({required this.symbol, required this.name, this.price, this.priceCurrency, this.logoUrl, this.priceDate}); + factory _Currency.fromJson(Map json) => _$CurrencyFromJson(json); + +@override final String symbol; +@override final String name; +@override final String? price; +@override final String? priceCurrency; +@override final String? logoUrl; +@override final String? priceDate; + +/// Create a copy of Currency +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$CurrencyCopyWith<_Currency> get copyWith => __$CurrencyCopyWithImpl<_Currency>(this, _$identity); + +@override +Map toJson() { + return _$CurrencyToJson(this, ); } -abstract class _Currency implements Currency { - const factory _Currency( - {required final String symbol, - required final String name, - final String? price, - final String? priceCurrency, - final String? logoUrl, - final String? priceDate}) = _$CurrencyImpl; - - factory _Currency.fromJson(Map json) = - _$CurrencyImpl.fromJson; - - @override - String get symbol; - @override - String get name; - @override - String? get price; - @override - String? get priceCurrency; - @override - String? get logoUrl; - @override - String? get priceDate; - - /// Create a copy of Currency - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$CurrencyImplCopyWith<_$CurrencyImpl> get copyWith => - throw _privateConstructorUsedError; +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Currency&&(identical(other.symbol, symbol) || other.symbol == symbol)&&(identical(other.name, name) || other.name == name)&&(identical(other.price, price) || other.price == price)&&(identical(other.priceCurrency, priceCurrency) || other.priceCurrency == priceCurrency)&&(identical(other.logoUrl, logoUrl) || other.logoUrl == logoUrl)&&(identical(other.priceDate, priceDate) || other.priceDate == priceDate)); } + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,symbol,name,price,priceCurrency,logoUrl,priceDate); + +@override +String toString() { + return 'Currency(symbol: $symbol, name: $name, price: $price, priceCurrency: $priceCurrency, logoUrl: $logoUrl, priceDate: $priceDate)'; +} + + +} + +/// @nodoc +abstract mixin class _$CurrencyCopyWith<$Res> implements $CurrencyCopyWith<$Res> { + factory _$CurrencyCopyWith(_Currency value, $Res Function(_Currency) _then) = __$CurrencyCopyWithImpl; +@override @useResult +$Res call({ + String symbol, String name, String? price, String? priceCurrency, String? logoUrl, String? priceDate +}); + + + + +} +/// @nodoc +class __$CurrencyCopyWithImpl<$Res> + implements _$CurrencyCopyWith<$Res> { + __$CurrencyCopyWithImpl(this._self, this._then); + + final _Currency _self; + final $Res Function(_Currency) _then; + +/// Create a copy of Currency +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? symbol = null,Object? name = null,Object? price = freezed,Object? priceCurrency = freezed,Object? logoUrl = freezed,Object? priceDate = freezed,}) { + return _then(_Currency( +symbol: null == symbol ? _self.symbol : symbol // ignore: cast_nullable_to_non_nullable +as String,name: null == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String,price: freezed == price ? _self.price : price // ignore: cast_nullable_to_non_nullable +as String?,priceCurrency: freezed == priceCurrency ? _self.priceCurrency : priceCurrency // ignore: cast_nullable_to_non_nullable +as String?,logoUrl: freezed == logoUrl ? _self.logoUrl : logoUrl // ignore: cast_nullable_to_non_nullable +as String?,priceDate: freezed == priceDate ? _self.priceDate : priceDate // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + + +} + +// dart format on diff --git a/packages/genius_api/lib/models/currency.g.dart b/packages/genius_api/lib/models/currency.g.dart index 48cfdf17..ba37c355 100644 --- a/packages/genius_api/lib/models/currency.g.dart +++ b/packages/genius_api/lib/models/currency.g.dart @@ -6,22 +6,20 @@ part of 'currency.dart'; // JsonSerializableGenerator // ************************************************************************** -_$CurrencyImpl _$$CurrencyImplFromJson(Map json) => - _$CurrencyImpl( - symbol: json['symbol'] as String, - name: json['name'] as String, - price: json['price'] as String?, - priceCurrency: json['priceCurrency'] as String?, - logoUrl: json['logoUrl'] as String?, - priceDate: json['priceDate'] as String?, - ); +_Currency _$CurrencyFromJson(Map json) => _Currency( + symbol: json['symbol'] as String, + name: json['name'] as String, + price: json['price'] as String?, + priceCurrency: json['priceCurrency'] as String?, + logoUrl: json['logoUrl'] as String?, + priceDate: json['priceDate'] as String?, +); -Map _$$CurrencyImplToJson(_$CurrencyImpl instance) => - { - 'symbol': instance.symbol, - 'name': instance.name, - 'price': instance.price, - 'priceCurrency': instance.priceCurrency, - 'logoUrl': instance.logoUrl, - 'priceDate': instance.priceDate, - }; +Map _$CurrencyToJson(_Currency instance) => { + 'symbol': instance.symbol, + 'name': instance.name, + 'price': instance.price, + 'priceCurrency': instance.priceCurrency, + 'logoUrl': instance.logoUrl, + 'priceDate': instance.priceDate, +}; diff --git a/packages/genius_api/lib/models/network.dart b/packages/genius_api/lib/models/network.dart index ec619920..9f85900d 100644 --- a/packages/genius_api/lib/models/network.dart +++ b/packages/genius_api/lib/models/network.dart @@ -4,7 +4,7 @@ part 'network.freezed.dart'; part 'network.g.dart'; @freezed -class Network with _$Network { +sealed class Network with _$Network { const factory Network( {String? name, String? symbol, diff --git a/packages/genius_api/lib/models/network.freezed.dart b/packages/genius_api/lib/models/network.freezed.dart index fb4a4a11..530e0d0e 100644 --- a/packages/genius_api/lib/models/network.freezed.dart +++ b/packages/genius_api/lib/models/network.freezed.dart @@ -1,5 +1,5 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file // ignore_for_file: type=lint // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark @@ -9,280 +9,281 @@ part of 'network.dart'; // FreezedGenerator // ************************************************************************** +// dart format off T _$identity(T value) => value; -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); - -Network _$NetworkFromJson(Map json) { - return _Network.fromJson(json); -} - /// @nodoc mixin _$Network { - String? get name => throw _privateConstructorUsedError; - String? get symbol => throw _privateConstructorUsedError; - int? get chainId => throw _privateConstructorUsedError; - String? get coinGeckoId => throw _privateConstructorUsedError; - String? get rpcUrl => throw _privateConstructorUsedError; - String? get iconPath => throw _privateConstructorUsedError; - String? get tokensPath => throw _privateConstructorUsedError; + + String? get name; String? get symbol; int? get chainId; String? get coinGeckoId; String? get rpcUrl; String? get iconPath; String? get tokensPath; +/// Create a copy of Network +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$NetworkCopyWith get copyWith => _$NetworkCopyWithImpl(this as Network, _$identity); /// Serializes this Network to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + - /// Create a copy of Network - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $NetworkCopyWith get copyWith => throw _privateConstructorUsedError; +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is Network&&(identical(other.name, name) || other.name == name)&&(identical(other.symbol, symbol) || other.symbol == symbol)&&(identical(other.chainId, chainId) || other.chainId == chainId)&&(identical(other.coinGeckoId, coinGeckoId) || other.coinGeckoId == coinGeckoId)&&(identical(other.rpcUrl, rpcUrl) || other.rpcUrl == rpcUrl)&&(identical(other.iconPath, iconPath) || other.iconPath == iconPath)&&(identical(other.tokensPath, tokensPath) || other.tokensPath == tokensPath)); } -/// @nodoc -abstract class $NetworkCopyWith<$Res> { - factory $NetworkCopyWith(Network value, $Res Function(Network) then) = - _$NetworkCopyWithImpl<$Res, Network>; - @useResult - $Res call( - {String? name, - String? symbol, - int? chainId, - String? coinGeckoId, - String? rpcUrl, - String? iconPath, - String? tokensPath}); +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,name,symbol,chainId,coinGeckoId,rpcUrl,iconPath,tokensPath); + +@override +String toString() { + return 'Network(name: $name, symbol: $symbol, chainId: $chainId, coinGeckoId: $coinGeckoId, rpcUrl: $rpcUrl, iconPath: $iconPath, tokensPath: $tokensPath)'; } + +} + +/// @nodoc +abstract mixin class $NetworkCopyWith<$Res> { + factory $NetworkCopyWith(Network value, $Res Function(Network) _then) = _$NetworkCopyWithImpl; +@useResult +$Res call({ + String? name, String? symbol, int? chainId, String? coinGeckoId, String? rpcUrl, String? iconPath, String? tokensPath +}); + + + + +} /// @nodoc -class _$NetworkCopyWithImpl<$Res, $Val extends Network> +class _$NetworkCopyWithImpl<$Res> implements $NetworkCopyWith<$Res> { - _$NetworkCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of Network - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? name = freezed, - Object? symbol = freezed, - Object? chainId = freezed, - Object? coinGeckoId = freezed, - Object? rpcUrl = freezed, - Object? iconPath = freezed, - Object? tokensPath = freezed, - }) { - return _then(_value.copyWith( - name: freezed == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String?, - symbol: freezed == symbol - ? _value.symbol - : symbol // ignore: cast_nullable_to_non_nullable - as String?, - chainId: freezed == chainId - ? _value.chainId - : chainId // ignore: cast_nullable_to_non_nullable - as int?, - coinGeckoId: freezed == coinGeckoId - ? _value.coinGeckoId - : coinGeckoId // ignore: cast_nullable_to_non_nullable - as String?, - rpcUrl: freezed == rpcUrl - ? _value.rpcUrl - : rpcUrl // ignore: cast_nullable_to_non_nullable - as String?, - iconPath: freezed == iconPath - ? _value.iconPath - : iconPath // ignore: cast_nullable_to_non_nullable - as String?, - tokensPath: freezed == tokensPath - ? _value.tokensPath - : tokensPath // ignore: cast_nullable_to_non_nullable - as String?, - ) as $Val); - } + _$NetworkCopyWithImpl(this._self, this._then); + + final Network _self; + final $Res Function(Network) _then; + +/// Create a copy of Network +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? name = freezed,Object? symbol = freezed,Object? chainId = freezed,Object? coinGeckoId = freezed,Object? rpcUrl = freezed,Object? iconPath = freezed,Object? tokensPath = freezed,}) { + return _then(_self.copyWith( +name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String?,symbol: freezed == symbol ? _self.symbol : symbol // ignore: cast_nullable_to_non_nullable +as String?,chainId: freezed == chainId ? _self.chainId : chainId // ignore: cast_nullable_to_non_nullable +as int?,coinGeckoId: freezed == coinGeckoId ? _self.coinGeckoId : coinGeckoId // ignore: cast_nullable_to_non_nullable +as String?,rpcUrl: freezed == rpcUrl ? _self.rpcUrl : rpcUrl // ignore: cast_nullable_to_non_nullable +as String?,iconPath: freezed == iconPath ? _self.iconPath : iconPath // ignore: cast_nullable_to_non_nullable +as String?,tokensPath: freezed == tokensPath ? _self.tokensPath : tokensPath // ignore: cast_nullable_to_non_nullable +as String?, + )); } -/// @nodoc -abstract class _$$NetworkImplCopyWith<$Res> implements $NetworkCopyWith<$Res> { - factory _$$NetworkImplCopyWith( - _$NetworkImpl value, $Res Function(_$NetworkImpl) then) = - __$$NetworkImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {String? name, - String? symbol, - int? chainId, - String? coinGeckoId, - String? rpcUrl, - String? iconPath, - String? tokensPath}); } -/// @nodoc -class __$$NetworkImplCopyWithImpl<$Res> - extends _$NetworkCopyWithImpl<$Res, _$NetworkImpl> - implements _$$NetworkImplCopyWith<$Res> { - __$$NetworkImplCopyWithImpl( - _$NetworkImpl _value, $Res Function(_$NetworkImpl) _then) - : super(_value, _then); - - /// Create a copy of Network - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? name = freezed, - Object? symbol = freezed, - Object? chainId = freezed, - Object? coinGeckoId = freezed, - Object? rpcUrl = freezed, - Object? iconPath = freezed, - Object? tokensPath = freezed, - }) { - return _then(_$NetworkImpl( - name: freezed == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String?, - symbol: freezed == symbol - ? _value.symbol - : symbol // ignore: cast_nullable_to_non_nullable - as String?, - chainId: freezed == chainId - ? _value.chainId - : chainId // ignore: cast_nullable_to_non_nullable - as int?, - coinGeckoId: freezed == coinGeckoId - ? _value.coinGeckoId - : coinGeckoId // ignore: cast_nullable_to_non_nullable - as String?, - rpcUrl: freezed == rpcUrl - ? _value.rpcUrl - : rpcUrl // ignore: cast_nullable_to_non_nullable - as String?, - iconPath: freezed == iconPath - ? _value.iconPath - : iconPath // ignore: cast_nullable_to_non_nullable - as String?, - tokensPath: freezed == tokensPath - ? _value.tokensPath - : tokensPath // ignore: cast_nullable_to_non_nullable - as String?, - )); - } + +/// Adds pattern-matching-related methods to [Network]. +extension NetworkPatterns on Network { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _Network value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Network() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _Network value) $default,){ +final _that = this; +switch (_that) { +case _Network(): +return $default(_that);} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _Network value)? $default,){ +final _that = this; +switch (_that) { +case _Network() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( String? name, String? symbol, int? chainId, String? coinGeckoId, String? rpcUrl, String? iconPath, String? tokensPath)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Network() when $default != null: +return $default(_that.name,_that.symbol,_that.chainId,_that.coinGeckoId,_that.rpcUrl,_that.iconPath,_that.tokensPath);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( String? name, String? symbol, int? chainId, String? coinGeckoId, String? rpcUrl, String? iconPath, String? tokensPath) $default,) {final _that = this; +switch (_that) { +case _Network(): +return $default(_that.name,_that.symbol,_that.chainId,_that.coinGeckoId,_that.rpcUrl,_that.iconPath,_that.tokensPath);} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String? name, String? symbol, int? chainId, String? coinGeckoId, String? rpcUrl, String? iconPath, String? tokensPath)? $default,) {final _that = this; +switch (_that) { +case _Network() when $default != null: +return $default(_that.name,_that.symbol,_that.chainId,_that.coinGeckoId,_that.rpcUrl,_that.iconPath,_that.tokensPath);case _: + return null; + +} +} + } /// @nodoc @JsonSerializable() -class _$NetworkImpl implements _Network { - const _$NetworkImpl( - {this.name, - this.symbol, - this.chainId, - this.coinGeckoId, - this.rpcUrl, - this.iconPath, - this.tokensPath}); - - factory _$NetworkImpl.fromJson(Map json) => - _$$NetworkImplFromJson(json); - - @override - final String? name; - @override - final String? symbol; - @override - final int? chainId; - @override - final String? coinGeckoId; - @override - final String? rpcUrl; - @override - final String? iconPath; - @override - final String? tokensPath; - - @override - String toString() { - return 'Network(name: $name, symbol: $symbol, chainId: $chainId, coinGeckoId: $coinGeckoId, rpcUrl: $rpcUrl, iconPath: $iconPath, tokensPath: $tokensPath)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$NetworkImpl && - (identical(other.name, name) || other.name == name) && - (identical(other.symbol, symbol) || other.symbol == symbol) && - (identical(other.chainId, chainId) || other.chainId == chainId) && - (identical(other.coinGeckoId, coinGeckoId) || - other.coinGeckoId == coinGeckoId) && - (identical(other.rpcUrl, rpcUrl) || other.rpcUrl == rpcUrl) && - (identical(other.iconPath, iconPath) || - other.iconPath == iconPath) && - (identical(other.tokensPath, tokensPath) || - other.tokensPath == tokensPath)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, name, symbol, chainId, - coinGeckoId, rpcUrl, iconPath, tokensPath); - - /// Create a copy of Network - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$NetworkImplCopyWith<_$NetworkImpl> get copyWith => - __$$NetworkImplCopyWithImpl<_$NetworkImpl>(this, _$identity); - - @override - Map toJson() { - return _$$NetworkImplToJson( - this, - ); - } + +class _Network implements Network { + const _Network({this.name, this.symbol, this.chainId, this.coinGeckoId, this.rpcUrl, this.iconPath, this.tokensPath}); + factory _Network.fromJson(Map json) => _$NetworkFromJson(json); + +@override final String? name; +@override final String? symbol; +@override final int? chainId; +@override final String? coinGeckoId; +@override final String? rpcUrl; +@override final String? iconPath; +@override final String? tokensPath; + +/// Create a copy of Network +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$NetworkCopyWith<_Network> get copyWith => __$NetworkCopyWithImpl<_Network>(this, _$identity); + +@override +Map toJson() { + return _$NetworkToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Network&&(identical(other.name, name) || other.name == name)&&(identical(other.symbol, symbol) || other.symbol == symbol)&&(identical(other.chainId, chainId) || other.chainId == chainId)&&(identical(other.coinGeckoId, coinGeckoId) || other.coinGeckoId == coinGeckoId)&&(identical(other.rpcUrl, rpcUrl) || other.rpcUrl == rpcUrl)&&(identical(other.iconPath, iconPath) || other.iconPath == iconPath)&&(identical(other.tokensPath, tokensPath) || other.tokensPath == tokensPath)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,name,symbol,chainId,coinGeckoId,rpcUrl,iconPath,tokensPath); + +@override +String toString() { + return 'Network(name: $name, symbol: $symbol, chainId: $chainId, coinGeckoId: $coinGeckoId, rpcUrl: $rpcUrl, iconPath: $iconPath, tokensPath: $tokensPath)'; } -abstract class _Network implements Network { - const factory _Network( - {final String? name, - final String? symbol, - final int? chainId, - final String? coinGeckoId, - final String? rpcUrl, - final String? iconPath, - final String? tokensPath}) = _$NetworkImpl; - - factory _Network.fromJson(Map json) = _$NetworkImpl.fromJson; - - @override - String? get name; - @override - String? get symbol; - @override - int? get chainId; - @override - String? get coinGeckoId; - @override - String? get rpcUrl; - @override - String? get iconPath; - @override - String? get tokensPath; - - /// Create a copy of Network - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$NetworkImplCopyWith<_$NetworkImpl> get copyWith => - throw _privateConstructorUsedError; + +} + +/// @nodoc +abstract mixin class _$NetworkCopyWith<$Res> implements $NetworkCopyWith<$Res> { + factory _$NetworkCopyWith(_Network value, $Res Function(_Network) _then) = __$NetworkCopyWithImpl; +@override @useResult +$Res call({ + String? name, String? symbol, int? chainId, String? coinGeckoId, String? rpcUrl, String? iconPath, String? tokensPath +}); + + + + } +/// @nodoc +class __$NetworkCopyWithImpl<$Res> + implements _$NetworkCopyWith<$Res> { + __$NetworkCopyWithImpl(this._self, this._then); + + final _Network _self; + final $Res Function(_Network) _then; + +/// Create a copy of Network +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? name = freezed,Object? symbol = freezed,Object? chainId = freezed,Object? coinGeckoId = freezed,Object? rpcUrl = freezed,Object? iconPath = freezed,Object? tokensPath = freezed,}) { + return _then(_Network( +name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String?,symbol: freezed == symbol ? _self.symbol : symbol // ignore: cast_nullable_to_non_nullable +as String?,chainId: freezed == chainId ? _self.chainId : chainId // ignore: cast_nullable_to_non_nullable +as int?,coinGeckoId: freezed == coinGeckoId ? _self.coinGeckoId : coinGeckoId // ignore: cast_nullable_to_non_nullable +as String?,rpcUrl: freezed == rpcUrl ? _self.rpcUrl : rpcUrl // ignore: cast_nullable_to_non_nullable +as String?,iconPath: freezed == iconPath ? _self.iconPath : iconPath // ignore: cast_nullable_to_non_nullable +as String?,tokensPath: freezed == tokensPath ? _self.tokensPath : tokensPath // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + + +} + +// dart format on diff --git a/packages/genius_api/lib/models/network.g.dart b/packages/genius_api/lib/models/network.g.dart index 59933444..54883147 100644 --- a/packages/genius_api/lib/models/network.g.dart +++ b/packages/genius_api/lib/models/network.g.dart @@ -6,24 +6,22 @@ part of 'network.dart'; // JsonSerializableGenerator // ************************************************************************** -_$NetworkImpl _$$NetworkImplFromJson(Map json) => - _$NetworkImpl( - name: json['name'] as String?, - symbol: json['symbol'] as String?, - chainId: (json['chainId'] as num?)?.toInt(), - coinGeckoId: json['coinGeckoId'] as String?, - rpcUrl: json['rpcUrl'] as String?, - iconPath: json['iconPath'] as String?, - tokensPath: json['tokensPath'] as String?, - ); +_Network _$NetworkFromJson(Map json) => _Network( + name: json['name'] as String?, + symbol: json['symbol'] as String?, + chainId: (json['chainId'] as num?)?.toInt(), + coinGeckoId: json['coinGeckoId'] as String?, + rpcUrl: json['rpcUrl'] as String?, + iconPath: json['iconPath'] as String?, + tokensPath: json['tokensPath'] as String?, +); -Map _$$NetworkImplToJson(_$NetworkImpl instance) => - { - 'name': instance.name, - 'symbol': instance.symbol, - 'chainId': instance.chainId, - 'coinGeckoId': instance.coinGeckoId, - 'rpcUrl': instance.rpcUrl, - 'iconPath': instance.iconPath, - 'tokensPath': instance.tokensPath, - }; +Map _$NetworkToJson(_Network instance) => { + 'name': instance.name, + 'symbol': instance.symbol, + 'chainId': instance.chainId, + 'coinGeckoId': instance.coinGeckoId, + 'rpcUrl': instance.rpcUrl, + 'iconPath': instance.iconPath, + 'tokensPath': instance.tokensPath, +}; diff --git a/packages/genius_api/lib/models/news.dart b/packages/genius_api/lib/models/news.dart index 42ccbb3f..c6aeaeae 100644 --- a/packages/genius_api/lib/models/news.dart +++ b/packages/genius_api/lib/models/news.dart @@ -4,9 +4,13 @@ part 'news.freezed.dart'; part 'news.g.dart'; @freezed -class News with _$News { - const factory News( - {String? headline, String? body, String? date, String? imgSrc}) = _News; +sealed class News with _$News { + const factory News({ + String? headline, + String? body, + String? date, + String? imgSrc, + }) = _News; factory News.fromJson(Map json) => _$NewsFromJson(json); } diff --git a/packages/genius_api/lib/models/news.freezed.dart b/packages/genius_api/lib/models/news.freezed.dart index 8a2ed730..8125c7df 100644 --- a/packages/genius_api/lib/models/news.freezed.dart +++ b/packages/genius_api/lib/models/news.freezed.dart @@ -1,5 +1,5 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file // ignore_for_file: type=lint // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark @@ -9,204 +9,272 @@ part of 'news.dart'; // FreezedGenerator // ************************************************************************** +// dart format off T _$identity(T value) => value; -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); - -News _$NewsFromJson(Map json) { - return _News.fromJson(json); -} - /// @nodoc mixin _$News { - String? get headline => throw _privateConstructorUsedError; - String? get body => throw _privateConstructorUsedError; - String? get date => throw _privateConstructorUsedError; - String? get imgSrc => throw _privateConstructorUsedError; + + String? get headline; String? get body; String? get date; String? get imgSrc; +/// Create a copy of News +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$NewsCopyWith get copyWith => _$NewsCopyWithImpl(this as News, _$identity); /// Serializes this News to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + - /// Create a copy of News - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $NewsCopyWith get copyWith => throw _privateConstructorUsedError; +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is News&&(identical(other.headline, headline) || other.headline == headline)&&(identical(other.body, body) || other.body == body)&&(identical(other.date, date) || other.date == date)&&(identical(other.imgSrc, imgSrc) || other.imgSrc == imgSrc)); } -/// @nodoc -abstract class $NewsCopyWith<$Res> { - factory $NewsCopyWith(News value, $Res Function(News) then) = - _$NewsCopyWithImpl<$Res, News>; - @useResult - $Res call({String? headline, String? body, String? date, String? imgSrc}); +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,headline,body,date,imgSrc); + +@override +String toString() { + return 'News(headline: $headline, body: $body, date: $date, imgSrc: $imgSrc)'; } + +} + +/// @nodoc +abstract mixin class $NewsCopyWith<$Res> { + factory $NewsCopyWith(News value, $Res Function(News) _then) = _$NewsCopyWithImpl; +@useResult +$Res call({ + String? headline, String? body, String? date, String? imgSrc +}); + + + + +} /// @nodoc -class _$NewsCopyWithImpl<$Res, $Val extends News> +class _$NewsCopyWithImpl<$Res> implements $NewsCopyWith<$Res> { - _$NewsCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of News - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? headline = freezed, - Object? body = freezed, - Object? date = freezed, - Object? imgSrc = freezed, - }) { - return _then(_value.copyWith( - headline: freezed == headline - ? _value.headline - : headline // ignore: cast_nullable_to_non_nullable - as String?, - body: freezed == body - ? _value.body - : body // ignore: cast_nullable_to_non_nullable - as String?, - date: freezed == date - ? _value.date - : date // ignore: cast_nullable_to_non_nullable - as String?, - imgSrc: freezed == imgSrc - ? _value.imgSrc - : imgSrc // ignore: cast_nullable_to_non_nullable - as String?, - ) as $Val); - } + _$NewsCopyWithImpl(this._self, this._then); + + final News _self; + final $Res Function(News) _then; + +/// Create a copy of News +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? headline = freezed,Object? body = freezed,Object? date = freezed,Object? imgSrc = freezed,}) { + return _then(_self.copyWith( +headline: freezed == headline ? _self.headline : headline // ignore: cast_nullable_to_non_nullable +as String?,body: freezed == body ? _self.body : body // ignore: cast_nullable_to_non_nullable +as String?,date: freezed == date ? _self.date : date // ignore: cast_nullable_to_non_nullable +as String?,imgSrc: freezed == imgSrc ? _self.imgSrc : imgSrc // ignore: cast_nullable_to_non_nullable +as String?, + )); } -/// @nodoc -abstract class _$$NewsImplCopyWith<$Res> implements $NewsCopyWith<$Res> { - factory _$$NewsImplCopyWith( - _$NewsImpl value, $Res Function(_$NewsImpl) then) = - __$$NewsImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({String? headline, String? body, String? date, String? imgSrc}); } -/// @nodoc -class __$$NewsImplCopyWithImpl<$Res> - extends _$NewsCopyWithImpl<$Res, _$NewsImpl> - implements _$$NewsImplCopyWith<$Res> { - __$$NewsImplCopyWithImpl(_$NewsImpl _value, $Res Function(_$NewsImpl) _then) - : super(_value, _then); - - /// Create a copy of News - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? headline = freezed, - Object? body = freezed, - Object? date = freezed, - Object? imgSrc = freezed, - }) { - return _then(_$NewsImpl( - headline: freezed == headline - ? _value.headline - : headline // ignore: cast_nullable_to_non_nullable - as String?, - body: freezed == body - ? _value.body - : body // ignore: cast_nullable_to_non_nullable - as String?, - date: freezed == date - ? _value.date - : date // ignore: cast_nullable_to_non_nullable - as String?, - imgSrc: freezed == imgSrc - ? _value.imgSrc - : imgSrc // ignore: cast_nullable_to_non_nullable - as String?, - )); - } + +/// Adds pattern-matching-related methods to [News]. +extension NewsPatterns on News { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _News value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _News() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _News value) $default,){ +final _that = this; +switch (_that) { +case _News(): +return $default(_that);} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _News value)? $default,){ +final _that = this; +switch (_that) { +case _News() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( String? headline, String? body, String? date, String? imgSrc)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _News() when $default != null: +return $default(_that.headline,_that.body,_that.date,_that.imgSrc);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( String? headline, String? body, String? date, String? imgSrc) $default,) {final _that = this; +switch (_that) { +case _News(): +return $default(_that.headline,_that.body,_that.date,_that.imgSrc);} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String? headline, String? body, String? date, String? imgSrc)? $default,) {final _that = this; +switch (_that) { +case _News() when $default != null: +return $default(_that.headline,_that.body,_that.date,_that.imgSrc);case _: + return null; + +} +} + } /// @nodoc @JsonSerializable() -class _$NewsImpl implements _News { - const _$NewsImpl({this.headline, this.body, this.date, this.imgSrc}); - - factory _$NewsImpl.fromJson(Map json) => - _$$NewsImplFromJson(json); - - @override - final String? headline; - @override - final String? body; - @override - final String? date; - @override - final String? imgSrc; - - @override - String toString() { - return 'News(headline: $headline, body: $body, date: $date, imgSrc: $imgSrc)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$NewsImpl && - (identical(other.headline, headline) || - other.headline == headline) && - (identical(other.body, body) || other.body == body) && - (identical(other.date, date) || other.date == date) && - (identical(other.imgSrc, imgSrc) || other.imgSrc == imgSrc)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, headline, body, date, imgSrc); - - /// Create a copy of News - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$NewsImplCopyWith<_$NewsImpl> get copyWith => - __$$NewsImplCopyWithImpl<_$NewsImpl>(this, _$identity); - - @override - Map toJson() { - return _$$NewsImplToJson( - this, - ); - } -} - -abstract class _News implements News { - const factory _News( - {final String? headline, - final String? body, - final String? date, - final String? imgSrc}) = _$NewsImpl; - - factory _News.fromJson(Map json) = _$NewsImpl.fromJson; - - @override - String? get headline; - @override - String? get body; - @override - String? get date; - @override - String? get imgSrc; - - /// Create a copy of News - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$NewsImplCopyWith<_$NewsImpl> get copyWith => - throw _privateConstructorUsedError; + +class _News implements News { + const _News({this.headline, this.body, this.date, this.imgSrc}); + factory _News.fromJson(Map json) => _$NewsFromJson(json); + +@override final String? headline; +@override final String? body; +@override final String? date; +@override final String? imgSrc; + +/// Create a copy of News +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$NewsCopyWith<_News> get copyWith => __$NewsCopyWithImpl<_News>(this, _$identity); + +@override +Map toJson() { + return _$NewsToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _News&&(identical(other.headline, headline) || other.headline == headline)&&(identical(other.body, body) || other.body == body)&&(identical(other.date, date) || other.date == date)&&(identical(other.imgSrc, imgSrc) || other.imgSrc == imgSrc)); } + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,headline,body,date,imgSrc); + +@override +String toString() { + return 'News(headline: $headline, body: $body, date: $date, imgSrc: $imgSrc)'; +} + + +} + +/// @nodoc +abstract mixin class _$NewsCopyWith<$Res> implements $NewsCopyWith<$Res> { + factory _$NewsCopyWith(_News value, $Res Function(_News) _then) = __$NewsCopyWithImpl; +@override @useResult +$Res call({ + String? headline, String? body, String? date, String? imgSrc +}); + + + + +} +/// @nodoc +class __$NewsCopyWithImpl<$Res> + implements _$NewsCopyWith<$Res> { + __$NewsCopyWithImpl(this._self, this._then); + + final _News _self; + final $Res Function(_News) _then; + +/// Create a copy of News +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? headline = freezed,Object? body = freezed,Object? date = freezed,Object? imgSrc = freezed,}) { + return _then(_News( +headline: freezed == headline ? _self.headline : headline // ignore: cast_nullable_to_non_nullable +as String?,body: freezed == body ? _self.body : body // ignore: cast_nullable_to_non_nullable +as String?,date: freezed == date ? _self.date : date // ignore: cast_nullable_to_non_nullable +as String?,imgSrc: freezed == imgSrc ? _self.imgSrc : imgSrc // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + + +} + +// dart format on diff --git a/packages/genius_api/lib/models/token.dart b/packages/genius_api/lib/models/token.dart index 11483f75..f0d2cc75 100644 --- a/packages/genius_api/lib/models/token.dart +++ b/packages/genius_api/lib/models/token.dart @@ -4,7 +4,7 @@ part 'token.freezed.dart'; part 'token.g.dart'; @freezed -class Token with _$Token { +sealed class Token with _$Token { const factory Token( {String? address, String? iconPath, diff --git a/packages/genius_api/lib/models/token.freezed.dart b/packages/genius_api/lib/models/token.freezed.dart index 75e5f034..50df2a5c 100644 --- a/packages/genius_api/lib/models/token.freezed.dart +++ b/packages/genius_api/lib/models/token.freezed.dart @@ -1,5 +1,5 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file // ignore_for_file: type=lint // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark @@ -9,209 +9,272 @@ part of 'token.dart'; // FreezedGenerator // ************************************************************************** +// dart format off T _$identity(T value) => value; -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); - -Token _$TokenFromJson(Map json) { - return _Token.fromJson(json); -} - /// @nodoc mixin _$Token { - String? get address => throw _privateConstructorUsedError; - String? get iconPath => throw _privateConstructorUsedError; - String? get name => throw _privateConstructorUsedError; - String? get coinGeckoId => throw _privateConstructorUsedError; + + String? get address; String? get iconPath; String? get name; String? get coinGeckoId; +/// Create a copy of Token +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$TokenCopyWith get copyWith => _$TokenCopyWithImpl(this as Token, _$identity); /// Serializes this Token to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + - /// Create a copy of Token - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $TokenCopyWith get copyWith => throw _privateConstructorUsedError; +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is Token&&(identical(other.address, address) || other.address == address)&&(identical(other.iconPath, iconPath) || other.iconPath == iconPath)&&(identical(other.name, name) || other.name == name)&&(identical(other.coinGeckoId, coinGeckoId) || other.coinGeckoId == coinGeckoId)); } -/// @nodoc -abstract class $TokenCopyWith<$Res> { - factory $TokenCopyWith(Token value, $Res Function(Token) then) = - _$TokenCopyWithImpl<$Res, Token>; - @useResult - $Res call( - {String? address, String? iconPath, String? name, String? coinGeckoId}); +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,address,iconPath,name,coinGeckoId); + +@override +String toString() { + return 'Token(address: $address, iconPath: $iconPath, name: $name, coinGeckoId: $coinGeckoId)'; } + +} + +/// @nodoc +abstract mixin class $TokenCopyWith<$Res> { + factory $TokenCopyWith(Token value, $Res Function(Token) _then) = _$TokenCopyWithImpl; +@useResult +$Res call({ + String? address, String? iconPath, String? name, String? coinGeckoId +}); + + + + +} /// @nodoc -class _$TokenCopyWithImpl<$Res, $Val extends Token> +class _$TokenCopyWithImpl<$Res> implements $TokenCopyWith<$Res> { - _$TokenCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of Token - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? address = freezed, - Object? iconPath = freezed, - Object? name = freezed, - Object? coinGeckoId = freezed, - }) { - return _then(_value.copyWith( - address: freezed == address - ? _value.address - : address // ignore: cast_nullable_to_non_nullable - as String?, - iconPath: freezed == iconPath - ? _value.iconPath - : iconPath // ignore: cast_nullable_to_non_nullable - as String?, - name: freezed == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String?, - coinGeckoId: freezed == coinGeckoId - ? _value.coinGeckoId - : coinGeckoId // ignore: cast_nullable_to_non_nullable - as String?, - ) as $Val); - } + _$TokenCopyWithImpl(this._self, this._then); + + final Token _self; + final $Res Function(Token) _then; + +/// Create a copy of Token +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? address = freezed,Object? iconPath = freezed,Object? name = freezed,Object? coinGeckoId = freezed,}) { + return _then(_self.copyWith( +address: freezed == address ? _self.address : address // ignore: cast_nullable_to_non_nullable +as String?,iconPath: freezed == iconPath ? _self.iconPath : iconPath // ignore: cast_nullable_to_non_nullable +as String?,name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String?,coinGeckoId: freezed == coinGeckoId ? _self.coinGeckoId : coinGeckoId // ignore: cast_nullable_to_non_nullable +as String?, + )); } -/// @nodoc -abstract class _$$TokenImplCopyWith<$Res> implements $TokenCopyWith<$Res> { - factory _$$TokenImplCopyWith( - _$TokenImpl value, $Res Function(_$TokenImpl) then) = - __$$TokenImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {String? address, String? iconPath, String? name, String? coinGeckoId}); } -/// @nodoc -class __$$TokenImplCopyWithImpl<$Res> - extends _$TokenCopyWithImpl<$Res, _$TokenImpl> - implements _$$TokenImplCopyWith<$Res> { - __$$TokenImplCopyWithImpl( - _$TokenImpl _value, $Res Function(_$TokenImpl) _then) - : super(_value, _then); - - /// Create a copy of Token - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? address = freezed, - Object? iconPath = freezed, - Object? name = freezed, - Object? coinGeckoId = freezed, - }) { - return _then(_$TokenImpl( - address: freezed == address - ? _value.address - : address // ignore: cast_nullable_to_non_nullable - as String?, - iconPath: freezed == iconPath - ? _value.iconPath - : iconPath // ignore: cast_nullable_to_non_nullable - as String?, - name: freezed == name - ? _value.name - : name // ignore: cast_nullable_to_non_nullable - as String?, - coinGeckoId: freezed == coinGeckoId - ? _value.coinGeckoId - : coinGeckoId // ignore: cast_nullable_to_non_nullable - as String?, - )); - } + +/// Adds pattern-matching-related methods to [Token]. +extension TokenPatterns on Token { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _Token value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Token() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _Token value) $default,){ +final _that = this; +switch (_that) { +case _Token(): +return $default(_that);} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _Token value)? $default,){ +final _that = this; +switch (_that) { +case _Token() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( String? address, String? iconPath, String? name, String? coinGeckoId)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Token() when $default != null: +return $default(_that.address,_that.iconPath,_that.name,_that.coinGeckoId);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( String? address, String? iconPath, String? name, String? coinGeckoId) $default,) {final _that = this; +switch (_that) { +case _Token(): +return $default(_that.address,_that.iconPath,_that.name,_that.coinGeckoId);} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String? address, String? iconPath, String? name, String? coinGeckoId)? $default,) {final _that = this; +switch (_that) { +case _Token() when $default != null: +return $default(_that.address,_that.iconPath,_that.name,_that.coinGeckoId);case _: + return null; + +} +} + } /// @nodoc @JsonSerializable() -class _$TokenImpl implements _Token { - const _$TokenImpl({this.address, this.iconPath, this.name, this.coinGeckoId}); - - factory _$TokenImpl.fromJson(Map json) => - _$$TokenImplFromJson(json); - - @override - final String? address; - @override - final String? iconPath; - @override - final String? name; - @override - final String? coinGeckoId; - - @override - String toString() { - return 'Token(address: $address, iconPath: $iconPath, name: $name, coinGeckoId: $coinGeckoId)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$TokenImpl && - (identical(other.address, address) || other.address == address) && - (identical(other.iconPath, iconPath) || - other.iconPath == iconPath) && - (identical(other.name, name) || other.name == name) && - (identical(other.coinGeckoId, coinGeckoId) || - other.coinGeckoId == coinGeckoId)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => - Object.hash(runtimeType, address, iconPath, name, coinGeckoId); - - /// Create a copy of Token - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$TokenImplCopyWith<_$TokenImpl> get copyWith => - __$$TokenImplCopyWithImpl<_$TokenImpl>(this, _$identity); - - @override - Map toJson() { - return _$$TokenImplToJson( - this, - ); - } -} - -abstract class _Token implements Token { - const factory _Token( - {final String? address, - final String? iconPath, - final String? name, - final String? coinGeckoId}) = _$TokenImpl; - - factory _Token.fromJson(Map json) = _$TokenImpl.fromJson; - - @override - String? get address; - @override - String? get iconPath; - @override - String? get name; - @override - String? get coinGeckoId; - - /// Create a copy of Token - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$TokenImplCopyWith<_$TokenImpl> get copyWith => - throw _privateConstructorUsedError; + +class _Token implements Token { + const _Token({this.address, this.iconPath, this.name, this.coinGeckoId}); + factory _Token.fromJson(Map json) => _$TokenFromJson(json); + +@override final String? address; +@override final String? iconPath; +@override final String? name; +@override final String? coinGeckoId; + +/// Create a copy of Token +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$TokenCopyWith<_Token> get copyWith => __$TokenCopyWithImpl<_Token>(this, _$identity); + +@override +Map toJson() { + return _$TokenToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Token&&(identical(other.address, address) || other.address == address)&&(identical(other.iconPath, iconPath) || other.iconPath == iconPath)&&(identical(other.name, name) || other.name == name)&&(identical(other.coinGeckoId, coinGeckoId) || other.coinGeckoId == coinGeckoId)); } + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,address,iconPath,name,coinGeckoId); + +@override +String toString() { + return 'Token(address: $address, iconPath: $iconPath, name: $name, coinGeckoId: $coinGeckoId)'; +} + + +} + +/// @nodoc +abstract mixin class _$TokenCopyWith<$Res> implements $TokenCopyWith<$Res> { + factory _$TokenCopyWith(_Token value, $Res Function(_Token) _then) = __$TokenCopyWithImpl; +@override @useResult +$Res call({ + String? address, String? iconPath, String? name, String? coinGeckoId +}); + + + + +} +/// @nodoc +class __$TokenCopyWithImpl<$Res> + implements _$TokenCopyWith<$Res> { + __$TokenCopyWithImpl(this._self, this._then); + + final _Token _self; + final $Res Function(_Token) _then; + +/// Create a copy of Token +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? address = freezed,Object? iconPath = freezed,Object? name = freezed,Object? coinGeckoId = freezed,}) { + return _then(_Token( +address: freezed == address ? _self.address : address // ignore: cast_nullable_to_non_nullable +as String?,iconPath: freezed == iconPath ? _self.iconPath : iconPath // ignore: cast_nullable_to_non_nullable +as String?,name: freezed == name ? _self.name : name // ignore: cast_nullable_to_non_nullable +as String?,coinGeckoId: freezed == coinGeckoId ? _self.coinGeckoId : coinGeckoId // ignore: cast_nullable_to_non_nullable +as String?, + )); +} + + +} + +// dart format on diff --git a/packages/genius_api/lib/models/token.g.dart b/packages/genius_api/lib/models/token.g.dart index 09aa1819..e299eaa7 100644 --- a/packages/genius_api/lib/models/token.g.dart +++ b/packages/genius_api/lib/models/token.g.dart @@ -6,17 +6,16 @@ part of 'token.dart'; // JsonSerializableGenerator // ************************************************************************** -_$TokenImpl _$$TokenImplFromJson(Map json) => _$TokenImpl( - address: json['address'] as String?, - iconPath: json['iconPath'] as String?, - name: json['name'] as String?, - coinGeckoId: json['coinGeckoId'] as String?, - ); +_Token _$TokenFromJson(Map json) => _Token( + address: json['address'] as String?, + iconPath: json['iconPath'] as String?, + name: json['name'] as String?, + coinGeckoId: json['coinGeckoId'] as String?, +); -Map _$$TokenImplToJson(_$TokenImpl instance) => - { - 'address': instance.address, - 'iconPath': instance.iconPath, - 'name': instance.name, - 'coinGeckoId': instance.coinGeckoId, - }; +Map _$TokenToJson(_Token instance) => { + 'address': instance.address, + 'iconPath': instance.iconPath, + 'name': instance.name, + 'coinGeckoId': instance.coinGeckoId, +}; diff --git a/packages/genius_api/lib/models/user.dart b/packages/genius_api/lib/models/user.dart index 3f13ad7c..b9cbc7b6 100644 --- a/packages/genius_api/lib/models/user.dart +++ b/packages/genius_api/lib/models/user.dart @@ -5,7 +5,7 @@ part 'user.freezed.dart'; part 'user.g.dart'; @freezed -class User with _$User { +abstract class User with _$User { const factory User({ required String profilePictureUrl, required String nickname, diff --git a/packages/genius_api/lib/models/user.freezed.dart b/packages/genius_api/lib/models/user.freezed.dart index 4be5790a..a62c4521 100644 --- a/packages/genius_api/lib/models/user.freezed.dart +++ b/packages/genius_api/lib/models/user.freezed.dart @@ -1,5 +1,5 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file // ignore_for_file: type=lint // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark @@ -9,294 +9,293 @@ part of 'user.dart'; // FreezedGenerator // ************************************************************************** +// dart format off T _$identity(T value) => value; -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); - -User _$UserFromJson(Map json) { - return _User.fromJson(json); -} - /// @nodoc mixin _$User { - String get profilePictureUrl => throw _privateConstructorUsedError; - String get nickname => throw _privateConstructorUsedError; - String get email => throw _privateConstructorUsedError; - String get firstName => throw _privateConstructorUsedError; - String get lastName => throw _privateConstructorUsedError; - String get dateOfBirth => throw _privateConstructorUsedError; - List get wallets => throw _privateConstructorUsedError; + + String get profilePictureUrl; String get nickname; String get email; String get firstName; String get lastName; String get dateOfBirth; List get wallets; +/// Create a copy of User +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$UserCopyWith get copyWith => _$UserCopyWithImpl(this as User, _$identity); /// Serializes this User to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + - /// Create a copy of User - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $UserCopyWith get copyWith => throw _privateConstructorUsedError; +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is User&&(identical(other.profilePictureUrl, profilePictureUrl) || other.profilePictureUrl == profilePictureUrl)&&(identical(other.nickname, nickname) || other.nickname == nickname)&&(identical(other.email, email) || other.email == email)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.dateOfBirth, dateOfBirth) || other.dateOfBirth == dateOfBirth)&&const DeepCollectionEquality().equals(other.wallets, wallets)); } -/// @nodoc -abstract class $UserCopyWith<$Res> { - factory $UserCopyWith(User value, $Res Function(User) then) = - _$UserCopyWithImpl<$Res, User>; - @useResult - $Res call( - {String profilePictureUrl, - String nickname, - String email, - String firstName, - String lastName, - String dateOfBirth, - List wallets}); +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,profilePictureUrl,nickname,email,firstName,lastName,dateOfBirth,const DeepCollectionEquality().hash(wallets)); + +@override +String toString() { + return 'User(profilePictureUrl: $profilePictureUrl, nickname: $nickname, email: $email, firstName: $firstName, lastName: $lastName, dateOfBirth: $dateOfBirth, wallets: $wallets)'; +} + + } /// @nodoc -class _$UserCopyWithImpl<$Res, $Val extends User> +abstract mixin class $UserCopyWith<$Res> { + factory $UserCopyWith(User value, $Res Function(User) _then) = _$UserCopyWithImpl; +@useResult +$Res call({ + String profilePictureUrl, String nickname, String email, String firstName, String lastName, String dateOfBirth, List wallets +}); + + + + +} +/// @nodoc +class _$UserCopyWithImpl<$Res> implements $UserCopyWith<$Res> { - _$UserCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of User - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? profilePictureUrl = null, - Object? nickname = null, - Object? email = null, - Object? firstName = null, - Object? lastName = null, - Object? dateOfBirth = null, - Object? wallets = null, - }) { - return _then(_value.copyWith( - profilePictureUrl: null == profilePictureUrl - ? _value.profilePictureUrl - : profilePictureUrl // ignore: cast_nullable_to_non_nullable - as String, - nickname: null == nickname - ? _value.nickname - : nickname // ignore: cast_nullable_to_non_nullable - as String, - email: null == email - ? _value.email - : email // ignore: cast_nullable_to_non_nullable - as String, - firstName: null == firstName - ? _value.firstName - : firstName // ignore: cast_nullable_to_non_nullable - as String, - lastName: null == lastName - ? _value.lastName - : lastName // ignore: cast_nullable_to_non_nullable - as String, - dateOfBirth: null == dateOfBirth - ? _value.dateOfBirth - : dateOfBirth // ignore: cast_nullable_to_non_nullable - as String, - wallets: null == wallets - ? _value.wallets - : wallets // ignore: cast_nullable_to_non_nullable - as List, - ) as $Val); - } + _$UserCopyWithImpl(this._self, this._then); + + final User _self; + final $Res Function(User) _then; + +/// Create a copy of User +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? profilePictureUrl = null,Object? nickname = null,Object? email = null,Object? firstName = null,Object? lastName = null,Object? dateOfBirth = null,Object? wallets = null,}) { + return _then(_self.copyWith( +profilePictureUrl: null == profilePictureUrl ? _self.profilePictureUrl : profilePictureUrl // ignore: cast_nullable_to_non_nullable +as String,nickname: null == nickname ? _self.nickname : nickname // ignore: cast_nullable_to_non_nullable +as String,email: null == email ? _self.email : email // ignore: cast_nullable_to_non_nullable +as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable +as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable +as String,dateOfBirth: null == dateOfBirth ? _self.dateOfBirth : dateOfBirth // ignore: cast_nullable_to_non_nullable +as String,wallets: null == wallets ? _self.wallets : wallets // ignore: cast_nullable_to_non_nullable +as List, + )); } -/// @nodoc -abstract class _$$UserImplCopyWith<$Res> implements $UserCopyWith<$Res> { - factory _$$UserImplCopyWith( - _$UserImpl value, $Res Function(_$UserImpl) then) = - __$$UserImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {String profilePictureUrl, - String nickname, - String email, - String firstName, - String lastName, - String dateOfBirth, - List wallets}); } -/// @nodoc -class __$$UserImplCopyWithImpl<$Res> - extends _$UserCopyWithImpl<$Res, _$UserImpl> - implements _$$UserImplCopyWith<$Res> { - __$$UserImplCopyWithImpl(_$UserImpl _value, $Res Function(_$UserImpl) _then) - : super(_value, _then); - - /// Create a copy of User - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? profilePictureUrl = null, - Object? nickname = null, - Object? email = null, - Object? firstName = null, - Object? lastName = null, - Object? dateOfBirth = null, - Object? wallets = null, - }) { - return _then(_$UserImpl( - profilePictureUrl: null == profilePictureUrl - ? _value.profilePictureUrl - : profilePictureUrl // ignore: cast_nullable_to_non_nullable - as String, - nickname: null == nickname - ? _value.nickname - : nickname // ignore: cast_nullable_to_non_nullable - as String, - email: null == email - ? _value.email - : email // ignore: cast_nullable_to_non_nullable - as String, - firstName: null == firstName - ? _value.firstName - : firstName // ignore: cast_nullable_to_non_nullable - as String, - lastName: null == lastName - ? _value.lastName - : lastName // ignore: cast_nullable_to_non_nullable - as String, - dateOfBirth: null == dateOfBirth - ? _value.dateOfBirth - : dateOfBirth // ignore: cast_nullable_to_non_nullable - as String, - wallets: null == wallets - ? _value._wallets - : wallets // ignore: cast_nullable_to_non_nullable - as List, - )); - } + +/// Adds pattern-matching-related methods to [User]. +extension UserPatterns on User { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _User value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _User() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _User value) $default,){ +final _that = this; +switch (_that) { +case _User(): +return $default(_that);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _User value)? $default,){ +final _that = this; +switch (_that) { +case _User() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( String profilePictureUrl, String nickname, String email, String firstName, String lastName, String dateOfBirth, List wallets)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _User() when $default != null: +return $default(_that.profilePictureUrl,_that.nickname,_that.email,_that.firstName,_that.lastName,_that.dateOfBirth,_that.wallets);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( String profilePictureUrl, String nickname, String email, String firstName, String lastName, String dateOfBirth, List wallets) $default,) {final _that = this; +switch (_that) { +case _User(): +return $default(_that.profilePictureUrl,_that.nickname,_that.email,_that.firstName,_that.lastName,_that.dateOfBirth,_that.wallets);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String profilePictureUrl, String nickname, String email, String firstName, String lastName, String dateOfBirth, List wallets)? $default,) {final _that = this; +switch (_that) { +case _User() when $default != null: +return $default(_that.profilePictureUrl,_that.nickname,_that.email,_that.firstName,_that.lastName,_that.dateOfBirth,_that.wallets);case _: + return null; + +} +} + } /// @nodoc @JsonSerializable() -class _$UserImpl implements _User { - const _$UserImpl( - {required this.profilePictureUrl, - required this.nickname, - required this.email, - required this.firstName, - required this.lastName, - required this.dateOfBirth, - required final List wallets}) - : _wallets = wallets; - - factory _$UserImpl.fromJson(Map json) => - _$$UserImplFromJson(json); - - @override - final String profilePictureUrl; - @override - final String nickname; - @override - final String email; - @override - final String firstName; - @override - final String lastName; - @override - final String dateOfBirth; - final List _wallets; - @override - List get wallets { - if (_wallets is EqualUnmodifiableListView) return _wallets; - // ignore: implicit_dynamic_type - return EqualUnmodifiableListView(_wallets); - } - - @override - String toString() { - return 'User(profilePictureUrl: $profilePictureUrl, nickname: $nickname, email: $email, firstName: $firstName, lastName: $lastName, dateOfBirth: $dateOfBirth, wallets: $wallets)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$UserImpl && - (identical(other.profilePictureUrl, profilePictureUrl) || - other.profilePictureUrl == profilePictureUrl) && - (identical(other.nickname, nickname) || - other.nickname == nickname) && - (identical(other.email, email) || other.email == email) && - (identical(other.firstName, firstName) || - other.firstName == firstName) && - (identical(other.lastName, lastName) || - other.lastName == lastName) && - (identical(other.dateOfBirth, dateOfBirth) || - other.dateOfBirth == dateOfBirth) && - const DeepCollectionEquality().equals(other._wallets, _wallets)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash( - runtimeType, - profilePictureUrl, - nickname, - email, - firstName, - lastName, - dateOfBirth, - const DeepCollectionEquality().hash(_wallets)); - - /// Create a copy of User - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$UserImplCopyWith<_$UserImpl> get copyWith => - __$$UserImplCopyWithImpl<_$UserImpl>(this, _$identity); - - @override - Map toJson() { - return _$$UserImplToJson( - this, - ); - } + +class _User implements User { + const _User({required this.profilePictureUrl, required this.nickname, required this.email, required this.firstName, required this.lastName, required this.dateOfBirth, required final List wallets}): _wallets = wallets; + factory _User.fromJson(Map json) => _$UserFromJson(json); + +@override final String profilePictureUrl; +@override final String nickname; +@override final String email; +@override final String firstName; +@override final String lastName; +@override final String dateOfBirth; + final List _wallets; +@override List get wallets { + if (_wallets is EqualUnmodifiableListView) return _wallets; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_wallets); } -abstract class _User implements User { - const factory _User( - {required final String profilePictureUrl, - required final String nickname, - required final String email, - required final String firstName, - required final String lastName, - required final String dateOfBirth, - required final List wallets}) = _$UserImpl; - - factory _User.fromJson(Map json) = _$UserImpl.fromJson; - - @override - String get profilePictureUrl; - @override - String get nickname; - @override - String get email; - @override - String get firstName; - @override - String get lastName; - @override - String get dateOfBirth; - @override - List get wallets; - - /// Create a copy of User - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$UserImplCopyWith<_$UserImpl> get copyWith => - throw _privateConstructorUsedError; + +/// Create a copy of User +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$UserCopyWith<_User> get copyWith => __$UserCopyWithImpl<_User>(this, _$identity); + +@override +Map toJson() { + return _$UserToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _User&&(identical(other.profilePictureUrl, profilePictureUrl) || other.profilePictureUrl == profilePictureUrl)&&(identical(other.nickname, nickname) || other.nickname == nickname)&&(identical(other.email, email) || other.email == email)&&(identical(other.firstName, firstName) || other.firstName == firstName)&&(identical(other.lastName, lastName) || other.lastName == lastName)&&(identical(other.dateOfBirth, dateOfBirth) || other.dateOfBirth == dateOfBirth)&&const DeepCollectionEquality().equals(other._wallets, _wallets)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,profilePictureUrl,nickname,email,firstName,lastName,dateOfBirth,const DeepCollectionEquality().hash(_wallets)); + +@override +String toString() { + return 'User(profilePictureUrl: $profilePictureUrl, nickname: $nickname, email: $email, firstName: $firstName, lastName: $lastName, dateOfBirth: $dateOfBirth, wallets: $wallets)'; } + + +} + +/// @nodoc +abstract mixin class _$UserCopyWith<$Res> implements $UserCopyWith<$Res> { + factory _$UserCopyWith(_User value, $Res Function(_User) _then) = __$UserCopyWithImpl; +@override @useResult +$Res call({ + String profilePictureUrl, String nickname, String email, String firstName, String lastName, String dateOfBirth, List wallets +}); + + + + +} +/// @nodoc +class __$UserCopyWithImpl<$Res> + implements _$UserCopyWith<$Res> { + __$UserCopyWithImpl(this._self, this._then); + + final _User _self; + final $Res Function(_User) _then; + +/// Create a copy of User +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? profilePictureUrl = null,Object? nickname = null,Object? email = null,Object? firstName = null,Object? lastName = null,Object? dateOfBirth = null,Object? wallets = null,}) { + return _then(_User( +profilePictureUrl: null == profilePictureUrl ? _self.profilePictureUrl : profilePictureUrl // ignore: cast_nullable_to_non_nullable +as String,nickname: null == nickname ? _self.nickname : nickname // ignore: cast_nullable_to_non_nullable +as String,email: null == email ? _self.email : email // ignore: cast_nullable_to_non_nullable +as String,firstName: null == firstName ? _self.firstName : firstName // ignore: cast_nullable_to_non_nullable +as String,lastName: null == lastName ? _self.lastName : lastName // ignore: cast_nullable_to_non_nullable +as String,dateOfBirth: null == dateOfBirth ? _self.dateOfBirth : dateOfBirth // ignore: cast_nullable_to_non_nullable +as String,wallets: null == wallets ? _self._wallets : wallets // ignore: cast_nullable_to_non_nullable +as List, + )); +} + + +} + +// dart format on diff --git a/packages/genius_api/lib/models/user.g.dart b/packages/genius_api/lib/models/user.g.dart index 5cc5b59f..d9ef6250 100644 --- a/packages/genius_api/lib/models/user.g.dart +++ b/packages/genius_api/lib/models/user.g.dart @@ -6,25 +6,24 @@ part of 'user.dart'; // JsonSerializableGenerator // ************************************************************************** -_$UserImpl _$$UserImplFromJson(Map json) => _$UserImpl( - profilePictureUrl: json['profilePictureUrl'] as String, - nickname: json['nickname'] as String, - email: json['email'] as String, - firstName: json['firstName'] as String, - lastName: json['lastName'] as String, - dateOfBirth: json['dateOfBirth'] as String, - wallets: (json['wallets'] as List) - .map((e) => Wallet.fromJson(e as Map)) - .toList(), - ); +_User _$UserFromJson(Map json) => _User( + profilePictureUrl: json['profilePictureUrl'] as String, + nickname: json['nickname'] as String, + email: json['email'] as String, + firstName: json['firstName'] as String, + lastName: json['lastName'] as String, + dateOfBirth: json['dateOfBirth'] as String, + wallets: (json['wallets'] as List) + .map((e) => Wallet.fromJson(e as Map)) + .toList(), +); -Map _$$UserImplToJson(_$UserImpl instance) => - { - 'profilePictureUrl': instance.profilePictureUrl, - 'nickname': instance.nickname, - 'email': instance.email, - 'firstName': instance.firstName, - 'lastName': instance.lastName, - 'dateOfBirth': instance.dateOfBirth, - 'wallets': instance.wallets, - }; +Map _$UserToJson(_User instance) => { + 'profilePictureUrl': instance.profilePictureUrl, + 'nickname': instance.nickname, + 'email': instance.email, + 'firstName': instance.firstName, + 'lastName': instance.lastName, + 'dateOfBirth': instance.dateOfBirth, + 'wallets': instance.wallets, +}; diff --git a/packages/genius_api/lib/models/wallet.dart b/packages/genius_api/lib/models/wallet.dart index 214539a5..13c7725c 100644 --- a/packages/genius_api/lib/models/wallet.dart +++ b/packages/genius_api/lib/models/wallet.dart @@ -5,7 +5,7 @@ part 'wallet.freezed.dart'; part 'wallet.g.dart'; @freezed -class Wallet with _$Wallet { +abstract class Wallet with _$Wallet { const factory Wallet({ required TWCoinType coinType, required String walletName, diff --git a/packages/genius_api/lib/models/wallet.freezed.dart b/packages/genius_api/lib/models/wallet.freezed.dart index d4be0020..65604bc3 100644 --- a/packages/genius_api/lib/models/wallet.freezed.dart +++ b/packages/genius_api/lib/models/wallet.freezed.dart @@ -1,5 +1,5 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file // ignore_for_file: type=lint // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark @@ -9,267 +9,286 @@ part of 'wallet.dart'; // FreezedGenerator // ************************************************************************** +// dart format off T _$identity(T value) => value; -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); - -Wallet _$WalletFromJson(Map json) { - return _Wallet.fromJson(json); -} - /// @nodoc mixin _$Wallet { - TWCoinType get coinType => throw _privateConstructorUsedError; - String get walletName => throw _privateConstructorUsedError; - String get currencySymbol => throw _privateConstructorUsedError; - WalletType get walletType => throw _privateConstructorUsedError; - /// The idea for making balance an int is that we store the smallest unit (i.e. satoshis, wei, etc.). However, these can be changed - double get balance => throw _privateConstructorUsedError; - String get address => throw _privateConstructorUsedError; + TWCoinType get coinType; String get walletName; String get currencySymbol; WalletType get walletType;/// The idea for making balance an int is that we store the smallest unit (i.e. satoshis, wei, etc.). However, these can be changed + double get balance; String get address; +/// Create a copy of Wallet +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$WalletCopyWith get copyWith => _$WalletCopyWithImpl(this as Wallet, _$identity); /// Serializes this Wallet to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); - /// Create a copy of Wallet - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $WalletCopyWith get copyWith => throw _privateConstructorUsedError; + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is Wallet&&(identical(other.coinType, coinType) || other.coinType == coinType)&&(identical(other.walletName, walletName) || other.walletName == walletName)&&(identical(other.currencySymbol, currencySymbol) || other.currencySymbol == currencySymbol)&&(identical(other.walletType, walletType) || other.walletType == walletType)&&(identical(other.balance, balance) || other.balance == balance)&&(identical(other.address, address) || other.address == address)); } -/// @nodoc -abstract class $WalletCopyWith<$Res> { - factory $WalletCopyWith(Wallet value, $Res Function(Wallet) then) = - _$WalletCopyWithImpl<$Res, Wallet>; - @useResult - $Res call( - {TWCoinType coinType, - String walletName, - String currencySymbol, - WalletType walletType, - double balance, - String address}); +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,coinType,walletName,currencySymbol,walletType,balance,address); + +@override +String toString() { + return 'Wallet(coinType: $coinType, walletName: $walletName, currencySymbol: $currencySymbol, walletType: $walletType, balance: $balance, address: $address)'; +} + + } /// @nodoc -class _$WalletCopyWithImpl<$Res, $Val extends Wallet> +abstract mixin class $WalletCopyWith<$Res> { + factory $WalletCopyWith(Wallet value, $Res Function(Wallet) _then) = _$WalletCopyWithImpl; +@useResult +$Res call({ + TWCoinType coinType, String walletName, String currencySymbol, WalletType walletType, double balance, String address +}); + + + + +} +/// @nodoc +class _$WalletCopyWithImpl<$Res> implements $WalletCopyWith<$Res> { - _$WalletCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of Wallet - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? coinType = null, - Object? walletName = null, - Object? currencySymbol = null, - Object? walletType = null, - Object? balance = null, - Object? address = null, - }) { - return _then(_value.copyWith( - coinType: null == coinType - ? _value.coinType - : coinType // ignore: cast_nullable_to_non_nullable - as TWCoinType, - walletName: null == walletName - ? _value.walletName - : walletName // ignore: cast_nullable_to_non_nullable - as String, - currencySymbol: null == currencySymbol - ? _value.currencySymbol - : currencySymbol // ignore: cast_nullable_to_non_nullable - as String, - walletType: null == walletType - ? _value.walletType - : walletType // ignore: cast_nullable_to_non_nullable - as WalletType, - balance: null == balance - ? _value.balance - : balance // ignore: cast_nullable_to_non_nullable - as double, - address: null == address - ? _value.address - : address // ignore: cast_nullable_to_non_nullable - as String, - ) as $Val); - } + _$WalletCopyWithImpl(this._self, this._then); + + final Wallet _self; + final $Res Function(Wallet) _then; + +/// Create a copy of Wallet +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? coinType = null,Object? walletName = null,Object? currencySymbol = null,Object? walletType = null,Object? balance = null,Object? address = null,}) { + return _then(_self.copyWith( +coinType: null == coinType ? _self.coinType : coinType // ignore: cast_nullable_to_non_nullable +as TWCoinType,walletName: null == walletName ? _self.walletName : walletName // ignore: cast_nullable_to_non_nullable +as String,currencySymbol: null == currencySymbol ? _self.currencySymbol : currencySymbol // ignore: cast_nullable_to_non_nullable +as String,walletType: null == walletType ? _self.walletType : walletType // ignore: cast_nullable_to_non_nullable +as WalletType,balance: null == balance ? _self.balance : balance // ignore: cast_nullable_to_non_nullable +as double,address: null == address ? _self.address : address // ignore: cast_nullable_to_non_nullable +as String, + )); } -/// @nodoc -abstract class _$$WalletImplCopyWith<$Res> implements $WalletCopyWith<$Res> { - factory _$$WalletImplCopyWith( - _$WalletImpl value, $Res Function(_$WalletImpl) then) = - __$$WalletImplCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {TWCoinType coinType, - String walletName, - String currencySymbol, - WalletType walletType, - double balance, - String address}); } -/// @nodoc -class __$$WalletImplCopyWithImpl<$Res> - extends _$WalletCopyWithImpl<$Res, _$WalletImpl> - implements _$$WalletImplCopyWith<$Res> { - __$$WalletImplCopyWithImpl( - _$WalletImpl _value, $Res Function(_$WalletImpl) _then) - : super(_value, _then); - - /// Create a copy of Wallet - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? coinType = null, - Object? walletName = null, - Object? currencySymbol = null, - Object? walletType = null, - Object? balance = null, - Object? address = null, - }) { - return _then(_$WalletImpl( - coinType: null == coinType - ? _value.coinType - : coinType // ignore: cast_nullable_to_non_nullable - as TWCoinType, - walletName: null == walletName - ? _value.walletName - : walletName // ignore: cast_nullable_to_non_nullable - as String, - currencySymbol: null == currencySymbol - ? _value.currencySymbol - : currencySymbol // ignore: cast_nullable_to_non_nullable - as String, - walletType: null == walletType - ? _value.walletType - : walletType // ignore: cast_nullable_to_non_nullable - as WalletType, - balance: null == balance - ? _value.balance - : balance // ignore: cast_nullable_to_non_nullable - as double, - address: null == address - ? _value.address - : address // ignore: cast_nullable_to_non_nullable - as String, - )); - } + +/// Adds pattern-matching-related methods to [Wallet]. +extension WalletPatterns on Wallet { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _Wallet value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _Wallet() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _Wallet value) $default,){ +final _that = this; +switch (_that) { +case _Wallet(): +return $default(_that);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _Wallet value)? $default,){ +final _that = this; +switch (_that) { +case _Wallet() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( TWCoinType coinType, String walletName, String currencySymbol, WalletType walletType, double balance, String address)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _Wallet() when $default != null: +return $default(_that.coinType,_that.walletName,_that.currencySymbol,_that.walletType,_that.balance,_that.address);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( TWCoinType coinType, String walletName, String currencySymbol, WalletType walletType, double balance, String address) $default,) {final _that = this; +switch (_that) { +case _Wallet(): +return $default(_that.coinType,_that.walletName,_that.currencySymbol,_that.walletType,_that.balance,_that.address);case _: + throw StateError('Unexpected subclass'); + +} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( TWCoinType coinType, String walletName, String currencySymbol, WalletType walletType, double balance, String address)? $default,) {final _that = this; +switch (_that) { +case _Wallet() when $default != null: +return $default(_that.coinType,_that.walletName,_that.currencySymbol,_that.walletType,_that.balance,_that.address);case _: + return null; + +} +} + } /// @nodoc @JsonSerializable() -class _$WalletImpl implements _Wallet { - const _$WalletImpl( - {required this.coinType, - required this.walletName, - required this.currencySymbol, - required this.walletType, - required this.balance, - required this.address}); - - factory _$WalletImpl.fromJson(Map json) => - _$$WalletImplFromJson(json); - - @override - final TWCoinType coinType; - @override - final String walletName; - @override - final String currencySymbol; - @override - final WalletType walletType; - - /// The idea for making balance an int is that we store the smallest unit (i.e. satoshis, wei, etc.). However, these can be changed - @override - final double balance; - @override - final String address; - - @override - String toString() { - return 'Wallet(coinType: $coinType, walletName: $walletName, currencySymbol: $currencySymbol, walletType: $walletType, balance: $balance, address: $address)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$WalletImpl && - (identical(other.coinType, coinType) || - other.coinType == coinType) && - (identical(other.walletName, walletName) || - other.walletName == walletName) && - (identical(other.currencySymbol, currencySymbol) || - other.currencySymbol == currencySymbol) && - (identical(other.walletType, walletType) || - other.walletType == walletType) && - (identical(other.balance, balance) || other.balance == balance) && - (identical(other.address, address) || other.address == address)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => Object.hash(runtimeType, coinType, walletName, - currencySymbol, walletType, balance, address); - - /// Create a copy of Wallet - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$WalletImplCopyWith<_$WalletImpl> get copyWith => - __$$WalletImplCopyWithImpl<_$WalletImpl>(this, _$identity); - - @override - Map toJson() { - return _$$WalletImplToJson( - this, - ); - } + +class _Wallet implements Wallet { + const _Wallet({required this.coinType, required this.walletName, required this.currencySymbol, required this.walletType, required this.balance, required this.address}); + factory _Wallet.fromJson(Map json) => _$WalletFromJson(json); + +@override final TWCoinType coinType; +@override final String walletName; +@override final String currencySymbol; +@override final WalletType walletType; +/// The idea for making balance an int is that we store the smallest unit (i.e. satoshis, wei, etc.). However, these can be changed +@override final double balance; +@override final String address; + +/// Create a copy of Wallet +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$WalletCopyWith<_Wallet> get copyWith => __$WalletCopyWithImpl<_Wallet>(this, _$identity); + +@override +Map toJson() { + return _$WalletToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _Wallet&&(identical(other.coinType, coinType) || other.coinType == coinType)&&(identical(other.walletName, walletName) || other.walletName == walletName)&&(identical(other.currencySymbol, currencySymbol) || other.currencySymbol == currencySymbol)&&(identical(other.walletType, walletType) || other.walletType == walletType)&&(identical(other.balance, balance) || other.balance == balance)&&(identical(other.address, address) || other.address == address)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,coinType,walletName,currencySymbol,walletType,balance,address); + +@override +String toString() { + return 'Wallet(coinType: $coinType, walletName: $walletName, currencySymbol: $currencySymbol, walletType: $walletType, balance: $balance, address: $address)'; +} + + +} + +/// @nodoc +abstract mixin class _$WalletCopyWith<$Res> implements $WalletCopyWith<$Res> { + factory _$WalletCopyWith(_Wallet value, $Res Function(_Wallet) _then) = __$WalletCopyWithImpl; +@override @useResult +$Res call({ + TWCoinType coinType, String walletName, String currencySymbol, WalletType walletType, double balance, String address +}); + + + + } +/// @nodoc +class __$WalletCopyWithImpl<$Res> + implements _$WalletCopyWith<$Res> { + __$WalletCopyWithImpl(this._self, this._then); + + final _Wallet _self; + final $Res Function(_Wallet) _then; -abstract class _Wallet implements Wallet { - const factory _Wallet( - {required final TWCoinType coinType, - required final String walletName, - required final String currencySymbol, - required final WalletType walletType, - required final double balance, - required final String address}) = _$WalletImpl; - - factory _Wallet.fromJson(Map json) = _$WalletImpl.fromJson; - - @override - TWCoinType get coinType; - @override - String get walletName; - @override - String get currencySymbol; - @override - WalletType get walletType; - - /// The idea for making balance an int is that we store the smallest unit (i.e. satoshis, wei, etc.). However, these can be changed - @override - double get balance; - @override - String get address; - - /// Create a copy of Wallet - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$WalletImplCopyWith<_$WalletImpl> get copyWith => - throw _privateConstructorUsedError; +/// Create a copy of Wallet +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? coinType = null,Object? walletName = null,Object? currencySymbol = null,Object? walletType = null,Object? balance = null,Object? address = null,}) { + return _then(_Wallet( +coinType: null == coinType ? _self.coinType : coinType // ignore: cast_nullable_to_non_nullable +as TWCoinType,walletName: null == walletName ? _self.walletName : walletName // ignore: cast_nullable_to_non_nullable +as String,currencySymbol: null == currencySymbol ? _self.currencySymbol : currencySymbol // ignore: cast_nullable_to_non_nullable +as String,walletType: null == walletType ? _self.walletType : walletType // ignore: cast_nullable_to_non_nullable +as WalletType,balance: null == balance ? _self.balance : balance // ignore: cast_nullable_to_non_nullable +as double,address: null == address ? _self.address : address // ignore: cast_nullable_to_non_nullable +as String, + )); } + + +} + +// dart format on diff --git a/packages/genius_api/lib/models/wallet.g.dart b/packages/genius_api/lib/models/wallet.g.dart index 2e98d6f3..6cfa7f47 100644 --- a/packages/genius_api/lib/models/wallet.g.dart +++ b/packages/genius_api/lib/models/wallet.g.dart @@ -6,24 +6,23 @@ part of 'wallet.dart'; // JsonSerializableGenerator // ************************************************************************** -_$WalletImpl _$$WalletImplFromJson(Map json) => _$WalletImpl( - coinType: $enumDecode(_$TWCoinTypeEnumMap, json['coinType']), - walletName: json['walletName'] as String, - currencySymbol: json['currencySymbol'] as String, - walletType: $enumDecode(_$WalletTypeEnumMap, json['walletType']), - balance: (json['balance'] as num).toDouble(), - address: json['address'] as String, - ); +_Wallet _$WalletFromJson(Map json) => _Wallet( + coinType: $enumDecode(_$TWCoinTypeEnumMap, json['coinType']), + walletName: json['walletName'] as String, + currencySymbol: json['currencySymbol'] as String, + walletType: $enumDecode(_$WalletTypeEnumMap, json['walletType']), + balance: (json['balance'] as num).toDouble(), + address: json['address'] as String, +); -Map _$$WalletImplToJson(_$WalletImpl instance) => - { - 'coinType': _$TWCoinTypeEnumMap[instance.coinType]!, - 'walletName': instance.walletName, - 'currencySymbol': instance.currencySymbol, - 'walletType': _$WalletTypeEnumMap[instance.walletType]!, - 'balance': instance.balance, - 'address': instance.address, - }; +Map _$WalletToJson(_Wallet instance) => { + 'coinType': _$TWCoinTypeEnumMap[instance.coinType]!, + 'walletName': instance.walletName, + 'currencySymbol': instance.currencySymbol, + 'walletType': _$WalletTypeEnumMap[instance.walletType]!, + 'balance': instance.balance, + 'address': instance.address, +}; const _$TWCoinTypeEnumMap = { TWCoinType.TWCoinTypeAeternity: 'TWCoinTypeAeternity', diff --git a/packages/genius_api/pubspec.yaml b/packages/genius_api/pubspec.yaml index 7e4fefa9..9b9bea1d 100644 --- a/packages/genius_api/pubspec.yaml +++ b/packages/genius_api/pubspec.yaml @@ -2,12 +2,13 @@ name: genius_api version: 2.0.0 environment: - sdk: ">=3.0.0" + sdk: "^3.8.0" dev_dependencies: ffigen: ^19.1.0 build_runner: ^2.8.0 freezed: ^3.2.3 + json_serializable: ^6.11.1 dependencies: flutter: From 02e764398bd4c2b0a9bc2e2df0e3d7ffb28ea898 Mon Sep 17 00:00:00 2001 From: Eduardo Menges Mattje Date: Wed, 1 Oct 2025 14:58:52 -0300 Subject: [PATCH 4/6] Removed storage permission error message for desktops --- packages/genius_api/lib/src/genius_api.dart | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/genius_api/lib/src/genius_api.dart b/packages/genius_api/lib/src/genius_api.dart index 9ee0483c..9cc86b43 100755 --- a/packages/genius_api/lib/src/genius_api.dart +++ b/packages/genius_api/lib/src/genius_api.dart @@ -48,6 +48,9 @@ class GeniusApi { Future requestPermissions() async { try { + if (Platform.isLinux || Platform.isWindows) { + return; + } if (await Permission.storage.isDenied) { await Permission.storage.request(); } From 41c888cc6b8694779279b7809cc8978d0bf4837e Mon Sep 17 00:00:00 2001 From: Eduardo Menges Mattje Date: Wed, 1 Oct 2025 15:00:25 -0300 Subject: [PATCH 5/6] Added pooling for SDK Transaction Manager status --- lib/account/account_dropdown_selector.dart | 5 +- .../sgnus/sgnus_connection_widget.dart | 40 +- lib/components/sgnus/sgnus_wallet.dart | 2 +- lib/test/dev_overrides.dart | 3 +- .../sgnus_connection_controller.dart | 6 +- .../lib/models/sgnus_connection.dart | 5 +- .../lib/models/sgnus_connection.freezed.dart | 420 ++++++++++-------- .../lib/models/sgnus_connection.g.dart | 25 +- packages/genius_api/lib/src/genius_api.dart | 346 ++++++++++----- .../lib/src/local_secure_storage_base.dart | 2 +- 10 files changed, 534 insertions(+), 320 deletions(-) diff --git a/lib/account/account_dropdown_selector.dart b/lib/account/account_dropdown_selector.dart index 58ab3906..4cddb7cc 100644 --- a/lib/account/account_dropdown_selector.dart +++ b/lib/account/account_dropdown_selector.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:genius_api/ffi/genius_api_ffi.dart'; import 'package:genius_api/ffi/trust_wallet_api_ffi.dart'; import 'package:genius_api/genius_api.dart'; import 'package:genius_api/models/sgnus_connection.dart'; @@ -300,7 +301,9 @@ class _AccountDropdownSelectorState extends State { builder: (context, state) { final connection = snapshot.data; final wallets = [...state.wallets]; - if (connection != null && connection.isConnected) { + if (connection != null && + connection.connection == + GeniusTransactionManagerState.GENIUS_TM_STATE_READY) { wallets.insert( 0, Wallet( diff --git a/lib/components/sgnus/sgnus_connection_widget.dart b/lib/components/sgnus/sgnus_connection_widget.dart index 8c2a1172..f64007e0 100644 --- a/lib/components/sgnus/sgnus_connection_widget.dart +++ b/lib/components/sgnus/sgnus_connection_widget.dart @@ -1,6 +1,7 @@ import 'package:auto_size_text/auto_size_text.dart'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:genius_api/ffi/genius_api_ffi.dart'; import 'package:genius_api/genius_api.dart'; import 'package:genius_api/models/sgnus_connection.dart'; @@ -26,8 +27,8 @@ class SGNUSConnectionState extends State { child: Text('No connection data available'), ); } - final connection = snapshot.data!; + return GestureDetector( onTap: () => context.push('/network'), child: Column( @@ -36,16 +37,20 @@ class SGNUSConnectionState extends State { Row( mainAxisAlignment: MainAxisAlignment.end, children: [ - const Flexible( + Flexible( child: AutoSizeText( maxLines: 1, overflow: TextOverflow.ellipsis, - 'SGNUS Connection ', - style: TextStyle(fontSize: 14), + readableConnectionState(connection.connection), + style: const TextStyle(fontSize: 14), )), const SizedBox(width: 8), - if (connection.isConnected) const CheckmarkAnimation(), - if (!connection.isConnected) const XAnimation(), + if (connection.connection != null && + connection.connection == + GeniusTransactionManagerState.GENIUS_TM_STATE_READY) + const CheckmarkAnimation() + else + const XAnimation(), ], ), ], @@ -84,16 +89,20 @@ class SGNUSConnectionMobileState extends State { Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - const Flexible( + Flexible( child: AutoSizeText( maxLines: 1, overflow: TextOverflow.ellipsis, - 'SGNUS Connection ', + readableConnectionState(connection.connection), style: TextStyle(fontSize: 14), )), const SizedBox(width: 8), - if (connection.isConnected) const CheckmarkAnimation(), - if (!connection.isConnected) const XAnimation(), + if (connection.connection != null && + connection.connection == + GeniusTransactionManagerState.GENIUS_TM_STATE_READY) + const CheckmarkAnimation() + else + const XAnimation(), ], ), ], @@ -103,3 +112,14 @@ class SGNUSConnectionMobileState extends State { ); } } + +String readableConnectionState(GeniusTransactionManagerState? state) { + return 'SGNUS Connection: ${switch (state) { + null => "disconnected", + GeniusTransactionManagerState.GENIUS_TM_STATE_CREATING => "creating", + GeniusTransactionManagerState.GENIUS_TM_STATE_INITIALIZING => + "initializing", + GeniusTransactionManagerState.GENIUS_TM_STATE_SYNCHING => "syncing", + GeniusTransactionManagerState.GENIUS_TM_STATE_READY => "ready", + }}'; +} diff --git a/lib/components/sgnus/sgnus_wallet.dart b/lib/components/sgnus/sgnus_wallet.dart index 9e865703..eb8421f6 100644 --- a/lib/components/sgnus/sgnus_wallet.dart +++ b/lib/components/sgnus/sgnus_wallet.dart @@ -28,7 +28,7 @@ class SGNUSWalletState extends State { final connection = snapshot.data!; - if (connection.isConnected) { + if (connection.connection != null) { return WalletPreview( walletBalance: const Flexible( child: GeniusBalanceDisplay( diff --git a/lib/test/dev_overrides.dart b/lib/test/dev_overrides.dart index 0d4f2ceb..4e8bac4c 100644 --- a/lib/test/dev_overrides.dart +++ b/lib/test/dev_overrides.dart @@ -2,6 +2,7 @@ import 'dart:math'; import 'package:flutter/material.dart'; import 'package:genius_api/controllers/sgnus_transactions_controller.dart'; +import 'package:genius_api/ffi/genius_api_ffi.dart'; import 'package:genius_api/ffi/trust_wallet_api_ffi.dart'; import 'package:genius_api/genius_api.dart'; import 'package:genius_api/models/sgnus_connection.dart'; @@ -26,7 +27,7 @@ void byPassSGNUSConnecton(geniusApi) { geniusApi.getSGNUSController().updateConnection(const SGNUSConnection( sgnusAddress: "0x67890-Bypass", walletAddress: "0x12345-Bypass", - isConnected: true)); + connection: GeniusTransactionManagerState.GENIUS_TM_STATE_READY)); } void byPassWalletCreation(localWalletStorage) { diff --git a/packages/genius_api/lib/controllers/sgnus_connection_controller.dart b/packages/genius_api/lib/controllers/sgnus_connection_controller.dart index 101a3a96..13556df4 100644 --- a/packages/genius_api/lib/controllers/sgnus_connection_controller.dart +++ b/packages/genius_api/lib/controllers/sgnus_connection_controller.dart @@ -5,7 +5,8 @@ import 'package:rxdart/rxdart.dart'; class SGNUSConnectionController { // Private StreamController final _controller = BehaviorSubject.seeded( - SGNUSConnection(sgnusAddress: "", walletAddress: "", isConnected: false)); + SGNUSConnection(sgnusAddress: "", walletAddress: "", connection: null), + ); // Expose the stream for listeners Stream get stream => _controller.stream; @@ -17,7 +18,8 @@ class SGNUSConnectionController { void emptyConnection() { _controller.add(SGNUSConnection( - sgnusAddress: "", walletAddress: "", isConnected: false)); + sgnusAddress: "", walletAddress: "", connection: null), + ); } // Close the controller when done diff --git a/packages/genius_api/lib/models/sgnus_connection.dart b/packages/genius_api/lib/models/sgnus_connection.dart index c8e6b7bb..a19a80ea 100644 --- a/packages/genius_api/lib/models/sgnus_connection.dart +++ b/packages/genius_api/lib/models/sgnus_connection.dart @@ -1,14 +1,15 @@ import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:genius_api/ffi/genius_api_ffi.dart'; part 'sgnus_connection.freezed.dart'; part 'sgnus_connection.g.dart'; @freezed -class SGNUSConnection with _$SGNUSConnection { +sealed class SGNUSConnection with _$SGNUSConnection { const factory SGNUSConnection({ required String sgnusAddress, required String walletAddress, - required bool isConnected, + required GeniusTransactionManagerState? connection, }) = _SGNUSConnection; factory SGNUSConnection.fromJson(Map json) => diff --git a/packages/genius_api/lib/models/sgnus_connection.freezed.dart b/packages/genius_api/lib/models/sgnus_connection.freezed.dart index 22cdad34..a19df45b 100644 --- a/packages/genius_api/lib/models/sgnus_connection.freezed.dart +++ b/packages/genius_api/lib/models/sgnus_connection.freezed.dart @@ -1,5 +1,5 @@ -// coverage:ignore-file // GENERATED CODE - DO NOT MODIFY BY HAND +// coverage:ignore-file // ignore_for_file: type=lint // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark @@ -9,199 +9,269 @@ part of 'sgnus_connection.dart'; // FreezedGenerator // ************************************************************************** +// dart format off T _$identity(T value) => value; -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); - -SGNUSConnection _$SGNUSConnectionFromJson(Map json) { - return _SGNUSConnection.fromJson(json); -} - /// @nodoc mixin _$SGNUSConnection { - String get sgnusAddress => throw _privateConstructorUsedError; - String get walletAddress => throw _privateConstructorUsedError; - bool get isConnected => throw _privateConstructorUsedError; + + String get sgnusAddress; String get walletAddress; GeniusTransactionManagerState? get connection; +/// Create a copy of SGNUSConnection +/// with the given fields replaced by the non-null parameter values. +@JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +$SGNUSConnectionCopyWith get copyWith => _$SGNUSConnectionCopyWithImpl(this as SGNUSConnection, _$identity); /// Serializes this SGNUSConnection to a JSON map. - Map toJson() => throw _privateConstructorUsedError; + Map toJson(); + - /// Create a copy of SGNUSConnection - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - $SGNUSConnectionCopyWith get copyWith => - throw _privateConstructorUsedError; +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is SGNUSConnection&&(identical(other.sgnusAddress, sgnusAddress) || other.sgnusAddress == sgnusAddress)&&(identical(other.walletAddress, walletAddress) || other.walletAddress == walletAddress)&&(identical(other.connection, connection) || other.connection == connection)); } -/// @nodoc -abstract class $SGNUSConnectionCopyWith<$Res> { - factory $SGNUSConnectionCopyWith( - SGNUSConnection value, $Res Function(SGNUSConnection) then) = - _$SGNUSConnectionCopyWithImpl<$Res, SGNUSConnection>; - @useResult - $Res call({String sgnusAddress, String walletAddress, bool isConnected}); +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,sgnusAddress,walletAddress,connection); + +@override +String toString() { + return 'SGNUSConnection(sgnusAddress: $sgnusAddress, walletAddress: $walletAddress, connection: $connection)'; } -/// @nodoc -class _$SGNUSConnectionCopyWithImpl<$Res, $Val extends SGNUSConnection> - implements $SGNUSConnectionCopyWith<$Res> { - _$SGNUSConnectionCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - /// Create a copy of SGNUSConnection - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? sgnusAddress = null, - Object? walletAddress = null, - Object? isConnected = null, - }) { - return _then(_value.copyWith( - sgnusAddress: null == sgnusAddress - ? _value.sgnusAddress - : sgnusAddress // ignore: cast_nullable_to_non_nullable - as String, - walletAddress: null == walletAddress - ? _value.walletAddress - : walletAddress // ignore: cast_nullable_to_non_nullable - as String, - isConnected: null == isConnected - ? _value.isConnected - : isConnected // ignore: cast_nullable_to_non_nullable - as bool, - ) as $Val); - } + } /// @nodoc -abstract class _$$SGNUSConnectionImplCopyWith<$Res> +abstract mixin class $SGNUSConnectionCopyWith<$Res> { + factory $SGNUSConnectionCopyWith(SGNUSConnection value, $Res Function(SGNUSConnection) _then) = _$SGNUSConnectionCopyWithImpl; +@useResult +$Res call({ + String sgnusAddress, String walletAddress, GeniusTransactionManagerState? connection +}); + + + + +} +/// @nodoc +class _$SGNUSConnectionCopyWithImpl<$Res> implements $SGNUSConnectionCopyWith<$Res> { - factory _$$SGNUSConnectionImplCopyWith(_$SGNUSConnectionImpl value, - $Res Function(_$SGNUSConnectionImpl) then) = - __$$SGNUSConnectionImplCopyWithImpl<$Res>; - @override - @useResult - $Res call({String sgnusAddress, String walletAddress, bool isConnected}); + _$SGNUSConnectionCopyWithImpl(this._self, this._then); + + final SGNUSConnection _self; + final $Res Function(SGNUSConnection) _then; + +/// Create a copy of SGNUSConnection +/// with the given fields replaced by the non-null parameter values. +@pragma('vm:prefer-inline') @override $Res call({Object? sgnusAddress = null,Object? walletAddress = null,Object? connection = freezed,}) { + return _then(_self.copyWith( +sgnusAddress: null == sgnusAddress ? _self.sgnusAddress : sgnusAddress // ignore: cast_nullable_to_non_nullable +as String,walletAddress: null == walletAddress ? _self.walletAddress : walletAddress // ignore: cast_nullable_to_non_nullable +as String,connection: freezed == connection ? _self.connection : connection // ignore: cast_nullable_to_non_nullable +as GeniusTransactionManagerState?, + )); +} + +} + + +/// Adds pattern-matching-related methods to [SGNUSConnection]. +extension SGNUSConnectionPatterns on SGNUSConnection { +/// A variant of `map` that fallback to returning `orElse`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeMap(TResult Function( _SGNUSConnection value)? $default,{required TResult orElse(),}){ +final _that = this; +switch (_that) { +case _SGNUSConnection() when $default != null: +return $default(_that);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// Callbacks receives the raw object, upcasted. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case final Subclass2 value: +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult map(TResult Function( _SGNUSConnection value) $default,){ +final _that = this; +switch (_that) { +case _SGNUSConnection(): +return $default(_that);} +} +/// A variant of `map` that fallback to returning `null`. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case final Subclass value: +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? mapOrNull(TResult? Function( _SGNUSConnection value)? $default,){ +final _that = this; +switch (_that) { +case _SGNUSConnection() when $default != null: +return $default(_that);case _: + return null; + +} +} +/// A variant of `when` that fallback to an `orElse` callback. +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return orElse(); +/// } +/// ``` + +@optionalTypeArgs TResult maybeWhen(TResult Function( String sgnusAddress, String walletAddress, GeniusTransactionManagerState? connection)? $default,{required TResult orElse(),}) {final _that = this; +switch (_that) { +case _SGNUSConnection() when $default != null: +return $default(_that.sgnusAddress,_that.walletAddress,_that.connection);case _: + return orElse(); + +} +} +/// A `switch`-like method, using callbacks. +/// +/// As opposed to `map`, this offers destructuring. +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case Subclass2(:final field2): +/// return ...; +/// } +/// ``` + +@optionalTypeArgs TResult when(TResult Function( String sgnusAddress, String walletAddress, GeniusTransactionManagerState? connection) $default,) {final _that = this; +switch (_that) { +case _SGNUSConnection(): +return $default(_that.sgnusAddress,_that.walletAddress,_that.connection);} +} +/// A variant of `when` that fallback to returning `null` +/// +/// It is equivalent to doing: +/// ```dart +/// switch (sealedClass) { +/// case Subclass(:final field): +/// return ...; +/// case _: +/// return null; +/// } +/// ``` + +@optionalTypeArgs TResult? whenOrNull(TResult? Function( String sgnusAddress, String walletAddress, GeniusTransactionManagerState? connection)? $default,) {final _that = this; +switch (_that) { +case _SGNUSConnection() when $default != null: +return $default(_that.sgnusAddress,_that.walletAddress,_that.connection);case _: + return null; + +} } -/// @nodoc -class __$$SGNUSConnectionImplCopyWithImpl<$Res> - extends _$SGNUSConnectionCopyWithImpl<$Res, _$SGNUSConnectionImpl> - implements _$$SGNUSConnectionImplCopyWith<$Res> { - __$$SGNUSConnectionImplCopyWithImpl( - _$SGNUSConnectionImpl _value, $Res Function(_$SGNUSConnectionImpl) _then) - : super(_value, _then); - - /// Create a copy of SGNUSConnection - /// with the given fields replaced by the non-null parameter values. - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? sgnusAddress = null, - Object? walletAddress = null, - Object? isConnected = null, - }) { - return _then(_$SGNUSConnectionImpl( - sgnusAddress: null == sgnusAddress - ? _value.sgnusAddress - : sgnusAddress // ignore: cast_nullable_to_non_nullable - as String, - walletAddress: null == walletAddress - ? _value.walletAddress - : walletAddress // ignore: cast_nullable_to_non_nullable - as String, - isConnected: null == isConnected - ? _value.isConnected - : isConnected // ignore: cast_nullable_to_non_nullable - as bool, - )); - } } /// @nodoc @JsonSerializable() -class _$SGNUSConnectionImpl implements _SGNUSConnection { - const _$SGNUSConnectionImpl( - {required this.sgnusAddress, - required this.walletAddress, - required this.isConnected}); - - factory _$SGNUSConnectionImpl.fromJson(Map json) => - _$$SGNUSConnectionImplFromJson(json); - - @override - final String sgnusAddress; - @override - final String walletAddress; - @override - final bool isConnected; - - @override - String toString() { - return 'SGNUSConnection(sgnusAddress: $sgnusAddress, walletAddress: $walletAddress, isConnected: $isConnected)'; - } - - @override - bool operator ==(Object other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$SGNUSConnectionImpl && - (identical(other.sgnusAddress, sgnusAddress) || - other.sgnusAddress == sgnusAddress) && - (identical(other.walletAddress, walletAddress) || - other.walletAddress == walletAddress) && - (identical(other.isConnected, isConnected) || - other.isConnected == isConnected)); - } - - @JsonKey(includeFromJson: false, includeToJson: false) - @override - int get hashCode => - Object.hash(runtimeType, sgnusAddress, walletAddress, isConnected); - - /// Create a copy of SGNUSConnection - /// with the given fields replaced by the non-null parameter values. - @JsonKey(includeFromJson: false, includeToJson: false) - @override - @pragma('vm:prefer-inline') - _$$SGNUSConnectionImplCopyWith<_$SGNUSConnectionImpl> get copyWith => - __$$SGNUSConnectionImplCopyWithImpl<_$SGNUSConnectionImpl>( - this, _$identity); - - @override - Map toJson() { - return _$$SGNUSConnectionImplToJson( - this, - ); - } -} - -abstract class _SGNUSConnection implements SGNUSConnection { - const factory _SGNUSConnection( - {required final String sgnusAddress, - required final String walletAddress, - required final bool isConnected}) = _$SGNUSConnectionImpl; - - factory _SGNUSConnection.fromJson(Map json) = - _$SGNUSConnectionImpl.fromJson; - - @override - String get sgnusAddress; - @override - String get walletAddress; - @override - bool get isConnected; - - /// Create a copy of SGNUSConnection - /// with the given fields replaced by the non-null parameter values. - @override - @JsonKey(includeFromJson: false, includeToJson: false) - _$$SGNUSConnectionImplCopyWith<_$SGNUSConnectionImpl> get copyWith => - throw _privateConstructorUsedError; + +class _SGNUSConnection implements SGNUSConnection { + const _SGNUSConnection({required this.sgnusAddress, required this.walletAddress, required this.connection}); + factory _SGNUSConnection.fromJson(Map json) => _$SGNUSConnectionFromJson(json); + +@override final String sgnusAddress; +@override final String walletAddress; +@override final GeniusTransactionManagerState? connection; + +/// Create a copy of SGNUSConnection +/// with the given fields replaced by the non-null parameter values. +@override @JsonKey(includeFromJson: false, includeToJson: false) +@pragma('vm:prefer-inline') +_$SGNUSConnectionCopyWith<_SGNUSConnection> get copyWith => __$SGNUSConnectionCopyWithImpl<_SGNUSConnection>(this, _$identity); + +@override +Map toJson() { + return _$SGNUSConnectionToJson(this, ); +} + +@override +bool operator ==(Object other) { + return identical(this, other) || (other.runtimeType == runtimeType&&other is _SGNUSConnection&&(identical(other.sgnusAddress, sgnusAddress) || other.sgnusAddress == sgnusAddress)&&(identical(other.walletAddress, walletAddress) || other.walletAddress == walletAddress)&&(identical(other.connection, connection) || other.connection == connection)); +} + +@JsonKey(includeFromJson: false, includeToJson: false) +@override +int get hashCode => Object.hash(runtimeType,sgnusAddress,walletAddress,connection); + +@override +String toString() { + return 'SGNUSConnection(sgnusAddress: $sgnusAddress, walletAddress: $walletAddress, connection: $connection)'; } + + +} + +/// @nodoc +abstract mixin class _$SGNUSConnectionCopyWith<$Res> implements $SGNUSConnectionCopyWith<$Res> { + factory _$SGNUSConnectionCopyWith(_SGNUSConnection value, $Res Function(_SGNUSConnection) _then) = __$SGNUSConnectionCopyWithImpl; +@override @useResult +$Res call({ + String sgnusAddress, String walletAddress, GeniusTransactionManagerState? connection +}); + + + + +} +/// @nodoc +class __$SGNUSConnectionCopyWithImpl<$Res> + implements _$SGNUSConnectionCopyWith<$Res> { + __$SGNUSConnectionCopyWithImpl(this._self, this._then); + + final _SGNUSConnection _self; + final $Res Function(_SGNUSConnection) _then; + +/// Create a copy of SGNUSConnection +/// with the given fields replaced by the non-null parameter values. +@override @pragma('vm:prefer-inline') $Res call({Object? sgnusAddress = null,Object? walletAddress = null,Object? connection = freezed,}) { + return _then(_SGNUSConnection( +sgnusAddress: null == sgnusAddress ? _self.sgnusAddress : sgnusAddress // ignore: cast_nullable_to_non_nullable +as String,walletAddress: null == walletAddress ? _self.walletAddress : walletAddress // ignore: cast_nullable_to_non_nullable +as String,connection: freezed == connection ? _self.connection : connection // ignore: cast_nullable_to_non_nullable +as GeniusTransactionManagerState?, + )); +} + + +} + +// dart format on diff --git a/packages/genius_api/lib/models/sgnus_connection.g.dart b/packages/genius_api/lib/models/sgnus_connection.g.dart index 4b25e619..6a02fd2c 100644 --- a/packages/genius_api/lib/models/sgnus_connection.g.dart +++ b/packages/genius_api/lib/models/sgnus_connection.g.dart @@ -6,18 +6,29 @@ part of 'sgnus_connection.dart'; // JsonSerializableGenerator // ************************************************************************** -_$SGNUSConnectionImpl _$$SGNUSConnectionImplFromJson( - Map json) => - _$SGNUSConnectionImpl( +_SGNUSConnection _$SGNUSConnectionFromJson(Map json) => + _SGNUSConnection( sgnusAddress: json['sgnusAddress'] as String, walletAddress: json['walletAddress'] as String, - isConnected: json['isConnected'] as bool, + connection: $enumDecodeNullable( + _$GeniusTransactionManagerStateEnumMap, + json['connection'], + ), ); -Map _$$SGNUSConnectionImplToJson( - _$SGNUSConnectionImpl instance) => +Map _$SGNUSConnectionToJson(_SGNUSConnection instance) => { 'sgnusAddress': instance.sgnusAddress, 'walletAddress': instance.walletAddress, - 'isConnected': instance.isConnected, + 'connection': _$GeniusTransactionManagerStateEnumMap[instance.connection], }; + +const _$GeniusTransactionManagerStateEnumMap = { + GeniusTransactionManagerState.GENIUS_TM_STATE_CREATING: + 'GENIUS_TM_STATE_CREATING', + GeniusTransactionManagerState.GENIUS_TM_STATE_INITIALIZING: + 'GENIUS_TM_STATE_INITIALIZING', + GeniusTransactionManagerState.GENIUS_TM_STATE_SYNCHING: + 'GENIUS_TM_STATE_SYNCHING', + GeniusTransactionManagerState.GENIUS_TM_STATE_READY: 'GENIUS_TM_STATE_READY', +}; diff --git a/packages/genius_api/lib/src/genius_api.dart b/packages/genius_api/lib/src/genius_api.dart index 9cc86b43..91540f3f 100755 --- a/packages/genius_api/lib/src/genius_api.dart +++ b/packages/genius_api/lib/src/genius_api.dart @@ -35,16 +35,16 @@ class GeniusApi { final FFIBridgePrebuilt ffiBridgePrebuilt; final SGNUSConnectionController _sgnusConnectionController; final SGNUSTransactionsController _sgnusTransactionsController; + late final Timer _timer; late final String address; late final String jsonFilePath; bool isSdkInitialized = false; - GeniusApi({ - required LocalWalletStorage secureStorage, - }) : _secureStorage = secureStorage, - ffiBridgePrebuilt = FFIBridgePrebuilt(), - _sgnusConnectionController = SGNUSConnectionController(), - _sgnusTransactionsController = SGNUSTransactionsController(); + GeniusApi({required LocalWalletStorage secureStorage}) + : _secureStorage = secureStorage, + ffiBridgePrebuilt = FFIBridgePrebuilt(), + _sgnusConnectionController = SGNUSConnectionController(), + _sgnusTransactionsController = SGNUSTransactionsController(); Future requestPermissions() async { try { @@ -123,11 +123,14 @@ class GeniusApi { PrivateKey privateKey; if (storedKey.isMnemonic()) { - privateKey = - storedKey.wallet("")!.getKeyForCoin(TWCoinType.TWCoinTypeEthereum); + privateKey = storedKey + .wallet("")! + .getKeyForCoin(TWCoinType.TWCoinTypeEthereum); } else { - privateKey = - storedKey.privateKey(TWCoinType.TWCoinTypeEthereum, Uint8List(0))!; + privateKey = storedKey.privateKey( + TWCoinType.TWCoinTypeEthereum, + Uint8List(0), + )!; } jsonFilePath = await copyJsonToWritableDirectory(); @@ -141,7 +144,13 @@ class GeniusApi { final privateKeyAsPtr = privateKeyAsStr.toNativeUtf8(); debugPrint('Json File Path: $jsonFilePath'); final retVal = ffiBridgePrebuilt.gns_lib.GeniusSDKInit( - basePathPtr.cast(), privateKeyAsPtr.cast(), true, true, 41001, false); + basePathPtr.cast(), + privateKeyAsPtr.cast(), + true, + true, + 41001, + false, + ); if (retVal == nullptr) { return; @@ -152,14 +161,19 @@ class GeniusApi { malloc.free(basePathPtr); malloc.free(privateKeyAsPtr); - // Update UI with SGNUS connection status - getSGNUSController().updateConnection(SGNUSConnection( - sgnusAddress: address, - walletAddress: storedKey - .wallet("") - ?.getAddressForCoin(TWCoinType.TWCoinTypeEthereum) ?? - "", - isConnected: true)); + _timer = Timer.periodic(Duration(seconds: 5), (timer) async { + getSGNUSController().updateConnection( + SGNUSConnection( + sgnusAddress: address, + walletAddress: + storedKey + .wallet("") + ?.getAddressForCoin(TWCoinType.TWCoinTypeEthereum) ?? + "", + connection: getTransactionManagerState(), + ), + ); + }); isSdkInitialized = true; } @@ -171,23 +185,27 @@ class GeniusApi { final filePath = '${directory.path}/dev_config.json'; debugPrint( - 'Application documents directory: ${directory.path}'); // Log the directory path + 'Application documents directory: ${directory.path}', + ); // Log the directory path // Load the asset file final jsonString = await rootBundle.loadString('assets/dev_config.json'); debugPrint( - 'Loaded JSON string: $jsonString'); // Log the content of the JSON + 'Loaded JSON string: $jsonString', + ); // Log the content of the JSON // Write the file to the writable directory final file = File(filePath); await file.writeAsString(jsonString); debugPrint( - 'File written to: $filePath'); // Log the file path after writing + 'File written to: $filePath', + ); // Log the file path after writing // Verify the file was written correctly final writtenFileContent = await file.readAsString(); debugPrint( - 'Content of the written file: $writtenFileContent'); // Log the written file content + 'Content of the written file: $writtenFileContent', + ); // Log the written file content // Return the directory path for use in FFI return '${directory.path}/'; @@ -223,7 +241,11 @@ class GeniusApi { } void mintTokens( - int amount, String transactionHash, String chainId, String tokenId) { + int amount, + String transactionHash, + String chainId, + String tokenId, + ) { final Pointer transhash = transactionHash.toNativeUtf8(); final Pointer chainid = chainId.toNativeUtf8(); @@ -231,16 +253,21 @@ class GeniusApi { final tokenIdData = calloc(); // Parse hex string token_id and fill the data array - String cleanTokenId = - tokenId.startsWith('0x') ? tokenId.substring(2) : tokenId; + String cleanTokenId = tokenId.startsWith('0x') + ? tokenId.substring(2) + : tokenId; for (int i = 0; i < 32 && i * 2 < cleanTokenId.length; i++) { String hexByte = cleanTokenId.substring(i * 2, (i + 1) * 2); tokenIdData.ref.data[i] = int.parse(hexByte, radix: 16); } - ffiBridgePrebuilt.gns_lib.GeniusSDKMint(amount, transhash as Pointer, - chainid as Pointer, tokenIdData.ref); + ffiBridgePrebuilt.gns_lib.GeniusSDKMint( + amount, + transhash as Pointer, + chainid as Pointer, + tokenIdData.ref, + ); calloc.free(tokenIdData); malloc.free(transhash); @@ -254,16 +281,16 @@ class GeniusApi { void requestAIProcess() { //String job_id = "QmUDMvGQXbUKMsjmTzjf4ZuMx7tHx6Z4x8YH8RbwrgyGAf"; -// + // //Pointer charPointer = malloc.allocate(job_id.length + 1); -// + // //for (int i = 0; i < job_id.length; i++) { // charPointer.elementAt(i).value = job_id.codeUnitAt(i); //} //charPointer.elementAt(job_id.length).value = 0; -// + // //ffiBridgePrebuilt.gns_lib.GeniusSDKProcess(charPointer, 100); -// + // //malloc.free(charPointer); } @@ -341,10 +368,15 @@ class GeniusApi { Future saveWallet(HDWallet wallet) async { String mnemonic = wallet.mnemonic(); String ethAddress = wallet.getAddressForCoin(TWCoinType.TWCoinTypeEthereum); - String walletName = wallet.name ?? + String walletName = + wallet.name ?? "${ethAddress.substring(0, 5)}...${ethAddress.substring(ethAddress.length - 4)}"; StoredKey? storedKey = StoredKey.importHDWallet( - mnemonic, walletName, "", TWCoinType.TWCoinTypeEthereum); + mnemonic, + walletName, + "", + TWCoinType.TWCoinTypeEthereum, + ); if (storedKey == null) { return; @@ -364,12 +396,18 @@ class GeniusApi { }) async { if (securityType == SecurityType.passphrase) { return await importWalletFromMnemonic( - securityValue, walletName, coinType); + securityValue, + walletName, + coinType, + ); } if (securityType == SecurityType.privateKey) { return await importWalletFromPrivateKey( - securityValue, walletName, coinType); + securityValue, + walletName, + coinType, + ); } if (securityType == SecurityType.address) { @@ -378,14 +416,22 @@ class GeniusApi { if (securityType == SecurityType.keystore) { return await importWalletFromKeyStore( - securityValue, password, walletName, coinType); + securityValue, + password, + walletName, + coinType, + ); } return false; } - Future importWalletFromKeyStore(String json, String? password, - String walletName, TWCoinType coinType) async { + Future importWalletFromKeyStore( + String json, + String? password, + String walletName, + TWCoinType coinType, + ) async { StoredKey? storedKey = StoredKey.importJson(json); if (storedKey == null) { @@ -393,11 +439,15 @@ class GeniusApi { } final mnemonic = storedKey.decryptMnemonic( - Uint8List.fromList(password?.codeUnits ?? List.empty())); + Uint8List.fromList(password?.codeUnits ?? List.empty()), + ); - final pk = hex.encode(storedKey.decryptPrivateKey( - Uint8List.fromList(password?.codeUnits ?? List.empty())) ?? - List.empty()); + final pk = hex.encode( + storedKey.decryptPrivateKey( + Uint8List.fromList(password?.codeUnits ?? List.empty()), + ) ?? + List.empty(), + ); if (mnemonic == null || pk == "") { return false; @@ -415,21 +465,31 @@ class GeniusApi { return false; } - await _secureStorage.saveWatchedWallet(Wallet( + await _secureStorage.saveWatchedWallet( + Wallet( balance: 0, walletName: walletName, currencySymbol: CoinUtil.getSymbol(coinType), coinType: coinType, walletType: WalletType.tracking, - address: address)); + address: address, + ), + ); return true; } Future importWalletFromMnemonic( - String mnemonic, String walletName, TWCoinType coinType) async { - StoredKey? storedKey = - StoredKey.importHDWallet(mnemonic, walletName, "", coinType); + String mnemonic, + String walletName, + TWCoinType coinType, + ) async { + StoredKey? storedKey = StoredKey.importHDWallet( + mnemonic, + walletName, + "", + coinType, + ); if (storedKey == null) { return false; @@ -442,10 +502,17 @@ class GeniusApi { } Future importWalletFromPrivateKey( - String privateKey, String walletName, TWCoinType coinType) async { + String privateKey, + String walletName, + TWCoinType coinType, + ) async { final privateKeyData = Uint8List.fromList(hex.decode(privateKey)); - StoredKey? storedKey = - StoredKey.importPrivateKey(privateKeyData, walletName, "", coinType); + StoredKey? storedKey = StoredKey.importPrivateKey( + privateKeyData, + walletName, + "", + coinType, + ); if (storedKey == null) { return false; @@ -475,8 +542,9 @@ class GeniusApi { } } else { // Parse provided token ID - String cleanTokenId = - tokenId.startsWith('0x') ? tokenId.substring(2) : tokenId; + String cleanTokenId = tokenId.startsWith('0x') + ? tokenId.substring(2) + : tokenId; for (int i = 0; i < 32 && i * 2 < cleanTokenId.length; i++) { String hexByte = cleanTokenId.substring(i * 2, (i + 1) * 2); @@ -484,8 +552,9 @@ class GeniusApi { } } - final balance = - ffiBridgePrebuilt.gns_lib.GeniusSDKGetBalance(tokenIdData.ref); + final balance = ffiBridgePrebuilt.gns_lib.GeniusSDKGetBalance( + tokenIdData.ref, + ); calloc.free(tokenIdData); return balance.toString(); } @@ -494,8 +563,8 @@ class GeniusApi { if (!isSdkInitialized) { return "0"; } - GeniusTokenValue tokenValue = - ffiBridgePrebuilt.gns_lib.GeniusSDKGetBalanceGNUS(); + GeniusTokenValue tokenValue = ffiBridgePrebuilt.gns_lib + .GeniusSDKGetBalanceGNUS(); final array = tokenValue.value; List charCodes = []; for (int i = 0; i < 22; i++) { @@ -516,8 +585,10 @@ class GeniusApi { } var address = ffiBridgePrebuilt.gns_lib.GeniusSDKGetAddress(); - List charCodes = - List.generate(66, (index) => address.address[index]); + List charCodes = List.generate( + 66, + (index) => address.address[index], + ); return String.fromCharCodes(charCodes); } @@ -538,16 +609,20 @@ class GeniusApi { // Fallback: try different nanosecond-based conversions with year validation. None of these transaction should be outside of 2024/2025 so we're filtering for that final conversions = [ () => DateTime.fromMicrosecondsSinceEpoch( - timestamp ~/ 1000000), // nanoseconds (Linux) + timestamp ~/ 1000000, + ), // nanoseconds (Linux) () => DateTime.fromMicrosecondsSinceEpoch( - timestamp ~/ 10), // 100ns (Windows old) + timestamp ~/ 10, + ), // 100ns (Windows old) () => DateTime.fromMicrosecondsSinceEpoch(timestamp ~/ 10000000), () => DateTime.fromMicrosecondsSinceEpoch(timestamp ~/ 100000000), () => DateTime.fromMicrosecondsSinceEpoch(timestamp ~/ 100), // 10ns () => DateTime.fromMicrosecondsSinceEpoch( - timestamp ~/ 1000), // microseconds + timestamp ~/ 1000, + ), // microseconds () => DateTime.fromMicrosecondsSinceEpoch( - timestamp ~/ 1), // already microseconds + timestamp ~/ 1, + ), // already microseconds ]; for (final convert in conversions) { @@ -572,8 +647,9 @@ class GeniusApi { var transactions = ffiBridgePrebuilt.gns_lib.GeniusSDKGetOutTransactions(); List ret = List.generate(transactions.size, (i) { - var buffer = - transactions.ptr[i].ptr.asTypedList(transactions.ptr[i].size); + var buffer = transactions.ptr[i].ptr.asTypedList( + transactions.ptr[i].size, + ); var header = DAGWrapper.fromBuffer(buffer).dagStruct; var fromAddress = String.fromCharCodes(header.sourceAddr); @@ -585,8 +661,12 @@ class GeniusApi { if (header.type == "escrow") { rawRecipients = EscrowTx.fromBuffer(buffer).utxoParams.outputs; } else if (header.type == "mint") { - recipients.add(TransferRecipients( - amount: MintTx.fromBuffer(buffer).amount.toString(), toAddr: "")); + recipients.add( + TransferRecipients( + amount: MintTx.fromBuffer(buffer).amount.toString(), + toAddr: "", + ), + ); } else if (header.type == "process") { // No recipients in this kind of transaction } else if (header.type == "transfer") { @@ -596,26 +676,32 @@ class GeniusApi { } if (rawRecipients != null) { - recipients.addAll(rawRecipients.map((output) => TransferRecipients( - toAddr: output.destAddr - .map((byte) => byte.toRadixString(16).padLeft(2, '0')) - .join(), - amount: output.encryptedAmount.toString()))); + recipients.addAll( + rawRecipients.map( + (output) => TransferRecipients( + toAddr: output.destAddr + .map((byte) => byte.toRadixString(16).padLeft(2, '0')) + .join(), + amount: output.encryptedAmount.toString(), + ), + ), + ); } Transaction trans = Transaction( - hash: String.fromCharCodes(header.dataHash), - fromAddress: fromAddress, - recipients: recipients, - timeStamp: parseTimestamp(header.timestamp.toInt()), - transactionDirection: address == fromAddress - ? TransactionDirection.sent - : TransactionDirection.received, - fees: '0', - coinSymbol: 'minions', - transactionStatus: TransactionStatus.completed, - isSGNUS: true, - type: TransactionType.fromString(header.type)); + hash: String.fromCharCodes(header.dataHash), + fromAddress: fromAddress, + recipients: recipients, + timeStamp: parseTimestamp(header.timestamp.toInt()), + transactionDirection: address == fromAddress + ? TransactionDirection.sent + : TransactionDirection.received, + fees: '0', + coinSymbol: 'minions', + transactionStatus: TransactionStatus.completed, + isSGNUS: true, + type: TransactionType.fromString(header.type), + ); return trans; }); @@ -646,8 +732,9 @@ class GeniusApi { } } else { // Parse provided token ID - String cleanTokenId = - tokenId.startsWith('0x') ? tokenId.substring(2) : tokenId; + String cleanTokenId = tokenId.startsWith('0x') + ? tokenId.substring(2) + : tokenId; for (int i = 0; i < 32 && i * 2 < cleanTokenId.length; i++) { String hexByte = cleanTokenId.substring(i * 2, (i + 1) * 2); @@ -655,8 +742,11 @@ class GeniusApi { } } - final ret = ffiBridgePrebuilt.gns_lib - .GeniusSDKTransfer(amount, convertedAddress, tokenIdData.ref); + final ret = ffiBridgePrebuilt.gns_lib.GeniusSDKTransfer( + amount, + convertedAddress, + tokenIdData.ref, + ); calloc.free(convertedAddress); calloc.free(tokenIdData); @@ -693,8 +783,9 @@ class GeniusApi { } } else { // Parse provided token ID - String cleanTokenId = - tokenId.startsWith('0x') ? tokenId.substring(2) : tokenId; + String cleanTokenId = tokenId.startsWith('0x') + ? tokenId.substring(2) + : tokenId; for (int i = 0; i < 32 && i * 2 < cleanTokenId.length; i++) { String hexByte = cleanTokenId.substring(i * 2, (i + 1) * 2); @@ -702,21 +793,24 @@ class GeniusApi { } } - final result = - ffiBridgePrebuilt.gns_lib.GeniusSDKPayDev(amount, tokenIdData.ref); + final result = ffiBridgePrebuilt.gns_lib.GeniusSDKPayDev( + amount, + tokenIdData.ref, + ); calloc.free(tokenIdData); return result; } - Future> bridgeOut( - {required String contractAddress, - required String rpcUrl, - required String address, - required String amountToBurn, - required int sourceChainId, - required int destinationChainId, - bool shouldMintTokens = false}) async { + Future> bridgeOut({ + required String contractAddress, + required String rpcUrl, + required String address, + required String amountToBurn, + required int sourceChainId, + required int destinationChainId, + bool shouldMintTokens = false, + }) async { final wallet = await _secureStorage.getWallet(address); if (wallet == null) { @@ -724,12 +818,13 @@ class GeniusApi { } final resp = await Web3(geniusApi: this).executeBridgeOutTransaction( - contractAddress: contractAddress, - rpcUrl: rpcUrl, - amountToBurn: amountToBurn, - sourceChainId: sourceChainId, - destinationChainId: destinationChainId, - wallet: wallet); + contractAddress: contractAddress, + rpcUrl: rpcUrl, + amountToBurn: amountToBurn, + sourceChainId: sourceChainId, + destinationChainId: destinationChainId, + wallet: wallet, + ); if (shouldMintTokens && resp.isSuccess && resp.data != null) { final hardCodedTokenIdForNow = 0; @@ -745,13 +840,14 @@ class GeniusApi { return resp; } - Future> getBrigeOutGasCost( - {required String contractAddress, - required String rpcUrl, - required String address, - required String amountToBurn, - required int sourceChainId, - required int destinationChainId}) async { + Future> getBrigeOutGasCost({ + required String contractAddress, + required String rpcUrl, + required String address, + required String amountToBurn, + required int sourceChainId, + required int destinationChainId, + }) async { final wallet = await _secureStorage.getWallet(address); if (wallet == null) { @@ -760,15 +856,17 @@ class GeniusApi { final web3 = Web3(geniusApi: this); final gasResponse = await web3.getBrigeOutGasCost( - contractAddress: contractAddress, - rpcUrl: rpcUrl, - amountToBurn: amountToBurn, - destinationChainId: destinationChainId, - wallet: wallet); + contractAddress: contractAddress, + rpcUrl: rpcUrl, + amountToBurn: amountToBurn, + destinationChainId: destinationChainId, + wallet: wallet, + ); if (!gasResponse.isSuccess) { return ApiResponse.error( - gasResponse.errorMessage ?? "Failed to retrieve gas costs"); + gasResponse.errorMessage ?? "Failed to retrieve gas costs", + ); } final gasPriceInGwei = web3.getGasPriceInGwei(gasResponse.data); @@ -789,8 +887,16 @@ class GeniusApi { final privateKey = getDevPrivateKey() ?? web3.getPrivateKeyStr(wallet); final resp = await web3.signAndSendTransaction( - tx: tx, rpcUrl: rpcUrl, chainId: sourceChainId, privateKey: privateKey); + tx: tx, + rpcUrl: rpcUrl, + chainId: sourceChainId, + privateKey: privateKey, + ); return resp; } + + GeniusTransactionManagerState getTransactionManagerState() { + return ffiBridgePrebuilt.gns_lib.GeniusSDKGetTransactionManagerState(); + } } diff --git a/packages/local_secure_storage/lib/src/local_secure_storage_base.dart b/packages/local_secure_storage/lib/src/local_secure_storage_base.dart index acd64331..c6a00f94 100644 --- a/packages/local_secure_storage/lib/src/local_secure_storage_base.dart +++ b/packages/local_secure_storage/lib/src/local_secure_storage_base.dart @@ -1,9 +1,9 @@ import 'dart:convert'; import 'package:flutter/services.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; -import 'package:genius_api/genius_api.dart'; import 'package:genius_api/models/account.dart'; import 'package:genius_api/models/network.dart'; +import 'package:genius_api/models/wallet.dart'; import 'package:genius_api/tw/coin_util.dart'; import 'package:genius_api/tw/stored_key.dart'; import 'package:genius_api/tw/stored_key_wallet.dart'; From 9ef576042063e0af44bec44c574920318332e3be Mon Sep 17 00:00:00 2001 From: Eduardo Menges Mattje Date: Tue, 7 Oct 2025 15:40:22 -0300 Subject: [PATCH 6/6] Fix CI --- lib/network/network_page.dart | 15 ++++++++++++--- pubspec.lock | 30 +++++++++++++++--------------- pubspec.yaml | 1 + 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/lib/network/network_page.dart b/lib/network/network_page.dart index ea2d5d23..a632115e 100644 --- a/lib/network/network_page.dart +++ b/lib/network/network_page.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:connectivity_plus/connectivity_plus.dart'; +import 'package:genius_api/ffi/genius_api_ffi.dart'; import 'package:genius_api/genius_api.dart'; import 'package:genius_api/models/sgnus_connection.dart'; import 'package:genius_wallet/wallets/cubit/wallet_details_cubit.dart'; @@ -99,17 +100,25 @@ class _NetworkStatusPageState extends State { final connection = snapshot.data; return ListTile( leading: Icon( - (connection != null && connection.isConnected) + (connection != null && + connection.connection == + GeniusTransactionManagerState + .GENIUS_TM_STATE_READY) ? Icons.check_circle : Icons.error_outline, - color: (connection != null && connection.isConnected) + color: (connection != null && + connection.connection == + GeniusTransactionManagerState + .GENIUS_TM_STATE_READY) ? Colors.green : Colors.red, ), title: const Text('SGNUS Connection'), subtitle: Text(connection == null ? 'No data' - : connection.isConnected + : connection.connection == + GeniusTransactionManagerState + .GENIUS_TM_STATE_READY ? "Connected\nAddress: ${connection.sgnusAddress}\nWallet: ${connection.walletAddress}" : "Disconnected"), ); diff --git a/pubspec.lock b/pubspec.lock index 99805a15..5d97c298 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -226,7 +226,7 @@ packages: source: hosted version: "1.19.1" connectivity_plus: - dependency: transitive + dependency: "direct main" description: name: connectivity_plus sha256: b5e72753cf63becce2c61fd04dfe0f1c430cc5278b53a1342dc5ad839eab29ec @@ -696,26 +696,26 @@ packages: dependency: transitive description: name: leak_tracker - sha256: "33e2e26bdd85a0112ec15400c8cbffea70d0f9c3407491f672a2fad47915e2de" + sha256: "6bb818ecbdffe216e81182c2f0714a2e62b593f4a4f13098713ff1685dfb6ab0" url: "https://pub.dev" source: hosted - version: "11.0.2" + version: "10.0.9" leak_tracker_flutter_testing: dependency: transitive description: name: leak_tracker_flutter_testing - sha256: "1dbc140bb5a23c75ea9c4811222756104fbcd1a27173f0c34ca01e16bea473c1" + sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573 url: "https://pub.dev" source: hosted - version: "3.0.10" + version: "3.0.9" leak_tracker_testing: dependency: transitive description: name: leak_tracker_testing - sha256: "8d5a2d49f4a66b49744b23b018848400d23e54caf9463f4eb20df3eb8acb2eb1" + sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" url: "https://pub.dev" source: hosted - version: "3.0.2" + version: "3.0.1" lints: dependency: transitive description: @@ -1364,26 +1364,26 @@ packages: dependency: "direct main" description: name: test - sha256: "65e29d831719be0591f7b3b1a32a3cda258ec98c58c7b25f7b84241bc31215bb" + sha256: "301b213cd241ca982e9ba50266bd3f5bd1ea33f1455554c5abb85d1be0e2d87e" url: "https://pub.dev" source: hosted - version: "1.26.2" + version: "1.25.15" test_api: dependency: transitive description: name: test_api - sha256: "522f00f556e73044315fa4585ec3270f1808a4b186c936e612cab0b565ff1e00" + sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd url: "https://pub.dev" source: hosted - version: "0.7.6" + version: "0.7.4" test_core: dependency: transitive description: name: test_core - sha256: "80bf5a02b60af04b09e14f6fe68b921aad119493e26e490deaca5993fef1b05a" + sha256: "84d17c3486c8dfdbe5e12a50c8ae176d15e2a771b96909a9442b40173649ccaa" url: "https://pub.dev" source: hosted - version: "0.6.11" + version: "0.6.8" timeago: dependency: "direct main" description: @@ -1508,10 +1508,10 @@ packages: dependency: transitive description: name: vector_math - sha256: d530bd74fea330e6e364cda7a85019c434070188383e1cd8d9777ee586914c5b + sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" url: "https://pub.dev" source: hosted - version: "2.2.0" + version: "2.1.4" vm_service: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 52db4560..c5a10fc9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -49,6 +49,7 @@ dependencies: reown_walletkit: ^1.3.2 crypto: ^3.0.6 intl: ^0.20.2 + connectivity_plus: ^6.1.5 dev_dependencies: flutter_test: