remove libstatus references from the wallet view

This commit is contained in:
Iuri Matias 2021-06-09 10:27:21 -04:00
parent a90aa4cc3a
commit 80456eaa10
4 changed files with 32 additions and 14 deletions

View File

@ -34,7 +34,6 @@ type
const getLinkPreviewDataTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
let arg = decode[GetLinkPreviewDataTaskArg](argEncoded)
var success: bool
# We need to call directly on libstatus because going through the status model is not thread safe
let
response = status_chat.getLinkPreviewData(arg.link, success)
responseJson = %* { "result": %response, "success": %success, "uuid": %arg.uuid }

View File

@ -6,12 +6,13 @@ import # vendor libs
NimQml, chronicles, stint
import # status-desktop libs
../../status/[status, wallet, settings],
../../status/[status, wallet, settings, tokens],
../../status/wallet/collectibles as status_collectibles,
../../status/libstatus/wallet as status_wallet,
../../status/libstatus/tokens, ../../status/types,
../../status/wallet as status_wallet,
../../status/types,
../../status/utils as status_utils,
../../status/libstatus/eth/contracts, ../../status/ens as status_ens,
../../status/tokens as status_tokens,
../../status/ens as status_ens,
views/[asset_list, account_list, account_item, token_list, transaction_list, collectibles_list],
../../status/tasks/[qt, task_runner_impl], ../../status/signals/types as signal_types
@ -78,7 +79,7 @@ const initBalancesTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
let arg = decode[InitBalancesTaskArg](argEncoded)
var tokenBalances = initTable[string, string]()
for token in arg.tokenList:
tokenBalances[token] = getTokenBalance(token, arg.address)
tokenBalances[token] = status_tokens.getTokenBalance(token, arg.address)
let output = %* {
"address": arg.address,
"eth": getEthBalance(arg.address),
@ -147,7 +148,7 @@ const loadTransactionsTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.}
arg = decode[LoadTransactionsTaskArg](argEncoded)
output = %*{
"address": arg.address,
"history": getTransfersByAddress(arg.address, arg.toBlock, arg.limit, arg.loadMore),
"history": status_wallet.getTransfersByAddress(arg.address, arg.toBlock, arg.limit, arg.loadMore),
"loadMore": arg.loadMore
}
arg.finish(output)
@ -379,7 +380,6 @@ QtObject:
write = setCurrentAssetList
notify = currentAssetListChanged
proc totalFiatBalanceChanged*(self: WalletView) {.signal.}
proc getTotalFiatBalance(self: WalletView): string {.slot.} =
@ -526,10 +526,10 @@ QtObject:
self.currentAccountChanged()
proc removeCustomToken*(self: WalletView, tokenAddress: string) {.slot.} =
let t = getCustomTokens().getErc20ContractByAddress(parseAddress(tokenAddress))
let t = self.status.tokens.getCustomTokens().getErc20ContractByAddress(parseAddress(tokenAddress))
if t == nil: return
self.status.wallet.hideAsset(t.symbol)
removeCustomToken(tokenAddress)
self.status.tokens.removeCustomToken(tokenAddress)
self.customTokenList.loadCustomTokens()
for account in self.status.wallet.accounts:
if account.address == self.currentAccount.address:
@ -699,12 +699,12 @@ QtObject:
proc decodeTokenApproval*(self: WalletView, tokenAddress: string, data: string): string {.slot.} =
let amount = data[74..len(data)-1]
let token = getToken(tokenAddress)
let token = self.status.tokens.getToken(tokenAddress)
if(token != nil):
let amountDec = $hex2Token(amount, token.decimals)
let amountDec = $self.status.wallet.hex2Token(amount, token.decimals)
return $(%* {"symbol": token.symbol, "amount": amountDec})
return """{"error":"Unknown token address"}""";
proc isFetchingHistory*(self: WalletView): bool {.slot.} =

View File

@ -25,6 +25,9 @@ proc getSNTAddress*(): string =
proc getCustomTokens*(self: TokensModel, useCached: bool = true): seq[Erc20Contract] =
result = status_tokens.getCustomTokens(useCached)
proc removeCustomToken*(self: TokensModel, address: string) =
status_tokens.removeCustomToken(address)
proc getSNTBalance*(account: string): string =
result = status_tokens.getSNTBalance(account)
@ -37,6 +40,13 @@ proc tokenName*(contract: Contract): string =
proc tokensymbol*(contract: Contract): string =
result = status_tokens.tokensymbol(contract)
proc getTokenBalance*(tokenAddress: string, account: string): string =
result = status_tokens.getTokenBalance(tokenAddress, account)
proc getToken*(self: TokensModel, tokenAddress: string): Erc20Contract =
result = status_tokens.getToken(tokenAddress)
export newErc20Contract
export getErc20Contracts
export Erc20Contract
export getErc20ContractByAddress

View File

@ -374,3 +374,12 @@ proc watchTransaction*(self: WalletModel, transactionHash: string): string =
proc getPendingTransactions*(self: WalletModel): string =
result = status_wallet.getPendingTransactions()
proc getTransfersByAddress*(address: string): seq[types.Transaction] =
result = status_wallet.getTransfersByAddress(address)
proc watchTransaction*(transactionHash: string): string =
result = status_wallet.watchTransaction(transactionHash)
proc hex2Token*(self: WalletModel, input: string, decimals: int): string =
result = status_wallet.hex2Token(input, decimals)