-
Notifications
You must be signed in to change notification settings - Fork 15
/
migrations.go
37 lines (30 loc) · 1.12 KB
/
migrations.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 keeper
import (
"fmt"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
sdk "github.com/cosmos/cosmos-sdk/types"
v1 "github.com/burnt-labs/xion/x/xion/migrations/v1"
"github.com/burnt-labs/xion/x/xion/types"
)
type Migrator struct {
wasmOpsKeeper wasmtypes.ContractOpsKeeper
wasmViewKeeper wasmtypes.ViewKeeper
aaKeeper types.AbstractAccountKeeper
}
func NewMigrator(wasmOpsKeeper wasmtypes.ContractOpsKeeper, wasmViewKeeper wasmtypes.ViewKeeper, aaKeeper types.AbstractAccountKeeper) Migrator {
return Migrator{wasmOpsKeeper: wasmOpsKeeper, wasmViewKeeper: wasmViewKeeper, aaKeeper: aaKeeper}
}
func (m Migrator) Migrate1to2(ctx sdk.Context) error {
switch ctx.ChainID() {
case "xion-mainnet-1":
return nil // no migration needed
case "xion-testnet-1":
newCodeID := uint64(327)
return v1.MigrateStore(ctx, m.wasmOpsKeeper, m.wasmViewKeeper, m.aaKeeper, newCodeID)
case "xion-1": // integration tests chainID
newCodeID := uint64(2)
return v1.MigrateStore(ctx, m.wasmOpsKeeper, m.wasmViewKeeper, m.aaKeeper, newCodeID)
default:
return fmt.Errorf("unsupported chain id: %s", ctx.ChainID())
}
}