2
2
pragma solidity >= 0.8.0 < 0.9.0 ;
3
3
4
4
import "wormhole-solidity-sdk/Utils.sol " ;
5
+ import "wormhole-solidity-sdk/libraries/BytesParsing.sol " ;
5
6
6
7
import {TransceiverStructs} from
7
8
"@wormhole-foundation/native_token_transfer/libraries/TransceiverStructs.sol " ;
@@ -21,9 +22,11 @@ import {ITransceiver} from "@wormhole-foundation/native_token_transfer/interface
21
22
import {IAxelarTransceiver} from "./interfaces/IAxelarTransceiver.sol " ;
22
23
23
24
contract AxelarTransceiver is IAxelarTransceiver , AxelarGMPExecutable , Transceiver {
25
+ using BytesParsing for bytes ;
26
+
24
27
IAxelarGasService public immutable gasService;
25
28
26
- string public constant AXELAR_TRANSCEIVER_VERSION = "1.1 .0 " ;
29
+ string public constant AXELAR_TRANSCEIVER_VERSION = "2.0 .0 " ;
27
30
28
31
// These mappings are used to convert chainId and chainName between Wormhole and Axelar formats.
29
32
struct AxelarTransceiverStorage {
@@ -37,9 +40,6 @@ contract AxelarTransceiver is IAxelarTransceiver, AxelarGMPExecutable, Transceiv
37
40
bytes32 internal constant AXELAR_TRANSCEIVER_STORAGE_SLOT =
38
41
0x6d72a7741b755e11bdb1cef6ed3f290bbe196e69da228a3ae322e5bc37ea7600 ;
39
42
40
- // TODO: update this based on tests
41
- uint256 internal constant DESTINATION_EXECUTION_GAS_LIMIT = 200000 ;
42
-
43
43
constructor (
44
44
address _gateway ,
45
45
address _gasService ,
@@ -97,25 +97,35 @@ contract AxelarTransceiver is IAxelarTransceiver, AxelarGMPExecutable, Transceiv
97
97
emit AxelarChainIdSet (chainId, chainName, transceiverAddress);
98
98
}
99
99
100
+ /// @inheritdoc IAxelarTransceiver
101
+ function parseAxelarTransceiverInstruction (
102
+ bytes memory encoded
103
+ ) public pure returns (AxelarTransceiverInstruction memory instruction ) {
104
+ uint256 offset = 0 ;
105
+ (instruction.estimatedMsgValue, offset) = encoded.asUint256Unchecked (offset);
106
+ encoded.checkLength (offset);
107
+ }
108
+
109
+ /// @inheritdoc IAxelarTransceiver
110
+ function encodeAxelarTransceiverInstruction (
111
+ AxelarTransceiverInstruction memory instruction
112
+ ) public pure returns (bytes memory ) {
113
+ return abi.encodePacked (instruction.estimatedMsgValue);
114
+ }
115
+
100
116
/// @notice Fetch the delivery price for a given recipient chain transfer.
101
- /// @ param recipientChainId The Wormhole chain ID of the target chain.
102
- /// param instruction An additional Instruction provided by the Transceiver to be
117
+ /// param recipientChainId The Wormhole chain ID of the target chain.
118
+ /// @ param instruction An additional Instruction provided by the Transceiver to be
103
119
/// executed on the recipient chain.
104
120
/// @return deliveryPrice The cost of delivering a message to the recipient chain,
105
121
/// in this chain's native token.
106
122
function _quoteDeliveryPrice (
107
- uint16 recipientChainId ,
108
- TransceiverStructs.TransceiverInstruction memory /* instruction*/
123
+ uint16 , /* recipientChainId*/
124
+ TransceiverStructs.TransceiverInstruction memory instruction
109
125
) internal view virtual override returns (uint256 ) {
110
- // Use the gas estimation from gas service
111
- AxelarTransceiverStorage storage slot = _storage ();
112
- return gasService.estimateGasFee (
113
- slot.idToAxelarChainId[recipientChainId],
114
- slot.idToTransceiverAddress[recipientChainId],
115
- bytes ("" ),
116
- DESTINATION_EXECUTION_GAS_LIMIT,
117
- bytes ("" )
118
- );
126
+ AxelarTransceiverInstruction memory axIns =
127
+ parseAxelarTransceiverInstruction (instruction.payload);
128
+ return axIns.estimatedMsgValue;
119
129
}
120
130
121
131
/// @dev Send a message to another chain.
0 commit comments