From 21d08f3502f8d6d46ea83be03143fc49d32a455c Mon Sep 17 00:00:00 2001 From: arthcp Date: Thu, 5 Dec 2024 15:45:01 +0400 Subject: [PATCH] feat: latest --- .env.sample | 12 ++++++++---- script/Deploy.s.sol | 26 +++++++++++--------------- script/SetFees.sol | 22 ++++++++++++++++++++++ script/checkCounters.s.sol | 0 script/incrementCounters.s.sol | 0 src/CounterAppGateway.sol | 15 ++++++++++----- src/CounterDeployer.sol | 9 ++++----- 7 files changed, 55 insertions(+), 29 deletions(-) create mode 100644 script/SetFees.sol create mode 100644 script/checkCounters.s.sol create mode 100644 script/incrementCounters.s.sol diff --git a/.env.sample b/.env.sample index c993d9d..5eaa586 100644 --- a/.env.sample +++ b/.env.sample @@ -2,9 +2,13 @@ PRIVATE_KEY="0x" WALLET_ADDRESS="0x" SOCKET_RPC="https://rpc-socket-composer-testnet.t.conduit.xyz" - +SEPOLIA_RPC="https://rpc.ankr.com/eth_sepolia/" ARBITRUM_SEPOLIA_RPC="https://rpc.ankr.com/arbitrum_sepolia" -ARBITRUM_API_KEY="some_key" - OPTIMISM_SEPOLIA_RPC="https://rpc.ankr.com/optimism_sepolia" -OPTIMISM_API_KEY="some_key" +BASE_SEPOLIA_RPC="https://rpc.ankr.com/base_sepolia" + +ADDRESS_RESOLVER="0x9433644DEa540F91faC99EC6FAC9d7579f925624" # TODO: ADD correct AddressResolver on Socket Composer Testnet + +# Set values after deployemnt +COUNTER_DEPLOYER="" +COUNTER_APP_GATEWAY="" diff --git a/script/Deploy.s.sol b/script/Deploy.s.sol index 7498088..38e4172 100644 --- a/script/Deploy.s.sol +++ b/script/Deploy.s.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.0; import {Script} from "forge-std/Script.sol"; import {console} from "forge-std/Console.sol"; -import {CounterComposer} from "../src/CounterComposer.sol"; +import {CounterAppGateway} from "../src/CounterAppGateway.sol"; import {CounterDeployer} from "../src/CounterDeployer.sol"; import {Counter} from "../src/Counter.sol"; import {FeesData} from "lib/socket-poc/contracts/common/Structs.sol"; @@ -14,30 +14,26 @@ contract CounterDeploy is Script { uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); vm.startBroadcast(deployerPrivateKey); - address addressResolver = 0x9433644DEa540F91faC99EC6FAC9d7579f925624; // TODO: ADD correct AddressResolver on Socket Composer Testnet + address addressResolver = vm.envAddress("ADDRESS_RESOLVER"); // Setting fee payment on Arbitrum Sepolia - FeesData memory feesData = FeesData({ - feePoolChain: 421614, - feePoolToken: ETH_ADDRESS, - maxFees: 0.01 ether - }); + // FeesData memory feesData = FeesData({ + // feePoolChain: 421614, + // feePoolToken: ETH_ADDRESS, + // maxFees: 0.01 ether + // }); CounterDeployer deployer = new CounterDeployer( - addressResolver, - feesData + addressResolver ); - CounterComposer gateway = new CounterComposer( + CounterAppGateway gateway = new CounterAppGateway( addressResolver, - address(deployer), - feesData + address(deployer) ); - address counterPlug = deployer.counter(); console.log("Contracts deployed:"); - console.log("CounterComposer:", address(gateway)); + console.log("CounterAppGateway:", address(gateway)); console.log("Counter Deployer:", address(deployer)); - console.log("Counter:", address(counterPlug)); console.log("Deploying contracts on Arbitrum Sepolia..."); deployer.deployContracts(421614); diff --git a/script/SetFees.sol b/script/SetFees.sol new file mode 100644 index 0000000..5a99e4e --- /dev/null +++ b/script/SetFees.sol @@ -0,0 +1,22 @@ +contract SetFees is Script { + function run() external { + uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); + string memory arbitrumSepoliaRPC = vm.envString("ARBITRUM_SEPOLIA_RPC"); + + vm.startBroadcast(deployerPrivateKey); + vm.fork(arbitrumSepoliaRPC); + + address payloadDelivery = 0x9433644DEa540F91faC99EC6FAC9d7579f925624; // TODO: ADD correct PayloadDelivery on Socket Composer Testnet + + // Set fees on Arbitrum Sepolia + FeesData memory feesData = FeesData({ + feePoolChain: 421614, + feePoolToken: ETH_ADDRESS, + maxFees: 0.01 ether + }); + + PayloadDelivery(payloadDelivery).deposit(ETH_ADDRESS, 0.01 ether, address(this)); + CounterDeployer(counterDeployer).setFees(feesData); + CounterAppGateway(counterAppGateway).setFees(feesData); + } +} diff --git a/script/checkCounters.s.sol b/script/checkCounters.s.sol new file mode 100644 index 0000000..e69de29 diff --git a/script/incrementCounters.s.sol b/script/incrementCounters.s.sol new file mode 100644 index 0000000..e69de29 diff --git a/src/CounterAppGateway.sol b/src/CounterAppGateway.sol index d032a6e..ed24293 100644 --- a/src/CounterAppGateway.sol +++ b/src/CounterAppGateway.sol @@ -7,13 +7,18 @@ import "./Counter.sol"; contract CounterAppGateway is AppGatewayBase { constructor( address _addressResolver, - address deployerContract_, - FeesData memory feesData_ - ) AppGatewayBase(_addressResolver, feesData_) Ownable(msg.sender) { + address deployerContract_ + ) AppGatewayBase(_addressResolver) { addressResolver.setContractsToGateways(deployerContract_); } - function incrementCounter(address _instance) public async(abi.encode(_instance)) { - Counter(_instance).increase(); + function incrementCounters( + address[] memory instances + ) public async { + // the increase function is called on given list of instances + // this + for (uint256 i = 0; i < instances.length; i++) { + Counter(instances[i]).increase(); + } } } diff --git a/src/CounterDeployer.sol b/src/CounterDeployer.sol index 43d0a7e..36c4435 100644 --- a/src/CounterDeployer.sol +++ b/src/CounterDeployer.sol @@ -8,20 +8,19 @@ contract CounterDeployer is AppDeployerBase { address public counter; constructor( - address addressResolver_, - FeesData memory feesData_ - ) AppDeployerBase(addressResolver_, feesData_) Ownable(msg.sender) { + address addressResolver_ + ) AppDeployerBase(addressResolver_) { counter = address(new Counter()); creationCodeWithArgs[counter] = type(Counter).creationCode; } function deployContracts( uint32 chainSlug - ) external async(abi.encode(chainSlug)) { + ) external async { _deploy(counter, chainSlug); } - function initialize(uint32 chainSlug) public override async(abi.encode(chainSlug)) { + function initialize(uint32 chainSlug) public override async { address socket = getSocketAddress(chainSlug); address counterForwarder = forwarderAddresses[counter][chainSlug]; Counter(counterForwarder).setSocket(socket);