Skip to content

Commit

Permalink
wtf
Browse files Browse the repository at this point in the history
  • Loading branch information
vemonet committed Feb 22, 2024
1 parent 2e200c8 commit ef4008c
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 5 deletions.
1 change: 1 addition & 0 deletions backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ post-install-commands = [
[tool.hatch.envs.default.scripts]
dev = [
"python src/luce/manage.py migrate",
"python scripts/init_luce_registry.py",
"python src/luce/manage.py runserver localhost:8000 {args}",
]
test = "python src/luce/manage.py test {args}"
Expand Down
5 changes: 3 additions & 2 deletions backend/scripts/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ python /app/src/luce/manage.py migrate
# echo "[email protected] | provider"
# echo "[email protected] | requester"

# python /app/scripts/init_luce_registry.py


echo "🚀 Access the LUCE backend API on http://localhost:8000"


# Start Django on port 8000
python /app/src/luce/manage.py runserver 0.0.0.0:8000



# curl -H "Authorization: XXX" -H "Content-Type: application/json" -X POST http://localhost8000/admin/deployRegistry
28 changes: 28 additions & 0 deletions backend/scripts/init_luce_registry.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import os
from brownie import accounts
from brownie import project, network
import django



p = project.load("brownie", name="BrownieProject")
p.load_config()
network.connect('luce')

from brownie.project.BrownieProject import LUCERegistry

DJANGO_SETTINGS_MODULE = 'lucehome.settings'
os.environ['DJANGO_SETTINGS_MODULE'] = DJANGO_SETTINGS_MODULE
django.setup()

# account[0] as the administrator
contract = LUCERegistry.deploy({'from': accounts[0]})
receipt = contract.tx
if receipt.status == 1:
contract_address = receipt.contract_address
print("Deploy LUCERegistry contract succeeded")
else:
print("Deploy LUCERegistry contract failed")

print(contract_address)
print(receipt.status)
4 changes: 1 addition & 3 deletions backend/src/luce/blockchain/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ def save(self, *args, **kwargs):
super().save(*args, **kwargs)

def deploy(self):
from brownie import accounts
from brownie.project.BrownieProject import PlonkVerifier

# 1. deploy contract
Expand All @@ -125,7 +124,6 @@ class LuceRegistryContract(models.Model):
user = models.ForeignKey(User, on_delete=models.CASCADE)

def deploy(self):
# from brownie import accounts
from brownie.project.BrownieProject import LUCERegistry

# account[0] as the administrator
Expand Down Expand Up @@ -394,7 +392,7 @@ def deploy(self):
print("proof\n" + str(proof['public_signals']))
commitment = {
"public_signals": proof['public_signals']

}

contract = LuceMain.deploy(verifier_address,
Expand Down
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ services:
restart: unless-stopped
volumes:
- ./backend/src:/app/backend/src
- ./backend/scripts:/app/backend/scripts
environment:
# PostgreSQL config
- DJANGO_USE_PSQL=true
Expand Down

0 comments on commit ef4008c

Please sign in to comment.