createRole method
Implementation
Future createRole({
required String operator,
required String name,
String? id,
String? owner,
List<RuleDoc>? rules,
String? contextId,
}) async {
final uuid = Uuid();
final ownerBytes = owner != null ? base64Decode(owner) : null;
final role = Role()
..id = (id != null ? hex.decode(id) : uuid.v4buffer(List.filled(16, 0)))
..name = name
..owner = ownerBytes ?? await signer.publicKey();
role.rules.clear();
if (rules != null) {
role.rules.addAll(rules.map((r) => r.asRule()));
}
final request = role.createRequest();
final client = getServiceClient(operator);
final envelop = await requestEnvelope(
request: request,
contextId: contextId != null ? hex.decode(contextId) : null,
);
await client.tx.createTransaction(envelop);
return id;
}