Skip to content

Commit 0bd0ec2

Browse files
committed
evm: Add makeCCTPv2Request
1 parent e6c471e commit 0bd0ec2

File tree

4 files changed

+56
-1
lines changed

4 files changed

+56
-1
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,13 @@ uint32 sourceDomain
222222
uint64 nonce
223223
```
224224

225+
##### CCTP v2 Request
226+
227+
```solidity
228+
bytes4 prefix = "ERC2" // 4-byte prefix for this struct
229+
uint8 autoDiscover // Currently, must be one.
230+
```
231+
225232
#### Relay Instructions
226233

227234
##### Gas Instruction

evm/README.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,31 @@ executor.requestExecution{value: executorArgs.value}(
9494

9595
<!-- cspell:enable -->
9696

97+
#### Example v2 CCTP Request
98+
99+
The `depositForBurn` function in CCTP v2 doesn't return anything, so we don't have a unique identifier for a transfer.
100+
The off-chain executor will detect all Circle V2 transfers in the transaction and relay them.
101+
102+
<!-- cspell:disable -->
103+
104+
```solidity
105+
import "example-messaging-executor/evm/src/interfaces/IExecutor.sol";
106+
import "example-messaging-executor/evm/src/libraries/ExecutorMessages.sol";
107+
...
108+
circleTokenMessenger.depositForBurn(amount, destinationDomain, mintRecipient, burnToken, destinationCaller, maxFee, minFinalityThreshold);
109+
110+
executor.requestExecution{value: executorArgs.value}(
111+
0,
112+
bytes32(0),
113+
executorArgs.refundAddress,
114+
executorArgs.signedQuote,
115+
ExecutorMessages.makeCCTPv2Request(),
116+
executorArgs.instructions
117+
);
118+
```
119+
120+
<!-- cspell:enable -->
121+
97122
### Execution Support
98123

99124
#### v1 VAA Execution
@@ -117,7 +142,15 @@ function receiveMessage(bytes memory encodedMessage) external
117142
The Circle Message Transmitter contract implements the following function.
118143

119144
```solidity
120-
function receiveMessage(bytes calldata message,bytes calldata attestation) external override whenNotPaused returns (bool success)
145+
function receiveMessage(bytes calldata message, bytes calldata attestation) external override whenNotPaused returns (bool success)
146+
```
147+
148+
#### v2 CCTP Execution
149+
150+
The Circle Message Transmitter contract implements the following function.
151+
152+
```solidity
153+
function receiveMessage(bytes calldata message, bytes calldata attestation) external override whenNotPaused returns (bool success)
121154
```
122155

123156
## Executor Development

evm/src/libraries/ExecutorMessages.sol

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ library ExecutorMessages {
66
bytes4 private constant REQ_VAA_V1 = "ERV1";
77
bytes4 private constant REQ_NTT_V1 = "ERN1";
88
bytes4 private constant REQ_CCTP_V1 = "ERC1";
9+
bytes4 private constant REQ_CCTP_V2 = "ERC2";
910

1011
/// @notice Payload length will not fit in a uint32.
1112
/// @dev Selector: 492f620d.
@@ -63,4 +64,12 @@ library ExecutorMessages {
6364
function makeCCTPv1Request(uint32 sourceDomain, uint64 nonce) internal pure returns (bytes memory) {
6465
return abi.encodePacked(REQ_CCTP_V1, sourceDomain, nonce);
6566
}
67+
68+
/// @notice Encodes a version 2 CCTP request payload.
69+
/// This request currently assumes the Executor will auto detect the event off chain.
70+
/// That may change in the future, in which case this interface would change.
71+
/// @return bytes The encoded request.
72+
function makeCCTPv2Request() internal pure returns (bytes memory) {
73+
return abi.encodePacked(REQ_CCTP_V2, uint8(1));
74+
}
6675
}

evm/test/ExecutorMessages.t.sol

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,10 @@ contract ExecutorMessagesTest is Test {
4646
bytes memory buf = ExecutorMessages.makeCCTPv1Request(srcDomain, nonce);
4747
assertEq(keccak256(expected), keccak256(buf));
4848
}
49+
50+
function test_makeCCTPv2Request() public pure {
51+
bytes memory expected = abi.encodePacked("ERC2", uint8(1));
52+
bytes memory buf = ExecutorMessages.makeCCTPv2Request();
53+
assertEq(keccak256(expected), keccak256(buf));
54+
}
4955
}

0 commit comments

Comments
 (0)