fix off by one in pledge updates
This commit is contained in:
parent
b70dce4be4
commit
8ae34629cc
|
@ -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
|
||||||
|
|
|
@ -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))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue