Skip to content

Commit

Permalink
Merge pull request #55 from 3Dpass/dev
Browse files Browse the repository at this point in the history
Feature: Multitransfers 2.9.0
  • Loading branch information
L3odr0id authored Oct 31, 2023
2 parents 785f4f4 + 4df25c7 commit 5d9e3b1
Show file tree
Hide file tree
Showing 79 changed files with 2,813 additions and 945 deletions.
14 changes: 11 additions & 3 deletions assets/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@
"to_address_hint": "Enter address",
"amount_label": "Amount (Balance: {})",
"amount_hint": "Enter amount",
"enter_password_hint": "password",
"enter_password_label": "Your password",
"enter_password_hint": "Enter password",
"enter_password_label": "Password",
"existential_deposit_label": "existential deposit",
"existential_deposit_text": "The minimum amount thath an account should have to be deemed active.",
"estimated_transfer_fee": "Estimated transfer fee",
Expand Down Expand Up @@ -303,5 +303,13 @@
"status_success": "Success",
"status_failed": "Failed",
"status_error": "Error",
"error_wrong_amount_int": "A positive integer expected"
"error_wrong_amount_int": "A positive integer expected",

"@2.9.0":{
},
"from_select_account_title": "Select account",
"add_account_from_label": "Add accout to send FROM",
"add_account_to_label": "Add accout to send TO",
"password_hint_1": "Press ",
"password_hint_2": " to copy the password of the account above"
}
7 changes: 0 additions & 7 deletions lib/core/polkawallet/app_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'package:flutter/material.dart';
import 'package:logger/logger.dart';
import 'package:polkawallet_sdk/api/types/balanceData.dart';
import 'package:polkawallet_sdk/api/types/networkStateData.dart';
import 'package:polkawallet_sdk/api/types/txInfoData.dart';
import 'package:polkawallet_sdk/plugin/index.dart';
import 'package:polkawallet_sdk/storage/keyring.dart';
import 'package:threedpass/core/polkawallet/non_native_tokens_api.dart';
Expand Down Expand Up @@ -76,12 +75,6 @@ class AppService {
);
}
}

TxSenderData get userSenderData => TxSenderData(
keyring.current.address,
keyring.current.pubKey,
);

// final subScan = SubScanApi();
}

Expand Down
2 changes: 1 addition & 1 deletion lib/core/polkawallet/bloc/app_service_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class AppServiceLoaderCubit extends Cubit<AppService> {

void addHandler(
final String msgId,
final void Function(String) setTransactionResult,
final TransactionsCallback setTransactionResult,
) {
state.plugin.sdk.webView!.addGlobalHandler(
TxUpdateEventLogsHandler(msgId, setTransactionResult),
Expand Down
17 changes: 0 additions & 17 deletions lib/core/polkawallet/utils/transfer_type.dart

This file was deleted.

107 changes: 0 additions & 107 deletions lib/core/polkawallet/utils/tx_info.dart

This file was deleted.

38 changes: 34 additions & 4 deletions lib/core/polkawallet/utils/tx_update_event_logs_handler.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:logger/logger.dart';
import 'package:polkawallet_sdk/utils/web_logs_handler.dart';
import 'package:threedpass/features/wallet_screen/domain/entities/transfer_history_ui.dart';
import 'package:threedpass/setup.dart';

typedef TransactionsCallback = void Function({
required ExtrisincStatus status,
required String? message,
});

class TxUpdateEventLogsHandler extends WebLogsHandler {
const TxUpdateEventLogsHandler(
Expand All @@ -10,8 +19,7 @@ class TxUpdateEventLogsHandler extends WebLogsHandler {

final String msgId;

/// @param {String} is extrinsicSuccess or message
final void Function(String) setTransactionResult;
final TransactionsCallback setTransactionResult;

static const String extrinsicSuccess = 'ok';

Expand Down Expand Up @@ -40,10 +48,32 @@ class TxUpdateEventLogsHandler extends WebLogsHandler {
}

final String title = dataSection['title'] as String;
final String message = dataSection['message'] as String;
debugPrint('$title $message');

if (title == "system.ExtrinsicSuccess") {
setTransactionResult(extrinsicSuccess);
getIt<Logger>().d('Found ExtrinsicSuccess for $msgId');
setTransactionResult(status: ExtrisincStatus.success, message: null);
} else if (title == 'system.ExtrinsicFailed') {
setTransactionResult(dataSection['message'] as String);
getIt<Logger>().d('Found ExtrinsicFailed for $msgId');
setTransactionResult(
status: ExtrisincStatus.failed,
message: message,
);
}

if (title.contains('error')) {
if (message.contains('password check failed')) {
setTransactionResult(
status: ExtrisincStatus.error,
message: message,
);
} else {
setTransactionResult(
status: ExtrisincStatus.failed,
message: message,
);
}
}
}
}
5 changes: 5 additions & 0 deletions lib/core/theme/d3p_special_colors.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ extension ScaffoldCustomColors on CustomColors {
Color get cardBackground => brightness == Brightness.light
? D3pColors.lightCardBackground
: D3pColors.darkCardBackground;

// https://github.com/flutter/flutter/blob/ad200896cbe17f8b2ae3560f541c1abafa8f4cd1/packages/flutter/lib/src/material/input_decorator.dart#L4564C22-L4564C22
Color get defaultInputColor => brightness == Brightness.light
? const Color(0x0A000000)
: const Color(0x1AFFFFFF);
}

extension PinCodeColors on CustomColors {
Expand Down
14 changes: 13 additions & 1 deletion lib/core/theme/d3p_special_styles.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:threedpass/core/theme/d3p_colors.dart';
import 'package:threedpass/core/theme/d3p_special_colors.dart';
import 'package:threedpass/core/theme/d3p_theme.dart';

Expand Down Expand Up @@ -84,7 +85,7 @@ extension BodyCustomText on CustomTextStyles {
themeData.textTheme.bodyLarge!.copyWith(color: _themeOpposite);
TextStyle get d3pBodyMedium =>
themeData.textTheme.bodyMedium!.copyWith(color: _themeOpposite);
TextStyle get dp3BodySmall =>
TextStyle get d3pBodySmall =>
themeData.textTheme.bodySmall!.copyWith(color: _themeOpposite);
}

Expand All @@ -95,3 +96,14 @@ extension SpecialText on CustomTextStyles {
TextStyle get d3pSettingsHeaderSmall => themeData.textTheme.bodySmall!
.copyWith(color: themeData.customColors.moreFadedGrey);
}

extension Buttons on CustomTextStyles {
TextStyle get d3pFloatingButton =>
themeData.customTextStyles.d3pBodyMedium.copyWith(
fontSize: 16,
letterSpacing: 1.2,
fontWeight: FontWeight.w500,
);

TextStyle get hintStyle => d3pBodySmall.copyWith(color: D3pColors.disabled);
}
Loading

0 comments on commit 5d9e3b1

Please sign in to comment.