Skip to content

Commit

Permalink
misc: fixes after merging branches
Browse files Browse the repository at this point in the history
  • Loading branch information
vicnaum committed Jan 4, 2025
1 parent 9961155 commit 9533c22
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 91 deletions.
8 changes: 4 additions & 4 deletions contracts/dashboard/factories/AppFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ contract AppFactory {
event Lens_AppFactory_Deployment(address indexed app, string metadataURI, KeyValue[] extraData);

address internal immutable _beacon;
address internal immutable _proxyAdminLock;
address internal immutable _lock;

constructor(address beacon, address proxyAdminLock) {
constructor(address beacon, address lock) {
_beacon = beacon;
_proxyAdminLock = proxyAdminLock;
_lock = lock;
}

function deployApp(
Expand All @@ -28,7 +28,7 @@ contract AppFactory {
AppInitialProperties calldata initialProperties,
KeyValue[] calldata extraData
) external returns (address) {
address proxyAdmin = address(new ProxyAdmin(proxyAdminOwner, _proxyAdminLock));
address proxyAdmin = address(new ProxyAdmin(proxyAdminOwner, _lock));
App app = App(address(new BeaconProxy(proxyAdmin, _beacon)));
app.initialize(metadataURI, sourceStampVerificationEnabled, accessControl, initialProperties, extraData);
emit Lens_AppFactory_Deployment(address(app), metadataURI, extraData);
Expand Down
8 changes: 4 additions & 4 deletions contracts/dashboard/factories/FeedFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ contract FeedFactory {

IAccessControl internal immutable _factoryOwnedAccessControl;
address internal immutable _beacon;
address internal immutable _proxyAdminLock;
address internal immutable _lock;

constructor(address beacon, address proxyAdminLock) {
constructor(address beacon, address lock) {
_factoryOwnedAccessControl = new RoleBasedAccessControl({owner: address(this)});
_beacon = beacon;
_proxyAdminLock = proxyAdminLock;
_lock = lock;
}

function deployFeed(
Expand All @@ -30,7 +30,7 @@ contract FeedFactory {
RuleChange[] calldata ruleChanges,
KeyValue[] calldata extraData
) external returns (address) {
address proxyAdmin = address(new ProxyAdmin(proxyAdminOwner, _proxyAdminLock));
address proxyAdmin = address(new ProxyAdmin(proxyAdminOwner, _lock));
Feed feed = Feed(address(new BeaconProxy(proxyAdmin, _beacon)));
feed.initialize(metadataURI, _factoryOwnedAccessControl);
feed.changeFeedRules(ruleChanges);
Expand Down
145 changes: 74 additions & 71 deletions deploy/deployAux.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,100 +110,104 @@ async function deployLensAccount(lensFactory: ethers.Contract): Promise<string>

async function deployLensFeed(lensFactory: ethers.Contract): Promise<string> {
const contractName = 'Feed';
const existingContract = loadContractFromAddressBook(contractName);
const name = "LensGlobal" + contractName;
const existingContract = loadContractFromAddressBook(name);
if (existingContract && existingContract.address) {
console.log(`${contractName} already deployed at ${existingContract.address}. Skipping...`);
console.log(`${name} already deployed at ${existingContract.address}. Skipping...`);
return existingContract.address;
}

console.log('Deploying Feed');
console.log('Deploying ' + name);
const transaction = await lensFactory.deployFeed(metadataURI, getWallet().address, [], [], []);

const txReceipt = (await transaction.wait()) as ethers.TransactionReceipt;
const events = parseLensContractDeployedEventsFromReceipt(txReceipt);
const feedAddress = getAddressFromEvents(events, 'feed');
const accessControlAddress = getAddressFromEvents(events, 'access-control');
const primitiveAddress = getAddressFromEvents(events, contractName.toLowerCase());
// const accessControlAddress = getAddressFromEvents(events, 'access-control');

await verifyPrimitive('Feed', feedAddress, [metadataURI, accessControlAddress]);
// await verifyPrimitive(contractName, primitiveAddress, [metadataURI, accessControlAddress]);

saveContractToAddressBook({
name: 'LensGlobalFeed',
contractName: 'Feed',
name: name,
contractName: contractName,
contractType: ContractType.Primitive,
address: feedAddress
address: primitiveAddress
});

return feedAddress;
return primitiveAddress;
}

async function deployLensGroup(lensFactory: ethers.Contract): Promise<string> {
const contractName = 'Group';
const existingContract = loadContractFromAddressBook(contractName);
const name = "LensGlobal" + contractName;
const existingContract = loadContractFromAddressBook(name);
if (existingContract && existingContract.address) {
console.log(`${contractName} already deployed at ${existingContract.address}. Skipping...`);
console.log(`${name} already deployed at ${existingContract.address}. Skipping...`);
return existingContract.address;
}

console.log('Deploying Group');
console.log('Deploying ' + name);
const transaction = await lensFactory.deployGroup(metadataURI, getWallet().address, [], [], []);

const txReceipt = (await transaction.wait()) as ethers.TransactionReceipt;
const events = parseLensContractDeployedEventsFromReceipt(txReceipt);
const groupAddress = getAddressFromEvents(events, 'group');
const accessControlAddress = getAddressFromEvents(events, 'access-control');
const primitiveAddress = getAddressFromEvents(events, contractName.toLowerCase());
// const accessControlAddress = getAddressFromEvents(events, 'access-control');

await verifyPrimitive('Group', groupAddress, [metadataURI, accessControlAddress]);
// await verifyPrimitive(contractName, primitiveAddress, [metadataURI, accessControlAddress]);

saveContractToAddressBook({
name: 'LensGlobalGroup',
contractName: 'Group',
name: name,
contractName: contractName,
contractType: ContractType.Primitive,
address: groupAddress
address: primitiveAddress
});

return groupAddress;
return primitiveAddress;
}

async function deployLensGraph(lensFactory: ethers.Contract): Promise<string> {
const contractName = 'Graph';
const existingContract = loadContractFromAddressBook(contractName);
const name = "LensGlobal" + contractName;
const existingContract = loadContractFromAddressBook(name);
if (existingContract && existingContract.address) {
console.log(`${contractName} already deployed at ${existingContract.address}. Skipping...`);
console.log(`${name} already deployed at ${existingContract.address}. Skipping...`);
return existingContract.address;
}

console.log('Deploying Graph');
console.log('Deploying ' + name);
const transaction = await lensFactory.deployGraph(metadataURI, getWallet().address, [], [], []);

const txReceipt = (await transaction.wait()) as ethers.TransactionReceipt;
const events = parseLensContractDeployedEventsFromReceipt(txReceipt);
const graphAddress = getAddressFromEvents(events, 'graph');
const accessControlAddress = getAddressFromEvents(events, 'access-control');
const primitiveAddress = getAddressFromEvents(events, contractName.toLowerCase());
// const accessControlAddress = getAddressFromEvents(events, 'access-control');

await verifyPrimitive('Graph', graphAddress, [metadataURI, accessControlAddress]);
// await verifyPrimitive(contractName, primitiveAddress, [metadataURI, accessControlAddress]);

saveContractToAddressBook({
name: 'LensGlobalGraph',
contractName: 'Graph',
name: name,
contractName: contractName,
contractType: ContractType.Primitive,
address: graphAddress
address: primitiveAddress
});

return graphAddress;
return primitiveAddress;
}

export async function deployLensNamespace(
lensFactory: ethers.Contract,
noVerify: Boolean = false
): Promise<string> {
const contractName = 'Namespace';
const existingContract = loadContractFromAddressBook(contractName);
const name = "LensGlobal" + contractName;
const existingContract = loadContractFromAddressBook(name);
if (existingContract && existingContract.address) {
console.log(`${contractName} already deployed at ${existingContract.address}. Skipping...`);
console.log(`${name} already deployed at ${existingContract.address}. Skipping...`);
return existingContract.address;
}

console.log('Deploying Namespace');
console.log('Deploying ' + name);
const namespace = 'lens';
const nftName = 'nftName';
const nftSymbol = 'nftSymbol';
Expand All @@ -221,46 +225,45 @@ export async function deployLensNamespace(

const txReceipt = (await transaction.wait()) as ethers.TransactionReceipt;
const events = parseLensContractDeployedEventsFromReceipt(txReceipt);
const namespaceAddress = getAddressFromEvents(events, 'namespace');
const accessControlAddress = getAddressFromEvents(events, 'access-control');
const lensUsernameTokenURIProviderAddress = getAddressFromEvents(
events,
'username-token-uri-provider'
);

if (!noVerify) {
await verifyPrimitive('Namespace', namespaceAddress, [
namespace,
metadataURI,
accessControlAddress,
nftName,
nftSymbol,
lensUsernameTokenURIProviderAddress,
]);
}
const primitiveAddress = getAddressFromEvents(events, contractName.toLowerCase());
// const accessControlAddress = getAddressFromEvents(events, 'access-control');
// const lensUsernameTokenURIProviderAddress = getAddressFromEvents(
// events,
// 'username-token-uri-provider'
// );

// await verifyPrimitive('Namespace', primitiveAddress, [
// namespace,
// metadataURI,
// accessControlAddress,
// nftName,
// nftSymbol,
// lensUsernameTokenURIProviderAddress,
// ]);

saveContractToAddressBook({
name: 'LensGlobalNamespace',
contractName: 'Namespace',
name: name,
contractName: contractName,
contractType: ContractType.Primitive,
address: namespaceAddress
address: primitiveAddress
});

return namespaceAddress;
return primitiveAddress;
}

export async function deployLensApp(
lensFactory: ethers.Contract,
initialProperties: AppInitialProperties
): Promise<string> {
const contractName = 'App';
const existingContract = loadContractFromAddressBook(contractName);
const name = "LensGlobal" + contractName;
const existingContract = loadContractFromAddressBook(name);
if (existingContract && existingContract.address) {
console.log(`${contractName} already deployed at ${existingContract.address}. Skipping...`);
console.log(`${name} already deployed at ${existingContract.address}. Skipping...`);
return existingContract.address;
}

console.log('Deploying App');
console.log('Deploying ' + name);
console.log('Using the following initial properties:');
console.log(initialProperties);
const transaction = await lensFactory.deployApp(
Expand All @@ -275,25 +278,25 @@ export async function deployLensApp(
const txReceipt = (await transaction.wait()) as ethers.TransactionReceipt;

const events = parseLensContractDeployedEventsFromReceipt(txReceipt);
const appAddress = getAddressFromEvents(events, 'app');
const accessControlAddress = getAddressFromEvents(events, 'access-control');
const primitiveAddress = getAddressFromEvents(events, contractName.toLowerCase());
// const accessControlAddress = getAddressFromEvents(events, 'access-control');

await verifyPrimitive('App', appAddress, [
metadataURI,
false,
accessControlAddress,
initialProperties,
[],
]);
// await verifyPrimitive('App', appAddress, [
// metadataURI,
// false,
// accessControlAddress,
// initialProperties,
// [],
// ]);

saveContractToAddressBook({
name: 'LensGlobalApp',
contractName: 'App',
contractType: ContractType.Misc,
address: appAddress
name: name,
contractName: contractName,
contractType: ContractType.Primitive,
address: primitiveAddress
});

return appAddress;
return primitiveAddress;
}

export async function deployLensAccessControl() {
Expand Down
10 changes: 5 additions & 5 deletions deploy/deployFactories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,39 @@ export default async function deployFactories(): Promise<void> {
contractType: ContractType.Factory,
constructorArguments: [
loadContractAddressFromAddressBook('AppBeacon'),
loadContractAddressFromAddressBook('ProxyAdminLock'),
loadContractAddressFromAddressBook('Lock'),
],
},
{
contractName: 'FeedFactory',
contractType: ContractType.Factory,
constructorArguments: [
loadContractAddressFromAddressBook('FeedBeacon'),
loadContractAddressFromAddressBook('ProxyAdminLock'),
loadContractAddressFromAddressBook('Lock'),
],
},
{
contractName: 'GraphFactory',
contractType: ContractType.Factory,
constructorArguments: [
loadContractAddressFromAddressBook('GraphBeacon'),
loadContractAddressFromAddressBook('ProxyAdminLock'),
loadContractAddressFromAddressBook('Lock'),
],
},
{
contractName: 'GroupFactory',
contractType: ContractType.Factory,
constructorArguments: [
loadContractAddressFromAddressBook('GroupBeacon'),
loadContractAddressFromAddressBook('ProxyAdminLock'),
loadContractAddressFromAddressBook('Lock'),
],
},
{
contractName: 'NamespaceFactory',
contractType: ContractType.Factory,
constructorArguments: [
loadContractAddressFromAddressBook('NamespaceBeacon'),
loadContractAddressFromAddressBook('ProxyAdminLock'),
loadContractAddressFromAddressBook('Lock'),
],
},
{
Expand Down
2 changes: 1 addition & 1 deletion deploy/deployProxyStuff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { deployLensContract, ContractType, ContractInfo, loadContractAddressFrom

export async function deployProxyAdminLock(lockOwner: string): Promise<void> {
const proxyAdminLock = await deployLensContract({
contractName: 'ProxyAdminLock',
contractName: 'Lock',
contractType: ContractType.Aux,
constructorArguments: [lockOwner, true],
});
Expand Down
5 changes: 5 additions & 0 deletions deploy/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ export const verifyContract = async (data: {
constructorArguments: string;
bytecode: string;
}) => {
// Skip verification for local networks
if (hre.network.name === 'inMemoryNode') {
console.log('Skipping contract verification on local network');
return 0;
}
const verificationRequestId: number = await hre.run('verify:verify', {
...data,
noCompile: true,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"license": "UNLICENSED. Copyright (C) 2024 Lens Labs. All Rights Reserved.",
"scripts": {
"deploy": "hardhat deploy-zksync --script deploy.ts",
"deploy:local": "anvil-zksync && hardhat deploy-zksync --script deploy.ts --network inMemoryNode",
"deploy:local": "hardhat deploy-zksync --script deploy.ts --network inMemoryNode",
"interact": "hardhat deploy-zksync --script interact.ts",
"compile": "hardhat compile",
"clean": "hardhat clean",
Expand Down
4 changes: 2 additions & 2 deletions script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {GroupFactory} from "./../contracts/dashboard/factories/GroupFactory.sol"
import {NamespaceFactory} from "./../contracts/dashboard/factories/NamespaceFactory.sol";
import {LensFactory} from "./../contracts/dashboard/factories/LensFactory.sol";

import {ProxyAdminLock} from "./../contracts/core/upgradeability/ProxyAdminLock.sol";
import {Lock} from "./../contracts/core/upgradeability/Lock.sol";
import {Beacon} from "./../contracts/core/upgradeability/Beacon.sol";

import {AccountBlockingRule} from "./../contracts/rules/base/AccountBlockingRule.sol";
Expand Down Expand Up @@ -63,7 +63,7 @@ contract MyScript is Script {
address groupGatedFeedRule;

function run() external {
proxyAdminLock = address(new ProxyAdminLock(lockOwner, true));
proxyAdminLock = address(new Lock(lockOwner, true));
_deployImplementations();
_deployBeacons();
_deployFactories();
Expand Down
2 changes: 1 addition & 1 deletion test/factories/lens-factory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('Account', function () {

// Proxy stuff

const proxyAdminLock = await deployContract('ProxyAdminLock', [await ownerWallet.getAddress(), true], { wallet: ownerWallet, silent: true });
const proxyAdminLock = await deployContract('Lock', [await ownerWallet.getAddress(), true], { wallet: ownerWallet, silent: true });

const appImplementation = await deployContract('App', [], { wallet: ownerWallet, silent: true });
const feedImplementation = await deployContract('Feed', [], { wallet: ownerWallet, silent: true });
Expand Down
Loading

0 comments on commit 9533c22

Please sign in to comment.