From adcb4fddf949750a47ef1454070ff0d25425c2e1 Mon Sep 17 00:00:00 2001 From: FelixFan1992 Date: Mon, 13 Nov 2023 16:21:33 -0500 Subject: [PATCH 1/2] foundry test setup --- contracts/foundry.toml | 4 ++++ contracts/hardhat.config.ts | 13 +++++++++++++ contracts/remappings.txt | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/contracts/foundry.toml b/contracts/foundry.toml index cf27c0f2a8b..9fd06ea4761 100644 --- a/contracts/foundry.toml +++ b/contracts/foundry.toml @@ -22,6 +22,10 @@ src = 'src/v0.8/functions/dev/v1_X' test = 'src/v0.8/functions/tests/v1_X' gas_price = 3_000_000_000 # 3 gwei +[profile.automationexp] +auto_detect_solc = true +src = 'src/v0.8/automation/' + [profile.vrf] optimizer_runs = 1000 src = 'src/v0.8/vrf' diff --git a/contracts/hardhat.config.ts b/contracts/hardhat.config.ts index 5306827b8e3..d6d98d38bdb 100644 --- a/contracts/hardhat.config.ts +++ b/contracts/hardhat.config.ts @@ -56,6 +56,9 @@ let config = { ), hardfork: 'merge', }, + optimism_goerli: { + url: 'https://op.getblock.io/608a6708-d787-4ba8-bcbd-493001ea7fd9/goerli/', + }, }, solidity: { compilers: [ @@ -141,6 +144,16 @@ if (process.env.NETWORK_NAME && process.env.EXPLORER_API_KEY) { apiKey: { [process.env.NETWORK_NAME]: process.env.EXPLORER_API_KEY, }, + customChains: [ + { + network: 'optimism_goerli', + chainId: 420, + urls: { + apiURL: 'https://api-goerli-optimistic.etherscan.io/api', + browserURL: 'https://goerli-optimism.etherscan.io/', + }, + }, + ], }, } } diff --git a/contracts/remappings.txt b/contracts/remappings.txt index f0ac4993c2c..6a0a28b8316 100644 --- a/contracts/remappings.txt +++ b/contracts/remappings.txt @@ -1,6 +1,6 @@ ds-test/=foundry-lib/forge-std/lib/ds-test/src forge-std/=foundry-lib/forge-std/src -@openzeppelin/=node_modules/@openzeppelin/ +@openzeppelin/=src/v0.8/vendor/openzeppelin-solidity/v4.9.3 hardhat/=node_modules/hardhat/ @eth-optimism/=node_modules/@eth-optimism From 5d4be64c1f6486f9b84bab43b0779e87df514e9f Mon Sep 17 00:00:00 2001 From: FelixFan1992 Date: Mon, 20 Nov 2023 10:30:46 -0500 Subject: [PATCH 2/2] rename crons --- .../automation/libraries/external/{Cron.sol => ECron.sol} | 4 ++-- .../automation/libraries/internal/{Cron.sol => ICron.sol} | 2 +- .../src/v0.8/automation/testhelpers/CronTestHelper.sol | 4 ++-- .../v0.8/automation/testhelpers/CronUpkeepTestHelper.sol | 6 +++--- contracts/src/v0.8/automation/upkeeps/CronUpkeep.sol | 4 ++-- .../src/v0.8/automation/upkeeps/CronUpkeepDelegate.sol | 4 ++-- contracts/src/v0.8/automation/upkeeps/CronUpkeepFactory.sol | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) rename contracts/src/v0.8/automation/libraries/external/{Cron.sol => ECron.sol} (96%) rename contracts/src/v0.8/automation/libraries/internal/{Cron.sol => ICron.sol} (99%) diff --git a/contracts/src/v0.8/automation/libraries/external/Cron.sol b/contracts/src/v0.8/automation/libraries/external/ECron.sol similarity index 96% rename from contracts/src/v0.8/automation/libraries/external/Cron.sol rename to contracts/src/v0.8/automation/libraries/external/ECron.sol index 0c93c19eda8..f2afb98569d 100644 --- a/contracts/src/v0.8/automation/libraries/external/Cron.sol +++ b/contracts/src/v0.8/automation/libraries/external/ECron.sol @@ -1,6 +1,6 @@ pragma solidity 0.8.6; -import {Cron as CronInternal, Spec} from "../internal/Cron.sol"; +import {ICron as CronInternal, Spec} from "../internal/ICron.sol"; /** * @title The Cron library @@ -10,7 +10,7 @@ import {Cron as CronInternal, Spec} from "../internal/Cron.sol"; * @dev this is the external version of the library, which relies on the internal library * by the same name. */ -library Cron { +library ECron { using CronInternal for Spec; using CronInternal for string; diff --git a/contracts/src/v0.8/automation/libraries/internal/Cron.sol b/contracts/src/v0.8/automation/libraries/internal/ICron.sol similarity index 99% rename from contracts/src/v0.8/automation/libraries/internal/Cron.sol rename to contracts/src/v0.8/automation/libraries/internal/ICron.sol index fe72c412b60..b9229cb9eb9 100644 --- a/contracts/src/v0.8/automation/libraries/internal/Cron.sol +++ b/contracts/src/v0.8/automation/libraries/internal/ICron.sol @@ -84,7 +84,7 @@ struct Field { * abstraction called a Spec. The library also includes a spec function, nextTick(), which * determines the next time a cron job should fire based on the current block timestamp. */ -library Cron { +library ICron { using strings for *; /** diff --git a/contracts/src/v0.8/automation/testhelpers/CronTestHelper.sol b/contracts/src/v0.8/automation/testhelpers/CronTestHelper.sol index f50054715d2..389c21249cf 100644 --- a/contracts/src/v0.8/automation/testhelpers/CronTestHelper.sol +++ b/contracts/src/v0.8/automation/testhelpers/CronTestHelper.sol @@ -2,8 +2,8 @@ pragma solidity 0.8.6; -import {Cron as CronInternal, Spec} from "../libraries/internal/Cron.sol"; -import {Cron as CronExternal} from "../libraries/external/Cron.sol"; +import {ICron as CronInternal, Spec} from "../libraries/internal/ICron.sol"; +import {ECron as CronExternal} from "../libraries/external/ECron.sol"; /** * @title The CronInternalTestHelper contract diff --git a/contracts/src/v0.8/automation/testhelpers/CronUpkeepTestHelper.sol b/contracts/src/v0.8/automation/testhelpers/CronUpkeepTestHelper.sol index 8ede4ea3933..5e04cd735dc 100644 --- a/contracts/src/v0.8/automation/testhelpers/CronUpkeepTestHelper.sol +++ b/contracts/src/v0.8/automation/testhelpers/CronUpkeepTestHelper.sol @@ -3,7 +3,7 @@ pragma solidity 0.8.6; import "../upkeeps/CronUpkeep.sol"; -import {Cron, Spec} from "../libraries/internal/Cron.sol"; +import {ICron, Spec} from "../libraries/internal/ICron.sol"; /** * @title The CronUpkeepTestHelper contract @@ -11,8 +11,8 @@ import {Cron, Spec} from "../libraries/internal/Cron.sol"; * It is only intended for use in tests. */ contract CronUpkeepTestHelper is CronUpkeep { - using Cron for Spec; - using Cron for string; + using ICron for Spec; + using ICron for string; constructor( address owner, diff --git a/contracts/src/v0.8/automation/upkeeps/CronUpkeep.sol b/contracts/src/v0.8/automation/upkeeps/CronUpkeep.sol index 614b84635ab..5aa0448595d 100644 --- a/contracts/src/v0.8/automation/upkeeps/CronUpkeep.sol +++ b/contracts/src/v0.8/automation/upkeeps/CronUpkeep.sol @@ -24,8 +24,8 @@ import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; import "../../shared/access/ConfirmedOwner.sol"; import "../KeeperBase.sol"; import "../interfaces/KeeperCompatibleInterface.sol"; -import {Cron as CronInternal, Spec} from "../libraries/internal/Cron.sol"; -import {Cron as CronExternal} from "../libraries/external/Cron.sol"; +import {ICron as CronInternal, Spec} from "../libraries/internal/ICron.sol"; +import {ECron as CronExternal} from "../libraries/external/ECron.sol"; /** * @title The CronUpkeep contract diff --git a/contracts/src/v0.8/automation/upkeeps/CronUpkeepDelegate.sol b/contracts/src/v0.8/automation/upkeeps/CronUpkeepDelegate.sol index ec2c2a0fd91..d7092c71240 100644 --- a/contracts/src/v0.8/automation/upkeeps/CronUpkeepDelegate.sol +++ b/contracts/src/v0.8/automation/upkeeps/CronUpkeepDelegate.sol @@ -3,7 +3,7 @@ pragma solidity 0.8.6; import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol"; -import {Cron, Spec} from "../libraries/internal/Cron.sol"; +import {ICron, Spec} from "../libraries/internal/ICron.sol"; /** * @title The CronUpkeepDelegate contract @@ -13,7 +13,7 @@ import {Cron, Spec} from "../libraries/internal/Cron.sol"; */ contract CronUpkeepDelegate { using EnumerableSet for EnumerableSet.UintSet; - using Cron for Spec; + using ICron for Spec; address private s_owner; // from ConfirmedOwner address private s_delegate; diff --git a/contracts/src/v0.8/automation/upkeeps/CronUpkeepFactory.sol b/contracts/src/v0.8/automation/upkeeps/CronUpkeepFactory.sol index cd9ae5d7a92..b680a01fd8c 100644 --- a/contracts/src/v0.8/automation/upkeeps/CronUpkeepFactory.sol +++ b/contracts/src/v0.8/automation/upkeeps/CronUpkeepFactory.sol @@ -5,7 +5,7 @@ pragma solidity 0.8.6; import "./CronUpkeep.sol"; import "./CronUpkeepDelegate.sol"; import "../../shared/access/ConfirmedOwner.sol"; -import {Spec, Cron as CronExternal} from "../libraries/external/Cron.sol"; +import {Spec, ECron as CronExternal} from "../libraries/external/ECron.sol"; /** * @title The CronUpkeepFactory contract