planetmint-go/x/dao/keeper/msg_server_reissue_rddl_proposal.go
Julian Strobl 2cf9bd4c43
refactor: replace raw tx by command in reissuance (#266)
In the beginning we wanted to send the raw transaction to elements, but
what we ended up doing is to send the command like:
```
"reissueasset assetID amount"
```
to elements-cli/elements-rpc.

Closes #226

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2024-01-10 10:30:58 +01:00

39 lines
1.4 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"
)
var (
reissueTag = "reissue: "
)
func (k msgServer) ReissueRDDLProposal(goCtx context.Context, msg *types.MsgReissueRDDLProposal) (*types.MsgReissueRDDLProposalResponse, error) {
ctx := sdk.UnwrapSDKContext(goCtx)
validatorIdentity, validResult := util.GetValidatorCometBFTIdentity(ctx)
if validResult && msg.Proposer == validatorIdentity {
util.GetAppLogger().Info(ctx, reissueTag+"asset: "+msg.GetCommand())
txID, err := util.ReissueAsset(msg.Command)
if err != nil {
util.GetAppLogger().Error(ctx, reissueTag+"asset reissuance failed: "+err.Error())
}
// 3. notarize result by notarizing the liquid tx-id
util.SendReissuanceResult(goCtx, msg.GetProposer(), txID, msg.GetBlockHeight())
} else {
util.GetAppLogger().Error(ctx, reissueTag+"failed. valid result: %v proposer: %s validator identity: %s", validResult, msg.Proposer, validatorIdentity)
}
var reissuance types.Reissuance
reissuance.BlockHeight = msg.GetBlockHeight()
reissuance.Proposer = msg.GetProposer()
reissuance.Command = msg.GetCommand()
reissuance.FirstIncludedPop = msg.GetFirstIncludedPop()
reissuance.LastIncludedPop = msg.GetLastIncludedPop()
k.StoreReissuance(ctx, reissuance)
return &types.MsgReissueRDDLProposalResponse{}, nil
}