-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathIETHBridge.sol
More file actions
84 lines (72 loc) · 3.7 KB
/
Copy pathIETHBridge.sol
File metadata and controls
84 lines (72 loc) · 3.7 KB
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
80
81
82
83
84
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;
/// @dev Bridges native value (i.e. ETH) by creating and verifying ETHDeposits.
///
/// These can be created by sending value to the `deposit` function. Later, the receiver can
/// claim the deposit on the destination chain by using a storage proof.
interface IETHBridge {
struct ETHDeposit {
// The nonce of the deposit
uint256 nonce;
// The sender of the deposit
address from;
// The receiver of the deposit
address to;
// The amount of the deposit
uint256 amount;
// Any calldata to be sent to the receiver in case of a contract
bytes data;
// Application-specific context data (e.g., for relayer selection, tips, etc.)
bytes context;
// Address that is allowed to cancel the deposit on the destination chain (zero address means deposit is
// uncancellable)
address canceler;
}
/// @dev Emitted when a deposit is made.
/// @param id The deposit id
/// @param deposit The ETH deposit
event DepositMade(bytes32 indexed id, ETHDeposit deposit);
/// @dev Emitted when a deposit is claimed.
/// @param id The deposit id
/// @param deposit The claimed ETH deposit
event DepositClaimed(bytes32 indexed id, ETHDeposit deposit);
/// @dev Emitted when a deposit is cancelled.
/// @param id The deposit id
/// @param claimee The address that received the cancelled deposit
event DepositCancelled(bytes32 indexed id, address claimee);
/// @dev Failed to call the receiver with value.
error FailedClaim();
/// @dev A deposit was already claimed or cancelled
error AlreadyProcessed();
/// @dev Only canceler can cancel a deposit.
error OnlyCanceler();
/// @dev Whether the deposit identified by `id` has been claimed or cancelled.
/// @param id The deposit id
function processed(bytes32 id) external view returns (bool);
/// @dev ETH Deposit identifier.
/// @param ethDeposit The ETH deposit struct
function getDepositId(ETHDeposit memory ethDeposit) external view returns (bytes32 id);
/// @dev Creates an ETH deposit with `msg.value`
/// @param to The receiver of the deposit
/// @param data Any calldata to be sent to the receiver in case of a contract
/// @param context Application-specific context data
/// @param canceler Address on the destination chain that is allowed to cancel the deposit (zero address means
/// deposit is uncancellable)
function deposit(address to, bytes memory data, bytes memory context, address canceler)
external
payable
returns (bytes32 id);
/// @dev Claims an ETH deposit created by the sender (`from`) with `nonce`. The `value` ETH claimed is
/// sent to the receiver (`to`) after verifying a storage proof.
/// @param ethDeposit The ETH deposit struct
/// @param height The `height` of the checkpoint on the source chain (i.e. the block number or publicationId)
/// @param proof Encoded proof of the storage slot where the deposit is stored
function claimDeposit(ETHDeposit memory ethDeposit, uint256 height, bytes memory proof) external;
/// @dev Initiates a cancel on the deposit, must be called by the canceler on the destination chain.
/// @param ethDeposit The ETH deposit struct
/// @param claimee The address that will receive the cancelled deposit
/// @param height The `height` of the checkpoint on the source chain (i.e. the block number or publicationId)
/// @param proof Encoded proof of the storage slot where the deposit is stored
function cancelDeposit(ETHDeposit memory ethDeposit, address claimee, uint256 height, bytes memory proof)
external;
}