Skip to content

Commit

Permalink
update pstake version to 1.3.1, move iteration of mints outside funct…
Browse files Browse the repository at this point in the history
…ion (#167)
  • Loading branch information
Anmol1696 authored Dec 22, 2022
1 parent dc390a8 commit 883a500
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 37 deletions.
68 changes: 34 additions & 34 deletions app/upgrades/v6/untombstoning.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,48 +45,46 @@ func mintLostTokens(
bankKeeper *bankkeeper.BaseKeeper,
stakingKeeper *stakingkeeper.Keeper,
mintKeeper *mintkeeper.Keeper,
cosMints []CosMints,
mintRecord CosMints,
) error {
for _, mintRecord := range cosMints {
cosValAddress, err := sdk.ValAddressFromBech32(mintRecord.Delegatee)
if err != nil {
return fmt.Errorf("validator address is not valid bech32: %s", cosValAddress)
}
cosValAddress, err := sdk.ValAddressFromBech32(mintRecord.Delegatee)
if err != nil {
return fmt.Errorf("validator address is not valid bech32: %s", cosValAddress)
}

coinAmount, _ := sdk.NewIntFromString(mintRecord.AmountUxprt)
coinAmount, _ := sdk.NewIntFromString(mintRecord.AmountUxprt)

coin := sdk.NewCoin("uxprt", coinAmount)
coins := sdk.NewCoins(coin)
coin := sdk.NewCoin("uxprt", coinAmount)
coins := sdk.NewCoins(coin)

err = mintKeeper.MintCoins(ctx, coins)
if err != nil {
return fmt.Errorf("error minting %duxprt to %s: %+v", mintRecord.AmountUxprt, mintRecord.Address, err)
}
err = mintKeeper.MintCoins(ctx, coins)
if err != nil {
return fmt.Errorf("error minting %suxprt to %s: %+v", mintRecord.AmountUxprt, mintRecord.Address, err)
}

delegatorAccount, err := sdk.AccAddressFromBech32(mintRecord.Address)
if err != nil {
return fmt.Errorf("error converting human address %s to sdk.AccAddress: %+v", mintRecord.Address, err)
}
delegatorAccount, err := sdk.AccAddressFromBech32(mintRecord.Address)
if err != nil {
return fmt.Errorf("error converting human address %s to sdk.AccAddress: %+v", mintRecord.Address, err)
}

err = bankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, delegatorAccount, coins)
if err != nil {
return fmt.Errorf("error sending minted %duxprt to %s: %+v", mintRecord.AmountUxprt, mintRecord.Address, err)
}
err = bankKeeper.SendCoinsFromModuleToAccount(ctx, minttypes.ModuleName, delegatorAccount, coins)
if err != nil {
return fmt.Errorf("error sending minted %suxprt to %s: %+v", mintRecord.AmountUxprt, mintRecord.Address, err)
}

sdkAddress, err := sdk.AccAddressFromBech32(mintRecord.Address)
if err != nil {
return fmt.Errorf("account address is not valid bech32: %s", mintRecord.Address)
}
sdkAddress, err := sdk.AccAddressFromBech32(mintRecord.Address)
if err != nil {
return fmt.Errorf("account address is not valid bech32: %s", mintRecord.Address)
}

cosValidator, found := stakingKeeper.GetValidator(ctx, cosValAddress)
if !found {
return fmt.Errorf("cos validator '%s' not found", cosValAddress)
}
cosValidator, found := stakingKeeper.GetValidator(ctx, cosValAddress)
if !found {
return fmt.Errorf("cos validator '%s' not found", cosValAddress)
}

_, err = stakingKeeper.Delegate(ctx, sdkAddress, coin.Amount, stakingtypes.Unbonded, cosValidator, true)
if err != nil {
return fmt.Errorf("error delegating minted %duxprt from %s to %s: %+v", mintRecord.AmountUxprt, mintRecord.Address, mintRecord.Delegatee, err)
}
_, err = stakingKeeper.Delegate(ctx, sdkAddress, coin.Amount, stakingtypes.Unbonded, cosValidator, true)
if err != nil {
return fmt.Errorf("error delegating minted %suxprt from %s to %s: %+v", mintRecord.AmountUxprt, mintRecord.Address, mintRecord.Delegatee, err)
}
return nil
}
Expand Down Expand Up @@ -157,7 +155,9 @@ func RevertCosTombstoning(
revertTombstone(ctx, slashingKeeper, value)
}

mintLostTokens(ctx, bankKeeper, stakingKeeper, mintKeeper, Mints)
for _, mint := range Mints {
mintLostTokens(ctx, bankKeeper, stakingKeeper, mintKeeper, mint)
}
}
return nil
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/gogo/protobuf v1.3.3
github.com/gorilla/mux v1.8.0
github.com/persistenceOne/persistence-sdk v1.0.0
github.com/persistenceOne/pstake-native v1.3.0
github.com/persistenceOne/pstake-native v1.3.1
github.com/prometheus/client_golang v1.13.0
github.com/rakyll/statik v0.1.7
github.com/spf13/cast v1.5.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -616,8 +616,8 @@ github.com/pelletier/go-toml/v2 v2.0.5/go.mod h1:OMHamSCAODeSsVrwwvcJOaoN0LIUIaF
github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac=
github.com/persistenceOne/persistence-sdk v1.0.0 h1:2HTdjW3HNhJ4fZYF22UsiajCQRKYk+TPpIQkCUeOj3A=
github.com/persistenceOne/persistence-sdk v1.0.0/go.mod h1:EZ4YlLUQMzRbxrF1/YoAaEv9+GYyfxoHvlsc9ULrxDw=
github.com/persistenceOne/pstake-native v1.3.0 h1:6xpnzv7TJkXsuUnpHPXJZQG2RX/vxxCc0aHL3Kg+zaU=
github.com/persistenceOne/pstake-native v1.3.0/go.mod h1:byclNxsC8/7PIREvZoVEciKXzXTLRMRkYEbL7wCirPQ=
github.com/persistenceOne/pstake-native v1.3.1 h1:+O4Zpe7nDHJFdZUou4jRJlrrYWYcUTZFlYbMCAs96fc=
github.com/persistenceOne/pstake-native v1.3.1/go.mod h1:byclNxsC8/7PIREvZoVEciKXzXTLRMRkYEbL7wCirPQ=
github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7/go.mod h1:CRroGNssyjTd/qIG2FyxByd2S8JEAZXBl4qUrZf8GS0=
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 h1:q2e307iGHPdTGp0hoxKjt1H5pDo6utceo3dQVK3I5XQ=
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o=
Expand Down

0 comments on commit 883a500

Please sign in to comment.