Skip to content

Commit

Permalink
🎨 Enforce PEP 8 Formatting Rules
Browse files Browse the repository at this point in the history
Signed-off-by: Pascal Marco Caversaccio <[email protected]>
  • Loading branch information
pcaversaccio committed Nov 6, 2024
1 parent ba95fee commit e9cb3af
Show file tree
Hide file tree
Showing 32 changed files with 876 additions and 554 deletions.
218 changes: 109 additions & 109 deletions .gas-snapshot

Large diffs are not rendered by default.

252 changes: 126 additions & 126 deletions .gas-snapshot-venom

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion GUIDELINES.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,6 @@ def _as_singleton_array(element: uint256) -> DynArray[uint256, 1]:
- `external` functions
- `internal` functions
- There should be two line breaks between each variable or event declaration or function.
- Code comments should have a maximum line length of 80 characters including blank spaces.
- Each line of code should be limited to a maximum of 120 characters, including spaces.
- Code comments should be confined to a maximum of 80 characters per line, including spaces, with an allowed exception for comments with long URL links.
- For any undocumented behavior, please refer to [🐍Vyper's Official Style Guide](https://docs.vyperlang.org/en/latest/style-guide.html) and/or [PEP 8 – Style Guide for Python Code](https://peps.python.org/pep-0008).
2 changes: 1 addition & 1 deletion lib/create-util
Submodule create-util updated 2 files
+1 −1 package.json
+51 −51 pnpm-lock.yaml
2 changes: 1 addition & 1 deletion lib/forge-std
Submodule forge-std updated 2 files
+65 −0 src/Vm.sol
+1 −1 test/Vm.t.sol
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/snekmate/auth/access_control.vy
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def _grant_role(role: bytes32, account: address):
@param role The 32-byte role definition.
@param account The 20-byte address of the account.
"""
if (not(self.hasRole[role][account])):
if not self.hasRole[role][account]:
self.hasRole[role][account] = True
log IAccessControl.RoleGranted(role=role, account=account, sender=msg.sender)

Expand All @@ -236,6 +236,6 @@ def _revoke_role(role: bytes32, account: address):
@param role The 32-byte role definition.
@param account The 20-byte address of the account.
"""
if (self.hasRole[role][account]):
if self.hasRole[role][account]:
self.hasRole[role][account] = False
log IAccessControl.RoleRevoked(role=role, account=account, sender=msg.sender)
2 changes: 1 addition & 1 deletion src/snekmate/extensions/erc2981.vy
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def royaltyInfo(token_id: uint256, sale_price: uint256) -> (address, uint256):
`sale_price`.
"""
royalty: RoyaltyInfo = self._token_royalty_info[token_id]
if (royalty.receiver == empty(address)):
if royalty.receiver == empty(address):
royalty = self._default_royalty_info

# The following line uses intentionally checked arithmetic to
Expand Down
35 changes: 26 additions & 9 deletions src/snekmate/extensions/erc4626.vy
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,14 @@ _UNDERLYING_DECIMALS: immutable(uint8)

@deploy
@payable
def __init__(name_: String[25], symbol_: String[5], asset_: IERC20, decimals_offset_: uint8, name_eip712_: String[50], version_eip712_: String[20]):
def __init__(
name_: String[25],
symbol_: String[5],
asset_: IERC20,
decimals_offset_: uint8,
name_eip712_: String[50],
version_eip712_: String[20],
):
"""
@dev To omit the opcodes for checking the `msg.value`
in the creation-time EVM bytecode, the constructor
Expand Down Expand Up @@ -324,7 +331,7 @@ def previewMint(shares: uint256) -> uint256:


@external
def mint(shares: uint256, receiver:address) -> uint256:
def mint(shares: uint256, receiver: address) -> uint256:
"""
@dev Mints exactly `shares` vault shares to `receiver` by
depositing `assets` of underlying tokens.
Expand Down Expand Up @@ -459,8 +466,10 @@ def _try_get_underlying_decimals(underlying: IERC20) -> (bool, uint8):
# successful with return data `0x`). Furthermore, it is important
# to note that an external call via `raw_call` does not perform an
# external code size check on the target address.
success, return_data = raw_call(underlying.address, method_id("decimals()"), max_outsize=32, is_static_call=True, revert_on_failure=False)
if (success and (len(return_data) == 32) and (convert(return_data, uint256) <= convert(max_value(uint8), uint256))):
success, return_data = raw_call(
underlying.address, method_id("decimals()"), max_outsize=32, is_static_call=True, revert_on_failure=False
)
if success and len(return_data) == 32 and convert(return_data, uint256) <= convert(max_value(uint8), uint256):
return (True, convert(return_data, uint8))
return (False, empty(uint8))

Expand Down Expand Up @@ -489,7 +498,9 @@ def _convert_to_shares(assets: uint256, roundup: bool) -> uint256:
to round up or not. The default `False` is round down.
@return uint256 The converted 32-byte shares amount.
"""
return math._mul_div(assets, erc20.totalSupply + 10 ** convert(_DECIMALS_OFFSET, uint256), self._total_assets() + 1, roundup)
return math._mul_div(
assets, erc20.totalSupply + 10 ** convert(_DECIMALS_OFFSET, uint256), self._total_assets() + 1, roundup
)


@internal
Expand All @@ -503,7 +514,9 @@ def _convert_to_assets(shares: uint256, roundup: bool) -> uint256:
to round up or not. The default `False` is round down.
@return uint256 The converted 32-byte assets amount.
"""
return math._mul_div(shares, self._total_assets() + 1, erc20.totalSupply + 10 ** convert(_DECIMALS_OFFSET, uint256), roundup)
return math._mul_div(
shares, self._total_assets() + 1, erc20.totalSupply + 10 ** convert(_DECIMALS_OFFSET, uint256), roundup
)


@internal
Expand Down Expand Up @@ -656,7 +669,9 @@ def _deposit(sender: address, receiver: address, assets: uint256, shares: uint25
# always performs an external code size check on the target address unless
# you add the kwarg `skip_contract_check=True`. If the check fails (i.e.
# the target address is an EOA), the call reverts.
assert extcall _ASSET.transferFrom(sender, self, assets, default_return_value=True), "erc4626: transferFrom operation did not succeed"
assert extcall _ASSET.transferFrom(
sender, self, assets, default_return_value=True
), "erc4626: transferFrom operation did not succeed"
erc20._mint(receiver, shares)
log IERC4626.Deposit(sender=sender, owner=receiver, assets=assets, shares=shares)

Expand All @@ -672,7 +687,7 @@ def _withdraw(sender: address, receiver: address, owner: address, assets: uint25
@param assets The 32-byte assets amount.
@param shares The 32-byte shares amount.
"""
if (sender != owner):
if sender != owner:
erc20._spend_allowance(owner, sender, shares)

# If `asset` is an ERC-777, `transfer` can trigger a reentrancy
Expand All @@ -696,5 +711,7 @@ def _withdraw(sender: address, receiver: address, owner: address, assets: uint25
# always performs an external code size check on the target address unless
# you add the kwarg `skip_contract_check=True`. If the check fails (i.e.
# the target address is an EOA), the call reverts.
assert extcall _ASSET.transfer(receiver, assets, default_return_value=True), "erc4626: transfer operation did not succeed"
assert extcall _ASSET.transfer(
receiver, assets, default_return_value=True
), "erc4626: transfer operation did not succeed"
log IERC4626.Withdraw(sender=sender, receiver=receiver, owner=owner, assets=assets, shares=shares)
9 changes: 8 additions & 1 deletion src/snekmate/extensions/mocks/erc4626_mock.vy
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,14 @@ exports: erc4626.__interface__

@deploy
@payable
def __init__(name_: String[25], symbol_: String[5], asset_: IERC20, decimals_offset_: uint8, name_eip712_: String[50], version_eip712_: String[20]):
def __init__(
name_: String[25],
symbol_: String[5],
asset_: IERC20,
decimals_offset_: uint8,
name_eip712_: String[50],
version_eip712_: String[20],
):
"""
@dev To omit the opcodes for checking the `msg.value`
in the creation-time EVM bytecode, the constructor
Expand Down
7 changes: 6 additions & 1 deletion src/snekmate/governance/mocks/timelock_controller_mock.vy
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ exports: tc.__interface__

@deploy
@payable
def __init__(minimum_delay_: uint256, proposers_: DynArray[address, tc._DYNARRAY_BOUND], executors_: DynArray[address, tc._DYNARRAY_BOUND], admin_: address):
def __init__(
minimum_delay_: uint256,
proposers_: DynArray[address, tc._DYNARRAY_BOUND],
executors_: DynArray[address, tc._DYNARRAY_BOUND],
admin_: address,
):
"""
@dev Initialises the contract with the following parameters:
- `minimum_delay_`: The initial minimum delay in seconds
Expand Down
Loading

0 comments on commit e9cb3af

Please sign in to comment.