Skip to content

Commit 43dfc21

Browse files
committed
enhance vault type check
1 parent 33b6d2e commit 43dfc21

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

x/btcbridge/types/asset.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,8 @@ func AssetTypeFromDenom(denom string, p Params) AssetType {
1717

1818
return AssetType_ASSET_TYPE_UNSPECIFIED
1919
}
20+
21+
// SupportedAssetTypes returns the currently supported asset types
22+
func SupportedAssetTypes() []AssetType {
23+
return []AssetType{AssetType_ASSET_TYPE_BTC, AssetType_ASSET_TYPE_RUNES}
24+
}

x/btcbridge/types/msg_initiate_dkg.go

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package types
22

33
import (
44
"encoding/base64"
5+
"slices"
56

67
errorsmod "cosmossdk.io/errors"
78
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
@@ -43,22 +44,8 @@ func (m *MsgInitiateDKG) ValidateBasic() error {
4344
participants[p.ConsensusPubkey] = true
4445
}
4546

46-
if len(m.VaultTypes) == 0 {
47-
return errorsmod.Wrap(ErrInvalidDKGParams, "vault types can not be empty")
48-
}
49-
50-
vaultTypes := make(map[AssetType]bool)
51-
52-
for _, t := range m.VaultTypes {
53-
if t == AssetType_ASSET_TYPE_UNSPECIFIED {
54-
return errorsmod.Wrap(ErrInvalidDKGParams, "invalid vault type")
55-
}
56-
57-
if vaultTypes[t] {
58-
return errorsmod.Wrap(ErrInvalidDKGParams, "duplicate vault type")
59-
}
60-
61-
vaultTypes[t] = true
47+
if !slices.Equal(m.VaultTypes, SupportedAssetTypes()) {
48+
return errorsmod.Wrap(ErrInvalidDKGParams, "incorrect vault types")
6249
}
6350

6451
if m.EnableTransfer {

0 commit comments

Comments
 (0)