2019-01-11 12:08:01 -08:00
|
|
|
package staking
|
2018-02-23 15:57:31 -08:00
|
|
|
|
|
|
|
import (
|
2019-04-15 09:25:04 -07:00
|
|
|
"fmt"
|
2018-12-19 19:28:38 -08:00
|
|
|
"time"
|
2018-08-12 00:33:48 -07:00
|
|
|
|
2018-11-29 09:21:45 -08:00
|
|
|
abci "github.com/tendermint/tendermint/abci/types"
|
|
|
|
"github.com/tendermint/tendermint/libs/common"
|
|
|
|
tmtypes "github.com/tendermint/tendermint/types"
|
|
|
|
|
2018-02-23 15:57:31 -08:00
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
2019-01-11 12:08:01 -08:00
|
|
|
"github.com/cosmos/cosmos-sdk/x/staking/keeper"
|
|
|
|
"github.com/cosmos/cosmos-sdk/x/staking/types"
|
2018-02-23 15:57:31 -08:00
|
|
|
)
|
|
|
|
|
2018-06-26 19:00:12 -07:00
|
|
|
func NewHandler(k keeper.Keeper) sdk.Handler {
|
2018-02-27 18:07:20 -08:00
|
|
|
return func(ctx sdk.Context, msg sdk.Msg) sdk.Result {
|
2019-06-26 09:03:25 -07:00
|
|
|
ctx = ctx.WithEventManager(sdk.NewEventManager())
|
|
|
|
|
2018-03-14 11:42:50 -07:00
|
|
|
switch msg := msg.(type) {
|
2018-06-26 19:00:12 -07:00
|
|
|
case types.MsgCreateValidator:
|
2018-05-31 12:22:46 -07:00
|
|
|
return handleMsgCreateValidator(ctx, msg, k)
|
2019-04-15 09:25:04 -07:00
|
|
|
|
2018-06-26 19:00:12 -07:00
|
|
|
case types.MsgEditValidator:
|
2018-05-31 12:22:46 -07:00
|
|
|
return handleMsgEditValidator(ctx, msg, k)
|
2019-04-15 09:25:04 -07:00
|
|
|
|
2018-06-26 19:00:12 -07:00
|
|
|
case types.MsgDelegate:
|
2018-03-27 17:26:52 -07:00
|
|
|
return handleMsgDelegate(ctx, msg, k)
|
2019-04-15 09:25:04 -07:00
|
|
|
|
2018-06-26 19:00:12 -07:00
|
|
|
case types.MsgBeginRedelegate:
|
|
|
|
return handleMsgBeginRedelegate(ctx, msg, k)
|
2019-04-15 09:25:04 -07:00
|
|
|
|
2019-01-17 09:53:22 -08:00
|
|
|
case types.MsgUndelegate:
|
|
|
|
return handleMsgUndelegate(ctx, msg, k)
|
2019-04-15 09:25:04 -07:00
|
|
|
|
2018-03-13 11:27:52 -07:00
|
|
|
default:
|
2019-04-15 09:25:04 -07:00
|
|
|
errMsg := fmt.Sprintf("unrecognized staking message type: %T", msg)
|
|
|
|
return sdk.ErrUnknownRequest(errMsg).Result()
|
2018-02-27 18:07:20 -08:00
|
|
|
}
|
2018-02-23 15:57:31 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-19 11:36:00 -07:00
|
|
|
// Called every block, update validator set
|
2019-06-26 09:03:25 -07:00
|
|
|
func EndBlocker(ctx sdk.Context, k keeper.Keeper) []abci.ValidatorUpdate {
|
2018-11-04 22:11:03 -08:00
|
|
|
// Calculate validator set changes.
|
|
|
|
//
|
|
|
|
// NOTE: ApplyAndReturnValidatorSetUpdates has to come before
|
|
|
|
// UnbondAllMatureValidatorQueue.
|
|
|
|
// This fixes a bug when the unbonding period is instant (is the case in
|
|
|
|
// some of the tests). The test expected the validator to be completely
|
|
|
|
// unbonded after the Endblocker (go from Bonded -> Unbonding during
|
|
|
|
// ApplyAndReturnValidatorSetUpdates and then Unbonding -> Unbonded during
|
|
|
|
// UnbondAllMatureValidatorQueue).
|
2018-12-19 19:28:38 -08:00
|
|
|
validatorUpdates := k.ApplyAndReturnValidatorSetUpdates(ctx)
|
2018-11-04 22:11:03 -08:00
|
|
|
|
|
|
|
// Unbond all mature validators from the unbonding queue.
|
2018-10-14 17:37:06 -07:00
|
|
|
k.UnbondAllMatureValidatorQueue(ctx)
|
|
|
|
|
2018-11-04 22:11:03 -08:00
|
|
|
// Remove all mature unbonding delegations from the ubd queue.
|
2019-01-16 02:35:18 -08:00
|
|
|
matureUnbonds := k.DequeueAllMatureUBDQueue(ctx, ctx.BlockHeader().Time)
|
2018-10-07 21:43:47 -07:00
|
|
|
for _, dvPair := range matureUnbonds {
|
2019-02-25 07:16:52 -08:00
|
|
|
err := k.CompleteUnbonding(ctx, dvPair.DelegatorAddress, dvPair.ValidatorAddress)
|
2018-10-07 21:43:47 -07:00
|
|
|
if err != nil {
|
|
|
|
continue
|
|
|
|
}
|
2018-12-19 19:28:38 -08:00
|
|
|
|
2019-06-26 09:03:25 -07:00
|
|
|
ctx.EventManager().EmitEvent(
|
|
|
|
sdk.NewEvent(
|
|
|
|
types.EventTypeCompleteUnbonding,
|
|
|
|
sdk.NewAttribute(types.AttributeKeyValidator, dvPair.ValidatorAddress.String()),
|
|
|
|
sdk.NewAttribute(types.AttributeKeyDelegator, dvPair.DelegatorAddress.String()),
|
|
|
|
),
|
|
|
|
)
|
2018-10-07 21:43:47 -07:00
|
|
|
}
|
|
|
|
|
2018-11-04 22:11:03 -08:00
|
|
|
// Remove all mature redelegations from the red queue.
|
2018-10-07 21:43:47 -07:00
|
|
|
matureRedelegations := k.DequeueAllMatureRedelegationQueue(ctx, ctx.BlockHeader().Time)
|
|
|
|
for _, dvvTriplet := range matureRedelegations {
|
2019-02-25 07:16:52 -08:00
|
|
|
err := k.CompleteRedelegation(ctx, dvvTriplet.DelegatorAddress,
|
|
|
|
dvvTriplet.ValidatorSrcAddress, dvvTriplet.ValidatorDstAddress)
|
2018-10-07 21:43:47 -07:00
|
|
|
if err != nil {
|
|
|
|
continue
|
|
|
|
}
|
2018-12-19 19:28:38 -08:00
|
|
|
|
2019-06-26 09:03:25 -07:00
|
|
|
ctx.EventManager().EmitEvent(
|
|
|
|
sdk.NewEvent(
|
|
|
|
types.EventTypeCompleteRedelegation,
|
|
|
|
sdk.NewAttribute(types.AttributeKeyDelegator, dvvTriplet.DelegatorAddress.String()),
|
|
|
|
sdk.NewAttribute(types.AttributeKeySrcValidator, dvvTriplet.ValidatorSrcAddress.String()),
|
|
|
|
sdk.NewAttribute(types.AttributeKeyDstValidator, dvvTriplet.ValidatorDstAddress.String()),
|
|
|
|
),
|
|
|
|
)
|
2018-10-07 21:43:47 -07:00
|
|
|
}
|
2018-12-19 19:28:38 -08:00
|
|
|
|
2019-06-26 09:03:25 -07:00
|
|
|
return validatorUpdates
|
2018-04-04 20:22:13 -07:00
|
|
|
}
|
|
|
|
|
2018-02-23 15:57:31 -08:00
|
|
|
// These functions assume everything has been authenticated,
|
|
|
|
// now we just perform action and save
|
2018-03-14 11:42:50 -07:00
|
|
|
|
2018-06-26 19:00:12 -07:00
|
|
|
func handleMsgCreateValidator(ctx sdk.Context, msg types.MsgCreateValidator, k keeper.Keeper) sdk.Result {
|
2018-02-27 18:07:20 -08:00
|
|
|
// check to see if the pubkey or sender has been registered before
|
2019-02-25 07:16:52 -08:00
|
|
|
if _, found := k.GetValidator(ctx, msg.ValidatorAddress); found {
|
2018-07-09 17:42:57 -07:00
|
|
|
return ErrValidatorOwnerExists(k.Codespace()).Result()
|
|
|
|
}
|
2018-09-24 15:23:58 -07:00
|
|
|
|
2019-02-07 17:41:23 -08:00
|
|
|
if _, found := k.GetValidatorByConsAddr(ctx, sdk.GetConsAddress(msg.PubKey)); found {
|
2018-07-09 17:42:57 -07:00
|
|
|
return ErrValidatorPubKeyExists(k.Codespace()).Result()
|
2018-02-27 18:07:20 -08:00
|
|
|
}
|
2018-09-24 15:23:58 -07:00
|
|
|
|
2019-06-20 06:51:18 -07:00
|
|
|
if msg.Value.Denom != k.BondDenom(ctx) {
|
2018-06-26 19:00:12 -07:00
|
|
|
return ErrBadDenom(k.Codespace()).Result()
|
2018-03-13 11:27:52 -07:00
|
|
|
}
|
2018-02-27 18:07:20 -08:00
|
|
|
|
2019-01-21 16:52:03 -08:00
|
|
|
if _, err := msg.Description.EnsureLength(); err != nil {
|
|
|
|
return err.Result()
|
|
|
|
}
|
|
|
|
|
2018-11-29 09:21:45 -08:00
|
|
|
if ctx.ConsensusParams() != nil {
|
|
|
|
tmPubKey := tmtypes.TM2PB.PubKey(msg.PubKey)
|
|
|
|
if !common.StringInSlice(tmPubKey.Type, ctx.ConsensusParams().Validator.PubKeyTypes) {
|
2019-05-20 06:13:32 -07:00
|
|
|
return ErrValidatorPubKeyTypeNotSupported(k.Codespace(),
|
2019-01-21 16:52:03 -08:00
|
|
|
tmPubKey.Type,
|
|
|
|
ctx.ConsensusParams().Validator.PubKeyTypes).Result()
|
2018-11-29 09:21:45 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-25 07:16:52 -08:00
|
|
|
validator := NewValidator(msg.ValidatorAddress, msg.PubKey, msg.Description)
|
2018-09-24 15:23:58 -07:00
|
|
|
commission := NewCommissionWithTime(
|
2018-10-10 23:26:54 -07:00
|
|
|
msg.Commission.Rate, msg.Commission.MaxRate,
|
2018-09-24 15:23:58 -07:00
|
|
|
msg.Commission.MaxChangeRate, ctx.BlockHeader().Time,
|
|
|
|
)
|
|
|
|
validator, err := validator.SetInitialCommission(commission)
|
|
|
|
if err != nil {
|
|
|
|
return err.Result()
|
|
|
|
}
|
|
|
|
|
2019-02-08 12:44:19 -08:00
|
|
|
validator.MinSelfDelegation = msg.MinSelfDelegation
|
|
|
|
|
2018-06-26 19:00:12 -07:00
|
|
|
k.SetValidator(ctx, validator)
|
2018-09-24 21:09:31 -07:00
|
|
|
k.SetValidatorByConsAddr(ctx, validator)
|
2018-10-03 09:37:06 -07:00
|
|
|
k.SetNewValidatorByPowerIndex(ctx, validator)
|
2018-02-23 15:57:31 -08:00
|
|
|
|
2019-02-07 17:41:23 -08:00
|
|
|
// call the after-creation hook
|
2019-02-25 07:16:52 -08:00
|
|
|
k.AfterValidatorCreated(ctx, validator.OperatorAddress)
|
2018-10-22 17:49:53 -07:00
|
|
|
|
2018-06-26 19:00:12 -07:00
|
|
|
// move coins from the msg.Address account to a (self-delegation) delegator account
|
2018-05-09 21:01:58 -07:00
|
|
|
// the validator account and global shares are updated within here
|
2019-06-28 13:11:27 -07:00
|
|
|
// NOTE source will always be from a wallet which are unbonded
|
|
|
|
_, err = k.Delegate(ctx, msg.DelegatorAddress, msg.Value.Amount, sdk.Unbonded, validator, true)
|
2018-04-03 10:03:49 -07:00
|
|
|
if err != nil {
|
|
|
|
return err.Result()
|
|
|
|
}
|
2018-06-26 19:00:12 -07:00
|
|
|
|
2019-06-26 09:03:25 -07:00
|
|
|
ctx.EventManager().EmitEvents(sdk.Events{
|
|
|
|
sdk.NewEvent(
|
|
|
|
types.EventTypeCreateValidator,
|
|
|
|
sdk.NewAttribute(types.AttributeKeyValidator, msg.ValidatorAddress.String()),
|
|
|
|
sdk.NewAttribute(types.AttributeKeyAmount, msg.Value.Amount.String()),
|
|
|
|
),
|
|
|
|
sdk.NewEvent(
|
|
|
|
sdk.EventTypeMessage,
|
|
|
|
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
|
|
|
sdk.NewAttribute(sdk.AttributeKeySender, msg.DelegatorAddress.String()),
|
|
|
|
),
|
|
|
|
})
|
|
|
|
|
|
|
|
return sdk.Result{Events: ctx.EventManager().Events()}
|
2018-02-23 15:57:31 -08:00
|
|
|
}
|
|
|
|
|
2018-06-26 19:00:12 -07:00
|
|
|
func handleMsgEditValidator(ctx sdk.Context, msg types.MsgEditValidator, k keeper.Keeper) sdk.Result {
|
2018-05-09 21:01:58 -07:00
|
|
|
// validator must already be registered
|
2019-02-25 07:16:52 -08:00
|
|
|
validator, found := k.GetValidator(ctx, msg.ValidatorAddress)
|
2018-03-20 14:21:18 -07:00
|
|
|
if !found {
|
2018-06-26 19:00:12 -07:00
|
|
|
return ErrNoValidatorFound(k.Codespace()).Result()
|
2018-03-13 11:27:52 -07:00
|
|
|
}
|
2018-02-23 15:57:31 -08:00
|
|
|
|
2018-03-28 08:08:22 -07:00
|
|
|
// replace all editable fields (clients should autofill existing values)
|
2018-06-26 19:00:12 -07:00
|
|
|
description, err := validator.Description.UpdateDescription(msg.Description)
|
|
|
|
if err != nil {
|
|
|
|
return err.Result()
|
|
|
|
}
|
2018-09-24 15:23:58 -07:00
|
|
|
|
2018-06-26 19:00:12 -07:00
|
|
|
validator.Description = description
|
2018-05-09 21:01:58 -07:00
|
|
|
|
2018-09-24 15:23:58 -07:00
|
|
|
if msg.CommissionRate != nil {
|
2018-10-03 09:37:06 -07:00
|
|
|
commission, err := k.UpdateValidatorCommission(ctx, validator, *msg.CommissionRate)
|
|
|
|
if err != nil {
|
2018-09-24 15:23:58 -07:00
|
|
|
return err.Result()
|
|
|
|
}
|
2019-01-08 21:28:46 -08:00
|
|
|
|
2019-02-07 17:41:23 -08:00
|
|
|
// call the before-modification hook since we're about to update the commission
|
2019-02-25 07:16:52 -08:00
|
|
|
k.BeforeValidatorModified(ctx, msg.ValidatorAddress)
|
2019-02-07 17:41:23 -08:00
|
|
|
|
2018-10-03 09:37:06 -07:00
|
|
|
validator.Commission = commission
|
2018-09-24 15:23:58 -07:00
|
|
|
}
|
|
|
|
|
2019-02-08 12:44:19 -08:00
|
|
|
if msg.MinSelfDelegation != nil {
|
|
|
|
if !(*msg.MinSelfDelegation).GT(validator.MinSelfDelegation) {
|
|
|
|
return ErrMinSelfDelegationDecreased(k.Codespace()).Result()
|
|
|
|
}
|
|
|
|
if (*msg.MinSelfDelegation).GT(validator.Tokens) {
|
|
|
|
return ErrSelfDelegationBelowMinimum(k.Codespace()).Result()
|
|
|
|
}
|
|
|
|
validator.MinSelfDelegation = (*msg.MinSelfDelegation)
|
|
|
|
}
|
|
|
|
|
2018-07-27 21:42:07 -07:00
|
|
|
k.SetValidator(ctx, validator)
|
2018-09-24 15:23:58 -07:00
|
|
|
|
2019-06-26 09:03:25 -07:00
|
|
|
ctx.EventManager().EmitEvents(sdk.Events{
|
|
|
|
sdk.NewEvent(
|
|
|
|
types.EventTypeEditValidator,
|
|
|
|
sdk.NewAttribute(types.AttributeKeyCommissionRate, validator.Commission.String()),
|
|
|
|
sdk.NewAttribute(types.AttributeKeyMinSelfDelegation, validator.MinSelfDelegation.String()),
|
|
|
|
),
|
|
|
|
sdk.NewEvent(
|
|
|
|
sdk.EventTypeMessage,
|
|
|
|
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
|
|
|
sdk.NewAttribute(sdk.AttributeKeySender, msg.ValidatorAddress.String()),
|
|
|
|
),
|
|
|
|
})
|
|
|
|
|
|
|
|
return sdk.Result{Events: ctx.EventManager().Events()}
|
2018-02-23 15:57:31 -08:00
|
|
|
}
|
|
|
|
|
2018-06-26 19:00:12 -07:00
|
|
|
func handleMsgDelegate(ctx sdk.Context, msg types.MsgDelegate, k keeper.Keeper) sdk.Result {
|
2019-02-25 07:16:52 -08:00
|
|
|
validator, found := k.GetValidator(ctx, msg.ValidatorAddress)
|
2018-03-20 14:21:18 -07:00
|
|
|
if !found {
|
2018-06-26 19:00:12 -07:00
|
|
|
return ErrNoValidatorFound(k.Codespace()).Result()
|
2018-02-27 18:07:20 -08:00
|
|
|
}
|
2018-08-31 12:21:12 -07:00
|
|
|
|
2019-06-20 06:51:18 -07:00
|
|
|
if msg.Amount.Denom != k.BondDenom(ctx) {
|
2018-06-26 19:00:12 -07:00
|
|
|
return ErrBadDenom(k.Codespace()).Result()
|
2018-02-27 18:07:20 -08:00
|
|
|
}
|
2018-08-31 12:21:12 -07:00
|
|
|
|
2019-06-28 13:11:27 -07:00
|
|
|
// NOTE: source funds are always unbonded
|
|
|
|
_, err := k.Delegate(ctx, msg.DelegatorAddress, msg.Amount.Amount, sdk.Unbonded, validator, true)
|
2018-04-03 10:03:49 -07:00
|
|
|
if err != nil {
|
|
|
|
return err.Result()
|
|
|
|
}
|
2018-06-26 19:00:12 -07:00
|
|
|
|
2019-06-26 09:03:25 -07:00
|
|
|
ctx.EventManager().EmitEvents(sdk.Events{
|
|
|
|
sdk.NewEvent(
|
|
|
|
types.EventTypeDelegate,
|
|
|
|
sdk.NewAttribute(types.AttributeKeyValidator, msg.ValidatorAddress.String()),
|
|
|
|
sdk.NewAttribute(types.AttributeKeyAmount, msg.Amount.Amount.String()),
|
|
|
|
),
|
|
|
|
sdk.NewEvent(
|
|
|
|
sdk.EventTypeMessage,
|
|
|
|
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
|
|
|
sdk.NewAttribute(sdk.AttributeKeySender, msg.DelegatorAddress.String()),
|
|
|
|
),
|
|
|
|
})
|
|
|
|
|
|
|
|
return sdk.Result{Events: ctx.EventManager().Events()}
|
2018-02-23 15:57:31 -08:00
|
|
|
}
|
|
|
|
|
2019-01-17 09:53:22 -08:00
|
|
|
func handleMsgUndelegate(ctx sdk.Context, msg types.MsgUndelegate, k keeper.Keeper) sdk.Result {
|
2019-03-25 14:13:02 -07:00
|
|
|
shares, err := k.ValidateUnbondAmount(
|
|
|
|
ctx, msg.DelegatorAddress, msg.ValidatorAddress, msg.Amount.Amount,
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return err.Result()
|
|
|
|
}
|
|
|
|
|
2019-06-20 06:51:18 -07:00
|
|
|
if msg.Amount.Denom != k.BondDenom(ctx) {
|
|
|
|
return ErrBadDenom(k.Codespace()).Result()
|
|
|
|
}
|
|
|
|
|
2019-03-25 14:13:02 -07:00
|
|
|
completionTime, err := k.Undelegate(ctx, msg.DelegatorAddress, msg.ValidatorAddress, shares)
|
2018-03-16 13:36:16 -07:00
|
|
|
if err != nil {
|
2018-06-26 19:00:12 -07:00
|
|
|
return err.Result()
|
2018-03-16 13:36:16 -07:00
|
|
|
}
|
2018-04-03 19:26:39 -07:00
|
|
|
|
2019-06-26 09:03:25 -07:00
|
|
|
completionTimeBz := types.ModuleCdc.MustMarshalBinaryLengthPrefixed(completionTime)
|
|
|
|
ctx.EventManager().EmitEvents(sdk.Events{
|
|
|
|
sdk.NewEvent(
|
|
|
|
types.EventTypeUnbond,
|
|
|
|
sdk.NewAttribute(types.AttributeKeyValidator, msg.ValidatorAddress.String()),
|
|
|
|
sdk.NewAttribute(types.AttributeKeyAmount, msg.Amount.Amount.String()),
|
|
|
|
sdk.NewAttribute(types.AttributeKeyCompletionTime, completionTime.Format(time.RFC3339)),
|
|
|
|
),
|
|
|
|
sdk.NewEvent(
|
|
|
|
sdk.EventTypeMessage,
|
|
|
|
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
|
|
|
sdk.NewAttribute(sdk.AttributeKeySender, msg.DelegatorAddress.String()),
|
|
|
|
),
|
|
|
|
})
|
|
|
|
|
|
|
|
return sdk.Result{Data: completionTimeBz, Events: ctx.EventManager().Events()}
|
2018-06-26 19:00:12 -07:00
|
|
|
}
|
2018-02-23 15:57:31 -08:00
|
|
|
|
2018-06-26 19:00:12 -07:00
|
|
|
func handleMsgBeginRedelegate(ctx sdk.Context, msg types.MsgBeginRedelegate, k keeper.Keeper) sdk.Result {
|
2019-03-25 14:13:02 -07:00
|
|
|
shares, err := k.ValidateUnbondAmount(
|
|
|
|
ctx, msg.DelegatorAddress, msg.ValidatorSrcAddress, msg.Amount.Amount,
|
|
|
|
)
|
|
|
|
if err != nil {
|
|
|
|
return err.Result()
|
|
|
|
}
|
|
|
|
|
2019-06-20 06:51:18 -07:00
|
|
|
if msg.Amount.Denom != k.BondDenom(ctx) {
|
|
|
|
return ErrBadDenom(k.Codespace()).Result()
|
|
|
|
}
|
|
|
|
|
2019-03-25 14:13:02 -07:00
|
|
|
completionTime, err := k.BeginRedelegation(
|
|
|
|
ctx, msg.DelegatorAddress, msg.ValidatorSrcAddress, msg.ValidatorDstAddress, shares,
|
|
|
|
)
|
2018-06-26 19:00:12 -07:00
|
|
|
if err != nil {
|
|
|
|
return err.Result()
|
2018-02-23 15:57:31 -08:00
|
|
|
}
|
|
|
|
|
2019-06-26 09:03:25 -07:00
|
|
|
completionTimeBz := types.ModuleCdc.MustMarshalBinaryLengthPrefixed(completionTime)
|
|
|
|
ctx.EventManager().EmitEvents(sdk.Events{
|
|
|
|
sdk.NewEvent(
|
|
|
|
types.EventTypeRedelegate,
|
|
|
|
sdk.NewAttribute(types.AttributeKeySrcValidator, msg.ValidatorSrcAddress.String()),
|
|
|
|
sdk.NewAttribute(types.AttributeKeyDstValidator, msg.ValidatorDstAddress.String()),
|
|
|
|
sdk.NewAttribute(types.AttributeKeyAmount, msg.Amount.Amount.String()),
|
|
|
|
sdk.NewAttribute(types.AttributeKeyCompletionTime, completionTime.Format(time.RFC3339)),
|
|
|
|
),
|
|
|
|
sdk.NewEvent(
|
|
|
|
sdk.EventTypeMessage,
|
|
|
|
sdk.NewAttribute(sdk.AttributeKeyModule, types.AttributeValueCategory),
|
|
|
|
sdk.NewAttribute(sdk.AttributeKeySender, msg.DelegatorAddress.String()),
|
|
|
|
),
|
|
|
|
})
|
|
|
|
|
|
|
|
return sdk.Result{Data: completionTimeBz, Events: ctx.EventManager().Events()}
|
2018-02-23 15:57:31 -08:00
|
|
|
}
|