Skip to content

Commit

Permalink
refactor method again
Browse files Browse the repository at this point in the history
  • Loading branch information
nullpointer0x00 committed Oct 13, 2023
1 parent ba1c7cf commit 9ea8554
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions x/ibchooks/marker_hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ func (h MarkerHooks) createNewIbcMarker(ctx sdktypes.Context, data transfertypes
allowForceTransfer,
[]string{},
)
h.getExistingSupply(ctx, marker)
existingSupply := h.getExistingSupply(ctx, marker)
_ = marker.SetSupply(marker.GetSupply().Add(existingSupply))
if err = ResetMarkerAccessGrants(transferAuthAddrs, marker); err != nil {
return err
}
Expand All @@ -106,11 +107,9 @@ func (h MarkerHooks) createNewIbcMarker(ctx sdktypes.Context, data transfertypes
return h.addDenomMetaData(ctx, packet, ibcKeeper, ibcDenom, data)
}

// getExistingSupply updates marker account's supply, this ensures the supply is correct for ibc coins that may exist before a marker is created.
// The current circulation will be 0 if the ibc coin does not exist yet.
func (h MarkerHooks) getExistingSupply(ctx sdktypes.Context, marker *markertypes.MarkerAccount) {
currentSupply := h.MarkerKeeper.CurrentCirculation(ctx, marker)
_ = marker.SetSupply(marker.GetSupply().Add(sdktypes.NewCoin(marker.Denom, currentSupply)))
// getExistingSupply returns current supply coin, if coin does not exist amount will be 0
func (h MarkerHooks) getExistingSupply(ctx sdktypes.Context, marker *markertypes.MarkerAccount) sdktypes.Coin {
return sdktypes.NewCoin(marker.Denom, h.MarkerKeeper.CurrentCirculation(ctx, marker))
}

// addDenomMetaData adds denom metadata for ibc token
Expand Down

0 comments on commit 9ea8554

Please sign in to comment.