djwebdapp 0.6.8__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 (157) hide show
  1. djwebdapp-0.6.8/LICENSE +21 -0
  2. djwebdapp-0.6.8/MANIFEST.in +2 -0
  3. djwebdapp-0.6.8/PKG-INFO +191 -0
  4. djwebdapp-0.6.8/README.rst +122 -0
  5. djwebdapp-0.6.8/setup.cfg +4 -0
  6. djwebdapp-0.6.8/setup.py +58 -0
  7. djwebdapp-0.6.8/src/djwebdapp/__init__.py +0 -0
  8. djwebdapp-0.6.8/src/djwebdapp/admin.py +104 -0
  9. djwebdapp-0.6.8/src/djwebdapp/apps.py +9 -0
  10. djwebdapp-0.6.8/src/djwebdapp/exceptions.py +13 -0
  11. djwebdapp-0.6.8/src/djwebdapp/management/__init__.py +0 -0
  12. djwebdapp-0.6.8/src/djwebdapp/management/commands/__init__.py +0 -0
  13. djwebdapp-0.6.8/src/djwebdapp/management/commands/history_download.py +29 -0
  14. djwebdapp-0.6.8/src/djwebdapp/management/commands/index.py +19 -0
  15. djwebdapp-0.6.8/src/djwebdapp/management/commands/normalize.py +19 -0
  16. djwebdapp-0.6.8/src/djwebdapp/management/commands/refresh_balances.py +15 -0
  17. djwebdapp-0.6.8/src/djwebdapp/management/commands/spool.py +16 -0
  18. djwebdapp-0.6.8/src/djwebdapp/migrations/0001_initial.py +111 -0
  19. djwebdapp-0.6.8/src/djwebdapp/migrations/0002_alter_transaction_receiver_alter_transaction_sender.py +24 -0
  20. djwebdapp-0.6.8/src/djwebdapp/migrations/0003_transaction_txgroup_alter_transaction_hash_and_more.py +27 -0
  21. djwebdapp-0.6.8/src/djwebdapp/migrations/0004_alter_transaction_options.py +17 -0
  22. djwebdapp-0.6.8/src/djwebdapp/migrations/0005_alter_transaction_unique_together_and_more.py +35 -0
  23. djwebdapp-0.6.8/src/djwebdapp/migrations/0006_blockchain_min_confirmations_alter_transaction_state.py +23 -0
  24. djwebdapp-0.6.8/src/djwebdapp/migrations/0007_alter_transaction_amount.py +18 -0
  25. djwebdapp-0.6.8/src/djwebdapp/migrations/0008_transaction_index.py +21 -0
  26. djwebdapp-0.6.8/src/djwebdapp/migrations/0009_account_index.py +21 -0
  27. djwebdapp-0.6.8/src/djwebdapp/migrations/0010_alter_transaction_nonce.py +18 -0
  28. djwebdapp-0.6.8/src/djwebdapp/migrations/0011_rename_max_level_blockchain_index_level.py +18 -0
  29. djwebdapp-0.6.8/src/djwebdapp/migrations/0012_transaction_number.py +18 -0
  30. djwebdapp-0.6.8/src/djwebdapp/migrations/0013_transaction_normalized_dependency.py +61 -0
  31. djwebdapp-0.6.8/src/djwebdapp/migrations/0014_alter_account_unique_together.py +17 -0
  32. djwebdapp-0.6.8/src/djwebdapp/migrations/0015_alter_transaction_state.py +33 -0
  33. djwebdapp-0.6.8/src/djwebdapp/migrations/0016_alter_transaction_has_code.py +20 -0
  34. djwebdapp-0.6.8/src/djwebdapp/migrations/0017_event.py +46 -0
  35. djwebdapp-0.6.8/src/djwebdapp/migrations/0018_blockchain_chain_id.py +18 -0
  36. djwebdapp-0.6.8/src/djwebdapp/migrations/0019_alter_event_event_index_alter_event_normalized_and_more.py +49 -0
  37. djwebdapp-0.6.8/src/djwebdapp/migrations/__init__.py +0 -0
  38. djwebdapp-0.6.8/src/djwebdapp/models.py +1240 -0
  39. djwebdapp-0.6.8/src/djwebdapp/normalizers.py +35 -0
  40. djwebdapp-0.6.8/src/djwebdapp/provider.py +539 -0
  41. djwebdapp-0.6.8/src/djwebdapp/signals.py +3 -0
  42. djwebdapp-0.6.8/src/djwebdapp.egg-info/PKG-INFO +191 -0
  43. djwebdapp-0.6.8/src/djwebdapp.egg-info/SOURCES.txt +155 -0
  44. djwebdapp-0.6.8/src/djwebdapp.egg-info/dependency_links.txt +1 -0
  45. djwebdapp-0.6.8/src/djwebdapp.egg-info/requires.txt +38 -0
  46. djwebdapp-0.6.8/src/djwebdapp.egg-info/top_level.txt +9 -0
  47. djwebdapp-0.6.8/src/djwebdapp_ethereum/__init__.py +0 -0
  48. djwebdapp-0.6.8/src/djwebdapp_ethereum/admin.py +10 -0
  49. djwebdapp-0.6.8/src/djwebdapp_ethereum/apps.py +5 -0
  50. djwebdapp-0.6.8/src/djwebdapp_ethereum/migrations/0001_initial.py +27 -0
  51. djwebdapp-0.6.8/src/djwebdapp_ethereum/migrations/0002_ethereumcall_ethereumcontract.py +35 -0
  52. djwebdapp-0.6.8/src/djwebdapp_ethereum/migrations/0003_ethereumtransaction_caller.py +19 -0
  53. djwebdapp-0.6.8/src/djwebdapp_ethereum/migrations/0004_ethereumevent.py +39 -0
  54. djwebdapp-0.6.8/src/djwebdapp_ethereum/migrations/__init__.py +0 -0
  55. djwebdapp-0.6.8/src/djwebdapp_ethereum/models.py +146 -0
  56. djwebdapp-0.6.8/src/djwebdapp_ethereum/provider.py +482 -0
  57. djwebdapp-0.6.8/src/djwebdapp_example/__init__.py +0 -0
  58. djwebdapp-0.6.8/src/djwebdapp_example/balance.py +7 -0
  59. djwebdapp-0.6.8/src/djwebdapp_example/balance_update.py +34 -0
  60. djwebdapp-0.6.8/src/djwebdapp_example/deploy.py +3 -0
  61. djwebdapp-0.6.8/src/djwebdapp_example/deploy_fa12.py +1 -0
  62. djwebdapp-0.6.8/src/djwebdapp_example/migrations/0001_initial.py +51 -0
  63. djwebdapp-0.6.8/src/djwebdapp_example/migrations/__init__.py +0 -0
  64. djwebdapp-0.6.8/src/djwebdapp_example/models.py +112 -0
  65. djwebdapp-0.6.8/src/djwebdapp_example/spool.py +4 -0
  66. djwebdapp-0.6.8/src/djwebdapp_example/wait.py +3 -0
  67. djwebdapp-0.6.8/src/djwebdapp_example/wallet_create.py +3 -0
  68. djwebdapp-0.6.8/src/djwebdapp_example_ethereum/__init__.py +0 -0
  69. djwebdapp-0.6.8/src/djwebdapp_example_ethereum/account.py +14 -0
  70. djwebdapp-0.6.8/src/djwebdapp_example_ethereum/admin.py +3 -0
  71. djwebdapp-0.6.8/src/djwebdapp_example_ethereum/apps.py +6 -0
  72. djwebdapp-0.6.8/src/djwebdapp_example_ethereum/blockchain.py +12 -0
  73. djwebdapp-0.6.8/src/djwebdapp_example_ethereum/blockchain_with_event_provider.py +11 -0
  74. djwebdapp-0.6.8/src/djwebdapp_example_ethereum/client.py +9 -0
  75. djwebdapp-0.6.8/src/djwebdapp_example_ethereum/deploy.py +10 -0
  76. djwebdapp-0.6.8/src/djwebdapp_example_ethereum/deploy_contract.py +40 -0
  77. djwebdapp-0.6.8/src/djwebdapp_example_ethereum/deploy_model.py +42 -0
  78. djwebdapp-0.6.8/src/djwebdapp_example_ethereum/index.py +29 -0
  79. djwebdapp-0.6.8/src/djwebdapp_example_ethereum/load.py +2 -0
  80. djwebdapp-0.6.8/src/djwebdapp_example_ethereum/migrations/0001_initial.py +48 -0
  81. djwebdapp-0.6.8/src/djwebdapp_example_ethereum/migrations/0002_fa12ethereumbalancemovement.py +52 -0
  82. djwebdapp-0.6.8/src/djwebdapp_example_ethereum/migrations/__init__.py +0 -0
  83. djwebdapp-0.6.8/src/djwebdapp_example_ethereum/mint_normalize.py +54 -0
  84. djwebdapp-0.6.8/src/djwebdapp_example_ethereum/models.py +108 -0
  85. djwebdapp-0.6.8/src/djwebdapp_example_ethereum/normalize.py +17 -0
  86. djwebdapp-0.6.8/src/djwebdapp_example_ethereum/normalizers.py +51 -0
  87. djwebdapp-0.6.8/src/djwebdapp_example_ethereum/tests.py +3 -0
  88. djwebdapp-0.6.8/src/djwebdapp_example_ethereum/transfer.py +12 -0
  89. djwebdapp-0.6.8/src/djwebdapp_example_ethereum/views.py +3 -0
  90. djwebdapp-0.6.8/src/djwebdapp_example_ethereum/wallet_import.py +31 -0
  91. djwebdapp-0.6.8/src/djwebdapp_example_tezos/Proxy.py +30 -0
  92. djwebdapp-0.6.8/src/djwebdapp_example_tezos/__init__.py +0 -0
  93. djwebdapp-0.6.8/src/djwebdapp_example_tezos/account.py +14 -0
  94. djwebdapp-0.6.8/src/djwebdapp_example_tezos/admin.py +3 -0
  95. djwebdapp-0.6.8/src/djwebdapp_example_tezos/apps.py +6 -0
  96. djwebdapp-0.6.8/src/djwebdapp_example_tezos/blockchain.py +10 -0
  97. djwebdapp-0.6.8/src/djwebdapp_example_tezos/call_parallel.py +35 -0
  98. djwebdapp-0.6.8/src/djwebdapp_example_tezos/callee.json +622 -0
  99. djwebdapp-0.6.8/src/djwebdapp_example_tezos/callee.py +23 -0
  100. djwebdapp-0.6.8/src/djwebdapp_example_tezos/caller.json +678 -0
  101. djwebdapp-0.6.8/src/djwebdapp_example_tezos/caller.py +22 -0
  102. djwebdapp-0.6.8/src/djwebdapp_example_tezos/client.py +6 -0
  103. djwebdapp-0.6.8/src/djwebdapp_example_tezos/contracts/FA12.json +1510 -0
  104. djwebdapp-0.6.8/src/djwebdapp_example_tezos/contracts/FA12.py +34 -0
  105. djwebdapp-0.6.8/src/djwebdapp_example_tezos/deploy.py +15 -0
  106. djwebdapp-0.6.8/src/djwebdapp_example_tezos/deploy_client.py +5 -0
  107. djwebdapp-0.6.8/src/djwebdapp_example_tezos/deploy_contract.py +46 -0
  108. djwebdapp-0.6.8/src/djwebdapp_example_tezos/deploy_model.py +43 -0
  109. djwebdapp-0.6.8/src/djwebdapp_example_tezos/index.py +33 -0
  110. djwebdapp-0.6.8/src/djwebdapp_example_tezos/load.py +12 -0
  111. djwebdapp-0.6.8/src/djwebdapp_example_tezos/migrations/0001_initial.py +48 -0
  112. djwebdapp-0.6.8/src/djwebdapp_example_tezos/migrations/__init__.py +0 -0
  113. djwebdapp-0.6.8/src/djwebdapp_example_tezos/mint_normalize.py +54 -0
  114. djwebdapp-0.6.8/src/djwebdapp_example_tezos/models.py +59 -0
  115. djwebdapp-0.6.8/src/djwebdapp_example_tezos/normalize.py +23 -0
  116. djwebdapp-0.6.8/src/djwebdapp_example_tezos/normalize_old.py +13 -0
  117. djwebdapp-0.6.8/src/djwebdapp_example_tezos/normalizers.py +25 -0
  118. djwebdapp-0.6.8/src/djwebdapp_example_tezos/tests.py +3 -0
  119. djwebdapp-0.6.8/src/djwebdapp_example_tezos/transfer.py +21 -0
  120. djwebdapp-0.6.8/src/djwebdapp_example_tezos/views.py +3 -0
  121. djwebdapp-0.6.8/src/djwebdapp_example_tezos/wallet_import.py +19 -0
  122. djwebdapp-0.6.8/src/djwebdapp_fa2/__init__.py +0 -0
  123. djwebdapp-0.6.8/src/djwebdapp_fa2/admin.py +0 -0
  124. djwebdapp-0.6.8/src/djwebdapp_fa2/apps.py +6 -0
  125. djwebdapp-0.6.8/src/djwebdapp_fa2/migrations/0001_initial.py +169 -0
  126. djwebdapp-0.6.8/src/djwebdapp_fa2/migrations/__init__.py +0 -0
  127. djwebdapp-0.6.8/src/djwebdapp_fa2/models.py +106 -0
  128. djwebdapp-0.6.8/src/djwebdapp_fa2/normalizers.py +70 -0
  129. djwebdapp-0.6.8/src/djwebdapp_fa2/serializers.py +17 -0
  130. djwebdapp-0.6.8/src/djwebdapp_fa2/urls.py +14 -0
  131. djwebdapp-0.6.8/src/djwebdapp_fa2/views.py +33 -0
  132. djwebdapp-0.6.8/src/djwebdapp_multisig/__init__.py +0 -0
  133. djwebdapp-0.6.8/src/djwebdapp_multisig/admin.py +6 -0
  134. djwebdapp-0.6.8/src/djwebdapp_multisig/apps.py +6 -0
  135. djwebdapp-0.6.8/src/djwebdapp_multisig/migrations/0001_initial.py +79 -0
  136. djwebdapp-0.6.8/src/djwebdapp_multisig/migrations/__init__.py +0 -0
  137. djwebdapp-0.6.8/src/djwebdapp_multisig/models.py +41 -0
  138. djwebdapp-0.6.8/src/djwebdapp_rest_framework/__init__.py +0 -0
  139. djwebdapp-0.6.8/src/djwebdapp_rest_framework/apps.py +6 -0
  140. djwebdapp-0.6.8/src/djwebdapp_rest_framework/migrations/__init__.py +0 -0
  141. djwebdapp-0.6.8/src/djwebdapp_rest_framework/models.py +0 -0
  142. djwebdapp-0.6.8/src/djwebdapp_rest_framework/views.py +125 -0
  143. djwebdapp-0.6.8/src/djwebdapp_tezos/__init__.py +0 -0
  144. djwebdapp-0.6.8/src/djwebdapp_tezos/admin.py +10 -0
  145. djwebdapp-0.6.8/src/djwebdapp_tezos/management/__init__.py +0 -0
  146. djwebdapp-0.6.8/src/djwebdapp_tezos/management/commands/__init__.py +0 -0
  147. djwebdapp-0.6.8/src/djwebdapp_tezos/migrations/0001_initial.py +25 -0
  148. djwebdapp-0.6.8/src/djwebdapp_tezos/migrations/0002_tezostransaction_caller.py +24 -0
  149. djwebdapp-0.6.8/src/djwebdapp_tezos/migrations/0003_tezoscall_tezoscontract.py +33 -0
  150. djwebdapp-0.6.8/src/djwebdapp_tezos/migrations/0004_delete_tezoscall_delete_tezoscontract.py +19 -0
  151. djwebdapp-0.6.8/src/djwebdapp_tezos/migrations/0005_tezoscall_tezoscontract.py +33 -0
  152. djwebdapp-0.6.8/src/djwebdapp_tezos/migrations/__init__.py +0 -0
  153. djwebdapp-0.6.8/src/djwebdapp_tezos/models.py +150 -0
  154. djwebdapp-0.6.8/src/djwebdapp_tezos/provider.py +478 -0
  155. djwebdapp-0.6.8/tests/test_rest_framework.py +96 -0
  156. djwebdapp-0.6.8/tests/test_transaction.py +75 -0
  157. djwebdapp-0.6.8/tests/test_txgraph.py +40 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Pyratzlabs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,2 @@
1
+ include *.rst
2
+ recursive-include src *.html *.css *.js *.py *.json
@@ -0,0 +1,191 @@
1
+ Metadata-Version: 2.4
2
+ Name: djwebdapp
3
+ Version: 0.6.8
4
+ Home-page: https://yourlabs.io/oss/djwebdapp
5
+ Author: James Pic
6
+ Author-email: jamespic@gmail.com
7
+ License: MIT
8
+ Keywords: cli
9
+ Requires-Python: >=3.8
10
+ Description-Content-Type: text/x-rst
11
+ License-File: LICENSE
12
+ Requires-Dist: django-model-utils
13
+ Requires-Dist: djfernet>=0.8.1
14
+ Requires-Dist: django-picklefield>=3.0.1
15
+ Requires-Dist: networkx==2.8.8
16
+ Requires-Dist: mnemonic
17
+ Provides-Extra: test
18
+ Requires-Dist: django; extra == "test"
19
+ Requires-Dist: djangorestframework; extra == "test"
20
+ Requires-Dist: pytest; extra == "test"
21
+ Requires-Dist: pytest-cov; extra == "test"
22
+ Requires-Dist: pytest-django; extra == "test"
23
+ Requires-Dist: web3<=6.20,>=6.7.0; extra == "test"
24
+ Requires-Dist: eth-typing<5; extra == "test"
25
+ Provides-Extra: ethereum
26
+ Requires-Dist: web3<=6.20,>=6.7.0; extra == "ethereum"
27
+ Requires-Dist: eth-typing<5; extra == "ethereum"
28
+ Provides-Extra: tezos
29
+ Requires-Dist: pytezos>3.4; extra == "tezos"
30
+ Requires-Dist: pymich>=0.9.8; extra == "tezos"
31
+ Provides-Extra: binary
32
+ Requires-Dist: pysodium; extra == "binary"
33
+ Requires-Dist: secp256k1; extra == "binary"
34
+ Requires-Dist: fastecdsa; extra == "binary"
35
+ Provides-Extra: all
36
+ Requires-Dist: django; extra == "all"
37
+ Requires-Dist: djangorestframework; extra == "all"
38
+ Requires-Dist: pytest; extra == "all"
39
+ Requires-Dist: pytest-cov; extra == "all"
40
+ Requires-Dist: pytest-django; extra == "all"
41
+ Requires-Dist: web3<=6.20,>=6.7.0; extra == "all"
42
+ Requires-Dist: eth-typing<5; extra == "all"
43
+ Requires-Dist: web3<=6.20,>=6.7.0; extra == "all"
44
+ Requires-Dist: eth-typing<5; extra == "all"
45
+ Requires-Dist: pytezos>3.4; extra == "all"
46
+ Requires-Dist: pymich>=0.9.8; extra == "all"
47
+ Requires-Dist: django; extra == "all"
48
+ Requires-Dist: djangorestframework; extra == "all"
49
+ Requires-Dist: pytest; extra == "all"
50
+ Requires-Dist: pytest-cov; extra == "all"
51
+ Requires-Dist: pytest-django; extra == "all"
52
+ Requires-Dist: web3<=6.20,>=6.7.0; extra == "all"
53
+ Requires-Dist: eth-typing<5; extra == "all"
54
+ Requires-Dist: web3<=6.20,>=6.7.0; extra == "all"
55
+ Requires-Dist: eth-typing<5; extra == "all"
56
+ Requires-Dist: pytezos>3.4; extra == "all"
57
+ Requires-Dist: pymich>=0.9.8; extra == "all"
58
+ Dynamic: author
59
+ Dynamic: author-email
60
+ Dynamic: description
61
+ Dynamic: description-content-type
62
+ Dynamic: home-page
63
+ Dynamic: keywords
64
+ Dynamic: license
65
+ Dynamic: license-file
66
+ Dynamic: provides-extra
67
+ Dynamic: requires-dist
68
+ Dynamic: requires-python
69
+
70
+ djWebdApp
71
+ ~~~~~~~~~
72
+
73
+ `**Documentation**
74
+ <https://djwebdapp.rtfd.io>`_
75
+
76
+ Django is a great web application framework "for perfectionists with deadlines".
77
+
78
+ A dApp is an app running on the blockchain: a smart contract on which users can
79
+ call functions on.
80
+
81
+ This module provides blockchain support for Django, for reading and/or writing
82
+ the blockchain, with the following features usable independently:
83
+
84
+ * blockchain indexer
85
+ * private key vault
86
+ * blockchain writer
87
+ * blockchain data normalization
88
+ * multiple blockchain support (tezos & ethereum so far)
89
+ * inter-blockchain contract synchronisation
90
+ * metamask authentication backend (TBA)
91
+
92
+ In addition to these features, djWebdApp differenciates itself from indexers
93
+ like dipdup because it is extensible: it's just a module you add to your Django
94
+ project like any other Django App, in which you can add models, endpoints, and
95
+ have an admin interface for free, and so on, benefiting from the `vast Django
96
+ ecosystem of apps <https://djangopackages.org/>`_.
97
+
98
+ Video demos
99
+ ===========
100
+
101
+ - `Tezos tutorial demo
102
+ <https://www.youtube.com/watch?v=quSX-gJ6eow>`_
103
+ - `Ethereum tutorial demo
104
+ <https://www.youtube.com/watch?v=oTjvnjB_8Tc>`_
105
+
106
+ Getting started
107
+ ===============
108
+
109
+ Django basics
110
+ -------------
111
+
112
+ If you are not familiar with the Django development framework, it is
113
+ recommended you follow `their tutorial first
114
+ <https://docs.djangoproject.com/en/4.0/intro/tutorial01/>`_, even though you
115
+ can go through this tutorial copy/pasting your way.
116
+
117
+ You may use the demo project or create your own and install djwebdapp there.
118
+
119
+ Install
120
+ -------
121
+
122
+ To install djwebdapp with all optional dependencies::
123
+
124
+ pip install djwebdapp[all][binary]
125
+
126
+ Don't use ``[binary]`` right there if you prefer to install compiled python
127
+ packages from your system package manager.
128
+
129
+ See setup.py's extra_requires for other possibilities.
130
+
131
+ Demo project
132
+ ------------
133
+
134
+ For this tutorial, we'll use the ``djwebdapp_demo`` project:
135
+
136
+ .. code-block:: bash
137
+
138
+ git clone https://yourlabs.io/oss/djwebdapp.git
139
+ cd djwebdapp
140
+ pip install --editable .[all][binary]
141
+ ./manage.py migrate
142
+ ./manage.py shell
143
+
144
+ .. _Local blockchains:
145
+
146
+ Local blockchains
147
+ -----------------
148
+
149
+ Instead of using mainnets for development, we're going to use a local
150
+ blockchains, so that we can work completely locally.
151
+
152
+ We provide a ``docker-compose.yml`` in the root directory of this repository,
153
+ run ``docker-compose up`` to start it.
154
+
155
+ As some of us will also want to convert this to `GitLab-CI
156
+ services <https://docs.gitlab.com/ee/ci/services/>`_\ , we'll refer to our services
157
+ by hostname from now on, which is why we add the following to
158
+ ``/etc/hosts``::
159
+
160
+ 127.0.0.1 tzlocal tzkt-api ethlocal
161
+
162
+ You should then have:
163
+
164
+ - a local ethereum HTTP RPC API on ``ethlocal:8545`` with a WebSocket on
165
+ ``ethlocal:30303``,
166
+ - a local tezos sandbox on ``tzlocal:8732`` which autobakes every second,
167
+ useable like geth development mode.
168
+ - a local tezos indexer to use the contract history download() function.
169
+
170
+ See documentation for **Example contract deployment** in each blockchain
171
+ specific documentation pages for more pointers.
172
+
173
+ Custom project
174
+ --------------
175
+
176
+ Instead of the demo project, you can also create your own project, instead of
177
+ the first step of cloning do:
178
+
179
+ * run ``django-admin startproject your_project_name``
180
+ * in ``your_project_name/your_project_name/settings.py``, add to
181
+ ``INSTALLED_APPS``: ``'djwebdapp', 'djwebdapp_tezos',
182
+ 'djwebdapp_ethereum'``... See ``djwebdapp_demo/settings.py`` for other
183
+ INSTALLED_APPS you can use
184
+ * proceed with the next steps ``migrate`, ``createsuperuser``, ``runserver``
185
+ ...
186
+
187
+ Tutorial
188
+ --------
189
+
190
+ Read documentation `online
191
+ <https://djwebdapp.rtfd.io>`_ or in the ``docs/`` directory.
@@ -0,0 +1,122 @@
1
+ djWebdApp
2
+ ~~~~~~~~~
3
+
4
+ `**Documentation**
5
+ <https://djwebdapp.rtfd.io>`_
6
+
7
+ Django is a great web application framework "for perfectionists with deadlines".
8
+
9
+ A dApp is an app running on the blockchain: a smart contract on which users can
10
+ call functions on.
11
+
12
+ This module provides blockchain support for Django, for reading and/or writing
13
+ the blockchain, with the following features usable independently:
14
+
15
+ * blockchain indexer
16
+ * private key vault
17
+ * blockchain writer
18
+ * blockchain data normalization
19
+ * multiple blockchain support (tezos & ethereum so far)
20
+ * inter-blockchain contract synchronisation
21
+ * metamask authentication backend (TBA)
22
+
23
+ In addition to these features, djWebdApp differenciates itself from indexers
24
+ like dipdup because it is extensible: it's just a module you add to your Django
25
+ project like any other Django App, in which you can add models, endpoints, and
26
+ have an admin interface for free, and so on, benefiting from the `vast Django
27
+ ecosystem of apps <https://djangopackages.org/>`_.
28
+
29
+ Video demos
30
+ ===========
31
+
32
+ - `Tezos tutorial demo
33
+ <https://www.youtube.com/watch?v=quSX-gJ6eow>`_
34
+ - `Ethereum tutorial demo
35
+ <https://www.youtube.com/watch?v=oTjvnjB_8Tc>`_
36
+
37
+ Getting started
38
+ ===============
39
+
40
+ Django basics
41
+ -------------
42
+
43
+ If you are not familiar with the Django development framework, it is
44
+ recommended you follow `their tutorial first
45
+ <https://docs.djangoproject.com/en/4.0/intro/tutorial01/>`_, even though you
46
+ can go through this tutorial copy/pasting your way.
47
+
48
+ You may use the demo project or create your own and install djwebdapp there.
49
+
50
+ Install
51
+ -------
52
+
53
+ To install djwebdapp with all optional dependencies::
54
+
55
+ pip install djwebdapp[all][binary]
56
+
57
+ Don't use ``[binary]`` right there if you prefer to install compiled python
58
+ packages from your system package manager.
59
+
60
+ See setup.py's extra_requires for other possibilities.
61
+
62
+ Demo project
63
+ ------------
64
+
65
+ For this tutorial, we'll use the ``djwebdapp_demo`` project:
66
+
67
+ .. code-block:: bash
68
+
69
+ git clone https://yourlabs.io/oss/djwebdapp.git
70
+ cd djwebdapp
71
+ pip install --editable .[all][binary]
72
+ ./manage.py migrate
73
+ ./manage.py shell
74
+
75
+ .. _Local blockchains:
76
+
77
+ Local blockchains
78
+ -----------------
79
+
80
+ Instead of using mainnets for development, we're going to use a local
81
+ blockchains, so that we can work completely locally.
82
+
83
+ We provide a ``docker-compose.yml`` in the root directory of this repository,
84
+ run ``docker-compose up`` to start it.
85
+
86
+ As some of us will also want to convert this to `GitLab-CI
87
+ services <https://docs.gitlab.com/ee/ci/services/>`_\ , we'll refer to our services
88
+ by hostname from now on, which is why we add the following to
89
+ ``/etc/hosts``::
90
+
91
+ 127.0.0.1 tzlocal tzkt-api ethlocal
92
+
93
+ You should then have:
94
+
95
+ - a local ethereum HTTP RPC API on ``ethlocal:8545`` with a WebSocket on
96
+ ``ethlocal:30303``,
97
+ - a local tezos sandbox on ``tzlocal:8732`` which autobakes every second,
98
+ useable like geth development mode.
99
+ - a local tezos indexer to use the contract history download() function.
100
+
101
+ See documentation for **Example contract deployment** in each blockchain
102
+ specific documentation pages for more pointers.
103
+
104
+ Custom project
105
+ --------------
106
+
107
+ Instead of the demo project, you can also create your own project, instead of
108
+ the first step of cloning do:
109
+
110
+ * run ``django-admin startproject your_project_name``
111
+ * in ``your_project_name/your_project_name/settings.py``, add to
112
+ ``INSTALLED_APPS``: ``'djwebdapp', 'djwebdapp_tezos',
113
+ 'djwebdapp_ethereum'``... See ``djwebdapp_demo/settings.py`` for other
114
+ INSTALLED_APPS you can use
115
+ * proceed with the next steps ``migrate`, ``createsuperuser``, ``runserver``
116
+ ...
117
+
118
+ Tutorial
119
+ --------
120
+
121
+ Read documentation `online
122
+ <https://djwebdapp.rtfd.io>`_ or in the ``docs/`` directory.
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,58 @@
1
+ from setuptools import setup, find_packages
2
+
3
+
4
+ extras_require = dict(
5
+ test=[
6
+ 'django',
7
+ 'djangorestframework',
8
+ 'pytest',
9
+ 'pytest-cov',
10
+ 'pytest-django',
11
+ 'web3>=6.7.0,<=6.20',
12
+ 'eth-typing<5',
13
+ ],
14
+ ethereum=[
15
+ #'web3>=6.7.0', # no [dev] for persistent deployments
16
+ 'web3>=6.7.0,<=6.20',
17
+ 'eth-typing<5',
18
+ ],
19
+ tezos=[
20
+ 'pytezos>3.4',
21
+ 'pymich>=0.9.8',
22
+ ],
23
+ binary=[
24
+ 'pysodium',
25
+ 'secp256k1',
26
+ 'fastecdsa',
27
+ ],
28
+ )
29
+
30
+ extras_require['all'] = []
31
+ for name, deps in extras_require.items():
32
+ if name == 'binary':
33
+ continue
34
+ extras_require['all'] += deps
35
+
36
+
37
+ setup(
38
+ name='djwebdapp',
39
+ version='0.6.8',
40
+ setup_requires='setupmeta',
41
+ packages=find_packages('src'),
42
+ package_dir={'': 'src'},
43
+ install_requires=[
44
+ 'django-model-utils',
45
+ 'djfernet>=0.8.1',
46
+ 'django-picklefield>=3.0.1',
47
+ 'networkx==2.8.8',
48
+ 'mnemonic',
49
+ ],
50
+ extras_require=extras_require,
51
+ author='James Pic',
52
+ author_email='jamespic@gmail.com',
53
+ url='https://yourlabs.io/oss/djwebdapp',
54
+ include_package_data=True,
55
+ license='MIT',
56
+ keywords='cli',
57
+ python_requires='>=3.8',
58
+ )
File without changes
@@ -0,0 +1,104 @@
1
+ from django.contrib import admin
2
+
3
+ from .models import Account, Blockchain, Node, Transaction
4
+
5
+
6
+ @admin.register(Account)
7
+ class AccountAdmin(admin.ModelAdmin):
8
+ search_fields = (
9
+ 'name',
10
+ 'description',
11
+ 'address',
12
+ 'owner__username',
13
+ )
14
+ list_display = (
15
+ 'address',
16
+ 'name',
17
+ 'balance',
18
+ 'blockchain',
19
+ 'last_level',
20
+ )
21
+ list_filter = (
22
+ 'blockchain',
23
+ 'revealed',
24
+ )
25
+ readonly_fields = (
26
+ 'revealed',
27
+ 'counter',
28
+ 'last_level',
29
+ )
30
+
31
+ def get_queryset(self, qs):
32
+ return super().get_queryset(qs).select_related('owner')
33
+
34
+
35
+ @admin.register(Blockchain)
36
+ class BlockchainAdmin(admin.ModelAdmin):
37
+ search_fields = (
38
+ 'name',
39
+ 'description',
40
+ )
41
+ list_display = (
42
+ 'name',
43
+ 'is_active',
44
+ 'min_level',
45
+ 'index_level',
46
+ )
47
+ list_filter = (
48
+ 'is_active',
49
+ )
50
+
51
+
52
+ @admin.register(Node)
53
+ class NodeAdmin(admin.ModelAdmin):
54
+ search_fields = (
55
+ 'name',
56
+ )
57
+ list_display = (
58
+ 'endpoint',
59
+ 'priority',
60
+ 'is_active',
61
+ )
62
+ list_filter = (
63
+ 'is_active',
64
+ 'blockchain',
65
+ )
66
+
67
+
68
+ @admin.register(Transaction)
69
+ class TransactionAdmin(admin.ModelAdmin):
70
+ search_fields = (
71
+ 'name',
72
+ 'description',
73
+ 'function',
74
+ 'hash',
75
+ 'sender__address',
76
+ 'sender__owner__username',
77
+ 'receiver__address',
78
+ 'receiver__owner__username',
79
+ )
80
+ list_display = (
81
+ 'kind',
82
+ 'function',
83
+ 'state',
84
+ 'name',
85
+ 'hash',
86
+ 'address',
87
+ )
88
+ list_filter = (
89
+ 'kind',
90
+ 'state',
91
+ 'blockchain',
92
+ 'created_at',
93
+ 'updated_at',
94
+ )
95
+ readonly_fields = (
96
+ 'gas',
97
+ 'gasprice',
98
+ 'level',
99
+ 'last_fail',
100
+ 'history',
101
+ 'kind',
102
+ 'error',
103
+ 'has_code',
104
+ )
@@ -0,0 +1,9 @@
1
+ from django.apps import AppConfig
2
+ from django.utils.module_loading import autodiscover_modules
3
+
4
+
5
+ class DjwebdappConfig(AppConfig):
6
+ name = 'djwebdapp'
7
+
8
+ def ready(self):
9
+ autodiscover_modules('normalizers')
@@ -0,0 +1,13 @@
1
+
2
+
3
+ class BaseException(Exception):
4
+ """ Base exception class for all exceptions of this package. """
5
+ pass
6
+
7
+
8
+ class PermanentError(BaseException):
9
+ """ Raised when a transaction can not be deployed. """
10
+
11
+
12
+ class TemporaryError(BaseException):
13
+ """ Raised when a transaction has not been deployed. """
File without changes
@@ -0,0 +1,29 @@
1
+ from django.core.management.base import BaseCommand
2
+
3
+ from djwebdapp.models import Blockchain
4
+
5
+
6
+ class Command(BaseCommand):
7
+ help = '''
8
+ Import a contract from tzkt.
9
+
10
+ Example usage:
11
+
12
+ ./manage.py history_download 'Tezos Mainnet' <address>
13
+ '''
14
+
15
+ def add_arguments(self, parser):
16
+ parser.add_argument(
17
+ 'blockchain',
18
+ type=str,
19
+ help='Name of the blockchain to import into'
20
+ )
21
+ parser.add_argument(
22
+ 'target',
23
+ type=str,
24
+ help='Id of the contract to import',
25
+ )
26
+
27
+ def handle(self, *args, **options):
28
+ blockchain = Blockchain.objects.get(name=options['blockchain'])
29
+ blockchain.provider.download(target=options['target'])
@@ -0,0 +1,19 @@
1
+ from django.core.management.base import BaseCommand
2
+
3
+ from djwebdapp.models import Blockchain
4
+
5
+
6
+ class Command(BaseCommand):
7
+ help = 'Synchronize external transactions'
8
+
9
+ def handle(self, *args, **options):
10
+ for blockchain in Blockchain.objects.filter(is_active=True):
11
+ try:
12
+ blockchain.provider.logger.info(f'Indexing {blockchain}')
13
+ blockchain.provider.index()
14
+ except: # noqa
15
+ blockchain.provider.logger.exception(
16
+ f'{blockchain}.provider.index() failure!'
17
+ )
18
+ else:
19
+ print('Found 0 blockchain to index! check is_active')
@@ -0,0 +1,19 @@
1
+ from django.core.management.base import BaseCommand
2
+
3
+ from djwebdapp.models import Blockchain
4
+
5
+
6
+ class Command(BaseCommand):
7
+ help = 'Normalize indexed transactions'
8
+
9
+ def handle(self, *args, **options):
10
+ for blockchain in Blockchain.objects.filter(is_active=True):
11
+ try:
12
+ blockchain.provider.logger.info(f'Normalizing {blockchain}')
13
+ blockchain.provider.normalize()
14
+ except: # noqa
15
+ blockchain.provider.logger.exception(
16
+ f'{blockchain}.normalize() failure!'
17
+ )
18
+ else:
19
+ print('Found 0 blockchain to normalize! check is_active')
@@ -0,0 +1,15 @@
1
+ from django.core.management.base import BaseCommand
2
+
3
+ from djwebdapp.models import Blockchain
4
+
5
+
6
+ class Command(BaseCommand):
7
+ help = 'Synchronize balance'
8
+
9
+ def handle(self, *args, **options):
10
+ for blockchain in Blockchain.objects.all():
11
+ for address in blockchain.account_set.all():
12
+ try:
13
+ address.refresh_balance()
14
+ except Exception as exception:
15
+ blockchain.provider.logger.exception(exception)
@@ -0,0 +1,16 @@
1
+ from django.core.management.base import BaseCommand
2
+
3
+ from djwebdapp.models import Blockchain
4
+
5
+
6
+ class Command(BaseCommand):
7
+ help = 'Synchronize external transactions'
8
+
9
+ def handle(self, *args, **options):
10
+ for blockchain in Blockchain.objects.filter(is_active=True):
11
+ try:
12
+ blockchain.provider.spool()
13
+ except: # noqa
14
+ blockchain.provider.logger.exception(
15
+ f'{blockchain}.provider.spool() failure!'
16
+ )