-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* prepare v11.14.0 * lint * interchain-test
- Loading branch information
1 parent
ee7ad6f
commit 8d68d5e
Showing
5 changed files
with
107 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package v11_14_0 | ||
|
||
import ( | ||
store "github.com/cosmos/cosmos-sdk/store/types" | ||
|
||
"github.com/persistenceOne/persistenceCore/v11/app/upgrades" | ||
) | ||
|
||
const ( | ||
// UpgradeName defines the on-chain upgrade name. | ||
UpgradeName = "v11.14.0" | ||
) | ||
|
||
var Upgrade = upgrades.Upgrade{ | ||
UpgradeName: UpgradeName, | ||
CreateUpgradeHandler: CreateUpgradeHandler, | ||
StoreUpgrades: store.StoreUpgrades{}, | ||
} |
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,55 @@ | ||
package v11_14_0 | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" | ||
"github.com/persistenceOne/pstake-native/v2/x/liquidstakeibc/keeper" | ||
liquidstakeibctypes "github.com/persistenceOne/pstake-native/v2/x/liquidstakeibc/types" | ||
|
||
"github.com/persistenceOne/persistenceCore/v11/app/upgrades" | ||
) | ||
|
||
func CreateUpgradeHandler(args upgrades.UpgradeHandlerArgs) upgradetypes.UpgradeHandler { | ||
return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { | ||
ctx.Logger().Info("running module migrations...") | ||
|
||
RemoveStargazeUnbondedBalance(ctx, args.Keepers.LiquidStakeIBCKeeper) | ||
|
||
return args.ModuleManager.RunMigrations(ctx, args.Configurator, vm) | ||
} | ||
} | ||
|
||
func RemoveStargazeUnbondedBalance(ctx sdk.Context, liquidStakeIBCKeeper *keeper.Keeper) { | ||
ctx.Logger().Info("starting to move tokens...") | ||
|
||
// as per https://github.com/persistenceOne/pstake-native/issues/853 | ||
chainID := "stargaze-1" | ||
epoch := int64(582) | ||
stkAmt := sdk.NewCoin("stk/ustars", sdk.NewInt(60621412694)) | ||
unbondAmt := sdk.NewCoin("ustars", sdk.NewInt(62810179898)) | ||
refillerAddr := "persistence1fp6qhht94pmfdq9h94dvw0tnmnlf2vutnlu7pt" | ||
|
||
ctx.Logger().Info("set user unbonding...") | ||
liquidStakeIBCKeeper.SetUserUnbonding(ctx, &liquidstakeibctypes.UserUnbonding{ | ||
ChainId: chainID, | ||
EpochNumber: epoch, | ||
Address: refillerAddr, | ||
StkAmount: stkAmt, | ||
UnbondAmount: unbondAmt, | ||
}) | ||
|
||
ctx.Logger().Info("set epoch unbonding...") | ||
liquidStakeIBCKeeper.SetUnbonding(ctx, &liquidstakeibctypes.Unbonding{ | ||
ChainId: chainID, | ||
EpochNumber: epoch, | ||
MatureTime: ctx.BlockTime(), | ||
BurnAmount: stkAmt, | ||
UnbondAmount: unbondAmt, | ||
IbcSequenceId: "", | ||
State: 2, | ||
}) | ||
|
||
ctx.Logger().Info("done remove stargaze unbonded balance...") | ||
|
||
} |
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,30 @@ | ||
package v11_14_0_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/CosmWasm/wasmd/x/wasm" | ||
dbm "github.com/cometbft/cometbft-db" | ||
"github.com/cometbft/cometbft/libs/log" | ||
tmproto "github.com/cometbft/cometbft/proto/tendermint/types" | ||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" | ||
"github.com/cosmos/cosmos-sdk/types" | ||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/persistenceOne/persistenceCore/v11/app" | ||
v11_14_0 "github.com/persistenceOne/persistenceCore/v11/app/upgrades/v11.14.0" | ||
) | ||
|
||
func TestRemoveStargazeUnbondedBalance(t *testing.T) { | ||
testApp := app.NewApplication(log.NewNopLogger(), dbm.NewMemDB(), nil, true, simtestutil.NewAppOptionsWithFlagHome(""), []wasm.Option{}) | ||
ctx := testApp.NewContext(true, tmproto.Header{}) | ||
v11_14_0.RemoveStargazeUnbondedBalance(ctx, testApp.LiquidStakeIBCKeeper) | ||
|
||
unbonding, ok := testApp.LiquidStakeIBCKeeper.GetUnbonding(ctx, "stargaze-1", 582) | ||
require.True(t, ok) | ||
require.Equal(t, types.NewInt(62810179898), unbonding.UnbondAmount.Amount) | ||
|
||
userUnbonding, ok := testApp.LiquidStakeIBCKeeper.GetUserUnbonding(ctx, "stargaze-1", "persistence1fp6qhht94pmfdq9h94dvw0tnmnlf2vutnlu7pt", 582) | ||
require.True(t, ok) | ||
require.Equal(t, types.NewInt(62810179898), userUnbonding.UnbondAmount.Amount) | ||
} |
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