-
Notifications
You must be signed in to change notification settings - Fork 26
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 #380 from sge-network/release/v1.6.x
Release / v1.6.0
- Loading branch information
Showing
58 changed files
with
6,614 additions
and
667 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,19 @@ | ||
package v8 | ||
|
||
import ( | ||
store "github.com/cosmos/cosmos-sdk/store/types" | ||
|
||
"github.com/sge-network/sge/app/upgrades" | ||
) | ||
|
||
// UpgradeName defines the on-chain upgrade name for the v1.6.0 upgrade. | ||
const UpgradeName = "v1.6.0" | ||
|
||
var Upgrade = upgrades.Upgrade{ | ||
UpgradeName: UpgradeName, | ||
CreateUpgradeHandler: CreateUpgradeHandler, | ||
StoreUpgrades: store.StoreUpgrades{ | ||
Added: []string{}, | ||
Deleted: []string{}, | ||
}, | ||
} |
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,56 @@ | ||
package v8 | ||
|
||
import ( | ||
sdkmath "cosmossdk.io/math" | ||
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/google/uuid" | ||
"github.com/sge-network/sge/app/keepers" | ||
"github.com/sge-network/sge/x/reward/types" | ||
) | ||
|
||
func CreateUpgradeHandler( | ||
mm *module.Manager, | ||
configurator module.Configurator, | ||
k *keepers.AppKeepers, | ||
) upgradetypes.UpgradeHandler { | ||
return func(ctx sdk.Context, plan upgradetypes.Plan, fromVM module.VersionMap) (module.VersionMap, error) { | ||
allCampaigns := k.RewardKeeper.GetAllCampaign(ctx) | ||
promoters := make(map[string]struct{}) | ||
for _, c := range allCampaigns { | ||
c.CapCount = 0 // infinite cap for all campaigns | ||
c.Pool.Withdrawn = sdkmath.ZeroInt() | ||
k.RewardKeeper.SetCampaign(ctx, c) | ||
promoters[c.Promoter] = struct{}{} | ||
} | ||
|
||
promoterAddresses := []string{} | ||
for addr := range promoters { | ||
promoterAddresses = append(promoterAddresses, addr) | ||
} | ||
|
||
if len(promoterAddresses) > 0 { | ||
promoterUID := uuid.NewString() | ||
k.RewardKeeper.SetPromoter(ctx, types.Promoter{ | ||
Creator: promoterAddresses[0], | ||
UID: promoterUID, | ||
Addresses: promoterAddresses, | ||
Conf: types.PromoterConf{ | ||
CategoryCap: []types.CategoryCap{ | ||
{Category: types.RewardCategory_REWARD_CATEGORY_SIGNUP, CapPerAcc: 1}, | ||
}, | ||
}, | ||
}) | ||
|
||
for _, addr := range promoterAddresses { | ||
k.RewardKeeper.SetPromoterByAddress(ctx, types.PromoterByAddress{ | ||
PromoterUID: promoterUID, | ||
Address: addr, | ||
}) | ||
} | ||
} | ||
|
||
return mm.RunMigrations(ctx, configurator, fromVM) | ||
} | ||
} |
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
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 @@ | ||
syntax = "proto3"; | ||
package sgenetwork.sge.reward; | ||
|
||
import "gogoproto/gogo.proto"; | ||
|
||
import "sge/reward/reward.proto"; | ||
|
||
option go_package = "github.com/sge-network/sge/x/reward/types"; | ||
|
||
// Promoter is type for defining the reward promoter properties and configuration. | ||
message Promoter { | ||
// creator is the address of promoter. | ||
string creator = 1; | ||
|
||
// uid is the unique identifier of a promoter. | ||
string uid = 2 [ | ||
(gogoproto.customname) = "UID", | ||
(gogoproto.jsontag) = "uid", | ||
json_name = "uid" | ||
]; | ||
|
||
// addresses is the list of account addresses of promoter. | ||
repeated string addresses = 3; | ||
|
||
// conf is the configurations of the current promoter for the reward grant. | ||
PromoterConf conf = 4 [ (gogoproto.nullable) = false ]; | ||
} | ||
|
||
// PromoterConf is type for defining the promoter specific configurations. | ||
message PromoterConf { | ||
// category_cap is the maximium allowed cap for each category. | ||
repeated CategoryCap category_cap = 1 [ (gogoproto.nullable) = false ]; | ||
} | ||
|
||
// CategoryCap is type to define category and its maximum cap. | ||
message CategoryCap { | ||
RewardCategory category = 1; | ||
int32 cap_per_acc = 2; | ||
} | ||
|
||
// PromoterByAddress is type for defining the promoter by address. | ||
message PromoterByAddress { | ||
// promoter_uid is the unique identifier of a certain promoter. | ||
string promoter_uid = 1 [ | ||
(gogoproto.customname) = "PromoterUID", | ||
(gogoproto.jsontag) = "promoter_uid", | ||
json_name = "promoter_uid" | ||
]; | ||
// address is the address of the promoter account. | ||
string address = 2; | ||
} |
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.