zano_web3 6.14.0 → 6.15.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 +23 -0
- package/package.json +1 -1
- package/server/src/server.ts +19 -0
- package/server/src/types.ts +6 -0
package/README.md
CHANGED
|
@@ -204,6 +204,7 @@ export interface Wallet {
|
|
|
204
204
|
- `sendTransfer(assetId: string, address: string, amount: string)`: Sends a transfer to an address.
|
|
205
205
|
- `getBalances()`: Retrieves the balances.
|
|
206
206
|
- `validateWallet(rpcUrl: string, authData: AuthData)`: Validates the wallet.
|
|
207
|
+
- `getAliasDetails(alias:string)` : Retrieves information about a specific address alias.
|
|
207
208
|
|
|
208
209
|
|
|
209
210
|
#### 1. **Updating Wallet RPC URL**
|
|
@@ -370,6 +371,28 @@ import { AuthData } from "./types";
|
|
|
370
371
|
})();
|
|
371
372
|
```
|
|
372
373
|
|
|
374
|
+
#### 9. **Get Alias details**
|
|
375
|
+
|
|
376
|
+
```javascript
|
|
377
|
+
import { ServerWallet } from "zano_web3/server";
|
|
378
|
+
|
|
379
|
+
const alias = "alias";
|
|
380
|
+
|
|
381
|
+
(async (alias) => {
|
|
382
|
+
const zanoServerAPI = new ServerWallet({
|
|
383
|
+
walletUrl: "http://127.0.0.1:11211/json_rpc",
|
|
384
|
+
daemonUrl: "http://127.0.0.1:11211/json_rpc"
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
try {
|
|
388
|
+
const aliasDetails = await zanoServerAPI.getAliasDetails(alias);
|
|
389
|
+
console.log(aliasDetails);
|
|
390
|
+
} catch (error) {
|
|
391
|
+
console.error(error.message);
|
|
392
|
+
}
|
|
393
|
+
})(alias);
|
|
394
|
+
```
|
|
395
|
+
|
|
373
396
|
## Requirements
|
|
374
397
|
|
|
375
398
|
- Correct RPC URLs for the wallet and daemon.
|
package/package.json
CHANGED
package/server/src/server.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
ValidationParams,
|
|
8
8
|
BalanceInfo,
|
|
9
9
|
TxInfo,
|
|
10
|
+
AliasDetails,
|
|
10
11
|
} from "./types";
|
|
11
12
|
|
|
12
13
|
import { ZANO_ASSET_ID, ZanoError } from "./utils";
|
|
@@ -292,6 +293,24 @@ class ServerWallet {
|
|
|
292
293
|
|
|
293
294
|
return txs.data.result as TxInfo;
|
|
294
295
|
}
|
|
296
|
+
async getAliasDetails(alias: string) {
|
|
297
|
+
try {
|
|
298
|
+
const response = await this.fetchDaemon("get_alias_details", {
|
|
299
|
+
alias,
|
|
300
|
+
});
|
|
301
|
+
if (response.data.result) {
|
|
302
|
+
return response.data.result as AliasDetails;
|
|
303
|
+
} else {
|
|
304
|
+
throw new ZanoError(
|
|
305
|
+
`Error fetching alias ${alias}`,
|
|
306
|
+
"ALIAS_FETCH_ERROR"
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
} catch {
|
|
310
|
+
throw new ZanoError("Failed to fetch alias", "ALIAS_FETCH_ERROR");
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
|
|
295
314
|
}
|
|
296
315
|
|
|
297
316
|
export default ServerWallet;
|