Skip to content

Commit 59f9840

Browse files
authored
Merge pull request #1117 from blocknative/release/2.3.0
Release 2.3.0 - Main
2 parents 959d5c4 + 5c29be6 commit 59f9840

File tree

33 files changed

+254
-104
lines changed

33 files changed

+254
-104
lines changed

.github/ISSUE_TEMPLATE/BUG.yml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,26 +41,26 @@ body:
4141
attributes:
4242
label: What package is effected by this issue?
4343
options:
44-
- @web3-onboard/core
45-
- @web3-onboard/common
46-
- @web3-onboard/coinbase
47-
- @web3-onboard/decent
48-
- @web3-onboard/formatic
49-
- @web3-onboard/gnosis
50-
- @web3-onboard/injected
51-
- @web3-onboard/keepkey
52-
- @web3-onboard/keystone
53-
- @web3-onboard/ledger
54-
- @web3-onboard/magic
55-
- @web3-onboard/mew
56-
- @web3-onboard/portis
57-
- @web3-onboard/react
58-
- @web3-onboard/torus
59-
- @web3-onboard/trezor
60-
- @web3-onboard/vue
61-
- @web3-onboard/walletconnect
62-
- @web3-onboard/walletlink
63-
- @web3-onboard/web3auth
44+
- "@web3-onboard/core"
45+
- "@web3-onboard/common"
46+
- "@web3-onboard/coinbase"
47+
- "@web3-onboard/decent"
48+
- "@web3-onboard/formatic"
49+
- "@web3-onboard/gnosis"
50+
- "@web3-onboard/injected"
51+
- "@web3-onboard/keepkey"
52+
- "@web3-onboard/keystone"
53+
- "@web3-onboard/ledger"
54+
- "@web3-onboard/magic"
55+
- "@web3-onboard/mew"
56+
- "@web3-onboard/portis"
57+
- "@web3-onboard/react"
58+
- "@web3-onboard/torus"
59+
- "@web3-onboard/trezor"
60+
- "@web3-onboard/vue"
61+
- "@web3-onboard/walletconnect"
62+
- "@web3-onboard/walletlink"
63+
- "@web3-onboard/web3auth"
6464
- bnc-onboard (v1)
6565
validations:
6666
required: true

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Web3-Onboard
2+
**easy way to connect users to dapps**
23

34
## Features
45

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "web3-onboard-monorepo",
3-
"version": "2.2.0",
3+
"version": "2.3.0",
44
"private": true,
55
"workspaces": [
66
"./packages/*"

packages/coinbase/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"name": "@web3-onboard/coinbase",
3-
"version": "2.0.6",
3+
"version": "2.0.7",
44
"description": "Coinbase Wallet module for web3-onboard",
5+
"repository": "blocknative/web3-onboard",
56
"module": "dist/index.js",
67
"browser": "dist/index.js",
78
"main": "dist/index.js",
@@ -21,6 +22,6 @@
2122
},
2223
"dependencies": {
2324
"@coinbase/wallet-sdk": "^3.0.5",
24-
"@web3-onboard/common": "^2.1.3"
25+
"@web3-onboard/common": "^2.1.4"
2526
}
2627
}

packages/common/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "@web3-onboard/common",
3-
"version": "2.1.3",
3+
"version": "2.1.4",
4+
"repository": "blocknative/web3-onboard",
45
"scripts": {
56
"build": "rollup -c",
67
"dev": "rollup -c -w",

packages/core/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"name": "@web3-onboard/core",
3-
"version": "2.3.1",
3+
"version": "2.3.2",
4+
"repository": "blocknative/web3-onboard",
45
"scripts": {
56
"build": "rollup -c",
67
"dev": "rollup -c -w",
@@ -41,7 +42,7 @@
4142
"typescript": "^4.5.5"
4243
},
4344
"dependencies": {
44-
"@web3-onboard/common": "^2.1.3",
45+
"@web3-onboard/common": "^2.1.4",
4546
"bignumber.js": "^9.0.0",
4647
"bnc-sdk": "^4.4.1",
4748
"bowser": "^2.11.0",

packages/core/src/index.ts

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ import disconnectWallet from './disconnect'
44
import setChain from './chain'
55
import { state } from './store'
66
import { reset$ } from './streams'
7-
import { validateInitOptions, validateNotify, validateNotifyOptions } from './validation'
7+
import {
8+
validateInitOptions,
9+
validateNotify,
10+
validateNotifyOptions
11+
} from './validation'
812
import initI18N from './i18n'
913
import App from './views/Index.svelte'
1014
import type { InitOptions, OnboardAPI, Notify } from './types'
@@ -103,14 +107,14 @@ function init(options: InitOptions): OnboardAPI {
103107
}
104108

105109
// update notify
106-
if (typeof notify !== undefined) {
110+
if (typeof notify !== 'undefined') {
107111
if ('desktop' in notify || 'mobile' in notify) {
108112
const error = validateNotifyOptions(notify)
109-
113+
110114
if (error) {
111115
throw error
112116
}
113-
117+
114118
if (
115119
(!notify.desktop || (notify.desktop && !notify.desktop.position)) &&
116120
accountCenter &&
@@ -128,6 +132,7 @@ function init(options: InitOptions): OnboardAPI {
128132
notify.mobile.position = accountCenter.mobile.position
129133
}
130134
let notifyUpdate: Partial<Notify>
135+
131136
if (device.type === 'mobile' && notify.mobile) {
132137
notifyUpdate = {
133138
...APP_INITIAL_STATE.notify,
@@ -139,15 +144,34 @@ function init(options: InitOptions): OnboardAPI {
139144
...notify.desktop
140145
}
141146
}
147+
if (!apiKey || !notifyUpdate.enabled) {
148+
notifyUpdate.enabled = false
149+
}
142150
updateNotify(notifyUpdate)
143151
} else {
144152
const error = validateNotify(notify as Notify)
145-
153+
146154
if (error) {
147155
throw error
148156
}
149-
updateNotify(notify as Notify)
157+
const notifyUpdate: Partial<Notify> = {
158+
...APP_INITIAL_STATE.notify,
159+
...notify
160+
}
161+
162+
if (!apiKey || !notifyUpdate.enabled) {
163+
notifyUpdate.enabled = false
164+
}
165+
console.log(notifyUpdate)
166+
updateNotify(notifyUpdate)
167+
}
168+
} else {
169+
const notifyUpdate: Partial<Notify> = APP_INITIAL_STATE.notify
170+
171+
if (!apiKey) {
172+
notifyUpdate.enabled = false
150173
}
174+
updateNotify(notifyUpdate)
151175
}
152176

153177
if (svelteInstance) {

packages/core/src/views/Index.svelte

Lines changed: 71 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
import AccountCenter from './account-center/Index.svelte'
99
import Notify from './notify/Index.svelte'
1010
import { configuration } from '../configuration'
11+
import type { Observable } from 'rxjs'
12+
import type { Notification } from '../types'
1113
1214
const { device } = configuration
1315
const accountCenter$ = state
@@ -17,12 +19,61 @@
1719
const notify$ = state
1820
.select('notify')
1921
.pipe(startWith(state.get().notify), shareReplay(1))
22+
23+
const notifications$: Observable<Notification[]> = state
24+
.select('notifications')
25+
.pipe(startWith(state.get().notifications))
26+
2027
const positioningDefaults = {
2128
topLeft: 'top: 0; left: 0;',
2229
topRight: 'top: 0; right: 0;',
2330
bottomRight: 'bottom: 0; right: 0;',
2431
bottomLeft: 'bottom: 0; left: 0;'
2532
}
33+
34+
$: sharedContainer =
35+
$accountCenter$.enabled &&
36+
$notify$.enabled &&
37+
$notify$.position === $accountCenter$.position
38+
39+
$: samePositionOrMobile =
40+
device.type === 'mobile' || $accountCenter$.position === $notify$.position
41+
42+
$: sharedMobileContainerCheck =
43+
device.type === 'mobile' &&
44+
(($notify$.position.includes('bottom') &&
45+
$accountCenter$.position.includes('bottom')) ||
46+
($notify$.position.includes('top') &&
47+
$accountCenter$.position.includes('top')))
48+
49+
$: separateMobileContainerCheck =
50+
device.type === 'mobile' &&
51+
(($notify$.position.includes('top') &&
52+
$accountCenter$.position.includes('bottom')) ||
53+
($notify$.position.includes('bottom') &&
54+
$accountCenter$.position.includes('top')))
55+
56+
$: displayNotifySeparate =
57+
$notify$.enabled &&
58+
(!$accountCenter$.enabled ||
59+
($notify$.position !== $accountCenter$.position &&
60+
device.type !== 'mobile') ||
61+
separateMobileContainerCheck) &&
62+
$wallets$.length
63+
64+
$: displayAccountCenterSeparate =
65+
$accountCenter$.enabled &&
66+
(!$notify$.enabled ||
67+
($notify$.position !== $accountCenter$.position &&
68+
device.type !== 'mobile') ||
69+
separateMobileContainerCheck) &&
70+
$wallets$.length
71+
72+
$: displayAccountCenterNotifySameContainer =
73+
$notify$.enabled &&
74+
$accountCenter$.enabled &&
75+
$wallets$.length &&
76+
(sharedContainer || sharedMobileContainerCheck)
2677
</script>
2778

2879
<style>
@@ -280,7 +331,7 @@
280331
<SwitchChain />
281332
{/if}
282333

283-
{#if $notify$.enabled && $accountCenter$.enabled && $wallets$.length}
334+
{#if displayAccountCenterNotifySameContainer}
284335
<div
285336
class="container flex flex-column fixed z-indexed"
286337
style="{positioningDefaults[$accountCenter$.position]}; {device.type ===
@@ -290,8 +341,12 @@
290341
? 'padding-top:0;'
291342
: ''} "
292343
>
293-
{#if $notify$.position.includes('bottom') && $accountCenter$.position.includes('bottom') && (device.type === 'mobile' || $accountCenter$.position === $notify$.position)}
294-
<Notify position={$notify$.position} sharedContainer={true} />
344+
{#if $notify$.position.includes('bottom') && $accountCenter$.position.includes('bottom') && samePositionOrMobile}
345+
<Notify
346+
notifications={$notifications$}
347+
position={$notify$.position}
348+
{sharedContainer}
349+
/>
295350
{/if}
296351
<div
297352
style={!$accountCenter$.expanded &&
@@ -306,12 +361,16 @@
306361
>
307362
<AccountCenter settings={$accountCenter$} />
308363
</div>
309-
{#if $notify$.position.includes('top') && $accountCenter$.position.includes('top') && (device.type === 'mobile' || $accountCenter$.position === $notify$.position)}
310-
<Notify position={$notify$.position} sharedContainer={true} />
364+
{#if $notify$.position.includes('top') && $accountCenter$.position.includes('top') && samePositionOrMobile}
365+
<Notify
366+
notifications={$notifications$}
367+
position={$notify$.position}
368+
{sharedContainer}
369+
/>
311370
{/if}
312371
</div>
313372
{/if}
314-
{#if $accountCenter$.enabled && (!$notify$.enabled || ($notify$.position !== $accountCenter$.position && device.type !== 'mobile')) && $wallets$.length}
373+
{#if displayAccountCenterSeparate}
315374
<div
316375
class="container flex flex-column fixed z-indexed"
317376
style="{positioningDefaults[$accountCenter$.position]}; {device.type ===
@@ -338,7 +397,7 @@
338397
</div>
339398
</div>
340399
{/if}
341-
{#if $notify$.enabled && (!$accountCenter$.enabled || ($notify$.position !== $accountCenter$.position && device.type !== 'mobile') || ($notify$.position.includes('top') && $accountCenter$.position.includes('bottom')) || ($notify$.position.includes('bottom') && $accountCenter$.position.includes('top'))) && $wallets$.length}
400+
{#if displayNotifySeparate}
342401
<div
343402
class="container flex flex-column fixed z-indexed"
344403
style="{positioningDefaults[$notify$.position]}; {device.type ===
@@ -348,6 +407,10 @@
348407
? 'padding-top:0;'
349408
: ''} "
350409
>
351-
<Notify position={$notify$.position} sharedContainer={false} />
410+
<Notify
411+
notifications={$notifications$}
412+
position={$notify$.position}
413+
{sharedContainer}
414+
/>
352415
</div>
353416
{/if}

packages/core/src/views/connect/Index.svelte

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
let scrollContainer: HTMLElement
5353
5454
let walletToAutoSelect =
55-
autoSelect &&
55+
autoSelect.label &&
5656
walletModules.find(
5757
({ label }) => label.toLowerCase() === autoSelect.label.toLowerCase()
5858
)
@@ -209,7 +209,7 @@
209209
// user rejected account access
210210
if (code === ProviderRpcErrorCode.ACCOUNT_ACCESS_REJECTED) {
211211
connectionRejected = true
212-
if (autoSelect) {
212+
if (walletToAutoSelect) {
213213
walletToAutoSelect = null
214214
215215
if (autoSelect.disableModals) {
@@ -360,7 +360,7 @@
360360

361361
<svelte:window bind:innerWidth={windowWidth} />
362362

363-
{#if !autoSelect || (autoSelect && !autoSelect.disableModals)}
363+
{#if !autoSelect.disableModals}
364364
<Modal {close}>
365365
<div class="container relative flex">
366366
{#if windowWidth >= 809}
@@ -396,7 +396,7 @@
396396
{connectingErrorMessage}
397397
/>
398398
</div>
399-
{:else if !autoSelect}
399+
{:else}
400400
<InstallWallet />
401401
{/if}
402402
{/if}

packages/core/src/views/notify/Index.svelte

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import { shareReplay, startWith } from 'rxjs/operators'
88
import Notification from './Notification.svelte'
99
import { configuration } from '../../configuration'
10+
import type { Notification as NotificationType } from '../../types'
1011
1112
const { device } = configuration
1213
@@ -16,6 +17,7 @@
1617
1718
export let position: string
1819
export let sharedContainer: boolean
20+
export let notifications: NotificationType[]
1921
2022
let x: number
2123
let y: number
@@ -36,8 +38,6 @@
3638
x = 0
3739
y = 0
3840
39-
const notifications$ = state.select('notifications').pipe(startWith([]))
40-
4141
let overflowY = 'y-scroll'
4242
const updateScrollYOnRemove = (): void => {
4343
if (overflowY !== 'y-visible') {
@@ -114,7 +114,7 @@
114114
}
115115
</style>
116116

117-
{#if $notifications$.length}
117+
{#if notifications.length}
118118
<ul
119119
class="bn-notify-{position} {overflowY}"
120120
style={`${
@@ -129,7 +129,7 @@
129129
: '24px'
130130
})`}
131131
>
132-
{#each $notifications$ as notification (notification.key)}
132+
{#each notifications as notification (notification.key)}
133133
<li
134134
animate:flip={{ duration: 500 }}
135135
on:click|stopPropagation

0 commit comments

Comments
 (0)