forked from Snowfork/snowbridge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIGateway.sol
116 lines (87 loc) · 4.06 KB
/
IGateway.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: 2023 Snowfork <hello@snowfork.com>
pragma solidity 0.8.25;
import {OperatingMode, InboundMessage, ParaID, ChannelID, MultiAddress} from "../Types.sol";
import {Verification} from "../Verification.sol";
import {UD60x18} from "prb/math/src/UD60x18.sol";
interface IGateway {
/**
* Events
*/
// Emitted when inbound message has been dispatched
event InboundMessageDispatched(ChannelID indexed channelID, uint64 nonce, bytes32 indexed messageID, bool success);
// Emitted when an outbound message has been accepted for delivery to a Polkadot parachain
event OutboundMessageAccepted(ChannelID indexed channelID, uint64 nonce, bytes32 indexed messageID, bytes payload);
// Emitted when an agent has been created for a consensus system on Polkadot
event AgentCreated(bytes32 agentID, address agent);
// Emitted when a channel has been created
event ChannelCreated(ChannelID indexed channelID);
// Emitted when a channel has been updated
event ChannelUpdated(ChannelID indexed channelID);
// Emitted when the operating mode is changed
event OperatingModeChanged(OperatingMode mode);
// Emitted when pricing params updated
event PricingParametersChanged();
// Emitted when funds are withdrawn from an agent
event AgentFundsWithdrawn(bytes32 indexed agentID, address indexed recipient, uint256 amount);
// Emitted when foreign token from polkadot registed
event ForeignTokenRegistered(bytes32 indexed tokenID, address token);
/**
* Getters
*/
function operatingMode() external view returns (OperatingMode);
function channelOperatingModeOf(ChannelID channelID) external view returns (OperatingMode);
function channelNoncesOf(ChannelID channelID) external view returns (uint64, uint64);
function agentOf(bytes32 agentID) external view returns (address);
function pricingParameters() external view returns (UD60x18, uint128);
function implementation() external view returns (address);
/**
* Messaging
*/
// Submit a message from a Polkadot network
function submitV1(
InboundMessage calldata message,
bytes32[] calldata leafProof,
Verification.Proof calldata headerProof
) external;
/**
* Token Transfers
*/
// @dev Emitted when the fees updated
event TokenTransferFeesChanged();
/// @dev Emitted once the funds are locked and an outbound message is successfully queued.
event TokenSent(
address indexed token,
address indexed sender,
ParaID indexed destinationChain,
MultiAddress destinationAddress,
uint128 amount
);
/// @dev Emitted when a command is sent to register a new wrapped token on AssetHub
event TokenRegistrationSent(address token);
/// @dev Check whether a token is registered
function isTokenRegistered(address token) external view returns (bool);
/// @dev Get token id of an ERC20 contract address.
function queryForeignTokenID(address token) external view returns (bytes32);
/// @dev Quote a fee in Ether for registering a token, covering
/// 1. Delivery costs to BridgeHub
/// 2. XCM Execution costs on AssetHub
function quoteRegisterTokenFee() external view returns (uint256);
/// @dev Register an ERC20 token and create a wrapped derivative on AssetHub in the `ForeignAssets` pallet.
function registerToken(address token) external payable;
/// @dev Quote a fee in Ether for sending a token
/// 1. Delivery costs to BridgeHub
/// 2. XCM execution costs on destinationChain
function quoteSendTokenFee(address token, ParaID destinationChain, uint128 destinationFee)
external
view
returns (uint256);
/// @dev Send ERC20 tokens to parachain `destinationChain` and deposit into account `destinationAddress`
function sendToken(
address token,
ParaID destinationChain,
MultiAddress calldata destinationAddress,
uint128 destinationFee,
uint128 amount
) external payable;
}