Skip to content

Commit

Permalink
πŸ‘ owner param
Browse files Browse the repository at this point in the history
πŸ‘  owner param
  • Loading branch information
z0r0z authored Nov 12, 2022
1 parent 11d369d commit 7c31987
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions src/utils/SelfPermit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,48 +11,49 @@ import {Permit} from "./Permit.sol";
abstract contract SelfPermit {
/// @dev ERC20.

/// @notice Permits this contract to spend a given EIP-2612 `token` from `msg.sender`.
/// @dev The `owner` is always `msg.sender` and the `spender` is always `address(this)`.
/// @notice Permits this contract to spend a given EIP-2612 `token` from `owner`.
/// @param token The address of the asset spent.
/// @param owner The address of the asset holder.
/// @param value The amount permitted to spend.
/// @param deadline The unix timestamp before which permit must be spent.
/// @param v Must produce valid secp256k1 signature from the `msg.sender` along with `r` and `s`.
/// @param r Must produce valid secp256k1 signature from the `msg.sender` along with `v` and `s`.
/// @param s Must produce valid secp256k1 signature from the `msg.sender` along with `r` and `v`.
function selfPermit(
Permit token,
address owner,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) public virtual {
token.permit(msg.sender, address(this), value, deadline, v, r, s);
token.permit(owner, address(this), value, deadline, v, r, s);
}

/// @notice Permits this contract to spend a given Dai-style `token` from `msg.sender`.
/// @dev The `owner` is always `msg.sender` and the `spender` is always `address(this)`.
/// @notice Permits this contract to spend a given Dai-style `token` from `owner`.
/// @param token The address of the asset spent.
/// @param owner The address of the asset holder.
/// @param nonce The current nonce of the `owner`.
/// @param deadline The unix timestamp before which permit must be spent.
/// @param v Must produce valid secp256k1 signature from the `msg.sender` along with `r` and `s`.
/// @param r Must produce valid secp256k1 signature from the `msg.sender` along with `v` and `s`.
/// @param s Must produce valid secp256k1 signature from the `msg.sender` along with `r` and `v`.
function selfPermitAllowed(
Permit token,
address owner,
uint256 nonce,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) public virtual {
token.permit(msg.sender, address(this), nonce, deadline, true, v, r, s);
token.permit(owner, address(this), nonce, deadline, true, v, r, s);
}

/// @dev ERC721.

/// @notice Permits this contract to spend a given EIP-2612-style NFT `tokenID` from `msg.sender`.
/// @dev The `spender` is always `address(this)`.
/// @notice Permits this contract to spend a given EIP-2612-style NFT `tokenID`.
/// @param token The address of the asset spent.
/// @param tokenId The ID of the token that is being approved for permit.
/// @param deadline The unix timestamp before which permit must be spent.
Expand All @@ -71,7 +72,6 @@ abstract contract SelfPermit {
}

/// @notice Permits this contract to spend a given EIP-4494 NFT `tokenID`.
/// @dev The `spender` is always `address(this)`.
/// @param token The address of the asset spent.
/// @param tokenId The ID of the token that is being approved for permit.
/// @param deadline The unix timestamp before which permit must be spent.
Expand All @@ -88,19 +88,20 @@ abstract contract SelfPermit {
/// @dev ERC1155.

/// @notice Permits this contract to spend a given EIP-2612-style multitoken.
/// @dev The `owner` is always `msg.sender` and the `operator` is always `address(this)`.
/// @param token The address of the asset spent.
/// @param owner The address of the asset holder.
/// @param deadline The unix timestamp before which permit must be spent.
/// @param v Must produce valid secp256k1 signature from the `msg.sender` along with `r` and `s`.
/// @param r Must produce valid secp256k1 signature from the `msg.sender` along with `v` and `s`.
/// @param s Must produce valid secp256k1 signature from the `msg.sender` along with `r` and `v`.
function selfPermit1155(
Permit token,
address owner,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) public virtual {
token.permit(msg.sender, address(this), true, deadline, v, r, s);
token.permit(owner, address(this), true, deadline, v, r, s);
}
}

0 comments on commit 7c31987

Please sign in to comment.