-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(permit): refactor permit-utils package (#3258)
* feat: add permit-utils lib Generated using `nx g @nx/js:lib` command * chore: remove default files * feat: add utils to permit-utils package * feat: remove utils from modules/permit in favor of permit-utils pkg * chore: move PermitProviderConnector to utils * chore: updated eslint rules similar to main app * chore: remove external dependency on DAI * chore: remove types that are not used in the lib * chore: remove dependency on GP_VAULT_RELAYER * chore: remove dependency on @cowprotocol/common-utils * refactor: sorting imports * chore: update project name * chore: add readme * refactor: move buildPermitCallData to utils * refactor: rename checkIsTokenPermittable to getTokenPermitInfo * chore: move IsTokenPermittableResult back to modules/permit * chore: set permit-utils pkg version to 0.0.1-RC.0 * refactor: export fns individually rather than everything from the file * fix: typo on project name 🤦 * chore: fix config with `nx repair` * fix: project name has to match path I think. Now it builds * chore: pick the version from package.json when publishing a package * chore: add otp arg to all projects * chore: copy README on publish to dist folder so it gets added to npm * chore: remove dependency on cow-sdk package * fix: must have macrosPlugin as part of vite.config * chore: change provider type to JsonRpcProvider * chore: expose GetTokenPermitIntoResult * chore: remove stuff added automatically which are not needed * fix: js code style * chore: remove commands which are not relevant in the NPM context * chore: add somewhat complete usage example * chore: remove another dep added automatically jest-environment-node * chore: import AbiInput from @1inch lib instead of directly from web3 * chore: remove @ethersproject/bignumber dep. Already part of ethers * refactor: removed extra comma * refactor: remove dependency on @uniswap/core * chore: exclude all external dependencies from the build * chore: change package type from commonjs to module * chore: add required dependencies to lib package.json * feat: set different entry points for different module styles * chore: update some package dependencies * fix: exclusions MUST not be the whole /node_modules/ as it breaks the generated bundle * fix: no longer using Token type on permit-utils * fix: uploaded local registry path by mistake
- Loading branch information
1 parent
08c9b8b
commit 28ea672
Showing
40 changed files
with
937 additions
and
258 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,11 @@ | ||
import { DAI } from '@cowprotocol/common-const' | ||
import { SupportedChainId } from '@cowprotocol/cow-sdk' | ||
import { MaxUint256 } from '@ethersproject/constants' | ||
import { Wallet } from '@ethersproject/wallet' | ||
|
||
import ms from 'ms.macro' | ||
|
||
import { TradeType } from '../trade' | ||
|
||
// PK used only for signing permit requests for quoting and identifying token 'permittability' | ||
// Do not use or try to send funds to it. Or do. It'll be your funds 🤷 | ||
const PERMIT_PK = '0xc58a2a421ca71ca57ae698f1c32feeb0b0ccb434da0b8089d88d80fb918f3f9d' // address: 0xFf65D1DfCF256cf4A8D5F2fb8e70F936606B7474 | ||
|
||
export const PERMIT_SIGNER = new Wallet(PERMIT_PK) | ||
|
||
export const PERMIT_GAS_LIMIT_MIN: Record<SupportedChainId, number> = { | ||
1: 55_000, | ||
100: 55_000, | ||
5: 36_000, | ||
} | ||
|
||
export const DEFAULT_PERMIT_GAS_LIMIT = '80000' | ||
|
||
export const DEFAULT_PERMIT_VALUE = MaxUint256.toString() | ||
|
||
export const DEFAULT_PERMIT_DURATION = ms`5 years` | ||
|
||
export const ORDER_TYPE_SUPPORTS_PERMIT: Record<TradeType, boolean> = { | ||
[TradeType.SWAP]: true, | ||
[TradeType.LIMIT_ORDER]: true, | ||
[TradeType.ADVANCED_ORDERS]: false, | ||
} | ||
|
||
export const PENDING_ORDER_PERMIT_CHECK_INTERVAL = ms`1min` | ||
|
||
// DAI's mainnet contract (https://etherscan.io/address/0x6b175474e89094c44da98b954eedeac495271d0f#readContract) returns | ||
// `1` for the version, while when calling the contract method returns `2`. | ||
// Also, if we use the version returned by the contract, it simply doesn't work | ||
// Thus, do not call it for DAI. | ||
// TODO: figure out whether more tokens behave the same way | ||
export const TOKENS_TO_SKIP_VERSION = new Set([DAI.address.toLowerCase()]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { getJestProjects } from '@nx/jest' | ||
|
||
export default { | ||
projects: getJestProjects(), | ||
} |
Oops, something went wrong.