-
Notifications
You must be signed in to change notification settings - Fork 12
/
proposal_legacy.go
31 lines (27 loc) · 1.12 KB
/
proposal_legacy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// nolint:staticcheck
package crosschain
import (
"fmt"
errorsmod "cosmossdk.io/errors"
sdk "github.com/cosmos/cosmos-sdk/types"
errortypes "github.com/cosmos/cosmos-sdk/types/errors"
govv1betal "github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
"github.com/functionx/fx-core/v4/x/crosschain/keeper"
"github.com/functionx/fx-core/v4/x/crosschain/types"
)
// NewCrosschainProposalHandler
// Deprecated: instead of defining gov router proposal handlers, the v0.46 gov execution models is based on sdk.Msgs
func NewCrosschainProposalHandler(k keeper.RouterKeeper) govv1betal.Handler {
return func(ctx sdk.Context, content govv1betal.Content) error {
switch c := content.(type) {
case *types.UpdateChainOraclesProposal:
router := k.Router()
if !router.HasRoute(c.ChainName) {
return errorsmod.Wrap(errortypes.ErrUnknownRequest, fmt.Sprintf("Unrecognized cross chain type: %s", c.ChainName))
}
return router.GetRoute(c.ChainName).ProposalServer.UpdateChainOraclesProposal(ctx, c)
default:
return errorsmod.Wrapf(errortypes.ErrUnknownRequest, "Unrecognized %s proposal content type: %T", types.ModuleName, c)
}
}
}