Skip to content
This repository has been archived by the owner on Dec 3, 2024. It is now read-only.

Commit

Permalink
update Natspec of state variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Lam committed Feb 28, 2024
1 parent 9e330b0 commit daaa54d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
23 changes: 12 additions & 11 deletions contracts/src/TeleporterTokenDestination.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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:
*
Expand Down Expand Up @@ -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_,
Expand All @@ -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
*/
Expand Down
19 changes: 11 additions & 8 deletions contracts/src/TeleporterTokenSource.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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:
Expand Down

0 comments on commit daaa54d

Please sign in to comment.