Skip to content

Commit

Permalink
feat: get role registration types
Browse files Browse the repository at this point in the history
  • Loading branch information
JGiter committed Jun 4, 2021
1 parent cd06dc3 commit ffd22ec
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/iam.ts
Expand Up @@ -1480,6 +1480,27 @@ export class IAM extends IAMBase {
}
}

async registrationTypesOfRoles(roles: string[]): Promise<Record<string, Set<RegistrationTypes>>> {
const types: Record<string, Set<RegistrationTypes>> = roles.reduce((acc, role) => acc[role] = new Set(), {});
for await (const role of roles) {
const def = await this._domainDefinitionReader.read({ node: role });
if (!DomainReader.isRoleDefinition(def)) {
continue;
}
const resolver = await this._ensRegistry.resolver(role);
const { chainId } = await this._provider.getNetwork();
const { ensResolverAddress, ensPublicResolverAddress } = chainConfigs[chainId];
if (resolver === ensResolverAddress) {
types[role].add(RegistrationTypes.OnChain);
types[role].add(RegistrationTypes.OffChain);
}
else if (resolver === ensPublicResolverAddress) {
types[role].add(RegistrationTypes.OffChain);
}
}
return types;
}

async subscribeTo({
subject = `${this._did}.${NATS_EXCHANGE_TOPIC}`,
messageHandler
Expand Down

0 comments on commit ffd22ec

Please sign in to comment.