Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.22.2-alpha.1",
"version": "2.22.2-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
6 changes: 3 additions & 3 deletions packages/core/src/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ async function connect(
'At least one chain must be set before attempting to connect a wallet'
)

const { autoSelect } = options || {
autoSelect: { label: '', disableModals: false }
let { autoSelect } = options || {}
if (!autoSelect) {
autoSelect = { label: '', disableModals: false }
}

// if auto selecting, wait until next event loop
Expand All @@ -44,7 +45,6 @@ async function connect(
if (!state.get().walletModules.length) {
setWalletModules(configuration.initialWalletInit)
}

connectWallet$.next({
autoSelect:
typeof autoSelect === 'string'
Expand Down
29 changes: 18 additions & 11 deletions packages/core/src/disconnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,25 @@ async function disconnect(options: DisconnectOptions): Promise<WalletState[]> {
disconnectWallet$.next(label)
removeWallet(label)

const labels = JSON.parse(
getLocalStore(STORAGE_KEYS.LAST_CONNECTED_WALLET) || ''
)
const lastConnectedWallets = getLocalStore(STORAGE_KEYS.LAST_CONNECTED_WALLET)
if (lastConnectedWallets) {
try {
const labels = JSON.parse(lastConnectedWallets)

if (Array.isArray(labels) && labels.indexOf(label) >= 0) {
setLocalStore(
STORAGE_KEYS.LAST_CONNECTED_WALLET,
JSON.stringify(labels.filter(walletLabel => walletLabel !== label))
)
}
if (typeof labels === 'string' && labels === label) {
delLocalStore(STORAGE_KEYS.LAST_CONNECTED_WALLET)
if (Array.isArray(labels) && labels.indexOf(label) >= 0) {
setLocalStore(
STORAGE_KEYS.LAST_CONNECTED_WALLET,
JSON.stringify(labels.filter(walletLabel => walletLabel !== label))
)
}
if (typeof labels === 'string' && labels === label) {
delLocalStore(STORAGE_KEYS.LAST_CONNECTED_WALLET)
}
} catch (e) {
console.error(
`There was an error disconnecting the last connected wallet from localStorage - Error: ${e}`
)
}
}

return state.get().wallets
Expand Down
7 changes: 7 additions & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,12 @@ function init(options: InitOptions): OnboardAPI {
) {
connectAllPreviousWallets(lastConnectedWalletsParsed, connect)
}
if (
lastConnectedWalletsParsed &&
typeof lastConnectedWalletsParsed === 'string'
) {
connectAllPreviousWallets([lastConnectedWalletsParsed], connect)
}
} catch (err) {
// Handle for legacy single wallet approach
// Above try will throw syntax error is local storage is not json
Expand Down Expand Up @@ -361,6 +367,7 @@ const connectAllPreviousWallets = async (
}
}
}

setLocalStore(
STORAGE_KEYS.LAST_CONNECTED_WALLET,
JSON.stringify(activeWalletsList)
Expand Down
2 changes: 1 addition & 1 deletion packages/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@web3-onboard/blocto": "^2.1.1",
"@web3-onboard/capsule": "2.2.0-alpha.1",
"@web3-onboard/cede-store": "^2.3.1",
"@web3-onboard/core": "2.22.2-alpha.1",
"@web3-onboard/core": "2.22.2-alpha.2",
"@web3-onboard/coinbase": "^2.4.1",
"@web3-onboard/dcent": "^2.2.7",
"@web3-onboard/enkrypt": "^2.1.1",
Expand Down
5 changes: 3 additions & 2 deletions packages/demo/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@
const onboard = Onboard({
wallets: [
metamaskSDKWallet,
injected,
coinbaseWallet,
injected,
ledger,
trezor,
walletConnect,
Expand Down Expand Up @@ -415,7 +415,8 @@
connect: {
// disableClose: true,
// removeWhereIsMyWalletWarning: true,
autoConnectAllPreviousWallet: true
// autoConnectLastWallet: false,
autoConnectAllPreviousWallet: true,
},
appMetadata: {
name: 'Blocknative',
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.9.2-alpha.1",
"version": "2.9.2-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 @@ -61,7 +61,7 @@
"typescript": "^5.4.5"
},
"dependencies": {
"@web3-onboard/core": "2.22.2-alpha.1",
"@web3-onboard/core": "2.22.2-alpha.2",
"@web3-onboard/common": "^2.4.1",
"use-sync-external-store": "1.0.0"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/solid/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3-onboard/solid",
"version": "2.1.2-alpha.1",
"version": "2.1.2-alpha.2",
"description": "A collection of solid Composables for integrating Web3-Onboard in to a Solid 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 @@
},
"dependencies": {
"@web3-onboard/common": "^2.4.1",
"@web3-onboard/core": "2.22.2-alpha.1",
"@web3-onboard/core": "2.22.2-alpha.2",
"solid-js": "^1.8.1"
}
}
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.8.2-alpha.1",
"version": "2.8.2-alpha.2",
"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 @@ -62,7 +62,7 @@
"@vueuse/core": "^8.4.2",
"@vueuse/rxjs": "^8.2.0",
"@web3-onboard/common": "^2.4.1",
"@web3-onboard/core": "2.22.2-alpha.1",
"@web3-onboard/core": "2.22.2-alpha.2",
"vue-demi": "^0.12.4"
},
"peerDependencies": {
Expand Down