planetmint-go/x/dao/keeper/msg_server_reissue_rddl_proposal.go
Julian Strobl 5470fc668b
Improve linter setup (#185)
* [linter] Remove unused exclusions

Linter `nosnakecase` was removed in 1e1138d0268a9896a1bd058e9b65b808eb20666e.

* [linter] Add tool for code clone detection

* [linter] Add `errorlint`

Find code that will cause problems with the error wrapping scheme
introduced in Go 1.13.

* [linter] Add `exhaustive`

Check exhaustiveness of enum switch statements.

* [linter] Add `forcetypeassert`

Finds type assertions which did forcely such as below:
```
func f() {
	var a interface{}
	_ = a.(int) // type assertion must be checked
}
```

* [linter] Add `gocritic`

Provides diagnostics that check for bugs, performance and style issues.

Signed-off-by: Julian Strobl <jmastr@mailbox.org>
2023-11-16 17:44:38 +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
}