* 4.6.0-rc.0 * Fix release script to only release @openzeppelin/contracts (cherry picked from commit2bd75a44bb) * make ERC2981:royaltyInfo public (#3305) (cherry picked from commitd2832ca7a9) Signed-off-by: Hadrien Croubois <hadrien.croubois@gmail.com> * add transpilation guards to the crosschain mocks (#3306) (cherry picked from commit9af5af8fff) Signed-off-by: Hadrien Croubois <hadrien.croubois@gmail.com> * Fix tests on upgradeable contracts after transpilation (cherry picked from commit0762479dd5) Signed-off-by: Hadrien Croubois <hadrien.croubois@gmail.com> * Remove unused constructor argument (cherry picked from commit69c3781043) Signed-off-by: Hadrien Croubois <hadrien.croubois@gmail.com> * Bump minimum Solidity version for Initializable.sol to 0.8.2 (#3328) (cherry picked from commitcb14ea3c5c) * Fix update-comment script to ignore invalid tags (cherry picked from commit848fef5b6c) Signed-off-by: Hadrien Croubois <hadrien.croubois@gmail.com> * 4.6.0 Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
55 lines
1.8 KiB
Solidity
55 lines
1.8 KiB
Solidity
// SPDX-License-Identifier: MIT
|
|
// OpenZeppelin Contracts (last updated v4.6.0) (crosschain/CrossChainEnabled.sol)
|
|
|
|
pragma solidity ^0.8.4;
|
|
|
|
import "./errors.sol";
|
|
|
|
/**
|
|
* @dev Provides information for building cross-chain aware contracts. This
|
|
* abstract contract provides accessors and modifiers to control the execution
|
|
* flow when receiving cross-chain messages.
|
|
*
|
|
* Actual implementations of cross-chain aware contracts, which are based on
|
|
* this abstraction, will have to inherit from a bridge-specific
|
|
* specialization. Such specializations are provided under
|
|
* `crosschain/<chain>/CrossChainEnabled<chain>.sol`.
|
|
*
|
|
* _Available since v4.6._
|
|
*/
|
|
abstract contract CrossChainEnabled {
|
|
/**
|
|
* @dev Throws if the current function call is not the result of a
|
|
* cross-chain execution.
|
|
*/
|
|
modifier onlyCrossChain() {
|
|
if (!_isCrossChain()) revert NotCrossChainCall();
|
|
_;
|
|
}
|
|
|
|
/**
|
|
* @dev Throws if the current function call is not the result of a
|
|
* cross-chain execution initiated by `account`.
|
|
*/
|
|
modifier onlyCrossChainSender(address expected) {
|
|
address actual = _crossChainSender();
|
|
if (expected != actual) revert InvalidCrossChainSender(actual, expected);
|
|
_;
|
|
}
|
|
|
|
/**
|
|
* @dev Returns whether the current function call is the result of a
|
|
* cross-chain message.
|
|
*/
|
|
function _isCrossChain() internal view virtual returns (bool);
|
|
|
|
/**
|
|
* @dev Returns the address of the sender of the cross-chain message that
|
|
* triggered the current function call.
|
|
*
|
|
* IMPORTANT: Should revert with `NotCrossChainCall` if the current function
|
|
* call is not the result of a cross-chain message.
|
|
*/
|
|
function _crossChainSender() internal view virtual returns (address);
|
|
}
|