Skip to content

Commit

Permalink
feat: ignore contract type in repr (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
antazoey authored Aug 10, 2022
1 parent db8580d commit fc96ceb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
16 changes: 8 additions & 8 deletions ethpm_types/abi.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class ConstructorABI(BaseModel):
type: Literal["constructor"]
"""The value ``"constructor"``."""

contract_type: Optional["ContractType"] = Field(None, exclude=True)
contract_type: Optional["ContractType"] = Field(None, exclude=True, repr=False)
"""
A reference to this ABI's contract type. This gets set during ``ContractType``
deserialization.
Expand Down Expand Up @@ -158,7 +158,7 @@ class FallbackABI(BaseModel):
type: Literal["fallback"]
"""The value ``"fallback"``."""

contract_type: Optional["ContractType"] = Field(None, exclude=True)
contract_type: Optional["ContractType"] = Field(None, exclude=True, repr=False)
"""
A reference to this ABI's contract type. This gets set during ``ContractType``
deserialization.
Expand Down Expand Up @@ -196,7 +196,7 @@ class ReceiveABI(BaseModel):
type: Literal["receive"]
"""The value ``"receive"``."""

contract_type: Optional["ContractType"] = Field(None, exclude=True)
contract_type: Optional["ContractType"] = Field(None, exclude=True, repr=False)
"""
A reference to this ABI's contract type. This gets set during ``ContractType``
deserialization.
Expand Down Expand Up @@ -230,7 +230,7 @@ class MethodABI(BaseModel):
type: Literal["function"]
"""The value ``"function"``."""

contract_type: Optional["ContractType"] = Field(None, exclude=True)
contract_type: Optional["ContractType"] = Field(None, exclude=True, repr=False)
"""
A reference to this ABI's contract type. This gets set during ``ContractType``
deserialization.
Expand Down Expand Up @@ -309,7 +309,7 @@ class EventABI(BaseModel):
type: Literal["event"]
"""The value ``"event"``."""

contract_type: Optional["ContractType"] = Field(None, exclude=True)
contract_type: Optional["ContractType"] = Field(None, exclude=True, repr=False)
"""
A reference to this ABI's contract type. This gets set during ``ContractType``
deserialization.
Expand Down Expand Up @@ -353,7 +353,7 @@ class ErrorABI(BaseModel):
type: Literal["error"]
"""The value ``"error"``."""

contract_type: Optional["ContractType"] = Field(None, exclude=True)
contract_type: Optional["ContractType"] = Field(None, exclude=True, repr=False)
"""
A reference to this ABI's contract type. This gets set during ``ContractType``
deserialization.
Expand Down Expand Up @@ -395,7 +395,7 @@ class StructABI(BaseModel):
type: Literal["struct"]
"""The value ``"struct"``."""

contract_type: Optional["ContractType"] = Field(None, exclude=True)
contract_type: Optional["ContractType"] = Field(None, exclude=True, repr=False)
"""
A reference to this ABI's contract type. This gets set during ``ContractType``
deserialization.
Expand Down Expand Up @@ -440,7 +440,7 @@ class UnprocessedABI(BaseModel):
type: str
"""The type name as a string."""

contract_type: Optional["ContractType"] = Field(None, exclude=True)
contract_type: Optional["ContractType"] = Field(None, exclude=True, repr=False)
"""
A reference to this ABI's contract type. This gets set during ``ContractType``
deserialization.
Expand Down
12 changes: 12 additions & 0 deletions tests/test_solidity_and_vyper.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,15 @@ def test_select_by_name_contains(vyper_contract):
assert "NumberChange(uint256,uint256)" in contract_type.events
assert keccak(text="NumberChange(uint256,uint256)") in contract_type.events
assert keccak(text="MadeUpEvent(uint64)") not in contract_type.events


def test_contract_type_excluded_in_repr_abi(vyper_contract):
contract_type = ContractType.parse_obj(vyper_contract)
actual = repr(contract_type.events[0])
assert "contract_type" not in actual

actual = repr(contract_type.mutable_methods[0])
assert "contract_type" not in actual

actual = repr(contract_type.view_methods[0])
assert "contract_type" not in actual

0 comments on commit fc96ceb

Please sign in to comment.