From 276ff740dd050bf6d330ff40d4c0ff00e99d19b5 Mon Sep 17 00:00:00 2001 From: Yuval Niezni Date: Tue, 2 Apr 2024 21:26:27 +0300 Subject: [PATCH 1/2] add unspent input ep --- src/ncw-api-client.ts | 4 ++++ src/ncw-sdk.ts | 12 +++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/ncw-api-client.ts b/src/ncw-api-client.ts index 8e4dbc4..a425865 100644 --- a/src/ncw-api-client.ts +++ b/src/ncw-api-client.ts @@ -3,6 +3,7 @@ import { AssetResponse, Web3PagedResponse, NCW, + DepositAddressResponse, } from "./types"; import { NcwSdk } from "./ncw-sdk"; @@ -156,6 +157,9 @@ export class NcwApiClient implements NcwSdk { public async getDeviceSetupStatus(walletId: string, deviceId: string): Promise { return await this.apiClient.issueGetRequest( `${this.NCW_BASE_PATH}/${walletId}/devices/${deviceId}/setup_status`); + } + public async getUnspentInputs(walletId: string, accountId: string, assetId: string): Promise { + return await this.apiClient.issueGetRequest(`/v1/ncw/${walletId}/accounts/${accountId}/${assetId}/unspent_inputs`); } } diff --git a/src/ncw-sdk.ts b/src/ncw-sdk.ts index 533627e..796d0ea 100644 --- a/src/ncw-sdk.ts +++ b/src/ncw-sdk.ts @@ -1,5 +1,5 @@ import { - AssetResponse, Web3PagedResponse, NCW, + AssetResponse, Web3PagedResponse, NCW, DepositAddressResponse, } from "./types"; export interface NcwSdk { @@ -182,4 +182,14 @@ export interface NcwSdk { * @return {*} {Promise} */ getDeviceSetupStatus(walletId: string, deviceId: string): Promise; + + /** + * Gets utxo list for an asset + * + * @param {string} walletId + * @param {string} accountId + * @param {string} assetId + * @return {*} {Promise} + */ + getUnspentInputs(walletId: string, accountId: string, assetId: string): Promise } From ac12750aa0ab8f8be47de718e444793c29b77333 Mon Sep 17 00:00:00 2001 From: Yuval Niezni Date: Tue, 2 Apr 2024 21:38:52 +0300 Subject: [PATCH 2/2] fix type and response --- src/fireblocks-sdk.ts | 4 ++-- src/ncw-api-client.ts | 4 ++-- src/ncw-sdk.ts | 6 +++--- src/types.ts | 11 +++++++++++ 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/fireblocks-sdk.ts b/src/fireblocks-sdk.ts index c2fcade..873635e 100644 --- a/src/fireblocks-sdk.ts +++ b/src/fireblocks-sdk.ts @@ -133,7 +133,7 @@ import { TokenLinkStatus, SupportedContractTemplateType, AbiFunction, - TokenOwnershipSpamUpdatePayload, ScreeningSupportedAssetResponse, ScreeningSupportedProviders, + TokenOwnershipSpamUpdatePayload, ScreeningSupportedAssetResponse, ScreeningSupportedProviders, UnspentInputsResponse, } from "./types"; import { AxiosProxyConfig, AxiosResponse, InternalAxiosRequestConfig } from "axios"; import { PIIEncryption } from "./pii-client"; @@ -381,7 +381,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 { + public async getUnspentInputs(vaultAccountId: string, assetId: string): Promise { return await this.apiClient.issueGetRequest(`/v1/vault/accounts/${vaultAccountId}/${assetId}/unspent_inputs`); } diff --git a/src/ncw-api-client.ts b/src/ncw-api-client.ts index a425865..21950a3 100644 --- a/src/ncw-api-client.ts +++ b/src/ncw-api-client.ts @@ -3,7 +3,7 @@ import { AssetResponse, Web3PagedResponse, NCW, - DepositAddressResponse, + UnspentInputsResponse, } from "./types"; import { NcwSdk } from "./ncw-sdk"; @@ -159,7 +159,7 @@ export class NcwApiClient implements NcwSdk { `${this.NCW_BASE_PATH}/${walletId}/devices/${deviceId}/setup_status`); } - public async getUnspentInputs(walletId: string, accountId: string, assetId: string): Promise { + public async getUnspentInputs(walletId: string, accountId: number, assetId: string): Promise { return await this.apiClient.issueGetRequest(`/v1/ncw/${walletId}/accounts/${accountId}/${assetId}/unspent_inputs`); } } diff --git a/src/ncw-sdk.ts b/src/ncw-sdk.ts index 796d0ea..06c2313 100644 --- a/src/ncw-sdk.ts +++ b/src/ncw-sdk.ts @@ -1,5 +1,5 @@ import { - AssetResponse, Web3PagedResponse, NCW, DepositAddressResponse, + AssetResponse, Web3PagedResponse, NCW, UnspentInputsResponse, } from "./types"; export interface NcwSdk { @@ -189,7 +189,7 @@ export interface NcwSdk { * @param {string} walletId * @param {string} accountId * @param {string} assetId - * @return {*} {Promise} + * @return {*} {Promise} */ - getUnspentInputs(walletId: string, accountId: string, assetId: string): Promise + getUnspentInputs(walletId: string, accountId: number, assetId: string): Promise } diff --git a/src/types.ts b/src/types.ts index 2842b27..85288ea 100644 --- a/src/types.ts +++ b/src/types.ts @@ -2073,6 +2073,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";