Skip to content

Commit 111ca6e

Browse files
committed
Updated ERC specs
1 parent 27fbb93 commit 111ca6e

File tree

7 files changed

+27
-35
lines changed

7 files changed

+27
-35
lines changed

contracts/crosschain/axelar/AxelarGatewayDestination.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ import {AxelarGatewayBase} from "./AxelarGatewayBase.sol";
1414
*
1515
* The contract implements implements AxelarExecutable's {_execute} function to execute the message,
1616
* converting Axelar's native workflow into the standard ERC7786 active mode.
17-
* Alternatively, it provides a way to set a message as executed by calling the {setExecutedMessage}
17+
* Alternatively, it provides a way to set a message as executed by calling the {setMessageExecuted}
1818
* function (passive mode).
1919
*/
2020
abstract contract AxelarGatewayDestination is IERC7786GatewayDestinationPassive, AxelarGatewayBase, AxelarExecutable {
2121
using Strings for address;
2222
using Strings for string;
2323

2424
/// @dev Sets a message as executed so it can't be executed again. Should be called by the receiver contract.
25-
function setExecutedMessage(
25+
function setMessageExecuted(
2626
bytes calldata messageKey,
2727
string calldata source, // CAIP-2
2828
string calldata sender, // CAIP-10
@@ -81,7 +81,7 @@ abstract contract AxelarGatewayDestination is IERC7786GatewayDestinationPassive,
8181
require(getRemoteGateway(source).equal(remoteAccount), "Invalid origin gateway");
8282

8383
// Active mode
84-
IERC7786Receiver(receiver.parseAddress()).receiveMessage(
84+
IERC7786Receiver(receiver.parseAddress()).executeMessage(
8585
address(0), // not needed in active mode
8686
new bytes(0), // not needed in active mode
8787
source,

contracts/crosschain/axelar/AxelarGatewaySource.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ abstract contract AxelarGatewaySource is IERC7786GatewaySource, AxelarGatewayBas
3737
bytes memory adapterPayload = abi.encode(sender, receiver, payload, attributes);
3838

3939
// Emit event
40-
emit MessageCreated(
40+
emit MessagePosted(
4141
0,
4242
CAIP10.format(CAIP2.local(), sender),
4343
CAIP10.format(destination, receiver),

contracts/crosschain/interfaces/draft-IERC7786.sol

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,17 @@ pragma solidity ^0.8.0;
99
*/
1010
interface IERC7786GatewaySource {
1111
/**
12-
* @dev Event emitted when a message is created. If `outboxId` is zero, no further processing is necessary, and
13-
* no {MessageSent} event SHOULD be expected. If `outboxId` is not zero, then further (gateway specific, and non
14-
* standardized) action is required.
12+
* @dev Event emitted when a message is created. If `outboxId` is zero, no further processing is necessary. If
13+
* `outboxId` is not zero, then further (gateway specific, and non standardized) action is required.
1514
*/
16-
event MessageCreated(
15+
event MessagePosted(
1716
bytes32 indexed outboxId,
1817
string sender, // CAIP-10 account ID
1918
string receiver, // CAIP-10 account ID
2019
bytes payload,
2120
bytes[] attributes
2221
);
2322

24-
/**
25-
* @dev This event is emitted when a message, for which the {MessageCreated} event contains an non zero `outboxId`,
26-
* received the required post processing actions, and was thus sent to the destination chain.
27-
*/
28-
event MessageSent(bytes32 indexed outboxId);
29-
3023
/// @dev This error is thrown when a message creation fails because of an unsupported attribute being specified.
3124
error UnsupportedAttribute(bytes4 selector);
3225

@@ -39,13 +32,12 @@ interface IERC7786GatewaySource {
3932
* message MUST be sent and this function must return 0.
4033
*
4134
* * MUST emit a {MessageCreated} event.
42-
* * SHOULD NOT emit a {MessageSent} event.
4335
*
4436
* If any of the `attributes` is not supported, this function SHOULD revert with an {UnsupportedAttribute} error.
4537
* Other errors SHOULD revert with errors not specified in ERC-7786.
4638
*/
4739
function sendMessage(
48-
string calldata destination, // CAIP-2 chain ID
40+
string calldata destinationChain, // CAIP-2 chain ID
4941
string calldata receiver, // CAIP-10 account ID
5042
bytes calldata payload,
5143
bytes[] calldata attributes
@@ -68,9 +60,9 @@ interface IERC7786GatewayDestinationPassive {
6860
*
6961
* NOTE: implementing this interface is OPTIONAL. Some destination gateway MAY only support active mode.
7062
*/
71-
function setExecutedMessage(
63+
function setMessageExecuted(
7264
bytes calldata messageKey,
73-
string calldata source,
65+
string calldata sourceChain,
7466
string calldata sender,
7567
bytes calldata payload,
7668
bytes[] calldata attributes
@@ -88,10 +80,10 @@ interface IERC7786Receiver {
8880
*
8981
* This function may be called directly by the gateway (active mode) or by a third party (passive mode).
9082
*/
91-
function receiveMessage(
83+
function executeMessage(
9284
address gateway,
9385
bytes calldata gatewayMessageKey,
94-
string calldata source,
86+
string calldata sourceChain,
9587
string calldata sender,
9688
bytes calldata payload,
9789
bytes[] calldata attributes

contracts/crosschain/mocks/ERC7786GatewayMock.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@ contract ERC7786GatewayMock is IERC7786GatewaySource, IERC7786GatewayDestination
3838

3939
if (_activeMode) {
4040
address target = Strings.parseAddress(receiver);
41-
IERC7786Receiver(target).receiveMessage(address(this), new bytes(0), source, sender, payload, attributes);
41+
IERC7786Receiver(target).executeMessage(address(this), new bytes(0), source, sender, payload, attributes);
4242
} else {
4343
_outbox.set(uint256(keccak256(abi.encode(source, sender, receiver, payload, attributes))));
4444
}
4545

46-
emit MessageCreated(0, CAIP10.format(source, sender), CAIP10.format(source, receiver), payload, attributes);
46+
emit MessagePosted(0, CAIP10.format(source, sender), CAIP10.format(source, receiver), payload, attributes);
4747
return 0;
4848
}
4949

50-
function setExecutedMessage(
50+
function setMessageExecuted(
5151
bytes calldata /*messageKey*/, // this mock doesn't use a messageKey
5252
string calldata source,
5353
string calldata sender,

contracts/crosschain/utils/draft-ERC7786Receiver.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {IERC7786GatewayDestinationPassive, IERC7786Receiver} from "../interfaces
77
/**
88
* @dev Base implementation of an ERC-7786 compliant cross-chain message receiver.
99
*
10-
* This abstract contract exposes the `receiveMessage` function that is used in both active and passive mode for
10+
* This abstract contract exposes the `executeMessage` function that is used in both active and passive mode for
1111
* communication with (one or multiple) destination gateways. This contract leaves two function unimplemented:
1212
*
1313
* {_isKnownGateway}, an internal getter used to verify whether an address is recognised by the contract as a valid
@@ -21,7 +21,7 @@ abstract contract ERC7786Receiver is IERC7786Receiver {
2121
error ERC7786ReceivePassiveModeValue();
2222

2323
/// @inheritdoc IERC7786Receiver
24-
function receiveMessage(
24+
function executeMessage(
2525
address gateway,
2626
bytes calldata gatewayMessageKey,
2727
string calldata source,
@@ -35,7 +35,7 @@ abstract contract ERC7786Receiver is IERC7786Receiver {
3535
} else if (_isKnownGateway(gateway)) {
3636
// Passive mode
3737
if (msg.value != 0) revert ERC7786ReceivePassiveModeValue();
38-
IERC7786GatewayDestinationPassive(gateway).setExecutedMessage(
38+
IERC7786GatewayDestinationPassive(gateway).setMessageExecuted(
3939
gatewayMessageKey,
4040
source,
4141
sender,

test/crosschain/ERC7786Receiver.test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe('ERC7786Receiver', function () {
3131

3232
it('nominal workflow', async function () {
3333
await expect(this.gateway.connect(this.sender).sendMessage(this.caip2, getAddress(this.receiver), payload, attributes))
34-
.to.emit(this.gateway, 'MessageCreated')
34+
.to.emit(this.gateway, 'MessagePosted')
3535
.withArgs(ethers.ZeroHash, this.toCaip10(this.sender), this.toCaip10(this.receiver), payload, attributes)
3636
.to.emit(this.receiver, 'MessageReceived')
3737
.withArgs(this.gateway, this.caip2, getAddress(this.sender), payload, attributes);
@@ -45,12 +45,12 @@ describe('ERC7786Receiver', function () {
4545

4646
it('nominal workflow', async function () {
4747
await expect(this.gateway.connect(this.sender).sendMessage(this.caip2, this.receiver.target, payload, attributes))
48-
.to.emit(this.gateway, 'MessageCreated')
48+
.to.emit(this.gateway, 'MessagePosted')
4949
.withArgs(ethers.ZeroHash, this.toCaip10(this.sender), this.toCaip10(this.receiver), payload, attributes)
5050
.to.not.emit(this.receiver, 'MessageReceived');
5151

5252
await expect(
53-
this.receiver.receiveMessage(this.gateway, '0x', this.caip2, getAddress(this.sender), payload, attributes),
53+
this.receiver.executeMessage(this.gateway, '0x', this.caip2, getAddress(this.sender), payload, attributes),
5454
)
5555
.to.emit(this.receiver, 'MessageReceived')
5656
.withArgs(this.gateway, this.caip2, getAddress(this.sender), payload, attributes);
@@ -62,21 +62,21 @@ describe('ERC7786Receiver', function () {
6262
// Altering the message (in this case, changing the sender's address)
6363
// Here the error is actually triggered by the gateway itself.
6464
await expect(
65-
this.receiver.receiveMessage(this.gateway, '0x', this.caip2, getAddress(this.notAGateway), payload, attributes),
65+
this.receiver.executeMessage(this.gateway, '0x', this.caip2, getAddress(this.notAGateway), payload, attributes),
6666
).to.be.revertedWith('invalid message');
6767
});
6868

6969
it('invalid gateway', async function () {
7070
await expect(
71-
this.receiver.receiveMessage(this.notAGateway, '0x', this.caip2, getAddress(this.sender), payload, attributes),
71+
this.receiver.executeMessage(this.notAGateway, '0x', this.caip2, getAddress(this.sender), payload, attributes),
7272
)
7373
.to.be.revertedWithCustomError(this.receiver, 'ERC7786ReceiverInvalidGateway')
7474
.withArgs(this.notAGateway);
7575
});
7676

7777
it('with value', async function () {
7878
await expect(
79-
this.receiver.receiveMessage(this.gateway, '0x', this.caip2, getAddress(this.sender), payload, attributes, {
79+
this.receiver.executeMessage(this.gateway, '0x', this.caip2, getAddress(this.sender), payload, attributes, {
8080
value: 1n,
8181
}),
8282
).to.be.revertedWithCustomError(this.receiver, 'ERC7786ReceivePassiveModeValue');

test/crosschain/axelar/AxelarGateway.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe('AxelarGateway', function () {
5454

5555
const tx = await this.srcGateway.connect(this.sender).sendMessage(this.CAIP2, getAddress(this.receiver), payload, attributes);
5656
await expect(tx)
57-
.to.emit(this.srcGateway, 'MessageCreated').withArgs(ethers.ZeroHash, srcCAIP10, dstCAIP10, payload, attributes)
57+
.to.emit(this.srcGateway, 'MessagePosted').withArgs(ethers.ZeroHash, srcCAIP10, dstCAIP10, payload, attributes)
5858
.to.emit(this.axelar, 'ContractCall').withArgs(this.srcGateway, 'local', getAddress(this.dstGateway), ethers.keccak256(package), package)
5959
.to.emit(this.axelar, 'ContractCallExecuted').withArgs(anyValue)
6060
.to.emit(this.receiver, 'MessageReceived').withArgs(ethers.ZeroAddress, this.CAIP2, getAddress(this.sender), payload, attributes);
@@ -75,15 +75,15 @@ describe('AxelarGateway', function () {
7575

7676
const tx = await this.srcGateway.connect(this.sender).sendMessage(this.CAIP2, getAddress(this.receiver), payload, attributes);
7777
await expect(tx)
78-
.to.emit(this.srcGateway, 'MessageCreated').withArgs(ethers.ZeroHash, srcCAIP10, dstCAIP10, payload, attributes)
78+
.to.emit(this.srcGateway, 'MessagePosted').withArgs(ethers.ZeroHash, srcCAIP10, dstCAIP10, payload, attributes)
7979
.to.emit(this.axelar, 'ContractCall').withArgs(this.srcGateway, 'local', getAddress(this.dstGateway), ethers.keccak256(package), package)
8080
.to.emit(this.axelar, 'CommandIdPending').withArgs(anyValue, 'local', getAddress(this.dstGateway), package);
8181

8282
const { logs } = await tx.wait();
8383
const commandIdEvent = logs.find(({ address, topics }) => address == this.axelar.target && topics[0] == this.axelar.interface.getEvent('CommandIdPending').topicHash);
8484
const [ commandId ] = this.axelar.interface.decodeEventLog('CommandIdPending', commandIdEvent.data, commandIdEvent.topics);
8585

86-
await expect(this.receiver.receiveMessage(
86+
await expect(this.receiver.executeMessage(
8787
this.dstGateway,
8888
commandId, // bytes32 is already self-encoded
8989
this.CAIP2,

0 commit comments

Comments
 (0)