Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
)
.sort((a, b) => {
return (
parseInt(a.split(".")[2], 10) -
parseInt(b.split(".")[2], 10)
);
});
const lastActive = active.last() || `1.${isWitness ? "6" : "5"}.1`;
lastIdx = parseInt(lastActive.split(".")[2], 10);
for (var i = 1; i <= lastIdx + 10; i++) {
vote_ids.push(`1.${isWitness ? "6" : "5"}.${i}`);
}
} else {
lastIdx = parseInt(vote_ids[vote_ids.length - 1].split(".")[2], 10);
}
FetchChainObjects(ChainStore.getObject, vote_ids, 5000, {}).then(
vote_objs => {
this.state[`all_${type}`] = current.concat(
Immutable.List(
vote_objs
.filter(a => !!a)
.map(a =>
a.get(
isWitness
? "witness_account"
: "committee_member_account"
)
)
)
);
if (!!vote_objs[vote_objs.length - 1]) {
// there are more valid vote objs, fetch 10 more
const hasProxy = proxy_account_id !== "1.2.5";
if (hasProxy && proxyOptions) {
let proxy_votes = proxyOptions.get("votes");
let proxy_vote_ids = proxy_votes.toArray();
proxy_vids = Immutable.Set(proxy_vote_ids);
ChainStore.getObjectsByVoteIds(proxy_vote_ids);
proxyPromise = FetchChainObjects(
ChainStore.getObjectByVoteID,
proxy_vote_ids,
10000
);
}
Promise.all([
FetchChainObjects(ChainStore.getObjectByVoteID, vote_ids, 10000),
proxyPromise
]).then(res => {
const [vote_objs, proxy_vote_objs] = res;
function sortVoteObjects(objects) {
let witnesses = new Immutable.List();
let committee = new Immutable.List();
let workers = new Immutable.Set();
objects.forEach(obj => {
let account_id = obj.get("committee_member_account");
if (account_id) {
committee = committee.push(account_id);
} else if ((account_id = obj.get("worker_account"))) {
// console.log( "worker: ", obj );
// workers = workers.add(obj.get("id"));
} else if ((account_id = obj.get("witness_account"))) {
witnesses = witnesses.push(account_id);
_load() {
// cache asset issuer name
if (!this.state.assetIssuerName) {
FetchChainObjects(ChainStore.getAccountName, [
this.props.asset.get("issuer")
]).then(result => {
if (this._isMounted) {
// re-render, ChainStore cache now has the object
this.setState({assetIssuerName: result[0]});
}
});
}
}
showModal = operation => async () => {
if (operation.payload) {
// cache for modal
await FetchChainObjects(
ChainStore.getAccount,
[operation.payload.transfer.to],
undefined,
{}
);
await FetchChainObjects(
ChainStore.getAccount,
[operation.payload.transfer.from],
undefined,
{}
);
await FetchChainObjects(ChainStore.getAsset, [
operation.payload.transfer.asset_id
]);
}
this.setState({
let votes = options.get("votes");
let vote_ids = votes.toArray();
let vids = Immutable.Set(vote_ids);
ChainStore.getObjectsByVoteIds(vote_ids);
let proxyPromise = null,
proxy_vids = Immutable.Set([]);
const hasProxy = proxy_account_id !== "1.2.5";
if (hasProxy && proxyOptions) {
let proxy_votes = proxyOptions.get("votes");
let proxy_vote_ids = proxy_votes.toArray();
proxy_vids = Immutable.Set(proxy_vote_ids);
ChainStore.getObjectsByVoteIds(proxy_vote_ids);
proxyPromise = FetchChainObjects(
ChainStore.getObjectByVoteID,
proxy_vote_ids,
10000
);
}
Promise.all([
FetchChainObjects(ChainStore.getObjectByVoteID, vote_ids, 10000),
proxyPromise
]).then(res => {
const [vote_objs, proxy_vote_objs] = res;
function sortVoteObjects(objects) {
let witnesses = new Immutable.List();
let committee = new Immutable.List();
let workers = new Immutable.Set();
objects.forEach(obj => {
validateAccount(collection, account) {
if (!account) return null;
if (collection === "witnesses") {
return FetchChainObjects(
ChainStore.getWitnessById,
[account.get("id")],
3000
).then(res => {
return res[0] ? null : "Not a witness";
});
}
if (collection === "committee") {
return FetchChainObjects(
ChainStore.getCommitteeMemberById,
[account.get("id")],
3000
).then(res => {
return res[0] ? null : "Not a committee member";
});
}