From 1e36ac416555f1c90cec06faeacc5d971d363bf1 Mon Sep 17 00:00:00 2001 From: Bhupesh-MS Date: Fri, 21 Jun 2024 16:21:54 +0530 Subject: [PATCH 1/3] added input field validations --- package.json | 1 + src/components/App.tsx | 5 +- src/components/ConfigureProfile.tsx | 19 ++++-- src/components/Docker.tsx | 6 +- src/components/Env.tsx | 2 +- src/components/PublishProfile.tsx | 2 +- src/hooks/useConfiguration.tsx | 50 ++++++++++++++-- src/index.css | 23 +++++++- src/utils/ensUtils.ts | 92 +++++++++++++++++++++++++++++ yarn.lock | 33 +++++++++++ 10 files changed, 216 insertions(+), 17 deletions(-) create mode 100644 src/utils/ensUtils.ts diff --git a/package.json b/package.json index 56c09ac..2ef8037 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "@types/react-dom": "^18.3.0", "axios": "^1.7.2", "buffer": "npm:buffer@6.0.3", + "ethers": "^6.13.1", "react": "^18.3.0", "react-dom": "^18.3.0", "react-scripts": "5.0.1", diff --git a/src/components/App.tsx b/src/components/App.tsx index b3aab99..928b31c 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -12,7 +12,7 @@ const App = () => { const { address, isConnected, handleEnsChange, handleRpcChange, handleUrlChange, createConfigAndProfile, profileAndKeysCreated, storeEnv, profile, writeContractIsPending, publishProfile, - ensResolverFound, hash, writeContractError } = useConfiguration(); + ensResolverFound, hash, writeContractError, ensError, rpcError, urlError } = useConfiguration(); return (
@@ -30,6 +30,9 @@ const App = () => { handleEnsChange={handleEnsChange} handleUrlChange={handleUrlChange} handleRpcChange={handleRpcChange} + ensError={ensError} + rpcError={rpcError} + urlError={urlError} createConfigAndProfile={createConfigAndProfile} isConnected={isConnected} /> diff --git a/src/components/ConfigureProfile.tsx b/src/components/ConfigureProfile.tsx index 8db84e4..a44170b 100644 --- a/src/components/ConfigureProfile.tsx +++ b/src/components/ConfigureProfile.tsx @@ -3,35 +3,44 @@ interface ConfigureProfileProps { handleUrlChange: (event: React.ChangeEvent) => void, handleRpcChange: (event: React.ChangeEvent) => void, createConfigAndProfile: () => void, + ensError: string | null, + rpcError: string | null, + urlError: string | null, isConnected: boolean, } export function ConfigureProfile(props: ConfigureProfileProps) { return
-

Step 1: create config and profile

+

Step 1: Create config and profile

To create the profile and config file, please connect the account the delivery service will use. Also, we need this information: -

+

ENS: props.handleEnsChange(event)}> + * (the ens domain your delivery service will use, e.g. myPersonalDeliveryService.eth)

-

+ {props.ensError && {props.ensError}} +

URL: props.handleUrlChange(event)}> + * (the url your delivery service will use, e.g. https://my-personal-delivery-service.com)

-

+ {props.urlError && {props.urlError}} +

RPC: props.handleRpcChange(event)}> + * (the rpc url your delivery service will use, e.g. https://mainnet.infura.io/v3/f02ijf0283i0jq0jdoisjd07829)

+ {props.rpcError && {props.rpcError}}
-
diff --git a/src/components/Docker.tsx b/src/components/Docker.tsx index d84737e..2f15a4a 100644 --- a/src/components/Docker.tsx +++ b/src/components/Docker.tsx @@ -19,16 +19,16 @@ export function Docker() { and save it as docker-compose.yml
  • - move all 3 files (docker-compose.yml, .env, config.yml) into a + Move all 3 files (docker-compose.yml, .env, config.yml) into a directory on the machine you want to run the service on (e.g. a web server)
  • - in this directory, execute `docker-compose up -d` to start the + In this directory, execute `docker-compose up -d` to start the delivery service
  • - visit <yourUrl>:8083/hello with your web browser to get a + Visit <yourUrl>:8083/hello with your web browser to get a first friendly response from your delivery service
  • diff --git a/src/components/Env.tsx b/src/components/Env.tsx index 4fea6fd..f8b52c2 100644 --- a/src/components/Env.tsx +++ b/src/components/Env.tsx @@ -7,7 +7,7 @@ interface EnvProps { export function Env(props: EnvProps) { return
    -

    Step 2: store .env and config.yml

    +

    Step 2: Store .env and config.yml

    {" "} diff --git a/src/components/PublishProfile.tsx b/src/components/PublishProfile.tsx index 503c595..711da23 100644 --- a/src/components/PublishProfile.tsx +++ b/src/components/PublishProfile.tsx @@ -12,7 +12,7 @@ interface PublishProfileProps { export default function PublishProfile(props: PublishProfileProps) { return
    -

    Step 3: publish profile

    +

    Step 3: Publish profile

    Now, please connect the account that controls the ENS domain so we can publish the profile.

    diff --git a/src/hooks/useConfiguration.tsx b/src/hooks/useConfiguration.tsx index df8bf93..c677acd 100644 --- a/src/hooks/useConfiguration.tsx +++ b/src/hooks/useConfiguration.tsx @@ -2,10 +2,12 @@ import { useEffect, useState } from "react"; import { namehash, normalize } from "viem/ens"; import { resolverAbi } from "../utils/resolverAbi"; import { configureEnv } from "../utils/configureEnv"; -import { useAccount, useEnsResolver, useSignMessage, useWriteContract } from "wagmi"; +import { useAccount, useChainId, useEnsResolver, useSignMessage, useWriteContract } from "wagmi"; import { DeliveryServiceProfile, DeliveryServiceProfileKeys } from "@dm3-org/dm3-lib-profile"; import { createKeyPair, createSigningKeyPair, createStorageKey } from "@dm3-org/dm3-lib-crypto"; import { DELIVERY_SERVICE, ENV_FILE_NAME, KEY_CREATION_MESSAGE, ZERO_ADDRESS } from "../utils/constants"; +import { areAllPropertiesValid } from "../utils/ensUtils"; +import { ethers } from "ethers"; export const useConfiguration = () => { @@ -15,6 +17,8 @@ export const useConfiguration = () => { const [url, setUrl] = useState(""); const [rpc, setRpc] = useState(""); + const [provider, setProvider] = useState(null); + const [keys, setKeys] = useState(); const [profile, setProfile] = useState(); @@ -22,7 +26,13 @@ export const useConfiguration = () => { const [keyCreationMessage, setKeyCreationMessage] = useState(""); const [profileAndKeysCreated, setProfileAndKeysCreated] = useState(false); - const { isConnected, address } = useAccount(); + const [ensError, setEnsError] = useState(null); + const [urlError, setUrlError] = useState(null); + const [rpcError, setRpcError] = useState(null); + + const { isConnected, address, connector } = useAccount(); + + const chainConnected = useChainId(); const { data: signMessageData, @@ -48,22 +58,29 @@ export const useConfiguration = () => { event: React.ChangeEvent ) => { setEnsInput(event.target.value); + setEnsError(null); }; const handleUrlChange = ( event: React.ChangeEvent ) => { setUrl(event.target.value); + setUrlError(null); }; const handleRpcChange = ( event: React.ChangeEvent ) => { setRpc(event.target.value); + setRpcError(null); }; - const createConfigAndProfile = () => { - // todo: check if ens is valid + const createConfigAndProfile = async () => { + const isValid = await areAllPropertiesValid(ensInput, setEnsError, rpc, setRpcError, url, + setUrlError, address as string, provider); + if (!isValid) { + return; + } setEnsDomain(ensInput); const dsEnsAndUrl = JSON.stringify({ ens: ensDomain, @@ -116,7 +133,26 @@ export const useConfiguration = () => { } } - useEffect(() => { }, [address]); + const initializeProvider = () => { + if (chainConnected === 11155111) { + const sepoliaProvider = new ethers.JsonRpcProvider(url, { + name: 'sepolia', + chainId: 11155111, + ensAddress: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e', + }); + setProvider(sepoliaProvider); + } else { + const mainnetProvider = new ethers.JsonRpcProvider(url, { + name: 'mainnet', + chainId: 1, + }); + setProvider(mainnetProvider); + } + } + + useEffect(() => { + initializeProvider(); + }, [address]); useEffect(() => { if (isError && !ensResolverIsLoading) { @@ -173,6 +209,10 @@ export const useConfiguration = () => { publishProfile, hash, writeContractError, + ensError, + urlError, + rpcError, + connector }; } \ No newline at end of file diff --git a/src/index.css b/src/index.css index f3bf2d3..ba63c25 100644 --- a/src/index.css +++ b/src/index.css @@ -25,6 +25,27 @@ body { justify-content: flex-end; } -.ds-container{ +.ds-container { padding: 1rem; +} + +.config-profile-para { + margin-bottom: 0.3rem; +} + +.error { + color: #C30F1A; + font-size: 14px; +} + +.env-btn { + margin-top: 1rem; + cursor: pointer; +} + +.mandatory { + color: #C30F1A; + font-size: 14px; + margin-left: 0.2rem; + margin-right: 0.2rem; } \ No newline at end of file diff --git a/src/utils/ensUtils.ts b/src/utils/ensUtils.ts new file mode 100644 index 0000000..5fbaca2 --- /dev/null +++ b/src/utils/ensUtils.ts @@ -0,0 +1,92 @@ +import { isValidName, ethers, JsonRpcProvider } from "ethers"; + +const validateEns = async (provider: JsonRpcProvider, ens: string, setEnsError: Function, account: string): Promise => { + if (!isValidName(ens)) { + setEnsError("Invalid ENS name"); + return false; + } + const isEnsNameOwned = await isEnsNameRegistered(provider, ens, account, setEnsError); + if (!isEnsNameOwned) { + return false; + } + return true; +} + +const validateRpc = (rpc: string, setRpcError: Function): boolean => { + try { + if (!rpc.length) { + setRpcError("Invalid RPC endpoint"); + return false; + } + + new ethers.JsonRpcProvider(rpc); + return true; + } catch (error) { + console.log("Error in RPC node : ", error); + setRpcError("Invalid RPC endpoint"); + return false; + } +} + +const validateUrl = (url: string, setUrlError: Function): boolean => { + try { + const validatedUrl = new URL(url); + if (validatedUrl.protocol !== "https:") { + setUrlError("URL endpoint must be https"); + return false; + } + return true; + } catch (error) { + setUrlError("Invalid URL endpoint"); + return false; + } +} + +export const areAllPropertiesValid = async ( + ens: string, + setEnsError: Function, + rpc: string, + setRpcError: Function, + url: string, + setUrlError: Function, + account: string, + provider: JsonRpcProvider +): Promise => { + const isEnsValid = await validateEns(provider, ens, setEnsError, account); + const isRpcValid = validateRpc(rpc, setRpcError); + const isUrlValid = validateUrl(url, setUrlError); + return (isEnsValid && isRpcValid && isUrlValid); +} + +const isEnsNameRegistered = async ( + mainnetProvider: JsonRpcProvider, + ensName: string, + account: string, + setEnsError: Function +): Promise => { + + try { + const resolver = await mainnetProvider.getResolver(ensName); + + if (resolver === null) { + setEnsError("Resolver not found"); + return false; + } + + console.log(resolver); + + const owner = await mainnetProvider.resolveName(ensName); + + if (!owner || owner.toLowerCase() !== account.toLowerCase()) { + setEnsError("You are not the owner/manager of this name"); + return false; + } + + return true; + } catch (error) { + console.log("Error in validating ens name : ", error); + setEnsError("You are not the owner/manager of this name"); + return false; + } + +}; \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 5a5ab0f..92470c1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12,6 +12,11 @@ resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.10.0.tgz#d2a39395c587e092d77cbbc80acf956a54f38bf7" integrity sha512-nA9XHtlAkYfJxY7bce8DcN7eKxWWCWkU+1GR9d+U6MbNpfwQp8TI7vqOsBsMcHoT4mBu2kypKoSKnghEzOOq5Q== +"@adraffy/ens-normalize@1.10.1": + version "1.10.1" + resolved "https://registry.yarnpkg.com/@adraffy/ens-normalize/-/ens-normalize-1.10.1.tgz#63430d04bd8c5e74f8d7d049338f1cd9d4f02069" + integrity sha512-96Z2IP3mYmF1Xg2cDm8f1gWGf/HUVedQ3FMifV4kG/PQ4yEP51xDtRAEfhVNt5f/uzpNkZHwWQuUcu6D6K+Ekw== + "@alloc/quick-lru@^5.2.0": version "5.2.0" resolved "https://registry.yarnpkg.com/@alloc/quick-lru/-/quick-lru-5.2.0.tgz#7bf68b20c0a350f936915fcae06f58e32007ce30" @@ -3135,6 +3140,11 @@ dependencies: undici-types "~5.26.4" +"@types/node@18.15.13": + version "18.15.13" + resolved "https://registry.yarnpkg.com/@types/node/-/node-18.15.13.tgz#f64277c341150c979e42b00e4ac289290c9df469" + integrity sha512-N+0kuo9KgrUQ1Sn/ifDXsvg0TTleP7rIy4zOBGECxAljqvqfqpTfzx0Q1NUedOixRMBfe2Whhb056a42cWs26Q== + "@types/node@^18.19.3": version "18.19.36" resolved "https://registry.yarnpkg.com/@types/node/-/node-18.19.36.tgz#c9861e84727e07ecf79a5ff6d0e14f91bab2b478" @@ -3903,6 +3913,11 @@ aes-js@3.0.0: resolved "https://registry.yarnpkg.com/aes-js/-/aes-js-3.0.0.tgz#e21df10ad6c2053295bcbb8dab40b09dbea87e4d" integrity sha512-H7wUZRn8WpTq9jocdxQ2c8x2sKo9ZVmzfRE13GiNJXfp7NcKYEdvl3vspKjXox6RIG2VtaRe4JFvxG4rqp2Zuw== +aes-js@4.0.0-beta.5: + version "4.0.0-beta.5" + resolved "https://registry.yarnpkg.com/aes-js/-/aes-js-4.0.0-beta.5.tgz#8d2452c52adedebc3a3e28465d858c11ca315873" + integrity sha512-G965FqalsNyrPqgEGON7nIx1e/OVENSgiEIzyC63haUMuvNnwIgIjMs52hlTCKhkBny7A2ORNlfY9Zu+jmGk1Q== + agent-base@6: version "6.0.2" resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-6.0.2.tgz#49fff58577cfee3f37176feab4c22e00f86d7f77" @@ -6436,6 +6451,19 @@ ethers@5.7.2: "@ethersproject/web" "5.7.1" "@ethersproject/wordlists" "5.7.0" +ethers@^6.13.1: + version "6.13.1" + resolved "https://registry.yarnpkg.com/ethers/-/ethers-6.13.1.tgz#2b9f9c7455cde9d38b30fe6589972eb083652961" + integrity sha512-hdJ2HOxg/xx97Lm9HdCWk949BfYqYWpyw4//78SiwOLgASyfrNszfMUNB2joKjvGUdwhHfaiMMFFwacVVoLR9A== + dependencies: + "@adraffy/ens-normalize" "1.10.1" + "@noble/curves" "1.2.0" + "@noble/hashes" "1.3.2" + "@types/node" "18.15.13" + aes-js "4.0.0-beta.5" + tslib "2.4.0" + ws "8.17.1" + event-target-shim@^5.0.0: version "5.0.1" resolved "https://registry.yarnpkg.com/event-target-shim/-/event-target-shim-5.0.1.tgz#5d4d3ebdf9583d63a5333ce2deb7480ab2b05789" @@ -11900,6 +11928,11 @@ tslib@1.14.1, tslib@^1.8.1: resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00" integrity sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg== +tslib@2.4.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.0.tgz#7cecaa7f073ce680a05847aa77be941098f36dc3" + integrity sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ== + tslib@^2.0.0, tslib@^2.0.3, tslib@^2.1.0, tslib@^2.3.1: version "2.6.3" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.3.tgz#0438f810ad7a9edcde7a241c3d80db693c8cbfe0" From bb127cf9142c9e393d32904f6ed31c9fc76e3a81 Mon Sep 17 00:00:00 2001 From: Bhupesh-MS Date: Fri, 21 Jun 2024 18:26:54 +0530 Subject: [PATCH 2/3] fixed input validation of ens name --- package.json | 1 + src/components/App.tsx | 6 +- src/components/ConfigureProfile.tsx | 23 +++- src/hooks/useConfiguration.tsx | 41 +++---- src/utils/ensUtils.ts | 61 +++++++---- yarn.lock | 161 ++++++++++++++++++++++++++-- 6 files changed, 236 insertions(+), 57 deletions(-) diff --git a/package.json b/package.json index 2ef8037..d43fdf1 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "dependencies": { "@dm3-org/dm3-lib-crypto": "^1.3.0", "@dm3-org/dm3-lib-profile": "^1.3.0", + "@ensdomains/ensjs": "^3.7.0", "@rainbow-me/rainbowkit": "^2.1.1", "@tanstack/react-query": "^5.28.4", "@types/jest": "^29.5.2", diff --git a/src/components/App.tsx b/src/components/App.tsx index 928b31c..a6dcfc9 100644 --- a/src/components/App.tsx +++ b/src/components/App.tsx @@ -12,7 +12,8 @@ const App = () => { const { address, isConnected, handleEnsChange, handleRpcChange, handleUrlChange, createConfigAndProfile, profileAndKeysCreated, storeEnv, profile, writeContractIsPending, publishProfile, - ensResolverFound, hash, writeContractError, ensError, rpcError, urlError } = useConfiguration(); + ensResolverFound, hash, writeContractError, ensError, rpcError, urlError, + ensInput, rpc, url } = useConfiguration(); return (

    @@ -30,6 +31,9 @@ const App = () => { handleEnsChange={handleEnsChange} handleUrlChange={handleUrlChange} handleRpcChange={handleRpcChange} + ens={ensInput} + url={url} + rpc={rpc} ensError={ensError} rpcError={rpcError} urlError={urlError} diff --git a/src/components/ConfigureProfile.tsx b/src/components/ConfigureProfile.tsx index a44170b..5d4ec86 100644 --- a/src/components/ConfigureProfile.tsx +++ b/src/components/ConfigureProfile.tsx @@ -1,4 +1,7 @@ interface ConfigureProfileProps { + ens: string, + rpc: string, + url: string, handleEnsChange: (event: React.ChangeEvent) => void, handleUrlChange: (event: React.ChangeEvent) => void, handleRpcChange: (event: React.ChangeEvent) => void, @@ -11,13 +14,18 @@ interface ConfigureProfileProps { export function ConfigureProfile(props: ConfigureProfileProps) { + const isDisabled = (!props.isConnected || !props.ens.length || !props.url.length || !props.rpc.length) + ? true : false; + return

    Step 1: Create config and profile

    To create the profile and config file, please connect the account the delivery service will use. Also, we need this information:

    ENS: - props.handleEnsChange(event)}> + props.handleEnsChange(event)} /> * (the ens domain your delivery service will use, e.g. myPersonalDeliveryService.eth) @@ -25,7 +33,9 @@ export function ConfigureProfile(props: ConfigureProfileProps) { {props.ensError && {props.ensError}}

    URL: - props.handleUrlChange(event)}> + props.handleUrlChange(event)} /> * (the url your delivery service will use, e.g. https://my-personal-delivery-service.com) @@ -33,14 +43,19 @@ export function ConfigureProfile(props: ConfigureProfileProps) { {props.urlError && {props.urlError}}

    RPC: - props.handleRpcChange(event)}> + props.handleRpcChange(event)} /> * (the rpc url your delivery service will use, e.g. https://mainnet.infura.io/v3/f02ijf0283i0jq0jdoisjd07829)

    {props.rpcError && {props.rpcError}}
    -
    diff --git a/src/hooks/useConfiguration.tsx b/src/hooks/useConfiguration.tsx index c677acd..80e4501 100644 --- a/src/hooks/useConfiguration.tsx +++ b/src/hooks/useConfiguration.tsx @@ -2,12 +2,11 @@ import { useEffect, useState } from "react"; import { namehash, normalize } from "viem/ens"; import { resolverAbi } from "../utils/resolverAbi"; import { configureEnv } from "../utils/configureEnv"; +import { areAllPropertiesValid } from "../utils/ensUtils"; import { useAccount, useChainId, useEnsResolver, useSignMessage, useWriteContract } from "wagmi"; import { DeliveryServiceProfile, DeliveryServiceProfileKeys } from "@dm3-org/dm3-lib-profile"; import { createKeyPair, createSigningKeyPair, createStorageKey } from "@dm3-org/dm3-lib-crypto"; import { DELIVERY_SERVICE, ENV_FILE_NAME, KEY_CREATION_MESSAGE, ZERO_ADDRESS } from "../utils/constants"; -import { areAllPropertiesValid } from "../utils/ensUtils"; -import { ethers } from "ethers"; export const useConfiguration = () => { @@ -17,8 +16,6 @@ export const useConfiguration = () => { const [url, setUrl] = useState(""); const [rpc, setRpc] = useState(""); - const [provider, setProvider] = useState(null); - const [keys, setKeys] = useState(); const [profile, setProfile] = useState(); @@ -30,10 +27,9 @@ export const useConfiguration = () => { const [urlError, setUrlError] = useState(null); const [rpcError, setRpcError] = useState(null); + const chainId = useChainId(); const { isConnected, address, connector } = useAccount(); - const chainConnected = useChainId(); - const { data: signMessageData, error, @@ -77,7 +73,7 @@ export const useConfiguration = () => { const createConfigAndProfile = async () => { const isValid = await areAllPropertiesValid(ensInput, setEnsError, rpc, setRpcError, url, - setUrlError, address as string, provider); + setUrlError, address as string, chainId); if (!isValid) { return; } @@ -133,25 +129,15 @@ export const useConfiguration = () => { } } - const initializeProvider = () => { - if (chainConnected === 11155111) { - const sepoliaProvider = new ethers.JsonRpcProvider(url, { - name: 'sepolia', - chainId: 11155111, - ensAddress: '0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e', - }); - setProvider(sepoliaProvider); - } else { - const mainnetProvider = new ethers.JsonRpcProvider(url, { - name: 'mainnet', - chainId: 1, - }); - setProvider(mainnetProvider); - } - } - + // clears all input field & error on change of account useEffect(() => { - initializeProvider(); + console.log("Account changed : ", address); + setEnsInput(""); + setRpc(""); + setUrl(""); + setEnsError(null); + setRpcError(null); + setUrlError(null); }, [address]); useEffect(() => { @@ -212,7 +198,10 @@ export const useConfiguration = () => { ensError, urlError, rpcError, - connector + connector, + ensInput, + url, + rpc }; } \ No newline at end of file diff --git a/src/utils/ensUtils.ts b/src/utils/ensUtils.ts index 5fbaca2..ff409d1 100644 --- a/src/utils/ensUtils.ts +++ b/src/utils/ensUtils.ts @@ -1,26 +1,42 @@ -import { isValidName, ethers, JsonRpcProvider } from "ethers"; +import { isValidName, ethers } from "ethers"; +import { createPublicClient, http } from 'viem'; +import { addEnsContracts } from '@ensdomains/ensjs'; +import { getOwner } from '@ensdomains/ensjs/public'; +import { mainnet, sepolia, optimism } from 'viem/chains'; -const validateEns = async (provider: JsonRpcProvider, ens: string, setEnsError: Function, account: string): Promise => { +const validateEns = async (ens: string, setEnsError: Function, account: string, chainId: number): Promise => { if (!isValidName(ens)) { setEnsError("Invalid ENS name"); return false; } - const isEnsNameOwned = await isEnsNameRegistered(provider, ens, account, setEnsError); + + const isEnsNameOwned = await isAccountOwnerOfEnsName(ens, account, setEnsError, chainId); + if (!isEnsNameOwned) { return false; } + return true; } const validateRpc = (rpc: string, setRpcError: Function): boolean => { try { + if (!rpc.length) { setRpcError("Invalid RPC endpoint"); return false; } + const validatedUrl = new URL(rpc); + + if (validatedUrl.protocol !== "https:") { + setRpcError("RPC endpoint must be https"); + return false; + } + new ethers.JsonRpcProvider(rpc); return true; + } catch (error) { console.log("Error in RPC node : ", error); setRpcError("Invalid RPC endpoint"); @@ -30,12 +46,16 @@ const validateRpc = (rpc: string, setRpcError: Function): boolean => { const validateUrl = (url: string, setUrlError: Function): boolean => { try { + const validatedUrl = new URL(url); + if (validatedUrl.protocol !== "https:") { setUrlError("URL endpoint must be https"); return false; } + return true; + } catch (error) { setUrlError("Invalid URL endpoint"); return false; @@ -50,42 +70,43 @@ export const areAllPropertiesValid = async ( url: string, setUrlError: Function, account: string, - provider: JsonRpcProvider + chainId: number, ): Promise => { - const isEnsValid = await validateEns(provider, ens, setEnsError, account); + const isEnsValid = await validateEns(ens, setEnsError, account, chainId); const isRpcValid = validateRpc(rpc, setRpcError); const isUrlValid = validateUrl(url, setUrlError); return (isEnsValid && isRpcValid && isUrlValid); } -const isEnsNameRegistered = async ( - mainnetProvider: JsonRpcProvider, +const isAccountOwnerOfEnsName = async ( ensName: string, account: string, - setEnsError: Function + setEnsError: Function, + chainId: number, ): Promise => { try { - const resolver = await mainnetProvider.getResolver(ensName); - if (resolver === null) { - setEnsError("Resolver not found"); - return false; - } + const chain = chainId === 1 ? mainnet : (chainId === 10 ? optimism : sepolia); - console.log(resolver); + const client = createPublicClient({ + chain: addEnsContracts(chain), + transport: http(), + }); - const owner = await mainnetProvider.resolveName(ensName); + const result = await getOwner(client, { name: ensName }); - if (!owner || owner.toLowerCase() !== account.toLowerCase()) { - setEnsError("You are not the owner/manager of this name"); - return false; + if (result && result.owner && result.owner.toLowerCase() === account.toLowerCase()) { + console.log("You are not the owner of ens name : ", result) + return true; } - return true; + setEnsError("You are not the owner of this name"); + return false; + } catch (error) { console.log("Error in validating ens name : ", error); - setEnsError("You are not the owner/manager of this name"); + setEnsError("You are not the owner of this name"); return false; } diff --git a/yarn.lock b/yarn.lock index 92470c1..f001a11 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1336,6 +1336,58 @@ resolved "https://registry.yarnpkg.com/@emotion/hash/-/hash-0.9.1.tgz#4ffb0055f7ef676ebc3a5a91fb621393294e2f43" integrity sha512-gJB6HLm5rYwSLI6PQa+X1t5CFGrv1J1TWG+sOyMCeKz2ojaj6Fnl/rZEspogG+cvqbt4AE/2eIyD2QfLKTBNlQ== +"@ensdomains/address-encoder@1.0.0-rc.3": + version "1.0.0-rc.3" + resolved "https://registry.yarnpkg.com/@ensdomains/address-encoder/-/address-encoder-1.0.0-rc.3.tgz#78a8081bed834661e7fd21a9c9f67f927100fce5" + integrity sha512-8o6zH69rObIqDY4PusEWuN9jvVOct+9jj9AOPO7ifc3ev8nmsly0e8TE1sHkhk0iKFbd3DlSsUnJ+yuRWmdLCQ== + dependencies: + "@noble/curves" "^1.2.0" + "@noble/hashes" "^1.3.2" + "@scure/base" "^1.1.5" + +"@ensdomains/address-encoder@1.1.1": + version "1.1.1" + resolved "https://registry.yarnpkg.com/@ensdomains/address-encoder/-/address-encoder-1.1.1.tgz#5cbec1fc6e2435b109c058426d7c222cb5a5d8de" + integrity sha512-yg7s+suCuKRhaGsgLu57W/jxIs/Lnqs/SU7jT7UwS4ATSnW94jbUCbmyyZ82CQwKsmwaUE8uYvvVb4N6lfz29A== + dependencies: + "@noble/curves" "^1.2.0" + "@noble/hashes" "^1.3.2" + "@scure/base" "^1.1.5" + +"@ensdomains/content-hash@3.1.0-rc.1": + version "3.1.0-rc.1" + resolved "https://registry.yarnpkg.com/@ensdomains/content-hash/-/content-hash-3.1.0-rc.1.tgz#f22220df19be2f60683070a683f5760a9a7134d8" + integrity sha512-OzdkXgdFmduzcJKU4KRkkJkQHnm5p7m7FkX8k+bHOEoOIzc0ueGT/Jay4nnb60wNk1wSHRmzY+hHBMpFDiGReg== + dependencies: + "@ensdomains/address-encoder" "1.0.0-rc.3" + "@noble/curves" "^1.2.0" + "@scure/base" "^1.1.5" + +"@ensdomains/dnsprovejs@^0.5.1": + version "0.5.1" + resolved "https://registry.yarnpkg.com/@ensdomains/dnsprovejs/-/dnsprovejs-0.5.1.tgz#7b09121580d3224736567e680697fe179f0288af" + integrity sha512-nfm4ggpK5YBVwVwLZKF9WPjRGRTL9aUxX2O4pqv/AnQCz3WeGHsW7VhVFLj2s4EoWSzCXwR1E6nuqgUwnH692w== + dependencies: + "@noble/hashes" "^1.3.2" + dns-packet "^5.6.1" + typescript-logging "^1.0.1" + +"@ensdomains/ensjs@^3.7.0": + version "3.7.0" + resolved "https://registry.yarnpkg.com/@ensdomains/ensjs/-/ensjs-3.7.0.tgz#1643b38096dbedb7d1323ad77c5272d1e01f8e68" + integrity sha512-5Pe0q+MLrW1Exj75Jkol17qz16tMg2vbjvv36gZ1LxLpcbtYh5StqmrdPHAuqoqv0rUvaPU/UVcr5N3ds+hrSg== + dependencies: + "@adraffy/ens-normalize" "1.10.1" + "@ensdomains/address-encoder" "1.1.1" + "@ensdomains/content-hash" "3.1.0-rc.1" + "@ensdomains/dnsprovejs" "^0.5.1" + abitype "^1.0.0" + dns-packet "^5.3.1" + graphql "^16.3.0" + graphql-request "6.1.0" + pako "^2.1.0" + traverse "^0.6.8" + "@eslint-community/eslint-utils@^4.2.0": version "4.4.0" resolved "https://registry.yarnpkg.com/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz#a23514e8fb9af1269d5f7788aa556798d61c6b59" @@ -1742,6 +1794,11 @@ "@ethersproject/properties" "^5.7.0" "@ethersproject/strings" "^5.7.0" +"@graphql-typed-document-node/core@^3.2.0": + version "3.2.0" + resolved "https://registry.yarnpkg.com/@graphql-typed-document-node/core/-/core-3.2.0.tgz#5f3d96ec6b2354ad6d8a28bf216a1d97b5426861" + integrity sha512-mB9oAsNCm9aM3/SOv4YtBMqZbYj10R7dkq8byBqxGY/ncFwhf2oQzMV+LCRlWoDSEBJ3COiR1yeDvMtsoOsuFQ== + "@humanwhocodes/config-array@^0.11.14": version "0.11.14" resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.14.tgz#d78e481a039f7566ecc9660b4ea7fe6b1fec442b" @@ -2321,7 +2378,7 @@ dependencies: "@noble/hashes" "1.3.2" -"@noble/curves@1.4.0", "@noble/curves@~1.4.0": +"@noble/curves@1.4.0", "@noble/curves@^1.2.0", "@noble/curves@~1.4.0": version "1.4.0" resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.4.0.tgz#f05771ef64da724997f69ee1261b2417a49522d6" integrity sha512-p+4cb332SFCrReJkCYe8Xzm0OWi4Jji5jVdIZRL/PmacmDkFNw6MrrV+gGpiPxLHbV+zKFRywUWbaseT+tZRXg== @@ -2333,7 +2390,7 @@ resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.2.tgz#6f26dbc8fbc7205873ce3cee2f690eba0d421b39" integrity sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ== -"@noble/hashes@1.4.0", "@noble/hashes@^1.3.1", "@noble/hashes@~1.4.0": +"@noble/hashes@1.4.0", "@noble/hashes@^1.3.1", "@noble/hashes@^1.3.2", "@noble/hashes@~1.4.0": version "1.4.0" resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.4.0.tgz#45814aa329f30e4fe0ba49426f49dfccdd066426" integrity sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg== @@ -2550,7 +2607,7 @@ resolved "https://registry.yarnpkg.com/@safe-global/safe-gateway-typescript-sdk/-/safe-gateway-typescript-sdk-3.21.3.tgz#8088826c34946e34ac1c79556a8e71e3876de0db" integrity sha512-6w0WkSgD0X7s7yhtCNxvCVP5uhDRGoeBWflkRaklntY2/oNiSqPgna3cKhXV+itDLiCBTUpDfytzcF0MbkcM2w== -"@scure/base@^1.1.3", "@scure/base@~1.1.0", "@scure/base@~1.1.2", "@scure/base@~1.1.6": +"@scure/base@^1.1.3", "@scure/base@^1.1.5", "@scure/base@~1.1.0", "@scure/base@~1.1.2", "@scure/base@~1.1.6": version "1.1.7" resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.1.7.tgz#fe973311a5c6267846aa131bc72e96c5d40d2b30" integrity sha512-PPNYBslrLNNUQ/Yad37MHYsNQtK67EhWb6WtSvNLLPo7SdVZgkUjD6Dg+5On7zNwmskf8OX7I7Nx5oN+MIWE0g== @@ -3847,6 +3904,11 @@ abitype@1.0.0: resolved "https://registry.yarnpkg.com/abitype/-/abitype-1.0.0.tgz#237176dace81d90d018bebf3a45cb42f2a2d9e97" integrity sha512-NMeMah//6bJ56H5XRj8QCV4AwuW6hB6zqz2LnhhLdcWVQOsXki6/Pn3APeqxCma62nXIcmZWdu1DlHWS74umVQ== +abitype@^1.0.0: + version "1.0.4" + resolved "https://registry.yarnpkg.com/abitype/-/abitype-1.0.4.tgz#a817ff44860e8a84e9a37ed22aa9b738dbb51dba" + integrity sha512-UivtYZOGJGE8rsrM/N5vdRkUpqEZVmuTumfTuolm7m/6O09wprd958rx8kUBwVAAAhQDveGAgD0GJdBuR8s6tw== + abort-controller@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/abort-controller/-/abort-controller-3.0.0.tgz#eaf54d53b62bae4138e809ca225c8439a6efb392" @@ -5117,7 +5179,7 @@ create-hmac@^1.1.0, create-hmac@^1.1.4, create-hmac@^1.1.7: safe-buffer "^5.0.1" sha.js "^2.4.8" -cross-fetch@^3.1.4: +cross-fetch@^3.1.4, cross-fetch@^3.1.5: version "3.1.8" resolved "https://registry.yarnpkg.com/cross-fetch/-/cross-fetch-3.1.8.tgz#0327eba65fd68a7d119f8fb2bf9334a1a7956f82" integrity sha512-cvA+JwZoU0Xq+h6WkMvAUqPEYy92Obet6UdKLfW60qn99ftItKjB5T+BkyWOFWe2pUyfQ+IJHmpOTznqk1M6Kg== @@ -5637,7 +5699,7 @@ dlv@^1.1.3: resolved "https://registry.yarnpkg.com/dlv/-/dlv-1.1.3.tgz#5c198a8a11453596e751494d49874bc7732f2e79" integrity sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA== -dns-packet@^5.2.2: +dns-packet@^5.2.2, dns-packet@^5.3.1, dns-packet@^5.6.1: version "5.6.1" resolved "https://registry.yarnpkg.com/dns-packet/-/dns-packet-5.6.1.tgz#ae888ad425a9d1478a0674256ab866de1012cf2f" integrity sha512-l4gcSouhcgIKRvyy99RNVOgxXiicE+2jZoNmaNmZ6JXiGajBOJAesk1OBlJuM5k2c+eudGdLxDqXuPCKIj6kpw== @@ -5901,6 +5963,13 @@ error-ex@^1.3.1: dependencies: is-arrayish "^0.2.1" +error-stack-parser@^1.3.6: + version "1.3.6" + resolved "https://registry.yarnpkg.com/error-stack-parser/-/error-stack-parser-1.3.6.tgz#e0e73b93e417138d1cd7c0b746b1a4a14854c292" + integrity sha512-xhuSYd8wLgOXwNgjcPeXMPL/IiiA1Huck+OPvClpJViVNNlJVtM41o+1emp7bPvlCJwCatFX2DWc05/DgfbWzA== + dependencies: + stackframe "^0.3.1" + error-stack-parser@^2.0.6: version "2.1.4" resolved "https://registry.yarnpkg.com/error-stack-parser/-/error-stack-parser-2.1.4.tgz#229cb01cdbfa84440bfa91876285b94680188286" @@ -7051,6 +7120,19 @@ graphemer@^1.4.0: resolved "https://registry.yarnpkg.com/graphemer/-/graphemer-1.4.0.tgz#fb2f1d55e0e3a1849aeffc90c4fa0dd53a0e66c6" integrity sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag== +graphql-request@6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/graphql-request/-/graphql-request-6.1.0.tgz#f4eb2107967af3c7a5907eb3131c671eac89be4f" + integrity sha512-p+XPfS4q7aIpKVcgmnZKhMNqhltk20hfXtkaIkTfjjmiKMJ5xrt5c743cL03y/K7y1rg3WrIC49xGiEQ4mxdNw== + dependencies: + "@graphql-typed-document-node/core" "^3.2.0" + cross-fetch "^3.1.5" + +graphql@^16.3.0: + version "16.8.2" + resolved "https://registry.yarnpkg.com/graphql/-/graphql-16.8.2.tgz#54771c7ff195da913f5e70af8044a026d32eca2a" + integrity sha512-cvVIBILwuoSyD54U4cF/UXDh5yAobhNV/tPygI4lZhgOIJQE/WLWC4waBRb4I6bDVYb3OVx3lfHbaQOEoUD5sg== + gzip-size@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/gzip-size/-/gzip-size-6.0.0.tgz#065367fd50c239c0671cbcbad5be3e2eeb10e462" @@ -9469,6 +9551,11 @@ p-try@^2.0.0: resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== +pako@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/pako/-/pako-2.1.0.tgz#266cc37f98c7d883545d11335c00fbd4062c9a86" + integrity sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug== + param-case@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/param-case/-/param-case-3.0.4.tgz#7d17fe4aa12bde34d4a77d91acfb6219caad01c5" @@ -11330,6 +11417,11 @@ source-map-support@^0.5.6, source-map-support@~0.5.20: buffer-from "^1.0.0" source-map "^0.6.0" +source-map@0.5.6: + version "0.5.6" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412" + integrity sha512-MjZkVp0NHr5+TPihLcadqnlVoGIoWo4IBHptutGh9wI3ttUYvCG26HkSuDi+K6lsZ25syXJXcctwgyVCt//xqA== + source-map@0.6.1, source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.0, source-map@~0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" @@ -11395,6 +11487,13 @@ stable@^0.1.8: resolved "https://registry.yarnpkg.com/stable/-/stable-0.1.8.tgz#836eb3c8382fe2936feaf544631017ce7d47a3cf" integrity sha512-ji9qxRnOVfcuLDySj9qzhGSEFVobyt1kIOSkj1qZzYLzq7Tos/oUUWvotUPQLlrsidqsK6tBH89Bc9kL5zHA6w== +stack-generator@^1.0.7: + version "1.1.0" + resolved "https://registry.yarnpkg.com/stack-generator/-/stack-generator-1.1.0.tgz#36f6a920751a6c10f499a13c32cbb5f51a0b8b25" + integrity sha512-sZDVjwC56vZoo+a5t0LH/1sMQLWYLi/r+Z2ztyCAOhOX3QBP34GWxK0FWf2eU1TIU2CJKCKBAtDZycUh/ZKMlw== + dependencies: + stackframe "^1.0.2" + stack-utils@^2.0.3: version "2.0.6" resolved "https://registry.yarnpkg.com/stack-utils/-/stack-utils-2.0.6.tgz#aaf0748169c02fc33c8232abccf933f54a1cc34f" @@ -11402,11 +11501,33 @@ stack-utils@^2.0.3: dependencies: escape-string-regexp "^2.0.0" -stackframe@^1.3.4: +stackframe@^0.3.1, stackframe@~0.3: + version "0.3.1" + resolved "https://registry.yarnpkg.com/stackframe/-/stackframe-0.3.1.tgz#33aa84f1177a5548c8935533cbfeb3420975f5a4" + integrity sha512-XmoiF4T5nuWEp2x2w92WdGjdHGY/cZa6LIbRsDRQR/Xlk4uW0PAUlH1zJYVffocwKpCdwyuypIp25xsSXEtZHw== + +stackframe@^1.0.2, stackframe@^1.3.4: version "1.3.4" resolved "https://registry.yarnpkg.com/stackframe/-/stackframe-1.3.4.tgz#b881a004c8c149a5e8efef37d51b16e412943310" integrity sha512-oeVtt7eWQS+Na6F//S4kJ2K2VbRlS9D43mAlMyVpVWovy9o+jfgH8O9agzANzaiLjclA0oYzUXEM4PurhSUChw== +stacktrace-gps@^2.4.3: + version "2.4.4" + resolved "https://registry.yarnpkg.com/stacktrace-gps/-/stacktrace-gps-2.4.4.tgz#69c827e9d6d6f41cf438d7f195e2e3cbfcf28c44" + integrity sha512-msFhuMEEklQLUtaJ+GeCDjzUN+PamfHWQiK3C1LnbHjoxSeF5dAxiE+aJkptNMmMNOropGFJ7G3ZT7dPZHgDaQ== + dependencies: + source-map "0.5.6" + stackframe "~0.3" + +stacktrace-js@1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/stacktrace-js/-/stacktrace-js-1.3.1.tgz#67cab2589af5c417b962f7369940277bb3b6a18b" + integrity sha512-b+5voFnXqg9TWdOE50soXL+WuOreYUm1Ukg9U7rzEWGL4+gcVxIcFasNBtOffVX0I1lYqVZj0PZXZvTt5e3YRQ== + dependencies: + error-stack-parser "^1.3.6" + stack-generator "^1.0.7" + stacktrace-gps "^2.4.3" + static-eval@2.0.2: version "2.0.2" resolved "https://registry.yarnpkg.com/static-eval/-/static-eval-2.0.2.tgz#2d1759306b1befa688938454c546b7871f806a42" @@ -11903,6 +12024,15 @@ tr46@~0.0.3: resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a" integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw== +traverse@^0.6.8: + version "0.6.9" + resolved "https://registry.yarnpkg.com/traverse/-/traverse-0.6.9.tgz#76cfdbacf06382d460b76f8b735a44a6209d8b81" + integrity sha512-7bBrcF+/LQzSgFmT0X5YclVqQxtv7TDJ1f8Wj7ibBu/U6BMLeOpUxuZjV7rMc44UtKxlnMFigdhFAIszSX1DMg== + dependencies: + gopd "^1.0.1" + typedarray.prototype.slice "^1.0.3" + which-typed-array "^1.1.15" + tryer@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/tryer/-/tryer-1.0.1.tgz#f2c85406800b9b0f74c9f7465b81eaad241252f8" @@ -12038,6 +12168,25 @@ typedarray-to-buffer@^3.1.5: dependencies: is-typedarray "^1.0.0" +typedarray.prototype.slice@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/typedarray.prototype.slice/-/typedarray.prototype.slice-1.0.3.tgz#bce2f685d3279f543239e4d595e0d021731d2d1a" + integrity sha512-8WbVAQAUlENo1q3c3zZYuy5k9VzBQvp8AX9WOtbvyWlLM1v5JaSRmjubLjzHF4JFtptjH/5c/i95yaElvcjC0A== + dependencies: + call-bind "^1.0.7" + define-properties "^1.2.1" + es-abstract "^1.23.0" + es-errors "^1.3.0" + typed-array-buffer "^1.0.2" + typed-array-byte-offset "^1.0.2" + +typescript-logging@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/typescript-logging/-/typescript-logging-1.0.1.tgz#e0f8157943780cf5943aacd53b04cb73d108a0f9" + integrity sha512-zp28ABme0m5q/nXabBaY9Hv/35N8lMH4FsvhpUO0zVi4vFs3uKlb5br2it61HAZF5k+U0aP6E67j0VD0IzXGpQ== + dependencies: + stacktrace-js "1.3.1" + typescript@5.4.2: version "5.4.2" resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.4.2.tgz#0ae9cebcfae970718474fe0da2c090cad6577372" From b3f1b9cb7bf9a3acefffa656cf22ce90b6517249 Mon Sep 17 00:00:00 2001 From: Bhupesh-MS Date: Fri, 21 Jun 2024 18:28:41 +0530 Subject: [PATCH 3/3] fixed https error message --- src/utils/ensUtils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/ensUtils.ts b/src/utils/ensUtils.ts index ff409d1..f68c93e 100644 --- a/src/utils/ensUtils.ts +++ b/src/utils/ensUtils.ts @@ -30,7 +30,7 @@ const validateRpc = (rpc: string, setRpcError: Function): boolean => { const validatedUrl = new URL(rpc); if (validatedUrl.protocol !== "https:") { - setRpcError("RPC endpoint must be https"); + setRpcError("RPC endpoint must start with https"); return false; } @@ -50,7 +50,7 @@ const validateUrl = (url: string, setUrlError: Function): boolean => { const validatedUrl = new URL(url); if (validatedUrl.protocol !== "https:") { - setUrlError("URL endpoint must be https"); + setUrlError("URL endpoint must start with https"); return false; }