Skip to content

Commit

Permalink
Merge pull request #132 from open-format/feature/of-282-deploy-an-erc…
Browse files Browse the repository at this point in the history
…20-token-to-act-as-oft-on-testnet

Feature/of 282 deploy an erc20 token to act as oft on testnet
  • Loading branch information
george-openformat authored Jul 11, 2024
2 parents dabecd1 + 6b75421 commit 89247c2
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ deploy-ERC721LazyDropFacet:; forge script scripts/facet/ERC721LazyDropFacet.s.so
# patch
patch-SettingsFacet:; forge script scripts/facet/SettingsFacet.s.sol:Patch --rpc-url $(rpc) --broadcast $(verbose) $(legacy) $(slow)

# Operations
# All things relating to Open Formats app and $OFT
ops-setup:; make \
confirm-operations-wallet \
ops-CreateOpenFormatApp \
ops-DeployXP \
ops-DeployOFT

ops-CreateOpenFormatApp:; forge script scripts/operations/OpenFormatApp.s.sol:CreateApp --rpc-url $(rpc) --broadcast $(verbose) $(legacy) $(slow)
ops-DeployXP:; forge script scripts/operations/OpenFormatApp.s.sol:DeployXP --rpc-url $(rpc) --broadcast $(verbose) $(legacy) $(slow)
ops-DeployOFT:; forge script scripts/operations/OpenFormatApp.s.sol:DeployOFT --rpc-url $(rpc) --broadcast $(verbose) $(legacy) $(slow)

# helpers

# example: `make CreateApp args="app name" rpc=anvil`
Expand Down Expand Up @@ -185,4 +197,8 @@ update-addPlatformFeeToTokens:; make \
# deploys a new settings facet, replaces exisitng function selectors and adds new ones
# Date: 30.03.23

update-SettingsFacet-ExposeGlobals:; forge script scripts/facet/SettingsFacet.s.sol:Update_ExposeGlobals --rpc-url $(rpc) --broadcast $(verbose) $(legacy) $(slow)
update-SettingsFacet-ExposeGlobals:; forge script scripts/facet/SettingsFacet.s.sol:Update_ExposeGlobals --rpc-url $(rpc) --broadcast $(verbose) $(legacy) $(slow)

# utils - bash scripts
confirm-operations-wallet:; export WALLET_ADDRESS=$$(cast wallet address ${PRIVATE_KEY}) && \
bash bin/confirm-operations-wallet.sh
14 changes: 14 additions & 0 deletions bin/confirm-operations-wallet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
OPERATIONS_WALLET="0x10CE240074E46579E535506B38A2e6E852c49c8E"

if [ "${WALLET_ADDRESS}" = "${OPERATIONS_WALLET}" ]; then
echo "Using operator wallet"
else
echo -e "\nWARNING:\nYou are not using the operations wallet."
read -p "Continue? (Y/n): " confirm
if [[ "$confirm" =~ ^[Yy]$ ]]; then
echo "Continuing..."
else
echo "Script aborted."
exit 1
fi
fi
91 changes: 91 additions & 0 deletions scripts/operations/OpenFormatApp.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.16;

import "forge-std/Script.sol";
import "forge-std/console.sol";
import {Utils} from "scripts/utils/Utils.sol";
import {AppFactory} from "src/factories/App.sol";
import {ERC20FactoryFacet} from "src/facet/ERC20FactoryFacet.sol";
import {CONTRACT_NAME as APP_FACTORY} from "scripts/core/AppFactory.s.sol";

string constant OPEN_FORMAT_APP = "Open_Format_App";
string constant OFT = "OFT";
string constant XP = "XP";

contract CreateApp is Script, Utils {
function run() external {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
address deployerAddress = vm.addr(deployerPrivateKey);

vm.startBroadcast(deployerPrivateKey);
address appFactoryAddress = getContractDeploymentAddress(APP_FACTORY);

if (appFactoryAddress == address(0)) {
revert("Cannot find app factory deployment, make sure it is deployed");
}

// create open format app
address openFormatApp = AppFactory(appFactoryAddress).create("Open Format App", deployerAddress);

vm.stopBroadcast();

exportContractDeployment(OPEN_FORMAT_APP, openFormatApp, block.number);
}
}

contract DeployXP is Script, Utils {
function run() external {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
address deployerAddress = vm.addr(deployerPrivateKey);

address openFormatApp = getContractDeploymentAddress(OPEN_FORMAT_APP);

if (openFormatApp == address(0)) {
revert("Cannot find open format app, make sure it is created");
}

vm.startBroadcast(deployerPrivateKey);

// deploy XP
address xp = ERC20FactoryFacet(openFormatApp).createERC20(
"XP",
"XP",
18,
0,
"Base"
);

vm.stopBroadcast();

exportContractDeployment(XP, xp, block.number);
}
}

contract DeployOFT is Script, Utils {
function run() external {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
address deployerAddress = vm.addr(deployerPrivateKey);

address openFormatApp = getContractDeploymentAddress(OPEN_FORMAT_APP);

if (openFormatApp == address(0)) {
revert("Cannot find open format app, make sure it is created");
}

vm.startBroadcast(deployerPrivateKey);

// deploy OFT
address oft = ERC20FactoryFacet(openFormatApp).createERC20(
"Open Format Token",
"OFT",
18,
100_000,
"Base"
);

vm.stopBroadcast();

exportContractDeployment(OFT, oft, block.number);
}
}

0 comments on commit 89247c2

Please sign in to comment.