refactor: ensure settings is accessed via model
This commit is contained in:
parent
9711c20949
commit
3acabfd2a8
|
@ -21,14 +21,16 @@ type
|
||||||
Address = UserRole + 4,
|
Address = UserRole + 4,
|
||||||
Decimals = UserRole + 5
|
Decimals = UserRole + 5
|
||||||
IsCustom = UserRole + 6
|
IsCustom = UserRole + 6
|
||||||
|
|
||||||
GetTokenDetailsTaskArg = ref object of QObjectTaskArg
|
GetTokenDetailsTaskArg = ref object of QObjectTaskArg
|
||||||
|
chainId: int
|
||||||
address: string
|
address: string
|
||||||
|
|
||||||
const getTokenDetailsTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
|
const getTokenDetailsTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
|
||||||
let arg = decode[GetTokenDetailsTaskArg](argEncoded)
|
let arg = decode[GetTokenDetailsTaskArg](argEncoded)
|
||||||
try:
|
try:
|
||||||
let
|
let
|
||||||
tkn = newErc20Contract(getCurrentNetwork().toChainId(), arg.address.parseAddress)
|
tkn = newErc20Contract(arg.chainId, arg.address.parseAddress)
|
||||||
decimals = tkn.tokenDecimals()
|
decimals = tkn.tokenDecimals()
|
||||||
output = %* {
|
output = %* {
|
||||||
"address": arg.address,
|
"address": arg.address,
|
||||||
|
@ -44,11 +46,12 @@ const getTokenDetailsTask: Task = proc(argEncoded: string) {.gcsafe, nimcall.} =
|
||||||
}
|
}
|
||||||
arg.finish(output)
|
arg.finish(output)
|
||||||
|
|
||||||
proc getTokenDetails[T](self: T, slot: string, address: string) =
|
proc getTokenDetails[T](self: T, slot: string, chainId: int, address: string) =
|
||||||
let arg = GetTokenDetailsTaskArg(
|
let arg = GetTokenDetailsTaskArg(
|
||||||
tptr: cast[ByteAddress](getTokenDetailsTask),
|
tptr: cast[ByteAddress](getTokenDetailsTask),
|
||||||
vptr: cast[ByteAddress](self.vptr),
|
vptr: cast[ByteAddress](self.vptr),
|
||||||
slot: slot,
|
slot: slot,
|
||||||
|
chainId: chainId,
|
||||||
address: address)
|
address: address)
|
||||||
self.appService.threadpool.start(arg)
|
self.appService.threadpool.start(arg)
|
||||||
|
|
||||||
|
@ -70,7 +73,8 @@ QtObject:
|
||||||
|
|
||||||
proc loadDefaultTokens*(self:TokenList) =
|
proc loadDefaultTokens*(self:TokenList) =
|
||||||
if self.tokens.len == 0:
|
if self.tokens.len == 0:
|
||||||
self.tokens = allErc20ContractsByChainId(getCurrentNetwork().toChainId())
|
let chainId = self.status.settings.getCurrentNetwork().toChainId()
|
||||||
|
self.tokens = allErc20ContractsByChainId(chainId)
|
||||||
self.isCustom = false
|
self.isCustom = false
|
||||||
self.tokensLoaded(self.tokens.len)
|
self.tokensLoaded(self.tokens.len)
|
||||||
|
|
||||||
|
@ -126,7 +130,8 @@ QtObject:
|
||||||
TokenRoles.IsCustom.int:"isCustom"}.toTable
|
TokenRoles.IsCustom.int:"isCustom"}.toTable
|
||||||
|
|
||||||
proc getTokenDetails*(self: TokenList, address: string) {.slot.} =
|
proc getTokenDetails*(self: TokenList, address: string) {.slot.} =
|
||||||
self.getTokenDetails("tokenDetailsResolved", address)
|
let chainId = self.status.settings.getCurrentNetwork().toChainId()
|
||||||
|
self.getTokenDetails("tokenDetailsResolved", chainId, address)
|
||||||
|
|
||||||
proc tokenDetailsWereResolved*(self: TokenList, tokenDetails: string) {.signal.}
|
proc tokenDetailsWereResolved*(self: TokenList, tokenDetails: string) {.signal.}
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit cf2a43f9b31da1862699bb5538d54a0e91a25ec5
|
Subproject commit e29ba9c9faa391ec6c4c504edc37e044c8ff4736
|
Loading…
Reference in New Issue