diff --git a/airdrop/__init__.py b/airdrop/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/airdrop/admin.py b/airdrop/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/airdrop/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/airdrop/apps.py b/airdrop/apps.py new file mode 100644 index 0000000..06e8113 --- /dev/null +++ b/airdrop/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class AirdropConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'airdrop' diff --git a/airdrop/migrations/__init__.py b/airdrop/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/airdrop/models.py b/airdrop/models.py new file mode 100644 index 0000000..178ecc9 --- /dev/null +++ b/airdrop/models.py @@ -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 diff --git a/airdrop/tests.py b/airdrop/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/airdrop/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/airdrop/views.py b/airdrop/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/airdrop/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/api/airdrop/__init__.py b/api/airdrop/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/api/airdrop/api_v1.py b/api/airdrop/api_v1.py new file mode 100644 index 0000000..e69de29 diff --git a/hailstone/__init__.py b/hailstone/__init__.py index 650b67a..e69de29 100644 --- a/hailstone/__init__.py +++ b/hailstone/__init__.py @@ -1,4 +0,0 @@ -import pymysql - -pymysql.version_info = (1, 4, 2, "final", 0) -pymysql.install_as_MySQLdb() \ No newline at end of file diff --git a/hailstone/settings.py b/hailstone/settings.py index 0000f81..9f47c6c 100644 --- a/hailstone/settings.py +++ b/hailstone/settings.py @@ -22,6 +22,7 @@ "wallet", "services", "channels", + 'airdrop', ] MIDDLEWARE = [ diff --git a/services/savour_rpc/airdrop_pb2.py b/services/savour_rpc/airdrop_pb2.py new file mode 100644 index 0000000..16ccfa4 --- /dev/null +++ b/services/savour_rpc/airdrop_pb2.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: savourrpc/airdrop.proto +# Protobuf Python Version: 4.25.1 +"""Generated protocol buffer code.""" +from google.protobuf import descriptor as _descriptor +from google.protobuf import descriptor_pool as _descriptor_pool +from google.protobuf import symbol_database as _symbol_database +from google.protobuf.internal import builder as _builder +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from services.savour_rpc import common_pb2 as savourrpc_dot_common__pb2 + + +DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x17savourrpc/airdrop.proto\x12\x11savourrpc.airdrop\x1a\x16savourrpc/common.proto\"Y\n\x10\x44ppLinkPointsReq\x12\x16\n\x0e\x63onsumer_token\x18\x01 \x01(\t\x12\x0c\n\x04type\x18\x02 \x01(\x05\x12\x0f\n\x07\x61\x64\x64ress\x18\x03 \x01(\t\x12\x0e\n\x06points\x18\x04 \x01(\r\"D\n\x10\x44ppLinkPointsRep\x12#\n\x04\x63ode\x18\x01 \x01(\x0e\x32\x15.savourrpc.ReturnCode\x12\x0b\n\x03msg\x18\x02 \x01(\t2s\n\x0e\x41irdropService\x12\x61\n\x13submitDppLinkPoints\x12#.savourrpc.airdrop.DppLinkPointsReq\x1a#.savourrpc.airdrop.DppLinkPointsRep\"\x00\x42\'\n\x14group.savour.airdropZ\x0f./proto/airdropb\x06proto3') + +_globals = globals() +_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals) +_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'savourrpc.airdrop_pb2', _globals) +if _descriptor._USE_C_DESCRIPTORS == False: + _globals['DESCRIPTOR']._options = None + _globals['DESCRIPTOR']._serialized_options = b'\n\024group.savour.airdropZ\017./proto/airdrop' + _globals['_DPPLINKPOINTSREQ']._serialized_start=70 + _globals['_DPPLINKPOINTSREQ']._serialized_end=159 + _globals['_DPPLINKPOINTSREP']._serialized_start=161 + _globals['_DPPLINKPOINTSREP']._serialized_end=229 + _globals['_AIRDROPSERVICE']._serialized_start=231 + _globals['_AIRDROPSERVICE']._serialized_end=346 +# @@protoc_insertion_point(module_scope) diff --git a/services/savour_rpc/airdrop_pb2_grpc.py b/services/savour_rpc/airdrop_pb2_grpc.py new file mode 100644 index 0000000..c5e5a9b --- /dev/null +++ b/services/savour_rpc/airdrop_pb2_grpc.py @@ -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)