From c7d26cc065e6d6823698d9d918f5f02223d1ea15 Mon Sep 17 00:00:00 2001 From: Alexandr Date: Mon, 24 Feb 2025 19:15:01 +0300 Subject: [PATCH] add addAssetToWhitelist method, add comment in transfer params, update readme for this updates. --- README.md | 13 +++++++++++-- server/src/server.ts | 9 ++++++--- web/src/zanoWallet.ts | 4 ++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d48e2ac..0af3a2a 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,14 @@ const newAliasData = await zanoWallet.createAlias('newAlias'); console.log('Alias created:', newAliasData); ``` +### Add asset to whitelist + +To add asset to whitelist, use the `addAssetToWhitelist` method: + +```typescript +const zanoWrappedABCId = 'f74bb56a5b4fa562e679ccaadd697463498a66de4f1760b2cd40f11c3a00a7a8'; +await zanoWallet.addAssetToWhitelist(zanoWrappedABCId); +``` ## Exported Types @@ -201,7 +209,7 @@ export interface Wallet { - `getAssetsList()`: Retrieves the list of assets. - `getAssetDetails(assetId: string)`: Retrieves details of a specific asset. - `getAssetInfo(assetId: string)`: Retrieves info of a specific asset. -- `sendTransfer(assetId: string, address: string, amount: string)`: Sends a transfer to an address. +- `sendTransfer(assetId: string, address: string, amount: string, comment?: string)`: Sends a transfer to an address. - `getBalances()`: Retrieves the balances. - `validateWallet(rpcUrl: string, authData: AuthData)`: Validates the wallet. @@ -313,9 +321,10 @@ import { ServerWallet } from "zano_web3/server"; const assetId = "example-asset-id"; const address = "recipient-address"; const amount = "10.5"; // in asset units + const comment = "Thanks for the coffee"; // optional param try { - const transferResult = await zanoServerAPI.sendTransfer(assetId, address, amount); + const transferResult = await zanoServerAPI.sendTransfer(assetId, address, amount, comment); console.log("Transfer successful:", transferResult); } catch (error) { console.error("Transfer failed:", error.message); diff --git a/server/src/server.ts b/server/src/server.ts index 3815885..f8db04a 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -137,7 +137,7 @@ class ServerWallet { } } - async sendTransfer(assetId: string, address: string, amount: string) { + async sendTransfer(assetId: string, address: string, amount: string, comment?: string) { let decimalPoint: number; let auditable: boolean; @@ -160,11 +160,14 @@ class ServerWallet { .toString(); try { - const response = await this.fetchWallet("transfer", { + const params = { destinations: [{ address, amount: bigAmount, asset_id: assetId }], fee: "10000000000", mixin: auditable ? 0 : 15, - }); + comment + } + + const response = await this.fetchWallet("transfer", params); if (response.data.result) { return response.data.result; diff --git a/web/src/zanoWallet.ts b/web/src/zanoWallet.ts index 11bedab..11d9c04 100644 --- a/web/src/zanoWallet.ts +++ b/web/src/zanoWallet.ts @@ -214,6 +214,10 @@ class ZanoWallet { async createAlias(alias: string) { return ((await this.zanoWallet.request('CREATE_ALIAS', { alias })) || undefined).data; } + + async addAssetToWhitelist(asset_id: string){ + return ((await this.zanoWallet.request('ASSETS_WHITELIST_ADD', { asset_id })) || undefined).data; + } } export default ZanoWallet; \ No newline at end of file