Skip to content

Commit

Permalink
chore: use named paramaters
Browse files Browse the repository at this point in the history
  • Loading branch information
thaixuandang committed Sep 13, 2024
1 parent b77289f commit 32401f3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
31 changes: 26 additions & 5 deletions src/REP15.sol
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ abstract contract REP15 is ERC721, IREP15, IREP15Errors {
_checkAuthorizedOwnershipManager(tokenId, operator);
_requestDetachContext(ctxHash, tokenId, operator, data);
} else {
// _detachContext(ctxHash, tokenId, operator, data, false, true);
_detachContext({
ctxHash: ctxHash,
tokenId: tokenId,
Expand All @@ -154,7 +153,14 @@ abstract contract REP15 is ERC721, IREP15, IREP15Errors {

_checkAuthorizedOwnershipManager(tokenId, operator);

_detachContext(ctxHash, tokenId, operator, data, true, true);
_detachContext({
ctxHash: ctxHash,
tokenId: tokenId,
operator: operator,
data: data,
checkReadyForDetachment: true,
emitEvent: true
});
}

/**
Expand Down Expand Up @@ -348,7 +354,14 @@ abstract contract REP15 is ERC721, IREP15, IREP15Errors {
REP15Utils.TokenContext storage $tokenContext = _requireAttachedTokenContext(ctxHash, tokenId, true);

if (!$tokenContext.locked) {
_detachContext(ctxHash, tokenId, operator, data, false, true);
_detachContext({
ctxHash: ctxHash,
tokenId: tokenId,
operator: operator,
data: data,
checkReadyForDetachment: false,
emitEvent: true
});
return;
}

Expand Down Expand Up @@ -394,7 +407,8 @@ abstract contract REP15 is ERC721, IREP15, IREP15Errors {

address controller = _contexts[ctxHash].controller;
if (controller.code.length > 0) {
try IREP15ContextCallback(controller).onExecDetachContext(ctxHash, tokenId, contextUser, operator, data) { } catch { }
try IREP15ContextCallback(controller).onExecDetachContext(ctxHash, tokenId, contextUser, operator, data) { }
catch { }
}
}

Expand All @@ -421,7 +435,14 @@ abstract contract REP15 is ERC721, IREP15, IREP15Errors {
bytes32[] storage attachedContexts = _attachedContexts[tokenId];
for (int256 i = int256(attachedContexts.length) - 1; i >= 0; --i) {
bytes32 ctxHash = attachedContexts[uint256(i)];
_detachContext(ctxHash, tokenId, auth, "", _tokenContext[tokenId][ctxHash].locked, false);
_detachContext({
ctxHash: ctxHash,
tokenId: tokenId,
operator: auth,
data: "",
checkReadyForDetachment: _tokenContext[tokenId][ctxHash].locked,
emitEvent: false
});
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/mocks/ControllerMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ contract ControllerMock is IREP15ContextCallback {
if (_reverted) revert("ControllerMock: reverted onDetachRequested");
}

function onExecDetachContext(bytes32 ctxHash, uint256 tokenId, address user, address operator, bytes calldata data) external {
function onExecDetachContext(bytes32 ctxHash, uint256 tokenId, address user, address operator, bytes calldata data)
external
{
emit OnExecDetachContext(ctxHash, tokenId, user, operator, data);
if (_reverted) revert("ControllerMock: reverted onExecDetachContext");
}
Expand Down

0 comments on commit 32401f3

Please sign in to comment.