parent
0c7442d696
commit
8fd5e9d1af
|
@ -113,7 +113,7 @@ method refreshWalletAccounts*(self: Module) =
|
|||
x.walletType,
|
||||
x.isWallet,
|
||||
x.isChat,
|
||||
x.getBalance(enabledChainIds),
|
||||
x.getCurrencyBalance(enabledChainIds),
|
||||
x.emoji,
|
||||
x.derivedfrom,
|
||||
))
|
||||
|
@ -128,7 +128,7 @@ method refreshWalletAccounts*(self: Module) =
|
|||
w.walletType,
|
||||
w.isWallet,
|
||||
w.isChat,
|
||||
w.getBalance(enabledChainIds),
|
||||
w.getCurrencyBalance(enabledChainIds),
|
||||
assets,
|
||||
w.emoji,
|
||||
w.derivedfrom,
|
||||
|
|
|
@ -114,6 +114,14 @@ proc getBalances*(self: WalletTokenDto, chainIds: seq[int]): seq[BalanceDto] =
|
|||
if self.balancesPerChain.hasKey(chainId):
|
||||
result.add(self.balancesPerChain[chainId])
|
||||
|
||||
proc getBalance*(self: WalletTokenDto, chainIds: seq[int]): float64 =
|
||||
var sum = 0.0
|
||||
for chainId in chainIds:
|
||||
if self.balancesPerChain.hasKey(chainId):
|
||||
sum += self.balancesPerChain[chainId].balance
|
||||
|
||||
return sum
|
||||
|
||||
proc getCurrencyBalance*(self: WalletTokenDto, chainIds: seq[int]): float64 =
|
||||
var sum = 0.0
|
||||
for chainId in chainIds:
|
||||
|
@ -135,17 +143,6 @@ proc getVisible*(self: WalletTokenDto, chainIds: seq[int]): bool =
|
|||
proc getCurrencyBalance*(self: WalletAccountDto, chainIds: seq[int]): float64 =
|
||||
return self.tokens.map(t => t.getCurrencyBalance(chainIds)).foldl(a + b, 0.0)
|
||||
|
||||
proc getBalance*(self: WalletTokenDto, chainIds: seq[int]): float64 =
|
||||
var sum = 0.0
|
||||
for chainId in chainIds:
|
||||
if self.balancesPerChain.hasKey(chainId):
|
||||
sum += self.balancesPerChain[chainId].balance
|
||||
|
||||
return sum
|
||||
|
||||
proc getBalance*(self: WalletAccountDto, chainIds: seq[int]): float64 =
|
||||
return self.tokens.map(t => t.getBalance(chainIds)).foldl(a + b, 0.0)
|
||||
|
||||
proc toBalanceDto*(jsonObj: JsonNode): BalanceDto =
|
||||
result = BalanceDto()
|
||||
result.balance = jsonObj{"balance"}.getStr.parseFloat()
|
||||
|
|
Loading…
Reference in New Issue