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

Ui/UX updated & Bug fix #159

Merged
merged 4 commits into from
Feb 14, 2024
Merged
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
29 changes: 19 additions & 10 deletions lib/features/common/contract/token_contract_use_case.dart
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,17 @@ class TokenContractUseCase extends ReactiveUseCase {
await _repository.tokenContract.estimateGasFeeForContractCall(
from: from, to: to, data: data, value: value);

Future<TransactionModel> sendTransaction(
{required String privateKey,
required String to,
String? from,
required EtherAmount amount,
TransactionGasEstimation? estimatedGasFee,
Uint8List? data,
String? tokenAddress,
Token? token}) async =>
Future<TransactionModel> sendTransaction({
required String privateKey,
required String to,
String? from,
required EtherAmount amount,
TransactionGasEstimation? estimatedGasFee,
Uint8List? data,
String? tokenAddress,
Token? token,
int? nonce,
}) async =>
await _repository.tokenContract.sendTransaction(
privateKey: privateKey,
to: to,
Expand All @@ -238,7 +240,8 @@ class TokenContractUseCase extends ReactiveUseCase {
estimatedGasFee: estimatedGasFee,
data: data,
tokenAddress: tokenAddress,
token: token);
token: token,
nonce: nonce);

Uint8List getTokenTransferData(
String tokenHash, EthereumAddress toAddress, BigInt amount) {
Expand Down Expand Up @@ -271,4 +274,10 @@ class TokenContractUseCase extends ReactiveUseCase {
Future<int> getEpochDetails(int chainId) async {
return await _repository.tokenContract.getEpochDetails(chainId);
}

Future<int> getAddressNonce(EthereumAddress address,
{BlockNum? atBlock}) async {
return await _repository.tokenContract
.getAddressNonce(address, atBlock: atBlock);
}
}
91 changes: 49 additions & 42 deletions lib/features/settings/subfeatures/dapp_hooks/dapp_hooks_page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:datadashwallet/common/common.dart';
import 'package:datadashwallet/features/common/common.dart';
import 'package:datadashwallet/features/settings/subfeatures/notifications/widgets/switch_row_item.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
Expand All @@ -9,7 +8,6 @@ import 'package:mxc_ui/mxc_ui.dart';

import 'dapp_hooks_presenter.dart';
import 'dapp_hooks_state.dart';
import 'widgets/dapp_hooks_information_widget.dart';

class DAppHooksPage extends HookConsumerWidget {
const DAppHooksPage({Key? key}) : super(key: key);
Expand Down Expand Up @@ -53,12 +51,12 @@ class DAppHooksPage extends HookConsumerWidget {
),
),
children: [
SwitchRowItem(
MXCSwitchRowItem(
title: translate('dapp_hooks'),
value: dappHooksState.dAppHooksData!.enabled,
onChanged: dappHooksPresenter.enableDAppHooks,
enabled: true,
textTrailingWidget: DAppHooksInformation(texts: [
textTrailingWidget: MXCInformationButton(texts: [
TextSpan(
text: FlutterI18n.translate(context, 'experiencing_issues'),
style: FontTheme.of(context)
Expand All @@ -74,6 +72,7 @@ class DAppHooksPage extends HookConsumerWidget {
.copyWith(color: ColorsTheme.of(context).chipTextBlack),
),
]),
titleStyle: FontTheme.of(context).h6(),
),
const SizedBox(height: Sizes.spaceNormal),
MXCDropDown(
Expand All @@ -83,44 +82,52 @@ class DAppHooksPage extends HookConsumerWidget {
enabled:
isSettingsChangeEnabled && dappHooksState.dAppHooksData!.enabled,
),
const SizedBox(height: Sizes.spaceNormal),
SwitchRowItem(
key: const Key('wifiHookSwitch'),
title: translate('wifi_hooks'),
value: dappHooksState.dAppHooksData!.wifiHooks.enabled,
onChanged: dappHooksPresenter.enableWifiHooks,
enabled: isSettingsChangeEnabled,
textTrailingWidget: DAppHooksInformation(texts: [
TextSpan(
text: FlutterI18n.translate(context, 'experiencing_issues'),
style: FontTheme.of(context)
.subtitle2()
.copyWith(color: ColorsTheme.of(context).chipTextBlack),
),
const TextSpan(text: ' '),
TextSpan(
text: FlutterI18n.translate(context, 'wifi_hooks_solutions'),
style: FontTheme.of(context)
.subtitle1()
.copyWith(color: ColorsTheme.of(context).chipTextBlack),
),
]),
),
const SizedBox(height: Sizes.spaceNormal),
SwitchRowItem(
key: const Key('minerHookSwitch'),
title: translate('miner_hooks'),
value: dappHooksState.dAppHooksData!.minerHooks.enabled,
onChanged: dappHooksPresenter.enableMinerHooks,
enabled: isSettingsChangeEnabled,
),
const SizedBox(height: Sizes.spaceNormal),
MXCDropDown(
key: const Key('minerHooksTimingDropDown'),
onTap: dappHooksPresenter.showTimePickerDialog,
selectedItem: autoClaimTime,
enabled: isSettingsChangeEnabled &&
dappHooksState.dAppHooksData!.minerHooks.enabled,
const SizedBox(height: Sizes.spaceXLarge),
Padding(
padding: const EdgeInsets.symmetric(horizontal: Sizes.spaceXLarge),
child: Column(
children: [
MXCSwitchRowItem(
key: const Key('wifiHookSwitch'),
title: translate('wifi_hooks'),
value: dappHooksState.dAppHooksData!.wifiHooks.enabled,
onChanged: dappHooksPresenter.enableWifiHooks,
enabled: isSettingsChangeEnabled,
textTrailingWidget: MXCInformationButton(texts: [
TextSpan(
text: FlutterI18n.translate(context, 'experiencing_issues'),
style: FontTheme.of(context)
.subtitle2()
.copyWith(color: ColorsTheme.of(context).chipTextBlack),
),
const TextSpan(text: ' '),
TextSpan(
text:
FlutterI18n.translate(context, 'wifi_hooks_solutions'),
style: FontTheme.of(context)
.subtitle1()
.copyWith(color: ColorsTheme.of(context).chipTextBlack),
),
]),
),
const SizedBox(height: Sizes.spaceNormal),
MXCSwitchRowItem(
key: const Key('minerHookSwitch'),
title: translate('miner_hooks'),
value: dappHooksState.dAppHooksData!.minerHooks.enabled,
onChanged: dappHooksPresenter.enableMinerHooks,
enabled: isSettingsChangeEnabled,
),
const SizedBox(height: Sizes.spaceNormal),
MXCDropDown(
key: const Key('minerHooksTimingDropDown'),
onTap: dappHooksPresenter.showTimePickerDialog,
selectedItem: autoClaimTime,
enabled: isSettingsChangeEnabled &&
dappHooksState.dAppHooksData!.minerHooks.enabled,
),
],
),
),
],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,18 @@ class DAppHooksUseCase extends ReactiveUseCase {
print("memo: ${finalData.toString()}");

print("tx");
final address = EthereumAddress.fromHex(account.address);
final nonce = await _tokenContractUseCase.getAddressNonce(address,
atBlock: const BlockNum.pending());

final tx = await _tokenContractUseCase.sendTransaction(
from: account.address,
to: account.address,
privateKey: account.privateKey,
data: MXCType.stringToUint8List(jsonEncode(finalData.toMap())),
amount: MxcAmount.zero());
from: account.address,
to: account.address,
privateKey: account.privateKey,
data: MXCType.stringToUint8List(jsonEncode(finalData.toMap())),
amount: MxcAmount.zero(),
nonce: nonce,
);
AXSNotification().showNotification(
"Successful Wi-Fi Transaction Update",
"You have successfully updated the list of Wi-Fi networks by submitting a transaction to the MXC zkEVM.",
Expand Down Expand Up @@ -172,7 +178,7 @@ class DAppHooksUseCase extends ReactiveUseCase {
//when going to the background
foregroundNotificationConfig: const geo.ForegroundNotificationConfig(
notificationText:
"AXS wallet background location service for Wi-Fi hooks is running, Please do not dismiss this notification.",
"AXS wallet background location service for Wi-Fi hooks is running... .",
notificationTitle: "AXS wallet location service",
enableWakeLock: true,
notificationIcon: geo.AndroidResource(
Expand Down

This file was deleted.

Loading
Loading