forked from CosmWasm/wasmd
-
Notifications
You must be signed in to change notification settings - Fork 9
/
genesis.go
60 lines (55 loc) · 1.66 KB
/
genesis.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package types
import (
sdk "github.com/Finschia/finschia-sdk/types"
sdkerrors "github.com/Finschia/finschia-sdk/types/errors"
wasmtypes "github.com/Finschia/wasmd/x/wasm/types"
)
func (gs GenesisState) ValidateBasic() error {
if err := gs.Params.ValidateBasic(); err != nil {
return sdkerrors.Wrap(err, "params")
}
for i := range gs.Codes {
if err := gs.Codes[i].ValidateBasic(); err != nil {
return sdkerrors.Wrapf(err, "code: %d", i)
}
}
for i := range gs.Contracts {
if err := gs.Contracts[i].ValidateBasic(); err != nil {
return sdkerrors.Wrapf(err, "contract: %d", i)
}
}
for i := range gs.Sequences {
if err := gs.Sequences[i].ValidateBasic(); err != nil {
return sdkerrors.Wrapf(err, "sequence: %d", i)
}
}
for i := range gs.GenMsgs {
if err := gs.GenMsgs[i].ValidateBasic(); err != nil {
return sdkerrors.Wrapf(err, "gen message: %d", i)
}
}
for i, addr := range gs.InactiveContractAddresses {
if _, err := sdk.AccAddressFromBech32(addr); err != nil {
return sdkerrors.Wrapf(err, "inactive contract address: %d", i)
}
}
return nil
}
// RawWasmState convert to wasm genesis state for vanilla import.
// Custom data models for privileged contracts are not included
func (gs GenesisState) RawWasmState() wasmtypes.GenesisState {
params := wasmtypes.Params{
CodeUploadAccess: gs.Params.CodeUploadAccess,
InstantiateDefaultPermission: gs.Params.InstantiateDefaultPermission,
}
return wasmtypes.GenesisState{
Params: params,
Codes: gs.Codes,
Contracts: gs.Contracts,
Sequences: gs.Sequences,
GenMsgs: gs.GenMsgs,
}
}
func ValidateGenesis(data GenesisState) error {
return data.ValidateBasic()
}