Skip to content

Commit

Permalink
feat: Added chain_details and validate_address action parsers in …
Browse files Browse the repository at this point in the history
…`mirai_web3`
  • Loading branch information
i-asimkhan committed Feb 20, 2024
1 parent 2979639 commit 192ced1
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/mirai_web3/lib/action_parsers/action_parsers.dart
Original file line number Diff line number Diff line change
@@ -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';
Original file line number Diff line number Diff line change
@@ -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<Map<String, dynamic>> {
const MiraiWeb3ChainDetailsParser();

@override
String get actionType => 'web3ChainDetails';

@override
getModel(Map<String, dynamic> json) => json;

@override
FutureOr<dynamic> onCall(
BuildContext context, Map<String, dynamic> model) async {
return Web3ModalService.getChainDetails();
}
}
Original file line number Diff line number Diff line change
@@ -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<Map<String, dynamic>> {
const MiraiWeb3ValidateAddressParser();

@override
String get actionType => 'web3ValidateAddress';

@override
getModel(Map<String, dynamic> json) => json;

@override
FutureOr<dynamic> onCall(
BuildContext context, Map<String, dynamic> model) async {
return Web3ModalService.validateCryptoAddress(model['address']);
}
}

0 comments on commit 192ced1

Please sign in to comment.