Skip to content

Commit

Permalink
Merge a5712bb into a027eef
Browse files Browse the repository at this point in the history
  • Loading branch information
AntiD2ta committed Dec 16, 2019
2 parents a027eef + a5712bb commit e73679a
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 16 deletions.
22 changes: 15 additions & 7 deletions src/models/blockchainModels.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package models

import (
"github.com/fibercrypto/fibercryptowallet/src/util/logging"
"strconv"

"github.com/fibercrypto/fibercryptowallet/src/coin/skycoin/models" //callable as skycoin
"github.com/fibercrypto/fibercryptowallet/src/core"
Expand Down Expand Up @@ -106,15 +105,24 @@ func (blockchainStatus *BlockchainStatusModel) updateInfo() error {
}

// block details
blockchainStatus.SetNumberOfBlocks(strconv.FormatUint(numberOfBlocks, 10))
blockchainStatus.SetNumberOfBlocks(util.FormatCoins(numberOfBlocks, 1))
blockchainStatus.SetTimestampLastBlock(qtcore.NewQDateTime3(qtcore.NewQDate3(year, month, day), qtcore.NewQTime3(h, m, s, 0), qtcore.Qt__LocalTime))
blockchainStatus.SetHashLastBlock(string(lastBlockHash))

// sky details
blockchainStatus.SetCurrentSkySupply(strconv.FormatUint(currentSkySupply, 10))
blockchainStatus.SetTotalSkySupply(strconv.FormatUint(totalSkySupply, 10))
blockchainStatus.SetCurrentCoinHoursSupply(strconv.FormatUint(currentCoinHoursSupply, 10))
blockchainStatus.SetTotalCoinHoursSupply(strconv.FormatUint(totalCoinHoursSupply, 10))
accuracy, err := util.AltcoinQuotient(skycoin.SkycoinTicker)
if err != nil {
logWalletsModel.WithError(err).Warn("Couldn't get " + skycoin.SkycoinTicker + " coins quotient")
}
blockchainStatus.SetCurrentSkySupply(util.FormatCoins(currentSkySupply, accuracy))
blockchainStatus.SetTotalSkySupply(util.FormatCoins(totalSkySupply, accuracy))

accuracy, err = util.AltcoinQuotient(skycoin.CoinHoursTicker)
if err != nil {
logWalletsModel.WithError(err).Warn("Couldn't get " + skycoin.CoinHoursTicker + " coins quotient")
}
blockchainStatus.SetCurrentCoinHoursSupply(util.FormatCoins(currentCoinHoursSupply, accuracy))
blockchainStatus.SetTotalCoinHoursSupply(util.FormatCoins(totalCoinHoursSupply, accuracy))
blockchainStatus.SetLoading(false)

return nil
Expand Down
33 changes: 25 additions & 8 deletions src/models/history/historyManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func (hm *HistoryManager) getTransactionsOfAddresses(filterAddresses []string) [
logHistoryManager.WithError(err).Warn("Couldn't get Coin Hours quotient")
continue
}
qIn.SetAddressCoinHours(strconv.FormatUint(chUint64/accuracy, 10))
qIn.SetAddressCoinHours(util.FormatCoins(chUint64, accuracy))
inputs.AddAddress(qIn)
_, ok := addresses[in.GetSpentOutput().GetAddress().String()]
if ok {
Expand Down Expand Up @@ -251,14 +251,22 @@ func (hm *HistoryManager) getTransactionsOfAddresses(filterAddresses []string) [
logHistoryManager.WithError(err).Warn("Couldn't compute fee of the operation")
continue
}
txnDetails.SetHoursBurned(strconv.FormatUint(fee, 10))
accuracy, err := util.AltcoinQuotient(coin.CoinHoursTicker)
if err != nil {
logHistoryManager.WithError(err).Warn("Couldn't get " + coin.CoinHoursTicker + " coins quotient")
}
txnDetails.SetHoursBurned(util.FormatCoins(fee, accuracy))

switch txnDetails.Type() {
case transactions.TransactionTypeReceive:
{
txnDetails.SetHoursTraspassed(strconv.FormatUint(traspassedHoursIn, 10))
accuracy, err := util.AltcoinQuotient(coin.CoinHoursTicker)
if err != nil {
logHistoryManager.WithError(err).Warn("Couldn't get " + coin.CoinHoursTicker + " coins quotient")
}
txnDetails.SetHoursTraspassed(util.FormatCoins(traspassedHoursIn, accuracy))
val := float64(skyAmountIn)
accuracy, err := util.AltcoinQuotient(params.SkycoinTicker)
accuracy, err = util.AltcoinQuotient(params.SkycoinTicker)
if err != nil {
logHistoryManager.WithError(err).Warn("Couldn't get Skycoins quotient")
continue
Expand Down Expand Up @@ -302,9 +310,14 @@ func (hm *HistoryManager) getTransactionsOfAddresses(filterAddresses []string) [
}

}
txnDetails.SetHoursTraspassed(strconv.FormatUint(traspassedHoursMoved, 10))
accuracy, err := util.AltcoinQuotient(coin.CoinHoursTicker)
if err != nil {
logHistoryManager.WithError(err).Warn("Couldn't get " + coin.CoinHoursTicker + " coins quotient")
}
txnDetails.SetHoursTraspassed(util.FormatCoins(traspassedHoursMoved, accuracy))
val := float64(skyAmountMoved)
accuracy, _ := util.AltcoinQuotient(params.SkycoinTicker)
//FIXME: Error here is skipped
accuracy, _ = util.AltcoinQuotient(params.SkycoinTicker)
if err != nil {
logHistoryManager.WithError(err).Warn("Couldn't get Skycoins quotient")
continue
Expand All @@ -315,9 +328,13 @@ func (hm *HistoryManager) getTransactionsOfAddresses(filterAddresses []string) [
}
case transactions.TransactionTypeSend:
{
txnDetails.SetHoursTraspassed(strconv.FormatUint(traspassedHoursOut, 10))
accuracy, err := util.AltcoinQuotient(coin.CoinHoursTicker)
if err != nil {
logHistoryManager.WithError(err).Warn("Couldn't get " + coin.CoinHoursTicker + " coins quotient")
}
txnDetails.SetHoursTraspassed(util.FormatCoins(traspassedHoursOut, accuracy))
val := float64(skyAmountOut)
accuracy, err := util.AltcoinQuotient(params.SkycoinTicker)
accuracy, err = util.AltcoinQuotient(params.SkycoinTicker)
if err != nil {
logHistoryManager.WithError(err).Warn("Couldn't get Skycoins quotient")
continue
Expand Down
11 changes: 10 additions & 1 deletion src/models/walletsModel.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package models

import (
"strconv"

coin "github.com/fibercrypto/fibercryptowallet/src/coin/skycoin/models"
"github.com/fibercrypto/fibercryptowallet/src/util"
"github.com/fibercrypto/fibercryptowallet/src/util/logging"
"github.com/therecipe/qt/core"
"github.com/therecipe/qt/qml"
Expand Down Expand Up @@ -98,7 +102,12 @@ func (walletModel *WalletModel) data(index *core.QModelIndex, role int) *core.QV

case CoinHours:
{
return core.NewQVariant1(w.CoinHours())
accuracy, err := util.AltcoinQuotient(coin.CoinHoursTicker)
if err != nil {
logWalletsModel.WithError(err).Warn("Couldn't get " + coin.CoinHoursTicker + " coins quotient")
}
val, err := strconv.ParseUint(w.CoinHours(), 10, 64)
return core.NewQVariant1(util.FormatCoins(val, accuracy))
}
case FileName:
{
Expand Down

0 comments on commit e73679a

Please sign in to comment.