-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from P4-Games/feature/update-deploy-scripts
[feat] added new and fixed deploy scripts & tests
- Loading branch information
Showing
13 changed files
with
393 additions
and
126 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 |
---|---|---|
@@ -0,0 +1,98 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity 0.8.24; | ||
|
||
import {Script, console} from "forge-std/Script.sol"; | ||
import {HelperConfig} from "./HelperConfig.s.sol"; | ||
import {ChatterPay} from "../src/L2/ChatterPay.sol"; | ||
import {ChatterPayWalletFactory} from "../src/L2/ChatterPayWalletFactory.sol"; | ||
import {ChatterPayPaymaster} from "../src/L2/ChatterPayPaymaster.sol"; | ||
import {ChatterPayNFT} from "../src/L2/ChatterPayNFT.sol"; | ||
import {ChatterPayVault} from "../src/L2/ChatterPayVault.sol"; | ||
import {Upgrades} from "openzeppelin-foundry-upgrades/Upgrades.sol"; | ||
|
||
contract DeployAllContracts is Script { | ||
uint256 ethSepoliaChainId = 11155111; | ||
uint256 scrollSepoliaChainId = 534351; | ||
uint256 scrollDevnetChainId = 2227728; | ||
uint256 arbitrumSepoliaChainId = 421614; | ||
|
||
HelperConfig helperConfig; | ||
ChatterPay chatterPay; | ||
ChatterPayWalletFactory factory; | ||
ChatterPayPaymaster paymaster; | ||
ChatterPayNFT chatterPayNFT; | ||
ChatterPayVault vault; | ||
address entryPoint; | ||
address backendEOA; | ||
string NFTBaseUri = "https://back.chatterpay.net/nft/metadata/opensea/"; | ||
|
||
function run() | ||
public | ||
returns ( | ||
HelperConfig, | ||
ChatterPay, | ||
ChatterPayWalletFactory, | ||
ChatterPayNFT, | ||
ChatterPayPaymaster | ||
) | ||
{ | ||
helperConfig = new HelperConfig(); | ||
HelperConfig.NetworkConfig memory config = helperConfig.getConfig(); | ||
entryPoint = config.entryPoint; | ||
backendEOA = config.account; | ||
|
||
vm.startBroadcast(config.account); | ||
|
||
console.log( | ||
"Deploying ChatterPay contracts in chainId %s with account: %s", | ||
block.chainid, | ||
config.account | ||
); | ||
|
||
deployPaymaster(); | ||
deployChatterPay(); | ||
deployFactory(); | ||
deployNFT(); | ||
deployVault(); | ||
|
||
vm.stopBroadcast(); | ||
|
||
return (helperConfig, chatterPay, factory, chatterPayNFT, paymaster); | ||
} | ||
|
||
function deployPaymaster() internal { | ||
paymaster = new ChatterPayPaymaster(entryPoint, backendEOA); | ||
console.log("Paymaster deployed to address %s", address(paymaster)); | ||
} | ||
|
||
function deployChatterPay() internal { | ||
chatterPay = new ChatterPay(); | ||
console.log("ChatterPay Proxy deployed to:", address(chatterPay)); | ||
chatterPay = ChatterPay(payable(chatterPay)); | ||
} | ||
|
||
function deployFactory() internal { | ||
factory = new ChatterPayWalletFactory( | ||
address(chatterPay), | ||
entryPoint, | ||
backendEOA, | ||
address(paymaster) | ||
); | ||
console.log("Factory deployed to:", address(factory)); | ||
} | ||
|
||
function deployNFT() internal { | ||
address proxy = Upgrades.deployUUPSProxy( | ||
"ChatterPayNFT.sol", | ||
abi.encodeCall(ChatterPayNFT.initialize, (backendEOA, NFTBaseUri)) | ||
); | ||
console.log("NFT deployed to:", address(proxy)); | ||
chatterPayNFT = ChatterPayNFT(proxy); | ||
} | ||
|
||
function deployVault() internal { | ||
vault = new ChatterPayVault(); | ||
console.log("Vault deployed to:", address(vault)); | ||
} | ||
} |
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,115 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity 0.8.24; | ||
|
||
import {Script, console} from "forge-std/Script.sol"; | ||
import {HelperConfig} from "./HelperConfig.s.sol"; | ||
import {ChatterPay} from "../src/L2/ChatterPay.sol"; | ||
import {ChatterPayWalletFactory} from "../src/L2/ChatterPayWalletFactory.sol"; | ||
import {ChatterPayPaymaster} from "../src/L2/ChatterPayPaymaster.sol"; | ||
import {TokensPriceFeeds} from "../src/Ethereum/TokensPriceFeeds.sol"; | ||
import {ChatterPayNFT} from "../src/L2/ChatterPayNFT.sol"; | ||
import {Upgrades} from "openzeppelin-foundry-upgrades/Upgrades.sol"; | ||
import {DevOpsTools} from "lib/foundry-devops/src/DevOpsTools.sol"; | ||
|
||
contract DeployChatterPay is Script { | ||
uint256 ethSepoliaChainId = 11155111; | ||
uint256 scrollSepoliaChainId = 534351; | ||
uint256 scrollDevnetChainId = 2227728; | ||
uint256 arbitrumSepoliaChainId = 421614; | ||
|
||
HelperConfig helperConfig; | ||
ChatterPay chatterPay; | ||
ChatterPayWalletFactory factory; | ||
ChatterPayPaymaster paymaster; | ||
TokensPriceFeeds tokensPriceFeeds; | ||
ChatterPayNFT chatterPayNFT; | ||
|
||
address backendEOA = vm.envAddress("BACKEND_EOA"); | ||
|
||
function run() public { | ||
deployChatterPayOnL2(); | ||
} | ||
|
||
function deployChatterPayOnL2() | ||
public | ||
returns ( | ||
HelperConfig, | ||
ChatterPay, | ||
ChatterPayWalletFactory, | ||
TokensPriceFeeds, | ||
ChatterPayNFT, | ||
ChatterPayPaymaster | ||
) | ||
{ | ||
// Deploy HelperConfig | ||
helperConfig = new HelperConfig(); | ||
HelperConfig.NetworkConfig memory config = helperConfig.getConfig(); | ||
|
||
vm.startBroadcast(config.account); | ||
console.log( | ||
"Deploying ChatterPay contracts in chainId %s with account: %s", | ||
block.chainid, | ||
config.account | ||
); | ||
|
||
// Deploy Logic | ||
// CREATE2 for production | ||
// chatterPay = new ChatterPay{ | ||
// salt: keccak256(abi.encodePacked(config.account)) | ||
// }(); | ||
chatterPay = new ChatterPay(); | ||
console.log("ChatterPay deployed to address %s", address(chatterPay)); | ||
|
||
// Deploy Paymaster | ||
// CREATE2 for production | ||
// paymaster = new ChatterPayPaymaster{ | ||
// salt: keccak256(abi.encodePacked(config.account)) | ||
// }(config.account); | ||
address backendSigner = vm.envAddress("BACKEND_EOA"); | ||
paymaster = new ChatterPayPaymaster(config.entryPoint, backendSigner); | ||
console.log("Paymaster deployed to address %s", address(paymaster)); | ||
|
||
// Deploy Factory (with Wallet Implementation, EntryPoint, Account & Paymaster addresses as parameters) | ||
// CREATE2 for production | ||
// factory = new ChatterPayWalletFactory{ | ||
// salt: keccak256(abi.encodePacked(config.account)) | ||
// }(address(chatterPay), config.entryPoint, config.account, paymaster); | ||
factory = new ChatterPayWalletFactory(address(chatterPay), config.entryPoint, config.account, address(paymaster)); | ||
console.log( | ||
"WalletFactory deployed to address %s", | ||
address(factory) | ||
); | ||
|
||
chatterPay.initialize( | ||
config.entryPoint, | ||
config.account, | ||
address(paymaster) | ||
); | ||
console.log("ChatterPay initialized"); | ||
|
||
// Deploy ChatterPayNFT | ||
// main: "https://chatterpay-back-671609149217.us-central1.run.app/" | ||
// dev: "https://chatterpay-back-staging-671609149217.us-central1.run.app/" | ||
string | ||
memory baseURI = "https://chatterpay-back-staging-671609149217.us-central1.run.app/"; | ||
address proxyNFT = Upgrades.deployUUPSProxy( | ||
"ChatterPayNFT.sol", | ||
abi.encodeCall(ChatterPayNFT.initialize, (config.account, baseURI)) | ||
); | ||
|
||
console.log("proxyNFT deployed to address %s", address(proxyNFT)); | ||
chatterPayNFT = ChatterPayNFT(proxyNFT); | ||
|
||
vm.stopBroadcast(); | ||
|
||
return ( | ||
helperConfig, | ||
chatterPay, | ||
factory, | ||
tokensPriceFeeds, | ||
chatterPayNFT, | ||
paymaster | ||
); | ||
} | ||
} |
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,115 +1,36 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity 0.8.24; | ||
pragma solidity ^0.8.0; | ||
|
||
import {Script, console} from "forge-std/Script.sol"; | ||
import {HelperConfig} from "./HelperConfig.s.sol"; | ||
import {ChatterPay} from "../src/L2/ChatterPay.sol"; | ||
import {ChatterPayWalletFactory} from "../src/L2/ChatterPayWalletFactory.sol"; | ||
import {ChatterPayPaymaster} from "../src/L2/ChatterPayPaymaster.sol"; | ||
import {TokensPriceFeeds} from "../src/Ethereum/TokensPriceFeeds.sol"; | ||
import {ChatterPayNFT} from "../src/L2/ChatterPayNFT.sol"; | ||
import {Upgrades} from "openzeppelin-foundry-upgrades/Upgrades.sol"; | ||
import {DevOpsTools} from "lib/foundry-devops/src/DevOpsTools.sol"; | ||
import {HelperConfig} from "./HelperConfig.s.sol"; | ||
import {ChatterPay} from "../src/L2/ChatterPay.sol"; | ||
|
||
contract DeployChatterPay is Script { | ||
uint256 ethSepoliaChainId = 11155111; | ||
uint256 scrollSepoliaChainId = 534351; | ||
uint256 scrollDevnetChainId = 2227728; | ||
uint256 arbitrumSepoliaChainId = 421614; | ||
|
||
HelperConfig helperConfig; | ||
ChatterPay chatterPay; | ||
ChatterPayWalletFactory factory; | ||
ChatterPayPaymaster paymaster; | ||
TokensPriceFeeds tokensPriceFeeds; | ||
ChatterPayNFT chatterPayNFT; | ||
|
||
address backendEOA = vm.envAddress("BACKEND_EOA"); | ||
|
||
function run() public { | ||
deployChatterPayOnL2(); | ||
} | ||
function run() external { | ||
|
||
function deployChatterPayOnL2() | ||
public | ||
returns ( | ||
HelperConfig, | ||
ChatterPay, | ||
ChatterPayWalletFactory, | ||
TokensPriceFeeds, | ||
ChatterPayNFT, | ||
ChatterPayPaymaster | ||
) | ||
{ | ||
// Deploy HelperConfig | ||
helperConfig = new HelperConfig(); | ||
HelperConfig.NetworkConfig memory config = helperConfig.getConfig(); | ||
|
||
vm.startBroadcast(config.account); | ||
console.log( | ||
"Deploying ChatterPay contracts in chainId %s with account: %s", | ||
block.chainid, | ||
config.account | ||
// This will get the address of the most recent deployment of the ChatterPayPaymaster contract | ||
// If you want to set the paymaster to a different address, you can do so here | ||
address paymaster = DevOpsTools.get_most_recent_deployment( | ||
"ChatterPayPaymaster", | ||
block.chainid | ||
); | ||
|
||
// Deploy Logic | ||
// CREATE2 for production | ||
// chatterPay = new ChatterPay{ | ||
// salt: keccak256(abi.encodePacked(config.account)) | ||
// }(); | ||
chatterPay = new ChatterPay(); | ||
console.log("ChatterPay deployed to address %s", address(chatterPay)); | ||
vm.startBroadcast(); | ||
|
||
// Deploy Paymaster | ||
// CREATE2 for production | ||
// paymaster = new ChatterPayPaymaster{ | ||
// salt: keccak256(abi.encodePacked(config.account)) | ||
// }(config.account); | ||
address backendSigner = vm.envAddress("BACKEND_EOA"); | ||
paymaster = new ChatterPayPaymaster(config.entryPoint, backendSigner); | ||
console.log("Paymaster deployed to address %s", address(paymaster)); | ||
|
||
// Deploy Factory (with Wallet Implementation, EntryPoint, Account & Paymaster addresses as parameters) | ||
// CREATE2 for production | ||
// factory = new ChatterPayWalletFactory{ | ||
// salt: keccak256(abi.encodePacked(config.account)) | ||
// }(address(chatterPay), config.entryPoint, config.account, paymaster); | ||
factory = new ChatterPayWalletFactory(address(chatterPay), config.entryPoint, config.account, address(paymaster)); | ||
console.log( | ||
"WalletFactory deployed to address %s", | ||
address(factory) | ||
); | ||
|
||
chatterPay.initialize( | ||
config.entryPoint, | ||
config.account, | ||
address(paymaster) | ||
address proxy = Upgrades.deployUUPSProxy( | ||
"ChatterPay.sol", | ||
abi.encodeCall(ChatterPay.initialize, (config.entryPoint, config.account, paymaster)) | ||
); | ||
console.log("ChatterPay initialized"); | ||
|
||
// Deploy ChatterPayNFT | ||
// main: "https://chatterpay-back-671609149217.us-central1.run.app/" | ||
// dev: "https://chatterpay-back-staging-671609149217.us-central1.run.app/" | ||
string | ||
memory baseURI = "https://chatterpay-back-staging-671609149217.us-central1.run.app/"; | ||
address proxyNFT = Upgrades.deployUUPSProxy( | ||
"ChatterPayNFT.sol", | ||
abi.encodeCall(ChatterPayNFT.initialize, (config.account, baseURI)) | ||
); | ||
|
||
console.log("proxyNFT deployed to address %s", address(proxyNFT)); | ||
chatterPayNFT = ChatterPayNFT(proxyNFT); | ||
console.log("ChatterPay Proxy deployed to:", address(proxy)); | ||
|
||
vm.stopBroadcast(); | ||
|
||
return ( | ||
helperConfig, | ||
chatterPay, | ||
factory, | ||
tokensPriceFeeds, | ||
chatterPayNFT, | ||
paymaster | ||
); | ||
} | ||
} |
Oops, something went wrong.