Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CW-912 [1/?] one class per file, minor cleanups #12

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
MONERO_C_TAG=v0.18.3.4-RC5
MONERO_C_TAG=v0.18.3.4-RC9
COIN=monero
4 changes: 2 additions & 2 deletions .fvmrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"flutter": "3.24.4"
}
"flutter": "3.27.3"
}
2 changes: 1 addition & 1 deletion .github/workflows/build_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- name: Install dependencies
run: |
sudo apt update
sudo apt install -y build-essential pkg-config autoconf libtool ccache make cmake gcc g++ git curl lbzip2 libtinfo5 gperf unzip python-is-python3
sudo apt install -y build-essential pkg-config autoconf libtool ccache make cmake gcc g++ git curl lbzip2 libtinfo5 gperf unzip python-is-python3 llvm
- name: setup ccache
uses: hendrikmuhs/[email protected]
with:
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,7 @@ app.*.map.json
lib/l10n/*.dart
lib/generated/
lib/gen/*.dart
missing_translations.txt
missing_translations.txt

# FVM Version Cache
.fvm/
2 changes: 1 addition & 1 deletion .tooling/format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cd "$(dirname "$0")"
cd ..
dart run build_runner build
pushd lib
for dir in coins themes utils view_model views widgets;
for dir in coins themes utils view_model views;
do
pushd $dir
dart fix --apply
Expand Down
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"dart.flutterSdkPath": ".fvm/versions/3.27.3"
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class MainActivity : FlutterActivity() {
val packageInfo: PackageInfo
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
packageInfo = packageManager.getPackageInfo(packageName, PackageManager.GET_SIGNING_CERTIFICATES)
val signatures = packageInfo.signingInfo.apkContentsSigners
if (signatures.isNotEmpty()) {
val signatures = packageInfo.signingInfo?.apkContentsSigners
if (signatures?.isNotEmpty() == true) {
val md = MessageDigest.getInstance("SHA-1")
val publicKey = md.digest(signatures[0].toByteArray())
return Base64.encodeToString(publicKey, Base64.DEFAULT)
Expand All @@ -45,7 +45,7 @@ class MainActivity : FlutterActivity() {
@Suppress("DEPRECATION")
packageInfo = packageManager.getPackageInfo(packageName, PackageManager.GET_SIGNATURES)
val signatures = packageInfo.signatures
if (signatures.isNotEmpty()) {
if (signatures?.isNotEmpty() == true) {
val md = MessageDigest.getInstance("SHA-1")
val publicKey = md.digest(signatures[0].toByteArray())
return Base64.encodeToString(publicKey, Base64.DEFAULT)
Expand Down
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip
2 changes: 1 addition & 1 deletion android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pluginManagement {

plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "8.7.0" apply false
id "com.android.application" version '8.8.0' apply false
id "org.jetbrains.kotlin.android" version "2.0.21" apply false
}

Expand Down
1 change: 1 addition & 0 deletions ios/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ Runner/GeneratedPluginRegistrant.*

libwallet2_api_c.dylib
MoneroWallet.framework/MoneroWallet
monero_libwallet2_api_c.dylib
160 changes: 0 additions & 160 deletions lib/coins/abstract.dart

This file was deleted.

9 changes: 9 additions & 0 deletions lib/coins/abstract/address.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class Address {
Address(this.address);
final String address;

@override
String toString() {
return address;
}
}
7 changes: 7 additions & 0 deletions lib/coins/abstract/amount.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class Amount {
Amount(this.amount);
final int amount;

@override
String toString() => "$amount";
}
32 changes: 32 additions & 0 deletions lib/coins/abstract/coin.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import 'package:cupcake/coins/abstract/strings.dart';
import 'package:cupcake/coins/abstract/wallet.dart';
import 'package:cupcake/coins/abstract/wallet_info.dart';
import 'package:cupcake/coins/types.dart';

enum Coins { monero, unknown }

abstract class Coin {
Coins get type => Coins.unknown;

CoinStrings get strings;

bool get isEnabled;

Future<List<CoinWalletInfo>> get coinWallets;

Future<CoinWallet> createNewWallet(
String walletName,
String walletPassword, {
ProgressCallback? progressCallback,
required bool? createWallet,
required String? seed,
required int? restoreHeight,
required String? primaryAddress,
required String? viewKey,
required String? spendKey,
required String? seedOffsetOrEncryption,
});

Future<CoinWallet> openWallet(CoinWalletInfo walletInfo,
{required String password});
}
11 changes: 11 additions & 0 deletions lib/coins/abstract/exception.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class CoinException implements Exception {
CoinException(this.exception, {this.details});

String exception;
String? details;

@override
String toString() {
return "$exception\n$details";
}
}
12 changes: 12 additions & 0 deletions lib/coins/abstract/strings.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'package:flutter_svg/flutter_svg.dart';

abstract class CoinStrings {
String get nameLowercase;
String get nameCapitalized;
String get nameUppercase;
String get symbolLowercase;
String get symbolUppercase;
String get nameFull;

SvgPicture get svg;
}
45 changes: 45 additions & 0 deletions lib/coins/abstract/wallet.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import 'package:cupcake/coins/abstract/coin.dart';
import 'package:cupcake/coins/abstract/wallet_seed_detail.dart';
import 'package:cupcake/l10n/app_localizations.dart';
import 'package:cupcake/utils/urqr.dart';
import 'package:flutter/widgets.dart';

abstract class CoinWallet {
CoinWallet();

Coin get coin;

Future<void> handleUR(BuildContext context, URQRData ur) =>
throw UnimplementedError();

bool get hasAccountSupport => false;

bool get hasAddressesSupport => false;

int getAccountsCount();

void setAccount(int accountIndex);

int getAccountId();

int get addressIndex;

String get getAccountLabel;

String get getCurrentAddress;

String get seed;

String get primaryAddress;

String get walletName;

int getBalance();

String getBalanceString();

Future<void> close();

Future<List<WalletSeedDetail>> seedDetails(AppLocalizations L) =>
throw UnimplementedError();
}
Loading