@txnlab/use-wallet 2.0.0-alpha.4 → 2.0.0-rc.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.
Files changed (76) hide show
  1. package/README.md +136 -97
  2. package/dist/cjs/index.js +662 -338
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/cjs/jest.config.d.ts +1 -1
  5. package/dist/cjs/src/clients/algosigner/client.d.ts +4 -3
  6. package/dist/cjs/src/clients/algosigner/types.d.ts +12 -12
  7. package/dist/cjs/src/clients/base/base.d.ts +4 -3
  8. package/dist/cjs/src/clients/daffi/client.d.ts +6 -4
  9. package/dist/cjs/src/clients/daffi/types.d.ts +7 -10
  10. package/dist/cjs/src/clients/defly/client.d.ts +6 -5
  11. package/dist/cjs/src/clients/defly/types.d.ts +8 -11
  12. package/dist/cjs/src/clients/exodus/client.d.ts +4 -3
  13. package/dist/cjs/src/clients/exodus/types.d.ts +10 -12
  14. package/dist/cjs/src/clients/kmd/client.d.ts +5 -3
  15. package/dist/cjs/src/clients/kmd/types.d.ts +8 -10
  16. package/dist/cjs/src/clients/mnemonic/client.d.ts +5 -3
  17. package/dist/cjs/src/clients/mnemonic/types.d.ts +7 -7
  18. package/dist/cjs/src/clients/myalgo/client.d.ts +4 -7
  19. package/dist/cjs/src/clients/myalgo/types.d.ts +7 -10
  20. package/dist/cjs/src/clients/pera/client.d.ts +6 -4
  21. package/dist/cjs/src/clients/pera/types.d.ts +7 -10
  22. package/dist/cjs/src/clients/walletconnect2/client.d.ts +7 -5
  23. package/dist/cjs/src/clients/walletconnect2/constants.d.ts +0 -1
  24. package/dist/cjs/src/clients/walletconnect2/types.d.ts +8 -11
  25. package/dist/cjs/src/constants/constants.d.ts +1 -2
  26. package/dist/cjs/src/hooks/useInitializeProviders.d.ts +4 -4
  27. package/dist/cjs/src/index.d.ts +2 -2
  28. package/dist/cjs/src/store/state/debugStore.d.ts +1 -1
  29. package/dist/cjs/src/store/state/walletStore.d.ts +3 -3
  30. package/dist/cjs/src/testUtils/mockClients.d.ts +1 -1
  31. package/dist/cjs/src/types/api.d.ts +3 -3
  32. package/dist/cjs/src/types/node.d.ts +8 -8
  33. package/dist/cjs/src/types/providers.d.ts +40 -12
  34. package/dist/cjs/src/types/utilities.d.ts +1 -0
  35. package/dist/cjs/src/types/wallet.d.ts +9 -12
  36. package/dist/cjs/src/utils/encodeNFDTransactionsArray.d.ts +1 -1
  37. package/dist/cjs/src/utils/initializeProviders.d.ts +1 -1
  38. package/dist/cjs/src/utils/reconnectProviders.d.ts +1 -1
  39. package/dist/esm/index.js +662 -336
  40. package/dist/esm/jest.config.d.ts +1 -1
  41. package/dist/esm/src/clients/algosigner/client.d.ts +4 -3
  42. package/dist/esm/src/clients/algosigner/types.d.ts +12 -12
  43. package/dist/esm/src/clients/base/base.d.ts +4 -3
  44. package/dist/esm/src/clients/daffi/client.d.ts +6 -4
  45. package/dist/esm/src/clients/daffi/types.d.ts +7 -10
  46. package/dist/esm/src/clients/defly/client.d.ts +6 -5
  47. package/dist/esm/src/clients/defly/types.d.ts +8 -11
  48. package/dist/esm/src/clients/exodus/client.d.ts +4 -3
  49. package/dist/esm/src/clients/exodus/types.d.ts +10 -12
  50. package/dist/esm/src/clients/kmd/client.d.ts +5 -3
  51. package/dist/esm/src/clients/kmd/types.d.ts +8 -10
  52. package/dist/esm/src/clients/mnemonic/client.d.ts +5 -3
  53. package/dist/esm/src/clients/mnemonic/types.d.ts +7 -7
  54. package/dist/esm/src/clients/myalgo/client.d.ts +4 -7
  55. package/dist/esm/src/clients/myalgo/types.d.ts +7 -10
  56. package/dist/esm/src/clients/pera/client.d.ts +6 -4
  57. package/dist/esm/src/clients/pera/types.d.ts +7 -10
  58. package/dist/esm/src/clients/walletconnect2/client.d.ts +7 -5
  59. package/dist/esm/src/clients/walletconnect2/constants.d.ts +0 -1
  60. package/dist/esm/src/clients/walletconnect2/types.d.ts +8 -11
  61. package/dist/esm/src/constants/constants.d.ts +1 -2
  62. package/dist/esm/src/hooks/useInitializeProviders.d.ts +4 -4
  63. package/dist/esm/src/index.d.ts +2 -2
  64. package/dist/esm/src/store/state/debugStore.d.ts +1 -1
  65. package/dist/esm/src/store/state/walletStore.d.ts +3 -3
  66. package/dist/esm/src/testUtils/mockClients.d.ts +1 -1
  67. package/dist/esm/src/types/api.d.ts +3 -3
  68. package/dist/esm/src/types/node.d.ts +8 -8
  69. package/dist/esm/src/types/providers.d.ts +40 -12
  70. package/dist/esm/src/types/utilities.d.ts +1 -0
  71. package/dist/esm/src/types/wallet.d.ts +9 -12
  72. package/dist/esm/src/utils/encodeNFDTransactionsArray.d.ts +1 -1
  73. package/dist/esm/src/utils/initializeProviders.d.ts +1 -1
  74. package/dist/esm/src/utils/reconnectProviders.d.ts +1 -1
  75. package/dist/index.d.ts +193 -200
  76. package/package.json +14 -18
package/README.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## Overview
6
6
 
7
- With the `useWallet` hook and utility functions, you can:
7
+ With the `use-wallet`'s hooks and utility functions, you can:
8
8
 
9
9
  - Easily add or remove wallet support with a few lines of code
10
10
  - Configure each wallet provider as needed for your application
@@ -12,15 +12,16 @@ With the `useWallet` hook and utility functions, you can:
12
12
  - Sign and send transactions
13
13
  - Restore sessions for returning users
14
14
 
15
- This library supports most Algorand wallet providers, including Defly, Pera, Daffi, and Exodus (see [Supported Wallet Providers](#supported-wallet-providers) for the full list).
15
+ It provides an abstraction layer that unifies the initialization, connection, and transaction signing logic, eliminating the need to interact with each wallet's individual API.
16
16
 
17
- <!-- It provides an abstraction layer that handles the initialization, connection, and transaction signing logic, eliminating the need to interact with each wallet's individual API. -->
17
+ This library supports most Algorand wallet providers, including Defly, Pera, Daffi, and Exodus (see [Supported Wallet Providers](#supported-wallet-providers) for the full list).
18
18
 
19
- As of version 2.x it includes [WalletConnect 2.0 support](#walletconnect-20-support).
19
+ Version 2.x introduces [WalletConnect 2.0 support](#walletconnect-20-support).
20
20
 
21
21
  ## Table of Contents
22
22
 
23
23
  - [Live Examples](#live-examples)
24
+ - [Requirements](#requirements)
24
25
  - [Installation](#installation)
25
26
  - [Initializing Providers](#initializing-providers)
26
27
  - [The `useWallet` Hook](#the-usewallet-hook)
@@ -32,11 +33,10 @@ As of version 2.x it includes [WalletConnect 2.0 support](#walletconnect-20-supp
32
33
  - [Supported Wallet Providers](#supported-wallet-providers)
33
34
  - [Legacy Wallet Support](#legacy-wallet-support)
34
35
  - [Provider Configuration](#provider-configuration)
35
- - [Default configuration](#default-configuration)
36
- - [Node configuration](#node-configuration)
37
- - [Customize provider support](#customize-provider-support)
38
- - [Provider objects](#provider-objects)
39
- - [Static imports](#static-imports)
36
+ - [Provider Definitions](#provider-definitions)
37
+ - [Node Configuration](#node-configuration)
38
+ - [Algosdk Static Import](#algosdk-static-import)
39
+ - [Full Configuration Example](#full-configuration-example)
40
40
  - [WalletConnect 2.0 Support](#walletconnect-20-support)
41
41
  - [Migration Guide](#migration-guide)
42
42
  - [Local Development](#local-development)
@@ -54,9 +54,13 @@ As of version 2.x it includes [WalletConnect 2.0 support](#walletconnect-20-supp
54
54
 
55
55
  **NFDomains** - https://app.nf.domains/
56
56
 
57
+ ## Requirements
58
+
59
+ Since this library uses [React Hooks](https://react.dev/reference/react), your app will need to be using React 16.8 or higher.
60
+
57
61
  ## Installation
58
62
 
59
- Since this library uses React Hooks, your app will need to be using React 16.8 or higher.
63
+ Commands shown below use `npm install` but you can use `yarn add` or `pnpm add` instead.
60
64
 
61
65
  First, install the library
62
66
 
@@ -70,27 +74,35 @@ If you haven't already, install the Algorand JS SDK
70
74
  npm install algosdk
71
75
  ```
72
76
 
73
- Finally, install the peer dependencies for the wallets you wish to support. To use the default configuration:
77
+ Finally, install any peer dependencies for the wallets you wish to support. For example, to support Defly, Pera, and Daffi wallets:
74
78
 
75
79
  ```bash
76
- npm install @perawallet/connect @blockshake/defly-connect @daffiwallet/connect
80
+ npm install @blockshake/defly-connect @perawallet/connect @daffiwallet/connect
77
81
  ```
78
82
 
79
- Replace `npm install` with `yarn add` or `pnpm add` in the commands above, depending on your preferred package manager.
80
-
81
83
  ## Initializing Providers
82
84
 
83
85
  In the root of your app, initialize the `WalletProvider` with the `useInitializeProviders` hook.
84
86
 
85
- This example initializes `useWallet` with the default configuration options. See [Provider Configuration](#provider-configuration) for more options.
87
+ This example initializes `useWallet` with Defly, Pera, Daffi and Exodus wallet providers. The default node configuration (mainnet via [AlgoNode](https://algonode.io/api/)) is used. See [Provider Configuration](#provider-configuration) for more options.
86
88
 
87
89
  ```jsx
88
90
  import React from 'react'
89
- import { WalletProvider, useInitializeProviders } from '@txnlab/use-wallet'
91
+ import { WalletProvider, useInitializeProviders, PROVIDER_ID } from '@txnlab/use-wallet'
92
+ import { DeflyWalletConnect } from '@blockshake/defly-connect'
93
+ import { PeraWalletConnect } from '@perawallet/connect'
94
+ import { DaffiWalletConnect } from '@daffiwallet/connect'
90
95
 
91
96
  export default function App() {
92
- // default configuration
93
- const providers = useInitializeProviders()
97
+ const providers = useInitializeProviders([
98
+ {
99
+ providers: [
100
+ { id: PROVIDER_ID.DEFLY, clientStatic: DeflyWalletConnect },
101
+ { id: PROVIDER_ID.PERA, clientStatic: PeraWalletConnect },
102
+ { id: PROVIDER_ID.DAFFI, clientStatic: DaffiWalletConnect }
103
+ ]
104
+ }
105
+ ])
94
106
 
95
107
  return (
96
108
  <WalletProvider value={providers}>
@@ -326,11 +338,13 @@ const signTransactions: (
326
338
  ) => Promise<Uint8Array[]>
327
339
  ```
328
340
 
329
- The `signTransactions` function will accept an array of transactions or an array of transaction groups.
341
+ The `signTransactions` function will accept an array of transactions (encoded) or an array of transaction groups.
342
+
343
+ #### Advanced Usage
330
344
 
331
345
  You can optionally specify which transactions should be signed by providing an array of indexes as the second argument, `indexesToSign`.
332
346
 
333
- By setting `returnGroup` to `false`, the returned promise will resolve to an array of signed transactions only. Otherwise it will return flat array of all transactions by default.
347
+ By setting `returnGroup` to `false`, the returned promise will resolve to an array of signed transactions only. Otherwise it will return a flat array of all transactions by default.
334
348
 
335
349
  ### sendTransactions
336
350
 
@@ -369,24 +383,27 @@ useEffect(() => {
369
383
 
370
384
  ## Supported Wallet Providers
371
385
 
386
+ ### Defly Wallet
387
+
388
+ - Website - https://defly.app/
389
+ - Download Defly Wallet - [iOS](https://apps.apple.com/us/app/defly/id1602672723) / [Android](https://play.google.com/store/apps/details?id=io.blockshake.defly.app)
390
+ - Defly Connect - https://github.com/blockshake-io/defly-connect
391
+ - Install dependency - `npm install @blockshake/defly-connect`
392
+
372
393
  ### Pera Wallet
373
394
 
374
395
  - Website - https://perawallet.app/
375
396
  - Download Pera Mobile - [iOS](https://apps.apple.com/us/app/algorand-wallet/id1459898525) / [Android](https://play.google.com/store/apps/details?id=com.algorand.android)
376
397
  - Pera Web Wallet - https://web.perawallet.app/
377
398
  - Pera Connect - https://github.com/perawallet/connect
378
-
379
- ### Defly Wallet
380
-
381
- - Website - https://defly.app/
382
- - Download Defly Wallet - [iOS](https://apps.apple.com/us/app/defly/id1602672723) / [Android](https://play.google.com/store/apps/details?id=io.blockshake.defly.app)
383
- - Defly Connect - https://github.com/blockshake-io/defly-connect
399
+ - Install dependency - `npm install @perawallet/connect`
384
400
 
385
401
  ### Daffi Wallet
386
402
 
387
403
  - Website - https://www.daffi.me/
388
404
  - Download Daffi Wallet - [iOS](https://apps.apple.com/kn/app/daffiwallet/id1659597876) / [Android](https://play.google.com/store/apps/details?id=me.daffi.daffi_wallet)
389
405
  - Daffi Connect - https://github.com/RDinitiativ/daffiwallet_connect
406
+ - Install dependency - `npm install @daffiwallet/connect`
390
407
 
391
408
  ### WalletConnect
392
409
 
@@ -394,6 +411,7 @@ useEffect(() => {
394
411
  - Documentation - https://docs.walletconnect.com/
395
412
  - WalletConnect Cloud - https://cloud.walletconnect.com/
396
413
  - Web3Modal - https://web3modal.com/
414
+ - Install dependency - `npm install @walletconnect/modal-sign-html`
397
415
 
398
416
  ### Exodus Wallet
399
417
 
@@ -408,7 +426,7 @@ useEffect(() => {
408
426
 
409
427
  Support for these wallets will be removed in a future release.
410
428
 
411
- ### AlgoSigner
429
+ ### AlgoSigner (deprecated)
412
430
 
413
431
  - GitHub - https://github.com/PureStake/algosigner
414
432
  - EOL Press Release - https://www.algorand.foundation/news/algosigner-support-ending
@@ -417,28 +435,37 @@ Support for these wallets will be removed in a future release.
417
435
 
418
436
  - Website - https://wallet.myalgo.com/home
419
437
  - FAQ - https://wallet.myalgo.com/home#faq
438
+ - Install dependency - `npm install @randlabs/myalgo-connect`
420
439
 
421
440
  ## Provider Configuration
422
441
 
423
- ### Default Configuration
442
+ The `useInitializeProviders` hook accepts a configuration object with the following properties:
424
443
 
425
- Calling `useInitializeProviders` with no arguments initializes the default supported wallet providers with the default node configuration:
444
+ | Key | Type | Default Value |
445
+ | ---------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------- |
446
+ | providers | `Array<ProviderDef>` | _required_ |
447
+ | nodeConfig.network | `string \| undefined` | `'mainnet'` |
448
+ | nodeConfig.nodeServer | `string \| undefined` | `'https://mainnet-api.algonode.cloud'` |
449
+ | nodeConfig.nodeToken | `string \| algosdk.AlgodTokenHeader \| algosdk.CustomTokenHeader \| algosdk.BaseHTTPClient \| undefined` | `''` |
450
+ | nodeConfig.nodePort | `string \| number \| undefined` | `443` |
451
+ | nodeConfig.nodeHeaders | `Record<string, string> \| undefined` | |
452
+ | algosdkStatic | `typeof algosdk \| undefined` | |
426
453
 
427
- | Key | Default Value |
428
- | --------------------- | ------------------------------------------------------------------------------ |
429
- | providers | `[PROVIDER_ID.PERA, PROVIDER_ID.DEFLY, PROVIDER_ID.DAFFI, PROVIDER_ID.EXODUS]` |
430
- | nodeConfig.network | `'mainnet'` |
431
- | nodeConfig.nodeServer | `'https://mainnet-api.algonode.cloud'` |
432
- | nodeConfig.nodeToken | `''` |
433
- | nodeConfig.nodePort | `443` |
434
- | algosdkStatic | `undefined` |
454
+ ### Provider Definitions
455
+
456
+ The `providers` property is required, and must include at least one provider definition object. This is how you specify which wallet providers you wish to support in your app.
457
+
458
+ If a wallet provider has an SDK library dependency, make sure you have installed the package. Then set the provider definition's `clientStatic` property to the dependency's exported module. For example, to use the Defly Wallet provider, you must install the `@blockshake/defly-connect` package and set its `clientStatic` property to `DeflyWalletConnect`.
435
459
 
436
460
  ```jsx
437
461
  import React from 'react'
438
- import { WalletProvider, useInitializeProviders } from '@txnlab/use-wallet'
462
+ import { WalletProvider, useInitializeProviders, PROVIDER_ID } from '@txnlab/use-wallet'
463
+ import { DeflyWalletConnect } from '@blockshake/defly-connect'
439
464
 
440
465
  export default function App() {
441
- const providers = useInitializeProviders()
466
+ const providers = useInitializeProviders({
467
+ providers: [{ id: PROVIDER_ID.DEFLY, clientStatic: DeflyWalletConnect }]
468
+ })
442
469
 
443
470
  return (
444
471
  <WalletProvider value={providers}>
@@ -448,11 +475,17 @@ export default function App() {
448
475
  }
449
476
  ```
450
477
 
478
+ If a provider has options that can be configured, you can set them in the `clientOptions` property. In most cases these would be the options that are passed to the provider's SDK library when it is initialized. See each [supported provider](#supported-wallet-providers)'s documentation for more details.
479
+
480
+ While most client options are optional, the WalletConnect provider has required `clientOptions` that must be set. See the [WalletConnect 2.0](#walletconnect-20-support) section below for more details.
481
+
482
+ **TypeScript:** The provider definitions are type-safe, so your IDE should be able to provide autocomplete suggestions for the client's available options based on the `id` that is set.
483
+
451
484
  ### Node configuration
452
485
 
453
- To configure the Algorand node that providers will use to send transactions, you can set the `nodeConfig` property. The `network` property should be specified as `mainnet`, `testnet`, `betanet` or the name of your local development network.
486
+ To configure the Algorand node that providers will use to send transactions, you can set the `nodeConfig` property. The `network` property should be specified as `mainnet`, `testnet`, `betanet` or the name of your local development network\*.
454
487
 
455
- Refer to your wallet providers' documentation to see which networks they support.
488
+ \* _Refer to each wallet providers' documentation to see which networks they support._
456
489
 
457
490
  ```jsx
458
491
  const providers = await initializeProviders({
@@ -465,45 +498,33 @@ const providers = await initializeProviders({
465
498
  })
466
499
  ```
467
500
 
468
- ### Customize provider support
501
+ ### Algosdk Static Import
469
502
 
470
- You can choose which wallet providers to support by setting the `providers` property to an array of provider IDs or [provider objects](#provider-objects). The example below shows provider IDs being used.
503
+ By default, `use-wallet` dynamically imports the `algosdk` peer dependency installed in your app, to reduce bundle size.
471
504
 
472
- ```jsx
473
- // Only initialize Pera and Defly providers
474
- const providers = useInitializeProviders({
475
- providers: [PROVIDER_ID.PERA, PROVIDER_ID.DEFLY]
476
- })
477
- ```
478
-
479
- ### Provider objects
480
-
481
- Some wallet providers have accompanying client libraries that can be configured. You can pass an object to the providers array to set `clientOptions`, as shown below.
505
+ Some React frameworks, like [Remix](https://remix.run/), do not support dynamic imports. To get around this, you can set the optional `algosdkStatic` root property to the imported `algosdk` module.
482
506
 
483
507
  ```jsx
484
- const providers = useInitializeProviders({
485
- providers: [
486
- PROVIDER_ID.DEFLY, // use default options for Defly Connect
487
- { id: PROVIDER_ID.PERA, clientOptions: { shouldShowSignTxnToast: false } },
488
- { id: PROVIDER_ID.MYALGO, clientOptions: { disableLedgerNano: false } },
489
- PROVIDER_ID.EXODUS // Exodus has no client library
490
- ]
491
- })
492
- ```
493
-
494
- See each provider's documentation for the available client options.
495
-
496
- You will need to use provider objects for [static imports](#static-imports), and for [WalletConnect 2.0](#walletconnect-20) support.
497
-
498
- **TypeScript:** The provider objects are type-safe, so your IDE should be able to provide autocomplete suggestions for the client's available options based on the `id` that is set.
499
-
500
- ### Static Imports
508
+ import React from 'react'
509
+ import algosdk from 'algosdk'
510
+ import { PROVIDER_ID, WalletProvider, useInitializeProviders } from '@txnlab/use-wallet'
511
+ import { DeflyWalletConnect } from '@blockshake/defly-connect'
501
512
 
502
- By default, `use-wallet` dynamically imports all of the dependencies for the providers, as well as `algosdk`, to reduce bundle size.
513
+ export default function App() {
514
+ const providers = useInitializeProviders({
515
+ providers: [{ id: PROVIDER_ID.DEFLY, clientStatic: DeflyWalletConnect }],
516
+ algosdkStatic: algosdk
517
+ })
503
518
 
504
- Some React frameworks, like [Remix](https://remix.run/), do not support dynamic imports. To get around this, provider clients can be imported in your application and passed to the provider objects `clientStatic` property.
519
+ return (
520
+ <WalletProvider value={providers}>
521
+ <div className="App">{/* ... */}</div>
522
+ </WalletProvider>
523
+ )
524
+ }
525
+ ```
505
526
 
506
- Set the imported `algosdk` to the `algosdkStatic` root property.
527
+ ### Full Configuration Example
507
528
 
508
529
  ```jsx
509
530
  import React from 'react'
@@ -511,16 +532,18 @@ import algosdk from 'algosdk'
511
532
  import { PROVIDER_ID, WalletProvider, useInitializeProviders } from '@txnlab/use-wallet'
512
533
  import { DeflyWalletConnect } from '@blockshake/defly-connect'
513
534
  import { PeraWalletConnect } from '@perawallet/connect'
514
- import { Web3ModalSign } from '@web3modal/sign-html'
535
+ import { DaffiWalletConnect } from '@daffiwallet/connect'
536
+ import { WalletConnectModalSign } from '@walletconnect/modal-sign-html'
515
537
 
516
538
  export default function App() {
517
539
  const providers = useInitializeProviders({
518
540
  providers: [
519
- { id: PROVIDER_ID.PERA, clientStatic: PeraWalletConnect },
520
541
  { id: PROVIDER_ID.DEFLY, clientStatic: DeflyWalletConnect },
542
+ { id: PROVIDER_ID.PERA, clientStatic: PeraWalletConnect },
543
+ { id: PROVIDER_ID.DAFFI, clientStatic: DaffiWalletConnect },
521
544
  {
522
545
  id: PROVIDER_ID.WALLETCONNECT,
523
- clientStatic: Web3ModalSign,
546
+ clientStatic: WalletConnectModalSign,
524
547
  clientOptions: {
525
548
  projectId: '<YOUR_PROJECT_ID>',
526
549
  metadata: {
@@ -528,11 +551,20 @@ export default function App() {
528
551
  description: 'Example Dapp',
529
552
  url: '#',
530
553
  icons: ['https://walletconnect.com/walletconnect-logo.png']
554
+ },
555
+ modalOptions: {
556
+ themeMode: 'dark'
531
557
  }
532
558
  }
533
559
  },
534
- PROVIDER_ID.EXODUS
560
+ { id: PROVIDER_ID.EXODUS }
535
561
  ],
562
+ nodeConfig: {
563
+ network: 'mainnet',
564
+ nodeServer: 'https://mainnet-api.algonode.cloud',
565
+ nodeToken: '',
566
+ nodePort: '443'
567
+ }
536
568
  algosdkStatic: algosdk
537
569
  })
538
570
 
@@ -546,21 +578,22 @@ export default function App() {
546
578
 
547
579
  ## WalletConnect 2.0 Support
548
580
 
549
- `use-wallet` v2 introduces support for WalletConnect 2.0. This is a major upgrade to the WalletConnect protocol, and introduces a number of breaking changes for app developers to contend with.
581
+ `use-wallet` v2 introduces support for WalletConnect 2.0. This is a major upgrade to the WalletConnect protocol, and introduces a number of breaking changes for app developers.
550
582
 
551
583
  However, Algorand apps with `use-wallet` will be able to support the new protocol with minimal effort:
552
584
 
553
585
  1. **Obtain a project ID** - You will need to obtain a project ID from [WalletConnect Cloud](https://cloud.walletconnect.com/). This is a simple process, and there is no waiting period. Every app will need its own unique project ID.
554
586
 
555
- 2. **Install peer dependency** - Install `@web3modal/sign-html`.
587
+ 2. **Install client library** - Install `@walletconnect/modal-sign-html` and set `clientStatic` to the imported `WalletConnectModalSign` module.
556
588
 
557
- 3. **Update provider configuration** - You will need to use a provider object to initialize WalletConnect, and pass your `clientOptions` as shown below
589
+ 3. **Required options** - Set the required `clientOptions` as shown below
558
590
 
559
591
  ```jsx
560
592
  const providers = useInitializeProviders({
561
593
  providers: [
562
594
  {
563
595
  id: PROVIDER_ID.WALLETCONNECT,
596
+ clientStatic: WalletConnectModalSign,
564
597
  clientOptions: {
565
598
  projectId: '<YOUR_PROJECT_ID>',
566
599
  metadata: {
@@ -576,9 +609,7 @@ const providers = useInitializeProviders({
576
609
  })
577
610
  ```
578
611
 
579
- Since it requires the unique `projectId`, the WalletConnect provider is not initialized by default. This is a change from v1. If you want to support WalletConnect, it must be added to the `providers` array.
580
-
581
- See [Migrating to WalletConnect 2.0](#migrating-to-walletconnect-20) below for more information.
612
+ **IMPORTANT:** Only wallets that have been upgraded to support WalletConnect 2.0 will be able to connect to your app with this provider.
582
613
 
583
614
  ### "Module not found" errors in Next.js 13
584
615
 
@@ -603,31 +634,38 @@ See https://github.com/WalletConnect/walletconnect-monorepo/issues/1908#issuecom
603
634
 
604
635
  Version 2.x is a major version bump, and includes some breaking changes from 1.x.
605
636
 
606
- ### initializeProviders
637
+ ### useInitializeProviders
607
638
 
608
- `initializeProviders` is now asynchronous, and must be called from inside a `useEffect` hook.
639
+ The most significant change is how wallet providers are initialized.
609
640
 
610
- To simplify this, the `useInitializeProviders` hook is now provided, which calls `initializeProviders` internally. It accepts a single object as an argument.
641
+ `initializeProviders` has been replaced by the `useInitializeProviders` hook. It accepts a single configuration object as an argument. Its properties correspond to the three arguments passed to its predecessor.
611
642
 
612
- The providers array should be set as the `providers` property.
643
+ The `providers` property is an array of provider definition objects, with an `id` set to a `PROVIDER_ID` constant. Wallet provider SDKs are no longer dynamically imported by their client classes. They must be statically imported and set as the `clientStatic` property.
613
644
 
614
645
  ```diff
615
- - const providers = initializeProviders([PROVIDER_ID.PERA, PROVIDER_ID.DEFLY])
646
+ - const providers = initializeProviders([PROVIDER_ID.PERA, PROVIDER_ID.DEFLY, PROVIDER_ID.EXODUS])
616
647
  + const providers = useInitializeProviders({
617
- + providers: [PROVIDER_ID.PERA, PROVIDER_ID.DEFLY]
648
+ + providers: [
649
+ + { id: PROVIDER_ID.PERA, clientStatic: PeraWalletConnect },
650
+ + { id: PROVIDER_ID.DEFLY, clientStatic: DeflyWalletConnect },
651
+ + { id: PROVIDER_ID.EXODUS }
652
+ + ]
618
653
  + })
619
654
  ```
620
655
 
656
+ We've also done away with the concept of "default" providers. Each provider you wish to support in your app must be explicitly defined in the `providers` array.
657
+
621
658
  Node configuration should be set as the `nodeConfig` property.
622
659
 
623
660
  ```diff
624
- - const providers = initializeProviders([], {
661
+ - const providers = initializeProviders([...], {
625
662
  - network: 'testnet',
626
663
  - nodeServer: 'https://testnet-api.algonode.cloud',
627
664
  - nodeToken: '',
628
665
  - nodePort: '443'
629
666
  - })
630
667
  + const providers = useInitializeProviders({
668
+ + providers: [...],
631
669
  + nodeConfig: {
632
670
  + network: 'testnet',
633
671
  + nodeServer: 'https://testnet-api.algonode.cloud',
@@ -641,26 +679,27 @@ See [Provider Configuration](#provider-configuration) for more details.
641
679
 
642
680
  ### shouldShowSignTxnToast
643
681
 
644
- Pera Connect and Defly Connect both have a `shouldShowSignTxnToast` option that is set to `true` by default. `use-wallet` v1 set this to `false` by default, and required setting the option back to `true` to achieve the libraries' default behavior.
682
+ Pera Connect, Defly Connect and Daffi Connect share a `shouldShowSignTxnToast` option that is set to `true` by default. `use-wallet` v1 set these to `false` by default, and required setting the option back to `true` to achieve the libraries' default behavior.
645
683
 
646
- In v2 this option is set to `true` by default. If your app has this option explicitly set you can remove it from your configuration. If you wish to disable the toast(s), you must now explicitly set the option to `false`.
684
+ In v2 this option is set to `true` by default. If your app has this option set to `true` you can remove it from your configuration. If you wish to disable the toast(s), you must now explicitly set the option to `false`.
647
685
 
648
686
  ```jsx
649
687
  const providers = useInitializeProviders({
650
688
  providers: [
651
689
  { id: PROVIDER_ID.DEFLY, clientOptions: { shouldShowSignTxnToast: false } },
652
- { id: PROVIDER_ID.PERA, clientOptions: { shouldShowSignTxnToast: false } }
690
+ { id: PROVIDER_ID.PERA, clientOptions: { shouldShowSignTxnToast: false } },
691
+ { id: PROVIDER_ID.DAFFI, clientOptions: { shouldShowSignTxnToast: false } }
653
692
  // other providers...
654
693
  ]
655
694
  })
656
695
  ```
657
696
 
658
- ### WalletConnect provider
697
+ ### WalletConnect peer dependencies
659
698
 
660
- The WalletConnect provider now supports WalletConnect 2.0. To continue supporting this provider, or to add support to your application, you must install the `@web3modal/sign-html` package.
699
+ The WalletConnect provider now supports WalletConnect 2.0. To continue supporting this provider, or to add support to your application, you must install the `@walletconnect/modal-sign-html` package.
661
700
 
662
701
  ```bash
663
- npm install @web3modal/sign-html
702
+ npm install @walletconnect/modal-sign-html
664
703
  ```
665
704
 
666
705
  The peer dependencies for WalletConnect 1.x should be uninstalled.
@@ -669,7 +708,7 @@ The peer dependencies for WalletConnect 1.x should be uninstalled.
669
708
  npm uninstall @walletconnect/client @json-rpc-tools/utils algorand-walletconnect-qrcode-modal
670
709
  ```
671
710
 
672
- WalletConnect is no longer initialized by default. To add support for WalletConnect, you must add it to the `providers` array, and pass your `clientOptions` as described in [WalletConnect 2.0 Support](#walletconnect-20-support) above.
711
+ See [WalletConnect 2.0 Support](#walletconnect-20-support) for more details.
673
712
 
674
713
  ## Local Development
675
714