-
Notifications
You must be signed in to change notification settings - Fork 181
/
migrate.go
50 lines (45 loc) · 1.5 KB
/
migrate.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
package v0_11
import (
sdk "github.com/okex/exchain/libs/cosmos-sdk/types"
"github.com/okex/exchain/x/common"
"github.com/okex/exchain/x/dex/legacy/v0_10"
)
func Migrate(oldGenState v0_10.GenesisState) GenesisState {
params := Params{
ListFee: oldGenState.Params.ListFee,
TransferOwnershipFee: oldGenState.Params.TransferOwnershipFee,
DelistMaxDepositPeriod: oldGenState.Params.DelistMaxDepositPeriod,
DelistMinDeposit: oldGenState.Params.DelistMinDeposit,
DelistVotingPeriod: oldGenState.Params.DelistVotingPeriod,
WithdrawPeriod: oldGenState.Params.WithdrawPeriod,
RegisterOperatorFee: sdk.NewDecCoinFromDec(common.NativeToken, sdk.ZeroDec()),
}
operatorMap := make(map[string]struct{})
var operators DEXOperators
var maxTokenPairID uint64 = 0
for _, pair := range oldGenState.TokenPairs {
if pair.ID > maxTokenPairID {
maxTokenPairID = pair.ID
}
if _, exist := operatorMap[pair.Owner.String()]; exist {
continue
}
operatorMap[pair.Owner.String()] = struct{}{}
operator := DEXOperator{
Address: pair.Owner,
HandlingFeeAddress: pair.Owner,
Website: "",
InitHeight: pair.BlockHeight,
TxHash: "",
}
operators = append(operators, operator)
}
return GenesisState{
Params: params,
TokenPairs: oldGenState.TokenPairs,
WithdrawInfos: oldGenState.WithdrawInfos,
ProductLocks: oldGenState.ProductLocks,
Operators: operators,
MaxTokenPairID: maxTokenPairID,
}
}