Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crashlytics reported errors fixes #198

Merged
merged 4 commits into from
Feb 19, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,12 @@ class SendCryptoPage extends HookConsumerWidget {
suffixButton: MxcTextFieldButton.svg(
svg: 'assets/svg/ic_contact.svg',
onTap: () async {
Recipient res = await Navigator.of(context)
.push(route(const SelectRecipientPage()));
Recipient? res = (await Navigator.of(context)
.push(route(const SelectRecipientPage())) as Recipient?);

if (res == null) {
return;
}
ref.read(presenter).recipientController.text =
res.address ?? res.mns ?? '';
ref.watch(state).formKey.currentState!.validate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,12 @@ class SendCryptoPresenter extends CompletePresenter<SendCryptoState> {
}

void validateAndUpdate() {
final result = state.formKey.currentState!.validate();
// It's rare but happened in some cases http://github.com/orgs/MXCzkEVM/projects/4/views/1?pane=issue&itemId=98388906
final formState = state.formKey.currentState;
if (formState == null) {
return;
}
final result = formState.validate();
notify(() => state.valid = result);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class ChainConfigurationRepository extends GlobalCacheRepository {
final String zone = 'chain_configuration';

late final Field<List<Network>> networks = fieldWithDefault<List<Network>>(
'networks', [],
'networks', Network.fixedNetworks(),
serializer: (b) => b
.map((e) => {
'logo': e.logo,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:firebase_crashlytics/firebase_crashlytics.dart';
import 'package:moonchain_wallet/core/core.dart';
import 'package:moonchain_wallet/features/settings/settings.dart';
import 'package:mxc_logic/mxc_logic.dart';


class ChainConfigurationUseCase extends ReactiveUseCase {
ChainConfigurationUseCase(this._repository, this._authUseCase);

Expand Down Expand Up @@ -138,10 +138,21 @@ class ChainConfigurationUseCase extends ReactiveUseCase {
}
}

void getCurrentNetwork() {
final currentNetwork =
_repository.items.where((item) => item.enabled).first;
update(selectedNetwork, currentNetwork);
void getCurrentNetwork() async{
final chains =_repository.items;
try {
final currentNetwork =
chains.where((item) => item.enabled).first;
update(selectedNetwork, currentNetwork);
} catch (e, s) {
FirebaseCrashlytics.instance.setCustomKey("chains_list_not_enabled_any", chains.map((e) => e.toJson(),).toList().toString());
await FirebaseCrashlytics.instance.recordError(
e,
s,
reason: 'Fatal error on detecting enabled chain',
information: ['chains_list_not_enabled_any is reported with It\'s value'],
);
}
}

Network getCurrentNetworkWithoutRefresh() {
Expand Down
6 changes: 0 additions & 6 deletions lib/features/splash/setup_wallet/setup_wallet_presenter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ class SplashSetupWalletPresenter
@override
void initState() {
listen(_chainConfigurationUseCase.networks, (value) {
if (value.isEmpty) {
// populates the default list for the first time
final defaultList = Network.fixedNetworks();
_chainConfigurationUseCase.addItems(defaultList);
}

_chainConfigurationUseCase.getCurrentNetwork();
_authUseCase.resetNetwork(
_chainConfigurationUseCase.getCurrentNetworkWithoutRefresh());
Expand Down