+ Can't find a hook that you like?{' '} + + Add a custom hook + +
++ This app/hook can only be used as a post-hook and cannot be added as a pre-hook. +
, + ) + } else if (conditions.position === 'pre' && !isPreHook) { + setManifestError( ++ This app/hook can only be used as a pre-hook and cannot be added as a post-hook. +
, + ) + } else { + setManifestError(null) + setDappInfo({ + ...dapp, + type: HookDappType.IFRAME, + url: input, + }) + } + } + } else { + setManifestError('Manifest does not contain "cow_hook_dapp" property.') + } + }) + .catch((error) => { + if (!isRequestRelevant) return + + console.error(error) + setManifestError('Can not fetch the manifest.json') + }) + .finally(() => { + if (!isRequestRelevant) return + + setLoading(false) + }) + + return () => { + isRequestRelevant = false + } + }, [input]) + + return null +} diff --git a/apps/cowswap-frontend/src/modules/hooksStore/pure/AddCustomHookForm/index.tsx b/apps/cowswap-frontend/src/modules/hooksStore/pure/AddCustomHookForm/index.tsx new file mode 100644 index 0000000000..5f43f8b616 --- /dev/null +++ b/apps/cowswap-frontend/src/modules/hooksStore/pure/AddCustomHookForm/index.tsx @@ -0,0 +1,142 @@ +import { ReactElement, useCallback, useEffect, useState } from 'react' + +import { uriToHttp } from '@cowprotocol/common-utils' +import { ButtonOutlined, ButtonPrimary, InlineBanner, Loader, SearchInput } from '@cowprotocol/ui' + +import { ExternalSourceAlert } from 'common/pure/ExternalSourceAlert' + +import { ExternalDappLoader } from './CustomDappLoader' +import { Wrapper } from './styled' + +import { HookDappIframe } from '../../types/hooks' +import { HookDappDetails } from '../HookDappDetails' + +interface AddCustomHookFormProps { + isPreHook: boolean + isSmartContractWallet: boolean | undefined + addHookDapp(dapp: HookDappIframe): void + children: ReactElement | null +} + +export function AddCustomHookForm({ addHookDapp, children, isPreHook, isSmartContractWallet }: AddCustomHookFormProps) { + const [input, setInput] = useState
+ Adding this app/hook grants it access to your wallet actions and trading information. Ensure you
+ understand the implications.
+
+ Always review wallet requests carefully before approving.
+
{descriptionShort}
@@ -31,7 +40,17 @@ export function HookListItem({ dapp, onSelect, onOpenDetails }: HookListItemProp
- By adding this list you are implicitly trusting that the data is correct. Anyone can create a list, including - creating fake versions of existing lists and lists that claim to represent projects that do not have one. -
-- If you purchase a token from this list, you may not be able to sell it back. -
-+ By adding this list you are implicitly trusting that the data is correct. Anyone can create a list, + including creating fake versions of existing lists and lists that claim to represent projects that do not + have one. +
++ If you purchase a token from this list, you may not be able to sell it back. +
+ > +Please, specify valid order first
- if (!proxyAddress) returnPlease, connect wallet first
+ if (!proxyAddress) returnPlease connect your wallet to continue
+ if (!orderParams) returnPlease specify your swap order before proceeding
return (