getAddress method

  1. @override
String? getAddress(
  1. String fellowship,
  2. String template,
  3. int? someInteraction
)

Get the lock address associated to the given fellowship, template and optional state

fellowship A String label of the fellowship to get the lock address for template A String label of the template to get the lock address for someState The optional state index to get the lock address for. If not provided, the next state for the given fellowship and template pair will be used Returns the lock address for the given indices if possible. Else null

Implementation

@override
String? getAddress(String fellowship, String template, int? someInteraction) {
  final fellowshipResult = fellowshipsStore.findFirstSync(_instance,
      finder: Finder(filter: Filter.equals("name", fellowship)));

  final templateResult = templatesStore.findFirstSync(_instance,
      finder: Finder(filter: Filter.equals("name", template)));

  if (fellowshipResult != null && templateResult != null) {
    final x = fellowshipResult["x"]! as int;
    final y = templateResult["y"]! as int;
    final cartesianResult = cartesiansStore.findFirstSync(_instance,
        finder: Finder(
          filter: Filter.and([
            Filter.equals("x", x),
            Filter.equals("y", y),
            Filter.equals("z", someInteraction ?? 1),
          ]),
        ));

    if (cartesianResult == null) return null;
    return cartesianResult["address"]! as String;
  }
  return null;
}