You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
142 lines
4.9 KiB
142 lines
4.9 KiB
4 years ago
|
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||
|
pragma solidity >=0.6.11;
|
||
|
|
||
3 years ago
|
// ============ Internal Imports ============
|
||
2 years ago
|
import {IInterchainGasPaymaster} from "../interfaces/IInterchainGasPaymaster.sol";
|
||
|
import {IOutbox} from "../interfaces/IOutbox.sol";
|
||
|
import {IAbacusConnectionManager} from "../interfaces/IAbacusConnectionManager.sol";
|
||
3 years ago
|
|
||
4 years ago
|
// ============ External Imports ============
|
||
3 years ago
|
import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
|
||
4 years ago
|
|
||
3 years ago
|
abstract contract AbacusConnectionClient is OwnableUpgradeable {
|
||
4 years ago
|
// ============ Mutable Storage ============
|
||
|
|
||
3 years ago
|
IAbacusConnectionManager public abacusConnectionManager;
|
||
3 years ago
|
// Interchain Gas Paymaster contract. The relayer associated with this contract
|
||
|
// must be willing to relay messages dispatched from the current Outbox contract,
|
||
|
// otherwise payments made to the paymaster will not result in relayed messages.
|
||
|
IInterchainGasPaymaster public interchainGasPaymaster;
|
||
|
|
||
|
uint256[48] private __GAP; // gap for upgrade safety
|
||
4 years ago
|
|
||
3 years ago
|
// ============ Events ============
|
||
|
|
||
|
/**
|
||
3 years ago
|
* @notice Emitted when a new abacusConnectionManager is set.
|
||
|
* @param abacusConnectionManager The address of the abacusConnectionManager contract
|
||
3 years ago
|
*/
|
||
3 years ago
|
event AbacusConnectionManagerSet(address indexed abacusConnectionManager);
|
||
3 years ago
|
|
||
3 years ago
|
/**
|
||
|
* @notice Emitted when a new Interchain Gas Paymaster is set.
|
||
|
* @param interchainGasPaymaster The address of the Interchain Gas Paymaster.
|
||
|
*/
|
||
3 years ago
|
event InterchainGasPaymasterSet(address indexed interchainGasPaymaster);
|
||
3 years ago
|
|
||
4 years ago
|
// ============ Modifiers ============
|
||
|
|
||
|
/**
|
||
3 years ago
|
* @notice Only accept messages from an Abacus Inbox contract
|
||
4 years ago
|
*/
|
||
3 years ago
|
modifier onlyInbox() {
|
||
3 years ago
|
require(_isInbox(msg.sender), "!inbox");
|
||
4 years ago
|
_;
|
||
|
}
|
||
|
|
||
3 years ago
|
// ======== Initializer =========
|
||
4 years ago
|
|
||
3 years ago
|
function __AbacusConnectionClient_initialize(
|
||
|
address _abacusConnectionManager
|
||
2 years ago
|
) internal onlyInitializing {
|
||
3 years ago
|
_setAbacusConnectionManager(_abacusConnectionManager);
|
||
3 years ago
|
__Ownable_init();
|
||
4 years ago
|
}
|
||
|
|
||
2 years ago
|
function __AbacusConnectionClient_initialize(
|
||
|
address _abacusConnectionManager,
|
||
|
address _interchainGasPaymaster
|
||
|
) internal onlyInitializing {
|
||
|
_setInterchainGasPaymaster(_interchainGasPaymaster);
|
||
|
__AbacusConnectionClient_initialize(_abacusConnectionManager);
|
||
|
}
|
||
|
|
||
4 years ago
|
// ============ External functions ============
|
||
|
|
||
|
/**
|
||
3 years ago
|
* @notice Sets the address of the application's AbacusConnectionManager.
|
||
|
* @param _abacusConnectionManager The address of the AbacusConnectionManager contract.
|
||
4 years ago
|
*/
|
||
3 years ago
|
function setAbacusConnectionManager(address _abacusConnectionManager)
|
||
4 years ago
|
external
|
||
3 years ago
|
virtual
|
||
4 years ago
|
onlyOwner
|
||
|
{
|
||
3 years ago
|
_setAbacusConnectionManager(_abacusConnectionManager);
|
||
4 years ago
|
}
|
||
|
|
||
3 years ago
|
/**
|
||
|
* @notice Sets the address of the application's InterchainGasPaymaster.
|
||
|
* @param _interchainGasPaymaster The address of the InterchainGasPaymaster contract.
|
||
|
*/
|
||
|
function setInterchainGasPaymaster(address _interchainGasPaymaster)
|
||
2 years ago
|
external
|
||
|
virtual
|
||
3 years ago
|
onlyOwner
|
||
2 years ago
|
{
|
||
|
_setInterchainGasPaymaster(_interchainGasPaymaster);
|
||
|
}
|
||
|
|
||
|
// ============ Internal functions ============
|
||
|
|
||
|
/**
|
||
|
* @notice Sets the address of the application's InterchainGasPaymaster.
|
||
|
* @param _interchainGasPaymaster The address of the InterchainGasPaymaster contract.
|
||
|
*/
|
||
|
function _setInterchainGasPaymaster(address _interchainGasPaymaster)
|
||
|
internal
|
||
3 years ago
|
{
|
||
|
interchainGasPaymaster = IInterchainGasPaymaster(
|
||
|
_interchainGasPaymaster
|
||
|
);
|
||
3 years ago
|
emit InterchainGasPaymasterSet(_interchainGasPaymaster);
|
||
3 years ago
|
}
|
||
|
|
||
3 years ago
|
/**
|
||
3 years ago
|
* @notice Modify the contract the Application uses to validate Inbox contracts
|
||
3 years ago
|
* @param _abacusConnectionManager The address of the abacusConnectionManager contract
|
||
3 years ago
|
*/
|
||
3 years ago
|
function _setAbacusConnectionManager(address _abacusConnectionManager)
|
||
3 years ago
|
internal
|
||
|
{
|
||
3 years ago
|
abacusConnectionManager = IAbacusConnectionManager(
|
||
|
_abacusConnectionManager
|
||
|
);
|
||
3 years ago
|
emit AbacusConnectionManagerSet(_abacusConnectionManager);
|
||
3 years ago
|
}
|
||
|
|
||
4 years ago
|
/**
|
||
3 years ago
|
* @notice Get the local Outbox contract from the abacusConnectionManager
|
||
3 years ago
|
* @return The local Outbox contract
|
||
4 years ago
|
*/
|
||
3 years ago
|
function _outbox() internal view returns (IOutbox) {
|
||
3 years ago
|
return abacusConnectionManager.outbox();
|
||
4 years ago
|
}
|
||
|
|
||
|
/**
|
||
3 years ago
|
* @notice Determine whether _potentialInbox is an enrolled Inbox from the abacusConnectionManager
|
||
3 years ago
|
* @return True if _potentialInbox is an enrolled Inbox
|
||
4 years ago
|
*/
|
||
3 years ago
|
function _isInbox(address _potentialInbox) internal view returns (bool) {
|
||
3 years ago
|
return abacusConnectionManager.isInbox(_potentialInbox);
|
||
4 years ago
|
}
|
||
|
|
||
|
/**
|
||
3 years ago
|
* @notice Get the local domain from the abacusConnectionManager
|
||
4 years ago
|
* @return The local domain
|
||
|
*/
|
||
3 years ago
|
function _localDomain() internal view virtual returns (uint32) {
|
||
3 years ago
|
return abacusConnectionManager.localDomain();
|
||
4 years ago
|
}
|
||
|
}
|