Example #1
0

from flask import Flask
from flask_jsonrpc import JSONRPC
from flask_sqlalchemy import SQLAlchemy
import pymysql
from flask_cors import CORS
from config import setting

pymysql.install_as_MySQLdb()

app = Flask(__name__,template_folder="../")
cors = CORS(app, support_credentials=True)
app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://%s:%s@%s/%s' %(setting.MYSQLDATABASE["user"],
                                                                setting.MYSQLDATABASE["passwd"],
                                                                setting.MYSQLDATABASE["host"],
                                                                setting.MYSQLDATABASE["db_neo_table"])
app.config["SQLALCHEMY_TRACK_MODIFICATIONS"]=True
db = SQLAlchemy(app)
jsonrpc = JSONRPC(app, "/")


from project_log.my_log import setup_mylogger

app_logger = setup_mylogger(logfile="log/runserver.log")

from .controller import *

import time

from web3 import HTTPProvider, Web3

from config import setting
from pymongo import MongoClient
from project_log.my_log import setup_mylogger
from utils.utils import split_to_words

logger = setup_mylogger(logfile="log/add_token_holding.log")




class MongodbEth(object):
    def __init__(self):
        self.client = MongoClient(setting.MONGO_URI)
        self.db= self.client.eth_table







    def get_current_block_number(self):
        return self.db.BookmarkForToken.find_one().get("height")


    def query_token_holding(self,address):
        return self.db.Balance.find_one({"address":address})
import time

from ethereum.utils import checksum_encode
from web3 import Web3, HTTPProvider

from config import setting, ERC20_ABI, ERC20_ABI_EXCEPTION_1, ERC20_ABI_EXCEPTION_2
from pymongo import MongoClient
from project_log.my_log import setup_mylogger
from utils.eth_tool import EthContractService

logger = setup_mylogger(logfile="log/extract_token.log")


class EthRpcClient(object):
    def __init__(self, eth_url):
        self.web3 = Web3(HTTPProvider(eth_url))

    def get_contract_code(self, contract_address):
        contract_address = checksum_encode(contract_address)
        bytecode = self.web3.eth.getCode(contract_address).hex()
        return bytecode

    def get_contract_instance(self, contract_address, abi):
        '''
        获取合约实例
        '''
        contract_address = checksum_encode(contract_address)

        contract = self.web3.eth.contract(address=contract_address, abi=abi)
        return contract
Example #4
0
    get_claimable_from_neoscan, get_unclaimed_from_neoscan, get_tokenholding_from_neoscan, handle_invoke_tx_decimal
from app.model import InvokeTx, ContractTx, Vout, ClaimTx, Token, TokenHolding, Vin, ContractTxMapping, ContractTxDetail
from decimal import Decimal

from sqlalchemy import or_

from config import setting
import binascii

from neo.IO import Helper
from neo.Core import Helper as CoreHelper
from neocore.Cryptography.Crypto import Crypto

from project_log.my_log import setup_mylogger

runserver_logger = setup_mylogger(logfile="runserver.log")


def construct_raw_tx(txData, signature, publicKey):
    rawData = txData + "01" + "41" + "40" + signature + "23" + "21" + publicKey + "ac"
    return rawData


def async_send_raw_tx(rawTx):
    try:
        verify_res = recover_and_verify_tx(rawTx).get("verify")
    except:
        verify_res = False
    if verify_res:
        import threading
        t = threading.Thread(target=send_raw_tx, args=(rawTx, ))  # 创建线程
Example #5
0
import time
from web3 import HTTPProvider, Web3
from config import setting
from pymongo import MongoClient
from project_log.my_log import setup_mylogger
from utils.utils import split_to_words

logger = setup_mylogger(logfile="log/extract_token_holding.log")




class MongodbEth(object):
    def __init__(self):
        self.client = MongoClient(setting.MONGO_URI)
        self.db= self.client.eth_table
        self.db.HandledLogForBalance.create_index([("blockNumber", 1), ("logIndex", 1)], unique=True)
        self.db.Balance.create_index([("address", 1)], unique=True)
        # self.db.TokensOfOwner.create_index([("address", 1)])
        # self.db.TokensOfOwner.create_index([("asset", 1)])
        try:
            self.db.create_collection("HandledLogForBalance", capped=True,size=10000000)
        except Exception as e:
            pass

    def get_handled_log(self,blockNumber,logIndex):
        return self.db.HandledLogForBalance.find_one({"blockNumber":blockNumber,"logIndex":logIndex})

    def insert_handled_log(self,block_number, log_index):
Example #6
0
import time
from web3 import HTTPProvider, Web3
from config import setting
from pymongo import MongoClient
from project_log.my_log import setup_mylogger
from utils.utils import split_to_words

logger = setup_mylogger(logfile="log/{}.log".format(__file__[:-3]))




class MongodbEth(object):
    def __init__(self):
        self.client = MongoClient(setting.MONGO_URI)
        self.db= self.client.eth_table
        self.db.TokensOfOwner.create_index([("address", 1)])
        self.db.TokensOfOwner.create_index([("asset", 1)])
        # try:
        #     self.db.create_collection("HandledLogForBalance", capped=True,size=10000000)
        # except Exception as e:
        #     pass

    def get_handled_log(self,blockNumber,logIndex):
        return self.db.HandledLogForBalance.find_one({"blockNumber":blockNumber,"logIndex":logIndex})

    def insert_handled_log(self,block_number, log_index):

        self.db.HandledLogForBalance.insert_one({"blockNumber":block_number,"logIndex":log_index})