Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

cdb: Add delegation row in create validator handler #2219

Merged
merged 3 commits into from
Jul 13, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
2 changes: 1 addition & 1 deletion CHANGELOG_UNRELEASED.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

### Emitter & Flusher

- (bugs) [\#2219](https://github.com/bandprotocol/bandchain/pull/2219) Add delegation row in create validator handler.
- (impv) [\#2196](https://github.com/bandprotocol/bandchain/pull/2196) Fix create view table command
- (impv) [\#2186](https://github.com/bandprotocol/bandchain/pull/2186) Add temporary view tables.
- (bugs) [\#2192](https://github.com/bandprotocol/bandchain/pull/2192) Add `commission_amount` field to Withdraw Commission Reward.
Expand Down Expand Up @@ -60,4 +61,3 @@
### MISC

- (impv) [\#2195](https://github.com/bandprotocol/bandchain/pull/2195) Remove lib and update executable as base64 encoded.

4 changes: 2 additions & 2 deletions chain/emitter/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ func (app *App) InitChain(req abci.RequestInitChain) abci.ResponseInitChain {
var tx auth.StdTx
app.Codec().MustUnmarshalJSON(genTx, &tx)
for _, msg := range tx.Msgs {
if createMsg, ok := msg.(staking.MsgCreateValidator); ok {
app.emitSetValidator(createMsg.ValidatorAddress)
if msg, ok := msg.(staking.MsgCreateValidator); ok {
app.handleMsgCreateValidator(nil, msg, nil, nil)
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions chain/emitter/staking.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,12 @@ func (app *App) emitUpdateValidatorStatus(addr sdk.ValAddress) {
func (app *App) emitDelegation(operatorAddress sdk.ValAddress, delegatorAddress sdk.AccAddress) {
delegation, found := app.StakingKeeper.GetDelegation(app.DeliverContext, delegatorAddress, operatorAddress)
if found {
info := app.DistrKeeper.GetDelegatorStartingInfo(app.DeliverContext, operatorAddress, delegatorAddress)
latestReward := app.DistrKeeper.GetValidatorHistoricalRewards(app.DeliverContext, operatorAddress, info.PreviousPeriod)
_, ratio := app.getCurrentRewardAndCurrentRatio(operatorAddress)
app.Write("SET_DELEGATION", JsDict{
"delegator_address": delegatorAddress,
"operator_address": operatorAddress,
"shares": delegation.Shares.String(),
"last_ratio": latestReward.CumulativeRewardRatio[0].Amount.String(),
"last_ratio": ratio,
})
} else {
app.Write("REMOVE_DELEGATION", JsDict{
Expand All @@ -80,6 +79,7 @@ func (app *App) handleMsgCreateValidator(
txHash []byte, msg staking.MsgCreateValidator, evMap EvMap, extra JsDict,
) {
app.emitSetValidator(msg.ValidatorAddress)
app.emitDelegation(msg.ValidatorAddress, msg.DelegatorAddress)
}

// handleMsgEditValidator implements emitter handler for MsgEditValidator.
Expand Down