-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
2,674 additions
and
190 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package v2 | ||
|
||
import ( | ||
"context" | ||
|
||
upgradetypes "cosmossdk.io/x/upgrade/types" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
) | ||
|
||
// UpgradeName is the upgrade version name | ||
const UpgradeName = "v2" | ||
|
||
// CreateUpgradeHandler creates the upgrade handler | ||
func CreateUpgradeHandler( | ||
mm *module.Manager, | ||
configurator module.Configurator, | ||
) upgradetypes.UpgradeHandler { | ||
return func(ctx context.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { | ||
return mm.RunMigrations(ctx, configurator, vm) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package keeper | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
v2 "github.com/sideprotocol/side/x/btcbridge/migrations/v2" | ||
) | ||
|
||
// Migrator is a struct for handling in-place store migrations | ||
type Migrator struct { | ||
keeper Keeper | ||
} | ||
|
||
// NewMigrator returns a new Migrator | ||
func NewMigrator(keeper Keeper) Migrator { | ||
return Migrator{keeper: keeper} | ||
} | ||
|
||
// Migrate1to2 migrates from version 1 to 2 | ||
func (m Migrator) Migrate1to2(ctx sdk.Context) error { | ||
return v2.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package v2 | ||
|
||
import ( | ||
storetypes "cosmossdk.io/store/types" | ||
"github.com/cosmos/cosmos-sdk/codec" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
"github.com/sideprotocol/side/x/btcbridge/types" | ||
) | ||
|
||
// MigrateStore migrates the x/btcbridge module state from the consensus version 1 to | ||
// version 2 | ||
func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) error { | ||
migrateParams(ctx, storeKey, cdc) | ||
|
||
return nil | ||
} | ||
|
||
// migrateParams migrates the params | ||
func migrateParams(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) { | ||
store := ctx.KVStore(storeKey) | ||
|
||
// get current params | ||
var paramsV1 types.ParamsV1 | ||
bz := store.Get(types.ParamsStoreKey) | ||
cdc.MustUnmarshal(bz, ¶msV1) | ||
|
||
// build new params | ||
params := &types.Params{ | ||
Confirmations: paramsV1.Confirmations, | ||
MaxAcceptableBlockDepth: paramsV1.MaxAcceptableBlockDepth, | ||
BtcVoucherDenom: paramsV1.BtcVoucherDenom, | ||
DepositEnabled: paramsV1.DepositEnabled, | ||
WithdrawEnabled: paramsV1.WithdrawEnabled, | ||
TrustedNonBtcRelayers: paramsV1.TrustedNonBtcRelayers, | ||
Vaults: paramsV1.Vaults, | ||
WithdrawParams: paramsV1.WithdrawParams, | ||
ProtocolLimits: paramsV1.ProtocolLimits, | ||
ProtocolFees: paramsV1.ProtocolFees, | ||
TssParams: types.TSSParams{ | ||
DkgTimeoutPeriod: paramsV1.TssParams.DkgTimeoutPeriod, | ||
ParticipantUpdateTransitionPeriod: paramsV1.TssParams.ParticipantUpdateTransitionPeriod, | ||
}, | ||
} | ||
|
||
params.TrustedFeeProviders = paramsV1.TrustedOracles | ||
params.TrustedBtcRelayers = []string{} | ||
|
||
bz = cdc.MustMarshal(params) | ||
store.Set(types.ParamsStoreKey, bz) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.