Skip to content

Commit

Permalink
[FEATURE DONE] add scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaojintao97 committed Nov 11, 2024
1 parent bd8d1b5 commit d9043c8
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 1 deletion.
40 changes: 40 additions & 0 deletions script/DeployYumeRelayGate.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// SPDX-License-Identifier: GPL-3.0-or-later

pragma solidity 0.8.14;

import "forge-std/Script.sol";
import { DeploySetting } from "./libraries/DeploySetting.sol";
import { LibDeploy } from "./libraries/LibDeploy.sol";

contract DeployCyberRelayGate is Script, DeploySetting {
function run() external {
_setDeployParams();
vm.startBroadcast();

if (
block.chainid == DeploySetting.OP_SEPOLIA ||
block.chainid == DeploySetting.CYBER_TESTNET
) {
LibDeploy.deployYumeRelayGate(
vm,
deployParams.deployerContract,
deployParams.protocolOwner
);
} else if (
block.chainid == DeploySetting.CYBER ||
block.chainid == DeploySetting.ARBITRUM ||
block.chainid == DeploySetting.OPTIMISM ||
block.chainid == DeploySetting.BLAST ||
block.chainid == DeploySetting.BASE ||
block.chainid == DeploySetting.ETH
) {
LibDeploy.deployYumeRelayGate(
vm,
deployParams.deployerContract,
deployParams.protocolOwner
);
}

vm.stopBroadcast();
}
}
39 changes: 39 additions & 0 deletions script/DeployYumeRelayHook.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// SPDX-License-Identifier: GPL-3.0-or-later

pragma solidity 0.8.14;

import "forge-std/Script.sol";
import { DeploySetting } from "./libraries/DeploySetting.sol";
import { LibDeploy } from "./libraries/LibDeploy.sol";

contract DeployNFTRelayHook is Script, DeploySetting {
function run() external {
_setDeployParams();
vm.startBroadcast();

if (block.chainid == DeploySetting.OP_SEPOLIA ||
block.chainid == DeploySetting.CYBER_TESTNET
) {
LibDeploy.deployYumeRelayHook(
vm,
deployParams.deployerContract,
deployParams.protocolOwner
);
} else if(
block.chainid == DeploySetting.CYBER ||
block.chainid == DeploySetting.ARBITRUM ||
block.chainid == DeploySetting.OPTIMISM ||
block.chainid == DeploySetting.BLAST ||
block.chainid == DeploySetting.BASE ||
block.chainid == DeploySetting.ETH
) {
LibDeploy.deployYumeRelayHook(
vm,
deployParams.deployerContract,
deployParams.protocolOwner
);
}

vm.stopBroadcast();
}
}
46 changes: 46 additions & 0 deletions script/libraries/LibDeploy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ import { CyberMintNFTRelayHook } from "../../src/periphery/CyberMintNFTRelayHook
import { CyberNFT } from "../../src/periphery/CyberNFT.sol";
import { CyberIDPermissionedRelayHook } from "../../src/periphery/CyberIDPermissionedRelayHook.sol";
import { AggregatorV3Interface } from "../../src/interfaces/AggregatorV3Interface.sol";
import {YumeRelayGate} from "../../src/periphery/YumeRelayGate.sol";
import {YumeMintNFTRelayHook} from "../../src/periphery/YumeMintNFTRelayHook.sol";

library LibDeploy {
// create2 deploy all contract with this protocol salt
Expand Down Expand Up @@ -825,6 +827,33 @@ library LibDeploy {
_write(vm, "CyberRelayGate(Proxy)", cyberRelayGateProxy);
}

function deployYumeRelayGate(Vm vm, address _dc, address owner) internal {
Create2Deployer dc = Create2Deployer(_dc);

address yumeRelayGateImpl = dc.deploy(
type(YumeRelayGate).creationCode,
SALT
);

_write(vm, "YumeRelayGate(Impl)", yumeRelayGateImpl);

address yumeRelayGateProxy = dc.deploy(
abi.encodePacked(
type(ERC1967Proxy).creationCode,
abi.encode(
yumeRelayGateImpl,
abi.encodeWithSelector(
CyberRelayGate.initialize.selector,
owner
)
)
),
SALT
);

_write(vm, "YumeRelayGate(Proxy)", yumeRelayGateProxy);
}

function deployCyberNFT(Vm vm, address _dc, address owner) internal {
Create2Deployer dc = Create2Deployer(_dc);
address cyberNFTImpl = dc.deploy(type(CyberNFT).creationCode, SALT);
Expand Down Expand Up @@ -932,6 +961,23 @@ library LibDeploy {
hook.configMintFee(nft, 1, erc20FeeToken, true, recipient, 4 ether);
}

function deployYumeRelayHook(
Vm vm,
address _dc,
address owner
) internal {
Create2Deployer dc = Create2Deployer(_dc);
address yumeRelayHook = dc.deploy(
abi.encodePacked(
type(YumeMintNFTRelayHook).creationCode,
abi.encode(owner)
),
SALT
);

_write(vm, "YumeMintNFTRelayHook", yumeRelayHook);
}

function deployCyberProjectNFTV2(
Vm vm,
address _dc,
Expand Down
2 changes: 1 addition & 1 deletion src/periphery/YumeMintNFTRelayHook.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ contract YumeMintNFTRelayHook is IYumeRelayGateHook, Ownable {
struct MintFeeConfig {
bool enabled;
address recipient;
uint fee;
uint256 fee;
}

struct BatchConfigMintFeeParams {
Expand Down

0 comments on commit d9043c8

Please sign in to comment.