0.0.1-RC.3 • Published 7 months ago

alfetopito-permit-utils v0.0.1-RC.3

Weekly downloads
-
License
-
Repository
-
Last release
7 months ago

@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.

0.0.1-RC.3

7 months ago

0.0.1-RC.2

7 months ago

0.0.1-RC.1

7 months ago

0.0.1-RC.0

7 months ago