Skip to content

Commit

Permalink
fix(vue): optional chain ID when getting accounts (#277)
Browse files Browse the repository at this point in the history
  • Loading branch information
tien authored Oct 20, 2024
1 parent 5e63f82 commit 127620f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/olive-rats-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@reactive-dot/vue": patch
---

Fixed a bug that caused an error when retrieving accounts without specifying a chain ID.
6 changes: 4 additions & 2 deletions packages/vue/src/composables/use-accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ export function useAccounts(options?: ChainComposableOptions) {
}

function useAccountsPromise(options?: ChainComposableOptions) {
const chainId = internal_useChainId(options);
const chainId = internal_useChainId({ ...options, optionalChainId: true });
const connectedWalletsObservable = useConnectedWalletsObservable();
const chainSpecPromise = useChainSpecPromise(options);

return useLazyValue(
computed(() => ["accounts", chainId.value]),
computed(() =>
chainId.value === undefined ? ["accounts"] : ["accounts", chainId.value],
),
() => getAccounts(connectedWalletsObservable.value, chainSpecPromise.value),
);
}

0 comments on commit 127620f

Please sign in to comment.