Skip to content

Commit c3e10b0

Browse files
authored
Enhancement: Remove built in UnstoppableDomain resolution, create unstoppable-resolution package for opt in support (#1641)
* Add unstoppable resolution package and remove built in ability * Add new package commit and docs * Fix some docs links * Remove deprecated prop from demo init * Merge in dev
1 parent 8fe8450 commit c3e10b0

File tree

20 files changed

+229
-65
lines changed

20 files changed

+229
-65
lines changed

.circleci/config.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,12 @@ jobs:
375375
working_directory: ~/web3-onboard-monorepo/packages/taho
376376
steps:
377377
- node-build-steps
378+
build-unstoppable-resolution:
379+
docker:
380+
- image: cimg/node:16.13.1
381+
working_directory: ~/web3-onboard-monorepo/packages/unstoppable-resolution
382+
steps:
383+
- node-build-steps
378384

379385
# Build staging/Alpha releases
380386
build-staging-core:
@@ -587,6 +593,12 @@ jobs:
587593
working_directory: ~/web3-onboard-monorepo/packages/taho
588594
steps:
589595
- node-staging-build-steps
596+
build-staging-unstoppable-resolution:
597+
docker:
598+
- image: cimg/node:16.13.1
599+
working_directory: ~/web3-onboard-monorepo/packages/unstoppable-resolution
600+
steps:
601+
- node-staging-build-steps
590602

591603
workflows:
592604
version: 2
@@ -801,3 +813,9 @@ workflows:
801813
<<: *deploy_production_filters
802814
- build-staging-taho:
803815
<<: *deploy_staging_filters
816+
unstoppable-resolution:
817+
jobs:
818+
- build-unstoppable-resolution:
819+
<<: *deploy_production_filters
820+
- build-staging-unstoppable-resolution:
821+
<<: *deploy_staging_filters

.github/ISSUE_TEMPLATE/BUG.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
name: Bug Report
22
description: File a bug report
3-
title: '[Bug]: '
43
labels: [bug]
54
assignees:
65
- taylorjdawson

docs/src/routes/docs/[...3]modules/core.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,10 @@ type ConnectModalOptions = {
229229
*/
230230
wheresMyWalletLink?: string
231231
/**
232-
* Define support for Unstoppable Domains resolutions
233-
* after a user connects. Similar to ens, uns can be used for users who
234-
* have minted an Unstoppable Domain and associated it with their wallet.
235-
* ENS resolution takes precedent over UNS
236-
* Defaults to false
232+
* @deprecated Has no effect unless `@web3-onboard/unstoppable-resolution`
233+
* package has been added and passed into the web3-onboard initialization
234+
* In this case remove the `@web3-onboard/unstoppable-resolution` package
235+
* to remove unstoppableDomain resolution support
237236
*/
238237
disableUDResolution?: boolean
239238
}
@@ -429,7 +428,8 @@ unsubscribe()
429428
```
430429

431430
##### **Notifications as Toast Messages**
432-
The Notifications messages can also be used to send fully customized Dapp toast messages and updated. Check out the [customNotifications API docs for examples and code snippets](#customnotification)
431+
432+
The Notifications messages can also be used to send fully customized Dapp toast messages and updated. Check out the [customNotifications API docs for examples and code snippets](#customnotification)
433433

434434
```ts
435435
type NotifyOptions = {
@@ -640,6 +640,7 @@ const onboard = Onboard({
640640
```
641641

642642
---
643+
643644
## Connecting a Wallet
644645

645646
To initiate a user to select and connect a wallet you can call the `connectWallet` function on an initialized Onboard instance. It will return a `Promise` that will resolve when the user either successfully connects a wallet, or when they dismiss the UI. The resolved value from the promise will be the latest state of the `wallets` array. The order of the wallets array is last to first, so the most recently selected wallet will be the first item in the array and can be thought of as the "primary wallet". If no wallet was selected, then the `wallets` array will have the same state as it had before calling `connectWallet`.
@@ -1016,7 +1017,7 @@ The `customNotification` method also returns a `dismiss` method that is called w
10161017

10171018
#### **preflightNotifications**
10181019

1019-
Notify can be used to deliver standard notifications along with preflight updates by passing a `PreflightNotificationsOptions` object to the `preflightNotifications` API action.
1020+
Notify can be used to deliver standard notifications along with preflight updates by passing a `PreflightNotificationsOptions` object to the `preflightNotifications` API action.
10201021

10211022
<img src="{notifyPreflightImg}" alt="Preflight notifications image"/>
10221023

@@ -1033,6 +1034,7 @@ Preflight event types include:
10331034
This API call will return a promise that resolves to the transaction hash (if `sendTransaction` resolves the transaction hash and is successful), the internal notification id (if no `sendTransaction` function is provided) or return nothing if an error occurs or `sendTransaction` is not provided or doesn't resolve to a string.
10341035

10351036
Example:
1037+
10361038
```typescript copy
10371039
const balanceValue = Object.values(balance)[0]
10381040
// if using ethers v6 this is:
@@ -1544,7 +1546,7 @@ export default config
15441546

15451547
### SvelteKit + Vite
15461548

1547-
Checkout a boilerplate example (here)[https://github.com/blocknative/web3-onboard/tree/develop/examples/with-sveltekit]
1549+
Checkout a boilerplate example [here](https://github.com/blocknative/web3-onboard/tree/develop/examples/with-sveltekit)
15481550

15491551
Add the following dev dependencies:
15501552

@@ -1657,7 +1659,7 @@ See [this github issue](https://github.com/blocknative/web3-onboard/issues/1568#
16571659

16581660
### Vite
16591661

1660-
Checkout a boilerplate example for Vite-React (here)[https://github.com/blocknative/web3-onboard/tree/develop/examples/with-vite-react]
1662+
Checkout a boilerplate example for Vite-React [here](https://github.com/blocknative/web3-onboard/tree/develop/examples/with-vite-react)
16611663

16621664
Add the following dev dependencies:
16631665

@@ -1732,9 +1734,9 @@ build: {
17321734

17331735
### Next.js
17341736

1735-
Checkout a boilerplate example for NextJS v13 (here)[https://github.com/blocknative/web3-onboard/tree/develop/examples/with-nextjs-13]
1737+
Checkout a boilerplate example for NextJS v13 [here](https://github.com/blocknative/web3-onboard/tree/develop/examples/with-nextjs-13)
17361738

1737-
Checkout a boilerplate example for NextJS (here)[https://github.com/blocknative/web3-onboard/tree/develop/examples/with-nextjs]
1739+
Checkout a boilerplate example for NextJS [here](https://github.com/blocknative/web3-onboard/tree/develop/examples/with-nextjs)
17381740

17391741
:::admonition type=note
17401742

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Unstoppable Domains Resolution
2+
3+
A module to add Unstoppable Domain resolution to web3-onboard.
4+
5+
### Install
6+
7+
<Tabs values={['yarn', 'npm']}>
8+
<TabPanel value="yarn">
9+
10+
```sh copy
11+
yarn add @web3-onboard/unstoppable-resolution
12+
```
13+
14+
</TabPanel>
15+
<TabPanel value="npm">
16+
17+
```sh copy
18+
npm install @web3-onboard/unstoppable-resolution
19+
```
20+
21+
</TabPanel>
22+
</Tabs>
23+
24+
### Standalone Setup
25+
26+
```typescript
27+
import Onboard from '@web3-onboard/core'
28+
import unstoppableResolution from '@web3-onboard/unstoppable-resolution'
29+
30+
const onboard = Onboard({
31+
// ... other Onboard options
32+
unstoppableResolution
33+
})
34+
```
35+
36+
## Build Environments
37+
38+
For build env configurations and setups please see the Build Env section [here](/docs/modules/core#build-environments)

packages/core/README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,11 +206,10 @@ type ConnectModalOptions = {
206206
*/
207207
wheresMyWalletLink?: string
208208
/**
209-
* Define support for Unstoppable Domains resolutions
210-
* after a user connects. Similar to ens, uns can be used for users who
211-
* have minted an Unstoppable Domain and associated it with their wallet.
212-
* ENS resolution takes precedent over UNS
213-
* Defaults to false
209+
* @deprecated Has no effect unless `@web3-onboard/unstoppable-resolution`
210+
* package has been added and passed into the web3-onboard initialization
211+
* In this case remove the `@web3-onboard/unstoppable-resolution` package
212+
* to remove unstoppableDomain resolution support
214213
*/
215214
disableUDResolution?: boolean
216215
}

packages/core/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@web3-onboard/core",
3-
"version": "2.16.2",
3+
"version": "2.17.0-alpha.1",
44
"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.",
55
"keywords": [
66
"Ethereum",
@@ -71,6 +71,7 @@
7171
"@typescript-eslint/parser": "^4.31.1",
7272
"@web3-onboard/gas": "^2.1.5",
7373
"@web3-onboard/transaction-preview": "^2.0.5",
74+
"@web3-onboard/unstoppable-resolution": "^2.0.0-alpha.1",
7475
"eslint": "^7.32.0",
7576
"eslint-config-prettier": "^8.3.0",
7677
"eslint-plugin-svelte3": "^3.2.1",
@@ -84,7 +85,6 @@
8485
"typescript": "^4.5.5"
8586
},
8687
"dependencies": {
87-
"@unstoppabledomains/resolution": "^8.0",
8888
"@web3-onboard/common": "^2.3.1",
8989
"bignumber.js": "^9.0.0",
9090
"bnc-sdk": "^4.6.7",

packages/core/src/configuration.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ export let configuration: Configuration = {
99
initialWalletInit: [],
1010
gas: null,
1111
containerElements: { accountCenter: null, connectModal: null },
12-
transactionPreview: null
12+
transactionPreview: null,
13+
unstoppableResolution: null
1314
}
1415

1516
export function updateConfiguration(update: Partial<Configuration>): void {

packages/core/src/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ function init(options: InitOptions): OnboardAPI {
9797
containerElements,
9898
transactionPreview,
9999
theme,
100-
disableFontDownload
100+
disableFontDownload,
101+
unstoppableResolution
101102
} = options
102103

103104
if (containerElements) updateConfiguration({ containerElements })
@@ -205,7 +206,8 @@ function init(options: InitOptions): OnboardAPI {
205206
apiKey,
206207
initialWalletInit: wallets,
207208
gas,
208-
transactionPreview
209+
transactionPreview,
210+
unstoppableResolution
209211
})
210212

211213
if (apiKey && transactionPreview) {

packages/core/src/provider.ts

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { validEnsChain } from './utils.js'
99
import disconnect from './disconnect.js'
1010
import { state } from './store/index.js'
1111
import { getBNMulitChainSdk } from './services.js'
12+
import { configuration } from './configuration.js'
1213

1314
import type {
1415
ChainId,
@@ -26,11 +27,12 @@ import type {
2627
Address,
2728
Balances,
2829
Ens,
29-
Uns,
3030
WalletPermission,
3131
WalletState
3232
} from './types.js'
3333

34+
import type { Uns } from '@web3-onboard/unstoppable-resolution'
35+
3436
export const ethersProviders: {
3537
[key: string]: providers.StaticJsonRpcProvider
3638
} = {}
@@ -383,27 +385,14 @@ export async function getUns(
383385
address: Address,
384386
chain: Chain
385387
): Promise<Uns | null> {
386-
const { connect } = state.get()
388+
const { unstoppableResolution } = configuration
387389

388390
// check if address is valid ETH address before attempting to resolve
389391
// chain we don't recognize and don't have a rpcUrl for requests
390-
if (connect.disableUDResolution || !utils.isAddress(address) || !chain)
391-
return null
392+
if (!unstoppableResolution || !utils.isAddress(address) || !chain) return null
392393

393394
try {
394-
let uns = null
395-
const { Resolution } = await import('@unstoppabledomains/resolution')
396-
397-
const resolutionInstance = new Resolution()
398-
const name = await resolutionInstance.reverse(address)
399-
400-
if (name) {
401-
uns = {
402-
name
403-
}
404-
}
405-
406-
return uns
395+
return await unstoppableResolution(address)
407396
} catch (error) {
408397
console.error(error)
409398
return null

packages/core/src/types.ts

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import type {
1212
} from '@web3-onboard/common'
1313

1414
import type gas from '@web3-onboard/gas'
15+
import type unstoppableResolution from '@web3-onboard/unstoppable-resolution'
1516
import type { TransactionPreviewAPI } from '@web3-onboard/transaction-preview'
1617

1718
import type en from './i18n/en.json'
@@ -77,6 +78,13 @@ export interface InitOptions {
7778
* the Theme initialization object or set as css variable
7879
*/
7980
disableFontDownload?: boolean
81+
/**
82+
* Type of unstoppableResolution module
83+
* A small module that can bee added to allow Unstoppable Domain
84+
* address resolution similar to that of ens (Ethereum Name Service)
85+
* ENS resolution will take president if available
86+
*/
87+
unstoppableResolution?: typeof unstoppableResolution
8088
}
8189

8290
export type Theme = ThemingMap | BuiltInThemes | 'system'
@@ -176,6 +184,7 @@ export type Configuration = {
176184
gas?: typeof gas
177185
containerElements?: ContainerElements
178186
transactionPreview?: TransactionPreviewAPI
187+
unstoppableResolution?: typeof unstoppableResolution
179188
}
180189

181190
export type Locale = string
@@ -193,15 +202,15 @@ export type ConnectModalOptions = {
193202
* Defaults to false
194203
*/
195204
disableClose?: boolean
196-
/**
197-
* If set to true, the most recently connected wallet will store in
198-
* local storage. Then on init, onboard will try to reconnect to
205+
/**
206+
* If set to true, the most recently connected wallet will store in
207+
* local storage. Then on init, onboard will try to reconnect to
199208
* that wallet with no modals displayed
200209
*/
201210
autoConnectLastWallet?: boolean
202-
/**
203-
* If set to true, all previously connected wallets will store in
204-
* local storage. Then on init, onboard will try to reconnect to
211+
/**
212+
* If set to true, all previously connected wallets will store in
213+
* local storage. Then on init, onboard will try to reconnect to
205214
* each wallet with no modals displayed
206215
*/
207216
autoConnectAllPreviousWallet?: boolean
@@ -219,11 +228,10 @@ export type ConnectModalOptions = {
219228
*/
220229
wheresMyWalletLink?: string
221230
/**
222-
* Define support for Unstoppable Domains resolutions
223-
* after a user connects. Similar to ens, uns can be used for users who
224-
* have minted an Unstoppable Domain and associated it with their wallet.
225-
* ENS resolution takes precedent over UNS
226-
* Defaults to false
231+
* @deprecated Has no effect unless `@web3-onboard/unstoppable-resolution`
232+
* package has been added and passed into the web3-onboard initialization
233+
* In this case remove the `@web3-onboard/unstoppable-resolution` package
234+
* to remove unstoppableDomain resolution support
227235
*/
228236
disableUDResolution?: boolean
229237
}
@@ -315,7 +323,7 @@ export type Notification = {
315323
*/
316324
message: string
317325
/**
318-
* handle codes in your own way - see codes here under the notify
326+
* handle codes in your own way - see codes here under the notify
319327
* prop default en file at ./packages/core/src/i18n/en.json
320328
*/
321329
eventCode: string
@@ -324,14 +332,14 @@ export type Notification = {
324332
*/
325333
type: NotificationType
326334
/**
327-
* time (in ms) after which the notification will be dismissed. If set
328-
* to `0` the notification will remain on screen until the user dismisses the
329-
* notification, refreshes the page or navigates away from the site
335+
* time (in ms) after which the notification will be dismissed. If set
336+
* to `0` the notification will remain on screen until the user dismisses the
337+
* notification, refreshes the page or navigates away from the site
330338
* with the notifications
331339
*/
332340
autoDismiss: number
333341
/**
334-
* add link to the transaction hash. For instance, a link to the
342+
* add link to the transaction hash. For instance, a link to the
335343
* transaction on etherscan
336344
*/
337345
link?: string
@@ -394,7 +402,7 @@ export type Action =
394402
| UpdateConnectModalAction
395403

396404
export type AddChainsAction = { type: 'add_chains'; payload: Chain[] }
397-
export type UpdateChainsAction = { type: 'update_chains'; payload: Chain}
405+
export type UpdateChainsAction = { type: 'update_chains'; payload: Chain }
398406
export type AddWalletAction = { type: 'add_wallet'; payload: WalletState }
399407

400408
export type UpdateWalletAction = {

0 commit comments

Comments
 (0)