-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: deploy contracts with
forge script
- Loading branch information
Showing
3 changed files
with
39 additions
and
25 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,29 +1,15 @@ | ||
#!/bin/bash | ||
RPC_URL="http://127.0.0.1:8545" | ||
PK="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" | ||
CONCRETE_FACTORIES=("SingleLevelTournamentFactory" \ | ||
"TopTournamentFactory" \ | ||
"MiddleTournamentFactory" \ | ||
"BottomTournamentFactory") | ||
#!/usr/bin/env bash | ||
|
||
deployed_factories=() | ||
for factory in ${CONCRETE_FACTORIES[@]}; do | ||
deployed_at=`forge create $factory --rpc-url=$RPC_URL --private-key=$PK | \ | ||
grep "Deployed to: " | \ | ||
tr -d '\n' | \ | ||
tail -c 42` | ||
deployed_factories+=($deployed_at) | ||
done | ||
set -euo pipefail | ||
|
||
deployed_at=`forge create TournamentFactory --rpc-url=$RPC_URL --private-key=$PK --constructor-args \ | ||
${deployed_factories[0]} \ | ||
${deployed_factories[1]} \ | ||
${deployed_factories[2]} \ | ||
${deployed_factories[3]} | \ | ||
grep "Deployed to: " | \ | ||
tr -d '\n' | \ | ||
tail -c 42` | ||
INITIAL_HASH=`xxd -p -c32 "${MACHINE_PATH}/hash"` | ||
|
||
initial_hash=`xxd -p -c32 $MACHINE_PATH/hash` | ||
export PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 | ||
|
||
cast send --private-key=$PK --rpc-url=$RPC_URL $deployed_at "instantiateTop(bytes32)" 0x$initial_hash | ||
forge script \ | ||
script/TopTournament.s.sol \ | ||
--fork-url "http://127.0.0.1:8545" \ | ||
--broadcast \ | ||
--sig "run(bytes32)" \ | ||
"${INITIAL_HASH}" \ | ||
-vvvv |
27 changes: 27 additions & 0 deletions
27
permissionless-arbitration/contracts/script/TopTournament.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,27 @@ | ||
// (c) Cartesi and individual authors (see AUTHORS) | ||
// SPDX-License-Identifier: Apache-2.0 (see LICENSE) | ||
|
||
pragma solidity ^0.8.17; | ||
|
||
import {Script} from "forge-std/Script.sol"; | ||
|
||
import {Machine} from "src/Machine.sol"; | ||
|
||
import "src/tournament/factories/TournamentFactory.sol"; | ||
|
||
contract TopTournamentScript is Script { | ||
function run(Machine.Hash initialHash) external { | ||
vm.startBroadcast(vm.envUint("PRIVATE_KEY")); | ||
|
||
TournamentFactory factory = new TournamentFactory( | ||
new SingleLevelTournamentFactory(), | ||
new TopTournamentFactory(), | ||
new MiddleTournamentFactory(), | ||
new BottomTournamentFactory() | ||
); | ||
|
||
factory.instantiateTop(initialHash); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
} |
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