@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/cjs/index.js
CHANGED
|
@@ -520,9 +520,11 @@ exports.PROVIDER_ID = void 0;
|
|
|
520
520
|
PROVIDER_ID["DEFLY"] = "Defly";
|
|
521
521
|
PROVIDER_ID["EXODUS"] = "Exodus";
|
|
522
522
|
})(exports.PROVIDER_ID || (exports.PROVIDER_ID = {}));
|
|
523
|
-
const NODE_SERVER =
|
|
524
|
-
|
|
525
|
-
|
|
523
|
+
const NODE_SERVER = process.env.REACT_APP_NODE_URL ||
|
|
524
|
+
process.env.NEXT_PUBLIC_NODE_URL ||
|
|
525
|
+
"https://mainnet-api.algonode.cloud";
|
|
526
|
+
const NODE_TOKEN = process.env.REACT_APP_NODE_TOKEN || process.env.NEXT_PUBLIC_NODE_TOKEN || "";
|
|
527
|
+
const NODE_PORT = process.env.REACT_APP_NODE_PORT || process.env.NEXT_PUBLIC_NODE_PORT || "";
|
|
526
528
|
|
|
527
529
|
/*
|
|
528
530
|
* big.js v6.2.1
|
|
@@ -3649,32 +3651,55 @@ function useConnectWallet() {
|
|
|
3649
3651
|
}
|
|
3650
3652
|
};
|
|
3651
3653
|
const connect = async (id) => {
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
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);
|
|
3657
3666
|
}
|
|
3658
|
-
setActiveAccount(walletInfo.accounts[0]);
|
|
3659
|
-
addAccounts(walletInfo.accounts);
|
|
3660
3667
|
};
|
|
3661
3668
|
const setActive = async (id) => {
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3669
|
+
try {
|
|
3670
|
+
await disconnectWCSessions(id);
|
|
3671
|
+
const accounts = getAccountsByProvider(id);
|
|
3672
|
+
setActiveAccount(accounts[0]);
|
|
3673
|
+
}
|
|
3674
|
+
catch (e) {
|
|
3675
|
+
console.error(e);
|
|
3676
|
+
}
|
|
3665
3677
|
};
|
|
3666
3678
|
const reconnect = async (id) => {
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
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);
|
|
3671
3689
|
}
|
|
3672
3690
|
};
|
|
3673
3691
|
const disconnect = async (id) => {
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
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
|
+
}
|
|
3678
3703
|
};
|
|
3679
3704
|
return {
|
|
3680
3705
|
providers: providers$1,
|