Skip to content

Commit 5073067

Browse files
committed
chore: forge init
1 parent d45bf6f commit 5073067

File tree

13 files changed

+2275
-0
lines changed

13 files changed

+2275
-0
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "lib/forge-std"]
22
path = lib/forge-std
33
url = https://github.com/foundry-rs/forge-std
4+
[submodule "lib/solady"]
5+
path = lib/solady
6+
url = https://github.com/vectorized/solady

.prettierrc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"plugins": ["prettier-plugin-solidity"],
3+
"useTabs": false,
4+
"printWidth": 120,
5+
"trailingComma": "es5",
6+
"tabWidth": 4,
7+
"semi": false,
8+
"singleQuote": false,
9+
"bracketSpacing": true,
10+
"overrides": [
11+
{
12+
"files": "*.sol",
13+
"options": {
14+
"singleQuote": false
15+
}
16+
}
17+
]
18+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity 0.8.26;
3+
4+
import { ERC4337 } from "solady/accounts/ERC4337.sol";
5+
6+
/// @title SmartAccounts
7+
/// @dev This contract extends the ERC4337 implementation to provide specific behavior for
8+
/// signature verification and domain information for EIP-712 compatibility.
9+
contract SmartAccounts is ERC4337 {
10+
/// @notice Returns the address used to verify ERC1271 signatures.
11+
/// @dev Overrides the `_erc1271Signer` function from the ERC1271 contract.
12+
/// This implementation uses the owner of the account as the signer.
13+
/// @return The address of the signer, which is the owner of the account.
14+
function _erc1271Signer() internal view override returns (address) {
15+
return owner(); // Uses the `owner` function from the `Ownable` contract.
16+
}
17+
18+
/// @notice Provides the domain name and version for EIP-712 typed data signing.
19+
/// @dev Overrides the `_domainNameAndVersion` function from the ERC4337 contract.
20+
/// This is used in EIP-712 for encoding domain-separated data.
21+
/// @return name The name of the domain.
22+
/// @return version The version of the domain.
23+
function _domainNameAndVersion() internal pure override returns (string memory name, string memory version) {
24+
return ("SmartAccount", "1"); // Provides a domain name and version specific to this contract.
25+
}
26+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity 0.8.26;
3+
4+
import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
5+
import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
6+
import { EnumerableSet } from "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
7+
import { ERC165Checker } from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
8+
9+
import { AccessControlledUpgradeable } from "@synaps3/primitives/upgradeable/AccessControlledUpgradeable.sol";
10+
import { IRightsPolicyManager } from "@synaps3/interfaces/rights/IRightsPolicyManager.sol";
11+
import { IRightsAccessAgreement } from "@synaps3/interfaces/rights/IRightsAccessAgreement.sol";
12+
13+
contract AgreementPortal is Initializable, UUPSUpgradeable, AccessControlledUpgradeable {
14+
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
15+
IRightsPolicyManager public immutable RIGHTS_POLICY_MANAGER;
16+
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
17+
IRightsAccessAgreement public immutable RIGHTS_AGREEMENT;
18+
19+
/// @custom:oz-upgrades-unsafe-allow constructor
20+
constructor(address rightsPolicyManager, address rightsAgreement) {
21+
/// https://forum.openzeppelin.com/t/uupsupgradeable-vulnerability-post-mortem/15680
22+
/// https://forum.openzeppelin.com/t/what-does-disableinitializers-function-mean/28730/5
23+
_disableInitializers();
24+
RIGHTS_POLICY_MANAGER = IRightsPolicyManager(rightsPolicyManager);
25+
RIGHTS_AGREEMENT = IRightsAccessAgreement(rightsAgreement);
26+
}
27+
28+
/// @notice Initializes the proxy state.
29+
function initialize(address accessManager) public initializer {
30+
__UUPSUpgradeable_init();
31+
__AccessControlled_init(accessManager);
32+
}
33+
34+
function flashAgreement(
35+
uint256 amount,
36+
address holder,
37+
address currency,
38+
address policyAddress,
39+
address[] calldata parties,
40+
bytes calldata payload
41+
) public returns (uint256) {
42+
address broker = address(RIGHTS_POLICY_MANAGER);
43+
uint256 proof = RIGHTS_AGREEMENT.createAgreement(amount, currency, broker, parties, payload);
44+
return RIGHTS_POLICY_MANAGER.registerPolicy(proof, holder, policyAddress);
45+
}
46+
47+
/// @notice Function that should revert when msg.sender is not authorized to upgrade the contract.
48+
/// @param newImplementation The address of the new implementation contract.
49+
/// @dev See https://docs.openzeppelin.com/contracts/4.x/api/proxy#UUPSUpgradeable-_authorizeUpgrade-address-
50+
function _authorizeUpgrade(address newImplementation) internal override onlyAdmin {}
51+
}

lib/solady

Submodule solady added at 4c8be46

0 commit comments

Comments
 (0)