getLock method

  1. @override
Lock? getLock(
  1. String fellowship,
  2. String contract,
  3. int nextState
)

Using the template associated the given template, the verification keys associated to the fellowship and template pair, and the z state given by nextState, build a Lock

fellowship A String label of the fellowship to get the Lock verification keys for template A String label of the template to get the verification keys and template for nextState The z index state to build the lock for Returns a built lock, if possible. Else null

Implementation

@override
Lock? getLock(String fellowship, String contract, int nextState) {
  final lockTemplate = getLockTemplate(contract);
  final entityVks = getEntityVks(fellowship, contract);

  if (lockTemplate == null || entityVks == null) return null;

  final childVks = entityVks.map((vk) {
    final fullKey = quivr_shared
  .VerificationKey.fromBuffer(
        Encoding().decodeFromBase58Check(vk).get());
    return api.deriveChildVerificationKey(fullKey, nextState);
  });
  final res = lockTemplate.build(childVks.toList());

  return res.isRight ? res.right! : null;
}