This commit is contained in:
Czarek Nakamoto 2024-04-12 14:54:24 +02:00 committed by cyan
parent 7bc6967fc9
commit 176150cc55
5 changed files with 90 additions and 22 deletions

View file

@ -0,0 +1,44 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '11.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def flutter_root
generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
unless File.exist?(generated_xcode_build_settings_path)
raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
File.foreach(generated_xcode_build_settings_path) do |line|
matches = line.match(/FLUTTER_ROOT\=(.*)/)
return matches[1].strip if matches
end
raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end
require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)
flutter_ios_podfile_setup
target 'Runner' do
use_frameworks!
use_modular_headers!
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
target 'RunnerTests' do
inherit! :search_paths
end
end
post_install do |installer|
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
end
end

View file

@ -2,15 +2,15 @@ import 'package:cw_monero/api/wallet.dart';
import 'package:monero/monero.dart' as monero;
monero.wallet? wptr = null;
monero.SubaddressAccount? account;
monero.SubaddressAccount? subaddressAccount;
bool isUpdating = false;
void refreshAccounts() {
try {
isUpdating = true;
account = monero.Wallet_subaddressAccount(wptr!);
monero.SubaddressAccount_refresh(account!);
subaddressAccount = monero.Wallet_subaddressAccount(wptr!);
monero.SubaddressAccount_refresh(subaddressAccount!);
isUpdating = false;
} catch (e) {
isUpdating = false;
@ -20,10 +20,15 @@ void refreshAccounts() {
List<monero.SubaddressAccountRow> getAllAccount() {
// final size = monero.Wallet_numSubaddressAccounts(wptr!);
final size = monero.SubaddressAccount_getAll_size(wptr!);
refreshAccounts();
int size = monero.SubaddressAccount_getAll_size(subaddressAccount!);
print("size: $size");
if (size == 0) {
monero.Wallet_addSubaddressAccount(wptr!);
return getAllAccount();
}
return List.generate(size, (index) {
return monero.SubaddressAccount_getAll_byIndex(wptr!, index: index);
return monero.SubaddressAccount_getAll_byIndex(subaddressAccount!, index: index);
});
}

View file

@ -3,12 +3,12 @@ import 'package:cw_monero/api/wallet.dart';
import 'package:monero/monero.dart' as monero;
bool isUpdating = false;
monero.AddressBook? addressbook = null;
monero.Subaddress? subaddressPtr = null;
void refreshSubaddresses({required int accountIndex}) {
try {
isUpdating = true;
addressbook = monero.Wallet_subaddressAccount(wptr!);
monero.AddressBook_refresh(addressbook!);
subaddressPtr = monero.Wallet_subaddress(wptr!);
monero.Subaddress_refresh(subaddressPtr!,accountIndex: accountIndex, label: '');
isUpdating = false;
} catch (e) {
isUpdating = false;
@ -17,15 +17,21 @@ void refreshSubaddresses({required int accountIndex}) {
}
List<monero.SubaddressRow> getAllSubaddresses() {
final size = monero.AddressBook_getAll_size(addressbook!);
monero.Subaddress_refresh(subaddressPtr!,
accountIndex: 0,
label: '' // BUG: by me (mrcyjanek), it isn't used, will remove.
);
final size = monero.Subaddress_getAll_size(subaddressPtr!);
return List.generate(size, (index) {
return monero.Subaddress_getAll_byIndex(wptr!, index: index);
return monero.Subaddress_getAll_byIndex(subaddressAccount!, index: index);
});
}
void addSubaddressSync({required int accountIndex, required String label}) {
monero.Wallet_addSubaddress(wptr!, accountIndex: accountIndex, label: label);
refreshSubaddresses(accountIndex: accountIndex);
}
void setLabelForSubaddressSync(

View file

@ -1,4 +1,5 @@
import 'dart:async';
import 'package:cw_monero/api/account_list.dart';
import 'package:cw_monero/api/exceptions/setup_wallet_exception.dart';
import 'package:monero/monero.dart' as monero;
@ -13,9 +14,10 @@ bool isNewTransactionExist() => false;
String getFilename() => monero.Wallet_filename(wptr!);
// TODO(mrcyjanek): Cake polyseed support
String getSeed() => monero.Wallet_seed(wptr!, seedOffset: '');
String getAddress({int accountIndex = 0, int addressIndex = 0}) => monero.Wallet_address(wptr!, accountIndex: accountIndex, addressIndex: addressIndex);
String getAddress({int accountIndex = 0, int addressIndex = 1}) => monero.Wallet_address(wptr!, accountIndex: accountIndex, addressIndex: addressIndex);
int getFullBalance({int accountIndex = 0}) => monero.Wallet_balance(wptr!, accountIndex: accountIndex);
@ -34,7 +36,16 @@ bool setupNodeSync(
bool useSSL = false,
bool isLightWallet = false,
String? socksProxyAddress}) {
print('''
{
wptr!,
daemonAddress: $address,
useSsl: $useSSL,
proxyAddress: $socksProxyAddress ?? '',
daemonUsername: $login ?? '',
daemonPassword: $password ?? ''
}
''');
monero.Wallet_init(
wptr!,
daemonAddress: address,
@ -49,8 +60,10 @@ bool setupNodeSync(
final status = monero.Wallet_status(wptr!);
if (status == 0) {
throw SetupWalletException(message: monero.Wallet_errorString(wptr!));
if (status != 0) {
final error = monero.Wallet_errorString(wptr!);
print("error: $error");
throw SetupWalletException(message: error);
}
return status == 0;
@ -81,7 +94,6 @@ void setPasswordSync(String password) {
}
void closeCurrentWallet() {
monero.Wallet_store(wptr!);
monero.Wallet_stop(wptr!);
}

View file

@ -26,12 +26,13 @@ void createWalletSync(
required String password,
required String language,
int nettype = 0}) {
wptr = monero.WalletManager_createWallet(wmPtr, path: path, password: password, language: language);
wptr = monero.WalletManager_createWallet(wmPtr, path: path, password: password, language: language, networkType: 0);
final status = monero.Wallet_status(wptr!);
if (status != 0) {
throw WalletCreationException(message: monero.Wallet_errorString(wptr!));
}
monero.Wallet_store(wptr!, path: path);
// is the line below needed?
// setupNodeSync(address: "node.moneroworld.com:18089");
@ -47,10 +48,6 @@ void restoreWalletFromSeedSync(
required String seed,
int nettype = 0,
int restoreHeight = 0}) {
final pathPointer = path.toNativeUtf8();
final passwordPointer = password.toNativeUtf8();
final seedPointer = seed.toNativeUtf8();
final errorMessagePointer = ''.toNativeUtf8();
wptr = monero.WalletManager_recoveryWallet(
wmPtr,
@ -59,12 +56,14 @@ void restoreWalletFromSeedSync(
mnemonic: seed,
restoreHeight: restoreHeight,
seedOffset: '',
networkType: 0,
);
final status = monero.Wallet_status(wptr!);
if (status != 0) {
throw WalletRestoreFromSeedException(message: monero.Wallet_errorString(wptr!));
final error = monero.Wallet_errorString(wptr!);
throw WalletRestoreFromSeedException(message: error);
}
}
@ -92,6 +91,7 @@ void restoreWalletFromKeysSync(
addressString: address,
viewKeyString: viewKey,
spendKeyString: spendKey,
nettype: 0,
);
final status = monero.Wallet_status(wptr!);
@ -123,6 +123,7 @@ void restoreWalletFromSpendKeySync(
addressString: '',
spendKeyString: spendKey,
viewKeyString: '',
nettype: 0,
);
final status = monero.Wallet_status(wptr!);