Skip to content

Commit

Permalink
Merge pull request #50 from P4-Games/feature/update-deploy-scripts
Browse files Browse the repository at this point in the history
removed DeployAllContracts.v2.s.sol
  • Loading branch information
tomasfrancizco authored Dec 31, 2024
2 parents 78e80f5 + ed6d15d commit 256775e
Show file tree
Hide file tree
Showing 11 changed files with 102 additions and 159 deletions.
2 changes: 1 addition & 1 deletion script/DeployAllContracts.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
pragma solidity 0.8.24;

import {Script, console} from "forge-std/Script.sol";
import {HelperConfig} from "./HelperConfig.s.sol";
import {HelperConfig} from "./utils/HelperConfig.s.sol";
import {ChatterPay} from "../src/L2/ChatterPay.sol";
import {ChatterPayWalletFactory} from "../src/L2/ChatterPayWalletFactory.sol";
import {ChatterPayPaymaster} from "../src/L2/ChatterPayPaymaster.sol";
Expand Down
115 changes: 0 additions & 115 deletions script/DeployAllContracts.v2.s.sol

This file was deleted.

23 changes: 2 additions & 21 deletions script/DeployChatterPay.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,15 @@
pragma solidity ^0.8.0;

import {Script, console} from "forge-std/Script.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 {

HelperConfig helperConfig;
function run() external {

helperConfig = new HelperConfig();
HelperConfig.NetworkConfig memory config = helperConfig.getConfig();

// 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
);

vm.startBroadcast();

address proxy = Upgrades.deployUUPSProxy(
"ChatterPay.sol",
abi.encodeCall(ChatterPay.initialize, (config.entryPoint, config.account, paymaster))
);
ChatterPay chatterPay = new ChatterPay();

console.log("ChatterPay Proxy deployed to:", address(proxy));
console.log("ChatterPay implementation deployed to:", address(chatterPay));

vm.stopBroadcast();
}
Expand Down
2 changes: 1 addition & 1 deletion script/DeployFactory.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity ^0.8.0;

import {Script, console} from "forge-std/Script.sol";
import {DevOpsTools} from "lib/foundry-devops/src/DevOpsTools.sol";
import {HelperConfig} from "./HelperConfig.s.sol";
import {HelperConfig} from "./utils/HelperConfig.s.sol";
import {ChatterPayWalletFactory} from "../src/L2/ChatterPayWalletFactory.sol";

// address _walletImplementation,
Expand Down
2 changes: 1 addition & 1 deletion script/DeployNFTs.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity ^0.8.0;

import {Script, console} from "forge-std/Script.sol";
import {Upgrades} from "openzeppelin-foundry-upgrades/Upgrades.sol";
import {HelperConfig} from "./HelperConfig.s.sol";
import {HelperConfig} from "./utils/HelperConfig.s.sol";
import {ChatterPayNFT} from "../src/L2/ChatterPayNFT.sol";

contract DeployChatterPay is Script {
Expand Down
2 changes: 1 addition & 1 deletion script/DeployPaymaster.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pragma solidity ^0.8.0;

import {Script, console} from "forge-std/Script.sol";
import {HelperConfig} from "./HelperConfig.s.sol";
import {HelperConfig} from "./utils/HelperConfig.s.sol";
import {ChatterPayPaymaster} from "../src/L2/ChatterPayPaymaster.sol";

contract DeployChatterPayPaymaster is Script {
Expand Down
36 changes: 36 additions & 0 deletions script/UpdateChatterPay.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {Script, console} from "forge-std/Script.sol";
import {ChatterPayWalletFactory} from "../src/L2/ChatterPayWalletFactory.sol";
import {DevOpsTools} from "lib/foundry-devops/src/DevOpsTools.sol";
import {ChatterPay} from "../src/L2/ChatterPay.sol";

contract UpdateChatterPay is Script {
function run() external {
vm.startBroadcast();

// Change this contract for the new version ChatterPay implementation contract you want to deploy
ChatterPay chatterPay = new ChatterPay();

// This will get the address of the most recent deployment of the ChatterPay Factory contract
// If you want to set the implementation to a different address, you can replace it here
address factoryAddress = DevOpsTools.get_most_recent_deployment(
"ChatterPayWalletFactory",
block.chainid
);

ChatterPayWalletFactory factory = ChatterPayWalletFactory(
factoryAddress
);

factory.setImplementationAddress(address(chatterPay));

console.log(
"ChatterPay implementation updated to %s and updated in the factory",
address(chatterPay)
);

vm.stopBroadcast();
}
}
41 changes: 41 additions & 0 deletions script/UpdateNFTs.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {Script, console} from "forge-std/Script.sol";
import {Upgrades} from "openzeppelin-foundry-upgrades/Upgrades.sol";
import {DevOpsTools} from "lib/foundry-devops/src/DevOpsTools.sol";
import {HelperConfig} from "./utils/HelperConfig.s.sol";
import {ChatterPayNFT} from "../src/L2/ChatterPayNFT.sol";

contract DeployChatterPay is Script {
HelperConfig helperConfig;

function run() external {
helperConfig = new HelperConfig();
HelperConfig.NetworkConfig memory config = helperConfig.getConfig();

// Set desired baseURI for NFT metadata
string
memory baseURI = "https://back.chatterpay.net/nft/metadata/opensea/";
// Set previously deployed NFT proxy contract address
address proxy = address(0);
bytes memory data = abi.encodeWithSignature(
"initialize(address,string)",
config.account,
baseURI
);

vm.startBroadcast();

Upgrades.upgradeProxy(
proxy,
"ChatterPayNFT.v2.sol",
data,
config.account
);

console.log("NFT updated to:", address(proxy));

vm.stopBroadcast();
}
}
22 changes: 11 additions & 11 deletions script/HelperConfig.s.sol → script/utils/HelperConfig.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity 0.8.24;

import {Script, console} from "forge-std/Script.sol";
import {EntryPoint} from "lib/entry-point-v6/core/EntryPoint.sol";
import {ERC20Mock} from "./utils/ERC20Mock.sol";
import {ERC20Mock} from "./ERC20Mock.sol";

contract HelperConfig is Script {
/*//////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -75,7 +75,7 @@ contract HelperConfig is Script {

function getEthereumSepoliaConfig()
public
pure
view
returns (NetworkConfig memory)
{
return
Expand All @@ -85,13 +85,13 @@ contract HelperConfig is Script {
usdt: 0x7169D38820dfd117C3FA1f22a697dBA58d90BA06,
weth: 0x0000000000000000000000000000000000000000, // address TBD
matic: 0x0000000000000000000000000000000000000000, // address TBD
account: BURNER_WALLET
account: BACKEND_SIGNER
});
}

function getArbitrumSepoliaConfig()
public
pure
view
returns (NetworkConfig memory)
{
return
Expand All @@ -101,13 +101,13 @@ contract HelperConfig is Script {
usdt: 0x961bf3bf61d3446907E0Db83C9c5D958c17A94f6, // address TBD
weth: 0x0000000000000000000000000000000000000000, // address TBD
matic: 0x0000000000000000000000000000000000000000, // address TBD
account: BURNER_WALLET
account: BACKEND_SIGNER
});
}

function getScrollDevnetConfig()
public
pure
view
returns (NetworkConfig memory)
{
return
Expand All @@ -117,13 +117,13 @@ contract HelperConfig is Script {
usdt: 0x0000000000000000000000000000000000000000, // address TBD
weth: 0x0000000000000000000000000000000000000000, // address TBD
matic: 0x0000000000000000000000000000000000000000, // address TBD
account: BURNER_WALLET
account: BACKEND_SIGNER
});
}

function getScrollSepoliaConfig()
public
pure
view
returns (NetworkConfig memory)
{
return
Expand All @@ -133,13 +133,13 @@ contract HelperConfig is Script {
usdt: 0x0000000000000000000000000000000000000000, // address TBD
weth: 0x0000000000000000000000000000000000000000, // address TBD
matic: 0x0000000000000000000000000000000000000000, // address TBD
account: BURNER_WALLET
account: BACKEND_SIGNER
});
}

function getOptimismSepoliaConfig()
public
pure
view
returns (NetworkConfig memory)
{
return
Expand All @@ -149,7 +149,7 @@ contract HelperConfig is Script {
usdt: 0x0000000000000000000000000000000000000000, // address TBD
weth: 0x0000000000000000000000000000000000000000, // address TBD
matic: 0x0000000000000000000000000000000000000000, // address TBD
account: BURNER_WALLET
account: BACKEND_SIGNER
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity 0.8.24;

import {Script, console} from "forge-std/Script.sol";
import {UserOperation} from "lib/entry-point-v6/interfaces/UserOperation.sol";
import {HelperConfig} from "script/HelperConfig.s.sol";
import {HelperConfig} from "script/utils/HelperConfig.s.sol";
import {IEntryPoint} from "lib/entry-point-v6/interfaces/IEntryPoint.sol";
import {MessageHashUtils} from "@openzeppelin/contracts/utils/cryptography/MessageHashUtils.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
Expand Down
14 changes: 7 additions & 7 deletions test/ChatterPayTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
pragma solidity ^0.8.24;

import {Test, console} from "forge-std/Test.sol";
import {DeployAllContracts} from "../script/DeployAllContracts.s.sol";
import {HelperConfig} from "../script/HelperConfig.s.sol";
import {ChatterPay} from "../src/L2/ChatterPay.sol";
import {ChatterPayWalletFactory} from "../src/L2/ChatterPayWalletFactory.sol";
import {ChatterPayNFT} from "../src/L2/ChatterPayNFT.sol";
import {ChatterPayPaymaster} from "../src/L2/ChatterPayPaymaster.sol";
import {DeployAllContracts} from "script/DeployAllContracts.s.sol";
import {HelperConfig} from "script/utils/HelperConfig.s.sol";
import {ChatterPay} from "src/L2/ChatterPay.sol";
import {ChatterPayWalletFactory} from "src/L2/ChatterPayWalletFactory.sol";
import {ChatterPayNFT} from "src/L2/ChatterPayNFT.sol";
import {ChatterPayPaymaster} from "src/L2/ChatterPayPaymaster.sol";
import {ERC20Mock} from "@openzeppelin/contracts/mocks/token/ERC20Mock.sol";
import {SendPackedUserOp, UserOperation, IEntryPoint} from "script/SendPackedUserOp.s.sol";
import {SendPackedUserOp, UserOperation, IEntryPoint} from "script/utils/SendPackedUserOp.s.sol";

contract ChatterPayTest is Test {
HelperConfig helperConfig;
Expand Down

0 comments on commit 256775e

Please sign in to comment.