prepareOperation static method

Future<List<OperationModel>> prepareOperation(
  1. String server,
  2. List<OperationModel> operations
)

Implementation

static Future<List<OperationModel>> prepareOperation(
    String server, List<OperationModel> operations) async {
  var feeEstimation = FeeEstimation(server, operations);
  var estimate = await feeEstimation.estimateFees();
  if (operations[0].kind == 'reveal') {
    operations[0].fee = '1500';
    operations[0].gasLimit = TezosConstants.DefaultKeyRevealGasLimit;
    operations[0].storageLimit = TezosConstants.DefaultKeyRevealStorageLimit;

    operations[1].fee = estimate['estimatedFee'].toString();

    for (var i = 1; i < operations.length; i++) {
      operations[i].gasLimit = estimate['gasStorageList'][i]['gas'];
      operations[i].storageLimit =
          estimate['gasStorageList'][i]['storageCost'];
    }
  } else {
    operations[0].fee = estimate['estimatedFee'].toString();

    for (var i = 0; i < operations.length; i++) {
      operations[i].gasLimit = estimate['gasStorageList'][i]['gas'];
      operations[i].storageLimit =
          estimate['gasStorageList'][i]['storageCost'];
    }
  }

  return operations;
}