Skip to content

Commit 5e0c2cb

Browse files
authored
Merge pull request #1149 from blocknative/release/2.5.0
(main) Release: 2.5.0
2 parents 4116b63 + 5a5de75 commit 5e0c2cb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+353
-157
lines changed

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "web3-onboard-monorepo",
3-
"version": "2.4.0",
3+
"version": "2.5.0",
44
"private": true,
55
"workspaces": [
66
"./packages/*"
@@ -33,7 +33,10 @@
3333
"Mempool",
3434
"pending",
3535
"confirmed",
36-
"Injected Wallet"
36+
"Injected Wallet",
37+
"GameStop",
38+
"Crypto",
39+
"Crypto Wallet"
3740
],
3841
"repository": {
3942
"type": "git",

packages/coinbase/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@web3-onboard/coinbase",
3-
"version": "2.0.8",
3+
"version": "2.0.9",
44
"description": "Coinbase SDK wallet module for connecting to Web3-Onboard. 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, 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",
@@ -29,7 +29,9 @@
2929
"Mempool",
3030
"pending",
3131
"confirmed",
32-
"Injected Wallet"
32+
"Injected Wallet",
33+
"Crypto",
34+
"Crypto Wallet"
3335
],
3436
"repository": {
3537
"type": "git",
@@ -57,6 +59,6 @@
5759
},
5860
"dependencies": {
5961
"@coinbase/wallet-sdk": "^3.0.5",
60-
"@web3-onboard/common": "^2.1.5"
62+
"@web3-onboard/common": "^2.1.6"
6163
}
6264
}

packages/common/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@web3-onboard/common",
3-
"version": "2.1.5",
3+
"version": "2.1.6",
44
"description": "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, 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",
@@ -29,7 +29,9 @@
2929
"Mempool",
3030
"pending",
3131
"confirmed",
32-
"Injected Wallet"
32+
"Injected Wallet",
33+
"Crypto",
34+
"Crypto Wallet"
3335
],
3436
"repository": {
3537
"type": "git",

packages/common/src/elements/TableHeader.svelte

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,7 @@
8080
input[type='checkbox'] {
8181
-webkit-appearance: none;
8282
width: auto;
83-
background: var(
84-
--account-select-white,
85-
var(--onboard-white, var(--white))
86-
);
83+
background: var(--account-select-white, var(--onboard-white, var(--white)));
8784
border: 1px solid
8885
var(--account-select-gray-300, var(--onboard-gray-300, var(--gray-300)));
8986
padding: 0.5em;
@@ -144,6 +141,9 @@
144141
--account-select-font-family-light,
145142
var(--font-family-light)
146143
);
144+
font-size: var(--account-select-font-size-7, var(--font-size-7));
145+
max-width: 15rem;
146+
line-height: 1;
147147
}
148148
149149
.table-controls {

packages/common/src/views/AccountSelect.svelte

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,17 @@
6767
loadingAccounts = false
6868
} catch (err) {
6969
const { message } = err as { message: string }
70-
errorFromScan = message || 'There was an error scanning for accounts'
70+
71+
if (
72+
typeof message === 'string' &&
73+
message.includes('could not detect network')
74+
) {
75+
errorFromScan =
76+
'There was an error detecting connected network from RPC endpoint'
77+
} else {
78+
errorFromScan = message || 'There was an error scanning for accounts'
79+
}
80+
7181
loadingAccounts = false
7282
}
7383
}
@@ -397,10 +407,7 @@
397407
right: 0.2rem;
398408
width: 2.5rem;
399409
height: 2.5rem;
400-
background: var(
401-
--account-select-white,
402-
var(--onboard-white, var(--white))
403-
);
410+
background: var(--account-select-white, var(--onboard-white, var(--white)));
404411
border-radius: 1rem;
405412
}
406413

packages/core/README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ onboard.state.actions.updateAccountCenter({
713713
```
714714

715715
**`setPrimaryWallet`**
716-
The primary wallet (first in the list of connected wallets) and primary account (first in the list of connected accounts for a wallet) can be set by using the `setPrimaryWallet` function. The wallet that is to be set needs to be passed in for the first parameter and if you would like to set the primary account, the address of that account also needs to be passed in:
716+
The primary wallet (first in the list of connected wallets) and primary account (first in the list of connected accounts for a wallet) can be set by using the `setPrimaryWallet` function. The wallet that is set needs to be passed in for the first parameter and if you would like to set the primary account, the address of that account also needs to be passed in:
717717

718718
```typescript
719719
// set the second wallet in the wallets array as the primary
@@ -792,6 +792,10 @@ The Onboard styles can customized via [CSS variables](https://developer.mozilla.
792792

793793
/* CUSTOMIZE ACCOUNT CENTER*/
794794
--account-center-z-index
795+
--account-center-position-top
796+
--account-center-position-bottom
797+
--account-center-position-right
798+
--account-center-position-left
795799
--account-center-minimized-background
796800
--account-center-maximized-upper-background
797801
--account-center-maximized-network-section
@@ -925,7 +929,12 @@ The Onboard styles can customized via [CSS variables](https://developer.mozilla.
925929
--account-select-modal-margin-4: 1rem;
926930
--account-select-modal-margin-5: 0.5rem;
927931

928-
/* notify STYLES */
932+
/* NOTIFY STYLES */
933+
/* Notify Positioning variables only take effect if Notify is Positioned separate of Account Center */
934+
--notify-onboard-container-position-top
935+
--notify-onboard-container-position-bottom
936+
--notify-onboard-container-position-right
937+
--notify-onboard-container-position-left
929938
--notify-onboard-font-family-normal
930939
--notify-onboard-font-size-5
931940
--notify-onboard-gray-300

packages/core/package.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@web3-onboard/core",
3-
"version": "2.4.0",
3+
"version": "2.5.0",
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",
@@ -29,7 +29,10 @@
2929
"Mempool",
3030
"pending",
3131
"confirmed",
32-
"Injected Wallet"
32+
"Injected Wallet",
33+
"GameStop",
34+
"Crypto",
35+
"Crypto Wallet"
3336
],
3437
"repository": {
3538
"type": "git",
@@ -78,7 +81,7 @@
7881
"typescript": "^4.5.5"
7982
},
8083
"dependencies": {
81-
"@web3-onboard/common": "^2.1.5",
84+
"@web3-onboard/common": "^2.1.6",
8285
"bignumber.js": "^9.0.0",
8386
"bnc-sdk": "^4.4.1",
8487
"bowser": "^2.11.0",

packages/core/src/configuration.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ export let configuration: Configuration = {
55
svelteInstance: null,
66
appMetadata: null,
77
apiKey: null,
8-
device: getDevice()
8+
device: getDevice(),
9+
initialWalletInit: []
910
}
1011

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

packages/core/src/connect.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import { firstValueFrom } from 'rxjs'
22
import { filter, withLatestFrom, pluck } from 'rxjs/operators'
3+
import { configuration } from './configuration'
34
import { state } from './store'
5+
import { setWalletModules } from './store/actions'
46
import { connectWallet$, wallets$ } from './streams'
57
import type { ConnectOptions, ConnectOptionsString, WalletState } from './types'
8+
import { wait } from './utils'
69
import { validateConnectOptions } from './validation'
710

811
async function connect(
@@ -28,6 +31,16 @@ async function connect(
2831
autoSelect: { label: '', disableModals: false }
2932
}
3033

34+
// if auto selecting, wait until next event loop
35+
if (autoSelect && (typeof autoSelect === 'string' || autoSelect.label)) {
36+
await wait(50)
37+
}
38+
39+
// first time calling connect, so initialize and set wallet modules
40+
if (!state.get().walletModules.length) {
41+
setWalletModules(configuration.initialWalletInit)
42+
}
43+
3144
connectWallet$.next({
3245
autoSelect:
3346
typeof autoSelect === 'string'

packages/core/src/index.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ import { configuration, updateConfiguration } from './configuration'
1717

1818
import {
1919
addChains,
20-
setWalletModules,
2120
updateAccountCenter,
2221
updateNotify,
2322
customNotification,
2423
setLocale,
25-
setPrimaryWallet
24+
setPrimaryWallet,
25+
setWalletModules
2626
} from './store/actions'
2727

2828
import updateBalances from './update-balances'
@@ -61,7 +61,8 @@ export type {
6161
CustomNotification,
6262
Notification,
6363
Notify,
64-
UpdateNotification
64+
UpdateNotification,
65+
PreflightNotificationsOptions
6566
} from './types'
6667

6768
export type { EIP1193Provider } from '@web3-onboard/common'
@@ -167,7 +168,6 @@ function init(options: InitOptions): OnboardAPI {
167168
if (!apiKey || !notifyUpdate.enabled) {
168169
notifyUpdate.enabled = false
169170
}
170-
console.log(notifyUpdate)
171171
updateNotify(notifyUpdate)
172172
}
173173
} else {
@@ -190,11 +190,10 @@ function init(options: InitOptions): OnboardAPI {
190190
updateConfiguration({
191191
appMetadata,
192192
svelteInstance: app,
193-
apiKey
193+
apiKey,
194+
initialWalletInit: wallets
194195
})
195196

196-
setWalletModules(wallets)
197-
198197
return API
199198
}
200199

@@ -316,10 +315,13 @@ function mountApp() {
316315
</style>
317316
`
318317

319-
const containerElementQuery = state.get().accountCenter.containerElement || 'body'
318+
const containerElementQuery =
319+
state.get().accountCenter.containerElement || 'body'
320320
const containerElement = document.querySelector(containerElementQuery)
321321
if (!containerElement) {
322-
throw new Error(`Element with query ${state.get().accountCenter} does not exist.`)
322+
throw new Error(
323+
`Element with query ${state.get().accountCenter} does not exist.`
324+
)
323325
}
324326

325327
containerElement.appendChild(onboard)

packages/core/src/preflight-notifications.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ export async function preflightNotifications(
6363
if (transactionCost.gt(new BigNumber(balance))) {
6464
const eventCode = 'nsfFail'
6565

66-
const newNotification = buildNotification(eventCode, id)
67-
addNotification(newNotification)
66+
addNotification(buildNotification(eventCode, id))
6867
}
6968
}
7069

@@ -93,8 +92,7 @@ export async function preflightNotifications(
9392
}, reminderTimeout)
9493

9594
const eventCode = 'txRequest'
96-
const newNotification = buildNotification(eventCode, id)
97-
addNotification(newNotification)
95+
addNotification(buildNotification(eventCode, id))
9896

9997
// if not provided with sendTransaction function,
10098
// resolve with transaction hash(or void) so dev can initiate transaction
@@ -112,8 +110,7 @@ export async function preflightNotifications(
112110
}
113111
const { eventCode, errorMsg } = extractMessageFromError(error as CatchError)
114112

115-
const newNotification = buildNotification(eventCode, id)
116-
addNotification(newNotification)
113+
addNotification(buildNotification(eventCode, id))
117114
console.error(errorMsg)
118115
return
119116
}

packages/core/src/store/actions.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ export function removeWallet(id: string): void {
123123
}
124124

125125
export function setPrimaryWallet(wallet: WalletState, address?: string): void {
126-
console.log({ address })
127126
const error =
128127
validateWallet(wallet) || (address && validateString(address, 'address'))
129128

packages/core/src/types.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ export type Configuration = {
119119
appMetadata: AppMetadata | null
120120
device: Device | DeviceNotBrowser
121121
apiKey: string
122+
initialWalletInit: WalletInit[]
122123
}
123124

124125
export type Locale = string
@@ -213,14 +214,16 @@ export interface PreflightNotificationsOptions {
213214
estimateGas?: () => Promise<string>
214215
gasPrice?: () => Promise<string>
215216
balance?: string | number
216-
txDetails?: {
217-
value: string | number
218-
to?: string
219-
from?: string
220-
}
217+
txDetails?: TxDetails
221218
txApproveReminderTimeout?: number
222219
}
223220

221+
export interface TxDetails {
222+
value: string | number
223+
to?: string
224+
from?: string
225+
}
226+
224227
// ==== ACTIONS ==== //
225228
export type Action =
226229
| AddChainsAction

packages/core/src/utils.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ export function shortenEns(ens: string): string {
8585

8686
export async function copyWalletAddress(text: string): Promise<void> {
8787
try {
88-
const copy = await navigator.clipboard.writeText(text);
89-
return copy
88+
const copy = await navigator.clipboard.writeText(text)
89+
return copy
9090
} catch (err) {
9191
console.error('Failed to copy: ', err)
9292
}
@@ -242,3 +242,6 @@ export const defaultNotifyEventStyles: Record<string, NotifyEventStyles> = {
242242
eventIcon: info
243243
}
244244
}
245+
246+
export const wait = (time: number) =>
247+
new Promise(resolve => setTimeout(resolve, time))

0 commit comments

Comments
 (0)