@txnlab/use-wallet 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +41 -18
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +41 -18
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -3651,32 +3651,55 @@ function useConnectWallet() {
|
|
|
3651
3651
|
}
|
|
3652
3652
|
};
|
|
3653
3653
|
const connect = async (id) => {
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3654
|
+
try {
|
|
3655
|
+
await disconnectWCSessions(id);
|
|
3656
|
+
const walletClient = await getWalletClient(id);
|
|
3657
|
+
const walletInfo = await walletClient.connect(() => disconnect(id));
|
|
3658
|
+
if (!walletInfo || !walletInfo.accounts.length) {
|
|
3659
|
+
throw new Error("Failed to connect " + id);
|
|
3660
|
+
}
|
|
3661
|
+
setActiveAccount(walletInfo.accounts[0]);
|
|
3662
|
+
addAccounts(walletInfo.accounts);
|
|
3663
|
+
}
|
|
3664
|
+
catch (e) {
|
|
3665
|
+
console.error(e);
|
|
3659
3666
|
}
|
|
3660
|
-
setActiveAccount(walletInfo.accounts[0]);
|
|
3661
|
-
addAccounts(walletInfo.accounts);
|
|
3662
3667
|
};
|
|
3663
3668
|
const setActive = async (id) => {
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3669
|
+
try {
|
|
3670
|
+
await disconnectWCSessions(id);
|
|
3671
|
+
const accounts = getAccountsByProvider(id);
|
|
3672
|
+
setActiveAccount(accounts[0]);
|
|
3673
|
+
}
|
|
3674
|
+
catch (e) {
|
|
3675
|
+
console.error(e);
|
|
3676
|
+
}
|
|
3667
3677
|
};
|
|
3668
3678
|
const reconnect = async (id) => {
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3679
|
+
try {
|
|
3680
|
+
const walletClient = await getWalletClient(id);
|
|
3681
|
+
const walletInfo = await walletClient?.reconnect(() => disconnect(id));
|
|
3682
|
+
if (walletInfo && walletInfo.accounts.length) {
|
|
3683
|
+
addAccounts(walletInfo.accounts);
|
|
3684
|
+
}
|
|
3685
|
+
}
|
|
3686
|
+
catch (e) {
|
|
3687
|
+
console.error(e);
|
|
3688
|
+
disconnect(id);
|
|
3673
3689
|
}
|
|
3674
3690
|
};
|
|
3675
3691
|
const disconnect = async (id) => {
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3692
|
+
try {
|
|
3693
|
+
const walletClient = await getWalletClient(id);
|
|
3694
|
+
walletClient?.disconnect();
|
|
3695
|
+
}
|
|
3696
|
+
catch (e) {
|
|
3697
|
+
console.error(e);
|
|
3698
|
+
}
|
|
3699
|
+
finally {
|
|
3700
|
+
clearActiveAccount(id);
|
|
3701
|
+
removeAccounts(id);
|
|
3702
|
+
}
|
|
3680
3703
|
};
|
|
3681
3704
|
return {
|
|
3682
3705
|
providers: providers$1,
|