dao-treasury 0.0.32__cp310-cp310-musllinux_1_2_i686.whl → 0.0.33__cp310-cp310-musllinux_1_2_i686.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.
@@ -1,5 +1,28 @@
1
1
  """
2
- This module contains logic for sorting transactions into various categories.
2
+ This module provides the core logic for sorting DAO Treasury transactions into transaction groups (categories).
3
+
4
+ Sorting enables comprehensive financial reporting and categorization tailored for on-chain organizations.
5
+ Transactions are matched against either statically defined rules or more advanced dynamic rules based on user-defined matching functions.
6
+
7
+ Sorting works by attempting matches in this order:
8
+ 1. Check if the transaction is an internal transfer (within treasury wallets).
9
+ 2. Check if the transaction is "Out of Range" (neither sender nor receiver was a treasury wallet at the time of the tx).
10
+ 3. Match by transaction hash using registered HashMatchers.
11
+ 4. Match by sender address using registered FromAddressMatchers.
12
+ 5. Match by recipient address using registered ToAddressMatchers.
13
+ 6. Assign "Must Sort Inbound" or "Must Sort Outbound" groups if part of treasury.
14
+ 7. Raise an error if no match is found (unexpected case).
15
+
16
+ See the complete [sort rules documentation](https://bobthebuidler.github.io/dao-treasury/sort_rules.html) for detailed explanations
17
+ and examples on defining and registering sort rules.
18
+
19
+ See Also:
20
+ :func:`dao_treasury.sorting.sort_basic`
21
+ :func:`dao_treasury.sorting.sort_basic_entity`
22
+ :func:`dao_treasury.sorting.sort_advanced`
23
+ :class:`dao_treasury.sorting.HashMatcher`
24
+ :class:`dao_treasury.sorting.FromAddressMatcher`
25
+ :class:`dao_treasury.sorting.ToAddressMatcher`
3
26
  """
4
27
 
5
28
  from logging import getLogger
@@ -72,16 +95,54 @@ INTERNAL_TRANSFER_TXGROUP_DBID: Final = TxGroup.get_dbid(
72
95
  name="Internal Transfer",
73
96
  parent=TxGroup.get_dbid("Ignore"),
74
97
  )
75
- # TODO: write a docstring
98
+ """Database ID for the 'Internal Transfer' transaction group.
99
+
100
+ This group represents transactions that occur internally between treasury-owned wallets.
101
+ Such internal movements of funds within the DAO's treasury do not require separate handling or reporting.
102
+
103
+ See Also:
104
+ :class:`dao_treasury.db.TxGroup`
105
+ """
76
106
 
77
107
  OUT_OF_RANGE_TXGROUP_DBID = TxGroup.get_dbid(
78
108
  name="Out of Range", parent=TxGroup.get_dbid("Ignore")
79
109
  )
80
- # TODO: write a docstring
110
+ """Database ID for the 'Out of Range' transaction group.
111
+
112
+ This category is assigned to transactions where neither the sender nor the recipient
113
+ wallet are members of the treasury at the time of the transaction.
114
+
115
+ See Also:
116
+ :class:`dao_treasury.db.TxGroup`
117
+ """
81
118
 
82
119
 
83
120
  def sort_basic(entry: LedgerEntry) -> TxGroupDbid:
84
- # TODO: write docstring
121
+ """Determine the transaction group ID for a basic ledger entry using static matching.
122
+
123
+ The function attempts to categorize the transaction by testing:
124
+ - If both 'from' and 'to' addresses are treasury wallets (internal transfer).
125
+ - If neither ‘to’ address is a treasury wallet at the time of the transaction (out of range).
126
+ - If the transaction hash matches a known HashMatcher.
127
+ - If the 'from' address matches a FromAddressMatcher.
128
+ - If the 'to' address matches a ToAddressMatcher.
129
+ - Assignment to 'Must Sort Outbound' or 'Must Sort Inbound' groups if applicable.
130
+ - Raises `NotImplementedError` if none of the above conditions are met (should not happen).
131
+
132
+ Args:
133
+ entry: A ledger entry representing a blockchain transaction.
134
+
135
+ Examples:
136
+ >>> from eth_portfolio.structs import Transaction
137
+ >>> entry = Transaction(from_address="0xabc...", to_address="0xdef...", block_number=1234567)
138
+ >>> group_id = sort_basic(entry)
139
+ >>> print(group_id)
140
+
141
+ See Also:
142
+ :func:`sort_basic_entity`
143
+ :func:`sort_advanced`
144
+ :class:`dao_treasury.sorting.HashMatcher`
145
+ """
85
146
  from_address = entry.from_address
86
147
  to_address = entry.to_address
87
148
  block = entry.block_number
@@ -117,7 +178,25 @@ def sort_basic(entry: LedgerEntry) -> TxGroupDbid:
117
178
 
118
179
 
119
180
  def sort_basic_entity(tx: db.TreasuryTx) -> TxGroupDbid:
120
- # TODO: write docstring
181
+ """Determine the transaction group ID for a TreasuryTx database entity using static matching.
182
+
183
+ Similar to :func:`sort_basic` but operates on a TreasuryTx entity from the database.
184
+ It considers additional constants such as `DISPERSE_APP` when determining whether
185
+ a transaction is out of range.
186
+
187
+ Args:
188
+ tx: A TreasuryTx database entity representing a treasury transaction.
189
+
190
+ Examples:
191
+ >>> from dao_treasury.db import TreasuryTx
192
+ >>> tx = TreasuryTx[123]
193
+ >>> group_id = sort_basic_entity(tx)
194
+ >>> print(group_id)
195
+
196
+ See Also:
197
+ :func:`sort_basic`
198
+ :func:`sort_advanced`
199
+ """
121
200
  from_address = tx.from_address.address
122
201
  to_address = tx.to_address
123
202
  block = tx.block
@@ -167,7 +246,31 @@ def sort_basic_entity(tx: db.TreasuryTx) -> TxGroupDbid:
167
246
 
168
247
 
169
248
  async def sort_advanced(entry: db.TreasuryTx) -> TxGroupDbid:
170
- # TODO: write docstring
249
+ """Determine the transaction group ID for a TreasuryTx entity using advanced dynamic rules.
250
+
251
+ Starts with the result of static matching via :func:`sort_basic_entity`, then
252
+ applies advanced asynchronous matching rules registered under :data:`SORT_RULES`.
253
+ Applies rules sequentially until a match is found or all rules are exhausted.
254
+
255
+ If a rule's match attempt raises a `ContractNotVerified` exception, the rule is skipped.
256
+
257
+ Updates the TreasuryTx entity's transaction group in the database when a match
258
+ other than 'Must Sort Inbound/Outbound' is found.
259
+
260
+ Args:
261
+ entry: A TreasuryTx database entity representing a treasury transaction.
262
+
263
+ Examples:
264
+ >>> from dao_treasury.db import TreasuryTx
265
+ >>> import asyncio
266
+ >>> tx = TreasuryTx[123]
267
+ >>> group_id = asyncio.run(sort_advanced(tx))
268
+ >>> print(group_id)
269
+
270
+ See Also:
271
+ :func:`sort_basic_entity`
272
+ :data:`SORT_RULES`
273
+ """
171
274
  txgroup_dbid = sort_basic_entity(entry)
172
275
 
173
276
  if txgroup_dbid in (
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dao_treasury
3
- Version: 0.0.32
3
+ Version: 0.0.33
4
4
  Summary: Produce comprehensive financial reports for your on-chain org
5
5
  Classifier: Development Status :: 3 - Alpha
6
6
  Classifier: Intended Audience :: Developers
@@ -14,7 +14,7 @@ Classifier: Operating System :: OS Independent
14
14
  Classifier: Topic :: Software Development :: Libraries
15
15
  Requires-Python: >=3.10,<3.13
16
16
  Description-Content-Type: text/markdown
17
- Requires-Dist: eth-portfolio-temp<0.1,>=0.0.29.dev0
17
+ Requires-Dist: eth-portfolio-temp<0.1,>=0.0.30.dev0
18
18
  Dynamic: classifier
19
19
  Dynamic: description
20
20
  Dynamic: description-content-type
@@ -1,4 +1,4 @@
1
- bf2b4fe1f86ad2ea158b__mypyc.cpython-310-i386-linux-gnu.so,sha256=FVv9J-fNBNm_lACMzRRx-1JLOAEOreVPZO5Y-i1HTdA,1454192
1
+ bf2b4fe1f86ad2ea158b__mypyc.cpython-310-i386-linux-gnu.so,sha256=dMzZrXy-1JCQsHSuY4OiPpgSC36NIb_eK-TtsKhUXTc,1454196
2
2
  dao_treasury/ENVIRONMENT_VARIABLES.py,sha256=yKvgOMUyU7-fF_-1zSMXML7ah7-r2f0oHrOV0p10LPc,195
3
3
  dao_treasury/__init__.py,sha256=ZQ0ZROQzSyJdYuQS1Z_VD0c7CiV8BWZcLTX66wO4slc,1004
4
4
  dao_treasury/_docker.cpython-310-i386-linux-gnu.so,sha256=CN3BW4fzOrm_JFh-7OJn2sTkLUQdd5vWMrB53LnuH98,16572
@@ -9,22 +9,24 @@ dao_treasury/_wallet.cpython-310-i386-linux-gnu.so,sha256=ZBqDRhPMRPRLIoDb1gzeUf
9
9
  dao_treasury/_wallet.py,sha256=sIeUsyu9Y8MmOm-9bfwIEYjJ9Owgv1GXdTLZpcXMnCg,10338
10
10
  dao_treasury/constants.cpython-310-i386-linux-gnu.so,sha256=4AaK5_3W297jgmdDNcgnpjV3Xzi21k83RlrdhM0U9sY,16580
11
11
  dao_treasury/constants.py,sha256=IFg_CyVnfPhPjKyFX1Ix4QaB8ghbOI5QZGSy2TNsUSA,507
12
- dao_treasury/db.py,sha256=pGz4C2OmxHI9CyrphbFzs04aiVP_VQeViaavCiJuR3o,44831
12
+ dao_treasury/db.py,sha256=F-ZZQ21KCTCNusOgQADIMXl1mpuuI7g26nCV2Y7U8Yk,46136
13
13
  dao_treasury/docker-compose.yaml,sha256=Q6NPNT9iKkKOehDcKtxltvQjbxZuXmb51Tjwb1M21_I,1376
14
14
  dao_treasury/main.py,sha256=31EA10Fpaj9y-cRJPnNnvCBI38UM0848xlzn7A0BzC4,8047
15
15
  dao_treasury/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  dao_treasury/treasury.py,sha256=7xLVQPqnDd3cexbYuF1opTjCiHgkPqHFOanRom8wiLE,6506
17
17
  dao_treasury/types.cpython-310-i386-linux-gnu.so,sha256=-Wlq5_Bt9wAXmHm-_6Po-ZgKddgEuB5POyN9doSa1uA,16564
18
18
  dao_treasury/types.py,sha256=dJDx0hYfDDL3slcUzRnCgrzFFsgCzoqg8uaTtLaT4kk,3685
19
- dao_treasury/.grafana/provisioning/dashboards/dashboards.yaml,sha256=ecu7lHpcrYFTSEHbZErX63mn2CFPqEXcprtcYDcHPSo,713
19
+ dao_treasury/.grafana/provisioning/dashboards/dashboards.yaml,sha256=tr6FBJeAAPX76db8E3qBBVWnq2-yrWDXDGuclMDg6dw,1277
20
20
  dao_treasury/.grafana/provisioning/dashboards/streams/LlamaPay.json,sha256=7bDAboObB2LsY6EicAL-DAC0HKIaSRVW6AbGzmy_xUI,3403
21
- dao_treasury/.grafana/provisioning/dashboards/summary/Monthly.json,sha256=y7t4O0ujImcfVULGsV_0WxcZCm7sz1jtAB5ZXUfPww4,7911
22
- dao_treasury/.grafana/provisioning/dashboards/transactions/Treasury Transactions.json,sha256=2IuiXuDGAx_PUAFiiu5omNntDpidi8axXEUXLcvA_b8,15974
23
- dao_treasury/.grafana/provisioning/dashboards/treasury/Cashflow.json,sha256=52LHxaxfPj5NoPB1guTvayd08ETIfFjlydBsoywnxjI,42349
21
+ dao_treasury/.grafana/provisioning/dashboards/summary/Monthly.json,sha256=O6ghjzBf333baPjuMuUNguxF2v6rvPCiOu39sm1zxxY,6533
22
+ dao_treasury/.grafana/provisioning/dashboards/transactions/Treasury Transactions.json,sha256=jefr19wdT7r2zNXOG_3GzKDaq3WFIQkou8veHxkisnY,13230
23
+ dao_treasury/.grafana/provisioning/dashboards/treasury/Cashflow (Including Unsorted).json,sha256=lpSE0g8lU9rEPMUxJPo1ObkHk_B2Qvp8LMrJEMzeYSk,25530
24
+ dao_treasury/.grafana/provisioning/dashboards/treasury/Cashflow.json,sha256=DOpO3leNVyUUQD5ou5FkdGCGc1xJmCRQjuzSUCvBnGU,18139
25
+ dao_treasury/.grafana/provisioning/dashboards/treasury/Operating Cashflow.json,sha256=xGQTzjF9dKzV3QSifRAbU5eGz2SrzJ7MJlmQKcFq5TE,14311
24
26
  dao_treasury/.grafana/provisioning/dashboards/treasury/Treasury.json,sha256=p9bupL06-CKqkqCOb6KkgP1LCa6P1VMkq3yhkyqMAzI,70178
25
27
  dao_treasury/.grafana/provisioning/datasources/datasources.yaml,sha256=mjQs8or651NgD_bZnKBm8vSghzjw_g3enL01YPt0dik,327
26
28
  dao_treasury/sorting/__init__.cpython-310-i386-linux-gnu.so,sha256=GDRmThf4QH7gQJY8MJcrRs6ee4LckBBGd8gRXaWMWTU,16572
27
- dao_treasury/sorting/__init__.py,sha256=F_yKKdpdHKGH5RRt-8cZ-M1CuHFI_XvSypnE0YHdovo,5785
29
+ dao_treasury/sorting/__init__.py,sha256=vKj3NPB7EWbX7_fSUWKXk-NsyPasOkFhJvJVGclBOAE,10371
28
30
  dao_treasury/sorting/_matchers.cpython-310-i386-linux-gnu.so,sha256=bVwimtyQO0coY3j6yV3qYlAunOgjJ6Jnm1PhJC2v_9s,16596
29
31
  dao_treasury/sorting/_matchers.py,sha256=u0GfPYiODr_NtzbfyLxEKDuXmWRiaeuZulDj9FPDOH8,14005
30
32
  dao_treasury/sorting/_rules.cpython-310-i386-linux-gnu.so,sha256=chyA1u_nEQ0nkndcRGWi1grHbjtsKoO7nq8s2i_nzzU,16580
@@ -43,7 +45,7 @@ dao_treasury/streams/__init__.cpython-310-i386-linux-gnu.so,sha256=CSSJTizhz2lhW
43
45
  dao_treasury/streams/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
44
46
  dao_treasury/streams/llamapay.cpython-310-i386-linux-gnu.so,sha256=WeyPGWhuevhvC0Is5A9uZoNjg8e18bgsWOs14pZcYUA,16588
45
47
  dao_treasury/streams/llamapay.py,sha256=xc2sgmTV4EnQFFemea87QoUdIeGtO9OJQCwJG9c-SJQ,12774
46
- dao_treasury-0.0.32.dist-info/METADATA,sha256=CtChVdcnb51eL9ngQP9PEA_D4uYWnelEtQuAUkD9G_g,7030
47
- dao_treasury-0.0.32.dist-info/WHEEL,sha256=U4i16otdlfBhNVHGS7XHFbWxUW-DEunqf9S09fwcX-w,110
48
- dao_treasury-0.0.32.dist-info/top_level.txt,sha256=Gw-ri_26lZA_3hwhnOX48mffUbmBGr8NhtoQ0XoMeF8,41
49
- dao_treasury-0.0.32.dist-info/RECORD,,
48
+ dao_treasury-0.0.33.dist-info/METADATA,sha256=oVCiHn3_IVPb94PL9AgbZGva7AU88_vmhfO8VU1r2Qk,7030
49
+ dao_treasury-0.0.33.dist-info/WHEEL,sha256=U4i16otdlfBhNVHGS7XHFbWxUW-DEunqf9S09fwcX-w,110
50
+ dao_treasury-0.0.33.dist-info/top_level.txt,sha256=Gw-ri_26lZA_3hwhnOX48mffUbmBGr8NhtoQ0XoMeF8,41
51
+ dao_treasury-0.0.33.dist-info/RECORD,,