fix: network serialization (#28)

This commit is contained in:
Anthony Laibe 2021-09-16 23:30:29 +02:00 committed by GitHub
parent 12a8b59780
commit 87dd134eac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 48 deletions

View File

@ -174,66 +174,66 @@ var NODE_CONFIG* = %* {
},
"Networks": [
{
"chain_id": 1,
"chain_name": "Ethereum Mainnet",
"rpc_url": "https://mainnet.infura.io/v3/" & INFURA_TOKEN_RESOLVED,
"block_explorer_url": "https://etherscan.io/",
"icon_url": "",
"native_currency_name": "Ether",
"native_currency_symbol": "ETH",
"native_currency_decimals": 18,
"chainId": 1,
"chainName": "Ethereum Mainnet",
"rpcUrl": "https://mainnet.infura.io/v3/" & INFURA_TOKEN_RESOLVED,
"blockExplorerUrl": "https://etherscan.io/",
"iconUrl": "",
"nativeCurrencyName": "Ether",
"nativeCurrencySymbol": "ETH",
"nativeCurrencyDecimals": 18,
"isTest": false,
"layer": 1,
"enabled": true,
},
{
"chain_id": 3,
"chain_name": "Ropsten",
"rpc_url": "https://ropsten.infura.io/v3/" & INFURA_TOKEN_RESOLVED,
"block_explorer_url": "https://ropsten.etherscan.io/",
"icon_url": "",
"native_currency_name": "Ether",
"native_currency_symbol": "ETH",
"native_currency_decimals": 18,
"chainId": 3,
"chainName": "Ropsten",
"rpcUrl": "https://ropsten.infura.io/v3/" & INFURA_TOKEN_RESOLVED,
"blockExplorerUrl": "https://ropsten.etherscan.io/",
"iconUrl": "",
"nativeCurrencyName": "Ether",
"nativeCurrencySymbol": "ETH",
"nativeCurrencyDecimals": 18,
"isTest": true,
"layer": 1,
"enabled": false,
},
{
"chain_id": 4,
"chain_name": "Rinkeby",
"rpc_url": "https://rinkeby.infura.io/v3/" & INFURA_TOKEN_RESOLVED,
"block_explorer_url": "https://rinkeby.etherscan.io/",
"icon_url": "",
"native_currency_name": "Ether",
"native_currency_symbol": "ETH",
"native_currency_decimals": 18,
"chainId": 4,
"chainName": "Rinkeby",
"rpcUrl": "https://rinkeby.infura.io/v3/" & INFURA_TOKEN_RESOLVED,
"blockExplorerUrl": "https://rinkeby.etherscan.io/",
"iconUrl": "",
"nativeCurrencyName": "Ether",
"nativeCurrencySymbol": "ETH",
"nativeCurrencyDecimals": 18,
"isTest": true,
"layer": 1,
"enabled": false,
},
{
"chain_id": 5,
"chain_name": "Goerli",
"rpc_url": "http://goerli.blockscout.com/",
"block_explorer_url": "https://goerli.etherscan.io/",
"icon_url": "",
"native_currency_name": "Ether",
"native_currency_symbol": "ETH",
"native_currency_decimals": 18,
"chainId": 5,
"chainName": "Goerli",
"rpcUrl": "http://goerli.blockscout.com/",
"blockExplorerUrl": "https://goerli.etherscan.io/",
"iconUrl": "",
"nativeCurrencyName": "Ether",
"nativeCurrencySymbol": "ETH",
"nativeCurrencyDecimals": 18,
"isTest": true,
"layer": 1,
"enabled": false,
},
{
"chain_id": 10,
"chain_name": "Optimistic Ethereum",
"rpc_url": "https://mainnet.infura.io/v3/" & INFURA_TOKEN_RESOLVED,
"block_explorer_url": "https://optimistic.etherscan.io",
"icon_url": "",
"native_currency_name": "Ether",
"native_currency_symbol": "ETH",
"native_currency_decimals": 18,
"chainId": 10,
"chainName": "Optimistic Ethereum",
"rpcUrl": "https://mainnet.infura.io/v3/" & INFURA_TOKEN_RESOLVED,
"blockExplorerUrl": "https://optimistic.etherscan.io",
"iconUrl": "",
"nativeCurrencyName": "Ether",
"nativeCurrencySymbol": "ETH",
"nativeCurrencyDecimals": 18,
"isTest": false,
"layer": 2,
"enabled": true,

View File

@ -27,7 +27,7 @@ type
StatusWalletController* = ref object
events: EventEmitter
accounts: seq[WalletAccount]
networks: seq[Network]
networks*: seq[Network]
tokens: seq[Erc20Contract]
totalBalance*: float

View File

@ -1,4 +1,4 @@
from json import JsonNode, `%*`
from json import JsonNode, `%*`, parseJson
from strformat import fmt
import json_serialization
@ -19,9 +19,4 @@ proc `$`*(self: Network): string =
return fmt"Network(chainID:{self.chainID}, name:{self.chainName}, rpcURL:{self.rpcURL}, isTest:{self.isTest}, enabled:{self.enabled})"
proc toPayload*(self: Network): JsonNode =
return %* [{
"chain_id": self.chainID, "native_currency_decimals": self.nativeCurrencyDecimals, "layer": self.layer,
"chain_name": self.chainName, "rpc_url": self.rpcURL, "block_explorer_url": self.blockExplorerURL,
"icon_url": self.iconURL, "native_currency_name": self.nativeCurrencyName,
"native_currency_symbol": self.nativeCurrencySymbol, "is_test": self.isTest, "enabled": self.enabled
}]
return %* [Json.encode(self).parseJson]