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

added bulk functions #209

Merged
merged 7 commits into from
Nov 2, 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
Binary file added .DS_Store
Binary file not shown.
82 changes: 80 additions & 2 deletions src/fireblocks-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ import {
UsersGroup,
LeanContractTemplateDto,
ContractTemplateDto,
BatchTask, BatchJob, JobCreatedResponse,
ContractUploadRequest,
ContractDeployResponse,
ContractDeployRequest,
Expand Down Expand Up @@ -710,12 +711,12 @@ export class FireblocksSDK {
* @param vaultAccountId
* @param name A new name for the vault account
*/
public async updateVaultAccount(vaultAccountId: string, name: string): Promise<VaultAccountResponse> {
public async updateVaultAccount(vaultAccountId: string, name: string, requestOptions?: RequestOptions): Promise<VaultAccountResponse> {
const body = {
name: name
};

return await this.apiClient.issuePutRequest(`/v1/vault/accounts/${vaultAccountId}`, body);
return await this.apiClient.issuePostRequest(`/v1/vault/accounts/${vaultAccountId}`, body, requestOptions);
}

/**
Expand Down Expand Up @@ -1946,4 +1947,81 @@ export class FireblocksSDK {
private getCommaSeparatedList(items: Array<string>): string | undefined {
return items ? items.join(",") : undefined;
}

/**
* Get list of jobs for current tenant
* @param fromTime beggining of time range in Unix Epoch
* @param toTime ending of time range in Unix Epoch
*/
public getJobsForTenant(fromTime: number, toTime: number): Promise<BatchJob[]> {
gadiguy marked this conversation as resolved.
Show resolved Hide resolved
return this.apiClient.issueGetRequest(`/v1/batch/jobs?fromTime=${fromTime}&toTime=${toTime}`);
}

/**
* Get job info by job ID
* @param jobId
*/
public getJobById(jobId: string): Promise<BatchJob> {
return this.apiClient.issueGetRequest(`/v1/batch/${jobId}`);
}

/**
* Get tasks belonging to given job
* @param jobId
*/
public getTasksByJobId(jobId: string): Promise<BatchTask> {
return this.apiClient.issueGetRequest(`/v1/batch/${jobId}/tasks`);
}

/**
* Cancel a job by ID
* @param jobId
*/
public cancelJob(jobId: string): Promise<void> {
return this.apiClient.issuePostRequest(`/v1/batch/${jobId}/cancel`, {});
}

/**
* Pause a job by ID
* @param jobId
*/
public pauseJob(jobId: string): Promise<void> {
return this.apiClient.issuePostRequest(`/v1/batch/${jobId}/pause`, {});
}

/**
* Continue a job by ID
* @param jobId
*/
public continueJob(jobId: string): Promise<void> {
return this.apiClient.issuePostRequest(`/v1/batch/${jobId}/continue`, {});
}

/**
* Create multiple vault accounts in one bulk operation
gadiguy marked this conversation as resolved.
Show resolved Hide resolved
* @param count number of vault accounts
* @param assetId optional asset id to create in each new account
* @param requestOptions
*/
public createVaultAccountsBulk(count: number, assetId: string, requestOptions?: RequestOptions): Promise<JobCreatedResponse> {
const body = {
count,
assetId
};
return this.apiClient.issuePostRequest(`/v1/vault/accounts/bulk`, body, requestOptions);
}

/**
* Creates a new asset within a list of existing vault accounts
* @param assetId The asset to add
* @param vaultAccountIdFrom The first of the account ID range
* @param vaultAccountIdTo The last of the account ID range
* @param requestOptions
*/
public createVaultAssetsBulk(assetId: string, vaultAccountIdFrom: string, vaultAccountIdTo: string, requestOptions?: RequestOptions): Promise<JobCreatedResponse> {
const body = {
assetId, vaultAccountIdFrom, vaultAccountIdTo
};
return this.apiClient.issuePostRequest(`/v1/vault/assets/bulk`, body, requestOptions);
}
}
40 changes: 38 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1618,8 +1618,6 @@ export interface PendingTokenLinkDto {
blockchainId?: string;
}

type CreateTokenParams = EVMTokenCreateParamsDto | StellarRippleCreateParamsDto;

export interface IssueTokenRequest {
symbol: string;
name: string;
Expand All @@ -1628,6 +1626,44 @@ export interface IssueTokenRequest {
createParams: CreateTokenParams;
}

export interface JobCreatedResponse {
jobId: string;
}

export enum BatchStatus {
CREATED = "CREATED",
IN_PROGRESS = "INPROGRESS",
DONE = "DONE",
ERROR = "ERROR",
CANCELED = "CANCELED",
PAUSED = "PAUSED"
}

export class BatchJob {
id: string;
tenantId: string;
type: string;
userId: string;
created: number;
updated?: number;
state: BatchJob;
data: string;
}

export class BatchTask {
id: string;
jobId: string;
type: string;
tenantId: string;
created: number;
updated?: number;
state: BatchStatus;
data?: string;
result?: string;
}

type CreateTokenParams = EVMTokenCreateParamsDto | StellarRippleCreateParamsDto;

interface StellarRippleCreateParamsDto {
issuerAddress?: string;
}
Expand Down
Loading