Skip to content

Commit fa6f216

Browse files
fix: change wallet lit issue (#288)
1 parent 085650e commit fa6f216

File tree

5 files changed

+21
-14
lines changed

5 files changed

+21
-14
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/create-invoice-form/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@requestnetwork/create-invoice-form",
3-
"version": "0.11.15",
3+
"version": "0.11.16",
44
"main": "./dist/web-component.umd.cjs",
55
"scripts": {
66
"dev": "vite dev",

packages/create-invoice-form/src/lib/create-invoice-form.svelte

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,11 @@
152152
cipherProvider?.disconnectWallet();
153153
};
154154
155-
const handleWalletChange = (data: any) => {
156-
if (data?.address) {
155+
const handleWalletChange = (account: GetAccountReturnType, previousAccount: GetAccountReturnType) => {
156+
if (account?.address !== previousAccount?.address) {
157+
handleWalletDisconnection();
158+
handleWalletConnection();
159+
} else if (account?.address) {
157160
handleWalletConnection();
158161
} else {
159162
handleWalletDisconnection();
@@ -162,10 +165,9 @@
162165
163166
onMount(() => {
164167
unwatchAccount = watchAccount(wagmiConfig, {
165-
onChange(data) {
168+
onChange(account: GetAccountReturnType, previousAccount: GetAccountReturnType) {
166169
tick().then(() => {
167-
console.log("Wallet changed");
168-
handleWalletChange(data);
170+
handleWalletChange(account, previousAccount);
169171
});
170172
},
171173
});

packages/invoice-dashboard/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@requestnetwork/invoice-dashboard",
3-
"version": "0.11.14",
3+
"version": "0.11.15",
44
"main": "./dist/web-component.umd.cjs",
55
"scripts": {
66
"dev": "vite dev",

packages/invoice-dashboard/src/lib/view-requests.svelte

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,11 @@
119119
cipherProvider = undefined;
120120
};
121121
122-
const handleWalletChange = (data: any) => {
123-
if (data?.address) {
122+
const handleWalletChange = (account: GetAccountReturnType, previousAccount: GetAccountReturnType) => {
123+
if (account?.address !== previousAccount?.address) {
124+
handleWalletDisconnection();
125+
handleWalletConnection();
126+
} else if (account?.address) {
124127
handleWalletConnection();
125128
} else {
126129
handleWalletDisconnection();
@@ -129,9 +132,9 @@
129132
130133
onMount(() => {
131134
unwatchAccount = watchAccount(wagmiConfig, {
132-
onChange(data) {
135+
onChange(account: GetAccountReturnType, previousAccount: GetAccountReturnType) {
133136
tick().then(() => {
134-
handleWalletChange(data);
137+
handleWalletChange(account, previousAccount);
135138
});
136139
},
137140
});
@@ -160,7 +163,7 @@
160163
requestNetwork: RequestNetwork | undefined | null
161164
) => {
162165
if (!account?.address || !requestNetwork) return;
163-
166+
loading = true;
164167
try {
165168
const requestsData = await requestNetwork?.fromIdentity({
166169
type: Types.Identity.TYPE.ETHEREUM_ADDRESS,
@@ -171,6 +174,8 @@
171174
.sort((a, b) => b.timestamp - a.timestamp);
172175
} catch (error) {
173176
console.error("Failed to fetch requests:", error);
177+
} finally {
178+
loading = false;
174179
}
175180
};
176181

0 commit comments

Comments
 (0)