Skip to content
This repository has been archived by the owner on May 19, 2023. It is now read-only.

Commit

Permalink
feat: fix linter
Browse files Browse the repository at this point in the history
  • Loading branch information
nduchak committed Sep 8, 2020
1 parent 7954f35 commit 85c3124
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
18 changes: 13 additions & 5 deletions src/services/storage/handlers/stake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ const handlers = {

const stake = await StakeModel.findOne({ where: { token, account } })

stake!.total = total
await stake!.save()
if (!stake) {
throw new Error(`Stake for acoount ${account}, token ${token} not created`)
}

stake.total = total
await stake.save()
logger.info(`Account ${account} stake amount ${amount}, final balance ${total}`)

if (stakeService.emit) {
stakeService.emit('updated', stake!.toJSON())
stakeService.emit('updated', stake.toJSON())
}
},

Expand All @@ -27,8 +31,12 @@ const handlers = {

const stake = await StakeModel.findOne({ where: { token, account } })

stake!.total = total
await stake!.save()
if (!stake) {
throw new Error(`Stake for acoount ${account}, token ${token} not created`)
}

stake.total = total
await stake.save()
logger.info(`Account ${account} stake amount ${amount}, final balance ${total}`)

if (stakeService.emit) {
Expand Down
4 changes: 2 additions & 2 deletions test/services/storage/processor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ describe('Storage services: Events Processor', () => {
const updatedStake = await StakeModel.findOne({ where: { token, account } })

expect(updatedStake?.total).to.be.eql(new BigNumber(event.returnValues.total))
expect(stakeServiceEmitSpy).to.have.been.calledWith('updated', updatedStake!.toJSON())
expect(stakeServiceEmitSpy).to.have.been.calledWith('updated', updatedStake?.toJSON())
})
})
describe('Unstaked', () => {
Expand All @@ -476,7 +476,7 @@ describe('Storage services: Events Processor', () => {
await processor(event)
const updatedStake = await StakeModel.findOne({ where: { token, account } })

expect(stakeServiceEmitSpy).to.have.been.calledWith('updated', updatedStake!.toJSON())
expect(stakeServiceEmitSpy).to.have.been.calledWith('updated', updatedStake?.toJSON())
expect(updatedStake?.total).to.be.eql(new BigNumber(event.returnValues.total))
})
})
Expand Down

0 comments on commit 85c3124

Please sign in to comment.