-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathBridgeValidator.sol
79 lines (68 loc) · 2.39 KB
/
BridgeValidator.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.23;
import { ISuperRegistry } from "src/interfaces/ISuperRegistry.sol";
import { IBridgeValidator } from "src/interfaces/IBridgeValidator.sol";
import { Error } from "src/libraries/Error.sol";
/// @title BridgeValidator
/// @dev Inherited by specific bridge handlers to verify the calldata being sent
/// @author Zeropoint Labs
abstract contract BridgeValidator is IBridgeValidator {
//////////////////////////////////////////////////////////////
// CONSTANTS //
//////////////////////////////////////////////////////////////
ISuperRegistry public immutable superRegistry;
address constant NATIVE = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
//////////////////////////////////////////////////////////////
// CONSTRUCTOR //
//////////////////////////////////////////////////////////////
constructor(address superRegistry_) {
if (superRegistry_ == address(0)) {
revert Error.ZERO_ADDRESS();
}
superRegistry = ISuperRegistry(superRegistry_);
}
//////////////////////////////////////////////////////////////
// EXTERNAL VIEW FUNCTIONS //
//////////////////////////////////////////////////////////////
/// @inheritdoc IBridgeValidator
function validateReceiver(
bytes calldata txData_,
address receiver_
)
external
view
virtual
override
returns (bool valid_);
/// @inheritdoc IBridgeValidator
function validateTxData(ValidateTxDataArgs calldata args_)
external
view
virtual
override
returns (bool hasDstSwap);
/// @inheritdoc IBridgeValidator
function decodeAmountIn(
bytes calldata txData_,
bool genericSwapDisallowed_
)
external
view
virtual
override
returns (uint256 amount_);
/// @inheritdoc IBridgeValidator
function decodeDstSwap(bytes calldata txData_)
external
pure
virtual
override
returns (address token_, uint256 amount_);
/// @inheritdoc IBridgeValidator
function decodeSwapOutputToken(bytes calldata txData_)
external
pure
virtual
override
returns (address outputToken_);
}