-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from ronin-chain/feature/rename-to-katana-and-a…
…dd-dependencies feat: rename to Katana and add dependencies
- Loading branch information
Showing
42 changed files
with
1,583 additions
and
1,509 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
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
Submodule katana-v3-contracts
added at
dd8273
Submodule openzeppelin-contracts
added at
dbb610
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,84 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
pragma solidity ^0.8.17; | ||
|
||
// Command implementations | ||
import { Dispatcher } from "./base/Dispatcher.sol"; | ||
import { RewardsCollector } from "./base/RewardsCollector.sol"; | ||
import { RouterParameters } from "./base/RouterImmutables.sol"; | ||
import { PaymentsImmutables, PaymentsParameters } from "./modules/PaymentsImmutables.sol"; | ||
import { NFTImmutables, NFTParameters } from "./modules/NFTImmutables.sol"; | ||
import { KatanaImmutables, KatanaParameters } from "./modules/katana/KatanaImmutables.sol"; | ||
import { Commands } from "./libraries/Commands.sol"; | ||
import { IAggregateRouter } from "./interfaces/IAggregateRouter.sol"; | ||
|
||
contract AggregateRouter is IAggregateRouter, Dispatcher, RewardsCollector { | ||
modifier checkDeadline(uint256 deadline) { | ||
if (block.timestamp > deadline) revert TransactionDeadlinePassed(); | ||
_; | ||
} | ||
|
||
constructor(RouterParameters memory params) | ||
KatanaImmutables( | ||
KatanaParameters(params.v2Factory, params.v3Factory, params.pairInitCodeHash, params.poolInitCodeHash) | ||
) | ||
PaymentsImmutables(PaymentsParameters(params.permit2, params.weth9, params.openseaConduit, params.sudoswap)) | ||
NFTImmutables( | ||
NFTParameters( | ||
params.seaportV1_5, | ||
params.seaportV1_4, | ||
params.nftxZap, | ||
params.x2y2, | ||
params.foundation, | ||
params.sudoswap, | ||
params.elementMarket, | ||
params.nft20Zap, | ||
params.cryptopunks, | ||
params.looksRareV2, | ||
params.routerRewardsDistributor, | ||
params.looksRareRewardsDistributor, | ||
params.looksRareToken | ||
) | ||
) | ||
{ } | ||
|
||
/// @inheritdoc IAggregateRouter | ||
function execute(bytes calldata commands, bytes[] calldata inputs, uint256 deadline) | ||
external | ||
payable | ||
checkDeadline(deadline) | ||
{ | ||
execute(commands, inputs); | ||
} | ||
|
||
/// @inheritdoc Dispatcher | ||
function execute(bytes calldata commands, bytes[] calldata inputs) public payable override isNotLocked { | ||
bool success; | ||
bytes memory output; | ||
uint256 numCommands = commands.length; | ||
if (inputs.length != numCommands) revert LengthMismatch(); | ||
|
||
// loop through all given commands, execute them and pass along outputs as defined | ||
for (uint256 commandIndex = 0; commandIndex < numCommands;) { | ||
bytes1 command = commands[commandIndex]; | ||
|
||
bytes calldata input = inputs[commandIndex]; | ||
|
||
(success, output) = dispatch(command, input); | ||
|
||
if (!success && successRequired(command)) { | ||
revert ExecutionFailed({ commandIndex: commandIndex, message: output }); | ||
} | ||
|
||
unchecked { | ||
commandIndex++; | ||
} | ||
} | ||
} | ||
|
||
function successRequired(bytes1 command) internal pure returns (bool) { | ||
return command & Commands.FLAG_ALLOW_REVERT == 0; | ||
} | ||
|
||
/// @notice To receive ETH from WETH and NFT protocols | ||
receive() external payable { } | ||
} |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,32 +1,32 @@ | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
pragma solidity ^0.8.17; | ||
|
||
import {IERC721Receiver} from '@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol'; | ||
import {IERC1155Receiver} from '@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol'; | ||
import {IERC165} from '@openzeppelin/contracts/utils/introspection/IERC165.sol'; | ||
import { IERC721Receiver } from "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol"; | ||
import { IERC1155Receiver } from "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol"; | ||
import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol"; | ||
|
||
/// @title ERC Callback Support | ||
/// @notice Implements various functions introduced by a variety of ERCs for security reasons. | ||
/// All are called by external contracts to ensure that this contract safely supports the ERC in question. | ||
contract Callbacks is IERC721Receiver, IERC1155Receiver { | ||
function onERC721Received(address, address, uint256, bytes calldata) external pure returns (bytes4) { | ||
return this.onERC721Received.selector; | ||
} | ||
function onERC721Received(address, address, uint256, bytes calldata) external pure returns (bytes4) { | ||
return this.onERC721Received.selector; | ||
} | ||
|
||
function onERC1155Received(address, address, uint256, uint256, bytes calldata) external pure returns (bytes4) { | ||
return this.onERC1155Received.selector; | ||
} | ||
function onERC1155Received(address, address, uint256, uint256, bytes calldata) external pure returns (bytes4) { | ||
return this.onERC1155Received.selector; | ||
} | ||
|
||
function onERC1155BatchReceived(address, address, uint256[] calldata, uint256[] calldata, bytes calldata) | ||
external | ||
pure | ||
returns (bytes4) | ||
{ | ||
return this.onERC1155BatchReceived.selector; | ||
} | ||
function onERC1155BatchReceived(address, address, uint256[] calldata, uint256[] calldata, bytes calldata) | ||
external | ||
pure | ||
returns (bytes4) | ||
{ | ||
return this.onERC1155BatchReceived.selector; | ||
} | ||
|
||
function supportsInterface(bytes4 interfaceId) external pure returns (bool) { | ||
return interfaceId == type(IERC1155Receiver).interfaceId || interfaceId == type(IERC721Receiver).interfaceId | ||
|| interfaceId == type(IERC165).interfaceId; | ||
} | ||
function supportsInterface(bytes4 interfaceId) external pure returns (bool) { | ||
return interfaceId == type(IERC1155Receiver).interfaceId || interfaceId == type(IERC721Receiver).interfaceId | ||
|| interfaceId == type(IERC165).interfaceId; | ||
} | ||
} |
Oops, something went wrong.