Skip to content

Commit

Permalink
Use Existing Precompile ACL Address and Update IPGraph Precompile Add…
Browse files Browse the repository at this point in the history
…ress (#247)

* change precompile address and use existing precompile ACL
  • Loading branch information
kingster-will authored Sep 18, 2024
1 parent 4c57a25 commit de6de66
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 25 deletions.
2 changes: 1 addition & 1 deletion contracts/modules/royalty/RoyaltyModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ contract RoyaltyModule is IRoyaltyModule, VaultController, ReentrancyGuardUpgrad
using SafeERC20 for IERC20;

/// @notice Ip graph precompile contract address
address public constant IP_GRAPH = address(0x1A);
address public constant IP_GRAPH = address(0x1B);

/// @notice Returns the percentage scale - represents 100%
uint32 public constant MAX_PERCENT = 100_000_000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ contract RoyaltyPolicyLAP is
0x0c915ba68e2c4e37f19454bb13066f18f9db418fcefbf3c585b4b7d0fb0e0600;

/// @notice Ip graph precompile contract address
address public constant IP_GRAPH = address(0x1A);
address public constant IP_GRAPH = address(0x1B);

/// @notice Returns the RoyaltyModule address
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ contract RoyaltyPolicyLRP is
0xbbe79ec88963794a251328747c07178ad16a06e9c87463d90d5d0d429fa6e700;

/// @notice Ip graph precompile contract address
address public constant IP_GRAPH = address(0x1A);
address public constant IP_GRAPH = address(0x1B);

/// @notice Returns the RoyaltyModule address
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
Expand Down
2 changes: 1 addition & 1 deletion contracts/registries/LicenseRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ contract LicenseRegistry is ILicenseRegistry, AccessManagedUpgradeable, UUPSUpgr
using EnumerableSet for EnumerableSet.AddressSet;
using IPAccountStorageOps for IIPAccount;

address public constant IP_GRAPH = address(0x1A);
address public constant IP_GRAPH = address(0x1B);
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
ILicensingModule public immutable LICENSING_MODULE;
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
Expand Down
4 changes: 3 additions & 1 deletion script/foundry/deployment/Main.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ contract Main is DeployHelper {
address internal ERC6551_REGISTRY = 0x000000006551c19487814612e58FE06813775758;
address internal CREATE3_DEPLOYER = 0x384a891dFDE8180b054f04D66379f16B7a678Ad6;
uint256 internal CREATE3_DEFAULT_SEED = 0;
address internal IP_GRAPH_ACL = 0x680E66e4c7Df9133a7AFC1ed091089B32b89C4ae;
// For arbitration policy
uint256 internal constant ARBITRATION_PRICE = 1000 * 10 ** 6; // 1000 USDC
address internal constant TREASURY_ADDRESS = address(200);
Expand All @@ -25,7 +26,8 @@ contract Main is DeployHelper {
address(0), // replaced with USDC in DeployHelper.sol
ARBITRATION_PRICE,
MAX_ROYALTY_APPROVAL,
TREASURY_ADDRESS
TREASURY_ADDRESS,
IP_GRAPH_ACL
)
{}

Expand Down
42 changes: 25 additions & 17 deletions script/foundry/utils/DeployHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag
AccessManager internal protocolAccessManager; // protocol roles
AccessController internal accessController; // per IPA roles
IPGraphACL internal ipGraphACL;
bool internal newDeployedIpGraphACL;

// Pause
ProtocolPauseAdmin internal protocolPauser;
Expand Down Expand Up @@ -131,14 +132,18 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag
address erc20_,
uint256 arbitrationPrice_,
uint256 maxRoyaltyApproval_,
address treasury_
address treasury_,
address ipGraphACL_
) JsonDeploymentHandler("main") {
erc6551Registry = ERC6551Registry(erc6551Registry_);
create3Deployer = ICreate3Deployer(create3Deployer_);
erc20 = ERC20(erc20_);
ARBITRATION_PRICE = arbitrationPrice_;
MAX_ROYALTY_APPROVAL = maxRoyaltyApproval_;
TREASURY_ADDRESS = treasury_;
ipGraphACL = IPGraphACL(ipGraphACL_);
if (address(ipGraphACL) == address(0))
newDeployedIpGraphACL = true;

/// @dev USDC addresses are fetched from
/// (mainnet) https://developers.circle.com/stablecoins/docs/usdc-on-main-networks
Expand Down Expand Up @@ -303,7 +308,7 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag
new LicenseRegistry(
_getDeployedAddress(type(LicensingModule).name),
_getDeployedAddress(type(DisputeModule).name),
_getDeployedAddress(type(IPGraphACL).name)
newDeployedIpGraphACL ? _getDeployedAddress(type(IPGraphACL).name) : address(ipGraphACL)
)
);
licenseRegistry = LicenseRegistry(
Expand Down Expand Up @@ -520,7 +525,7 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag
_predeploy("RoyaltyPolicyLAP");
impl = address(new RoyaltyPolicyLAP(
address(royaltyModule),
_getDeployedAddress(type(IPGraphACL).name)
newDeployedIpGraphACL ? _getDeployedAddress(type(IPGraphACL).name) : address(ipGraphACL)
));
royaltyPolicyLAP = RoyaltyPolicyLAP(
TestProxyHelper.deployUUPSProxy(
Expand All @@ -541,7 +546,7 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag
_predeploy("RoyaltyPolicyLRP");
impl = address(new RoyaltyPolicyLRP(
address(royaltyModule),
_getDeployedAddress(type(IPGraphACL).name)
newDeployedIpGraphACL ? _getDeployedAddress(type(IPGraphACL).name) : address(ipGraphACL)
));
royaltyPolicyLRP = RoyaltyPolicyLRP(
TestProxyHelper.deployUUPSProxy(
Expand Down Expand Up @@ -647,17 +652,17 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag
);
_postdeploy("CoreMetadataViewModule", address(coreMetadataViewModule));

_predeploy("IPGraphACL");
ipGraphACL = IPGraphACL(
create3Deployer.deploy(
_getSalt(type(IPGraphACL).name),
abi.encodePacked(
type(IPGraphACL).creationCode,
abi.encode(address(protocolAccessManager))
// only deploy IPGraphACL if it doesn't exist
if (newDeployedIpGraphACL) {
_predeploy("IPGraphACL");
ipGraphACL = IPGraphACL(
create3Deployer.deploy(
_getSalt(type(IPGraphACL).name),
abi.encodePacked(type(IPGraphACL).creationCode, abi.encode(address(protocolAccessManager)))
)
)
);
_postdeploy("IPGraphACL", address(ipGraphACL));
);
_postdeploy("IPGraphACL", address(ipGraphACL));
}
}

function _predeploy(string memory contractKey) private view {
Expand Down Expand Up @@ -714,9 +719,12 @@ contract DeployHelper is Script, BroadcastManager, JsonDeploymentHandler, Storag
licenseRegistry.registerLicenseTemplate(address(pilTemplate));

// IPGraphACL
ipGraphACL.whitelistAddress(address(licenseRegistry));
ipGraphACL.whitelistAddress(address(royaltyPolicyLAP));
ipGraphACL.whitelistAddress(address(royaltyPolicyLRP));
// only configure IPGraphACL when it first deploys
if (newDeployedIpGraphACL) {
ipGraphACL.whitelistAddress(address(licenseRegistry));
ipGraphACL.whitelistAddress(address(royaltyPolicyLAP));
ipGraphACL.whitelistAddress(address(royaltyPolicyLRP));
}

// set default license to non-commercial social remixing
uint256 licenseId = pilTemplate.registerLicenseTerms(PILFlavors.nonCommercialSocialRemixing());
Expand Down
7 changes: 4 additions & 3 deletions test/foundry/utils/BaseTest.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ contract BaseTest is Test, DeployHelper, LicensingHelper {
address internal constant TREASURY_ADDRESS = address(200);

address internal lrHarnessImpl;
MockIPGraph ipGraph = MockIPGraph(address(0x1A));
MockIPGraph ipGraph = MockIPGraph(address(0x1B));

constructor()
DeployHelper(
Expand All @@ -62,13 +62,14 @@ contract BaseTest is Test, DeployHelper, LicensingHelper {
address(erc20),
ARBITRATION_PRICE,
MAX_ROYALTY_APPROVAL,
TREASURY_ADDRESS
TREASURY_ADDRESS,
address(0)
)
{}

/// @notice Sets up the base test contract.
function setUp() public virtual {
vm.etch(address(0x1A), address(new MockIPGraph()).code);
vm.etch(address(0x1B), address(new MockIPGraph()).code);

u = UsersLib.createMockUsers(vm);

Expand Down

0 comments on commit de6de66

Please sign in to comment.