@1inch/solidity-utils 1.2.7 → 1.2.8

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,44 @@
1
+ // SPDX-License-Identifier: MIT
2
+
3
+ pragma solidity ^0.8.0;
4
+
5
+ import "@openzeppelin/contracts/token/ERC20/extensions/draft-ERC20Permit.sol";
6
+
7
+ contract DaiLikePermitMock is ERC20Permit {
8
+ // bytes32 public constant PERMIT_TYPEHASH = keccak256("Permit(address holder,address spender,uint256 nonce,uint256 expiry,bool allowed)");
9
+ bytes32 public constant PERMIT_TYPEHASH = 0xea2aa0a1be11a07ed86d755c93467f4f82362b452371d1ba94d1715123511acb;
10
+
11
+ constructor(
12
+ string memory name,
13
+ string memory symbol,
14
+ address initialAccount,
15
+ uint256 initialBalance
16
+ ) payable ERC20(name, symbol) ERC20Permit(name) {
17
+ _mint(initialAccount, initialBalance);
18
+ }
19
+
20
+ function permit(address holder, address spender, uint256 nonce, uint256 expiry, bool allowed, uint8 v, bytes32 r, bytes32 s) external
21
+ {
22
+ bytes32 digest =
23
+ keccak256(abi.encodePacked(
24
+ "\x19\x01",
25
+ this.DOMAIN_SEPARATOR(),
26
+ keccak256(abi.encode(PERMIT_TYPEHASH,
27
+ holder,
28
+ spender,
29
+ nonce,
30
+ expiry,
31
+ allowed))
32
+ ));
33
+
34
+ require(holder != address(0), "Dai/invalid-address-0");
35
+ require(holder == ecrecover(digest, v, r, s), "Dai/invalid-permit");
36
+ // solhint-disable-next-line not-rely-on-time
37
+ require(expiry == 0 || block.timestamp <= expiry, "Dai/permit-expired");
38
+ require(nonce == nonces(holder), "Dai/invalid-nonce");
39
+ _useNonce(holder);
40
+ uint wad = allowed ? type(uint128).max : 0;
41
+ _approve(holder, spender, wad);
42
+ emit Approval(holder, spender, wad);
43
+ }
44
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1inch/solidity-utils",
3
- "version": "1.2.7",
3
+ "version": "1.2.8",
4
4
  "main": "index.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -38,7 +38,7 @@
38
38
  "solidity-utils-docify": "utils/docify.utils.js"
39
39
  },
40
40
  "scripts": {
41
- "build": "rimraf ./dist && mkdir dist && shx cp -R js ./dist/js && shx cp -R utils ./dist/utils && shx cp package.json ./dist && shx cp README.md ./dist && shx cp -R ./contracts ./dist/contracts && shx rm -rf dist/contracts/mocks dist/contracts/tests",
41
+ "build": "rimraf ./dist && mkdir dist && shx cp -R js ./dist/js && shx cp -R utils ./dist/utils && shx cp package.json ./dist && shx cp README.md ./dist && shx cp -R ./contracts ./dist/contracts && shx rm -rf dist/contracts/mocks dist/contracts/tests && shx mkdir -p dist/contracts/mocks && shx cp ./contracts/mocks/DaiLikePermitMock.sol dist/contracts/mocks/",
42
42
  "coverage": "hardhat coverage",
43
43
  "lint": "yarn run lint:js && yarn run lint:sol",
44
44
  "lint:fix": "yarn run lint:js:fix && yarn run lint:sol:fix",