Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.isConnected().subscribe(async (isConnected) => {
if (!isConnected) {
return;
}
try {
// FIXME This now gets done in api/Base as well, cleanup as soon as we
// have apis based on api-rx & api-promise (For now a bit of inefficiency)
const meta = await this._api.state.getMetadata().toPromise();
this._genesisHash = await this._api.chain.getBlockHash(0).toPromise();
ApiBase.extrinsics = extrinsicsFromMeta(meta);
ApiBase.storage = storageFromMeta(meta);
Event.injectMetadata(meta);
Method.injectMethods(ApiBase.extrinsics);
if (!isReady) {
isReady = true;
resolveReady(true);
}
} catch (error) {
console.error(error);
}
});
});
describe('storage with default values', () => {
Method.injectMethods(extrinsicsFromMeta(metadata));
metadata.asV1.modules
.filter(({ storage }) => storage.isSome)
.map((mod) =>
mod.storage.unwrap().forEach(({ fallback, name, type }) => {
it(`creates default types for ${mod.prefix}.${name}, type ${type}`, () => {
expect(
() => createType(type.toString(), fallback)
).not.toThrow();
});
})
);
});
});