Skip to content

Commit

Permalink
Update 'scripts' and 'tasks' to work on Amoy & Sepolia
Browse files Browse the repository at this point in the history
  • Loading branch information
RCantu92 committed Apr 1, 2024
1 parent 4b70158 commit 3749bdc
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 19 deletions.
33 changes: 16 additions & 17 deletions scripts/deployments/stake-delegation.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,66 +100,65 @@ async function migrate(config = {}) {
config.childChainManagerProxy ? fortaConstructorArgs.push(config.childChainManagerProxy) : null;

contracts.rewardsDistributor = await utils.tryFetchProxy(
CACHE,
'staking-rewards',
'RewardsDistributor',
'uups',
[deployment.access.address, ...deployEnv.FEE_PARAMS(chainId)],
[deployment["access-manager"].address, ...deployEnv.FEE_PARAMS(chainId)],
{
constructorArgs: [deployment.forwarder.address, deployment.token.address, deployment['stake-subject-gateway'].address],
constructorArgs: [deployment.forwarder.address, deployment["token"].address, deployment['stake-subject-gateway'].address],
unsafeAllow: ['delegatecall'],
}
},
CACHE
);

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

contracts.stakeAllocator = await utils.tryFetchProxy(CACHE, 'staking-allocator', 'StakeAllocator', 'uups', [deployment.access.address], {
contracts.stakeAllocator = await utils.tryFetchProxy('StakeAllocator', 'uups', [deployment["access-manager"].address], {
constructorArgs: [deployment.forwarder.address, deployment['stake-subject-gateway'].address, contracts.rewardsDistributor.address],
unsafeAllow: ['delegatecall'],
});
}, CACHE);

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

DEBUG(`Deploying ScannerPool registry...`);

contracts.scannerPools = await utils.tryFetchProxy(
CACHE,
'scanner-pools',
'ScannerPoolRegistry',
'uups',
[deployment.access.address, 'Forta Scanner Pools', 'FScannerPools', deployment['stake-subject-gateway'].address, deployEnv.SCANNER_REGISTRATION_DELAY(chainId)],
[deployment["access-manager"].address, 'Forta Scanner Pools', 'FScannerPools', deployment['stake-subject-gateway'].address, deployEnv.SCANNER_REGISTRATION_DELAY(chainId)],
{
constructorArgs: [deployment.forwarder.address, contracts.stakeAllocator.address],
unsafeAllow: 'delegatecall',
}
},
CACHE
);

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

contracts.registryMigration = await utils.tryFetchProxy(CACHE, 'scanner-to-scanner-pool-migration', 'ScannerToScannerPoolMigration', 'uups', [deployment.access.address], {
constructorArgs: [deployment.forwarder.address, deployment.scanners.address, contracts.scannerPools.address, deployment.staking.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) {
contracts.ens = {};

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

DEBUG(`registry: ${contracts.ens.registry.address}`);

contracts.ens.resolver = await ethers
.getContractFactory('PublicResolver', deployer)
.then((factory) => utils.tryFetchContract(CACHE, 'ens-resolver', factory, [contracts.ens.registry.address, ethers.constants.AddressZero]));
.then((factory) => utils.tryFetchContract('PublicResolver', [contracts.ens.registry.address, ethers.constants.AddressZero], CACHE));

DEBUG(`resolver: ${contracts.ens.resolver.address}`);

contracts.ens.reverse = await ethers
.getContractFactory('ReverseRegistrar', deployer)
.then((factory) => utils.tryFetchContract(CACHE, 'ens-reverse', factory, [contracts.ens.registry.address, contracts.ens.resolver.address]));
.then((factory) => utils.tryFetchContract('ReverseRegistrar', [contracts.ens.registry.address, contracts.ens.resolver.address], CACHE));

DEBUG(`reverse: ${contracts.ens.reverse.address}`);

Expand Down
3 changes: 3 additions & 0 deletions scripts/loadEnv.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const ROOT_CHAIN_MANAGER = {
const CHILD_CHAIN_MANAGER_PROXY = {
137: '0xA6FA4fB5f76172d178d61B04b0ecd319C5d1C0aa',
80001: '0xb5505a6d998549090530911180f38aC5130101c6',
80002: '0xb991E39a401136348Dee93C75143B159FabF483f'
};

const CHAIN_TYPE = {
Expand Down Expand Up @@ -65,6 +66,7 @@ const SCANNER_REGISTRATION_DELAY = (chainId) => {
switch (chainId) {
case 5:
case 80001:
case 80002:
case 31337:
return 1000;
default:
Expand All @@ -88,6 +90,7 @@ const FEE_PARAMS = (chainId) => {
switch (chainId) {
case 5:
case 80001:
case 80002:
case 31337:
return [2, 1000];
default:
Expand Down
4 changes: 4 additions & 0 deletions scripts/utils/contractHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ const getBlockExplorerDomain = (hre) => {
return 'polygonscan.com';
case 'mumbai':
return 'mumbai.polygonscan.com';
case 'amoy':
return 'www.oklink.com/amoy';
case 'sepolia':
return 'sepolia.etherscan.io';
}
};

Expand Down
2 changes: 2 additions & 0 deletions scripts/utils/deploymentFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ const CHAIN_NAME = {
5: 'goerli',
137: 'polygon',
80001: 'mumbai',
80002: 'amoy',
31337: 'local',
11155111: 'sepolia'
};

function validateInput(chainId, releaseVersion) {
Expand Down
6 changes: 5 additions & 1 deletion scripts/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ function toEIP3770(chainId, address) {
}

function networkName(chainId) {
return chainsMini.find((c) => c.chainId === chainId)?.name;
if(chainId === 80002) {
return "amoy"
} else {
return chainsMini.find((c) => c.chainId === chainId)?.name;
}
}

/*********************************************************************************************************************
Expand Down
4 changes: 3 additions & 1 deletion tasks/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ async function deployNonUpgradeable(params, deploymentInfo, contract, hre, name,
console.log('Non upgradeable');
console.log(name);
console.log('constructorArgs', constructorArgs);
console.log('opts', params.impl.opts);
// NOTE: If `params` would've had a `.impl` property,
// `deployUpgradeable()` would've been called instead
// console.log('opts', params.impl.opts);
contract = await tryFetchContract(hre, name, constructorArgs, releaseWriter);
console.log('Saving output...');
await saveNonUpgradeable(releaseWriter, name, constructorArgs, contract.address, await getContractVersion(hre, contract));
Expand Down

0 comments on commit 3749bdc

Please sign in to comment.