This repository has been archived by the owner on Apr 30, 2024. It is now read-only.
generated from storyprotocol/solidity-template
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactored licensing from param based to fw based
- Loading branch information
Raul
committed
Jan 29, 2024
1 parent
0b4c31b
commit 1046bf5
Showing
22 changed files
with
727 additions
and
576 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
|
||
pragma solidity ^0.8.23; | ||
|
||
import { Licensing } from "contracts/lib/Licensing.sol"; | ||
import { IParamVerifier } from "contracts/interfaces/licensing/IParamVerifier.sol"; | ||
|
||
interface ILicensingFramework is IParamVerifier { | ||
function licenseRegistry() external view returns (address); | ||
function policyToJson(bytes memory policyData) external view returns (string memory); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
// See https://github.com/storyprotocol/protocol-contracts/blob/main/StoryProtocol-AlphaTestingAgreement-17942166.3.pdf | ||
pragma solidity ^0.8.23; | ||
|
||
// contracts | ||
import { IParamVerifier } from "contracts/interfaces/licensing/IParamVerifier.sol"; | ||
import { ILicensingFramework } from "contracts/interfaces/licensing/ILicensingFramework.sol"; | ||
import { LicenseRegistry } from "contracts/registries/LicenseRegistry.sol"; | ||
import { Licensing } from "contracts/lib/Licensing.sol"; | ||
import { Errors } from "contracts/lib/Errors.sol"; | ||
import { LicenseRegistryAware } from "contracts/modules/licensing/LicenseRegistryAware.sol"; | ||
|
||
// external | ||
import { ERC165 } from "@openzeppelin/contracts/utils/introspection/ERC165.sol"; | ||
import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; | ||
|
||
abstract contract BaseLicensingFramework is IParamVerifier, ILicensingFramework, ERC165, LicenseRegistryAware { | ||
|
||
string public licenseUrl; | ||
|
||
uint256 public frameworkId; | ||
|
||
/// @notice Initializes the base module contract. | ||
/// @param registry The address of the license registry. | ||
constructor(address registry, string memory templateUrl) LicenseRegistryAware(registry) { | ||
licenseUrl = templateUrl; | ||
} | ||
|
||
function register() external returns(uint256) { | ||
Licensing.Framework memory framework = Licensing.Framework({ | ||
licensingFramework: address(this), | ||
licenseUrl: licenseUrl | ||
}); | ||
frameworkId = LICENSE_REGISTRY.addLicenseFramework(framework); | ||
return frameworkId; | ||
} | ||
|
||
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC165) returns (bool) { | ||
return interfaceId == type(ILicensingFramework).interfaceId || super.supportsInterface(interfaceId); | ||
} | ||
|
||
function licenseRegistry() virtual override external view returns (address) { | ||
return address(LICENSE_REGISTRY); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
// See https://github.com/storyprotocol/protocol-contracts/blob/main/StoryProtocol-AlphaTestingAgreement-17942166.3.pdf | ||
pragma solidity ^0.8.23; | ||
|
||
// contracts | ||
import { LicenseRegistry } from "contracts/registries/LicenseRegistry.sol"; | ||
import { Errors } from "contracts/lib/Errors.sol"; | ||
|
||
abstract contract LicenseRegistryAware { | ||
|
||
/// @notice Gets the protocol-wide license registry. | ||
LicenseRegistry public immutable LICENSE_REGISTRY; | ||
|
||
/// @notice Initializes the base module contract. | ||
/// @param licenseRegistry The address of the license registry. | ||
constructor(address licenseRegistry) { | ||
LICENSE_REGISTRY = LicenseRegistry(licenseRegistry); | ||
} | ||
|
||
/// @notice Modifier for authorizing the calling entity. | ||
modifier onlyLicenseRegistry() { | ||
if (msg.sender != address(LICENSE_REGISTRY)) { | ||
revert Errors.LicenseRegistryAware__CallerNotLicenseRegistry(); | ||
} | ||
_; | ||
} | ||
|
||
} |
Oops, something went wrong.