zano_web3 4.6.0 → 4.7.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.
Files changed (2) hide show
  1. package/README.md +66 -13
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -9,6 +9,7 @@
9
9
  - **Local Storage Support**: Optionally store wallet credentials in local storage.
10
10
  - **Customizable**: Offers hooks for various connection lifecycle events.
11
11
  - **Error Handling**: Provides a structured way to handle errors during the connection process.
12
+ - **Alias Management**: Allows retrieving and creating aliases.
12
13
 
13
14
  ## Installation
14
15
 
@@ -88,26 +89,78 @@ zanoWallet.setWalletCredentials({
88
89
  });
89
90
  ```
90
91
 
91
- ## Using the `useZanoWallet` Hook
92
+ ### Retrieving Wallet Data
92
93
 
93
- The `useZanoWallet` hook is a custom React hook provided by the `zano_web3` library. It simplifies the process of interacting with the ZanoWallet extension in a React application.
94
+ You can retrieve the wallet data using the `getWallet` method:
94
95
 
95
- This hook is designed to handle server-side rendering (SSR) limitations by ensuring that it only runs on the client-side. This means that any code using the `useZanoWallet` hook will not be executed during server-side rendering, but will work as expected once the application is running in the browser.
96
+ ```typescript
97
+ const wallet = await zanoWallet.getWallet();
98
+ console.log('Wallet data:', wallet);
99
+ ```
100
+
101
+ ### Getting Address by Alias
96
102
 
97
- To use the `useZanoWallet` hook, you can import it from the `zano_web3` library and call it within a functional component:
103
+ To get an address by alias, use the `getAddressByAlias` method:
98
104
 
99
105
  ```typescript
100
- import { useZanoWallet } from 'zano_web3';
106
+ const address = await zanoWallet.getAddressByAlias('exampleAlias');
107
+ console.log('Address:', address);
108
+ ```
109
+
110
+ ### Creating an Alias
111
+
112
+ To create a new alias, use the `createAlias` method:
113
+
114
+ ```typescript
115
+ const newAliasData = await zanoWallet.createAlias('newAlias');
116
+ console.log('Alias created:', newAliasData);
117
+ ```
118
+
119
+
120
+ ## Exported Types
101
121
 
102
- function MyComponent() {
103
-
104
- const wallet = useZanoWallet({
105
- // same params as for new ZanoWallet
106
- });
122
+ The following TypeScript interfaces are exported by the `zano_web3` library.
123
+ You can import them directly from library:
124
+
125
+ ```typescript
126
+ import { Wallet, Asset, Transfer, Transaction } from 'zano_web3';
127
+ ```
128
+
129
+ ```typescript
130
+ export interface Asset {
131
+ name: string;
132
+ ticker: string;
133
+ assetId: string;
134
+ decimalPoint: number;
135
+ balance: string;
136
+ unlockedBalance: string;
137
+ }
138
+
139
+ export interface Transfer {
140
+ amount: string;
141
+ assetId: string;
142
+ incoming: boolean;
143
+ }
144
+
145
+ export interface Transaction {
146
+ isConfirmed: boolean;
147
+ txHash: string;
148
+ blobSize: number;
149
+ timestamp: number;
150
+ height: number;
151
+ paymentId: string;
152
+ comment: string;
153
+ fee: string;
154
+ isInitiator: boolean;
155
+ transfers: Transfer[];
156
+ }
107
157
 
108
- return (
109
- <div>Your component...</div>
110
- );
158
+ export interface Wallet {
159
+ address: string;
160
+ alias: string;
161
+ balance: string;
162
+ assets: Asset[];
163
+ transactions: Transaction[];
111
164
  }
112
165
  ```
113
166
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zano_web3",
3
- "version": "4.6.0",
3
+ "version": "4.7.0",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",