forked from wormhole-foundation/native-token-transfers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEndpointStandalone.sol
63 lines (52 loc) · 2 KB
/
EndpointStandalone.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// SPDX-License-Identifier: Apache 2
pragma solidity >=0.8.8 <0.9.0;
import "./Endpoint.sol";
import "./interfaces/IManagerStandalone.sol";
import "./interfaces/IEndpointStandalone.sol";
import "./libraries/Implementation.sol";
import "./libraries/external/ReentrancyGuardUpgradeable.sol";
abstract contract EndpointStandalone is
IEndpointStandalone,
Endpoint,
Implementation,
ReentrancyGuardUpgradeable
{
/// @dev updating bridgeManager requires a new Endpoint deployment.
/// Projects should implement their own governance to remove the old Endpoint contract address and then add the new one.
address public immutable manager;
constructor(address _manager) {
manager = _manager;
}
modifier onlyManager() {
if (msg.sender != manager) {
revert CallerNotManager(msg.sender);
}
_;
}
function _initialize() internal override {
// TODO: check if it's safe to not initialise reentrancy guard
__ReentrancyGuard_init();
}
function _migrate() internal override {}
/// @dev When we add new immutables, this function should be updated
function _checkImmutables() internal view override {
assert(this.manager() == manager);
}
function upgrade(address newImplementation) external onlyManager {
_upgrade(newImplementation);
}
/// @notice Called by the BridgeManager contract to send a cross-chain message.
function sendMessage(
uint16 recipientChain,
bytes memory managerMessage
) external payable nonReentrant onlyManager {
_sendMessage(recipientChain, managerMessage);
}
function quoteDeliveryPrice(uint16 targetChain) external view override returns (uint256) {
return _quoteDeliveryPrice(targetChain);
}
function _deliverToManager(EndpointStructs.ManagerMessage memory payload) internal override {
// forward the VAA payload to the endpoint manager contract
IManagerStandalone(manager).attestationReceived(payload);
}
}