readAll method

Future<List<Cip150MetadataEntry>> readAll({
  1. BlockNum? atBlock,
  2. bool includeSealedState = true,
})

Reads every entry, optionally including its sealed state.

Implementation

Future<List<Cip150MetadataEntry>> readAll({
  BlockNum? atBlock,
  bool includeSealedState = true,
}) async {
  final keys = await listKeys(atBlock: atBlock);
  final entries = await Future.wait(
    keys.map((key) async {
      final values = await Future.wait<Object?>([
        getValue(key, atBlock: atBlock),
        if (includeSealedState) isSealed(key, atBlock: atBlock),
      ]);
      return Cip150MetadataEntry(
        key: key,
        value: values[0]! as String,
        sealed: includeSealedState ? values[1]! as bool : null,
      );
    }),
  );
  return List.unmodifiable(entries);
}