sendVoteOrUnvote method

Future<String> sendVoteOrUnvote(
  1. String voterAddress,
  2. HydraPrivate hydraPrivate,
  3. String createTx(
    1. HydraTxBuilder builder,
    2. SecpPublicKey senderPubKey,
    3. int nonce
    ),
  4. int? nonce,
)

Implementation

Future<String> sendVoteOrUnvote(
  String voterAddress,
  HydraPrivate hydraPrivate,
  String Function(
    HydraTxBuilder builder,
    SecpPublicKey senderPubKey,
    int nonce,
  )
      createTx,
  int? nonce,
) async {
  final voterBip44PubKey = hydraPrivate.public.keyByAddress(voterAddress);
  nonce ??= (await getWalletNonce(voterAddress)) + 1;

  final builder = HydraTxBuilder(_networkConfig.network);
  final transferTx = createTx(builder, voterBip44PubKey.publicKey(), nonce);

  final signedTx = hydraPrivate.signHydraTransaction(
    voterAddress,
    transferTx,
  );

  final resp = await sendTx(signedTx.toString());
  return resp;
}