Skip to content

Commit

Permalink
fix default logic and change log
Browse files Browse the repository at this point in the history
  • Loading branch information
nullpointer0x00 committed Oct 18, 2023
1 parent f310518 commit 2fa12f0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* Bump cometbft to v0.34.29 (from v0.34.28) [PR 1649](https://github.com/provenance-io/provenance/pull/1649).
* Add genesis/init for Marker module send deny list addresses. [#1660](https://github.com/provenance-io/provenance/issues/1660)
* Add automatic changelog entries for dependabot. [#1674](https://github.com/provenance-io/provenance/issues/1674)
* Add upgrade handler to set net assert values to markers [PR 1712](https://github.com/provenance-io/provenance/pull/1712).
* Add upgrade handler to set net asset values to markers [PR 1712](https://github.com/provenance-io/provenance/pull/1712).
* Ensure IBC marker has matching supply [#1706](https://github.com/provenance-io/provenance/issues/1706).

### Bug Fixes
Expand Down
11 changes: 5 additions & 6 deletions app/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ var upgrades = map[string]appUpgrade{
"tp1cxuqqyjjf5x66jvlmtvj3juppn370ev7rr5cja3ml65nzhxgvpkszfuvtw.investment": markertypes.NewNetAssetValue(sdk.NewInt64Coin(markertypes.UsdDenom, 10), 33600000),
"pm.sale.pool.7v2gsuvnudyfvuig50r3k3": markertypes.NewNetAssetValue(sdk.NewInt64Coin(markertypes.UsdDenom, 19026640), 1),
}
addMarkerNavs(ctx, app, denomToNav)
addMarkerNavs(ctx, app, denomToNav, markertypes.NewNetAssetValue(sdk.NewInt64Coin(markertypes.UsdDenom, int64(150)), 1))

setExchangeParams(ctx, app)

Expand All @@ -148,7 +148,7 @@ var upgrades = map[string]appUpgrade{
denomToNav := map[string]markertypes.NetAssetValue{
// TODO: Add custom mainnet values here
}
addMarkerNavs(ctx, app, denomToNav)
addMarkerNavs(ctx, app, denomToNav, markertypes.NewNetAssetValue(sdk.NewInt64Coin(markertypes.UsdDenom, int64(150)), 1))
setExchangeParams(ctx, app)

return vm, nil
Expand Down Expand Up @@ -362,7 +362,7 @@ func updateMaxSupply(ctx sdk.Context, app *App) {
}

// addMarkerNavs adds navs to existing markers, if denom is not in map it will default to $0.15 cents
func addMarkerNavs(ctx sdk.Context, app *App, denomToNav map[string]markertypes.NetAssetValue) {
func addMarkerNavs(ctx sdk.Context, app *App, denomToNav map[string]markertypes.NetAssetValue, defaultNav markertypes.NetAssetValue) {
ctx.Logger().Info("Adding marker net asset values")
for denom, nav := range denomToNav {
marker, err := app.MarkerKeeper.GetMarkerByDenom(ctx, denom)
Expand All @@ -385,9 +385,8 @@ func addMarkerNavs(ctx sdk.Context, app *App, denomToNav map[string]markertypes.
return false
}
if !hasNav {
nav := markertypes.NewNetAssetValue(sdk.NewInt64Coin(markertypes.UsdDenom, int64(150)), 1)
if err := app.MarkerKeeper.AddSetNetAssetValues(ctx, record, []markertypes.NetAssetValue{nav}, "upgrade_handler"); err != nil {
ctx.Logger().Error(fmt.Sprintf("unable to set net asset value %v: %v", nav, err))
if err := app.MarkerKeeper.AddSetNetAssetValues(ctx, record, []markertypes.NetAssetValue{defaultNav}, "upgrade_handler"); err != nil {
ctx.Logger().Error(fmt.Sprintf("unable to set net asset value %v: %v", defaultNav, err))
}
}
return false
Expand Down

0 comments on commit 2fa12f0

Please sign in to comment.