xync-schema 0.6.36.dev3__py3-none-any.whl → 0.6.37__py3-none-any.whl

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/enums.py CHANGED
@@ -91,9 +91,10 @@ class ExAction(IntEnum):
91
91
  send_appeal_msg = 17 # Отправка сообщения по апелляции
92
92
  get_appeal_msg = -17 # Получение сообщения по апелляции
93
93
  """ Ex: Public """
94
- taker_curs = 21 # Список поддерживаемых валют тейкера
95
- coins = 22 # Список торгуемых монет (с ограничениям по валютам, если есть)
96
- pms = 23 # Список платежных методов по каждой валюте
94
+ pms = 20 # Список платежных методов по каждой валюте
95
+ curs = 21 # Список поддерживаемых валют тейкера
96
+ cur_pms_map = 22 # Мэппинг валюта => платежные методы
97
+ coins = 23 # Список торгуемых монет (с ограничениям по валютам, если есть)
97
98
  ads = 24 # Список объяв по (buy/sell, cur, coin, pm)
98
99
  """ Agent: Fiat """
99
100
  my_fiats = 25 # Список реквизитов моих платежных методов
xync_schema/models.py CHANGED
@@ -1,6 +1,7 @@
1
1
  from datetime import datetime
2
2
  from tortoise import fields
3
3
  from tortoise.queryset import QuerySet
4
+ from tortoise import Model as BaseModel
4
5
  from x_auth.enums import Role
5
6
  from x_auth.models import Model
6
7
  from x_model.models import TsTrait, DatetimeSecField
@@ -18,8 +19,6 @@ class Country(Model):
18
19
  curexs: fields.ManyToManyRelation["Curex"]
19
20
  fiats: fields.BackwardFKRelation["Fiat"]
20
21
 
21
- _icon = "location"
22
-
23
22
 
24
23
  class Cur(Model):
25
24
  id = fields.SmallIntField(True)
@@ -28,8 +27,7 @@ class Cur(Model):
28
27
  country: str | None = fields.CharField(63, null=True)
29
28
 
30
29
  pms: fields.ManyToManyRelation["Pm"] = fields.ManyToManyField("models.Pm", through="pmcur")
31
- curexs: fields.ReverseRelation["Curex"]
32
- pmcurs: fields.ReverseRelation["Pmcur"] # no need. use pms
30
+ exs: fields.ManyToManyRelation["Ex"] = fields.ManyToManyField("models.Ex", through="curex")
33
31
  pairs: fields.ReverseRelation["Pair"]
34
32
  countries: fields.ReverseRelation[Country]
35
33
 
@@ -65,12 +63,11 @@ class Ex(Model):
65
63
  logo: str = fields.CharField(511, default="")
66
64
 
67
65
  pms: fields.ManyToManyRelation["Pm"]
66
+ curs: fields.ManyToManyRelation[Cur]
68
67
  pmcurs: fields.ManyToManyRelation["Pmcur"] = fields.ManyToManyField("models.Pmcur", through="pmcurex")
69
68
  coins: fields.ManyToManyRelation[Coin]
70
69
 
71
70
  agents: fields.ReverseRelation["Agent"]
72
- curexs: fields.ReverseRelation["Curex"]
73
- pmcurexs: fields.ReverseRelation["Pmcurex"]
74
71
  pmexs: fields.ReverseRelation["Pmex"]
75
72
  pairs: fields.ReverseRelation["Pair"]
76
73
  # deps: fields.ReverseRelation["Dep"]
@@ -90,18 +87,29 @@ class Ex(Model):
90
87
  return client(self)
91
88
 
92
89
 
93
- class Curex(Model):
90
+ class Curex(BaseModel):
94
91
  cur: fields.ForeignKeyRelation[Cur] = fields.ForeignKeyField("models.Cur")
95
92
  ex: fields.ForeignKeyRelation[Ex] = fields.ForeignKeyField("models.Ex")
93
+ exid: str = fields.CharField(31)
94
+ p2p: bool = fields.BooleanField(default=True)
96
95
  countries: fields.ManyToManyRelation[Country] = fields.ManyToManyField(
97
96
  "models.Country", through="curexcountry", backward_key="curexs"
98
97
  )
99
98
 
100
- _name = {"cur__ticker", "ex__name"}
99
+ class Meta:
100
+ table_description = "Currency in Exchange"
101
+ unique_together = (("ex_id", "cur_id"), ("ex_id", "exid"))
102
+
103
+
104
+ class Coinex(BaseModel):
105
+ coin: fields.ForeignKeyRelation[Coin] = fields.ForeignKeyField("models.Coin")
106
+ ex: fields.ForeignKeyRelation[Ex] = fields.ForeignKeyField("models.Ex")
107
+ exid: str = fields.CharField(31)
108
+ p2p: bool = fields.BooleanField(default=True)
101
109
 
102
110
  class Meta:
103
111
  table_description = "Currency in Exchange"
104
- unique_together = (("cur_id", "ex_id"),)
112
+ unique_together = (("ex_id", "coin_id"), ("ex_id", "exid"))
105
113
 
106
114
 
107
115
  class Pair(Model, TsTrait):
@@ -193,7 +201,7 @@ class Agent(Model, TsTrait):
193
201
 
194
202
  class PydanticMeta(Model.PydanticMeta):
195
203
  # max_recursion = 3
196
- include = "ex", "assets", "auth", "updated_at"
204
+ include = "id", "ex", "assets", "auth", "updated_at"
197
205
  computed = ["balance"]
198
206
 
199
207
  async def client(self):
@@ -239,14 +247,11 @@ class Ad(Model, TsTrait):
239
247
 
240
248
  class Pm(Model):
241
249
  name: str = fields.CharField(63, unique=True)
242
- identifier: str | None = fields.CharField(63, unique=True, null=True)
250
+ # identifier: str | None = fields.CharField(63, unique=True, null=True)
243
251
  rank: int | None = fields.SmallIntField(default=0)
244
252
  type_: PmType | None = fields.IntEnumField(PmType, null=True)
245
- template: int | None = fields.SmallIntField(null=True)
246
253
  logo: str | None = fields.CharField(127, null=True)
247
254
  multiAllow: bool | None = fields.BooleanField(null=True)
248
- riskLevel: int | None = fields.SmallIntField(null=True)
249
- chatNeed: bool | None = fields.BooleanField(null=True)
250
255
 
251
256
  ads: fields.ManyToManyRelation[Ad]
252
257
  curs: fields.ManyToManyRelation[Cur]
@@ -271,42 +276,35 @@ class Pmcur(Model): # for fiat with no exs tie
271
276
  fiats: fields.ReverseRelation["Fiat"]
272
277
  exs: fields.ManyToManyRelation[Ex]
273
278
 
274
- _name = {"pm__name", "cur__ticker"}
275
-
276
279
  class Meta:
277
280
  table_description = "Payment methods - Currencies"
278
- unique_together = (("pm", "cur"),)
281
+ # unique_together = ("pm", "cur"),
279
282
 
280
283
  class PydanticMeta(Model.PydanticMeta):
281
284
  max_recursion: int = 2 # default: 3
282
285
  include = "cur_id", "pm"
283
286
 
284
287
 
285
- class Pmex(Model): # existence pm in ex with no cur tie
288
+ class Pmex(BaseModel): # existence pm in ex with no cur tie
286
289
  pm: fields.ForeignKeyRelation[Pm] = fields.ForeignKeyField("models.Pm", "pmexs")
287
290
  pm_id: int
288
291
  ex: fields.ForeignKeyRelation[Ex] = fields.ForeignKeyField("models.Ex", "pmexs")
289
292
  ex_id: int
290
- exid: int = fields.SmallIntField()
291
-
292
- _name = {"pm__name", "ex__name"}
293
+ exid: str = fields.CharField(31)
293
294
 
294
295
  class Meta:
295
- table_description = "Payment methods - Currencies"
296
296
  unique_together = (("pm_id", "ex_id"), ("ex_id", "exid"))
297
297
 
298
298
 
299
- class Pmcurex(Model): # existence pm in ex for exact cur, with "blocked" flag
299
+ class Pmcurex(BaseModel): # existence pm in ex for exact cur, with "blocked" flag
300
300
  pmcur: fields.ForeignKeyRelation[Pmcur] = fields.ForeignKeyField("models.Pmcur")
301
301
  pmcur_id: int
302
302
  ex: fields.ForeignKeyRelation[Ex] = fields.ForeignKeyField("models.Ex")
303
303
  ex_id: int
304
304
  blocked: bool = fields.BooleanField(default=False)
305
305
 
306
- _name = {"pmcur__pm__name", "pmcur__cur__ticker", "ex__name"}
307
-
308
- class Meta:
309
- table_description = "Payment methods - Currencies"
306
+ # class Meta:
307
+ # unique_together = (("ex_id", "pmcur_id"),)
310
308
 
311
309
 
312
310
  class Fiat(Model):
@@ -337,14 +335,12 @@ class Fiat(Model):
337
335
  # # exclude_raw_fields = True
338
336
 
339
337
 
340
- class Fiatex(Model): # existence pm in ex with no cur tie
338
+ class Fiatex(BaseModel): # existence pm in ex with no cur tie
341
339
  fiat: fields.ForeignKeyRelation[Fiat] = fields.ForeignKeyField("models.Fiat", "fiatexs")
342
340
  fiat_id: int
343
341
  ex: fields.ForeignKeyRelation[Ex] = fields.ForeignKeyField("models.Ex", "fiatexs")
344
342
  ex_id: int
345
- exid: int = fields.SmallIntField()
346
-
347
- _name = {"fiat__detail", "ex__name"}
343
+ exid: int = fields.IntField()
348
344
 
349
345
  class Meta:
350
346
  table_description = "Fiat on Ex"
@@ -0,0 +1,204 @@
1
+ Metadata-Version: 2.1
2
+ Name: xync-schema
3
+ Version: 0.6.37
4
+ Summary: XyncNet project database model schema
5
+ Author-email: Mike Artemiev <mixartemev@gmail.com>
6
+ License: EULA
7
+ Project-URL: Homepage, https://gitlab.com/xync/back/schema
8
+ Project-URL: Repository, https://gitlab.com/xync/back/schema
9
+ Requires-Python: >=3.12
10
+ Description-Content-Type: text/markdown
11
+ Requires-Dist: xtg-auth
12
+ Provides-Extra: dev
13
+ Requires-Dist: build ; extra == 'dev'
14
+ Requires-Dist: pytest-asyncio ; extra == 'dev'
15
+ Requires-Dist: twine ; extra == 'dev'
16
+
17
+ ## INSTALL
18
+ ```bash
19
+ # Create python virtual environment
20
+ python3 -m venv venv
21
+ # Activate this environment
22
+ source venv/bin/activate
23
+ # Install dependencies
24
+ pip install -r requirements.dev.txt
25
+
26
+ # Create pg db
27
+ createdb --U username -W dbname
28
+ ## set password for db user
29
+
30
+ # Copy .env file from sample template
31
+ cp .env.sample .env
32
+ ## set your pg creds in .env file
33
+ ```
34
+
35
+ ## TEST
36
+ ```bash
37
+ pytest
38
+ ```
39
+
40
+
41
+ ### pre-commit
42
+ You can done `commit` only after `pytest` will done success.
43
+ Pre-commit script stored in `.git/hooks/pre-commit` file; current script is:
44
+ ```shell
45
+ #!/bin/sh
46
+ pytest
47
+ ```
48
+
49
+ ### Relations
50
+ ```mermaid
51
+ classDiagram
52
+ direction BT
53
+ class Agent {
54
+ timestamp(0) with time zone created_at
55
+ timestamp(0) with time zone updated_at
56
+ integer exid
57
+ jsonb auth
58
+ smallint ex_id
59
+ bigint user_id
60
+ integer id
61
+ }
62
+ class Asset {
63
+ smallint type_ /* spot: 1\nearn: 2\nfound: 3 */
64
+ double precision free
65
+ double precision freeze
66
+ double precision lock
67
+ double precision target
68
+ integer agent_id
69
+ smallint coin_id
70
+ integer id
71
+ }
72
+ class Coin {
73
+ varchar(15) ticker
74
+ double precision rate
75
+ boolean is_fiat
76
+ smallint id
77
+ }
78
+ class CoinEx {
79
+ varchar(31) exid
80
+ boolean p2p
81
+ smallint coin_id
82
+ smallint ex_id
83
+ integer id
84
+ }
85
+ class Country {
86
+ integer code
87
+ varchar(3) short
88
+ varchar(63) name
89
+ smallint cur_id
90
+ smallint id
91
+ }
92
+ class Cur {
93
+ varchar(3) ticker
94
+ double precision rate
95
+ varchar(63) country
96
+ smallint id
97
+ }
98
+ class CurEx {
99
+ varchar(31) exid
100
+ boolean p2p
101
+ smallint cur_id
102
+ smallint ex_id
103
+ integer id
104
+ }
105
+ class CurExCountry {
106
+ integer curexs
107
+ smallint country_id
108
+ }
109
+ class Ex {
110
+ varchar(31) name
111
+ varchar(63) host /* With no protocol 'https://' */
112
+ varchar(63) host_p2p /* With no protocol 'https://' */
113
+ varchar(63) url_login /* With no protocol 'https://' */
114
+ smallint type_ /* p2p: 1\ncex: 2\nmain: 3\ndex: 4\nfutures: 8 */
115
+ varchar(511) logo
116
+ smallint id
117
+ }
118
+ class Fiat {
119
+ varchar(127) detail
120
+ varchar(127) name
121
+ double precision amount
122
+ double precision target
123
+ smallint country_id
124
+ integer pmcur_id
125
+ bigint user_id
126
+ integer id
127
+ }
128
+ class FiatEx {
129
+ integer exid
130
+ smallint ex_id
131
+ integer fiat_id
132
+ integer id
133
+ }
134
+ class Limit {
135
+ integer amount
136
+ integer unit
137
+ integer level
138
+ boolean income
139
+ bigint added_by_id
140
+ integer pmcur_id
141
+ integer id
142
+ }
143
+ class Pm {
144
+ varchar(63) name
145
+ smallint rank
146
+ smallint type_ /* bank: 0\nweb_wallet: 1\ncash: 2\ngift_card: 3\ncredit_card: 4 */
147
+ varchar(127) logo
148
+ boolean multiAllow
149
+ integer id
150
+ }
151
+ class PmCur {
152
+ smallint cur_id
153
+ integer pm_id
154
+ integer id
155
+ }
156
+ class PmCurEx {
157
+ boolean blocked
158
+ smallint ex_id
159
+ integer pmcur_id
160
+ integer id
161
+ }
162
+ class PmEx {
163
+ varchar(31) exid
164
+ smallint ex_id
165
+ integer pm_id
166
+ integer id
167
+ }
168
+ class User {
169
+ timestamp(0) with time zone created_at
170
+ timestamp(0) with time zone updated_at
171
+ smallint role /* READER: 4\nWRITER: 2\nMANAGER: 6\nADMIN: 7 */
172
+ smallint status /* CREATOR: 5\nADMINISTRATOR: 4\nMEMBER: 3\nRESTRICTED: 2\nLEFT:... */
173
+ varchar(95) username
174
+ bigint ref_id
175
+ bigint id
176
+ }
177
+
178
+ Agent --> Ex : ex_id-id
179
+ Agent --> User : user_id-id
180
+ Asset --> Agent : agent_id-id
181
+ Asset --> Coin : coin_id-id
182
+ CoinEx --> Coin : coin_id-id
183
+ CoinEx --> Ex : ex_id-id
184
+ Country --> Cur : cur_id-id
185
+ CurEx --> Cur : cur_id-id
186
+ CurEx --> Ex : ex_id-id
187
+ CurExCountry --> Country : country_id-id
188
+ CurExCountry --> CurEx : curexs-id
189
+ Fiat --> Country : country_id-id
190
+ Fiat --> PmCur : pmcur_id-id
191
+ Fiat --> User : user_id-id
192
+ FiatEx --> Ex : ex_id-id
193
+ FiatEx --> Fiat : fiat_id-id
194
+ Limit --> PmCur : pmcur_id-id
195
+ Limit --> User : added_by_id-id
196
+ PmCur --> Cur : cur_id-id
197
+ PmCur --> Pm : pm_id-id
198
+ PmCurEx --> Ex : ex_id-id
199
+ PmCurEx --> PmCur : pmcur_id-id
200
+ PmEx --> Ex : ex_id-id
201
+ PmEx --> Pm : pm_id-id
202
+ User --> User : ref_id-id
203
+
204
+ ```
@@ -0,0 +1,8 @@
1
+ xync_schema/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ xync_schema/enums.py,sha256=oOpyfG2i1-UKD8Udh2sVBIMUHTIhKZMPIA6Rh7lqnDA,10013
3
+ xync_schema/models.py,sha256=x5RiBV1Wvqwu9TSezDyGtyXqIQBhbDZJM6EOVl2F4t0,20106
4
+ xync_schema/pydantic.py,sha256=cyviSX1P2Cj6fLFq_IsrYdWB6gBOYwR4adPXrAmlP7g,274
5
+ xync_schema-0.6.37.dist-info/METADATA,sha256=uHomi_tU8TxJIpbejuWbSnAEQ2jQt2TAk_9ENjgpiJ4,4352
6
+ xync_schema-0.6.37.dist-info/WHEEL,sha256=a7TGlA-5DaHMRrarXjVbQagU3Man_dCnGIWMJr5kRWo,91
7
+ xync_schema-0.6.37.dist-info/top_level.txt,sha256=jN8IBDfVY8b85Byyk8v0Gyj_0yLB8FO56WV4EvcXWY4,12
8
+ xync_schema-0.6.37.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.3.0)
2
+ Generator: setuptools (75.4.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,47 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: xync-schema
3
- Version: 0.6.36.dev3
4
- Summary: XyncNet project database model schema
5
- Author-email: Mike Artemiev <mixartemev@gmail.com>
6
- License: EULA
7
- Project-URL: Homepage, https://gitlab.com/xync/back/schema
8
- Project-URL: Repository, https://gitlab.com/xync/back/schema
9
- Requires-Python: >=3.12
10
- Description-Content-Type: text/markdown
11
- Requires-Dist: xtg-auth
12
- Provides-Extra: dev
13
- Requires-Dist: build ; extra == 'dev'
14
- Requires-Dist: pytest-asyncio ; extra == 'dev'
15
- Requires-Dist: twine ; extra == 'dev'
16
-
17
- ## INSTALL
18
- ```bash
19
- # Create python virtual environment
20
- python3 -m venv venv
21
- # Activate this environment
22
- source venv/bin/activate
23
- # Install dependencies
24
- pip install -r requirements.dev.txt
25
-
26
- # Create pg db
27
- createdb --U username -W dbname
28
- ## set password for db user
29
-
30
- # Copy .env file from sample template
31
- cp .env.sample .env
32
- ## set your pg creds in .env file
33
- ```
34
-
35
- ## TEST
36
- ```bash
37
- pytest
38
- ```
39
-
40
-
41
- ### pre-commit
42
- You can done `commit` only after `pytest` will done success.
43
- Pre-commit script stored in `.git/hooks/pre-commit` file; current script is:
44
- ```shell
45
- #!/bin/sh
46
- pytest
47
- ```
@@ -1,8 +0,0 @@
1
- xync_schema/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- xync_schema/enums.py,sha256=555m5ZD-l5be9h-_hAHysfCkmKHwKjLFDPM1pw_gFuQ,9932
3
- xync_schema/models.py,sha256=AT_ZZA6H1xz_Lg-tikATVMpcm3X3-lawCL95H7_jS1o,20093
4
- xync_schema/pydantic.py,sha256=cyviSX1P2Cj6fLFq_IsrYdWB6gBOYwR4adPXrAmlP7g,274
5
- xync_schema-0.6.36.dev3.dist-info/METADATA,sha256=4OIwa3Ug1J1fWwRB7qBume4sEv-iSPlum8Uk78lqYv8,1099
6
- xync_schema-0.6.36.dev3.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
7
- xync_schema-0.6.36.dev3.dist-info/top_level.txt,sha256=jN8IBDfVY8b85Byyk8v0Gyj_0yLB8FO56WV4EvcXWY4,12
8
- xync_schema-0.6.36.dev3.dist-info/RECORD,,