Merge branches 'main' and 'main' of https://github.com/hyle-team/zano_web3
This commit is contained in:
commit
a09a16dbe4
3 changed files with 48 additions and 0 deletions
23
README.md
23
README.md
|
|
@ -204,6 +204,7 @@ export interface Wallet {
|
|||
- `sendTransfer(assetId: string, address: string, amount: string)`: Sends a transfer to an address.
|
||||
- `getBalances()`: Retrieves the balances.
|
||||
- `validateWallet(rpcUrl: string, authData: AuthData)`: Validates the wallet.
|
||||
- `getAliasDetails(alias:string)` : Retrieves information about a specific address alias.
|
||||
|
||||
|
||||
#### 1. **Updating Wallet RPC URL**
|
||||
|
|
@ -370,6 +371,28 @@ import { AuthData } from "./types";
|
|||
})();
|
||||
```
|
||||
|
||||
#### 9. **Get Alias details**
|
||||
|
||||
```javascript
|
||||
import { ServerWallet } from "zano_web3/server";
|
||||
|
||||
const alias = "alias";
|
||||
|
||||
(async (alias) => {
|
||||
const zanoServerAPI = new ServerWallet({
|
||||
walletUrl: "http://127.0.0.1:11211/json_rpc",
|
||||
daemonUrl: "http://127.0.0.1:11211/json_rpc"
|
||||
});
|
||||
|
||||
try {
|
||||
const aliasDetails = await zanoServerAPI.getAliasDetails(alias);
|
||||
console.log(aliasDetails);
|
||||
} catch (error) {
|
||||
console.error(error.message);
|
||||
}
|
||||
})(alias);
|
||||
```
|
||||
|
||||
## Requirements
|
||||
|
||||
- Correct RPC URLs for the wallet and daemon.
|
||||
|
|
@ -7,6 +7,7 @@ import {
|
|||
ValidationParams,
|
||||
BalanceInfo,
|
||||
TxInfo,
|
||||
AliasDetails,
|
||||
} from "./types";
|
||||
|
||||
import { ZANO_ASSET_ID, ZanoError } from "./utils";
|
||||
|
|
@ -292,6 +293,24 @@ class ServerWallet {
|
|||
|
||||
return txs.data.result as TxInfo;
|
||||
}
|
||||
async getAliasDetails(alias: string) {
|
||||
try {
|
||||
const response = await this.fetchDaemon("get_alias_details", {
|
||||
alias,
|
||||
});
|
||||
if (response.data.result) {
|
||||
return response.data.result as AliasDetails;
|
||||
} else {
|
||||
throw new ZanoError(
|
||||
`Error fetching alias ${alias}`,
|
||||
"ALIAS_FETCH_ERROR"
|
||||
);
|
||||
}
|
||||
} catch {
|
||||
throw new ZanoError("Failed to fetch alias", "ALIAS_FETCH_ERROR");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default ServerWallet;
|
||||
|
|
|
|||
|
|
@ -100,4 +100,10 @@ export interface TxInfo {
|
|||
};
|
||||
total_transfers: number;
|
||||
transfers: Transfer[];
|
||||
}
|
||||
|
||||
export interface AliasDetails {
|
||||
address: string;
|
||||
comment: string;
|
||||
tracking_key: string;
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue