Skip to content

Commit

Permalink
fix: missing initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
geolffreym committed Dec 28, 2024
1 parent 024aa0a commit 9416d93
Show file tree
Hide file tree
Showing 7 changed files with 217 additions and 220 deletions.
3 changes: 0 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"cSpell.words": [
"IERC",
"Initializable",
"synaps",
"UUPS"
]
}
142 changes: 71 additions & 71 deletions broadcast/04_Deploy_Facades_AccessWorkflow.s.sol/80002/run-latest.json

Large diffs are not rendered by default.

148 changes: 74 additions & 74 deletions broadcast/05_Deploy_Agg_AccessAgg.s.sol/80002/run-latest.json

Large diffs are not rendered by default.

116 changes: 58 additions & 58 deletions broadcast/06_Deploy_Agg_PoliciesAgg.s.sol/80002/run-latest.json

Large diffs are not rendered by default.

16 changes: 7 additions & 9 deletions contracts/aggregation/PoliciesAgg.sol
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,17 @@ contract PoliciesAgg is Initializable, UUPSUpgradeable, AccessControlledUpgradea
__AccessControlled_init(accessManager);
}

/// @notice Retrieves all policies associated with a holder.
/// @param holder Address of the rights holder.
/// @return Array of `PolicyTerms` containing policies and their associated terms.
function getPoliciesByHolder(address holder) external view returns (PolicyTerms[] memory) {
/// @notice Retrieves all policies that apply to the entirety of a holder's content.
/// @param holder The address of the rights holder whose policies are being queried.
function getHolderWidePolicies(address holder) external view returns (PolicyTerms[] memory) {
bytes memory criteria = abi.encode(holder);
PolicyTerms[] memory policies = getAvailablePoliciesTerms(holder, criteria);
return policies;
}

/// @notice Retrieves all policies associated with a specific asset ID.
/// @param assetId The ID of the asset.
/// @return Array of `PolicyTerms` containing policies and their associated terms.
function getPoliciesByAsset(uint256 assetId) external view returns (PolicyTerms[] memory) {
/// @notice Retrieves all policies that govern operations on a specific asset.
/// @param assetId The unique identifier of the asset whose policies are being queried.
function getAssetSpecificPolicies(uint256 assetId) external view returns (PolicyTerms[] memory) {
bytes memory criteria = abi.encode(assetId);
address holder = ASSET_OWNERSHIP.ownerOf(assetId);
PolicyTerms[] memory policies = getAvailablePoliciesTerms(holder, criteria);
Expand All @@ -73,7 +71,7 @@ contract PoliciesAgg is Initializable, UUPSUpgradeable, AccessControlledUpgradea
PolicyTerms[] memory terms = new PolicyTerms[](policies.length);
uint256 availablePoliciesLen = policies.length;

for (uint256 i; i < availablePoliciesLen; i = i.uncheckedInc()) {
for (uint256 i = 0; i < availablePoliciesLen; i = i.uncheckedInc()) {
address policyAddress = policies[i];
bytes memory callData = abi.encodeCall(IPolicy.resolveTerms, (criteria));
(bool success, bytes memory result) = policyAddress.staticcall(callData);
Expand Down
6 changes: 4 additions & 2 deletions contracts/policies/SubscriptionPolicy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ contract SubscriptionPolicy is BasePolicy {
return _commit(holder, agreement, subExpire);
}

/// @notice Verifies if a specific account has access holder's content.
/// @notice Verifies if an account has access to holder's content or asset id.
function isAccessAllowed(address account, bytes calldata criteria) external view returns (bool) {
// Default behavior: only check attestation compliance.
if (_isHolderAddress(criteria)) {
Expand All @@ -88,9 +88,11 @@ contract SubscriptionPolicy is BasePolicy {
return isCompliant(account, getHolder(assetId));
}

/// @notice Retrieves the terms associated with a specific criteria.
/// @notice Retrieves the terms associated with a specific criteria and policy.
function resolveTerms(bytes calldata criteria) external view returns (T.Terms memory) {
// this policy only support holder address criteria
// the terms are handled in the holder's content's context
// cannot process individual asset id terms
if (!_isHolderAddress(criteria)) {
revert InvalidNotSupportedOperation();
}
Expand Down
6 changes: 3 additions & 3 deletions script/deployment/08_Deploy_Policies_Subscription.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ contract DeploySubscriptionPolicy is DeployBase {
function run() external returns (address) {
vm.startBroadcast(getAdminPK());

address rightsPolicyManager = computeCreate3Address("SALT_RIGHT_POLICY_MANAGER");
address assetOwnership = computeCreate3Address("SALT_ASSET_OWNERSHIP");
address assetOwnership = vm.envAddress("ASSET_OWNERSHIP");
address easAddress = computeCreate3Address("SALT_ATTESTATION_EAS");
address rightsPolicyManager = vm.envAddress("RIGHT_POLICY_MANAGER");

bytes memory creationCode = type(SubscriptionPolicy).creationCode;
bytes memory initCode = abi.encodePacked(
creationCode,
abi.encode(rightsPolicyManager, assetOwnership, easAddress)
);

address policy = deploy(initCode, "SALT_SUBSCRIPTION_POLICY");
vm.stopBroadcast();

Expand Down

0 comments on commit 9416d93

Please sign in to comment.