-
Notifications
You must be signed in to change notification settings - Fork 96
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 #290 from terra-money/feat/v2.11/cosmos-sdk/v0.47.10
feat(v2.11): cosmos sdk/v0.47.10
- Loading branch information
Showing
11 changed files
with
200 additions
and
112 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -220,4 +220,5 @@ const ( | |
Upgrade2_8 = "v2.8" | ||
Upgrade2_9 = "v2.9" | ||
Upgrade2_10 = "v2.10" | ||
Upgrade2_11 = "v2.11" | ||
) |
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,58 @@ | ||
package v2_11 | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/types/module" | ||
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" | ||
ibctransferkeeper "github.com/cosmos/ibc-go/v7/modules/apps/transfer/keeper" | ||
transfertypes "github.com/cosmos/ibc-go/v7/modules/apps/transfer/types" | ||
custombankkeeper "github.com/terra-money/core/v2/x/bank/keeper" | ||
) | ||
|
||
type EscrowUpdate struct { | ||
EscrowAddress sdk.AccAddress | ||
Assets []sdk.Coin | ||
} | ||
|
||
func CreateUpgradeHandler( | ||
mm *module.Manager, | ||
cfg module.Configurator, | ||
bankKeeper custombankkeeper.Keeper, | ||
transferKeeper ibctransferkeeper.Keeper, | ||
) upgradetypes.UpgradeHandler { | ||
return func(ctx sdk.Context, plan upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) { | ||
if ctx.ChainID() != "phoenix-1" { | ||
return mm.RunMigrations(ctx, cfg, vm) | ||
} | ||
// This slice is initialized with objects that describe the escrow account address and the coins that need to be minted to fix the discrepancy. | ||
// To find the escrow account and address have been used the following software: | ||
// https://github.com/strangelove-ventures/escrow-checker/commit/adf0d867e2210c9ff0a27d8dff1c74ed0c8a00dc | ||
updates := []EscrowUpdate{ | ||
{ | ||
EscrowAddress: sdk.AccAddress("terra1s308jav50mgct9x4f87u23w2tfe8q6qe45y7s4"), | ||
Assets: []sdk.Coin{sdk.NewCoin("ibc/815FC81EB6BD612206BD9A9909A02F7691D24A5B97CDFE2124B1BDCA9D4AB14C", sdk.NewInt(1000000000))}, | ||
}, | ||
} | ||
|
||
for _, update := range updates { | ||
for _, coin := range update.Assets { | ||
coins := sdk.NewCoins(coin) | ||
|
||
if err := bankKeeper.MintCoins(ctx, transfertypes.ModuleName, coins); err != nil { | ||
return nil, err | ||
} | ||
|
||
if err := bankKeeper.SendCoinsFromModuleToAccount(ctx, transfertypes.ModuleName, update.EscrowAddress, coins); err != nil { | ||
return nil, err | ||
} | ||
|
||
// For ibc-go v7+ you will also need to update the transfer module's store for the total escrow amounts. | ||
currentTotalEscrow := transferKeeper.GetTotalEscrowForDenom(ctx, coin.GetDenom()) | ||
newTotalEscrow := currentTotalEscrow.Add(coin) | ||
transferKeeper.SetTotalEscrowForDenom(ctx, newTotalEscrow) | ||
} | ||
} | ||
|
||
return mm.RunMigrations(ctx, cfg, 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
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
Oops, something went wrong.