Skip to content

Commit

Permalink
Rename create_with_code_of to create_forwarder_to.
Browse files Browse the repository at this point in the history
  • Loading branch information
jacqueswww committed Mar 5, 2019
1 parent 60c637f commit eeee97d
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion tests/parser/exceptions/test_constancy_exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def foo() -> int128:
@public
@constant
def foo() -> int128:
x = create_with_code_of(0x1234567890123456789012345678901234567890, value=9)
x = create_forwarder_to(0x1234567890123456789012345678901234567890, value=9)
return 5
""",
"""
Expand Down
2 changes: 1 addition & 1 deletion tests/parser/exceptions/test_invalid_literal_exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def foo():
"""
@public
def foo():
x = create_with_code_of(0x123456789012345678901234567890123456789)
x = create_forwarder_to(0x123456789012345678901234567890123456789)
""",
"""
@public
Expand Down
4 changes: 2 additions & 2 deletions tests/parser/exceptions/test_structure_exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def foo():
"""
@public
def foo():
x = create_with_code_of(0x1234567890123456789012345678901234567890, b"cow")
x = create_forwarder_to(0x1234567890123456789012345678901234567890, b"cow")
""",
"""
@public
Expand All @@ -108,7 +108,7 @@ def foo():
"""
@public
def foo():
x = create_with_code_of(0x1234567890123456789012345678901234567890, outsize=4)
x = create_forwarder_to(0x1234567890123456789012345678901234567890, outsize=4)
""",
"""
x: public()
Expand Down
2 changes: 1 addition & 1 deletion tests/parser/features/test_assert.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def test():
code = """
@public
def test():
assert create_with_code_of(self) == 1
assert create_forwarder_to(self) == 1
"""
assert_compile_failed(lambda: get_contract(code), ConstancyViolationException)

Expand Down
10 changes: 5 additions & 5 deletions tests/parser/functions/test_create_with_code_of.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@


def test_create_with_code_of_create(get_contract):
def test_create_forwarder_to_create(get_contract):
code = """
main: address
@public
def test() -> address:
self.main = create_with_code_of(self)
self.main = create_forwarder_to(self)
return self.main
"""

Expand All @@ -15,7 +15,7 @@ def test() -> address:
assert c.test() == '0x4F9DA333DCf4E5A53772791B95c161B2FC041859'


def test_create_with_code_of_call(get_contract, w3):
def test_create_forwarder_to_call(get_contract, w3):
code = """
contract SubContract:
Expand All @@ -28,7 +28,7 @@ def hello() -> bytes[100]: constant
@public
def test() -> address:
self.other = create_with_code_of(self)
self.other = create_forwarder_to(self)
return self.other
Expand Down Expand Up @@ -63,7 +63,7 @@ def hello(a: uint256) -> bytes[100]: constant
@public
def test() -> address:
self.other = create_with_code_of(self)
self.other = create_forwarder_to(self)
return self.other
Expand Down
12 changes: 6 additions & 6 deletions tests/parser/functions/test_raw_call.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from vyper.functions import get_create_with_code_of_bytecode
from vyper.functions import get_create_forwarder_to_bytecode


def test_caller_code(get_contract_with_gas_estimation):
Expand Down Expand Up @@ -36,21 +36,21 @@ def returnten() -> int128:
outer_code = """
@public
def create_and_call_returnten(inp: address) -> int128:
x: address = create_with_code_of(inp)
x: address = create_forwarder_to(inp)
o: int128 = extract32(raw_call(x, convert("\xd0\x1f\xb1\xb8", bytes[4]), outsize=32, gas=50000), 0, type=int128) # noqa: E501
return o
@public
def create_and_return_forwarder(inp: address) -> address:
x: address = create_with_code_of(inp)
x: address = create_forwarder_to(inp)
return x
"""

c2 = get_contract_with_gas_estimation(outer_code)
assert c2.create_and_call_returnten(c.address) == 10
c2.create_and_call_returnten(c.address, transact={})

expected_forwarder_code_mask = get_create_with_code_of_bytecode()[12:]
expected_forwarder_code_mask = get_create_forwarder_to_bytecode()[12:]

c3 = c2.create_and_return_forwarder(c.address, call={})
c2.create_and_return_forwarder(c.address, transact={})
Expand Down Expand Up @@ -78,13 +78,13 @@ def returnten() -> int128:
outer_code = """
@public
def create_and_call_returnten(inp: address) -> int128:
x: address = create_with_code_of(inp)
x: address = create_forwarder_to(inp)
o: int128 = extract32(raw_call(x, convert("\xd0\x1f\xb1\xb8", bytes[4]), outsize=32, gas=50000), 0, type=int128) # noqa: E501
return o
@public
def create_and_return_forwarder(inp: address) -> address:
return create_with_code_of(inp)
return create_forwarder_to(inp)
"""

c2 = get_contract_with_gas_estimation(outer_code)
Expand Down
2 changes: 1 addition & 1 deletion tests/parser/syntax/test_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"""
@public
def foo() -> int128:
x: address = create_with_code_of(
x: address = create_forwarder_to(
0x1234567890123456789012345678901234567890,
value=block.timestamp,
)
Expand Down
8 changes: 4 additions & 4 deletions tests/parser/syntax/test_create_with_code_of.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"""
@public
def foo():
x: address = create_with_code_of(0x1234567890123456789012345678901234567890, value=4, value=9)
x: address = create_forwarder_to(0x1234567890123456789012345678901234567890, value=4, value=9)
"""
]

Expand All @@ -23,20 +23,20 @@ def test_type_mismatch_exception(bad_code):
"""
@public
def foo():
x: address = create_with_code_of(0x1234567890123456789012345678901234567890)
x: address = create_forwarder_to(0x1234567890123456789012345678901234567890)
""",
"""
@public
def foo():
x: address = create_with_code_of(
x: address = create_forwarder_to(
0x1234567890123456789012345678901234567890,
value=as_wei_value(9, "wei")
)
""",
"""
@public
def foo():
x: address = create_with_code_of(0x1234567890123456789012345678901234567890, value=9)
x: address = create_forwarder_to(0x1234567890123456789012345678901234567890, value=9)
"""
]

Expand Down
10 changes: 5 additions & 5 deletions vyper/functions/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1007,7 +1007,7 @@ def shift(expr, args, kwargs, context):
)


def get_create_with_code_of_bytecode():
def get_create_forwarder_to_bytecode():
from vyper.compile_lll import (
assembly_to_evm,
num_to_bytearray
Expand Down Expand Up @@ -1047,7 +1047,7 @@ def get_create_with_code_of_bytecode():


@signature('address', value=Optional('uint256', zero_value))
def create_with_code_of(expr, args, kwargs, context):
def create_forwarder_to(expr, args, kwargs, context):

value = kwargs['value']
if value != zero_value:
Expand All @@ -1060,7 +1060,7 @@ def create_with_code_of(expr, args, kwargs, context):
)
placeholder = context.new_placeholder(ByteArrayType(96))

kode = get_create_with_code_of_bytecode()
kode = get_create_forwarder_to_bytecode()
high = bytes_to_int(kode[:32])
low = bytes_to_int((kode + b'\x00' * 32)[47:79])

Expand Down Expand Up @@ -1159,7 +1159,7 @@ def _clear():
'uint256_addmod': uint256_addmod,
'uint256_mulmod': uint256_mulmod,
'shift': shift,
'create_with_code_of': create_with_code_of,
'create_forwarder_to': create_forwarder_to,
'min': _min,
'max': _max,
}
Expand All @@ -1170,5 +1170,5 @@ def _clear():
'selfdestruct': selfdestruct,
'raw_call': raw_call,
'raw_log': raw_log,
'create_with_code_of': create_with_code_of,
'create_forwarder_to': create_forwarder_to,
}

0 comments on commit eeee97d

Please sign in to comment.