Add references to trades list
This commit is contained in:
parent
49bb686040
commit
cdebded0f6
|
@ -116,6 +116,8 @@ class LocalPlatformClient(ABC):
|
|||
if dash["contact_count"] > 0:
|
||||
for contact in dash["contact_list"]:
|
||||
contact_id = contact["data"]["contact_id"]
|
||||
reference = await db.tx_to_ref(str(contact_id))
|
||||
contact["reference"] = reference
|
||||
dash_tmp[contact_id] = contact
|
||||
return dash_tmp
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ from core.util import logs
|
|||
|
||||
log = logs.get_logger("db")
|
||||
|
||||
r = aioredis.from_url("redis://redis:6379", db=0)
|
||||
r = aioredis.from_url("redis://redis:6379", db=0) # noqa
|
||||
|
||||
|
||||
def convert(data):
|
||||
|
@ -28,6 +28,7 @@ async def get_refs():
|
|||
:return: list of trade IDs
|
||||
:rtype: list
|
||||
"""
|
||||
r = aioredis.from_url("redis://redis:6379", db=0)
|
||||
references = []
|
||||
ref_keys = await r.keys("trade.*.reference")
|
||||
for key in ref_keys:
|
||||
|
@ -44,6 +45,7 @@ async def tx_to_ref(tx):
|
|||
:return: reference
|
||||
:rtype: string
|
||||
"""
|
||||
r = aioredis.from_url("redis://redis:6379", db=0)
|
||||
refs = await get_refs()
|
||||
for reference in refs:
|
||||
ref_data = await r.hgetall(f"trade.{reference}")
|
||||
|
@ -62,6 +64,7 @@ async def ref_to_tx(reference):
|
|||
:return: trade ID
|
||||
:rtype: string
|
||||
"""
|
||||
r = aioredis.from_url("redis://redis:6379", db=0)
|
||||
ref_data = convert(await r.hgetall(f"trade.{reference}"))
|
||||
if not ref_data:
|
||||
return False
|
||||
|
@ -74,6 +77,7 @@ async def get_ref_map():
|
|||
:return: dict of references keyed by TXID
|
||||
:rtype: dict
|
||||
"""
|
||||
r = aioredis.from_url("redis://redis:6379", db=0)
|
||||
references = {}
|
||||
ref_keys = await r.keys("trade.*.reference")
|
||||
for key in ref_keys:
|
||||
|
@ -90,6 +94,7 @@ async def get_ref(reference):
|
|||
:return: dict of trade information
|
||||
:rtype: dict
|
||||
"""
|
||||
r = aioredis.from_url("redis://redis:6379", db=0)
|
||||
ref_data = await r.hgetall(f"trade.{reference}")
|
||||
ref_data = convert(ref_data)
|
||||
if "subclass" not in ref_data:
|
||||
|
@ -107,6 +112,7 @@ async def get_tx(tx):
|
|||
:return: dict of trade information
|
||||
:rtype: dict
|
||||
"""
|
||||
r = aioredis.from_url("redis://redis:6379", db=0)
|
||||
tx_data = await r.hgetall(f"tx.{tx}")
|
||||
tx_data = convert(tx_data)
|
||||
if not tx_data:
|
||||
|
@ -115,6 +121,7 @@ async def get_tx(tx):
|
|||
|
||||
|
||||
async def get_subclass(reference):
|
||||
r = aioredis.from_url("redis://redis:6379", db=0)
|
||||
obj = await r.hget(f"trade.{reference}", "subclass")
|
||||
subclass = convert(obj)
|
||||
return subclass
|
||||
|
@ -126,6 +133,7 @@ async def del_ref(reference):
|
|||
:param reference: trade reference to delete
|
||||
:type reference: string
|
||||
"""
|
||||
r = aioredis.from_url("redis://redis:6379", db=0)
|
||||
tx = await ref_to_tx(reference)
|
||||
await r.delete(f"trade.{reference}")
|
||||
await r.delete(f"trade.{tx}.reference")
|
||||
|
@ -138,6 +146,7 @@ async def cleanup(subclass, references):
|
|||
:param references: list of references to reconcile against
|
||||
:type references: list
|
||||
"""
|
||||
r = aioredis.from_url("redis://redis:6379", db=0)
|
||||
messages = []
|
||||
ref_map = await get_ref_map()
|
||||
for tx, reference in ref_map.items():
|
||||
|
|
|
@ -61,10 +61,11 @@ class ContactData(MyModel):
|
|||
class ContactActions(MyModel):
|
||||
advertisement_public_view: str | None
|
||||
advertisement_url: str | None
|
||||
message_post_url: str
|
||||
messages_url: str
|
||||
release_url: str
|
||||
message_post_url: str | None
|
||||
messages_url: str | None
|
||||
release_url: str | None
|
||||
cancel_url: str | None
|
||||
dispute_url: str | None
|
||||
|
||||
|
||||
class Contact(MyModel):
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
hx-get="{{ list_url }}">
|
||||
<thead>
|
||||
<th>id</th>
|
||||
<th>ref</th>
|
||||
<th>buyer</th>
|
||||
<th>seller</th>
|
||||
<th>amount</th>
|
||||
<th>crypto</th>
|
||||
<th>provider</th>
|
||||
|
@ -27,18 +27,23 @@
|
|||
<td>
|
||||
<a
|
||||
class="has-text-grey"
|
||||
onclick="window.prompt('Copy to clipboard: Ctrl+C, Enter', '{{ item.data.contact_id }}/');">
|
||||
onclick="window.prompt('Copy to clipboard: Ctrl+C, Enter', '{{ item.data.contact_id }}');">
|
||||
<span class="icon" data-tooltip="Copy to clipboard">
|
||||
<i class="fa-solid fa-copy" aria-hidden="true"></i>
|
||||
</span>
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<a
|
||||
class="has-text-grey"
|
||||
data-tooltip="Copy to clipboard"
|
||||
onclick="window.prompt('Copy to clipboard: Ctrl+C, Enter', '{{ item.reference }}');">
|
||||
<code>{{ item.reference }}</code>
|
||||
</a>
|
||||
</td>
|
||||
<td data-tooltip="{{ item.data.buyer.name }}
|
||||
Trades: {{ item.data.buyer.trade_count }}
|
||||
Last online: {{ item.data.buyer.last_online }}">{{ item.data.buyer.username }}</td>
|
||||
<td data-tooltip="{{ item.data.seller.name }}
|
||||
Trades: {{ item.data.seller.trade_count }}
|
||||
Last online: {{ item.data.seller.last_online }}">{{ item.data.seller.username }}</td>
|
||||
<td>{{ item.data.amount }} {{ item.data.currency }}</td>
|
||||
<td>{{ item.data.amount_xmr }} XMR</td>
|
||||
<td>{{ item.data.advertisement.payment_method }}</td>
|
||||
|
|
Loading…
Reference in New Issue