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

Commit

Permalink
feat: update stake based on token address
Browse files Browse the repository at this point in the history
  • Loading branch information
nduchak committed Sep 7, 2020
1 parent e48f8be commit 69ae4c1
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/services/storage/handlers/stake.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,18 @@ const logger = loggingFactory('storage:handler:stake')

const handlers = {
async Staked (event: EventData, { stakeService }: StorageServices): Promise<void> {
const { user: account, total, data, amount } = event.returnValues
const { user: account, total, token, amount } = event.returnValues

// TODO Update specific stake based on token
const [, [stake]] = await StakeModel.update({ total }, { where: { account, tokenAddress: data } })
const [, [stake]] = await StakeModel.update({ total }, { where: { account, tokenAddress: token } })
logger.info(`Account ${account} stake amount ${amount}, final balance ${total}`)

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

async Unstaked (event: EventData, { stakeService }: StorageServices): Promise<void> {
const { user: account, total, data, amount } = event.returnValues
const { user: account, total, token, amount } = event.returnValues

// TODO Update specific stake based on token
const [, [stake]] = await StakeModel.update({ total }, { where: { account, tokenAddress: data } })
const [, [stake]] = await StakeModel.update({ total }, { where: { account, tokenAddress: token } })
logger.info(`Account ${account} unstack amount ${amount}, final balance ${total}`)

if (stakeService.emit) stakeService.emit('updated', stake.toJSON())
Expand Down

0 comments on commit 69ae4c1

Please sign in to comment.