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

feat: auto cheatcodes #8

Merged
merged 15 commits into from
Nov 13, 2023
Merged

feat: auto cheatcodes #8

merged 15 commits into from
Nov 13, 2023

Conversation

dristpunk
Copy link
Contributor

@dristpunk dristpunk commented Nov 2, 2023

Closes BES-108

@dristpunk dristpunk self-assigned this Nov 2, 2023
@gas1cent gas1cent merged commit f37b426 into dev Nov 13, 2023
2 checks passed
@gas1cent gas1cent deleted the feat/auto-cheatcodes branch November 13, 2023 09:29
Copy link

linear bot commented Nov 13, 2023

BES-108 Automatically allow cheatcodes

In solidity you can get the bytecode of a contract that has not yet been deployed via type(Contract).createionCode

https://docs.soliditylang.org/en/latest/units-and-global-variables.html#type-information

We could make a helper for mocks. It would be used like this:

MockOracle _oracle = MockOracle(deployMock('Oracle', type(MockOracle).creationCode));

The helper will be:

function deployMock(string calldata _label, bytes calldata _creationCode) returns(address _deployed)

Inside the helper we can:

  • get the address of the next deployment, using CREATE2
  • rewrite its contents using etch. New content - bytecode that is transferred to the helper
  • use label to set the name of the contract so that it appears in the foundry logs not just as an address
  • return the generated address

@gas1cent gas1cent added this to the v1.0.3 milestone Apr 7, 2024
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.

2 participants