Skip to content

Commit 94c4c7c

Browse files
authored
feat: add direct approval if approving (#82)
1 parent 256561d commit 94c4c7c

4 files changed

Lines changed: 585 additions & 0 deletions

File tree

src/BullaApprovalRegistry.sol

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,28 @@ contract BullaApprovalRegistry is IBullaApprovalRegistry, Ownable, EIP712 {
110110
);
111111
}
112112

113+
/*///////////////////////////////////////////////////////////////
114+
APPROVE FUNCTIONS
115+
//////////////////////////////////////////////////////////////*/
116+
117+
function approveCreateClaim(
118+
address controller,
119+
CreateClaimApprovalType approvalType,
120+
uint64 approvalCount,
121+
bool isBindingAllowed
122+
) external {
123+
BullaClaimPermitLib.approveCreateClaim(
124+
approvals[msg.sender][controller],
125+
controllerRegistry,
126+
_domainSeparatorV4(),
127+
msg.sender,
128+
controller,
129+
approvalType,
130+
approvalCount,
131+
isBindingAllowed
132+
);
133+
}
134+
113135
/*///////////////////////////////////////////////////////////////
114136
ADMIN FUNCTIONS
115137
//////////////////////////////////////////////////////////////*/

src/interfaces/IBullaApprovalRegistry.sol

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,17 @@ interface IBullaApprovalRegistry {
7070
bytes memory signature
7171
) external;
7272

73+
/*///////////////////////////////////////////////////////////////
74+
APPROVE FUNCTIONS
75+
//////////////////////////////////////////////////////////////*/
76+
77+
function approveCreateClaim(
78+
address controller,
79+
CreateClaimApprovalType approvalType,
80+
uint64 approvalCount,
81+
bool isBindingAllowed
82+
) external;
83+
7384
/*///////////////////////////////////////////////////////////////
7485
ADMIN FUNCTIONS
7586
//////////////////////////////////////////////////////////////*/

src/libraries/BullaClaimPermitLib.sol

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,29 @@ library BullaClaimPermitLib {
186186
!SignatureChecker.isValidSignatureNow(user, digest, signature) // spec.SIG1, spec.SIG2
187187
) revert IBullaApprovalRegistry.InvalidSignature();
188188

189+
approveCreateClaim(
190+
approvals,
191+
controllerRegistry,
192+
domainSeparator,
193+
user,
194+
controller,
195+
approvalType,
196+
approvalCount,
197+
isBindingAllowed
198+
);
199+
}
200+
201+
function approveCreateClaim(
202+
Approvals storage approvals,
203+
IBullaControllerRegistry controllerRegistry,
204+
bytes32 domainSeparator,
205+
address user,
206+
address controller,
207+
CreateClaimApprovalType approvalType,
208+
uint64 approvalCount,
209+
bool isBindingAllowed
210+
) public {
211+
uint64 nonce = approvals.createClaim.nonce;
189212
if (approvalType == CreateClaimApprovalType.Unapproved) {
190213
if (approvalCount > 0 || isBindingAllowed) revert IBullaApprovalRegistry.InvalidApproval(); // spec.R2, spec.R3
191214

0 commit comments

Comments
 (0)