Skip to content

Commit

Permalink
Merge pull request #2 from ronin-chain/feature/rename-to-katana-and-a…
Browse files Browse the repository at this point in the history
…dd-dependencies

feat: rename to Katana and add dependencies
  • Loading branch information
thaixuandang authored Aug 26, 2024
2 parents 4774b79 + 7491692 commit 04a360b
Show file tree
Hide file tree
Showing 42 changed files with 1,583 additions and 1,509 deletions.
15 changes: 12 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,20 @@ jobs:
fail-fast: true

name: Foundry project
runs-on: ubuntu-latest
runs-on: [self-hosted, gke]

steps:
- uses: actions/checkout@v3
- id: 'gh-app'
name: 'Get Token'
uses: 'tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a' #v1.7.0
with:
app_id: ${{ secrets.GH_APP_ID }}
private_key: ${{ secrets.GH_PRIVATE_KEY }}

- uses: actions/checkout@v4
with:
submodules: recursive
token: ${{ steps.gh-app.outputs.token }}

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
Expand All @@ -37,7 +46,7 @@ jobs:
- name: Run Forge build
run: |
forge --version
forge build --sizes
forge build
id: build

- name: Run Forge tests
Expand Down
14 changes: 13 additions & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,16 @@
path = lib/foundry-deployment-kit
url = https://github.com/axieinfinity/foundry-deployment-kit
branch = v0.2.0


[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "lib/solmate"]
path = lib/solmate
url = https://github.com/transmissions11/solmate
[submodule "lib/katana-v3-contracts"]
path = lib/katana-v3-contracts
url = https://github.com/ronin-chain/katana-v3-contracts
[submodule "lib/permit2"]
path = lib/permit2
url = https://github.com/Uniswap/permit2
1 change: 1 addition & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ ffi = true

solc = '0.8.26'
optimizer_runs = 1_000_000
via_ir=true
evm_version = 'istanbul'
use_literal_content = true
extra_output = ["devdoc", "userdoc", "storagelayout"]
Expand Down
1 change: 1 addition & 0 deletions lib/katana-v3-contracts
Submodule katana-v3-contracts added at dd8273
1 change: 1 addition & 0 deletions lib/openzeppelin-contracts
Submodule openzeppelin-contracts added at dbb610
1 change: 1 addition & 0 deletions lib/permit2
Submodule permit2 added at a7cd18
1 change: 1 addition & 0 deletions lib/solmate
Submodule solmate added at 8d910d
5 changes: 4 additions & 1 deletion remappings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
@contract-libs/=lib/foundry-deployment-kit/lib/contract-libs/src/
forge-std/=lib/foundry-deployment-kit/lib/forge-std/src/
@solady/=lib/foundry-deployment-kit/lib/solady/src/
@openzeppelin/contracts/=lib/foundry-deployment-kit/lib/openzeppelin-contracts/contracts/
@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/
solmate/=lib/solmate/
permit2/=lib/permit2/
@katana/v3-contracts/=lib/katana-v3-contracts/src/
4 changes: 3 additions & 1 deletion script/utils/Contract.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ pragma solidity ^0.8.23;

import { LibString, TContract } from "@fdk/types/Types.sol";

enum Contract { Counter }
enum Contract {
Counter
}

using { key, name } for Contract global;

Expand Down
84 changes: 84 additions & 0 deletions src/aggregate-router/AggregateRouter.sol
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 { }
}
84 changes: 0 additions & 84 deletions src/aggregate-router/UniversalRouter.sol

This file was deleted.

40 changes: 20 additions & 20 deletions src/aggregate-router/base/Callbacks.sol
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;
}
}
Loading

0 comments on commit 04a360b

Please sign in to comment.