wormchain: tokenbridge: Don't register asset meta for unknown chains

This commit is contained in:
Chirantan Ekbote 2022-08-23 17:10:59 +09:00 committed by Chirantan Ekbote
parent 832a72057d
commit 8f70fd1719
2 changed files with 6 additions and 1 deletions

View File

@ -52,7 +52,7 @@ func (k msgServer) ExecuteVAA(goCtx context.Context, msg *types.MsgExecuteVAA) (
// Check if emitter is a registered chain
registration, found := k.GetChainRegistration(ctx, uint32(v.EmitterChain))
if !found {
return nil, types.ErrUnregisteredEmitter
return nil, types.ErrUnregisteredChain
}
if !bytes.Equal(v.EmitterAddress[:], registration.EmitterAddress) {
return nil, types.ErrUnregisteredEmitter
@ -200,6 +200,10 @@ func (k msgServer) ExecuteVAA(goCtx context.Context, msg *types.MsgExecuteVAA) (
return nil, types.ErrNativeAssetRegistration
}
if _, found := k.GetChainRegistration(ctx, uint32(tokenChain)); !found {
return nil, types.ErrUnregisteredEmitter
}
identifier := types.GetWrappedCoinIdentifier(tokenChain, tokenAddress)
rollBackProtection, found := k.GetCoinMetaRollbackProtection(ctx, identifier)
if found && rollBackProtection.LastUpdateSequence >= v.Sequence {

View File

@ -39,4 +39,5 @@ var (
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")
ErrUnregisteredChain = sdkerrors.Register(ModuleName, 1138, "chain is not registered")
)