sonic-sdk 0.1.0__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.
Files changed (138) hide show
  1. sonic_sdk-0.1.0/INSTALL.md +195 -0
  2. sonic_sdk-0.1.0/PKG-INFO +240 -0
  3. sonic_sdk-0.1.0/pyproject.toml +83 -0
  4. sonic_sdk-0.1.0/setup.cfg +4 -0
  5. sonic_sdk-0.1.0/sonic/__init__.py +112 -0
  6. sonic_sdk-0.1.0/sonic/_vendor/__init__.py +1 -0
  7. sonic_sdk-0.1.0/sonic/_vendor/dominion/__init__.py +51 -0
  8. sonic_sdk-0.1.0/sonic/_vendor/dominion/_version.py +1 -0
  9. sonic_sdk-0.1.0/sonic/_vendor/dominion/core/__init__.py +16 -0
  10. sonic_sdk-0.1.0/sonic/_vendor/dominion/core/calculator.py +127 -0
  11. sonic_sdk-0.1.0/sonic/_vendor/dominion/core/float_guard.py +196 -0
  12. sonic_sdk-0.1.0/sonic/_vendor/dominion/core/router.py +287 -0
  13. sonic_sdk-0.1.0/sonic/_vendor/dominion/db/__init__.py +1 -0
  14. sonic_sdk-0.1.0/sonic/_vendor/dominion/db/config.py +29 -0
  15. sonic_sdk-0.1.0/sonic/_vendor/dominion/db/models.py +441 -0
  16. sonic_sdk-0.1.0/sonic/_vendor/dominion/db/session.py +81 -0
  17. sonic_sdk-0.1.0/sonic/_vendor/dominion/events/__init__.py +1 -0
  18. sonic_sdk-0.1.0/sonic/_vendor/dominion/events/channels.py +26 -0
  19. sonic_sdk-0.1.0/sonic/_vendor/dominion/events/redis_bridge.py +210 -0
  20. sonic_sdk-0.1.0/sonic/_vendor/dominion/gateway/__init__.py +6 -0
  21. sonic_sdk-0.1.0/sonic/_vendor/dominion/gateway/legacy_adapter.py +123 -0
  22. sonic_sdk-0.1.0/sonic/_vendor/dominion/gateway/smart_block_parser.py +79 -0
  23. sonic_sdk-0.1.0/sonic/_vendor/dominion/gec_interface/__init__.py +24 -0
  24. sonic_sdk-0.1.0/sonic/_vendor/dominion/gec_interface/csk_provider.py +148 -0
  25. sonic_sdk-0.1.0/sonic/_vendor/dominion/gec_interface/emitter.py +111 -0
  26. sonic_sdk-0.1.0/sonic/_vendor/dominion/gec_interface/frontier_config.py +50 -0
  27. sonic_sdk-0.1.0/sonic/_vendor/dominion/gec_interface/payload_builder.py +79 -0
  28. sonic_sdk-0.1.0/sonic/_vendor/dominion/messenger/__init__.py +5 -0
  29. sonic_sdk-0.1.0/sonic/_vendor/dominion/messenger/sonic_protocol.py +155 -0
  30. sonic_sdk-0.1.0/sonic/_vendor/dominion/milestones/__init__.py +12 -0
  31. sonic_sdk-0.1.0/sonic/_vendor/dominion/milestones/contract_locks.py +53 -0
  32. sonic_sdk-0.1.0/sonic/_vendor/dominion/milestones/scheduler.py +176 -0
  33. sonic_sdk-0.1.0/sonic/_vendor/dominion/repos/__init__.py +19 -0
  34. sonic_sdk-0.1.0/sonic/_vendor/dominion/repos/dlq_repo.py +110 -0
  35. sonic_sdk-0.1.0/sonic/_vendor/dominion/repos/float_repo.py +67 -0
  36. sonic_sdk-0.1.0/sonic/_vendor/dominion/repos/journal_repo.py +73 -0
  37. sonic_sdk-0.1.0/sonic/_vendor/dominion/repos/milestone_repo.py +100 -0
  38. sonic_sdk-0.1.0/sonic/_vendor/dominion/repos/receipt_repo.py +70 -0
  39. sonic_sdk-0.1.0/sonic/_vendor/dominion/repos/tax_repo.py +199 -0
  40. sonic_sdk-0.1.0/sonic/_vendor/dominion/repos/workflow_repo.py +100 -0
  41. sonic_sdk-0.1.0/sonic/_vendor/dominion/sbn_bridge/__init__.py +19 -0
  42. sonic_sdk-0.1.0/sonic/_vendor/dominion/sbn_bridge/agent_bridge.py +238 -0
  43. sonic_sdk-0.1.0/sonic/_vendor/dominion/sbn_bridge/numa_reporter.py +102 -0
  44. sonic_sdk-0.1.0/sonic/_vendor/dominion/sbn_bridge/snapchore_client.py +87 -0
  45. sonic_sdk-0.1.0/sonic/_vendor/dominion/sbn_client.py +280 -0
  46. sonic_sdk-0.1.0/sonic/_vendor/dominion/sonic_client.py +287 -0
  47. sonic_sdk-0.1.0/sonic/_vendor/dominion/streaming/__init__.py +6 -0
  48. sonic_sdk-0.1.0/sonic/_vendor/dominion/streaming/crypto_stream.py +141 -0
  49. sonic_sdk-0.1.0/sonic/_vendor/dominion/streaming/fiat_stream.py +148 -0
  50. sonic_sdk-0.1.0/sonic/_vendor/dominion/tasks/__init__.py +1 -0
  51. sonic_sdk-0.1.0/sonic/_vendor/dominion/tasks/dlq_tasks.py +98 -0
  52. sonic_sdk-0.1.0/sonic/_vendor/dominion/tasks/gec_tasks.py +96 -0
  53. sonic_sdk-0.1.0/sonic/_vendor/dominion/tasks/numa_tasks.py +80 -0
  54. sonic_sdk-0.1.0/sonic/_vendor/dominion/tax/__init__.py +14 -0
  55. sonic_sdk-0.1.0/sonic/_vendor/dominion/tax/registry.py +296 -0
  56. sonic_sdk-0.1.0/sonic/_vendor/dominion/translation_rules.py +302 -0
  57. sonic_sdk-0.1.0/sonic/_vendor/dominion/vault/__init__.py +6 -0
  58. sonic_sdk-0.1.0/sonic/_vendor/dominion/vault/journal.py +197 -0
  59. sonic_sdk-0.1.0/sonic/_vendor/dominion/vault/snapchore_receipts.py +193 -0
  60. sonic_sdk-0.1.0/sonic/_vendor/dominion/webhooks/__init__.py +1 -0
  61. sonic_sdk-0.1.0/sonic/_vendor/dominion/webhooks/handlers.py +142 -0
  62. sonic_sdk-0.1.0/sonic/_vendor/dominion/webhooks/routes.py +115 -0
  63. sonic_sdk-0.1.0/sonic/_vendor/dominion/workflows/__init__.py +5 -0
  64. sonic_sdk-0.1.0/sonic/_vendor/dominion/workflows/payroll_dag.py +323 -0
  65. sonic_sdk-0.1.0/sonic/_vendor/sbn/__init__.py +87 -0
  66. sonic_sdk-0.1.0/sonic/_vendor/sbn/_http.py +220 -0
  67. sonic_sdk-0.1.0/sonic/_vendor/sbn/_version.py +1 -0
  68. sonic_sdk-0.1.0/sonic/_vendor/sbn/auth.py +136 -0
  69. sonic_sdk-0.1.0/sonic/_vendor/sbn/blocks.py +48 -0
  70. sonic_sdk-0.1.0/sonic/_vendor/sbn/client.py +144 -0
  71. sonic_sdk-0.1.0/sonic/_vendor/sbn/console.py +228 -0
  72. sonic_sdk-0.1.0/sonic/_vendor/sbn/control_plane.py +223 -0
  73. sonic_sdk-0.1.0/sonic/_vendor/sbn/gateway.py +171 -0
  74. sonic_sdk-0.1.0/sonic/_vendor/sbn/lattice.py +176 -0
  75. sonic_sdk-0.1.0/sonic/_vendor/sbn/snapchore.py +199 -0
  76. sonic_sdk-0.1.0/sonic/_vendor/snapchore/__init__.py +80 -0
  77. sonic_sdk-0.1.0/sonic/_vendor/snapchore/__main__.py +5 -0
  78. sonic_sdk-0.1.0/sonic/_vendor/snapchore/block/__init__.py +250 -0
  79. sonic_sdk-0.1.0/sonic/_vendor/snapchore/capture/__init__.py +11 -0
  80. sonic_sdk-0.1.0/sonic/_vendor/snapchore/capture/snapchore_device_interface.py +351 -0
  81. sonic_sdk-0.1.0/sonic/_vendor/snapchore/chain/__init__.py +274 -0
  82. sonic_sdk-0.1.0/sonic/_vendor/snapchore/cli.py +322 -0
  83. sonic_sdk-0.1.0/sonic/_vendor/snapchore/core/device_capture.py +15 -0
  84. sonic_sdk-0.1.0/sonic/_vendor/snapchore/device_capture.py +19 -0
  85. sonic_sdk-0.1.0/sonic/_vendor/snapchore/logging/__init__.py +78 -0
  86. sonic_sdk-0.1.0/sonic/_vendor/snapchore/metadata_extractor.py +38 -0
  87. sonic_sdk-0.1.0/sonic/_vendor/snapchore/serialize.py +174 -0
  88. sonic_sdk-0.1.0/sonic/_vendor/snapchore/snapchore.py +81 -0
  89. sonic_sdk-0.1.0/sonic/_vendor/snapchore/utils/__init__.py +0 -0
  90. sonic_sdk-0.1.0/sonic/_vendor/snapchore/validator.py +389 -0
  91. sonic_sdk-0.1.0/sonic/_version.py +1 -0
  92. sonic_sdk-0.1.0/sonic/api/__init__.py +0 -0
  93. sonic_sdk-0.1.0/sonic/api/app.py +38 -0
  94. sonic_sdk-0.1.0/sonic/api/deps.py +40 -0
  95. sonic_sdk-0.1.0/sonic/api/middleware/__init__.py +0 -0
  96. sonic_sdk-0.1.0/sonic/api/middleware/auth.py +29 -0
  97. sonic_sdk-0.1.0/sonic/api/middleware/idempotency.py +49 -0
  98. sonic_sdk-0.1.0/sonic/api/routes/__init__.py +0 -0
  99. sonic_sdk-0.1.0/sonic/api/routes/health.py +25 -0
  100. sonic_sdk-0.1.0/sonic/api/routes/merchants.py +101 -0
  101. sonic_sdk-0.1.0/sonic/api/routes/payments.py +126 -0
  102. sonic_sdk-0.1.0/sonic/api/routes/payouts.py +42 -0
  103. sonic_sdk-0.1.0/sonic/api/routes/receipts.py +171 -0
  104. sonic_sdk-0.1.0/sonic/api/routes/webhooks.py +110 -0
  105. sonic_sdk-0.1.0/sonic/config.py +51 -0
  106. sonic_sdk-0.1.0/sonic/core/__init__.py +0 -0
  107. sonic_sdk-0.1.0/sonic/core/engine.py +133 -0
  108. sonic_sdk-0.1.0/sonic/core/finality_gate.py +113 -0
  109. sonic_sdk-0.1.0/sonic/core/payout_executor.py +89 -0
  110. sonic_sdk-0.1.0/sonic/core/receipt_builder.py +120 -0
  111. sonic_sdk-0.1.0/sonic/core/treasury.py +132 -0
  112. sonic_sdk-0.1.0/sonic/events/__init__.py +0 -0
  113. sonic_sdk-0.1.0/sonic/events/emitter.py +57 -0
  114. sonic_sdk-0.1.0/sonic/events/types.py +46 -0
  115. sonic_sdk-0.1.0/sonic/events/webhooks.py +69 -0
  116. sonic_sdk-0.1.0/sonic/models/__init__.py +9 -0
  117. sonic_sdk-0.1.0/sonic/models/base.py +22 -0
  118. sonic_sdk-0.1.0/sonic/models/event_log.py +48 -0
  119. sonic_sdk-0.1.0/sonic/models/merchant.py +40 -0
  120. sonic_sdk-0.1.0/sonic/models/receipt.py +50 -0
  121. sonic_sdk-0.1.0/sonic/models/transaction.py +58 -0
  122. sonic_sdk-0.1.0/sonic/providers/__init__.py +0 -0
  123. sonic_sdk-0.1.0/sonic/providers/base.py +45 -0
  124. sonic_sdk-0.1.0/sonic/providers/circle_provider.py +101 -0
  125. sonic_sdk-0.1.0/sonic/providers/moov_provider.py +83 -0
  126. sonic_sdk-0.1.0/sonic/providers/stripe_provider.py +77 -0
  127. sonic_sdk-0.1.0/sonic/sbn/__init__.py +13 -0
  128. sonic_sdk-0.1.0/sonic/sbn/attester.py +158 -0
  129. sonic_sdk-0.1.0/sonic/sbn/client.py +308 -0
  130. sonic_sdk-0.1.0/sonic/sbn/frontier.py +37 -0
  131. sonic_sdk-0.1.0/sonic/sbn/receipt_coupler.py +125 -0
  132. sonic_sdk-0.1.0/sonic/seeds/__init__.py +0 -0
  133. sonic_sdk-0.1.0/sonic/seeds/merchants.py +118 -0
  134. sonic_sdk-0.1.0/sonic_sdk.egg-info/PKG-INFO +240 -0
  135. sonic_sdk-0.1.0/sonic_sdk.egg-info/SOURCES.txt +136 -0
  136. sonic_sdk-0.1.0/sonic_sdk.egg-info/dependency_links.txt +1 -0
  137. sonic_sdk-0.1.0/sonic_sdk.egg-info/requires.txt +29 -0
  138. sonic_sdk-0.1.0/sonic_sdk.egg-info/top_level.txt +1 -0
@@ -0,0 +1,195 @@
1
+ # Sonic SDK Installation Guide
2
+
3
+ | Package | Description | Version |
4
+ |---------|-------------|---------|
5
+ | **sonic-sdk** | Multi-currency settlement engine with cryptographic receipt attestation | 0.1.0 |
6
+
7
+ ---
8
+
9
+ ## Prerequisites
10
+
11
+ - Python 3.10+
12
+ - GitHub access to `ToweraiDev/sonic-pay` (private repo)
13
+ - One of: SSH key linked to GitHub, or a GitHub Personal Access Token (PAT)
14
+
15
+ ---
16
+
17
+ ## Install via SSH (recommended)
18
+
19
+ If you have SSH keys configured with GitHub:
20
+
21
+ ```bash
22
+ pip install "sonic-sdk @ git+ssh://git@github.com/ToweraiDev/sonic-pay.git"
23
+ ```
24
+
25
+ With optional extras:
26
+
27
+ ```bash
28
+ # Database support (SQLAlchemy, asyncpg, Alembic)
29
+ pip install "sonic-sdk[db] @ git+ssh://git@github.com/ToweraiDev/sonic-pay.git"
30
+
31
+ # Redis support
32
+ pip install "sonic-sdk[redis] @ git+ssh://git@github.com/ToweraiDev/sonic-pay.git"
33
+
34
+ # Everything
35
+ pip install "sonic-sdk[all] @ git+ssh://git@github.com/ToweraiDev/sonic-pay.git"
36
+ ```
37
+
38
+ ## Install via Personal Access Token
39
+
40
+ For CI/CD pipelines or machines without SSH:
41
+
42
+ ```bash
43
+ # Create a PAT at https://github.com/settings/tokens
44
+ # Classic: needs `repo` scope
45
+ # Fine-grained: needs "Contents" read access to ToweraiDev/sonic-pay
46
+
47
+ export GH_TOKEN=ghp_xxxxxxxxxxxx
48
+
49
+ pip install "sonic-sdk @ git+https://${GH_TOKEN}@github.com/ToweraiDev/sonic-pay.git"
50
+ ```
51
+
52
+ ## Install via GitHub CLI
53
+
54
+ If you have `gh` authenticated:
55
+
56
+ ```bash
57
+ pip install "sonic-sdk @ git+https://$(gh auth token)@github.com/ToweraiDev/sonic-pay.git"
58
+ ```
59
+
60
+ ---
61
+
62
+ ## Adding to your project
63
+
64
+ ### requirements.txt
65
+
66
+ ```
67
+ sonic-sdk @ git+ssh://git@github.com/ToweraiDev/sonic-pay.git
68
+ ```
69
+
70
+ Or with extras:
71
+
72
+ ```
73
+ sonic-sdk[all] @ git+ssh://git@github.com/ToweraiDev/sonic-pay.git
74
+ ```
75
+
76
+ ### pyproject.toml (pip/setuptools)
77
+
78
+ ```toml
79
+ [project]
80
+ dependencies = [
81
+ "sonic-sdk @ git+ssh://git@github.com/ToweraiDev/sonic-pay.git",
82
+ ]
83
+ ```
84
+
85
+ ### pyproject.toml (Poetry)
86
+
87
+ ```toml
88
+ [tool.poetry.dependencies]
89
+ sonic-sdk = {git = "ssh://git@github.com/ToweraiDev/sonic-pay.git"}
90
+ ```
91
+
92
+ ---
93
+
94
+ ## Pin to a specific commit or tag
95
+
96
+ Append `@<ref>` to pin a version:
97
+
98
+ ```bash
99
+ # Pin to a commit
100
+ pip install "sonic-sdk @ git+ssh://git@github.com/ToweraiDev/sonic-pay.git@abc1234"
101
+
102
+ # Pin to a tag
103
+ pip install "sonic-sdk @ git+ssh://git@github.com/ToweraiDev/sonic-pay.git@v0.1.0"
104
+ ```
105
+
106
+ ---
107
+
108
+ ## Local development
109
+
110
+ Clone and install in editable mode:
111
+
112
+ ```bash
113
+ git clone git@github.com:ToweraiDev/sonic-pay.git
114
+ cd sonic-pay
115
+ python -m venv .venv
116
+ source .venv/bin/activate # Linux/macOS
117
+ # .venv\Scripts\activate # Windows
118
+
119
+ pip install -r requirements.txt # installs -e .[all,dev]
120
+ ```
121
+
122
+ ---
123
+
124
+ ## Quick Start
125
+
126
+ ```python
127
+ from sonic import Transaction, TxState, SonicReceipt, SbnClient
128
+
129
+ # Build a transaction through the state machine
130
+ tx = Transaction(tx_id="tx-001", merchant_id="m-acme")
131
+ event = tx.advance(TxState.RECEIVABLE_DETECTED, amount=100.00, currency="USD")
132
+
133
+ # Seal receipt to SBN for tamper-evident attestation
134
+ sbn = SbnClient(api_key="sbn_live_...")
135
+ sbn_hash = sbn.seal({"receipt_hash": event.receipt_hash})
136
+ ```
137
+
138
+ ### Core modules
139
+
140
+ ```python
141
+ from sonic.core.engine import Transaction, TxState, TxEvent, InvalidTransition
142
+ from sonic.core.receipt_builder import SonicReceipt, ReceiptChain, canonical_hash
143
+ from sonic.core.finality_gate import FinalityGate, FinalityPolicy, FinalityStatus
144
+ from sonic.core.treasury import Treasury, ConversionQuote
145
+ from sonic.core.payout_executor import PayoutExecutor, PayoutInstruction, PayoutResult
146
+ from sonic.events.types import EventType
147
+ from sonic.events.emitter import EventEmitter
148
+ from sonic.sbn import SbnClient, SbnAttester, ReceiptCoupler
149
+ from sonic.sbn.frontier import SONIC_FRONTIER
150
+ from sonic.config import SonicSettings, settings
151
+ ```
152
+
153
+ ### Vendored SDKs
154
+
155
+ `sonic-sdk` vendors `sbn-sdk`, `snapchore-core`, and `dominion-sdk` — no separate
156
+ install needed.
157
+
158
+ ```python
159
+ # Dominion payroll client (re-exported at top level)
160
+ from sonic import DominionSbnClient, DominionSonicClient
161
+
162
+ # Direct access to vendored packages
163
+ from sonic._vendor.sbn import SbnClient as RawSbnClient, SlotSummary
164
+ from sonic._vendor.snapchore import SmartBlock, SnapChoreChain, snapchore_capture
165
+ from sonic._vendor.dominion import DominionSbnClient, DominionSonicClient
166
+ ```
167
+
168
+ ---
169
+
170
+ ## Optional Extras
171
+
172
+ | Extra | Packages | Use case |
173
+ |-------|----------|----------|
174
+ | `db` | sqlalchemy, asyncpg, alembic | Postgres persistence |
175
+ | `redis` | redis | Event bus / attestation queue |
176
+ | `server` | fastapi, uvicorn, psycopg2, python-jose | Running the Sonic HTTP API server |
177
+ | `all` | db + redis | Everything (without server) |
178
+ | `dev` | pytest, pytest-asyncio, ruff, mypy, python-dotenv | Development & testing |
179
+
180
+ ---
181
+
182
+ ## Dependencies
183
+
184
+ ### Core (always installed)
185
+
186
+ - `httpx` >= 0.27.0
187
+ - `cryptography` >= 42.0
188
+ - `pydantic` >= 2.5
189
+ - `pydantic-settings` >= 2.1
190
+
191
+ ### Vendored (included in package — no separate install)
192
+
193
+ - `sbn-sdk` 0.2.0 — SmartBlocks Network client
194
+ - `snapchore-core` 0.1.0 — Cryptographic integrity for stateful events
195
+ - `dominion-sdk` 0.1.0 — Sovereign Compression Payroll Router
@@ -0,0 +1,240 @@
1
+ Metadata-Version: 2.4
2
+ Name: sonic-sdk
3
+ Version: 0.1.0
4
+ Summary: Multi-currency settlement engine with cryptographic receipt attestation for the SmartBlocks Network.
5
+ Author-email: Tower Technologies <dev@towerai.dev>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Repository, https://github.com/ToweraiDev/sonic-pay
8
+ Keywords: sonic,settlement,smartblocks,sbn,snapchore,gec,payments
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Topic :: Office/Business :: Financial
17
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
+ Classifier: Typing :: Typed
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ Requires-Dist: httpx>=0.27.0
22
+ Requires-Dist: cryptography>=42.0
23
+ Requires-Dist: pydantic>=2.5
24
+ Requires-Dist: pydantic-settings>=2.1
25
+ Provides-Extra: db
26
+ Requires-Dist: sqlalchemy[asyncio]>=2.0.0; extra == "db"
27
+ Requires-Dist: asyncpg>=0.29.0; extra == "db"
28
+ Requires-Dist: alembic>=1.13.0; extra == "db"
29
+ Provides-Extra: redis
30
+ Requires-Dist: redis>=5.0.0; extra == "redis"
31
+ Provides-Extra: server
32
+ Requires-Dist: fastapi>=0.109; extra == "server"
33
+ Requires-Dist: uvicorn[standard]>=0.27; extra == "server"
34
+ Requires-Dist: psycopg2-binary>=2.9; extra == "server"
35
+ Requires-Dist: python-jose[cryptography]>=3.3; extra == "server"
36
+ Provides-Extra: all
37
+ Requires-Dist: sonic-sdk[db,redis]; extra == "all"
38
+ Provides-Extra: dev
39
+ Requires-Dist: pytest>=8.0.0; extra == "dev"
40
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
41
+ Requires-Dist: pytest-cov>=4.1; extra == "dev"
42
+ Requires-Dist: ruff>=0.2; extra == "dev"
43
+ Requires-Dist: mypy>=1.8; extra == "dev"
44
+ Requires-Dist: python-dotenv>=1.0.0; extra == "dev"
45
+
46
+ # Sonic SDK Installation Guide
47
+
48
+ | Package | Description | Version |
49
+ |---------|-------------|---------|
50
+ | **sonic-sdk** | Multi-currency settlement engine with cryptographic receipt attestation | 0.1.0 |
51
+
52
+ ---
53
+
54
+ ## Prerequisites
55
+
56
+ - Python 3.10+
57
+ - GitHub access to `ToweraiDev/sonic-pay` (private repo)
58
+ - One of: SSH key linked to GitHub, or a GitHub Personal Access Token (PAT)
59
+
60
+ ---
61
+
62
+ ## Install via SSH (recommended)
63
+
64
+ If you have SSH keys configured with GitHub:
65
+
66
+ ```bash
67
+ pip install "sonic-sdk @ git+ssh://git@github.com/ToweraiDev/sonic-pay.git"
68
+ ```
69
+
70
+ With optional extras:
71
+
72
+ ```bash
73
+ # Database support (SQLAlchemy, asyncpg, Alembic)
74
+ pip install "sonic-sdk[db] @ git+ssh://git@github.com/ToweraiDev/sonic-pay.git"
75
+
76
+ # Redis support
77
+ pip install "sonic-sdk[redis] @ git+ssh://git@github.com/ToweraiDev/sonic-pay.git"
78
+
79
+ # Everything
80
+ pip install "sonic-sdk[all] @ git+ssh://git@github.com/ToweraiDev/sonic-pay.git"
81
+ ```
82
+
83
+ ## Install via Personal Access Token
84
+
85
+ For CI/CD pipelines or machines without SSH:
86
+
87
+ ```bash
88
+ # Create a PAT at https://github.com/settings/tokens
89
+ # Classic: needs `repo` scope
90
+ # Fine-grained: needs "Contents" read access to ToweraiDev/sonic-pay
91
+
92
+ export GH_TOKEN=ghp_xxxxxxxxxxxx
93
+
94
+ pip install "sonic-sdk @ git+https://${GH_TOKEN}@github.com/ToweraiDev/sonic-pay.git"
95
+ ```
96
+
97
+ ## Install via GitHub CLI
98
+
99
+ If you have `gh` authenticated:
100
+
101
+ ```bash
102
+ pip install "sonic-sdk @ git+https://$(gh auth token)@github.com/ToweraiDev/sonic-pay.git"
103
+ ```
104
+
105
+ ---
106
+
107
+ ## Adding to your project
108
+
109
+ ### requirements.txt
110
+
111
+ ```
112
+ sonic-sdk @ git+ssh://git@github.com/ToweraiDev/sonic-pay.git
113
+ ```
114
+
115
+ Or with extras:
116
+
117
+ ```
118
+ sonic-sdk[all] @ git+ssh://git@github.com/ToweraiDev/sonic-pay.git
119
+ ```
120
+
121
+ ### pyproject.toml (pip/setuptools)
122
+
123
+ ```toml
124
+ [project]
125
+ dependencies = [
126
+ "sonic-sdk @ git+ssh://git@github.com/ToweraiDev/sonic-pay.git",
127
+ ]
128
+ ```
129
+
130
+ ### pyproject.toml (Poetry)
131
+
132
+ ```toml
133
+ [tool.poetry.dependencies]
134
+ sonic-sdk = {git = "ssh://git@github.com/ToweraiDev/sonic-pay.git"}
135
+ ```
136
+
137
+ ---
138
+
139
+ ## Pin to a specific commit or tag
140
+
141
+ Append `@<ref>` to pin a version:
142
+
143
+ ```bash
144
+ # Pin to a commit
145
+ pip install "sonic-sdk @ git+ssh://git@github.com/ToweraiDev/sonic-pay.git@abc1234"
146
+
147
+ # Pin to a tag
148
+ pip install "sonic-sdk @ git+ssh://git@github.com/ToweraiDev/sonic-pay.git@v0.1.0"
149
+ ```
150
+
151
+ ---
152
+
153
+ ## Local development
154
+
155
+ Clone and install in editable mode:
156
+
157
+ ```bash
158
+ git clone git@github.com:ToweraiDev/sonic-pay.git
159
+ cd sonic-pay
160
+ python -m venv .venv
161
+ source .venv/bin/activate # Linux/macOS
162
+ # .venv\Scripts\activate # Windows
163
+
164
+ pip install -r requirements.txt # installs -e .[all,dev]
165
+ ```
166
+
167
+ ---
168
+
169
+ ## Quick Start
170
+
171
+ ```python
172
+ from sonic import Transaction, TxState, SonicReceipt, SbnClient
173
+
174
+ # Build a transaction through the state machine
175
+ tx = Transaction(tx_id="tx-001", merchant_id="m-acme")
176
+ event = tx.advance(TxState.RECEIVABLE_DETECTED, amount=100.00, currency="USD")
177
+
178
+ # Seal receipt to SBN for tamper-evident attestation
179
+ sbn = SbnClient(api_key="sbn_live_...")
180
+ sbn_hash = sbn.seal({"receipt_hash": event.receipt_hash})
181
+ ```
182
+
183
+ ### Core modules
184
+
185
+ ```python
186
+ from sonic.core.engine import Transaction, TxState, TxEvent, InvalidTransition
187
+ from sonic.core.receipt_builder import SonicReceipt, ReceiptChain, canonical_hash
188
+ from sonic.core.finality_gate import FinalityGate, FinalityPolicy, FinalityStatus
189
+ from sonic.core.treasury import Treasury, ConversionQuote
190
+ from sonic.core.payout_executor import PayoutExecutor, PayoutInstruction, PayoutResult
191
+ from sonic.events.types import EventType
192
+ from sonic.events.emitter import EventEmitter
193
+ from sonic.sbn import SbnClient, SbnAttester, ReceiptCoupler
194
+ from sonic.sbn.frontier import SONIC_FRONTIER
195
+ from sonic.config import SonicSettings, settings
196
+ ```
197
+
198
+ ### Vendored SDKs
199
+
200
+ `sonic-sdk` vendors `sbn-sdk`, `snapchore-core`, and `dominion-sdk` — no separate
201
+ install needed.
202
+
203
+ ```python
204
+ # Dominion payroll client (re-exported at top level)
205
+ from sonic import DominionSbnClient, DominionSonicClient
206
+
207
+ # Direct access to vendored packages
208
+ from sonic._vendor.sbn import SbnClient as RawSbnClient, SlotSummary
209
+ from sonic._vendor.snapchore import SmartBlock, SnapChoreChain, snapchore_capture
210
+ from sonic._vendor.dominion import DominionSbnClient, DominionSonicClient
211
+ ```
212
+
213
+ ---
214
+
215
+ ## Optional Extras
216
+
217
+ | Extra | Packages | Use case |
218
+ |-------|----------|----------|
219
+ | `db` | sqlalchemy, asyncpg, alembic | Postgres persistence |
220
+ | `redis` | redis | Event bus / attestation queue |
221
+ | `server` | fastapi, uvicorn, psycopg2, python-jose | Running the Sonic HTTP API server |
222
+ | `all` | db + redis | Everything (without server) |
223
+ | `dev` | pytest, pytest-asyncio, ruff, mypy, python-dotenv | Development & testing |
224
+
225
+ ---
226
+
227
+ ## Dependencies
228
+
229
+ ### Core (always installed)
230
+
231
+ - `httpx` >= 0.27.0
232
+ - `cryptography` >= 42.0
233
+ - `pydantic` >= 2.5
234
+ - `pydantic-settings` >= 2.1
235
+
236
+ ### Vendored (included in package — no separate install)
237
+
238
+ - `sbn-sdk` 0.2.0 — SmartBlocks Network client
239
+ - `snapchore-core` 0.1.0 — Cryptographic integrity for stateful events
240
+ - `dominion-sdk` 0.1.0 — Sovereign Compression Payroll Router
@@ -0,0 +1,83 @@
1
+ [project]
2
+ name = "sonic-sdk"
3
+ version = "0.1.0"
4
+ description = "Multi-currency settlement engine with cryptographic receipt attestation for the SmartBlocks Network."
5
+ readme = "INSTALL.md"
6
+ requires-python = ">=3.10"
7
+ license = "Apache-2.0"
8
+ authors = [
9
+ { name = "Tower Technologies", email = "dev@towerai.dev" },
10
+ ]
11
+ keywords = ["sonic", "settlement", "smartblocks", "sbn", "snapchore", "gec", "payments"]
12
+ classifiers = [
13
+ "Development Status :: 3 - Alpha",
14
+ "Intended Audience :: Developers",
15
+ "Programming Language :: Python :: 3",
16
+ "Programming Language :: Python :: 3.10",
17
+ "Programming Language :: Python :: 3.11",
18
+ "Programming Language :: Python :: 3.12",
19
+ "Programming Language :: Python :: 3.13",
20
+ "Topic :: Office/Business :: Financial",
21
+ "Topic :: Software Development :: Libraries :: Python Modules",
22
+ "Typing :: Typed",
23
+ ]
24
+
25
+ dependencies = [
26
+ "httpx>=0.27.0",
27
+ "cryptography>=42.0",
28
+ "pydantic>=2.5",
29
+ "pydantic-settings>=2.1",
30
+ ]
31
+
32
+ [project.optional-dependencies]
33
+ db = [
34
+ "sqlalchemy[asyncio]>=2.0.0",
35
+ "asyncpg>=0.29.0",
36
+ "alembic>=1.13.0",
37
+ ]
38
+ redis = [
39
+ "redis>=5.0.0",
40
+ ]
41
+ server = [
42
+ "fastapi>=0.109",
43
+ "uvicorn[standard]>=0.27",
44
+ "psycopg2-binary>=2.9",
45
+ "python-jose[cryptography]>=3.3",
46
+ ]
47
+ all = [
48
+ "sonic-sdk[db,redis]",
49
+ ]
50
+ dev = [
51
+ "pytest>=8.0.0",
52
+ "pytest-asyncio>=0.23.0",
53
+ "pytest-cov>=4.1",
54
+ "ruff>=0.2",
55
+ "mypy>=1.8",
56
+ "python-dotenv>=1.0.0",
57
+ ]
58
+
59
+ [project.urls]
60
+ Repository = "https://github.com/ToweraiDev/sonic-pay"
61
+
62
+ [build-system]
63
+ requires = ["setuptools>=68.0", "wheel"]
64
+ build-backend = "setuptools.build_meta"
65
+
66
+ [tool.setuptools.packages.find]
67
+ include = ["sonic*"]
68
+ exclude = ["stillpoint-nested-dev-context*", "tower-agent-nested-dev-context*", "tests*", "alembic*"]
69
+
70
+ [tool.ruff]
71
+ target-version = "py310"
72
+ line-length = 100
73
+
74
+ [tool.ruff.lint]
75
+ select = ["E", "F", "I", "N", "W", "UP"]
76
+
77
+ [tool.pytest.ini_options]
78
+ asyncio_mode = "auto"
79
+ testpaths = ["tests"]
80
+
81
+ [tool.mypy]
82
+ python_version = "3.10"
83
+ strict = true
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,112 @@
1
+ """Sonic — Multi-currency settlement engine with cryptographic receipt attestation.
2
+
3
+ Sonic is a settlement engine that processes multi-currency payments with
4
+ cryptographic receipt chains and optional SBN (SmartBlocks Network)
5
+ attestation. Every state transition produces an immutable, hash-chained
6
+ receipt that can be independently verified.
7
+
8
+ Division: Tower Technologies, Brooks Holdings Inc.
9
+
10
+ Core workflow::
11
+
12
+ from sonic import Transaction, TxState, SonicReceipt, SbnClient
13
+
14
+ # Build a transaction through the state machine
15
+ tx = Transaction(tx_id="tx-001", merchant_id="m-acme")
16
+ event = tx.advance(TxState.RECEIVABLE_DETECTED, amount=100.00, currency="USD")
17
+
18
+ # Seal receipt to SBN for tamper-evident attestation
19
+ sbn = SbnClient(api_key="sbn_live_...")
20
+ sbn_hash = sbn.seal({"receipt_hash": event.receipt_hash})
21
+
22
+ Core modules::
23
+
24
+ from sonic.core.engine import Transaction, TxState, TxEvent
25
+ from sonic.core.receipt_builder import SonicReceipt, ReceiptChain, canonical_hash
26
+ from sonic.core.finality_gate import FinalityGate, FinalityPolicy, FinalityStatus
27
+ from sonic.core.treasury import Treasury, ConversionQuote
28
+ from sonic.core.payout_executor import PayoutExecutor, PayoutInstruction, PayoutResult
29
+ from sonic.events.types import EventType
30
+ from sonic.events.emitter import EventEmitter
31
+ from sonic.sbn import SbnClient, SbnAttester, ReceiptCoupler
32
+ """
33
+
34
+ from __future__ import annotations
35
+
36
+ from sonic._version import __version__
37
+
38
+ # Core settlement
39
+ from sonic.core.engine import Transaction, TxState, TxEvent, InvalidTransition, TRANSITIONS
40
+ from sonic.core.receipt_builder import SonicReceipt, ReceiptChain, canonical_hash
41
+ from sonic.core.finality_gate import (
42
+ FinalityGate,
43
+ FinalityPolicy,
44
+ FinalityStatus,
45
+ DEFAULT_POLICIES,
46
+ )
47
+ from sonic.core.treasury import Treasury, ConversionQuote
48
+ from sonic.core.payout_executor import PayoutExecutor, PayoutInstruction, PayoutResult
49
+
50
+ # Events
51
+ from sonic.events.types import EventType
52
+ from sonic.events.emitter import EventEmitter
53
+
54
+ # SBN integration
55
+ from sonic.sbn.client import SbnClient, SbnError, SbnQuotaExceeded
56
+ from sonic.sbn.attester import SbnAttester
57
+ from sonic.sbn.receipt_coupler import ReceiptCoupler
58
+ from sonic.sbn.frontier import SONIC_FRONTIER
59
+
60
+ # Configuration
61
+ from sonic.config import SonicSettings, settings
62
+
63
+ # Vendored SDKs — re-export top-level clients
64
+ from sonic._vendor.dominion import (
65
+ DominionSbnClient,
66
+ DominionSonicClient,
67
+ DominionTranslationRule,
68
+ DOMINION_TRANSLATION_RULES,
69
+ )
70
+
71
+ __all__ = [
72
+ # Core — state machine
73
+ "Transaction",
74
+ "TxState",
75
+ "TxEvent",
76
+ "InvalidTransition",
77
+ "TRANSITIONS",
78
+ # Core — receipts
79
+ "SonicReceipt",
80
+ "ReceiptChain",
81
+ "canonical_hash",
82
+ # Core — finality
83
+ "FinalityGate",
84
+ "FinalityPolicy",
85
+ "FinalityStatus",
86
+ "DEFAULT_POLICIES",
87
+ # Core — treasury
88
+ "Treasury",
89
+ "ConversionQuote",
90
+ # Core — payouts
91
+ "PayoutExecutor",
92
+ "PayoutInstruction",
93
+ "PayoutResult",
94
+ # Events
95
+ "EventType",
96
+ "EventEmitter",
97
+ # SBN
98
+ "SbnClient",
99
+ "SbnError",
100
+ "SbnQuotaExceeded",
101
+ "SbnAttester",
102
+ "ReceiptCoupler",
103
+ "SONIC_FRONTIER",
104
+ # Config
105
+ "SonicSettings",
106
+ "settings",
107
+ # Vendored — Dominion
108
+ "DominionSbnClient",
109
+ "DominionSonicClient",
110
+ "DominionTranslationRule",
111
+ "DOMINION_TRANSLATION_RULES",
112
+ ]
@@ -0,0 +1 @@
1
+ """Vendored dependencies — sbn-sdk, snapchore-core, dominion-sdk."""
@@ -0,0 +1,51 @@
1
+ """Dominion — Sovereign Compression Payroll Router & Reflex Engine.
2
+
3
+ Dominion is a reflexive sovereign routing and compression layer that
4
+ orchestrates Smart Block-based payouts across fiat, crypto, and hybrid
5
+ treasury systems. It is GEC-native: every payout operation emits y/x
6
+ efficiency metrics and optional CSK vectors into the SBN analytics
7
+ pipeline, making it a first-class participant in NUMA governance.
8
+
9
+ Tier model:
10
+ Tier 1 — Legacy payroll processing (no SBN integration)
11
+ Tier 2 — Legacy + SnapChore attestation + GEC scoring + Sonic settlement
12
+ Tier 3 — Tier 2 + Lightweight Tower Agent + NUMA governance + Translation Rules
13
+
14
+ Division: Tower Technologies, Brooks Holdings Inc.
15
+
16
+ Clients:
17
+ DominionSbnClient — wraps SBN Python SDK for SnapChore, Lattice, GEC, NUMA
18
+ DominionSonicClient — HTTP client to Sonic settlement engine
19
+
20
+ Hard Stops:
21
+ Tax codes are user-programmable and required. No tax codes = no operations.
22
+
23
+ Usage::
24
+
25
+ from dominion import DominionSbnClient, DominionSonicClient
26
+
27
+ sbn = DominionSbnClient(
28
+ base_url="https://api.smartblocks.network",
29
+ api_key="sbn_live_...",
30
+ project_id="proj-dominion",
31
+ tier=2,
32
+ )
33
+ sonic = DominionSonicClient(base_url="https://sonic.example.com")
34
+ """
35
+
36
+ from __future__ import annotations
37
+
38
+ from ._version import __version__
39
+
40
+ from .sbn_client import DominionSbnClient
41
+ from .sonic_client import DominionSonicClient
42
+ from .translation_rules import DominionTranslationRule, DOMINION_TRANSLATION_RULES
43
+
44
+ __all__ = [
45
+ # Clients
46
+ "DominionSbnClient",
47
+ "DominionSonicClient",
48
+ # Translation rules
49
+ "DominionTranslationRule",
50
+ "DOMINION_TRANSLATION_RULES",
51
+ ]
@@ -0,0 +1 @@
1
+ __version__ = "0.1.0"