Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
feat: detect web socket mxc top up
Browse files Browse the repository at this point in the history
  • Loading branch information
reasje committed Mar 15, 2024
1 parent 27e7ad1 commit a25de6d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ class BackgroundFetchConfigUseCase extends ReactiveUseCase {
if (expectedEpochOccurrence <= epochQuantity) {
periodicalCallData = periodicalCallData.copyWith(lasEpoch: epochNumber);
AXSNotification().showNotification("Epoch Achievement Alert!",
"Congratulations! The anticipated epoch you've been waiting for has just occurred. It's a significant milestone. Let's take the next steps forward.,");
"Congratulations! The anticipated epoch you've been waiting for has just occurred. It's a significant milestone. Let's take the next steps forward.");
}

return periodicalCallData;
Expand Down
22 changes: 22 additions & 0 deletions lib/features/wallet/presentation/wallet_page_presenter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,28 @@ class WalletPresenter extends CompletePresenter<WalletState> {
break;
// coin transfer done
case 'transaction':
final newMXCTx = WannseeTransactionModel.fromJson(
json.encode(event.payload['transactions'][0]));

final newTx = TransactionModel.fromMXCTransaction(
newMXCTx, state.account!.address);

if (newTx.token.symbol == Config.mxcName &&
newTx.type == TransactionType.received) {
final decimal = newTx.token.decimals ?? Config.ethDecimals;
final formattedValue =
MXCFormatter.convertWeiToEth(newTx.value ?? '0', decimal);
showNotification(
translate('mxc_top_up_notification_title')!,
translate('mxc_top_up_notification_text')!
.replaceFirst(
'{0}',
state.account!.mns ??
MXCFormatter.formatWalletAddress(
state.account!.address),
)
.replaceFirst('{1}', formattedValue));
}
// Sometimes getting the tx list from remote right away, results in having the pending tx in the list too (Which shouldn't be)
Future.delayed(const Duration(seconds: 3), () {
getMXCTransactions();
Expand Down

0 comments on commit a25de6d

Please sign in to comment.