Skip to content

Commit 8c8d814

Browse files
committed
remove compose from oapp-solana
1 parent 8acaad6 commit 8c8d814

41 files changed

Lines changed: 448 additions & 2001 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

examples/oapp-solana/contracts/MyOApp.sol

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,17 @@ 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) {
33-
bytes memory _payload = abi.encodePacked(
34-
abi.encode(uint256(bytes(_message).length)),
35-
bytes(_message),
36-
_composeMsg
37-
);
38-
uint8 msgType = _composeMsg.length > 0 ? StringMsgCodec.COMPOSED_TYPE : StringMsgCodec.VANILLA_TYPE;
39-
bytes memory options = combineOptions(_dstEid, msgType, _options);
31+
bytes memory _payload = abi.encodePacked(abi.encode(uint256(bytes(_message).length)), bytes(_message));
32+
bytes memory options = combineOptions(_dstEid, StringMsgCodec.VANILLA_TYPE, _options);
4033
receipt = _lzSend(_dstEid, _payload, options, MessagingFee(msg.value, 0), payable(msg.sender));
4134
}
4235

@@ -51,17 +44,11 @@ contract MyOApp is OApp, OAppOptionsType3 {
5144
function quote(
5245
uint32 _dstEid,
5346
string calldata _message,
54-
bytes calldata _composeMsg,
5547
bytes calldata _options,
5648
bool _payInLzToken
5749
) public view returns (MessagingFee memory fee) {
58-
bytes memory payload = abi.encodePacked(
59-
abi.encode(uint256(bytes(_message).length)),
60-
bytes(_message),
61-
_composeMsg
62-
);
63-
uint8 msgType = _composeMsg.length > 0 ? StringMsgCodec.COMPOSED_TYPE : StringMsgCodec.VANILLA_TYPE;
64-
bytes memory options = combineOptions(_dstEid, msgType, _options);
50+
bytes memory payload = abi.encodePacked(abi.encode(uint256(bytes(_message).length)), bytes(_message));
51+
bytes memory options = combineOptions(_dstEid, StringMsgCodec.VANILLA_TYPE, _options);
6552
fee = _quote(_dstEid, payload, options, _payInLzToken);
6653
}
6754

@@ -84,8 +71,7 @@ contract MyOApp is OApp, OAppOptionsType3 {
8471
address /*_executor*/,
8572
bytes calldata /*_extraData*/
8673
) internal override {
87-
(string memory stringValue, ) = StringMsgCodec.decode(payload);
74+
string memory stringValue = StringMsgCodec.decode(payload);
8875
data = stringValue;
89-
// TODO: process _composeMsg
9076
}
9177
}

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

Lines changed: 3 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,6 @@ 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
}

0 commit comments

Comments
 (0)