Skip to content

Commit f576be1

Browse files
authored
Support essential dapps in DeFi dropdown (#3218)
1 parent f5f133b commit f576be1

File tree

7 files changed

+21
-8
lines changed

7 files changed

+21
-8
lines changed

configs/envs/.env.eth

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ NEXT_PUBLIC_BEACON_CHAIN_VALIDATOR_URL_TEMPLATE=https://beaconcha.in/validator/{
2424
NEXT_PUBLIC_CONTRACT_CODE_IDES=[{'title':'Remix IDE','url':'https://remix.ethereum.org/?address={hash}&blockscout={domain}','icon_url':'https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/ide-icons/remix.png'}]
2525
NEXT_PUBLIC_CONTRACT_INFO_API_HOST=https://contracts-info.services.blockscout.com
2626
NEXT_PUBLIC_DATA_AVAILABILITY_ENABLED=true
27-
NEXT_PUBLIC_DEFI_DROPDOWN_ITEMS=[{'text':'Swap','icon':'swap','url':'https://eth.blockscout.com/essential-dapps/swap?utm_source=defi-dropdown-&utm_medium=swap'},{'text':'Revoke','icon':'integration/partial','dappId':'revokescout'}, {'text': 'Multisend', 'icon': 'token', 'url': 'https://eth.blockscout.com/essential-dapps/multisend?utm_source=defi-dropdown-multisend&utm_medium=multisend'}]
27+
NEXT_PUBLIC_DEFI_DROPDOWN_ITEMS=[{'text':'Swap','icon':'swap','dappId':'swap','isEssentialDapp':true},{'text':'Revoke','icon':'integration/partial','dappId':'revoke','isEssentialDapp':true},{'text':'Multisend','icon':'navigation/tokens','dappId':'multisend','isEssentialDapp':true}]
2828
NEXT_PUBLIC_DEX_POOLS_ENABLED=true
2929
NEXT_PUBLIC_FEATURED_NETWORKS=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/featured-networks/eth.json
3030
NEXT_PUBLIC_FEATURED_NETWORKS_ALL_LINK=https://chains.blockscout.com/
@@ -42,7 +42,7 @@ NEXT_PUBLIC_MARKETPLACE_BANNER_CONTENT_URL=https://gist.githubusercontent.com/ma
4242
NEXT_PUBLIC_MARKETPLACE_BANNER_LINK_URL=https://eth.blockscout.com/apps/revokescout?chainId=1
4343
NEXT_PUBLIC_MARKETPLACE_CATEGORIES_URL=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/marketplace-categories/default.json
4444
NEXT_PUBLIC_MARKETPLACE_ENABLED=true
45-
NEXT_PUBLIC_MARKETPLACE_ESSENTIAL_DAPPS_CONFIG={'swap': {'url': 'https://swapscout.vercel.app', 'chains': ['1', '10', '30', '100', '122', '130', '137', '324', '480', '1135', '1514', '1868', '8453', '13371', '42161', '42220', '57073', '534352', '11155111', '1313161554', '1923', '42793', '59144'], 'fee': '0.004', 'integrator': 'blockscout'}, 'multisend': {'chains': ['1', '10', '30', '100', '122', '130', '137', '324', '480', '1135', '1514', '1868', '8453', '13371', '42161', '42220', '57073', '534352', '11155111', '1313161554', '59144', '7000'], 'posthogKey': 'phc_7O4WGsecqqDO1PeaKayHAxUWN1PjheOmQCiDxEMcmkx', 'posthogHost': 'https://us.i.posthog.com'}}
45+
NEXT_PUBLIC_MARKETPLACE_ESSENTIAL_DAPPS_CONFIG={'swap': {'url': 'https://swapscout.vercel.app', 'chains': ['1', '10', '30', '100', '122', '130', '137', '324', '480', '1135', '1514', '1868', '8453', '13371', '42161', '42220', '57073', '534352', '11155111', '1313161554', '1923', '42793', '59144'], 'fee': '0.004', 'integrator': 'blockscout'}, 'multisend': {'chains': ['1', '10', '30', '100', '122', '130', '137', '324', '480', '1135', '1514', '1868', '8453', '13371', '42161', '42220', '57073', '534352', '11155111', '1313161554', '59144', '7000'], 'posthogKey': 'phc_7O4WGsecqqDO1PeaKayHAxUWN1PjheOmQCiDxEMcmkx', 'posthogHost': 'https://us.i.posthog.com'}, 'revoke': {'chains': ['1', '10', '30', '100', '122', '130', '324', '480', '8453', '13371', '42161', '42220', '57073', '534352', '1868', '7887', '1514', '245022934', '61', '148', '314', '137', '7000', '42793', '4326']}}
4646
NEXT_PUBLIC_MARKETPLACE_SUBMIT_FORM=https://airtable.com/appiy5yijZpMMSKjT/shr6uMGPKjj1DK7NL
4747
NEXT_PUBLIC_MARKETPLACE_SUGGEST_IDEAS_FORM=https://airtable.com/appiy5yijZpMMSKjT/pag3t82DUCyhGRZZO/form
4848
NEXT_PUBLIC_METADATA_SERVICE_API_HOST=https://metadata.services.blockscout.com

deploy/tools/envs-validator/schemas/features/defiDropdown.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const deFiDropdownItemSchema: yup.ObjectSchema<DeFiDropdownItem> = yup
99
text: yup.string().required(),
1010
icon: yup.string<IconName>(),
1111
dappId: yup.string(),
12+
isEssentialDapp: yup.boolean(),
1213
url: yup.string().test(urlTest),
1314
})
1415
.test('oneOfRequired', 'NEXT_PUBLIC_DEFI_DROPDOWN_ITEMS: Either dappId or url is required', function(value) {
@@ -21,4 +22,4 @@ export const defiDropdownSchema = yup.object({
2122
.transform(replaceQuotes)
2223
.json()
2324
.of(deFiDropdownItemSchema),
24-
});
25+
});

docs/ENVS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ If the feature is enabled, a single button or a dropdown (if more than 1 item is
913913

914914
| Variable | Type| Description | Compulsoriness | Default value | Example value | Version |
915915
| --- | --- | --- | --- | --- | --- | --- |
916-
| NEXT_PUBLIC_DEFI_DROPDOWN_ITEMS | `[{ text: string; icon?: string; dappId?: string, url?: string }]` | An array of dropdown items containing the button text, icon name and dappId in Dappscout or an external url | - | - | `[{'text':'Swap','icon':'swap','dappId':'uniswap'},{'text':'Payment link','icon':'payment_link','dappId':'peanut-protocol'}]` | v1.31.0+ |
916+
| NEXT_PUBLIC_DEFI_DROPDOWN_ITEMS | `[{ text: string; icon?: string; dappId?: string, url?: string, isEssentialDapp?: boolean }]` | An array of dropdown items containing the button text, icon name and dappId in Dappscout or an external url | - | - | `[{'text':'Swap','icon':'swap','dappId':'swap','isEssentialDapp':true},{'text':'Payment link','icon':'payment_link','dappId':'peanut-protocol'}]` | v1.31.0+ |
917917

918918
&nbsp;
919919

types/client/deFiDropdown.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ export type DeFiDropdownItem = {
44
text: string;
55
icon?: IconName;
66
} & (
7-
{ dappId: string; url?: never } |
8-
{ url: string; dappId?: never }
7+
{ dappId: string; isEssentialDapp?: boolean; url?: never } |
8+
{ url: string; dappId?: never; isEssentialDapp?: never }
99
);

ui/pages/MarketplaceEssentialDapp.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ import getQueryParamString from 'lib/router/getQueryParamString';
99
import Multisend from 'ui/marketplace/essentialDapps/multisend/Multisend';
1010
import Revoke from 'ui/marketplace/essentialDapps/revoke/Revoke';
1111
import Swap from 'ui/marketplace/essentialDapps/swap/Swap';
12+
import useAutoConnectWallet from 'ui/marketplace/useAutoConnectWallet';
1213
import PageTitle from 'ui/shared/Page/PageTitle';
1314

1415
const feature = config.features.marketplace;
1516

1617
const EssentialDapp = () => {
1718
const router = useRouter();
19+
useAutoConnectWallet();
20+
1821
const id = getQueryParamString(router.query.id);
1922

2023
let title = null;

ui/snippets/topBar/DeFiDropdown.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ const DeFiDropdown = () => {
5959
<Link
6060
href={
6161
items[0].dappId ?
62-
route({ pathname: '/apps/[id]', query: { id: items[0].dappId, action: 'connect' } }) :
62+
route({
63+
pathname: items[0].isEssentialDapp ? '/essential-dapps/[id]' : '/apps/[id]',
64+
query: { id: items[0].dappId, action: 'connect' },
65+
}) :
6366
items[0].url
6467
}
6568
target={ items[0].dappId ? '_self' : '_blank' }

ui/snippets/topBar/DeFiDropdownItem.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,13 @@ type Props = {
1515
const DeFiDropdownItem = ({ item }: Props) => {
1616
return (
1717
<Link
18-
href={ item.dappId ? route({ pathname: '/apps/[id]', query: { id: item.dappId, action: 'connect' } }) : item.url }
18+
href={ item.dappId ?
19+
route({
20+
pathname: item.isEssentialDapp ? '/essential-dapps/[id]' : '/apps/[id]',
21+
query: { id: item.dappId, action: 'connect' },
22+
}) :
23+
item.url
24+
}
1925
external={ !item.dappId }
2026
w="100%"
2127
h="34px"

0 commit comments

Comments
 (0)