Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 0 additions & 70 deletions script/checkCounters.s.sol

This file was deleted.

61 changes: 61 additions & 0 deletions script/counter/checkCounters.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {Script} from "forge-std/Script.sol";
import {console} from "forge-std/console.sol";
import {CounterDeployer} from "../../src/counter/CounterDeployer.sol";
import {Counter} from "../../src/counter/Counter.sol";

contract CheckCounters is Script {
// bytes32 public counter = keccak256(abi.encode("counter"));

function run() external {
CounterDeployer deployer = CounterDeployer(vm.envAddress("COUNTER_DEPLOYER"));

vm.createSelectFork(vm.envString("SOCKET_RPC"));
address counterInstanceArbitrumSepolia = deployer.getOnChainAddress(deployer.counter(), 421614);
address counterInstanceOptimismSepolia = deployer.getOnChainAddress(deployer.counter(), 11155420);
address counterInstanceBaseSepolia = deployer.getOnChainAddress(deployer.counter(), 84532);
//address counterInstanceSepolia = deployer.getOnChainAddress(
// deployer.counter(),
// 11155111
//);

if (counterInstanceArbitrumSepolia != address(0)) {
vm.createSelectFork(vm.envString("ARBITRUM_SEPOLIA_RPC"));
uint256 counterValueArbitrumSepolia = Counter(counterInstanceArbitrumSepolia).counter();
console.log("Counter value on Arbitrum Sepolia: ", counterValueArbitrumSepolia);
} else {
console.log("Counter not yet deployed on Arbitrum Sepolia");
}

if (counterInstanceOptimismSepolia != address(0)) {
vm.createSelectFork(vm.envString("OPTIMISM_SEPOLIA_RPC"));
uint256 counterValueOptimismSepolia = Counter(counterInstanceOptimismSepolia).counter();
console.log("Counter value on Optimism Sepolia: ", counterValueOptimismSepolia);
} else {
console.log("Counter not yet deployed on Optimism Sepolia");
}

if (counterInstanceBaseSepolia != address(0)) {
vm.createSelectFork(vm.envString("BASE_SEPOLIA_RPC"));
uint256 counterValueBaseSepolia = Counter(counterInstanceBaseSepolia).counter();
console.log("Counter value on Base Sepolia: ", counterValueBaseSepolia);
} else {
console.log("Counter not yet deployed on Base Sepolia");
}

//if (counterInstanceSepolia != address(0)) {
// vm.createSelectFork(vm.envString("SEPOLIA_RPC"));
// uint256 counterValueOptimismSepolia = Counter(
// counterInstanceOptimismSepolia
// ).counter();
// console.log(
// "Counter value on Ethereum Sepolia: ",
// counterValueOptimismSepolia
// );
//} else {
// console.log("Counter not yet deployed on Ethereum Sepolia");
//}
}
}
25 changes: 7 additions & 18 deletions script/Deploy.s.sol → script/counter/deployCounterOffchain.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ pragma solidity ^0.8.0;

import {Script} from "forge-std/Script.sol";
import {console} from "forge-std/console.sol";
import {CounterAppGateway} from "../src/CounterAppGateway.sol";
import {CounterDeployer} from "../src/CounterDeployer.sol";
import {CounterAppGateway} from "../../src/counter/CounterAppGateway.sol";
import {CounterDeployer} from "../../src/counter/CounterDeployer.sol";
import {FeesData} from "lib/socket-protocol/contracts/common/Structs.sol";
import {ETH_ADDRESS} from "lib/socket-protocol/contracts/common/Constants.sol";

Expand All @@ -19,22 +19,11 @@ contract CounterDeploy is Script {
vm.startBroadcast(deployerPrivateKey);

// Setting fee payment on Arbitrum Sepolia
FeesData memory feesData = FeesData({
feePoolChain: 421614,
feePoolToken: ETH_ADDRESS,
maxFees: 0.01 ether
});

CounterDeployer deployer = new CounterDeployer(
addressResolver,
feesData
);

CounterAppGateway gateway = new CounterAppGateway(
addressResolver,
address(deployer),
feesData
);
FeesData memory feesData = FeesData({feePoolChain: 421614, feePoolToken: ETH_ADDRESS, maxFees: 0.01 ether});

CounterDeployer deployer = new CounterDeployer(addressResolver, feesData);

CounterAppGateway gateway = new CounterAppGateway(addressResolver, address(deployer), feesData);

console.log("Contracts deployed:");
console.log("CounterDeployer:", address(deployer));
Expand Down
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 {CounterDeployer} from "../src/CounterDeployer.sol";
import {CounterDeployer} from "../../src/counter/CounterDeployer.sol";
import {ETH_ADDRESS} from "lib/socket-protocol/contracts/common/Constants.sol";

contract CounterDeployOnchain is Script {
Expand All @@ -15,9 +15,7 @@ contract CounterDeployOnchain is Script {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
vm.startBroadcast(deployerPrivateKey);

CounterDeployer deployer = CounterDeployer(
vm.envAddress("COUNTER_DEPLOYER")
);
CounterDeployer deployer = CounterDeployer(vm.envAddress("COUNTER_DEPLOYER"));

console.log("Counter Deployer:", address(deployer));

Expand All @@ -27,5 +25,7 @@ contract CounterDeployOnchain is Script {
deployer.deployContracts(11155420);
console.log("Deploying contracts on Base Sepolia...");
deployer.deployContracts(84532);
//console.log("Deploying contracts on Ethereum Sepolia...");
//deployer.deployContracts(11155111);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ pragma solidity ^0.8.0;

import {Script} from "forge-std/Script.sol";
import {console} from "forge-std/console.sol";
import {CounterDeployer} from "../src/CounterDeployer.sol";
import {CounterAppGateway} from "../src/CounterAppGateway.sol";
import {CounterDeployer} from "../../src/counter/CounterDeployer.sol";
import {CounterAppGateway} from "../../src/counter/CounterAppGateway.sol";

contract IncrementCounters is Script {
function run() external {
Expand All @@ -13,36 +13,23 @@ contract IncrementCounters is Script {

vm.createSelectFork(socketRPC);

CounterDeployer deployer = CounterDeployer(
vm.envAddress("COUNTER_DEPLOYER")
);
CounterAppGateway gateway = CounterAppGateway(
vm.envAddress("COUNTER_APP_GATEWAY")
);
CounterDeployer deployer = CounterDeployer(vm.envAddress("COUNTER_DEPLOYER"));
CounterAppGateway gateway = CounterAppGateway(vm.envAddress("COUNTER_APP_GATEWAY"));

address counterForwarderArbitrumSepolia = deployer.forwarderAddresses(
deployer.counter(),
421614
);
address counterForwarderOptimismSepolia = deployer.forwarderAddresses(
deployer.counter(),
11155420
);
address counterForwarderBaseSepolia = deployer.forwarderAddresses(
deployer.counter(),
84532
);
address counterForwarderSepolia = deployer.forwarderAddresses(
deployer.counter(),
11155111
);
address counterForwarderArbitrumSepolia = deployer.forwarderAddresses(deployer.counter(), 421614);
address counterForwarderOptimismSepolia = deployer.forwarderAddresses(deployer.counter(), 11155420);
address counterForwarderBaseSepolia = deployer.forwarderAddresses(deployer.counter(), 84532);
//address counterForwarderSepolia = deployer.forwarderAddresses(
// deployer.counter(),
// 11155111
//);

// Count non-zero addresses
uint256 nonZeroCount = 0;
if (counterForwarderArbitrumSepolia != address(0)) nonZeroCount++;
if (counterForwarderOptimismSepolia != address(0)) nonZeroCount++;
if (counterForwarderBaseSepolia != address(0)) nonZeroCount++;
if (counterForwarderSepolia != address(0)) nonZeroCount++;
//if (counterForwarderSepolia != address(0)) nonZeroCount++;

address[] memory instances = new address[](nonZeroCount);
uint256 index = 0;
Expand All @@ -64,12 +51,12 @@ contract IncrementCounters is Script {
} else {
console.log("Base Sepolia forwarder not yet deployed");
}
if (counterForwarderSepolia != address(0)) {
instances[index] = counterForwarderSepolia;
index++;
} else {
console.log("Sepolia forwarder not yet deployed");
}
//if (counterForwarderSepolia != address(0)) {
// instances[index] = counterForwarderSepolia;
// index++;
//} else {
// console.log("Ethereum Sepolia forwarder not yet deployed");
//}

vm.startBroadcast(deployerPrivateKey);
gateway.incrementCounters(instances);
Expand Down
49 changes: 36 additions & 13 deletions script/transactionStatus.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,12 @@ const apiUrl = 'https://apiv2.dev.socket.tech/getDetailsByTxHash?txHash=';
let intervalId;

// Track statuses for each hash
let statusTracker = transactions.map(hash => ({ hash, status: 'PENDING', printed: false }));
let statusTracker = transactions.map(hash => ({
hash,
status: 'PENDING',
printed: false,
printedPayloads: new Set()
}));
let allDonePrinted = false; // Prevent multiple prints of the final message

// Function to perform API requests
Expand All @@ -50,10 +55,26 @@ const fetchTransactionStatus = async (hash) => {
}
};

const processMultiplePayloads = (payloads, tx) => {
if (payloads.length > 1) {
payloads.forEach(payload => {
// Create a unique key for the payload to track printed status
const payloadKey = `${payload.executeDetails.executeTxHash}-${payload.callBackDetails.callbackStatus}`;

if (payload.callBackDetails.callbackStatus === 'PROMISE_RESOLVED' &&
payload.executeDetails.executeTxHash &&
!tx.printedPayloads.has(payloadKey)) {
console.log(`Hash: ${payload.executeDetails.executeTxHash}, Status: ${payload.callBackDetails.callbackStatus}, ChainId: ${payload.chainSlug}`);

tx.printedPayloads.add(payloadKey);
}
});
}
};

// Function to check transaction status
const checkTransactionStatus = async () => {
let allCompleted = true;

for (let i = 0; i < statusTracker.length; i++) {
const tx = statusTracker[i];

Expand All @@ -76,26 +97,28 @@ const checkTransactionStatus = async () => {

const transactionResponse = data.response[0]; // First response object
const status = transactionResponse.status || 'UNKNOWN';
const payload = transactionResponse.payloads?.[0];
const chainSlug = payload?.chainSlug || 'N/A';
const payloads = transactionResponse.payloads || [];

// Update tracker
tx.status = status;

if (status === 'COMPLETED' && !tx.printed) {
const deployerDetails = payload?.deployerDetails || {};
console.log(`Hash: ${tx.hash}, Status: ${status}, ChainId: ${chainSlug}`);
processMultiplePayloads(payloads, tx);

const deployerDetails = payloads[0].deployerDetails || {};

if (Object.keys(deployerDetails).length !== 0) {
const onChainAddress = deployerDetails.onChainAddress;
const forwarderAddress = deployerDetails.forwarderAddress;
console.log(`OnChainAddress: ${onChainAddress}`);
console.log(`ForwarderAddress: ${forwarderAddress}`);
console.log(`Hash: ${tx.hash}, Status: ${status}, ChainId: ${payloads[0].chainSlug}`);
console.log(`OnChainAddress: ${deployerDetails.onChainAddress}`);
console.log(`ForwarderAddress: ${deployerDetails.forwarderAddress}`);
} else {
console.log(`Hash: ${tx.hash}, Status: ${status}, ChainId: 7625382`);
}

// Mark this transaction as printed
tx.printed = true;
}
else if (status === 'IN_PROGRESS') {
processMultiplePayloads(payloads, tx);
}
} else {
console.error(`Invalid or empty response for hash: ${tx.hash}`);
}
Expand All @@ -114,4 +137,4 @@ const checkTransactionStatus = async () => {

// Start periodic polling every second
console.log('Starting to monitor transaction statuses...');
intervalId = setInterval(checkTransactionStatus, 1000);
intervalId = setInterval(checkTransactionStatus, 2000);
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ import "socket-protocol/contracts/base/AppGatewayBase.sol";
import "./Counter.sol";

contract CounterAppGateway is AppGatewayBase {
constructor(
address _addressResolver,
address deployerContract_,
FeesData memory feesData_
) AppGatewayBase(_addressResolver) {
constructor(address _addressResolver, address deployerContract_, FeesData memory feesData_)
AppGatewayBase(_addressResolver)
{
addressResolver.setContractsToGateways(deployerContract_);
_setFeesData(feesData_);
}
Expand Down
5 changes: 1 addition & 4 deletions src/CounterDeployer.sol → src/counter/CounterDeployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ import "socket-protocol/contracts/base/AppDeployerBase.sol";
contract CounterDeployer is AppDeployerBase {
bytes32 public counter = _createContractId("counter");

constructor(
address addressResolver_,
FeesData memory feesData_
) AppDeployerBase(addressResolver_) {
constructor(address addressResolver_, FeesData memory feesData_) AppDeployerBase(addressResolver_) {
creationCodeWithArgs[counter] = type(Counter).creationCode;
_setFeesData(feesData_);
}
Expand Down
Loading
Loading