Skip to content

Commit

Permalink
airdrop grpc server
Browse files Browse the repository at this point in the history
  • Loading branch information
guoshijiang committed Mar 2, 2024
1 parent 047199a commit ab32f76
Show file tree
Hide file tree
Showing 13 changed files with 171 additions and 4 deletions.
Empty file added airdrop/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions airdrop/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions airdrop/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class AirdropConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'airdrop'
Empty file added airdrop/migrations/__init__.py
Empty file.
57 changes: 57 additions & 0 deletions airdrop/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
from django.db import models
from common.models import BaseModel, Asset


TypeChoice = [(x, x) for x in ['BridgeTransfer', 'BridgeStaking']]


class User(BaseModel):
name = models.CharField(
max_length=100,
unique=True,
verbose_name='用户名'
)
photo = models.ImageField(
upload_to='symbol/%Y/%m/%d/',
blank=True,
null=True
)
type = models.CharField(
max_length=100,
choices=TypeChoice,
default="BridgeTransfer",
verbose_name='交易类别'
)
address = models.CharField(
max_length=100,
unique=True,
verbose_name='用户地址'
)

class Meta:
verbose_name = 'User'
verbose_name_plural = verbose_name

def __str__(self):
return self.name

def as_dict(self):
return {
'id': self.id,
'name': self.name,
}


class PointsRecord(BaseModel):
address = models.CharField(
max_length=100,
unique=True,
verbose_name='用户地址'
)

class Meta:
verbose_name = 'PointsRecord'
verbose_name_plural = verbose_name

def __str__(self):
return self.address
3 changes: 3 additions & 0 deletions airdrop/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
3 changes: 3 additions & 0 deletions airdrop/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.shortcuts import render

# Create your views here.
Empty file added api/airdrop/__init__.py
Empty file.
Empty file added api/airdrop/api_v1.py
Empty file.
4 changes: 0 additions & 4 deletions hailstone/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
import pymysql

pymysql.version_info = (1, 4, 2, "final", 0)
pymysql.install_as_MySQLdb()
1 change: 1 addition & 0 deletions hailstone/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"wallet",
"services",
"channels",
'airdrop',
]

MIDDLEWARE = [
Expand Down
32 changes: 32 additions & 0 deletions services/savour_rpc/airdrop_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 66 additions & 0 deletions services/savour_rpc/airdrop_pb2_grpc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""
import grpc

from services.savour_rpc import airdrop_pb2 as savourrpc_dot_airdrop__pb2


class AirdropServiceStub(object):
"""Missing associated documentation comment in .proto file."""

def __init__(self, channel):
"""Constructor.
Args:
channel: A grpc.Channel.
"""
self.submitDppLinkPoints = channel.unary_unary(
'/savourrpc.airdrop.AirdropService/submitDppLinkPoints',
request_serializer=savourrpc_dot_airdrop__pb2.DppLinkPointsReq.SerializeToString,
response_deserializer=savourrpc_dot_airdrop__pb2.DppLinkPointsRep.FromString,
)


class AirdropServiceServicer(object):
"""Missing associated documentation comment in .proto file."""

def submitDppLinkPoints(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')


def add_AirdropServiceServicer_to_server(servicer, server):
rpc_method_handlers = {
'submitDppLinkPoints': grpc.unary_unary_rpc_method_handler(
servicer.submitDppLinkPoints,
request_deserializer=savourrpc_dot_airdrop__pb2.DppLinkPointsReq.FromString,
response_serializer=savourrpc_dot_airdrop__pb2.DppLinkPointsRep.SerializeToString,
),
}
generic_handler = grpc.method_handlers_generic_handler(
'savourrpc.airdrop.AirdropService', rpc_method_handlers)
server.add_generic_rpc_handlers((generic_handler,))


# This class is part of an EXPERIMENTAL API.
class AirdropService(object):
"""Missing associated documentation comment in .proto file."""

@staticmethod
def submitDppLinkPoints(request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None):
return grpc.experimental.unary_unary(request, target, '/savourrpc.airdrop.AirdropService/submitDppLinkPoints',
savourrpc_dot_airdrop__pb2.DppLinkPointsReq.SerializeToString,
savourrpc_dot_airdrop__pb2.DppLinkPointsRep.FromString,
options, channel_credentials,
insecure, call_credentials, compression, wait_for_ready, timeout, metadata)

0 comments on commit ab32f76

Please sign in to comment.