-
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(hooks-store): add dapp id to hook callData (#4920)
- Loading branch information
Showing
26 changed files
with
286 additions
and
227 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
34 changes: 0 additions & 34 deletions
34
apps/cowswap-frontend/src/modules/hooksStore/dapps/AirdropHookApp/hook.tsx
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
apps/cowswap-frontend/src/modules/hooksStore/dapps/BuildHookApp/hook.tsx
This file was deleted.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
apps/cowswap-frontend/src/modules/hooksStore/dapps/ClaimGnoHookApp/const.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 |
---|---|---|
@@ -1 +1,9 @@ | ||
import { SBCDepositContract as SBCDepositContractType, SBCDepositContractAbi } from '@cowprotocol/abis' | ||
import { Contract } from '@ethersproject/contracts' | ||
|
||
export const SBC_DEPOSIT_CONTRACT_ADDRESS = '0x0B98057eA310F4d31F2a452B414647007d1645d9' | ||
|
||
export const SBCDepositContract = new Contract( | ||
SBC_DEPOSIT_CONTRACT_ADDRESS, | ||
SBCDepositContractAbi, | ||
) as SBCDepositContractType |
29 changes: 0 additions & 29 deletions
29
apps/cowswap-frontend/src/modules/hooksStore/dapps/ClaimGnoHookApp/hook.tsx
This file was deleted.
Oops, something went wrong.
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
16 changes: 0 additions & 16 deletions
16
apps/cowswap-frontend/src/modules/hooksStore/dapps/ClaimGnoHookApp/useSBCDepositContract.ts
This file was deleted.
Oops, something went wrong.
17 changes: 0 additions & 17 deletions
17
apps/cowswap-frontend/src/modules/hooksStore/dapps/PermitHookApp/hook.tsx
This file was deleted.
Oops, something went wrong.
41 changes: 23 additions & 18 deletions
41
apps/cowswap-frontend/src/modules/hooksStore/hookRegistry.tsx
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,21 +1,26 @@ | ||
import { SupportedChainId } from '@cowprotocol/cow-sdk' | ||
import { hookDappsRegistry } from '@cowprotocol/hook-dapp-lib' | ||
|
||
import { AIRDROP_HOOK_APP } from './dapps/AirdropHookApp/hook' | ||
import { PRE_BUILD, POST_BUILD } from './dapps/BuildHookApp/hook' | ||
import { PRE_CLAIM_GNO } from './dapps/ClaimGnoHookApp/hook' | ||
import { PERMIT_HOOK } from './dapps/PermitHookApp/hook' | ||
import { AirdropHookApp } from './dapps/AirdropHookApp' | ||
import { BuildHookApp } from './dapps/BuildHookApp' | ||
import { ClaimGnoHookApp } from './dapps/ClaimGnoHookApp' | ||
import { PermitHookApp } from './dapps/PermitHookApp' | ||
import { HookDapp } from './types/hooks' | ||
|
||
export const PRE_HOOK_REGISTRY: Record<SupportedChainId, HookDapp[]> = { | ||
[SupportedChainId.MAINNET]: [PRE_BUILD], | ||
[SupportedChainId.GNOSIS_CHAIN]: [PRE_CLAIM_GNO, PRE_BUILD], | ||
[SupportedChainId.SEPOLIA]: [PRE_BUILD, PERMIT_HOOK, AIRDROP_HOOK_APP], | ||
[SupportedChainId.ARBITRUM_ONE]: [PRE_BUILD], | ||
} | ||
|
||
export const POST_HOOK_REGISTRY: Record<SupportedChainId, HookDapp[]> = { | ||
[SupportedChainId.MAINNET]: [POST_BUILD], | ||
[SupportedChainId.GNOSIS_CHAIN]: [POST_BUILD], | ||
[SupportedChainId.SEPOLIA]: [POST_BUILD, AIRDROP_HOOK_APP, PERMIT_HOOK], | ||
[SupportedChainId.ARBITRUM_ONE]: [POST_BUILD], | ||
} | ||
export const ALL_HOOK_DAPPS = [ | ||
{ | ||
...hookDappsRegistry.BUILD_CUSTOM_HOOK, | ||
component: (props) => <BuildHookApp {...props} />, | ||
}, | ||
{ | ||
...hookDappsRegistry.CLAIM_GNO_FROM_VALIDATORS, | ||
component: (props) => <ClaimGnoHookApp {...props} />, | ||
}, | ||
{ | ||
...hookDappsRegistry.PERMIT_TOKEN, | ||
component: (props) => <PermitHookApp {...props} />, | ||
}, | ||
{ | ||
...hookDappsRegistry.CLAIM_COW_AIRDROP, | ||
component: (props) => <AirdropHookApp {...props} />, | ||
}, | ||
] as HookDapp[] |
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
10 changes: 4 additions & 6 deletions
10
apps/cowswap-frontend/src/modules/hooksStore/hooks/useAllHookDapps.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 |
---|---|---|
@@ -1,17 +1,15 @@ | ||
import { useMemo } from 'react' | ||
|
||
import { useWalletInfo } from '@cowprotocol/wallet' | ||
|
||
import { useCustomHookDapps } from './useCustomHookDapps' | ||
import { useInternalHookDapps } from './useInternalHookDapps' | ||
|
||
import { POST_HOOK_REGISTRY, PRE_HOOK_REGISTRY } from '../hookRegistry' | ||
import { HookDapp } from '../types/hooks' | ||
|
||
export function useAllHookDapps(isPreHook: boolean): HookDapp[] { | ||
const { chainId } = useWalletInfo() | ||
const internalHookDapps = useInternalHookDapps(isPreHook) | ||
const customHookDapps = useCustomHookDapps(isPreHook) | ||
|
||
return useMemo(() => { | ||
return (isPreHook ? PRE_HOOK_REGISTRY : POST_HOOK_REGISTRY)[chainId].concat(customHookDapps) | ||
}, [customHookDapps, chainId]) | ||
return internalHookDapps.concat(customHookDapps) | ||
}, [customHookDapps, internalHookDapps]) | ||
} |
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
Oops, something went wrong.