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,18 +15,21 @@ export class RegistryService {
private static accountRegistry: AccountIndex; private static accountRegistry: AccountIndex;
public static async getRegistry(): Promise<CICRegistry> { public static async getRegistry(): Promise<CICRegistry> {
if (!RegistryService.registry) { return new Promise(async (resolve, reject) => {
RegistryService.registry = new CICRegistry( if (!RegistryService.registry) {
Web3Service.getInstance(), RegistryService.registry = new CICRegistry(
environment.registryAddress, Web3Service.getInstance(),
'Registry', environment.registryAddress,
RegistryService.fileGetter, 'Registry',
['../../assets/js/block-sync/data'] RegistryService.fileGetter,
); ['../../assets/js/block-sync/data']
RegistryService.registry.declaratorHelper.addTrust(environment.trustedDeclaratorAddress); );
await RegistryService.registry.load(); RegistryService.registry.declaratorHelper.addTrust(environment.trustedDeclaratorAddress);
} await RegistryService.registry.load();
return RegistryService.registry; return resolve(RegistryService.registry);
}
return resolve(RegistryService.registry);
});
} }
public static async getTokenRegistry(): Promise<TokenRegistry> { public static async getTokenRegistry(): Promise<TokenRegistry> {