-
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.
Merge remote-tracking branch 'origin/main' into develop
- Loading branch information
Showing
6 changed files
with
62 additions
and
15 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
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
21 changes: 21 additions & 0 deletions
21
apps/cowswap-frontend/src/modules/permit/hooks/useGetPermitInfo.ts
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,21 @@ | ||
import { useAtomValue } from 'jotai' | ||
import { useCallback } from 'react' | ||
|
||
import { SupportedChainId } from '@cowprotocol/cow-sdk' | ||
|
||
import { permittableTokensAtom } from '../state/permittableTokensAtom' | ||
import { IsTokenPermittableResult } from '../types' | ||
|
||
/** | ||
* Returns a callback for getting PermitInfo for a given token | ||
* | ||
* Assumes permit info was already checked and cached. | ||
*/ | ||
export function useGetPermitInfo(chainId: SupportedChainId): (tokenAddress: string) => IsTokenPermittableResult { | ||
const permittableTokens = useAtomValue(permittableTokensAtom) | ||
|
||
return useCallback( | ||
(tokenAddress: string) => permittableTokens[chainId][tokenAddress.toLowerCase()], | ||
[chainId, permittableTokens] | ||
) | ||
} |
11 changes: 4 additions & 7 deletions
11
apps/cowswap-frontend/src/modules/permit/utils/buildPermitCallData.ts
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
7 changes: 7 additions & 0 deletions
7
apps/cowswap-frontend/src/modules/permit/utils/fixTokenName.ts
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,7 @@ | ||
export function fixTokenName(tokenName: string): string { | ||
// TODO: this is ugly and I'm not happy with it either | ||
// It'll probably go away when the tokens overhaul is implemented | ||
// For now, this is a problem for favourite tokens cached locally with the hardcoded name for USDC token | ||
// Using the wrong name breaks the signature. | ||
return tokenName === 'USD//C' ? 'USD Coin' : tokenName | ||
} |
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