planetmint-go/x/dao/keeper/msg_server_distribution_result.go
Jürgen Eckel a982abecf5
Distribute assets (#162)
* distributed & result msgs
* added DistributionResult
* added RDDL token conversion methods
* set proper validatoraddress within the testcases for e2e/dao
* set proper root dir for test cases
* fixed some wordings
---------

Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
2023-11-15 13:31:20 +01:00

27 lines
812 B
Go

package keeper
import (
"context"
"strconv"
errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/planetmint/planetmint-go/x/dao/types"
)
func (k msgServer) DistributionResult(goCtx context.Context, msg *types.MsgDistributionResult) (*types.MsgDistributionResultResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
distribution, found := k.LookupDistributionOrder(ctx, msg.GetLastPop())
if found {
distribution.DaoTxID = msg.DaoTxID
distribution.PopTxID = msg.PopTxID
distribution.InvestorTxID = msg.InvestorTxID
k.StoreDistributionOrder(ctx, distribution)
} else {
return nil, errorsmod.Wrapf(types.ErrDistributionNotFound, " for provided block height %s", strconv.FormatInt(msg.GetLastPop(), 10))
}
return &types.MsgDistributionResultResponse{}, nil
}