addNewLockTemplate method

  1. @override
Future<void> addNewLockTemplate(
  1. String contract,
  2. LockTemplate lockTemplate
)

Add a new lock template entry to the wallet state's cartesian indexing. Lock templates are at the y (template) layer. This new entry will be associated to the label given by template. The index of the new entry (and thus associated with the template label) will be automatically derived by the next available y-index.

template A String label of the template to associate the new lockTemplate entry with lockTemplate The list of Lock Templates of the lock templates to add to the new Entries entry

Implementation

@override
Future<void> addNewLockTemplate(
    String contract, LockTemplate lockTemplate) async {
  final contractResult = cartesiansStore.findFirstSync(_instance,
      finder: Finder(
        sortOrders: [SortOrder("yContract", false)],
      ));

  final yContract =
      contractResult != null ? (contractResult["yContract"]! as int) + 1 : 1;

  await contractsStore.add(
    _instance,
    Contract(
      contract: contract,
      yContract: yContract,
      lock: jsonEncode(lockTemplate),
    ).toSembast,
  );
}