Skip to content

Commit

Permalink
feat: use rpc provider if no connected provider is available
Browse files Browse the repository at this point in the history
  • Loading branch information
juanmahidalgo committed Dec 22, 2023
1 parent b14061a commit 9602c42
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 89 deletions.
169 changes: 84 additions & 85 deletions webapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"dcl-catalyst-commons": "^9.0.1",
"decentraland-connect": "^5.1.0",
"decentraland-crypto-fetch": "^1.0.3",
"decentraland-dapps": "^16.21.1",
"decentraland-dapps": "^16.21.4",
"decentraland-transactions": "^1.50.0",
"decentraland-ui": "^4.30.7",
"dotenv": "^10.0.0",
Expand Down
13 changes: 10 additions & 3 deletions webapp/src/modules/ens/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { ethers } from 'ethers'
import { getSigner } from 'decentraland-dapps/dist/lib/eth'
import { ChainId } from '@dcl/schemas'
import { getNetworkProvider } from 'decentraland-dapps/dist/lib/eth'
import { getConfiguration } from 'decentraland-connect/dist/configuration'
import { DCLRegistrar__factory } from '../../contracts/factories/DCLRegistrar__factory'
import { config } from '../../config'

Expand All @@ -20,10 +22,15 @@ export async function isNameAvailable(name: string): Promise<boolean> {
if (!name) {
return false
}
const signer: ethers.Signer = await getSigner()
const chainId = Number(config.get('CHAIN_ID')) as ChainId
const networkProvider = await getNetworkProvider(chainId)
const configuration = getConfiguration()
const provider = networkProvider
? new ethers.providers.Web3Provider(networkProvider)
: new ethers.providers.JsonRpcProvider(configuration.network.urls[chainId])
const contractDCLRegistrar = DCLRegistrar__factory.connect(
REGISTRAR_ADDRESS,
signer
provider
)
return contractDCLRegistrar.available(name)
}
Expand Down

0 comments on commit 9602c42

Please sign in to comment.