You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With solidity scripting and deploys on the way (foundry-rs/foundry#1208), a a series of new cheatcodes for sending transactions will be added to the Vm interface. To access these, you'd currently need to have your scripts inherit from Test which is a bit awkward because (1) this is not a test file, and (2) even if you just renamed Test, you still inherit lots of cheatcodes and forge-std methods which can be dangerous for live transactions, and therefore are not desirable to have present in a script.
As a result, I think we should refactor to have abstract contract Script and abstract contract Test is Script, this way scripts can just inherit from Script, and tests can continue to inherit from Test with no breaking changes.
This abstract Script contract will contain:
A minimal Vm interface with just the new broadcast cheatcodes, as well as "view" cheatcodes that don't change state. I may be missing some, but I think this includes: load, addr, getNonce, records, accesses, getCode, and label.
The stdMath library.
The stdStorage library, but with the checked_write methods disabled.
Libraries don't get inherited by default, so we may need to split the last one into stdStorageRead and stdStorage is stdStorageRead (assuming libraries can inherit? I'm not actually sure). Alternatively perhaps we make it into a contract and use a storage var to conditionally disable checked_write based on that, though this would be a breaking change.
The text was updated successfully, but these errors were encountered:
With solidity scripting and deploys on the way (foundry-rs/foundry#1208), a a series of new cheatcodes for sending transactions will be added to the
Vm
interface. To access these, you'd currently need to have your scripts inherit fromTest
which is a bit awkward because (1) this is not a test file, and (2) even if you just renamedTest
, you still inherit lots of cheatcodes and forge-std methods which can be dangerous for live transactions, and therefore are not desirable to have present in a script.As a result, I think we should refactor to have
abstract contract Script
andabstract contract Test is Script
, this way scripts can just inherit fromScript
, and tests can continue to inherit fromTest
with no breaking changes.This abstract
Script
contract will contain:Vm
interface with just the newbroadcast
cheatcodes, as well as "view" cheatcodes that don't change state. I may be missing some, but I think this includes:load
,addr
,getNonce
,records
,accesses
,getCode
, andlabel
.stdMath
library.stdStorage
library, but with thechecked_write
methods disabled.Libraries don't get inherited by default, so we may need to split the last one into
stdStorageRead
andstdStorage is stdStorageRead
(assuming libraries can inherit? I'm not actually sure). Alternatively perhaps we make it into a contract and use a storage var to conditionally disablechecked_write
based on that, though this would be a breaking change.The text was updated successfully, but these errors were encountered: