test-isol-01 0.0.14 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,128 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.0;
3
+
4
+ import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
5
+ import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Wrapper.sol";
6
+ import "../adapter/TransferAuthorize.sol";
7
+ import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
8
+
9
+ /**
10
+ * @title ERC20WrappedWithAuthorize
11
+ * @notice ERC20 wrapper that allows wrapping any existing ERC20 token
12
+ * and adds EIP-712 off-chain authorization functions.
13
+ * @dev Inherits ERC20, ERC20Wrapper, and ERC20TransferWithAuthorize:
14
+ * - ERC20: standard token functionality
15
+ * - ERC20Wrapper: depositFor/withdrawTo underlying tokens
16
+ * - ERC20TransferWithAuthorize: transferWithAuthorize and receiveWithAuthorize
17
+ */
18
+ abstract contract WrapERC20xTransferWithAuthorize is ERC20, ERC20Wrapper, TransferAuthorize, ReentrancyGuard {
19
+
20
+ /**
21
+ * @notice Construct a wrapped ERC20 with authorization support
22
+ * @param _underlyingToken Address of the ERC20 token to wrap. Users deposit this token to receive the wrapped token.
23
+ * @param _name Name of the wrapped token (ERC20 metadata and EIP-712 domain name)
24
+ * @param _symbol Symbol of the wrapped token (ERC20 metadata)
25
+ * @param _version Version string for EIP-712 domain (e.g. "1")
26
+ */
27
+ constructor(
28
+ address _underlyingToken,
29
+ string memory _name,
30
+ string memory _symbol,
31
+ string memory _version
32
+ )
33
+ ERC20(_name, _symbol)
34
+ ERC20Wrapper(IERC20(_underlyingToken))
35
+ TransferAuthorize(_name, _version)
36
+ {}
37
+
38
+ /// @notice Relayer-triggered transfer using an off-chain signature by `from`.
39
+ /// @dev This allows anyone (a relayer) to submit the signed authorization on-chain.
40
+ function transferWithAuthorize(
41
+ address from,
42
+ address to,
43
+ uint256 value,
44
+ uint256 validAfter,
45
+ uint256 validBefore,
46
+ bytes32 nonce,
47
+ bytes calldata signature
48
+ ) external nonReentrant {
49
+ address signer = _verifyTransfer(
50
+ from,
51
+ to,
52
+ value,
53
+ validAfter,
54
+ validBefore,
55
+ nonce,
56
+ signature
57
+ );
58
+ require(signer == from, "ERC20TransferAuthorize: invalid signature");
59
+ _useAuthorize(from, nonce);
60
+ _transfer(from, to, value);
61
+ }
62
+
63
+ /// @notice Relayer-triggered transfer using an off-chain signature by `from`.
64
+ /// @dev This allows anyone (a relayer) to submit the signed authorization on-chain.
65
+ function transferFromWithAuthorize(
66
+ address from,
67
+ address to,
68
+ uint256 value,
69
+ uint256 validAfter,
70
+ uint256 validBefore,
71
+ bytes32 nonce,
72
+ bytes calldata signature
73
+ ) external nonReentrant {
74
+ address signer = _verifyTransferFrom(
75
+ from,
76
+ to,
77
+ value,
78
+ validAfter,
79
+ validBefore,
80
+ nonce,
81
+ signature
82
+ );
83
+ require(signer == from, "ERC20TransferAuthorize: invalid signature");
84
+ _useAuthorize(from, nonce);
85
+ _spendAllowance(from, to, value);
86
+ _transfer(from, to, value);
87
+ }
88
+
89
+ /// @notice Relayer-triggered transfer using an off-chain signature by `from`.
90
+ /// @dev This allows anyone (a relayer) to submit the signed authorization on-chain.
91
+ function burnWithAuthorize(
92
+ address from,
93
+ address to,
94
+ uint256 value,
95
+ uint256 validAfter,
96
+ uint256 validBefore,
97
+ bytes32 nonce,
98
+ bytes calldata signature
99
+ ) external nonReentrant {
100
+ address signer = _verifyBurn(
101
+ from,
102
+ to,
103
+ value,
104
+ validAfter,
105
+ validBefore,
106
+ nonce,
107
+ signature
108
+ );
109
+ require(signer == from, "ERC20TransferAuthorize: invalid signature");
110
+ _useAuthorize(from, nonce);
111
+ _burn(from, value);
112
+ }
113
+
114
+ /**
115
+ * @notice Returns the token decimals
116
+ * @dev Overrides both ERC20 and ERC20Wrapper decimals function
117
+ * @return uint8 decimals of the token (usually matches underlying token)
118
+ */
119
+ function decimals()
120
+ public
121
+ view
122
+ virtual
123
+ override(ERC20, ERC20Wrapper)
124
+ returns (uint8)
125
+ {
126
+ return super.decimals();
127
+ }
128
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "test-isol-01",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "devDependencies": {
@@ -1,41 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity ^0.8.0;
3
-
4
- import { IERC20, ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
5
- import { ERC20Wrapper } from "@openzeppelin/contracts/token/ERC20/extensions/ERC20Wrapper.sol";
6
- import { ERC20xTransferWithAuthorize } from "./ERC20xTransferWithAuthorize.sol";
7
-
8
- /**
9
- * @title ERC20WrappedWithAuthorize
10
- * @notice ERC20 wrapper that allows wrapping any existing ERC20 token
11
- * and adds EIP-712 off-chain authorization functions.
12
- * @dev Inherits ERC20, ERC20Wrapper, and ERC20TransferWithAuthorize:
13
- * - ERC20: standard token functionality
14
- * - ERC20Wrapper: depositFor/withdrawTo underlying tokens
15
- * - ERC20TransferWithAuthorize: transferWithAuthorize and receiveWithAuthorize
16
- */
17
- abstract contract WrapERC20xTransferWithAuthorize is ERC20, ERC20Wrapper, ERC20xTransferWithAuthorize {
18
-
19
- constructor(
20
- address _underlyingToken
21
- // string memory _name,
22
- // string memory _symbol,
23
- // string memory _version
24
- )
25
- ERC20Wrapper(IERC20(_underlyingToken))
26
- {}
27
-
28
- /**
29
- * @notice Returns the token decimals
30
- * @dev Overrides both ERC20 and ERC20Wrapper decimals function
31
- * @return uint8 decimals of the token (usually matches underlying token)
32
- */
33
- function decimals()
34
- public
35
- view
36
- override(ERC20, ERC20Wrapper)
37
- returns (uint8)
38
- {
39
- return super.decimals();
40
- }
41
- }