-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39 from rarimo/feature/handler-v1.1.1-rc6
Feature/handler v1.1.4-rc6
- Loading branch information
Showing
7 changed files
with
684 additions
and
20 deletions.
There are no files selected for viewing
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
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,24 @@ | ||
package keeper | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
v2 "github.com/rarimo/rarimo-core/x/rootupdater/migrations/v2" | ||
) | ||
|
||
type Migrator struct { | ||
keeper Keeper | ||
} | ||
|
||
func NewMigrator(keeper Keeper) Migrator { | ||
return Migrator{ | ||
keeper: keeper, | ||
} | ||
} | ||
|
||
func (m Migrator) Migrate1to2(ctx sdk.Context) error { | ||
if err := v2.MigrateStore(ctx, m.keeper.storeKey, m.keeper.cdc); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} |
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,35 @@ | ||
package v2 | ||
|
||
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/rarimo/rarimo-core/x/rootupdater/types" | ||
) | ||
|
||
func MigrateStore(ctx sdk.Context, storeKey storetypes.StoreKey, cdc codec.BinaryCodec) error { | ||
ctx.Logger().Info(fmt.Sprintf("Performing v1.1.4-rc6 %s module migrations", types.ModuleName)) | ||
|
||
store := ctx.KVStore(storeKey) | ||
|
||
oldParamsBytes := store.Get(types.KeyPrefix(types.ParamsKey)) | ||
store.Delete(types.KeyPrefix(types.ParamsKey)) | ||
|
||
oldParams := OldParamas{} | ||
cdc.MustUnmarshal(oldParamsBytes, &oldParams) | ||
params := types.Params{ | ||
DestinationContractAddress: "0x2af05993a27df83094a963af64b5d25296230544", | ||
SourceContractAddress: oldParams.ContractAddress, | ||
Root: oldParams.Root, | ||
RootTimestamp: oldParams.RootTimestamp, | ||
LastSignedRootIndex: oldParams.LastSignedRootIndex, | ||
LastSignedRoot: oldParams.LastSignedRoot, | ||
BlockHeight: oldParams.BlockHeight, | ||
EventName: oldParams.EventName, | ||
} | ||
|
||
store.Set(types.KeyPrefix(types.ParamsKey), cdc.MustMarshal(¶ms)) | ||
|
||
return nil | ||
} |
Oops, something went wrong.