Skip to content

Commit

Permalink
feat: latest
Browse files Browse the repository at this point in the history
  • Loading branch information
arthcp committed Dec 5, 2024
1 parent 8416311 commit 21d08f3
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 29 deletions.
12 changes: 8 additions & 4 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -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=""
26 changes: 11 additions & 15 deletions script/Deploy.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} 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";
Expand All @@ -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);
Expand Down
22 changes: 22 additions & 0 deletions script/SetFees.sol
Original file line number Diff line number Diff line change
@@ -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);
}
}
Empty file added script/checkCounters.s.sol
Empty file.
Empty file added script/incrementCounters.s.sol
Empty file.
15 changes: 10 additions & 5 deletions src/CounterAppGateway.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
9 changes: 4 additions & 5 deletions src/CounterDeployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 21d08f3

Please sign in to comment.