Smarter balance fetching (#3605)
* Smarter dApps Manifest fetching... * Fetching only visible accounts (and don't delete other balances) #3590 * Moved balances action into BalancesActions #3590 * Fetch balances for accounts and contracts #3590 * Add balances to contract/address/account views #3590 * Fix transaction not fetching on first load * Remove console.warn * Fix pending tokens not showing #3154 * Fix tokens image update * Remove unused name in Header * Separate Tokens and ETH fetching #3590 * Remove unused isTest * Fetch Tokens Balance via Filter #3590 * Fix linting * Fix updating tokens image (#3590) * Fix contract balances * Improved Status * Fixing secureApi issues... * Fetch all tokens every 2 minutes (for safety) #3590 * PR changes fix * Fix Account error
This commit is contained in:
committed by
Jaco Greeff
parent
9fdab84305
commit
08c507daaa
@@ -15,9 +15,9 @@
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import BigNumber from 'bignumber.js';
|
||||
import { range } from 'lodash';
|
||||
|
||||
import { isArray, isHex, isInstanceOf, isString } from '../util/types';
|
||||
import { padLeft } from '../util/format';
|
||||
|
||||
export function inAddress (address) {
|
||||
// TODO: address validation if we have upper-lower addresses
|
||||
@@ -51,19 +51,20 @@ export function inHash (hash) {
|
||||
return inHex(hash);
|
||||
}
|
||||
|
||||
export function pad (input, length) {
|
||||
const value = inHex(input).substr(2, length * 2);
|
||||
return '0x' + value + range(length * 2 - value.length).map(() => '0').join('');
|
||||
}
|
||||
|
||||
export function inTopics (_topics) {
|
||||
let topics = (_topics || [])
|
||||
.filter((topic) => topic === null || topic)
|
||||
.map((topic) => topic === null ? null : pad(topic, 32));
|
||||
.map((topic) => {
|
||||
if (topic === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// while (topics.length < 4) {
|
||||
// topics.push(null);
|
||||
// }
|
||||
if (Array.isArray(topic)) {
|
||||
return inTopics(topic);
|
||||
}
|
||||
|
||||
return padLeft(topic, 32);
|
||||
});
|
||||
|
||||
return topics;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,8 @@ export const ERROR_CODES = {
|
||||
REQUEST_NOT_FOUND: -32042,
|
||||
COMPILATION_ERROR: -32050,
|
||||
ENCRYPTION_ERROR: -32055,
|
||||
FETCH_ERROR: -32060
|
||||
FETCH_ERROR: -32060,
|
||||
INVALID_PARAMS: -32602
|
||||
};
|
||||
|
||||
export default class TransportError extends ExtendableError {
|
||||
|
||||
@@ -79,7 +79,7 @@ export default class Ws extends JsonRpcBase {
|
||||
this._ws.onclose = this._onClose;
|
||||
this._ws.onmessage = this._onMessage;
|
||||
|
||||
// Get counts in dev mode
|
||||
// Get counts in dev mode only
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
this._count = 0;
|
||||
this._lastCount = {
|
||||
@@ -93,8 +93,13 @@ export default class Ws extends JsonRpcBase {
|
||||
const s = Math.round(1000 * n / t) / 1000;
|
||||
|
||||
if (this._debug) {
|
||||
console.log('::parityWS', `speed: ${s} req/s`, `count: ${this._count}`);
|
||||
console.log('::parityWS', `speed: ${s} req/s`, `count: ${this._count}`, `(+${n})`);
|
||||
}
|
||||
|
||||
this._lastCount = {
|
||||
timestamp: Date.now(),
|
||||
count: this._count
|
||||
};
|
||||
}, 5000);
|
||||
|
||||
window._parityWS = this;
|
||||
@@ -117,6 +122,7 @@ export default class Ws extends JsonRpcBase {
|
||||
this._connected = false;
|
||||
this._connecting = false;
|
||||
|
||||
event.timestamp = Date.now();
|
||||
this._lastError = event;
|
||||
|
||||
if (this._autoConnect) {
|
||||
@@ -144,6 +150,8 @@ export default class Ws extends JsonRpcBase {
|
||||
window.setTimeout(() => {
|
||||
if (this._connected) {
|
||||
console.error('ws:onError', event);
|
||||
|
||||
event.timestamp = Date.now();
|
||||
this._lastError = event;
|
||||
}
|
||||
}, 50);
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import { range } from 'lodash';
|
||||
import { inHex } from '../format/input';
|
||||
|
||||
export function bytesToHex (bytes) {
|
||||
return '0x' + bytes.map((b) => ('0' + b.toString(16)).slice(-2)).join('');
|
||||
}
|
||||
@@ -33,3 +36,13 @@ export function hex2Ascii (_hex) {
|
||||
export function asciiToHex (string) {
|
||||
return '0x' + string.split('').map((s) => s.charCodeAt(0).toString(16)).join('');
|
||||
}
|
||||
|
||||
export function padRight (input, length) {
|
||||
const value = inHex(input).substr(2, length * 2);
|
||||
return '0x' + value + range(length * 2 - value.length).map(() => '0').join('');
|
||||
}
|
||||
|
||||
export function padLeft (input, length) {
|
||||
const value = inHex(input).substr(2, length * 2);
|
||||
return '0x' + range(length * 2 - value.length).map(() => '0').join('') + value;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user