-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: pass contract_name to VyperContract #338
Changes from 3 commits
d443a9e
83bfb30
06a6335
2c84cba
ec96cc3
25f81b2
b6c61cb
88a99a0
91ea2ac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -146,8 +146,11 @@ def __init__( | |||||||||||
compiler_data: CompilerData, | ||||||||||||
env: Optional[Env] = None, | ||||||||||||
filename: Optional[str] = None, | ||||||||||||
contract_name: Optional[str] = None, | ||||||||||||
): | ||||||||||||
contract_name = Path(compiler_data.contract_path).stem | ||||||||||||
contract_name = ( | ||||||||||||
contract_name if contract_name else Path(compiler_data.contract_path).stem | ||||||||||||
) | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
super().__init__(contract_name, env, filename) | ||||||||||||
self.compiler_data = compiler_data | ||||||||||||
|
||||||||||||
|
@@ -518,8 +521,9 @@ def __init__( | |||||||||||
created_from: Address = None, | ||||||||||||
filename: str = None, | ||||||||||||
gas=None, | ||||||||||||
contract_name=None, | ||||||||||||
): | ||||||||||||
super().__init__(compiler_data, env, filename) | ||||||||||||
super().__init__(compiler_data, env, filename, contract_name) | ||||||||||||
|
||||||||||||
self.created_from = created_from | ||||||||||||
self._computation = None | ||||||||||||
|
@@ -544,7 +548,11 @@ def __init__( | |||||||||||
addr = Address(override_address) | ||||||||||||
else: | ||||||||||||
addr = self._run_init( | ||||||||||||
*args, value=value, override_address=override_address, gas=gas | ||||||||||||
*args, | ||||||||||||
value=value, | ||||||||||||
override_address=override_address, | ||||||||||||
gas=gas, | ||||||||||||
contract_name=contract_name, | ||||||||||||
) | ||||||||||||
self._address = addr | ||||||||||||
|
||||||||||||
|
@@ -569,7 +577,9 @@ def __init__( | |||||||||||
|
||||||||||||
self.env.register_contract(self._address, self) | ||||||||||||
|
||||||||||||
def _run_init(self, *args, value=0, override_address=None, gas=None): | ||||||||||||
def _run_init( | ||||||||||||
self, *args, value=0, override_address=None, gas=None, contract_name=None | ||||||||||||
): | ||||||||||||
encoded_args = b"" | ||||||||||||
if self._ctor: | ||||||||||||
encoded_args = self._ctor.prepare_calldata(*args) | ||||||||||||
|
@@ -582,6 +592,7 @@ def _run_init(self, *args, value=0, override_address=None, gas=None): | |||||||||||
override_address=override_address, | ||||||||||||
gas=gas, | ||||||||||||
contract=self, | ||||||||||||
contract_name=contract_name, | ||||||||||||
) | ||||||||||||
|
||||||||||||
self._computation = computation | ||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -212,6 +212,7 @@ def deploy( | |
override_address: Optional[_AddressType] = None, | ||
# the calling vyper contract | ||
contract: Any = None, | ||
contract_name: Optional[str] = None, # TODO: This isn't used | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We probably don't need this, we can call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If someone passes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think it would be an error to pass |
||
): | ||
sender = self._get_sender(sender) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -361,7 +361,14 @@ def execute_code( | |
|
||
# OVERRIDES | ||
def deploy( | ||
self, sender=None, gas=None, value=0, bytecode=b"", contract=None, **kwargs | ||
self, | ||
sender=None, | ||
gas=None, | ||
value=0, | ||
bytecode=b"", | ||
contract=None, | ||
contract_name=None, | ||
**kwargs, | ||
): | ||
# reset to latest block for simulation | ||
self._reset_fork() | ||
|
@@ -402,7 +409,11 @@ def deploy( | |
print(f"contract deployed at {create_address}") | ||
|
||
if (deployments_db := get_deployments_db()) is not None: | ||
contract_name = getattr(contract, "contract_name", None) | ||
contract_name = ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why would we want 2 names for the contract? This value There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you mean? This would only set 1 name. It defaults to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yea i don't think contract_name should be passed to env.deploy(). it already exists on the contract object |
||
contract_name | ||
if contract_name | ||
else getattr(contract, "contract_name", None) | ||
) | ||
try: | ||
source_bundle = get_verification_bundle(contract) | ||
except Exception as e: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ pytest | |
pytest-xdist | ||
pytest-cov | ||
sphinx-rtd-theme | ||
requests-cache | ||
|
||
# jupyter | ||
jupyter_server | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should follow the same order as the super class tbh