Skip to content

Commit 3e3680a

Browse files
author
abstrct
committed
Updating alpha and watt unit types to have more precision. This brings them more in-line with Cosmos standards and gives the system more flexibility for tweaking.
1 parent 2f8578c commit 3e3680a

9 files changed

Lines changed: 119 additions & 141 deletions

File tree

cmd/structsd/main.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@ import (
99
"structs/app"
1010
"structs/cmd/structsd/cmd"
1111

12-
sdk "github.com/cosmos/cosmos-sdk/types"
13-
"cosmossdk.io/math"
12+
//sdk "github.com/cosmos/cosmos-sdk/types"
13+
//"cosmossdk.io/math"
1414

1515
)
1616

1717
func main() {
18-
sdk.DefaultPowerReduction = math.NewIntFromUint64(10)
18+
// Was used to change the Staking voting power
19+
// But now asset definition of Alpha is more in-line with Cosmos network norms
20+
//sdk.DefaultPowerReduction = math.NewIntFromUint64(10)
1921

2022
rootCmd := cmd.NewRootCmd()
2123
if err := svrcmd.Execute(rootCmd, "", app.DefaultNodeHome); err != nil {

docs/static/openapi.yml

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

x/structs/keeper/guild_cache.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func (cache *GuildCache) PermissionCheck(permission types.Permission, activePlay
194194

195195
func (cache *GuildCache) BankMint(amountAlpha math.Int, amountToken math.Int, player *PlayerCache) (error) {
196196

197-
alphaCollateralCoin := sdk.NewCoin("alpha", amountAlpha)
197+
alphaCollateralCoin := sdk.NewCoin("ualpha", amountAlpha)
198198
alphaCollateralCoins := sdk.NewCoins(alphaCollateralCoin)
199199

200200

@@ -226,7 +226,7 @@ func (cache *GuildCache) BankMint(amountAlpha math.Int, amountToken math.Int, pl
226226

227227
func (cache *GuildCache) BankRedeem(amountToken math.Int, player *PlayerCache) (error) {
228228

229-
alphaCollateralBalance := cache.K.bankKeeper.SpendableCoin(cache.Ctx, cache.K.accountKeeper.GetModuleAddress(cache.GetBankCollateralPool()), "alpha")
229+
alphaCollateralBalance := cache.K.bankKeeper.SpendableCoin(cache.Ctx, cache.K.accountKeeper.GetModuleAddress(cache.GetBankCollateralPool()), "ualpha")
230230
guildTokenSupply := cache.K.bankKeeper.GetSupply(cache.Ctx, cache.GetBankDenom())
231231

232232
guildTokenCoin := sdk.NewCoin(cache.GetBankDenom(), amountToken)
@@ -256,7 +256,7 @@ func (cache *GuildCache) BankRedeem(amountToken math.Int, player *PlayerCache) (
256256
}
257257

258258
// Move the Alpha to Player
259-
alphaAmountCoin := sdk.NewCoin("alpha", alphaAmount)
259+
alphaAmountCoin := sdk.NewCoin("ualpha", alphaAmount)
260260
alphaAmountCoins := sdk.NewCoins(alphaAmountCoin)
261261
cache.K.bankKeeper.SendCoinsFromModuleToAccount(cache.Ctx, cache.GetBankCollateralPool(), player.GetPrimaryAccount(), alphaAmountCoins)
262262

x/structs/keeper/msg_server_struct_generator_infuse.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,13 @@ func (k msgServer) StructGeneratorInfuse(goCtx context.Context, msg *types.MsgSt
7777
return &types.MsgStructGeneratorStatusResponse{}, sdkerrors.Wrapf(types.ErrStructInfuse, "Infuse amount (%s) is invalid", msg.InfuseAmount)
7878
}
7979

80-
if (infusionAmount[0].Denom != "alpha") {
80+
if (infusionAmount[0].Denom == "ualpha") {
81+
// All good
82+
} else if (infusionAmount[0].Denom == "alpha") {
83+
alphaUnitConversionInt := math.NewIntFromUint64(uint64(1000000))
84+
infusionAmount[0].Amount = infusionAmount[0].Amount.Mul(alphaUnitConversionInt)
85+
infusionAmount[0].Denom = "ualpha"
86+
} else {
8187
return &types.MsgStructGeneratorStatusResponse{}, sdkerrors.Wrapf(types.ErrStructInfuse, "Infuse amount (%s) is invalid, %s is not a fuel", msg.InfuseAmount, infusionAmount[0].Denom)
8288
}
8389

x/structs/keeper/player.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ func (k Keeper) DischargePlayer(ctx context.Context, playerId string) {
218218
func (k Keeper) GetPlayerInventory(ctx context.Context, primaryAddress string) (types.PlayerInventory){
219219

220220
playerAcc, _ := sdk.AccAddressFromBech32(primaryAddress)
221-
storage := k.bankKeeper.SpendableCoin(ctx, playerAcc, "alpha")
221+
storage := k.bankKeeper.SpendableCoin(ctx, playerAcc, "ualpha")
222222

223223
return types.PlayerInventory{Rocks: storage}
224224

x/structs/keeper/player_cache.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ func (cache *PlayerCache) SetPrimaryAddress(address string) {
393393
func (cache *PlayerCache) DepositRefinedAlpha() {
394394
// Got this far, let's reward the player with some fresh Alpha
395395
// Mint the new Alpha to the module
396-
newAlpha, _ := sdk.ParseCoinsNormalized("1alpha")
396+
newAlpha, _ := sdk.ParseCoinsNormalized("1000000ualpha")
397397
cache.K.bankKeeper.MintCoins(cache.Ctx, types.ModuleName, newAlpha)
398398
// Transfer the refined Alpha to the player
399399
playerAcc, _ := sdk.AccAddressFromBech32(cache.GetPrimaryAddress())

0 commit comments

Comments
 (0)