Skip to content

Commit

Permalink
Merge pull request #272 from fireblocks/ncw-unspent-inputs
Browse files Browse the repository at this point in the history
NCW: get unspent inputs
  • Loading branch information
yuval-fireblocks authored Apr 10, 2024
2 parents ac9fe07 + 08235ce commit 60a92ee
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/fireblocks-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ import {
ScreeningSupportedAssetResponse,
ScreeningSupportedProviders,
RegisterAssetResponse,
UnspentInputsResponse,
} from "./types";
import { AxiosProxyConfig, AxiosResponse, InternalAxiosRequestConfig } from "axios";
import { PIIEncryption } from "./pii-client";
Expand Down Expand Up @@ -384,7 +385,7 @@ export class FireblocksSDK {
* @param vaultAccountId The vault account ID
* @param assetId The ID of the asset for which to get the utxo list
*/
public async getUnspentInputs(vaultAccountId: string, assetId: string): Promise<DepositAddressResponse[]> {
public async getUnspentInputs(vaultAccountId: string, assetId: string): Promise<UnspentInputsResponse[]> {
return await this.apiClient.issueGetRequest(`/v1/vault/accounts/${vaultAccountId}/${assetId}/unspent_inputs`);
}

Expand Down
4 changes: 4 additions & 0 deletions src/ncw-api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
AssetResponse,
Web3PagedResponse,
NCW,
UnspentInputsResponse,
} from "./types";
import { NcwSdk } from "./ncw-sdk";

Expand Down Expand Up @@ -156,6 +157,9 @@ export class NcwApiClient implements NcwSdk {
public async getDeviceSetupStatus(walletId: string, deviceId: string): Promise<NCW.DeviceKeySetupResponse> {
return await this.apiClient.issueGetRequest(
`${this.NCW_BASE_PATH}/${walletId}/devices/${deviceId}/setup_status`);
}

public async getUnspentInputs(walletId: string, accountId: number, assetId: string): Promise<UnspentInputsResponse[]> {
return await this.apiClient.issueGetRequest(`/v1/ncw/${walletId}/accounts/${accountId}/${assetId}/unspent_inputs`);
}
}
12 changes: 11 additions & 1 deletion src/ncw-sdk.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
AssetResponse, Web3PagedResponse, NCW,
AssetResponse, Web3PagedResponse, NCW, UnspentInputsResponse,
} from "./types";

export interface NcwSdk {
Expand Down Expand Up @@ -182,4 +182,14 @@ export interface NcwSdk {
* @return {*} {Promise<NCW.DeviceKeySetupResponse>}
*/
getDeviceSetupStatus(walletId: string, deviceId: string): Promise<NCW.DeviceKeySetupResponse>;

/**
* Gets utxo list for an asset
*
* @param {string} walletId
* @param {string} accountId
* @param {string} assetId
* @return {*} {Promise<UnspentInputsResponse>}
*/
getUnspentInputs(walletId: string, accountId: number, assetId: string): Promise<UnspentInputsResponse[]>
}
11 changes: 11 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2105,6 +2105,17 @@ export interface SmartTransfersTicketTermFundPayload {
feeLevel?: FeeLevel;
}

export interface UnspentInputsResponse {
input: {
txHash: string;
index: number;
},
address: string;
amount: string;
confirmations: number;
status: string;
}

export namespace NCW {
export const WalletIdHeader = "X-End-User-Wallet-Id";

Expand Down

0 comments on commit 60a92ee

Please sign in to comment.