Skip to content

Commit

Permalink
rename var
Browse files Browse the repository at this point in the history
  • Loading branch information
yuval-fireblocks committed Aug 22, 2023
1 parent 572d4c1 commit e105d26
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/ncw-api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,41 @@ import {
import { NcwSdk } from "./ncw-sdk";

export class NcwApiClient implements NcwSdk {
private readonly BASE_URL = "/v1/ncw/wallets";
private readonly NCW_BASE_PATH = "/v1/ncw/wallets";

constructor(private readonly apiClient: ApiClient) { }

public async createWallet(): Promise<{ walletId: string; enabled: boolean; }> {
return await this.apiClient.issuePostRequest(
`${this.BASE_URL}`,
`${this.NCW_BASE_PATH}`,
{});
}

public async getWallet(walletId: string): Promise<{ walletId: string; enabled: boolean; }> {
return await this.apiClient.issueGetRequest(
`${this.BASE_URL}/${walletId}`);
`${this.NCW_BASE_PATH}/${walletId}`);
}

public async enableWallet(walletId: string, enabled: boolean): Promise<void> {
return await this.apiClient.issuePutRequest(
`${this.BASE_URL}/${walletId}/enable`,
`${this.NCW_BASE_PATH}/${walletId}/enable`,
{ enabled });
}

public async getWalletDevices(walletId: string): Promise<NCW.Device> {
return await this.apiClient.issueGetRequest(
`${this.BASE_URL}/${walletId}/devices/`);
`${this.NCW_BASE_PATH}/${walletId}/devices/`);
}

public async enableWalletDevice(walletId: string, deviceId: string, enabled: boolean): Promise<void> {
return await this.apiClient.issuePutRequest(
`${this.BASE_URL}/${walletId}/devices/${deviceId}/enable`,
`${this.NCW_BASE_PATH}/${walletId}/devices/${deviceId}/enable`,
{ enabled });
}

public async invokeWalletRpc(walletId: string, deviceId: string, payload: string): Promise<{ result: string; } | { error: { message: string; code?: number; }; }> {
return await this.apiClient.issuePostRequest(
`${this.BASE_URL}/${walletId}/devices/${deviceId}/invoke`,
`${this.NCW_BASE_PATH}/${walletId}/devices/${deviceId}/invoke`,
{ payload });
}

Expand All @@ -50,7 +50,7 @@ export class NcwApiClient implements NcwSdk {
accountId: number;
}> {
return await this.apiClient.issuePostRequest(
`${this.BASE_URL}/${walletId}/accounts`,
`${this.NCW_BASE_PATH}/${walletId}/accounts`,
{});
}

Expand All @@ -62,7 +62,7 @@ export class NcwApiClient implements NcwSdk {
...(order && { order }),
});

return await this.apiClient.issueGetRequest(`${this.BASE_URL}?${params.toString()}`);
return await this.apiClient.issueGetRequest(`${this.NCW_BASE_PATH}?${params.toString()}`);
}

public async getWalletAccounts(walletId: string, { pageCursor, pageSize, sort, order }: NCW.GetWalletsPayload = {}): Promise<Web3PagedResponse<{
Expand All @@ -77,15 +77,15 @@ export class NcwApiClient implements NcwSdk {
});

return await this.apiClient.issueGetRequest(
`${this.BASE_URL}/${walletId}/accounts?${params.toString()}`);
`${this.NCW_BASE_PATH}/${walletId}/accounts?${params.toString()}`);
}

public async getWalletAccount(walletId: string, accountId: number): Promise<{
walletId: string;
accountId: number;
}> {
return await this.apiClient.issueGetRequest(
`${this.BASE_URL}/${walletId}/accounts/${accountId}`);
`${this.NCW_BASE_PATH}/${walletId}/accounts/${accountId}`);
}

public async getWalletAssets(walletId: string, accountId: number, { pageCursor, pageSize, sort, order }: NCW.GetWalletAssetsPayload = {}): Promise<Web3PagedResponse<NCW.WalletAssetResponse>> {
Expand All @@ -97,17 +97,17 @@ export class NcwApiClient implements NcwSdk {
});

return await this.apiClient.issueGetRequest(
`${this.BASE_URL}/${walletId}/accounts/${accountId}/assets?${params.toString()}`);
`${this.NCW_BASE_PATH}/${walletId}/accounts/${accountId}/assets?${params.toString()}`);
}

public async getWalletAsset(walletId: string, accountId: number, assetId: string): Promise<NCW.WalletAssetResponse> {
return await this.apiClient.issueGetRequest(
`${this.BASE_URL}/${walletId}/accounts/${accountId}/assets/${assetId}`);
`${this.NCW_BASE_PATH}/${walletId}/accounts/${accountId}/assets/${assetId}`);
}

public async activateWalletAsset(walletId: string, accountId: number, assetId: string): Promise<NCW.WalletAssetAddress> {
return await this.apiClient.issuePostRequest(
`${this.BASE_URL}/${walletId}/accounts/${accountId}/assets/${assetId}`, {});
`${this.NCW_BASE_PATH}/${walletId}/accounts/${accountId}/assets/${assetId}`, {});
}

public async getWalletAssetAddresses(walletId: string, accountId: number, assetId: string, { pageCursor, pageSize, sort, order }: NCW.GetWalletAddressesPayload = {}): Promise<Web3PagedResponse<NCW.WalletAssetAddress>> {
Expand All @@ -119,17 +119,17 @@ export class NcwApiClient implements NcwSdk {
});

return await this.apiClient.issueGetRequest(
`${this.BASE_URL}/${walletId}/accounts/${accountId}/assets/${assetId}/addresses?${params.toString()}`);
`${this.NCW_BASE_PATH}/${walletId}/accounts/${accountId}/assets/${assetId}/addresses?${params.toString()}`);
}

public async getWalletAssetBalance(walletId: string, accountId: number, assetId: string): Promise<AssetResponse> {
return await this.apiClient.issueGetRequest(
`${this.BASE_URL}/${walletId}/accounts/${accountId}/assets/${assetId}/balance`);
`${this.NCW_BASE_PATH}/${walletId}/accounts/${accountId}/assets/${assetId}/balance`);
}

public async refreshWalletAssetBalance(walletId: string, accountId: number, assetId: string): Promise<AssetResponse> {
return await this.apiClient.issuePutRequest(
`${this.BASE_URL}/${walletId}/accounts/${accountId}/assets/${assetId}/balance`,
`${this.NCW_BASE_PATH}/${walletId}/accounts/${accountId}/assets/${assetId}/balance`,
{});
}
}

0 comments on commit e105d26

Please sign in to comment.