Skip to content

Commit

Permalink
Merge pull request #36 from dwarvesf/fix/format-earned-amount
Browse files Browse the repository at this point in the history
fix: format earned amount to currency
  • Loading branch information
baenv authored Jan 5, 2024
2 parents 71b4786 + 6dd8ffd commit 2e80b05
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 11 additions & 1 deletion pkg/discord/view/icy/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ func (e *Icy) PersonalInfo(original *model.DiscordMessage, accounting *model.Icy
formattedContractFund = fund
}

var formattedTotalEarnedICY string = "NaN"
if totalEarnedICY := cryptoutils.StringBigIntToStringCurrency(totalEarned.TotalEarnsICY, 0); totalEarnedICY != "" {
formattedTotalEarnedICY = totalEarnedICY
}

var formattedTotalEarnedUSDT string = "NaN"
if totalEarnedUSDT := cryptoutils.StringBigIntToStringCurrency(big.NewFloat(totalEarned.TotalEarnsUSD).String(), 0); totalEarnedUSDT != "" {
formattedTotalEarnedUSDT = totalEarnedUSDT
}

last5Txns := [][]string{}
last5Msgs := []string{}
for _, txn := range earnedTxns {
Expand Down Expand Up @@ -66,7 +76,7 @@ func (e *Icy) PersonalInfo(original *model.DiscordMessage, accounting *model.Icy
"",
// Your Earned ICY
fmt.Sprintf("%s **Your Earned ICY**", discordEmojiPepeCoolNerd),
fmt.Sprintf("%s`%s ICY` ~ %s`%d USDT`", discordEmojiIceCube, totalEarned.TotalEarnsICY, discordEmojiDollar, totalEarned.TotalEarnsUSD),
fmt.Sprintf("%s`%s ICY` ~ %s`%s USDT`", discordEmojiIceCube, formattedTotalEarnedICY, discordEmojiDollar, formattedTotalEarnedUSDT),
"",
// Your Last 5 Transactions
fmt.Sprintf("%s **Your Last 5 Earns**", discordEmojiAnxinICY),
Expand Down
4 changes: 2 additions & 2 deletions pkg/model/icy.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,6 @@ type AdapterICYTotalEarned struct {
}

type ICYTotalEarned struct {
TotalEarnsICY string `json:"totalEarnsICY"`
TotalEarnsUSD int64 `json:"totalEarnsUSD"`
TotalEarnsICY string `json:"totalEarnsICY"`
TotalEarnsUSD float64 `json:"totalEarnsUSD"`
}

0 comments on commit 2e80b05

Please sign in to comment.