Skip to content

Commit c789755

Browse files
modify BridgeAggregationHookMetadata to only include Axelar payment data
1 parent 8f40524 commit c789755

File tree

2 files changed

+8
-35
lines changed

2 files changed

+8
-35
lines changed

solidity/contracts/hooks/libs/BridgeAggregationHookMetadata.sol

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,16 @@ pragma solidity >=0.8.0;
44
/**
55
* Format of metadata:
66
*
7-
* [0:2] variant
8-
* [2:34] Axelar Payment
9-
* [34:66] Wormhole Payment
10-
* [66:] additional metadata
7+
* [0:32] variant
8+
* [32:] additional metadata
119
*/
1210
library BridgeAggregationHookMetadata {
1311
struct Metadata {
1412
uint256 AxelarPayment;
15-
uint256 WormholePayment;
1613
}
1714

1815
uint8 private constant AXELAR_PAYMENT_OFFSET = 0;
19-
uint8 private constant WORMHOLE_PAYMENT_OFFSET = 32;
20-
uint8 private constant MIN_METADATA_LENGTH = 64;
16+
uint8 private constant MIN_METADATA_LENGTH = 32;
2117

2218
/**
2319
* @notice Returns the required payment for Axelar bridging.
@@ -36,24 +32,6 @@ library BridgeAggregationHookMetadata {
3632
);
3733
}
3834

39-
/**
40-
* @notice Returns the required payment for Wormhole bridging.
41-
* @param _metadata ABI encoded standard hook metadata.
42-
* @return uint256 Payment amount.
43-
*/
44-
function wormholeGasPayment(
45-
bytes calldata _metadata
46-
) internal pure returns (uint256) {
47-
if (_metadata.length < WORMHOLE_PAYMENT_OFFSET + 32) return 0;
48-
return
49-
uint256(
50-
bytes32(
51-
_metadata[WORMHOLE_PAYMENT_OFFSET:WORMHOLE_PAYMENT_OFFSET +
52-
32]
53-
)
54-
);
55-
}
56-
5735
/**
5836
* @notice Returs any additional metadata.
5937
* @param _metadata ABI encoded standard hook metadata.
@@ -69,16 +47,13 @@ library BridgeAggregationHookMetadata {
6947
/**
7048
* @notice Formats the specified Axelar and Wormhole payments.
7149
* @param _axelarPayment msg.value for the message.
72-
* @param _wormholePayment Gas limit for the message.
7350
* @param _customMetadata Additional metadata to include.
7451
* @return ABI encoded standard hook metadata.
7552
*/
7653
function formatMetadata(
7754
uint256 _axelarPayment,
78-
uint256 _wormholePayment,
7955
bytes memory _customMetadata
8056
) internal pure returns (bytes memory) {
81-
return
82-
abi.encodePacked(_axelarPayment, _wormholePayment, _customMetadata);
57+
return abi.encodePacked(_axelarPayment, _customMetadata);
8358
}
8459
}

solidity/test/hooks/AxelarHook.t.sol

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ contract AxelarHookTest is Test {
3131
string destionationContract = "neutronContract";
3232
address axelarGateway = address(0);
3333
address axelarGasReceiver = address(0);
34-
bytes gmp_call_code = abi.encodePacked(uint8(1));
3534
error BadQuote(uint256 balance, uint256 required);
3635

3736
function setUp() public {
@@ -42,8 +41,7 @@ contract AxelarHookTest is Test {
4241
destinationChain,
4342
destionationContract,
4443
axelarGateway,
45-
axelarGasReceiver,
46-
gmp_call_code
44+
axelarGasReceiver
4745
);
4846
testMessage = _encodeTestMessage();
4947
}
@@ -66,7 +64,7 @@ contract AxelarHookTest is Test {
6664
vm.expectRevert("No Axelar Payment Received");
6765
uint256 expectedQuote = 0;
6866
bytes memory justRightCustomMetadata = BridgeAggregationHookMetadata
69-
.formatMetadata(expectedQuote, 0, abi.encodePacked());
67+
.formatMetadata(expectedQuote, abi.encodePacked());
7068
bytes memory testMetadata = StandardHookMetadata.formatMetadata(
7169
100,
7270
100,
@@ -80,7 +78,7 @@ contract AxelarHookTest is Test {
8078
function test_quoteDispatch_ReturnsSmallQuote() public {
8179
uint256 expectedQuote = 1;
8280
bytes memory justRightCustomMetadata = BridgeAggregationHookMetadata
83-
.formatMetadata(expectedQuote, 0, abi.encodePacked());
81+
.formatMetadata(expectedQuote, abi.encodePacked());
8482
bytes memory testMetadata = StandardHookMetadata.formatMetadata(
8583
100,
8684
100,
@@ -96,7 +94,7 @@ contract AxelarHookTest is Test {
9694
// type(uint256).max = 115792089237316195423570985008687907853269984665640564039457584007913129639935. that's a big quote
9795
uint256 expectedQuote = type(uint256).max;
9896
bytes memory justRightCustomMetadata = BridgeAggregationHookMetadata
99-
.formatMetadata(expectedQuote, 0, abi.encodePacked());
97+
.formatMetadata(expectedQuote, abi.encodePacked());
10098
bytes memory testMetadata = StandardHookMetadata.formatMetadata(
10199
100,
102100
100,

0 commit comments

Comments
 (0)