@cowprotocol/permit-utils 2.4.0 → 3.0.1

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.
Files changed (79) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/package.json +28 -6
  3. package/src/abi/erc20.json +56 -56
  4. package/src/abi/versionAbis.d.ts +15 -0
  5. package/src/abi/versionAbis.js +41 -0
  6. package/src/abi/versionAbis.js.map +1 -0
  7. package/src/const.d.ts +24 -0
  8. package/src/const.js +18 -0
  9. package/src/const.js.map +1 -0
  10. package/src/consts/1inchPermitUtils.d.ts +25 -0
  11. package/src/consts/1inchPermitUtils.js +68 -0
  12. package/src/consts/1inchPermitUtils.js.map +1 -0
  13. package/src/imports/{1inchPermitUtils.ts → 1inchPermitUtils.d.ts} +1 -3
  14. package/src/imports/1inchPermitUtils.js +14 -0
  15. package/src/imports/1inchPermitUtils.js.map +1 -0
  16. package/src/{index.ts → index.d.ts} +8 -11
  17. package/src/index.js +20 -0
  18. package/src/index.js.map +1 -0
  19. package/src/lib/checkIsCallDataAValidPermit.d.ts +3 -0
  20. package/src/lib/checkIsCallDataAValidPermit.js +47 -0
  21. package/src/lib/checkIsCallDataAValidPermit.js.map +1 -0
  22. package/src/lib/generatePermitHook.d.ts +2 -0
  23. package/src/lib/generatePermitHook.js +106 -0
  24. package/src/lib/generatePermitHook.js.map +1 -0
  25. package/src/lib/getPermitUtilsInstance.d.ts +3 -0
  26. package/src/lib/getPermitUtilsInstance.js +71 -0
  27. package/src/lib/getPermitUtilsInstance.js.map +1 -0
  28. package/src/lib/getTokenPermitInfo.d.ts +2 -0
  29. package/src/lib/getTokenPermitInfo.js +204 -0
  30. package/src/lib/getTokenPermitInfo.js.map +1 -0
  31. package/src/types.d.ts +47 -0
  32. package/src/types.js +3 -0
  33. package/src/types.js.map +1 -0
  34. package/src/utils/PermitProviderConnector.d.ts +13 -0
  35. package/src/utils/PermitProviderConnector.js +64 -0
  36. package/src/utils/PermitProviderConnector.js.map +1 -0
  37. package/src/utils/buildPermitCallData.d.ts +3 -0
  38. package/src/utils/buildPermitCallData.js +20 -0
  39. package/src/utils/buildPermitCallData.js.map +1 -0
  40. package/src/utils/getContract.d.ts +3 -0
  41. package/src/utils/getContract.js +8 -0
  42. package/src/utils/getContract.js.map +1 -0
  43. package/src/utils/getEip712Domain.d.ts +13 -0
  44. package/src/utils/getEip712Domain.js +44 -0
  45. package/src/utils/getEip712Domain.js.map +1 -0
  46. package/src/utils/getPermitDeadline.d.ts +1 -0
  47. package/src/utils/getPermitDeadline.js +10 -0
  48. package/src/utils/getPermitDeadline.js.map +1 -0
  49. package/src/utils/getTokenName.d.ts +2 -0
  50. package/src/utils/getTokenName.js +13 -0
  51. package/src/utils/getTokenName.js.map +1 -0
  52. package/src/utils/getTokenPermitVersion.d.ts +2 -0
  53. package/src/utils/getTokenPermitVersion.js +28 -0
  54. package/src/utils/getTokenPermitVersion.js.map +1 -0
  55. package/src/utils/isSupportedPermitInfo.d.ts +2 -0
  56. package/src/utils/isSupportedPermitInfo.js +7 -0
  57. package/src/utils/isSupportedPermitInfo.js.map +1 -0
  58. package/jest.config.ts +0 -11
  59. package/project.json +0 -42
  60. package/src/abi/versionAbis.ts +0 -37
  61. package/src/const.ts +0 -20
  62. package/src/consts/1inchPermitUtils.ts +0 -68
  63. package/src/lib/checkIsCallDataAValidPermit.ts +0 -64
  64. package/src/lib/generatePermitHook.ts +0 -133
  65. package/src/lib/getPermitUtilsInstance.ts +0 -51
  66. package/src/lib/getTokenPermitInfo.ts +0 -281
  67. package/src/types.ts +0 -61
  68. package/src/utils/PermitProviderConnector.ts +0 -75
  69. package/src/utils/buildPermitCallData.ts +0 -26
  70. package/src/utils/getContract.ts +0 -6
  71. package/src/utils/getEip712Domain.ts +0 -70
  72. package/src/utils/getPermitDeadline.ts +0 -7
  73. package/src/utils/getTokenName.ts +0 -13
  74. package/src/utils/getTokenPermitVersion.ts +0 -35
  75. package/src/utils/isSupportedPermitInfo.ts +0 -5
  76. package/tsconfig.json +0 -22
  77. package/tsconfig.lib.json +0 -10
  78. package/tsconfig.spec.json +0 -9
  79. package/vite.config.mts +0 -51
package/CHANGELOG.md CHANGED
@@ -1,5 +1,42 @@
1
1
  # Changelog
2
2
 
3
+ ## [3.0.1](https://github.com/cowprotocol/cowswap/compare/permit-utils-v3.0.0...permit-utils-v3.0.1) (2026-03-18)
4
+
5
+
6
+ ### 🐛 Bug Fixes
7
+
8
+ * update libs publising and bundling ([#7173](https://github.com/cowprotocol/cowswap/issues/7173)) ([e3bc5f1](https://github.com/cowprotocol/cowswap/commit/e3bc5f179124c11590a992789db43d912f8ee4a6))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @cowprotocol/hook-dapp-lib bumped to 2.0.9
16
+
17
+ ## [3.0.0](https://github.com/cowprotocol/cowswap/compare/permit-utils-v2.4.0...permit-utils-v3.0.0) (2026-03-11)
18
+
19
+
20
+ ### ⚠ BREAKING CHANGES
21
+
22
+ * Remove support for Lens network ([#7128](https://github.com/cowprotocol/cowswap/issues/7128))
23
+
24
+ ### ✨ Features
25
+
26
+ * remove support for Lens network ([#7128](https://github.com/cowprotocol/cowswap/issues/7128)) ([ffdd36d](https://github.com/cowprotocol/cowswap/commit/ffdd36db765eb1feb7fc675347de40b1e6df2bdd))
27
+
28
+
29
+ ### 🔧 Miscellaneous
30
+
31
+ * **hotfix:** 2026-03-10 ([8c831f7](https://github.com/cowprotocol/cowswap/commit/8c831f70685c058f460d7a0fabbf2941163b9fba))
32
+
33
+
34
+ ### Dependencies
35
+
36
+ * The following workspace dependencies were updated
37
+ * dependencies
38
+ * @cowprotocol/hook-dapp-lib bumped to 2.0.8
39
+
3
40
  ## [2.4.0](https://github.com/cowprotocol/cowswap/compare/permit-utils-v2.3.2...permit-utils-v2.4.0) (2026-03-10)
4
41
 
5
42
 
package/package.json CHANGED
@@ -1,16 +1,23 @@
1
1
  {
2
2
  "name": "@cowprotocol/permit-utils",
3
- "version": "2.4.0",
3
+ "version": "3.0.1",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "https://github.com/cowprotocol/cowswap.git",
7
+ "directory": "libs/permit-utils"
8
+ },
4
9
  "type": "commonjs",
5
- "main": "./src/index.ts",
10
+ "main": "./src/index.js",
6
11
  "types": "./src/index.d.ts",
7
12
  "license": "ISC",
8
13
  "publishConfig": {
9
14
  "access": "public"
10
15
  },
11
16
  "dependencies": {
12
- "@cowprotocol/cow-sdk": "7.4.1",
13
17
  "@1inch/permit-signed-approvals-utils": "^1.5.1",
18
+ "@cowprotocol/cow-sdk": "8.0.0",
19
+ "@cowprotocol/hook-dapp-lib": "^2.0.9",
20
+ "@cowprotocol/sdk-bridging": "3.0.0",
14
21
  "@ethersproject/abi": "5.7.0",
15
22
  "@ethersproject/abstract-signer": "5.7.0",
16
23
  "@ethersproject/address": "5.7.0",
@@ -19,12 +26,27 @@
19
26
  "@ethersproject/contracts": "5.7.0",
20
27
  "@ethersproject/providers": "5.7.0",
21
28
  "@ethersproject/wallet": "5.7.0",
29
+ "@types/ms.macro": "2.0.3",
30
+ "@uniswap/sdk-core": "3.2.6",
31
+ "@web3-react/types": "8.2.3",
22
32
  "ethers": "5.7.2",
33
+ "eventemitter3": "4.0.7",
23
34
  "ms.macro": "^2.0.0",
24
35
  "viem": "^2.42.1",
25
- "@cowprotocol/hook-dapp-lib": "2.0.7"
36
+ "@cowprotocol/iframe-transport": "2.0.9",
37
+ "@cowprotocol/types": "4.0.1",
38
+ "tslib": "1.14.1"
26
39
  },
27
- "devDependencies": {
28
- "@types/ms.macro": "^2.0.0"
40
+ "resolutions": {
41
+ "@safe-global/safe-apps-sdk": "^9.1.0",
42
+ "@types/react": "19.1.3",
43
+ "@types/react-dom": "19.1.3",
44
+ "stylus": "npm:empty-npm-package@1.0.0",
45
+ "@babel/traverse": "^7.23.2",
46
+ "@walletconnect/ethereum-provider": "2.18.0",
47
+ "@walletconnect/sign-client": "2.18.0",
48
+ "@walletconnect/universal-provider": "2.18.0",
49
+ "@walletconnect/utils": "2.18.0",
50
+ "@walletconnect/types": "2.18.0"
29
51
  }
30
52
  }
@@ -1,59 +1,59 @@
1
1
  [
2
- {
3
- "constant": true,
4
- "inputs": [],
5
- "name": "name",
6
- "outputs": [
7
- {
8
- "name": "",
9
- "type": "string"
10
- }
11
- ],
12
- "payable": false,
13
- "stateMutability": "view",
14
- "type": "function"
15
- },
16
- {
17
- "inputs": [],
18
- "name": "eip712Domain",
19
- "outputs": [
20
- {
21
- "internalType": "bytes1",
22
- "name": "fields",
23
- "type": "bytes1"
24
- },
25
- {
26
- "internalType": "string",
2
+ {
3
+ "constant": true,
4
+ "inputs": [],
27
5
  "name": "name",
28
- "type": "string"
29
- },
30
- {
31
- "internalType": "string",
32
- "name": "version",
33
- "type": "string"
34
- },
35
- {
36
- "internalType": "uint256",
37
- "name": "chainId",
38
- "type": "uint256"
39
- },
40
- {
41
- "internalType": "address",
42
- "name": "verifyingContract",
43
- "type": "address"
44
- },
45
- {
46
- "internalType": "bytes32",
47
- "name": "salt",
48
- "type": "bytes32"
49
- },
50
- {
51
- "internalType": "uint256[]",
52
- "name": "extensions",
53
- "type": "uint256[]"
54
- }
55
- ],
56
- "stateMutability": "view",
57
- "type": "function"
58
- }
6
+ "outputs": [
7
+ {
8
+ "name": "",
9
+ "type": "string"
10
+ }
11
+ ],
12
+ "payable": false,
13
+ "stateMutability": "view",
14
+ "type": "function"
15
+ },
16
+ {
17
+ "inputs": [],
18
+ "name": "eip712Domain",
19
+ "outputs": [
20
+ {
21
+ "internalType": "bytes1",
22
+ "name": "fields",
23
+ "type": "bytes1"
24
+ },
25
+ {
26
+ "internalType": "string",
27
+ "name": "name",
28
+ "type": "string"
29
+ },
30
+ {
31
+ "internalType": "string",
32
+ "name": "version",
33
+ "type": "string"
34
+ },
35
+ {
36
+ "internalType": "uint256",
37
+ "name": "chainId",
38
+ "type": "uint256"
39
+ },
40
+ {
41
+ "internalType": "address",
42
+ "name": "verifyingContract",
43
+ "type": "address"
44
+ },
45
+ {
46
+ "internalType": "bytes32",
47
+ "name": "salt",
48
+ "type": "bytes32"
49
+ },
50
+ {
51
+ "internalType": "uint256[]",
52
+ "name": "extensions",
53
+ "type": "uint256[]"
54
+ }
55
+ ],
56
+ "stateMutability": "view",
57
+ "type": "function"
58
+ }
59
59
  ]
@@ -0,0 +1,15 @@
1
+ /**
2
+ * ABIs for fetching the version of different permit flavours
3
+ */
4
+ export declare const VERSION_ABIS: {
5
+ constant: boolean;
6
+ inputs: never[];
7
+ name: string;
8
+ outputs: {
9
+ name: string;
10
+ type: string;
11
+ }[];
12
+ payable: boolean;
13
+ stateMutability: string;
14
+ type: string;
15
+ }[][];
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VERSION_ABIS = void 0;
4
+ /**
5
+ * ABIs for fetching the version of different permit flavours
6
+ */
7
+ exports.VERSION_ABIS = [
8
+ [
9
+ {
10
+ constant: true,
11
+ inputs: [],
12
+ name: 'version',
13
+ outputs: [
14
+ {
15
+ name: '',
16
+ type: 'string',
17
+ },
18
+ ],
19
+ payable: false,
20
+ stateMutability: 'view',
21
+ type: 'function',
22
+ },
23
+ ],
24
+ [
25
+ {
26
+ constant: true,
27
+ inputs: [],
28
+ name: 'ERC712_VERSION',
29
+ outputs: [
30
+ {
31
+ name: '',
32
+ type: 'string',
33
+ },
34
+ ],
35
+ payable: false,
36
+ stateMutability: 'view',
37
+ type: 'function',
38
+ },
39
+ ],
40
+ ];
41
+ //# sourceMappingURL=versionAbis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"versionAbis.js","sourceRoot":"","sources":["../../../../../libs/permit-utils/src/abi/versionAbis.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,YAAY,GAAG;IAC1B;QACE;YACE,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE,EAAE;YACV,IAAI,EAAE,SAAS;YACf,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,EAAE;oBACR,IAAI,EAAE,QAAQ;iBACf;aACF;YACD,OAAO,EAAE,KAAK;YACd,eAAe,EAAE,MAAM;YACvB,IAAI,EAAE,UAAU;SACjB;KACF;IACD;QACE;YACE,QAAQ,EAAE,IAAI;YACd,MAAM,EAAE,EAAE;YACV,IAAI,EAAE,gBAAgB;YACtB,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,EAAE;oBACR,IAAI,EAAE,QAAQ;iBACf;aACF;YACD,OAAO,EAAE,KAAK;YACd,eAAe,EAAE,MAAM;YACvB,IAAI,EAAE,UAAU;SACjB;KACF;CACF,CAAA"}
package/src/const.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ import { Wallet } from '@ethersproject/wallet';
2
+ export declare const PERMIT_ACCOUNT: {
3
+ address: import("viem/accounts").Address;
4
+ nonceManager?: import("viem/accounts").NonceManager | undefined;
5
+ sign: (parameters: {
6
+ hash: import("viem").Hash;
7
+ }) => Promise<import("viem").Hex>;
8
+ signAuthorization: (parameters: import("viem").AuthorizationRequest) => Promise<import("viem/accounts").SignAuthorizationReturnType>;
9
+ signMessage: ({ message }: {
10
+ message: import("viem").SignableMessage;
11
+ }) => Promise<import("viem").Hex>;
12
+ signTransaction: <serializer extends import("viem").SerializeTransactionFn<import("viem").TransactionSerializable> = import("viem").SerializeTransactionFn<import("viem").TransactionSerializable>, transaction extends Parameters<serializer>[0] = Parameters<serializer>[0]>(transaction: transaction, options?: {
13
+ serializer?: serializer | undefined;
14
+ } | undefined) => Promise<import("viem").Hex>;
15
+ signTypedData: <const typedData extends import("viem").TypedData | Record<string, unknown>, primaryType extends keyof typedData | "EIP712Domain" = keyof typedData>(parameters: import("viem").TypedDataDefinition<typedData, primaryType>) => Promise<import("viem").Hex>;
16
+ publicKey: import("viem").Hex;
17
+ source: "privateKey";
18
+ type: "local";
19
+ };
20
+ export declare const PERMIT_SIGNER: Wallet;
21
+ export declare const DEFAULT_MIN_GAS_LIMIT = 55000;
22
+ export declare const DEFAULT_PERMIT_GAS_LIMIT = "80000";
23
+ export declare const DEFAULT_PERMIT_VALUE: bigint;
24
+ export declare const DEFAULT_PERMIT_DURATION: number;
package/src/const.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_PERMIT_DURATION = exports.DEFAULT_PERMIT_VALUE = exports.DEFAULT_PERMIT_GAS_LIMIT = exports.DEFAULT_MIN_GAS_LIMIT = exports.PERMIT_SIGNER = exports.PERMIT_ACCOUNT = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const constants_1 = require("@ethersproject/constants");
6
+ const wallet_1 = require("@ethersproject/wallet");
7
+ const ms_macro_1 = tslib_1.__importDefault(require("ms.macro"));
8
+ const accounts_1 = require("viem/accounts");
9
+ // PK used only for signing permit requests for quoting and identifying token 'permittability'
10
+ // Do not use or try to send funds to it. Or do. It'll be your funds 🤷
11
+ const PERMIT_PK = '0xa50dc0f7fc051309434deb3b1c71e927dbb711759231d8ecbf630c85d94a42fe'; // address: 0xDa5F16F4ab0410096a4403e7223988649fac38cF
12
+ exports.PERMIT_ACCOUNT = (0, accounts_1.privateKeyToAccount)(PERMIT_PK);
13
+ exports.PERMIT_SIGNER = new wallet_1.Wallet(PERMIT_PK);
14
+ exports.DEFAULT_MIN_GAS_LIMIT = 55_000;
15
+ exports.DEFAULT_PERMIT_GAS_LIMIT = '80000';
16
+ exports.DEFAULT_PERMIT_VALUE = constants_1.MaxUint256.toBigInt();
17
+ exports.DEFAULT_PERMIT_DURATION = (0, ms_macro_1.default) `5 years`;
18
+ //# sourceMappingURL=const.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"const.js","sourceRoot":"","sources":["../../../../libs/permit-utils/src/const.ts"],"names":[],"mappings":";;;;AAAA,wDAAqD;AACrD,kDAA8C;AAE9C,gEAAyB;AACzB,4CAAmD;AAEnD,8FAA8F;AAC9F,uEAAuE;AACvE,MAAM,SAAS,GAAG,oEAAoE,CAAA,CAAC,sDAAsD;AAEhI,QAAA,cAAc,GAAG,IAAA,8BAAmB,EAAC,SAAS,CAAC,CAAA;AAC/C,QAAA,aAAa,GAAG,IAAI,eAAM,CAAC,SAAS,CAAC,CAAA;AAErC,QAAA,qBAAqB,GAAG,MAAM,CAAA;AAE9B,QAAA,wBAAwB,GAAG,OAAO,CAAA;AAElC,QAAA,oBAAoB,GAAG,sBAAU,CAAC,QAAQ,EAAE,CAAA;AAE5C,QAAA,uBAAuB,GAAG,IAAA,kBAAE,EAAA,SAAS,CAAA"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @1inch/permit-signed-approvals-utils has a lot of extra variables and increases bundle size.
3
+ *
4
+ * At the same time it's repo is archived.
5
+ *
6
+ * Therefore we just copied needed constants, and when it's not possible, we should use import(...)
7
+ *
8
+ * You also can use `import type ... from '@1inch/permit-signed-approvals-utils'`
9
+ */
10
+ export declare const DAI_EIP_2612_PERMIT_ABI: {
11
+ constant: boolean;
12
+ inputs: {
13
+ internalType: string;
14
+ name: string;
15
+ type: string;
16
+ }[];
17
+ name: string;
18
+ outputs: never[];
19
+ payable: boolean;
20
+ stateMutability: string;
21
+ type: string;
22
+ }[];
23
+ export declare const EIP_2612_PERMIT_SELECTOR = "0xd505accf";
24
+ export declare const DAI_PERMIT_SELECTOR = "0x8fcbaf0c";
25
+ export declare const DAI_LIKE_PERMIT_TYPEHASH = "0xea2aa0a1be11a07ed86d755c93467f4f82362b452371d1ba94d1715123511acb";
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ /**
3
+ * @1inch/permit-signed-approvals-utils has a lot of extra variables and increases bundle size.
4
+ *
5
+ * At the same time it's repo is archived.
6
+ *
7
+ * Therefore we just copied needed constants, and when it's not possible, we should use import(...)
8
+ *
9
+ * You also can use `import type ... from '@1inch/permit-signed-approvals-utils'`
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.DAI_LIKE_PERMIT_TYPEHASH = exports.DAI_PERMIT_SELECTOR = exports.EIP_2612_PERMIT_SELECTOR = exports.DAI_EIP_2612_PERMIT_ABI = void 0;
13
+ exports.DAI_EIP_2612_PERMIT_ABI = [
14
+ {
15
+ constant: false,
16
+ inputs: [
17
+ {
18
+ internalType: 'address',
19
+ name: 'holder',
20
+ type: 'address',
21
+ },
22
+ {
23
+ internalType: 'address',
24
+ name: 'spender',
25
+ type: 'address',
26
+ },
27
+ {
28
+ internalType: 'uint256',
29
+ name: 'nonce',
30
+ type: 'uint256',
31
+ },
32
+ {
33
+ internalType: 'uint256',
34
+ name: 'expiry',
35
+ type: 'uint256',
36
+ },
37
+ {
38
+ internalType: 'bool',
39
+ name: 'allowed',
40
+ type: 'bool',
41
+ },
42
+ {
43
+ internalType: 'uint8',
44
+ name: 'v',
45
+ type: 'uint8',
46
+ },
47
+ {
48
+ internalType: 'bytes32',
49
+ name: 'r',
50
+ type: 'bytes32',
51
+ },
52
+ {
53
+ internalType: 'bytes32',
54
+ name: 's',
55
+ type: 'bytes32',
56
+ },
57
+ ],
58
+ name: 'permit',
59
+ outputs: [],
60
+ payable: false,
61
+ stateMutability: 'nonpayable',
62
+ type: 'function',
63
+ },
64
+ ];
65
+ exports.EIP_2612_PERMIT_SELECTOR = '0xd505accf';
66
+ exports.DAI_PERMIT_SELECTOR = '0x8fcbaf0c';
67
+ exports.DAI_LIKE_PERMIT_TYPEHASH = '0xea2aa0a1be11a07ed86d755c93467f4f82362b452371d1ba94d1715123511acb';
68
+ //# sourceMappingURL=1inchPermitUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"1inchPermitUtils.js","sourceRoot":"","sources":["../../../../../libs/permit-utils/src/consts/1inchPermitUtils.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAEU,QAAA,uBAAuB,GAAG;IACrC;QACE,QAAQ,EAAE,KAAK;QACf,MAAM,EAAE;YACN;gBACE,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,SAAS;aAChB;YACD;gBACE,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,SAAS;aAChB;YACD;gBACE,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,SAAS;aAChB;YACD;gBACE,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,SAAS;aAChB;YACD;gBACE,YAAY,EAAE,MAAM;gBACpB,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,MAAM;aACb;YACD;gBACE,YAAY,EAAE,OAAO;gBACrB,IAAI,EAAE,GAAG;gBACT,IAAI,EAAE,OAAO;aACd;YACD;gBACE,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,GAAG;gBACT,IAAI,EAAE,SAAS;aAChB;YACD;gBACE,YAAY,EAAE,SAAS;gBACvB,IAAI,EAAE,GAAG;gBACT,IAAI,EAAE,SAAS;aAChB;SACF;QACD,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,KAAK;QACd,eAAe,EAAE,YAAY;QAC7B,IAAI,EAAE,UAAU;KACjB;CACF,CAAA;AAEY,QAAA,wBAAwB,GAAG,YAAY,CAAA;AAEvC,QAAA,mBAAmB,GAAG,YAAY,CAAA;AAElC,QAAA,wBAAwB,GAAG,oEAAoE,CAAA"}
@@ -5,6 +5,4 @@
5
5
  *
6
6
  * You also can use `import type ... from '@1inch/permit-signed-approvals-utils'`
7
7
  */
8
-
9
- // eslint-disable-next-line @typescript-eslint/no-restricted-imports
10
- export { Eip2612PermitUtils } from '@1inch/permit-signed-approvals-utils'
8
+ export { Eip2612PermitUtils } from '@1inch/permit-signed-approvals-utils';
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ /**
3
+ * @1inch/permit-signed-approvals-utils has a lot of extra variables and increases bundle size, we should import in dynamically.
4
+ *
5
+ * It uses esm, but dymaic import breaks tree shaking, so we re-export here only used variables (642kb -> 256kb).
6
+ *
7
+ * You also can use `import type ... from '@1inch/permit-signed-approvals-utils'`
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.Eip2612PermitUtils = void 0;
11
+ // eslint-disable-next-line @typescript-eslint/no-restricted-imports
12
+ var permit_signed_approvals_utils_1 = require("@1inch/permit-signed-approvals-utils");
13
+ Object.defineProperty(exports, "Eip2612PermitUtils", { enumerable: true, get: function () { return permit_signed_approvals_utils_1.Eip2612PermitUtils; } });
14
+ //# sourceMappingURL=1inchPermitUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"1inchPermitUtils.js","sourceRoot":"","sources":["../../../../../libs/permit-utils/src/imports/1inchPermitUtils.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAEH,oEAAoE;AACpE,sFAAyE;AAAhE,mIAAA,kBAAkB,OAAA"}
@@ -1,11 +1,8 @@
1
- export { DEFAULT_MIN_GAS_LIMIT, PERMIT_ACCOUNT, PERMIT_SIGNER } from './const'
2
-
3
- export { checkIsCallDataAValidPermit } from './lib/checkIsCallDataAValidPermit'
4
- export { generatePermitHook } from './lib/generatePermitHook'
5
- export { getPermitUtilsInstance } from './lib/getPermitUtilsInstance'
6
- export { getTokenPermitInfo } from './lib/getTokenPermitInfo'
7
- export { isSupportedPermitInfo } from './utils/isSupportedPermitInfo'
8
-
9
- export * as oneInchPermitUtilsConsts from './consts/1inchPermitUtils'
10
-
11
- export type { GetTokenPermitIntoResult, PermitHookData, PermitHookParams, PermitInfo, PermitType } from './types'
1
+ export { DEFAULT_MIN_GAS_LIMIT, PERMIT_ACCOUNT, PERMIT_SIGNER } from './const';
2
+ export { checkIsCallDataAValidPermit } from './lib/checkIsCallDataAValidPermit';
3
+ export { generatePermitHook } from './lib/generatePermitHook';
4
+ export { getPermitUtilsInstance } from './lib/getPermitUtilsInstance';
5
+ export { getTokenPermitInfo } from './lib/getTokenPermitInfo';
6
+ export { isSupportedPermitInfo } from './utils/isSupportedPermitInfo';
7
+ export * as oneInchPermitUtilsConsts from './consts/1inchPermitUtils';
8
+ export type { GetTokenPermitIntoResult, PermitHookData, PermitHookParams, PermitInfo, PermitType } from './types';
package/src/index.js ADDED
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.oneInchPermitUtilsConsts = exports.isSupportedPermitInfo = exports.getTokenPermitInfo = exports.getPermitUtilsInstance = exports.generatePermitHook = exports.checkIsCallDataAValidPermit = exports.PERMIT_SIGNER = exports.PERMIT_ACCOUNT = exports.DEFAULT_MIN_GAS_LIMIT = void 0;
4
+ const tslib_1 = require("tslib");
5
+ var const_1 = require("./const");
6
+ Object.defineProperty(exports, "DEFAULT_MIN_GAS_LIMIT", { enumerable: true, get: function () { return const_1.DEFAULT_MIN_GAS_LIMIT; } });
7
+ Object.defineProperty(exports, "PERMIT_ACCOUNT", { enumerable: true, get: function () { return const_1.PERMIT_ACCOUNT; } });
8
+ Object.defineProperty(exports, "PERMIT_SIGNER", { enumerable: true, get: function () { return const_1.PERMIT_SIGNER; } });
9
+ var checkIsCallDataAValidPermit_1 = require("./lib/checkIsCallDataAValidPermit");
10
+ Object.defineProperty(exports, "checkIsCallDataAValidPermit", { enumerable: true, get: function () { return checkIsCallDataAValidPermit_1.checkIsCallDataAValidPermit; } });
11
+ var generatePermitHook_1 = require("./lib/generatePermitHook");
12
+ Object.defineProperty(exports, "generatePermitHook", { enumerable: true, get: function () { return generatePermitHook_1.generatePermitHook; } });
13
+ var getPermitUtilsInstance_1 = require("./lib/getPermitUtilsInstance");
14
+ Object.defineProperty(exports, "getPermitUtilsInstance", { enumerable: true, get: function () { return getPermitUtilsInstance_1.getPermitUtilsInstance; } });
15
+ var getTokenPermitInfo_1 = require("./lib/getTokenPermitInfo");
16
+ Object.defineProperty(exports, "getTokenPermitInfo", { enumerable: true, get: function () { return getTokenPermitInfo_1.getTokenPermitInfo; } });
17
+ var isSupportedPermitInfo_1 = require("./utils/isSupportedPermitInfo");
18
+ Object.defineProperty(exports, "isSupportedPermitInfo", { enumerable: true, get: function () { return isSupportedPermitInfo_1.isSupportedPermitInfo; } });
19
+ exports.oneInchPermitUtilsConsts = tslib_1.__importStar(require("./consts/1inchPermitUtils"));
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../libs/permit-utils/src/index.ts"],"names":[],"mappings":";;;;AAAA,iCAA8E;AAArE,8GAAA,qBAAqB,OAAA;AAAE,uGAAA,cAAc,OAAA;AAAE,sGAAA,aAAa,OAAA;AAE7D,iFAA+E;AAAtE,0IAAA,2BAA2B,OAAA;AACpC,+DAA6D;AAApD,wHAAA,kBAAkB,OAAA;AAC3B,uEAAqE;AAA5D,gIAAA,sBAAsB,OAAA;AAC/B,+DAA6D;AAApD,wHAAA,kBAAkB,OAAA;AAC3B,uEAAqE;AAA5D,8HAAA,qBAAqB,OAAA;AAE9B,8FAAqE"}
@@ -0,0 +1,3 @@
1
+ import { PermitInfo } from '../types';
2
+ import type { Eip2612PermitUtils } from '@1inch/permit-signed-approvals-utils';
3
+ export declare function checkIsCallDataAValidPermit(owner: string, chainId: number, eip2612Utils: Eip2612PermitUtils, tokenAddress: string, _tokenName: string | undefined, callData: string, { version, type, name }: PermitInfo): Promise<boolean | undefined>;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkIsCallDataAValidPermit = checkIsCallDataAValidPermit;
4
+ const __1 = require("..");
5
+ async function checkIsCallDataAValidPermit(owner, chainId, eip2612Utils, tokenAddress, _tokenName, callData, { version, type, name }) {
6
+ // TODO: take name only from PermitInfo
7
+ const tokenName = name || _tokenName;
8
+ if (type === 'unsupported') {
9
+ return false;
10
+ }
11
+ if (!tokenName) {
12
+ throw new Error(`No token name for ${tokenAddress}`);
13
+ }
14
+ const params = { chainId, tokenName, tokenAddress, callData, version };
15
+ let recoverPermitOwnerPromise = undefined;
16
+ // If pre-hook doesn't start with either selector, it's not a permit
17
+ if (callData.startsWith(__1.oneInchPermitUtilsConsts.EIP_2612_PERMIT_SELECTOR)) {
18
+ recoverPermitOwnerPromise = eip2612Utils.recoverPermitOwnerFromCallData({
19
+ ...params,
20
+ // I don't know why this was removed, ok?
21
+ // We added it back on buildPermitCallData.ts
22
+ // But it looks like this is needed 🤷
23
+ // Check the test for this method https://github.com/1inch/permit-signed-approvals-utils/blob/master/src/eip-2612-permit.test.ts#L85-L106
24
+ callData: callData.replace(__1.oneInchPermitUtilsConsts.EIP_2612_PERMIT_SELECTOR, '0x'),
25
+ });
26
+ }
27
+ else if (callData.startsWith(__1.oneInchPermitUtilsConsts.DAI_PERMIT_SELECTOR)) {
28
+ recoverPermitOwnerPromise = eip2612Utils.recoverDaiLikePermitOwnerFromCallData({
29
+ ...params,
30
+ callData: callData.replace(__1.oneInchPermitUtilsConsts.DAI_PERMIT_SELECTOR, '0x'),
31
+ });
32
+ }
33
+ if (!recoverPermitOwnerPromise) {
34
+ // The callData doesn't match any known permit type
35
+ return undefined;
36
+ }
37
+ try {
38
+ const recoveredOwner = await recoverPermitOwnerPromise;
39
+ // Permit is valid when recovered owner matches order owner
40
+ return recoveredOwner.toLowerCase() === owner.toLowerCase();
41
+ }
42
+ catch (e) {
43
+ console.debug(`[checkHasValidPendingPermit] Failed to check permit validity for owner ${owner} with callData ${callData}`, e);
44
+ return false;
45
+ }
46
+ }
47
+ //# sourceMappingURL=checkIsCallDataAValidPermit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkIsCallDataAValidPermit.js","sourceRoot":"","sources":["../../../../../libs/permit-utils/src/lib/checkIsCallDataAValidPermit.ts"],"names":[],"mappings":";;AAKA,kEA0DC;AA/DD,0BAA6C;AAKtC,KAAK,UAAU,2BAA2B,CAC/C,KAAa,EACb,OAAe,EACf,YAAgC,EAChC,YAAoB,EACpB,UAA8B,EAC9B,QAAgB,EAChB,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAc;IAEnC,uCAAuC;IACvC,MAAM,SAAS,GAAG,IAAI,IAAI,UAAU,CAAA;IAEpC,IAAI,IAAI,KAAK,aAAa,EAAE,CAAC;QAC3B,OAAO,KAAK,CAAA;IACd,CAAC;IAED,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,qBAAqB,YAAY,EAAE,CAAC,CAAA;IACtD,CAAC;IAED,MAAM,MAAM,GAAG,EAAE,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAA;IAEtE,IAAI,yBAAyB,GAAgC,SAAS,CAAA;IAEtE,oEAAoE;IACpE,IAAI,QAAQ,CAAC,UAAU,CAAC,4BAAwB,CAAC,wBAAwB,CAAC,EAAE,CAAC;QAC3E,yBAAyB,GAAG,YAAY,CAAC,8BAA8B,CAAC;YACtE,GAAG,MAAM;YACT,yCAAyC;YACzC,6CAA6C;YAC7C,sCAAsC;YACtC,yIAAyI;YACzI,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,4BAAwB,CAAC,wBAAwB,EAAE,IAAI,CAAC;SACpF,CAAC,CAAA;IACJ,CAAC;SAAM,IAAI,QAAQ,CAAC,UAAU,CAAC,4BAAwB,CAAC,mBAAmB,CAAC,EAAE,CAAC;QAC7E,yBAAyB,GAAG,YAAY,CAAC,qCAAqC,CAAC;YAC7E,GAAG,MAAM;YACT,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,4BAAwB,CAAC,mBAAmB,EAAE,IAAI,CAAC;SAC/E,CAAC,CAAA;IACJ,CAAC;IAED,IAAI,CAAC,yBAAyB,EAAE,CAAC;QAC/B,mDAAmD;QACnD,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,IAAI,CAAC;QACH,MAAM,cAAc,GAAG,MAAM,yBAAyB,CAAA;QAEtD,2DAA2D;QAC3D,OAAO,cAAc,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC,WAAW,EAAE,CAAA;IAC7D,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CACX,0EAA0E,KAAK,kBAAkB,QAAQ,EAAE,EAC3G,CAAC,CACF,CAAA;QACD,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ import { PermitHookData, PermitHookParams } from '../types';
2
+ export declare function generatePermitHook(params: PermitHookParams): Promise<PermitHookData | undefined>;