Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ncw latest backup #225

Merged
merged 1 commit into from
Dec 7, 2023
Merged
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
5 changes: 5 additions & 0 deletions src/ncw-api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ export class NcwApiClient implements NcwSdk {
`${this.NCW_BASE_PATH}/${walletId}`);
}

public async getLatestBackup(walletId: string): Promise<NCW.LatestBackupResponse> {
return await this.apiClient.issueGetRequest(
`${this.NCW_BASE_PATH}/${walletId}/backup/latest`);
}

public async enableWallet(walletId: string, enabled: boolean): Promise<void> {
return await this.apiClient.issuePutRequest(
`${this.NCW_BASE_PATH}/${walletId}/enable`,
Expand Down
8 changes: 8 additions & 0 deletions src/ncw-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ export interface NcwSdk {
*/
getWallet(walletId: string): Promise<{ walletId: string; enabled: boolean; }>;


/**
* Get NCW wallet's latest backup
*
* @param {string} walletId
*/
getLatestBackup(walletId: string): Promise<NCW.LatestBackupResponse>;

/**
* Enable a NCW wallet
*
Expand Down
13 changes: 13 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1870,6 +1870,19 @@ export namespace NCW {
enabled: boolean;
}

export class LatestBackupKey {
deviceId: string;
publicKey: string;
keyId: string;
algorithm: string;
}

export class LatestBackupResponse {
passphraseId: string;
createdAt: number;
keys: Array<LatestBackupKey>;
}

export interface GetWalletsPayload {
pageCursor?: string;
pageSize?: number;
Expand Down
Loading