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

Pre main qa #113

Merged
merged 45 commits into from
Nov 2, 2023
Merged
Changes from 12 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
1a99d4e
fix: Go back to wallet page on tx done
reasje Oct 24, 2023
381819a
fix: Go to send crypto on token tap
reasje Oct 24, 2023
4137110
Merge pull request #104 from MXCzkEVM/send_crypto_changes
reasje Oct 24, 2023
2b175a0
fix: Added 0x support for private keys
reasje Oct 24, 2023
0911d29
fix: Account import check with 0x
reasje Oct 24, 2023
db7bf06
fix: Handling diff cases with websocket
reasje Oct 25, 2023
327f143
fix: Avoid multiple load calls in choose crypto
reasje Oct 25, 2023
0ae8504
Merge pull request #105 from MXCzkEVM/websocket_fixes
reasje Oct 25, 2023
c4267b8
Update de.json
rd101rahul Oct 26, 2023
fae8bce
feat: Added max fee to en.json
reasje Oct 26, 2023
1f1abca
feat: Added priority to config
reasje Oct 26, 2023
c94bbef
feat: Added max fee to bottom sheets
reasje Oct 26, 2023
f031d70
Merge pull request #107 from MXCzkEVM/tx_error_fix
reasje Oct 26, 2023
40da684
fix: Balance update bug in other chains
reasje Oct 27, 2023
17f186c
Merge pull request #108 from MXCzkEVM/balance_update_fix
reasje Oct 27, 2023
c47eb35
feat: Added notice texts for receive bottom sheet
reasje Oct 30, 2023
cf160d0
feat: Added exchanges & l3 bridge links
reasje Oct 30, 2023
5432c36
feat: Added wallet address dialogs
reasje Oct 30, 2023
45a7701
feat: Added receive bottom to dapp section
reasje Oct 30, 2023
b5c1704
feat: Added receive bottom to receive button
reasje Oct 30, 2023
4e94669
feat: Added receive bottom to send crypto
reasje Oct 30, 2023
352fb29
feat: Added receive bottom sheet to mns register section
reasje Oct 30, 2023
4d61fdc
Merge pull request #109 from MXCzkEVM/zero_balance_guidance
reasje Oct 30, 2023
e5c36ac
feat: Cleaned receive bottom sheet
reasje Oct 31, 2023
662177e
feat: Updated mns with new receive bottom sheet
reasje Oct 31, 2023
f707aa4
feat: Added insufficient funds related errors
reasje Oct 31, 2023
7b9bfe0
feat: Updated send crypto with tx balance error with receive sheet
reasje Oct 31, 2023
24bd828
imprv: Updated dapp tx with balance errors with receive sheet
reasje Oct 31, 2023
c9019b4
fix: receive bottom sheet l3 link dynamic func
reasje Oct 31, 2023
36d6fa0
feat: Added error use case
reasje Oct 31, 2023
818bbca
feat: Added error message to receive bottom sheet
reasje Oct 31, 2023
4073d44
imprv: Improved error use case for unhandled cases
reasje Oct 31, 2023
fb76886
imprv: Improved the error handling & removed boilerplate code
reasje Oct 31, 2023
ca8a269
imprv: Removed isBalanceZero for fund check
reasje Oct 31, 2023
c8535ce
Merge pull request #110 from MXCzkEVM/zero_balance_guidance
reasje Oct 31, 2023
9e57dde
translate: new
Oct 31, 2023
1fdb9b8
imprv: Renamed tx history use case file
reasje Nov 2, 2023
96cef85
feat: Added mxc transactions use case
reasje Nov 2, 2023
c1d9a97
feat: Added contract call to wallet page
reasje Nov 2, 2023
e2c1b2d
feat: Added contract call to tx history page
reasje Nov 2, 2023
667ed61
Merge pull request #111 from MXCzkEVM/contact_call_support
reasje Nov 2, 2023
a20662b
translate: contract
Nov 2, 2023
5f0ed08
Update pubspec.yaml
rd101rahul Nov 2, 2023
52265a8
feat: Added contract call support for other chains
reasje Nov 2, 2023
39c7df1
Merge pull request #112 from MXCzkEVM/contact_call_support
reasje Nov 2, 2023
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
3 changes: 2 additions & 1 deletion assets/flutter_i18n/en.json
Original file line number Diff line number Diff line change
@@ -304,5 +304,6 @@
"unable_to_launch_email_app": "Unable to launch email app",
"deposit_from_exchanges_notice": "Buy from {0}, {1} exchanges and deposit zkEVM MXC directly to AXS wallet",
"deposit_with_l3_bridge_notice": "Buy from other exchanges and use {0} to deposit ERC20 MXC to AXS wallet",
"buy_some_x_for_fee_notice": "Buy some {0} to pay for gas fee for the transaction, normally less than 2 USD when the network is not busy"
"buy_some_x_for_fee_notice": "Buy some {0} to pay for gas fee for the transaction, normally less than 2 USD when the network is not busy",
"insufficient_funds_notice": "Insufficient balance for this transaction.\n Please add funds."
}
11 changes: 11 additions & 0 deletions lib/common/config.dart
Original file line number Diff line number Diff line change
@@ -46,4 +46,15 @@ class Config {
static String addressExplorer(String address) {
return 'address/$address';
}

/// If error happens with these messages then we will need to show receive bottom sheet
static List<String> fundErrors = [
// User doesn't have enough to pay for native token transfer
// Zero native token balance or not enough for fee
'gas required exceeds allowance',
// Sending more than tokens balance
'execution reverted: ERC20: transfer amount exceeds balance',
// Sending more than native token balance
'insufficient funds for gas * price + value'
];
}
2 changes: 1 addition & 1 deletion lib/common/dialogs/dialogs.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export 'alert_dialog.dart';
export 'bottom_sheet.dart';
export 'warning_dialog.dart';
export 'wallet_address_dialog.dart';
export 'receive_bottom_sheet/receive_bottom_sheet.dart';
21 changes: 21 additions & 0 deletions lib/common/dialogs/receive_bottom_sheet/components/black_box.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'package:flutter/material.dart';
import 'package:mxc_ui/mxc_ui.dart';

class BlackBox extends StatelessWidget {
const BlackBox({super.key, required this.child});

final Widget child;

@override
Widget build(BuildContext context) {
return Container(
margin: const EdgeInsets.only(top: 16),
padding: const EdgeInsets.all(16),
decoration: BoxDecoration(
color: ColorsTheme.of(context).grey6,
borderRadius: const BorderRadius.all(Radius.circular(35)),
),
child: child,
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import 'package:datadashwallet/common/common.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:mxc_ui/mxc_ui.dart';

List<TextSpan> depositFromExchangesNotice(
BuildContext context, void Function(String) launchUrl) {
final text = FlutterI18n.translate(context, 'deposit_from_exchanges_notice');
final firstSplit = text.split('{0}');
final firstPart = firstSplit[0];
final secondSplit = firstSplit[1].split('{1}');
final secondPart = secondSplit[0];
final thirdPart = secondSplit[1];
return [
TextSpan(
text: firstPart,
),
TextSpan(
text: 'OKX',
style: TextStyle(
color: ColorsTheme.of(context, listen: false).textSecondary,
decoration: TextDecoration.underline,
),
recognizer: TapGestureRecognizer()
..onTap = () {
launchUrl(Urls.okx);
},
),
TextSpan(text: secondPart),
TextSpan(
text: 'Gate.io',
style: TextStyle(
color: ColorsTheme.of(context, listen: false).textSecondary,
decoration: TextDecoration.underline,
),
recognizer: TapGestureRecognizer()
..onTap = () {
launchUrl(Urls.gateio);
},
),
TextSpan(text: thirdPart),
];
}

List<TextSpan> depositWithL3BridgeNotice(
BuildContext context,
VoidCallback onL3Tap,
) {
final text = FlutterI18n.translate(context, 'deposit_with_l3_bridge_notice');
final firstSplit = text.split('{0}');
final firstPart = firstSplit[0];
final secondPart = firstSplit[1];
return [
TextSpan(
text: firstPart,
),
TextSpan(
text: 'L3 bridge',
style: TextStyle(
color: ColorsTheme.of(context, listen: false).textSecondary,
decoration: TextDecoration.underline,
),
recognizer: TapGestureRecognizer()..onTap = onL3Tap,
),
TextSpan(text: secondPart),
];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart';

List<TextSpan> buySomeXForFeeNotice(
BuildContext context, String networkSymbol) {
String text = FlutterI18n.translate(context, 'buy_some_x_for_fee_notice');
text = text.replaceFirst('{0}', networkSymbol);
return [
TextSpan(
text: text,
),
];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import 'dart:ui';

import 'package:clipboard/clipboard.dart';
import 'package:datadashwallet/common/common.dart';
import 'package:flutter/material.dart';
import 'package:flutter_i18n/flutter_i18n.dart';
import 'package:mxc_ui/mxc_ui.dart';
import 'package:qr_flutter/qr_flutter.dart';

class ReceiveBottomSheet extends StatelessWidget {
const ReceiveBottomSheet(
{Key? key,
this.walletAddress,
required this.noticeComponents,
required this.showError})
: super(key: key);

final String? walletAddress;
final List<Widget> noticeComponents;
final bool showError;

@override
Widget build(BuildContext context) {
final formattedWalletAddress =
Formatter.formatWalletAddress(walletAddress ?? '');
bool isWalletAddressCopied = false;

return BackdropFilter(
filter: ImageFilter.blur(
sigmaX: 20,
sigmaY: 20,
),
child: Container(
padding: const EdgeInsets.only(right: 24, left: 24, bottom: 44),
decoration: BoxDecoration(
color: ColorsTheme.of(context).cardBackground,
borderRadius: const BorderRadius.only(
topLeft: Radius.circular(20),
topRight: Radius.circular(20),
),
),
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
MxcAppBarEvenly.title(
titleText: FlutterI18n.translate(context, 'receive'),
action: Container(
alignment: Alignment.centerRight,
child: InkWell(
child: const Icon(Icons.close),
onTap: () => Navigator.of(context).pop(false),
),
),
),
if (showError)
Text(
FlutterI18n.translate(context, 'insufficient_funds_notice'),
style: FontTheme.of(context).body1.error(),
textAlign: TextAlign.center,
),
QrImageView(
data: walletAddress ?? '',
size: 215,
dataModuleStyle: QrDataModuleStyle(
color: ColorsTheme.of(context).textPrimary,
dataModuleShape: QrDataModuleShape.square),
eyeStyle: QrEyeStyle(
color: ColorsTheme.of(context).textPrimary,
eyeShape: QrEyeShape.square),
),
const SizedBox(height: 16),
Text(
FlutterI18n.translate(context,
'scan_or_copy_address_below_to_receive_tokens_or_nfts'),
style: FontTheme.of(context).body1.secondary(),
textAlign: TextAlign.center,
),
BlackBox(
child: StatefulBuilder(builder: (_, setState) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
formattedWalletAddress,
style: FontTheme.of(context).subtitle1.primary(),
),
MxcChipButton(
key: const Key('copyButton'),
onTap: () async {
await FlutterClipboard.copy(walletAddress ?? '');
setState(() => isWalletAddressCopied = true);
},
title: isWalletAddressCopied
? FlutterI18n.translate(context, 'copied')
: FlutterI18n.translate(context, 'copy_address'),
iconData: Icons.check_circle_rounded,
iconSize: 16,
alignIconStart: true,
iconColor: isWalletAddressCopied
? ColorsTheme.of(context).iconBlack200
: ColorsTheme.of(context).iconPrimary,
textStyle: isWalletAddressCopied
? FontTheme.of(context).subtitle1().copyWith(
color: ColorsTheme.of(context).textBlack200)
: FontTheme.of(context).subtitle1.primary(),
backgroundColor: isWalletAddressCopied
? ColorsTheme.of(context).systemStatusActive
: null,
)
]);
}),
),
...noticeComponents
],
),
),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export 'black_box.dart';
export 'receive_bottom_sheet.dart';
export 'mxc_notices.dart';
export 'others_notice.dart';
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export 'receive_bottom_sheet_utils.dart';
export 'components/receive_bottom_sheet_components.dart';
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import 'package:datadashwallet/common/common.dart';
import 'package:datadashwallet/core/core.dart';
import 'package:datadashwallet/features/dapps/dapps.dart';
import 'package:flutter/material.dart';
import 'package:mxc_ui/mxc_ui.dart';

void showReceiveBottomSheet(
BuildContext context,
String walletAddress,
int chainId,
String networkSymbol,
VoidCallback onL3Tap,
void Function(String url) launchUrlInPlatformDefault,
bool showError) {
if (Config.isMxcChains(chainId)) {
showWalletAddressDialogMXCChains(
context: context,
walletAddress: walletAddress,
onL3Tap: () => onL3Tap(),
launchUrlInPlatformDefault: launchUrlInPlatformDefault,
showError: showError);
} else {
showWalletAddressDialogOtherChains(
context: context,
walletAddress: walletAddress,
networkSymbol: networkSymbol,
showError: showError);
}
}

void showWalletAddressDialogMXCChains(
{required BuildContext context,
required String walletAddress,
required VoidCallback onL3Tap,
required Function(String) launchUrlInPlatformDefault,
required bool showError}) =>
showWalletAddressDialog(
context: context,
walletAddress: walletAddress,
noticeComponents: [
BlackBox(
child: applyTextStyle(
context,
depositFromExchangesNotice(
context, launchUrlInPlatformDefault))),
BlackBox(
child: applyTextStyle(
context, depositWithL3BridgeNotice(context, onL3Tap))),
],
showError: showError);

void showWalletAddressDialogOtherChains(
{required BuildContext context,
required String walletAddress,
required String networkSymbol,
required bool showError}) =>
showWalletAddressDialog(
context: context,
walletAddress: walletAddress,
noticeComponents: [
BlackBox(
child: applyTextStyle(
context, buySomeXForFeeNotice(context, networkSymbol)))
],
showError: showError);

void showWalletAddressDialogSimple(
{required BuildContext context,
required String walletAddress,
required bool showError}) =>
showWalletAddressDialog(
context: context,
walletAddress: walletAddress,
noticeComponents: [],
showError: showError);

void showWalletAddressDialog(
{required BuildContext context,
required String walletAddress,
required List<Widget> noticeComponents,
required bool showError}) {
showModalBottomSheet<bool>(
context: context,
useRootNavigator: true,
isScrollControlled: true,
useSafeArea: true,
backgroundColor: Colors.transparent,
builder: (BuildContext context) => ReceiveBottomSheet(
walletAddress: walletAddress,
noticeComponents: noticeComponents,
showError: showError,
),
);
}

Widget applyTextStyle(BuildContext context, List<TextSpan> children) {
return RichText(
text: TextSpan(
style: FontTheme.of(context, listen: false).body1.primary(),
children: [...children],
),
);
}
Loading