From 9b52b12689f185d4d2cbe5ee684ba74f9ab93ab7 Mon Sep 17 00:00:00 2001 From: NIK Date: Wed, 18 Sep 2024 10:00:36 +0800 Subject: [PATCH 1/2] update version --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 73fcc55b..8e476906 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -17,7 +17,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.3.0+63 +version: 1.3.1+64 environment: sdk: '>=3.0.0 <4.0.0' From d6d95a7593fb9b03b740d81c045c99e65ca7fead Mon Sep 17 00:00:00 2001 From: NIK Date: Wed, 18 Sep 2024 10:01:50 +0800 Subject: [PATCH 2/2] add runAction add Action factory for vote action - we use factory to create actions, and the generic runAction method to execute them --- .../api/actions/vote_action_factory.dart | 22 +++++++++++++++++++ lib/core/network/api/eos_service.dart | 16 ++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 lib/core/network/api/actions/vote_action_factory.dart diff --git a/lib/core/network/api/actions/vote_action_factory.dart b/lib/core/network/api/actions/vote_action_factory.dart new file mode 100644 index 00000000..4c471a90 --- /dev/null +++ b/lib/core/network/api/actions/vote_action_factory.dart @@ -0,0 +1,22 @@ +import 'package:hypha_wallet/core/crypto/seeds_esr/eos_action.dart'; + +class Voteactionfactory { + // Vote action + // Note: Don't hard-code the dao contract since it's different on different networks + // get daoContract by calling + // final daoContract = remoteConfigService.daoContract(network: network); + // + static EOSAction voteAction(String daoContract, String voter, int proposalId, String vote) { + if (vote != 'pass' && vote != 'fail') { + throw 'vote needs to be one of pass or fail'; + } + return EOSAction() + ..account = daoContract + ..name = 'vote' + ..data = { + 'voter': voter, + 'proposal_id': proposalId, + 'vote': vote, + }; + } +} diff --git a/lib/core/network/api/eos_service.dart b/lib/core/network/api/eos_service.dart index c0394279..2cf6f346 100644 --- a/lib/core/network/api/eos_service.dart +++ b/lib/core/network/api/eos_service.dart @@ -4,6 +4,7 @@ import 'package:async/async.dart'; import 'package:dio/dio.dart' as dio; import 'package:flutter_dotenv/flutter_dotenv.dart'; import 'package:hypha_wallet/core/crypto/eosdart/eosdart.dart'; +import 'package:hypha_wallet/core/crypto/seeds_esr/eos_action.dart'; import 'package:hypha_wallet/core/crypto/seeds_esr/eos_transaction.dart'; import 'package:hypha_wallet/core/local/models/user_auth_data.dart'; import 'package:hypha_wallet/core/local/services/secure_storage_service.dart'; @@ -81,6 +82,21 @@ class EOSService { return sendTransaction(user: fromUser, eosTransaction: transferTransaction); } + /// Run a single action from signer account + Future> runAction({ + required UserProfileData signer, + required EOSAction action, + }) async { + if (action.authorization == null) { + final auth = Authorization() + ..actor = signer.accountName + ..permission = 'active'; + action.authorization = [auth]; + } + final transferTransaction = EOSTransaction([action], signer.network); + return sendTransaction(user: signer, eosTransaction: transferTransaction); + } + Future> deleteBlockchainAccount({ required UserProfileData user, }) async {