add map option to walletList
This commit is contained in:
parent
b1049bd7b7
commit
3492643d4f
|
@ -70,7 +70,7 @@ class GeolocProfiles(CesiumCommon):
|
|||
return finalResult
|
||||
|
||||
def getGVAProfiles(self, node):
|
||||
gva = ListWallets(node, False, False, False, False)
|
||||
gva = ListWallets(node, False, False, False, False, True)
|
||||
return gva.sendDoc()
|
||||
|
||||
def formatProfiles(self, cesiumProfiles, gvaProfiles):
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import sys, json
|
||||
import sys, re, os.path, json, ast
|
||||
from termcolor import colored
|
||||
from lib.natools import fmt, sign, get_privkey
|
||||
from gql import gql, Client
|
||||
|
@ -10,11 +10,12 @@ PUBKEY_REGEX = "(?![OIl])[1-9A-Za-z]{42,45}"
|
|||
|
||||
|
||||
class ListWallets:
|
||||
def __init__(self, node, brut, mbr, nonMbr, larf):
|
||||
def __init__(self, node, brut, mbr, nonMbr, larf, map=False):
|
||||
self.mbr = mbr
|
||||
self.larf = larf
|
||||
self.nonMbr = nonMbr
|
||||
self.brut = brut
|
||||
self.map = map
|
||||
# Define Duniter GVA node
|
||||
transport = AIOHTTPTransport(url=node)
|
||||
self.client = Client(transport=transport, fetch_schema_from_transport=True)
|
||||
|
@ -57,6 +58,7 @@ class ListWallets:
|
|||
|
||||
jsonBrut = queryResult["wallets"]["edges"]
|
||||
|
||||
walletList = []
|
||||
walletMap = {}
|
||||
for i, trans in enumerate(jsonBrut):
|
||||
dataWork = trans["node"]
|
||||
|
@ -70,14 +72,24 @@ class ListWallets:
|
|||
continue
|
||||
if self.larf and (dataWork["idty"] != None):
|
||||
continue
|
||||
walletMap[dataWork["script"]] = {
|
||||
"balance": dataWork["balance"]["amount"] / 100,
|
||||
"id": dataWork["idty"],
|
||||
}
|
||||
|
||||
if self.map:
|
||||
walletMap[dataWork["script"]] = {
|
||||
"balance": dataWork["balance"]["amount"] / 100,
|
||||
"id": dataWork["idty"],
|
||||
}
|
||||
else:
|
||||
walletList.append(
|
||||
{
|
||||
"pubkey": dataWork["script"],
|
||||
"balance": dataWork["balance"]["amount"] / 100,
|
||||
"id": dataWork["idty"],
|
||||
}
|
||||
)
|
||||
|
||||
if self.brut:
|
||||
names = []
|
||||
for dataWork in walletMap:
|
||||
for dataWork in walletList:
|
||||
if self.mbr or self.nonMbr:
|
||||
names.append(dataWork["pubkey"] + " " + dataWork["id"]["username"])
|
||||
else:
|
||||
|
@ -85,4 +97,7 @@ class ListWallets:
|
|||
|
||||
return "\n".join(names)
|
||||
else:
|
||||
return json.dumps(walletMap, indent=2)
|
||||
if self.map:
|
||||
return json.dumps(walletMap, indent=2)
|
||||
else:
|
||||
return json.dumps(walletList, indent=2)
|
||||
|
|
Loading…
Reference in New Issue