-
Notifications
You must be signed in to change notification settings - Fork 65
Single AddressBook for all adapters #919
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
74dd4f4
use a single address book instead of 1 per adapter for oft / xerc20 s…
grasphoper 1fe0b5e
update comments and naming
grasphoper 043c977
add a gas optimization suggested in OFT PR
grasphoper 4280e76
address PR comments and minor improvements
grasphoper 845cf49
fix spokePool test
grasphoper c03631d
Merge branch 'march-25-evm-audit' into if/single-addressbook
grasphoper 5d4df51
address PR comments
grasphoper File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,52 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity ^0.8.0; | ||
|
||
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; | ||
import { IOFT } from "../interfaces/IOFT.sol"; | ||
|
||
/** | ||
* @dev A helper contract for chain adapters that support OFT or XERC20 messaging on L1 | ||
* @dev Handles token => messenger/router mapping storage, as adapters are called via delegatecall and don't have relevant storage space | ||
*/ | ||
contract AdapterStore is Ownable { | ||
mapping(uint256 => mapping(address => address)) public oftMessengers; | ||
|
||
event OFTMessengerSet(uint256 indexed adapterDstId, address indexed l1Token, address oftMessenger); | ||
|
||
error OFTTokenMismatch(); | ||
error ArrayLengthMismatch(); | ||
|
||
function setOFTMessenger( | ||
uint256 adapterDstId, | ||
address l1Token, | ||
address oftMessenger | ||
) external onlyOwner { | ||
_setOFTMessenger(adapterDstId, l1Token, oftMessenger); | ||
} | ||
|
||
function batchSetOFTMessenger( | ||
uint256[] calldata adapterIds, | ||
address[] calldata tokens, | ||
address[] calldata messengers | ||
) external onlyOwner { | ||
if (adapterIds.length != tokens.length || adapterIds.length != messengers.length) { | ||
revert ArrayLengthMismatch(); | ||
} | ||
|
||
for (uint256 i = 0; i < adapterIds.length; i++) { | ||
_setOFTMessenger(adapterIds[i], tokens[i], messengers[i]); | ||
} | ||
} | ||
|
||
function _setOFTMessenger( | ||
uint256 _adapterChainId, | ||
address _l1Token, | ||
address _oftMessenger | ||
) internal { | ||
if (IOFT(_oftMessenger).token() != _l1Token) { | ||
revert OFTTokenMismatch(); | ||
} | ||
grasphoper marked this conversation as resolved.
Show resolved
Hide resolved
|
||
oftMessengers[_adapterChainId][_l1Token] = _oftMessenger; | ||
emit OFTMessengerSet(_adapterChainId, _l1Token, _oftMessenger); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.