Skip to content

Commit

Permalink
Update task/script file for Base Sepolia
Browse files Browse the repository at this point in the history
  • Loading branch information
RCantu92 committed Apr 4, 2024
1 parent 41ebfc3 commit c6eb9f9
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 23 deletions.
50 changes: 30 additions & 20 deletions scripts/deployments/stake-delegation.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,15 @@ const registerNode = async (name, owner, opts = {}) => {

const reverseRegister = async (contract, name) => {
const reverseResolved = await contract.provider.lookupAddress(contract.address);
// console.log(`\ncontract.signer: ${contract.signer.address}`);
// console.log(`contract.address: ${contract.address} | reverseResolved: ${reverseResolved}`);
if (reverseResolved != name) {
// console.log(`contract.provider.network.ensAddress: ${contract.provider.network.ensAddress} | name: ${name}`);
await contract
.setName(contract.provider.network.ensAddress, name)
.then((tx) => tx.wait())
.catch((e) => DEBUG(e));
// .catch((e) => console.log(e))
}
};

Expand All @@ -83,17 +87,17 @@ async function migrate(config = {}) {
if (config?.force) {
CACHE.clear();
}
config.childChain = config.childChain ? config.childChain : !!deployEnv.CHILD_CHAIN_MANAGER_PROXY[chainId];
config.childChainManagerProxy = config.childChainManagerProxy ?? deployEnv.CHILD_CHAIN_MANAGER_PROXY[chainId];
// config.childChain = config.childChain ? config.childChain : !!deployEnv.CHILD_CHAIN_MANAGER_PROXY[chainId];
// config.childChainManagerProxy = config.childChainManagerProxy ?? deployEnv.CHILD_CHAIN_MANAGER_PROXY[chainId];
config.chainsToDeploy = config.chainsToDeploy ?? ['L1', 'L2'];
const contracts = {};
const slashParams = {};

const hardhatDeployment = chainId === 31337;

const fortaConstructorArgs = [];
DEBUG('config.childChain', config.childChain);
DEBUG('config.childChainManagerProxy', config.childChainManagerProxy);
// DEBUG('config.childChain', config.childChain);
// DEBUG('config.childChainManagerProxy', config.childChainManagerProxy);

// For test compatibility: since we need to mint and FortaBridgedPolygon does not mint(), we base our decision to deploy
// FortaBridgedPolygon is based on the existence of childChainManagerProxy, not childChain
Expand Down Expand Up @@ -134,18 +138,24 @@ async function migrate(config = {}) {

DEBUG(`[${Object.keys(contracts).length}] scannerPools: ${contracts.scannerPools.address}`);

contracts.registryMigration = await utils.tryFetchProxy('ScannerToScannerPoolMigration', 'uups', [deployment["access-manager"].address], {
constructorArgs: [deployment.forwarder.address, deployment["scanner-registry"].address, contracts.scannerPools.address, deployment["forta-staking"].address],
unsafeAllow: 'delegatecall',
contracts.subjectGateway = await utils.tryFetchProxy('StakeSubjectGateway', 'uups', [deployment["access-manager"].address, deployment["forta-staking"].address], {
constructorArgs: [deployment.forwarder.address],
unsafeAllow: ['delegatecall'],
}, CACHE);

DEBUG(`[${Object.keys(contracts).length}.1] stake allocator: ${contracts.subjectGateway.address}`);

// contracts.registryMigration = await utils.tryFetchProxy('ScannerToScannerPoolMigration', 'uups', [deployment["access-manager"].address], {
// constructorArgs: [deployment.forwarder.address, deployment["scanner-registry"].address, contracts.scannerPools.address, deployment["forta-staking"].address],
// unsafeAllow: 'delegatecall',
// }, CACHE);

DEBUG(`roles fetched`);

if (!hardhatDeployment) {
if (!provider.network.ensAddress) {
// if (!provider.network.ensAddress) {
contracts.ens = {};

// (hre, contractName, args = [], cache)
contracts.ens.registry = await ethers.getContractFactory('ENSRegistry', deployer).then((factory) => utils.tryFetchContract('ENSRegistry', [], CACHE));

DEBUG(`registry: ${contracts.ens.registry.address}`);
Expand All @@ -167,31 +177,31 @@ async function migrate(config = {}) {

// ens registration

if (config.childChain) {
// if (config.childChain) {
await Promise.all([
registerNode('staking-subjects.forta.eth', deployer.address, { ...contracts.ens, resolved: contracts.subjectGateway.address, chainId: chainId }),
registerNode('scanner-pools.registries.forta.eth', deployer.address, { ...contracts.ens, resolved: contracts.scannerPools.address, chainId: chainId }),
registerNode('rewards.forta.eth', deployer.address, { ...contracts.ens, resolved: contracts.rewardsDistributor.address, chainId: chainId }),
]);
}
// }

DEBUG('ens configuration');
} else {
contracts.ens = {};
const ensRegistryAddress = await CACHE.get('ens-registry');
contracts.ens.registry = ensRegistryAddress ? await utils.attach('ENSRegistry', ensRegistryAddress) : null;
const ensResolverAddress = await CACHE.get('ens-resolver');
contracts.ens.resolver = ensRegistryAddress ? await utils.attach('PublicResolver', ensResolverAddress) : null;
}
// } else {
// contracts.ens = {};
// const ensRegistryAddress = await CACHE.get('ens-registry');
// contracts.ens.registry = ensRegistryAddress ? await utils.attach('ENSRegistry', ensRegistryAddress) : null;
// const ensResolverAddress = await CACHE.get('ens-resolver');
// contracts.ens.resolver = ensRegistryAddress ? await utils.attach('PublicResolver', ensResolverAddress) : null;
// }
DEBUG('Starting reverse registration...');
var reverseRegisters = [];
if (config.childChain) {
// if (config.childChain) {
reverseRegisters = reverseRegisters.concat([
reverseRegister(contracts.subjectGateway, 'staking-subjects.forta.eth'),
reverseRegister(contracts.scannerPools, 'scanner-pools.registries.forta.eth'),
reverseRegister(contracts.rewardsDistributor, 'rewards.forta.eth'),
]);
}
// }
await Promise.all(reverseRegisters);

DEBUG('reverse registration');
Expand Down
2 changes: 2 additions & 0 deletions scripts/loadEnv.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const SCANNER_REGISTRATION_DELAY = (chainId) => {
case 5:
case 80001:
case 80002:
case 84532:
case 31337:
return 1000;
default:
Expand All @@ -91,6 +92,7 @@ const FEE_PARAMS = (chainId) => {
case 5:
case 80001:
case 80002:
case 84532:
case 31337:
return [2, 1000];
default:
Expand Down
1 change: 1 addition & 0 deletions scripts/utils/deploymentFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const CHAIN_NAME = {
137: 'polygon',
80001: 'mumbai',
80002: 'amoy',
84532: 'basesepolia',
31337: 'local',
11155111: 'sepolia'
};
Expand Down
8 changes: 5 additions & 3 deletions scripts/utils/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const DEBUG = require('debug')('forta:utils');
const EthDater = require('block-by-date-ethers');
const process = require('process');
// const contractHelpers = require('./contractHelpers');
const contractHelpers = require('./contractHelpers');
require('./arrays');
const chainsMini = require('./chainsMini.json');

Expand Down Expand Up @@ -69,6 +69,8 @@ function toEIP3770(chainId, address) {
function networkName(chainId) {
if(chainId === 80002) {
return "amoy"
} else if(chainId === 84532) {
return "basesepolia"
} else {
return chainsMini.find((c) => c.chainId === chainId)?.name;
}
Expand Down Expand Up @@ -104,7 +106,7 @@ function durationToSeconds(duration) {
}

module.exports = {
/*
// /*
getDefaultProvider: (baseProvider, feeData) => contractHelpers.getDefaultProvider(hre, baseProvider, feeData),
getDefaultDeployer: (provider, baseDeployer, network) => contractHelpers.getDefaultDeployer(hre, provider, baseDeployer, network),
getFactory: (name) => contractHelpers.getFactory(hre, name),
Expand All @@ -117,7 +119,7 @@ module.exports = {
tryFetchProxy: (contractName, kind, args, opts, cache) => contractHelpers.tryFetchProxy(hre, contractName, kind, args, opts, cache),
getContractVersion: (contract, deployParams) => contractHelpers.getContractVersion(hre, contract, deployParams),
getBlockExplorerDomain: () => contractHelpers.getBlockExplorerDomain(hre),
*/
// */
dateToTimestamp,
durationToSeconds,
getEventsFromTx,
Expand Down

0 comments on commit c6eb9f9

Please sign in to comment.