getAddress method

  1. @override
String? getAddress(
  1. String fellowship,
  2. String contract,
  3. int? someState
)

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 contract, int? someState) {
  final fellowshipResult = fellowshipsStore.findFirstSync(_instance,
      finder: Finder(filter: Filter.equals("name", fellowship)));

  final contractResult = contractsStore.findFirstSync(_instance,
      finder: Finder(filter: Filter.equals("contract", contract)));

  if (fellowshipResult != null && contractResult != null) {
    final cartesianResult = cartesiansStore.findFirstSync(_instance,
        finder: Finder(
          filter: Filter.and([
            Filter.equals("xFellowship", fellowshipResult["xFellowship"]),
            Filter.equals("yContract", contractResult.key),
            Filter.equals("zState", someState ?? 0),
          ]),
        ));

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