Skip to content

Commit

Permalink
improve zano wallet opening, fix CI commands and messages on slack
Browse files Browse the repository at this point in the history
  • Loading branch information
MrCyjaneK committed Jan 27, 2025
1 parent df3a26d commit 4eacabd
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 94 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/pr_test_build_android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,19 @@ jobs:
- name: Fix github actions messing up $HOME...
run: 'echo HOME=/root | sudo tee -a $GITHUB_ENV'
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: configure git
run: |
git config --global --add safe.directory '*'
git config --global user.email "[email protected]"
git config --global user.name "CakeWallet CI"
- name: Get the full commit message
run: |
FULL_MESSAGE="$(git log -1 --pretty=%B)"
echo "message<<EOF" >> $GITHUB_ENV
echo "$FULL_MESSAGE" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Add secrets
run: |
touch lib/.secrets.g.dart
Expand Down Expand Up @@ -274,14 +283,14 @@ jobs:
echo "APK_FILE=$apk_file" >> $GITHUB_ENV
- name: Upload artifact to slack
if: ${{ !contains(github.event.head_commit.message, 'skip slack') }}
if: ${{ !contains(env.message, 'skip slack') }}
continue-on-error: true
uses: adrey/[email protected]
with:
token: ${{ secrets.SLACK_APP_TOKEN }}
path: ${{ env.APK_FILE }}
channel: ${{ secrets.SLACK_APK_CHANNEL }}
initial_comment: ${{ github.event.head_commit.message }}
initial_comment: ${{ env.message }}

- name: cleanup
run: rm -rf build/app/outputs/flutter-apk/test-apk/
Expand Down
19 changes: 14 additions & 5 deletions .github/workflows/pr_test_build_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,19 @@ jobs:
- name: Fix github actions messing up $HOME...
run: 'echo HOME=/root | sudo tee -a $GITHUB_ENV'
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: configure git
run: |
git config --global --add safe.directory '*'
git config --global user.email "[email protected]"
git config --global user.name "CakeWallet CI"
- name: Get the full commit message
run: |
FULL_MESSAGE="$(git log -1 --pretty=%B)"
echo "message<<EOF" >> $GITHUB_ENV
echo "$FULL_MESSAGE" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Add secrets
run: |
touch lib/.secrets.g.dart
Expand Down Expand Up @@ -231,7 +240,7 @@ jobs:
name: cakewallet_linux

- name: Prepare virtual desktop
if: ${{ contains(github.event.head_commit.message, 'run tests') }}
if: ${{ contains(env.message, 'run tests') }}
run: |
nohup Xvfb :99 -screen 0 720x1280x16 &
echo DISPLAY=:99 | sudo tee -a $GITHUB_ENV
Expand All @@ -247,28 +256,28 @@ jobs:
# isn't much in those wallets anyway, we still wouldn't like to leak it to anyone who is able to access github.

- name: Test [confirm_seeds_flow_test]
if: ${{ contains(github.event.head_commit.message, 'run tests') }}
if: ${{ contains(env.message, 'run tests') }}
timeout-minutes: 20
run: |
xmessage -timeout 30 "confirm_seeds_flow_test" &
rm -rf ~/.local/share/com.example.cake_wallet/ ~/Documents/cake_wallet/ ~/cake_wallet
exec timeout --signal=SIGKILL 900 flutter drive --driver=test_driver/integration_test.dart --target=integration_test/test_suites/confirm_seeds_flow_test.dart
- name: Test [create_wallet_flow_test]
if: ${{ contains(github.event.head_commit.message, 'run tests') }}
if: ${{ contains(env.message, 'run tests') }}
timeout-minutes: 20
run: |
xmessage -timeout 30 "create_wallet_flow_test" &
rm -rf ~/.local/share/com.example.cake_wallet/ ~/Documents/cake_wallet/ ~/cake_wallet
exec timeout --signal=SIGKILL 900 flutter drive --driver=test_driver/integration_test.dart --target=integration_test/test_suites/create_wallet_flow_test.dart
- name: Test [exchange_flow_test]
if: ${{ contains(github.event.head_commit.message, 'run tests') }}
if: ${{ contains(env.message, 'run tests') }}
timeout-minutes: 20
run: |
xmessage -timeout 30 "exchange_flow_test" &
rm -rf ~/.local/share/com.example.cake_wallet/ ~/Documents/cake_wallet/ ~/cake_wallet
exec timeout --signal=SIGKILL 900 flutter drive --driver=test_driver/integration_test.dart --target=integration_test/test_suites/exchange_flow_test.dart
- name: Test [restore_wallet_through_seeds_flow_test]
if: ${{ contains(github.event.head_commit.message, 'run tests') }}
if: ${{ contains(env.message, 'run tests') }}
timeout-minutes: 20
run: |
xmessage -timeout 30 "restore_wallet_through_seeds_flow_test" &
Expand Down
3 changes: 2 additions & 1 deletion cw_zano/lib/api/model/transfer.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:cw_core/utils/print_verbose.dart';
import 'package:cw_core/zano_asset.dart';
import 'package:cw_zano/api/model/employed_entries.dart';
import 'package:cw_zano/api/model/subtransfer.dart';
Expand Down Expand Up @@ -97,7 +98,7 @@ class Transfer {
if (single.assetId != ZanoWalletBase.zanoAssetId) {
final asset = zanoAssets[single.assetId];
if (asset == null) {
ZanoWalletApi.error('unknown asset ${single.assetId}');
printV('unknown asset ${single.assetId}');
}
final ticker = asset == null ? '***' : asset.ticker;
final decimalPoint = asset == null ? ZanoFormatter.defaultDecimalPoint : asset.decimalPoint;
Expand Down
3 changes: 2 additions & 1 deletion cw_zano/lib/zano_formatter.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:math';

import 'package:cw_core/utils/print_verbose.dart';
import 'package:cw_zano/zano_wallet_api.dart';
import 'package:decimal/decimal.dart';
import 'package:decimal/intl.dart';
Expand Down Expand Up @@ -66,7 +67,7 @@ class ZanoFormatter {
} else if (d == null) {
return BigInt.zero;
} else {
ZanoWalletApi.error('cannot cast value of type ${d.runtimeType} to BigInt');
printV(('cannot cast value of type ${d.runtimeType} to BigInt'));
throw 'cannot cast value of type ${d.runtimeType} to BigInt';
//return BigInt.zero;
}
Expand Down
44 changes: 26 additions & 18 deletions cw_zano/lib/zano_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,19 +152,27 @@ abstract class ZanoWalletBase
static Future<ZanoWallet> open(
{required String name, required String password, required WalletInfo walletInfo}) async {
final path = await pathForWallet(name: name, type: walletInfo.type);
final wallet = ZanoWallet(walletInfo, password);
await wallet.initWallet();
final createWalletResult = await wallet.loadWallet(path, password);
await wallet.initWallet();
await wallet.parseCreateWalletResult(createWalletResult);
await wallet.init(createWalletResult.wi.address);
return wallet;
if (ZanoWalletApi.openWalletCache[path] != null) {
final wallet = ZanoWallet(walletInfo, password);
await wallet.parseCreateWalletResult(ZanoWalletApi.openWalletCache[path]!).then((_) {
unawaited(wallet.init(ZanoWalletApi.openWalletCache[path]!.wi.address));
});
return wallet;
} else {
final wallet = ZanoWallet(walletInfo, password);
await wallet.initWallet();
final createWalletResult = await wallet.loadWallet(path, password);
await wallet.parseCreateWalletResult(createWalletResult).then((_) {
unawaited(wallet.init(createWalletResult.wi.address));
});
return wallet;
}
}

Future<void> parseCreateWalletResult(CreateWalletResult result) async {
hWallet = result.walletId;
seed = result.seed;
ZanoWalletApi.info('setting hWallet = ${result.walletId}');
printV('setting hWallet = ${result.walletId}');
walletAddresses.address = result.wi.address;
await loadAssets(result.wi.balances, maxRetries: _maxLoadAssetsRetries);
for (final item in result.wi.balances) {
Expand All @@ -185,7 +193,7 @@ abstract class ZanoWalletBase

@override
Future<void> close({bool shouldCleanup = true}) async {
closeWallet();
closeWallet(null);
_updateSyncInfoTimer?.cancel();
_autoSaveTimer?.cancel();
}
Expand Down Expand Up @@ -285,7 +293,7 @@ abstract class ZanoWalletBase
} while (result.lastItemIndex + 1 < result.totalTransfers);
return Transfer.makeMap(transfers, zanoAssets, currentDaemonHeight);
} catch (e) {
ZanoWalletApi.error(e.toString());
printV((e.toString()));
return {};
}
}
Expand Down Expand Up @@ -332,7 +340,7 @@ abstract class ZanoWalletBase
await store();
await walletAddresses.updateAddressesInBox();
} catch (e) {
ZanoWalletApi.error('Error while saving Zano wallet file ${e.toString()}');
printV(('Error while saving Zano wallet file ${e.toString()}'));
}
}

Expand All @@ -349,7 +357,7 @@ abstract class ZanoWalletBase
retryCount++;
await Future.delayed(Duration(seconds: 1));
} else {
ZanoWalletApi.error('failed to load assets after $retryCount retries');
printV(('failed to load assets after $retryCount retries'));
break;
}
}
Expand Down Expand Up @@ -402,7 +410,7 @@ abstract class ZanoWalletBase
} else {
final asset = zanoAssets[b.assetId];
if (asset == null) {
ZanoWalletApi.error('balance for an unknown asset ${b.assetInfo.assetId}');
printV(('balance for an unknown asset ${b.assetInfo.assetId}'));
continue;
}
if (balance.keys.any(
Expand All @@ -429,7 +437,7 @@ abstract class ZanoWalletBase
});
} catch (e) {
syncStatus = FailedSyncStatus();
ZanoWalletApi.error(e.toString());
printV((e.toString()));
}
}

Expand All @@ -453,7 +461,7 @@ abstract class ZanoWalletBase
_isTransactionUpdating = false;
} catch (e) {
printV("e: $e");
ZanoWalletApi.error(e.toString());
printV((e.toString()));
_isTransactionUpdating = false;
}
}
Expand All @@ -480,12 +488,12 @@ abstract class ZanoWalletBase
if (asset.enabled) {
final assetDescriptor = await addAssetsWhitelist(asset.assetId);
if (assetDescriptor == null) {
ZanoWalletApi.error('Error adding zano asset');
printV(('Error adding zano asset'));
}
} else {
final result = await removeAssetsWhitelist(asset.assetId);
if (result == false) {
ZanoWalletApi.error('Error removing zano asset');
printV(('Error removing zano asset'));
}
}
}
Expand Down Expand Up @@ -514,7 +522,7 @@ abstract class ZanoWalletBase
syncStatus = SyncingSyncStatus(blocksLeft, ptc);
}
} catch (e) {
ZanoWalletApi.error(e.toString());
printV((e.toString()));
}
}

Expand Down
3 changes: 2 additions & 1 deletion cw_zano/lib/zano_wallet_addresses.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:cw_core/utils/print_verbose.dart';
import 'package:cw_core/wallet_addresses.dart';
import 'package:cw_core/wallet_info.dart';
import 'package:cw_zano/zano_wallet_api.dart';
Expand Down Expand Up @@ -34,7 +35,7 @@ abstract class ZanoWalletAddressesBase extends WalletAddresses with Store {
addressesMap[address] = '';
await saveAddressesInBox();
} catch (e) {
ZanoWalletApi.error(e.toString());
printV(e.toString());
}
}
}
Loading

0 comments on commit 4eacabd

Please sign in to comment.