forked from latticexyz/mud
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(examples): add PostDeploy, test examples (latticexyz#725)
* fix(examples): add PostDeploy that tests expect * docs(examples): add test command * ci: test examples * docs(examples): check in example .env * ci: rename example workflow * docs(examples): clarify .env comment a bit more --------- Co-authored-by: Kevin Ingersoll <kingersoll@gmail.com>
- Loading branch information
Showing
6 changed files
with
40 additions
and
5 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
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 |
---|---|---|
|
@@ -9,7 +9,6 @@ yarn.lock | |
.docs | ||
lerna-debug.log | ||
.retype | ||
.env | ||
yarn-error.log | ||
.turbo | ||
|
||
|
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,8 @@ | ||
# This .env file is for demonstration purposes only. | ||
# | ||
# This should usually be excluded via .gitignore and the env vars attached to | ||
# your deployment enviroment, but we're including this here for ease of local | ||
# development. Please do not commit changes to this file! | ||
# | ||
# Anvil default private key: | ||
PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 |
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 |
---|---|---|
|
@@ -5,7 +5,6 @@ bindings/ | |
artifacts/ | ||
abi/ | ||
broadcast/ | ||
.env | ||
|
||
# Ignore all deploy artifacts | ||
deploys/**/*.json | ||
|
24 changes: 24 additions & 0 deletions
24
examples/v2-minimal/packages/contracts/script/PostDeploy.s.sol
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,24 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity >=0.8.0; | ||
|
||
import { Script } from "forge-std/Script.sol"; | ||
import { console } from "forge-std/console.sol"; | ||
import { IWorld } from "../src/codegen/world/IWorld.sol"; | ||
|
||
contract PostDeploy is Script { | ||
function run(address worldAddress) external { | ||
// Load the private key from the `PRIVATE_KEY` environment variable (in .env) | ||
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); | ||
|
||
// Start broadcasting transactions from the deployer account | ||
vm.startBroadcast(deployerPrivateKey); | ||
|
||
// ------------------ EXAMPLES ------------------ | ||
|
||
// Call increment on the world via the registered function selector | ||
uint32 newValue = IWorld(worldAddress).increment(); | ||
console.log("Increment via IWorld:", newValue); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
} |