feat: testnet tokens
This commit is contained in:
parent
811024b0ee
commit
24212a63e9
|
@ -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 =
|
||||
|
|
|
@ -3,7 +3,19 @@ import settings
|
|||
import types
|
||||
|
||||
proc getDefaultTokens*(): JsonNode =
|
||||
result = %* [
|
||||
if getCurrentNetwork() == Network.Testnet:
|
||||
return %* [
|
||||
{
|
||||
"symbol": "STT",
|
||||
"name": "Status Test Token",
|
||||
"address": "0xc55cf4b03948d7ebc8b9e8bad92643703811d162",
|
||||
"decimals": 18,
|
||||
"hasIcon": true
|
||||
}
|
||||
]
|
||||
|
||||
if getCurrentNetwork() == Network.Mainnet:
|
||||
return %* [
|
||||
{
|
||||
"symbol": "DAI",
|
||||
"name": "Dai Stablecoin",
|
||||
|
@ -1144,11 +1156,92 @@ proc getDefaultTokens*(): JsonNode =
|
|||
]
|
||||
|
||||
if getCurrentNetwork() == Network.Testnet:
|
||||
result.add(%* {
|
||||
return %* [
|
||||
{
|
||||
"symbol": "STT",
|
||||
"name": "Status Test Token",
|
||||
"address": "0xc55cf4b03948d7ebc8b9e8bad92643703811d162",
|
||||
"decimals": 18,
|
||||
"hasIcon": true
|
||||
})
|
||||
},
|
||||
{
|
||||
"symbol": "HND",
|
||||
"name": "Handy Test Token",
|
||||
"address": "0xdee43a267e8726efd60c2e7d5b81552dcd4fa35c",
|
||||
"decimals": 0,
|
||||
"hasIcon": false
|
||||
},
|
||||
{
|
||||
"symbol": "LXS",
|
||||
"name": "Lucky Test Token",
|
||||
"address": "0x703d7dc0bc8e314d65436adf985dda51e09ad43b",
|
||||
"decimals": 2,
|
||||
"hasIcon": false
|
||||
},
|
||||
{
|
||||
"symbol": "ADI",
|
||||
"name": "Adi Test Token",
|
||||
"address": "0xe639e24346d646e927f323558e6e0031bfc93581",
|
||||
"decimals": 7,
|
||||
"hasIcon": false
|
||||
},
|
||||
{
|
||||
"symbol": "WGN",
|
||||
"name": "Wagner Test Token",
|
||||
"address": "0x2e7cd05f437eb256f363417fd8f920e2efa77540",
|
||||
"decimals": 10,
|
||||
"hasIcon": false
|
||||
},
|
||||
{
|
||||
"symbol": "MDS",
|
||||
"name": "Modest Test Token",
|
||||
"address": "0x57cc9b83730e6d22b224e9dc3e370967b44a2de0",
|
||||
"decimals": 18,
|
||||
"hasIcon": false
|
||||
}
|
||||
]
|
||||
|
||||
if getCurrentNetwork() == Network.Rinkeby:
|
||||
return %* [
|
||||
{
|
||||
"symbol": "MOKSHA",
|
||||
"name": "Moksha Coin",
|
||||
"address": "0x6ba7dc8dd10880ab83041e60c4ede52bb607864b",
|
||||
"decimals": 18,
|
||||
"hasIcon": false
|
||||
},
|
||||
{
|
||||
"symbol": "KDO",
|
||||
"nft": true,
|
||||
"name": "KudosToken",
|
||||
"address": "0x93bb0afbd0627bbd3a6c72bc318341d3a22e254a",
|
||||
"hasIcon": false
|
||||
},
|
||||
{
|
||||
"symbol": "WIBB",
|
||||
"name": "WIBB",
|
||||
"address": "0x7d4ccf6af2f0fdad48ee7958bcc28bdef7b732c7",
|
||||
"decimals": 18,
|
||||
"hasIcon": false
|
||||
},
|
||||
{
|
||||
"symbol": "STT",
|
||||
"name": "Status Test Token",
|
||||
"address": "0x43d5adc3b49130a575ae6e4b00dfa4bc55c71621",
|
||||
"decimals": 18,
|
||||
"hasIcon": false
|
||||
}
|
||||
]
|
||||
|
||||
if getCurrentNetwork() == Network.XDai:
|
||||
return %* [
|
||||
{
|
||||
"symbol": "BUFF",
|
||||
"name": "buffiDai",
|
||||
"address": "0x3e50bf6703fc132a94e4baff068db2055655f11b",
|
||||
"decimals": 18,
|
||||
"hasIcon": false
|
||||
}
|
||||
]
|
||||
|
||||
return %* []
|
|
@ -46,9 +46,21 @@ proc getSetting*[T](name: Setting, useCached: bool = true): T =
|
|||
result = getSetting(name, default(type(T)), useCached)
|
||||
|
||||
proc getCurrentNetwork*(): Network =
|
||||
case getSetting[string](Setting.Networks_CurrentNetwork, constants.DEFAULT_NETWORK_NAME):
|
||||
of "mainnet_rpc":
|
||||
result = Network.Mainnet
|
||||
if getSetting[string](Setting.Networks_CurrentNetwork, constants.DEFAULT_NETWORK_NAME) == "testnet_rpc":
|
||||
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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue