@txnlab/use-wallet 2.2.0 → 2.3.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/README.md +1 -1
- package/dist/cjs/index.js +28 -17
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/src/context/WalletContext.d.ts +8 -0
- package/dist/cjs/src/index.d.ts +1 -1
- package/dist/cjs/src/store/index.d.ts +0 -1
- package/dist/esm/index.js +28 -17
- package/dist/esm/src/context/WalletContext.d.ts +8 -0
- package/dist/esm/src/index.d.ts +1 -1
- package/dist/esm/src/store/index.d.ts +0 -1
- package/dist/index.d.ts +35 -31
- package/package.json +1 -1
- package/dist/cjs/src/store/state/clientStore.d.ts +0 -5
- package/dist/cjs/src/testUtils/createWrapper.d.ts +0 -6
- package/dist/esm/src/store/state/clientStore.d.ts +0 -5
- package/dist/esm/src/testUtils/createWrapper.d.ts +0 -6
package/README.md
CHANGED
package/dist/cjs/index.js
CHANGED
|
@@ -1362,9 +1362,6 @@ const useDebugStore = create((set) => ({
|
|
|
1362
1362
|
setDebug: (debug) => set({ debug })
|
|
1363
1363
|
}));
|
|
1364
1364
|
|
|
1365
|
-
const ClientContext = require$$0.createContext(null);
|
|
1366
|
-
var clientStore = ClientContext.Provider;
|
|
1367
|
-
|
|
1368
1365
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1369
1366
|
const debugLog = (...args) => {
|
|
1370
1367
|
const { debug } = useDebugStore.getState();
|
|
@@ -2635,13 +2632,23 @@ class KMDWalletClient extends BaseClient {
|
|
|
2635
2632
|
return;
|
|
2636
2633
|
}
|
|
2637
2634
|
// Not to be signed by our signer, skip it
|
|
2638
|
-
else
|
|
2639
|
-
|
|
2635
|
+
else {
|
|
2636
|
+
const senderAddress = this.algosdk.encodeAddress(dtxn.snd);
|
|
2637
|
+
const rekeyAddress = dtxn.rekey ? this.algosdk.encodeAddress(dtxn.rekey) : null;
|
|
2638
|
+
const isSignerConnected = rekeyAddress
|
|
2639
|
+
? connectedAccounts.includes(rekeyAddress) && connectedAccounts.includes(senderAddress)
|
|
2640
|
+
: connectedAccounts.includes(senderAddress);
|
|
2641
|
+
if (!isSignerConnected) {
|
|
2642
|
+
return;
|
|
2643
|
+
}
|
|
2640
2644
|
}
|
|
2641
2645
|
// overwrite with an empty blob
|
|
2642
2646
|
signedTxns[idx] = new Uint8Array();
|
|
2643
2647
|
const txn = this.algosdk.Transaction.from_obj_for_encoding(dtxn);
|
|
2644
|
-
|
|
2648
|
+
const promise = txn.reKeyTo
|
|
2649
|
+
? this.#client.signTransactionWithSpecificPublicKey(token, pw, txn, txn.reKeyTo.publicKey)
|
|
2650
|
+
: this.#client.signTransaction(token, pw, txn);
|
|
2651
|
+
signingPromises.push(promise);
|
|
2645
2652
|
});
|
|
2646
2653
|
const signingResults = await Promise.all(signingPromises);
|
|
2647
2654
|
// Restore the newly signed txns in the correct order
|
|
@@ -2931,6 +2938,18 @@ function encodeNFDTransactionsArray(transactionsArray) {
|
|
|
2931
2938
|
});
|
|
2932
2939
|
}
|
|
2933
2940
|
|
|
2941
|
+
const WalletContext = require$$0.createContext(null);
|
|
2942
|
+
const useWalletContext = () => {
|
|
2943
|
+
const context = require$$0.useContext(WalletContext);
|
|
2944
|
+
if (context === undefined) {
|
|
2945
|
+
throw new Error('useWallet must be used within the WalletProvider');
|
|
2946
|
+
}
|
|
2947
|
+
return context;
|
|
2948
|
+
};
|
|
2949
|
+
const WalletProvider = ({ children, value }) => {
|
|
2950
|
+
return require$$0.createElement(WalletContext.Provider, { value: value }, children);
|
|
2951
|
+
};
|
|
2952
|
+
|
|
2934
2953
|
function shallow(objA, objB) {
|
|
2935
2954
|
if (Object.is(objA, objB)) {
|
|
2936
2955
|
return true;
|
|
@@ -2969,19 +2988,11 @@ function shallow(objA, objB) {
|
|
|
2969
2988
|
}
|
|
2970
2989
|
return true;
|
|
2971
2990
|
}
|
|
2972
|
-
var shallow$1 = (objA, objB) => {
|
|
2973
|
-
if ((undefined ? undefined.MODE : void 0) !== "production") {
|
|
2974
|
-
console.warn(
|
|
2975
|
-
"[DEPRECATED] Default export is deprecated. Instead use `import { shallow } from 'zustand/shallow'`."
|
|
2976
|
-
);
|
|
2977
|
-
}
|
|
2978
|
-
return shallow(objA, objB);
|
|
2979
|
-
};
|
|
2980
2991
|
|
|
2981
2992
|
function useWallet() {
|
|
2982
2993
|
const [providers, setProviders] = require$$0.useState(null);
|
|
2983
|
-
const clients =
|
|
2984
|
-
const { activeAccount, accounts: connectedAccounts, setActiveAccount: _setActiveAccount, addAccounts } = useHydratedWalletStore(walletStoreSelector, shallow
|
|
2994
|
+
const clients = useWalletContext();
|
|
2995
|
+
const { activeAccount, accounts: connectedAccounts, setActiveAccount: _setActiveAccount, addAccounts } = useHydratedWalletStore(walletStoreSelector, shallow);
|
|
2985
2996
|
const getAccountsByProvider = (id) => {
|
|
2986
2997
|
return connectedAccounts.filter((account) => account.providerId === id);
|
|
2987
2998
|
};
|
|
@@ -3188,7 +3199,7 @@ exports.DEFAULT_NETWORK = DEFAULT_NETWORK;
|
|
|
3188
3199
|
exports.DEFAULT_NODE_BASEURL = DEFAULT_NODE_BASEURL;
|
|
3189
3200
|
exports.DEFAULT_NODE_PORT = DEFAULT_NODE_PORT;
|
|
3190
3201
|
exports.DEFAULT_NODE_TOKEN = DEFAULT_NODE_TOKEN;
|
|
3191
|
-
exports.WalletProvider =
|
|
3202
|
+
exports.WalletProvider = WalletProvider;
|
|
3192
3203
|
exports.algosigner = AlgoSignerClient;
|
|
3193
3204
|
exports.custom = CustomWalletClient;
|
|
3194
3205
|
exports.defly = DeflyWalletClient;
|