Skip to content

Commit

Permalink
[core-v2.15.3-alpha.2]: Fix - Add config to disable Unstoppable Domai…
Browse files Browse the repository at this point in the history
…ns resolution (#1556)

* Add config to disable Unstoppable Domains resolution

* Remove commented code

* Clean up uns import

* Add check to getUns func

* revert check at account level
  • Loading branch information
Adamj1232 authored Feb 28, 2023
1 parent 626e5ae commit f794937
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 13 deletions.
8 changes: 8 additions & 0 deletions docs/src/routes/docs/[...3]modules/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,14 @@ type ConnectModalOptions = {
* Defaults to `https://ethereum.org/en/wallets/find-wallet/#main-content`
*/
iDontHaveAWalletLink?: string
/**
* Define support for Unstoppable Domains resolutions
* after a user connects. Similar to ens, uns can be used for users who
* have minted an Unstoppable Domain and associated it with their wallet.
* ENS resolution takes precedent over UNS
* Defaults to true
*/
disableUDResolution?: boolean
}
```
Expand Down
2 changes: 1 addition & 1 deletion docs/src/routes/docs/[...4]wallets/formatic.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Fortmatic

Wallet module for connecting Ledger hardware wallets to web3-onboard
Wallet module for connecting Fortmatic hardware wallets to web3-onboard

### Install

Expand Down
8 changes: 8 additions & 0 deletions packages/core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,14 @@ type ConnectModalOptions = {
* Defaults to `https://ethereum.org/en/wallets/find-wallet/#main-content`
*/
iDontHaveAWalletLink?: string
/**
* Define support for Unstoppable Domains resolutions
* after a user connects. Similar to ens, uns can be used for users who
* have minted an Unstoppable Domain and associated it with their wallet.
* ENS resolution takes precedent over UNS
* Defaults to false
*/
disableUDResolution?: boolean
}
```
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3-onboard/core",
"version": "2.15.3-alpha.1",
"version": "2.15.3-alpha.2",
"description": "Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardized spec compliant web3 providers for all supported wallets, framework agnostic modern javascript UI with code splitting, CSS customization, multi-chain and multi-account support, reactive wallet state subscriptions and real-time transaction state change notifications.",
"keywords": [
"Ethereum",
Expand Down
13 changes: 8 additions & 5 deletions packages/core/src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { validEnsChain } from './utils.js'
import disconnect from './disconnect.js'
import { state } from './store/index.js'
import { getBNMulitChainSdk } from './services.js'
import { Resolution } from '@unstoppabledomains/resolution'

import type {
ChainId,
Expand Down Expand Up @@ -384,15 +383,19 @@ export async function getUns(
address: Address,
chain: Chain
): Promise<Uns | null> {
const { connect } = state.get()

// check if address is valid ETH address before attempting to resolve
// chain we don't recognize and don't have a rpcUrl for requests
if (!utils.isAddress(address) || !chain) return null

const resolutionInstance = new Resolution()
if (connect.disableUDResolution || !utils.isAddress(address) || !chain)
return null

try {
const name = await resolutionInstance.reverse(address)
let uns = null
const { Resolution } = await import('@unstoppabledomains/resolution')

const resolutionInstance = new Resolution()
const name = await resolutionInstance.reverse(address)

if (name) {
uns = {
Expand Down
8 changes: 8 additions & 0 deletions packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,14 @@ export type ConnectModalOptions = {
* Defaults to `https://ethereum.org/en/wallets/find-wallet/#main-content`
*/
iDontHaveAWalletLink?: string
/**
* Define support for Unstoppable Domains resolutions
* after a user connects. Similar to ens, uns can be used for users who
* have minted an Unstoppable Domain and associated it with their wallet.
* ENS resolution takes precedent over UNS
* Defaults to false
*/
disableUDResolution?: boolean
}

export type CommonPositions =
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ const connectModalOptions = Joi.object({
showSidebar: Joi.boolean(),
disableClose: Joi.boolean(),
autoConnectLastWallet: Joi.boolean(),
iDontHaveAWalletLink: Joi.string()
iDontHaveAWalletLink: Joi.string(),
disableUDResolution: Joi.boolean()
})

const containerElements = Joi.object({
Expand Down
2 changes: 1 addition & 1 deletion packages/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"webpack-dev-server": "4.7.4"
},
"dependencies": {
"@web3-onboard/core": "^2.15.3-alpha.1",
"@web3-onboard/core": "^2.15.3-alpha.2",
"@web3-onboard/coinbase": "^2.1.4",
"@web3-onboard/transaction-preview": "^2.0.4",
"@web3-onboard/dcent": "^2.2.3",
Expand Down
1 change: 1 addition & 0 deletions packages/demo/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@
],
connect: {
// disableClose: true,
// disableUDResolution: true,
autoConnectLastWallet: true
},
appMetadata: {
Expand Down
4 changes: 2 additions & 2 deletions packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3-onboard/react",
"version": "2.6.5-alpha.1",
"version": "2.6.5-alpha.2",
"description": "A collection of React hooks for integrating Web3-Onboard in to React and Next.js projects. Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardised spec compliant web3 providers for all supported wallets, modern javascript UI with code splitting, CSS customization, multi-chain and multi-account support, reactive wallet state subscriptions and real-time transaction state change notifications.",
"keywords": [
"Ethereum",
Expand Down Expand Up @@ -62,7 +62,7 @@
"typescript": "^4.5.5"
},
"dependencies": {
"@web3-onboard/core": "^2.15.3-alpha.1",
"@web3-onboard/core": "^2.15.3-alpha.2",
"@web3-onboard/common": "^2.2.3",
"use-sync-external-store": "1.0.0"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/vue/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3-onboard/vue",
"version": "2.5.5-alpha.1",
"version": "2.5.5-alpha.12",
"description": "A collection of Vue Composables for integrating Web3-Onboard in to a Vue or Nuxt project. Web3-Onboard makes it simple to connect Ethereum hardware and software wallets to your dapp. Features standardized spec compliant web3 providers for all supported wallets, modern javascript UI with code splitting, CSS customization, multi-chain and multi-account support, reactive wallet state subscriptions and real-time transaction state change notifications.",
"keywords": [
"Ethereum",
Expand Down Expand Up @@ -63,7 +63,7 @@
"@vueuse/core": "^8.4.2",
"@vueuse/rxjs": "^8.2.0",
"@web3-onboard/common": "^2.2.3",
"@web3-onboard/core": "^2.15.3-alpha.1",
"@web3-onboard/core": "^2.15.3-alpha.2",
"vue-demi": "^0.12.4"
},
"peerDependencies": {
Expand Down

0 comments on commit f794937

Please sign in to comment.