diff --git a/assets/images/forest/ethereum.png b/assets/images/forest/ethereum.png new file mode 100644 index 000000000..2827ad56e Binary files /dev/null and b/assets/images/forest/ethereum.png differ diff --git a/assets/images/fruitSorbet/ethereum.png b/assets/images/fruitSorbet/ethereum.png new file mode 100644 index 000000000..2827ad56e Binary files /dev/null and b/assets/images/fruitSorbet/ethereum.png differ diff --git a/assets/images/fruitSorbet/ethereum.svg b/assets/images/fruitSorbet/ethereum.svg new file mode 100644 index 000000000..df9a44d1e --- /dev/null +++ b/assets/images/fruitSorbet/ethereum.svg @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/images/light/ethereum.png b/assets/images/light/ethereum.png new file mode 100644 index 000000000..2827ad56e Binary files /dev/null and b/assets/images/light/ethereum.png differ diff --git a/assets/images/light/ethereum.svg b/assets/images/light/ethereum.svg new file mode 100644 index 000000000..df9a44d1e --- /dev/null +++ b/assets/images/light/ethereum.svg @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/images/oceanBreeze/ethereum.png b/assets/images/oceanBreeze/ethereum.png new file mode 100644 index 000000000..2827ad56e Binary files /dev/null and b/assets/images/oceanBreeze/ethereum.png differ diff --git a/assets/images/oceanBreeze/ethereum.svg b/assets/images/oceanBreeze/ethereum.svg new file mode 100644 index 000000000..df9a44d1e --- /dev/null +++ b/assets/images/oceanBreeze/ethereum.svg @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/images/oledBlack/ethereum.png b/assets/images/oledBlack/ethereum.png new file mode 100644 index 000000000..2827ad56e Binary files /dev/null and b/assets/images/oledBlack/ethereum.png differ diff --git a/assets/images/oledBlack/ethereum.svg b/assets/images/oledBlack/ethereum.svg new file mode 100644 index 000000000..df9a44d1e --- /dev/null +++ b/assets/images/oledBlack/ethereum.svg @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/svg/cc.svg b/assets/svg/cc.svg new file mode 100644 index 000000000..646ae64ce --- /dev/null +++ b/assets/svg/cc.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/assets/svg/circle-plus.svg b/assets/svg/circle-plus.svg new file mode 100644 index 000000000..a09b12711 --- /dev/null +++ b/assets/svg/circle-plus.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/assets/svg/coin_icons/Ethereum.svg b/assets/svg/coin_icons/Ethereum.svg new file mode 100644 index 000000000..77020df7b --- /dev/null +++ b/assets/svg/coin_icons/Ethereum.svg @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/svg/coin_icons/bnb_icon.svg b/assets/svg/coin_icons/bnb_icon.svg new file mode 100644 index 000000000..d32653823 --- /dev/null +++ b/assets/svg/coin_icons/bnb_icon.svg @@ -0,0 +1,161 @@ + + + + + + image/svg+xml + + + + + + + + diff --git a/assets/svg/themed/dark/ethereum.svg b/assets/svg/themed/dark/ethereum.svg new file mode 100644 index 000000000..df9a44d1e --- /dev/null +++ b/assets/svg/themed/dark/ethereum.svg @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/svg/themed/fruitSorbet/ethereum.svg b/assets/svg/themed/fruitSorbet/ethereum.svg new file mode 100644 index 000000000..df9a44d1e --- /dev/null +++ b/assets/svg/themed/fruitSorbet/ethereum.svg @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/svg/themed/light/ethereum.svg b/assets/svg/themed/light/ethereum.svg new file mode 100644 index 000000000..df9a44d1e --- /dev/null +++ b/assets/svg/themed/light/ethereum.svg @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/svg/themed/oceanBreeze/ethereum.svg b/assets/svg/themed/oceanBreeze/ethereum.svg new file mode 100644 index 000000000..df9a44d1e --- /dev/null +++ b/assets/svg/themed/oceanBreeze/ethereum.svg @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/svg/themed/oledBlack/ethereum.svg b/assets/svg/themed/oledBlack/ethereum.svg new file mode 100644 index 000000000..df9a44d1e --- /dev/null +++ b/assets/svg/themed/oledBlack/ethereum.svg @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/svg/tokens.svg b/assets/svg/tokens.svg new file mode 100644 index 000000000..be52b614c --- /dev/null +++ b/assets/svg/tokens.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/ios/Podfile.lock b/ios/Podfile.lock index bb92ea24c..8cca5a81c 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -61,6 +61,8 @@ PODS: - cw_wownero/Wownero (0.0.2): - cw_shared_external - Flutter + - device_info_plus (0.0.1): + - Flutter - devicelocale (0.0.1): - Flutter - DKImagePickerController/Core (4.3.4): @@ -119,8 +121,9 @@ PODS: - MTBBarcodeScanner (5.0.11) - package_info_plus (0.4.5): - Flutter - - path_provider_ios (0.0.1): + - path_provider_foundation (0.0.1): - Flutter + - FlutterMacOS - permission_handler_apple (9.0.4): - Flutter - ReachabilitySwift (5.0.0) @@ -129,8 +132,9 @@ PODS: - SDWebImage/Core (5.13.2) - share_plus (0.0.1): - Flutter - - shared_preferences_ios (0.0.1): + - shared_preferences_foundation (0.0.1): - Flutter + - FlutterMacOS - stack_wallet_backup (0.0.1): - Flutter - SwiftProtobuf (1.19.0) @@ -147,6 +151,7 @@ DEPENDENCIES: - cw_monero (from `.symlinks/plugins/cw_monero/ios`) - cw_shared_external (from `.symlinks/plugins/cw_shared_external/ios`) - cw_wownero (from `.symlinks/plugins/cw_wownero/ios`) + - device_info_plus (from `.symlinks/plugins/device_info_plus/ios`) - devicelocale (from `.symlinks/plugins/devicelocale/ios`) - file_picker (from `.symlinks/plugins/file_picker/ios`) - Flutter (from `Flutter`) @@ -160,10 +165,10 @@ DEPENDENCIES: - lelantus (from `.symlinks/plugins/lelantus/ios`) - local_auth (from `.symlinks/plugins/local_auth/ios`) - package_info_plus (from `.symlinks/plugins/package_info_plus/ios`) - - path_provider_ios (from `.symlinks/plugins/path_provider_ios/ios`) + - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/ios`) - permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`) - share_plus (from `.symlinks/plugins/share_plus/ios`) - - shared_preferences_ios (from `.symlinks/plugins/shared_preferences_ios/ios`) + - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/ios`) - stack_wallet_backup (from `.symlinks/plugins/stack_wallet_backup/ios`) - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) - wakelock (from `.symlinks/plugins/wakelock/ios`) @@ -191,6 +196,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/cw_shared_external/ios" cw_wownero: :path: ".symlinks/plugins/cw_wownero/ios" + device_info_plus: + :path: ".symlinks/plugins/device_info_plus/ios" devicelocale: :path: ".symlinks/plugins/devicelocale/ios" file_picker: @@ -217,14 +224,14 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/local_auth/ios" package_info_plus: :path: ".symlinks/plugins/package_info_plus/ios" - path_provider_ios: - :path: ".symlinks/plugins/path_provider_ios/ios" + path_provider_foundation: + :path: ".symlinks/plugins/path_provider_foundation/ios" permission_handler_apple: :path: ".symlinks/plugins/permission_handler_apple/ios" share_plus: :path: ".symlinks/plugins/share_plus/ios" - shared_preferences_ios: - :path: ".symlinks/plugins/shared_preferences_ios/ios" + shared_preferences_foundation: + :path: ".symlinks/plugins/shared_preferences_foundation/ios" stack_wallet_backup: :path: ".symlinks/plugins/stack_wallet_backup/ios" url_launcher_ios: @@ -239,10 +246,11 @@ SPEC CHECKSUMS: cw_monero: 9816991daff0e3ad0a8be140e31933b5526babd4 cw_shared_external: 2972d872b8917603478117c9957dfca611845a92 cw_wownero: 08e5713fe311a3be95efd7f3c1bf9d47d9cfafde + device_info_plus: e5c5da33f982a436e103237c0c85f9031142abed devicelocale: b22617f40038496deffba44747101255cee005b0 DKImagePickerController: b512c28220a2b8ac7419f21c491fc8534b7601ac DKPhotoGallery: fdfad5125a9fdda9cc57df834d49df790dbb4179 - file_picker: 817ab1d8cd2da9d2da412a417162deee3500fc95 + file_picker: ce3938a0df3cc1ef404671531facef740d03f920 Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 flutter_libepiccash: 36241aa7d3126f6521529985ccb3dc5eaf7bb317 flutter_libmonero: da68a616b73dd0374a8419c684fa6b6df2c44ffe @@ -250,23 +258,23 @@ SPEC CHECKSUMS: flutter_native_splash: 52501b97d1c0a5f898d687f1646226c1f93c56ef flutter_secure_storage: 7953c38a04c3fdbb00571bcd87d8e3b5ceb9daec integration_test: a1e7d09bd98eca2fc37aefd79d4f41ad37bdbbe5 - isar_flutter_libs: bfb66f35a1fa9db9ec96b93539a03329ce147738 + isar_flutter_libs: b69f437aeab9c521821c3f376198c4371fa21073 lelantus: 97ab4ecc648423278f807e499b3a717dea9268f8 local_auth: 1740f55d7af0a2e2a8684ce225fe79d8931e808c MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb package_info_plus: 6c92f08e1f853dc01228d6f553146438dafcd14e - path_provider_ios: 14f3d2fd28c4fdb42f44e0f751d12861c43cee02 + path_provider_foundation: 37748e03f12783f9de2cb2c4eadfaa25fe6d4852 permission_handler_apple: 44366e37eaf29454a1e7b1b7d736c2cceaeb17ce ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825 SDWebImage: 72f86271a6f3139cc7e4a89220946489d4b9a866 share_plus: 056a1e8ac890df3e33cb503afffaf1e9b4fbae68 - shared_preferences_ios: 548a61f8053b9b8a49ac19c1ffbc8b92c50d68ad + shared_preferences_foundation: 297b3ebca31b34ec92be11acd7fb0ba932c822ca stack_wallet_backup: 5b8563aba5d8ffbf2ce1944331ff7294a0ec7c03 SwiftProtobuf: 6ef3f0e422ef90d6605ca20b21a94f6c1324d6b3 SwiftyGif: 6c3eafd0ce693cad58bb63d2b2fb9bacb8552780 - url_launcher_ios: 839c58cdb4279282219f5e248c3321761ff3c4de + url_launcher_ios: fb12c43172927bb5cf75aeebd073f883801f1993 wakelock: d0fc7c864128eac40eba1617cb5264d9c940b46f -PODFILE CHECKSUM: fe0e1ee7f3d1f7d00b11b474b62dd62134535aea +PODFILE CHECKSUM: 57c8aed26fba39d3ec9424816221f294a07c58eb COCOAPODS: 1.11.3 diff --git a/ios/Runner.xcodeproj/project.pbxproj b/ios/Runner.xcodeproj/project.pbxproj index 17990457d..0279825a9 100644 --- a/ios/Runner.xcodeproj/project.pbxproj +++ b/ios/Runner.xcodeproj/project.pbxproj @@ -17,7 +17,7 @@ 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; - C64D72F92051288D5CB5033D /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 08E84808BC00DEE3447AF47E /* Pods_Runner.framework */; }; + B49D91439948369648AB0603 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 51604430FD0FD1FA5C4767A0 /* Pods_Runner.framework */; }; /* End PBXBuildFile section */ /* Begin PBXCopyFilesBuildPhase section */ @@ -35,11 +35,12 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 08E84808BC00DEE3447AF47E /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 15168938F13F6113519C963B /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; + 1B82E12F9C5D326CBB2ADF7E /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; - 689E9A74C0452C94E3479BEA /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; + 51604430FD0FD1FA5C4767A0 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; @@ -53,7 +54,6 @@ 7E8A4F15288D645200F18717 /* flutter_libepiccash.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = flutter_libepiccash.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 7E8A4F19288D721300F18717 /* flutter_libepiccash.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = flutter_libepiccash.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 7E8A4F1D288D72D100F18717 /* flutter_libepiccash.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = flutter_libepiccash.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 7F0C23A93667326FB8E95604 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -61,7 +61,7 @@ 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - F69E2FD9CB433963DAA9B09E /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; + E6F536731AC506735EB76340 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -72,7 +72,7 @@ 7E1603B5288D73EA002F7A6F /* libepic_cash_wallet.a in Frameworks */, 7E729AE82893C1B1009BBD65 /* flutter_libepiccash.framework in Frameworks */, 7E569F992798D47200056D51 /* mobileliblelantus.framework in Frameworks */, - C64D72F92051288D5CB5033D /* Pods_Runner.framework in Frameworks */, + B49D91439948369648AB0603 /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -82,9 +82,9 @@ 4D9BC5822E8E05B80CC958A0 /* Pods */ = { isa = PBXGroup; children = ( - 7F0C23A93667326FB8E95604 /* Pods-Runner.debug.xcconfig */, - F69E2FD9CB433963DAA9B09E /* Pods-Runner.release.xcconfig */, - 689E9A74C0452C94E3479BEA /* Pods-Runner.profile.xcconfig */, + 1B82E12F9C5D326CBB2ADF7E /* Pods-Runner.debug.xcconfig */, + E6F536731AC506735EB76340 /* Pods-Runner.release.xcconfig */, + 15168938F13F6113519C963B /* Pods-Runner.profile.xcconfig */, ); path = Pods; sourceTree = ""; @@ -102,7 +102,7 @@ 7E8A4F06288D5A9300F18717 /* libepic_cash_wallet.a */, 7E8A4F02288D57DE00F18717 /* flutter_libepiccash.framework */, 7E569F982798D47200056D51 /* mobileliblelantus.framework */, - 08E84808BC00DEE3447AF47E /* Pods_Runner.framework */, + 51604430FD0FD1FA5C4767A0 /* Pods_Runner.framework */, ); name = Frameworks; sourceTree = ""; @@ -167,14 +167,14 @@ isa = PBXNativeTarget; buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; buildPhases = ( - D7C3965259DE109272702285 /* [CP] Check Pods Manifest.lock */, + B108E043921CDEDDCB9E1E86 /* [CP] Check Pods Manifest.lock */, 9740EEB61CF901F6004384FC /* Run Script */, 97C146EA1CF9000F007C117D /* Sources */, 97C146EB1CF9000F007C117D /* Frameworks */, 97C146EC1CF9000F007C117D /* Resources */, 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, - 30277110A528C730AF372175 /* [CP] Embed Pods Frameworks */, + FD1CA371131604E6658D4146 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -235,7 +235,57 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 30277110A528C730AF372175 /* [CP] Embed Pods Frameworks */ = { + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Thin Binary"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin\n"; + }; + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Run Script"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build\n"; + }; + B108E043921CDEDDCB9E1E86 /* [CP] Check Pods Manifest.lock */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", + ); + name = "[CP] Check Pods Manifest.lock"; + outputFileListPaths = ( + ); + outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; + showEnvVarsInLog = 0; + }; + FD1CA371131604E6658D4146 /* [CP] Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( @@ -267,9 +317,9 @@ "${BUILT_PRODUCTS_DIR}/lelantus/lelantus.framework", "${BUILT_PRODUCTS_DIR}/local_auth/local_auth.framework", "${BUILT_PRODUCTS_DIR}/package_info_plus/package_info_plus.framework", - "${BUILT_PRODUCTS_DIR}/path_provider_ios/path_provider_ios.framework", + "${BUILT_PRODUCTS_DIR}/path_provider_foundation/path_provider_foundation.framework", "${BUILT_PRODUCTS_DIR}/share_plus/share_plus.framework", - "${BUILT_PRODUCTS_DIR}/shared_preferences_ios/shared_preferences_ios.framework", + "${BUILT_PRODUCTS_DIR}/shared_preferences_foundation/shared_preferences_foundation.framework", "${BUILT_PRODUCTS_DIR}/stack_wallet_backup/stack_wallet_backup.framework", "${BUILT_PRODUCTS_DIR}/url_launcher_ios/url_launcher_ios.framework", "${BUILT_PRODUCTS_DIR}/wakelock/wakelock.framework", @@ -301,9 +351,9 @@ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/lelantus.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/local_auth.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/package_info_plus.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider_ios.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider_foundation.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/share_plus.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences_ios.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences_foundation.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/stack_wallet_backup.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher_ios.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/wakelock.framework", @@ -313,56 +363,6 @@ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; - 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Thin Binary"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin\n"; - }; - 9740EEB61CF901F6004384FC /* Run Script */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputPaths = ( - ); - name = "Run Script"; - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build\n"; - }; - D7C3965259DE109272702285 /* [CP] Check Pods Manifest.lock */ = { - isa = PBXShellScriptBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "${PODS_PODFILE_DIR_PATH}/Podfile.lock", - "${PODS_ROOT}/Manifest.lock", - ); - name = "[CP] Check Pods Manifest.lock"; - outputFileListPaths = ( - ); - outputPaths = ( - "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt", - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; - showEnvVarsInLog = 0; - }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ diff --git a/lib/hive/db.dart b/lib/db/hive/db.dart similarity index 99% rename from lib/hive/db.dart rename to lib/db/hive/db.dart index d56e5d243..1efa94cb2 100644 --- a/lib/hive/db.dart +++ b/lib/db/hive/db.dart @@ -253,4 +253,5 @@ abstract class DBKeys { static const String isFavorite = "isFavorite"; static const String id = "id"; static const String storedChainHeight = "storedChainHeight"; + static const String ethTokenContracts = "ethTokenContracts"; } diff --git a/lib/db/main_db.dart b/lib/db/isar/main_db.dart similarity index 92% rename from lib/db/main_db.dart rename to lib/db/isar/main_db.dart index 1fb672d34..76a60676f 100644 --- a/lib/db/main_db.dart +++ b/lib/db/isar/main_db.dart @@ -3,12 +3,12 @@ import 'package:flutter_native_splash/cli_commands.dart'; import 'package:isar/isar.dart'; import 'package:stackwallet/exceptions/main_db/main_db_exception.dart'; import 'package:stackwallet/models/isar/models/isar_models.dart'; +import 'package:stackwallet/utilities/amount/amount.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/format.dart'; import 'package:stackwallet/utilities/stack_file_system.dart'; import 'package:tuple/tuple.dart'; -part 'queries/queries.dart'; +part '../queries/queries.dart'; class MainDB { MainDB._(); @@ -32,6 +32,7 @@ class MainDB { UTXOSchema, AddressSchema, AddressLabelSchema, + EthContractSchema, ], directory: (await StackFileSystem.applicationIsarDirectory()).path, // inspector: kDebugMode, @@ -395,4 +396,26 @@ class MainDB { throw MainDBException("failed addNewTransactionData", e); } } + + // ========== Ethereum ======================================================= + + // eth contracts + + QueryBuilder getEthContracts() => + isar.ethContracts.where(); + + Future getEthContract(String contractAddress) => + isar.ethContracts.where().addressEqualTo(contractAddress).findFirst(); + + EthContract? getEthContractSync(String contractAddress) => + isar.ethContracts.where().addressEqualTo(contractAddress).findFirstSync(); + + Future putEthContract(EthContract contract) => isar.writeTxn(() async { + return await isar.ethContracts.put(contract); + }); + + Future putEthContracts(List contracts) => + isar.writeTxn(() async { + await isar.ethContracts.putAll(contracts); + }); } diff --git a/lib/db/queries/queries.dart b/lib/db/queries/queries.dart index 2995de06d..65fc6d26e 100644 --- a/lib/db/queries/queries.dart +++ b/lib/db/queries/queries.dart @@ -1,4 +1,4 @@ -part of 'package:stackwallet/db/main_db.dart'; +part of 'package:stackwallet/db/isar/main_db.dart'; enum CCFilter { all, @@ -67,10 +67,10 @@ extension MainDBQueries on MainDB { final maybeDecimal = Decimal.tryParse(searchTerm); if (maybeDecimal != null) { qq = qq.or().valueEqualTo( - Format.decimalAmountToSatoshis( + Amount.fromDecimal( maybeDecimal, - coin, - ), + fractionDigits: coin.decimals, + ).raw.toInt(), ); } @@ -139,10 +139,10 @@ extension MainDBQueries on MainDB { final maybeDecimal = Decimal.tryParse(searchTerm); if (maybeDecimal != null) { qq = qq.or().valueEqualTo( - Format.decimalAmountToSatoshis( + Amount.fromDecimal( maybeDecimal, - coin, - ), + fractionDigits: coin.decimals, + ).raw.toInt(), ); } diff --git a/lib/dto/ethereum/eth_token_tx_dto.dart b/lib/dto/ethereum/eth_token_tx_dto.dart new file mode 100644 index 000000000..e7329ef79 --- /dev/null +++ b/lib/dto/ethereum/eth_token_tx_dto.dart @@ -0,0 +1,169 @@ +/// address : "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984" +/// blockNumber : 16484149 +/// logIndex : 61 +/// topics : ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef","0x0000000000000000000000003a5cc8689d1b0cef2c317bc5c0ad6ce88b27d597","0x000000000000000000000000c5e81fc2401b8104966637d5334cbce92f01dbf7"] +/// data : "0x0000000000000000000000000000000000000000000000002dac1c4be587d800" +/// articulatedLog : {"name":"Transfer","inputs":{"_amount":"3291036540000000000","_from":"0x3a5cc8689d1b0cef2c317bc5c0ad6ce88b27d597","_to":"0xc5e81fc2401b8104966637d5334cbce92f01dbf7"}} +/// compressedLog : "{name:Transfer|inputs:{_amount:3291036540000000000|_from:0x3a5cc8689d1b0cef2c317bc5c0ad6ce88b27d597|_to:0xc5e81fc2401b8104966637d5334cbce92f01dbf7}}" +/// transactionHash : "0x5b59559a77fa5f1c70528d41f4fa2e5fa5a00b21fc2f3bc26b208b3062e46333" +/// transactionIndex : 25 + +class EthTokenTxDto { + EthTokenTxDto({ + required this.address, + required this.blockNumber, + required this.logIndex, + required this.topics, + required this.data, + required this.articulatedLog, + required this.compressedLog, + required this.transactionHash, + required this.transactionIndex, + }); + + EthTokenTxDto.fromMap(Map map) + : address = map['address'] as String, + blockNumber = map['blockNumber'] as int, + logIndex = map['logIndex'] as int, + topics = List.from(map['topics'] as List), + data = map['data'] as String, + articulatedLog = map['articulatedLog'] == null + ? null + : ArticulatedLog.fromMap( + Map.from( + map['articulatedLog'] as Map, + ), + ), + compressedLog = map['compressedLog'] as String, + transactionHash = map['transactionHash'] as String, + transactionIndex = map['transactionIndex'] as int; + + final String address; + final int blockNumber; + final int logIndex; + final List topics; + final String data; + final ArticulatedLog? articulatedLog; + final String compressedLog; + final String transactionHash; + final int transactionIndex; + + EthTokenTxDto copyWith({ + String? address, + int? blockNumber, + int? logIndex, + List? topics, + String? data, + ArticulatedLog? articulatedLog, + String? compressedLog, + String? transactionHash, + int? transactionIndex, + }) => + EthTokenTxDto( + address: address ?? this.address, + blockNumber: blockNumber ?? this.blockNumber, + logIndex: logIndex ?? this.logIndex, + topics: topics ?? this.topics, + data: data ?? this.data, + articulatedLog: articulatedLog ?? this.articulatedLog, + compressedLog: compressedLog ?? this.compressedLog, + transactionHash: transactionHash ?? this.transactionHash, + transactionIndex: transactionIndex ?? this.transactionIndex, + ); + + Map toMap() { + final map = {}; + map['address'] = address; + map['blockNumber'] = blockNumber; + map['logIndex'] = logIndex; + map['topics'] = topics; + map['data'] = data; + map['articulatedLog'] = articulatedLog?.toMap(); + map['compressedLog'] = compressedLog; + map['transactionHash'] = transactionHash; + map['transactionIndex'] = transactionIndex; + return map; + } + + @override + String toString() { + return toMap().toString(); + } +} + +/// name : "Transfer" +/// inputs : {"_amount":"3291036540000000000","_from":"0x3a5cc8689d1b0cef2c317bc5c0ad6ce88b27d597","_to":"0xc5e81fc2401b8104966637d5334cbce92f01dbf7"} + +class ArticulatedLog { + ArticulatedLog({ + required this.name, + required this.inputs, + }); + + ArticulatedLog.fromMap(Map map) + : name = map['name'] as String, + inputs = Inputs.fromMap( + Map.from( + map['inputs'] as Map, + ), + ); + + final String name; + final Inputs inputs; + + ArticulatedLog copyWith({ + String? name, + Inputs? inputs, + }) => + ArticulatedLog( + name: name ?? this.name, + inputs: inputs ?? this.inputs, + ); + + Map toMap() { + final map = {}; + map['name'] = name; + map['inputs'] = inputs.toMap(); + return map; + } +} + +/// _amount : "3291036540000000000" +/// _from : "0x3a5cc8689d1b0cef2c317bc5c0ad6ce88b27d597" +/// _to : "0xc5e81fc2401b8104966637d5334cbce92f01dbf7" +/// +class Inputs { + Inputs({ + required this.amount, + required this.from, + required this.to, + }); + + Inputs.fromMap(Map map) + : amount = map['_amount'] as String, + from = map['_from'] as String, + to = map['_to'] as String; + + final String amount; + final String from; + final String to; + + Inputs copyWith({ + String? amount, + String? from, + String? to, + }) => + Inputs( + amount: amount ?? this.amount, + from: from ?? this.from, + to: to ?? this.to, + ); + + Map toMap() { + final map = {}; + map['_amount'] = amount; + map['_from'] = from; + map['_to'] = to; + return map; + } +} diff --git a/lib/dto/ethereum/eth_token_tx_extra_dto.dart b/lib/dto/ethereum/eth_token_tx_extra_dto.dart new file mode 100644 index 000000000..bbc457b0c --- /dev/null +++ b/lib/dto/ethereum/eth_token_tx_extra_dto.dart @@ -0,0 +1,121 @@ +import 'dart:convert'; + +import 'package:stackwallet/utilities/amount/amount.dart'; +import 'package:stackwallet/utilities/enums/coin_enum.dart'; + +class EthTokenTxExtraDTO { + EthTokenTxExtraDTO({ + required this.blockHash, + required this.blockNumber, + required this.from, + required this.gas, + required this.gasCost, + required this.gasPrice, + required this.gasUsed, + required this.hash, + required this.input, + required this.nonce, + required this.timestamp, + required this.to, + required this.transactionIndex, + required this.value, + }); + + factory EthTokenTxExtraDTO.fromMap(Map map) => + EthTokenTxExtraDTO( + hash: map['hash'] as String, + blockHash: map['blockHash'] as String, + blockNumber: map['blockNumber'] as int, + transactionIndex: map['transactionIndex'] as int, + timestamp: map['timestamp'] as int, + from: map['from'] as String, + to: map['to'] as String, + value: Amount( + rawValue: BigInt.parse(map['value'] as String), + fractionDigits: Coin.ethereum.decimals, + ), + gas: _amountFromJsonNum(map['gas']), + gasPrice: _amountFromJsonNum(map['gasPrice']), + nonce: map['nonce'] as int, + input: map['input'] as String, + gasCost: _amountFromJsonNum(map['gasCost']), + gasUsed: _amountFromJsonNum(map['gasUsed']), + ); + + final String hash; + final String blockHash; + final int blockNumber; + final int transactionIndex; + final int timestamp; + final String from; + final String to; + final Amount value; + final Amount gas; + final Amount gasPrice; + final String input; + final int nonce; + final Amount gasCost; + final Amount gasUsed; + + static Amount _amountFromJsonNum(dynamic json) { + return Amount( + rawValue: BigInt.from(json as num), + fractionDigits: Coin.ethereum.decimals, + ); + } + + EthTokenTxExtraDTO copyWith({ + String? hash, + String? blockHash, + int? blockNumber, + int? transactionIndex, + int? timestamp, + String? from, + String? to, + Amount? value, + Amount? gas, + Amount? gasPrice, + int? nonce, + String? input, + Amount? gasCost, + Amount? gasUsed, + }) => + EthTokenTxExtraDTO( + hash: hash ?? this.hash, + blockHash: blockHash ?? this.blockHash, + blockNumber: blockNumber ?? this.blockNumber, + transactionIndex: transactionIndex ?? this.transactionIndex, + timestamp: timestamp ?? this.timestamp, + from: from ?? this.from, + to: to ?? this.to, + value: value ?? this.value, + gas: gas ?? this.gas, + gasPrice: gasPrice ?? this.gasPrice, + nonce: nonce ?? this.nonce, + input: input ?? this.input, + gasCost: gasCost ?? this.gasCost, + gasUsed: gasUsed ?? this.gasUsed, + ); + + Map toMap() { + final map = {}; + map['hash'] = hash; + map['blockHash'] = blockHash; + map['blockNumber'] = blockNumber; + map['transactionIndex'] = transactionIndex; + map['timestamp'] = timestamp; + map['from'] = from; + map['to'] = to; + map['value'] = value; + map['gas'] = gas; + map['gasPrice'] = gasPrice; + map['input'] = input; + map['nonce'] = nonce; + map['gasCost'] = gasCost; + map['gasUsed'] = gasUsed; + return map; + } + + @override + String toString() => jsonEncode(toMap()); +} diff --git a/lib/dto/ethereum/eth_tx_dto.dart b/lib/dto/ethereum/eth_tx_dto.dart new file mode 100644 index 000000000..a4345dec5 --- /dev/null +++ b/lib/dto/ethereum/eth_tx_dto.dart @@ -0,0 +1,135 @@ +import 'dart:convert'; + +import 'package:stackwallet/utilities/amount/amount.dart'; +import 'package:stackwallet/utilities/enums/coin_enum.dart'; + +class EthTxDTO { + EthTxDTO({ + required this.hash, + required this.blockHash, + required this.blockNumber, + required this.transactionIndex, + required this.timestamp, + required this.from, + required this.to, + required this.value, + required this.gas, + required this.gasPrice, + required this.maxFeePerGas, + required this.maxPriorityFeePerGas, + required this.isError, + required this.hasToken, + required this.compressedTx, + required this.gasCost, + required this.gasUsed, + }); + + factory EthTxDTO.fromMap(Map map) => EthTxDTO( + hash: map['hash'] as String, + blockHash: map['blockHash'] as String, + blockNumber: map['blockNumber'] as int, + transactionIndex: map['transactionIndex'] as int, + timestamp: map['timestamp'] as int, + from: map['from'] as String, + to: map['to'] as String, + value: _amountFromJsonNum(map['value']), + gas: _amountFromJsonNum(map['gas']), + gasPrice: _amountFromJsonNum(map['gasPrice']), + maxFeePerGas: _amountFromJsonNum(map['maxFeePerGas']), + maxPriorityFeePerGas: _amountFromJsonNum(map['maxPriorityFeePerGas']), + isError: map['isError'] as int, + hasToken: map['hasToken'] as int, + compressedTx: map['compressedTx'] as String, + gasCost: _amountFromJsonNum(map['gasCost']), + gasUsed: _amountFromJsonNum(map['gasUsed']), + ); + + final String hash; + final String blockHash; + final int blockNumber; + final int transactionIndex; + final int timestamp; + final String from; + final String to; + final Amount value; + final Amount gas; + final Amount gasPrice; + final Amount maxFeePerGas; + final Amount maxPriorityFeePerGas; + final int isError; + final int hasToken; + final String compressedTx; + final Amount gasCost; + final Amount gasUsed; + + static Amount _amountFromJsonNum(dynamic json) { + return Amount( + rawValue: BigInt.from(json as num), + fractionDigits: Coin.ethereum.decimals, + ); + } + + EthTxDTO copyWith({ + String? hash, + String? blockHash, + int? blockNumber, + int? transactionIndex, + int? timestamp, + String? from, + String? to, + Amount? value, + Amount? gas, + Amount? gasPrice, + Amount? maxFeePerGas, + Amount? maxPriorityFeePerGas, + int? isError, + int? hasToken, + String? compressedTx, + Amount? gasCost, + Amount? gasUsed, + }) => + EthTxDTO( + hash: hash ?? this.hash, + blockHash: blockHash ?? this.blockHash, + blockNumber: blockNumber ?? this.blockNumber, + transactionIndex: transactionIndex ?? this.transactionIndex, + timestamp: timestamp ?? this.timestamp, + from: from ?? this.from, + to: to ?? this.to, + value: value ?? this.value, + gas: gas ?? this.gas, + gasPrice: gasPrice ?? this.gasPrice, + maxFeePerGas: maxFeePerGas ?? this.maxFeePerGas, + maxPriorityFeePerGas: maxPriorityFeePerGas ?? this.maxPriorityFeePerGas, + isError: isError ?? this.isError, + hasToken: hasToken ?? this.hasToken, + compressedTx: compressedTx ?? this.compressedTx, + gasCost: gasCost ?? this.gasCost, + gasUsed: gasUsed ?? this.gasUsed, + ); + + Map toMap() { + final map = {}; + map['hash'] = hash; + map['blockHash'] = blockHash; + map['blockNumber'] = blockNumber; + map['transactionIndex'] = transactionIndex; + map['timestamp'] = timestamp; + map['from'] = from; + map['to'] = to; + map['value'] = value; + map['gas'] = gas; + map['gasPrice'] = gasPrice; + map['maxFeePerGas'] = maxFeePerGas; + map['maxPriorityFeePerGas'] = maxPriorityFeePerGas; + map['isError'] = isError; + map['hasToken'] = hasToken; + map['compressedTx'] = compressedTx; + map['gasCost'] = gasCost; + map['gasUsed'] = gasUsed; + return map; + } + + @override + String toString() => jsonEncode(toMap()); +} diff --git a/lib/dto/ethereum/pending_eth_tx_dto.dart b/lib/dto/ethereum/pending_eth_tx_dto.dart new file mode 100644 index 000000000..0c1fa03b6 --- /dev/null +++ b/lib/dto/ethereum/pending_eth_tx_dto.dart @@ -0,0 +1,150 @@ +/// blockHash : null +/// blockNumber : null +/// from : "0x..." +/// gas : "0x7e562" +/// maxPriorityFeePerGas : "0x444380" +/// maxFeePerGas : "0x342570c00" +/// hash : "0x...da64e4" +/// input : "....." +/// nonce : "0x70" +/// to : "0x00....." +/// transactionIndex : null +/// value : "0x0" +/// type : "0x2" +/// accessList : [] +/// chainId : "0x1" +/// v : "0x0" +/// r : "0xd..." +/// s : "0x17d...6e6" + +class PendingEthTxDto { + PendingEthTxDto({ + required this.blockHash, + required this.blockNumber, + required this.from, + required this.gas, + required this.maxPriorityFeePerGas, + required this.maxFeePerGas, + required this.hash, + required this.input, + required this.nonce, + required this.to, + required this.transactionIndex, + required this.value, + required this.type, + required this.accessList, + required this.chainId, + required this.v, + required this.r, + required this.s, + }); + + factory PendingEthTxDto.fromMap(Map map) => PendingEthTxDto( + blockHash: map['blockHash'] as String?, + blockNumber: map['blockNumber'] as int?, + from: map['from'] as String, + gas: map['gas'] as String, + maxPriorityFeePerGas: map['maxPriorityFeePerGas'] as String, + maxFeePerGas: map['maxFeePerGas'] as String, + hash: map['hash'] as String, + input: map['input'] as String, + nonce: map['nonce'] as String, + to: map['to'] as String, + transactionIndex: map['transactionIndex'] as int?, + value: map['value'] as String, + type: map['type'] as String, + accessList: map['accessList'] as List? ?? [], + chainId: map['chainId'] as String, + v: map['v'] as String, + r: map['r'] as String, + s: map['s'] as String, + ); + + final String? blockHash; + final int? blockNumber; + final String from; + final String gas; + final String maxPriorityFeePerGas; + final String maxFeePerGas; + final String hash; + final String input; + final String nonce; + final String to; + final int? transactionIndex; + final String value; + final String type; + final List accessList; + final String chainId; + final String v; + final String r; + final String s; + + PendingEthTxDto copyWith({ + String? blockHash, + int? blockNumber, + String? from, + String? gas, + String? maxPriorityFeePerGas, + String? maxFeePerGas, + String? hash, + String? input, + String? nonce, + String? to, + int? transactionIndex, + String? value, + String? type, + List? accessList, + String? chainId, + String? v, + String? r, + String? s, + }) => + PendingEthTxDto( + blockHash: blockHash ?? this.blockHash, + blockNumber: blockNumber ?? this.blockNumber, + from: from ?? this.from, + gas: gas ?? this.gas, + maxPriorityFeePerGas: maxPriorityFeePerGas ?? this.maxPriorityFeePerGas, + maxFeePerGas: maxFeePerGas ?? this.maxFeePerGas, + hash: hash ?? this.hash, + input: input ?? this.input, + nonce: nonce ?? this.nonce, + to: to ?? this.to, + transactionIndex: transactionIndex ?? this.transactionIndex, + value: value ?? this.value, + type: type ?? this.type, + accessList: accessList ?? this.accessList, + chainId: chainId ?? this.chainId, + v: v ?? this.v, + r: r ?? this.r, + s: s ?? this.s, + ); + + Map toMap() { + final map = {}; + map['blockHash'] = blockHash; + map['blockNumber'] = blockNumber; + map['from'] = from; + map['gas'] = gas; + map['maxPriorityFeePerGas'] = maxPriorityFeePerGas; + map['maxFeePerGas'] = maxFeePerGas; + map['hash'] = hash; + map['input'] = input; + map['nonce'] = nonce; + map['to'] = to; + map['transactionIndex'] = transactionIndex; + map['value'] = value; + map['type'] = type; + map['accessList'] = accessList; + map['chainId'] = chainId; + map['v'] = v; + map['r'] = r; + map['s'] = s; + return map; + } + + @override + String toString() { + return toMap().toString(); + } +} diff --git a/lib/electrumx_rpc/cached_electrumx.dart b/lib/electrumx_rpc/cached_electrumx.dart index e7d815eab..935e8605e 100644 --- a/lib/electrumx_rpc/cached_electrumx.dart +++ b/lib/electrumx_rpc/cached_electrumx.dart @@ -1,7 +1,7 @@ import 'dart:convert'; +import 'package:stackwallet/db/hive/db.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; -import 'package:stackwallet/hive/db.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/prefs.dart'; diff --git a/lib/main.dart b/lib/main.dart index f5208c48f..06a97e881 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -18,12 +18,12 @@ import 'package:hive_flutter/hive_flutter.dart'; import 'package:isar/isar.dart'; import 'package:keyboard_dismisser/keyboard_dismisser.dart'; import 'package:path_provider/path_provider.dart'; -import 'package:stackwallet/db/main_db.dart'; -import 'package:stackwallet/hive/db.dart'; +import 'package:stackwallet/db/hive/db.dart'; +import 'package:stackwallet/db/isar/main_db.dart'; import 'package:stackwallet/models/exchange/change_now/exchange_transaction.dart'; import 'package:stackwallet/models/exchange/change_now/exchange_transaction_status.dart'; import 'package:stackwallet/models/exchange/response_objects/trade.dart'; -import 'package:stackwallet/models/isar/models/log.dart'; +import 'package:stackwallet/models/isar/models/isar_models.dart'; import 'package:stackwallet/models/models.dart'; import 'package:stackwallet/models/node_model.dart'; import 'package:stackwallet/models/notification_model.dart'; @@ -251,6 +251,12 @@ class _MaterialAppWithThemeState extends ConsumerState await ref.read(storageCryptoHandlerProvider).hasPassword(); } await MainDB.instance.initMainDB(); + ref + .read(priceAnd24hChangeNotifierProvider) + .tokenContractAddressesToCheck + .addAll( + await MainDB.instance.getEthContracts().addressProperty().findAll(), + ); } Future load() async { diff --git a/lib/models/add_wallet_list_entity/add_wallet_list_entity.dart b/lib/models/add_wallet_list_entity/add_wallet_list_entity.dart new file mode 100644 index 000000000..3dd24d7b1 --- /dev/null +++ b/lib/models/add_wallet_list_entity/add_wallet_list_entity.dart @@ -0,0 +1,8 @@ +import 'package:equatable/equatable.dart'; +import 'package:stackwallet/utilities/enums/coin_enum.dart'; + +abstract class AddWalletListEntity extends Equatable { + Coin get coin; + String get name; + String get ticker; +} diff --git a/lib/models/add_wallet_list_entity/sub_classes/coin_entity.dart b/lib/models/add_wallet_list_entity/sub_classes/coin_entity.dart new file mode 100644 index 000000000..770a9d1cf --- /dev/null +++ b/lib/models/add_wallet_list_entity/sub_classes/coin_entity.dart @@ -0,0 +1,20 @@ +import 'package:stackwallet/models/add_wallet_list_entity/add_wallet_list_entity.dart'; +import 'package:stackwallet/utilities/enums/coin_enum.dart'; + +class CoinEntity extends AddWalletListEntity { + CoinEntity(this._coin); + + final Coin _coin; + + @override + Coin get coin => _coin; + + @override + String get name => coin.prettyName; + + @override + String get ticker => coin.ticker; + + @override + List get props => [coin, name, ticker]; +} diff --git a/lib/models/add_wallet_list_entity/sub_classes/eth_token_entity.dart b/lib/models/add_wallet_list_entity/sub_classes/eth_token_entity.dart new file mode 100644 index 000000000..ccc0da239 --- /dev/null +++ b/lib/models/add_wallet_list_entity/sub_classes/eth_token_entity.dart @@ -0,0 +1,21 @@ +import 'package:stackwallet/models/add_wallet_list_entity/add_wallet_list_entity.dart'; +import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart'; +import 'package:stackwallet/utilities/enums/coin_enum.dart'; + +class EthTokenEntity extends AddWalletListEntity { + EthTokenEntity(this.token); + + final EthContract token; + + @override + Coin get coin => Coin.ethereum; + + @override + String get name => token.name; + + @override + String get ticker => token.symbol; + + @override + List get props => [coin, name, ticker, token.address]; +} diff --git a/lib/models/balance.dart b/lib/models/balance.dart index 0589ac90d..aa9f04bde 100644 --- a/lib/models/balance.dart +++ b/lib/models/balance.dart @@ -1,15 +1,21 @@ import 'dart:convert'; -import 'package:decimal/decimal.dart'; +import 'package:stackwallet/utilities/amount/amount.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/format.dart'; + +enum Unit { + base, + u, + m, + normal; +} class Balance { final Coin coin; - final int total; - final int spendable; - final int blockedTotal; - final int pendingSpendable; + final Amount total; + final Amount spendable; + final Amount blockedTotal; + final Amount pendingSpendable; Balance({ required this.coin, @@ -19,36 +25,64 @@ class Balance { required this.pendingSpendable, }); - Decimal getTotal({bool includeBlocked = true}) => Format.satoshisToAmount( - includeBlocked ? total : total - blockedTotal, - coin: coin, - ); + // Decimal getTotal({bool includeBlocked = true}) => Format.satoshisToAmount( + // includeBlocked ? total : total - blockedTotal, + // coin: coin, + // ); + // + // Decimal getSpendable() => Format.satoshisToAmount( + // spendable, + // coin: coin, + // ); + // + // Decimal getPending() => Format.satoshisToAmount( + // pendingSpendable, + // coin: coin, + // ); + // + // Decimal getBlocked() => Format.satoshisToAmount( + // blockedTotal, + // coin: coin, + // ); - Decimal getSpendable() => Format.satoshisToAmount( - spendable, - coin: coin, - ); - - Decimal getPending() => Format.satoshisToAmount( - pendingSpendable, - coin: coin, - ); - - Decimal getBlocked() => Format.satoshisToAmount( - blockedTotal, - coin: coin, - ); - - String toJsonIgnoreCoin() => jsonEncode(toMap()..remove("coin")); + String toJsonIgnoreCoin() => jsonEncode({ + "total": total.toJsonString(), + "spendable": spendable.toJsonString(), + "blockedTotal": blockedTotal.toJsonString(), + "pendingSpendable": pendingSpendable.toJsonString(), + }); + // need to fall back to parsing from in due to cached balances being previously + // stored as int values instead of Amounts factory Balance.fromJson(String json, Coin coin) { final decoded = jsonDecode(json); return Balance( coin: coin, - total: decoded["total"] as int, - spendable: decoded["spendable"] as int, - blockedTotal: decoded["blockedTotal"] as int, - pendingSpendable: decoded["pendingSpendable"] as int, + total: decoded["total"] is String + ? Amount.fromSerializedJsonString(decoded["total"] as String) + : Amount( + rawValue: BigInt.from(decoded["total"] as int), + fractionDigits: coin.decimals, + ), + spendable: decoded["spendable"] is String + ? Amount.fromSerializedJsonString(decoded["spendable"] as String) + : Amount( + rawValue: BigInt.from(decoded["spendable"] as int), + fractionDigits: coin.decimals, + ), + blockedTotal: decoded["blockedTotal"] is String + ? Amount.fromSerializedJsonString(decoded["blockedTotal"] as String) + : Amount( + rawValue: BigInt.from(decoded["blockedTotal"] as int), + fractionDigits: coin.decimals, + ), + pendingSpendable: decoded["pendingSpendable"] is String + ? Amount.fromSerializedJsonString( + decoded["pendingSpendable"] as String) + : Amount( + rawValue: BigInt.from(decoded["pendingSpendable"] as int), + fractionDigits: coin.decimals, + ), ); } diff --git a/lib/models/isar/exchange_cache/currency.dart b/lib/models/isar/exchange_cache/currency.dart index 81471a3d1..1744f9350 100644 --- a/lib/models/isar/exchange_cache/currency.dart +++ b/lib/models/isar/exchange_cache/currency.dart @@ -44,11 +44,16 @@ class Currency { @Index() final bool isStackCoin; - @ignore - bool get supportsFixedRate => rateType == SupportedRateType.fixed || rateType == SupportedRateType.both; + final String? tokenContract; @ignore - bool get supportsEstimatedRate => rateType == SupportedRateType.estimated || rateType == SupportedRateType.both; + bool get supportsFixedRate => + rateType == SupportedRateType.fixed || rateType == SupportedRateType.both; + + @ignore + bool get supportsEstimatedRate => + rateType == SupportedRateType.estimated || + rateType == SupportedRateType.both; Currency({ required this.exchangeName, @@ -61,6 +66,7 @@ class Currency { required this.rateType, this.isAvailable, required this.isStackCoin, + required this.tokenContract, }); factory Currency.fromJson( @@ -83,6 +89,7 @@ class Currency { isAvailable: json["isAvailable"] as bool?, isStackCoin: json["isStackCoin"] as bool? ?? Currency.checkIsStackCoin(ticker), + tokenContract: json["tokenContract"] as String?, )..id = json["id"] as int?; } catch (e) { rethrow; @@ -102,6 +109,7 @@ class Currency { "rateType": rateType, "isAvailable": isAvailable, "isStackCoin": isStackCoin, + "tokenContract": tokenContract, }; return map; @@ -119,6 +127,7 @@ class Currency { SupportedRateType? rateType, bool? isAvailable, bool? isStackCoin, + String? tokenContract, }) { return Currency( exchangeName: exchangeName ?? this.exchangeName, @@ -131,6 +140,7 @@ class Currency { rateType: rateType ?? this.rateType, isAvailable: isAvailable ?? this.isAvailable, isStackCoin: isStackCoin ?? this.isStackCoin, + tokenContract: tokenContract ?? this.tokenContract, )..id = id ?? this.id; } diff --git a/lib/models/isar/exchange_cache/currency.g.dart b/lib/models/isar/exchange_cache/currency.g.dart index 02c58cadd..8f81bfdc0 100644 --- a/lib/models/isar/exchange_cache/currency.g.dart +++ b/lib/models/isar/exchange_cache/currency.g.dart @@ -67,6 +67,11 @@ const CurrencySchema = CollectionSchema( id: 9, name: r'ticker', type: IsarType.string, + ), + r'tokenContract': PropertySchema( + id: 10, + name: r'tokenContract', + type: IsarType.string, ) }, estimateSize: _currencyEstimateSize, @@ -150,6 +155,12 @@ int _currencyEstimateSize( bytesCount += 3 + object.name.length * 3; bytesCount += 3 + object.network.length * 3; bytesCount += 3 + object.ticker.length * 3; + { + final value = object.tokenContract; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } return bytesCount; } @@ -169,6 +180,7 @@ void _currencySerialize( writer.writeString(offsets[7], object.network); writer.writeByte(offsets[8], object.rateType.index); writer.writeString(offsets[9], object.ticker); + writer.writeString(offsets[10], object.tokenContract); } Currency _currencyDeserialize( @@ -190,6 +202,7 @@ Currency _currencyDeserialize( _CurrencyrateTypeValueEnumMap[reader.readByteOrNull(offsets[8])] ?? SupportedRateType.fixed, ticker: reader.readString(offsets[9]), + tokenContract: reader.readStringOrNull(offsets[10]), ); object.id = id; return object; @@ -223,6 +236,8 @@ P _currencyDeserializeProp( SupportedRateType.fixed) as P; case 9: return (reader.readString(offset)) as P; + case 10: + return (reader.readStringOrNull(offset)) as P; default: throw IsarError('Unknown property with id $propertyId'); } @@ -1533,6 +1548,158 @@ extension CurrencyQueryFilter )); }); } + + QueryBuilder + tokenContractIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'tokenContract', + )); + }); + } + + QueryBuilder + tokenContractIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'tokenContract', + )); + }); + } + + QueryBuilder tokenContractEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'tokenContract', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + tokenContractGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'tokenContract', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder tokenContractLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'tokenContract', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder tokenContractBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'tokenContract', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + tokenContractStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'tokenContract', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder tokenContractEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'tokenContract', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder tokenContractContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'tokenContract', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder tokenContractMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'tokenContract', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + tokenContractIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'tokenContract', + value: '', + )); + }); + } + + QueryBuilder + tokenContractIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'tokenContract', + value: '', + )); + }); + } } extension CurrencyQueryObject @@ -1661,6 +1828,18 @@ extension CurrencyQuerySortBy on QueryBuilder { return query.addSortBy(r'ticker', Sort.desc); }); } + + QueryBuilder sortByTokenContract() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'tokenContract', Sort.asc); + }); + } + + QueryBuilder sortByTokenContractDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'tokenContract', Sort.desc); + }); + } } extension CurrencyQuerySortThenBy @@ -1796,6 +1975,18 @@ extension CurrencyQuerySortThenBy return query.addSortBy(r'ticker', Sort.desc); }); } + + QueryBuilder thenByTokenContract() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'tokenContract', Sort.asc); + }); + } + + QueryBuilder thenByTokenContractDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'tokenContract', Sort.desc); + }); + } } extension CurrencyQueryWhereDistinct @@ -1865,6 +2056,14 @@ extension CurrencyQueryWhereDistinct return query.addDistinctBy(r'ticker', caseSensitive: caseSensitive); }); } + + QueryBuilder distinctByTokenContract( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'tokenContract', + caseSensitive: caseSensitive); + }); + } } extension CurrencyQueryProperty @@ -1935,4 +2134,10 @@ extension CurrencyQueryProperty return query.addPropertyName(r'ticker'); }); } + + QueryBuilder tokenContractProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'tokenContract'); + }); + } } diff --git a/lib/models/isar/models/blockchain_data/address.dart b/lib/models/isar/models/blockchain_data/address.dart index 770af4a6b..25281a629 100644 --- a/lib/models/isar/models/blockchain_data/address.dart +++ b/lib/models/isar/models/blockchain_data/address.dart @@ -122,7 +122,8 @@ enum AddressType { cryptonote, mimbleWimble, unknown, - nonWallet; + nonWallet, + ethereum; String get readableName { switch (this) { @@ -140,6 +141,8 @@ enum AddressType { return "Unknown"; case AddressType.nonWallet: return "Non wallet/unknown"; + case AddressType.ethereum: + return "Ethereum"; } } } diff --git a/lib/models/isar/models/blockchain_data/address.g.dart b/lib/models/isar/models/blockchain_data/address.g.dart index 37186584b..49188b395 100644 --- a/lib/models/isar/models/blockchain_data/address.g.dart +++ b/lib/models/isar/models/blockchain_data/address.g.dart @@ -260,6 +260,7 @@ const _AddresstypeEnumValueMap = { 'mimbleWimble': 4, 'unknown': 5, 'nonWallet': 6, + 'ethereum': 7, }; const _AddresstypeValueEnumMap = { 0: AddressType.p2pkh, @@ -269,6 +270,7 @@ const _AddresstypeValueEnumMap = { 4: AddressType.mimbleWimble, 5: AddressType.unknown, 6: AddressType.nonWallet, + 7: AddressType.ethereum, }; Id _addressGetId(Address object) { diff --git a/lib/models/isar/models/blockchain_data/transaction.dart b/lib/models/isar/models/blockchain_data/transaction.dart index 191f62b46..39d2cc0af 100644 --- a/lib/models/isar/models/blockchain_data/transaction.dart +++ b/lib/models/isar/models/blockchain_data/transaction.dart @@ -5,6 +5,7 @@ import 'package:isar/isar.dart'; import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; import 'package:stackwallet/models/isar/models/blockchain_data/input.dart'; import 'package:stackwallet/models/isar/models/blockchain_data/output.dart'; +import 'package:stackwallet/utilities/amount/amount.dart'; import 'package:tuple/tuple.dart'; part 'transaction.g.dart'; @@ -18,6 +19,7 @@ class Transaction { required this.type, required this.subType, required this.amount, + required this.amountString, required this.fee, required this.height, required this.isCancelled, @@ -26,6 +28,7 @@ class Transaction { required this.otherData, required this.inputs, required this.outputs, + required this.nonce, }); Tuple2 copyWith({ @@ -35,6 +38,7 @@ class Transaction { TransactionType? type, TransactionSubType? subType, int? amount, + String? amountString, int? fee, int? height, bool? isCancelled, @@ -43,6 +47,7 @@ class Transaction { String? otherData, List? inputs, List? outputs, + int? nonce, Id? id, Address? address, }) { @@ -54,12 +59,14 @@ class Transaction { type: type ?? this.type, subType: subType ?? this.subType, amount: amount ?? this.amount, + amountString: amountString ?? this.amountString, fee: fee ?? this.fee, height: height ?? this.height, isCancelled: isCancelled ?? this.isCancelled, isLelantus: isLelantus ?? this.isLelantus, slateId: slateId ?? this.slateId, otherData: otherData ?? this.otherData, + nonce: nonce ?? this.nonce, inputs: inputs ?? this.inputs, outputs: outputs ?? this.outputs) ..id = id ?? this.id, @@ -84,8 +91,11 @@ class Transaction { @enumerated late final TransactionSubType subType; + @Deprecated("May be inaccurate for large amounts (eth for example)") late final int amount; + late String? amountString; + late final int fee; late final int? height; @@ -98,6 +108,8 @@ class Transaction { late final String? otherData; + late final int? nonce; + late final List inputs; late final List outputs; @@ -105,6 +117,13 @@ class Transaction { @Backlink(to: "transactions") final address = IsarLink(); + @ignore + Amount? _cachedAmount; + + @ignore + Amount get realAmount => + _cachedAmount ??= Amount.fromSerializedJsonString(amountString!); + int getConfirmations(int currentChainHeight) { if (height == null || height! <= 0) return 0; return max(0, currentChainHeight - (height! - 1)); @@ -124,12 +143,14 @@ class Transaction { "type: ${type.name}, " "subType: ${subType.name}, " "amount: $amount, " + "amountString: $amountString, " "fee: $fee, " "height: $height, " "isCancelled: $isCancelled, " "isLelantus: $isLelantus, " "slateId: $slateId, " "otherData: $otherData, " + "nonce: $nonce, " "address: ${address.value}, " "inputsLength: ${inputs.length}, " "outputsLength: ${outputs.length}, " @@ -143,12 +164,14 @@ class Transaction { "type": type.name, "subType": subType.name, "amount": amount, + "amountString": amountString, "fee": fee, "height": height, "isCancelled": isCancelled, "isLelantus": isLelantus, "slateId": slateId, "otherData": otherData, + "nonce": nonce, "address": address.value?.toJsonString(), "inputs": inputs.map((e) => e.toJsonString()).toList(), "outputs": outputs.map((e) => e.toJsonString()).toList(), @@ -168,12 +191,14 @@ class Transaction { type: TransactionType.values.byName(json["type"] as String), subType: TransactionSubType.values.byName(json["subType"] as String), amount: json["amount"] as int, + amountString: json["amountString"] as String, fee: json["fee"] as int, height: json["height"] as int?, isCancelled: json["isCancelled"] as bool, isLelantus: json["isLelantus"] as bool?, slateId: json["slateId"] as String?, otherData: json["otherData"] as String?, + nonce: json["nonce"] as int?, inputs: List.from(json["inputs"] as List) .map((e) => Input.fromJsonString(e)) .toList(), @@ -207,5 +232,6 @@ enum TransactionSubType { none, bip47Notification, // bip47 payment code notification transaction flag mint, // firo specific - join; // firo specific + join, // firo specific + ethToken; // eth token } diff --git a/lib/models/isar/models/blockchain_data/transaction.g.dart b/lib/models/isar/models/blockchain_data/transaction.g.dart index 53acce84f..74a5a1652 100644 --- a/lib/models/isar/models/blockchain_data/transaction.g.dart +++ b/lib/models/isar/models/blockchain_data/transaction.g.dart @@ -22,72 +22,82 @@ const TransactionSchema = CollectionSchema( name: r'amount', type: IsarType.long, ), - r'fee': PropertySchema( + r'amountString': PropertySchema( id: 1, + name: r'amountString', + type: IsarType.string, + ), + r'fee': PropertySchema( + id: 2, name: r'fee', type: IsarType.long, ), r'height': PropertySchema( - id: 2, + id: 3, name: r'height', type: IsarType.long, ), r'inputs': PropertySchema( - id: 3, + id: 4, name: r'inputs', type: IsarType.objectList, target: r'Input', ), r'isCancelled': PropertySchema( - id: 4, + id: 5, name: r'isCancelled', type: IsarType.bool, ), r'isLelantus': PropertySchema( - id: 5, + id: 6, name: r'isLelantus', type: IsarType.bool, ), + r'nonce': PropertySchema( + id: 7, + name: r'nonce', + type: IsarType.long, + ), r'otherData': PropertySchema( - id: 6, + id: 8, name: r'otherData', type: IsarType.string, ), r'outputs': PropertySchema( - id: 7, + id: 9, name: r'outputs', type: IsarType.objectList, target: r'Output', ), r'slateId': PropertySchema( - id: 8, + id: 10, name: r'slateId', type: IsarType.string, ), r'subType': PropertySchema( - id: 9, + id: 11, name: r'subType', type: IsarType.byte, enumMap: _TransactionsubTypeEnumValueMap, ), r'timestamp': PropertySchema( - id: 10, + id: 12, name: r'timestamp', type: IsarType.long, ), r'txid': PropertySchema( - id: 11, + id: 13, name: r'txid', type: IsarType.string, ), r'type': PropertySchema( - id: 12, + id: 14, name: r'type', type: IsarType.byte, enumMap: _TransactiontypeEnumValueMap, ), r'walletId': PropertySchema( - id: 13, + id: 15, name: r'walletId', type: IsarType.string, ) @@ -165,6 +175,12 @@ int _transactionEstimateSize( Map> allOffsets, ) { var bytesCount = offsets.last; + { + final value = object.amountString; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } bytesCount += 3 + object.inputs.length * 3; { final offsets = allOffsets[Input]!; @@ -205,29 +221,31 @@ void _transactionSerialize( Map> allOffsets, ) { writer.writeLong(offsets[0], object.amount); - writer.writeLong(offsets[1], object.fee); - writer.writeLong(offsets[2], object.height); + writer.writeString(offsets[1], object.amountString); + writer.writeLong(offsets[2], object.fee); + writer.writeLong(offsets[3], object.height); writer.writeObjectList( - offsets[3], + offsets[4], allOffsets, InputSchema.serialize, object.inputs, ); - writer.writeBool(offsets[4], object.isCancelled); - writer.writeBool(offsets[5], object.isLelantus); - writer.writeString(offsets[6], object.otherData); + writer.writeBool(offsets[5], object.isCancelled); + writer.writeBool(offsets[6], object.isLelantus); + writer.writeLong(offsets[7], object.nonce); + writer.writeString(offsets[8], object.otherData); writer.writeObjectList( - offsets[7], + offsets[9], allOffsets, OutputSchema.serialize, object.outputs, ); - writer.writeString(offsets[8], object.slateId); - writer.writeByte(offsets[9], object.subType.index); - writer.writeLong(offsets[10], object.timestamp); - writer.writeString(offsets[11], object.txid); - writer.writeByte(offsets[12], object.type.index); - writer.writeString(offsets[13], object.walletId); + writer.writeString(offsets[10], object.slateId); + writer.writeByte(offsets[11], object.subType.index); + writer.writeLong(offsets[12], object.timestamp); + writer.writeString(offsets[13], object.txid); + writer.writeByte(offsets[14], object.type.index); + writer.writeString(offsets[15], object.walletId); } Transaction _transactionDeserialize( @@ -238,34 +256,36 @@ Transaction _transactionDeserialize( ) { final object = Transaction( amount: reader.readLong(offsets[0]), - fee: reader.readLong(offsets[1]), - height: reader.readLongOrNull(offsets[2]), + amountString: reader.readStringOrNull(offsets[1]), + fee: reader.readLong(offsets[2]), + height: reader.readLongOrNull(offsets[3]), inputs: reader.readObjectList( - offsets[3], + offsets[4], InputSchema.deserialize, allOffsets, Input(), ) ?? [], - isCancelled: reader.readBool(offsets[4]), - isLelantus: reader.readBoolOrNull(offsets[5]), - otherData: reader.readStringOrNull(offsets[6]), + isCancelled: reader.readBool(offsets[5]), + isLelantus: reader.readBoolOrNull(offsets[6]), + nonce: reader.readLongOrNull(offsets[7]), + otherData: reader.readStringOrNull(offsets[8]), outputs: reader.readObjectList( - offsets[7], + offsets[9], OutputSchema.deserialize, allOffsets, Output(), ) ?? [], - slateId: reader.readStringOrNull(offsets[8]), + slateId: reader.readStringOrNull(offsets[10]), subType: - _TransactionsubTypeValueEnumMap[reader.readByteOrNull(offsets[9])] ?? + _TransactionsubTypeValueEnumMap[reader.readByteOrNull(offsets[11])] ?? TransactionSubType.none, - timestamp: reader.readLong(offsets[10]), - txid: reader.readString(offsets[11]), - type: _TransactiontypeValueEnumMap[reader.readByteOrNull(offsets[12])] ?? + timestamp: reader.readLong(offsets[12]), + txid: reader.readString(offsets[13]), + type: _TransactiontypeValueEnumMap[reader.readByteOrNull(offsets[14])] ?? TransactionType.outgoing, - walletId: reader.readString(offsets[13]), + walletId: reader.readString(offsets[15]), ); object.id = id; return object; @@ -281,10 +301,12 @@ P _transactionDeserializeProp( case 0: return (reader.readLong(offset)) as P; case 1: - return (reader.readLong(offset)) as P; + return (reader.readStringOrNull(offset)) as P; case 2: - return (reader.readLongOrNull(offset)) as P; + return (reader.readLong(offset)) as P; case 3: + return (reader.readLongOrNull(offset)) as P; + case 4: return (reader.readObjectList( offset, InputSchema.deserialize, @@ -292,13 +314,15 @@ P _transactionDeserializeProp( Input(), ) ?? []) as P; - case 4: - return (reader.readBool(offset)) as P; case 5: - return (reader.readBoolOrNull(offset)) as P; + return (reader.readBool(offset)) as P; case 6: - return (reader.readStringOrNull(offset)) as P; + return (reader.readBoolOrNull(offset)) as P; case 7: + return (reader.readLongOrNull(offset)) as P; + case 8: + return (reader.readStringOrNull(offset)) as P; + case 9: return (reader.readObjectList( offset, OutputSchema.deserialize, @@ -306,19 +330,19 @@ P _transactionDeserializeProp( Output(), ) ?? []) as P; - case 8: + case 10: return (reader.readStringOrNull(offset)) as P; - case 9: + case 11: return (_TransactionsubTypeValueEnumMap[reader.readByteOrNull(offset)] ?? TransactionSubType.none) as P; - case 10: - return (reader.readLong(offset)) as P; - case 11: - return (reader.readString(offset)) as P; case 12: + return (reader.readLong(offset)) as P; + case 13: + return (reader.readString(offset)) as P; + case 14: return (_TransactiontypeValueEnumMap[reader.readByteOrNull(offset)] ?? TransactionType.outgoing) as P; - case 13: + case 15: return (reader.readString(offset)) as P; default: throw IsarError('Unknown property with id $propertyId'); @@ -330,12 +354,14 @@ const _TransactionsubTypeEnumValueMap = { 'bip47Notification': 1, 'mint': 2, 'join': 3, + 'ethToken': 4, }; const _TransactionsubTypeValueEnumMap = { 0: TransactionSubType.none, 1: TransactionSubType.bip47Notification, 2: TransactionSubType.mint, 3: TransactionSubType.join, + 4: TransactionSubType.ethToken, }; const _TransactiontypeEnumValueMap = { 'outgoing': 0, @@ -819,6 +845,160 @@ extension TransactionQueryFilter }); } + QueryBuilder + amountStringIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'amountString', + )); + }); + } + + QueryBuilder + amountStringIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'amountString', + )); + }); + } + + QueryBuilder + amountStringEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'amountString', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + amountStringGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'amountString', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + amountStringLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'amountString', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + amountStringBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'amountString', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + amountStringStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'amountString', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + amountStringEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'amountString', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + amountStringContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'amountString', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + amountStringMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'amountString', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + amountStringIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'amountString', + value: '', + )); + }); + } + + QueryBuilder + amountStringIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'amountString', + value: '', + )); + }); + } + QueryBuilder feeEqualTo( int value) { return QueryBuilder.apply(this, (query) { @@ -1123,6 +1303,77 @@ extension TransactionQueryFilter }); } + QueryBuilder nonceIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'nonce', + )); + }); + } + + QueryBuilder + nonceIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'nonce', + )); + }); + } + + QueryBuilder nonceEqualTo( + int? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'nonce', + value: value, + )); + }); + } + + QueryBuilder + nonceGreaterThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'nonce', + value: value, + )); + }); + } + + QueryBuilder nonceLessThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'nonce', + value: value, + )); + }); + } + + QueryBuilder nonceBetween( + int? lower, + int? upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'nonce', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + QueryBuilder otherDataIsNull() { return QueryBuilder.apply(this, (query) { @@ -1996,6 +2247,19 @@ extension TransactionQuerySortBy }); } + QueryBuilder sortByAmountString() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'amountString', Sort.asc); + }); + } + + QueryBuilder + sortByAmountStringDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'amountString', Sort.desc); + }); + } + QueryBuilder sortByFee() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'fee', Sort.asc); @@ -2044,6 +2308,18 @@ extension TransactionQuerySortBy }); } + QueryBuilder sortByNonce() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'nonce', Sort.asc); + }); + } + + QueryBuilder sortByNonceDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'nonce', Sort.desc); + }); + } + QueryBuilder sortByOtherData() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'otherData', Sort.asc); @@ -2143,6 +2419,19 @@ extension TransactionQuerySortThenBy }); } + QueryBuilder thenByAmountString() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'amountString', Sort.asc); + }); + } + + QueryBuilder + thenByAmountStringDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'amountString', Sort.desc); + }); + } + QueryBuilder thenByFee() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'fee', Sort.asc); @@ -2203,6 +2492,18 @@ extension TransactionQuerySortThenBy }); } + QueryBuilder thenByNonce() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'nonce', Sort.asc); + }); + } + + QueryBuilder thenByNonceDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'nonce', Sort.desc); + }); + } + QueryBuilder thenByOtherData() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'otherData', Sort.asc); @@ -2296,6 +2597,13 @@ extension TransactionQueryWhereDistinct }); } + QueryBuilder distinctByAmountString( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'amountString', caseSensitive: caseSensitive); + }); + } + QueryBuilder distinctByFee() { return QueryBuilder.apply(this, (query) { return query.addDistinctBy(r'fee'); @@ -2320,6 +2628,12 @@ extension TransactionQueryWhereDistinct }); } + QueryBuilder distinctByNonce() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'nonce'); + }); + } + QueryBuilder distinctByOtherData( {bool caseSensitive = true}) { return QueryBuilder.apply(this, (query) { @@ -2381,6 +2695,12 @@ extension TransactionQueryProperty }); } + QueryBuilder amountStringProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'amountString'); + }); + } + QueryBuilder feeProperty() { return QueryBuilder.apply(this, (query) { return query.addPropertyName(r'fee'); @@ -2411,6 +2731,12 @@ extension TransactionQueryProperty }); } + QueryBuilder nonceProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'nonce'); + }); + } + QueryBuilder otherDataProperty() { return QueryBuilder.apply(this, (query) { return query.addPropertyName(r'otherData'); diff --git a/lib/models/isar/models/contract.dart b/lib/models/isar/models/contract.dart new file mode 100644 index 000000000..88e2a454c --- /dev/null +++ b/lib/models/isar/models/contract.dart @@ -0,0 +1,3 @@ +abstract class Contract { + // for possible future use +} diff --git a/lib/models/isar/models/ethereum/eth_contract.dart b/lib/models/isar/models/ethereum/eth_contract.dart new file mode 100644 index 000000000..d969cd503 --- /dev/null +++ b/lib/models/isar/models/ethereum/eth_contract.dart @@ -0,0 +1,60 @@ +import 'package:isar/isar.dart'; +import 'package:stackwallet/models/isar/models/contract.dart'; + +part 'eth_contract.g.dart'; + +@collection +class EthContract extends Contract { + EthContract({ + required this.address, + required this.name, + required this.symbol, + required this.decimals, + required this.type, + this.abi, + }); + + Id id = Isar.autoIncrement; + + @Index(unique: true, replace: true) + late final String address; + + late final String name; + + late final String symbol; + + late final int decimals; + + late final String? abi; + + @enumerated + late final EthContractType type; + + EthContract copyWith({ + Id? id, + String? address, + String? name, + String? symbol, + int? decimals, + EthContractType? type, + List? walletIds, + String? abi, + String? otherData, + }) => + EthContract( + address: address ?? this.address, + name: name ?? this.name, + symbol: symbol ?? this.symbol, + decimals: decimals ?? this.decimals, + type: type ?? this.type, + abi: abi ?? this.abi, + )..id = id ?? this.id; +} + +// Used in Isar db and stored there as int indexes so adding/removing values +// in this definition should be done extremely carefully in production +enum EthContractType { + unknown, + erc20, + erc721; +} diff --git a/lib/models/isar/models/ethereum/eth_contract.g.dart b/lib/models/isar/models/ethereum/eth_contract.g.dart new file mode 100644 index 000000000..bc9548e8d --- /dev/null +++ b/lib/models/isar/models/ethereum/eth_contract.g.dart @@ -0,0 +1,1322 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'eth_contract.dart'; + +// ************************************************************************** +// IsarCollectionGenerator +// ************************************************************************** + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters + +extension GetEthContractCollection on Isar { + IsarCollection get ethContracts => this.collection(); +} + +const EthContractSchema = CollectionSchema( + name: r'EthContract', + id: 3784021410994159165, + properties: { + r'abi': PropertySchema( + id: 0, + name: r'abi', + type: IsarType.string, + ), + r'address': PropertySchema( + id: 1, + name: r'address', + type: IsarType.string, + ), + r'decimals': PropertySchema( + id: 2, + name: r'decimals', + type: IsarType.long, + ), + r'name': PropertySchema( + id: 3, + name: r'name', + type: IsarType.string, + ), + r'symbol': PropertySchema( + id: 4, + name: r'symbol', + type: IsarType.string, + ), + r'type': PropertySchema( + id: 5, + name: r'type', + type: IsarType.byte, + enumMap: _EthContracttypeEnumValueMap, + ) + }, + estimateSize: _ethContractEstimateSize, + serialize: _ethContractSerialize, + deserialize: _ethContractDeserialize, + deserializeProp: _ethContractDeserializeProp, + idName: r'id', + indexes: { + r'address': IndexSchema( + id: -259407546592846288, + name: r'address', + unique: true, + replace: true, + properties: [ + IndexPropertySchema( + name: r'address', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ) + }, + links: {}, + embeddedSchemas: {}, + getId: _ethContractGetId, + getLinks: _ethContractGetLinks, + attach: _ethContractAttach, + version: '3.0.5', +); + +int _ethContractEstimateSize( + EthContract object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + { + final value = object.abi; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + bytesCount += 3 + object.address.length * 3; + bytesCount += 3 + object.name.length * 3; + bytesCount += 3 + object.symbol.length * 3; + return bytesCount; +} + +void _ethContractSerialize( + EthContract object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeString(offsets[0], object.abi); + writer.writeString(offsets[1], object.address); + writer.writeLong(offsets[2], object.decimals); + writer.writeString(offsets[3], object.name); + writer.writeString(offsets[4], object.symbol); + writer.writeByte(offsets[5], object.type.index); +} + +EthContract _ethContractDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = EthContract( + abi: reader.readStringOrNull(offsets[0]), + address: reader.readString(offsets[1]), + decimals: reader.readLong(offsets[2]), + name: reader.readString(offsets[3]), + symbol: reader.readString(offsets[4]), + type: _EthContracttypeValueEnumMap[reader.readByteOrNull(offsets[5])] ?? + EthContractType.unknown, + ); + object.id = id; + return object; +} + +P _ethContractDeserializeProp( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readStringOrNull(offset)) as P; + case 1: + return (reader.readString(offset)) as P; + case 2: + return (reader.readLong(offset)) as P; + case 3: + return (reader.readString(offset)) as P; + case 4: + return (reader.readString(offset)) as P; + case 5: + return (_EthContracttypeValueEnumMap[reader.readByteOrNull(offset)] ?? + EthContractType.unknown) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +const _EthContracttypeEnumValueMap = { + 'unknown': 0, + 'erc20': 1, + 'erc721': 2, +}; +const _EthContracttypeValueEnumMap = { + 0: EthContractType.unknown, + 1: EthContractType.erc20, + 2: EthContractType.erc721, +}; + +Id _ethContractGetId(EthContract object) { + return object.id; +} + +List> _ethContractGetLinks(EthContract object) { + return []; +} + +void _ethContractAttach( + IsarCollection col, Id id, EthContract object) { + object.id = id; +} + +extension EthContractByIndex on IsarCollection { + Future getByAddress(String address) { + return getByIndex(r'address', [address]); + } + + EthContract? getByAddressSync(String address) { + return getByIndexSync(r'address', [address]); + } + + Future deleteByAddress(String address) { + return deleteByIndex(r'address', [address]); + } + + bool deleteByAddressSync(String address) { + return deleteByIndexSync(r'address', [address]); + } + + Future> getAllByAddress(List addressValues) { + final values = addressValues.map((e) => [e]).toList(); + return getAllByIndex(r'address', values); + } + + List getAllByAddressSync(List addressValues) { + final values = addressValues.map((e) => [e]).toList(); + return getAllByIndexSync(r'address', values); + } + + Future deleteAllByAddress(List addressValues) { + final values = addressValues.map((e) => [e]).toList(); + return deleteAllByIndex(r'address', values); + } + + int deleteAllByAddressSync(List addressValues) { + final values = addressValues.map((e) => [e]).toList(); + return deleteAllByIndexSync(r'address', values); + } + + Future putByAddress(EthContract object) { + return putByIndex(r'address', object); + } + + Id putByAddressSync(EthContract object, {bool saveLinks = true}) { + return putByIndexSync(r'address', object, saveLinks: saveLinks); + } + + Future> putAllByAddress(List objects) { + return putAllByIndex(r'address', objects); + } + + List putAllByAddressSync(List objects, + {bool saveLinks = true}) { + return putAllByIndexSync(r'address', objects, saveLinks: saveLinks); + } +} + +extension EthContractQueryWhereSort + on QueryBuilder { + QueryBuilder anyId() { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(const IdWhereClause.any()); + }); + } +} + +extension EthContractQueryWhere + on QueryBuilder { + QueryBuilder idEqualTo(Id id) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: id, + upper: id, + )); + }); + } + + QueryBuilder idNotEqualTo( + Id id) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ) + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ); + } else { + return query + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ) + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ); + } + }); + } + + QueryBuilder idGreaterThan(Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: include), + ); + }); + } + + QueryBuilder idLessThan(Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: include), + ); + }); + } + + QueryBuilder idBetween( + Id lowerId, + Id upperId, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: lowerId, + includeLower: includeLower, + upper: upperId, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder addressEqualTo( + String address) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'address', + value: [address], + )); + }); + } + + QueryBuilder addressNotEqualTo( + String address) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'address', + lower: [], + upper: [address], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'address', + lower: [address], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'address', + lower: [address], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'address', + lower: [], + upper: [address], + includeUpper: false, + )); + } + }); + } +} + +extension EthContractQueryFilter + on QueryBuilder { + QueryBuilder abiIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'abi', + )); + }); + } + + QueryBuilder abiIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'abi', + )); + }); + } + + QueryBuilder abiEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'abi', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'abi', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'abi', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'abi', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'abi', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'abi', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'abi', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'abi', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'abi', + value: '', + )); + }); + } + + QueryBuilder + abiIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'abi', + value: '', + )); + }); + } + + QueryBuilder addressEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'address', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + addressGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'address', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder addressLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'address', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder addressBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'address', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + addressStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'address', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder addressEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'address', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder addressContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'address', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder addressMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'address', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + addressIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'address', + value: '', + )); + }); + } + + QueryBuilder + addressIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'address', + value: '', + )); + }); + } + + QueryBuilder decimalsEqualTo( + int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'decimals', + value: value, + )); + }); + } + + QueryBuilder + decimalsGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'decimals', + value: value, + )); + }); + } + + QueryBuilder + decimalsLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'decimals', + value: value, + )); + }); + } + + QueryBuilder decimalsBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'decimals', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder idEqualTo( + Id value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idGreaterThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idLessThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idBetween( + Id lower, + Id upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'id', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder nameEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'name', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'name', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'name', + value: '', + )); + }); + } + + QueryBuilder + nameIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'name', + value: '', + )); + }); + } + + QueryBuilder symbolEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'symbol', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + symbolGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'symbol', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder symbolLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'symbol', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder symbolBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'symbol', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + symbolStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'symbol', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder symbolEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'symbol', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder symbolContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'symbol', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder symbolMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'symbol', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + symbolIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'symbol', + value: '', + )); + }); + } + + QueryBuilder + symbolIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'symbol', + value: '', + )); + }); + } + + QueryBuilder typeEqualTo( + EthContractType value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'type', + value: value, + )); + }); + } + + QueryBuilder typeGreaterThan( + EthContractType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'type', + value: value, + )); + }); + } + + QueryBuilder typeLessThan( + EthContractType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'type', + value: value, + )); + }); + } + + QueryBuilder typeBetween( + EthContractType lower, + EthContractType upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'type', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } +} + +extension EthContractQueryObject + on QueryBuilder {} + +extension EthContractQueryLinks + on QueryBuilder {} + +extension EthContractQuerySortBy + on QueryBuilder { + QueryBuilder sortByAbi() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'abi', Sort.asc); + }); + } + + QueryBuilder sortByAbiDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'abi', Sort.desc); + }); + } + + QueryBuilder sortByAddress() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'address', Sort.asc); + }); + } + + QueryBuilder sortByAddressDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'address', Sort.desc); + }); + } + + QueryBuilder sortByDecimals() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'decimals', Sort.asc); + }); + } + + QueryBuilder sortByDecimalsDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'decimals', Sort.desc); + }); + } + + QueryBuilder sortByName() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'name', Sort.asc); + }); + } + + QueryBuilder sortByNameDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'name', Sort.desc); + }); + } + + QueryBuilder sortBySymbol() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'symbol', Sort.asc); + }); + } + + QueryBuilder sortBySymbolDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'symbol', Sort.desc); + }); + } + + QueryBuilder sortByType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'type', Sort.asc); + }); + } + + QueryBuilder sortByTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'type', Sort.desc); + }); + } +} + +extension EthContractQuerySortThenBy + on QueryBuilder { + QueryBuilder thenByAbi() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'abi', Sort.asc); + }); + } + + QueryBuilder thenByAbiDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'abi', Sort.desc); + }); + } + + QueryBuilder thenByAddress() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'address', Sort.asc); + }); + } + + QueryBuilder thenByAddressDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'address', Sort.desc); + }); + } + + QueryBuilder thenByDecimals() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'decimals', Sort.asc); + }); + } + + QueryBuilder thenByDecimalsDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'decimals', Sort.desc); + }); + } + + QueryBuilder thenById() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.asc); + }); + } + + QueryBuilder thenByIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.desc); + }); + } + + QueryBuilder thenByName() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'name', Sort.asc); + }); + } + + QueryBuilder thenByNameDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'name', Sort.desc); + }); + } + + QueryBuilder thenBySymbol() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'symbol', Sort.asc); + }); + } + + QueryBuilder thenBySymbolDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'symbol', Sort.desc); + }); + } + + QueryBuilder thenByType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'type', Sort.asc); + }); + } + + QueryBuilder thenByTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'type', Sort.desc); + }); + } +} + +extension EthContractQueryWhereDistinct + on QueryBuilder { + QueryBuilder distinctByAbi( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'abi', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByAddress( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'address', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByDecimals() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'decimals'); + }); + } + + QueryBuilder distinctByName( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'name', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctBySymbol( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'symbol', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByType() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'type'); + }); + } +} + +extension EthContractQueryProperty + on QueryBuilder
( SupportedRateType.fixed) as P; case 9: return (reader.readString(offset)) as P; + case 10: + return (reader.readStringOrNull(offset)) as P; default: throw IsarError('Unknown property with id $propertyId'); } @@ -1533,6 +1548,158 @@ extension CurrencyQueryFilter )); }); } + + QueryBuilder + tokenContractIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'tokenContract', + )); + }); + } + + QueryBuilder + tokenContractIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'tokenContract', + )); + }); + } + + QueryBuilder tokenContractEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'tokenContract', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + tokenContractGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'tokenContract', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder tokenContractLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'tokenContract', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder tokenContractBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'tokenContract', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + tokenContractStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'tokenContract', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder tokenContractEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'tokenContract', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder tokenContractContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'tokenContract', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder tokenContractMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'tokenContract', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + tokenContractIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'tokenContract', + value: '', + )); + }); + } + + QueryBuilder + tokenContractIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'tokenContract', + value: '', + )); + }); + } } extension CurrencyQueryObject @@ -1661,6 +1828,18 @@ extension CurrencyQuerySortBy on QueryBuilder { return query.addSortBy(r'ticker', Sort.desc); }); } + + QueryBuilder sortByTokenContract() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'tokenContract', Sort.asc); + }); + } + + QueryBuilder sortByTokenContractDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'tokenContract', Sort.desc); + }); + } } extension CurrencyQuerySortThenBy @@ -1796,6 +1975,18 @@ extension CurrencyQuerySortThenBy return query.addSortBy(r'ticker', Sort.desc); }); } + + QueryBuilder thenByTokenContract() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'tokenContract', Sort.asc); + }); + } + + QueryBuilder thenByTokenContractDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'tokenContract', Sort.desc); + }); + } } extension CurrencyQueryWhereDistinct @@ -1865,6 +2056,14 @@ extension CurrencyQueryWhereDistinct return query.addDistinctBy(r'ticker', caseSensitive: caseSensitive); }); } + + QueryBuilder distinctByTokenContract( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'tokenContract', + caseSensitive: caseSensitive); + }); + } } extension CurrencyQueryProperty @@ -1935,4 +2134,10 @@ extension CurrencyQueryProperty return query.addPropertyName(r'ticker'); }); } + + QueryBuilder tokenContractProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'tokenContract'); + }); + } } diff --git a/lib/models/isar/models/blockchain_data/address.dart b/lib/models/isar/models/blockchain_data/address.dart index 770af4a6b..25281a629 100644 --- a/lib/models/isar/models/blockchain_data/address.dart +++ b/lib/models/isar/models/blockchain_data/address.dart @@ -122,7 +122,8 @@ enum AddressType { cryptonote, mimbleWimble, unknown, - nonWallet; + nonWallet, + ethereum; String get readableName { switch (this) { @@ -140,6 +141,8 @@ enum AddressType { return "Unknown"; case AddressType.nonWallet: return "Non wallet/unknown"; + case AddressType.ethereum: + return "Ethereum"; } } } diff --git a/lib/models/isar/models/blockchain_data/address.g.dart b/lib/models/isar/models/blockchain_data/address.g.dart index 37186584b..49188b395 100644 --- a/lib/models/isar/models/blockchain_data/address.g.dart +++ b/lib/models/isar/models/blockchain_data/address.g.dart @@ -260,6 +260,7 @@ const _AddresstypeEnumValueMap = { 'mimbleWimble': 4, 'unknown': 5, 'nonWallet': 6, + 'ethereum': 7, }; const _AddresstypeValueEnumMap = { 0: AddressType.p2pkh, @@ -269,6 +270,7 @@ const _AddresstypeValueEnumMap = { 4: AddressType.mimbleWimble, 5: AddressType.unknown, 6: AddressType.nonWallet, + 7: AddressType.ethereum, }; Id _addressGetId(Address object) { diff --git a/lib/models/isar/models/blockchain_data/transaction.dart b/lib/models/isar/models/blockchain_data/transaction.dart index 191f62b46..39d2cc0af 100644 --- a/lib/models/isar/models/blockchain_data/transaction.dart +++ b/lib/models/isar/models/blockchain_data/transaction.dart @@ -5,6 +5,7 @@ import 'package:isar/isar.dart'; import 'package:stackwallet/models/isar/models/blockchain_data/address.dart'; import 'package:stackwallet/models/isar/models/blockchain_data/input.dart'; import 'package:stackwallet/models/isar/models/blockchain_data/output.dart'; +import 'package:stackwallet/utilities/amount/amount.dart'; import 'package:tuple/tuple.dart'; part 'transaction.g.dart'; @@ -18,6 +19,7 @@ class Transaction { required this.type, required this.subType, required this.amount, + required this.amountString, required this.fee, required this.height, required this.isCancelled, @@ -26,6 +28,7 @@ class Transaction { required this.otherData, required this.inputs, required this.outputs, + required this.nonce, }); Tuple2 copyWith({ @@ -35,6 +38,7 @@ class Transaction { TransactionType? type, TransactionSubType? subType, int? amount, + String? amountString, int? fee, int? height, bool? isCancelled, @@ -43,6 +47,7 @@ class Transaction { String? otherData, List? inputs, List? outputs, + int? nonce, Id? id, Address? address, }) { @@ -54,12 +59,14 @@ class Transaction { type: type ?? this.type, subType: subType ?? this.subType, amount: amount ?? this.amount, + amountString: amountString ?? this.amountString, fee: fee ?? this.fee, height: height ?? this.height, isCancelled: isCancelled ?? this.isCancelled, isLelantus: isLelantus ?? this.isLelantus, slateId: slateId ?? this.slateId, otherData: otherData ?? this.otherData, + nonce: nonce ?? this.nonce, inputs: inputs ?? this.inputs, outputs: outputs ?? this.outputs) ..id = id ?? this.id, @@ -84,8 +91,11 @@ class Transaction { @enumerated late final TransactionSubType subType; + @Deprecated("May be inaccurate for large amounts (eth for example)") late final int amount; + late String? amountString; + late final int fee; late final int? height; @@ -98,6 +108,8 @@ class Transaction { late final String? otherData; + late final int? nonce; + late final List inputs; late final List outputs; @@ -105,6 +117,13 @@ class Transaction { @Backlink(to: "transactions") final address = IsarLink(); + @ignore + Amount? _cachedAmount; + + @ignore + Amount get realAmount => + _cachedAmount ??= Amount.fromSerializedJsonString(amountString!); + int getConfirmations(int currentChainHeight) { if (height == null || height! <= 0) return 0; return max(0, currentChainHeight - (height! - 1)); @@ -124,12 +143,14 @@ class Transaction { "type: ${type.name}, " "subType: ${subType.name}, " "amount: $amount, " + "amountString: $amountString, " "fee: $fee, " "height: $height, " "isCancelled: $isCancelled, " "isLelantus: $isLelantus, " "slateId: $slateId, " "otherData: $otherData, " + "nonce: $nonce, " "address: ${address.value}, " "inputsLength: ${inputs.length}, " "outputsLength: ${outputs.length}, " @@ -143,12 +164,14 @@ class Transaction { "type": type.name, "subType": subType.name, "amount": amount, + "amountString": amountString, "fee": fee, "height": height, "isCancelled": isCancelled, "isLelantus": isLelantus, "slateId": slateId, "otherData": otherData, + "nonce": nonce, "address": address.value?.toJsonString(), "inputs": inputs.map((e) => e.toJsonString()).toList(), "outputs": outputs.map((e) => e.toJsonString()).toList(), @@ -168,12 +191,14 @@ class Transaction { type: TransactionType.values.byName(json["type"] as String), subType: TransactionSubType.values.byName(json["subType"] as String), amount: json["amount"] as int, + amountString: json["amountString"] as String, fee: json["fee"] as int, height: json["height"] as int?, isCancelled: json["isCancelled"] as bool, isLelantus: json["isLelantus"] as bool?, slateId: json["slateId"] as String?, otherData: json["otherData"] as String?, + nonce: json["nonce"] as int?, inputs: List.from(json["inputs"] as List) .map((e) => Input.fromJsonString(e)) .toList(), @@ -207,5 +232,6 @@ enum TransactionSubType { none, bip47Notification, // bip47 payment code notification transaction flag mint, // firo specific - join; // firo specific + join, // firo specific + ethToken; // eth token } diff --git a/lib/models/isar/models/blockchain_data/transaction.g.dart b/lib/models/isar/models/blockchain_data/transaction.g.dart index 53acce84f..74a5a1652 100644 --- a/lib/models/isar/models/blockchain_data/transaction.g.dart +++ b/lib/models/isar/models/blockchain_data/transaction.g.dart @@ -22,72 +22,82 @@ const TransactionSchema = CollectionSchema( name: r'amount', type: IsarType.long, ), - r'fee': PropertySchema( + r'amountString': PropertySchema( id: 1, + name: r'amountString', + type: IsarType.string, + ), + r'fee': PropertySchema( + id: 2, name: r'fee', type: IsarType.long, ), r'height': PropertySchema( - id: 2, + id: 3, name: r'height', type: IsarType.long, ), r'inputs': PropertySchema( - id: 3, + id: 4, name: r'inputs', type: IsarType.objectList, target: r'Input', ), r'isCancelled': PropertySchema( - id: 4, + id: 5, name: r'isCancelled', type: IsarType.bool, ), r'isLelantus': PropertySchema( - id: 5, + id: 6, name: r'isLelantus', type: IsarType.bool, ), + r'nonce': PropertySchema( + id: 7, + name: r'nonce', + type: IsarType.long, + ), r'otherData': PropertySchema( - id: 6, + id: 8, name: r'otherData', type: IsarType.string, ), r'outputs': PropertySchema( - id: 7, + id: 9, name: r'outputs', type: IsarType.objectList, target: r'Output', ), r'slateId': PropertySchema( - id: 8, + id: 10, name: r'slateId', type: IsarType.string, ), r'subType': PropertySchema( - id: 9, + id: 11, name: r'subType', type: IsarType.byte, enumMap: _TransactionsubTypeEnumValueMap, ), r'timestamp': PropertySchema( - id: 10, + id: 12, name: r'timestamp', type: IsarType.long, ), r'txid': PropertySchema( - id: 11, + id: 13, name: r'txid', type: IsarType.string, ), r'type': PropertySchema( - id: 12, + id: 14, name: r'type', type: IsarType.byte, enumMap: _TransactiontypeEnumValueMap, ), r'walletId': PropertySchema( - id: 13, + id: 15, name: r'walletId', type: IsarType.string, ) @@ -165,6 +175,12 @@ int _transactionEstimateSize( Map> allOffsets, ) { var bytesCount = offsets.last; + { + final value = object.amountString; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } bytesCount += 3 + object.inputs.length * 3; { final offsets = allOffsets[Input]!; @@ -205,29 +221,31 @@ void _transactionSerialize( Map> allOffsets, ) { writer.writeLong(offsets[0], object.amount); - writer.writeLong(offsets[1], object.fee); - writer.writeLong(offsets[2], object.height); + writer.writeString(offsets[1], object.amountString); + writer.writeLong(offsets[2], object.fee); + writer.writeLong(offsets[3], object.height); writer.writeObjectList( - offsets[3], + offsets[4], allOffsets, InputSchema.serialize, object.inputs, ); - writer.writeBool(offsets[4], object.isCancelled); - writer.writeBool(offsets[5], object.isLelantus); - writer.writeString(offsets[6], object.otherData); + writer.writeBool(offsets[5], object.isCancelled); + writer.writeBool(offsets[6], object.isLelantus); + writer.writeLong(offsets[7], object.nonce); + writer.writeString(offsets[8], object.otherData); writer.writeObjectList( - offsets[7], + offsets[9], allOffsets, OutputSchema.serialize, object.outputs, ); - writer.writeString(offsets[8], object.slateId); - writer.writeByte(offsets[9], object.subType.index); - writer.writeLong(offsets[10], object.timestamp); - writer.writeString(offsets[11], object.txid); - writer.writeByte(offsets[12], object.type.index); - writer.writeString(offsets[13], object.walletId); + writer.writeString(offsets[10], object.slateId); + writer.writeByte(offsets[11], object.subType.index); + writer.writeLong(offsets[12], object.timestamp); + writer.writeString(offsets[13], object.txid); + writer.writeByte(offsets[14], object.type.index); + writer.writeString(offsets[15], object.walletId); } Transaction _transactionDeserialize( @@ -238,34 +256,36 @@ Transaction _transactionDeserialize( ) { final object = Transaction( amount: reader.readLong(offsets[0]), - fee: reader.readLong(offsets[1]), - height: reader.readLongOrNull(offsets[2]), + amountString: reader.readStringOrNull(offsets[1]), + fee: reader.readLong(offsets[2]), + height: reader.readLongOrNull(offsets[3]), inputs: reader.readObjectList( - offsets[3], + offsets[4], InputSchema.deserialize, allOffsets, Input(), ) ?? [], - isCancelled: reader.readBool(offsets[4]), - isLelantus: reader.readBoolOrNull(offsets[5]), - otherData: reader.readStringOrNull(offsets[6]), + isCancelled: reader.readBool(offsets[5]), + isLelantus: reader.readBoolOrNull(offsets[6]), + nonce: reader.readLongOrNull(offsets[7]), + otherData: reader.readStringOrNull(offsets[8]), outputs: reader.readObjectList( - offsets[7], + offsets[9], OutputSchema.deserialize, allOffsets, Output(), ) ?? [], - slateId: reader.readStringOrNull(offsets[8]), + slateId: reader.readStringOrNull(offsets[10]), subType: - _TransactionsubTypeValueEnumMap[reader.readByteOrNull(offsets[9])] ?? + _TransactionsubTypeValueEnumMap[reader.readByteOrNull(offsets[11])] ?? TransactionSubType.none, - timestamp: reader.readLong(offsets[10]), - txid: reader.readString(offsets[11]), - type: _TransactiontypeValueEnumMap[reader.readByteOrNull(offsets[12])] ?? + timestamp: reader.readLong(offsets[12]), + txid: reader.readString(offsets[13]), + type: _TransactiontypeValueEnumMap[reader.readByteOrNull(offsets[14])] ?? TransactionType.outgoing, - walletId: reader.readString(offsets[13]), + walletId: reader.readString(offsets[15]), ); object.id = id; return object; @@ -281,10 +301,12 @@ P _transactionDeserializeProp( case 0: return (reader.readLong(offset)) as P; case 1: - return (reader.readLong(offset)) as P; + return (reader.readStringOrNull(offset)) as P; case 2: - return (reader.readLongOrNull(offset)) as P; + return (reader.readLong(offset)) as P; case 3: + return (reader.readLongOrNull(offset)) as P; + case 4: return (reader.readObjectList( offset, InputSchema.deserialize, @@ -292,13 +314,15 @@ P _transactionDeserializeProp( Input(), ) ?? []) as P; - case 4: - return (reader.readBool(offset)) as P; case 5: - return (reader.readBoolOrNull(offset)) as P; + return (reader.readBool(offset)) as P; case 6: - return (reader.readStringOrNull(offset)) as P; + return (reader.readBoolOrNull(offset)) as P; case 7: + return (reader.readLongOrNull(offset)) as P; + case 8: + return (reader.readStringOrNull(offset)) as P; + case 9: return (reader.readObjectList( offset, OutputSchema.deserialize, @@ -306,19 +330,19 @@ P _transactionDeserializeProp( Output(), ) ?? []) as P; - case 8: + case 10: return (reader.readStringOrNull(offset)) as P; - case 9: + case 11: return (_TransactionsubTypeValueEnumMap[reader.readByteOrNull(offset)] ?? TransactionSubType.none) as P; - case 10: - return (reader.readLong(offset)) as P; - case 11: - return (reader.readString(offset)) as P; case 12: + return (reader.readLong(offset)) as P; + case 13: + return (reader.readString(offset)) as P; + case 14: return (_TransactiontypeValueEnumMap[reader.readByteOrNull(offset)] ?? TransactionType.outgoing) as P; - case 13: + case 15: return (reader.readString(offset)) as P; default: throw IsarError('Unknown property with id $propertyId'); @@ -330,12 +354,14 @@ const _TransactionsubTypeEnumValueMap = { 'bip47Notification': 1, 'mint': 2, 'join': 3, + 'ethToken': 4, }; const _TransactionsubTypeValueEnumMap = { 0: TransactionSubType.none, 1: TransactionSubType.bip47Notification, 2: TransactionSubType.mint, 3: TransactionSubType.join, + 4: TransactionSubType.ethToken, }; const _TransactiontypeEnumValueMap = { 'outgoing': 0, @@ -819,6 +845,160 @@ extension TransactionQueryFilter }); } + QueryBuilder + amountStringIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'amountString', + )); + }); + } + + QueryBuilder + amountStringIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'amountString', + )); + }); + } + + QueryBuilder + amountStringEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'amountString', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + amountStringGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'amountString', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + amountStringLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'amountString', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + amountStringBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'amountString', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + amountStringStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'amountString', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + amountStringEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'amountString', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + amountStringContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'amountString', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + amountStringMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'amountString', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + amountStringIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'amountString', + value: '', + )); + }); + } + + QueryBuilder + amountStringIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'amountString', + value: '', + )); + }); + } + QueryBuilder feeEqualTo( int value) { return QueryBuilder.apply(this, (query) { @@ -1123,6 +1303,77 @@ extension TransactionQueryFilter }); } + QueryBuilder nonceIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'nonce', + )); + }); + } + + QueryBuilder + nonceIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'nonce', + )); + }); + } + + QueryBuilder nonceEqualTo( + int? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'nonce', + value: value, + )); + }); + } + + QueryBuilder + nonceGreaterThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'nonce', + value: value, + )); + }); + } + + QueryBuilder nonceLessThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'nonce', + value: value, + )); + }); + } + + QueryBuilder nonceBetween( + int? lower, + int? upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'nonce', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + QueryBuilder otherDataIsNull() { return QueryBuilder.apply(this, (query) { @@ -1996,6 +2247,19 @@ extension TransactionQuerySortBy }); } + QueryBuilder sortByAmountString() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'amountString', Sort.asc); + }); + } + + QueryBuilder + sortByAmountStringDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'amountString', Sort.desc); + }); + } + QueryBuilder sortByFee() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'fee', Sort.asc); @@ -2044,6 +2308,18 @@ extension TransactionQuerySortBy }); } + QueryBuilder sortByNonce() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'nonce', Sort.asc); + }); + } + + QueryBuilder sortByNonceDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'nonce', Sort.desc); + }); + } + QueryBuilder sortByOtherData() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'otherData', Sort.asc); @@ -2143,6 +2419,19 @@ extension TransactionQuerySortThenBy }); } + QueryBuilder thenByAmountString() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'amountString', Sort.asc); + }); + } + + QueryBuilder + thenByAmountStringDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'amountString', Sort.desc); + }); + } + QueryBuilder thenByFee() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'fee', Sort.asc); @@ -2203,6 +2492,18 @@ extension TransactionQuerySortThenBy }); } + QueryBuilder thenByNonce() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'nonce', Sort.asc); + }); + } + + QueryBuilder thenByNonceDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'nonce', Sort.desc); + }); + } + QueryBuilder thenByOtherData() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'otherData', Sort.asc); @@ -2296,6 +2597,13 @@ extension TransactionQueryWhereDistinct }); } + QueryBuilder distinctByAmountString( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'amountString', caseSensitive: caseSensitive); + }); + } + QueryBuilder distinctByFee() { return QueryBuilder.apply(this, (query) { return query.addDistinctBy(r'fee'); @@ -2320,6 +2628,12 @@ extension TransactionQueryWhereDistinct }); } + QueryBuilder distinctByNonce() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'nonce'); + }); + } + QueryBuilder distinctByOtherData( {bool caseSensitive = true}) { return QueryBuilder.apply(this, (query) { @@ -2381,6 +2695,12 @@ extension TransactionQueryProperty }); } + QueryBuilder amountStringProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'amountString'); + }); + } + QueryBuilder feeProperty() { return QueryBuilder.apply(this, (query) { return query.addPropertyName(r'fee'); @@ -2411,6 +2731,12 @@ extension TransactionQueryProperty }); } + QueryBuilder nonceProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'nonce'); + }); + } + QueryBuilder otherDataProperty() { return QueryBuilder.apply(this, (query) { return query.addPropertyName(r'otherData'); diff --git a/lib/models/isar/models/contract.dart b/lib/models/isar/models/contract.dart new file mode 100644 index 000000000..88e2a454c --- /dev/null +++ b/lib/models/isar/models/contract.dart @@ -0,0 +1,3 @@ +abstract class Contract { + // for possible future use +} diff --git a/lib/models/isar/models/ethereum/eth_contract.dart b/lib/models/isar/models/ethereum/eth_contract.dart new file mode 100644 index 000000000..d969cd503 --- /dev/null +++ b/lib/models/isar/models/ethereum/eth_contract.dart @@ -0,0 +1,60 @@ +import 'package:isar/isar.dart'; +import 'package:stackwallet/models/isar/models/contract.dart'; + +part 'eth_contract.g.dart'; + +@collection +class EthContract extends Contract { + EthContract({ + required this.address, + required this.name, + required this.symbol, + required this.decimals, + required this.type, + this.abi, + }); + + Id id = Isar.autoIncrement; + + @Index(unique: true, replace: true) + late final String address; + + late final String name; + + late final String symbol; + + late final int decimals; + + late final String? abi; + + @enumerated + late final EthContractType type; + + EthContract copyWith({ + Id? id, + String? address, + String? name, + String? symbol, + int? decimals, + EthContractType? type, + List? walletIds, + String? abi, + String? otherData, + }) => + EthContract( + address: address ?? this.address, + name: name ?? this.name, + symbol: symbol ?? this.symbol, + decimals: decimals ?? this.decimals, + type: type ?? this.type, + abi: abi ?? this.abi, + )..id = id ?? this.id; +} + +// Used in Isar db and stored there as int indexes so adding/removing values +// in this definition should be done extremely carefully in production +enum EthContractType { + unknown, + erc20, + erc721; +} diff --git a/lib/models/isar/models/ethereum/eth_contract.g.dart b/lib/models/isar/models/ethereum/eth_contract.g.dart new file mode 100644 index 000000000..bc9548e8d --- /dev/null +++ b/lib/models/isar/models/ethereum/eth_contract.g.dart @@ -0,0 +1,1322 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'eth_contract.dart'; + +// ************************************************************************** +// IsarCollectionGenerator +// ************************************************************************** + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters + +extension GetEthContractCollection on Isar { + IsarCollection get ethContracts => this.collection(); +} + +const EthContractSchema = CollectionSchema( + name: r'EthContract', + id: 3784021410994159165, + properties: { + r'abi': PropertySchema( + id: 0, + name: r'abi', + type: IsarType.string, + ), + r'address': PropertySchema( + id: 1, + name: r'address', + type: IsarType.string, + ), + r'decimals': PropertySchema( + id: 2, + name: r'decimals', + type: IsarType.long, + ), + r'name': PropertySchema( + id: 3, + name: r'name', + type: IsarType.string, + ), + r'symbol': PropertySchema( + id: 4, + name: r'symbol', + type: IsarType.string, + ), + r'type': PropertySchema( + id: 5, + name: r'type', + type: IsarType.byte, + enumMap: _EthContracttypeEnumValueMap, + ) + }, + estimateSize: _ethContractEstimateSize, + serialize: _ethContractSerialize, + deserialize: _ethContractDeserialize, + deserializeProp: _ethContractDeserializeProp, + idName: r'id', + indexes: { + r'address': IndexSchema( + id: -259407546592846288, + name: r'address', + unique: true, + replace: true, + properties: [ + IndexPropertySchema( + name: r'address', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ) + }, + links: {}, + embeddedSchemas: {}, + getId: _ethContractGetId, + getLinks: _ethContractGetLinks, + attach: _ethContractAttach, + version: '3.0.5', +); + +int _ethContractEstimateSize( + EthContract object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + { + final value = object.abi; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + bytesCount += 3 + object.address.length * 3; + bytesCount += 3 + object.name.length * 3; + bytesCount += 3 + object.symbol.length * 3; + return bytesCount; +} + +void _ethContractSerialize( + EthContract object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeString(offsets[0], object.abi); + writer.writeString(offsets[1], object.address); + writer.writeLong(offsets[2], object.decimals); + writer.writeString(offsets[3], object.name); + writer.writeString(offsets[4], object.symbol); + writer.writeByte(offsets[5], object.type.index); +} + +EthContract _ethContractDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = EthContract( + abi: reader.readStringOrNull(offsets[0]), + address: reader.readString(offsets[1]), + decimals: reader.readLong(offsets[2]), + name: reader.readString(offsets[3]), + symbol: reader.readString(offsets[4]), + type: _EthContracttypeValueEnumMap[reader.readByteOrNull(offsets[5])] ?? + EthContractType.unknown, + ); + object.id = id; + return object; +} + +P _ethContractDeserializeProp( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readStringOrNull(offset)) as P; + case 1: + return (reader.readString(offset)) as P; + case 2: + return (reader.readLong(offset)) as P; + case 3: + return (reader.readString(offset)) as P; + case 4: + return (reader.readString(offset)) as P; + case 5: + return (_EthContracttypeValueEnumMap[reader.readByteOrNull(offset)] ?? + EthContractType.unknown) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +const _EthContracttypeEnumValueMap = { + 'unknown': 0, + 'erc20': 1, + 'erc721': 2, +}; +const _EthContracttypeValueEnumMap = { + 0: EthContractType.unknown, + 1: EthContractType.erc20, + 2: EthContractType.erc721, +}; + +Id _ethContractGetId(EthContract object) { + return object.id; +} + +List> _ethContractGetLinks(EthContract object) { + return []; +} + +void _ethContractAttach( + IsarCollection col, Id id, EthContract object) { + object.id = id; +} + +extension EthContractByIndex on IsarCollection { + Future getByAddress(String address) { + return getByIndex(r'address', [address]); + } + + EthContract? getByAddressSync(String address) { + return getByIndexSync(r'address', [address]); + } + + Future deleteByAddress(String address) { + return deleteByIndex(r'address', [address]); + } + + bool deleteByAddressSync(String address) { + return deleteByIndexSync(r'address', [address]); + } + + Future> getAllByAddress(List addressValues) { + final values = addressValues.map((e) => [e]).toList(); + return getAllByIndex(r'address', values); + } + + List getAllByAddressSync(List addressValues) { + final values = addressValues.map((e) => [e]).toList(); + return getAllByIndexSync(r'address', values); + } + + Future deleteAllByAddress(List addressValues) { + final values = addressValues.map((e) => [e]).toList(); + return deleteAllByIndex(r'address', values); + } + + int deleteAllByAddressSync(List addressValues) { + final values = addressValues.map((e) => [e]).toList(); + return deleteAllByIndexSync(r'address', values); + } + + Future putByAddress(EthContract object) { + return putByIndex(r'address', object); + } + + Id putByAddressSync(EthContract object, {bool saveLinks = true}) { + return putByIndexSync(r'address', object, saveLinks: saveLinks); + } + + Future> putAllByAddress(List objects) { + return putAllByIndex(r'address', objects); + } + + List putAllByAddressSync(List objects, + {bool saveLinks = true}) { + return putAllByIndexSync(r'address', objects, saveLinks: saveLinks); + } +} + +extension EthContractQueryWhereSort + on QueryBuilder { + QueryBuilder anyId() { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(const IdWhereClause.any()); + }); + } +} + +extension EthContractQueryWhere + on QueryBuilder { + QueryBuilder idEqualTo(Id id) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: id, + upper: id, + )); + }); + } + + QueryBuilder idNotEqualTo( + Id id) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ) + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ); + } else { + return query + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ) + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ); + } + }); + } + + QueryBuilder idGreaterThan(Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: include), + ); + }); + } + + QueryBuilder idLessThan(Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: include), + ); + }); + } + + QueryBuilder idBetween( + Id lowerId, + Id upperId, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: lowerId, + includeLower: includeLower, + upper: upperId, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder addressEqualTo( + String address) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'address', + value: [address], + )); + }); + } + + QueryBuilder addressNotEqualTo( + String address) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'address', + lower: [], + upper: [address], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'address', + lower: [address], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'address', + lower: [address], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'address', + lower: [], + upper: [address], + includeUpper: false, + )); + } + }); + } +} + +extension EthContractQueryFilter + on QueryBuilder { + QueryBuilder abiIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'abi', + )); + }); + } + + QueryBuilder abiIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'abi', + )); + }); + } + + QueryBuilder abiEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'abi', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'abi', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'abi', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'abi', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'abi', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'abi', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'abi', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'abi', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'abi', + value: '', + )); + }); + } + + QueryBuilder + abiIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'abi', + value: '', + )); + }); + } + + QueryBuilder addressEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'address', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + addressGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'address', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder addressLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'address', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder addressBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'address', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + addressStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'address', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder addressEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'address', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder addressContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'address', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder addressMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'address', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + addressIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'address', + value: '', + )); + }); + } + + QueryBuilder + addressIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'address', + value: '', + )); + }); + } + + QueryBuilder decimalsEqualTo( + int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'decimals', + value: value, + )); + }); + } + + QueryBuilder + decimalsGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'decimals', + value: value, + )); + }); + } + + QueryBuilder + decimalsLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'decimals', + value: value, + )); + }); + } + + QueryBuilder decimalsBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'decimals', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder idEqualTo( + Id value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idGreaterThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idLessThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idBetween( + Id lower, + Id upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'id', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder nameEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'name', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'name', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'name', + value: '', + )); + }); + } + + QueryBuilder + nameIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'name', + value: '', + )); + }); + } + + QueryBuilder symbolEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'symbol', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + symbolGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'symbol', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder symbolLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'symbol', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder symbolBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'symbol', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + symbolStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'symbol', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder symbolEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'symbol', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder symbolContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'symbol', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder symbolMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'symbol', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + symbolIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'symbol', + value: '', + )); + }); + } + + QueryBuilder + symbolIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'symbol', + value: '', + )); + }); + } + + QueryBuilder typeEqualTo( + EthContractType value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'type', + value: value, + )); + }); + } + + QueryBuilder typeGreaterThan( + EthContractType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'type', + value: value, + )); + }); + } + + QueryBuilder typeLessThan( + EthContractType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'type', + value: value, + )); + }); + } + + QueryBuilder typeBetween( + EthContractType lower, + EthContractType upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'type', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } +} + +extension EthContractQueryObject + on QueryBuilder {} + +extension EthContractQueryLinks + on QueryBuilder {} + +extension EthContractQuerySortBy + on QueryBuilder { + QueryBuilder sortByAbi() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'abi', Sort.asc); + }); + } + + QueryBuilder sortByAbiDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'abi', Sort.desc); + }); + } + + QueryBuilder sortByAddress() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'address', Sort.asc); + }); + } + + QueryBuilder sortByAddressDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'address', Sort.desc); + }); + } + + QueryBuilder sortByDecimals() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'decimals', Sort.asc); + }); + } + + QueryBuilder sortByDecimalsDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'decimals', Sort.desc); + }); + } + + QueryBuilder sortByName() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'name', Sort.asc); + }); + } + + QueryBuilder sortByNameDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'name', Sort.desc); + }); + } + + QueryBuilder sortBySymbol() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'symbol', Sort.asc); + }); + } + + QueryBuilder sortBySymbolDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'symbol', Sort.desc); + }); + } + + QueryBuilder sortByType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'type', Sort.asc); + }); + } + + QueryBuilder sortByTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'type', Sort.desc); + }); + } +} + +extension EthContractQuerySortThenBy + on QueryBuilder { + QueryBuilder thenByAbi() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'abi', Sort.asc); + }); + } + + QueryBuilder thenByAbiDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'abi', Sort.desc); + }); + } + + QueryBuilder thenByAddress() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'address', Sort.asc); + }); + } + + QueryBuilder thenByAddressDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'address', Sort.desc); + }); + } + + QueryBuilder thenByDecimals() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'decimals', Sort.asc); + }); + } + + QueryBuilder thenByDecimalsDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'decimals', Sort.desc); + }); + } + + QueryBuilder thenById() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.asc); + }); + } + + QueryBuilder thenByIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.desc); + }); + } + + QueryBuilder thenByName() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'name', Sort.asc); + }); + } + + QueryBuilder thenByNameDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'name', Sort.desc); + }); + } + + QueryBuilder thenBySymbol() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'symbol', Sort.asc); + }); + } + + QueryBuilder thenBySymbolDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'symbol', Sort.desc); + }); + } + + QueryBuilder thenByType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'type', Sort.asc); + }); + } + + QueryBuilder thenByTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'type', Sort.desc); + }); + } +} + +extension EthContractQueryWhereDistinct + on QueryBuilder { + QueryBuilder distinctByAbi( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'abi', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByAddress( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'address', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByDecimals() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'decimals'); + }); + } + + QueryBuilder distinctByName( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'name', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctBySymbol( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'symbol', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByType() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'type'); + }); + } +} + +extension EthContractQueryProperty + on QueryBuilder
( case 0: return (reader.readLong(offset)) as P; case 1: - return (reader.readLong(offset)) as P; + return (reader.readStringOrNull(offset)) as P; case 2: - return (reader.readLongOrNull(offset)) as P; + return (reader.readLong(offset)) as P; case 3: + return (reader.readLongOrNull(offset)) as P; + case 4: return (reader.readObjectList( offset, InputSchema.deserialize, @@ -292,13 +314,15 @@ P _transactionDeserializeProp
( Input(), ) ?? []) as P; - case 4: - return (reader.readBool(offset)) as P; case 5: - return (reader.readBoolOrNull(offset)) as P; + return (reader.readBool(offset)) as P; case 6: - return (reader.readStringOrNull(offset)) as P; + return (reader.readBoolOrNull(offset)) as P; case 7: + return (reader.readLongOrNull(offset)) as P; + case 8: + return (reader.readStringOrNull(offset)) as P; + case 9: return (reader.readObjectList( offset, OutputSchema.deserialize, @@ -306,19 +330,19 @@ P _transactionDeserializeProp( Output(), ) ?? []) as P; - case 8: + case 10: return (reader.readStringOrNull(offset)) as P; - case 9: + case 11: return (_TransactionsubTypeValueEnumMap[reader.readByteOrNull(offset)] ?? TransactionSubType.none) as P; - case 10: - return (reader.readLong(offset)) as P; - case 11: - return (reader.readString(offset)) as P; case 12: + return (reader.readLong(offset)) as P; + case 13: + return (reader.readString(offset)) as P; + case 14: return (_TransactiontypeValueEnumMap[reader.readByteOrNull(offset)] ?? TransactionType.outgoing) as P; - case 13: + case 15: return (reader.readString(offset)) as P; default: throw IsarError('Unknown property with id $propertyId'); @@ -330,12 +354,14 @@ const _TransactionsubTypeEnumValueMap = { 'bip47Notification': 1, 'mint': 2, 'join': 3, + 'ethToken': 4, }; const _TransactionsubTypeValueEnumMap = { 0: TransactionSubType.none, 1: TransactionSubType.bip47Notification, 2: TransactionSubType.mint, 3: TransactionSubType.join, + 4: TransactionSubType.ethToken, }; const _TransactiontypeEnumValueMap = { 'outgoing': 0, @@ -819,6 +845,160 @@ extension TransactionQueryFilter }); } + QueryBuilder + amountStringIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'amountString', + )); + }); + } + + QueryBuilder + amountStringIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'amountString', + )); + }); + } + + QueryBuilder + amountStringEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'amountString', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + amountStringGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'amountString', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + amountStringLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'amountString', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + amountStringBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'amountString', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + amountStringStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'amountString', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + amountStringEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'amountString', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + amountStringContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'amountString', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + amountStringMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'amountString', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + amountStringIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'amountString', + value: '', + )); + }); + } + + QueryBuilder + amountStringIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'amountString', + value: '', + )); + }); + } + QueryBuilder feeEqualTo( int value) { return QueryBuilder.apply(this, (query) { @@ -1123,6 +1303,77 @@ extension TransactionQueryFilter }); } + QueryBuilder nonceIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'nonce', + )); + }); + } + + QueryBuilder + nonceIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'nonce', + )); + }); + } + + QueryBuilder nonceEqualTo( + int? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'nonce', + value: value, + )); + }); + } + + QueryBuilder + nonceGreaterThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'nonce', + value: value, + )); + }); + } + + QueryBuilder nonceLessThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'nonce', + value: value, + )); + }); + } + + QueryBuilder nonceBetween( + int? lower, + int? upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'nonce', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + QueryBuilder otherDataIsNull() { return QueryBuilder.apply(this, (query) { @@ -1996,6 +2247,19 @@ extension TransactionQuerySortBy }); } + QueryBuilder sortByAmountString() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'amountString', Sort.asc); + }); + } + + QueryBuilder + sortByAmountStringDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'amountString', Sort.desc); + }); + } + QueryBuilder sortByFee() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'fee', Sort.asc); @@ -2044,6 +2308,18 @@ extension TransactionQuerySortBy }); } + QueryBuilder sortByNonce() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'nonce', Sort.asc); + }); + } + + QueryBuilder sortByNonceDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'nonce', Sort.desc); + }); + } + QueryBuilder sortByOtherData() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'otherData', Sort.asc); @@ -2143,6 +2419,19 @@ extension TransactionQuerySortThenBy }); } + QueryBuilder thenByAmountString() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'amountString', Sort.asc); + }); + } + + QueryBuilder + thenByAmountStringDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'amountString', Sort.desc); + }); + } + QueryBuilder thenByFee() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'fee', Sort.asc); @@ -2203,6 +2492,18 @@ extension TransactionQuerySortThenBy }); } + QueryBuilder thenByNonce() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'nonce', Sort.asc); + }); + } + + QueryBuilder thenByNonceDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'nonce', Sort.desc); + }); + } + QueryBuilder thenByOtherData() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'otherData', Sort.asc); @@ -2296,6 +2597,13 @@ extension TransactionQueryWhereDistinct }); } + QueryBuilder distinctByAmountString( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'amountString', caseSensitive: caseSensitive); + }); + } + QueryBuilder distinctByFee() { return QueryBuilder.apply(this, (query) { return query.addDistinctBy(r'fee'); @@ -2320,6 +2628,12 @@ extension TransactionQueryWhereDistinct }); } + QueryBuilder distinctByNonce() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'nonce'); + }); + } + QueryBuilder distinctByOtherData( {bool caseSensitive = true}) { return QueryBuilder.apply(this, (query) { @@ -2381,6 +2695,12 @@ extension TransactionQueryProperty }); } + QueryBuilder amountStringProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'amountString'); + }); + } + QueryBuilder feeProperty() { return QueryBuilder.apply(this, (query) { return query.addPropertyName(r'fee'); @@ -2411,6 +2731,12 @@ extension TransactionQueryProperty }); } + QueryBuilder nonceProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'nonce'); + }); + } + QueryBuilder otherDataProperty() { return QueryBuilder.apply(this, (query) { return query.addPropertyName(r'otherData'); diff --git a/lib/models/isar/models/contract.dart b/lib/models/isar/models/contract.dart new file mode 100644 index 000000000..88e2a454c --- /dev/null +++ b/lib/models/isar/models/contract.dart @@ -0,0 +1,3 @@ +abstract class Contract { + // for possible future use +} diff --git a/lib/models/isar/models/ethereum/eth_contract.dart b/lib/models/isar/models/ethereum/eth_contract.dart new file mode 100644 index 000000000..d969cd503 --- /dev/null +++ b/lib/models/isar/models/ethereum/eth_contract.dart @@ -0,0 +1,60 @@ +import 'package:isar/isar.dart'; +import 'package:stackwallet/models/isar/models/contract.dart'; + +part 'eth_contract.g.dart'; + +@collection +class EthContract extends Contract { + EthContract({ + required this.address, + required this.name, + required this.symbol, + required this.decimals, + required this.type, + this.abi, + }); + + Id id = Isar.autoIncrement; + + @Index(unique: true, replace: true) + late final String address; + + late final String name; + + late final String symbol; + + late final int decimals; + + late final String? abi; + + @enumerated + late final EthContractType type; + + EthContract copyWith({ + Id? id, + String? address, + String? name, + String? symbol, + int? decimals, + EthContractType? type, + List? walletIds, + String? abi, + String? otherData, + }) => + EthContract( + address: address ?? this.address, + name: name ?? this.name, + symbol: symbol ?? this.symbol, + decimals: decimals ?? this.decimals, + type: type ?? this.type, + abi: abi ?? this.abi, + )..id = id ?? this.id; +} + +// Used in Isar db and stored there as int indexes so adding/removing values +// in this definition should be done extremely carefully in production +enum EthContractType { + unknown, + erc20, + erc721; +} diff --git a/lib/models/isar/models/ethereum/eth_contract.g.dart b/lib/models/isar/models/ethereum/eth_contract.g.dart new file mode 100644 index 000000000..bc9548e8d --- /dev/null +++ b/lib/models/isar/models/ethereum/eth_contract.g.dart @@ -0,0 +1,1322 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'eth_contract.dart'; + +// ************************************************************************** +// IsarCollectionGenerator +// ************************************************************************** + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters + +extension GetEthContractCollection on Isar { + IsarCollection get ethContracts => this.collection(); +} + +const EthContractSchema = CollectionSchema( + name: r'EthContract', + id: 3784021410994159165, + properties: { + r'abi': PropertySchema( + id: 0, + name: r'abi', + type: IsarType.string, + ), + r'address': PropertySchema( + id: 1, + name: r'address', + type: IsarType.string, + ), + r'decimals': PropertySchema( + id: 2, + name: r'decimals', + type: IsarType.long, + ), + r'name': PropertySchema( + id: 3, + name: r'name', + type: IsarType.string, + ), + r'symbol': PropertySchema( + id: 4, + name: r'symbol', + type: IsarType.string, + ), + r'type': PropertySchema( + id: 5, + name: r'type', + type: IsarType.byte, + enumMap: _EthContracttypeEnumValueMap, + ) + }, + estimateSize: _ethContractEstimateSize, + serialize: _ethContractSerialize, + deserialize: _ethContractDeserialize, + deserializeProp: _ethContractDeserializeProp, + idName: r'id', + indexes: { + r'address': IndexSchema( + id: -259407546592846288, + name: r'address', + unique: true, + replace: true, + properties: [ + IndexPropertySchema( + name: r'address', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ) + }, + links: {}, + embeddedSchemas: {}, + getId: _ethContractGetId, + getLinks: _ethContractGetLinks, + attach: _ethContractAttach, + version: '3.0.5', +); + +int _ethContractEstimateSize( + EthContract object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + { + final value = object.abi; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + bytesCount += 3 + object.address.length * 3; + bytesCount += 3 + object.name.length * 3; + bytesCount += 3 + object.symbol.length * 3; + return bytesCount; +} + +void _ethContractSerialize( + EthContract object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeString(offsets[0], object.abi); + writer.writeString(offsets[1], object.address); + writer.writeLong(offsets[2], object.decimals); + writer.writeString(offsets[3], object.name); + writer.writeString(offsets[4], object.symbol); + writer.writeByte(offsets[5], object.type.index); +} + +EthContract _ethContractDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = EthContract( + abi: reader.readStringOrNull(offsets[0]), + address: reader.readString(offsets[1]), + decimals: reader.readLong(offsets[2]), + name: reader.readString(offsets[3]), + symbol: reader.readString(offsets[4]), + type: _EthContracttypeValueEnumMap[reader.readByteOrNull(offsets[5])] ?? + EthContractType.unknown, + ); + object.id = id; + return object; +} + +P _ethContractDeserializeProp( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readStringOrNull(offset)) as P; + case 1: + return (reader.readString(offset)) as P; + case 2: + return (reader.readLong(offset)) as P; + case 3: + return (reader.readString(offset)) as P; + case 4: + return (reader.readString(offset)) as P; + case 5: + return (_EthContracttypeValueEnumMap[reader.readByteOrNull(offset)] ?? + EthContractType.unknown) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +const _EthContracttypeEnumValueMap = { + 'unknown': 0, + 'erc20': 1, + 'erc721': 2, +}; +const _EthContracttypeValueEnumMap = { + 0: EthContractType.unknown, + 1: EthContractType.erc20, + 2: EthContractType.erc721, +}; + +Id _ethContractGetId(EthContract object) { + return object.id; +} + +List> _ethContractGetLinks(EthContract object) { + return []; +} + +void _ethContractAttach( + IsarCollection col, Id id, EthContract object) { + object.id = id; +} + +extension EthContractByIndex on IsarCollection { + Future getByAddress(String address) { + return getByIndex(r'address', [address]); + } + + EthContract? getByAddressSync(String address) { + return getByIndexSync(r'address', [address]); + } + + Future deleteByAddress(String address) { + return deleteByIndex(r'address', [address]); + } + + bool deleteByAddressSync(String address) { + return deleteByIndexSync(r'address', [address]); + } + + Future> getAllByAddress(List addressValues) { + final values = addressValues.map((e) => [e]).toList(); + return getAllByIndex(r'address', values); + } + + List getAllByAddressSync(List addressValues) { + final values = addressValues.map((e) => [e]).toList(); + return getAllByIndexSync(r'address', values); + } + + Future deleteAllByAddress(List addressValues) { + final values = addressValues.map((e) => [e]).toList(); + return deleteAllByIndex(r'address', values); + } + + int deleteAllByAddressSync(List addressValues) { + final values = addressValues.map((e) => [e]).toList(); + return deleteAllByIndexSync(r'address', values); + } + + Future putByAddress(EthContract object) { + return putByIndex(r'address', object); + } + + Id putByAddressSync(EthContract object, {bool saveLinks = true}) { + return putByIndexSync(r'address', object, saveLinks: saveLinks); + } + + Future> putAllByAddress(List objects) { + return putAllByIndex(r'address', objects); + } + + List putAllByAddressSync(List objects, + {bool saveLinks = true}) { + return putAllByIndexSync(r'address', objects, saveLinks: saveLinks); + } +} + +extension EthContractQueryWhereSort + on QueryBuilder { + QueryBuilder anyId() { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(const IdWhereClause.any()); + }); + } +} + +extension EthContractQueryWhere + on QueryBuilder { + QueryBuilder idEqualTo(Id id) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: id, + upper: id, + )); + }); + } + + QueryBuilder idNotEqualTo( + Id id) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ) + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ); + } else { + return query + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ) + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ); + } + }); + } + + QueryBuilder idGreaterThan(Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: include), + ); + }); + } + + QueryBuilder idLessThan(Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: include), + ); + }); + } + + QueryBuilder idBetween( + Id lowerId, + Id upperId, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: lowerId, + includeLower: includeLower, + upper: upperId, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder addressEqualTo( + String address) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'address', + value: [address], + )); + }); + } + + QueryBuilder addressNotEqualTo( + String address) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'address', + lower: [], + upper: [address], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'address', + lower: [address], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'address', + lower: [address], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'address', + lower: [], + upper: [address], + includeUpper: false, + )); + } + }); + } +} + +extension EthContractQueryFilter + on QueryBuilder { + QueryBuilder abiIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'abi', + )); + }); + } + + QueryBuilder abiIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'abi', + )); + }); + } + + QueryBuilder abiEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'abi', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'abi', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'abi', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'abi', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'abi', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'abi', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'abi', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'abi', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'abi', + value: '', + )); + }); + } + + QueryBuilder + abiIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'abi', + value: '', + )); + }); + } + + QueryBuilder addressEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'address', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + addressGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'address', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder addressLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'address', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder addressBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'address', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + addressStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'address', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder addressEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'address', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder addressContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'address', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder addressMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'address', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + addressIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'address', + value: '', + )); + }); + } + + QueryBuilder + addressIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'address', + value: '', + )); + }); + } + + QueryBuilder decimalsEqualTo( + int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'decimals', + value: value, + )); + }); + } + + QueryBuilder + decimalsGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'decimals', + value: value, + )); + }); + } + + QueryBuilder + decimalsLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'decimals', + value: value, + )); + }); + } + + QueryBuilder decimalsBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'decimals', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder idEqualTo( + Id value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idGreaterThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idLessThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idBetween( + Id lower, + Id upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'id', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder nameEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'name', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'name', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'name', + value: '', + )); + }); + } + + QueryBuilder + nameIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'name', + value: '', + )); + }); + } + + QueryBuilder symbolEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'symbol', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + symbolGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'symbol', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder symbolLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'symbol', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder symbolBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'symbol', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + symbolStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'symbol', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder symbolEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'symbol', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder symbolContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'symbol', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder symbolMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'symbol', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + symbolIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'symbol', + value: '', + )); + }); + } + + QueryBuilder + symbolIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'symbol', + value: '', + )); + }); + } + + QueryBuilder typeEqualTo( + EthContractType value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'type', + value: value, + )); + }); + } + + QueryBuilder typeGreaterThan( + EthContractType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'type', + value: value, + )); + }); + } + + QueryBuilder typeLessThan( + EthContractType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'type', + value: value, + )); + }); + } + + QueryBuilder typeBetween( + EthContractType lower, + EthContractType upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'type', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } +} + +extension EthContractQueryObject + on QueryBuilder {} + +extension EthContractQueryLinks + on QueryBuilder {} + +extension EthContractQuerySortBy + on QueryBuilder { + QueryBuilder sortByAbi() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'abi', Sort.asc); + }); + } + + QueryBuilder sortByAbiDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'abi', Sort.desc); + }); + } + + QueryBuilder sortByAddress() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'address', Sort.asc); + }); + } + + QueryBuilder sortByAddressDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'address', Sort.desc); + }); + } + + QueryBuilder sortByDecimals() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'decimals', Sort.asc); + }); + } + + QueryBuilder sortByDecimalsDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'decimals', Sort.desc); + }); + } + + QueryBuilder sortByName() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'name', Sort.asc); + }); + } + + QueryBuilder sortByNameDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'name', Sort.desc); + }); + } + + QueryBuilder sortBySymbol() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'symbol', Sort.asc); + }); + } + + QueryBuilder sortBySymbolDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'symbol', Sort.desc); + }); + } + + QueryBuilder sortByType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'type', Sort.asc); + }); + } + + QueryBuilder sortByTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'type', Sort.desc); + }); + } +} + +extension EthContractQuerySortThenBy + on QueryBuilder { + QueryBuilder thenByAbi() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'abi', Sort.asc); + }); + } + + QueryBuilder thenByAbiDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'abi', Sort.desc); + }); + } + + QueryBuilder thenByAddress() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'address', Sort.asc); + }); + } + + QueryBuilder thenByAddressDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'address', Sort.desc); + }); + } + + QueryBuilder thenByDecimals() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'decimals', Sort.asc); + }); + } + + QueryBuilder thenByDecimalsDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'decimals', Sort.desc); + }); + } + + QueryBuilder thenById() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.asc); + }); + } + + QueryBuilder thenByIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.desc); + }); + } + + QueryBuilder thenByName() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'name', Sort.asc); + }); + } + + QueryBuilder thenByNameDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'name', Sort.desc); + }); + } + + QueryBuilder thenBySymbol() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'symbol', Sort.asc); + }); + } + + QueryBuilder thenBySymbolDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'symbol', Sort.desc); + }); + } + + QueryBuilder thenByType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'type', Sort.asc); + }); + } + + QueryBuilder thenByTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'type', Sort.desc); + }); + } +} + +extension EthContractQueryWhereDistinct + on QueryBuilder { + QueryBuilder distinctByAbi( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'abi', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByAddress( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'address', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByDecimals() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'decimals'); + }); + } + + QueryBuilder distinctByName( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'name', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctBySymbol( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'symbol', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByType() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'type'); + }); + } +} + +extension EthContractQueryProperty + on QueryBuilder
( Output(), ) ?? []) as P; - case 8: + case 10: return (reader.readStringOrNull(offset)) as P; - case 9: + case 11: return (_TransactionsubTypeValueEnumMap[reader.readByteOrNull(offset)] ?? TransactionSubType.none) as P; - case 10: - return (reader.readLong(offset)) as P; - case 11: - return (reader.readString(offset)) as P; case 12: + return (reader.readLong(offset)) as P; + case 13: + return (reader.readString(offset)) as P; + case 14: return (_TransactiontypeValueEnumMap[reader.readByteOrNull(offset)] ?? TransactionType.outgoing) as P; - case 13: + case 15: return (reader.readString(offset)) as P; default: throw IsarError('Unknown property with id $propertyId'); @@ -330,12 +354,14 @@ const _TransactionsubTypeEnumValueMap = { 'bip47Notification': 1, 'mint': 2, 'join': 3, + 'ethToken': 4, }; const _TransactionsubTypeValueEnumMap = { 0: TransactionSubType.none, 1: TransactionSubType.bip47Notification, 2: TransactionSubType.mint, 3: TransactionSubType.join, + 4: TransactionSubType.ethToken, }; const _TransactiontypeEnumValueMap = { 'outgoing': 0, @@ -819,6 +845,160 @@ extension TransactionQueryFilter }); } + QueryBuilder + amountStringIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'amountString', + )); + }); + } + + QueryBuilder + amountStringIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'amountString', + )); + }); + } + + QueryBuilder + amountStringEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'amountString', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + amountStringGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'amountString', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + amountStringLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'amountString', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + amountStringBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'amountString', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + amountStringStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'amountString', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + amountStringEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'amountString', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + amountStringContains(String value, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'amountString', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + amountStringMatches(String pattern, {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'amountString', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + amountStringIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'amountString', + value: '', + )); + }); + } + + QueryBuilder + amountStringIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'amountString', + value: '', + )); + }); + } + QueryBuilder feeEqualTo( int value) { return QueryBuilder.apply(this, (query) { @@ -1123,6 +1303,77 @@ extension TransactionQueryFilter }); } + QueryBuilder nonceIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'nonce', + )); + }); + } + + QueryBuilder + nonceIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'nonce', + )); + }); + } + + QueryBuilder nonceEqualTo( + int? value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'nonce', + value: value, + )); + }); + } + + QueryBuilder + nonceGreaterThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'nonce', + value: value, + )); + }); + } + + QueryBuilder nonceLessThan( + int? value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'nonce', + value: value, + )); + }); + } + + QueryBuilder nonceBetween( + int? lower, + int? upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'nonce', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + QueryBuilder otherDataIsNull() { return QueryBuilder.apply(this, (query) { @@ -1996,6 +2247,19 @@ extension TransactionQuerySortBy }); } + QueryBuilder sortByAmountString() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'amountString', Sort.asc); + }); + } + + QueryBuilder + sortByAmountStringDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'amountString', Sort.desc); + }); + } + QueryBuilder sortByFee() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'fee', Sort.asc); @@ -2044,6 +2308,18 @@ extension TransactionQuerySortBy }); } + QueryBuilder sortByNonce() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'nonce', Sort.asc); + }); + } + + QueryBuilder sortByNonceDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'nonce', Sort.desc); + }); + } + QueryBuilder sortByOtherData() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'otherData', Sort.asc); @@ -2143,6 +2419,19 @@ extension TransactionQuerySortThenBy }); } + QueryBuilder thenByAmountString() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'amountString', Sort.asc); + }); + } + + QueryBuilder + thenByAmountStringDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'amountString', Sort.desc); + }); + } + QueryBuilder thenByFee() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'fee', Sort.asc); @@ -2203,6 +2492,18 @@ extension TransactionQuerySortThenBy }); } + QueryBuilder thenByNonce() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'nonce', Sort.asc); + }); + } + + QueryBuilder thenByNonceDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'nonce', Sort.desc); + }); + } + QueryBuilder thenByOtherData() { return QueryBuilder.apply(this, (query) { return query.addSortBy(r'otherData', Sort.asc); @@ -2296,6 +2597,13 @@ extension TransactionQueryWhereDistinct }); } + QueryBuilder distinctByAmountString( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'amountString', caseSensitive: caseSensitive); + }); + } + QueryBuilder distinctByFee() { return QueryBuilder.apply(this, (query) { return query.addDistinctBy(r'fee'); @@ -2320,6 +2628,12 @@ extension TransactionQueryWhereDistinct }); } + QueryBuilder distinctByNonce() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'nonce'); + }); + } + QueryBuilder distinctByOtherData( {bool caseSensitive = true}) { return QueryBuilder.apply(this, (query) { @@ -2381,6 +2695,12 @@ extension TransactionQueryProperty }); } + QueryBuilder amountStringProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'amountString'); + }); + } + QueryBuilder feeProperty() { return QueryBuilder.apply(this, (query) { return query.addPropertyName(r'fee'); @@ -2411,6 +2731,12 @@ extension TransactionQueryProperty }); } + QueryBuilder nonceProperty() { + return QueryBuilder.apply(this, (query) { + return query.addPropertyName(r'nonce'); + }); + } + QueryBuilder otherDataProperty() { return QueryBuilder.apply(this, (query) { return query.addPropertyName(r'otherData'); diff --git a/lib/models/isar/models/contract.dart b/lib/models/isar/models/contract.dart new file mode 100644 index 000000000..88e2a454c --- /dev/null +++ b/lib/models/isar/models/contract.dart @@ -0,0 +1,3 @@ +abstract class Contract { + // for possible future use +} diff --git a/lib/models/isar/models/ethereum/eth_contract.dart b/lib/models/isar/models/ethereum/eth_contract.dart new file mode 100644 index 000000000..d969cd503 --- /dev/null +++ b/lib/models/isar/models/ethereum/eth_contract.dart @@ -0,0 +1,60 @@ +import 'package:isar/isar.dart'; +import 'package:stackwallet/models/isar/models/contract.dart'; + +part 'eth_contract.g.dart'; + +@collection +class EthContract extends Contract { + EthContract({ + required this.address, + required this.name, + required this.symbol, + required this.decimals, + required this.type, + this.abi, + }); + + Id id = Isar.autoIncrement; + + @Index(unique: true, replace: true) + late final String address; + + late final String name; + + late final String symbol; + + late final int decimals; + + late final String? abi; + + @enumerated + late final EthContractType type; + + EthContract copyWith({ + Id? id, + String? address, + String? name, + String? symbol, + int? decimals, + EthContractType? type, + List? walletIds, + String? abi, + String? otherData, + }) => + EthContract( + address: address ?? this.address, + name: name ?? this.name, + symbol: symbol ?? this.symbol, + decimals: decimals ?? this.decimals, + type: type ?? this.type, + abi: abi ?? this.abi, + )..id = id ?? this.id; +} + +// Used in Isar db and stored there as int indexes so adding/removing values +// in this definition should be done extremely carefully in production +enum EthContractType { + unknown, + erc20, + erc721; +} diff --git a/lib/models/isar/models/ethereum/eth_contract.g.dart b/lib/models/isar/models/ethereum/eth_contract.g.dart new file mode 100644 index 000000000..bc9548e8d --- /dev/null +++ b/lib/models/isar/models/ethereum/eth_contract.g.dart @@ -0,0 +1,1322 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'eth_contract.dart'; + +// ************************************************************************** +// IsarCollectionGenerator +// ************************************************************************** + +// coverage:ignore-file +// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters + +extension GetEthContractCollection on Isar { + IsarCollection get ethContracts => this.collection(); +} + +const EthContractSchema = CollectionSchema( + name: r'EthContract', + id: 3784021410994159165, + properties: { + r'abi': PropertySchema( + id: 0, + name: r'abi', + type: IsarType.string, + ), + r'address': PropertySchema( + id: 1, + name: r'address', + type: IsarType.string, + ), + r'decimals': PropertySchema( + id: 2, + name: r'decimals', + type: IsarType.long, + ), + r'name': PropertySchema( + id: 3, + name: r'name', + type: IsarType.string, + ), + r'symbol': PropertySchema( + id: 4, + name: r'symbol', + type: IsarType.string, + ), + r'type': PropertySchema( + id: 5, + name: r'type', + type: IsarType.byte, + enumMap: _EthContracttypeEnumValueMap, + ) + }, + estimateSize: _ethContractEstimateSize, + serialize: _ethContractSerialize, + deserialize: _ethContractDeserialize, + deserializeProp: _ethContractDeserializeProp, + idName: r'id', + indexes: { + r'address': IndexSchema( + id: -259407546592846288, + name: r'address', + unique: true, + replace: true, + properties: [ + IndexPropertySchema( + name: r'address', + type: IndexType.hash, + caseSensitive: true, + ) + ], + ) + }, + links: {}, + embeddedSchemas: {}, + getId: _ethContractGetId, + getLinks: _ethContractGetLinks, + attach: _ethContractAttach, + version: '3.0.5', +); + +int _ethContractEstimateSize( + EthContract object, + List offsets, + Map> allOffsets, +) { + var bytesCount = offsets.last; + { + final value = object.abi; + if (value != null) { + bytesCount += 3 + value.length * 3; + } + } + bytesCount += 3 + object.address.length * 3; + bytesCount += 3 + object.name.length * 3; + bytesCount += 3 + object.symbol.length * 3; + return bytesCount; +} + +void _ethContractSerialize( + EthContract object, + IsarWriter writer, + List offsets, + Map> allOffsets, +) { + writer.writeString(offsets[0], object.abi); + writer.writeString(offsets[1], object.address); + writer.writeLong(offsets[2], object.decimals); + writer.writeString(offsets[3], object.name); + writer.writeString(offsets[4], object.symbol); + writer.writeByte(offsets[5], object.type.index); +} + +EthContract _ethContractDeserialize( + Id id, + IsarReader reader, + List offsets, + Map> allOffsets, +) { + final object = EthContract( + abi: reader.readStringOrNull(offsets[0]), + address: reader.readString(offsets[1]), + decimals: reader.readLong(offsets[2]), + name: reader.readString(offsets[3]), + symbol: reader.readString(offsets[4]), + type: _EthContracttypeValueEnumMap[reader.readByteOrNull(offsets[5])] ?? + EthContractType.unknown, + ); + object.id = id; + return object; +} + +P _ethContractDeserializeProp( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readStringOrNull(offset)) as P; + case 1: + return (reader.readString(offset)) as P; + case 2: + return (reader.readLong(offset)) as P; + case 3: + return (reader.readString(offset)) as P; + case 4: + return (reader.readString(offset)) as P; + case 5: + return (_EthContracttypeValueEnumMap[reader.readByteOrNull(offset)] ?? + EthContractType.unknown) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +const _EthContracttypeEnumValueMap = { + 'unknown': 0, + 'erc20': 1, + 'erc721': 2, +}; +const _EthContracttypeValueEnumMap = { + 0: EthContractType.unknown, + 1: EthContractType.erc20, + 2: EthContractType.erc721, +}; + +Id _ethContractGetId(EthContract object) { + return object.id; +} + +List> _ethContractGetLinks(EthContract object) { + return []; +} + +void _ethContractAttach( + IsarCollection col, Id id, EthContract object) { + object.id = id; +} + +extension EthContractByIndex on IsarCollection { + Future getByAddress(String address) { + return getByIndex(r'address', [address]); + } + + EthContract? getByAddressSync(String address) { + return getByIndexSync(r'address', [address]); + } + + Future deleteByAddress(String address) { + return deleteByIndex(r'address', [address]); + } + + bool deleteByAddressSync(String address) { + return deleteByIndexSync(r'address', [address]); + } + + Future> getAllByAddress(List addressValues) { + final values = addressValues.map((e) => [e]).toList(); + return getAllByIndex(r'address', values); + } + + List getAllByAddressSync(List addressValues) { + final values = addressValues.map((e) => [e]).toList(); + return getAllByIndexSync(r'address', values); + } + + Future deleteAllByAddress(List addressValues) { + final values = addressValues.map((e) => [e]).toList(); + return deleteAllByIndex(r'address', values); + } + + int deleteAllByAddressSync(List addressValues) { + final values = addressValues.map((e) => [e]).toList(); + return deleteAllByIndexSync(r'address', values); + } + + Future putByAddress(EthContract object) { + return putByIndex(r'address', object); + } + + Id putByAddressSync(EthContract object, {bool saveLinks = true}) { + return putByIndexSync(r'address', object, saveLinks: saveLinks); + } + + Future> putAllByAddress(List objects) { + return putAllByIndex(r'address', objects); + } + + List putAllByAddressSync(List objects, + {bool saveLinks = true}) { + return putAllByIndexSync(r'address', objects, saveLinks: saveLinks); + } +} + +extension EthContractQueryWhereSort + on QueryBuilder { + QueryBuilder anyId() { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(const IdWhereClause.any()); + }); + } +} + +extension EthContractQueryWhere + on QueryBuilder { + QueryBuilder idEqualTo(Id id) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: id, + upper: id, + )); + }); + } + + QueryBuilder idNotEqualTo( + Id id) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ) + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ); + } else { + return query + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ) + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ); + } + }); + } + + QueryBuilder idGreaterThan(Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: include), + ); + }); + } + + QueryBuilder idLessThan(Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: include), + ); + }); + } + + QueryBuilder idBetween( + Id lowerId, + Id upperId, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: lowerId, + includeLower: includeLower, + upper: upperId, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder addressEqualTo( + String address) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'address', + value: [address], + )); + }); + } + + QueryBuilder addressNotEqualTo( + String address) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'address', + lower: [], + upper: [address], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'address', + lower: [address], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'address', + lower: [address], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'address', + lower: [], + upper: [address], + includeUpper: false, + )); + } + }); + } +} + +extension EthContractQueryFilter + on QueryBuilder { + QueryBuilder abiIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'abi', + )); + }); + } + + QueryBuilder abiIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'abi', + )); + }); + } + + QueryBuilder abiEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'abi', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'abi', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'abi', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'abi', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'abi', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'abi', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'abi', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'abi', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'abi', + value: '', + )); + }); + } + + QueryBuilder + abiIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'abi', + value: '', + )); + }); + } + + QueryBuilder addressEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'address', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + addressGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'address', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder addressLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'address', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder addressBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'address', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + addressStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'address', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder addressEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'address', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder addressContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'address', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder addressMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'address', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + addressIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'address', + value: '', + )); + }); + } + + QueryBuilder + addressIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'address', + value: '', + )); + }); + } + + QueryBuilder decimalsEqualTo( + int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'decimals', + value: value, + )); + }); + } + + QueryBuilder + decimalsGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'decimals', + value: value, + )); + }); + } + + QueryBuilder + decimalsLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'decimals', + value: value, + )); + }); + } + + QueryBuilder decimalsBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'decimals', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder idEqualTo( + Id value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idGreaterThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idLessThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idBetween( + Id lower, + Id upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'id', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder nameEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'name', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'name', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'name', + value: '', + )); + }); + } + + QueryBuilder + nameIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'name', + value: '', + )); + }); + } + + QueryBuilder symbolEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'symbol', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + symbolGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'symbol', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder symbolLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'symbol', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder symbolBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'symbol', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + symbolStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'symbol', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder symbolEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'symbol', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder symbolContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'symbol', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder symbolMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'symbol', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + symbolIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'symbol', + value: '', + )); + }); + } + + QueryBuilder + symbolIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'symbol', + value: '', + )); + }); + } + + QueryBuilder typeEqualTo( + EthContractType value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'type', + value: value, + )); + }); + } + + QueryBuilder typeGreaterThan( + EthContractType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'type', + value: value, + )); + }); + } + + QueryBuilder typeLessThan( + EthContractType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'type', + value: value, + )); + }); + } + + QueryBuilder typeBetween( + EthContractType lower, + EthContractType upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'type', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } +} + +extension EthContractQueryObject + on QueryBuilder {} + +extension EthContractQueryLinks + on QueryBuilder {} + +extension EthContractQuerySortBy + on QueryBuilder { + QueryBuilder sortByAbi() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'abi', Sort.asc); + }); + } + + QueryBuilder sortByAbiDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'abi', Sort.desc); + }); + } + + QueryBuilder sortByAddress() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'address', Sort.asc); + }); + } + + QueryBuilder sortByAddressDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'address', Sort.desc); + }); + } + + QueryBuilder sortByDecimals() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'decimals', Sort.asc); + }); + } + + QueryBuilder sortByDecimalsDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'decimals', Sort.desc); + }); + } + + QueryBuilder sortByName() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'name', Sort.asc); + }); + } + + QueryBuilder sortByNameDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'name', Sort.desc); + }); + } + + QueryBuilder sortBySymbol() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'symbol', Sort.asc); + }); + } + + QueryBuilder sortBySymbolDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'symbol', Sort.desc); + }); + } + + QueryBuilder sortByType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'type', Sort.asc); + }); + } + + QueryBuilder sortByTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'type', Sort.desc); + }); + } +} + +extension EthContractQuerySortThenBy + on QueryBuilder { + QueryBuilder thenByAbi() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'abi', Sort.asc); + }); + } + + QueryBuilder thenByAbiDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'abi', Sort.desc); + }); + } + + QueryBuilder thenByAddress() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'address', Sort.asc); + }); + } + + QueryBuilder thenByAddressDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'address', Sort.desc); + }); + } + + QueryBuilder thenByDecimals() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'decimals', Sort.asc); + }); + } + + QueryBuilder thenByDecimalsDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'decimals', Sort.desc); + }); + } + + QueryBuilder thenById() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.asc); + }); + } + + QueryBuilder thenByIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.desc); + }); + } + + QueryBuilder thenByName() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'name', Sort.asc); + }); + } + + QueryBuilder thenByNameDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'name', Sort.desc); + }); + } + + QueryBuilder thenBySymbol() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'symbol', Sort.asc); + }); + } + + QueryBuilder thenBySymbolDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'symbol', Sort.desc); + }); + } + + QueryBuilder thenByType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'type', Sort.asc); + }); + } + + QueryBuilder thenByTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'type', Sort.desc); + }); + } +} + +extension EthContractQueryWhereDistinct + on QueryBuilder { + QueryBuilder distinctByAbi( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'abi', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByAddress( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'address', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByDecimals() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'decimals'); + }); + } + + QueryBuilder distinctByName( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'name', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctBySymbol( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'symbol', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByType() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'type'); + }); + } +} + +extension EthContractQueryProperty + on QueryBuilder
( + IsarReader reader, + int propertyId, + int offset, + Map> allOffsets, +) { + switch (propertyId) { + case 0: + return (reader.readStringOrNull(offset)) as P; + case 1: + return (reader.readString(offset)) as P; + case 2: + return (reader.readLong(offset)) as P; + case 3: + return (reader.readString(offset)) as P; + case 4: + return (reader.readString(offset)) as P; + case 5: + return (_EthContracttypeValueEnumMap[reader.readByteOrNull(offset)] ?? + EthContractType.unknown) as P; + default: + throw IsarError('Unknown property with id $propertyId'); + } +} + +const _EthContracttypeEnumValueMap = { + 'unknown': 0, + 'erc20': 1, + 'erc721': 2, +}; +const _EthContracttypeValueEnumMap = { + 0: EthContractType.unknown, + 1: EthContractType.erc20, + 2: EthContractType.erc721, +}; + +Id _ethContractGetId(EthContract object) { + return object.id; +} + +List> _ethContractGetLinks(EthContract object) { + return []; +} + +void _ethContractAttach( + IsarCollection col, Id id, EthContract object) { + object.id = id; +} + +extension EthContractByIndex on IsarCollection { + Future getByAddress(String address) { + return getByIndex(r'address', [address]); + } + + EthContract? getByAddressSync(String address) { + return getByIndexSync(r'address', [address]); + } + + Future deleteByAddress(String address) { + return deleteByIndex(r'address', [address]); + } + + bool deleteByAddressSync(String address) { + return deleteByIndexSync(r'address', [address]); + } + + Future> getAllByAddress(List addressValues) { + final values = addressValues.map((e) => [e]).toList(); + return getAllByIndex(r'address', values); + } + + List getAllByAddressSync(List addressValues) { + final values = addressValues.map((e) => [e]).toList(); + return getAllByIndexSync(r'address', values); + } + + Future deleteAllByAddress(List addressValues) { + final values = addressValues.map((e) => [e]).toList(); + return deleteAllByIndex(r'address', values); + } + + int deleteAllByAddressSync(List addressValues) { + final values = addressValues.map((e) => [e]).toList(); + return deleteAllByIndexSync(r'address', values); + } + + Future putByAddress(EthContract object) { + return putByIndex(r'address', object); + } + + Id putByAddressSync(EthContract object, {bool saveLinks = true}) { + return putByIndexSync(r'address', object, saveLinks: saveLinks); + } + + Future> putAllByAddress(List objects) { + return putAllByIndex(r'address', objects); + } + + List putAllByAddressSync(List objects, + {bool saveLinks = true}) { + return putAllByIndexSync(r'address', objects, saveLinks: saveLinks); + } +} + +extension EthContractQueryWhereSort + on QueryBuilder { + QueryBuilder anyId() { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(const IdWhereClause.any()); + }); + } +} + +extension EthContractQueryWhere + on QueryBuilder { + QueryBuilder idEqualTo(Id id) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: id, + upper: id, + )); + }); + } + + QueryBuilder idNotEqualTo( + Id id) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ) + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ); + } else { + return query + .addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: false), + ) + .addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: false), + ); + } + }); + } + + QueryBuilder idGreaterThan(Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.greaterThan(lower: id, includeLower: include), + ); + }); + } + + QueryBuilder idLessThan(Id id, + {bool include = false}) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause( + IdWhereClause.lessThan(upper: id, includeUpper: include), + ); + }); + } + + QueryBuilder idBetween( + Id lowerId, + Id upperId, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IdWhereClause.between( + lower: lowerId, + includeLower: includeLower, + upper: upperId, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder addressEqualTo( + String address) { + return QueryBuilder.apply(this, (query) { + return query.addWhereClause(IndexWhereClause.equalTo( + indexName: r'address', + value: [address], + )); + }); + } + + QueryBuilder addressNotEqualTo( + String address) { + return QueryBuilder.apply(this, (query) { + if (query.whereSort == Sort.asc) { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'address', + lower: [], + upper: [address], + includeUpper: false, + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'address', + lower: [address], + includeLower: false, + upper: [], + )); + } else { + return query + .addWhereClause(IndexWhereClause.between( + indexName: r'address', + lower: [address], + includeLower: false, + upper: [], + )) + .addWhereClause(IndexWhereClause.between( + indexName: r'address', + lower: [], + upper: [address], + includeUpper: false, + )); + } + }); + } +} + +extension EthContractQueryFilter + on QueryBuilder { + QueryBuilder abiIsNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNull( + property: r'abi', + )); + }); + } + + QueryBuilder abiIsNotNull() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(const FilterCondition.isNotNull( + property: r'abi', + )); + }); + } + + QueryBuilder abiEqualTo( + String? value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'abi', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiGreaterThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'abi', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiLessThan( + String? value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'abi', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiBetween( + String? lower, + String? upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'abi', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'abi', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'abi', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'abi', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'abi', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder abiIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'abi', + value: '', + )); + }); + } + + QueryBuilder + abiIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'abi', + value: '', + )); + }); + } + + QueryBuilder addressEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'address', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + addressGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'address', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder addressLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'address', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder addressBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'address', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + addressStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'address', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder addressEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'address', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder addressContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'address', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder addressMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'address', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + addressIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'address', + value: '', + )); + }); + } + + QueryBuilder + addressIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'address', + value: '', + )); + }); + } + + QueryBuilder decimalsEqualTo( + int value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'decimals', + value: value, + )); + }); + } + + QueryBuilder + decimalsGreaterThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'decimals', + value: value, + )); + }); + } + + QueryBuilder + decimalsLessThan( + int value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'decimals', + value: value, + )); + }); + } + + QueryBuilder decimalsBetween( + int lower, + int upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'decimals', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder idEqualTo( + Id value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idGreaterThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idLessThan( + Id value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'id', + value: value, + )); + }); + } + + QueryBuilder idBetween( + Id lower, + Id upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'id', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } + + QueryBuilder nameEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'name', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'name', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'name', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder nameIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'name', + value: '', + )); + }); + } + + QueryBuilder + nameIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'name', + value: '', + )); + }); + } + + QueryBuilder symbolEqualTo( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'symbol', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + symbolGreaterThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'symbol', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder symbolLessThan( + String value, { + bool include = false, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'symbol', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder symbolBetween( + String lower, + String upper, { + bool includeLower = true, + bool includeUpper = true, + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'symbol', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + symbolStartsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.startsWith( + property: r'symbol', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder symbolEndsWith( + String value, { + bool caseSensitive = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.endsWith( + property: r'symbol', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder symbolContains( + String value, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.contains( + property: r'symbol', + value: value, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder symbolMatches( + String pattern, + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.matches( + property: r'symbol', + wildcard: pattern, + caseSensitive: caseSensitive, + )); + }); + } + + QueryBuilder + symbolIsEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'symbol', + value: '', + )); + }); + } + + QueryBuilder + symbolIsNotEmpty() { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + property: r'symbol', + value: '', + )); + }); + } + + QueryBuilder typeEqualTo( + EthContractType value) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.equalTo( + property: r'type', + value: value, + )); + }); + } + + QueryBuilder typeGreaterThan( + EthContractType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.greaterThan( + include: include, + property: r'type', + value: value, + )); + }); + } + + QueryBuilder typeLessThan( + EthContractType value, { + bool include = false, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.lessThan( + include: include, + property: r'type', + value: value, + )); + }); + } + + QueryBuilder typeBetween( + EthContractType lower, + EthContractType upper, { + bool includeLower = true, + bool includeUpper = true, + }) { + return QueryBuilder.apply(this, (query) { + return query.addFilterCondition(FilterCondition.between( + property: r'type', + lower: lower, + includeLower: includeLower, + upper: upper, + includeUpper: includeUpper, + )); + }); + } +} + +extension EthContractQueryObject + on QueryBuilder {} + +extension EthContractQueryLinks + on QueryBuilder {} + +extension EthContractQuerySortBy + on QueryBuilder { + QueryBuilder sortByAbi() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'abi', Sort.asc); + }); + } + + QueryBuilder sortByAbiDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'abi', Sort.desc); + }); + } + + QueryBuilder sortByAddress() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'address', Sort.asc); + }); + } + + QueryBuilder sortByAddressDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'address', Sort.desc); + }); + } + + QueryBuilder sortByDecimals() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'decimals', Sort.asc); + }); + } + + QueryBuilder sortByDecimalsDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'decimals', Sort.desc); + }); + } + + QueryBuilder sortByName() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'name', Sort.asc); + }); + } + + QueryBuilder sortByNameDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'name', Sort.desc); + }); + } + + QueryBuilder sortBySymbol() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'symbol', Sort.asc); + }); + } + + QueryBuilder sortBySymbolDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'symbol', Sort.desc); + }); + } + + QueryBuilder sortByType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'type', Sort.asc); + }); + } + + QueryBuilder sortByTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'type', Sort.desc); + }); + } +} + +extension EthContractQuerySortThenBy + on QueryBuilder { + QueryBuilder thenByAbi() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'abi', Sort.asc); + }); + } + + QueryBuilder thenByAbiDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'abi', Sort.desc); + }); + } + + QueryBuilder thenByAddress() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'address', Sort.asc); + }); + } + + QueryBuilder thenByAddressDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'address', Sort.desc); + }); + } + + QueryBuilder thenByDecimals() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'decimals', Sort.asc); + }); + } + + QueryBuilder thenByDecimalsDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'decimals', Sort.desc); + }); + } + + QueryBuilder thenById() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.asc); + }); + } + + QueryBuilder thenByIdDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'id', Sort.desc); + }); + } + + QueryBuilder thenByName() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'name', Sort.asc); + }); + } + + QueryBuilder thenByNameDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'name', Sort.desc); + }); + } + + QueryBuilder thenBySymbol() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'symbol', Sort.asc); + }); + } + + QueryBuilder thenBySymbolDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'symbol', Sort.desc); + }); + } + + QueryBuilder thenByType() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'type', Sort.asc); + }); + } + + QueryBuilder thenByTypeDesc() { + return QueryBuilder.apply(this, (query) { + return query.addSortBy(r'type', Sort.desc); + }); + } +} + +extension EthContractQueryWhereDistinct + on QueryBuilder { + QueryBuilder distinctByAbi( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'abi', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByAddress( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'address', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByDecimals() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'decimals'); + }); + } + + QueryBuilder distinctByName( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'name', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctBySymbol( + {bool caseSensitive = true}) { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'symbol', caseSensitive: caseSensitive); + }); + } + + QueryBuilder distinctByType() { + return QueryBuilder.apply(this, (query) { + return query.addDistinctBy(r'type'); + }); + } +} + +extension EthContractQueryProperty + on QueryBuilder