@cowprotocol/permit-utils 3.2.1 → 3.2.3
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.
- package/abi/erc20.d.ts +47 -0
- package/const.d.ts +4 -6
- package/consts/1inchPermitUtils.d.ts +69 -13
- package/index.cjs +1 -1
- package/index.d.ts +1 -1
- package/index.js +421 -338
- package/lib/getPermitUtilsInstance.d.ts +23 -2
- package/package.json +4 -12
- package/types.d.ts +14 -12
- package/utils/PermitProviderConnector.d.ts +9 -10
- package/utils/buildPermitCallData.d.ts +3 -2
- package/utils/getEip712Domain.d.ts +3 -2
- package/utils/getTokenName.d.ts +3 -2
- package/utils/getTokenPermitVersion.d.ts +3 -2
- package/utils/getContract.d.ts +0 -3
|
@@ -1,3 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Address, PublicClient, WalletClient } from 'viem';
|
|
2
2
|
import { Eip2612PermitUtils } from '@1inch/permit-signed-approvals-utils';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Returns a cached Eip2612PermitUtils instance for querying and signing EIP-2612 permits.
|
|
5
|
+
*
|
|
6
|
+
* Two modes of operation:
|
|
7
|
+
*
|
|
8
|
+
* 1. **Read-only (no `account`)** — Uses a static PERMIT_ACCOUNT with an HTTP transport.
|
|
9
|
+
* This is used for checking whether a token supports permits, reading nonces, etc.
|
|
10
|
+
* No real signatures are produced; instances are cached per chainId.
|
|
11
|
+
*
|
|
12
|
+
* 2. **Signing (with `account` + `walletClient`)** — Uses the wagmi wallet client so
|
|
13
|
+
* `eth_signTypedData_v4` is routed through the user's actual wallet (MetaMask, WalletConnect, etc.).
|
|
14
|
+
* Plain HTTP transports (e.g. Infura) do NOT support signing, so `walletClient` is required
|
|
15
|
+
* when an account is provided. Instances are cached per chainId+account.
|
|
16
|
+
*
|
|
17
|
+
* The 1inch `Eip2612PermitUtils` class is lazily imported to keep it out of the main bundle.
|
|
18
|
+
*/
|
|
19
|
+
export declare function getPermitUtilsInstance({ chainId, publicClient, account, walletClient: wagmiWalletClient, }: {
|
|
20
|
+
chainId: number;
|
|
21
|
+
publicClient: PublicClient;
|
|
22
|
+
account?: Address;
|
|
23
|
+
walletClient?: WalletClient | null;
|
|
24
|
+
}): Promise<Eip2612PermitUtils>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cowprotocol/permit-utils",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.3",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/cowprotocol/cowswap.git",
|
|
@@ -16,18 +16,10 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@cowprotocol/cow-sdk": "9.0.2",
|
|
18
18
|
"@1inch/permit-signed-approvals-utils": "^1.5.1",
|
|
19
|
-
"@cowprotocol/hook-dapp-lib": "^2.2.
|
|
20
|
-
"@ethersproject/abi": "5.7.0",
|
|
21
|
-
"@ethersproject/abstract-signer": "5.7.0",
|
|
22
|
-
"@ethersproject/address": "5.7.0",
|
|
23
|
-
"@ethersproject/bignumber": "5.7.0",
|
|
24
|
-
"@ethersproject/constants": "5.7.0",
|
|
25
|
-
"@ethersproject/contracts": "5.7.0",
|
|
26
|
-
"@ethersproject/providers": "5.7.0",
|
|
27
|
-
"@ethersproject/wallet": "5.7.0",
|
|
28
|
-
"ethers": "5.7.2",
|
|
19
|
+
"@cowprotocol/hook-dapp-lib": "^2.2.4",
|
|
29
20
|
"ms.macro": "^2.0.0",
|
|
30
|
-
"viem": "^2.42.1"
|
|
21
|
+
"viem": "^2.42.1",
|
|
22
|
+
"wagmi": "^3.6.9"
|
|
31
23
|
},
|
|
32
24
|
"devDependencies": {
|
|
33
25
|
"@types/ms.macro": "^2.0.0"
|
package/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { cowAppDataLatestScheme } from '@cowprotocol/cow-sdk';
|
|
2
|
-
import { JsonRpcProvider } from '@ethersproject/providers';
|
|
3
2
|
import { Eip2612PermitUtils } from '@1inch/permit-signed-approvals-utils';
|
|
3
|
+
import { Address, PublicClient } from 'viem';
|
|
4
|
+
import { Config } from 'wagmi';
|
|
4
5
|
export type PermitType = 'dai-like' | 'eip-2612' | 'unsupported';
|
|
5
6
|
export type PermitInfo = {
|
|
6
7
|
type: PermitType;
|
|
@@ -8,19 +9,19 @@ export type PermitInfo = {
|
|
|
8
9
|
version?: string | undefined;
|
|
9
10
|
};
|
|
10
11
|
type TokenInfo = {
|
|
11
|
-
address:
|
|
12
|
+
address: Address;
|
|
12
13
|
name: string | undefined;
|
|
13
14
|
};
|
|
14
15
|
export type PermitHookParams = {
|
|
15
|
-
inputToken: TokenInfo;
|
|
16
|
-
spender: string;
|
|
17
16
|
chainId: number;
|
|
18
|
-
|
|
19
|
-
provider: JsonRpcProvider;
|
|
17
|
+
config: Config;
|
|
20
18
|
eip2612Utils: Eip2612PermitUtils;
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
inputToken: TokenInfo;
|
|
20
|
+
permitInfo: PermitInfo;
|
|
21
|
+
spender: string;
|
|
22
|
+
account?: Address;
|
|
23
23
|
amount?: bigint;
|
|
24
|
+
nonce?: number;
|
|
24
25
|
};
|
|
25
26
|
export type PermitHookData = cowAppDataLatestScheme.CoWHook;
|
|
26
27
|
type FailedToIdentify = {
|
|
@@ -37,11 +38,12 @@ export type BuildDaiLikePermitCallDataParams = BasePermitCallDataParams & {
|
|
|
37
38
|
callDataParams: Parameters<Eip2612PermitUtils['buildDaiLikePermitCallData']>;
|
|
38
39
|
};
|
|
39
40
|
export type GetTokenPermitInfoParams = {
|
|
40
|
-
spender: string;
|
|
41
|
-
tokenAddress: string;
|
|
42
41
|
chainId: number;
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
config: Config;
|
|
43
|
+
publicClient: PublicClient;
|
|
44
|
+
spender: string;
|
|
45
|
+
tokenAddress: Address;
|
|
45
46
|
amount?: bigint;
|
|
47
|
+
minGasLimit?: bigint | undefined;
|
|
46
48
|
};
|
|
47
49
|
export {};
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { JsonRpcProvider } from '@ethersproject/providers';
|
|
2
|
-
import { Wallet } from '@ethersproject/wallet';
|
|
3
1
|
import { AbiInput, AbiItem, EIP712TypedData, ProviderConnector } from '@1inch/permit-signed-approvals-utils';
|
|
2
|
+
import { Address, WalletClient, PublicClient, Hex } from 'viem';
|
|
4
3
|
export declare class PermitProviderConnector implements ProviderConnector {
|
|
5
|
-
private
|
|
6
|
-
private
|
|
7
|
-
constructor(
|
|
8
|
-
contractEncodeABI(abi: AbiItem[], address: string | null, methodName: string, methodParams: unknown[]):
|
|
9
|
-
signTypedData(
|
|
10
|
-
ethCall(contractAddress:
|
|
11
|
-
decodeABIParameter<T>(type: string, hex:
|
|
12
|
-
decodeABIParameters<T>(types: AbiInput[], hex:
|
|
4
|
+
private publicClient;
|
|
5
|
+
private walletClient;
|
|
6
|
+
constructor(publicClient: PublicClient, walletClient: WalletClient);
|
|
7
|
+
contractEncodeABI(abi: AbiItem[], address: string | null, methodName: string, methodParams: unknown[]): Hex;
|
|
8
|
+
signTypedData(walletAddress: Address, typedData: EIP712TypedData, _typedDataHash: string): Promise<Hex>;
|
|
9
|
+
ethCall(contractAddress: Address, callData: Hex): Promise<string>;
|
|
10
|
+
decodeABIParameter<T>(type: string, hex: Hex): T;
|
|
11
|
+
decodeABIParameters<T>(types: AbiInput[], hex: Hex): T;
|
|
13
12
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { BuildDaiLikePermitCallDataParams, BuildEip2612PermitCallDataParams } from '../types';
|
|
2
|
-
|
|
3
|
-
export declare function
|
|
2
|
+
import { Hex } from 'viem';
|
|
3
|
+
export declare function buildEip2612PermitCallData({ eip2612Utils, callDataParams, }: BuildEip2612PermitCallDataParams): Promise<Hex>;
|
|
4
|
+
export declare function buildDaiLikePermitCallData({ eip2612Utils, callDataParams, }: BuildDaiLikePermitCallDataParams): Promise<Hex>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Address } from 'viem';
|
|
2
|
+
import { Config } from 'wagmi';
|
|
3
|
+
export declare function getEip712Domain(tokenAddress: Address, chainId: number, config: Config): Promise<Eip712Domain>;
|
|
3
4
|
type Eip5267Return = {
|
|
4
5
|
fields: string;
|
|
5
6
|
name?: string;
|
package/utils/getTokenName.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Address } from 'viem';
|
|
2
|
+
import { Config } from 'wagmi';
|
|
3
|
+
export declare function getTokenName(tokenAddress: Address, chainId: number, config: Config): Promise<string>;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { Address } from 'viem';
|
|
2
|
+
import { Config } from 'wagmi';
|
|
3
|
+
export declare function getTokenPermitVersion(tokenAddress: Address, config: Config, index?: number): Promise<string>;
|
package/utils/getContract.d.ts
DELETED