[beta] Backports (#6497)
* Fix slow balances (#6471)
* Update token updates
* Update token info fetching
* Update logger
* Minor fixes to updates and notifications for balances
* Use Pubsub
* Fix timeout.
* Use pubsub for status.
* Fix signer subscription.
* Process tokens in chunks.
* Fix tokens loaded by chunks
* Linting
* Dispatch tokens asap
* Fix chunks processing.
* Better filter options
* Parallel log fetching.
* Fix signer polling.
* Fix initial block query.
* Token balances updates : the right(er) way
* Better tokens info fetching
* Fixes in token data fetching
* Only fetch what's needed (tokens)
* Fix linting issues
* Revert "Transaction permissioning (#6441)"
This reverts commit eed0e8b03a.
* Revert "Revert "Transaction permissioning (#6441)""
This reverts commit 8f96415e58dde652e5828706eb2639d43416f448.
* Update wasm-tests.
* Fixing balances fetching
* Fix requests tracking in UI
* Fix request watching
* Update the Logger
* PR Grumbles Fixes
* PR Grumbles fixes
* Linting...
* eth_call returns output of contract creations (#6420)
* eth_call returns output of contract creations
* Fix parameters order.
* Save outputs for light client as well.
* Don't accept transactions above block gas limit.
* Expose health status over RPC (#6274)
* Node-health to a separate crate.
* Initialize node_health outside of dapps.
* Expose health over RPC.
* Bring back 412 and fix JS.
* Add health to workspace and tests.
* Fix compilation without default features.
* Fix borked merge.
* Revert to generics to avoid virtual calls.
* Fix node-health tests.
* Add missing trailing comma.
* Fixing/removing failing JS tests.
* do not activate genesis epoch in immediate transition validator contract (#6349)
* Fix memory tracing.
* Add test to cover that.
* ensure balances of constructor accounts are kept
* test balance of spec-constructed account is kept
This commit is contained in:
@@ -25,7 +25,7 @@ export default class Eth extends PubsubBase {
|
||||
}
|
||||
|
||||
newHeads (callback) {
|
||||
return this.addListener('eth', 'newHeads', callback);
|
||||
return this.addListener('eth', 'newHeads', callback, null);
|
||||
}
|
||||
|
||||
logs (callback) {
|
||||
|
||||
@@ -266,7 +266,7 @@ export default class Parity extends PubsubBase {
|
||||
|
||||
// parity accounts API (only secure API or configured to be exposed)
|
||||
allAccountsInfo (callback) {
|
||||
return this._addListener(this._api, 'parity_allAccountsInfo', (error, data) => {
|
||||
return this.addListener(this._api, 'parity_allAccountsInfo', (error, data) => {
|
||||
error
|
||||
? callback(error)
|
||||
: callback(null, outAccountInfo(data));
|
||||
@@ -274,7 +274,7 @@ export default class Parity extends PubsubBase {
|
||||
}
|
||||
|
||||
getDappAddresses (callback, dappId) {
|
||||
return this._addListener(this._api, 'parity_getDappAddresses', (error, data) => {
|
||||
return this.addListener(this._api, 'parity_getDappAddresses', (error, data) => {
|
||||
error
|
||||
? callback(error)
|
||||
: callback(null, outAddresses(data));
|
||||
@@ -282,7 +282,7 @@ export default class Parity extends PubsubBase {
|
||||
}
|
||||
|
||||
getDappDefaultAddress (callback, dappId) {
|
||||
return this._addListener(this._api, 'parity_getDappDefaultAddress', (error, data) => {
|
||||
return this.addListener(this._api, 'parity_getDappDefaultAddress', (error, data) => {
|
||||
error
|
||||
? callback(error)
|
||||
: callback(null, outAddress(data));
|
||||
@@ -290,7 +290,7 @@ export default class Parity extends PubsubBase {
|
||||
}
|
||||
|
||||
getNewDappsAddresses (callback) {
|
||||
return this._addListener(this._api, 'parity_getDappDefaultAddress', (error, addresses) => {
|
||||
return this.addListener(this._api, 'parity_getDappDefaultAddress', (error, addresses) => {
|
||||
error
|
||||
? callback(error)
|
||||
: callback(null, addresses ? addresses.map(outAddress) : null);
|
||||
@@ -298,7 +298,7 @@ export default class Parity extends PubsubBase {
|
||||
}
|
||||
|
||||
getNewDappsDefaultAddress (callback) {
|
||||
return this._addListener(this._api, 'parity_getNewDappsDefaultAddress', (error, data) => {
|
||||
return this.addListener(this._api, 'parity_getNewDappsDefaultAddress', (error, data) => {
|
||||
error
|
||||
? callback(error)
|
||||
: callback(null, outAddress(data));
|
||||
@@ -306,7 +306,7 @@ export default class Parity extends PubsubBase {
|
||||
}
|
||||
|
||||
listRecentDapps (callback) {
|
||||
return this._addListener(this._api, 'parity_listRecentDapps', (error, data) => {
|
||||
return this.addListener(this._api, 'parity_listRecentDapps', (error, data) => {
|
||||
error
|
||||
? callback(error)
|
||||
: callback(null, outRecentDapps(data));
|
||||
@@ -314,7 +314,7 @@ export default class Parity extends PubsubBase {
|
||||
}
|
||||
|
||||
listGethAccounts (callback) {
|
||||
return this._addListener(this._api, 'parity_listGethAccounts', (error, data) => {
|
||||
return this.addListener(this._api, 'parity_listGethAccounts', (error, data) => {
|
||||
error
|
||||
? callback(error)
|
||||
: callback(null, outAddresses(data));
|
||||
@@ -322,15 +322,15 @@ export default class Parity extends PubsubBase {
|
||||
}
|
||||
|
||||
listVaults (callback) {
|
||||
return this._addListener(this._api, 'parity_listVaults', callback);
|
||||
return this.addListener(this._api, 'parity_listVaults', callback);
|
||||
}
|
||||
|
||||
listOpenedVaults (callback) {
|
||||
return this._addListener(this._api, 'parity_listOpenedVaults', callback);
|
||||
return this.addListener(this._api, 'parity_listOpenedVaults', callback);
|
||||
}
|
||||
|
||||
getVaultMeta (callback, vaultName) {
|
||||
return this._addListener(this._api, 'parity_getVaultMeta', (error, data) => {
|
||||
return this.addListener(this._api, 'parity_getVaultMeta', (error, data) => {
|
||||
error
|
||||
? callback(error)
|
||||
: callback(null, outVaultMeta(data));
|
||||
@@ -338,7 +338,7 @@ export default class Parity extends PubsubBase {
|
||||
}
|
||||
|
||||
deriveAddressHash (callback, address, password, hash, shouldSave) {
|
||||
return this._addListener(this._api, 'parity_deriveAddressHash', (error, data) => {
|
||||
return this.addListener(this._api, 'parity_deriveAddressHash', (error, data) => {
|
||||
error
|
||||
? callback(error)
|
||||
: callback(null, outAddress(data));
|
||||
@@ -346,10 +346,18 @@ export default class Parity extends PubsubBase {
|
||||
}
|
||||
|
||||
deriveAddressIndex (callback, address, password, index, shouldSave) {
|
||||
return this._addListener(this._api, 'parity_deriveAddressIndex', (error, data) => {
|
||||
return this.addListener(this._api, 'parity_deriveAddressIndex', (error, data) => {
|
||||
error
|
||||
? callback(error)
|
||||
: callback(null, outAddress(data));
|
||||
}, [inAddress(address), password, inDeriveIndex(index), !!shouldSave]);
|
||||
}
|
||||
|
||||
nodeHealth (callback) {
|
||||
return this.addListener(this._api, 'parity_nodeHealth', (error, data) => {
|
||||
error
|
||||
? callback(error)
|
||||
: callback(null, data);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
import Eth from './eth';
|
||||
import Parity from './parity';
|
||||
import Signer from './signer';
|
||||
import Net from './net';
|
||||
|
||||
import { isFunction } from '../util/types';
|
||||
@@ -29,6 +30,7 @@ export default class Pubsub {
|
||||
this._eth = new Eth(transport);
|
||||
this._net = new Net(transport);
|
||||
this._parity = new Parity(transport);
|
||||
this._signer = new Signer(transport);
|
||||
}
|
||||
|
||||
get net () {
|
||||
@@ -43,8 +45,35 @@ export default class Pubsub {
|
||||
return this._parity;
|
||||
}
|
||||
|
||||
get signer () {
|
||||
return this._signer;
|
||||
}
|
||||
|
||||
unsubscribe (subscriptionIds) {
|
||||
// subscriptions are namespace independent. Thus we can simply removeListener from any.
|
||||
return this._parity.removeListener(subscriptionIds);
|
||||
}
|
||||
|
||||
subscribeAndGetResult (f, callback) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let isFirst = true;
|
||||
let onSubscription = (error, data) => {
|
||||
const p1 = error ? Promise.reject(error) : Promise.resolve(data);
|
||||
const p2 = p1.then(callback);
|
||||
|
||||
if (isFirst) {
|
||||
isFirst = false;
|
||||
p2
|
||||
.then(resolve)
|
||||
.catch(reject);
|
||||
}
|
||||
};
|
||||
|
||||
try {
|
||||
f.call(this, onSubscription).catch(reject);
|
||||
} catch (err) {
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,11 +20,12 @@ export default class PubsubBase {
|
||||
this._transport = transport;
|
||||
}
|
||||
|
||||
addListener (module, eventName, callback, eventParams) {
|
||||
return eventParams
|
||||
? this._transport.subscribe(module, callback, eventName, eventParams)
|
||||
: this._transport.subscribe(module, callback, eventName, []);
|
||||
// this._transport.subscribe(module, callback, eventName); After Patch from tomac is merged to master! => eth_subscribe does not support empty array as params
|
||||
addListener (module, eventName, callback, eventParams = []) {
|
||||
if (eventName) {
|
||||
return this._transport.subscribe(module, callback, eventParams ? [eventName, eventParams] : [eventName]);
|
||||
}
|
||||
|
||||
return this._transport.subscribe(module, callback, eventParams);
|
||||
}
|
||||
|
||||
removeListener (subscriptionIds) {
|
||||
|
||||
16
js/src/api/pubsub/signer/index.js
Normal file
16
js/src/api/pubsub/signer/index.js
Normal file
@@ -0,0 +1,16 @@
|
||||
// Copyright 2015-2017 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity.
|
||||
|
||||
// Parity is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Parity is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
export default from './signer';
|
||||
37
js/src/api/pubsub/signer/signer.js
Normal file
37
js/src/api/pubsub/signer/signer.js
Normal file
@@ -0,0 +1,37 @@
|
||||
// Copyright 2015-2017 Parity Technologies (UK) Ltd.
|
||||
// This file is part of Parity.
|
||||
|
||||
// Parity is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
|
||||
// Parity is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
import PubsubBase from '../pubsubBase';
|
||||
|
||||
import { outSignerRequest } from '../../format/output';
|
||||
|
||||
export default class Net extends PubsubBase {
|
||||
constructor (transport) {
|
||||
super(transport);
|
||||
this._api = {
|
||||
subscribe: 'signer_subscribePending',
|
||||
unsubscribe: 'signer_unsubscribePending',
|
||||
subscription: 'signer_pending'
|
||||
};
|
||||
}
|
||||
|
||||
pendingRequests (callback) {
|
||||
return this.addListener(this._api, null, (error, data) => {
|
||||
error
|
||||
? callback(error)
|
||||
: callback(null, data.map(outSignerRequest));
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user