remove libstatus references from the wallet view
This commit is contained in:
parent
a90aa4cc3a
commit
80456eaa10
|
@ -34,7 +34,6 @@ type
|
||||||
const getLinkPreviewDataTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
|
const getLinkPreviewDataTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
|
||||||
let arg = decode[GetLinkPreviewDataTaskArg](argEncoded)
|
let arg = decode[GetLinkPreviewDataTaskArg](argEncoded)
|
||||||
var success: bool
|
var success: bool
|
||||||
# We need to call directly on libstatus because going through the status model is not thread safe
|
|
||||||
let
|
let
|
||||||
response = status_chat.getLinkPreviewData(arg.link, success)
|
response = status_chat.getLinkPreviewData(arg.link, success)
|
||||||
responseJson = %* { "result": %response, "success": %success, "uuid": %arg.uuid }
|
responseJson = %* { "result": %response, "success": %success, "uuid": %arg.uuid }
|
||||||
|
|
|
@ -6,12 +6,13 @@ import # vendor libs
|
||||||
NimQml, chronicles, stint
|
NimQml, chronicles, stint
|
||||||
|
|
||||||
import # status-desktop libs
|
import # status-desktop libs
|
||||||
../../status/[status, wallet, settings],
|
../../status/[status, wallet, settings, tokens],
|
||||||
../../status/wallet/collectibles as status_collectibles,
|
../../status/wallet/collectibles as status_collectibles,
|
||||||
../../status/libstatus/wallet as status_wallet,
|
../../status/wallet as status_wallet,
|
||||||
../../status/libstatus/tokens, ../../status/types,
|
../../status/types,
|
||||||
../../status/utils as status_utils,
|
../../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],
|
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
|
../../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)
|
let arg = decode[InitBalancesTaskArg](argEncoded)
|
||||||
var tokenBalances = initTable[string, string]()
|
var tokenBalances = initTable[string, string]()
|
||||||
for token in arg.tokenList:
|
for token in arg.tokenList:
|
||||||
tokenBalances[token] = getTokenBalance(token, arg.address)
|
tokenBalances[token] = status_tokens.getTokenBalance(token, arg.address)
|
||||||
let output = %* {
|
let output = %* {
|
||||||
"address": arg.address,
|
"address": arg.address,
|
||||||
"eth": getEthBalance(arg.address),
|
"eth": getEthBalance(arg.address),
|
||||||
|
@ -147,7 +148,7 @@ const loadTransactionsTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.}
|
||||||
arg = decode[LoadTransactionsTaskArg](argEncoded)
|
arg = decode[LoadTransactionsTaskArg](argEncoded)
|
||||||
output = %*{
|
output = %*{
|
||||||
"address": arg.address,
|
"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
|
"loadMore": arg.loadMore
|
||||||
}
|
}
|
||||||
arg.finish(output)
|
arg.finish(output)
|
||||||
|
@ -379,7 +380,6 @@ QtObject:
|
||||||
write = setCurrentAssetList
|
write = setCurrentAssetList
|
||||||
notify = currentAssetListChanged
|
notify = currentAssetListChanged
|
||||||
|
|
||||||
|
|
||||||
proc totalFiatBalanceChanged*(self: WalletView) {.signal.}
|
proc totalFiatBalanceChanged*(self: WalletView) {.signal.}
|
||||||
|
|
||||||
proc getTotalFiatBalance(self: WalletView): string {.slot.} =
|
proc getTotalFiatBalance(self: WalletView): string {.slot.} =
|
||||||
|
@ -526,10 +526,10 @@ QtObject:
|
||||||
self.currentAccountChanged()
|
self.currentAccountChanged()
|
||||||
|
|
||||||
proc removeCustomToken*(self: WalletView, tokenAddress: string) {.slot.} =
|
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
|
if t == nil: return
|
||||||
self.status.wallet.hideAsset(t.symbol)
|
self.status.wallet.hideAsset(t.symbol)
|
||||||
removeCustomToken(tokenAddress)
|
self.status.tokens.removeCustomToken(tokenAddress)
|
||||||
self.customTokenList.loadCustomTokens()
|
self.customTokenList.loadCustomTokens()
|
||||||
for account in self.status.wallet.accounts:
|
for account in self.status.wallet.accounts:
|
||||||
if account.address == self.currentAccount.address:
|
if account.address == self.currentAccount.address:
|
||||||
|
@ -699,12 +699,12 @@ QtObject:
|
||||||
|
|
||||||
proc decodeTokenApproval*(self: WalletView, tokenAddress: string, data: string): string {.slot.} =
|
proc decodeTokenApproval*(self: WalletView, tokenAddress: string, data: string): string {.slot.} =
|
||||||
let amount = data[74..len(data)-1]
|
let amount = data[74..len(data)-1]
|
||||||
let token = getToken(tokenAddress)
|
let token = self.status.tokens.getToken(tokenAddress)
|
||||||
|
|
||||||
if(token != nil):
|
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 $(%* {"symbol": token.symbol, "amount": amountDec})
|
||||||
|
|
||||||
return """{"error":"Unknown token address"}""";
|
return """{"error":"Unknown token address"}""";
|
||||||
|
|
||||||
proc isFetchingHistory*(self: WalletView): bool {.slot.} =
|
proc isFetchingHistory*(self: WalletView): bool {.slot.} =
|
||||||
|
|
|
@ -25,6 +25,9 @@ proc getSNTAddress*(): string =
|
||||||
proc getCustomTokens*(self: TokensModel, useCached: bool = true): seq[Erc20Contract] =
|
proc getCustomTokens*(self: TokensModel, useCached: bool = true): seq[Erc20Contract] =
|
||||||
result = status_tokens.getCustomTokens(useCached)
|
result = status_tokens.getCustomTokens(useCached)
|
||||||
|
|
||||||
|
proc removeCustomToken*(self: TokensModel, address: string) =
|
||||||
|
status_tokens.removeCustomToken(address)
|
||||||
|
|
||||||
proc getSNTBalance*(account: string): string =
|
proc getSNTBalance*(account: string): string =
|
||||||
result = status_tokens.getSNTBalance(account)
|
result = status_tokens.getSNTBalance(account)
|
||||||
|
|
||||||
|
@ -37,6 +40,13 @@ proc tokenName*(contract: Contract): string =
|
||||||
proc tokensymbol*(contract: Contract): string =
|
proc tokensymbol*(contract: Contract): string =
|
||||||
result = status_tokens.tokensymbol(contract)
|
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 newErc20Contract
|
||||||
export getErc20Contracts
|
export getErc20Contracts
|
||||||
export Erc20Contract
|
export Erc20Contract
|
||||||
|
export getErc20ContractByAddress
|
||||||
|
|
|
@ -374,3 +374,12 @@ proc watchTransaction*(self: WalletModel, transactionHash: string): string =
|
||||||
|
|
||||||
proc getPendingTransactions*(self: WalletModel): string =
|
proc getPendingTransactions*(self: WalletModel): string =
|
||||||
result = status_wallet.getPendingTransactions()
|
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)
|
||||||
|
|
Loading…
Reference in New Issue