Skip to content

Commit 05a0420

Browse files
author
Rahul Maganti
committed
evm: natspec changes and additions
1 parent 1470fc6 commit 05a0420

File tree

3 files changed

+80
-11
lines changed

3 files changed

+80
-11
lines changed

evm/src/interfaces/INttManager.sol

+39-4
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,22 @@ import "../libraries/TransceiverStructs.sol";
77
import "./INttManagerState.sol";
88

99
interface INttManager is INttManagerState {
10+
/// @notice The mode is either LOCKING or BURNING. In LOCKING mode, the NttManager locks the
11+
/// tokens of the sender and mints an equivalent amount on the target chain. In BURNING
12+
/// mode, the NttManager burns the tokens of the sender and mints an equivalent amount
13+
/// on the target chain.LOCKING mode preserves the total supply of the tokens.
1014
enum Mode {
1115
LOCKING,
1216
BURNING
1317
}
1418

15-
// @dev Information about attestations for a given message.
19+
/// @notice Information about attestations for a given message.
20+
/// @dev The fields are as follows:
21+
/// - executed: whether the message has been executed.
22+
/// - attested: bitmap of transceivers that have attested to this message.
23+
/// (NOTE: might contain disabled transceivers)
1624
struct AttestationInfo {
17-
// whether this message has been executed
1825
bool executed;
19-
// bitmap of transceivers that have attested to this message (NOTE: might contain disabled transceivers)
2026
uint64 attestedTransceivers;
2127
}
2228

@@ -43,12 +49,41 @@ interface INttManager is INttManagerState {
4349
/// @param mode The mode.
4450
error InvalidMode(uint8 mode);
4551

52+
/// @notice Error when the refund to the sender fails.
53+
/// @dev Selector 0x2ca23714.
54+
/// @param refundAmount The refund amount.
4655
error RefundFailed(uint256 refundAmount);
47-
error TransceiverAlreadyAttestedToMessage(bytes32 nttManagerMessageHash);
56+
57+
/// @notice Error when the tranceiver already attested to the message.
58+
/// To ensure the client does not continue to initiate calls to the ateestationReceived function.
59+
/// @dev Selector 0x2113894.
60+
/// @param nttManagerMessageHash The hash of the message.
61+
error TrasceiverAlreadyAttestedToMessage(bytes32 nttManagerMessageHash);
62+
63+
/// @notice Error when the message is not approved.
64+
/// @dev Selector 0x451c4fb0.
65+
/// @param msgHash The hash of the message.
4866
error MessageNotApproved(bytes32 msgHash);
67+
68+
/// @notice Error if the target chain is not supported or does not exist.
69+
/// @dev Selector 0x3dcb204a.
70+
/// @param targetChain The target chain.
71+
/// @param thisChain The current chain.
4972
error InvalidTargetChain(uint16 targetChain, uint16 thisChain);
73+
74+
/// @notice Error when the transfer amount is zero.
75+
/// @dev Selector 0x9993626a.
5076
error ZeroAmount();
77+
78+
/// @notice Error when the recipient is invalid.
79+
/// @dev Selector 0x9c8d2cd2.
5180
error InvalidRecipient();
81+
82+
/// @@notice Error when the amount burned is different than the balance difference,
83+
/// since NTT does not support burn fees.
84+
/// @dev Selector 0x02156a8f.
85+
/// @param burnAmount The amount burned.
86+
/// @param balanceDiff The balance after burning.
5287
error BurnAmountDifferentThanBalanceDiff(uint256 burnAmount, uint256 balanceDiff);
5388

5489
/// @notice Transfer a given amount to a recipient on a given chain. This function is called

evm/src/interfaces/IWormholeTransceiver.sol

+40-4
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,65 @@ import "../libraries/TransceiverStructs.sol";
66
import "./IWormholeTransceiverState.sol";
77

88
interface IWormholeTransceiver is IWormholeTransceiverState {
9+
10+
/// @notice The instruction for the WormholeTransceiver contract
11+
/// to skip delivery via the relayer.
912
struct WormholeTransceiverInstruction {
1013
bool shouldSkipRelayerSend;
1114
}
1215

16+
/// @notice Emitted when a relayed message is received.
17+
/// @dev Topic0
18+
/// 0xf557dbbb087662f52c815f6c7ee350628a37a51eae9608ff840d996b65f87475
19+
/// @param digest The digest of the message.
20+
/// @param emitterChainId The chain ID of the emitter.
21+
/// @param emitterAddress The address of the emitter.
1322
event ReceivedRelayedMessage(bytes32 digest, uint16 emitterChainId, bytes32 emitterAddress);
23+
24+
/// @notice Emitted when a message is received.
25+
/// @dev Topic0
26+
/// 0xf6fc529540981400dc64edf649eb5e2e0eb5812a27f8c81bac2c1d317e71a5f0.
27+
/// @param digest The digest of the message.
28+
/// @param emitterChainId The chain ID of the emitter.
29+
/// @param emitterAddress The address of the emitter.
30+
/// @param sequence The sequence of the message.
1431
event ReceivedMessage(
1532
bytes32 digest, uint16 emitterChainId, bytes32 emitterAddress, uint64 sequence
1633
);
34+
35+
/// @notice Emitted when a message is sent from the transceiver.
36+
/// @dev Topic0
37+
/// 0x53b3e029c5ead7bffc739118953883859d30b1aaa086e0dca4d0a1c99cd9c3f5.
38+
/// @param recipientChain The chain ID of the recipient.
39+
/// @param message The message.
1740
event SendTransceiverMessage(
1841
uint16 recipientChain, TransceiverStructs.TransceiverMessage message
1942
);
2043

44+
/// @notice Error when the relaying configuration is invalid. (e.g. chainId is not registered)
45+
/// @dev Selector: 0x9449a36c.
46+
/// @param chainId The chain ID that is invalid.
2147
error InvalidRelayingConfig(uint16 chainId);
48+
49+
/// @notice Error when the peer transceiver is invalid.
50+
/// @dev Selector: 0x79b1ce56.
51+
/// @param chainId The chain ID of the peer.
52+
/// @param peerAddress The address of the invalid peer.
2253
error InvalidWormholePeer(uint16 chainId, bytes32 peerAddress);
54+
55+
/// @notice Error when the VAA has already been consumed.
56+
/// @dev Selector: 0x406e719e.
57+
/// @param vaaHash The hash of the VAA.
2358
error TransferAlreadyCompleted(bytes32 vaaHash);
2459

25-
/// @notice Receive an attested message from the verification layer. This function should verify
26-
/// the `encodedVm` and then deliver the attestation to the transceiver NttManager contract.
60+
/// @notice Receive an attested message from the verification layer.
61+
/// This function should verify the `encodedVm` and then deliver the attestation
62+
/// to the transceiver NttManager contract.
2763
/// @param encodedMessage The attested message.
2864
function receiveMessage(bytes memory encodedMessage) external;
2965

30-
/// @notice Parses the encoded instruction and returns the instruction struct. This instruction
31-
/// is specific to the WormholeTransceiver contract.
66+
/// @notice Parses the encoded instruction and returns the instruction struct.
67+
/// This instruction is specific to the WormholeTransceiver contract.
3268
/// @param encoded The encoded instruction.
3369
/// @return instruction The parsed `WormholeTransceiverInstruction`.
3470
function parseWormholeTransceiverInstruction(bytes memory encoded)

evm/src/libraries/RateLimiter.sol

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ import "../libraries/TrimmedAmount.sol";
99

1010
abstract contract RateLimiter is IRateLimiter, IRateLimiterEvents {
1111
using TrimmedAmountLib for TrimmedAmount;
12-
/**
13-
* @dev The duration it takes for the limits to fully replenish
14-
*/
1512

13+
/// @dev The duration it takes for the limits to fully replenish.
1614
uint64 public immutable rateLimitDuration;
1715

1816
/// =============== STORAGE ===============================================

0 commit comments

Comments
 (0)