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

feat(storage): staking support #286

Merged
merged 29 commits into from
Sep 25, 2020
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8856bbd
feat: add stake contract to config
nduchak Sep 2, 2020
227f56c
feat: add stake model, hooks and event handler
nduchak Sep 2, 2020
22f31fc
feat: implement stake event handlers
nduchak Sep 3, 2020
c46b134
feat: adjust stake model
nduchak Sep 4, 2020
3e93708
feat: update stake based on token address
nduchak Sep 7, 2020
6170384
feat: add staking contract to config
nduchak Sep 8, 2020
4889665
feat: add unit tests for stacking events
nduchak Sep 8, 2020
9ca6f33
feat: add topics for staking contract
nduchak Sep 8, 2020
5ed802f
feat: fix linter
nduchak Sep 8, 2020
6d40d2d
feat: adjust store schema
nduchak Sep 8, 2020
b0686d9
feat: fix reorg event for staking
nduchak Sep 8, 2020
72137a2
feat: fix pr comments
nduchak Sep 9, 2020
b2ed49f
feat: fix linter
nduchak Sep 9, 2020
bc17d44
feat: fix more pr comments
nduchak Sep 9, 2020
6047732
chore: remove unused import
nduchak Sep 9, 2020
006e0b6
chore: add logging to db-backup
nduchak Sep 14, 2020
9126c13
feat: resolve token name before creating stake row
nduchak Sep 14, 2020
c72e682
feat: add erc20 abi const
nduchak Sep 14, 2020
67cfec3
feat: add stakes aggregation
nduchak Sep 15, 2020
413fb11
feat: fix linter
nduchak Sep 15, 2020
4173ed1
feat: update supported tokens
nduchak Sep 15, 2020
8e64301
feat: add supported tokens to config
nduchak Sep 16, 2020
636486b
feat: add type for supported tokens
nduchak Sep 16, 2020
3694ee9
feat: few iprovements
nduchak Sep 16, 2020
67c02c3
chore: adjust logs for unstacke event handler
nduchak Sep 16, 2020
9ae86fe
chore: update storage contract package
nduchak Sep 22, 2020
b9c54c6
chore: fix tests
nduchak Sep 23, 2020
f53ff31
chore: fix sonar cloud
nduchak Sep 23, 2020
d82f50d
feat: adjust topics for storage contract
nduchak Sep 23, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: update stake based on token address
nduchak committed Sep 23, 2020
commit 3e937088516ddad44916b925465e8a263aef1389
10 changes: 4 additions & 6 deletions src/services/storage/handlers/stake.ts
Original file line number Diff line number Diff line change
@@ -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())