Skip to content

Commit 14ee3ce

Browse files
committed
remove compose from oapp-solana
1 parent 15f7970 commit 14ee3ce

40 files changed

Lines changed: 440 additions & 1993 deletions

examples/oapp-solana/contracts/MyOApp.sol

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,20 @@ contract MyOApp is OApp, OAppOptionsType3 {
1919
* @notice Sends a message from the source chain to a destination chain.
2020
* @param _dstEid The endpoint ID of the destination chain.
2121
* @param _message The message string to be sent.
22-
* @param _composeMsg Extra “compose” bytes appended after the string.
2322
* @param _options Additional options for message execution.
2423
* @dev Encodes the message as bytes and sends it using the `_lzSend` internal function.
2524
* @return receipt A `MessagingReceipt` struct containing details of the message sent.
2625
*/
2726
function send(
2827
uint32 _dstEid,
2928
string calldata _message,
30-
bytes calldata _composeMsg,
3129
bytes calldata _options
3230
) external payable returns (MessagingReceipt memory receipt) {
3331
bytes memory _payload = abi.encodePacked(
3432
abi.encode(uint256(bytes(_message).length)),
35-
bytes(_message),
36-
_composeMsg
33+
bytes(_message)
3734
);
38-
uint8 msgType = _composeMsg.length > 0 ? StringMsgCodec.COMPOSED_TYPE : StringMsgCodec.VANILLA_TYPE;
39-
bytes memory options = combineOptions(_dstEid, msgType, _options);
35+
bytes memory options = combineOptions(_dstEid, StringMsgCodec.VANILLA_TYPE, _options);
4036
receipt = _lzSend(_dstEid, _payload, options, MessagingFee(msg.value, 0), payable(msg.sender));
4137
}
4238

@@ -51,17 +47,14 @@ contract MyOApp is OApp, OAppOptionsType3 {
5147
function quote(
5248
uint32 _dstEid,
5349
string calldata _message,
54-
bytes calldata _composeMsg,
5550
bytes calldata _options,
5651
bool _payInLzToken
5752
) public view returns (MessagingFee memory fee) {
5853
bytes memory payload = abi.encodePacked(
5954
abi.encode(uint256(bytes(_message).length)),
60-
bytes(_message),
61-
_composeMsg
55+
bytes(_message)
6256
);
63-
uint8 msgType = _composeMsg.length > 0 ? StringMsgCodec.COMPOSED_TYPE : StringMsgCodec.VANILLA_TYPE;
64-
bytes memory options = combineOptions(_dstEid, msgType, _options);
57+
bytes memory options = combineOptions(_dstEid, StringMsgCodec.VANILLA_TYPE, _options);
6558
fee = _quote(_dstEid, payload, options, _payInLzToken);
6659
}
6760

@@ -84,8 +77,7 @@ contract MyOApp is OApp, OAppOptionsType3 {
8477
address /*_executor*/,
8578
bytes calldata /*_extraData*/
8679
) internal override {
87-
(string memory stringValue, ) = StringMsgCodec.decode(payload);
80+
(string memory stringValue) = StringMsgCodec.decode(payload);
8881
data = stringValue;
89-
// TODO: process _composeMsg
9082
}
9183
}

examples/oapp-solana/contracts/libs/StringMsgCodec.sol

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ pragma solidity ^0.8.22;
44

55
library StringMsgCodec {
66
uint8 public constant VANILLA_TYPE = 1;
7-
uint8 public constant COMPOSED_TYPE = 2;
87

9-
/// @notice Reconstructs `(stringValue, composeMsg)` from `_msg`.
10-
function decode(bytes calldata _msg) internal pure returns (string memory stringValue, bytes memory composeMsg) {
8+
/// @notice Reconstructs `stringValue` from `_msg`.
9+
function decode(bytes calldata _msg) internal pure returns (string memory stringValue) {
1110
require(_msg.length >= 32, "msg too short");
1211

1312
// 1) Grab the first 32 bytes and ABI-decode as uint256, then cast down to u32
@@ -21,21 +20,7 @@ library StringMsgCodec {
2120
// 3) Extract the UTF-8 string
2221
stringValue = string(_msg[32:32 + N]);
2322

24-
// 4) Anything after that is `composeMsg`
25-
if (_msg.length > 32 + N) {
26-
composeMsg = _msg[32 + N:];
27-
} else {
28-
composeMsg = "";
29-
}
30-
}
31-
32-
/**
33-
* @dev Checks if the _msg is composed.
34-
* @param _msg The _msg.
35-
* @return A boolean indicating whether the _msg is composed.
36-
*/
37-
function isComposed(bytes calldata _msg) internal pure returns (bool) {
38-
(, bytes memory composeMsg) = decode(_msg);
39-
return composeMsg.length > 0;
23+
// 4) Anything after that is ignored
4024
}
4125
}
26+

0 commit comments

Comments
 (0)