Skip to content

Commit

Permalink
Monero update (#1325)
Browse files Browse the repository at this point in the history
* New price API

* Fix test app package id

* Fix workflow

* change environment variable to use pr number [skip ci]

* Fix un-needed padding

* Fix raw value for usdtSol

* Remove duplicate fetching for balance and transactions at start [skip ci]

* Fix address validation of spl tokens

* Add Service Status

* Update lib/src/widgets/service_status_tile.dart

Co-authored-by: Konstantin Ullrich <[email protected]>

* Update lib/src/widgets/services_updates_widget.dart

Co-authored-by: Konstantin Ullrich <[email protected]>

* Update monero version

* update sodium script

* Change automatic priority fee rate

* New versions [skip ci]

* Update monero version

* Temp remove split per abi

* Specifically build monero.com

* Revert monero dependencies trial fix

* Update Monero
Fix Monero Automatic Priority

* Fix android script

* Fix build_monero.sh android
Add svg notification icon

* trial 1

* trial 2

* trial 3

* trial 4

* Trial 5

* Trial

* revert

---------

Co-authored-by: Konstantin Ullrich <[email protected]>
  • Loading branch information
OmarHatem28 and konstantinullrich authored Mar 14, 2024
1 parent 6414364 commit 50b5ebc
Show file tree
Hide file tree
Showing 19 changed files with 156 additions and 63 deletions.
Binary file removed assets/images/notification_icon.png
Binary file not shown.
69 changes: 69 additions & 0 deletions assets/images/notification_icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion assets/text/Monerocom_Release_Notes.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
New themes
In-App live status page for the app services
Bug fixes and enhancements
6 changes: 1 addition & 5 deletions assets/text/Release_Notes.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,2 @@
Add Solana wallet
Support ALL Bitcoin address types (Legacy, Segwit (both variants), Taproot)
Enhance Sending/Receiving flow for Bitcoin
Improve fee calculations in Bitcoin
New themes
In-App live status page for the app services
Bug fixes and enhancements
14 changes: 5 additions & 9 deletions cw_core/lib/monero_transaction_priority.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import 'package:cw_core/transaction_priority.dart';
import 'package:cw_core/wallet_type.dart';
//import 'package:cake_wallet/generated/i18n.dart';
import 'package:cw_core/enumerable_item.dart';

class MoneroTransactionPriority extends TransactionPriority {
const MoneroTransactionPriority({required String title, required int raw})
Expand All @@ -12,21 +9,20 @@ class MoneroTransactionPriority extends TransactionPriority {
MoneroTransactionPriority.automatic,
MoneroTransactionPriority.medium,
MoneroTransactionPriority.fast,
MoneroTransactionPriority.fastest
MoneroTransactionPriority.fastest,
];
static const slow = MoneroTransactionPriority(title: 'Slow', raw: 0);
static const automatic = MoneroTransactionPriority(title: 'Automatic', raw: 1);
static const automatic = MoneroTransactionPriority(title: 'Automatic', raw: 0);
static const slow = MoneroTransactionPriority(title: 'Slow', raw: 1);
static const medium = MoneroTransactionPriority(title: 'Medium', raw: 2);
static const fast = MoneroTransactionPriority(title: 'Fast', raw: 3);
static const fastest = MoneroTransactionPriority(title: 'Fastest', raw: 4);
static const standard = slow;

static MoneroTransactionPriority deserialize({required int raw}) {
switch (raw) {
case 0:
return slow;
case 1:
return automatic;
case 1:
return slow;
case 2:
return medium;
case 3:
Expand Down
4 changes: 1 addition & 3 deletions cw_monero/lib/monero_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,7 @@ abstract class MoneroWalletBase
pendingTransactionDescription = await transaction_history.createTransaction(
address: address!,
amount: amount,
priorityRaw: _credentials.priority == MoneroTransactionPriority.automatic
? MoneroTransactionPriority.medium.serialize()
: _credentials.priority.serialize(),
priorityRaw: _credentials.priority.serialize(),
accountIndex: walletAddresses.account!.id,
preferredInputs: inputs);
}
Expand Down
15 changes: 15 additions & 0 deletions lib/entities/default_settings_migration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ Future<void> defaultSettingsMigration(
await changeSolanaCurrentNodeToDefault(
sharedPreferences: sharedPreferences, nodes: nodes);
break;
case 28:
await _updateMoneroPriority(sharedPreferences);
break;
default:
break;
}
Expand All @@ -215,6 +218,18 @@ Future<void> defaultSettingsMigration(
await sharedPreferences.setInt(PreferencesKey.currentDefaultSettingsMigrationVersion, version);
}

Future<void> _updateMoneroPriority(SharedPreferences sharedPreferences) async {
final currentPriority =
await sharedPreferences.getInt(PreferencesKey.moneroTransactionPriority) ??
monero!.getDefaultTransactionPriority().serialize();

// was set to automatic but automatic should be 0
if (currentPriority == 1) {
sharedPreferences.setInt(PreferencesKey.moneroTransactionPriority,
monero!.getDefaultTransactionPriority().serialize()); // 0
}
}

Future<void> _validateWalletInfoBoxData(Box<WalletInfo> walletInfoSource) async {
try {
final root = await getApplicationDocumentsDirectory();
Expand Down
2 changes: 1 addition & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ Future<void> initializeAppConfigs() async {
transactionDescriptions: transactionDescriptions,
secureStorage: secureStorage,
anonpayInvoiceInfo: anonpayInvoiceInfo,
initialMigrationVersion: 27);
initialMigrationVersion: 28);
}

Future<void> initialSetup(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ class SideMenuItem extends StatelessWidget {
required this.onTap,
this.imagePath,
this.icon,
this.widget,
this.isSelected = false,
}) : assert((icon != null && imagePath == null) || (icon == null && imagePath != null));
}) : assert(widget != null || icon != null || imagePath != null);

final void Function() onTap;
final String? imagePath;
final IconData? icon;
final bool isSelected;
final Widget? widget;

Color _setColor(BuildContext context) {
if (isSelected) {
Expand All @@ -28,18 +30,7 @@ class SideMenuItem extends StatelessWidget {
return InkWell(
child: Padding(
padding: EdgeInsets.all(20),
child: icon != null
? Icon(
icon,
color: _setColor(context),
)
: Image.asset(
imagePath ?? '',
fit: BoxFit.cover,
height: 30,
width: 30,
color: _setColor(context),
),
child: widget ?? _getIcon(context),
),
onTap: () => onTap.call(),
highlightColor: Colors.transparent,
Expand All @@ -48,4 +39,19 @@ class SideMenuItem extends StatelessWidget {
splashColor: Colors.transparent,
);
}

Widget _getIcon(BuildContext context) {
return icon != null
? Icon(
icon,
color: _setColor(context),
)
: Image.asset(
imagePath ?? '',
fit: BoxFit.cover,
height: 30,
width: 30,
color: _setColor(context),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_sideba
import 'package:cake_wallet/src/screens/dashboard/desktop_widgets/desktop_wallet_selection_dropdown.dart';
import 'package:cake_wallet/src/screens/dashboard/widgets/sync_indicator.dart';
import 'package:cake_wallet/src/screens/wallet_connect/widgets/modals/bottom_sheet_listener.dart';
import 'package:cake_wallet/src/widgets/services_updates_widget.dart';
import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
import 'package:cake_wallet/view_model/dashboard/desktop_sidebar_view_model.dart';
import 'package:flutter/cupertino.dart';
Expand Down Expand Up @@ -105,12 +106,18 @@ class DesktopSidebarWrapper extends BasePage {
? selectedIconPath
: unselectedIconPath,
),
SideMenuItem(
widget: ServicesUpdatesWidget(dashboardViewModel.getServicesStatus()),
isSelected: desktopSidebarViewModel.currentPage == SidebarItem.status,
onTap: () {},
),
],
bottomItems: [
SideMenuItem(
imagePath: 'assets/images/support_icon.png',
isSelected: desktopSidebarViewModel.currentPage == SidebarItem.support,
onTap: () => desktopSidebarViewModel.onPageChange(SidebarItem.support)),
imagePath: 'assets/images/support_icon.png',
isSelected: desktopSidebarViewModel.currentPage == SidebarItem.support,
onTap: () => desktopSidebarViewModel.onPageChange(SidebarItem.support),
),
SideMenuItem(
imagePath: 'assets/images/settings_outline.png',
isSelected: desktopSidebarViewModel.currentPage == SidebarItem.settings,
Expand Down
8 changes: 5 additions & 3 deletions lib/src/widgets/services_updates_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:cake_wallet/src/widgets/service_status_tile.dart';
import 'package:cake_wallet/themes/extensions/dashboard_page_theme.dart';
import 'package:cake_wallet/themes/extensions/wallet_list_theme.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:url_launcher/url_launcher.dart';

Expand Down Expand Up @@ -96,15 +97,16 @@ class ServicesUpdatesWidget extends StatelessWidget {
: null,
child: Stack(
children: [
Image.asset(
"assets/images/notification_icon.png",
SvgPicture.asset(
"assets/images/notification_icon.svg",
color: Theme.of(context).extension<DashboardPageTheme>()!.pageTitleTextColor,
width: 30,
),
if (state.hasData && state.data!.hasUpdates)
Container(
height: 7,
width: 7,
margin: EdgeInsetsDirectional.only(start: 8),
margin: EdgeInsetsDirectional.only(start: 15),
decoration: BoxDecoration(
color: Colors.red,
shape: BoxShape.circle,
Expand Down
16 changes: 9 additions & 7 deletions lib/view_model/dashboard/dashboard_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -344,15 +344,13 @@ abstract class DashboardViewModelBase with Store {
bool hasExchangeAction;

@computed
bool get isEnabledBuyAction =>
!settingsStore.disableBuy && availableBuyProviders.isNotEmpty;
bool get isEnabledBuyAction => !settingsStore.disableBuy && availableBuyProviders.isNotEmpty;

@observable
bool hasBuyAction;

@computed
bool get isEnabledSellAction =>
!settingsStore.disableSell && availableSellProviders.isNotEmpty;
bool get isEnabledSellAction => !settingsStore.disableSell && availableSellProviders.isNotEmpty;

@observable
bool hasSellAction;
Expand Down Expand Up @@ -477,7 +475,8 @@ abstract class DashboardViewModelBase with Store {

Future<List<String>> checkAffectedWallets() async {
// await load file
final vulnerableSeedsString = await rootBundle.loadString('assets/text/cakewallet_weak_bitcoin_seeds_hashed_sorted_version1.txt');
final vulnerableSeedsString = await rootBundle
.loadString('assets/text/cakewallet_weak_bitcoin_seeds_hashed_sorted_version1.txt');
final vulnerableSeeds = vulnerableSeedsString.split("\n");

final walletInfoSource = await CakeHive.openBox<WalletInfo>(WalletInfo.boxName);
Expand Down Expand Up @@ -513,13 +512,16 @@ abstract class DashboardViewModelBase with Store {

final oldSha = sharedPreferences.getString(PreferencesKey.serviceStatusShaKey);


final hash = await Cryptography.instance.sha256().hash(utf8.encode(res.body));
final currentSha = bytesToHex(hash.bytes);

final hasUpdates = oldSha != currentSha;

return ServicesResponse.fromJson(json.decode(res.body) as Map<String, dynamic>, hasUpdates, currentSha);
return ServicesResponse.fromJson(
json.decode(res.body) as Map<String, dynamic>,
hasUpdates,
currentSha,
);
} catch (_) {
return ServicesResponse([], false, '');
}
Expand Down
1 change: 1 addition & 0 deletions lib/view_model/dashboard/desktop_sidebar_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ part 'desktop_sidebar_view_model.g.dart';
enum SidebarItem {
dashboard,
transactions,
status,
support,
settings,
}
Expand Down
8 changes: 4 additions & 4 deletions scripts/android/app_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ TYPES=($MONERO_COM $CAKEWALLET $HAVEN)
APP_ANDROID_TYPE=$1

MONERO_COM_NAME="Monero.com"
MONERO_COM_VERSION="1.11.0"
MONERO_COM_BUILD_NUMBER=77
MONERO_COM_VERSION="1.11.1"
MONERO_COM_BUILD_NUMBER=78
MONERO_COM_BUNDLE_ID="com.monero.app"
MONERO_COM_PACKAGE="com.monero.app"
MONERO_COM_SCHEME="monero.com"

CAKEWALLET_NAME="Cake Wallet"
CAKEWALLET_VERSION="4.14.0"
CAKEWALLET_BUILD_NUMBER=196
CAKEWALLET_VERSION="4.14.1"
CAKEWALLET_BUILD_NUMBER=197
CAKEWALLET_BUNDLE_ID="com.cakewallet.cake_wallet"
CAKEWALLET_PACKAGE="com.cakewallet.cake_wallet"
CAKEWALLET_SCHEME="cakewallet"
Expand Down
7 changes: 3 additions & 4 deletions scripts/android/build_monero.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#!/bin/sh

. ./config.sh
MONERO_BRANCH=release-v0.18.2.2-android_tx_priority_fix
MONERO_BRANCH=release-v0.18.3.2-android
MONERO_SRC_DIR=${WORKDIR}/monero

git clone https://github.com/cake-tech/monero.git ${MONERO_SRC_DIR} --branch ${MONERO_BRANCH}
cd $MONERO_SRC_DIR
git submodule init
git submodule update
git submodule update --init --force

for arch in "aarch" "aarch64" "i686" "x86_64"
do
Expand Down Expand Up @@ -59,7 +58,7 @@ cd $MONERO_SRC_DIR
rm -rf ./build/release
mkdir -p ./build/release
cd ./build/release
CC=${CLANG} CXX=${CXXLANG} cmake -D USE_DEVICE_TREZOR=OFF -D BUILD_GUI_DEPS=1 -D BUILD_TESTS=OFF -D ARCH=${ARCH} -D STATIC=ON -D BUILD_64=${BUILD_64} -D CMAKE_BUILD_TYPE=release -D ANDROID=true -D INSTALL_VENDORED_LIBUNBOUND=ON -D BUILD_TAG=${TAG} -D CMAKE_SYSTEM_NAME="Android" -D CMAKE_ANDROID_STANDALONE_TOOLCHAIN="${ANDROID_STANDALONE_TOOLCHAIN_PATH}" -D CMAKE_ANDROID_ARCH_ABI=${ARCH_ABI} $FLAGS ../..
CC=${CLANG} CXX=${CXXLANG} cmake -D USE_DEVICE_TREZOR=OFF -D BUILD_GUI_DEPS=1 -D BUILD_TESTS=OFF -D ARCH=${ARCH} -D STATIC=ON -D BUILD_64=${BUILD_64} -D CMAKE_BUILD_TYPE=release -D ANDROID=true -D INSTALL_VENDORED_LIBUNBOUND=ON -D BUILD_TAG=${TAG} -D CMAKE_SYSTEM_NAME="Android" -D CMAKE_ANDROID_STANDALONE_TOOLCHAIN="${ANDROID_STANDALONE_TOOLCHAIN_PATH}" -D CMAKE_ANDROID_ARCH_ABI=${ARCH_ABI} -D MANUAL_SUBMODULES=1 $FLAGS ../..

make wallet_api -j$THREADS
find . -path ./lib -prune -o -name '*.a' -exec cp '{}' lib \;
Expand Down
Loading

0 comments on commit 50b5ebc

Please sign in to comment.