phala-pay 0.2.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 (211) hide show
  1. phala_pay-0.2.0/.gitignore +6 -0
  2. phala_pay-0.2.0/.python-version +1 -0
  3. phala_pay-0.2.0/CHANGELOG.md +315 -0
  4. phala_pay-0.2.0/LICENSE +202 -0
  5. phala_pay-0.2.0/Makefile +38 -0
  6. phala_pay-0.2.0/PKG-INFO +204 -0
  7. phala_pay-0.2.0/README.md +177 -0
  8. phala_pay-0.2.0/openapi-python-client.yaml +9 -0
  9. phala_pay-0.2.0/pyproject.toml +106 -0
  10. phala_pay-0.2.0/src/phala_pay/__init__.py +96 -0
  11. phala_pay-0.2.0/src/phala_pay/_client.py +582 -0
  12. phala_pay-0.2.0/src/phala_pay/_types.py +42 -0
  13. phala_pay-0.2.0/src/phala_pay/_webhook.py +174 -0
  14. phala_pay-0.2.0/src/phala_pay/py.typed +0 -0
  15. phala_pay-0.2.0/src/topup_client/__init__.py +8 -0
  16. phala_pay-0.2.0/src/topup_client/api/__init__.py +1 -0
  17. phala_pay-0.2.0/src/topup_client/api/account/__init__.py +1 -0
  18. phala_pay-0.2.0/src/topup_client/api/account/get_account.py +142 -0
  19. phala_pay-0.2.0/src/topup_client/api/account/pause_account.py +212 -0
  20. phala_pay-0.2.0/src/topup_client/api/account/resume_account.py +208 -0
  21. phala_pay-0.2.0/src/topup_client/api/account/roll_webhook_key.py +237 -0
  22. phala_pay-0.2.0/src/topup_client/api/account/update_account.py +220 -0
  23. phala_pay-0.2.0/src/topup_client/api/api_keys/__init__.py +1 -0
  24. phala_pay-0.2.0/src/topup_client/api/api_keys/create_api_key.py +229 -0
  25. phala_pay-0.2.0/src/topup_client/api/api_keys/get_api_key.py +173 -0
  26. phala_pay-0.2.0/src/topup_client/api/api_keys/list_api_keys.py +219 -0
  27. phala_pay-0.2.0/src/topup_client/api/api_keys/revoke_api_key.py +186 -0
  28. phala_pay-0.2.0/src/topup_client/api/api_keys/roll_api_key.py +232 -0
  29. phala_pay-0.2.0/src/topup_client/api/attestation/__init__.py +1 -0
  30. phala_pay-0.2.0/src/topup_client/api/attestation/get_attestation.py +196 -0
  31. phala_pay-0.2.0/src/topup_client/api/balance/__init__.py +1 -0
  32. phala_pay-0.2.0/src/topup_client/api/balance/get_balance.py +150 -0
  33. phala_pay-0.2.0/src/topup_client/api/config/__init__.py +1 -0
  34. phala_pay-0.2.0/src/topup_client/api/config/get_config.py +146 -0
  35. phala_pay-0.2.0/src/topup_client/api/deposit_addresses/__init__.py +1 -0
  36. phala_pay-0.2.0/src/topup_client/api/deposit_addresses/create_deposit_address.py +220 -0
  37. phala_pay-0.2.0/src/topup_client/api/deposit_addresses/get_deposit_address.py +220 -0
  38. phala_pay-0.2.0/src/topup_client/api/deposit_addresses/list_deposit_addresses.py +244 -0
  39. phala_pay-0.2.0/src/topup_client/api/deposit_addresses/rotate_deposit_address.py +206 -0
  40. phala_pay-0.2.0/src/topup_client/api/deposit_addresses/update_deposit_address.py +240 -0
  41. phala_pay-0.2.0/src/topup_client/api/deposits/__init__.py +1 -0
  42. phala_pay-0.2.0/src/topup_client/api/deposits/get_deposit.py +199 -0
  43. phala_pay-0.2.0/src/topup_client/api/deposits/list_deposits.py +368 -0
  44. phala_pay-0.2.0/src/topup_client/api/deposits/update_deposit.py +240 -0
  45. phala_pay-0.2.0/src/topup_client/api/events/__init__.py +1 -0
  46. phala_pay-0.2.0/src/topup_client/api/events/get_event.py +173 -0
  47. phala_pay-0.2.0/src/topup_client/api/events/list_events.py +327 -0
  48. phala_pay-0.2.0/src/topup_client/api/events/resend_event.py +232 -0
  49. phala_pay-0.2.0/src/topup_client/api/forwarders/__init__.py +1 -0
  50. phala_pay-0.2.0/src/topup_client/api/forwarders/list_forwarders.py +291 -0
  51. phala_pay-0.2.0/src/topup_client/api/quotes/__init__.py +1 -0
  52. phala_pay-0.2.0/src/topup_client/api/quotes/cancel_quote.py +206 -0
  53. phala_pay-0.2.0/src/topup_client/api/quotes/create_quote.py +217 -0
  54. phala_pay-0.2.0/src/topup_client/api/quotes/get_quote.py +235 -0
  55. phala_pay-0.2.0/src/topup_client/api/quotes/list_quotes.py +240 -0
  56. phala_pay-0.2.0/src/topup_client/api/quotes/update_quote.py +236 -0
  57. phala_pay-0.2.0/src/topup_client/api/refunds/__init__.py +1 -0
  58. phala_pay-0.2.0/src/topup_client/api/refunds/cancel_refund.py +222 -0
  59. phala_pay-0.2.0/src/topup_client/api/refunds/create_refund.py +233 -0
  60. phala_pay-0.2.0/src/topup_client/api/refunds/get_refund.py +199 -0
  61. phala_pay-0.2.0/src/topup_client/api/refunds/list_refunds.py +240 -0
  62. phala_pay-0.2.0/src/topup_client/api/refunds/mark_refund_paid.py +252 -0
  63. phala_pay-0.2.0/src/topup_client/api/refunds/update_refund.py +236 -0
  64. phala_pay-0.2.0/src/topup_client/api/sweeps/__init__.py +1 -0
  65. phala_pay-0.2.0/src/topup_client/api/sweeps/list_sweeps.py +263 -0
  66. phala_pay-0.2.0/src/topup_client/api/treasuries/__init__.py +1 -0
  67. phala_pay-0.2.0/src/topup_client/api/treasuries/cancel_treasury.py +206 -0
  68. phala_pay-0.2.0/src/topup_client/api/treasuries/create_treasury.py +278 -0
  69. phala_pay-0.2.0/src/topup_client/api/treasuries/create_treasury_challenge.py +221 -0
  70. phala_pay-0.2.0/src/topup_client/api/treasuries/get_treasury.py +173 -0
  71. phala_pay-0.2.0/src/topup_client/api/treasuries/list_treasuries.py +244 -0
  72. phala_pay-0.2.0/src/topup_client/api/treasuries/pause_treasury.py +214 -0
  73. phala_pay-0.2.0/src/topup_client/api/treasuries/resume_treasury.py +210 -0
  74. phala_pay-0.2.0/src/topup_client/api/webhook_endpoints/__init__.py +1 -0
  75. phala_pay-0.2.0/src/topup_client/api/webhook_endpoints/create_webhook_endpoint.py +224 -0
  76. phala_pay-0.2.0/src/topup_client/api/webhook_endpoints/delete_webhook_endpoint.py +177 -0
  77. phala_pay-0.2.0/src/topup_client/api/webhook_endpoints/get_webhook_endpoint.py +173 -0
  78. phala_pay-0.2.0/src/topup_client/api/webhook_endpoints/list_webhook_endpoints.py +210 -0
  79. phala_pay-0.2.0/src/topup_client/api/webhook_endpoints/test_webhook_endpoint.py +205 -0
  80. phala_pay-0.2.0/src/topup_client/api/webhook_endpoints/update_webhook_endpoint.py +240 -0
  81. phala_pay-0.2.0/src/topup_client/client.py +272 -0
  82. phala_pay-0.2.0/src/topup_client/errors.py +16 -0
  83. phala_pay-0.2.0/src/topup_client/models/__init__.py +203 -0
  84. phala_pay-0.2.0/src/topup_client/models/account_object.py +174 -0
  85. phala_pay-0.2.0/src/topup_client/models/account_object_object.py +13 -0
  86. phala_pay-0.2.0/src/topup_client/models/account_self_pause_request.py +53 -0
  87. phala_pay-0.2.0/src/topup_client/models/api_key_list.py +115 -0
  88. phala_pay-0.2.0/src/topup_client/models/api_key_list_object.py +13 -0
  89. phala_pay-0.2.0/src/topup_client/models/api_key_object.py +227 -0
  90. phala_pay-0.2.0/src/topup_client/models/api_key_object_object.py +13 -0
  91. phala_pay-0.2.0/src/topup_client/models/attestation_response.py +136 -0
  92. phala_pay-0.2.0/src/topup_client/models/attestation_response_object.py +15 -0
  93. phala_pay-0.2.0/src/topup_client/models/balance.py +106 -0
  94. phala_pay-0.2.0/src/topup_client/models/balance_amount.py +114 -0
  95. phala_pay-0.2.0/src/topup_client/models/balance_object.py +13 -0
  96. phala_pay-0.2.0/src/topup_client/models/client_deposit_address.py +160 -0
  97. phala_pay-0.2.0/src/topup_client/models/client_deposit_address_network.py +98 -0
  98. phala_pay-0.2.0/src/topup_client/models/client_deposit_address_object.py +15 -0
  99. phala_pay-0.2.0/src/topup_client/models/client_deposit_address_payment.py +164 -0
  100. phala_pay-0.2.0/src/topup_client/models/client_quote.py +209 -0
  101. phala_pay-0.2.0/src/topup_client/models/client_quote_object.py +13 -0
  102. phala_pay-0.2.0/src/topup_client/models/config.py +143 -0
  103. phala_pay-0.2.0/src/topup_client/models/config_asset.py +174 -0
  104. phala_pay-0.2.0/src/topup_client/models/config_object.py +13 -0
  105. phala_pay-0.2.0/src/topup_client/models/confirmation_policy.py +74 -0
  106. phala_pay-0.2.0/src/topup_client/models/create_api_key_request.py +111 -0
  107. phala_pay-0.2.0/src/topup_client/models/create_deposit_address_request.py +97 -0
  108. phala_pay-0.2.0/src/topup_client/models/create_quote_request.py +130 -0
  109. phala_pay-0.2.0/src/topup_client/models/create_refund_request.py +127 -0
  110. phala_pay-0.2.0/src/topup_client/models/create_treasury_challenge_request.py +58 -0
  111. phala_pay-0.2.0/src/topup_client/models/create_treasury_request.py +73 -0
  112. phala_pay-0.2.0/src/topup_client/models/create_webhook_endpoint_request.py +126 -0
  113. phala_pay-0.2.0/src/topup_client/models/deleted_webhook_endpoint.py +88 -0
  114. phala_pay-0.2.0/src/topup_client/models/deleted_webhook_endpoint_object.py +15 -0
  115. phala_pay-0.2.0/src/topup_client/models/delivery_attempt.py +90 -0
  116. phala_pay-0.2.0/src/topup_client/models/deposit.py +518 -0
  117. phala_pay-0.2.0/src/topup_client/models/deposit_address.py +270 -0
  118. phala_pay-0.2.0/src/topup_client/models/deposit_address_asset.py +90 -0
  119. phala_pay-0.2.0/src/topup_client/models/deposit_address_list.py +119 -0
  120. phala_pay-0.2.0/src/topup_client/models/deposit_address_list_object.py +15 -0
  121. phala_pay-0.2.0/src/topup_client/models/deposit_address_metadata.py +53 -0
  122. phala_pay-0.2.0/src/topup_client/models/deposit_address_network.py +108 -0
  123. phala_pay-0.2.0/src/topup_client/models/deposit_address_object.py +15 -0
  124. phala_pay-0.2.0/src/topup_client/models/deposit_admin.py +237 -0
  125. phala_pay-0.2.0/src/topup_client/models/deposit_event_delivery.py +117 -0
  126. phala_pay-0.2.0/src/topup_client/models/deposit_list.py +120 -0
  127. phala_pay-0.2.0/src/topup_client/models/deposit_list_object.py +13 -0
  128. phala_pay-0.2.0/src/topup_client/models/deposit_metadata.py +54 -0
  129. phala_pay-0.2.0/src/topup_client/models/deposit_object.py +13 -0
  130. phala_pay-0.2.0/src/topup_client/models/deposit_transition.py +109 -0
  131. phala_pay-0.2.0/src/topup_client/models/error_detail.py +117 -0
  132. phala_pay-0.2.0/src/topup_client/models/error_response.py +80 -0
  133. phala_pay-0.2.0/src/topup_client/models/error_type.py +15 -0
  134. phala_pay-0.2.0/src/topup_client/models/event_data.py +113 -0
  135. phala_pay-0.2.0/src/topup_client/models/event_data_object.py +53 -0
  136. phala_pay-0.2.0/src/topup_client/models/event_data_previous_attributes_type_0.py +53 -0
  137. phala_pay-0.2.0/src/topup_client/models/event_list.py +123 -0
  138. phala_pay-0.2.0/src/topup_client/models/event_list_object.py +13 -0
  139. phala_pay-0.2.0/src/topup_client/models/event_object_response.py +190 -0
  140. phala_pay-0.2.0/src/topup_client/models/event_object_response_object.py +15 -0
  141. phala_pay-0.2.0/src/topup_client/models/event_request.py +88 -0
  142. phala_pay-0.2.0/src/topup_client/models/forwarder.py +190 -0
  143. phala_pay-0.2.0/src/topup_client/models/forwarder_list.py +115 -0
  144. phala_pay-0.2.0/src/topup_client/models/forwarder_list_object.py +13 -0
  145. phala_pay-0.2.0/src/topup_client/models/forwarder_object.py +13 -0
  146. phala_pay-0.2.0/src/topup_client/models/mark_refund_paid_request.py +77 -0
  147. phala_pay-0.2.0/src/topup_client/models/metadata_clear.py +13 -0
  148. phala_pay-0.2.0/src/topup_client/models/metadata_param_type_0.py +50 -0
  149. phala_pay-0.2.0/src/topup_client/models/payment.py +187 -0
  150. phala_pay-0.2.0/src/topup_client/models/quote.py +314 -0
  151. phala_pay-0.2.0/src/topup_client/models/quote_list.py +121 -0
  152. phala_pay-0.2.0/src/topup_client/models/quote_list_object.py +13 -0
  153. phala_pay-0.2.0/src/topup_client/models/quote_metadata.py +50 -0
  154. phala_pay-0.2.0/src/topup_client/models/quote_object.py +13 -0
  155. phala_pay-0.2.0/src/topup_client/models/refund.py +249 -0
  156. phala_pay-0.2.0/src/topup_client/models/refund_list.py +116 -0
  157. phala_pay-0.2.0/src/topup_client/models/refund_list_object.py +13 -0
  158. phala_pay-0.2.0/src/topup_client/models/refund_metadata.py +50 -0
  159. phala_pay-0.2.0/src/topup_client/models/refund_object.py +13 -0
  160. phala_pay-0.2.0/src/topup_client/models/resend_event_request.py +50 -0
  161. phala_pay-0.2.0/src/topup_client/models/roll_api_key_request.py +52 -0
  162. phala_pay-0.2.0/src/topup_client/models/roll_webhook_key_request.py +53 -0
  163. phala_pay-0.2.0/src/topup_client/models/sweep.py +188 -0
  164. phala_pay-0.2.0/src/topup_client/models/sweep_list.py +117 -0
  165. phala_pay-0.2.0/src/topup_client/models/sweep_list_object.py +13 -0
  166. phala_pay-0.2.0/src/topup_client/models/sweep_object.py +13 -0
  167. phala_pay-0.2.0/src/topup_client/models/treasury.py +227 -0
  168. phala_pay-0.2.0/src/topup_client/models/treasury_challenge.py +128 -0
  169. phala_pay-0.2.0/src/topup_client/models/treasury_challenge_object.py +15 -0
  170. phala_pay-0.2.0/src/topup_client/models/treasury_list.py +115 -0
  171. phala_pay-0.2.0/src/topup_client/models/treasury_list_object.py +13 -0
  172. phala_pay-0.2.0/src/topup_client/models/treasury_object.py +13 -0
  173. phala_pay-0.2.0/src/topup_client/models/update_account_object_request.py +92 -0
  174. phala_pay-0.2.0/src/topup_client/models/update_metadata_request.py +88 -0
  175. phala_pay-0.2.0/src/topup_client/models/update_webhook_endpoint_request.py +179 -0
  176. phala_pay-0.2.0/src/topup_client/models/webhook_endpoint_list.py +116 -0
  177. phala_pay-0.2.0/src/topup_client/models/webhook_endpoint_list_object.py +15 -0
  178. phala_pay-0.2.0/src/topup_client/models/webhook_endpoint_object.py +274 -0
  179. phala_pay-0.2.0/src/topup_client/models/webhook_endpoint_object_metadata.py +50 -0
  180. phala_pay-0.2.0/src/topup_client/models/webhook_endpoint_object_object.py +15 -0
  181. phala_pay-0.2.0/src/topup_client/models/webhook_key_object.py +97 -0
  182. phala_pay-0.2.0/src/topup_client/models/webhook_key_version.py +89 -0
  183. phala_pay-0.2.0/src/topup_client/types.py +54 -0
  184. phala_pay-0.2.0/src/topup_sdk/__init__.py +79 -0
  185. phala_pay-0.2.0/src/topup_sdk/__main__.py +171 -0
  186. phala_pay-0.2.0/src/topup_sdk/addresses.py +168 -0
  187. phala_pay-0.2.0/src/topup_sdk/attestation.py +73 -0
  188. phala_pay-0.2.0/src/topup_sdk/client.py +1188 -0
  189. phala_pay-0.2.0/src/topup_sdk/errors.py +57 -0
  190. phala_pay-0.2.0/src/topup_sdk/export.py +51 -0
  191. phala_pay-0.2.0/src/topup_sdk/fulfillment.py +143 -0
  192. phala_pay-0.2.0/src/topup_sdk/ids.py +28 -0
  193. phala_pay-0.2.0/src/topup_sdk/py.typed +0 -0
  194. phala_pay-0.2.0/src/topup_sdk/signing.py +329 -0
  195. phala_pay-0.2.0/src/topup_sdk/sweeps.py +210 -0
  196. phala_pay-0.2.0/src/topup_sdk/treasury.py +47 -0
  197. phala_pay-0.2.0/src/topup_sdk/webhooks.py +162 -0
  198. phala_pay-0.2.0/tests/__init__.py +0 -0
  199. phala_pay-0.2.0/tests/test_addresses.py +105 -0
  200. phala_pay-0.2.0/tests/test_attestation.py +145 -0
  201. phala_pay-0.2.0/tests/test_client.py +641 -0
  202. phala_pay-0.2.0/tests/test_export.py +99 -0
  203. phala_pay-0.2.0/tests/test_fastapi_example.py +220 -0
  204. phala_pay-0.2.0/tests/test_fulfillment.py +183 -0
  205. phala_pay-0.2.0/tests/test_phala_pay.py +591 -0
  206. phala_pay-0.2.0/tests/test_signing.py +143 -0
  207. phala_pay-0.2.0/tests/test_sweeps.py +165 -0
  208. phala_pay-0.2.0/tests/test_treasury.py +39 -0
  209. phala_pay-0.2.0/tests/test_webhooks.py +174 -0
  210. phala_pay-0.2.0/tests/vectors.py +142 -0
  211. phala_pay-0.2.0/uv.lock +2402 -0
@@ -0,0 +1,6 @@
1
+ .venv/
2
+ __pycache__/
3
+ .mypy_cache/
4
+ .pytest_cache/
5
+ .ruff_cache/
6
+ dist/
@@ -0,0 +1 @@
1
+ 3.14
@@ -0,0 +1,315 @@
1
+ # Changelog
2
+
3
+ All notable changes to `phala-pay` (formerly `crypto-topup-sdk`) are recorded here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the rules in `docs/integration.md`
5
+ (section 5.9); versions follow [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.2.0] - 2026-09-29
10
+
11
+ The first release on PyPI.
12
+
13
+ ### Added
14
+
15
+ - `list_forwarders` / `pay.forwarders.list` take the API's `quote` and `deposit_address` filters.
16
+ - `Deposit.final_at`; `Config.max_open_quotes` and `max_open_amount_per_customer`
17
+ (`max_open_amount_per_account` is now the account's cap in the mode).
18
+
19
+ ### Fixed
20
+
21
+ - Error responses are read leniently: a body without `doc_url` (or any field but `code`), with an
22
+ unknown `type`, or not JSON at all (a proxy's `502` page) raises `ApiError` (`unexpected_response`
23
+ when there is no error object), never `KeyError` or `JSONDecodeError`, and a retryable status
24
+ is retried whatever its body.
25
+
26
+ ### Changed (breaking)
27
+
28
+ - Address checks derive every address from your pins, never from the response's `treasury`: a
29
+ quote or deposit address network naming another treasury than your pinned one of its chain
30
+ raises `AddressMismatchError`. With a live key (`ppay_sk_live_`, `ppay_rk_live_`) the check is
31
+ mandatory and fails closed unless `account`, `forwarder`, and `treasuries` are all given; in test
32
+ mode an unpinned treasury falls back to the response's with an `UnpinnedTreasuryWarning`.
33
+ - `roll_webhook_key` / `pay.account.roll_webhook_key` default to `expires_in=172800`, the shortest
34
+ overlap a live roll accepts (was `0`).
35
+
36
+ - `Deposit` has `amount_refunded` and `amount_reversed`, the service-computed cumulative
37
+ claw-backs; `Refund.receipt_log_index` replaces `log_index`, and `mark_paid(…,
38
+ receipt_log_index=…)` / `mark_refund_paid(…, receipt_log_index=…)` replace `log_index=`. A refund
39
+ marked paid can no longer be canceled. The FastAPI example applies every `deposit.*` event by
40
+ the balance rule (docs/integration.md §2.3).
41
+
42
+ - API conformance with Stripe (docs/design/multi-tenant.md, "API conformance"): business-state
43
+ failures such as `deposit_not_final`, `quote_unexpected_state`, `paused`, `treasury_not_set`,
44
+ and `*_cap_exceeded` are `400` (only `idempotency_key_in_use` is `409`); per-customer limits are
45
+ `429 customer_rate_limit`; every `429` carries `Retry-After`, which the client waits.
46
+ - `ApiError.request_id` reads only `Request-Id`; `X-Request-Id` is no longer sent. `ApiError`
47
+ gains `doc_url` and `retry_after`.
48
+ - A response the service saved for an `Idempotency-Key` (now every executed request, even a
49
+ `500`) arrives `Idempotent-Replayed` and is raised, not retried.
50
+ - A quote's address salt is `keccak256(abi.encode(account, client_reference_id, "quote",
51
+ quote_id))` (design D3; it was tagged `"lock"`): `topup_sdk.quote_salt` replaces `lock_salt`.
52
+ - Treasury events are `treasury.created`, `treasury.updated`, and `treasury.canceled` (were
53
+ `account.treasury.pending|updated|canceled`).
54
+ - The generated client has no admin API (the operator's is `openapi.admin.json`); every object's
55
+ `object` is a `Literal` (`literal_enums`), and so is `ErrorDetail.type_`.
56
+
57
+ - The API's name for your customer is `client_reference_id` everywhere: `pay.quotes.create(
58
+ client_reference_id=…)`, `pay.deposits.list(client_reference_id=…)`, `Quote`/`Deposit`
59
+ `.client_reference_id`, `CreditedDeposit.client_reference_id`, and `topup-sdk send-test-event
60
+ --client-reference-id`.
61
+ - `PhalaPay(…, forwarder=(factory, implementation))` is required and a pair, and
62
+ `treasuries={chain_id: treasury}` pins the treasury each address is derived from (required in
63
+ live mode, above). `TopupClient(forwarder=)` takes the same pair.
64
+ - A deposit's `status` is `pending`, `credited`, `rejected`, or `reversed`, with booleans `final`
65
+ and `swept`; `CreditedDeposit` accepts only `credited`.
66
+ - `Quote.payment` is the shared `Payment` model (`status` `seen` or `recorded`, with `chain_id` and
67
+ `asset`); `QuotePayment` is gone. `DepositAddress.payments` uses the same model.
68
+ - `AttestationResponse.tdx_quote` replaces `.quote`.
69
+ - Every object's `livemode` and `metadata` are required in the generated models.
70
+
71
+ ### Added
72
+
73
+ - Restricted keys: `TopupClient`/`PhalaPay` accept `ppay_rk_…` keys, and
74
+ `create_api_key(name=, permissions=[...])` / `pay.api_keys.create(permissions=)` create one.
75
+ - `pause_treasury` / `resume_treasury` (`pay.treasuries.pause`, `.resume`): the merchant's
76
+ crediting pause of a treasury. `topup_sdk.UnpinnedTreasuryWarning`.
77
+
78
+ - Events are snapshots with their cause: `Event.request` (`EventRequest`: the `Request-Id` and
79
+ `Idempotency-Key` of the request that caused it, `None` for the service's workers) and
80
+ `EventData.previous_attributes` on `*.updated` events; new events `refund.created`,
81
+ `refund.updated`, and `quote.canceled`.
82
+ - `pay.events.list(types=, delivery_success=, created_gt=, created_gte=, created_lt=,
83
+ created_lte=)`, `pay.deposits.list(created_gt=, created_lt=)`, and every page of
84
+ `pay.api_keys.list()` and `pay.treasuries.list()`. Webhook endpoints carry
85
+ `pending_deliveries`, `oldest_pending_at`, and `last_attempt`.
86
+ - `Literal` hints: `phala_pay.QuoteStatus`, `DepositStatus`, `DepositAddressStatus`,
87
+ `RefundStatus`, `TreasuryStatus`, `ApiKeyStatus`, `WebhookEndpointStatus`, `PaymentStatus`, and
88
+ `EventType`.
89
+ - `pay.account` (`retrieve`, `update(confirmation_policies=)`, `pause_quotes`, `resume_quotes`,
90
+ `roll_webhook_key`), `pay.api_keys`, `pay.webhook_endpoints`, `pay.events` (`list`, `retrieve`,
91
+ `resend`), `pay.treasuries` (`challenge`, `create`, `set_eoa`, `list`, `retrieve`, `cancel`),
92
+ `pay.balance`, `pay.sweeps`, `pay.forwarders`, `pay.quotes.list`, `pay.refunds.list`, and
93
+ `pay.export_account(directory)`, with the matching `TopupClient` methods.
94
+ - `ApiError.request_id`, read from the response's `Request-Id`.
95
+ - Offline sweeping: `topup_sdk.flush_transaction(factory, treasury, salts, token)`,
96
+ `flush_transactions(forwarders, token)`, `safe_batch(chain_id, safe, calls)` writing the Safe
97
+ Transaction Builder's `BatchFile` JSON with the app's checksum, `write_safe_batch`, and
98
+ `batch_checksum`.
99
+ - `topup_sdk.sign_treasury_challenge(message, private_key, address=)`, the EIP-191 proof of an EOA
100
+ treasury (extra `phala-pay[eoa]`), and `topup_sdk.quote_address(...)`.
101
+ - `DepositAddress.client_secret` and `.payments`; the generated client reads a deposit address's
102
+ public `ClientDepositAddress`.
103
+
104
+ - The generated client covers treasuries (design D10): `topup_client.api.treasuries`
105
+ (`create_treasury_challenge`, `create_treasury`, `list_treasuries`, `get_treasury`,
106
+ `cancel_treasury`) and the `Treasury`, `TreasuryChallenge`, and `TreasuryList` models; `Quote`
107
+ gains the optional `treasury`; `Treasury` carries `cancellation_reason`, and the admin client
108
+ gains `pause_account` and `resume_account`. Challenge and submit helpers for EOAs and Safes come with the SDK
109
+ work of design PR 10. The generated `RouteDailyReport` drops the treasury balance fields.
110
+ - `metadata`: `pay.quotes.create(…, metadata=)` and `pay.refunds.create(…, metadata=)`, and
111
+ `pay.quotes.update(id, metadata=)`, `pay.deposits.update(id, metadata=)`, and
112
+ `pay.refunds.update(id, metadata=)`, which merge (a key set to `""` is unset, `metadata=""`
113
+ unsets all); `TopupClient` gains the same `metadata=` and `update_quote`, `update_deposit`, and
114
+ `update_refund`. The regenerated `Quote`, `Deposit`, and `Refund` carry `metadata`, so a webhook
115
+ deposit carries its quote's.
116
+ - Deposit addresses, one per customer for every supported token on every chain:
117
+ `PhalaPay.deposit_addresses.create(client_reference_id=, metadata=)`, `.retrieve(id)`,
118
+ `.list(client_reference_id=, status=)`, `.update(id, metadata=)`, and `.rotate(id)`, with the
119
+ matching `TopupClient` methods and the generated `DepositAddress`, `DepositAddressNetwork`, and
120
+ `DepositAddressAsset` models. With a pinned `forwarder`, every network of an active deposit
121
+ address must pay the pinned treasury at the recomputed address, or `AddressMismatchError` is
122
+ raised. `topup_sdk.deposit_address_salt(account, livemode=, client_reference_id=, version=)` and
123
+ `topup_sdk.deposit_address(factory, implementation, treasury, …)` recompute any version offline
124
+ from a network's treasury; `Deposits.list` and `TopupClient.list_deposits` take
125
+ `deposit_address`, and `Deposit.deposit_address` names the address a deposit reached.
126
+
127
+ - Generated `topup_client.api.webhook_endpoints` (create, list, retrieve, update, delete, test)
128
+ and `topup_client.api.events` (list, retrieve, resend) with their models
129
+ (`WebhookEndpointObject`, `EventObjectResponse`, and the request and list types); the
130
+ hand-written `PhalaPay` helpers for them come with design PR 10.
131
+ - Generated `CreateAccountRequest` and `UpdateAccountRequest` lose `webhook_url`, and
132
+ `topup_client.api.admin.replay_outbox_event` and `OutboxReplayResponse` are removed: the
133
+ operator no longer manages merchants' webhooks.
134
+
135
+ - `TopupClient.roll_webhook_key(expires_in=)` rolls the mode's webhook key (one
136
+ `Idempotency-Key` across retries). `sign_webhook` accepts several keys, as a rotation signs.
137
+
138
+ ### Changed
139
+
140
+ - **Breaking**: webhooks are signed with your account's key per mode (design D11).
141
+ `Webhook.construct_event(payload, headers, public_key, expected_account, *, expected_livemode)`
142
+ and `verify_webhook(headers, body, public_keys, *, expected_account, expected_livemode)` fail
143
+ closed unless a signature verifies with a pinned key (one key, or a list while a rotation
144
+ overlaps) and the event's `account` and `livemode` match; `Event` and `WebhookEvent` carry
145
+ `account` and `livemode`. Events in the envelope before `evt_` ids are refused.
146
+ `attestation_report_data(nonce, account, livemode, keys)` computes the new binding and
147
+ `verify_attestation_binding(response, nonce, *, expected_account=, expected_livemode=)` returns
148
+ the attested public keys; `AttestationResponse` has `account`, `livemode`, and `webhook_keys`
149
+ instead of `keyid` and `settlement_pubkey`, and `TopupClient.attestation` sends the API key.
150
+ `topup-sdk send-test-event` takes `--account` and also checks that another account's event is
151
+ refused. `Quote`, `Deposit`, `Refund`, `Config`, and `AccountObject` gain `livemode` or
152
+ `webhook_keys`.
153
+ - **Breaking**: refunds are paid by the merchant from the refund's `treasury` and attached with
154
+ `TopupClient.mark_refund_paid(refund_id, transaction_hash, log_index=)` (`pay.refunds.mark_paid`);
155
+ `cancel_refund` (`pay.refunds.cancel`) cancels a pending one. `Refund` gains `treasury`,
156
+ `failure_reason`, and `log_index`, renames `tx_hash` to `transaction_hash`, and its `status` may
157
+ also be `failed` or `canceled`. A failed refund is announced by the `refund.failed` webhook,
158
+ whose `data.object` is the refund. The regenerated admin client drops `approve_refund`,
159
+ `record_refund`, `AdminRefundResponse`, and `RecordRefundRequest`.
160
+
161
+ - **Breaking**: the service sends no transactions, so attestation binds no flusher operators.
162
+ `AttestationResponse` drops `operators` (and `OperatorIdentity` is gone), `report_data` is
163
+ `sha256(nonce ‖ settlement_pubkey)`, and `attestation_report_data(nonce, settlement_pubkey)`
164
+ takes no operators. The admin daily report drops `flush_planning` (`FlushPlanningReport`), and
165
+ its `unflushed_balance_atomic` is what forwarders still hold: deposits not reversed minus
166
+ finalized `Flushed` amounts, whoever flushed.
167
+ - **Breaking**: merchant requests carry a secret key, `Authorization: Bearer ppay_sk_…`, instead
168
+ of an RFC 9421 signature (design D7, PR 5). `TopupClient(base_url, api_key, *, account=None,
169
+ forwarder=None, …)` and `PhalaPay(api_base, api_key, *, account=None, forwarder=None, …)`
170
+ replace the signer and key file arguments; the address check reads the account id once from
171
+ `GET /v1/account` unless `account=` is given. `TopupClient.get_account()` and `account_id()`
172
+ are new. The client retries `409 idempotency_key_in_use` instead of `signature_replayed`.
173
+ `RequestSigner` stays for the operator's admin requests.
174
+ - The regenerated client adds `/v1/account`, `/v1/api_keys` (create, list, retrieve, roll,
175
+ revoke), and the admin `create_account` (contact, due diligence, `charges_enabled`, first keys),
176
+ `update_account` (now `POST`), and `issue_api_key`; customer pauses take `livemode`.
177
+
178
+ - **Breaking**: products are gone; the service's tenant is an account, `acct_…`. Sign with the key
179
+ id the operator issued with your account, `{acct_…}/v1`: the client takes the account id from
180
+ it as the first input of every quote's address salt, as it took the product slug. The
181
+ regenerated admin client replaces `register_product`, `update_product`, `pause_account`, and
182
+ `resume_account` with `create_account`, `update_account`, `pause_customer`, and
183
+ `resume_customer`; the admin deposit view carries `account` and `livemode`.
184
+
185
+ - **Breaking**: forwarders are clones of the new permissionless factory whose address commits to
186
+ the treasury. `forwarder_address(factory, implementation, treasury, salt)` takes the treasury,
187
+ and `forwarder=` is the `(factory, implementation, treasury)` triple.
188
+
189
+ ### Added
190
+
191
+ - Fast credit: the regenerated client carries the config's `confirmations` and
192
+ `typical_credit_seconds`, and the admin deposit view's `receipt_log_index` and `final_at`.
193
+ `Event` documents `deposit.reversed`: claw its credit back as for `deposit.refunded`.
194
+
195
+ ### Changed
196
+
197
+ - **Breaking**: `topup_sdk.deposit_id(chain_id, tx_hash, receipt_log_index)` hashes the
198
+ transfer's position in its transaction's receipt (0 for a plain token transfer), the service's
199
+ deposit identity since fast credit; the argument was the block-wide `log_index`.
200
+
201
+ - `phala_pay`: the Stripe-style facade. `PhalaPay(api_base, key_id, key_file=… | seed=…,
202
+ forwarder=…)` with `quotes.create/retrieve/cancel`, `deposits.list` (auto-paginating) and
203
+ `retrieve`, `refunds.create/retrieve`, and `config.retrieve`; `webhooks.construct_event(payload,
204
+ headers, public_key)` verifies a delivery and returns a typed `Event` (`data.object` is a
205
+ `Deposit` or `Quote`), raising `SignatureVerificationError`.
206
+ - `TopupClient.create_refund` (sends an `Idempotency-Key`) and `get_refund`; `topup_sdk.ids`
207
+ (`object_id`, `parse_id`, and the `qt_`/`dep_`/`re_`/`evt_` prefixes).
208
+ - `TopupClient.get_config`, `create_quote` (sends an `Idempotency-Key`, generated unless given,
209
+ and reuses it on retries), `get_quote`, and `cancel_quote`; `topup_sdk.signing.sf_string`.
210
+ - `Quote.client_secret`, returned by `create_quote` only, and the generated `ClientQuote` model:
211
+ the public view the payer's browser reads from `GET /v1/quotes/{id}?client_secret=…`.
212
+
213
+ - `topup_sdk.fulfillment`: `CreditedDeposit.from_event` parses a verified `deposit.credited`
214
+ into a typed credit with its `fulfillment_key` (`deposit:<deposit_id>`), raising
215
+ `FulfillmentError` for any other shape; `credited_event_id` derives the event's
216
+ `webhook-id` from the deposit id; `CREDITED_EVENT`. The service emits this payload once
217
+ `deposit.credited` becomes the fulfillment event (docs/integration.md §2).
218
+ - `topup_sdk.sign_webhook` (test senders) and `topup-sdk send-test-event`, which checks a webhook
219
+ receiver answers a signed event and its duplicate with `2xx` and a forged copy with `4xx`.
220
+ - `DepositResponse.external_id` and `price_source` (also on `SupportDepositResponse`).
221
+ - Generated `topup_client.api.admin.update_product` with `UpdateProductRequest` for
222
+ `PUT /v1/admin/products/{slug}`.
223
+ - Generated `topup_client.api.admin.lift_reconciliation_block` and `replay_outbox_event` with
224
+ `AdminReasonRequest`, `ReconciliationBlockLiftResponse`, and `OutboxReplayResponse`.
225
+ - `DailyReportResponse.reconciliation_blocks` (`ReconciliationBlockReport`) and
226
+ `SupportDepositResponse.events` (`DepositEventResponse`). Optional, so the models also parse
227
+ responses from servers that predate them.
228
+ - `DailyReportResponse.reconciliation` (`ReconciliationRoundReport`, `FailedCheckReport`) and
229
+ `RouteDailyReport.flush_planning` (`FlushPlanningReport`): the latest reconciliation round and
230
+ scheduled flush planning run of the serving process. Optional, so the models also parse
231
+ reports from servers that predate them.
232
+ - `AttestationResponse.operators` (`OperatorIdentity`): the flusher operator of each configured
233
+ chain, bound into `report_data`. Optional, so the model also parses responses from servers
234
+ that predate it.
235
+ - Generated `topup_client.api.admin.register_product` with `RegisterProductRequest` and
236
+ `ProductResponse` for `POST /v1/admin/products`.
237
+ - `topup_sdk.verify_attestation_binding` and `attestation_report_data`, which check that
238
+ `report_data` binds the nonce, the settlement key, and every listed operator, and
239
+ `AttestationError`.
240
+ - `TopupClient.list_pending_deposits` and the generated `list_pending_deposits` operation with
241
+ `PendingDepositResponse` and `PendingDepositsResponse`: transfers to persistent addresses seen
242
+ before finality. Display only; they are not credited.
243
+ - `RateLockResponse.payment` (`RateLockPayment`): the payment the checkout page should show (the
244
+ consuming deposit, else the first qualifying payment, else the first), `seen` before finality
245
+ or `finalized` once it is a deposit.
246
+ - `DailyReportResponse.exposure_minor`, the global open rate-lock credit in destination minor
247
+ units (#94). Optional, so the model also parses reports from servers that predate it.
248
+
249
+ ### Changed
250
+
251
+ - **Breaking**: the distribution is `phala-pay` (was `crypto-topup-sdk`), published to
252
+ PyPI from `sdk-py-v*` tags. The `topup_sdk` and `topup_client` imports are unchanged.
253
+ - **Breaking**: `verify_webhook` parses Stripe-style events: `WebhookEvent(id, type, created, data)`
254
+ with `object` (the event's `data.object`), still accepting the old envelope of a replayed old
255
+ event. `CreditedDeposit` carries the deposit's fields (`deposit_id` `dep_…`, `account_id`,
256
+ `amount` in cents, `price_source` `quote` or `spot`, `quote`, …) and its `fulfillment_key` is
257
+ the `dep_` id; `deposit_id` returns `dep_…` and `credited_event_id` `evt_…`.
258
+ `topup-sdk send-test-event` takes `--account-id` and `--amount` and sends the new envelope.
259
+ - **Breaking**: `TopupClient(base_url, signer, *, forwarder=None, …)`: the product is the signer's
260
+ key id, `{product}/v1`; there is no `product_slug` argument. With `forwarder=(factory,
261
+ implementation)` pinned, `create_quote` and `get_quote` recompute an open quote's address and
262
+ raise the new `AddressMismatchError`.
263
+ - **Breaking**: `ApiError` carries the error object's `error_type` and `param`.
264
+ - `TopupClient.attestation` raises `AttestationError` unless `report_data` binds the returned
265
+ keys. It does not verify the quote itself.
266
+ - The service now rebuilds `@target-uri` from its configured public origin
267
+ (`TOPUP_PUBLIC_ORIGIN`) instead of the `Host` and `X-Forwarded-Proto` headers, so requests
268
+ signed for the public URL verify behind the dstack gateway (#77). The `http_message_signature`
269
+ security scheme in `openapi.json` documents this. No SDK code changed.
270
+
271
+ ### Removed
272
+
273
+ - **Breaking**: `create_deposit_address`, `get_deposit_address`, `rotate_deposit_address`,
274
+ `list_pending_deposits`, and `topup_sdk.persistent_salt`, with their generated operations and
275
+ models: quotes are the only flow.
276
+ - **Breaking**: `lookup_deposits` and `request_refund`; `list_deposits(external_id, state=…,
277
+ created_from=…, created_to=…)` becomes `list_deposits(account_id=…, quote=…, status=…,
278
+ tx_hash=…, created_gte=…, created_lte=…, expand=…)` over Stripe's cursors, and `get_deposit`
279
+ takes a `dep_` id. Use `create_refund` and `get_refund`.
280
+ - **Breaking**: `register_account`, `create_rate_lock`, `get_rate_lock`, `cancel_rate_lock`, and
281
+ `get_limits`, with their generated `topup_client` operations and models. Use `create_quote`,
282
+ `get_quote`, `cancel_quote`, and `get_config`.
283
+ - **Breaking:** the generated `RouteDailyReportSettlementsByStatus` and
284
+ `RouteDailyReport.settlements_by_status`, replaced by `credited_undelivered` and
285
+ `credited_undelivered_max_age_seconds`; the settlement-request test vectors, since the service
286
+ no longer sends settlement requests.
287
+
288
+ - **Breaking:** the generated `ErrorDetail.work_package` field and the `501` response of
289
+ `/v1/attestation` (`get_attestation`) (#90). Both belonged only to the pre-C11 placeholder
290
+ attestor; the production service never returned them. There was no deprecation window because
291
+ neither was ever reachable in production.
292
+ - **Breaking:** `RouteDailyReport.exposure_minor`, `exposure_minor_reason`, `pnl_minor`, and
293
+ `pnl_minor_reason` (#94). They were always null placeholders on the admin-only daily report;
294
+ PnL is not defined precisely enough in the design to compute. Allowed as a pre-GA exception:
295
+ no service has been deployed. Regenerated models only.
296
+
297
+ ## [0.1.0] - 2026-09-22
298
+
299
+ Not published.
300
+
301
+ Generated from OpenAPI `info.version` 0.1.0.
302
+
303
+ ### Added
304
+
305
+ - Generated `topup_client` package for the product and administrative API.
306
+ - RFC 9421 ed25519 request signing (`RequestSigner`, `SigningAuth`) with a random `nonce` per
307
+ signature, and inbound verification (`verify_request`) in the service's profile.
308
+ - Standard Webhooks `v1a` verification (`verify_webhook`, `verify_webhook_signature`).
309
+ - Deposit-id, salt, and CREATE2 forwarder-address recomputation.
310
+ - `TopupClient` with idempotent, retrying helpers for accounts, deposit addresses, rotation,
311
+ rate locks, deposits, limits, refunds, and attestation.
312
+ - `topup-sdk keygen` and `topup-sdk public-key` for credential issuance.
313
+
314
+ [unreleased]: https://github.com/Phala-Network/phala-pay/compare/sdk-py-v0.2.0...HEAD
315
+ [0.2.0]: https://github.com/Phala-Network/phala-pay/releases/tag/sdk-py-v0.2.0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,38 @@
1
+ # Python SDK tasks. Every target runs the tools pinned in uv.lock.
2
+ UV ?= uv
3
+ OPENAPI := ../../crates/topup/openapi.json
4
+ GENERATED := src/topup_client
5
+
6
+ .PHONY: sync generate check-generated lint test test-min-python check
7
+
8
+ sync:
9
+ $(UV) sync --locked --all-groups
10
+
11
+ generate:
12
+ $(UV) run --locked --group codegen openapi-python-client generate \
13
+ --path $(OPENAPI) \
14
+ --config openapi-python-client.yaml \
15
+ --meta none \
16
+ --output-path $(GENERATED) \
17
+ --overwrite \
18
+ --fail-on-warning
19
+
20
+ # Regeneration must be a no-op: the committed client always matches the committed OpenAPI spec.
21
+ check-generated: generate
22
+ git diff --exit-code -- $(GENERATED)
23
+ test -z "$$(git status --porcelain --untracked-files=all -- $(GENERATED))"
24
+
25
+ lint:
26
+ $(UV) run --locked ruff check . ../examples ../../deploy/product ../../deploy/sandbox/scenarios ../../deploy/sandbox/smoke.py
27
+ $(UV) run --locked ruff format --check . ../examples ../../deploy/product ../../deploy/sandbox/scenarios ../../deploy/sandbox/smoke.py
28
+ $(UV) run --locked mypy src/phala_pay src/topup_sdk tests ../examples ../../deploy/product ../../deploy/sandbox/scenarios ../../deploy/sandbox/smoke.py
29
+
30
+ test:
31
+ $(UV) run --locked pytest
32
+
33
+ # The development interpreter is the newest (.python-version); this exercises the
34
+ # requires-python floor in a throwaway environment so the project .venv is left alone.
35
+ test-min-python:
36
+ $(UV) run --locked --isolated --python 3.12 pytest -q
37
+
38
+ check: lint test test-min-python check-generated