Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ERC20Bridgeable: An ERC-7802 implementation #27

Merged
merged 116 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
eee0853
cross-chain prototype v1
Amxx Jun 21, 2024
50ced4a
split common <> axelar
Amxx Jun 21, 2024
28e88cd
add relay observability
Amxx Jun 23, 2024
948dab4
Update oz to master
ernestognw Jul 30, 2024
e350890
Iterate
Aug 13, 2024
de9da70
Remove salt
Aug 13, 2024
d760742
Iterate
Aug 14, 2024
348ad8d
Add GatewayAxelar specialization
Aug 14, 2024
edfd3ed
Iterate
ernestognw Aug 14, 2024
645794b
Fix GatewayAxelarSource
ernestognw Aug 20, 2024
270c5bd
Remove unnecessary contract
ernestognw Aug 26, 2024
4605a57
Iteration
ernestognw Aug 26, 2024
597bfc2
Remove interfaces
ernestognw Aug 26, 2024
2951fa5
Checkpoint
ernestognw Aug 26, 2024
a7bd130
Add incoming dual mode
ernestognw Aug 26, 2024
2f4588e
Fix compilation
ernestognw Aug 26, 2024
fd010bd
Apply review suggestions
ernestognw Aug 26, 2024
aa731cc
Install axelar contracts
ernestognw Sep 3, 2024
e39ff3a
Apply review sugggestion
ernestognw Sep 3, 2024
b54dda1
Resolve conflcits
ernestognw Sep 3, 2024
0e7d040
Apply suggestions
ernestognw Sep 3, 2024
2402926
wip fixes
frangio Sep 3, 2024
27dcd99
trying to get crosschain to compile
Amxx Sep 5, 2024
01d98fd
fix compilation
Amxx Sep 5, 2024
85ee12a
minor update
Amxx Sep 5, 2024
cdc3c94
make attributes a bytes[]
Amxx Sep 5, 2024
d7ce229
Address comments and add some tests
ernestognw Sep 10, 2024
6dc1c44
refactor and test caip utils
Amxx Sep 10, 2024
4cdf242
up
Amxx Sep 11, 2024
40b33a2
using unmerged version of Strings with parsing
Amxx Sep 16, 2024
a8ee58b
up
Amxx Sep 18, 2024
91cb0ac
workflow testing (active and passive)
Amxx Sep 18, 2024
80b0a59
update
Amxx Sep 19, 2024
b2ac19d
up
Amxx Sep 20, 2024
4f0f1f0
address PR comments
Amxx Sep 30, 2024
5a5b764
renovate
Amxx Sep 30, 2024
46db15d
rename
Amxx Sep 30, 2024
70855f7
fix foundry
Amxx Sep 30, 2024
3f3d6b6
codespell
Amxx Sep 30, 2024
336a56b
use checksumed addresses
Amxx Oct 1, 2024
86caeeb
use @openzepplin/contracts@master
Amxx Oct 22, 2024
426c3fc
add/move files that are no longer planned to be in the main repo
Amxx Oct 22, 2024
12236dd
get submodules when running tests
Amxx Oct 22, 2024
aad8745
Apply suggestions from code review
Amxx Oct 22, 2024
2aa5c15
Apply suggestions from code review
Amxx Oct 22, 2024
98dede1
simplify
Amxx Oct 22, 2024
9bd6a3b
update
Amxx Oct 22, 2024
c926b36
validateReceivedMessage -> setExecutedMessage
ernestognw Oct 29, 2024
a5f1368
Add docs
ernestognw Oct 29, 2024
6089900
Update AxelarGatewayDestination.sol
ernestognw Oct 30, 2024
a38ec99
Update
ernestognw Oct 30, 2024
27fbb93
Update
ernestognw Oct 30, 2024
12dd1d5
Standard cross-chain gateways and Axelar adapters (#9)
ernestognw Nov 1, 2024
111ca6e
Updated ERC specs
Amxx Nov 1, 2024
7e623de
executeMessage returns bytes4
Amxx Nov 5, 2024
fa95a69
Add AxelarGatewayDuplex
Amxx Nov 18, 2024
2117750
remove npm contracts dependency in favor of the master submodule
Amxx Nov 20, 2024
0d214da
slither remappings
Amxx Nov 20, 2024
3555ced
clarify CAIP-10 format
Amxx Nov 20, 2024
ddafa59
document reverts
Amxx Nov 20, 2024
00c5054
unused imports
Amxx Nov 20, 2024
b3d5990
unexpected attributes too short
Amxx Nov 20, 2024
0d84e79
document remoteGateway format
Amxx Nov 20, 2024
c31ff36
clarify AxelarGatewayDestination._execute
Amxx Nov 20, 2024
b6bef4e
rewrite require(..., error); as if (...) revert error;
Amxx Nov 20, 2024
2501575
typography
Amxx Nov 20, 2024
c07671e
custom errors
Amxx Nov 20, 2024
a67fa52
replace require with string with custom error
Amxx Nov 21, 2024
5edcfcb
Apply audit review suggestions
ernestognw Nov 28, 2024
5fbdc75
Adjust checks.yml
ernestognw Nov 28, 2024
fef72ea
Pick CI changes
ernestognw Nov 28, 2024
b173eed
Merge branch 'crosschain-audit-oct-2024' into cross-chain/prototype-v1
ernestognw Nov 28, 2024
650b9f4
Point gitmodules to master on OZ contracts
ernestognw Nov 28, 2024
0eee4fd
lint
ernestognw Nov 28, 2024
b19668e
Fix CI
ernestognw Nov 28, 2024
5d49769
Fix CI 2
ernestognw Nov 28, 2024
a3fb918
Fix slither
ernestognw Nov 28, 2024
6e6e72e
up
ernestognw Nov 28, 2024
b55ef66
up
ernestognw Nov 28, 2024
eefb622
Disable locked-ether slither rule for duplex
ernestognw Nov 28, 2024
823a33f
Make prettier version consistent
ernestognw Nov 28, 2024
e1b29c5
Run `forge update`
ernestognw Nov 28, 2024
8c58bef
Sync prettier version with vanilla contracts
ernestognw Nov 28, 2024
e3d2a9f
Point .gitmodules to master
ernestognw Nov 28, 2024
65c4f5c
Merge branch 'crosschain-audit-oct-2024' into cross-chain/prototype-v1
ernestognw Nov 28, 2024
95dcdbf
ERC7802 with ERC7786 gateway
ernestognw Nov 28, 2024
fb86380
Offload logic from token
ernestognw Nov 28, 2024
3994428
Change approach
ernestognw Nov 28, 2024
8033917
Rename
ernestognw Nov 28, 2024
0e4560c
Update NatSpec
ernestognw Nov 28, 2024
720aa18
Simplified
ernestognw Nov 28, 2024
fcf6389
Simplify more
ernestognw Nov 28, 2024
8f5d7bb
Simplify more
ernestognw Nov 28, 2024
9d4397a
up
ernestognw Nov 28, 2024
580449b
up
ernestognw Nov 28, 2024
3336295
Merge branch 'master' into erc7802
ernestognw Dec 2, 2024
3e4ce63
up
ernestognw Dec 2, 2024
bcbe2f4
up
ernestognw Dec 2, 2024
96047c6
Add tests
ernestognw Dec 8, 2024
6790552
Test ERC165 in ERC20Bridgeable
ernestognw Dec 10, 2024
2a307f3
Merge branch 'master' into erc7802
ernestognw Dec 10, 2024
209ec85
Update draft-ERC20Bridgeable.sol
Amxx Dec 10, 2024
3b831b3
simplify mock
Amxx Dec 10, 2024
ed3bdbe
cleanup
Amxx Dec 10, 2024
03d8e72
Merge branch 'master' into erc7802
ernestognw Dec 10, 2024
740410d
Downgrade to Solidity 0.8.20 in IERC7802 and ERC20Bridgeable
ernestognw Dec 10, 2024
ef98b13
shouldSupportInterfaces update
Amxx Dec 11, 2024
9ee73e3
remapping to the helpers in lib/@openzeppelin-contracts/test
Amxx Dec 11, 2024
a425efd
change dependency
Amxx Dec 11, 2024
a9ff35e
move interface
Amxx Dec 11, 2024
902fd6c
skip foundry install
Amxx Dec 12, 2024
4474056
checkout recurcive
Amxx Dec 12, 2024
02fae41
Update contracts/token/ERC20/extensions/draft-ERC20Bridgeable.sol
Amxx Dec 12, 2024
579029d
re-add test:inheritance
Amxx Dec 12, 2024
989121b
fix inheritance ordering
Amxx Dec 12, 2024
8f77104
Merge branch 'erc7802' of github.com:OpenZeppelin/openzeppelin-contra…
Amxx Dec 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,3 @@ runs:
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly
- name: Install submodule dependencies
shell: bash
run: forge install
8 changes: 8 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ jobs:
GAS: true
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up environment
uses: ./.github/actions/setup
- name: Run tests and generate gas report
Expand All @@ -44,6 +46,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up environment
uses: ./.github/actions/setup
- name: Run coverage
Expand All @@ -53,6 +57,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up environment
uses: ./.github/actions/setup
- name: Run tests
Expand All @@ -62,6 +68,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up environment
uses: ./.github/actions/setup
- uses: crytic/[email protected]
Expand Down
27 changes: 27 additions & 0 deletions contracts/mocks/token/draft-ERC20BridgeableMock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;

import {ERC20, ERC20Bridgeable} from "../../token/ERC20/extensions/draft-ERC20Bridgeable.sol";

abstract contract ERC20BridgeableMock is ERC20Bridgeable {
address bridge;

error OnlyTokenBridge();

event OnlyTokenBridgeFnCalled(address caller);

constructor(address bridge_) {
bridge = bridge_;
}

function onlyTokenBridgeFn() external onlyTokenBridge {
emit OnlyTokenBridgeFnCalled(msg.sender);
}

function _checkTokenBridge(address sender) internal view override {
if (sender != bridge) {
revert OnlyTokenBridge();
}
}
}
51 changes: 51 additions & 0 deletions contracts/token/ERC20/extensions/draft-ERC20Bridgeable.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.20;

import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {IERC7802} from "./draft-IERC7802.sol";
import {ERC165, IERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";

/**
* @dev ERC20 extension that implements the standard token interface according to
* https://github.com/ethereum/ERCs/blob/bcea9feb6c3f3ded391e33690056635d722b101e/ERCS/erc-7802.md[ERC-7802].
*
* NOTE: To implement a crosschain gateway for a chain, consider using an implementation if {IERC7786} token
* bridge (e.g. {AxelarGatewaySource}, {AxelarGatewayDestination}).
*/
abstract contract ERC20Bridgeable is ERC20, ERC165, IERC7802 {
/// @dev Modifier to restrict access to the token bridge.
modifier onlyTokenBridge() {
_checkTokenBridge(msg.sender);
_;
}

/// @inheritdoc ERC165
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return interfaceId == type(IERC7802).interfaceId || super.supportsInterface(interfaceId);
}

/**
* @dev See {IERC7802-crosschainMint}. Emits a {CrosschainMint} event.
*/
function crosschainMint(address to, uint256 value) public virtual override onlyTokenBridge {
_mint(to, value);
emit CrosschainMint(to, value, msg.sender);
}

/**
* @dev See {IERC7802-crosschainBurn}. Emits a {CrosschainBurn} event.
*/
function crosschainBurn(address from, uint256 value) public virtual override onlyTokenBridge {
_burn(from, value);
emit CrosschainBurn(from, value, msg.sender);
}

/**
* @dev Checks if the caller is a trusted token bridge. MUST revert otherwise.
*
* Developers should implement this function using an access control mechanism that allows
* customizing the list of allowed senders. Consider using {AccessControl} or {AccessManaged}.
*/
function _checkTokenBridge(address caller) internal virtual;
}
30 changes: 30 additions & 0 deletions contracts/token/ERC20/extensions/draft-IERC7802.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;

import {IERC165} from "@openzeppelin/contracts/utils/introspection/IERC165.sol";

/// @title IERC7802
/// @notice Defines the interface for crosschain ERC20 transfers.
interface IERC7802 is IERC165 {
/// @notice Emitted when a crosschain transfer mints tokens.
/// @param to Address of the account tokens are being minted for.
/// @param amount Amount of tokens minted.
/// @param sender Address of the caller (msg.sender) who invoked crosschainMint.
event CrosschainMint(address indexed to, uint256 amount, address indexed sender);

/// @notice Emitted when a crosschain transfer burns tokens.
/// @param from Address of the account tokens are being burned from.
/// @param amount Amount of tokens burned.
/// @param sender Address of the caller (msg.sender) who invoked crosschainBurn.
event CrosschainBurn(address indexed from, uint256 amount, address indexed sender);

/// @notice Mint tokens through a crosschain transfer.
/// @param _to Address to mint tokens to.
/// @param _amount Amount of tokens to mint.
function crosschainMint(address _to, uint256 _amount) external;

/// @notice Burn tokens through a crosschain transfer.
/// @param _from Address to burn tokens from.
/// @param _amount Amount of tokens to burn.
function crosschainBurn(address _from, uint256 _amount) external;
}
Loading
Loading