-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
JoscelynFarr
committed
Apr 12, 2024
1 parent
14ce8c5
commit 2fbfc94
Showing
7 changed files
with
229 additions
and
1 deletion.
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,36 @@ | ||
/* | ||
* Copyright (c) 2022, Circle Internet Financial Limited. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
pragma solidity ^0.8.19; | ||
/** | ||
* @title IMessageHandler | ||
* @notice Handles messages on destination domain forwarded from | ||
* an IReceiver | ||
*/ | ||
interface IMessageHandler { | ||
/** | ||
* @notice handles an incoming message from a Receiver | ||
* @param sourceDomain the source domain of the message | ||
* @param sender the sender of the message | ||
* @param messageBody The message raw bytes | ||
* @return success bool, true if successful | ||
*/ | ||
function handleReceiveMessage( | ||
uint32 sourceDomain, | ||
bytes32 sender, | ||
bytes calldata messageBody | ||
) external returns (bool); | ||
} |
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,26 @@ | ||
/* | ||
* Copyright (c) 2022, Circle Internet Financial Limited. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
pragma solidity ^0.8.19; | ||
|
||
import "./IRelayer.sol"; | ||
import "./IReceiver.sol"; | ||
|
||
/** | ||
* @title IMessageTransmitter | ||
* @notice Interface for message transmitters, which both relay and receive messages. | ||
*/ | ||
interface IMessageTransmitter is IRelayer, IReceiver { } |
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,33 @@ | ||
/* | ||
* Copyright (c) 2022, Circle Internet Financial Limited. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
pragma solidity ^0.8.19; | ||
/** | ||
* @title IReceiver | ||
* @notice Receives messages on destination chain and forwards them to IMessageDestinationHandler | ||
*/ | ||
interface IReceiver { | ||
/** | ||
* @notice Receives an incoming message, validating the header and passing | ||
* the body to application-specific handler. | ||
* @param message The message raw bytes | ||
* @param signature The message signature | ||
* @return success bool, true if successful | ||
*/ | ||
function receiveMessage(bytes calldata message, bytes calldata signature) | ||
external | ||
returns (bool success); | ||
} |
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,72 @@ | ||
/* | ||
* Copyright (c) 2022, Circle Internet Financial Limited. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
pragma solidity ^0.8.19; | ||
/** | ||
* @title IRelayer | ||
* @notice Sends messages from source domain to destination domain | ||
*/ | ||
interface IRelayer { | ||
/** | ||
* @notice Sends an outgoing message from the source domain. | ||
* @dev Increment nonce, format the message, and emit `MessageSent` event with message information. | ||
* @param destinationDomain Domain of destination chain | ||
* @param recipient Address of message recipient on destination domain as bytes32 | ||
* @param messageBody Raw bytes content of message | ||
* @return nonce reserved by message | ||
*/ | ||
function sendMessage( | ||
uint32 destinationDomain, | ||
bytes32 recipient, | ||
bytes calldata messageBody | ||
) external returns (uint64); | ||
|
||
/** | ||
* @notice Sends an outgoing message from the source domain, with a specified caller on the | ||
* destination domain. | ||
* @dev Increment nonce, format the message, and emit `MessageSent` event with message information. | ||
* WARNING: if the `destinationCaller` does not represent a valid address as bytes32, then it will not be possible | ||
* to broadcast the message on the destination domain. This is an advanced feature, and the standard | ||
* sendMessage() should be preferred for use cases where a specific destination caller is not required. | ||
* @param destinationDomain Domain of destination chain | ||
* @param recipient Address of message recipient on destination domain as bytes32 | ||
* @param destinationCaller caller on the destination domain, as bytes32 | ||
* @param messageBody Raw bytes content of message | ||
* @return nonce reserved by message | ||
*/ | ||
function sendMessageWithCaller( | ||
uint32 destinationDomain, | ||
bytes32 recipient, | ||
bytes32 destinationCaller, | ||
bytes calldata messageBody | ||
) external returns (uint64); | ||
|
||
/** | ||
* @notice Replace a message with a new message body and/or destination caller. | ||
* @dev The `originalAttestation` must be a valid attestation of `originalMessage`. | ||
* @param originalMessage original message to replace | ||
* @param originalAttestation attestation of `originalMessage` | ||
* @param newMessageBody new message body of replaced message | ||
* @param newDestinationCaller the new destination caller | ||
*/ | ||
function replaceMessage( | ||
bytes calldata originalMessage, | ||
bytes calldata originalAttestation, | ||
bytes calldata newMessageBody, | ||
bytes32 newDestinationCaller | ||
) external; | ||
} |
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,56 @@ | ||
/** | ||
* @title ITokenMinter | ||
* @notice interface for minter of tokens that are mintable, burnable, and interchangeable | ||
* across domains. | ||
*/ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
pragma solidity ^0.8.19; | ||
interface ITokenMinter { | ||
/** | ||
* @notice Mints `amount` of local tokens corresponding to the | ||
* given (`sourceDomain`, `burnToken`) pair, to `to` address. | ||
* @dev reverts if the (`sourceDomain`, `burnToken`) pair does not | ||
* map to a nonzero local token address. This mapping can be queried using | ||
* getLocalToken(). | ||
* @param sourceDomain Source domain where `burnToken` was burned. | ||
* @param burnToken Burned token address as bytes32. | ||
* @param to Address to receive minted tokens, corresponding to `burnToken`, | ||
* on this domain. | ||
* @param amount Amount of tokens to mint. Must be less than or equal | ||
* to the minterAllowance of this TokenMinter for given `_mintToken`. | ||
* @return mintToken token minted. | ||
*/ | ||
function mint( | ||
uint32 sourceDomain, | ||
bytes32 burnToken, | ||
address to, | ||
uint256 amount | ||
) external returns (address mintToken); | ||
|
||
/** | ||
* @notice Burn tokens owned by this ITokenMinter. | ||
* @param burnToken burnable token. | ||
* @param amount amount of tokens to burn. Must be less than or equal to this ITokenMinter's | ||
* account balance of the given `_burnToken`. | ||
*/ | ||
function burn(address burnToken, uint256 amount) external; | ||
|
||
/** | ||
* @notice Get the local token associated with the given remote domain and token. | ||
* @param remoteDomain Remote domain | ||
* @param remoteToken Remote token | ||
* @return local token address | ||
*/ | ||
function getLocalToken(uint32 remoteDomain, bytes32 remoteToken) | ||
external | ||
view | ||
returns (address); | ||
|
||
/** | ||
* @notice Set the token controller of this ITokenMinter. Token controller | ||
* is responsible for mapping local tokens to remote tokens, and managing | ||
* token-specific limits | ||
* @param newTokenController new token controller address | ||
*/ | ||
function setTokenController(address newTokenController) external; | ||
} |