Add promises to get registry.

This commit is contained in:
Spencer Ofwiti 2021-06-14 17:37:14 +03:00
parent bdc8f98d6b
commit f091808714

View File

@ -15,6 +15,7 @@ export class RegistryService {
private static accountRegistry: AccountIndex; private static accountRegistry: AccountIndex;
public static async getRegistry(): Promise<CICRegistry> { public static async getRegistry(): Promise<CICRegistry> {
return new Promise(async (resolve, reject) => {
if (!RegistryService.registry) { if (!RegistryService.registry) {
RegistryService.registry = new CICRegistry( RegistryService.registry = new CICRegistry(
Web3Service.getInstance(), Web3Service.getInstance(),
@ -25,8 +26,10 @@ export class RegistryService {
); );
RegistryService.registry.declaratorHelper.addTrust(environment.trustedDeclaratorAddress); RegistryService.registry.declaratorHelper.addTrust(environment.trustedDeclaratorAddress);
await RegistryService.registry.load(); await RegistryService.registry.load();
return resolve(RegistryService.registry);
} }
return RegistryService.registry; return resolve(RegistryService.registry);
});
} }
public static async getTokenRegistry(): Promise<TokenRegistry> { public static async getTokenRegistry(): Promise<TokenRegistry> {