2021-09-16 21:30:29 +00:00
|
|
|
from json import JsonNode, `%*`, parseJson
|
2021-09-09 21:36:28 +00:00
|
|
|
from strformat import fmt
|
2021-09-10 08:47:29 +00:00
|
|
|
import json_serialization
|
2021-09-09 21:36:28 +00:00
|
|
|
|
|
|
|
type Network* = ref object
|
2021-09-10 08:47:29 +00:00
|
|
|
chainID* {.serializedFieldName("chainId").}: int
|
|
|
|
nativeCurrencyDecimals* {.serializedFieldName("nativeCurrencyDecimals").}: int
|
2021-09-09 21:36:28 +00:00
|
|
|
layer* {.serializedFieldName("layer").}: int
|
2021-09-10 08:47:29 +00:00
|
|
|
chainName* {.serializedFieldName("chainName").}: string
|
|
|
|
rpcURL* {.serializedFieldName("rpcUrl").}: string
|
|
|
|
blockExplorerURL* {.serializedFieldName("blockExplorerUrl").}: string
|
|
|
|
iconURL* {.serializedFieldName("iconUrl").}: string
|
|
|
|
nativeCurrencyName* {.serializedFieldName("nativeCurrencyName").}: string
|
|
|
|
nativeCurrencySymbol* {.serializedFieldName("nativeCurrencySymbol").}: string
|
|
|
|
isTest* {.serializedFieldName("isTest").}: bool
|
2021-09-09 21:36:28 +00:00
|
|
|
enabled* {.serializedFieldName("enabled").}: bool
|
|
|
|
|
|
|
|
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 =
|
2021-09-16 21:30:29 +00:00
|
|
|
return %* [Json.encode(self).parseJson]
|