From 9fb6db43f37ff42335a9fa4ba77e194cbf56a6b8 Mon Sep 17 00:00:00 2001 From: Yuval Niezni Date: Mon, 18 Mar 2024 18:43:22 +0200 Subject: [PATCH 1/2] add wallet\device setup state EPs --- src/ncw-api-client.ts | 11 +++++++++++ src/ncw-sdk.ts | 17 +++++++++++++++++ src/types.ts | 44 +++++++++++++++++++++++++++++++++---------- 3 files changed, 62 insertions(+), 10 deletions(-) diff --git a/src/ncw-api-client.ts b/src/ncw-api-client.ts index 592ab556..8e4dbc4b 100644 --- a/src/ncw-api-client.ts +++ b/src/ncw-api-client.ts @@ -147,4 +147,15 @@ export class NcwApiClient implements NcwSdk { `${this.NCW_BASE_PATH}/${walletId}/accounts/${accountId}/assets/${assetId}/balance`, {}); } + + public async getWalletSetupStatus(walletId: string): Promise { + return await this.apiClient.issueGetRequest( + `${this.NCW_BASE_PATH}/${walletId}/setup_status`); + } + + public async getDeviceSetupStatus(walletId: string, deviceId: string): Promise { + return await this.apiClient.issueGetRequest( + `${this.NCW_BASE_PATH}/${walletId}/devices/${deviceId}/setup_status`); + + } } diff --git a/src/ncw-sdk.ts b/src/ncw-sdk.ts index b50f086c..1f95f113 100644 --- a/src/ncw-sdk.ts +++ b/src/ncw-sdk.ts @@ -165,4 +165,21 @@ export interface NcwSdk { * @return {*} {Promise} */ refreshWalletAssetBalance(walletId: string, accountId: number, assetId: string): Promise; + + /** + * get NCW wallet setup status + * + * @param {string} walletId + * @return {*} {Promise} + */ + getWalletSetupStatus(walletId: string): Promise; + + /** + * refresh a NCW asset balance + * + * @param {string} walletId + * @param {string} deviceId + * @return {*} {Promise} + */ + getDeviceSetupStatus(walletId: string, deviceId: string): Promise; } diff --git a/src/types.ts b/src/types.ts index 13d1355b..22590623 100644 --- a/src/types.ts +++ b/src/types.ts @@ -9,7 +9,7 @@ export interface Web3PagedResponse { paging?: Paging; } -export type APIResponseHeaders = AxiosResponseHeaders & {"x-request-id"?: string}; +export type APIResponseHeaders = AxiosResponseHeaders & { "x-request-id"?: string }; export interface VaultAccountResponse { id: string; @@ -1354,15 +1354,15 @@ export interface User { export type TRole = - | "ADMIN" - | "SIGNER" - | "EDITOR" - | "APPROVER" - | "VIEWER" - | "NON_SIGNING_ADMIN" - | "AUDITOR" - | "NCW_ADMIN" - | "NCW_SIGNER"; + | "ADMIN" + | "SIGNER" + | "EDITOR" + | "APPROVER" + | "VIEWER" + | "NON_SIGNING_ADMIN" + | "AUDITOR" + | "NCW_ADMIN" + | "NCW_SIGNER"; interface BaseUser { id: string; @@ -2164,6 +2164,30 @@ export namespace NCW { deviceId: string; enabled: boolean; } + + export enum SetupStatus { + COMPLETE = "COMPLETE", + INCOMPLETE = "INCOMPLETE", + } + + export class KeySetup { + status: SetupStatus; + algorithmName: string; + confirmed: boolean; + backedUp: boolean; + } + + export class DeviceKeySetupResponse { + status: SetupStatus; + deviceId: string; + setupStatus: Array; + } + + export class WalletSetupStatusResponse { + status: SetupStatus; + deviceSetupStatus: Array; + } + } export namespace TAP { From ba7c023b4f80033d6333f295367a22104e0a6ee1 Mon Sep 17 00:00:00 2001 From: Yuval Niezni Date: Wed, 20 Mar 2024 18:28:20 +0200 Subject: [PATCH 2/2] fix: lint and desc. --- src/ncw-sdk.ts | 2 +- src/types.ts | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/ncw-sdk.ts b/src/ncw-sdk.ts index 1f95f113..533627e8 100644 --- a/src/ncw-sdk.ts +++ b/src/ncw-sdk.ts @@ -175,7 +175,7 @@ export interface NcwSdk { getWalletSetupStatus(walletId: string): Promise; /** - * refresh a NCW asset balance + * get NCW device setup status * * @param {string} walletId * @param {string} deviceId diff --git a/src/types.ts b/src/types.ts index 22590623..2842b271 100644 --- a/src/types.ts +++ b/src/types.ts @@ -9,7 +9,7 @@ export interface Web3PagedResponse { paging?: Paging; } -export type APIResponseHeaders = AxiosResponseHeaders & { "x-request-id"?: string }; +export type APIResponseHeaders = AxiosResponseHeaders & {"x-request-id"?: string}; export interface VaultAccountResponse { id: string; @@ -1354,15 +1354,15 @@ export interface User { export type TRole = - | "ADMIN" - | "SIGNER" - | "EDITOR" - | "APPROVER" - | "VIEWER" - | "NON_SIGNING_ADMIN" - | "AUDITOR" - | "NCW_ADMIN" - | "NCW_SIGNER"; + | "ADMIN" + | "SIGNER" + | "EDITOR" + | "APPROVER" + | "VIEWER" + | "NON_SIGNING_ADMIN" + | "AUDITOR" + | "NCW_ADMIN" + | "NCW_SIGNER"; interface BaseUser { id: string;