From 192ced1ba2a877a2e5b8b7521db73676de3614b0 Mon Sep 17 00:00:00 2001 From: Aasim Khan Date: Tue, 20 Feb 2024 15:08:51 +0400 Subject: [PATCH] feat: Added `chain_details` and `validate_address` action parsers in `mirai_web3` --- .../lib/action_parsers/action_parsers.dart | 6 +++++ .../mirai_web3_chain_details_parser.dart | 22 +++++++++++++++++++ .../mirai_web3_validate_address_parser.dart | 22 +++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 packages/mirai_web3/lib/action_parsers/mirai_web3_chain_details/mirai_web3_chain_details_parser.dart create mode 100644 packages/mirai_web3/lib/action_parsers/mirai_web3_validate_address/mirai_web3_validate_address_parser.dart diff --git a/packages/mirai_web3/lib/action_parsers/action_parsers.dart b/packages/mirai_web3/lib/action_parsers/action_parsers.dart index 430041f1..397712a9 100644 --- a/packages/mirai_web3/lib/action_parsers/action_parsers.dart +++ b/packages/mirai_web3/lib/action_parsers/action_parsers.dart @@ -1,3 +1,9 @@ export 'package:mirai_web3/action_parsers/mirai_web3_connect/web3_connect_parser.dart'; export 'package:mirai_web3/action_parsers/mirai_web3_initialize/mirai_web3_initialize_parser.dart'; export 'package:mirai_web3/action_parsers/web3_sign_message/web3_sign_message.dart'; +export 'package:mirai_web3/action_parsers/mirai_web3_chain_details/mirai_web3_chain_details_parser.dart'; +export 'package:mirai_web3/action_parsers/mirai_web3_connect_with_network/web3_connect_with_network_parser.dart'; +export 'package:mirai_web3/action_parsers/mirai_web3_load_tokens/web3_load_tokens_parser.dart'; +export 'package:mirai_web3/action_parsers/mirai_web3_validate_address/mirai_web3_validate_address_parser.dart'; +export 'package:mirai_web3/action_parsers/mirai_web3_transfer_token/web3_transfer_token_parser.dart'; +export 'package:mirai_web3/action_parsers/web3_sign_message/web3_sign_message_parser.dart'; diff --git a/packages/mirai_web3/lib/action_parsers/mirai_web3_chain_details/mirai_web3_chain_details_parser.dart b/packages/mirai_web3/lib/action_parsers/mirai_web3_chain_details/mirai_web3_chain_details_parser.dart new file mode 100644 index 00000000..ffecd78b --- /dev/null +++ b/packages/mirai_web3/lib/action_parsers/mirai_web3_chain_details/mirai_web3_chain_details_parser.dart @@ -0,0 +1,22 @@ +import 'dart:async'; + +import 'package:flutter/widgets.dart'; +import 'package:mirai_framework/mirai_framework.dart'; +import 'package:mirai_web3/services/web_modal_service.dart'; + +class MiraiWeb3ChainDetailsParser + extends MiraiActionParser> { + const MiraiWeb3ChainDetailsParser(); + + @override + String get actionType => 'web3ChainDetails'; + + @override + getModel(Map json) => json; + + @override + FutureOr onCall( + BuildContext context, Map model) async { + return Web3ModalService.getChainDetails(); + } +} diff --git a/packages/mirai_web3/lib/action_parsers/mirai_web3_validate_address/mirai_web3_validate_address_parser.dart b/packages/mirai_web3/lib/action_parsers/mirai_web3_validate_address/mirai_web3_validate_address_parser.dart new file mode 100644 index 00000000..6dc5cabd --- /dev/null +++ b/packages/mirai_web3/lib/action_parsers/mirai_web3_validate_address/mirai_web3_validate_address_parser.dart @@ -0,0 +1,22 @@ +import 'dart:async'; + +import 'package:flutter/widgets.dart'; +import 'package:mirai_framework/mirai_framework.dart'; +import 'package:mirai_web3/services/web_modal_service.dart'; + +class MiraiWeb3ValidateAddressParser + extends MiraiActionParser> { + const MiraiWeb3ValidateAddressParser(); + + @override + String get actionType => 'web3ValidateAddress'; + + @override + getModel(Map json) => json; + + @override + FutureOr onCall( + BuildContext context, Map model) async { + return Web3ModalService.validateCryptoAddress(model['address']); + } +}