-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: generalizing adder example (#186)
* feat: generalizing adder example * fix: renaming to adhere to the concepts * Use forge-deploy-lib --------- Co-authored-by: Guilherme Dantas <[email protected]>
- Loading branch information
1 parent
e3525db
commit e0ffaa6
Showing
11 changed files
with
61 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
broadcast | ||
cache | ||
deployments.json | ||
deployment.json | ||
exploited | ||
lib | ||
out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
[profile.deploy] | ||
fs_permissions = [ | ||
{ access = "read-write", path = "./deployments.json" }, | ||
{ access = "read-write", path = "./deployment.json" }, | ||
] | ||
|
||
[profile.exploit] | ||
fs_permissions = [ | ||
{ access = "read", path = "./deployments.json" }, | ||
{ access = "read", path = "./deployment.json" }, | ||
] | ||
|
||
[profile.test] | ||
fs_permissions = [ | ||
{ access = "read", path = "./deployments.json" }, | ||
{ access = "read", path = "./deployment.json" }, | ||
{ access = "read-write", path = "./exploited" }, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
pragma solidity ^0.8.27; | ||
|
||
import {DeploymentReaderScript} from "forge-deploy-lib/DeploymentScript.sol"; | ||
|
||
import {IAdder} from "src/IAdder.sol"; | ||
|
||
contract AssertionScript is DeploymentReaderScript { | ||
function run() external { | ||
loadDeployment(); | ||
IAdder adder = IAdder(getContract("Adder")); | ||
if (adder.number() >= 1) return; | ||
vm.writeFile("./exploited", ""); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
pragma solidity ^0.8.27; | ||
|
||
import {DeploymentWriterScript} from "forge-deploy-lib/DeploymentScript.sol"; | ||
|
||
import {SafeAdder} from "src/safe/Adder.sol"; | ||
|
||
contract SetupScript is DeploymentWriterScript { | ||
function run() external { | ||
vm.startBroadcast(); | ||
addContract("Adder", address(new SafeAdder())); | ||
vm.stopBroadcast(); | ||
|
||
storeDeployment(); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
pragma solidity ^0.8.27; | ||
|
||
import {DeploymentWriterScript} from "forge-deploy-lib/DeploymentScript.sol"; | ||
|
||
import {UnsafeAdder} from "src/unsafe/Adder.sol"; | ||
|
||
contract SetupScript is DeploymentWriterScript { | ||
function run() external { | ||
vm.startBroadcast(); | ||
addContract("Adder", address(new UnsafeAdder())); | ||
vm.stopBroadcast(); | ||
|
||
storeDeployment(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters