alfetopito-permit-utils
TypeScript icon, indicating that this package has built-in type declarations

0.0.1-RC.3 • Public • Published

@cowprotocol/permit-utils

Collection of utils for handling token permits.

Installation

yarn add @cowprotocol/permit-utils

Usage

getTokenPermitInfo

import { getTokenPermitInfo } from "@cowprotocol/permit-utils"

const permitInfo = await getTokenPermitInfo({
  spender, tokenAddress, tokenName, chainId, provider
})

getPermitUtilsInstance

import { getPermitUtilsInstance } from "@cowprotocol/permit-utils"

// Using the a static account defined in the library
const staticEip2612PermitUtils = getPermitUtilsInstance(chainId, provider)

// Using a provided account address
const accountEip2612PermitUtils = getPermitUtilsInstance(chainId, provider, account)

generatePermitHook

import { generatePermitHook } from "@cowprotocol/permit-utils"

const hookData = await generatePermitHook({
  chainId,
  inputToken,
  spender,
  provider,
  permitInfo,
  eip2162Utils,
  account,
  nonce
})

checkIsCallDataAValidPermit

import { checkIsCallDataAValidPermit } from "@cowprotocol/permit-utils"

const isCallDataAValidPermit = await checkIsCallDataAValidPermit(
  account,
  chainId,
  eip2612Utils, 
  tokenAddress,
  tokenName,
  callData,
  permitInfo
)

Building

Run nx build permit-utils to build the library.

Running unit tests

Run nx test permit-utils to execute the unit tests via Jest.

Readme

Keywords

none

Package Sidebar

Install

npm i alfetopito-permit-utils

Weekly Downloads

0

Version

0.0.1-RC.3

License

none

Unpacked Size

4.7 MB

Total Files

15

Last publish

Collaborators

  • alfetopito