Skip to content

Commit

Permalink
remove unnecessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
AmadiMichael committed Feb 10, 2024
1 parent 7fff05f commit 3bb58ab
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 43 deletions.
30 changes: 0 additions & 30 deletions src/DN404.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,8 @@ abstract contract DN404 {

error TransferFromIncorrectOwner();

error TransferToNonERC721ReceiverImplementer();

error TokenDoesNotExist();

error CannotLink();

error AlreadyLinked();

error NotLinked();

uint256 private constant _WAD = 1000000000000000000;

uint256 private constant _MAX_TOKEN_ID = 0xffffffff;
Expand Down Expand Up @@ -280,7 +272,6 @@ abstract contract DN404 {
$.ownerships.set(id, 0);
delete $.tokenApprovals[id];

// _logNFTTransfer(t.mirror, from, address(0), id);
packedLogs[n++] = (uint256(uint160(from)) << 96) | id;
} while (i != end);
_logNFTBurn(t.mirror, packedLogs);
Expand Down Expand Up @@ -311,7 +302,6 @@ abstract contract DN404 {
$.ownerships.set(id, toAlias);
$.ownedIndex.set(id, uint32(i++));

// _logNFTTransfer(t.mirror, address(0), to, id);
packedLogs[n++] = (uint256(uint160(_to)) << 96) | id;

// todo: ensure we don't overwrite ownership of early tokens that weren't burned
Expand All @@ -336,26 +326,6 @@ abstract contract DN404 {
require(DN404Mirror(payable(mirror)).logMint(p));
}

function _logNFTTransfer(address mirror, address from, address to, uint256 id) private {
/// @solidity memory-safe-assembly
assembly {
let m := mload(0x40)
mstore(m, 0xf51ac936) // `logTransfer(address,address,uint256)`.
mstore(add(m, 0x20), shr(96, shl(96, from)))
mstore(add(m, 0x40), shr(96, shl(96, to)))
mstore(add(m, 0x60), id)
if iszero(
and(
and(eq(mload(0x00), 1), eq(returndatasize(), 0x20)),
call(gas(), mirror, 0, add(m, 0x1c), 0x64, 0x00, 0x20)
)
) {
returndatacopy(m, 0x00, returndatasize())
revert(m, returndatasize())
}
}
}

function _ownerAt(uint256 id) internal view virtual returns (address result) {
DN404Storage storage $ = _getDN404Storage();
result = $.aliasToAddress[$.ownerships.get(id)];
Expand Down
15 changes: 2 additions & 13 deletions src/DN404Mirror.sol
Original file line number Diff line number Diff line change
Expand Up @@ -372,21 +372,10 @@ contract DN404Mirror {
}
_return(1);
}
// `logTransfer(address,address,uint256)`.
if (fnSelector == 0xf51ac936) {
if (msg.sender != $.rootERC20) revert Unauthorized();

address from = address(uint160(_calldataload(0x04)));
address to = address(uint160(_calldataload(0x24)));
uint256 id = _calldataload(0x44);

emit Transfer(from, to, id);
_return(1);
}
_;
}

function logMint(uint256[] memory p) external returns (bool) {
function logMint(uint256[] calldata p) external returns (bool) {
DN404NFTStorage storage $ = _getDN404NFTStorage();
if (msg.sender != $.rootERC20) revert Unauthorized();

Expand All @@ -402,7 +391,7 @@ contract DN404Mirror {
_return(1);
}

function logBurn(uint256[] memory p) external returns (bool) {
function logBurn(uint256[] calldata p) external returns (bool) {
DN404NFTStorage storage $ = _getDN404NFTStorage();
if (msg.sender != $.rootERC20) revert Unauthorized();

Expand Down

0 comments on commit 3bb58ab

Please sign in to comment.