-
Notifications
You must be signed in to change notification settings - Fork 12
/
proposal.go
27 lines (23 loc) · 923 Bytes
/
proposal.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
package crosschain
import (
"fmt"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
"github.com/functionx/fx-core/v3/x/crosschain/keeper"
"github.com/functionx/fx-core/v3/x/crosschain/types"
)
func NewChainProposalHandler(k keeper.RouterKeeper) govtypes.Handler {
return func(ctx sdk.Context, content govtypes.Content) error {
switch c := content.(type) {
case *types.UpdateChainOraclesProposal:
router := k.Router()
if !router.HasRoute(c.ChainName) {
return sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, fmt.Sprintf("Unrecognized cross chain type: %s", c.ChainName))
}
return router.GetRoute(c.ChainName).ProposalServer.UpdateChainOraclesProposal(ctx, c)
default:
return sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "Unrecognized %s proposal content type: %T", types.ModuleName, c)
}
}
}