@txnlab/use-wallet 2.0.0-alpha.0 → 2.0.0-alpha.2
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 +19 -0
- package/dist/cjs/index.js +14 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/src/clients/walletconnect2/types.d.ts +1 -2
- package/dist/cjs/src/constants/constants.d.ts +1 -0
- package/dist/esm/index.js +14 -5
- package/dist/esm/src/clients/walletconnect2/types.d.ts +1 -2
- package/dist/esm/src/constants/constants.d.ts +1 -0
- package/dist/index.d.ts +3 -3
- package/package.json +3 -5
package/README.md
CHANGED
|
@@ -582,6 +582,25 @@ Since it requires the unique `projectId`, the WalletConnect provider is not init
|
|
|
582
582
|
|
|
583
583
|
See [Migrating to WalletConnect 2.0](#migrating-to-walletconnect-20) below for more information.
|
|
584
584
|
|
|
585
|
+
### "Module not found" errors in Next.js 13
|
|
586
|
+
|
|
587
|
+
With the WalletConnect provider initialized in your Next.js 13 app, you may see the error `Module not found: Can't resolve 'lokijs' in...` or similar in local development. To resolve this, add the following to your `next.config.js` file:
|
|
588
|
+
|
|
589
|
+
```js
|
|
590
|
+
/** @type {import('next').NextConfig} */
|
|
591
|
+
const nextConfig = {
|
|
592
|
+
webpack: (config) => {
|
|
593
|
+
config.externals.push('pino-pretty', 'lokijs', 'encoding') // list modules in error messages
|
|
594
|
+
return config
|
|
595
|
+
}
|
|
596
|
+
// ...other config
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
module.exports = nextConfig
|
|
600
|
+
```
|
|
601
|
+
|
|
602
|
+
See https://github.com/WalletConnect/walletconnect-monorepo/issues/1908#issuecomment-1487801131
|
|
603
|
+
|
|
585
604
|
## Migration Guide
|
|
586
605
|
|
|
587
606
|
Version 2.x is a major version bump, and includes some breaking changes from 1.x.
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var require$$0 = require('react');
|
|
4
|
-
var utils = require('@walletconnect/utils');
|
|
5
4
|
var algosdk = require('algosdk');
|
|
6
5
|
|
|
7
6
|
exports.PROVIDER_ID = void 0;
|
|
@@ -16,6 +15,12 @@ exports.PROVIDER_ID = void 0;
|
|
|
16
15
|
PROVIDER_ID["WALLETCONNECT"] = "walletconnect";
|
|
17
16
|
PROVIDER_ID["MNEMONIC"] = "mnemonic";
|
|
18
17
|
})(exports.PROVIDER_ID || (exports.PROVIDER_ID = {}));
|
|
18
|
+
const DEFAULT_PROVIDERS = [
|
|
19
|
+
exports.PROVIDER_ID.PERA,
|
|
20
|
+
exports.PROVIDER_ID.DEFLY,
|
|
21
|
+
exports.PROVIDER_ID.DAFFI,
|
|
22
|
+
exports.PROVIDER_ID.EXODUS
|
|
23
|
+
];
|
|
19
24
|
const DEFAULT_NETWORK$1 = 'mainnet';
|
|
20
25
|
const DEFAULT_NODE_BASEURL = 'https://mainnet-api.algonode.cloud';
|
|
21
26
|
const DEFAULT_NODE_TOKEN = '';
|
|
@@ -2052,7 +2057,11 @@ class WalletConnectClient extends BaseClient {
|
|
|
2052
2057
|
}
|
|
2053
2058
|
await this.#client.disconnect({
|
|
2054
2059
|
topic: session.topic,
|
|
2055
|
-
|
|
2060
|
+
// replicates getSdkError('USER_DISCONNECTED') from @walletconnect/utils
|
|
2061
|
+
reason: {
|
|
2062
|
+
message: 'User disconnected.',
|
|
2063
|
+
code: 6000
|
|
2064
|
+
}
|
|
2056
2065
|
});
|
|
2057
2066
|
}
|
|
2058
2067
|
catch (error) {
|
|
@@ -2666,7 +2675,7 @@ const initializeProviders = async (providers, nodeConfig, algosdkStatic) => {
|
|
|
2666
2675
|
// Initialize default providers if `providers` is undefined or empty
|
|
2667
2676
|
if (!providers || providers.length === 0) {
|
|
2668
2677
|
const initPromises = Object.keys(allClients)
|
|
2669
|
-
.filter((id) =>
|
|
2678
|
+
.filter((id) => DEFAULT_PROVIDERS.includes(id))
|
|
2670
2679
|
.map((id) => initClient(id));
|
|
2671
2680
|
await Promise.all(initPromises);
|
|
2672
2681
|
}
|
|
@@ -2708,7 +2717,7 @@ function encodeNFDTransactionsArray(transactionsArray) {
|
|
|
2708
2717
|
});
|
|
2709
2718
|
}
|
|
2710
2719
|
|
|
2711
|
-
function useInitializeProviders({ providers, nodeConfig, algosdkStatic } = {}) {
|
|
2720
|
+
function useInitializeProviders({ providers = [], nodeConfig, algosdkStatic } = {}) {
|
|
2712
2721
|
const [walletProviders, setWalletProviders] = require$$0.useState(null);
|
|
2713
2722
|
require$$0.useEffect(() => {
|
|
2714
2723
|
async function initializeAndConnect() {
|
|
@@ -2733,6 +2742,7 @@ exports.DEFAULT_NETWORK = DEFAULT_NETWORK$1;
|
|
|
2733
2742
|
exports.DEFAULT_NODE_BASEURL = DEFAULT_NODE_BASEURL;
|
|
2734
2743
|
exports.DEFAULT_NODE_PORT = DEFAULT_NODE_PORT;
|
|
2735
2744
|
exports.DEFAULT_NODE_TOKEN = DEFAULT_NODE_TOKEN;
|
|
2745
|
+
exports.DEFAULT_PROVIDERS = DEFAULT_PROVIDERS;
|
|
2736
2746
|
exports.WalletProvider = clientStore;
|
|
2737
2747
|
exports.algosigner = AlgoSignerClient;
|
|
2738
2748
|
exports.defly = DeflyWalletClient;
|