Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
olegkron committed Sep 17, 2024
1 parent 7cf553c commit 5386585
Show file tree
Hide file tree
Showing 53 changed files with 103 additions and 183 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const functionsGatewayUrls = {
testnet: ["https://01.functions-gateway.testnet.chain.link/", "https://02.functions-gateway.testnet.chain.link/"],
};

const CNetworks: Record<CNetworkNames, CNetwork> = {
export const cNetworks: Record<CNetworkNames, CNetwork> = {
localhost: {
accounts: [deployerPK, proxyDeployerPK],
// mock CLF data
Expand Down Expand Up @@ -375,4 +375,4 @@ const CNetworks: Record<CNetworkNames, CNetwork> = {
name: "avalanche",
},
};
export default CNetworks;
export default cNetworks;
4 changes: 2 additions & 2 deletions packages/hardhat/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import secrets from "./CLFSecrets";
import CLFnetworks from "./CLFnetworks";
import CLFSimulationConfig from "./CLFSimulationConfig";
import CNetworks, { functionsGatewayUrls, networkEnvKeys, networkTypes } from "./CNetworks";
import { cNetworks, functionsGatewayUrls, networkEnvKeys, networkTypes } from "./cNetworks";
import {
envPrefixes,
messengers,
Expand All @@ -18,7 +18,7 @@ export {
secrets,
CLFnetworks,
CLFSimulationConfig,
CNetworks,
cNetworks,
networkTypes,
networkEnvKeys,
functionsGatewayUrls,
Expand Down
2 changes: 1 addition & 1 deletion packages/hardhat/constants/liveChains.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CNetwork } from "../types/CNetwork";
import chains from "./CNetworks";
import chains from "./cNetworks";
import { ConceroChains } from "../types/chains";

// export const liveChains: CNetwork[] = [
Expand Down
6 changes: 3 additions & 3 deletions packages/hardhat/deploy/01_ConceroFakePool.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Deployment } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import chains from "../constants/CNetworks";
import CNetworks, { networkEnvKeys } from "../constants/CNetworks";
import chains from "../constants/cNetworks";
import cNetworks, { networkEnvKeys } from "../constants/cNetworks";
import updateEnvVariable from "../utils/updateEnvVariable";
import log from "../utils/log";
import { getEnvVar } from "../utils";
Expand All @@ -16,7 +16,7 @@ const deployConceroPool: (hre: HardhatRuntimeEnvironment, constructorArgs?: Cons
const { deployer } = await hre.getNamedAccounts();
const { deploy } = hre.deployments;
const { name, live } = hre.network;
const networkType = CNetworks[name].type;
const networkType = cNetworks[name].type;

const { linkToken, ccipRouter } = chains[name];

Expand Down
4 changes: 2 additions & 2 deletions packages/hardhat/deploy/03_ConceroDexSwap.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Deployment } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import CNetworks, { networkEnvKeys } from "../constants/CNetworks";
import cNetworks, { networkEnvKeys } from "../constants/cNetworks";
import updateEnvVariable from "../utils/updateEnvVariable";
import log from "../utils/log";
import { getEnvVar } from "../utils";
Expand All @@ -12,7 +12,7 @@ const deployConceroDexSwap: (hre: HardhatRuntimeEnvironment) => Promise<void> =
const { deployer } = await hre.getNamedAccounts();
const { deploy } = hre.deployments;
const { name, live } = hre.network;
const networkType = CNetworks[name].type;
const networkType = cNetworks[name].type;

const conceroProxyAddress = getEnvVar(`CONCERO_INFRA_PROXY_${networkEnvKeys[name]}`);

Expand Down
2 changes: 1 addition & 1 deletion packages/hardhat/deploy/04_ConceroBridge.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Deployment } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import chains, { networkEnvKeys } from "../constants/CNetworks";
import chains, { networkEnvKeys } from "../constants/cNetworks";
import updateEnvVariable from "../utils/updateEnvVariable";
import log from "../utils/log";
import path from "path";
Expand Down
2 changes: 1 addition & 1 deletion packages/hardhat/deploy/05_ConceroOrchestrator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Deployment } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import chains, { networkEnvKeys } from "../constants/CNetworks";
import chains, { networkEnvKeys } from "../constants/cNetworks";
import updateEnvVariable from "../utils/updateEnvVariable";
import log from "../utils/log";
import { getEnvVar } from "../utils";
Expand Down
2 changes: 1 addition & 1 deletion packages/hardhat/deploy/06_ConceroAutomation.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// import { Deployment } from "hardhat-deploy/types";
// import { HardhatRuntimeEnvironment } from "hardhat/types";
// import chains, { networkEnvKeys } from "../constants/CNetworks";
// import chains, { networkEnvKeys } from "../constants/cNetworks";
// import updateEnvVariable from "../utils/updateEnvVariable";
// import log from "../utils/log";
// import getHashSum from "../utils/getHashSum";
Expand Down
4 changes: 2 additions & 2 deletions packages/hardhat/deploy/07_LPToken.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Deployment } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import CNetworks, { networkEnvKeys } from "../constants/CNetworks";
import cNetworks, { networkEnvKeys } from "../constants/cNetworks";
import updateEnvVariable from "../utils/updateEnvVariable";
import log from "../utils/log";
import { getEnvVar } from "../utils";
Expand All @@ -15,7 +15,7 @@ const deployLPToken: (hre: HardhatRuntimeEnvironment, constructorArgs?: Construc
const { proxyDeployer } = await hre.getNamedAccounts();
const { deploy } = hre.deployments;
const { name, live } = hre.network;
const networkType = CNetworks[name].type;
const networkType = cNetworks[name].type;

const defaultArgs = {
parentProxyAddress: getEnvVar(`PARENT_POOL_PROXY_${networkEnvKeys[name]}`),
Expand Down
2 changes: 1 addition & 1 deletion packages/hardhat/deploy/08_ChildPool.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Deployment } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import chains, { networkEnvKeys } from "../constants/CNetworks";
import chains, { networkEnvKeys } from "../constants/cNetworks";
import updateEnvVariable from "../utils/updateEnvVariable";
import log from "../utils/log";
import { getEnvVar } from "../utils";
Expand Down
2 changes: 1 addition & 1 deletion packages/hardhat/deploy/09_ParentPool.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Deployment } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import chains, { networkEnvKeys } from "../constants/CNetworks";
import chains, { networkEnvKeys } from "../constants/cNetworks";
import updateEnvVariable from "../utils/updateEnvVariable";
import log from "../utils/log";
import { getEnvVar } from "../utils";
Expand Down
4 changes: 2 additions & 2 deletions packages/hardhat/deploy/10_ConceroProxyAdmin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Deployment } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import CNetworks from "../constants/CNetworks";
import cNetworks from "../constants/cNetworks";
import { getEnvVar, updateEnvAddress } from "../utils";
import log from "../utils/log";

Expand All @@ -13,7 +13,7 @@ const deployProxyAdmin: (hre: HardhatRuntimeEnvironment, proxyType: IProxyType)
const { proxyDeployer } = await hre.getNamedAccounts();
const { deploy } = hre.deployments;
const { name, live } = hre.network;
const networkType = CNetworks[name].type;
const networkType = cNetworks[name].type;

const initialOwner = getEnvVar(`PROXY_DEPLOYER_ADDRESS`);

Expand Down
4 changes: 2 additions & 2 deletions packages/hardhat/deploy/11_TransparentProxy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Deployment } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import CNetworks from "../constants/CNetworks";
import cNetworks from "../constants/cNetworks";
import { updateEnvAddress } from "../utils/updateEnvVariable";
import log from "../utils/log";
import { getEnvAddress } from "../utils/getEnvVar";
Expand All @@ -12,7 +12,7 @@ const deployTransparentProxy: (hre: HardhatRuntimeEnvironment, proxyType: IProxy
const { proxyDeployer } = await hre.getNamedAccounts();
const { deploy } = hre.deployments;
const { name, live } = hre.network;
const networkType = CNetworks[name].type;
const networkType = cNetworks[name].type;

const [initialImplementation, initialImplementationAlias] = getEnvAddress("pause", name);
const [proxyAdmin, proxyAdminAlias] = getEnvAddress(`${proxyType}Admin`, name);
Expand Down
4 changes: 2 additions & 2 deletions packages/hardhat/deploy/12_PauseDummy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Deployment } from "hardhat-deploy/types";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import CNetworks, { networkEnvKeys } from "../constants/CNetworks";
import cNetworks, { networkEnvKeys } from "../constants/cNetworks";
import updateEnvVariable from "../utils/updateEnvVariable";
import log from "../utils/log";

Expand All @@ -10,7 +10,7 @@ const deployPauseDummy: (hre: HardhatRuntimeEnvironment) => Promise<void> = asyn
const { deployer } = await hre.getNamedAccounts();
const { deploy } = hre.deployments;
const { name, live } = hre.network;
const networkType = CNetworks[name].type;
const networkType = cNetworks[name].type;

console.log("Deploying...", "deployPauseDummy", name);

Expand Down
4 changes: 2 additions & 2 deletions packages/hardhat/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import "hardhat-contract-sizer";
import { HardhatUserConfig } from "hardhat/config";
import "solidity-coverage";
import "@chainlink/hardhat-chainlink";
import CNetworks from "./constants/CNetworks";
import cNetworks from "./constants/cNetworks";
import "./tasks";
import { setup as setupTenderly } from "@tenderly/hardhat-tenderly";

Expand Down Expand Up @@ -51,7 +51,7 @@ const config: HardhatUserConfig = {
default: 1,
},
},
networks: CNetworks,
networks: cNetworks,
etherscan: {
apiKey: {
avalancheFuji: "snowtrace",
Expand Down
2 changes: 1 addition & 1 deletion packages/hardhat/tasks/CLF/donSecrets/list.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SecretsManager } from "@chainlink/functions-toolkit";
import chains from "../../../constants/CNetworks";
import chains from "../../../constants/cNetworks";
import { task } from "hardhat/config";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { liveChains } from "../../concero/deployInfra/deployInfra";
Expand Down
2 changes: 1 addition & 1 deletion packages/hardhat/tasks/CLF/donSecrets/upload.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { task, types } from "hardhat/config";
import { SecretsManager } from "@chainlink/functions-toolkit";
import chains, { networkEnvKeys } from "../../../constants/CNetworks";
import chains, { networkEnvKeys } from "../../../constants/cNetworks";
import secrets from "../../../constants/CLFSecrets";
import updateEnvVariable from "../../../utils/updateEnvVariable";
import { CNetwork } from "../../../types/CNetwork";
Expand Down
2 changes: 1 addition & 1 deletion packages/hardhat/tasks/CLF/subscriptions/accept.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { task } from "hardhat/config";
import chains from "../../../constants/CNetworks";
import chains from "../../../constants/cNetworks";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import log from "../../../utils/log";
import { formatEther } from "viem";
Expand Down
2 changes: 1 addition & 1 deletion packages/hardhat/tasks/CLF/subscriptions/add.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SubscriptionManager } from "@chainlink/functions-toolkit";
import chains from "../../../constants/CNetworks";
import chains from "../../../constants/cNetworks";
import { task } from "hardhat/config";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { CNetwork } from "../../../types/CNetwork";
Expand Down
2 changes: 1 addition & 1 deletion packages/hardhat/tasks/CLF/subscriptions/fund.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { task } from "hardhat/config";
import { SubscriptionManager } from "@chainlink/functions-toolkit";
import chains from "../../../constants/CNetworks";
import chains from "../../../constants/cNetworks";
import { formatEther } from "viem";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import log from "../../../utils/log";
Expand Down
14 changes: 9 additions & 5 deletions packages/hardhat/tasks/CLF/subscriptions/info.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { task } from "hardhat/config";
import { SubscriptionManager } from "@chainlink/functions-toolkit";
import chains from "../../../constants/CNetworks";
import chains from "../../../constants/cNetworks";
import { formatEther } from "viem";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { getEthersV5FallbackSignerAndProvider } from "../../../utils/getEthersSignerAndProvider";
Expand All @@ -15,12 +15,16 @@ task(
const hre: HardhatRuntimeEnvironment = require("hardhat");

const { name, live } = hre.network;
const {linkToken, functionsRouter, functionsSubIds} = chains[name];
const { linkToken, functionsRouter, functionsSubIds } = chains[name];

const subscriptionId = taskArgs.subid? parseInt(taskArgs.subid) : functionsSubIds[0];
const subscriptionId = taskArgs.subid ? parseInt(taskArgs.subid) : functionsSubIds[0];

const { signer } = await getEthersV5FallbackSignerAndProvider(name)
const sm = new SubscriptionManager({ signer, linkTokenAddress:linkToken, functionsRouterAddress: functionsRouter });
const { signer } = await getEthersV5FallbackSignerAndProvider(name);
const sm = new SubscriptionManager({
signer,
linkTokenAddress: linkToken,
functionsRouterAddress: functionsRouter,
});
await sm.initialize();
console.log(`Getting info for subscription ${subscriptionId}...`);

Expand Down
2 changes: 1 addition & 1 deletion packages/hardhat/tasks/CLF/subscriptions/remove.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import chains from "../../../constants/CNetworks";
import chains from "../../../constants/cNetworks";
import { task, types } from "hardhat/config";
import { SubscriptionManager, TransactionOptions } from "@chainlink/functions-toolkit";

Expand Down
2 changes: 1 addition & 1 deletion packages/hardhat/tasks/CLF/subscriptions/timeout.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { task, types } from "hardhat/config";
import { fetchRequestCommitment, SubscriptionManager, TransactionOptions } from "@chainlink/functions-toolkit";
import chains from "../../../constants/CNetworks";
import chains from "../../../constants/cNetworks";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { getEthersV6FallbackSignerAndProvider } from "../../../utils/getEthersSignerAndProvider";

Expand Down
2 changes: 1 addition & 1 deletion packages/hardhat/tasks/CLF/subscriptions/transfer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { task } from "hardhat/config";
import { SubscriptionManager, TransactionOptions } from "@chainlink/functions-toolkit";
import chains from "../../../constants/CNetworks";
import chains from "../../../constants/cNetworks";

import { HardhatRuntimeEnvironment } from "hardhat/types";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var __importDefault =
Object.defineProperty(exports, "__esModule", { value: true });
const config_1 = require("hardhat/config");
const functions_toolkit_1 = require("@chainlink/functions-toolkit");
const CNetworks_1 = __importDefault(require("../../../../constants/CNetworks"));
const CNetworks_1 = __importDefault(require("../../../../constants/cNetworks"));
(0, config_1.task)("clf-sub-transfer", "Request ownership of an Functions subscription be transferred to a new address")
.addParam("subid", "Subscription ID")
.addParam("newowner", "Address of the new owner")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// import networks from "../../../constants/CLFnetworks";
// import { HardhatRuntimeEnvironment } from "hardhat/types";
//
// import chains from "../../../constants/CNetworks";
// import chains from "../../../constants/cNetworks";
//
// const utils = require("../../utils");
// const chalk = require("chalk");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import chains from "../../../../constants/CNetworks";
import chains from "../../../../constants/cNetworks";
import { task } from "hardhat/config";

task(
Expand Down
4 changes: 2 additions & 2 deletions packages/hardhat/tasks/concero/callFunction.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { getEnvVar, getFallbackClients } from "../../utils";
import log from "../../utils/log";
import { task } from "hardhat/config";
import CNetworks, { networkEnvKeys } from "../../constants/CNetworks";
import cNetworks, { networkEnvKeys } from "../../constants/cNetworks";

export async function callContractFunction() {
const chain = CNetworks.base;
const chain = cNetworks.base;

const { walletClient, publicClient, account } = getFallbackClients(chain);
const gasPrice = await publicClient.getGasPrice();
Expand Down
4 changes: 2 additions & 2 deletions packages/hardhat/tasks/concero/changeOwnership.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import CNetworks from "../../constants/CNetworks";
import cNetworks from "../../constants/cNetworks";
import { privateKeyToAccount } from "viem/accounts";
import log from "../../utils/log";
import { task } from "hardhat/config";
Expand All @@ -9,7 +9,7 @@ import { getFallbackClients } from "../../utils/getViemClients";
export async function changeOwnership(hre, targetContract, newOwner: string) {
const { name: chainName } = hre.network;
const chainId = hre.network.config.chainId;
const { viemChain, url } = CNetworks[chainName];
const { viemChain, url } = cNetworks[chainName];

if (!viemChain) {
log(`Chain ${chainId} not found in live chains`, "changeOwnership");
Expand Down
4 changes: 2 additions & 2 deletions packages/hardhat/tasks/concero/decodeClfFulfill.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { task } from "hardhat/config";
import CNetworks from "../../constants/CNetworks";
import cNetworks from "../../constants/cNetworks";
import { getFallbackClients } from "../../utils/getViemClients";
import { decodeAbiParameters, parseAbiParameters } from "viem";

Expand All @@ -23,7 +23,7 @@ const reportAbiParameters = parseAbiParameters([
task("decode-clf-fulfill", "Decodes CLF TX to get signers and fulfillment data")
.addParam("txhash", "Transaction hash to decode")
.setAction(async taskArgs => {
const chain = CNetworks[hre.network.name];
const chain = cNetworks[hre.network.name];
const { publicClient } = getFallbackClients(chain);
const tx = await publicClient.getTransaction({
hash: taskArgs.txhash,
Expand Down
4 changes: 2 additions & 2 deletions packages/hardhat/tasks/concero/deleteDepositsOTWIds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { getFallbackClients } from "../../utils/getViemClients";
import { getEnvAddress } from "../../utils/getEnvVar";
import log from "../../utils/log";
import { task } from "hardhat/config";
import CNetworks from "../../constants/CNetworks";
import cNetworks from "../../constants/cNetworks";

export async function deleteDepositsOTWIds() {
const chain = CNetworks.base;
const chain = cNetworks.base;

const { walletClient, publicClient, account } = getFallbackClients(chain);
const gasPrice = await publicClient.getGasPrice();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { task, types } from "hardhat/config";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import deployConceroAutomation from "../../../deploy/06_ConceroAutomation";
import { setAutomationsVariables } from "./setAutomationsVariables";
import CNetworks, { networkEnvKeys } from "../../../constants/CNetworks";
import cNetworks, { networkEnvKeys } from "../../../constants/cNetworks";
import { compileContracts, getEnvVar, getFallbackClients } from "../../../utils";
import addCLFConsumer from "../../CLF/subscriptions/add";
import log from "../../../utils/log";
Expand All @@ -20,7 +20,7 @@ task("deploy-pool-clfcla", "Deploy the automations")
const hre: HardhatRuntimeEnvironment = require("hardhat");
const { name } = hre.network;
const slotId = parseInt(taskArgs.slotid);
const chain = CNetworks[name];
const chain = cNetworks[name];
const { viemChain } = chain;
if (!taskArgs.skipdeploy) {
await deployConceroAutomation(hre, { slotId });
Expand Down
Loading

0 comments on commit 5386585

Please sign in to comment.