Backporting to beta (#3229)
* Use ethcore_dappsPort when constructing URLs (#3139) * Upon connect, retrieve the available api ports * Update dapps to load from dappsPort * Update dapps summary with dappsPort * Allow proxy to use dappsPort * Replace /api/ping with HEAD / * Dynamic port for available apps * Retrieve content images with dappsPort * Fix / * Transfer token dropdown image fix * IdentityIcon loads images via contentHash * Update apps fetch to cater for dev & prod * DRY up 127.0.0.1:${dappsPort} with ${dappsUrl} * Cleaning up polluted namespaces (#3143) * Renaming ethcore_ to parity_ * Renaming files * Renaming poluted EthSigning * Tidy up the namespaces * Renaming files to match new structure * Splitting EthSigning into separate traits * jsapi move ethcore.* -> parity.* * Move jsonrpc parity definitions * Update UI API calls for parity interfaces * Move jsapi signer interfaces from personal to signer * Update UI to use signer.* where applicable * Updsate jsapi subscriptions for signer * Fix dodgy merge. * Update README. * Fix some tests. * Move parity-only personal.* to parity.* * Update UI for personal -> parity API moves * Update subscription APIs after personal -> parity move * personal. generateAuthorizationToken -> parity. generateAuthorizationToken (UI) * enode, dappsPort & signerPort (UI) * Update subscription tests (accountsInfo) * subscription update * personal -> parity * Additional error logging on method failures * move postTransaction to parity * Additional debug info with method failures * Fix personal tests. * Console wrning shows parameters, error object does not * Include parity_ signing methods. * Console log http transport info * Fix failing tests * Add RPC stubs for parity_accounts. * Allow some secure built-in dapps * Use parity_accounts in place of accountsInfo * Improve error reporting * Cleanup GHH error handling Former-commit-id: 5a094ccb9f0596d0e07abc23504b80dc099ad584
This commit is contained in:
@@ -25,6 +25,8 @@ export default class SecureApi extends Api {
|
||||
this._isConnecting = true;
|
||||
this._connectState = 0;
|
||||
this._needsToken = false;
|
||||
this._dappsPort = 8080;
|
||||
this._signerPort = 8180;
|
||||
|
||||
this._followConnection();
|
||||
}
|
||||
@@ -50,7 +52,7 @@ export default class SecureApi extends Api {
|
||||
case 0:
|
||||
if (isConnected) {
|
||||
this._isConnecting = false;
|
||||
return this.setToken();
|
||||
return this.connectSuccess();
|
||||
} else if (lastError) {
|
||||
this.updateToken('initial', 1);
|
||||
}
|
||||
@@ -60,7 +62,7 @@ export default class SecureApi extends Api {
|
||||
case 1:
|
||||
if (isConnected) {
|
||||
this._connectState = 2;
|
||||
this.personal
|
||||
this.parity
|
||||
.generateAuthorizationToken()
|
||||
.then((token) => {
|
||||
this.updateToken(token, 2);
|
||||
@@ -79,7 +81,7 @@ export default class SecureApi extends Api {
|
||||
case 2:
|
||||
if (isConnected) {
|
||||
this._isConnecting = false;
|
||||
return this.setToken();
|
||||
return this.connectSuccess();
|
||||
} else if (lastError) {
|
||||
return setManual();
|
||||
}
|
||||
@@ -89,12 +91,38 @@ export default class SecureApi extends Api {
|
||||
nextTick();
|
||||
}
|
||||
|
||||
connectSuccess () {
|
||||
this.setToken();
|
||||
|
||||
Promise
|
||||
.all([
|
||||
this.parity.dappsPort(),
|
||||
this.parity.signerPort()
|
||||
])
|
||||
.then(([dappsPort, signerPort]) => {
|
||||
this._dappsPort = dappsPort.toNumber();
|
||||
this._signerPort = signerPort.toNumber();
|
||||
});
|
||||
}
|
||||
|
||||
updateToken (token, connectedState = 0) {
|
||||
this._connectState = connectedState;
|
||||
this._transport.updateToken(token.replace(/[^a-zA-Z0-9]/g, ''));
|
||||
this._followConnection();
|
||||
}
|
||||
|
||||
get dappsPort () {
|
||||
return this._dappsPort;
|
||||
}
|
||||
|
||||
get dappsUrl () {
|
||||
return `http://127.0.0.1:${this._dappsPort}`;
|
||||
}
|
||||
|
||||
get signerPort () {
|
||||
return this._signerPort;
|
||||
}
|
||||
|
||||
get isConnecting () {
|
||||
return this._isConnecting;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user