sendTransactionOperation static method

Future<Map<String, Object?>> sendTransactionOperation(
  1. String server,
  2. SoftSigner signer,
  3. KeyStoreModel keyStore,
  4. String to,
  5. int amount, {
  6. int offset = 54,
  7. required bool isKeyRevealed,
})

send a transaction operation fee, gasLimit and storageLimit are estimated by the fee estimation service

Implementation

static Future<Map<String, Object?>> sendTransactionOperation(String server,
    SoftSigner signer, KeyStoreModel keyStore, String to, int amount,
    {int offset = 54, required bool isKeyRevealed}) async {
  var results = await Future.wait(!isKeyRevealed
      ? [
          TezosNodeReader.getCounterForAccount(
              server, keyStore.publicKeyHash),
          TezosNodeReader.getBlockAtOffset(server, offset),
          TezosNodeReader.isManagerKeyRevealedForAccount(
              server, keyStore.publicKeyHash)
        ]
      : [
          TezosNodeReader.getCounterForAccount(
              server, keyStore.publicKeyHash),
          TezosNodeReader.getBlockAtOffset(server, offset)
        ]);

  var counter = (results[0] as int) + 1;
  var blockHead = results[1];
  isKeyRevealed = !isKeyRevealed ? results[2] as bool : isKeyRevealed;

  OperationModel transaction = new OperationModel(
    destination: to,
    amount: amount.toString(),
    counter: counter,
    source: keyStore.publicKeyHash,
    gasLimit: TezosConstants.DefaultTransactionGasLimit,
    storageLimit: TezosConstants.DefaultTransactionStorageLimit,
  );

  var operations = await appendRevealOperation(
    server,
    keyStore.publicKey,
    keyStore.publicKeyHash,
    counter - 1,
    <OperationModel>[transaction],
    isKeyRevealed,
  );
  return sendOperation(server, operations, signer, offset, blockHead);
}