Exemplo n.º 1
0
async def eth_sendTransaction(transaction):
    '''
    发送未签名的交易
    '''
    formatted_transaction = input_transaction_formatter(transaction)
    res = await meter.send_transaction(formatted_transaction)
    return Success(res)
Exemplo n.º 2
0
async def trace_filter(filter_obj):
    to_blk = filter_obj.get('toBlock', None)
    if (to_blk == 'latest'):
        latest = await meter.get_block('best')
        filter_obj['toBlock'] = latest['number']
    res = await meter.get_trace_filter(filter_obj)
    return Success(res)
Exemplo n.º 3
0
async def eth_getStorageAt(address, position, block_identifier="best"):
    if position.startswith("0x"):
        position = position[2:]
    position = "0x{}".format(position.zfill(64))
    res = await meter.get_storage_at(
        address, position, normalize_block_identifier(block_identifier))
    return Success(res)
Exemplo n.º 4
0
async def eth_getLogs(filter_obj):
    to_blk = filter_obj.get('toBlock', None)
    if (to_blk == 'latest'):
        latest = await meter.get_block('best')
        filter_obj['toBlock'] = latest['number']
    return Success(await
                   meter.get_logs(filter_obj.get("address", None),
                                  input_log_filter_formatter(filter_obj)))
Exemplo n.º 5
0
async def eth_sendRawTransaction(raw):
    '''
    发送已签名的交易
    '''
    res = await meter.send_raw_transaction(raw)
    if 'error' in res and 'code' in res:
        return Error(int(res['code']), res['error'])
    return Success(res['id'])
Exemplo n.º 6
0
async def eth_getTransactionCount(address, block_identifier="best"):
    '''
    ethereum 用来处理 nonce, Meter 不需要
    '''
    # return encode_number(0)
    random.seed(time.time())
    nonce = random.randint(1, 0xffffffff)
    res = encode_number(nonce)
    return Success(res)
Exemplo n.º 7
0
async def eth_getFilterChanges(filter_id):
    res = await meter.get_filter_changes(filter_id)
    return Success(res)
Exemplo n.º 8
0
async def eth_uninstallFilter(filter_id):
    res = meter.uninstall_filter(filter_id)
    return Success(res)
Exemplo n.º 9
0
async def eth_newBlockFilter():
    res = await meter.new_block_filter()
    return Success(res)
Exemplo n.º 10
0
async def net_version():
    res = str(int(meter.get_chainid(), 16))
    return Success(res)
Exemplo n.º 11
0
async def evm_snapshot():
    return Success(encode_number(0))
Exemplo n.º 12
0
async def trace_block(filter_obj):
    res = await meter.get_trace_block(filter_obj)
    return Success(res)
Exemplo n.º 13
0
async def debug_traceTransaction(tx_hash, params):
    return Success(await meter.trace_transaction(tx_hash))
Exemplo n.º 14
0
async def eth_sign(transaction):
    '''
    发送未签名的交易
    '''
    return Success({})
Exemplo n.º 15
0
async def eth_accounts():
    accounts = meter.get_accounts()
    return Success(accounts)
Exemplo n.º 16
0
async def eth_blockNumber():
    res = encode_number(await meter.get_block_number())
    return Success(res)
Exemplo n.º 17
0
async def eth_call(transaction, block_identifier="best"):
    formatted_transaction = input_transaction_formatter(transaction)
    res = await meter.call(formatted_transaction,
                           normalize_block_identifier(block_identifier))
    return Success(res)
Exemplo n.º 18
0
async def eth_estimateGas(transaction):
    formatted_transaction = input_transaction_formatter(transaction)
    result = await meter.estimate_gas(formatted_transaction)
    res = encode_number(result)
    return Success(res)
Exemplo n.º 19
0
async def eth_maxPriorityFeePerGas():
    return Success(encode_number(0))
Exemplo n.º 20
0
async def eth_syncing():
    res = await meter.get_syncing()
    return Success(res)
Exemplo n.º 21
0
async def trace_transaction(filter_obj):
    res = await meter.get_trace_transaction(filter_obj)
    return Success(res)
Exemplo n.º 22
0
async def eth_getBalance(address, block_identifier="best"):
    res = await meter.get_balance(address,
                                  normalize_block_identifier(block_identifier))
    return Success(res)
Exemplo n.º 23
0
async def rpc_modules():
    return Success({
        "eth": "1.0",
        "net": "1.0",
        "web3": "1.0",
    })
Exemplo n.º 24
0
async def eth_getTransactionByHash(tx_hash):
    if tx_hash:
        res = await meter.get_transaction_by_hash(tx_hash)
        return Success(res)
    return Success(None)
Exemplo n.º 25
0
async def debug_storageRangeAt(blk_hash, tx_index, contract_addr, key_start,
                               max_result):
    res = await meter.storage_range_at(blk_hash, tx_index, contract_addr,
                                       key_start, max_result)
    return Success(res)
Exemplo n.º 26
0
async def eth_getTransactionReceipt(tx_hash):
    if tx_hash:
        res = await meter.get_transaction_receipt(tx_hash)
        return Success(res)
    return Success(None)
Exemplo n.º 27
0
async def net_listening():
    return Success(False)
Exemplo n.º 28
0
async def eth_getBlockByHash(block_hash, full_tx=False):
    res = await get_block(block_hash, full_tx)
    return Success(res)
Exemplo n.º 29
0
async def evm_revert(snapshot_idx=None):
    return Success(True)
Exemplo n.º 30
0
async def eth_getBlockByNumber(block_number, full_tx=False):
    res = await get_block(block_number, full_tx)
    return Success(res)