Skip to content
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: compile ABI-based dependencies at better time #130

Merged
merged 8 commits into from
Aug 30, 2024

Conversation

antazoey
Copy link
Member

@antazoey antazoey commented Aug 22, 2024

What I did

Using dependencies like snekmate for Vyper 0.4 was annoying because Vyper 0.3 range dependencies required being compiled for their abis but not in 0.4 so it is a difficult balance.

This PR compiles ABI-based dependencies at a more apt time, when we are further aware that they are indeed ABI-based dependencies and not site-package based or something else.

How I did it

move stuff around

How to verify it

Use snekmate via config like this:

dependencies:
   - python: snekmate
     config_override:
       contracts_folder: .

Use something in the Token.vy like @Ninjagod1251 did.

compile

ape compile

Should not see warning anymore.
Also it compiles much faster and is cleaner

Checklist

  • Passes all linting checks (pre-commit and CI jobs)
  • New test cases have been added and are passing
  • Documentation has been updated
  • PR title follows Conventional Commit standard (will be automatically included in the changelog)

@antazoey antazoey changed the title fix: remove attempt to compile dependencies fix: compile ABI-based dependencies at better time Aug 23, 2024
@antazoey antazoey marked this pull request as ready for review August 23, 2024 15:24
@Ninjagod1251
Copy link
Contributor

{
  "manifest": "ethpm/3",
  "name": "tmpxea07hsm",
  "version": "0.1.0",
  "meta": {
    "authors": null,
    "license": null,
    "description": null,
    "keywords": null,
    "links": null
  },
  "sources": {
    "contracts/contracts/Token.vy": {
      "urls": [],
      "checksum": null,
      "content": "# pragma version ~=0.4.0\n\"\"\"\n@title `erc20` Module Reference Implementation\n@custom:contract-name erc20_mock\n@license GNU Affero General Public License v3.0 only\n@author pcaversaccio\n\"\"\"\n\n\n# @dev We import and implement the `IERC20` interface,\n# which is a built-in interface of the Vyper compiler.\nfrom ethereum.ercs import IERC20\nimplements: IERC20\n\n\n# @dev We import and implement the `IERC20Detailed` interface,\n# which is a built-in interface of the Vyper compiler.\nfrom ethereum.ercs import IERC20Detailed\nimplements: IERC20Detailed\n\n\n# @dev We import and implement the `IERC20Permit`\n# interface, which is written using standard Vyper\n# syntax.\nfrom snekmate.tokens.interfaces import IERC20Permit\nimplements: IERC20Permit\n\n\n# @dev We import and implement the `IERC5267` interface,\n# which is written using standard Vyper syntax.\nfrom snekmate.utils.interfaces import IERC5267\nimplements: IERC5267\n\n\n# @dev We import and initialise the `ownable` module.\nfrom snekmate.auth import ownable as ow\ninitializes: ow\n\n\n# @dev We import and initialise the `erc20` module.\nfrom snekmate.tokens import erc20\ninitializes: erc20[ownable := ow]\n\nexports: erc20.__interface__\n\n\n# @dev The following two parameters are required for the Echidna\n# fuzzing test integration: https://github.com/crytic/properties.\nisMintableOrBurnable: public(constant(bool)) = True\ninitialSupply: public(uint256)\n\n\n@deploy\n@payable\ndef __init__(name_: String[25], symbol_: String[5], decimals_: uint8, initial_supply_: uint256, name_eip712_: String[50], version_eip712_: String[20]):\n    \"\"\"\n    @dev To omit the opcodes for checking the `msg.value`\n         in the creation-time EVM bytecode, the constructor\n         is declared as `payable`.\n    @notice The initial supply of the token as well\n            as the `owner` role will be assigned to\n            the `msg.sender`.\n    @param name_ The maximum 25-character user-readable\n           string name of the token.\n    @param symbol_ The maximum 5-character user-readable\n           string symbol of the token.\n    @param decimals_ The 1-byte decimal places of the token.\n    @param initial_supply_ The 32-byte non-decimalised initial\n           supply of the token.\n    @param name_eip712_ The maximum 50-character user-readable\n           string name of the signing domain, i.e. the name\n           of the dApp or protocol.\n    @param version_eip712_ The maximum 20-character current\n           main version of the signing domain. Signatures\n           from different versions are not compatible.\n    \"\"\"\n    # The following line assigns the `owner`\n    # to the `msg.sender`.\n    ow.__init__()\n    erc20.__init__(name_, symbol_, decimals_, name_eip712_, version_eip712_)\n\n    # The following line premints an initial token\n    # supply to the `msg.sender`, which takes the\n    # underlying `decimals` value into account.\n    erc20._mint(msg.sender, initial_supply_ * 10 ** convert(decimals_, uint256))\n\n    # We assign the initial token supply required by\n    # the Echidna external harness contract.\n    self.initialSupply = erc20.totalSupply\n\n\n# @dev Duplicate implementation of the `external` function\n# `burn_from` to enable the Echidna tests for the external\n# burnable properties.\n@external\ndef burnFrom(owner: address, amount: uint256):\n    \"\"\"\n    @dev Destroys `amount` tokens from `owner`,\n         deducting from the caller's allowance.\n    @notice Note that `owner` cannot be the\n            zero address. Also, the caller must\n            have an allowance for `owner`'s tokens\n            of at least `amount`.\n    @param owner The 20-byte owner address.\n    @param amount The 32-byte token amount to be destroyed.\n    \"\"\"\n    erc20._spend_allowance(owner, msg.sender, amount)\n    erc20._burn(owner, amount)\n",
      "installPath": null,
      "type": null,
      "license": null,
      "references": null,
      "imports": null
    }
  },
  "contractTypes": {},
  "compilers": null,
  "deployments": {},
  "buildDependencies": {}
}

this is my result, looks like I can compile.

but the

  "contractTypes": {},
  "compilers": null,
  "deployments": {},
  "buildDependencies": {}
}
``` fields are still empty.

@antazoey
Copy link
Member Author

antazoey commented Aug 23, 2024

fields are still empty.

This was just fixing those strange warnings you were seeing, I haven't looked into the missing fields yet.
That being said, it is not empty for me:

 'buildDependencies': {'snekmate': Url('file:///Users/jules/virtualenvs/ape/lib/python3.12/site-packages/snekmate')}}

@antazoey antazoey closed this Aug 23, 2024
@antazoey antazoey reopened this Aug 23, 2024
@antazoey antazoey enabled auto-merge (squash) August 30, 2024 16:13
@antazoey antazoey disabled auto-merge August 30, 2024 16:13
@antazoey antazoey merged commit 6aaa8a9 into ApeWorX:main Aug 30, 2024
11 checks passed
@antazoey antazoey deleted the fix/confusing-error branch August 30, 2024 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants