clean up imports

This commit is contained in:
Iuri Matias 2020-06-23 08:32:56 -04:00
parent 74cb71295e
commit 8915230cd8
47 changed files with 140 additions and 280 deletions

View File

@ -1,14 +1,10 @@
import NimQml
import eventemitter, chronicles
import NimQml, eventemitter, chronicles
import ../../status/chat as chat_model
import ../../status/mailservers as mailserver_model
import ../../signals/types
import ../../status/libstatus/types as status_types
import ../../status/chat
import ../../status/contacts
import ../../status/status
import views/channels_list
import view
import ../../status/[chat, contacts, status]
import view, views/channels_list
logScope:
topics = "chat-controller"

View File

@ -1,7 +1,4 @@
import NimQml
import Tables
import json, sequtils
import chronicles
import NimQml, Tables, json, sequtils, chronicles
import ../../status/status
import ../../status/chat as status_chat
@ -9,9 +6,7 @@ import ../../status/contacts as status_contacts
import ../../status/chat/[chat, message]
import ../../status/profile/profile
import views/channels_list
import views/message_list
import views/chat_item
import views/channels_list, views/message_list, views/chat_item
logScope:
topics = "chats-view"

View File

@ -1,7 +1,5 @@
import NimQml
import std/wrapnils
import ../../../status/chat/chat
import ../../../status/status
import NimQml, std/wrapnils
import ../../../status/[chat/chat, status]
import chat_members
QtObject:

View File

@ -1,10 +1,4 @@
import NimQml, Tables
import json
import nimcrypto
import strformat
import json_serialization
import NimQml, Tables, json, nimcrypto, strformat, json_serialization
import ../../signals/types
import ../../status/libstatus/types as status_types
import ../../status/libstatus/accounts as status_accounts
@ -106,4 +100,4 @@ QtObject:
proc setLastLoginResponse*(self: LoginView, loginResponse: StatusGoError) =
self.loginResponseChanged(loginResponse.error)
proc onLoggedOut*(self: LoginView) {.signal.}
proc onLoggedOut*(self: LoginView) {.signal.}

View File

@ -1,8 +1,6 @@
import NimQml
import chronicles
import NimQml, chronicles
import ../../signals/types
import ../../status/node
import ../../status/status
import ../../status/[status, node]
import view
logScope:

View File

@ -1,6 +1,5 @@
import NimQml
import ../../status/node
import ../../status/status
import ../../status/[status, node]
QtObject:
type NodeView* = ref object of QObject

View File

@ -1,13 +1,10 @@
import NimQml
import NimQml, eventemitter, chronicles, std/wrapnils
import ../../status/libstatus/types as status_types
import ../../status/libstatus/accounts as status_accounts
import ../../status/accounts as AccountModel
import eventemitter
import view
import chronicles
import ../../signals/types
import std/wrapnils
import ../../status/status
import ../../signals/types
import view
type OnboardingController* = ref object of SignalSubscriber
view*: OnboardingView

View File

@ -1,14 +1,9 @@
import NimQml, Tables
import json
import nimcrypto
import NimQml, Tables, json, nimcrypto, strformat, json_serialization, strutils
import ../../status/libstatus/types as status_types
import ../../signals/types
import strformat
import json_serialization
import ../../status/accounts as AccountModel
import views/account_info
import strutils
import ../../status/status
import views/account_info
type
AccountRoles {.pure.} = enum

View File

@ -1,13 +1,10 @@
import NimQml
import json, eventemitter
import strutils
import NimQml, json, eventemitter, strutils
import ../../status/libstatus/mailservers as status_mailservers
import ../../signals/types
import "../../status/libstatus/types" as status_types
import ../../status/libstatus/types as status_types
import ../../status/libstatus/settings as status_settings
import ../../status/profile/[profile, mailserver]
import ../../status/contacts
import ../../status/status
import ../../status/[status, contacts]
import ../../status/chat as status_chat
import ../../status/chat/chat
import view

View File

@ -1,58 +1,58 @@
import NimQml
import mailserversList
# import NimQml
# import mailserversList
QtObject:
type ProfileView* = ref object of QObject
username*, identicon*, id*: string
mailserversList*: MailServersList
# QtObject:
# type ProfileView* = ref object of QObject
# username*, identicon*, id*: string
# mailserversList*: MailServersList
proc setup(self: ProfileView) =
self.QObject.setup
# proc setup(self: ProfileView) =
# self.QObject.setup
proc delete*(self: ProfileView) =
self.mailserversList.delete
self.QObject.delete
# proc delete*(self: ProfileView) =
# self.mailserversList.delete
# self.QObject.delete
proc newProfileView*(): ProfileView =
new(result, delete)
result.username = ""
result.identicon = ""
result.mailserversList = newMailServersList()
result.setup
# proc newProfileView*(): ProfileView =
# new(result, delete)
# result.username = ""
# result.identicon = ""
# result.mailserversList = newMailServersList()
# result.setup
proc username*(self: ProfileView): string {.slot.} =
result = self.username
# proc username*(self: ProfileView): string {.slot.} =
# result = self.username
proc receivedUsername*(self: ProfileView, username: string) {.signal.}
# proc receivedUsername*(self: ProfileView, username: string) {.signal.}
proc addMailserverToList*(self: ProfileView, name: string, endpoint: string) {.slot.} =
self.mailserversList.add(name, endpoint)
# proc addMailserverToList*(self: ProfileView, name: string, endpoint: string) {.slot.} =
# self.mailserversList.add(name, endpoint)
proc setUsername*(self: ProfileView, username: string) {.slot.} =
self.username = username
self.receivedUsername(username)
# proc setUsername*(self: ProfileView, username: string) {.slot.} =
# self.username = username
# self.receivedUsername(username)
QtProperty[string] username:
read = username
write = setUsername
notify = receivedUsername
# QtProperty[string] username:
# read = username
# write = setUsername
# notify = receivedUsername
proc identicon*(self: ProfileView): string {.slot.} =
result = self.identicon
# proc identicon*(self: ProfileView): string {.slot.} =
# result = self.identicon
proc getMailserversList(self: ProfileView): QVariant {.slot.} =
return newQVariant(self.mailserversList)
# proc getMailserversList(self: ProfileView): QVariant {.slot.} =
# return newQVariant(self.mailserversList)
QtProperty[QVariant] mailserversList:
read = getMailserversList
# QtProperty[QVariant] mailserversList:
# read = getMailserversList
proc receivedIdenticon*(self: ProfileView, identicon: string) {.signal.}
# proc receivedIdenticon*(self: ProfileView, identicon: string) {.signal.}
proc setIdenticon*(self: ProfileView, identicon: string) {.slot.} =
self.identicon = identicon
self.receivedIdenticon(identicon)
# proc setIdenticon*(self: ProfileView, identicon: string) {.slot.} =
# self.identicon = identicon
# self.receivedIdenticon(identicon)
QtProperty[string] identicon:
read = identicon
write = setIdenticon
notify = receivedIdenticon
# QtProperty[string] identicon:
# read = identicon
# write = setIdenticon
# notify = receivedIdenticon

View File

@ -1,8 +1,5 @@
import NimQml
import sequtils
import views/mailservers_list
import views/contact_list
import views/profile_info
import NimQml, sequtils
import views/[mailservers_list, contact_list, profile_info]
import ../../status/profile/[mailserver, profile]
import ../../status/profile as status_profile
import ../../status/contacts as status_contacts

View File

@ -1,19 +1,12 @@
import NimQml
import eventemitter
import strformat
import strutils
import chronicles
import NimQml, eventemitter, strformat, strutils, chronicles
import view
import views/asset_list
import views/account_list
import views/account_item
import views/[asset_list, account_list, account_item]
import ../../status/libstatus/wallet as status_wallet
import ../../signals/types
import ../../status/wallet
import ../../status/[status, wallet]
import ../../status/wallet/account as WalletTypes
import ../../status/status
type WalletController* = ref object of SignalSubscriber
status: Status

View File

@ -1,15 +1,6 @@
import NimQml
import Tables
import strformat
import strutils
import views/asset_list
import views/account_list
import views/account_item
import views/transaction_list
import views/collectibles_list
import ../../status/wallet
import ../../status/status
import chronicles
import NimQml, Tables, strformat, strutils, chronicles
import ../../status/[status, wallet]
import views/[asset_list, account_list, account_item, transaction_list, collectibles_list]
QtObject:
type

View File

@ -1,6 +1,5 @@
import NimQml
import std/wrapnils
import ../../../status/wallet
import NimQml, std/wrapnils
from ../../../status/wallet import WalletAccount
QtObject:
type AccountItemView* = ref object of QObject

View File

@ -1,9 +1,7 @@
import NimQml
import Tables
import NimQml, Tables, random
import sequtils as sequtils
import random
import ./account_item
import ../../../status/wallet
import account_item
from ../../../status/wallet import WalletAccount
const accountColors* = ["#9B832F", "#D37EF4", "#1D806F", "#FA6565", "#7CDA00", "#887af9", "#8B3131"]

View File

@ -1,6 +1,5 @@
import NimQml
import tables
import ../../../status/wallet
import NimQml, tables
from ../../../status/wallet import Asset
type
AssetRoles {.pure.} = enum

View File

@ -1,6 +1,5 @@
import NimQml
import tables
import ../../../status/wallet
import NimQml, tables
from ../../../status/wallet import Collectible
type
CollectiblesRoles {.pure.} = enum

View File

@ -1,6 +1,5 @@
import NimQml
import tables
import ../../../status/wallet
import NimQml, tables
from ../../../status/wallet import Transaction
type
TransactionRoles {.pure.} = enum
@ -86,4 +85,3 @@ QtObject:
proc forceUpdate*(self: TransactionList) =
self.beginResetModel()
self.endResetModel()

View File

@ -1,6 +1,4 @@
import NimQml
import eventemitter
import chronicles
import NimQml, eventemitter, chronicles
import app/chat/core as chat
import app/wallet/core as wallet
@ -10,8 +8,7 @@ import app/onboarding/core as onboarding
import app/login/core as login
import signals/core as signals
import status/libstatus/types
import status/libstatus/libstatus
import status/libstatus/[types, libstatus]
import status/status as statuslib
var signalsQObjPointer: pointer
@ -27,8 +24,6 @@ proc mainProc() =
let engine = newQQmlApplicationEngine()
let signalController = signals.newController(app)
# We need this global variable in order to be able to access the application
# from the non-closure callback passed to `libstatus.setSignalEventCallback`
signalsQObjPointer = cast[pointer](signalController.vptr)

View File

@ -1,14 +1,6 @@
import NimQml
import NimQml, tables, json, chronicles, strutils, json_serialization
import ../status/libstatus/types as status_types
import tables
import json
import types
import messages
import discovery
import chronicles
import whisperFilter
import strutils
import json_serialization
import types, messages, discovery, whisperFilter
logScope:
topics = "signals"
@ -20,7 +12,6 @@ QtObject:
signalSubscribers*: Table[SignalType, seq[SignalSubscriber]]
variant*: QVariant
# Constructor
proc newController*(app: QApplication): SignalsController =
new(result)
result.app = app

View File

@ -1,9 +1,8 @@
import json
import types
import json, random
import ../status/libstatus/accounts as status_accounts
import ../status/chat/[chat, message]
import ../status/profile/profile
import random
import types
proc toMessage*(jsonMsg: JsonNode): Message

View File

@ -1,10 +1,7 @@
import json
import chronicles
import json, chronicles, json_serialization, tables
import ../status/libstatus/types
import ../status/chat/[chat, message]
import ../status/profile/profile
import json_serialization
import tables
type SignalSubscriber* = ref object of RootObj

View File

@ -1,7 +1,6 @@
import eventemitter, options
import libstatus/accounts as status_accounts
import libstatus/types
import options
import eventemitter
type
AccountModel* = ref object

View File

@ -1,6 +1,5 @@
import eventemitter, json, strutils, sequtils, tables
import eventemitter, json, strutils, sequtils, tables, chronicles
import libstatus/chat as status_chat
import chronicles
import profile/profile
import chat/[chat, message]
import ../signals/messages

View File

@ -1,7 +1,5 @@
import message
import strformat
import json
import sequtils
import strformat, json, sequtils
from message import Message
type ChatType* {.pure.}= enum
Unknown = 0,
@ -110,4 +108,3 @@ proc isAdmin*(self: Chat, pubKey: string): bool =
for member in self.members:
if member.id == pubKey and member.joined and member.admin: return true
return false

View File

@ -1,6 +1,6 @@
import chronicles
import libp2p/[multihash, multicodec, cid]
from strutils import parseHexInt, removePrefix
from strutils import parseHexInt
logScope:
topics = "sticker-decoding"

View File

@ -1,8 +1,6 @@
import eventemitter
import json
import eventemitter, json, sequtils
import libstatus/contacts as status_contacts
import profile/profile
import sequtils
type
ContactModel* = ref object

View File

@ -16,4 +16,4 @@ proc userNameOrAlias*(contact: Profile): string =
if(contact.ensName != "" and contact.ensVerified):
result = "@" & userName(contact.ensName, true)
else:
result = contact.alias
result = contact.alias

View File

@ -1,14 +1,9 @@
import libstatus
import core
import json
import json, os, nimcrypto, uuids, json_serialization, chronicles
import libstatus, core
import utils as utils
import accounts/constants
import nimcrypto
import os
import uuids
import types as types
import json_serialization
import chronicles
import accounts/constants
import ../../signals/types as signal_types
import ../wallet/account

View File

@ -1,30 +1,19 @@
import core
import json
import utils
import times
import strutils
import sequtils
import chronicles
import json, times, strutils, sequtils, chronicles
import core, utils
import ../chat/[chat, message]
import ../../signals/messages
proc buildFilter*(chat: Chat):JsonNode =
if chat.chatType == ChatType.PrivateGroupChat:
return newJNull()
result = %* {
"ChatID": chat.id,
"OneToOne": chat.chatType == ChatType.OneToOne
}
result = %* { "ChatID": chat.id, "OneToOne": chat.chatType == ChatType.OneToOne }
proc loadFilters*(filters: seq[JsonNode]): string =
result = callPrivateRPC("loadFilters".prefix, %* [filter(filters, proc(x:JsonNode):bool = x.kind != JNull)])
proc removeFilters*(chatId: string, filterId: string) =
discard callPrivateRPC("removeFilters".prefix, %* [
[{
"ChatID": chatId,
"FilterID": filterId
}]
[{ "ChatID": chatId, "FilterID": filterId }]
])
proc saveChat*(chatId: string, oneToOne: bool = false, active: bool = true, color: string) =

View File

@ -1,7 +1,6 @@
import core
import json
import utils
import ../profile/profile
import core, utils
from ../profile/profile import Profile
# TODO: remove Profile from here
proc blockContact*(contact: Profile): string =

View File

@ -1,5 +1,4 @@
import sequtils, strformat, sugar, macros, tables
import eth/common/eth_types, stew/byteutils, nimcrypto
import sequtils, strformat, sugar, macros, tables, eth/common/eth_types, stew/byteutils, nimcrypto
from eth/common/utils import parseAddress
type

View File

@ -1,8 +1,5 @@
import json
import libstatus
import nimcrypto
import utils
import chronicles
import json, nimcrypto, chronicles
import libstatus, utils
logScope:
topics = "rpc"

View File

@ -1,7 +1,5 @@
import core
import json
import utils
import times
import json, times
import core, utils
proc getMailservers*(): array[0..8, (string, string)] =
result = [
@ -48,10 +46,7 @@ proc ping*(timeoutMs: int): string =
for mailserver in getMailservers():
addresses.add(mailserver[1])
result = callPrivateRPC("mailservers_ping", %* [
{
"addresses": addresses,
"timeoutMs": timeoutMs
}
{ "addresses": addresses, "timeoutMs": timeoutMs }
])
proc update*(peer: string) =
@ -60,7 +55,6 @@ proc update*(peer: string) =
proc delete*(peer: string) =
discard callPrivateRPC("mailservers_deleteMailserver".prefix, %* [[peer]])
proc requestMessages*(topics: seq[string], symKeyID: string, peer: string, numberOfMessages: int) =
echo callPrivateRPC("requestMessages".prefix, %* [
{
@ -72,4 +66,4 @@ proc requestMessages*(topics: seq[string], symKeyID: string, peer: string, numbe
"cursor": nil,
"from": (times.toUnix(times.getTime()) - 86400) # Unhardcode this. Need to keep the last fetch in a DB
}
])
])

View File

@ -1,5 +1,5 @@
import core
import json
import core
proc saveSettings*(key: string, value: string): string =
callPrivateRPC("settings_saveSetting", %* [

View File

@ -1,32 +1,27 @@
import core as status
import json
import chronicles
import strformat
import stint
import strutils
import wallet
import json, chronicles, strformat, stint, strutils
import core, wallet
logScope:
topics = "wallet"
proc getCustomTokens*(): JsonNode =
let payload = %* []
let response = status.callPrivateRPC("wallet_getCustomTokens", payload).parseJson
let response = callPrivateRPC("wallet_getCustomTokens", payload).parseJson
if response["result"].kind == JNull:
return %* []
return response["result"]
proc addCustomToken*(address: string, name: string, symbol: string, decimals: int, color: string) =
let payload = %* [{"address": address, "name": name, "symbol": symbol, "decimals": decimals, "color": color}]
discard status.callPrivateRPC("wallet_addCustomToken", payload)
discard callPrivateRPC("wallet_addCustomToken", payload)
proc removeCustomToken*(address: string) =
let payload = %* [address]
discard status.callPrivateRPC("wallet_deleteCustomToken", payload)
discard callPrivateRPC("wallet_deleteCustomToken", payload)
proc getTokensBalances*(accounts: openArray[string], tokens: openArray[string]): JsonNode =
let payload = %* [accounts, tokens]
let response = status.callPrivateRPC("wallet_getTokensBalances", payload).parseJson
let response = callPrivateRPC("wallet_getTokensBalances", payload).parseJson
if response["result"].kind == JNull:
return %* {}
response["result"]
@ -37,7 +32,7 @@ proc getTokenBalance*(tokenAddress: string, account: string): string =
let payload = %* [{
"to": tokenAddress, "from": account, "data": fmt"0x70a08231000000000000000000000000{postfixedAccount}"
}, "latest"]
let response = status.callPrivateRPC("eth_call", payload)
let response = callPrivateRPC("eth_call", payload)
let balance = response.parseJson["result"].getStr
result = $hex2Eth(balance)

View File

@ -1,5 +1,4 @@
import eventemitter
import json_serialization
import eventemitter, json_serialization
import accounts/constants
type SignalCallback* = proc(eventMessage: cstring): void {.cdecl.}
@ -91,4 +90,3 @@ type
value*: string
fromAddress*: string
to*: string

View File

@ -1,8 +1,5 @@
import json
import types
import random
import json, types, random, strutils
from times import getTime, toUnix, nanosecond
import strutils
import accounts/signing_phrases
proc isWakuEnabled(): bool =

View File

@ -1,12 +1,5 @@
import core as status
import json
# import utils
import httpclient, json
import strformat
import stint
import strutils, sequtils
import chronicles
import types
import json, httpclient, json, strformat, stint, strutils, sequtils, chronicles
import core, types
import ../wallet/account
proc getWalletAccounts*(): seq[WalletAccount] =
@ -35,10 +28,10 @@ proc getWalletAccounts*(): seq[WalletAccount] =
proc getTransfersByAddress*(address: string): seq[Transaction] =
try:
let response = status.getBlockByNumber("latest")
let response = getBlockByNumber("latest")
let latestBlock = parseJson(response)["result"]
let transactionsResponse = status.getTransfersByAddress(address, latestBlock["number"].getStr, "0x14")
let transactionsResponse = getTransfersByAddress(address, latestBlock["number"].getStr, "0x14")
let transactions = parseJson(transactionsResponse)["result"]
var accountTransactions: seq[Transaction] = @[]
@ -70,12 +63,12 @@ proc sendTransaction*(from_address: string, to: string, value: string, password:
"from": from_address,
"to": to
}
var response = status.sendTransaction($args, password)
var response = sendTransaction($args, password)
result = response
proc getBalance*(address: string): string =
let payload = %* [address, "latest"]
parseJson(status.callPrivateRPC("eth_getBalance", payload))["result"].str
parseJson(callPrivateRPC("eth_getBalance", payload))["result"].str
proc hex2Eth*(input: string): string =
var value = fromHex(Stuint[256], input)

View File

@ -1,13 +1,8 @@
import algorithm, json, random, math, os
import algorithm, json, random, math, os, tables, sets, chronicles, eventemitter, sequtils, locks
import libstatus/core as status_core
import libstatus/chat as status_chat
import libstatus/mailservers as status_mailservers
import tables
import sets
import chronicles
import eventemitter
import sequtils
import locks
logScope:
topics = "mailserver-model"

View File

@ -1,7 +1,4 @@
import eventemitter
# import json
# import strformat
# import strutils
import libstatus/core as status
type NodeModel* = ref object

View File

@ -1,5 +1,4 @@
import json
import eventemitter
import json, eventemitter
import libstatus/types
import profile/profile
import libstatus/core as libstatus_core

View File

@ -1,4 +1,3 @@
type
MailServer* = ref object
name*, endpoint*: string

View File

@ -4,8 +4,7 @@ import ../libstatus/types
type Profile* = ref object
id*, alias*, username*, identicon*, address*, ensName*: string
ensVerified*: bool
ensVerifiedAt*: int
ensVerificationRetries*: int
ensVerifiedAt*, ensVerificationRetries*: int
systemTags*: seq[string]
proc isContact*(self: Profile): bool =

View File

@ -1,4 +1,5 @@
import eventemitter, json, strformat, strutils, chronicles, sequtils
from eth/common/utils import parseAddress
import libstatus/accounts as status_accounts
import libstatus/tokens as status_tokens
import libstatus/settings as status_settings
@ -8,7 +9,6 @@ from libstatus/types import GeneratedAccount, DerivedAccount, Transaction
import wallet/balance_manager
import wallet/account
import wallet/collectibles
from eth/common/utils import parseAddress
export account, collectibles
export Transaction

View File

@ -1,4 +1,4 @@
import eventemitter
from eventemitter import Args
type Collectible* = ref object
name*, image*, id*: string

View File

@ -1,6 +1,5 @@
import strformat, httpclient, json, chronicles, sequtils, strutils, tables
import ../libstatus/core as status
import ../libstatus/contracts as contracts
import ../libstatus/[core, contracts]
import eth/common/eth_types
import account
@ -10,7 +9,7 @@ proc getTokenUri(contract: Contract, tokenId: int): string =
"to": $contract.address,
"data": contract.methods["tokenURI"].encodeAbi(tokenId)
}, "latest"]
let response = status.callPrivateRPC("eth_call", payload)
let response = callPrivateRPC("eth_call", payload)
var postfixedResult: string = parseJson($response)["result"].str
postfixedResult.removeSuffix('0')
postfixedResult.removePrefix("0x")
@ -28,7 +27,7 @@ proc tokenOfOwnerByIndex(contract: Contract, address: EthAddress, index: int): i
"to": $contract.address,
"data": contract.methods["tokenOfOwnerByIndex"].encodeAbi(address, index)
}, "latest"]
let response = status.callPrivateRPC("eth_call", payload)
let response = callPrivateRPC("eth_call", payload)
let res = parseJson($response)["result"].str
if (res == "0x"):
return -1
@ -68,7 +67,7 @@ proc getCryptoKitties*(address: EthAddress): seq[Collectible] =
proc getEthermons*(address: EthAddress): seq[Collectible] =
result = @[]
try:
let contract = contracts.getContract(Network.Mainnet, "ethermon")
let contract = getContract(Network.Mainnet, "ethermon")
let tokens = tokensOfOwnerByIndex(contract, address)
if (tokens.len == 0):
@ -92,7 +91,7 @@ proc getEthermons*(address: EthAddress): seq[Collectible] =
proc getKudos*(address: EthAddress): seq[Collectible] =
result = @[]
try:
let contract = contracts.getContract(Network.Mainnet, "kudos")
let contract = getContract(Network.Mainnet, "kudos")
let tokens = tokensOfOwnerByIndex(contract, address)
if (tokens.len == 0):
@ -114,7 +113,5 @@ proc getKudos*(address: EthAddress): seq[Collectible] =
except Exception as e:
error "Error getting Kudos", msg = e.msg
proc getAllCollectibles*(address: EthAddress): seq[Collectible] =
result = concat(getCryptoKitties(address), getEthermons(address), getKudos(address))