Skip to content
This repository was archived by the owner on Jun 24, 2025. It is now read-only.

Commit c375eae

Browse files
authored
Add interfaces back. (#61)
1 parent b46cab7 commit c375eae

File tree

5 files changed

+100
-0
lines changed

5 files changed

+100
-0
lines changed

src/gmp/.soldeerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
out/
2+
cache/
3+
*.json

src/gmp/README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## Analog GMP Interfaces
2+
3+
This repo contains two interfaces by Analog.
4+
1. IGateway.sol
5+
2. IGmpReceiver.sol
6+
7+
### IGateway.sol
8+
Must be implemented by smart contracts which sends a message to Analog's gmp gateway.
9+
10+
### IGmpReceiver.sol
11+
Must be implemented by smart contracts which receives a message from Analog's gmp gateway.

src/gmp/foundry.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[profile.default]
2+
src = "src"
3+
out = "out"

src/gmp/src/IGateway.sol

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// SPDX-License-Identifier: MIT
2+
// Analog's Contracts (last updated v0.1.0) (src/interfaces/IGateway.sol)
3+
4+
pragma solidity >=0.8.0;
5+
6+
/**
7+
* @dev Required interface of an Gateway compliant contract
8+
*/
9+
interface IGateway {
10+
/**
11+
* @dev New GMP submitted by calling the `submitMessage` method.
12+
* @param id EIP-712 hash of the `GmpPayload`, which is it's unique identifier
13+
* @param source sender account, with an extra flag indicating if it is a contract or an EOA
14+
* @param destinationAddress the target address on the destination chain.
15+
* @param destinationNetwork the target chain where the contract call will be made.
16+
* @param gasLimit the gas limit available for the contract call
17+
* @param gasCost the gas limit available for the contract call
18+
* @param nonce Sequence number per sender, used to guarantee each message is unique.
19+
* @param data message data with no specified format
20+
*/
21+
event GmpCreated(
22+
bytes32 indexed id,
23+
bytes32 indexed source,
24+
address indexed destinationAddress,
25+
uint16 destinationNetwork,
26+
uint64 gasLimit,
27+
uint64 gasCost,
28+
uint64 nonce,
29+
bytes data
30+
);
31+
32+
function networkId() external view returns (uint16);
33+
34+
/**
35+
* @notice Estimate the gas cost of execute a GMP message.
36+
* @dev This function is called on the destination chain before calling the gateway to execute a source contract.
37+
* @param networkid The target chain where the contract call will be made
38+
* @param messageSize Message size
39+
* @param messageSize Message gas limit
40+
*/
41+
function estimateMessageCost(uint16 networkid, uint16 messageSize, uint64 gasLimit)
42+
external
43+
view
44+
returns (uint256);
45+
46+
/**
47+
* @dev Send message from chain A to chain B
48+
* @param destinationAddress the target address on the destination chain
49+
* @param destinationNetwork the target chain where the contract call will be made
50+
* @param executionGasLimit the gas limit available for the contract call
51+
* @param data message data with no specified format
52+
*/
53+
function submitMessage(
54+
address destinationAddress,
55+
uint16 destinationNetwork,
56+
uint64 executionGasLimit,
57+
bytes calldata data
58+
) external payable returns (bytes32);
59+
}

src/gmp/src/IGmpReceiver.sol

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// SPDX-License-Identifier: MIT
2+
// Analog's Contracts (last updated v0.1.0) (src/interfaces/IGmpReceiver.sol)
3+
4+
pragma solidity >=0.8.0;
5+
6+
/**
7+
* @dev Required interface of an GMP compliant contract
8+
*/
9+
interface IGmpReceiver {
10+
/**
11+
* @dev Handles the receipt of a single GMP message.
12+
* The contract must verify the msg.sender, it must be the Gateway Contract address.
13+
*
14+
* @param id The EIP-712 hash of the message payload, used as GMP unique identifier
15+
* @param network The chain_id of the source chain who send the message
16+
* @param source The pubkey/address which sent the GMP message
17+
* @param payload The message payload with no specified format
18+
* @return 32 byte result which will be stored together with GMP message
19+
*/
20+
function onGmpReceived(bytes32 id, uint128 network, bytes32 source, uint64 nonce, bytes calldata payload)
21+
external
22+
payable
23+
returns (bytes32);
24+
}

0 commit comments

Comments
 (0)