Skip to content

Commit

Permalink
Merge pull request #314 from hypha-dao/feature/run_action_stubs
Browse files Browse the repository at this point in the history
Feature/run action stubs
  • Loading branch information
n13 authored Sep 18, 2024
2 parents 5879997 + d6d95a7 commit 4b3a15e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
22 changes: 22 additions & 0 deletions lib/core/network/api/actions/vote_action_factory.dart
Original file line number Diff line number Diff line change
@@ -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,
};
}
}
16 changes: 16 additions & 0 deletions lib/core/network/api/eos_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -81,6 +82,21 @@ class EOSService {
return sendTransaction(user: fromUser, eosTransaction: transferTransaction);
}

/// Run a single action from signer account
Future<Result<String>> 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<Result<dynamic>> deleteBlockchainAccount({
required UserProfileData user,
}) async {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 4b3a15e

Please sign in to comment.