mirror of
https://github.com/lens-protocol/core.git
synced 2026-01-10 06:38:05 -05:00
feat: Added more to DeployPeriphery, envGen script for backend
This commit is contained in:
@@ -67,6 +67,30 @@
|
||||
"name": "FreeCollectModule",
|
||||
"addy": "0x0BE6bD7092ee83D44a6eC1D949626FeE48caB30c"
|
||||
},
|
||||
{
|
||||
"name": "FeeCollectModule",
|
||||
"addy": "0xeb4f3EC9d01856Cec2413bA5338bF35CeF932D82"
|
||||
},
|
||||
{
|
||||
"name": "LimitedFeeCollectModule",
|
||||
"addy": "0xFCDA2801a31ba70dfe542793020a934F880D54aB"
|
||||
},
|
||||
{
|
||||
"name": "TimedFeeCollectModule",
|
||||
"addy": "0x36447b496ebc97DDA6d8c8113Fe30A30dC0126Db"
|
||||
},
|
||||
{
|
||||
"name": "LimitedTimedFeeCollectModule",
|
||||
"addy": "0xDa76E44775C441eF53B9c769d175fB2948F15e1C"
|
||||
},
|
||||
{
|
||||
"name": "RevertCollectModule",
|
||||
"addy": "0x5E70fFD2C6D04d65C3abeBa64E93082cfA348dF8"
|
||||
},
|
||||
{
|
||||
"name": "SimpleFeeCollectModule",
|
||||
"addy": "0xb4a9874adc790eec88fd086e43d329bbc9520efd"
|
||||
},
|
||||
{
|
||||
"name": "MultirecipientFeeCollectModule",
|
||||
"addy": "0x99d6c3eabf05435e851c067d2c3222716f7fcfe5"
|
||||
@@ -102,6 +126,14 @@
|
||||
{
|
||||
"name": "TokenGatedReferenceModule",
|
||||
"addy": "0xb4ba8dccd35bd3dcc5d58dbb9c7dff9c9268add9"
|
||||
},
|
||||
{
|
||||
"name": "FollowerOnlyReferenceModule",
|
||||
"addy": "0x7Ea109eC988a0200A1F79Ae9b78590F92D357a16"
|
||||
},
|
||||
{
|
||||
"name": "DegreesOfSeparationReferenceModule",
|
||||
"addy": "0xe20D64D25779D2Ae0d76711e5Aca23EE633f2E1E"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -30,6 +30,7 @@ import {ModuleRegistry} from 'contracts/misc/ModuleRegistry.sol';
|
||||
import {IModuleRegistry} from 'contracts/interfaces/IModuleRegistry.sol';
|
||||
import {BaseFeeCollectModuleInitData} from 'contracts/modules/interfaces/IBaseFeeCollectModule.sol';
|
||||
import {Governance} from 'contracts/misc/access/Governance.sol';
|
||||
import {PublicActProxy} from 'contracts/misc/PublicActProxy.sol';
|
||||
|
||||
import {ArrayHelpers} from 'test/helpers/ArrayHelpers.sol';
|
||||
|
||||
@@ -80,6 +81,8 @@ contract LensV2DeployPeriphery is Script, ForkManagement, ArrayHelpers {
|
||||
DegreesOfSeparationReferenceModule degreesOfSeparationReferenceModule;
|
||||
FollowerOnlyReferenceModule followerOnlyReferenceModule;
|
||||
TokenGatedReferenceModule tokenGatedReferenceModule;
|
||||
PublicActProxy publicActProxy;
|
||||
LitAccessControl litAccessControl;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -97,6 +100,20 @@ contract LensV2DeployPeriphery is Script, ForkManagement, ArrayHelpers {
|
||||
// console.log(output);
|
||||
}
|
||||
|
||||
function saveValue(string memory contractName, string memory str) internal {
|
||||
// console.log('Saving %s (%s) into addresses under %s environment', contractName, deployedAddress, targetEnv);
|
||||
string[] memory inputs = new string[](5);
|
||||
inputs[0] = 'node';
|
||||
inputs[1] = 'script/helpers/saveAddress.js';
|
||||
inputs[2] = targetEnv;
|
||||
inputs[3] = contractName;
|
||||
inputs[4] = str;
|
||||
// bytes memory res =
|
||||
vm.ffi(inputs);
|
||||
// string memory output = abi.decode(res, (string));
|
||||
// console.log(output);
|
||||
}
|
||||
|
||||
function saveModule(
|
||||
string memory moduleName,
|
||||
address moduleAddress,
|
||||
@@ -198,6 +215,15 @@ contract LensV2DeployPeriphery is Script, ForkManagement, ArrayHelpers {
|
||||
vm.label(address(profileCreationProxy), 'ProfileCreationProxy');
|
||||
saveContractAddress('ProfileCreationProxy', address(profileCreationProxy));
|
||||
|
||||
publicActProxy = new PublicActProxy({
|
||||
lensHub: address(hub),
|
||||
collectPublicationAction: address(collectPublicationAction)
|
||||
});
|
||||
console.log('\n+ + + PublicActProxy: %s', address(publicActProxy));
|
||||
vm.writeLine(addressesFile, string.concat('PublicActProxy: ', vm.toString(address(publicActProxy))));
|
||||
vm.label(address(publicActProxy), 'PublicActProxy');
|
||||
saveContractAddress('PublicActProxy', address(publicActProxy));
|
||||
|
||||
uint256 currentDeployerNonce = vm.getNonce(deployer.owner);
|
||||
/**
|
||||
* CollectNFT (currentDeployerNonce)
|
||||
@@ -315,6 +341,20 @@ contract LensV2DeployPeriphery is Script, ForkManagement, ArrayHelpers {
|
||||
// string.concat('TokenGatedReferenceModule: ', vm.toString(address(tokenGatedReferenceModule)))
|
||||
// );
|
||||
|
||||
address litAccessControlImpl = address(new LitAccessControl(address(hub), address(collectPublicationAction)));
|
||||
console.log('\n+ + + LitAccessControlImpl: %s', litAccessControlImpl);
|
||||
vm.writeLine(addressesFile, string.concat('LitAccessControlImpl: ', vm.toString(litAccessControlImpl)));
|
||||
vm.label(litAccessControlImpl, 'LitAccessControlImpl');
|
||||
saveContractAddress('LitAccessControlImpl', litAccessControlImpl);
|
||||
|
||||
litAccessControl = LitAccessControl(
|
||||
new TransparentUpgradeableProxy({_logic: litAccessControlImpl, admin_: proxyAdmin, _data: ''})
|
||||
);
|
||||
console.log('\n+ + + LitAccessControl: %s', address(litAccessControl));
|
||||
vm.writeLine(addressesFile, string.concat('LitAccessControl: ', vm.toString(address(litAccessControl))));
|
||||
vm.label(address(litAccessControl), 'LitAccessControl');
|
||||
saveContractAddress('LitAccessControl', address(litAccessControl));
|
||||
|
||||
vm.stopBroadcast();
|
||||
}
|
||||
|
||||
@@ -437,6 +477,24 @@ contract LensV2DeployPeriphery is Script, ForkManagement, ArrayHelpers {
|
||||
handle: 'secondprofile'
|
||||
});
|
||||
|
||||
(uint256 anonymousProfileId, ) = temporarilyCreationProxy.proxyCreateProfileWithHandle({
|
||||
createProfileParams: Types.CreateProfileParams({
|
||||
to: deployer.owner,
|
||||
followModule: address(0),
|
||||
followModuleInitData: ''
|
||||
}),
|
||||
handle: 'annoymouse'
|
||||
});
|
||||
|
||||
saveValue('AnonymousProfileId', vm.toString(anonymousProfileId));
|
||||
|
||||
// set DE to publicActProxy
|
||||
hub.changeDelegatedExecutorsConfig({
|
||||
delegatorProfileId: anonymousProfileId,
|
||||
delegatedExecutors: _toAddressArray(address(publicActProxy)),
|
||||
approvals: _toBoolArray(true)
|
||||
});
|
||||
|
||||
hub.follow({
|
||||
followerProfileId: firstProfileId,
|
||||
idsOfProfilesToFollow: _toUint256Array(secondProfileId),
|
||||
|
||||
163
script/helpers/envGen.js
Normal file
163
script/helpers/envGen.js
Normal file
@@ -0,0 +1,163 @@
|
||||
// This is a script that transforms addresses.json into backendEnv.txt
|
||||
|
||||
const path = require('path');
|
||||
|
||||
const findModule = (moduleType, moduleName, version) => {
|
||||
const module = addresses['Modules'][version][moduleType].find(
|
||||
(module) => module.name === moduleName
|
||||
);
|
||||
if (!module) {
|
||||
return 'undefined';
|
||||
} else {
|
||||
return module.addy;
|
||||
}
|
||||
};
|
||||
|
||||
const addressesPath = '../../addresses.json';
|
||||
|
||||
const addressesJson = require(path.join(__dirname, addressesPath));
|
||||
const [targetEnv] = process.argv.slice(2);
|
||||
|
||||
if (!addressesJson[targetEnv]) {
|
||||
console.error(`ERROR: Target environment "${targetEnv}" not found in addresses.json`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const addresses = addressesJson[targetEnv];
|
||||
|
||||
// Let's make sure to clear the backendEnv.txt first
|
||||
const fs = require('fs');
|
||||
fs.writeFileSync(`./backendEnv_${targetEnv}.txt`, '');
|
||||
|
||||
// And then write to backendEnv.txt line by line
|
||||
const str = fs.createWriteStream(`./backendEnv_${targetEnv}.txt`, { flags: 'a' });
|
||||
|
||||
str.write(`# Hub\n`);
|
||||
str.write(`LENS_HUB_PROXY=${addresses['LensHubProxy']}\n`);
|
||||
|
||||
str.write(`\n# LensHandles\n`);
|
||||
str.write(`LENS_HANDLE_PROXY=${addresses['LensHandles']}\n`);
|
||||
|
||||
str.write(`\n# TokenHandleRegistry\n`);
|
||||
str.write(`LENS_TOKEN_HANDLE_REGISTRY_PROXY=${addresses['TokenHandleRegistry']}\n`);
|
||||
|
||||
str.write(`\n# Public Act Proxy\n`);
|
||||
str.write(`LENS_PUBLIC_ACT_PROXY=${addresses['PublicActProxy']}\n`);
|
||||
|
||||
str.write(`\n# Profile creation proxy\n`);
|
||||
str.write(`PROFILE_CREATION_PROXY=${addresses['ProfileCreationProxy']}\n`);
|
||||
|
||||
str.write(`\n# ModuleRegistry\n`);
|
||||
str.write(`GLOBAL_MODULE_REGISTRY=${addresses['ModuleGlobals']}\n`);
|
||||
|
||||
// LEGACY COLLECT MODULES
|
||||
|
||||
str.write(`\n# legacy modules\n`);
|
||||
str.write(`## legacy collect modules\n`);
|
||||
str.write(`LEGACY_FEE_COLLECT_MODULE=${findModule('collect', 'FeeCollectModule', 'v1')}\n`);
|
||||
str.write(
|
||||
`LEGACY_LIMITED_FEE_COLLECT_MODULE=${findModule('collect', 'LimitedFeeCollectModule', 'v1')}\n`
|
||||
);
|
||||
str.write(
|
||||
`LEGACY_TIMED_FEE_COLLECT_MODULE=${findModule('collect', 'TimedFeeCollectModule', 'v1')}\n`
|
||||
);
|
||||
str.write(
|
||||
`LEGACY_LIMITED_TIMED_FEE_COLLECT_MODULE=${findModule(
|
||||
'collect',
|
||||
'LimitedTimedFeeCollectModule',
|
||||
'v1'
|
||||
)}\n`
|
||||
);
|
||||
str.write(`LEGACY_REVERT_COLLECT_MODULE=${findModule('collect', 'RevertCollectModule', 'v1')}\n`);
|
||||
str.write(`LEGACY_FREE_COLLECT_MODULE=${findModule('collect', 'FreeCollectModule', 'v1')}\n`);
|
||||
str.write(
|
||||
`LEGACY_SIMPLE_COLLECT_MODULE=${findModule('collect', 'SimpleFeeCollectModule', 'v1')}\n`
|
||||
);
|
||||
str.write(
|
||||
`LEGACY_MULTIRECIPIENT_FEE_COLLECT_MODULE=${findModule(
|
||||
'collect',
|
||||
'MultirecipientFeeCollectModule',
|
||||
'v1'
|
||||
)}\n`
|
||||
);
|
||||
|
||||
// LEGACY FOLLOW MODULES
|
||||
str.write(`\n## legacy follow modules\n`);
|
||||
str.write(`LEGACY_FEE_FOLLOW_MODULE=${findModule('follow', 'FeeFollowModule', 'v1')}\n`);
|
||||
str.write(`LEGACY_REVERT_FOLLOW_MODULE=${findModule('follow', 'RevertFollowModule', 'v1')}\n`);
|
||||
str.write(`LEGACY_PROFILE_FOLLOW_MODULE=${findModule('follow', 'ProfileFollowModule', 'v1')}\n`);
|
||||
|
||||
// LEGACY REFERENCE MODULES
|
||||
str.write(`\n## legacy reference modules\n`);
|
||||
str.write(
|
||||
`LEGACY_TOKEN_GATED_REFERENCE_MODULE=${findModule(
|
||||
'reference',
|
||||
'TokenGatedReferenceModule',
|
||||
'v1'
|
||||
)}\n`
|
||||
);
|
||||
str.write(
|
||||
`LEGACY_FOLLOWER_ONLY_REFERENCE_MODULE=${findModule(
|
||||
'reference',
|
||||
'FollowerOnlyReferenceModule',
|
||||
'v1'
|
||||
)}\n`
|
||||
);
|
||||
str.write(
|
||||
`LEGACY_DEGREE_OF_SEPERATION_REFERENCE_MODULE=${findModule(
|
||||
'reference',
|
||||
'DegreesOfSeparationReferenceModule',
|
||||
'v1'
|
||||
)}\n`
|
||||
);
|
||||
|
||||
str.write(`\n# v2 modules\n`);
|
||||
// V2 ACT MODULES
|
||||
str.write(`## v2 act modules\n`);
|
||||
str.write(`### Collect open action\n`);
|
||||
// We need to find the CollectPublicationAction inside Modules/V2/act[] array {name, addy}
|
||||
str.write(
|
||||
`LENS_COLLECT_PUBLICATION_ACTION_PROXY=${findModule('act', 'CollectPublicationAction', 'v2')}\n`
|
||||
);
|
||||
|
||||
// V2 COLLECT MODULES
|
||||
str.write(`\n## v2 collect modules\n`);
|
||||
str.write(
|
||||
`MULTIRECIPIENT_FEE_COLLECT_OPEN_ACTION_MODULE=${findModule(
|
||||
'collect',
|
||||
'MultirecipientFeeCollectModule',
|
||||
'v2'
|
||||
)}\n`
|
||||
);
|
||||
str.write(
|
||||
`SIMPLE_COLLECT_OPEN_ACTION_MODULE=${findModule('collect', 'SimpleFeeCollectModule', 'v2')}\n`
|
||||
);
|
||||
|
||||
// V2 FOLLOW MODULES
|
||||
str.write(`\n## v2 follow modules\n`);
|
||||
str.write(`FEE_FOLLOW_MODULE=${findModule('follow', 'FeeFollowModule', 'v2')}\n`);
|
||||
str.write(`REVERT_FOLLOW_MODULE=${findModule('follow', 'RevertFollowModule', 'v2')}\n`);
|
||||
|
||||
// V2 REFERENCE MODULES
|
||||
str.write(`\n## v2 reference modules\n`);
|
||||
str.write(
|
||||
`DEGREE_OF_SEPERATION_REFERENCE_MODULE=${findModule(
|
||||
'reference',
|
||||
'DegreesOfSeparationReferenceModule',
|
||||
'v2'
|
||||
)}\n`
|
||||
);
|
||||
str.write(
|
||||
`FOLLOWER_ONLY_REFERENCE_MODULE=${findModule('reference', 'FollowerOnlyReferenceModule', 'v2')}\n`
|
||||
);
|
||||
|
||||
// PublicActProxy ProfileId
|
||||
str.write(`\n# PublicActProxy ProfileId\n`);
|
||||
str.write(`PUBLIC_ACT_PROXY_PROFILE_ID=${addresses['AnonymousProfileId']}\n`);
|
||||
|
||||
// LitAccessControl
|
||||
str.write(`\n# LitAccessControl\n`);
|
||||
str.write(`LIT_ACCESS_CONTROL=${addresses['LitAccessControl']}\n`);
|
||||
|
||||
// Finished writing. Now we can close the stream
|
||||
str.end();
|
||||
Reference in New Issue
Block a user