Skip to content

Commit 7a117b9

Browse files
author
hard-nett
committed
bump v4 upgrade
1 parent 9820519 commit 7a117b9

File tree

2 files changed

+47
-38
lines changed

2 files changed

+47
-38
lines changed

app/upgrades/v4/headstash-patch.go

Lines changed: 40 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,56 @@
11
package v4
22

33
import (
4-
"fmt"
54
"strconv"
65
"strings"
76

87
sdk "github.com/cosmos/cosmos-sdk/types"
98

109
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
1110
distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
12-
1311
"github.com/terpnetwork/terp-core/v2/app/upgrades"
12+
13+
v3 "github.com/terpnetwork/terp-core/v2/app/upgrades/v3"
1414
)
1515

16-
// revert headstash allocation by depositing funds back into community pool
17-
func ReturnFundsToCommunityPool(ctx sdk.Context, dk keepers.DistrKeeper, bk keepers.BankKeeper) error {
18-
19-
headstashes := GetHeadstashPayments()
20-
21-
nativeDenom := upgrades.GetChainsDenomToken(ctx.ChainID())
22-
nativeFeeDenom := upgrades.GetChainsFeeDenomToken(ctx.ChainID())
23-
24-
for _, headstash := range headstashes {
25-
addr, err := sdk.AccAddressFromBech32(headstash[0])
26-
if err != nil {
27-
panic(err)
28-
}
29-
// defines the value associated with a given address
30-
amount, err := strconv.ParseInt(strings.TrimSpace(headstash[1]), 10, 64)
31-
if err != nil {
32-
panic(err)
33-
}
34-
terpcoins := sdk.NewCoins(
35-
sdk.NewInt64Coin(nativeDenom, amount),
36-
)
37-
thiolcoins := sdk.NewCoins(
38-
sdk.NewInt64Coin(nativeFeeDenom, amount),
39-
)
40-
if err := dsk.FundCommunityPool(ctx, terpcoins, addr); err != nil {
41-
panic(err)
42-
}
43-
if err := dsk.FundCommunityPool(ctx, thiolcoins, addr); err != nil {
44-
panic(err)
45-
}
46-
total += amount
47-
}
16+
// revert headstash allocation by depositing funds back into community pool
17+
func ReturnFundsToCommunityPool(
18+
ctx sdk.Context,
19+
dk distrkeeper.Keeper,
20+
bk bankkeeper.Keeper,
21+
) {
22+
23+
headstashes := v3.GetHeadstashPayments()
24+
total := int64(0)
25+
26+
nativeDenom := upgrades.GetChainsDenomToken(ctx.ChainID())
27+
nativeFeeDenom := upgrades.GetChainsFeeDenomToken(ctx.ChainID())
4828

29+
for _, headstash := range headstashes {
30+
addr, err := sdk.AccAddressFromBech32(headstash[0])
31+
if err != nil {
32+
panic(err)
33+
}
34+
// defines the value associated with a given address
35+
amount, err := strconv.ParseInt(strings.TrimSpace(headstash[1]), 10, 64)
36+
if err != nil {
37+
panic(err)
38+
}
39+
terpcoins := sdk.NewCoins(
40+
sdk.NewInt64Coin(nativeDenom, amount),
41+
)
42+
thiolcoins := sdk.NewCoins(
43+
sdk.NewInt64Coin(nativeFeeDenom, amount),
44+
)
45+
if err := dk.FundCommunityPool(ctx, terpcoins, addr); err != nil {
46+
panic(err)
47+
}
48+
if err := dk.FundCommunityPool(ctx, thiolcoins, addr); err != nil {
49+
panic(err)
50+
}
51+
total += amount
4952
}
5053

51-
// TODO: handle headstash-patch contract upload & instantiation
54+
}
55+
56+
// TODO: handle headstash-patch contract upload & instantiation

app/upgrades/v4/upgrade.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
package v4
22

33
import (
4+
"fmt"
5+
46
sdk "github.com/cosmos/cosmos-sdk/types"
57
"github.com/cosmos/cosmos-sdk/types/module"
68
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
79

810
"github.com/terpnetwork/terp-core/v2/app/keepers"
11+
"github.com/terpnetwork/terp-core/v2/app/upgrades"
912
clocktypes "github.com/terpnetwork/terp-core/v2/x/clock/types"
13+
globalfeetypes "github.com/terpnetwork/terp-core/v2/x/globalfee/types"
1014
)
1115

1216
// CreateUpgradeHandler creates an SDK upgrade handler for v4
@@ -16,7 +20,7 @@ func CreateV4UpgradeHandler(
1620
keepers *keepers.AppKeepers,
1721
) upgradetypes.UpgradeHandler {
1822
return func(ctx sdk.Context, _ upgradetypes.Plan, vm module.VersionMap) (module.VersionMap, error) {
19-
23+
logger := ctx.Logger().With("upgrade", UpgradeName)
2024
// x/clock
2125
if err := keepers.ClockKeeper.SetParams(ctx, clocktypes.DefaultParams()); err != nil {
2226
return nil, err
@@ -38,8 +42,8 @@ func CreateV4UpgradeHandler(
3842
}
3943
logger.Info(fmt.Sprintf("upgraded global fee params to %s", minGasPrices))
4044

41-
// revert headstash allocation
42-
ReturnFundsToCommunityPool(ctx, keepers.BankKeeper, keepers.DistrKeeper)
45+
// revert headstash allocation
46+
ReturnFundsToCommunityPool(ctx, keepers.DistrKeeper, keepers.BankKeeper)
4347

4448
// TODO: handle deployment & instantiation of headstash patch contract
4549

0 commit comments

Comments
 (0)