Skip to content

Commit 2fff384

Browse files
committed
evm: CCTPv2 support
1 parent 13db910 commit 2fff384

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

evm/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,28 @@ executor.requestExecution{value: executorArgs.value}(
9494

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

97+
#### Example v2 CCTP Request
98+
99+
<!-- cspell:disable -->
100+
101+
```solidity
102+
import "example-messaging-executor/evm/src/interfaces/IExecutor.sol";
103+
import "example-messaging-executor/evm/src/libraries/ExecutorMessages.sol";
104+
...
105+
uint64 nonce = circleTokenMessenger.depositForBurn(amount, destinationDomain, mintRecipient, burnToken, destinationCaller, maxFee, minFinalityThreshold);
106+
107+
executor.requestExecution{value: executorArgs.value}(
108+
0,
109+
bytes32(0),
110+
executorArgs.refundAddress,
111+
executorArgs.signedQuote,
112+
ExecutorMessages.makeCCTPv2Request(sourceDomain, nonce),
113+
executorArgs.instructions
114+
);
115+
```
116+
117+
<!-- cspell:enable -->
118+
97119
### Execution Support
98120

99121
#### v1 VAA Execution
@@ -120,6 +142,14 @@ The Circle Message Transmitter contract implements the following function.
120142
function receiveMessage(bytes calldata message,bytes calldata attestation) external override whenNotPaused returns (bool success)
121143
```
122144

145+
#### v2 CCTP Execution
146+
147+
The Circle Message Transmitter contract implements the following function.
148+
149+
```solidity
150+
function receiveMessage(bytes calldata message,bytes calldata attestation) external override whenNotPaused returns (bool success)
151+
```
152+
123153
## Executor Development
124154

125155
### Testing

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+
/// @param sourceDomain The source chain for the CCTP transfer.
70+
/// @param nonce The nonce of the CCTP transfer.
71+
/// @return bytes The encoded request.
72+
function makeCCTPv2Request(uint32 sourceDomain, uint64 nonce) internal pure returns (bytes memory) {
73+
return abi.encodePacked(REQ_CCTP_V2, sourceDomain, nonce);
74+
}
6675
}

evm/test/ExecutorMessages.t.sol

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,12 @@ 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+
uint32 srcDomain = 7;
52+
uint64 nonce = 42;
53+
bytes memory expected = abi.encodePacked("ERC2", srcDomain, nonce);
54+
bytes memory buf = ExecutorMessages.makeCCTPv2Request(srcDomain, nonce);
55+
assertEq(keccak256(expected), keccak256(buf));
56+
}
4957
}

0 commit comments

Comments
 (0)