コード例 #1
0
def zchain_address_get_balance(chainId, addr):
    logger.info('Zchain.Address.GetBalance')
    ercchainId = chainId
    chainId = chainId.lower()
    balance = "0"
    if chainId == 'eth':
        balance = eth_utils.eth_get_address_balance(addr, chainId)
    elif 'erc' in chainId:
        #print ercchainId
        asser = None
        if erc_chainId_map.has_key(ercchainId):
            asset = erc_chainId_map[ercchainId]
        if asset == None:
            return error_utils.invalid_chainid_type(chainId)

        temp = {
            'precison': asset['precison'],
            'addr': addr,
            'contract_addr': asset['address']
        }
        balance = eth_utils.eth_get_address_balance(temp, chainId)
    elif chainId == "hc":
        balance = hc_plugin.hc_get_balance(addr)
    elif chainId in sim_btc_utils_all:
        balance = sim_btc_plugin[chainId].sim_btc_get_balance(addr)
    else:
        return error_utils.invalid_chainid_type(chainId)

    return {'chainId': chainId, 'address': addr, 'balance': balance}
コード例 #2
0
ファイル: sim_api.py プロジェクト: HcashOrg/CrossChainMidWare
def zchain_addr_importaddr(chainId, addr):
    logger.info('Zchain.Addr.importAddr')
    if type(chainId) != unicode:
        return error_utils.mismatched_parameter_type('chainId', 'STRING')
    if sim_btc_plugin.has_key(chainId):
        sim_btc_plugin[chainId].sim_btc_import_addr(addr)
    elif chainId == "hc":
        hc_plugin.hc_import_addr(addr)
    elif chainId == "usdt":
        usdt_plugin.omni_import_addr(addr)
    elif chainId.lower() == 'eth':
        if "erc" in addr:
            temp_chainId = chainId.lower()
            pos = addr.find("erc")
            handle_addr = addr[0:pos]
            asset = db.b_eths_address.find_one({'chainId':temp_chainId,'address':handle_addr})
            if asset == None:
                db.b_eths_address.insert({'chainId': temp_chainId, 'address': handle_addr, 'isContractAddress': True})
            else:
                db.b_eths_address.update({'chainId':temp_chainId,'address':handle_addr},{"$set":{ 'isContractAddress': True}})
        else:
            temp_chainId = chainId.lower()
            asset = db.b_eths_address.find_one({'chainId': temp_chainId, 'address': addr})
            if asset == None:
                db.b_eths_address.insert({'chainId': temp_chainId, 'address': addr, 'isContractAddress': False})
            else:
                db.b_eths_address.update({'chainId':temp_chainId,'address':addr},{"$set":{ 'isContractAddress': False}})
        eth_utils.add_guard_address(addr)
    elif ('erc' in chainId.lower()):
        erc_asset = None
        if erc_chainId_map.has_key(chainId):
            erc_asset = erc_chainId_map[chainId]
        if erc_asset != None:
            if "erc" in addr:
                pos = addr.find("erc")
                handle_addr = addr[0:pos]
                asset = db.b_eths_address.find_one({'chainId': chainId, 'address': handle_addr})
                if asset == None:
                    db.b_eths_address.insert(
                        {'chainId': chainId, 'address': handle_addr, 'isContractAddress': True})
                else:
                    db.b_eths_address.update({'chainId': chainId, 'address': handle_addr},
                                             {"$set": {'isContractAddress': True}})
            else:
                asset = db.b_eths_address.find_one({'chainId': chainId, 'address': addr})
                if asset == None:
                    db.b_eths_address.insert(
                        {'chainId': chainId, 'address': addr, 'isContractAddress': False})
                else:
                    db.b_eths_address.update({'chainId': chainId, 'address': addr},
                                             {"$set": {'isContractAddress': False}})
            eth_utils.add_guard_address(addr)
    else:
        return error_utils.invalid_chainid_type(chainId)
    return {
        'chainId': chainId,
        'data': ""
    }
コード例 #3
0
ファイル: sim_api.py プロジェクト: HcashOrg/CrossChainMidWare
def zchain_Addr_GetAddErc(chainId,addr,precison):
    logger.info('Zchain.Addr.GetAddErc')

    if type(chainId) != unicode:
        return error_utils.mismatched_parameter_type('chainId', 'STRING')
    asset = None
    if erc_chainId_map.has_key(chainId):
        asset = erc_chainId_map[chainId]

    if asset is None:
        return {}
    else:
        return{
            'chainId':asset['chainId'],
            'address':asset['address'],
            'precision':asset['precison']
        }
コード例 #4
0
ファイル: sim_api.py プロジェクト: HcashOrg/CrossChainMidWare
def zchain_EthCall(chainId,callData,blockheight):
    logger.info('Zchain.EthCall')
    chainId = chainId.lower()
    if type(chainId) != unicode:
        return error_utils.mismatched_parameter_type('chainId', 'STRING')
    ercchainId = chainId
    if chainId == 'eth':
      ret = eth_utils.eth_call(callData,blockheight)
      return ret
    elif 'erc' in chainId:
        #print ercchainId
        asset = None
        if erc_chainId_map.has_key(ercchainId):
           asset = erc_chainId_map[ercchainId]
        if asset == None:
            return error_utils.invalid_chainid_type(chainId)

        ret = eth_utils.eth_call(callData, blockheight)
        return ret
    return error_utils.invalid_chainid_type()