feat: testnet tokens

This commit is contained in:
Richard Ramos 2020-09-08 12:40:09 -04:00 committed by Iuri Matias
parent 811024b0ee
commit 24212a63e9
6 changed files with 1280 additions and 1154 deletions

View File

@ -20,14 +20,17 @@ QtObject:
self.tokens = @[]
self.QAbstractListModel.delete
proc tokensLoaded(self: TokenList, cnt: int) {.signal.}
proc loadDefaultTokens*(self:TokenList) =
if self.tokens.len == 0:
self.tokens = getDefaultTokens().getElems()
self.tokensLoaded(self.tokens.len)
proc loadCustomTokens*(self: TokenList) =
self.beginResetModel()
self.tokens = getCustomTokens().getElems()
echo $self.tokens
self.tokensLoaded(self.tokens.len)
self.endResetModel()
proc newTokenList*(): TokenList =

File diff suppressed because it is too large Load Diff

View File

@ -46,10 +46,22 @@ proc getSetting*[T](name: Setting, useCached: bool = true): T =
result = getSetting(name, default(type(T)), useCached)
proc getCurrentNetwork*(): Network =
result = Network.Mainnet
if getSetting[string](Setting.Networks_CurrentNetwork, constants.DEFAULT_NETWORK_NAME) == "testnet_rpc":
case getSetting[string](Setting.Networks_CurrentNetwork, constants.DEFAULT_NETWORK_NAME):
of "mainnet_rpc":
result = Network.Mainnet
of "testnet_rpc":
result = Network.Testnet
of "rinkeby_rpc":
result = Network.Rinkeby
of "goerli_rpc":
result = Network.Goerli
of "xdai_rpc":
result = Network.XDai
of "poa_rpc":
result = Network.Poa
else:
result = Network.Other
proc getCurrentNetworkDetails*(): NetworkDetails =
let currNetwork = getSetting[string](Setting.Networks_CurrentNetwork, constants.DEFAULT_NETWORK_NAME)
let networks = getSetting[seq[NetworkDetails]](Setting.Networks_Networks)

View File

@ -45,8 +45,13 @@ proc getTokenByAddress*(tokenList: JsonNode, address: string): JsonNode =
proc visibleTokensSNTDefault(): JsonNode =
let currentNetwork = getSetting[string](Setting.Networks_CurrentNetwork)
let SNT = if getCurrentNetwork() == Network.Testnet: "STT" else: "SNT"
let response = getSetting[string](Setting.VisibleTokens, "{\"" & currentNetwork & "\": [\"" & SNT & "\"]}")
result = response.parseJson
let response = getSetting[string](Setting.VisibleTokens, "{}").parseJSON
if response.hasKey(currentNetwork): return response
# Set STT/SNT visible by default
response[currentNetwork] = %* [SNT]
return response
proc toggleAsset*(symbol: string) =
let currentNetwork = getSetting[string](Setting.Networks_CurrentNetwork)

View File

@ -143,7 +143,12 @@ proc readValue*(reader: var JsonReader, value: var Stuint[256])
type
Network* {.pure.} = enum
Mainnet,
Testnet
Testnet,
Rinkeby,
Goerli,
XDai,
Poa,
Other
Setting* {.pure.} = enum
Appearance = "appearance",

View File

@ -123,11 +123,19 @@ Item {
}
Repeater {
id: customTokensRepeater
model: walletModel.customTokenList
delegate: tokenComponent
anchors.top: customLbl.bottom
anchors.topMargin: Style.current.smallPadding
}
Connections {
target: walletModel.customTokenList
onTokensLoaded: {
customLbl.visible = cnt > 0
}
}
}
Column {