Skip to content

Commit

Permalink
Merge pull request #296 from fireblocks/SPT-2123-get/set-vasp-assigne…
Browse files Browse the repository at this point in the history
…d-to-vault

Get/set VASP assigned to vault
  • Loading branch information
skfb authored Oct 28, 2024
2 parents 9baa06a + 86e5b70 commit 6a8aaa0
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 49 deletions.
95 changes: 56 additions & 39 deletions src/fireblocks-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ import {
TravelRuleVasp,
TravelRuleVaspFilter,
TravelRuleEncryptionOptions,
TravelRuleVaspForVaultRequestResponse,
SmartTransfersTicketResponse,
SmartTransfersTicketCreatePayload,
SmartTransfersTicketsResponse,
Expand Down Expand Up @@ -194,16 +195,16 @@ export interface SDKOptions {
* Providing custom axios options including a response interceptor (https://axios-http.com/docs/interceptors)
*/
customAxiosOptions?: {
interceptors?: {
request?: {
onFulfilled: (value: InternalAxiosRequestConfig<any>) => InternalAxiosRequestConfig<any> | Promise<InternalAxiosRequestConfig<any>>;
onRejected: (error: any) => any;
};
response?: {
onFulfilled: (value: AxiosResponse<any, any>) => AxiosResponse<any, any> | Promise<AxiosResponse<any, any>>;
onRejected: (error: any) => any;
};
}
interceptors?: {
request?: {
onFulfilled: (value: InternalAxiosRequestConfig<any>) => InternalAxiosRequestConfig<any> | Promise<InternalAxiosRequestConfig<any>>;
onRejected: (error: any) => any;
};
response?: {
onFulfilled: (value: AxiosResponse<any, any>) => AxiosResponse<any, any> | Promise<AxiosResponse<any, any>>;
onRejected: (error: any) => any;
};
}
};

/**
Expand Down Expand Up @@ -350,7 +351,7 @@ export class FireblocksSDK {
* @param price The price in currency
*/
public async setAssetPrice(id: string, currency: string, price: number): Promise<AssetPriceResponse> {
return await this.apiClient.issuePostRequest(`/v1/assets/prices/${id}`, {currency, price});
return await this.apiClient.issuePostRequest(`/v1/assets/prices/${id}`, { currency, price });
}

/**
Expand Down Expand Up @@ -445,7 +446,7 @@ export class FireblocksSDK {

return await this.apiClient.issuePutRequest(
`/v1/vault/accounts/${vaultAccountId}/${assetId}/addresses/${addressId}`,
{description: description || ""});
{ description: description || "" });
}

/**
Expand Down Expand Up @@ -715,7 +716,7 @@ export class FireblocksSDK {
}

return {
transactions: [], pageDetails: { prevPage: "", nextPage: "" },
transactions: [], pageDetails: { prevPage: "", nextPage: "" },
};
}

Expand Down Expand Up @@ -862,7 +863,7 @@ export class FireblocksSDK {
* @param requestOptions
*/
public async setAutoFuel(vaultAccountId: string, autoFuel: boolean, requestOptions?: RequestOptions): Promise<OperationSuccessResponse> {
return await this.apiClient.issuePostRequest(`/v1/vault/accounts/${vaultAccountId}/set_auto_fuel`, {autoFuel}, requestOptions);
return await this.apiClient.issuePostRequest(`/v1/vault/accounts/${vaultAccountId}/set_auto_fuel`, { autoFuel }, requestOptions);
}

/**
Expand Down Expand Up @@ -906,7 +907,7 @@ export class FireblocksSDK {
* @param requestOptions
*/
public async activateVaultAsset(vaultAccountId: string, assetId: string, requestOptions?: RequestOptions): Promise<VaultAssetResponse> {
return await this.apiClient.issuePostRequest(`/v1/vault/accounts/${vaultAccountId}/${assetId}/activate`, {} , requestOptions);
return await this.apiClient.issuePostRequest(`/v1/vault/accounts/${vaultAccountId}/${assetId}/activate`, {}, requestOptions);
}

/**
Expand Down Expand Up @@ -943,7 +944,7 @@ export class FireblocksSDK {
* Creates a new contract wallet
* @param name A name for the new contract wallet
*/
public async createContractWallet(name: string, requestOptions?: RequestOptions): Promise<WalletContainerResponse<ExternalWalletAsset>> {
public async createContractWallet(name: string, requestOptions?: RequestOptions): Promise<WalletContainerResponse<ExternalWalletAsset>> {
const body = {
name,
};
Expand Down Expand Up @@ -994,7 +995,7 @@ export class FireblocksSDK {
* @param address The wallet address
* @param tag (for ripple only) The ripple account tag
*/
public async createContractWalletAsset(walletId: string, assetId: string, address: string, tag?: string, requestOptions?: RequestOptions): Promise<ExternalWalletAsset> {
public async createContractWalletAsset(walletId: string, assetId: string, address: string, tag?: string, requestOptions?: RequestOptions): Promise<ExternalWalletAsset> {
const path = `/v1/contracts/${walletId}/${assetId}`;

const body = {
Expand Down Expand Up @@ -1074,7 +1075,7 @@ export class FireblocksSDK {
* Deletes a single contract wallet
* @param walletId The contract wallet ID
*/
public async deleteContractWallet(walletId: string): Promise<OperationSuccessResponse> {
public async deleteContractWallet(walletId: string): Promise<OperationSuccessResponse> {
return await this.apiClient.issueDeleteRequest(`/v1/contracts/${walletId}`);
}

Expand All @@ -1094,7 +1095,7 @@ export class FireblocksSDK {
* @param requestOptions
*/
public async setCustomerRefIdForVaultAccount(vaultAccountId: string, customerRefId: string, requestOptions?: RequestOptions): Promise<OperationSuccessResponse> {
return await this.apiClient.issuePostRequest(`/v1/vault/accounts/${vaultAccountId}/set_customer_ref_id`, {customerRefId}, requestOptions);
return await this.apiClient.issuePostRequest(`/v1/vault/accounts/${vaultAccountId}/set_customer_ref_id`, { customerRefId }, requestOptions);
}

/**
Expand All @@ -1104,7 +1105,7 @@ export class FireblocksSDK {
* @param requestOptions
*/
public async setCustomerRefIdForInternalWallet(walletId: string, customerRefId: string, requestOptions?: RequestOptions): Promise<OperationSuccessResponse> {
return await this.apiClient.issuePostRequest(`/v1/internal_wallets/${walletId}/set_customer_ref_id`, {customerRefId}, requestOptions);
return await this.apiClient.issuePostRequest(`/v1/internal_wallets/${walletId}/set_customer_ref_id`, { customerRefId }, requestOptions);
}

/**
Expand All @@ -1114,7 +1115,7 @@ export class FireblocksSDK {
* @param requestOptions
*/
public async setCustomerRefIdForExternalWallet(walletId: string, customerRefId: string, requestOptions?: RequestOptions): Promise<OperationSuccessResponse> {
return await this.apiClient.issuePostRequest(`/v1/external_wallets/${walletId}/set_customer_ref_id`, {customerRefId}, requestOptions);
return await this.apiClient.issuePostRequest(`/v1/external_wallets/${walletId}/set_customer_ref_id`, { customerRefId }, requestOptions);
}

/**
Expand All @@ -1132,7 +1133,7 @@ export class FireblocksSDK {
addressId = `${address}:${tag}`;
}

return await this.apiClient.issuePostRequest(`/v1/vault/accounts/${vaultAccountId}/${assetId}/addresses/${addressId}/set_customer_ref_id`, {customerRefId}, requestOptions);
return await this.apiClient.issuePostRequest(`/v1/vault/accounts/${vaultAccountId}/${assetId}/addresses/${addressId}/set_customer_ref_id`, { customerRefId }, requestOptions);
}

/**
Expand All @@ -1142,7 +1143,7 @@ export class FireblocksSDK {
* @param requestOptions
*/
public async setConfirmationThresholdForTxId(txId: string, requiredConfirmationsNumber: number, requestOptions?: RequestOptions): Promise<OperationSuccessResponse> {
return await this.apiClient.issuePostRequest(`/v1/transactions/${txId}/set_confirmation_threshold`, {numOfConfirmations: requiredConfirmationsNumber}, requestOptions);
return await this.apiClient.issuePostRequest(`/v1/transactions/${txId}/set_confirmation_threshold`, { numOfConfirmations: requiredConfirmationsNumber }, requestOptions);
}

/**
Expand All @@ -1152,7 +1153,7 @@ export class FireblocksSDK {
* @param requestOptions
*/
public async setConfirmationThresholdForTxHash(txHash: string, requiredConfirmationsNumber: number, requestOptions?: RequestOptions): Promise<OperationSuccessResponse> {
return await this.apiClient.issuePostRequest(`/v1/txHash/${txHash}/set_confirmation_threshold`, {numOfConfirmations: requiredConfirmationsNumber}, requestOptions);
return await this.apiClient.issuePostRequest(`/v1/txHash/${txHash}/set_confirmation_threshold`, { numOfConfirmations: requiredConfirmationsNumber }, requestOptions);
}

/**
Expand Down Expand Up @@ -1234,7 +1235,7 @@ export class FireblocksSDK {
url += `/${assetId}`;
}

const body = {gasThreshold, gasCap, maxGasPrice};
const body = { gasThreshold, gasCap, maxGasPrice };

return await this.apiClient.issuePutRequest(url, body);
}
Expand All @@ -1245,7 +1246,7 @@ export class FireblocksSDK {
public async dropTransaction(txId: string, feeLevel?: string, requestedFee?: string, requestOptions?: RequestOptions): Promise<DropTransactionResponse> {
const url = `/v1/transactions/${txId}/drop`;

const body = {feeLevel, requestedFee};
const body = { feeLevel, requestedFee };

return await this.apiClient.issuePostRequest(url, body, requestOptions);
}
Expand Down Expand Up @@ -1275,9 +1276,9 @@ export class FireblocksSDK {
/**
* Gets a paginated response of the addresses for a given vault account and asset
*/
public async getPaginatedAddresses(vaultAccountId: string, assetId: string, paginatedAddressesRequestFilters?: OptionalPaginatedAddressesRequestFilters): Promise<PaginatedAddressesResponse> {
return await this.apiClient.issueGetRequest(`/v1/vault/accounts/${vaultAccountId}/${assetId}/addresses_paginated?${queryString.stringify(paginatedAddressesRequestFilters)}`);
}
public async getPaginatedAddresses(vaultAccountId: string, assetId: string, paginatedAddressesRequestFilters?: OptionalPaginatedAddressesRequestFilters): Promise<PaginatedAddressesResponse> {
return await this.apiClient.issueGetRequest(`/v1/vault/accounts/${vaultAccountId}/${assetId}/addresses_paginated?${queryString.stringify(paginatedAddressesRequestFilters)}`);
}

/**
* Get all vault assets balance overview
Expand Down Expand Up @@ -1336,7 +1337,7 @@ export class FireblocksSDK {
* @param resendStatusUpdated If true a webhook will be sent for the status of the transaction
* @param requestOptions
*/
public async resendTransactionWebhooksById(txId: string, resendCreated?: boolean, resendStatusUpdated?: boolean, requestOptions?: RequestOptions): Promise<ResendWebhooksResponse> {
public async resendTransactionWebhooksById(txId: string, resendCreated?: boolean, resendStatusUpdated?: boolean, requestOptions?: RequestOptions): Promise<ResendWebhooksResponse> {
const body = { resendCreated, resendStatusUpdated };
return await this.apiClient.issuePostRequest(`/v1/webhooks/resend/${txId}`, body, requestOptions);
}
Expand Down Expand Up @@ -1410,7 +1411,7 @@ export class FireblocksSDK {
/**
* Get the tenant's OTA (One-Time-Address) configuration
*/
public async getOtaConfiguration(): Promise<{enabled: boolean}> {
public async getOtaConfiguration(): Promise<{ enabled: boolean }> {
return await this.apiClient.issueGetRequest("/v1/management/ota");
}

Expand Down Expand Up @@ -1554,7 +1555,7 @@ export class FireblocksSDK {
const basePath = `/v1/connections`;

switch (type) {
case(Web3ConnectionType.WALLET_CONNECT): {
case (Web3ConnectionType.WALLET_CONNECT): {
return `${basePath}/wc`;
}
default: {
Expand Down Expand Up @@ -1585,7 +1586,7 @@ export class FireblocksSDK {
...(pageCursor && { next: pageCursor }),
...(pageSize && { pageSize: pageSize.toString() }),
...(sort && { sort }),
...(filter && { filter: stringify(filter, { delimiter: "," })}),
...(filter && { filter: stringify(filter, { delimiter: "," }) }),
...(order && { order }),
});

Expand Down Expand Up @@ -1628,7 +1629,7 @@ export class FireblocksSDK {
public async submitWeb3Connection(type: Web3ConnectionType, sessionId: string, approve: boolean): Promise<void> {
const path = this.getWeb3ConnectionPath(type);

return await this.apiClient.issuePutRequest(`${path}/${sessionId}`, {approve});
return await this.apiClient.issuePutRequest(`${path}/${sessionId}`, { approve });
}

/**
Expand Down Expand Up @@ -2113,7 +2114,7 @@ export class FireblocksSDK {
*
* @returns TokenLink
*/
public async linkContractByAddress(type: SupportedContractTemplateType, baseAssetId: string, contractAddress: string, displayName?: string): Promise<TokenLink> {
public async linkContractByAddress(type: SupportedContractTemplateType, baseAssetId: string, contractAddress: string, displayName?: string): Promise<TokenLink> {
return await this.apiClient.issuePostRequest(`/v1/tokenization/tokens/link`, { type, baseAssetId, contractAddress, displayName });
}

Expand Down Expand Up @@ -2273,6 +2274,22 @@ export class FireblocksSDK {
return await this.apiClient.issuePutRequest(`/v1/screening/travel-rule/vasp/update`, vaspInfo);
}

/**
* Get assigned VASP Did for a specific vault. Returns empty string vaspDid value in response if none assigned.
*/
public async getVaspForVault(vaultAccountId: number): Promise<TravelRuleVaspForVaultRequestResponse> {
return await this.apiClient.issueGetRequest(`/v1/screening/travel_rule/vault/${vaultAccountId.toString()}/vasp`);
}

/**
* Sets the VASP Did for a specific vault. Pass empty string to remove existing one.
*/
public async setVaspForVault(vaultAccountId: number, vaspDid: string): Promise<TravelRuleVaspForVaultRequestResponse> {
return await this.apiClient.issuePostRequest(`/v1/screening/travel_rule/vault/${vaultAccountId.toString()}/vasp`, {
vaspDid
});
}

/**
* Get PostScreening Policies for compliance
* @param screeningType The type of screening (e.g., 'travel_rule', 'aml')
Expand Down Expand Up @@ -2357,7 +2374,7 @@ export class FireblocksSDK {
* @param expiresIn
*/
public setSmartTransferTicketExpiresIn(ticketId: string, expiresIn: number): Promise<SmartTransfersTicketResponse> {
return this.apiClient.issuePutRequest(`/v1/smart-transfers/${ticketId}/expires-in`, {expiresIn});
return this.apiClient.issuePutRequest(`/v1/smart-transfers/${ticketId}/expires-in`, { expiresIn });
}

/**
Expand All @@ -2366,7 +2383,7 @@ export class FireblocksSDK {
* @param externalRefId
*/
public setSmartTransferTicketExternalId(ticketId: string, externalRefId: string): Promise<SmartTransfersTicketResponse> {
return this.apiClient.issuePutRequest(`/v1/smart-transfers/${ticketId}/external-id`, {externalRefId});
return this.apiClient.issuePutRequest(`/v1/smart-transfers/${ticketId}/external-id`, { externalRefId });
}

/**
Expand All @@ -2375,7 +2392,7 @@ export class FireblocksSDK {
* @param expiresIn
*/
public submitSmartTransferTicket(ticketId: string, expiresIn: number): Promise<SmartTransfersTicketResponse> {
return this.apiClient.issuePutRequest(`/v1/smart-transfers/${ticketId}/submit`, {expiresIn});
return this.apiClient.issuePutRequest(`/v1/smart-transfers/${ticketId}/submit`, { expiresIn });
}

/**
Expand Down Expand Up @@ -2589,7 +2606,7 @@ export class FireblocksSDK {
* Rescan transactions base on assetId and txHash
* @param rescanTxs An array of RescanTx
*/
public rescanTransactionsBeta(rescanTxs: RescanTx[]): Promise<RescanTxResponse []> {
public rescanTransactionsBeta(rescanTxs: RescanTx[]): Promise<RescanTxResponse[]> {
return this.apiClient.issuePostRequest(`/v1/transactions/rescan`, rescanTxs);
}
}
24 changes: 14 additions & 10 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface Web3PagedResponse<T> {
paging?: Paging;
}

export type APIResponseHeaders = AxiosResponseHeaders & {"x-request-id"?: string};
export type APIResponseHeaders = AxiosResponseHeaders & { "x-request-id"?: string };

export interface VaultAccountResponse {
id: string;
Expand Down Expand Up @@ -539,6 +539,10 @@ export interface TravelRuleVaspFilter {
order?: string;
}

export interface TravelRuleVaspForVaultRequestResponse {
vaspDid: string;
}

export interface ScreeningPolicyConfiguration {
bypassScreeningDuringServiceOutages?: boolean;
inboundTransactionDelay?: number;
Expand Down Expand Up @@ -1400,15 +1404,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;
Expand Down

0 comments on commit 6a8aaa0

Please sign in to comment.