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