getAbi method

Map getAbi(
  1. String name
)

Get ABI by name. Throws exception if no abi with this name exists for this contract

Implementation

Map getAbi(String name) {
  var abis = getAbis();
  List<Map> temp = [];
  for (var item in abis) {
    if (item['name'] == name) {
      temp.add(item);
    }
  }
  //it should not be possible for multiple ABIs to have the same name
  assert(temp.length < 2);

  //throw exception if ABI with this name was not found
  if (temp.isEmpty) {
    throw Exception('ABI with name $name was not found');
  }
  return temp[0];
}