How to use the vyper.compiler function in vyper

To help you get started, we’ve selected a few vyper examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ltfschoen / vyper-test / tests / contracts / auctions / test_simple_open_auction.py View on Github external
def auction_tester(t):
    from vyper import compiler
    t.languages['vyper'] = compiler.Compiler()
    contract_code = open('contracts/auctions/simple_open_auction.v.py').read()
    t.c = t.s.contract(contract_code, language='vyper', args=[t.accounts[0], FIVE_DAYS])
    return t
github vyperlang / vyper / tests / parser / syntax / test_timestamp_timedelta.py View on Github external
def test_timestamp_success(good_code):
    assert compiler.compile_code(good_code) is not None
github vyperlang / vyper / tests / parser / syntax / test_unit_exponents.py View on Github external
def test_exponent_fail(bad_code):

    with raises(TypeMismatchException):
        compiler.compile_code(bad_code)
github vyperlang / vyper / tests / parser / syntax / test_send.py View on Github external
def test_send_fail(bad_code):
    with raises(TypeMismatchException):
        compiler.compile_code(bad_code)
github vyperlang / vyper / tests / parser / syntax / test_unbalanced_return.py View on Github external
def test_return_mismatch(bad_code):
    with raises(StructureException):
        compiler.compile_code(bad_code)
github vyperlang / vyper / tests / parser / syntax / utils / test_event_names.py View on Github external
def test_varname_validity_fail(bad_code):
    if isinstance(bad_code, tuple):
        with raises(bad_code[1]):
            compiler.compile_code(bad_code[0])
    else:
        with raises(EventDeclarationException):
            compiler.compile_code(bad_code)
github vyperlang / vyper / tests / parser / syntax / test_ann_assign.py View on Github external
def test_as_wei_fail(bad_code):
    if isinstance(bad_code, tuple):
        with raises(bad_code[1]):
            compiler.compile_code(bad_code[0])
    else:
        with raises(VariableDeclarationException):
            compiler.compile_code(bad_code)
github vyperlang / vyper / tests / parser / exceptions / test_undef_function.py View on Github external
def test_undef_toplevel():
    code = """
@public
def foo():
    x = bar(55)
    """
    with raises(StructureException) as ex:
        compiler.compile(code)
    assert "Not a top-level function: bar" in str(ex.value)
github vyperlang / vyper / tests / parser / syntax / test_structs.py View on Github external
def test_block_fail(bad_code):
    if isinstance(bad_code, tuple):
        with raises(bad_code[1]):
            compiler.compile_code(bad_code[0])
    else:
        with raises(TypeMismatchException):
            compiler.compile_code(bad_code)
github nucypher / Sputnik / demo.py View on Github external
from sputnik.parser import Parser
from vyper import compiler


if __name__ == '__main__':
    #2
    # Setup Sputnik and deploy vyper contract
    SputnikParser = Parser('contracts/otp.sputnik')
    proggy = SputnikParser.get_program()
    sputnik = Sputnik(proggy, None)

    with open('contracts/hasheater.vy', 'r') as f:
        contract_code = f.read()

    contract_bytecode = compiler.compile(contract_code).hex()
    contract_abi = compiler.mk_full_signature(contract_code)
    w3.eth.defaultAccount = w3.eth.accounts[0]

    Contract = w3.eth.contract(abi=contract_abi, bytecode=contract_bytecode)
    tx_hash = Contract.constructor().transact()
    tx_receipt = w3.eth.waitForTransactionReceipt(tx_hash)
    contract = w3.eth.contract(
            address=tx_receipt.contractAddress,
            abi=contract_abi)

    #3
    # Setup numpy (insecure, but it's a hackathon...)
    rng = numpy.random.RandomState()

    #4
    # Setup NuFHE
    secret_key, bootstrap_key = nufhe.make_key_pair(sputnik.thr, rng, transform_type='NTT')