This repository has been archived by the owner on Dec 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
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
Matthew Lam
committed
Feb 28, 2024
1 parent
9e330b0
commit daaa54d
Showing
2 changed files
with
23 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,24 +18,25 @@ import {IERC20} from "@openzeppelin/[email protected]/token/ERC20/IERC20.sol"; | |
*/ | ||
|
||
/** | ||
* @title TeleporterTokenDestination | ||
* @dev Abstract contract for a Teleporter token bridge that receives tokens from a {TeleporterTokenSource} in exchange for the tokens of this token bridge instance. | ||
*/ | ||
abstract contract TeleporterTokenDestination is | ||
ITeleporterTokenBridge, | ||
TeleporterOwnerUpgradeable | ||
{ | ||
// The blockchain ID of the chain this contract is deployed on. | ||
/// @notice The blockchain ID of the chain this contract is deployed on. | ||
bytes32 public immutable blockchainID; | ||
|
||
// The blockchain ID of the source chain this contract receives tokens from. | ||
/// @notice The blockchain ID of the source chain this contract receives tokens from. | ||
bytes32 public immutable sourceBlockchainID; | ||
// The address of the source token bridge instance this contract receives tokens from. | ||
/// @notice The address of the source token bridge instance this contract receives tokens from. | ||
address public immutable tokenSourceAddress; | ||
// The ERC20 token this contract uses to pay for Teleporter fees. | ||
/// @notice The ERC20 token this contract uses to pay for Teleporter fees. | ||
IERC20 public immutable feeToken; | ||
|
||
/** | ||
* @dev Initializes this destination token bridge instance to receive | ||
* @notice Initializes this destination token bridge instance to receive | ||
* tokens from the specified source blockchain and token bridge instance. | ||
*/ | ||
constructor( | ||
|
@@ -55,9 +56,9 @@ abstract contract TeleporterTokenDestination is | |
} | ||
|
||
/** | ||
* @dev Sends tokens transferred to this contract to the destination token bridge instance. | ||
* @notice Sends tokens to the specified destination token bridge instance. | ||
* | ||
* Burns the bridged amount, and uses Teleporter to send a cross chain message. | ||
* @dev Burns the bridged amount, and uses Teleporter to send a cross chain message. | ||
* TODO: Determine if this can be abstracted to a common function with {TeleporterTokenSource} | ||
* Requirements: | ||
* | ||
|
@@ -119,9 +120,9 @@ abstract contract TeleporterTokenDestination is | |
} | ||
|
||
/** | ||
* @dev See {ITeleporterUpgradeable-_receiveTeleporterMessage} | ||
* @notice Verifies the source token bridge instance, and withdraws the amount to the recipient address. | ||
* | ||
* Verifies the source token bridge instance, and withdraws the amount to the recipient address. | ||
* @dev See {ITeleporterUpgradeable-_receiveTeleporterMessage} | ||
*/ | ||
function _receiveTeleporterMessage( | ||
bytes32 sourceBlockchainID_, | ||
|
@@ -142,14 +143,14 @@ abstract contract TeleporterTokenDestination is | |
} | ||
|
||
/** | ||
* @dev Burns tokens from the sender's balance. | ||
* @notice Burns tokens from the sender's balance. | ||
* @param amount The amount of tokens to burn | ||
*/ | ||
// solhint-disable-next-line no-empty-blocks | ||
function _burn(uint256 amount) internal virtual; | ||
|
||
/** | ||
* @dev Withdraws tokens to the recipient address. | ||
* @notice Withdraws tokens to the recipient address. | ||
* @param recipient The address to withdraw tokens to | ||
* @param amount The amount of tokens to withdraw | ||
*/ | ||
|
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 |
---|---|---|
|
@@ -18,28 +18,31 @@ import {IERC20} from "@openzeppelin/[email protected]/token/ERC20/IERC20.sol"; | |
*/ | ||
|
||
/** | ||
* @title TeleporterTokenSource | ||
* @dev Abstract contract for a Teleporter token bridge that sends tokens to {TeleporterTokenDestination} instances. | ||
* | ||
* This contract also handles multihop transfers, where tokens sent from a {TeleporterTokenDestination} | ||
* instance are forwarded to another {TeleporterTokenDestination} instance. | ||
*/ | ||
abstract contract TeleporterTokenSource is ITeleporterTokenBridge, TeleporterOwnerUpgradeable { | ||
// The blockchain ID of the chain this contract is deployed on. | ||
/// @notice The blockchain ID of the chain this contract is deployed on. | ||
bytes32 public immutable blockchainID; | ||
|
||
// The ERC20 token this contract uses to pay for Teleporter fees. | ||
/// @notice The ERC20 token this contract uses to pay for Teleporter fees. | ||
IERC20 public immutable feeToken; | ||
|
||
// Tracks the balances of tokens sent to other bridge instances. | ||
// Bridges are not allowed to unwrap more than has been sent to them. | ||
// (destinationBlockchainID, destinationBridgeAddress) -> balance | ||
/** | ||
* @notice Tracks the balances of tokens sent to other bridge instances. | ||
* Bridges are not allowed to unwrap more than has been sent to them. | ||
* @dev (destinationBlockchainID, destinationBridgeAddress) -> balance | ||
*/ | ||
mapping( | ||
bytes32 destinationBlockchainID | ||
=> mapping(address destinationBridgeAddress => uint256 balance) | ||
) public bridgedBalances; | ||
|
||
/** | ||
* @dev Initializes this source token bridge instance to send | ||
* @notice Initializes this source token bridge instance to send | ||
* tokens to the specified destination chain and token bridge instance. | ||
*/ | ||
constructor( | ||
|
@@ -52,9 +55,9 @@ abstract contract TeleporterTokenSource is ITeleporterTokenBridge, TeleporterOwn | |
} | ||
|
||
/** | ||
* @dev Sends tokens transferred to this contract to the destination token bridge instance. | ||
* @notice Sends tokens to the specified destination token bridge instance. | ||
* | ||
* Increases the bridge balance sent to each destination token bridge instance, | ||
* @dev Increases the bridge balance sent to each destination token bridge instance, | ||
* and uses Teleporter to send a cross chain message. | ||
* TODO: Determine if this can be abstracted to a common function with {TeleporterTokenDestination} | ||
* Requirements: | ||
|