fix off by one in pledge updates

This commit is contained in:
Barry Gitarts 2019-02-14 07:03:04 -05:00 committed by Barry G
parent b70dce4be4
commit 8ae34629cc
2 changed files with 2 additions and 2 deletions

View File

@ -55,7 +55,7 @@ export const updateStalePledges = async () => {
const stalePledges = await getStalePledges() const stalePledges = await getStalePledges()
const updatedPledges = await getPledges(stalePledges) const updatedPledges = await getPledges(stalePledges)
const batch = stalePledges.map(p => { const batch = stalePledges.map(p => {
const updated = updatedPledges[p.pledgeId] const updated = updatedPledges[p.pledgeId - 1]
return p.prepareUpdate(p => { return p.prepareUpdate(p => {
const { amount, nDelegates, pledgeState, blockNumber } = updated const { amount, nDelegates, pledgeState, blockNumber } = updated
p.amount = amount p.amount = amount

View File

@ -24,7 +24,7 @@ export const getAllPledges = async (start = 1) => {
export const getPledges = async (pledges = []) => { export const getPledges = async (pledges = []) => {
const updated = [] const updated = []
pledges.forEach(p => { pledges.forEach(p => {
updated[p.pledgeId] = getPledge(p.pledgeId - 1).call() updated[p.pledgeId - 1] = getPledge(p.pledgeId).call()
}) })
return Promise.all(updated.map(formatPledge)) return Promise.all(updated.map(formatPledge))
} }