-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CCTP-support + Remove Replay Protection (#18)
* CCTP support * remove replay protection --------- Co-authored-by: Joe Howarth <[email protected]>
- Loading branch information
1 parent
5b6e2dd
commit bacbe82
Showing
26 changed files
with
2,888 additions
and
568 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
pragma solidity ^0.8.13; | ||
|
||
import "./interfaces/IWormholeReceiver.sol"; | ||
import "./interfaces/IWormholeRelayer.sol"; | ||
import "./interfaces/IWormhole.sol"; | ||
import "./Utils.sol"; | ||
|
||
abstract contract Base { | ||
IWormholeRelayer public immutable wormholeRelayer; | ||
IWormhole public immutable wormhole; | ||
|
||
address registrationOwner; | ||
mapping(uint16 => bytes32) registeredSenders; | ||
|
||
constructor(address _wormholeRelayer, address _wormhole) { | ||
wormholeRelayer = IWormholeRelayer(_wormholeRelayer); | ||
wormhole = IWormhole(_wormhole); | ||
registrationOwner = msg.sender; | ||
} | ||
|
||
modifier onlyWormholeRelayer() { | ||
require( | ||
msg.sender == address(wormholeRelayer), | ||
"Msg.sender is not Wormhole Relayer" | ||
); | ||
_; | ||
} | ||
|
||
modifier isRegisteredSender(uint16 sourceChain, bytes32 sourceAddress) { | ||
require( | ||
registeredSenders[sourceChain] == sourceAddress, | ||
"Not registered sender" | ||
); | ||
_; | ||
} | ||
|
||
/** | ||
* Sets the registered address for 'sourceChain' to 'sourceAddress' | ||
* So that for messages from 'sourceChain', only ones from 'sourceAddress' are valid | ||
* | ||
* Assumes only one sender per chain is valid | ||
* Sender is the address that called 'send' on the Wormhole Relayer contract on the source chain) | ||
*/ | ||
function setRegisteredSender( | ||
uint16 sourceChain, | ||
bytes32 sourceAddress | ||
) public { | ||
require( | ||
msg.sender == registrationOwner, | ||
"Not allowed to set registered sender" | ||
); | ||
registeredSenders[sourceChain] = sourceAddress; | ||
} | ||
} |
Oops, something went wrong.