chores: move to backend part1
This commit is contained in:
parent
6ebd8cb1cc
commit
33216d5bb5
|
@ -6,7 +6,7 @@ import ../../../constants
|
|||
|
||||
import ../settings/service as settings_service
|
||||
import ../network/types
|
||||
import ../../../backend/about as status_about
|
||||
import ../../../backend/backend
|
||||
import ./update
|
||||
|
||||
include async_tasks
|
||||
|
@ -56,7 +56,7 @@ QtObject:
|
|||
|
||||
proc getNodeVersion*(self: Service): string =
|
||||
try:
|
||||
return status_about.getWeb3ClientVersion().result.getStr
|
||||
return backend.clientVersion().result.getStr
|
||||
except Exception as e:
|
||||
error "Error getting Node version"
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ type
|
|||
|
||||
const asyncActivityNotificationLoadTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
|
||||
let arg = decode[AsyncActivityNotificationLoadTaskArg](argEncoded)
|
||||
let activityNotificationsCallResult = status_activity_center.rpcActivityCenterNotifications(newJString(arg.cursor), arg.limit)
|
||||
let activityNotificationsCallResult = backend.activityCenterNotifications(newJString(arg.cursor), arg.limit)
|
||||
|
||||
let responseJson = %*{
|
||||
"activityNotifications": activityNotificationsCallResult.result
|
||||
|
|
|
@ -9,7 +9,7 @@ import json, tables, json_serialization
|
|||
|
||||
import ../chat/service as chat_service
|
||||
|
||||
import ../../../backend/activity_center as status_activity_center
|
||||
import ../../../backend/backend
|
||||
import ../../../backend/response_type
|
||||
import ./dto/notification
|
||||
|
||||
|
@ -112,7 +112,7 @@ QtObject:
|
|||
else:
|
||||
cursorVal = newJString(self.cursor)
|
||||
|
||||
let callResult = status_activity_center.rpcActivityCenterNotifications(cursorVal, DEFAULT_LIMIT)
|
||||
let callResult = backend.activityCenterNotifications(cursorVal, DEFAULT_LIMIT)
|
||||
let activityCenterNotificationsTuple = parseActivityCenterNotifications(callResult.result)
|
||||
|
||||
self.cursor = activityCenterNotificationsTuple[0];
|
||||
|
@ -125,7 +125,7 @@ QtObject:
|
|||
markAsReadProps: MarkAsReadNotificationProperties
|
||||
): string =
|
||||
try:
|
||||
discard status_activity_center.markActivityCenterNotificationsRead(@[notificationId])
|
||||
discard backend.markActivityCenterNotificationsRead(@[notificationId])
|
||||
self.events.emit(SIGNAL_MARK_NOTIFICATIONS_AS_READ, markAsReadProps)
|
||||
except Exception as e:
|
||||
error "Error marking as read", msg = e.msg
|
||||
|
@ -133,7 +133,7 @@ QtObject:
|
|||
|
||||
proc unreadActivityCenterNotificationsCount*(self: Service): int =
|
||||
try:
|
||||
let response = status_activity_center.unreadActivityCenterNotificationsCount()
|
||||
let response = backend.unreadActivityCenterNotificationsCount()
|
||||
|
||||
if response.result.kind != JNull:
|
||||
return response.result.getInt
|
||||
|
@ -146,7 +146,7 @@ QtObject:
|
|||
markAsUnreadProps: MarkAsUnreadNotificationProperties
|
||||
): string =
|
||||
try:
|
||||
discard status_activity_center.markActivityCenterNotificationsUnread(@[notificationId])
|
||||
discard backend.markActivityCenterNotificationsUnread(@[notificationId])
|
||||
self.events.emit(SIGNAL_MARK_NOTIFICATIONS_AS_UNREAD, markAsUnreadProps)
|
||||
except Exception as e:
|
||||
error "Error marking as unread", msg = e.msg
|
||||
|
@ -154,7 +154,7 @@ QtObject:
|
|||
|
||||
proc markAllActivityCenterNotificationsRead*(self: Service, initialLoad: bool = true):string =
|
||||
try:
|
||||
discard status_activity_center.markAllActivityCenterNotificationsRead()
|
||||
discard backend.markAllActivityCenterNotificationsRead()
|
||||
# This proc should accept ActivityCenterNotificationType in order to clear all notifications
|
||||
# per type, that's why we have this part here. If we add all types to notificationsType that
|
||||
# means that we need to clear all notifications for all types.
|
||||
|
@ -181,7 +181,7 @@ QtObject:
|
|||
|
||||
proc acceptActivityCenterNotifications*(self: Service, notificationIds: seq[string]): string =
|
||||
try:
|
||||
let response = status_activity_center.acceptActivityCenterNotifications(notificationIds)
|
||||
let response = backend.acceptActivityCenterNotifications(notificationIds)
|
||||
|
||||
let (chats, messages) = self.chatService.parseChatResponse(response)
|
||||
self.events.emit(chat_service.SIGNAL_CHAT_UPDATE,
|
||||
|
@ -193,7 +193,7 @@ QtObject:
|
|||
|
||||
proc dismissActivityCenterNotifications*(self: Service, notificationIds: seq[string]): string =
|
||||
try:
|
||||
discard status_activity_center.dismissActivityCenterNotifications(notificationIds)
|
||||
discard backend.dismissActivityCenterNotifications(notificationIds)
|
||||
self.events.emit(SIGNAL_MARK_NOTIFICATIONS_AS_DISMISSED,
|
||||
MarkAsDismissedNotificationProperties(notificationIds: notificationIds))
|
||||
except Exception as e:
|
||||
|
|
|
@ -2,7 +2,7 @@ import Tables, json, sequtils, strformat, chronicles
|
|||
import result
|
||||
include ../../common/json_utils
|
||||
import ./dto/bookmark as bookmark_dto
|
||||
import ../../../backend/bookmarks as status_go
|
||||
import ../../../backend/backend
|
||||
|
||||
export bookmark_dto
|
||||
|
||||
|
@ -24,7 +24,7 @@ proc newService*(): Service =
|
|||
|
||||
proc init*(self: Service) =
|
||||
try:
|
||||
let response = status_go.getBookmarks()
|
||||
let response = backend.getBookmarks()
|
||||
for bookmark in response.result.getElems().mapIt(it.toBookmarkDto()):
|
||||
self.bookmarks[bookmark.url] = bookmark
|
||||
|
||||
|
@ -37,7 +37,7 @@ proc getBookmarks*(self: Service): seq[BookmarkDto] =
|
|||
|
||||
proc storeBookmark*(self: Service, url, name: string): R =
|
||||
try:
|
||||
let response = status_go.storeBookmark(url, name).result
|
||||
let response = backend.storeBookmark(backend.Bookmark(name: name, url: url)).result
|
||||
self.bookmarks[url] = BookmarkDto()
|
||||
self.bookmarks[url].url = url
|
||||
self.bookmarks[url].name = name
|
||||
|
@ -52,7 +52,7 @@ proc deleteBookmark*(self: Service, url: string): bool =
|
|||
try:
|
||||
if not self.bookmarks.hasKey(url):
|
||||
return
|
||||
discard status_go.deleteBookmark(url)
|
||||
discard backend.deleteBookmark(url)
|
||||
self.bookmarks.del(url)
|
||||
except Exception as e:
|
||||
let errDescription = e.msg
|
||||
|
@ -65,7 +65,7 @@ proc updateBookmark*(self: Service, oldUrl, newUrl, newName: string): R =
|
|||
if not self.bookmarks.hasKey(oldUrl):
|
||||
return
|
||||
|
||||
let response = status_go.updateBookmark(oldUrl, newUrl, newName).result
|
||||
let response = backend.updateBookmark(oldUrl, backend.Bookmark(name: newName, url: newUrl)).result
|
||||
self.bookmarks.del(oldUrl)
|
||||
self.bookmarks[newUrl] = BookmarkDto()
|
||||
self.bookmarks[newUrl].url = newUrl
|
||||
|
|
|
@ -3,7 +3,7 @@ import chronicles, sequtils, json
|
|||
import dto
|
||||
import ../settings/service as settings_service
|
||||
|
||||
import ../../../backend/collectibles as collectibles
|
||||
import ../../../backend/backend
|
||||
|
||||
export dto
|
||||
|
||||
|
@ -29,7 +29,7 @@ proc init*(self: Service) =
|
|||
proc getCollections*(self: Service, address: string): seq[CollectionDto] =
|
||||
try:
|
||||
let networkId = self.settingsService.getCurrentNetworkId()
|
||||
let response = collectibles.getOpenseaCollections(networkId, address)
|
||||
let response = backend.getOpenseaCollectionsByOwner(networkId, address)
|
||||
return map(response.result.getElems(), proc(x: JsonNode): CollectionDto = x.toCollectionDto())
|
||||
except Exception as e:
|
||||
let errDesription = e.msg
|
||||
|
@ -39,7 +39,7 @@ proc getCollections*(self: Service, address: string): seq[CollectionDto] =
|
|||
proc getCollectibles*(self: Service, address: string, collectionSlug: string): seq[CollectibleDto] =
|
||||
try:
|
||||
let networkId = self.settingsService.getCurrentNetworkId()
|
||||
let response = collectibles.getOpenseaAssets(networkId, address, collectionSlug, limit)
|
||||
let response = backend.getOpenseaAssetsByOwnerAndCollection(networkId, address, collectionSlug, limit)
|
||||
return map(response.result.getElems(), proc(x: JsonNode): CollectibleDto = x.toCollectibleDto())
|
||||
except Exception as e:
|
||||
let errDesription = e.msg
|
||||
|
|
|
@ -3,7 +3,7 @@ import sets
|
|||
import result
|
||||
import options
|
||||
include ../../common/json_utils
|
||||
import ../../../backend/permissions as status_go
|
||||
import ../../../backend/backend
|
||||
import dto/dapp
|
||||
import dto/permission
|
||||
|
||||
|
@ -28,7 +28,7 @@ proc newService*(): Service =
|
|||
|
||||
proc init*(self: Service) =
|
||||
try:
|
||||
let response = status_go.getDappPermissions()
|
||||
let response = backend.getDappPermissions()
|
||||
for dapp in response.result.getElems().mapIt(it.toDapp()):
|
||||
if dapp.address == "":
|
||||
continue
|
||||
|
@ -48,7 +48,7 @@ proc getDapp*(self: Service, name: string, address: string): Option[Dapp] =
|
|||
|
||||
return none(Dapp)
|
||||
|
||||
proc addPermission*(self: Service, name: string, address: string, permission: Permission): R =
|
||||
proc addPermission*(self: Service, name: string, address: string, perm: permission.Permission): R =
|
||||
let key = name & address
|
||||
|
||||
try:
|
||||
|
@ -56,12 +56,16 @@ proc addPermission*(self: Service, name: string, address: string, permission: Pe
|
|||
self.dapps[key] = Dapp(
|
||||
name: name,
|
||||
address: address,
|
||||
permissions: initHashSet[Permission]()
|
||||
permissions: initHashSet[permission.Permission]()
|
||||
)
|
||||
|
||||
self.dapps[key].permissions.incl(permission)
|
||||
self.dapps[key].permissions.incl(perm)
|
||||
let permissions = self.dapps[key].permissions.toSeq().mapIt($it)
|
||||
discard status_go.addDappPermissions(name, address, permissions)
|
||||
discard backend.addDappPermissions(backend.Permission(
|
||||
dapp: name,
|
||||
address: address,
|
||||
permissions: permissions
|
||||
))
|
||||
result.ok self.dapps[key]
|
||||
except Exception as e:
|
||||
let errDescription = e.msg
|
||||
|
@ -69,11 +73,11 @@ proc addPermission*(self: Service, name: string, address: string, permission: Pe
|
|||
result.err errDescription
|
||||
|
||||
|
||||
proc hasPermission*(self: Service, dapp: string, address: string, permission: Permission): bool =
|
||||
proc hasPermission*(self: Service, dapp: string, address: string, perm: permission.Permission): bool =
|
||||
let key = dapp & address
|
||||
if not self.dapps.hasKey(key):
|
||||
return false
|
||||
return self.dapps[key].permissions.contains(permission)
|
||||
return self.dapps[key].permissions.contains(perm)
|
||||
|
||||
proc disconnect*(self: Service, dappName: string): bool =
|
||||
try:
|
||||
|
@ -82,7 +86,7 @@ proc disconnect*(self: Service, dappName: string): bool =
|
|||
if dapp.name != dappName:
|
||||
continue
|
||||
|
||||
discard status_go.deleteDappPermissions(dapp.name, dapp.address)
|
||||
discard backend.deleteDappPermissionsByNameAndAddress(dapp.name, dapp.address)
|
||||
addresses.add(dapp.address)
|
||||
|
||||
for address in addresses:
|
||||
|
@ -99,25 +103,29 @@ proc disconnectAddress*(self: Service, dappName: string, address: string): bool
|
|||
return
|
||||
|
||||
try:
|
||||
discard status_go.deleteDappPermissions(dappName, address)
|
||||
discard backend.deleteDappPermissionsByNameAndAddress(dappName, address)
|
||||
self.dapps.del(key)
|
||||
return true
|
||||
except Exception as e:
|
||||
let errDescription = e.msg
|
||||
error "error: ", errDescription
|
||||
|
||||
proc removePermission*(self: Service, name: string, address: string, permission: Permission): bool =
|
||||
proc removePermission*(self: Service, name: string, address: string, perm: permission.Permission): bool =
|
||||
let key = name & address
|
||||
if not self.dapps.hasKey(key):
|
||||
return
|
||||
|
||||
try:
|
||||
if self.dapps[key].permissions.contains(permission):
|
||||
self.dapps[key].permissions.excl(permission)
|
||||
if self.dapps[key].permissions.contains(perm):
|
||||
self.dapps[key].permissions.excl(perm)
|
||||
if self.dapps[key].permissions.len > 0:
|
||||
discard status_go.addDappPermissions(name, address, self.dapps[key].permissions.toSeq().mapIt($it))
|
||||
discard backend.addDappPermissions(backend.Permission(
|
||||
dapp: name,
|
||||
address: address,
|
||||
permissions: self.dapps[key].permissions.toSeq().mapIt($it)
|
||||
))
|
||||
else:
|
||||
discard status_go.deleteDappPermissions(name, address)
|
||||
discard backend.deleteDappPermissionsByNameAndAddress(name, address)
|
||||
self.dapps.del(key)
|
||||
return true
|
||||
except Exception as e:
|
||||
|
|
|
@ -7,7 +7,7 @@ import chronicles
|
|||
import sequtils
|
||||
|
||||
import ../settings/service as settings_service
|
||||
import ../../../backend/gif as status_gif
|
||||
import ../../../backend/backend
|
||||
import ./dto
|
||||
|
||||
logScope:
|
||||
|
@ -43,7 +43,7 @@ proc newService*(settingsService: settings_service.Service): Service =
|
|||
|
||||
proc setTenorAPIKey(self: Service) =
|
||||
try:
|
||||
let response = status_gif.setTenorAPIKey(TENOR_API_KEY_RESOLVED)
|
||||
let response = backend.setTenorAPIKey(TENOR_API_KEY_RESOLVED)
|
||||
if(not response.error.isNil):
|
||||
error "error setTenorAPIKey: ", errDescription = response.error.message
|
||||
|
||||
|
@ -52,7 +52,7 @@ proc setTenorAPIKey(self: Service) =
|
|||
|
||||
proc getRecentGifs(self: Service) =
|
||||
try:
|
||||
let response = status_gif.getRecentGifs()
|
||||
let response = backend.getRecentGifs()
|
||||
|
||||
if(not response.error.isNil):
|
||||
error "error getRecentGifs: ", errDescription = response.error.message
|
||||
|
@ -64,7 +64,7 @@ proc getRecentGifs(self: Service) =
|
|||
|
||||
proc getFavoriteGifs(self: Service) =
|
||||
try:
|
||||
let response = status_gif.getFavoriteGifs()
|
||||
let response = backend.getFavoriteGifs()
|
||||
|
||||
if(not response.error.isNil):
|
||||
error "error getFavoriteGifs: ", errDescription = response.error.message
|
||||
|
@ -84,7 +84,7 @@ proc init*(self: Service) =
|
|||
|
||||
proc tenorQuery(self: Service, path: string): seq[GifDto] =
|
||||
try:
|
||||
let response = status_gif.fetchGifs(path)
|
||||
let response = backend.fetchGifs(path)
|
||||
let doc = response.result.str.parseJson()
|
||||
|
||||
var items: seq[GifDto] = @[]
|
||||
|
@ -122,7 +122,7 @@ proc addToRecents*(self: Service, gifDto: GifDto) =
|
|||
|
||||
self.recents = newRecents
|
||||
let recent = %*{"items": map(newRecents, toJsonNode)}
|
||||
discard status_gif.updateRecentGifs(recent)
|
||||
discard backend.updateRecentGifs(recent)
|
||||
|
||||
proc getFavorites*(self: Service): seq[GifDto] =
|
||||
return self.favorites
|
||||
|
@ -149,4 +149,4 @@ proc toggleFavorite*(self: Service, gifDto: GifDto) =
|
|||
|
||||
self.favorites = newFavorites
|
||||
let favorites = %*{"items": map(newFavorites, toJsonNode)}
|
||||
discard status_gif.updateFavoriteGifs(favorites)
|
||||
discard backend.updateFavoriteGifs(favorites)
|
||||
|
|
|
@ -2,7 +2,7 @@ import json, json_serialization, chronicles, atomics
|
|||
|
||||
import ../../../app/core/eventemitter
|
||||
import ../../../app/global/global_singleton
|
||||
import ../../../backend/network as status_network
|
||||
import ../../../backend/backend as backend
|
||||
import ../settings/service as settings_service
|
||||
|
||||
import dto, types
|
||||
|
@ -37,8 +37,7 @@ proc getNetworks*(self: Service, useCached: bool = true): seq[NetworkDto] =
|
|||
if useCached and not cacheIsDirty:
|
||||
result = self.networks
|
||||
else:
|
||||
let payload = %* [false]
|
||||
let response = status_network.getNetworks(payload)
|
||||
let response = backend.getEthereumChains(false)
|
||||
if not response.error.isNil:
|
||||
raise newException(Exception, "Error getting networks: " & response.error.message)
|
||||
result = if response.result.isNil or response.result.kind == JNull: @[]
|
||||
|
@ -60,11 +59,11 @@ proc getEnabledNetworks*(self: Service): seq[NetworkDto] =
|
|||
result.add(network)
|
||||
|
||||
proc upsertNetwork*(self: Service, network: NetworkDto) =
|
||||
discard status_network.upsertNetwork(network.toPayload())
|
||||
discard backend.addEthereumChain(network.toPayload())
|
||||
self.dirty.store(true)
|
||||
|
||||
proc deleteNetwork*(self: Service, network: NetworkDto) =
|
||||
discard status_network.deleteNetwork(%* [network.chainId])
|
||||
discard backend.deleteEthereumChain(%* [network.chainId])
|
||||
self.dirty.store(true)
|
||||
|
||||
proc getNetwork*(self: Service, chainId: int): NetworkDto =
|
||||
|
|
|
@ -3,7 +3,7 @@ import chronicles, sequtils, json
|
|||
import dto
|
||||
|
||||
import ../../../app/core/eventemitter
|
||||
import ../../../backend/saved_addresses as backend
|
||||
import ../../../backend/backend
|
||||
|
||||
export dto
|
||||
|
||||
|
@ -45,11 +45,7 @@ proc getSavedAddresses*(self: Service): seq[SavedAddressDto] =
|
|||
|
||||
proc createOrUpdateSavedAddress*(self: Service, name, address: string): string =
|
||||
try:
|
||||
let response = backend.addSavedAddress(name, address)
|
||||
|
||||
if not response.error.isNil:
|
||||
raise newException(Exception, response.error.message)
|
||||
|
||||
discard backend.addSavedAddress(backend.SavedAddress(name: name, address: address))
|
||||
self.fetchAddresses()
|
||||
self.events.emit(SIGNAL_SAVED_ADDRESS_CHANGED, Args())
|
||||
return ""
|
||||
|
|
|
@ -4,7 +4,6 @@ from sugar import `=>`
|
|||
import web3/ethtypes
|
||||
from web3/conversions import `$`
|
||||
import ../../../backend/backend as backend
|
||||
import ../../../backend/tokens as token_backend
|
||||
|
||||
import ../settings/service as settings_service
|
||||
import ../network/service as network_service
|
||||
|
@ -79,7 +78,7 @@ QtObject:
|
|||
else:
|
||||
activeTokenSymbols[network.chainId] = @[]
|
||||
|
||||
let responseTokens = token_backend.getTokens(network.chainId)
|
||||
let responseTokens = backend.getTokens(network.chainId)
|
||||
let default_tokens = map(
|
||||
responseTokens.result.getElems(),
|
||||
proc(x: JsonNode): TokenDto = x.toTokenDto(activeTokenSymbols[network.chainId], hasIcon=true, isCustom=false)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import NimQml, chronicles, sequtils, sugar, stint, strutils, json, strformat, algorithm, math
|
||||
import ../../../backend/transactions as transactions
|
||||
import ../../../backend/wallet as status_wallet
|
||||
import ../../../backend/backend
|
||||
import ../../../backend/eth
|
||||
|
||||
import ../ens/utils as ens_utils
|
||||
|
@ -159,7 +159,7 @@ QtObject:
|
|||
try:
|
||||
# this may be improved (need to add some checkings) but due to removing `status-lib` dependencies, channges made
|
||||
# in this go are as minimal as possible
|
||||
let response = status_wallet.getPendingTransactions()
|
||||
let response = backend.getPendingTransactions()
|
||||
return response.result
|
||||
except Exception as e:
|
||||
let errDescription = e.msg
|
||||
|
|
|
@ -11,8 +11,7 @@ import dto
|
|||
|
||||
import ../../../app/core/eventemitter
|
||||
import ../../../backend/accounts as status_go_accounts
|
||||
import ../../../backend/tokens as status_go_tokens
|
||||
import ../../../backend/wallet as status_go_wallet
|
||||
import ../../../backend/backend as backend
|
||||
import ../../../backend/eth as status_go_eth
|
||||
import ../../../backend/cache
|
||||
|
||||
|
@ -154,7 +153,7 @@ proc getPrice*(self: Service, crypto: string, fiat: string): float64 =
|
|||
var prices = initTable[string, float]()
|
||||
|
||||
try:
|
||||
let response = status_go_wallet.fetchPrices(@[crypto], fiat)
|
||||
let response = backend.fetchPrices(@[crypto], fiat)
|
||||
for (symbol, value) in response.result.pairs:
|
||||
prices[symbol] = value.getFloat
|
||||
self.priceCache.set(cacheKey, $value.getFloat)
|
||||
|
@ -177,7 +176,7 @@ proc fetchPrices(self: Service): Table[string, float] =
|
|||
|
||||
var prices = initTable[string, float]()
|
||||
try:
|
||||
let response = status_go_wallet.fetchPrices(symbols, currency)
|
||||
let response = backend.fetchPrices(symbols, currency)
|
||||
for (symbol, value) in response.result.pairs:
|
||||
prices[symbol] = value.getFloat
|
||||
|
||||
|
@ -191,7 +190,7 @@ proc fetchBalances(self: Service, accounts: seq[string]): JsonNode =
|
|||
let visibleTokens = self.tokenService.getVisibleTokens()
|
||||
let tokens = visibleTokens.map(t => t.addressAsString())
|
||||
let chainIds = visibleTokens.map(t => t.chainId)
|
||||
return status_go_tokens.getBalances(chainIds, accounts, tokens).result
|
||||
return backend.getTokensBalancesForChainIDs(chainIds, accounts, tokens).result
|
||||
|
||||
proc refreshBalances(self: Service) =
|
||||
let prices = self.fetchPrices()
|
||||
|
@ -251,8 +250,8 @@ proc addNewAccountToLocalStore(self: Service) =
|
|||
|
||||
proc generateNewAccount*(self: Service, password: string, accountName: string, color: string, emoji: string): string =
|
||||
try:
|
||||
discard status_go_wallet.generateAccount(
|
||||
password,
|
||||
discard backend.generateAccount(
|
||||
hashPassword(password),
|
||||
accountName,
|
||||
color,
|
||||
emoji)
|
||||
|
@ -263,9 +262,9 @@ proc generateNewAccount*(self: Service, password: string, accountName: string, c
|
|||
|
||||
proc addAccountsFromPrivateKey*(self: Service, privateKey: string, password: string, accountName: string, color: string, emoji: string): string =
|
||||
try:
|
||||
discard status_go_wallet.addAccountWithPrivateKey(
|
||||
discard backend.addAccountWithPrivateKey(
|
||||
privateKey,
|
||||
password,
|
||||
hashPassword(password),
|
||||
accountName,
|
||||
color,
|
||||
emoji
|
||||
|
@ -277,9 +276,9 @@ proc addAccountsFromPrivateKey*(self: Service, privateKey: string, password: str
|
|||
|
||||
proc addAccountsFromSeed*(self: Service, mnemonic: string, password: string, accountName: string, color: string, emoji: string): string =
|
||||
try:
|
||||
discard status_go_wallet.addAccountWithMnemonic(
|
||||
discard backend.addAccountWithMnemonic(
|
||||
mnemonic,
|
||||
password,
|
||||
hashPassword(password),
|
||||
accountName,
|
||||
color,
|
||||
emoji
|
||||
|
@ -291,7 +290,7 @@ proc addAccountsFromSeed*(self: Service, mnemonic: string, password: string, acc
|
|||
|
||||
proc addWatchOnlyAccount*(self: Service, address: string, accountName: string, color: string, emoji: string): string =
|
||||
try:
|
||||
discard status_go_wallet.addAccountWatch(
|
||||
discard backend.addAccountWatch(
|
||||
address,
|
||||
accountName,
|
||||
color,
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
import json
|
||||
import ./core
|
||||
import response_type
|
||||
|
||||
export response_type
|
||||
|
||||
proc getWeb3ClientVersion*(): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
result = callPrivateRPC("web3_clientVersion")
|
|
@ -1,27 +0,0 @@
|
|||
import json
|
||||
import core, utils
|
||||
import response_type
|
||||
|
||||
export response_type
|
||||
|
||||
proc rpcActivityCenterNotifications*(cursorVal: JsonNode, limit: int): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
callPrivateRPC("activityCenterNotifications".prefix, %* [cursorVal, limit])
|
||||
|
||||
|
||||
proc markAllActivityCenterNotificationsRead*(): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
callPrivateRPC("markAllActivityCenterNotificationsRead".prefix, %*[])
|
||||
|
||||
proc markActivityCenterNotificationsRead*(ids: seq[string]): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
callPrivateRPC("markActivityCenterNotificationsRead".prefix, %*[ids])
|
||||
|
||||
proc markActivityCenterNotificationsUnread*(ids: seq[string]): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
callPrivateRPC("markActivityCenterNotificationsUnread".prefix, %*[ids])
|
||||
|
||||
proc acceptActivityCenterNotifications*(ids: seq[string]): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
callPrivateRPC("acceptActivityCenterNotifications".prefix, %*[ids])
|
||||
|
||||
proc dismissActivityCenterNotifications*(ids: seq[string]): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
result = callPrivateRPC("dismissActivityCenterNotifications".prefix, %*[ids])
|
||||
|
||||
proc unreadActivityCenterNotificationsCount*(): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
callPrivateRPC("unreadActivityCenterNotificationsCount".prefix, %*[])
|
|
@ -13,6 +13,22 @@ type
|
|||
decimals* {.serializedFieldName("decimals").}: int
|
||||
color* {.serializedFieldName("color").}: string
|
||||
|
||||
Bookmark* = ref object of RootObj
|
||||
name* {.serializedFieldName("name").}: string
|
||||
url* {.serializedFieldName("url").}: string
|
||||
|
||||
Permission* = ref object of RootObj
|
||||
dapp* {.serializedFieldName("dapp").}: string
|
||||
address* {.serializedFieldName("address").}: string
|
||||
permissions* {.serializedFieldName("permissions").}: seq[string]
|
||||
|
||||
SavedAddress* = ref object of RootObj
|
||||
name* {.serializedFieldName("name").}: string
|
||||
address* {.serializedFieldName("address").}: string
|
||||
|
||||
rpc(clientVersion, "web3"):
|
||||
discard
|
||||
|
||||
rpc(getCustomTokens, "wallet"):
|
||||
discard
|
||||
|
||||
|
@ -22,3 +38,135 @@ rpc(deleteCustomTokenByChainID, "wallet"):
|
|||
|
||||
rpc(addCustomToken, "wallet"):
|
||||
token: Token
|
||||
|
||||
rpc(getOpenseaCollectionsByOwner, "wallet"):
|
||||
chainId: int
|
||||
address: string
|
||||
|
||||
rpc(getOpenseaAssetsByOwnerAndCollection, "wallet"):
|
||||
chainId: int
|
||||
address: string
|
||||
collectionSlug: string
|
||||
limit: int
|
||||
|
||||
rpc(getEthereumChains, "wallet"):
|
||||
onlyEnabled: bool
|
||||
|
||||
rpc(addEthereumChain, "wallet"):
|
||||
payload: JsonNode
|
||||
|
||||
rpc(deleteEthereumChain, "wallet"):
|
||||
payload: JsonNode
|
||||
|
||||
rpc(addSavedAddress, "wallet"):
|
||||
savedAddress: SavedAddress
|
||||
|
||||
rpc(deleteSavedAddress, "wallet"):
|
||||
address: string
|
||||
|
||||
rpc(getSavedAddresses, "wallet"):
|
||||
discard
|
||||
|
||||
rpc(getTokens, "wallet"):
|
||||
chainId: int
|
||||
|
||||
rpc(getTokensBalancesForChainIDs, "wallet"):
|
||||
chainIds: seq[int]
|
||||
accounts: seq[string]
|
||||
tokens: seq[string]
|
||||
|
||||
rpc(getPendingTransactions, "wallet"):
|
||||
discard
|
||||
|
||||
rpc(fetchPrices, "wallet"):
|
||||
symbols: seq[string]
|
||||
currency: string
|
||||
|
||||
rpc(generateAccount, "accounts"):
|
||||
password: string
|
||||
name: string
|
||||
color: string
|
||||
emoji: string
|
||||
|
||||
rpc(addAccountWithMnemonic, "accounts"):
|
||||
mnemonic: string
|
||||
password: string
|
||||
name: string
|
||||
color: string
|
||||
emoji: string
|
||||
|
||||
rpc(addAccountWithPrivateKey, "accounts"):
|
||||
privateKey: string
|
||||
password: string
|
||||
name: string
|
||||
color: string
|
||||
emoji: string
|
||||
|
||||
rpc(addAccountWatch, "accounts"):
|
||||
address: string
|
||||
name: string
|
||||
color: string
|
||||
emoji: string
|
||||
|
||||
rpc(activityCenterNotifications, "wakuext"):
|
||||
cursorVal: JsonNode
|
||||
limit: int
|
||||
|
||||
rpc(markAllActivityCenterNotificationsRead, "wakuext"):
|
||||
discard
|
||||
|
||||
rpc(markActivityCenterNotificationsRead, "wakuext"):
|
||||
ids: seq[string]
|
||||
|
||||
rpc(markActivityCenterNotificationsUnread, "wakuext"):
|
||||
ids: seq[string]
|
||||
|
||||
rpc(acceptActivityCenterNotifications, "wakuext"):
|
||||
ids: seq[string]
|
||||
|
||||
rpc(dismissActivityCenterNotifications, "wakuext"):
|
||||
ids: seq[string]
|
||||
|
||||
rpc(unreadActivityCenterNotificationsCount, "wakuext"):
|
||||
discard
|
||||
|
||||
rpc(getBookmarks, "browsers"):
|
||||
discard
|
||||
|
||||
rpc(storeBookmark, "browsers"):
|
||||
bookmark: Bookmark
|
||||
|
||||
rpc(updateBookmark, "browsers"):
|
||||
originalUrl: string
|
||||
bookmark: Bookmark
|
||||
|
||||
rpc(deleteBookmark, "browsers"):
|
||||
url: string
|
||||
|
||||
rpc(setTenorAPIKey, "gif"):
|
||||
key: string
|
||||
|
||||
rpc(fetchGifs, "gif"):
|
||||
path: string
|
||||
|
||||
rpc(updateRecentGifs, "gif"):
|
||||
recentGifs: JsonNode
|
||||
|
||||
rpc(updateFavoriteGifs, "gif"):
|
||||
favoriteGifs: JsonNode
|
||||
|
||||
rpc(getRecentGifs, "gif"):
|
||||
discard
|
||||
|
||||
rpc(getFavoriteGifs, "gif"):
|
||||
discard
|
||||
|
||||
rpc(getDappPermissions, "permissions"):
|
||||
discard
|
||||
|
||||
rpc(addDappPermissions, "permissions"):
|
||||
permission: Permission
|
||||
|
||||
rpc(deleteDappPermissionsByNameAndAddress, "permissions"):
|
||||
dapp: string
|
||||
address: string
|
|
@ -1,21 +0,0 @@
|
|||
import json
|
||||
import core
|
||||
import response_type
|
||||
|
||||
export response_type
|
||||
|
||||
proc getBookmarks*(): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
let payload = %* []
|
||||
result = callPrivateRPC("browsers_getBookmarks", payload)
|
||||
|
||||
proc storeBookmark*(url, name: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
let payload = %* [{"url": url, "name": name}]
|
||||
result = callPrivateRPC("browsers_storeBookmark", payload)
|
||||
|
||||
proc deleteBookmark*(url: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
let payload = %* [url]
|
||||
result = callPrivateRPC("browsers_deleteBookmark", payload)
|
||||
|
||||
proc updateBookmark*(originalUrl, newUrl, name: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
let payload = %* [originalUrl, {"url": newUrl, "name": name}]
|
||||
result = callPrivateRPC("browsers_updateBookmark", payload)
|
|
@ -1,14 +0,0 @@
|
|||
import json
|
||||
import ./core, ./response_type
|
||||
|
||||
export response_type
|
||||
|
||||
proc getOpenseaCollections*(chainId: int, address: string): RpcResponse[JsonNode] =
|
||||
let payload = %* [chainId, address]
|
||||
return callPrivateRPC("wallet_getOpenseaCollectionsByOwner", payload)
|
||||
|
||||
proc getOpenseaAssets*(
|
||||
chainId: int, address: string, collectionSlug: string, limit: int
|
||||
): RpcResponse[JsonNode] =
|
||||
let payload = %* [chainId, address, collectionSlug, limit]
|
||||
return callPrivateRPC("wallet_getOpenseaAssetsByOwnerAndCollection", payload)
|
|
@ -18,12 +18,23 @@ macro rpc*(rpcMethod: untyped, prefix: string, identDefs: untyped): untyped =
|
|||
let fieldNameIdent = identDef[0]
|
||||
let fieldName = fieldNameIdent.strval
|
||||
|
||||
if identDef[1][0].len == 0:
|
||||
params.add(nnkIdentDefs.newTree(
|
||||
ident(fieldName),
|
||||
ident(identDef[1][0].strVal),
|
||||
newNimNode(nnkEmpty)
|
||||
))
|
||||
|
||||
if identDef[1][0].len == 2:
|
||||
params.add(nnkIdentDefs.newTree(
|
||||
ident(fieldName),
|
||||
nnkBracketExpr.newTree(
|
||||
ident(identDef[1][0][0].strVal),
|
||||
ident(identDef[1][0][1].strVal)
|
||||
),
|
||||
newNimNode(nnkEmpty)
|
||||
))
|
||||
|
||||
payload.add(newIdentNode(fieldName))
|
||||
|
||||
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
import json, chronicles, core
|
||||
import response_type
|
||||
|
||||
export response_type
|
||||
|
||||
logScope:
|
||||
topics = "rpc-gif"
|
||||
|
||||
proc setTenorAPIKey*(key: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
let payload = %* [key]
|
||||
result = core.callPrivateRPC("gif_setTenorAPIKey", payload)
|
||||
|
||||
proc fetchGifs*(path: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
let payload = %* [path]
|
||||
result = core.callPrivateRPC("gif_fetchGifs", payload)
|
||||
|
||||
proc updateRecentGifs*(recentGifs: JsonNode): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
let payload = %* [recentGifs]
|
||||
return core.callPrivateRPC("gif_updateRecentGifs", payload)
|
||||
|
||||
proc updateFavoriteGifs*(favoriteGifs: JsonNode): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
let payload = %* [favoriteGifs]
|
||||
return core.callPrivateRPC("gif_updateFavoriteGifs", payload)
|
||||
|
||||
proc getRecentGifs*(): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
let payload = %* []
|
||||
return core.callPrivateRPC("gif_getRecentGifs", payload)
|
||||
|
||||
proc getFavoriteGifs*(): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
let payload = %* []
|
||||
return core.callPrivateRPC("gif_getFavoriteGifs", payload)
|
|
@ -1,12 +0,0 @@
|
|||
import json
|
||||
|
||||
import ./core, ./response_type
|
||||
|
||||
proc getNetworks*(payload: JsonNode): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
core.callPrivateRPC("wallet_getEthereumChains", payload)
|
||||
|
||||
proc upsertNetwork*(payload: JsonNode): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
core.callPrivateRPC("wallet_addEthereumChain", payload)
|
||||
|
||||
proc deleteNetwork*(payload: JsonNode): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
core.callPrivateRPC("wallet_deleteEthereumChain", payload)
|
|
@ -1,21 +0,0 @@
|
|||
import json
|
||||
import core
|
||||
import response_type
|
||||
|
||||
export response_type
|
||||
|
||||
proc getDappPermissions*(): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
let payload = %* []
|
||||
result = callPrivateRPC("permissions_getDappPermissions", payload)
|
||||
|
||||
proc addDappPermissions*(dapp: string, address: string, permissions: seq[string]): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
let payload = %*[{
|
||||
"dapp": dapp,
|
||||
"address": address,
|
||||
"permissions": permissions
|
||||
}]
|
||||
result = callPrivateRPC("permissions_addDappPermissions", payload)
|
||||
|
||||
proc deleteDappPermissions*(dapp: string, address: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
let payload = %* [dapp, address]
|
||||
result = callPrivateRPC("permissions_deleteDappPermissionsByNameAndAddress", payload)
|
|
@ -1,16 +0,0 @@
|
|||
import json
|
||||
import ./core, ./response_type
|
||||
|
||||
export response_type
|
||||
|
||||
proc addSavedAddress*(name, address: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
let payload = %* [{"name": name, "address": address}]
|
||||
return callPrivateRPC("wallet_addSavedAddress", payload)
|
||||
|
||||
proc deleteSavedAddress*(address: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
let payload = %* [address]
|
||||
return callPrivateRPC("wallet_deleteSavedAddress", payload)
|
||||
|
||||
proc getSavedAddresses*(): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
let payload = %* []
|
||||
return callPrivateRPC("wallet_getSavedAddresses", payload)
|
|
@ -1,11 +0,0 @@
|
|||
import json
|
||||
import ./core, ./response_type
|
||||
|
||||
export response_type
|
||||
|
||||
|
||||
proc getTokens*(chainId: int): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
return callPrivateRPC("wallet_getTokens", %* [chainId])
|
||||
|
||||
proc getBalances*(chainIds: seq[int], accounts: seq[string], tokens: seq[string]): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
return callPrivateRPC("wallet_getTokensBalancesForChainIDs", %* [chainIds, accounts, tokens])
|
|
@ -1,32 +0,0 @@
|
|||
import json, chronicles
|
||||
import core, utils
|
||||
import response_type
|
||||
|
||||
export response_type
|
||||
|
||||
logScope:
|
||||
topics = "rpc-wallet"
|
||||
|
||||
proc getPendingTransactions*(): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
let payload = %* []
|
||||
result = core.callPrivateRPC("wallet_getPendingTransactions", payload)
|
||||
|
||||
proc generateAccount*(password, name, color, emoji: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
let payload = %* [hashPassword(password), name, color, emoji]
|
||||
return core.callPrivateRPC("accounts_generateAccount", payload)
|
||||
|
||||
proc addAccountWithMnemonic*(mnemonic, password, name, color, emoji: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
let payload = %* [mnemonic, hashPassword(password), name, color, emoji]
|
||||
return core.callPrivateRPC("accounts_addAccountWithMnemonic", payload)
|
||||
|
||||
proc addAccountWithPrivateKey*(privateKey, password, name, color, emoji: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
let payload = %* [privateKey, hashPassword(password), name, color, emoji]
|
||||
return core.callPrivateRPC("accounts_addAccountWithPrivateKey", payload)
|
||||
|
||||
proc addAccountWatch*(address, name, color, emoji: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
let payload = %* [address, name, color, emoji]
|
||||
return core.callPrivateRPC("accounts_addAccountWatch", payload)
|
||||
|
||||
proc fetchPrices*(symbols: seq[string], currency: string): RpcResponse[JsonNode] {.raises: [Exception].} =
|
||||
let payload = %* [symbols, currency]
|
||||
return core.callPrivateRPC("wallet_fetchPrices", payload)
|
Loading…
Reference in New Issue