Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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);
Expand Down
9 changes: 6 additions & 3 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions web/src/zanoWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;