Add async crypto init (#697)

* Add async crypto init

* Used ed25519 for mock
This commit is contained in:
Jaco Greeff
2019-02-15 10:01:09 +01:00
committed by GitHub
parent e87eff1deb
commit 50159233ed
9 changed files with 33 additions and 28 deletions
+1
View File
@@ -36,6 +36,7 @@
"@polkadot/rpc-rx": "^0.43.2",
"@polkadot/storage": "^0.43.2",
"@polkadot/types": "^0.43.2",
"@polkadot/util-crypto": "^0.34.9",
"@types/rx": "^4.1.1",
"rxjs": "^6.3.3"
}
+6 -2
View File
@@ -27,6 +27,7 @@ import { Event, Hash, Metadata, Method, RuntimeVersion, typeRegistry } from '@po
import { MethodFunction, ModulesWithMethods } from '@polkadot/types/Method';
import { StorageFunction } from '@polkadot/types/StorageKey';
import { assert, compactStripLength, isFunction, isObject, isUndefined, logger, u8aToHex } from '@polkadot/util';
import { cryptoWaitReady } from '@polkadot/util-crypto';
import SubmittableExtrinsic from './SubmittableExtrinsic';
@@ -324,9 +325,12 @@ export default abstract class ApiBase<CodecResult, SubscriptionResult> implement
this._rpcBase._provider.on('connected', async () => {
this.emit('connected');
const hasMeta = await this.loadMeta();
const [hasMeta, cryptoReady] = await Promise.all([
this.loadMeta(),
cryptoWaitReady()
]);
if (hasMeta && !this._isReady) {
if (hasMeta && !this._isReady && cryptoReady) {
this._isReady = true;
this.emit('ready', this);
+1 -1
View File
@@ -33,6 +33,6 @@
"@polkadot/jsonrpc": "^0.43.2",
"@polkadot/rpc-provider": "^0.43.2",
"@polkadot/types": "^0.43.2",
"@polkadot/util": "^0.34.7"
"@polkadot/util": "^0.34.9"
}
}
+3 -3
View File
@@ -30,10 +30,10 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/rpc-provider#readme",
"dependencies": {
"@babel/runtime": "^7.2.0",
"@polkadot/keyring": "^0.34.7",
"@polkadot/keyring": "^0.34.9",
"@polkadot/storage": "^0.43.2",
"@polkadot/util": "^0.34.7",
"@polkadot/util-crypto": "^0.34.7",
"@polkadot/util": "^0.34.9",
"@polkadot/util-crypto": "^0.34.9",
"@types/nock": "^9.3.0",
"eventemitter3": "^3.1.0",
"isomorphic-fetch": "^2.2.1",
+1 -1
View File
@@ -30,7 +30,7 @@ const SUBSCRIPTIONS: string[] = Array.prototype.concat.apply(
)
);
const keyring = testKeyring({ type: 'sr25519' });
const keyring = testKeyring({ type: 'ed25519' });
const l = logger('api-mock');
/**
+1 -1
View File
@@ -12,6 +12,6 @@
"dependencies": {
"@babel/runtime": "^7.2.0",
"@polkadot/types": "^0.43.2",
"@polkadot/util": "^0.34.7"
"@polkadot/util": "^0.34.9"
}
}
+3 -3
View File
@@ -30,9 +30,9 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/type-storage#readme",
"dependencies": {
"@babel/runtime": "^7.2.0",
"@polkadot/keyring": "^0.34.7",
"@polkadot/keyring": "^0.34.9",
"@polkadot/types": "^0.43.2",
"@polkadot/util": "^0.34.7",
"@polkadot/util-crypto": "^0.34.7"
"@polkadot/util": "^0.34.9",
"@polkadot/util-crypto": "^0.34.9"
}
}
+2 -2
View File
@@ -30,8 +30,8 @@
"homepage": "https://github.com/polkadot-js/api/tree/master/packages/types#readme",
"dependencies": {
"@babel/runtime": "^7.2.0",
"@polkadot/keyring": "^0.34.7",
"@polkadot/util": "^0.34.7",
"@polkadot/keyring": "^0.34.9",
"@polkadot/util": "^0.34.9",
"core-js": "^2.6.2"
}
}