xync-schema 0.6.35__py3-none-any.whl → 0.6.36__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 ADDED
@@ -0,0 +1,253 @@
1
+ from enum import IntEnum
2
+
3
+
4
+ class AdStatus(IntEnum):
5
+ defActive = 0
6
+ active = 1
7
+ two = 2
8
+ old = 3
9
+ four = 4
10
+ notFound = 9
11
+
12
+
13
+ class OrderStatus(IntEnum):
14
+ zero = 0
15
+ active = 1
16
+ two = 2
17
+ three = 3
18
+ done = 4
19
+ fifth = 5
20
+ canceled = 6
21
+ paid_and_canceled = 7
22
+ # COMPLETED, PENDING, TRADING, BUYER_PAYED, DISTRIBUTING, COMPLETED, IN_APPEAL, CANCELLED, CANCELLED_BY_SYSTEM
23
+
24
+
25
+ class ExType(IntEnum):
26
+ p2p = 1
27
+ cex = 2
28
+ main = 3 # p2p+cex
29
+ dex = 4
30
+ futures = 8
31
+
32
+
33
+ class DepType(IntEnum):
34
+ earn = 1
35
+ stake = 2
36
+ beth = 3
37
+ lend = 4
38
+
39
+
40
+ class AssetType(IntEnum):
41
+ spot = 1
42
+ earn = 2
43
+ found = 3
44
+
45
+
46
+ class TradeType(IntEnum):
47
+ BUY = 0
48
+ SELL = 1
49
+
50
+
51
+ class PmType(IntEnum):
52
+ bank = 0
53
+ web_wallet = 1
54
+ cash = 2
55
+ gift_card = 3
56
+ credit_card = 4
57
+
58
+
59
+ class TaskType(IntEnum):
60
+ invite_approve = 1
61
+
62
+
63
+ class ExAction(IntEnum):
64
+ """Order"""
65
+
66
+ order_request = 1 # [T] Запрос на старт сделки
67
+ order_request_ask = -1 # [M] - Запрос мейкеру на сделку
68
+ cancel_request = 2 # [T] Отмена запроса на сделку
69
+ request_canceled = -2 # [M] - Уведомление об отмене запроса на сделку
70
+ accept_request = 3 # [M] Одобрить запрос на сделку
71
+ request_accepted = -3 # [T] Уведомление об одобрении запроса на сделку
72
+ reject_request = 4 # [M] Отклонить запрос на сделку
73
+ request_rejected = -4 # [T] Уведомление об отклонении запроса на сделку
74
+ mark_payed = 5 # [B] Перевод сделки в состояние "оплачено", c отправкой чека
75
+ payed = -5 # [S] Уведомиление продавца об оплате
76
+ cancel_order = 6 # [B] Отмена сделки
77
+ order_canceled = -6 # [S] Уведомиление продавцу об отмене оредера покупателем
78
+ confirm = 7 # [S] Подтвердить получение оплаты
79
+ order_completed = -7 # [B] Уведомиление покупателю об успешном завершении продавцом
80
+ appeal_available = -8 # [S,B] Уведомление о наступлении возможности подать аппеляцию
81
+ start_appeal = 9 # ,10 # [S,B] Подать аппеляцию cо скриншотом/видео/файлом
82
+ appeal_started = -9 # ,-10 # [S,B] Уведомление о поданной на меня аппеляци
83
+ dispute_appeal = 11 # ,12 # [S,B] Встречное оспаривание полученной аппеляции cо скриншотом/видео/файлом
84
+ appeal_disputed = -11 # ,-12 # [S,B] Уведомление о встречном оспаривание поданной аппеляции
85
+ order_completed_by_appeal = -13 # [S,B] Уведомление о завершении сделки по аппеляции
86
+ order_canceled_by_appeal = -14 # [B,S] Уведомление об отмене сделки по аппеляции
87
+ cancel_appeal = 15 # [B,S] Отмена аппеляции
88
+ appeal_canceled = -15 # [B,S] Уведомление об отмене аппеляции против меня
89
+ send_order_msg = 16 # Отправка сообщения юзеру в чат по ордеру с приложенным файлом
90
+ get_order_msg = -16 # Получение сообщения в чате по ордеру
91
+ send_appeal_msg = 17 # Отправка сообщения по апелляции
92
+ get_appeal_msg = -17 # Получение сообщения по апелляции
93
+ """ Ex: Public """
94
+ pms = 20 # Список платежных методов по каждой валюте
95
+ curs = 21 # Список поддерживаемых валют тейкера
96
+ cur_pms_map = 22 # Мэппинг валюта => платежные методы
97
+ coins = 23 # Список торгуемых монет (с ограничениям по валютам, если есть)
98
+ ads = 24 # Список объяв по (buy/sell, cur, coin, pm)
99
+ """ Agent: Fiat """
100
+ my_fiats = 25 # Список реквизитов моих платежных методов
101
+ fiat_new = 26 # Создание
102
+ fiat_upd = 27 # Редактирование
103
+ fiat_del = 28 # Удаление
104
+ """ Agent: Ad """
105
+ my_ads = 29 # Список моих ad
106
+ ad_new = 30 # Создание ad:
107
+ ad_upd = 31 # Редактирование
108
+ ad_del = 32 # Удаление
109
+ ad_switch = 33 # Вкл/выкл объявления
110
+ ads_switch = 34 # Вкл/выкл всех объявлений
111
+ """ Agent: Taker """
112
+ get_user = 35 # Получить объект юзера по его ид
113
+ send_user_msg = 36 # Отправка сообщения юзеру с приложенным файлом
114
+ block_user = 37 # [Раз]Блокировать юзера
115
+ rate_user = 38 # Поставить отзыв юзеру
116
+ """ Agent: Inbound """
117
+ get_user_msg = -36 # Получение сообщения от юзера
118
+ got_blocked = -37 # Получение уведомления о [раз]блокировке юзером
119
+ got_rated = -38 # Получение уведомления о полученном отзыве
120
+
121
+
122
+ exs = {
123
+ "Beribit": (
124
+ ExType.p2p,
125
+ "https://sun9-41.userapi.com/impg/cZCGFTXH5-11_HjiWw9aWr3__SlbmMIiXSc-ig/YtOHJpjuVW0.jpg?size=604x604&quality=95&sign=def93bbe4283c563eb2d75a5968350f2",
126
+ "beribit.app",
127
+ "beribit.app",
128
+ "beribit.app/login",
129
+ ),
130
+ "Binance": (
131
+ ExType.main,
132
+ "https://assets.coingecko.com/markets/images/52/large/binance.jpg",
133
+ "binance.com",
134
+ "binance.com",
135
+ "accounts.binance.com/login",
136
+ ),
137
+ "BingX": (
138
+ ExType.p2p,
139
+ "https://assets.coingecko.com/markets/images/812/large/YtFwQwJr_400x400.jpg",
140
+ "bingx.com",
141
+ "bingx.com",
142
+ "bingx.com/login",
143
+ ),
144
+ "Bisq": (ExType.p2p, "", "", "", ""),
145
+ "BitcoinGlobal": (ExType.p2p, "", "", "", ""),
146
+ "BitGet": (
147
+ ExType.p2p,
148
+ "https://assets.coingecko.com/markets/images/591/large/2023-07-25_21.47.43.jpg",
149
+ "www.bitget.com",
150
+ "www.bitget.com",
151
+ "www.bitget.com/login",
152
+ ),
153
+ "BitPapa": (
154
+ ExType.p2p,
155
+ "https://avatars.mds.yandex.net/i?id=130c32d9900d514d738ef89b9c61bcd3_l-4767909-images-thumbs&n=13",
156
+ "bitpapa.com",
157
+ "bitpapa.com",
158
+ "bitpapa.com/log-in",
159
+ ),
160
+ "Bitvalve ": (ExType.p2p, "", "", "", ""),
161
+ "Bybit": (
162
+ ExType.main,
163
+ "https://assets.coingecko.com/markets/images/698/large/bybit_spot.png",
164
+ "bybit.com",
165
+ "bybit.com",
166
+ "bybit.com/login",
167
+ ),
168
+ "CoinCola": (ExType.main, "", "", "", ""),
169
+ "CRYPTED": (ExType.p2p, "", "", "", ""),
170
+ "Garantex": (ExType.p2p, "", "", "", ""),
171
+ "Gate": (
172
+ ExType.p2p,
173
+ "https://assets.coingecko.com/markets/images/403/large/gate_io_logo.jpg",
174
+ "gate.io",
175
+ "gate.io",
176
+ "www.gate.io/login",
177
+ ),
178
+ "HodlHodl": (ExType.p2p, "", "", "", ""),
179
+ "Htx": (
180
+ ExType.main,
181
+ "https://assets.coingecko.com/markets/images/25/large/logo_V_colour_black.png",
182
+ "www.htx.com",
183
+ "www.htx.com",
184
+ "htx.com/login",
185
+ ),
186
+ "Koshelek": (ExType.p2p, "", "", "", ""),
187
+ "KuCoin": (
188
+ ExType.main,
189
+ "https://assets.coingecko.com/markets/images/61/large/kucoin.png",
190
+ "kucoin.com",
191
+ "kucoin.com",
192
+ "www.kucoin.com/ucenter/signin",
193
+ ),
194
+ "LocalCoinSwap": (ExType.p2p, "", "", "", ""),
195
+ "LocalMonero": (ExType.p2p, "", "", "", ""),
196
+ "Mexc": (
197
+ ExType.main,
198
+ "https://assets.coingecko.com/markets/images/409/large/MEXC_logo_square.jpeg",
199
+ "www.mexc.com",
200
+ "www.mexc.com",
201
+ "www.mexc.com/login",
202
+ ),
203
+ "Noones ": (ExType.p2p, "", "", "", ""),
204
+ "Okx": (
205
+ ExType.main,
206
+ "https://assets.coingecko.com/markets/images/379/large/WeChat_Image_20220117220452.png",
207
+ "www.okx.cab",
208
+ "www.okx.cab",
209
+ "www.okx.cab/account/login",
210
+ ),
211
+ "Paxful": (ExType.p2p, "", "", "", ""),
212
+ "PeachBitcoin": (ExType.p2p, "", "", "", ""),
213
+ "Phemex": (ExType.p2p, "", "", "", ""),
214
+ "Poloniex": (ExType.main, "", "", "", ""),
215
+ "Remitano": (ExType.p2p, "", "", "", ""),
216
+ "RiseX": (ExType.p2p, "", "", "", ""),
217
+ "RoboSats": (ExType.p2p, "", "", "", ""),
218
+ "Sigen": (
219
+ ExType.p2p,
220
+ "https://yastatic.net/naydex/yandex-search/neZ1W6346/a21f02dA/2SvJ6dTLJwRiz_lTFP-fhywHqi1fxPNRcIxuKzcpwJ0DGlJzbzdT8ARet86SrINoGNj87R9U-t8HLZcrrBASQf0_6OkAL7cgl6uc0gCrHxI9Y369emE2MJF5yotCyODdZ5iXljtkQJMXTMV9VXsEL68seaiqQF578wnB3V",
221
+ "sigen.pro",
222
+ "sigen.pro",
223
+ "sigen.pro/p2p",
224
+ ),
225
+ "SkyCrypto": (ExType.p2p, "", "", "", ""),
226
+ "SmartSwap": (ExType.p2p, "", "", "", ""),
227
+ "Solid": (ExType.main, "", "", "", ""),
228
+ "TgWallet": (
229
+ ExType.p2p,
230
+ "https://telerock.ru/uploads/posts/2024-03/f658443d9e_c9d505bbf856e2360ba6812079ba02d0.webp",
231
+ "walletbot.me",
232
+ "p2p.walletbot.me",
233
+ "walletbot.me",
234
+ ),
235
+ "TotalCoin": (ExType.p2p, "", "", "", ""),
236
+ "WazirX": (ExType.p2p, "", "", "", ""),
237
+ "WebMoney": (
238
+ ExType.p2p,
239
+ "https://vectorseek.com/wp-content/uploads/2023/08/Webmoney-Icon-Logo-Vector.svg-.png",
240
+ "exchanger.money",
241
+ "exchanger.money",
242
+ "exchanger.money",
243
+ ),
244
+ "WhiteBIT": (ExType.p2p, "", "", "", ""),
245
+ "xRocket": (
246
+ ExType.p2p,
247
+ "https://cdn.allmylinks.com/prod/Upload/file/R/L/6/8G0TaGNtUV8C1V7VQsivDtJcpEz2z7Lc.jpg",
248
+ "",
249
+ "",
250
+ "",
251
+ ),
252
+ # "catalogop2p(.com": ExType.p2p, ''), todo: discover brazilian p2p platforms
253
+ }
xync_schema/models.py CHANGED
@@ -1,111 +1,13 @@
1
1
  from datetime import datetime
2
- from enum import IntEnum
3
2
  from tortoise import fields
4
3
  from tortoise.queryset import QuerySet
4
+ from tortoise import Model as BaseModel
5
5
  from x_auth.enums import Role
6
6
  from x_auth.models import Model
7
7
  from x_model.models import TsTrait, DatetimeSecField
8
8
  from tg_auth.models import UserStatus, AuthUser
9
9
 
10
-
11
- class AdStatus(IntEnum):
12
- defActive = 0
13
- active = 1
14
- two = 2
15
- old = 3
16
- four = 4
17
- notFound = 9
18
-
19
-
20
- class OrderStatus(IntEnum):
21
- zero = 0
22
- active = 1
23
- two = 2
24
- three = 3
25
- done = 4
26
- fifth = 5
27
- canceled = 6
28
- paid_and_canceled = 7
29
- # COMPLETED, PENDING, TRADING, BUYER_PAYED, DISTRIBUTING, COMPLETED, IN_APPEAL, CANCELLED, CANCELLED_BY_SYSTEM
30
-
31
-
32
- class ExType(IntEnum):
33
- p2p = 1
34
- cex = 2
35
- main = 3 # p2p+cex
36
- dex = 4
37
- futures = 8
38
-
39
-
40
- class DepType(IntEnum):
41
- earn = 1
42
- stake = 2
43
- beth = 3
44
- lend = 4
45
-
46
-
47
- class AssetType(IntEnum):
48
- spot = 1
49
- earn = 2
50
- found = 3
51
-
52
-
53
- class TradeType(IntEnum):
54
- BUY = 0
55
- SELL = 1
56
-
57
-
58
- class PmType(IntEnum):
59
- bank = 0
60
- web_wallet = 1
61
- cash = 2
62
- gift_card = 3
63
- credit_card = 4
64
-
65
-
66
- class TaskType(IntEnum):
67
- invite_approve = 1
68
-
69
-
70
- class ExAction(IntEnum):
71
- """Public"""
72
-
73
- all_curs_taker = 1 # список поддерживаемых валют
74
- all_coins = 2 # список торгуемых монет по каждой валюте
75
- all_pms = 3 # список платежных методов по каждой валюте
76
- all_ads = 4 # список объяв по (buy/sell, cur, coin, pm)
77
- """ My PMs """
78
- fiats = 5 # список реквизитов моих платежных методов (fiats)
79
- fiat_new = 6 # создание моего fiat
80
- fiat_upd = 7 # редактирование моего fiat
81
- fiat_del = 8 # удаление моего fiat
82
- """ Ads """
83
- my_ads = 9 # список моих ad
84
- ad_new = 10 # создание ad: (buy/sell, cur, coin, [pm], price_type, price, details, autoreply)
85
- ad_upd = 11 # редактирование моего ad
86
- ad_del = 12 # удаление моего ad
87
- ad_on = 13 # включение моего ad
88
- ad_off = 14 # выключение моего ad
89
- """ Orders """
90
- order_approve = 15 # одобрить заявку
91
- order_reject = 16 # отклонить заявку
92
- take_ad = 17 # старт сделки (order) по чужому объявлению (ad) тейкером на сумму amount: (ad_id, amount)
93
- order_cancel = 18 # отмена order-a (только для buy заявок)
94
- order_paid = 19 # отправка статуса "оплачено" по buy ордеру
95
- order_payment_confirm = 20 # отправка подтверждения "получено" по sell ордеру
96
- get_chat = 21 # получение сообщений чата по ордеру
97
- send_msg = 22 # отправка сообщения в чат по ордеру с приложенным фото
98
- appeal_start = 23 # открыть апелляцию по ордеру
99
- appeal_accept = 24 # согласиться с чужой апелляцией
100
- appeal_cancel = 25 # отмена своей апелляции
101
- send_appeal_msg = 26 # сообщение по апелляции
102
- user_block = 27 # блокировать юзера
103
- user_review_post = 28 # поставить отзыв юзеру
104
- user_rating = 29 # рейтинг и отзывы юзера
105
- ws_chat = 30 # подписка на сообщения в чате
106
- ws_status = 31 # подписка на изменение статуса ордера
107
- get_orders = 32 # получшение заявок за заданное время, статус, направление, валюта, монета
108
- get_order = 33 # получшение инфы по конкретной заявке
10
+ from xync_schema.enums import ExType, AdStatus, PmType, AssetType, OrderStatus, ExAction
109
11
 
110
12
 
111
13
  class Country(Model):
@@ -117,8 +19,6 @@ class Country(Model):
117
19
  curexs: fields.ManyToManyRelation["Curex"]
118
20
  fiats: fields.BackwardFKRelation["Fiat"]
119
21
 
120
- _icon = "location"
121
-
122
22
 
123
23
  class Cur(Model):
124
24
  id = fields.SmallIntField(True)
@@ -127,8 +27,7 @@ class Cur(Model):
127
27
  country: str | None = fields.CharField(63, null=True)
128
28
 
129
29
  pms: fields.ManyToManyRelation["Pm"] = fields.ManyToManyField("models.Pm", through="pmcur")
130
- curexs: fields.ReverseRelation["Curex"]
131
- pmcurs: fields.ReverseRelation["Pmcur"] # no need. use pms
30
+ exs: fields.ManyToManyRelation["Ex"] = fields.ManyToManyField("models.Ex", through="curex")
132
31
  pairs: fields.ReverseRelation["Pair"]
133
32
  countries: fields.ReverseRelation[Country]
134
33
 
@@ -164,12 +63,11 @@ class Ex(Model):
164
63
  logo: str = fields.CharField(511, default="")
165
64
 
166
65
  pms: fields.ManyToManyRelation["Pm"]
66
+ curs: fields.ManyToManyRelation[Cur]
167
67
  pmcurs: fields.ManyToManyRelation["Pmcur"] = fields.ManyToManyField("models.Pmcur", through="pmcurex")
168
68
  coins: fields.ManyToManyRelation[Coin]
169
69
 
170
70
  agents: fields.ReverseRelation["Agent"]
171
- curexs: fields.ReverseRelation["Curex"]
172
- pmcurexs: fields.ReverseRelation["Pmcurex"]
173
71
  pmexs: fields.ReverseRelation["Pmex"]
174
72
  pairs: fields.ReverseRelation["Pair"]
175
73
  # deps: fields.ReverseRelation["Dep"]
@@ -182,19 +80,36 @@ class Ex(Model):
182
80
  class PydanticMeta(Model.PydanticMeta):
183
81
  include = "name", "logo"
184
82
 
83
+ async def client(self):
84
+ import sys
85
+
86
+ client = sys.modules[f"xync_client.{self.name}.ex"].Client
87
+ return client(self)
88
+
185
89
 
186
- class Curex(Model):
90
+ class Curex(BaseModel):
187
91
  cur: fields.ForeignKeyRelation[Cur] = fields.ForeignKeyField("models.Cur")
188
92
  ex: fields.ForeignKeyRelation[Ex] = fields.ForeignKeyField("models.Ex")
93
+ exid: str = fields.CharField(31)
94
+ p2p: bool = fields.BooleanField(default=True)
189
95
  countries: fields.ManyToManyRelation[Country] = fields.ManyToManyField(
190
96
  "models.Country", through="curexcountry", backward_key="curexs"
191
97
  )
192
98
 
193
- _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)
194
109
 
195
110
  class Meta:
196
111
  table_description = "Currency in Exchange"
197
- unique_together = (("cur_id", "ex_id"),)
112
+ unique_together = (("ex_id", "coin_id"), ("ex_id", "exid"))
198
113
 
199
114
 
200
115
  class Pair(Model, TsTrait):
@@ -286,7 +201,7 @@ class Agent(Model, TsTrait):
286
201
 
287
202
  class PydanticMeta(Model.PydanticMeta):
288
203
  # max_recursion = 3
289
- include = "ex", "assets", "auth", "updated_at"
204
+ include = "id", "ex", "assets", "auth", "updated_at"
290
205
  computed = ["balance"]
291
206
 
292
207
  async def client(self):
@@ -295,7 +210,7 @@ class Agent(Model, TsTrait):
295
210
  if isinstance(self.ex, QuerySet):
296
211
  # noinspection PyTypeChecker
297
212
  self.ex: Ex = await self.ex
298
- client = sys.modules[f"xync_client.{self.ex.name}.p2p"].AgentClient
213
+ client = sys.modules[f"xync_client.{self.ex.name}.agent"].Client
299
214
  return client(self)
300
215
 
301
216
 
@@ -332,21 +247,15 @@ class Ad(Model, TsTrait):
332
247
 
333
248
  class Pm(Model):
334
249
  name: str = fields.CharField(63, unique=True)
335
- identifier: str | None = fields.CharField(63, unique=True, null=True)
250
+ # identifier: str | None = fields.CharField(63, unique=True, null=True)
336
251
  rank: int | None = fields.SmallIntField(default=0)
337
252
  type_: PmType | None = fields.IntEnumField(PmType, null=True)
338
- template: int | None = fields.SmallIntField(null=True)
339
253
  logo: str | None = fields.CharField(127, null=True)
340
- color: str | None = fields.CharField(7, null=True)
341
254
  multiAllow: bool | None = fields.BooleanField(null=True)
342
- riskLevel: int | None = fields.SmallIntField(null=True)
343
- chatNeed: bool | None = fields.BooleanField(null=True)
344
255
 
345
256
  ads: fields.ManyToManyRelation[Ad]
346
257
  curs: fields.ManyToManyRelation[Cur]
347
- exs: fields.ManyToManyRelation[Ex] = fields.ManyToManyField(
348
- "models.Ex", through="pmex"
349
- ) # no need. use pmexs[.exid]
258
+ exs: fields.ManyToManyRelation[Ex] = fields.ManyToManyField("models.Ex", "pmex") # no need. use pmexs[.exid]
350
259
  orders: fields.ReverseRelation["Order"]
351
260
  pmcurs: fields.ReverseRelation["Pmcur"] # no need. use curs
352
261
  pmexs: fields.ReverseRelation["Pmex"]
@@ -354,6 +263,9 @@ class Pm(Model):
354
263
  class Meta:
355
264
  table_description = "Payment methods"
356
265
 
266
+ class PydanticMeta(Model.PydanticMeta):
267
+ include = ("id", "name", "logo")
268
+
357
269
 
358
270
  class Pmcur(Model): # for fiat with no exs tie
359
271
  pm: fields.ForeignKeyRelation[Pm] = fields.ForeignKeyField("models.Pm")
@@ -364,41 +276,35 @@ class Pmcur(Model): # for fiat with no exs tie
364
276
  fiats: fields.ReverseRelation["Fiat"]
365
277
  exs: fields.ManyToManyRelation[Ex]
366
278
 
367
- _name = {"pm__name", "cur__ticker"}
368
-
369
279
  class Meta:
370
280
  table_description = "Payment methods - Currencies"
371
- unique_together = (("pm", "cur"),)
281
+ # unique_together = ("pm", "cur"),
372
282
 
373
283
  class PydanticMeta(Model.PydanticMeta):
374
- exclude_raw_fields: bool = False
284
+ max_recursion: int = 2 # default: 3
285
+ include = "cur_id", "pm"
375
286
 
376
287
 
377
- class Pmex(Model): # existence pm in ex with no cur tie
288
+ class Pmex(BaseModel): # existence pm in ex with no cur tie
378
289
  pm: fields.ForeignKeyRelation[Pm] = fields.ForeignKeyField("models.Pm", "pmexs")
379
290
  pm_id: int
380
291
  ex: fields.ForeignKeyRelation[Ex] = fields.ForeignKeyField("models.Ex", "pmexs")
381
292
  ex_id: int
382
- exid: int = fields.SmallIntField()
383
-
384
- _name = {"pm__name", "ex__name"}
293
+ exid: str = fields.CharField(31)
385
294
 
386
295
  class Meta:
387
- table_description = "Payment methods - Currencies"
388
296
  unique_together = (("pm_id", "ex_id"), ("ex_id", "exid"))
389
297
 
390
298
 
391
- 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
392
300
  pmcur: fields.ForeignKeyRelation[Pmcur] = fields.ForeignKeyField("models.Pmcur")
393
301
  pmcur_id: int
394
302
  ex: fields.ForeignKeyRelation[Ex] = fields.ForeignKeyField("models.Ex")
395
303
  ex_id: int
396
304
  blocked: bool = fields.BooleanField(default=False)
397
305
 
398
- _name = {"pmcur__pm__name", "pmcur__cur__ticker", "ex__name"}
399
-
400
- class Meta:
401
- table_description = "Payment methods - Currencies"
306
+ # class Meta:
307
+ # unique_together = (("ex_id", "pmcur_id"),)
402
308
 
403
309
 
404
310
  class Fiat(Model):
@@ -429,14 +335,12 @@ class Fiat(Model):
429
335
  # # exclude_raw_fields = True
430
336
 
431
337
 
432
- class Fiatex(Model): # existence pm in ex with no cur tie
338
+ class Fiatex(BaseModel): # existence pm in ex with no cur tie
433
339
  fiat: fields.ForeignKeyRelation[Fiat] = fields.ForeignKeyField("models.Fiat", "fiatexs")
434
340
  fiat_id: int
435
341
  ex: fields.ForeignKeyRelation[Ex] = fields.ForeignKeyField("models.Ex", "fiatexs")
436
342
  ex_id: int
437
- exid: int = fields.SmallIntField()
438
-
439
- _name = {"fiat__detail", "ex__name"}
343
+ exid: int = fields.IntField()
440
344
 
441
345
  class Meta:
442
346
  table_description = "Fiat on Ex"
xync_schema/pydantic.py CHANGED
@@ -13,10 +13,3 @@ class FiatNew(FiatUpd):
13
13
  pm_id: int
14
14
  detail: str
15
15
  amount: float = 0
16
-
17
-
18
- class Agent(BaseModel):
19
- cur_id: int
20
- pm_id: int
21
- detail: str
22
- amount: float = 0
@@ -0,0 +1,267 @@
1
+ Metadata-Version: 2.1
2
+ Name: xync-schema
3
+ Version: 0.6.36
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 node21 {
54
+ timestamp(0) with time zone created_at
55
+ timestamp(0) with time zone updated_at
56
+ double precision price
57
+ double precision maxFiat
58
+ double precision minFiat
59
+ varchar(4095) detail
60
+ varchar(255) autoMsg
61
+ smallint status /* defActive: 0\nactive: 1\ntwo: 2\nold: 3\nfour: 4\nnotFound: 9 */
62
+ integer agent_id
63
+ smallint direction_id
64
+ bigint id
65
+ }
66
+ class node14 {
67
+ bigint ad_id
68
+ integer pm_id
69
+ integer id
70
+ }
71
+ class node8 {
72
+ timestamp(0) with time zone created_at
73
+ timestamp(0) with time zone updated_at
74
+ integer exid
75
+ jsonb auth
76
+ smallint ex_id
77
+ bigint user_id
78
+ integer id
79
+ }
80
+ class node1 {
81
+ smallint type_ /* spot: 1\nearn: 2\nfound: 3 */
82
+ double precision free
83
+ double precision freeze
84
+ double precision lock
85
+ double precision target
86
+ integer agent_id
87
+ smallint coin_id
88
+ integer id
89
+ }
90
+ class coin {
91
+ varchar(15) ticker
92
+ double precision rate
93
+ boolean is_fiat
94
+ smallint id
95
+ }
96
+ class node22 {
97
+ varchar(31) exid
98
+ boolean p2p
99
+ smallint coin_id
100
+ smallint ex_id
101
+ integer id
102
+ }
103
+ class country {
104
+ integer code
105
+ varchar(3) short
106
+ varchar(63) name
107
+ smallint cur_id
108
+ smallint id
109
+ }
110
+ class node19 {
111
+ varchar(3) ticker
112
+ double precision rate
113
+ varchar(63) country
114
+ smallint id
115
+ }
116
+ class node15 {
117
+ varchar(31) exid
118
+ boolean p2p
119
+ smallint cur_id
120
+ smallint ex_id
121
+ integer id
122
+ }
123
+ class curexcountry {
124
+ integer curexs
125
+ smallint country_id
126
+ }
127
+ class node2 {
128
+ boolean sell
129
+ integer total
130
+ smallint pair_id
131
+ smallint id
132
+ }
133
+ class node5 {
134
+ varchar(31) name
135
+ varchar(63) host /* With no protocol 'https://' */
136
+ varchar(63) host_p2p /* With no protocol 'https://' */
137
+ varchar(63) url_login /* With no protocol 'https://' */
138
+ smallint type_ /* p2p: 1\ncex: 2\nmain: 3\ndex: 4\nfutures: 8 */
139
+ varchar(511) logo
140
+ smallint id
141
+ }
142
+ class node13 {
143
+ varchar(127) detail
144
+ varchar(127) name
145
+ double precision amount
146
+ double precision target
147
+ smallint country_id
148
+ integer pmcur_id
149
+ bigint user_id
150
+ integer id
151
+ }
152
+ class node10 {
153
+ integer exid
154
+ smallint ex_id
155
+ integer fiat_id
156
+ integer id
157
+ }
158
+ class node3 {
159
+ integer amount
160
+ integer unit
161
+ integer level
162
+ boolean income
163
+ bigint added_by_id
164
+ integer pmcur_id
165
+ integer id
166
+ }
167
+ class node16 {
168
+ timestamp(0) with time zone created_at
169
+ timestamp(0) with time zone updated_at
170
+ double precision amount
171
+ smallint status /* zero: 0\nactive: 1\ntwo: 2\nthree: 3\ndone: 4\nfifth: 5\ncanc... */
172
+ timestamp(0) with time zone notify_pay_at
173
+ timestamp(0) with time zone confirm_pay_at
174
+ bigint ad_id
175
+ integer fiat_id
176
+ integer taker_id
177
+ bigint id
178
+ }
179
+ class node9 {
180
+ timestamp(0) with time zone created_at
181
+ timestamp(0) with time zone updated_at
182
+ double precision fee
183
+ smallint coin_id
184
+ smallint cur_id
185
+ smallint ex_id
186
+ smallint id
187
+ }
188
+ class node6 {
189
+ varchar(63) name
190
+ smallint rank
191
+ smallint type_ /* bank: 0\nweb_wallet: 1\ncash: 2\ngift_card: 3\ncredit_card: 4 */
192
+ varchar(127) logo
193
+ boolean multiAllow
194
+ integer id
195
+ }
196
+ class node12 {
197
+ smallint cur_id
198
+ integer pm_id
199
+ integer id
200
+ }
201
+ class pmcurex {
202
+ boolean blocked
203
+ smallint ex_id
204
+ integer pmcur_id
205
+ integer id
206
+ }
207
+ class pmex {
208
+ varchar(31) exid
209
+ smallint ex_id
210
+ integer pm_id
211
+ integer id
212
+ }
213
+ class node11 {
214
+ smallint action /* order_request: 1\norder_request_ask: -1\ncancel_request: 2\nr... */
215
+ boolean ok
216
+ timestamp(0) with time zone updated_at
217
+ smallint ex_id
218
+ integer id
219
+ }
220
+ class user {
221
+ timestamp(0) with time zone created_at
222
+ timestamp(0) with time zone updated_at
223
+ smallint role /* READER: 4\nWRITER: 2\nMANAGER: 6\nADMIN: 7 */
224
+ smallint status /* CREATOR: 5\nADMINISTRATOR: 4\nMEMBER: 3\nRESTRICTED: 2\nLEFT:... */
225
+ varchar(95) username
226
+ bigint ref_id
227
+ bigint id
228
+ }
229
+
230
+ node21 --> node8 : agent_id-id
231
+ node21 --> node2 : direction_id-id
232
+ node14 --> node21 : ad_id-id
233
+ node14 --> node6 : pm_id-id
234
+ node8 --> node5 : ex_id-id
235
+ node8 --> user : user_id-id
236
+ node1 --> node8 : agent_id-id
237
+ node1 --> coin : coin_id-id
238
+ node22 --> coin : coin_id-id
239
+ node22 --> node5 : ex_id-id
240
+ country --> node19 : cur_id-id
241
+ node15 --> node19 : cur_id-id
242
+ node15 --> node5 : ex_id-id
243
+ curexcountry --> country : country_id-id
244
+ curexcountry --> node15 : curexs-id
245
+ node2 --> node9 : pair_id-id
246
+ node13 --> country : country_id-id
247
+ node13 --> node12 : pmcur_id-id
248
+ node13 --> user : user_id-id
249
+ node10 --> node5 : ex_id-id
250
+ node10 --> node13 : fiat_id-id
251
+ node3 --> node12 : pmcur_id-id
252
+ node3 --> user : added_by_id-id
253
+ node16 --> node21 : ad_id-id
254
+ node16 --> node8 : taker_id-id
255
+ node16 --> node13 : fiat_id-id
256
+ node9 --> coin : coin_id-id
257
+ node9 --> node19 : cur_id-id
258
+ node9 --> node5 : ex_id-id
259
+ node12 --> node19 : cur_id-id
260
+ node12 --> node6 : pm_id-id
261
+ pmcurex --> node5 : ex_id-id
262
+ pmcurex --> node12 : pmcur_id-id
263
+ pmex --> node5 : ex_id-id
264
+ pmex --> node6 : pm_id-id
265
+ node11 --> node5 : ex_id-id
266
+ user --> user : ref_id-id
267
+ ```
@@ -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.36.dist-info/METADATA,sha256=CRTMBs1SdnRTjDiILAQPqC6PbSYVH-djU7yl3yWYHVE,6087
6
+ xync_schema-0.6.36.dist-info/WHEEL,sha256=a7TGlA-5DaHMRrarXjVbQagU3Man_dCnGIWMJr5kRWo,91
7
+ xync_schema-0.6.36.dist-info/top_level.txt,sha256=jN8IBDfVY8b85Byyk8v0Gyj_0yLB8FO56WV4EvcXWY4,12
8
+ xync_schema-0.6.36.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.35
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,7 +0,0 @@
1
- xync_schema/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- xync_schema/models.py,sha256=cLw-_1SLrym0PuZXuMhS1x9GWSIb4J5Qiql7mmTXGjg,23445
3
- xync_schema/pydantic.py,sha256=vvsgJfT9VLnRNDzOiY0dn2qJ5K_tN09bHRHRvw7Y3_c,369
4
- xync_schema-0.6.35.dist-info/METADATA,sha256=Q16UAHW9v-upCzppuLYtGYn0xtN0aMZHutswii4KTOc,1094
5
- xync_schema-0.6.35.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
6
- xync_schema-0.6.35.dist-info/top_level.txt,sha256=jN8IBDfVY8b85Byyk8v0Gyj_0yLB8FO56WV4EvcXWY4,12
7
- xync_schema-0.6.35.dist-info/RECORD,,