UNPKG

@kryptogo/kryptogokit-sdk-react

Version:

KryptogoKit offers a comprehensive web3 wallet solution with seamless KryptoGO Auth integration and multi-wallet connection support. Designed for users. Built for developers.

48 lines (47 loc) 2.66 kB
import { Hex } from 'viem'; import { type UseWalletClientReturnType } from 'wagmi'; export type PermitSignature = { r: Hex; s: Hex; v: Hex; }; export type SignPermitProps = { /** Address of the token to approve */ contractAddress: Hex; /** Name of the token to approve. * Corresponds to the `name` method on the ERC-20 contract. Please note this must match exactly byte-for-byte */ erc20Name: string; /** Owner of the tokens. Usually the currently connected address. */ ownerAddress: Hex; /** Address to grant allowance to */ spenderAddress: Hex; /** Expiration of this approval, in SECONDS */ deadline: bigint; /** Numerical chainId of the token contract */ chainId: number; /** Defaults to 1. Some tokens need a different version, check the [PERMIT INFORMATION](https://github.com/vacekj/wagmi-permit/blob/main/PERMIT.md) for more information */ permitVersion?: string; /** Permit nonce for the specific address and token contract. You can get the nonce from the `nonces` method on the token contract. */ nonce: bigint; }; export type Eip2612Props = SignPermitProps & { /** Amount to approve */ value: bigint; }; /** * Signs a permit for a given ERC-2612 ERC20 token using the specified parameters. * * @param {WalletClient} walletClient - Wallet client to invoke for signing the permit message * @param {SignPermitProps} props - The properties required to sign the permit. * @param {string} props.contractAddress - The address of the ERC20 token contract. * @param {string} props.erc20Name - The name of the ERC20 token. * @param {number} props.value - The amount of the ERC20 to approve. * @param {string} props.ownerAddress - The address of the token holder. * @param {string} props.spenderAddress - The address of the token spender. * @param {number} props.deadline - The permit expiration timestamp in seconds. * @param {number} props.nonce - The nonce of the address on the specified ERC20. * @param {number} props.chainId - The chain ID for which the permit will be valid. * @param {number} props.permitVersion - The version of the permit (optional, defaults to "1"). */ export declare const signPermit: (walletClient: UseWalletClientReturnType["data"], { contractAddress, erc20Name, ownerAddress, spenderAddress, value, deadline, nonce, chainId, permitVersion, }: Eip2612Props) => Promise<PermitSignature>; export declare const signPermitDai: (walletClient: UseWalletClientReturnType["data"], { contractAddress, erc20Name, ownerAddress, spenderAddress, deadline, nonce, chainId, permitVersion, }: SignPermitProps) => Promise<PermitSignature>;