mirror of
https://github.com/status-im/status-desktop.git
synced 2025-02-06 11:45:15 +00:00
parent
1ac4ea4158
commit
538cd6ae06
@ -40,8 +40,8 @@ proc getTokens*(self: Controller): seq[token_service.TokenDto] =
|
||||
for token in tokens:
|
||||
result.add(token)
|
||||
|
||||
proc addCustomToken*(self: Controller, chainId: int, address: string, name: string, symbol: string, decimals: int) =
|
||||
self.tokenService.addCustomToken(chainId, address, name, symbol, decimals)
|
||||
proc addCustomToken*(self: Controller, chainId: int, address: string, name: string, symbol: string, decimals: int): string =
|
||||
return self.tokenService.addCustomToken(chainId, address, name, symbol, decimals)
|
||||
|
||||
proc toggleVisible*(self: Controller, chainId: int, address: string) =
|
||||
self.walletAccountService.toggleTokenVisible(chainId, address)
|
||||
|
@ -11,7 +11,7 @@ method load*(self: AccessInterface) {.base.} =
|
||||
method isLoaded*(self: AccessInterface): bool {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method addCustomToken*(self: AccessInterface, chainId: int, address: string, name: string, symbol: string, decimals: int) {.base.} =
|
||||
method addCustomToken*(self: AccessInterface, chainId: int, address: string, name: string, symbol: string, decimals: int): string {.base.} =
|
||||
raise newException(ValueError, "No implementation available")
|
||||
|
||||
method toggleVisible*(self: AccessInterface, chainId: int, address: string) {.base.} =
|
||||
|
@ -74,8 +74,8 @@ method viewDidLoad*(self: Module) =
|
||||
self.moduleLoaded = true
|
||||
self.delegate.allTokensModuleDidLoad()
|
||||
|
||||
method addCustomToken*(self: Module, chainId: int, address: string, name: string, symbol: string, decimals: int) =
|
||||
self.controller.addCustomToken(chainId, address, name, symbol, decimals)
|
||||
method addCustomToken*(self: Module, chainId: int, address: string, name: string, symbol: string, decimals: int): string =
|
||||
return self.controller.addCustomToken(chainId, address, name, symbol, decimals)
|
||||
|
||||
method toggleVisible*(self: Module, chainId: int, address: string) =
|
||||
self.controller.toggleVisible(chainId, address)
|
||||
|
@ -61,8 +61,8 @@ QtObject:
|
||||
self.custom.setItems(items.filter(i => i.getIsCustom()))
|
||||
self.default.setItems(items.filter(i => not i.getIsCustom()))
|
||||
|
||||
proc addCustomToken(self: View, chainId: int, address: string, name: string, symbol: string, decimals: string) {.slot.} =
|
||||
self.delegate.addCustomToken(chainId, address, name, symbol, parseInt(decimals))
|
||||
proc addCustomToken(self: View, chainId: int, address: string, name: string, symbol: string, decimals: string): string {.slot.} =
|
||||
return self.delegate.addCustomToken(chainId, address, name, symbol, parseInt(decimals))
|
||||
|
||||
proc toggleVisible(self: View, chainId: int, address: string) {.slot.} =
|
||||
self.delegate.toggleVisible(chainId, address)
|
||||
|
@ -112,9 +112,14 @@ QtObject:
|
||||
if token.isVisible:
|
||||
result.add(token)
|
||||
|
||||
proc addCustomToken*(self: Service, chainId: int, address: string, name: string, symbol: string, decimals: int) =
|
||||
proc addCustomToken*(self: Service, chainId: int, address: string, name: string, symbol: string, decimals: int): string =
|
||||
# TODO(alaile): use chainId rather than first enabled network
|
||||
let networkWIP = self.networkService.getEnabledNetworks()[0]
|
||||
let foundToken = self.findTokenByAddress(networkWIP, parseAddress(address))
|
||||
|
||||
if not foundToken.isNil:
|
||||
return "token already exists"
|
||||
|
||||
let backendToken = backend.Token(
|
||||
name: name, chainId: networkWIP.chainId, address: address, symbol: symbol, decimals: decimals, color: ""
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user