Smarter Tokens fetching (#3546)

* Don't auto-subscribe for contracts #3240

* Smarter Balance : don't re-instantiate contracts, fetch tokens #3240

* Smarter Balance Tokens fetching (update image when needed) #3240

* Attaching to TokenReg Events instead of fetching for each block #3240

* Unsubscribe from shapeshit... #3240

* Unsubscribe from EthFilter if used once (resolved) #3240

* Remove warning

* PR review fix

* Typo

* Better contract JS API : one subscribe for all #3546

* Fixed test
This commit is contained in:
Nicolas Gotchac
2016-11-23 10:30:47 +01:00
committed by Jaco Greeff
parent a969c008d1
commit 33dd49160f
10 changed files with 440 additions and 150 deletions

View File

@@ -15,6 +15,7 @@
// 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';
@@ -50,14 +51,19 @@ 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)
.map(inHex);
.filter((topic) => topic === null || topic)
.map((topic) => topic === null ? null : pad(topic, 32));
while (topics.length < 4) {
topics.push(null);
}
// while (topics.length < 4) {
// topics.push(null);
// }
return topics;
}