-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
37 lines (29 loc) · 1.02 KB
/
main.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
package v3
import (
"fmt"
"github.com/cosmos/cosmos-sdk/codec"
storetypes "github.com/cosmos/cosmos-sdk/store/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/rarimo/rarimo-core/x/rarimocore/types"
)
func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) error {
ctx.Logger().Info(fmt.Sprintf("Performing v0.0.6 %s module migrations", types.ModuleName))
params := types.Params{}
b := ctx.KVStore(storeKey).Get(types.KeyPrefix(types.ParamsKey))
cdc.MustUnmarshal(b, ¶ms)
params.KeyECDSA = removeKeyConstantPrefix(params.KeyECDSA)
for _, party := range params.Parties {
party.PubKey = removeKeyConstantPrefix(party.PubKey)
}
b = cdc.MustMarshal(¶ms)
ctx.KVStore(storeKey).Set(types.KeyPrefix(types.ParamsKey), b)
return nil
}
func removeKeyConstantPrefix(key string) string {
// Values are valid in params
if b := hexutil.MustDecode(key); len(b) > 0 && b[0] == 0x04 {
return hexutil.Encode(b[1:])
}
return key
}