Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Smarter balance fetching #3605

Merged
merged 25 commits into from
Nov 25, 2016
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d49c987
Smarter dApps Manifest fetching...
ngotchac Nov 23, 2016
3e607cf
Fetching only visible accounts (and don't delete other balances) #3590
ngotchac Nov 23, 2016
a4be211
Moved balances action into BalancesActions #3590
ngotchac Nov 24, 2016
562d861
Merge branch 'master' into ng-balance-fetch
ngotchac Nov 24, 2016
80a085c
Fetch balances for accounts and contracts #3590
ngotchac Nov 24, 2016
3be4e60
Add balances to contract/address/account views #3590
ngotchac Nov 24, 2016
0984835
Fix transaction not fetching on first load
ngotchac Nov 24, 2016
7078ed8
Remove console.warn
ngotchac Nov 24, 2016
e3bd9f2
Fix pending tokens not showing #3154
ngotchac Nov 24, 2016
8ea8056
Fix tokens image update
ngotchac Nov 24, 2016
e63a143
Remove unused name in Header
ngotchac Nov 24, 2016
efc9ee9
Separate Tokens and ETH fetching #3590
ngotchac Nov 24, 2016
4d444d8
Remove unused isTest
ngotchac Nov 24, 2016
c71e9cf
Fetch Tokens Balance via Filter #3590
ngotchac Nov 24, 2016
10b90d9
Fix linting
ngotchac Nov 24, 2016
68a9f6b
Fix updating tokens image (#3590)
ngotchac Nov 24, 2016
2ad3f9e
Fix contract balances
ngotchac Nov 24, 2016
3a451bc
Improved Status
ngotchac Nov 24, 2016
85b7423
Merge branch 'master' into ng-balance-fetch
ngotchac Nov 24, 2016
8ae3da3
Fixing secureApi issues...
ngotchac Nov 25, 2016
4c1c8e1
Fetch all tokens every 2 minutes (for safety) #3590
ngotchac Nov 25, 2016
4040888
Merge branch 'master' into ng-balance-fetch
ngotchac Nov 25, 2016
3e1b311
PR changes fix
ngotchac Nov 25, 2016
8371d71
Merge branch 'master' into ng-balance-fetch
ngotchac Nov 25, 2016
3c57ef4
Fix Account error
ngotchac Nov 25, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions js/src/api/format/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,30 @@ export function inHash (hash) {
return inHex(hash);
}

export function pad (input, length) {
export function padRight (input, length) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move to /api/util/format.js? (pad{left,Right})

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;
}

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;
}

if (Array.isArray(topic)) {
return inTopics(topic);
}

return padLeft(topic, 32);
});

// while (topics.length < 4) {
// topics.push(null);
Expand Down
3 changes: 2 additions & 1 deletion js/src/api/transport/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
12 changes: 10 additions & 2 deletions js/src/api/transport/ws/ws.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion js/src/dapps/tokenreg/Status/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export const subscribeEvents = () => (dispatch, getState) => {
const params = log.params;

if (event === 'Registered' && type === 'pending') {
return dispatch(setTokenData(params.id.toNumber(), {
return dispatch(setTokenData(params.id.value.toNumber(), {
tla: '...',
base: -1,
address: params.addr.value,
Expand Down
Loading