@txnlab/use-wallet 0.0.9 → 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/constants/constants.d.ts +3 -3
- package/dist/cjs/index.js +46 -21
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/constants/constants.d.ts +3 -3
- package/dist/esm/index.js +46 -21
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.ts +8 -8
- package/package.json +1 -1
|
@@ -5,6 +5,6 @@ export declare enum PROVIDER_ID {
|
|
|
5
5
|
DEFLY = "Defly",
|
|
6
6
|
EXODUS = "Exodus"
|
|
7
7
|
}
|
|
8
|
-
export declare const NODE_SERVER
|
|
9
|
-
export declare const NODE_TOKEN
|
|
10
|
-
export declare const NODE_PORT
|
|
8
|
+
export declare const NODE_SERVER: string;
|
|
9
|
+
export declare const NODE_TOKEN: string;
|
|
10
|
+
export declare const NODE_PORT: string;
|
package/dist/esm/index.js
CHANGED
|
@@ -494,9 +494,11 @@ var PROVIDER_ID;
|
|
|
494
494
|
PROVIDER_ID["DEFLY"] = "Defly";
|
|
495
495
|
PROVIDER_ID["EXODUS"] = "Exodus";
|
|
496
496
|
})(PROVIDER_ID || (PROVIDER_ID = {}));
|
|
497
|
-
const NODE_SERVER =
|
|
498
|
-
|
|
499
|
-
|
|
497
|
+
const NODE_SERVER = process.env.REACT_APP_NODE_URL ||
|
|
498
|
+
process.env.NEXT_PUBLIC_NODE_URL ||
|
|
499
|
+
"https://mainnet-api.algonode.cloud";
|
|
500
|
+
const NODE_TOKEN = process.env.REACT_APP_NODE_TOKEN || process.env.NEXT_PUBLIC_NODE_TOKEN || "";
|
|
501
|
+
const NODE_PORT = process.env.REACT_APP_NODE_PORT || process.env.NEXT_PUBLIC_NODE_PORT || "";
|
|
500
502
|
|
|
501
503
|
/*
|
|
502
504
|
* big.js v6.2.1
|
|
@@ -3623,32 +3625,55 @@ function useConnectWallet() {
|
|
|
3623
3625
|
}
|
|
3624
3626
|
};
|
|
3625
3627
|
const connect = async (id) => {
|
|
3626
|
-
|
|
3627
|
-
|
|
3628
|
-
|
|
3629
|
-
|
|
3630
|
-
|
|
3628
|
+
try {
|
|
3629
|
+
await disconnectWCSessions(id);
|
|
3630
|
+
const walletClient = await getWalletClient(id);
|
|
3631
|
+
const walletInfo = await walletClient.connect(() => disconnect(id));
|
|
3632
|
+
if (!walletInfo || !walletInfo.accounts.length) {
|
|
3633
|
+
throw new Error("Failed to connect " + id);
|
|
3634
|
+
}
|
|
3635
|
+
setActiveAccount(walletInfo.accounts[0]);
|
|
3636
|
+
addAccounts(walletInfo.accounts);
|
|
3637
|
+
}
|
|
3638
|
+
catch (e) {
|
|
3639
|
+
console.error(e);
|
|
3631
3640
|
}
|
|
3632
|
-
setActiveAccount(walletInfo.accounts[0]);
|
|
3633
|
-
addAccounts(walletInfo.accounts);
|
|
3634
3641
|
};
|
|
3635
3642
|
const setActive = async (id) => {
|
|
3636
|
-
|
|
3637
|
-
|
|
3638
|
-
|
|
3643
|
+
try {
|
|
3644
|
+
await disconnectWCSessions(id);
|
|
3645
|
+
const accounts = getAccountsByProvider(id);
|
|
3646
|
+
setActiveAccount(accounts[0]);
|
|
3647
|
+
}
|
|
3648
|
+
catch (e) {
|
|
3649
|
+
console.error(e);
|
|
3650
|
+
}
|
|
3639
3651
|
};
|
|
3640
3652
|
const reconnect = async (id) => {
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3653
|
+
try {
|
|
3654
|
+
const walletClient = await getWalletClient(id);
|
|
3655
|
+
const walletInfo = await walletClient?.reconnect(() => disconnect(id));
|
|
3656
|
+
if (walletInfo && walletInfo.accounts.length) {
|
|
3657
|
+
addAccounts(walletInfo.accounts);
|
|
3658
|
+
}
|
|
3659
|
+
}
|
|
3660
|
+
catch (e) {
|
|
3661
|
+
console.error(e);
|
|
3662
|
+
disconnect(id);
|
|
3645
3663
|
}
|
|
3646
3664
|
};
|
|
3647
3665
|
const disconnect = async (id) => {
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3666
|
+
try {
|
|
3667
|
+
const walletClient = await getWalletClient(id);
|
|
3668
|
+
walletClient?.disconnect();
|
|
3669
|
+
}
|
|
3670
|
+
catch (e) {
|
|
3671
|
+
console.error(e);
|
|
3672
|
+
}
|
|
3673
|
+
finally {
|
|
3674
|
+
clearActiveAccount(id);
|
|
3675
|
+
removeAccounts(id);
|
|
3676
|
+
}
|
|
3652
3677
|
};
|
|
3653
3678
|
return {
|
|
3654
3679
|
providers: providers$1,
|