Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: preserve wallet operation return values in Vue useOnboard composable #2340

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
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/vue/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@web3-onboard/vue",
"version": "2.9.1",
"version": "2.9.2-alpha.1",
"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
11 changes: 8 additions & 3 deletions packages/vue/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,20 @@ const useOnboard = (): OnboardComposable => {

const connectWallet = async (options?: ConnectOptions) => {
connectingWallet.value = true
await (web3Onboard as OnboardAPI).connectWallet(options)
const walletState = await (web3Onboard as OnboardAPI).connectWallet(options)
lastConnectionTimestamp.value = Date.now()
connectingWallet.value = false
return walletState
}

const disconnectWallet = async (wallet: DisconnectOptions) => {
connectingWallet.value = true
await (web3Onboard as OnboardAPI).disconnectWallet(wallet)
const walletState = await (web3Onboard as OnboardAPI).disconnectWallet(
wallet
)
updateAlreadyConnectedWallets()
connectingWallet.value = false
return walletState
}

const disconnectConnectedWallet = async () => {
Expand Down Expand Up @@ -115,8 +119,9 @@ const useOnboard = (): OnboardComposable => {

const setChain = async (options: SetChainOptions) => {
settingChain.value = true
await (web3Onboard as OnboardAPI).setChain(options)
const success = await (web3Onboard as OnboardAPI).setChain(options)
settingChain.value = false
return success
}

return {
Expand Down
10 changes: 5 additions & 5 deletions packages/vue/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,25 @@ import type { Ref, ComputedRef } from 'vue-demi'
type ReadonlyRef<T> = Readonly<Ref<T>>

type SetChainOptions = {
chainId: string
chainId: string | number
chainNamespace?: string
wallet: string
wallet?: WalletState['label']
rpcUrl?: string
label?: string
token?: string
}

interface OnboardComposable {
alreadyConnectedWallets: ReadonlyRef<string[]>
connectWallet: (options?: ConnectOptions) => Promise<void>
connectWallet: (options?: ConnectOptions) => Promise<WalletState[]>
connectedChain: ComputedRef<ConnectedChain | null>
connectedWallet: ComputedRef<WalletState | null>
connectingWallet: ReadonlyRef<boolean>
disconnectWallet: (wallet: DisconnectOptions) => Promise<void>
disconnectWallet: (wallet: DisconnectOptions) => Promise<WalletState[]>
disconnectConnectedWallet: () => Promise<void>
getChain: (walletLabel: string) => ConnectedChain | null
lastConnectionTimestamp: ReadonlyRef<number>
setChain: (options: SetChainOptions) => Promise<void>
setChain: (options: SetChainOptions) => Promise<boolean>
settingChain: ReadonlyRef<boolean>
wallets: ReadonlyRef<WalletState[]>
}
Expand Down