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
2 changes: 0 additions & 2 deletions EventTopics.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,6 @@

| Event | Arguments | Topic |
| ---------------------------- | ---------------------------------------- | -------------------------------------------------------------------- |
| `AppGatewayCallFailed` | `(triggerId: bytes32)` | `0xcaf8475fdade8465ea31672463949e6cf1797fdcdd11eeddbbaf857e1e5907b7` |
| `CalledAppGateway` | `(triggerId: bytes32)` | `0xf659ffb3875368f54fb4ab8f5412ac4518af79701a48076f7a58d4448e4bdd0b` |
| `Initialized` | `(version: uint64)` | `0xc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d2` |
| `OwnershipHandoverCanceled` | `(pendingOwner: address)` | `0xfa7b8eab7da67f412cc9575ed43464468f9bfbae89d1675917346ca6d8fe3c92` |
| `OwnershipHandoverRequested` | `(pendingOwner: address)` | `0xdbf36a107da19e49527a7176a1babf963b4b0ff8cde35ee35d6cd8f1f9ac7e1d` |
Expand Down
7 changes: 0 additions & 7 deletions contracts/evmx/interfaces/IWatcher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,6 @@ import "./IPromiseResolver.sol";
/// @notice Interface for the Watcher Precompile system that handles payload verification and execution
/// @dev Defines core functionality for payload processing and promise resolution
interface IWatcher {
/// @notice Emitted when a new call is made to an app gateway
/// @param triggerId The unique identifier for the trigger
event CalledAppGateway(bytes32 triggerId);

/// @notice Emitted when a call to an app gateway fails
/// @param triggerId The unique identifier for the trigger
event AppGatewayCallFailed(bytes32 triggerId);

function requestHandler__() external view returns (IRequestHandler);

Expand Down
26 changes: 26 additions & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,29 @@ optimizer = true
optimizer_runs = 200
evm_version = 'paris'
via_ir = false

[labels]
0x67790E222c41b0E787C278e757b7c40f03Fa5709 = "AddressResolver"
0x89C928379fED43B7117b852931e2968ce39C8380 = "AddressResolverImpl"
0x1C70bc3043667e884222B8835E0Ae554eb512810 = "AsyncDeployer"
0x09a762309c63a4e19cd3d822aA340Fe964Ba9C92 = "AsyncDeployerImpl"
0xC12aDF88dfc116CAF88816d150FE498843dABEEe = "AuctionManager"
0x55b76897b3BF6ED04188cbaa7DC21ae14b35D3eE = "AuctionManagerImpl"
0x377431bD1A3321C401542C8B1EC6E0c23E125042 = "Configurations"
0xDe5DedAe6e17f906D1269D5e84BEfB06F3926310 = "ConfigurationsImpl"
0xd48218b2DafF9063177b0c6Bae229ec6C5f086a9 = "DeployForwarder"
0x8e178161BB3B36a28C15DFBe3142afF8757B8993 = "DeployForwarderImpl"
0x870fCA8803bEFd119B1317AFB6794F97af7e515e = "ERC1967Factory"
0x761A9024D267006061ec943d02e3949678906f3E = "FeesManager"
0x29C583B64FD2d7b70f8F6253C2a28D60af364Cb5 = "FeesManagerImpl"
0x9De353dD1131aB4e502590D3a1832652FA316268 = "FeesPool"
0x73b1B3dF6C71e0aa912f9d6933920D4461ae9718 = "PromiseResolver"
0x58f49313816c1876417EE53De8F5de047359fB2C = "ReadPrecompile"
0x63a6D7096b5a2F5c9Ce7D8632A7A2034A85b7F01 = "RequestHandler"
0x593f4844ceEA828bC6d9D78A0ef7Ce64F42190dC = "RequestHandlerImpl"
0xF77d2059a66026Efac11334D30372429553CAaC3 = "SchedulePrecompile"
0xe4D1B4B8c0eEE90ac1f5314e758446CBa201BBA8 = "Watcher"
0x7726e559A5129A9174f89F7E2029f7212B66dD13 = "WatcherImpl"
0xd8be408E271EEe9d3D0f28305bB9b6003589E1A9 = "WritePrecompile"
0xE24c4b0f67f566Fa558b3FE85f1780CD330f1F4D = "WritePrecompileImpl"
0x4Faa9C39f4E1C5be5f9c2e3F5AC8774da3b7B1C2 = "APP_GATEWAY"
5 changes: 5 additions & 0 deletions hardhat-scripts/constants/feeConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import { DeploymentMode } from "../../src";
import { TokenMap } from "./types";

const tokens: TokenMap = {
[DeploymentMode.LOCAL]: {
421614: ["0x5e732b6f5DC56dDAe4dBDbf844348F87C3B0b957"],
11155420: ["0xb669f76f781dC75E06183DcdB7fd8bcD8Ef700E6"],
},
[DeploymentMode.DEV]: {
421614: ["0x2321BF7AdFaf49b1338F1Cd474859dBc0D8dfA96"],
11155420: ["0x15dbE4B96306Cc9Eba15D834d6c1a895cF4e1697"],
Expand All @@ -14,6 +18,7 @@ const tokens: TokenMap = {
};

const feePools: { [key: string]: string } = {
[DeploymentMode.LOCAL]: "0x9De353dD1131aB4e502590D3a1832652FA316268",
[DeploymentMode.DEV]: "0xc20Be67ef742202dc93A78aa741E7C3715eA1DFd",
[DeploymentMode.STAGE]: "0xe2054B575664dfDBD7a7FbAf2B12420ae88DE0FF",
};
Expand Down
2 changes: 1 addition & 1 deletion hardhat-scripts/deploy/1.deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ const deployEVMxContracts = async () => {
deployUtils.addresses[contractName] = proxyFactory.address;

const feePool = getFeePool(mode);
if (feePool.length == 0) {
if (feePool?.length == 0) {
const feesPool = await getOrDeploy(
Contracts.FeesPool,
Contracts.FeesPool,
Expand Down
2 changes: 1 addition & 1 deletion hardhat-scripts/deploy/7.upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const getBucketName = () => {
const getFileName = () => {
switch (mode) {
case DeploymentMode.LOCAL:
return "pocConfig.json";
return process.env.CONFIG_FILE_NAME || "pocConfig.json";
case DeploymentMode.DEV:
return "devConfig.json";
case DeploymentMode.STAGE:
Expand Down
29 changes: 18 additions & 11 deletions hardhat-scripts/deploy/8.setupEnv.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { ChainSlug, Contracts } from "../../src";
import {
ChainAddressesObj,
ChainSlug,
Contracts,
EVMxAddressesObj,
} from "../../src";
import fs from "fs";
import path from "path";
import { EVMX_CHAIN_ID, mode } from "../config/config";
import { getAddresses } from "../utils";
import { getAddresses } from "../utils/address";
import { getFeeTokens } from "../constants";

const envFilePath = path.join(__dirname, "../../.env");
Expand All @@ -16,8 +21,10 @@ const lines = envContent.split("\n");

// Get the latest addresses
const latestAddresses = getAddresses(mode);
const latestEVMxAddresses = latestAddresses[EVMX_CHAIN_ID];

const latestEVMxAddresses = latestAddresses[EVMX_CHAIN_ID] as EVMxAddressesObj;
const arbSepoliaAddresses = latestAddresses[
ChainSlug.ARBITRUM_SEPOLIA
] as ChainAddressesObj;
// Create a new array to hold the updated lines
const updatedLines = lines.map((line) => {
if (line.startsWith("ADDRESS_RESOLVER=")) {
Expand All @@ -29,23 +36,23 @@ const updatedLines = lines.map((line) => {
} else if (line.startsWith("FEES_MANAGER=")) {
return `FEES_MANAGER=${latestEVMxAddresses[Contracts.FeesManager]}`;
} else if (line.startsWith("ARBITRUM_SOCKET=")) {
return `ARBITRUM_SOCKET=${
latestAddresses[ChainSlug.ARBITRUM_SEPOLIA][Contracts.Socket]
}`;
return `ARBITRUM_SOCKET=${arbSepoliaAddresses[Contracts.Socket]}`;
} else if (line.startsWith("ARBITRUM_SWITCHBOARD=")) {
return `ARBITRUM_SWITCHBOARD=${
latestAddresses[ChainSlug.ARBITRUM_SEPOLIA][Contracts.FastSwitchboard]
arbSepoliaAddresses[Contracts.FastSwitchboard]
}`;
} else if (line.startsWith("ARBITRUM_FEES_PLUG=")) {
const feesPlug =
latestAddresses[ChainSlug.ARBITRUM_SEPOLIA][Contracts.FeesPlug];
const feesPlug = arbSepoliaAddresses[Contracts.FeesPlug];
if (feesPlug) {
return `ARBITRUM_FEES_PLUG=${feesPlug}`;
} else {
return line;
}
} else if (line.startsWith("ARBITRUM_TEST_USDC=")) {
const testUSDC = getFeeTokens(mode, ChainSlug.ARBITRUM_SEPOLIA)[0];
const testUSDC = getFeeTokens(
mode,
ChainSlug.ARBITRUM_SEPOLIA
)[0] as string;
if (testUSDC) {
return `ARBITRUM_TEST_USDC=${testUSDC}`;
} else {
Expand Down
64 changes: 64 additions & 0 deletions hardhat-scripts/misc-scripts/createLabels.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// scripts/generate-labels.ts
import fs from "fs";
import path from "path";
import { getAddresses } from "../utils/address";
import { EVMX_CHAIN_ID, mode } from "../config";

function generateFoundryLabels(chainSlug?: string) {
// Read deployed addresses
const deployedAddresses = getAddresses(mode);

// Read existing foundry.toml
const foundryPath = path.join(__dirname, "../../foundry.toml");
let foundryContent = fs.existsSync(foundryPath)
? fs.readFileSync(foundryPath, "utf8")
: "";

// Remove existing [labels] section
foundryContent = foundryContent.replace(/\[labels\][\s\S]*?(?=\[|$)/g, "");

// Generate new labels section
let labelsSection = "[labels]\n";
const chainIds = [EVMX_CHAIN_ID];
if (chainSlug) {
const additionalChainId = parseInt(chainSlug, 10);
if (isNaN(additionalChainId)) {
console.error(`❌ Invalid chain ID: ${chainSlug}`);
process.exit(1);
}
if (additionalChainId !== EVMX_CHAIN_ID) chainIds.push(additionalChainId);
}

for (const chainId of chainIds) {
const chainAddresses = deployedAddresses[chainId];

if (!chainAddresses) {
console.error(`❌ No addresses found for chain ${chainId}`);
continue;
}

// Add all addresses to the labels section
for (const [contractName, address] of Object.entries(chainAddresses)) {
if (typeof address === "string") {
labelsSection += `${address} = "${contractName}"\n`;
}
}
console.log(`✅ Added labels for chain ${chainId}`);
}

// Add APP_GATEWAY label if environment variable exists
if (process.env.APP_GATEWAY) {
labelsSection += `${process.env.APP_GATEWAY} = "APP_GATEWAY"\n`;
}

// Append labels section
foundryContent += labelsSection;

// Write back to foundry.toml
fs.writeFileSync(foundryPath, foundryContent);
console.log("✅ Updated foundry.toml with contract labels");
}

// Get chainSlug from command line arguments
const chainSlug = process.argv[2];
generateFoundryLabels(chainSlug);
12 changes: 0 additions & 12 deletions hardhat-scripts/utils/accounts.ts

This file was deleted.

3 changes: 2 additions & 1 deletion hardhat-scripts/utils/address.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import dev_addresses from "../../deployments/dev_addresses.json";
import stage_addresses from "../../deployments/stage_addresses.json";
import local_addresses from "../../deployments/local_addresses.json";
import { ChainAddressesObj, DeploymentMode, EVMxAddressesObj } from "../../src";
import { ChainAddressesObj, EVMxAddressesObj } from "../../src/types";
import { DeploymentMode } from "../../src/enums";

export const getAddresses = (
mode: DeploymentMode
Expand Down
1 change: 0 additions & 1 deletion hardhat-scripts/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export * from "./address";
export * from "./appConfig";
export * from "./networks";
export * from "./overrides";
export * from "./accounts";
export * from "./deployUtils";
export * from "./sign";
export * from "./gatewayId";
1 change: 0 additions & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import type {
import { resolve } from "path";
import fs from "fs";

import "./hardhat-scripts/utils/accounts";
import { getJsonRpcUrl } from "./hardhat-scripts/utils/networks";
import {
ChainId,
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"publishConfig": {
"access": "public"
},
"version": "1.1.21",
"version": "1.1.22",
"description": "socket protocol",
"scripts": {
"build": "yarn abi && tsc --project lib.tsconfig.json",
Expand All @@ -19,7 +19,8 @@
"lintContracts": "prettier \"./**\" --write --plugin=prettier-plugin-solidity",
"compile": "forge build",
"deploy": "bash setupInfraContracts.sh",
"publish-core": "yarn build && yarn publish --patch --no-git-tag-version"
"publish-core": "yarn build && yarn publish --patch --no-git-tag-version",
"trace":"bash trace.sh"
},
"pre-commit": [],
"author": "",
Expand Down
2 changes: 1 addition & 1 deletion script/counter/DeployEVMxCounterApp.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ contract CounterDeploy is Script {
vm.startBroadcast(deployerPrivateKey);

// Setting fee payment on Arbitrum Sepolia
uint256 fees = 10 ether;
uint256 fees = 1 ether;

CounterAppGateway gateway = new CounterAppGateway(addressResolver, fees);

Expand Down
2 changes: 1 addition & 1 deletion script/helpers/DepositCredit.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {TestUSDC} from "../../contracts/evmx/mocks/TestUSDC.sol";
// source .env && forge script script/helpers/DepositCreditAndNative.s.sol --broadcast --skip-simulation
contract DepositCredit is Script {
function run() external {
uint256 feesAmount = 100000000; // 100 USDC
uint256 feesAmount = 2000000; // 2 USDC
vm.createSelectFork(vm.envString("ARBITRUM_SEPOLIA_RPC"));

uint256 privateKey = vm.envUint("PRIVATE_KEY");
Expand Down
36 changes: 36 additions & 0 deletions script/helpers/DepositCreditMainnet.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity ^0.8.21;

import {Script} from "forge-std/Script.sol";
import {console} from "forge-std/console.sol";
import {FeesPlug} from "../../contracts/evmx/plugs/FeesPlug.sol";
import {TestUSDC} from "../../contracts/evmx/mocks/TestUSDC.sol";
import "solady/tokens/ERC20.sol";
// source .env && forge script script/helpers/DepositCreditAndNative.s.sol --broadcast --skip-simulation
contract DepositCredit is Script {
function run() external {
uint256 feesAmount = 1000000; // 1 USDC
vm.createSelectFork(vm.envString("ARBITRUM_RPC"));

uint256 privateKey = vm.envUint("PRIVATE_KEY");
vm.startBroadcast(privateKey);
FeesPlug feesPlug = FeesPlug(payable(vm.envAddress("ARBITRUM_FEES_PLUG")));
address appGateway = vm.envAddress("APP_GATEWAY");
ERC20 USDCContract = ERC20(vm.envAddress("ARBITRUM_USDC"));

// approve fees plug to spend test USDC
USDCContract.approve(address(feesPlug), feesAmount);

address sender = vm.addr(privateKey);
console.log("Sender address:", sender);
uint256 balance = USDCContract.balanceOf(sender);
console.log("Sender USDC balance:", balance);
if (balance < feesAmount) {
revert("Sender does not have enough USDC");
}
console.log("App Gateway:", appGateway);
console.log("Fees Plug:", address(feesPlug));
console.log("Fees Amount:", feesAmount);
feesPlug.depositCredit(address(USDCContract), appGateway, feesAmount);
}
}
5 changes: 3 additions & 2 deletions setupInfraContracts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ time npx hardhat run hardhat-scripts/deploy/3.configureChains.ts --no-compile
time npx hardhat run hardhat-scripts/deploy/4.configureEVMx.ts --no-compile
time npx hardhat run hardhat-scripts/deploy/5.fundTransfers.ts --no-compile
time npx hardhat run hardhat-scripts/deploy/6.connect.ts --no-compile
time npx hardhat run hardhat-scripts/deploy/7.upload.ts --no-compile
time npx hardhat run hardhat-scripts/deploy/8.setupEnv.ts --no-compile
time npx ts-node hardhat-scripts/deploy/7.upload.ts
time npx ts-node hardhat-scripts/deploy/8.setupEnv.ts
time npx hardhat run hardhat-scripts/deploy/9.setupTransmitter.ts --no-compile
time npx hardhat run hardhat-scripts/misc-scripts/errorCodes.ts --no-compile
time npx hardhat run hardhat-scripts/misc-scripts/eventTopics.ts --no-compile
time npx hardhat run hardhat-scripts/misc-scripts/functionSigs.ts --no-compile
time npx ts-node hardhat-scripts/misc-scripts/createLabels.ts
time npx hardhat run hardhat-scripts/verify/verify.ts --no-compile
yarn lint
4 changes: 2 additions & 2 deletions src/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export enum Events {
FeesDeposited = "FeesDeposited",

// Watcher
CalledAppGateway = "CalledAppGateway",
AppGatewayCallFailed = "AppGatewayCallFailed",
TriggerFailed = "TriggerFailed",
TriggerSucceeded = "TriggerSucceeded",

// PromiseResolver
PromiseResolved = "PromiseResolved",
Expand Down
5 changes: 1 addition & 4 deletions src/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ export const socketEvents = [

export const feesPlugEvents = [Events.FeesDeposited];

export const watcherEvents = [
Events.CalledAppGateway,
Events.AppGatewayCallFailed,
];
export const watcherEvents = [Events.TriggerFailed, Events.TriggerSucceeded];

export const promiseResolverEvents = [
Events.PromiseResolved,
Expand Down
Loading