emulate method

Future<List<Map>> emulate(
  1. Map body, {
  2. String block = 'best',
})

Upload a tx body for emulation, Get a list of execution responses (as the tx has multiple clauses).

Implementation

Future<List<Map>> emulate(Map body, {String block = 'best'}) async {
  var u = Uri.parse('$url/accounts/*?revision=$block');
  var headers = {
    "accept": "application/json",
    "Content-Type": "application/json"
  };
  var res = await http.post(u, headers: headers, body: json.encode(body));
  if (res.statusCode != 200) {
    var r = res.body;
    throw Exception("HTTP error: ${res.statusCode} ${res.reasonPhrase}, $r");
  }
  Map allResponses = json.decode(res.body)[0]; // A list of responses
  return [injectRevertReason(allResponses)];
}