planetmint-go/x/dao/keeper/msg_server_reissue_rddl_proposal.go
Julian Strobl db5f4fb3fe
[lib] Switch from RPC (REST) to gRPC (#183)
* [lib] Add `SimulateTx()`

* [lib] Set `plmnt` as default bech32 account prefix

* [linter] Function should pass the context parameter (contextcheck)

// Closes #175

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2023-11-16 14:47:16 +01:00

37 lines
1.1 KiB
Go

package keeper
import (
"context"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/planetmint/planetmint-go/util"
"github.com/planetmint/planetmint-go/x/dao/types"
)
func (k msgServer) ReissueRDDLProposal(goCtx context.Context, msg *types.MsgReissueRDDLProposal) (*types.MsgReissueRDDLProposalResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
logger := ctx.Logger()
validatorIdentity, validResult := util.GetValidatorCometBFTIdentity(ctx)
if validResult && msg.Proposer == validatorIdentity {
// 1. sign tx
// 2. broadcast tx
logger.Debug("REISSUE: Asset")
txID, err := util.ReissueAsset(msg.Tx)
if err == nil {
// 3. notarize result by notarizing the liquid tx-id
_ = util.SendRDDLReissuanceResult(goCtx, msg.GetProposer(), txID, msg.GetBlockHeight())
//TODO verify and resolve error
} else {
logger.Error("REISSUE: Asset reissuance failure: " + err.Error())
}
}
var reissuance types.Reissuance
reissuance.BlockHeight = msg.GetBlockHeight()
reissuance.Proposer = msg.GetProposer()
reissuance.Rawtx = msg.GetTx()
k.StoreReissuance(ctx, reissuance)
return &types.MsgReissueRDDLProposalResponse{}, nil
}