fetchABI method

Future<Map<String, dynamic>> fetchABI(
  1. String addr
)

Implementation

Future<Map<String, dynamic>> fetchABI(String addr) async {
  final modules = await aptosClient.getAccountModules(addr);
  final abis = (modules as List)
    .map((module) => module["abi"])
    .expand((abi) =>
      abi["exposed_functions"]
        .where((ef) => ef["is_entry"] as bool)
        .map((ef) => {
              "fullName": "${abi["address"]}::${abi["name"]}::${ef["name"]}",
              ...ef,
            },
        ),
    );

  final abiMap = <String, dynamic>{};
  for (var abi in abis) {
    abiMap[abi["fullName"]] = abi;
  }

  return abiMap;
}