Skip to content

Commit 75feab1

Browse files
authored
Finishing touches (#91)
* minor improvements and unification * add missing message fee value when attesting a token * revert message fee docs in interface and fix handling in demo integration
1 parent a7c8786 commit 75feab1

31 files changed

+86
-224
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ This SDK largely follows [the Solidity style guide](https://docs.soliditylang.or
4848
* indentation uses 2 instead of 4 spaces
4949
* maximum line length where feasible is 100 characters (urls in comments are an exception)
5050
* [order of functions](https://docs.soliditylang.org/en/latest/style-guide.html) is roughly followed but more important functions might be sorted to the top.
51-
* additional whitespace are at times added to create more compelling visual blocks (e.g. for a block of related assignments)
51+
* additional whitespace is at times added to create more compelling visual blocks (e.g. for a block of related assignments)
5252
* function modifiers do not get a separate line each once line length is exceeded
5353
* NatSpec is avoided because it favors a "box-checking" approach towards documentation rather than focusing on essentials and rationales
5454

gen/utils.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1+
const LOWER_TO_UPPER = /([a-z])([A-Z])/g;
2+
13
export function toCapsSnakeCase(identifier: string) {
2-
return identifier.split('').map((char, index) =>
3-
( char === char.toUpperCase() //insert underscore before uppercase letters
4-
&& char !== char.toLowerCase() //don't insert underscore before numbers
5-
&& index !== 0 //don't insert underscore at the beginning
6-
) ? '_' + char : char.toUpperCase()
7-
).join('');
4+
//insert underscore between lowercase and uppercase letters and then capitalize all
5+
return identifier.replace(LOWER_TO_UPPER, '$1_$2').toUpperCase();
86
}

src/RawDispatcher.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// SPDX-License-Identifier: Apache 2
2-
32
pragma solidity ^0.8.0;
43

54
//TL;DR:

src/constants/Chains.sol

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,11 @@ pragma solidity ^0.8.0;
77
uint16 constant CHAIN_ID_UNSET = 0;
88
uint16 constant CHAIN_ID_SOLANA = 1;
99
uint16 constant CHAIN_ID_ETHEREUM = 2;
10-
uint16 constant CHAIN_ID_TERRA = 3;
1110
uint16 constant CHAIN_ID_BSC = 4;
1211
uint16 constant CHAIN_ID_POLYGON = 5;
1312
uint16 constant CHAIN_ID_AVALANCHE = 6;
14-
uint16 constant CHAIN_ID_OASIS = 7;
1513
uint16 constant CHAIN_ID_ALGORAND = 8;
16-
uint16 constant CHAIN_ID_AURORA = 9;
1714
uint16 constant CHAIN_ID_FANTOM = 10;
18-
uint16 constant CHAIN_ID_KARURA = 11;
19-
uint16 constant CHAIN_ID_ACALA = 12;
2015
uint16 constant CHAIN_ID_KLAYTN = 13;
2116
uint16 constant CHAIN_ID_CELO = 14;
2217
uint16 constant CHAIN_ID_NEAR = 15;
@@ -31,7 +26,6 @@ uint16 constant CHAIN_ID_ARBITRUM = 23;
3126
uint16 constant CHAIN_ID_OPTIMISM = 24;
3227
uint16 constant CHAIN_ID_GNOSIS = 25;
3328
uint16 constant CHAIN_ID_PYTHNET = 26;
34-
uint16 constant CHAIN_ID_XPLA = 28;
3529
uint16 constant CHAIN_ID_BTC = 29;
3630
uint16 constant CHAIN_ID_BASE = 30;
3731
uint16 constant CHAIN_ID_SEI = 32;
@@ -46,7 +40,7 @@ uint16 constant CHAIN_ID_SNAXCHAIN = 43;
4640
uint16 constant CHAIN_ID_UNICHAIN = 44;
4741
uint16 constant CHAIN_ID_WORLDCHAIN = 45;
4842
uint16 constant CHAIN_ID_INK = 46;
49-
uint16 constant CHAIN_ID_HYPER_E_V_M = 47;
43+
uint16 constant CHAIN_ID_HYPER_EVM = 47;
5044
uint16 constant CHAIN_ID_MONAD = 48;
5145
uint16 constant CHAIN_ID_MEZO = 50;
5246
uint16 constant CHAIN_ID_SONIC = 52;

src/constants/Common.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ uint256 constant WORD_SIZE_PLUS_ONE = 33;
1414
uint256 constant SCRATCH_SPACE_PTR = 0x00;
1515
uint256 constant SCRATCH_SPACE_SIZE = 64;
1616

17-
uint256 constant FREE_MEMORY_PTR = 0x40;
17+
uint256 constant FREE_MEMORY_PTR = 0x40;

src/interfaces/IDeliveryProvider.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// SPDX-License-Identifier: Apache 2
2-
32
pragma solidity ^0.8.0;
43

54
interface IDeliveryProvider {

src/interfaces/IWormholeRelayer.sol

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
// SPDX-License-Identifier: Apache 2
22
pragma solidity ^0.8.0;
33

4+
// ╭──────────────────────────────────────────────────────────────╮
5+
// │ Prefer using WormholeRelayer.sol over the raw interface here │
6+
// ╰──────────────────────────────────────────────────────────────╯
7+
48
struct MessageKey {
59
uint8 keyType; // 0-127 are reserved for standardized KeyTypes, 128-255 are for custom use
610
bytes encodedKey; //all key types except VaaKeys are encoded with a 4 byte length prefix
@@ -44,8 +48,7 @@ interface IWormholeRelayerSend {
4448
*
4549
* `targetAddress` must implement the IWormholeReceiver interface
4650
*
47-
* This function must be called with `msg.value` equal to wormholeMessageFee +
48-
* `quoteEVMDeliveryPrice(targetChain, receiverValue, gasLimit)`
51+
* This function must be called with `msg.value` equal to `quoteEVMDeliveryPrice(targetChain, receiverValue, gasLimit)`
4952
*
5053
* Any refunds (from leftover gas) will be paid to the delivery provider. In order to receive the refunds, use the `sendPayloadToEvm` function
5154
* with `refundChain` and `refundAddress` as parameters
@@ -73,8 +76,7 @@ interface IWormholeRelayerSend {
7376
* Any refunds (from leftover gas) will be sent to `refundAddress` on chain `refundChain`
7477
* `targetAddress` must implement the IWormholeReceiver interface
7578
*
76-
* This function must be called with `msg.value` equal to wormholeMessageFee +
77-
* `quoteEVMDeliveryPrice(targetChain, receiverValue, gasLimit)`
79+
* This function must be called with `msg.value` equal to `quoteEVMDeliveryPrice(targetChain, receiverValue, gasLimit)`
7880
*
7981
* @param targetChain in Wormhole Chain ID format
8082
* @param targetAddress address to call on targetChain (that implements IWormholeReceiver)
@@ -103,8 +105,7 @@ interface IWormholeRelayerSend {
103105
*
104106
* `targetAddress` must implement the IWormholeReceiver interface
105107
*
106-
* This function must be called with `msg.value` equal to wormholeMessageFee +
107-
* `quoteEVMDeliveryPrice(targetChain, receiverValue, gasLimit)`
108+
* This function must be called with `msg.value` equal to `quoteEVMDeliveryPrice(targetChain, receiverValue, gasLimit)`
108109
*
109110
* Any refunds (from leftover gas) will be paid to the delivery provider. In order to receive the refunds, use the `sendVaasToEvm` function
110111
* with `refundChain` and `refundAddress` as parameters
@@ -134,8 +135,7 @@ interface IWormholeRelayerSend {
134135
* Any refunds (from leftover gas) will be sent to `refundAddress` on chain `refundChain`
135136
* `targetAddress` must implement the IWormholeReceiver interface
136137
*
137-
* This function must be called with `msg.value` equal to wormholeMessageFee +
138-
* `quoteEVMDeliveryPrice(targetChain, receiverValue, gasLimit)`
138+
* This function must be called with `msg.value` equal to `quoteEVMDeliveryPrice(targetChain, receiverValue, gasLimit)`
139139
*
140140
* @param targetChain in Wormhole Chain ID format
141141
* @param targetAddress address to call on targetChain (that implements IWormholeReceiver)
@@ -168,7 +168,7 @@ interface IWormholeRelayerSend {
168168
* Any refunds (from leftover gas) will be sent to `refundAddress` on chain `refundChain`
169169
* `targetAddress` must implement the IWormholeReceiver interface
170170
*
171-
* This function must be called with `msg.value` equal to wormholeMessageFee +
171+
* This function must be called with `msg.value` equal to
172172
* quoteEVMDeliveryPrice(targetChain, receiverValue, gasLimit, deliveryProviderAddress) + paymentForExtraReceiverValue
173173
*
174174
* @param targetChain in Wormhole Chain ID format
@@ -210,7 +210,7 @@ interface IWormholeRelayerSend {
210210
* Any refunds (from leftover gas) will be sent to `refundAddress` on chain `refundChain`
211211
* `targetAddress` must implement the IWormholeReceiver interface
212212
*
213-
* This function must be called with `msg.value` equal to wormholeMessageFee +
213+
* This function must be called with `msg.value` equal to
214214
* quoteEVMDeliveryPrice(targetChain, receiverValue, gasLimit, deliveryProviderAddress) + paymentForExtraReceiverValue
215215
*
216216
* Note: MessageKeys can specify wormhole messages (VaaKeys) or other types of messages (ex. USDC CCTP attestations). Ensure the selected
@@ -255,7 +255,7 @@ interface IWormholeRelayerSend {
255255
* Any refunds (from leftover gas) will be sent to `refundAddress` on chain `refundChain`
256256
* `targetAddress` must implement the IWormholeReceiver interface
257257
*
258-
* This function must be called with `msg.value` equal to wormholeMessageFee +
258+
* This function must be called with `msg.value` equal to
259259
* quoteDeliveryPrice(targetChain, receiverValue, encodedExecutionParameters, deliveryProviderAddress) + paymentForExtraReceiverValue
260260
*
261261
* @param targetChain in Wormhole Chain ID format
@@ -297,7 +297,7 @@ interface IWormholeRelayerSend {
297297
* Any refunds (from leftover gas) will be sent to `refundAddress` on chain `refundChain`
298298
* `targetAddress` must implement the IWormholeReceiver interface
299299
*
300-
* This function must be called with `msg.value` equal to wormholeMessageFee +
300+
* This function must be called with `msg.value` equal to
301301
* quoteDeliveryPrice(targetChain, receiverValue, encodedExecutionParameters, deliveryProviderAddress) + paymentForExtraReceiverValue
302302
*
303303
* Note: MessageKeys can specify wormhole messages (VaaKeys) or other types of messages (ex. USDC CCTP attestations). Ensure the selected
@@ -337,7 +337,7 @@ interface IWormholeRelayerSend {
337337
* @notice Requests a previously published delivery instruction to be redelivered
338338
* (e.g. with a different delivery provider)
339339
*
340-
* This function must be called with `msg.value` equal to wormholeMessageFee +
340+
* This function must be called with `msg.value` equal to
341341
* quoteEVMDeliveryPrice(targetChain, newReceiverValue, newGasLimit, newDeliveryProviderAddress)
342342
*
343343
* @notice *** This will only be able to succeed if the following is true **
@@ -370,7 +370,7 @@ interface IWormholeRelayerSend {
370370
* @notice Requests a previously published delivery instruction to be redelivered
371371
*
372372
*
373-
* This function must be called with `msg.value` equal to wormholeMessageFee +
373+
* This function must be called with `msg.value` equal to
374374
* quoteDeliveryPrice(targetChain, newReceiverValue, newEncodedExecutionParameters, newDeliveryProviderAddress)
375375
*
376376
* @param deliveryVaaKey VaaKey identifying the wormhole message containing the

src/interfaces/token/IERC20.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// SPDX-License-Identifier: Apache 2
2-
32
pragma solidity ^0.8.0;
43

54
//https://eips.ethereum.org/EIPS/eip-20

src/interfaces/token/IERC20Metadata.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// SPDX-License-Identifier: Apache 2
2-
32
pragma solidity ^0.8.0;
43

54
import "IERC20/IERC20.sol";

src/interfaces/token/IERC20Permit.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// SPDX-License-Identifier: Apache 2
2-
32
pragma solidity ^0.8.0;
43

54
import "IERC20/IERC20.sol";

0 commit comments

Comments
 (0)