mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-11-26 15:35:46 +00:00
aggregating error messages
Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com>
This commit is contained in:
parent
b1c4d11ccf
commit
26455f5532
@ -51,21 +51,21 @@ func (cm CheckMachineDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate
|
||||
func (cm CheckMachineDecorator) handleNotarizeAsset(ctx sdk.Context, notarizeMsg *assettypes.MsgNotarizeAsset) (sdk.Context, error) {
|
||||
_, found := cm.mk.GetMachineIndexByAddress(ctx, notarizeMsg.GetCreator())
|
||||
if !found {
|
||||
return ctx, errorsmod.Wrapf(machinetypes.ErrMachineNotFound, "error during CheckTx or ReCheckTx")
|
||||
return ctx, errorsmod.Wrapf(machinetypes.ErrMachineNotFound, ErrorAnteContext)
|
||||
}
|
||||
return ctx, nil
|
||||
}
|
||||
|
||||
func (cm CheckMachineDecorator) handleAttestMachine(ctx sdk.Context, attestMsg *machinetypes.MsgAttestMachine) (sdk.Context, error) {
|
||||
if attestMsg.GetCreator() != attestMsg.Machine.GetAddress() {
|
||||
return ctx, errorsmod.Wrapf(machinetypes.ErrMachineIsNotCreator, "error during CheckTx or ReCheckTx")
|
||||
return ctx, errorsmod.Wrapf(machinetypes.ErrMachineIsNotCreator, ErrorAnteContext)
|
||||
}
|
||||
_, activated, found := cm.mk.GetTrustAnchor(ctx, attestMsg.Machine.MachineId)
|
||||
if !found {
|
||||
return ctx, errorsmod.Wrapf(machinetypes.ErrTrustAnchorNotFound, "error during CheckTx or ReCheckTx")
|
||||
return ctx, errorsmod.Wrapf(machinetypes.ErrTrustAnchorNotFound, ErrorAnteContext)
|
||||
}
|
||||
if activated {
|
||||
return ctx, errorsmod.Wrapf(machinetypes.ErrTrustAnchorAlreadyInUse, "error during CheckTx or ReCheckTx")
|
||||
return ctx, errorsmod.Wrapf(machinetypes.ErrTrustAnchorAlreadyInUse, ErrorAnteContext)
|
||||
}
|
||||
return ctx, nil
|
||||
}
|
||||
@ -73,7 +73,7 @@ func (cm CheckMachineDecorator) handleAttestMachine(ctx sdk.Context, attestMsg *
|
||||
func (cm CheckMachineDecorator) handlePopResult(ctx sdk.Context, popMsg *daotypes.MsgReportPopResult) (sdk.Context, error) {
|
||||
_, found := cm.mk.GetMachineIndexByAddress(ctx, popMsg.GetCreator())
|
||||
if !found {
|
||||
return ctx, errorsmod.Wrapf(machinetypes.ErrMachineNotFound, "error during CheckTx or ReCheckTx")
|
||||
return ctx, errorsmod.Wrapf(machinetypes.ErrMachineNotFound, ErrorAnteContext)
|
||||
}
|
||||
return ctx, nil
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ func (cmad CheckReissuanceDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simu
|
||||
isValid := cmad.dk.IsValidReissuanceProposal(ctx, MsgProposal)
|
||||
if !isValid {
|
||||
util.GetAppLogger().Info(ctx, anteHandlerTag+"rejected reissuance proposal")
|
||||
return ctx, errorsmod.Wrapf(daotypes.ErrReissuanceProposal, "error during CheckTx or ReCheckTx")
|
||||
return ctx, errorsmod.Wrapf(daotypes.ErrReissuanceProposal, ErrorAnteContext)
|
||||
}
|
||||
util.GetAppLogger().Debug(ctx, anteHandlerTag+"accepted reissuance proposal: "+MsgProposal.String())
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ func (cv CheckValidatorDecorator) handleMsg(ctx sdk.Context, msg sdk.Msg) (_ sdk
|
||||
signer := msg.GetSigners()[0]
|
||||
_, found := cv.sk.GetValidator(ctx, sdk.ValAddress(signer))
|
||||
if !found {
|
||||
return ctx, errorsmod.Wrapf(types.ErrRestrictedMsg, "error during CheckTx or ReCheckTx")
|
||||
return ctx, errorsmod.Wrapf(types.ErrRestrictedMsg, ErrorAnteContext)
|
||||
}
|
||||
return ctx, nil
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ func NewDeductFeeDecorator(ak AccountKeeper, bk authtypes.BankKeeper, fk Feegran
|
||||
func checkTxFee(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, error) {
|
||||
feeTx, ok := tx.(sdk.FeeTx)
|
||||
if !ok {
|
||||
return nil, errorsmod.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx")
|
||||
return nil, errorsmod.Wrap(sdkerrors.ErrTxDecode, ErrorTxFeeTx)
|
||||
}
|
||||
|
||||
feeCoins := feeTx.GetFee()
|
||||
@ -74,7 +74,7 @@ func checkTxFee(ctx sdk.Context, tx sdk.Tx) (sdk.Coins, error) {
|
||||
func (dfd DeductFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool, next sdk.AnteHandler) (sdk.Context, error) {
|
||||
feeTx, ok := tx.(sdk.FeeTx)
|
||||
if !ok {
|
||||
return ctx, errorsmod.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx")
|
||||
return ctx, errorsmod.Wrap(sdkerrors.ErrTxDecode, ErrorTxFeeTx)
|
||||
}
|
||||
|
||||
if !simulate && ctx.BlockHeight() > 0 && feeTx.GetGas() == 0 {
|
||||
@ -102,7 +102,7 @@ func (dfd DeductFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bo
|
||||
func (dfd DeductFeeDecorator) checkDeductFee(ctx sdk.Context, sdkTx sdk.Tx, fee sdk.Coins) error {
|
||||
feeTx, ok := sdkTx.(sdk.FeeTx)
|
||||
if !ok {
|
||||
return errorsmod.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx")
|
||||
return errorsmod.Wrap(sdkerrors.ErrTxDecode, ErrorTxFeeTx)
|
||||
}
|
||||
|
||||
if addr := dfd.accountKeeper.GetModuleAddress(authtypes.FeeCollectorName); addr == nil {
|
||||
|
||||
6
app/ante/error.go
Normal file
6
app/ante/error.go
Normal file
@ -0,0 +1,6 @@
|
||||
package ante
|
||||
|
||||
var (
|
||||
ErrorAnteContext = "error during CheckTx or ReCheckTx"
|
||||
ErrorTxFeeTx = "Tx must be a FeeTx"
|
||||
)
|
||||
@ -52,7 +52,7 @@ func (rcd RedeemClaimDecorator) handleCreateRedeemClaim(ctx sdk.Context, msg sdk
|
||||
balance := rcd.bk.GetBalance(ctx, addr, params.ClaimDenom)
|
||||
|
||||
if !balance.Amount.GTE(sdk.NewIntFromUint64(createRedeemClaimMsg.Amount)) {
|
||||
return ctx, errorsmod.Wrap(sdkerrors.ErrInsufficientFunds, "error during checkTx or reCheckTx")
|
||||
return ctx, errorsmod.Wrap(sdkerrors.ErrInsufficientFunds, ErrorAnteContext)
|
||||
}
|
||||
|
||||
return ctx, nil
|
||||
|
||||
5
errormsg/error.go
Normal file
5
errormsg/error.go
Normal file
@ -0,0 +1,5 @@
|
||||
package errormsg
|
||||
|
||||
var (
|
||||
ErrorInvalidCreator = "invalid creator address (%s)"
|
||||
)
|
||||
5
testutil/sample/error.go
Normal file
5
testutil/sample/error.go
Normal file
@ -0,0 +1,5 @@
|
||||
package sample
|
||||
|
||||
var (
|
||||
ErrorInvalidAddress = "invalid_address"
|
||||
)
|
||||
@ -4,6 +4,7 @@ import (
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/planetmint/planetmint-go/errormsg"
|
||||
)
|
||||
|
||||
const TypeMsgNotarizeAsset = "notarize_asset"
|
||||
@ -41,7 +42,7 @@ func (msg *MsgNotarizeAsset) GetSignBytes() []byte {
|
||||
func (msg *MsgNotarizeAsset) ValidateBasic() error {
|
||||
_, err := sdk.AccAddressFromBech32(msg.Creator)
|
||||
if err != nil {
|
||||
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
|
||||
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, errormsg.ErrorInvalidCreator, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -19,7 +19,7 @@ func TestMsgNotarizeAssetValidateBasic(t *testing.T) {
|
||||
{
|
||||
name: "invalid address",
|
||||
msg: MsgNotarizeAsset{
|
||||
Creator: "invalid_address",
|
||||
Creator: sample.ErrorInvalidAddress,
|
||||
},
|
||||
err: sdkerrors.ErrInvalidAddress,
|
||||
}, {
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/planetmint/planetmint-go/errormsg"
|
||||
)
|
||||
|
||||
const TypeMsgDistributionRequest = "distribution_request"
|
||||
@ -41,7 +42,7 @@ func (msg *MsgDistributionRequest) GetSignBytes() []byte {
|
||||
func (msg *MsgDistributionRequest) ValidateBasic() error {
|
||||
_, err := sdk.AccAddressFromBech32(msg.Creator)
|
||||
if err != nil {
|
||||
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
|
||||
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, errormsg.ErrorInvalidCreator, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/planetmint/planetmint-go/errormsg"
|
||||
)
|
||||
|
||||
const TypeMsgDistributionResult = "distribution_result"
|
||||
@ -47,7 +48,7 @@ func (msg *MsgDistributionResult) GetSignBytes() []byte {
|
||||
func (msg *MsgDistributionResult) ValidateBasic() error {
|
||||
_, err := sdk.AccAddressFromBech32(msg.Creator)
|
||||
if err != nil {
|
||||
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
|
||||
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, errormsg.ErrorInvalidCreator, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/planetmint/planetmint-go/errormsg"
|
||||
)
|
||||
|
||||
const TypeMsgInitPop = "init_pop"
|
||||
@ -44,7 +45,7 @@ func (msg *MsgInitPop) GetSignBytes() []byte {
|
||||
func (msg *MsgInitPop) ValidateBasic() error {
|
||||
_, err := sdk.AccAddressFromBech32(msg.Creator)
|
||||
if err != nil {
|
||||
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
|
||||
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, errormsg.ErrorInvalidCreator, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/planetmint/planetmint-go/testutil/sample"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@ -17,7 +18,7 @@ func TestMsgInitPop_ValidateBasic(t *testing.T) {
|
||||
{
|
||||
name: "invalid address",
|
||||
msg: MsgInitPop{
|
||||
Creator: "invalid_address",
|
||||
Creator: sample.ErrorInvalidAddress,
|
||||
},
|
||||
err: sdkerrors.ErrInvalidAddress,
|
||||
},
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/planetmint/planetmint-go/errormsg"
|
||||
)
|
||||
|
||||
const TypeMsgMintToken = "mint_token"
|
||||
@ -41,7 +42,7 @@ func (msg *MsgMintToken) GetSignBytes() []byte {
|
||||
func (msg *MsgMintToken) ValidateBasic() error {
|
||||
_, err := sdk.AccAddressFromBech32(msg.Creator)
|
||||
if err != nil {
|
||||
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
|
||||
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, errormsg.ErrorInvalidCreator, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/planetmint/planetmint-go/testutil/sample"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@ -17,7 +18,7 @@ func TestMsgMintToken_ValidateBasic(t *testing.T) {
|
||||
{
|
||||
name: "invalid address",
|
||||
msg: MsgMintToken{
|
||||
Creator: "invalid_address",
|
||||
Creator: sample.ErrorInvalidAddress,
|
||||
},
|
||||
err: sdkerrors.ErrInvalidAddress,
|
||||
},
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/planetmint/planetmint-go/errormsg"
|
||||
)
|
||||
|
||||
const TypeMsgReissueRDDLProposal = "reissue_rddl_proposal"
|
||||
@ -46,7 +47,7 @@ func (msg *MsgReissueRDDLProposal) GetSignBytes() []byte {
|
||||
func (msg *MsgReissueRDDLProposal) ValidateBasic() error {
|
||||
_, err := sdk.AccAddressFromBech32(msg.Creator)
|
||||
if err != nil {
|
||||
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
|
||||
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, errormsg.ErrorInvalidCreator, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/planetmint/planetmint-go/errormsg"
|
||||
)
|
||||
|
||||
const TypeMsgReissueRDDLResult = "reissue_rddl_result"
|
||||
@ -43,7 +44,7 @@ func (msg *MsgReissueRDDLResult) GetSignBytes() []byte {
|
||||
func (msg *MsgReissueRDDLResult) ValidateBasic() error {
|
||||
_, err := sdk.AccAddressFromBech32(msg.Creator)
|
||||
if err != nil {
|
||||
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
|
||||
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, errormsg.ErrorInvalidCreator, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/planetmint/planetmint-go/errormsg"
|
||||
)
|
||||
|
||||
const TypeMsgReportPopResult = "report_pop_result"
|
||||
@ -41,7 +42,7 @@ func (msg *MsgReportPopResult) GetSignBytes() []byte {
|
||||
func (msg *MsgReportPopResult) ValidateBasic() error {
|
||||
_, err := sdk.AccAddressFromBech32(msg.Creator)
|
||||
if err != nil {
|
||||
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
|
||||
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, errormsg.ErrorInvalidCreator, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/planetmint/planetmint-go/errormsg"
|
||||
)
|
||||
|
||||
const TypeMsgUpdateParams = "update_params"
|
||||
@ -41,7 +42,7 @@ func (msg *MsgUpdateParams) GetSignBytes() []byte {
|
||||
func (msg *MsgUpdateParams) ValidateBasic() error {
|
||||
_, err := sdk.AccAddressFromBech32(msg.Authority)
|
||||
if err != nil {
|
||||
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
|
||||
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, errormsg.ErrorInvalidCreator, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/planetmint/planetmint-go/testutil/sample"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@ -17,7 +18,7 @@ func TestMsgUpdateParams_ValidateBasic(t *testing.T) {
|
||||
{
|
||||
name: "invalid address",
|
||||
msg: MsgUpdateParams{
|
||||
Authority: "invalid_address",
|
||||
Authority: sample.ErrorInvalidAddress,
|
||||
},
|
||||
err: sdkerrors.ErrInvalidAddress,
|
||||
},
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/planetmint/planetmint-go/errormsg"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -51,7 +52,7 @@ func (msg *MsgCreateRedeemClaim) GetSignBytes() []byte {
|
||||
func (msg *MsgCreateRedeemClaim) ValidateBasic() error {
|
||||
_, err := sdk.AccAddressFromBech32(msg.Creator)
|
||||
if err != nil {
|
||||
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
|
||||
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, errormsg.ErrorInvalidCreator, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -97,7 +98,7 @@ func (msg *MsgUpdateRedeemClaim) GetSignBytes() []byte {
|
||||
func (msg *MsgUpdateRedeemClaim) ValidateBasic() error {
|
||||
_, err := sdk.AccAddressFromBech32(msg.Creator)
|
||||
if err != nil {
|
||||
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
|
||||
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, errormsg.ErrorInvalidCreator, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@ -136,7 +137,7 @@ func (msg *MsgConfirmRedeemClaim) GetSignBytes() []byte {
|
||||
func (msg *MsgConfirmRedeemClaim) ValidateBasic() error {
|
||||
_, err := sdk.AccAddressFromBech32(msg.Creator)
|
||||
if err != nil {
|
||||
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
|
||||
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, errormsg.ErrorInvalidCreator, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/planetmint/planetmint-go/testutil/sample"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@ -17,7 +18,7 @@ func TestMsgCreateRedeemClaim_ValidateBasic(t *testing.T) {
|
||||
{
|
||||
name: "invalid address",
|
||||
msg: MsgCreateRedeemClaim{
|
||||
Creator: "invalid_address",
|
||||
Creator: sample.ErrorInvalidAddress,
|
||||
},
|
||||
err: sdkerrors.ErrInvalidAddress,
|
||||
},
|
||||
@ -46,7 +47,7 @@ func TestMsgUpdateRedeemClaim_ValidateBasic(t *testing.T) {
|
||||
{
|
||||
name: "invalid address",
|
||||
msg: MsgUpdateRedeemClaim{
|
||||
Creator: "invalid_address",
|
||||
Creator: sample.ErrorInvalidAddress,
|
||||
},
|
||||
err: sdkerrors.ErrInvalidAddress,
|
||||
},
|
||||
@ -75,7 +76,7 @@ func TestMsgConfirmRedeemClaim_ValidateBasic(t *testing.T) {
|
||||
{
|
||||
name: "invalid address",
|
||||
msg: MsgConfirmRedeemClaim{
|
||||
Creator: "invalid_address",
|
||||
Creator: sample.ErrorInvalidAddress,
|
||||
},
|
||||
err: sdkerrors.ErrInvalidAddress,
|
||||
},
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/planetmint/planetmint-go/errormsg"
|
||||
)
|
||||
|
||||
const TypeMsgAttestMachine = "attest_machine"
|
||||
@ -41,7 +42,7 @@ func (msg *MsgAttestMachine) GetSignBytes() []byte {
|
||||
func (msg *MsgAttestMachine) ValidateBasic() error {
|
||||
_, err := sdk.AccAddressFromBech32(msg.Creator)
|
||||
if err != nil {
|
||||
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
|
||||
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, errormsg.ErrorInvalidCreator, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/planetmint/planetmint-go/testutil/sample"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@ -17,7 +18,7 @@ func TestMsgAttestMachineValidateBasic(t *testing.T) {
|
||||
{
|
||||
name: "invalid address",
|
||||
msg: MsgAttestMachine{
|
||||
Creator: "invalid_address",
|
||||
Creator: sample.ErrorInvalidAddress,
|
||||
},
|
||||
err: sdkerrors.ErrInvalidAddress,
|
||||
},
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/planetmint/planetmint-go/errormsg"
|
||||
)
|
||||
|
||||
const TypeMsgNotarizeLiquidAsset = "notarize_liquid_asset"
|
||||
@ -41,7 +42,7 @@ func (msg *MsgNotarizeLiquidAsset) GetSignBytes() []byte {
|
||||
func (msg *MsgNotarizeLiquidAsset) ValidateBasic() error {
|
||||
_, err := sdk.AccAddressFromBech32(msg.Creator)
|
||||
if err != nil {
|
||||
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
|
||||
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, errormsg.ErrorInvalidCreator, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/planetmint/planetmint-go/errormsg"
|
||||
)
|
||||
|
||||
const TypeMsgRegisterTrustAnchor = "register_trust_anchor"
|
||||
@ -41,7 +42,7 @@ func (msg *MsgRegisterTrustAnchor) GetSignBytes() []byte {
|
||||
func (msg *MsgRegisterTrustAnchor) ValidateBasic() error {
|
||||
_, err := sdk.AccAddressFromBech32(msg.Creator)
|
||||
if err != nil {
|
||||
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err)
|
||||
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, errormsg.ErrorInvalidCreator, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/planetmint/planetmint-go/testutil/sample"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@ -17,7 +18,7 @@ func TestMsgRegisterTrustAnchor_ValidateBasic(t *testing.T) {
|
||||
{
|
||||
name: "invalid address",
|
||||
msg: MsgRegisterTrustAnchor{
|
||||
Creator: "invalid_address",
|
||||
Creator: sample.ErrorInvalidAddress,
|
||||
},
|
||||
err: sdkerrors.ErrInvalidAddress,
|
||||
},
|
||||
|
||||
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/planetmint/planetmint-go/testutil/sample"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
@ -17,7 +18,7 @@ func TestMsgUpdateParams_ValidateBasic(t *testing.T) {
|
||||
{
|
||||
name: "invalid address",
|
||||
msg: MsgUpdateParams{
|
||||
Authority: "invalid_address",
|
||||
Authority: sample.ErrorInvalidAddress,
|
||||
},
|
||||
err: sdkerrors.ErrInvalidAddress,
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user