ERC2771RecipientHelperLib
Implements EIP-2771 standard, as defined in https://eips.ethereum.org/EIPS/eip-2771
This library can be included in a Diamond Facet to provide it with _msgSender()
and _msgData()
_msgSender
Returns the sender of this call.
If the call came through the trusted forwarder, return the original sender,
otherwise, return msg.sender
.
Should be used in the contract anywhere instead of msg.sender
.
Return Values
Name | Type | Description |
---|---|---|
ret | address | The address of the real sender of this call. |
_msgData
Returns the msg.data of this call.
If the call came through the trusted forwarder, then the real sender was appended as the last 20 bytes
of the msg.data - so this method will strip those 20 bytes off.
Otherwise (if the call was made directly and not through the forwarder), return msg.data
.
Should be used in the contract instead of msg.data, where this difference matters.
Return Values
Name | Type | Description |
---|---|---|
ret | bytes | The msg.data of this call. |
_isTrustedForwarder
Queries whether a given address corresponds to the trusted forwarder that is being used.
Parameters
Name | Type | Description |
---|---|---|
layout | struct ERC2771RecipientStorage.Layout | |
forwarder | address | the address to inquire. |
Return Values
Name | Type | Description |
---|---|---|
[0] | bool | bool true if the given address is the address of the trusted forwarder, false if not. |