@txnlab/use-wallet 2.1.1 → 2.1.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.
Files changed (2) hide show
  1. package/README.md +31 -17
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -138,19 +138,19 @@ import React from 'react'
138
138
  import { WalletProvider, useInitializeProviders, PROVIDER_ID } from '@txnlab/use-wallet'
139
139
 
140
140
  const getDynamicDeflyWalletConnect = async () => {
141
- const DeflyWalletConnect = (await import("@blockshake/defly-connect")).DeflyWalletConnect;
142
- return DeflyWalletConnect;
143
- };
141
+ const DeflyWalletConnect = (await import('@blockshake/defly-connect')).DeflyWalletConnect
142
+ return DeflyWalletConnect
143
+ }
144
144
 
145
145
  const getDynamicPeraWalletConnect = async () => {
146
- const PeraWalletConnect = (await import("@perawallet/connect")).PeraWalletConnect;
147
- return PeraWalletConnect;
148
- };
146
+ const PeraWalletConnect = (await import('@perawallet/connect')).PeraWalletConnect
147
+ return PeraWalletConnect
148
+ }
149
149
 
150
150
  const getDynamicDaffiWalletConnect = async () => {
151
- const DaffiWalletConnect = (await import("@daffiwallet/connect")).DaffiWalletConnect;
152
- return DaffiWalletConnect;
153
- };
151
+ const DaffiWalletConnect = (await import('@daffiwallet/connect')).DaffiWalletConnect
152
+ return DaffiWalletConnect
153
+ }
154
154
 
155
155
  export default function App() {
156
156
  const providers = useInitializeProviders({
@@ -170,7 +170,6 @@ export default function App() {
170
170
  }
171
171
  ```
172
172
 
173
-
174
173
  ## The `useWallet` Hook
175
174
 
176
175
  The `useWallet` hook is used to access wallet provider and account state, send unsigned transactions to be signed, and send signed transactions to the node from anywhere in your app. It returns an object with the following properties:
@@ -335,14 +334,10 @@ Here is an example of a signing and sending simple pay transaction using `signTr
335
334
  ```jsx
336
335
  import React from 'react'
337
336
  import algosdk from 'algosdk'
338
- import {
339
- useWallet,
340
- DEFAULT_NODE_BASEURL,
341
- DEFAULT_NODE_TOKEN,
342
- DEFAULT_NODE_PORT
343
- } from '@txnlab/use-wallet'
337
+ import { useWallet } from '@txnlab/use-wallet'
338
+ import { NODE_BASEURL, NODE_TOKEN, NODE_PORT } from '@/constants'
344
339
 
345
- const algodClient = new algosdk.Algodv2(DEFAULT_NODE_TOKEN, DEFAULT_NODE_BASEURL, DEFAULT_NODE_PORT)
340
+ const algodClient = new algosdk.Algodv2(NODE_TOKEN, NODE_BASEURL, NODE_PORT)
346
341
 
347
342
  export default function Transact() {
348
343
  const { activeAddress, signTransactions, sendTransactions } = useWallet()
@@ -558,6 +553,25 @@ const providers = useInitializeProviders({
558
553
  })
559
554
  ```
560
555
 
556
+ The node configuration must match the network your app's algod client is connected to. The recommended approach is to define the node configuration variables as constants and pass them to both the `useInitializeProviders` hook and the `algosdk.Algodv2` constructor.
557
+
558
+ ```jsx
559
+ import algosdk from 'algosdk'
560
+ import { NODE_BASEURL, NODE_TOKEN, NODE_PORT } from '@/constants'
561
+
562
+ const algodClient = new algosdk.Algodv2(NODE_TOKEN, NODE_BASEURL, NODE_PORT)
563
+
564
+ const providers = useInitializeProviders({
565
+ providers: [...],
566
+ nodeConfig: {
567
+ network: 'testnet',
568
+ nodeServer: NODE_BASEURL,
569
+ nodeToken: NODE_TOKEN,
570
+ nodePort: NODE_PORT
571
+ }
572
+ })
573
+ ```
574
+
561
575
  ### Algosdk Static Import
562
576
 
563
577
  By default, the providers dynamically import the `algosdk` peer dependency installed in your app, to reduce bundle size.
package/package.json CHANGED
@@ -12,7 +12,7 @@
12
12
  "url": "https://github.com/txnlab/use-wallet/issues"
13
13
  },
14
14
  "homepage": "https://txnlab.github.io/use-wallet",
15
- "version": "2.1.1",
15
+ "version": "2.1.2",
16
16
  "description": "React hooks for using Algorand compatible wallets in dApps.",
17
17
  "scripts": {
18
18
  "dev": "yarn storybook",