From a52e3a4596c1e58003c2a18be76388849631b5f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?U=C4=9Fur=20Eren?= Date: Mon, 9 Sep 2024 13:27:57 +0300 Subject: [PATCH] feat: sepolia support for deployment script --- packages/contracts/scripts/deploy.js | 8 ++-- packages/contracts/scripts/libs/contract.js | 41 ++++++++++++++------- 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/packages/contracts/scripts/deploy.js b/packages/contracts/scripts/deploy.js index ce4fd30d..75be3c05 100644 --- a/packages/contracts/scripts/deploy.js +++ b/packages/contracts/scripts/deploy.js @@ -1,5 +1,5 @@ import colors from "colors"; -import { deployFactory, deployTokenLocker } from "./libs/contract.js"; +import { deployFactory, deployLockManager } from "./libs/contract.js"; const MIN_LOCK_TIME = 15_721_200; // 6 months @@ -11,12 +11,12 @@ const main = async () => { console.log(` |_| |___|`.red); // Token Locker - console.log(`\n${"Deploying TokenLocker contract".blue}`); - await deployTokenLocker(MIN_LOCK_TIME); + console.log(`\n${"Deploying LockManager contract".blue}`); + const { lockManager } = await deployLockManager(MIN_LOCK_TIME); // Factory console.log(`\n${"Deploying Factory contract".blue}`); - await deployFactory(); + await deployFactory(lockManager); }; main(); diff --git a/packages/contracts/scripts/libs/contract.js b/packages/contracts/scripts/libs/contract.js index f00d74c9..7772e5e2 100644 --- a/packages/contracts/scripts/libs/contract.js +++ b/packages/contracts/scripts/libs/contract.js @@ -24,15 +24,26 @@ const getContracts = () => { return contracts; }; -const getTokenLockerPath = () => { +const getLockPositionPath = () => { const contracts = getContracts(); - const tokenLocker = contracts.find((contract) => - contract.includes("TokenLocker"), + const lockPosition = contracts.find((contract) => + contract.includes("LockPosition"), ); - if (!tokenLocker) { - throw new Error("TokenLocker contract not found. Run `scarb build` first"); + if (!lockPosition) { + throw new Error("LockPosition contract not found. Run `scarb build` first"); } - return path.join(TARGET_PATH, tokenLocker); + return path.join(TARGET_PATH, lockPosition); +}; + +const getLockManagerPath = () => { + const contracts = getContracts(); + const lockManager = contracts.find((contract) => + contract.includes("LockManager"), + ); + if (!lockManager) { + throw new Error("LockManager contract not found. Run `scarb build` first"); + } + return path.join(TARGET_PATH, lockManager); }; const getUnruggableMemecoinPath = () => { @@ -88,19 +99,20 @@ const declare = async (filepath, contract_name) => { return contract; }; -export const deployTokenLocker = async (min_lock_time) => { +export const deployLockManager = async (min_lock_time) => { // Load account const account = getAccount(); // Declare contract - const locker = await declare(getTokenLockerPath(), "TokenLocker"); + const lockManager = await declare(getLockManagerPath(), "LockManager"); + const lockPosition = await declare(getLockPositionPath(), "LockPosition"); // Deploy contract - console.log(`\nDeploying TokenLocker...`.green); + console.log(`\nDeploying LockManager...`.green); console.log("Min lock time: ".green, min_lock_time); const contract = await account.deployContract({ - classHash: locker.class_hash, - constructorCalldata: [min_lock_time], + classHash: lockManager.class_hash, + constructorCalldata: [min_lock_time, lockPosition.class_hash], }); // Wait for transaction @@ -110,9 +122,11 @@ export const deployTokenLocker = async (min_lock_time) => { `${network.explorer_url}/tx/${contract.transaction_hash})`, ); await account.waitForTransaction(contract.transaction_hash); + + return { lockManager: contract.address } }; -export const deployFactory = async () => { +export const deployFactory = async (lockManagerAddress) => { // Load account const account = getAccount(); @@ -133,9 +147,10 @@ export const deployFactory = async () => { const contract = await account.deployContract({ classHash: factory.class_hash, constructorCalldata: [ - process.env.STARKNET_ACCOUNT_ADDRESS, memecoin.class_hash, + lockManagerAddress, exchanges, + [] ], });