@txnlab/use-wallet 2.1.3 → 2.3.0

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 CHANGED
@@ -45,6 +45,11 @@ Version 2.x introduces [WalletConnect 2.0 support](#walletconnect-20-support).
45
45
  - [WalletConnect 2.0 Support](#walletconnect-20-support)
46
46
  - [Defly Wallet (iOS) beta](#defly-wallet-ios-beta)
47
47
  - [Pera Wallet (Android) beta](#pera-wallet-android-beta)
48
+ - ["Module not found" errors in Next.js 13](#module-not-found-errors-in-nextjs-13)
49
+ - [Custom Provider](#custom-provider)
50
+ - [Custom Provider example](#custom-provider-example)
51
+ - [Initializing Custom Provider](#initializing-custom-provider)
52
+ - [Manual Provider (example implementation)](#manual-provider-example-implementation)
48
53
  - [Migration Guide](#migration-guide)
49
54
  - [Local Development](#local-development)
50
55
  - [Support](#support)
@@ -476,6 +481,10 @@ useEffect(() => {
476
481
 
477
482
  - Documentation - https://developer.algorand.org/docs/rest-apis/kmd
478
483
 
484
+ ### Custom
485
+
486
+ - Documentation - [Custom Provider](#custom-provider)
487
+
479
488
  ## Legacy Wallet Support
480
489
 
481
490
  Support for these wallets will be removed in a future release.
@@ -714,6 +723,79 @@ module.exports = nextConfig
714
723
 
715
724
  See https://github.com/WalletConnect/walletconnect-monorepo/issues/1908#issuecomment-1487801131
716
725
 
726
+ ## Custom Provider
727
+
728
+ As of v2.2.0, you can now add support for a **custom provider** that delegates wallet actions to your application. This is useful if you want to support a wallet that is not yet integrated with UseWallet, or if your application requires any additional, custom interactions.
729
+
730
+ ### Custom Provider example
731
+
732
+ ```jsx
733
+ import { PROVIDER_ID, Metadata, CustomProvider } from '@txnlab/use-wallet'
734
+ import type _algosdk from 'algosdk'
735
+
736
+ export class MyCustomProvider implements CustomProvider {
737
+ algosdk: typeof _algosdk
738
+
739
+ constructor(algosdk: typeof _algosdk, ...) {
740
+ this.algosdk = algosdk
741
+ // ...
742
+ }
743
+
744
+ async connect(metadata: Metadata): Promise<Wallet> {
745
+ // connect to wallet
746
+ }
747
+
748
+ async disconnect(): Promise<void> {
749
+ // disconnect from wallet
750
+ }
751
+
752
+ async reconnect(metadata: Metadata): Promise<Wallet | null> {
753
+ // reconnect to wallet
754
+ }
755
+
756
+ async signTransactions(
757
+ connectedAccounts: string[],
758
+ txnGroups: Uint8Array[] | Uint8Array[][],
759
+ indexesToSign?: number[] | undefined,
760
+ returnGroup?: boolean | undefined
761
+ ): Promise<Uint8Array[]> {
762
+ // sign transactions
763
+ }
764
+ }
765
+ ```
766
+
767
+ ### Initializing Custom Provider
768
+
769
+ ```jsx
770
+ const providers = useInitializeProviders({
771
+ providers: [
772
+ {
773
+ id: PROVIDER_ID.CUSTOM,
774
+ clientOptions: {
775
+ name: 'My Custom Provider',
776
+ icon: 'data:image/png;base64...',
777
+ getProvider: (params: {
778
+ network?: Network
779
+ algod?: algosdk.Algodv2
780
+ algosdkStatic?: typeof algosdk
781
+ }) => {
782
+ return new MyCustomProvider(params.algosdkStatic ?? algosdk)
783
+ }
784
+ }
785
+ }
786
+ // other providers...
787
+ ]
788
+ })
789
+ ```
790
+
791
+ ### Manual Provider (example implementation)
792
+
793
+ See [TestManualProvider.ts](https://github.com/TxnLab/use-wallet/blob/main/src/components/Example/TestManualProvider.tsx) for a full example implementation of a custom provider. You can try it by running
794
+
795
+ ```bash
796
+ yarn storybook
797
+ ```
798
+
717
799
  ## Migration Guide
718
800
 
719
801
  Version 2.x is a major version bump, and includes some breaking changes from 1.x.