xync-schema 0.0.54.dev2__tar.gz → 0.0.54.dev4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {xync_schema-0.0.54.dev2/xync_schema.egg-info → xync_schema-0.0.54.dev4}/PKG-INFO +1 -1
- {xync_schema-0.0.54.dev2 → xync_schema-0.0.54.dev4}/xync_schema/enums.py +30 -13
- xync_schema-0.0.54.dev4/xync_schema/graph.py +65 -0
- {xync_schema-0.0.54.dev2 → xync_schema-0.0.54.dev4}/xync_schema/models.py +47 -6
- {xync_schema-0.0.54.dev2 → xync_schema-0.0.54.dev4}/xync_schema/xtype.py +2 -1
- {xync_schema-0.0.54.dev2 → xync_schema-0.0.54.dev4/xync_schema.egg-info}/PKG-INFO +1 -1
- {xync_schema-0.0.54.dev2 → xync_schema-0.0.54.dev4}/xync_schema.egg-info/SOURCES.txt +1 -0
- {xync_schema-0.0.54.dev2 → xync_schema-0.0.54.dev4}/.env.sample +0 -0
- {xync_schema-0.0.54.dev2 → xync_schema-0.0.54.dev4}/.gitignore +0 -0
- {xync_schema-0.0.54.dev2 → xync_schema-0.0.54.dev4}/.pre-commit-config.yaml +0 -0
- {xync_schema-0.0.54.dev2 → xync_schema-0.0.54.dev4}/README.md +0 -0
- {xync_schema-0.0.54.dev2 → xync_schema-0.0.54.dev4}/makefile +0 -0
- {xync_schema-0.0.54.dev2 → xync_schema-0.0.54.dev4}/pyproject.toml +0 -0
- {xync_schema-0.0.54.dev2 → xync_schema-0.0.54.dev4}/setup.cfg +0 -0
- {xync_schema-0.0.54.dev2 → xync_schema-0.0.54.dev4}/tests/__init__.py +0 -0
- {xync_schema-0.0.54.dev2 → xync_schema-0.0.54.dev4}/tests/test_db.py +0 -0
- {xync_schema-0.0.54.dev2 → xync_schema-0.0.54.dev4}/xync_schema/__init__.py +0 -0
- {xync_schema-0.0.54.dev2 → xync_schema-0.0.54.dev4}/xync_schema.egg-info/dependency_links.txt +0 -0
- {xync_schema-0.0.54.dev2 → xync_schema-0.0.54.dev4}/xync_schema.egg-info/requires.txt +0 -0
- {xync_schema-0.0.54.dev2 → xync_schema-0.0.54.dev4}/xync_schema.egg-info/top_level.txt +0 -0
|
@@ -29,23 +29,40 @@ class AdStatus(IntEnum):
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
class OrderStatus(IntEnum):
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
completed = 7
|
|
40
|
-
appealable = 8
|
|
41
|
-
appealed_by_seller = 9
|
|
42
|
-
appealed_by_buyer = 10
|
|
43
|
-
seller_appeal_disputed_by_buyer = 11
|
|
44
|
-
buyer_appeal_disputed_by_seller = 12
|
|
32
|
+
created = 1
|
|
33
|
+
paid = 2
|
|
34
|
+
completed = 3
|
|
35
|
+
canceled = 4
|
|
36
|
+
appealed_by_seller = 5
|
|
37
|
+
appealed_by_buyer = 6
|
|
38
|
+
appeal_disputed = 7
|
|
45
39
|
# todo: 8T - один вирт экшн на бездействие обеих сторон, а 12T и 13T - по отдельности?
|
|
46
40
|
# COMPLETED, PENDING, TRADING, BUYER_PAYED, DISTRIBUTING, COMPLETED, IN_APPEAL, CANCELLED, CANCELLED_BY_SYSTEM
|
|
47
41
|
|
|
48
42
|
|
|
43
|
+
class OrderAction(IntEnum):
|
|
44
|
+
# requested
|
|
45
|
+
taker_create = 1
|
|
46
|
+
wait_for_cancel = 0
|
|
47
|
+
# created
|
|
48
|
+
buyer_pay = 2
|
|
49
|
+
seller_confirm = 3
|
|
50
|
+
buyer_cancel = 4
|
|
51
|
+
# paid
|
|
52
|
+
wait_for_pay = 5
|
|
53
|
+
seller_appeal = 6
|
|
54
|
+
buyer_appeal = 7
|
|
55
|
+
# appealed by seller
|
|
56
|
+
buyer_dispute_appeal_s = 8
|
|
57
|
+
buyer_agree_appeal_s = 10 # cancel
|
|
58
|
+
wait_appeal_s = 12 # -> cancel
|
|
59
|
+
# appealed by buyer
|
|
60
|
+
seller_dispute_appeal_b = 9
|
|
61
|
+
seller_agree_appeal_b = 11 # confirm
|
|
62
|
+
wait_appeal_b = 13 # -> confirm
|
|
63
|
+
wait_disputed_appeal = 14 # ?
|
|
64
|
+
|
|
65
|
+
|
|
49
66
|
class ExType(IntEnum):
|
|
50
67
|
p2p = 1
|
|
51
68
|
cex = 2
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
from xync_schema.enums import OrderStatus, OrderAction
|
|
2
|
+
|
|
3
|
+
acts = (
|
|
4
|
+
{ # buyer
|
|
5
|
+
# 1
|
|
6
|
+
OrderStatus.created: {
|
|
7
|
+
OrderAction.buyer_cancel: OrderStatus.canceled,
|
|
8
|
+
OrderAction.buyer_pay: OrderStatus.paid,
|
|
9
|
+
},
|
|
10
|
+
# 2
|
|
11
|
+
OrderStatus.paid: {
|
|
12
|
+
OrderAction.buyer_cancel: OrderStatus.canceled,
|
|
13
|
+
OrderAction.buyer_appeal: OrderStatus.appealed_by_buyer,
|
|
14
|
+
},
|
|
15
|
+
# 5
|
|
16
|
+
OrderStatus.appealed_by_seller: {
|
|
17
|
+
OrderAction.buyer_cancel: OrderStatus.canceled,
|
|
18
|
+
OrderAction.buyer_dispute_appeal_s: OrderStatus.appeal_disputed,
|
|
19
|
+
},
|
|
20
|
+
# 6
|
|
21
|
+
OrderStatus.appealed_by_buyer: {
|
|
22
|
+
OrderAction.buyer_cancel: OrderStatus.canceled,
|
|
23
|
+
},
|
|
24
|
+
# 7
|
|
25
|
+
OrderStatus.appeal_disputed: {
|
|
26
|
+
OrderAction.buyer_cancel: OrderStatus.canceled,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
{ # seller
|
|
30
|
+
# 2
|
|
31
|
+
OrderStatus.paid: {
|
|
32
|
+
OrderAction.seller_confirm: OrderStatus.completed,
|
|
33
|
+
OrderAction.seller_appeal: OrderStatus.appealed_by_seller,
|
|
34
|
+
},
|
|
35
|
+
# 5
|
|
36
|
+
OrderStatus.appealed_by_seller: {
|
|
37
|
+
OrderAction.seller_confirm: OrderStatus.completed,
|
|
38
|
+
},
|
|
39
|
+
# 6
|
|
40
|
+
OrderStatus.appealed_by_buyer: {
|
|
41
|
+
OrderAction.seller_dispute_appeal_b: OrderStatus.appeal_disputed,
|
|
42
|
+
OrderAction.seller_confirm: OrderStatus.completed,
|
|
43
|
+
},
|
|
44
|
+
# 7
|
|
45
|
+
OrderStatus.appeal_disputed: {
|
|
46
|
+
OrderAction.seller_confirm: OrderStatus.completed,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
waits: dict[OrderStatus, dict[OrderAction, OrderStatus]] = {
|
|
53
|
+
# 1
|
|
54
|
+
OrderStatus.created: {
|
|
55
|
+
OrderAction.wait_for_cancel: OrderStatus.canceled,
|
|
56
|
+
},
|
|
57
|
+
# 5
|
|
58
|
+
OrderStatus.appealed_by_seller: {
|
|
59
|
+
OrderAction.wait_appeal_s: OrderStatus.canceled,
|
|
60
|
+
},
|
|
61
|
+
# 6
|
|
62
|
+
OrderStatus.appealed_by_buyer: {
|
|
63
|
+
OrderAction.wait_appeal_b: OrderStatus.completed,
|
|
64
|
+
},
|
|
65
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import re
|
|
2
2
|
import struct
|
|
3
3
|
import sys
|
|
4
|
+
from typing import Any
|
|
4
5
|
from uuid import UUID
|
|
5
6
|
from datetime import datetime, timezone, timedelta
|
|
6
7
|
from decimal import Decimal
|
|
@@ -164,6 +165,11 @@ class Ex(Model):
|
|
|
164
165
|
client = sys.modules[module_name].ExClient
|
|
165
166
|
return client(self, bot, **kwargs)
|
|
166
167
|
|
|
168
|
+
def etype(self):
|
|
169
|
+
module_name = f"xync_client.{self.name}.etype"
|
|
170
|
+
__import__(module_name)
|
|
171
|
+
return sys.modules[module_name]
|
|
172
|
+
|
|
167
173
|
|
|
168
174
|
class CurEx(BaseModel):
|
|
169
175
|
cur: ForeignKeyRelation[Cur] = ForeignKeyField("models.Cur", on_update=CASCADE)
|
|
@@ -297,6 +303,11 @@ class User(TgUser, TsTrait):
|
|
|
297
303
|
borrows: BackwardFKRelation["Credit"]
|
|
298
304
|
investments: BackwardFKRelation["Investment"]
|
|
299
305
|
|
|
306
|
+
def __init__(self, **kwargs: Any) -> None:
|
|
307
|
+
super().__init__(**kwargs)
|
|
308
|
+
self.pm_clients = {pma.pm_id: pma.client() for pma in self.pm_agents}
|
|
309
|
+
self.agent_clients = {a.id: a.client() for a in self.person.actor.agents}
|
|
310
|
+
|
|
300
311
|
async def free_assets(self):
|
|
301
312
|
assets = await Asset.filter(agent__actor__person__user__id=self.id).values("free", "addr__coin__rate")
|
|
302
313
|
return sum(asset["free"] * asset["addr__coin__rate"] for asset in assets)
|
|
@@ -527,12 +538,19 @@ class Agent(Model, TsTrait):
|
|
|
527
538
|
# include = "id", "actor__ex", "auth", "updated_at"
|
|
528
539
|
# computed = ["balance"]
|
|
529
540
|
|
|
530
|
-
def client(self, ex_cl, fbot, bbot, proxy=None):
|
|
541
|
+
def client(self, ex_cl, fbot, bbot, pm_clients=None, proxy=None):
|
|
531
542
|
module_name = f"xync_client.{self.actor.ex.name}.agent"
|
|
532
543
|
__import__(module_name)
|
|
533
544
|
client = sys.modules[module_name].AgentClient
|
|
534
545
|
return client(
|
|
535
|
-
self,
|
|
546
|
+
self,
|
|
547
|
+
ex_cl,
|
|
548
|
+
fbot,
|
|
549
|
+
bbot,
|
|
550
|
+
pm_clients or {},
|
|
551
|
+
headers=self.auth.get("headers"),
|
|
552
|
+
cookies=self.auth.get("cookies"),
|
|
553
|
+
proxy=proxy,
|
|
536
554
|
)
|
|
537
555
|
|
|
538
556
|
|
|
@@ -688,9 +706,14 @@ class Ad(Model, TsTrait):
|
|
|
688
706
|
|
|
689
707
|
|
|
690
708
|
class MyAd(Model): # Road
|
|
709
|
+
WEB = "https://www.bybit.com/ru-RU/p2p/sell/USDT/RUB?share="
|
|
710
|
+
MOB = "https://app.bybit.com/inapp?by_dp=bybitapp://open/route?targetUrl=by-mini://p2p/home?share="
|
|
711
|
+
|
|
691
712
|
ad: OneToOneRelation[Ad] = OneToOneField("models.Ad", "my_ad", on_update=CASCADE)
|
|
692
713
|
ad_id: int # new
|
|
693
714
|
target_place: int = UInt1Field(default=1)
|
|
715
|
+
hex: bytes = BinaryField(null=True)
|
|
716
|
+
shared_at: datetime | None = DatetimeSecField(null=True)
|
|
694
717
|
|
|
695
718
|
pay_req: ForeignKeyNullableRelation["PayReq"] = ForeignKeyField(
|
|
696
719
|
"models.PayReq", "maked_ads", on_update=CASCADE, null=True
|
|
@@ -703,6 +726,12 @@ class MyAd(Model): # Road
|
|
|
703
726
|
class Meta:
|
|
704
727
|
table = "my_ad"
|
|
705
728
|
|
|
729
|
+
def get_url(self):
|
|
730
|
+
# if not self.hex:
|
|
731
|
+
# return None
|
|
732
|
+
hx = self.hex.hex()
|
|
733
|
+
return self.WEB + hx, self.MOB + hx
|
|
734
|
+
|
|
706
735
|
|
|
707
736
|
class Race(Model):
|
|
708
737
|
road: ForeignKeyRelation[MyAd] = ForeignKeyField("models.MyAd", "race", on_update=CASCADE)
|
|
@@ -764,10 +793,15 @@ class PmAgent(Model):
|
|
|
764
793
|
table = "pm_agent"
|
|
765
794
|
unique_together = (("pm_id", "user_id"),)
|
|
766
795
|
|
|
767
|
-
def client(self,
|
|
768
|
-
module_name = f"xync_client.Pms.{self.pm.norm.capitalize()}"
|
|
796
|
+
def client(self, bot=None, browser=None):
|
|
797
|
+
module_name = f"xync_client.Pms.{self.pm.norm.capitalize()}.agent"
|
|
769
798
|
__import__(module_name)
|
|
770
|
-
|
|
799
|
+
kwargs = {}
|
|
800
|
+
if bot:
|
|
801
|
+
kwargs["bot"] = bot
|
|
802
|
+
if browser:
|
|
803
|
+
kwargs["browser"] = browser
|
|
804
|
+
return sys.modules[module_name].PmAgentClient(self, **kwargs)
|
|
771
805
|
|
|
772
806
|
|
|
773
807
|
class PmCur(Model): # for fiat with no exs tie
|
|
@@ -1022,7 +1056,7 @@ class Order(Model):
|
|
|
1022
1056
|
payreq_id: int
|
|
1023
1057
|
maker_topic: int = UInt2Field(null=True) # todo: remove nullability
|
|
1024
1058
|
taker_topic: int = UInt2Field(null=True)
|
|
1025
|
-
status: OrderStatus = IntEnumField(OrderStatus, default=OrderStatus.
|
|
1059
|
+
status: OrderStatus = IntEnumField(OrderStatus, default=OrderStatus.created)
|
|
1026
1060
|
created_at: datetime | None = DatetimeSecField(auto_now_add=True)
|
|
1027
1061
|
payed_at: datetime | None = DatetimeSecField(null=True)
|
|
1028
1062
|
confirmed_at: datetime | None = DatetimeSecField(null=True)
|
|
@@ -1034,6 +1068,13 @@ class Order(Model):
|
|
|
1034
1068
|
|
|
1035
1069
|
_name = {"cred__pmcur__pm__name"}
|
|
1036
1070
|
|
|
1071
|
+
def ami_maker(self, uid: int) -> bool:
|
|
1072
|
+
return self.taker_id != uid
|
|
1073
|
+
|
|
1074
|
+
async def ami_seller(self, uid: int) -> bool:
|
|
1075
|
+
await self.fetch_related("ad__pair_side") # todo: check and fetch if only need
|
|
1076
|
+
return self.ad.pair_side.is_sell == self.ami_maker(uid)
|
|
1077
|
+
|
|
1037
1078
|
async def client(self):
|
|
1038
1079
|
if isinstance(self.ad, QuerySet):
|
|
1039
1080
|
# noinspection PyTypeChecker
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{xync_schema-0.0.54.dev2 → xync_schema-0.0.54.dev4}/xync_schema.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|