wormchain: tokenbridge: Don't allow self-registration

Don't allow registering an emitter for wormhole chain on wormhole chain.
This commit is contained in:
Chirantan Ekbote 2022-08-23 17:02:09 +09:00 committed by Chirantan Ekbote
parent 5666ee51b5
commit 832a72057d
2 changed files with 5 additions and 0 deletions

View File

@ -84,6 +84,10 @@ func (k msgServer) ExecuteGovernanceVAA(goCtx context.Context, msg *types.MsgExe
chainId := binary.BigEndian.Uint16(payload[:2])
bridgeEmitter := payload[2:34]
if chainId == uint16(wormholeConfig.ChainId) {
return nil, types.ErrRegisterWormholeChain
}
if _, found := k.GetChainRegistration(ctx, uint32(chainId)); found {
return nil, types.ErrChainAlreadyRegistered
}

View File

@ -38,4 +38,5 @@ var (
ErrAmountTooHigh = sdkerrors.Register(ModuleName, 1133, "the amount would exceed the bridges capacity of u64")
ErrAssetMetaRollback = sdkerrors.Register(ModuleName, 1134, "asset meta must have a higher sequence than the last update")
ErrNegativeFee = sdkerrors.Register(ModuleName, 1135, "fee cannot be negative")
ErrRegisterWormholeChain = sdkerrors.Register(ModuleName, 1136, "cannot register an emitter for wormhole-chain on wormhole-chain")
)