diff --git a/src/fireblocks-sdk.ts b/src/fireblocks-sdk.ts index e288fc4e..a2a13f9b 100644 --- a/src/fireblocks-sdk.ts +++ b/src/fireblocks-sdk.ts @@ -80,7 +80,7 @@ import { ValidateCreateTravelRuleTransaction, ValidateFullTravelRuleResult, TravelRuleVasp, - TravelRuleVaspFilter, + TravelRuleVaspFilter, GetWebhooksResponse, Webhook, } from "./types"; import { AxiosProxyConfig, AxiosResponse } from "axios"; import { PIIEncryption } from "./pii-client"; @@ -104,12 +104,12 @@ export interface SDKOptions { * Providing custom axios options including a response interceptor (https://axios-http.com/docs/interceptors) */ customAxiosOptions?: { - interceptors?: { - response?: { - onFulfilled: (value: AxiosResponse) => AxiosResponse | Promise>; - onRejected: (error: any) => any; - }; - } + interceptors?: { + response?: { + onFulfilled: (value: AxiosResponse) => AxiosResponse | Promise>; + onRejected: (error: any) => any; + }; + } }; /** @@ -159,6 +159,7 @@ export class FireblocksSDK { public async getSupportedAssets(): Promise { return await this.apiClient.issueGetRequest("/v1/supported_assets"); } + /** * Gets a list of vault accounts per page matching the given filter or path * @param pagedVaultAccountsRequestFilters Filters for the first request @@ -166,6 +167,7 @@ export class FireblocksSDK { public async getVaultAccountsWithPageInfo(pagedVaultAccountsRequestFilters: PagedVaultAccountsRequestFilters): Promise { return await this.apiClient.issueGetRequest(`/v1/vault/accounts_paged?${queryString.stringify(pagedVaultAccountsRequestFilters)}`); } + /** * Gets a single vault account * @param vaultAccountId The vault account ID @@ -261,7 +263,7 @@ export class FireblocksSDK { * @returns NetworkConnectionResponse */ public async createNetworkConnection(localNetworkId: string, remoteNetworkId: string, routingPolicy?: NetworkConnectionRoutingPolicy): Promise { - const body = { localNetworkId, remoteNetworkId, routingPolicy }; + const body = {localNetworkId, remoteNetworkId, routingPolicy}; return await this.apiClient.issuePostRequest(`/v1/network_connections`, body); } @@ -289,7 +291,7 @@ export class FireblocksSDK { * @param routingPolicy The desired routing policy */ public async setNetworkConnectionRoutingPolicy(connectionId: string, routingPolicy: NetworkConnectionRoutingPolicy): Promise { - const body = { routingPolicy }; + const body = {routingPolicy}; return await this.apiClient.issuePatchRequest(`/v1/network_connections/${connectionId}/set_routing_policy`, body); } @@ -308,7 +310,7 @@ export class FireblocksSDK { * @returns NetworkConnectionResponse */ public async createNetworkId(name: string, routingPolicy?: NetworkIdRoutingPolicy): Promise { - const body = { name, routingPolicy }; + const body = {name, routingPolicy}; return await this.apiClient.issuePostRequest(`/v1/network_ids`, body); } @@ -328,7 +330,7 @@ export class FireblocksSDK { * @returns OperationSuccessResponse */ public async setNetworkIdDiscoverability(networkId: string, isDiscoverable: boolean): Promise { - const body = { isDiscoverable }; + const body = {isDiscoverable}; return await this.apiClient.issuePatchRequest(`/v1/network_ids/${networkId}/set_discoverability`, body); } @@ -339,7 +341,7 @@ export class FireblocksSDK { * @returns OperationSuccessResponse */ public async setNetworkIdRoutingPolicy(networkId: string, routingPolicy: NetworkIdRoutingPolicy): Promise { - const body = { routingPolicy }; + const body = {routingPolicy}; return await this.apiClient.issuePatchRequest(`/v1/network_ids/${networkId}/set_routing_policy`, body); } @@ -485,7 +487,7 @@ export class FireblocksSDK { } return { - transactions: [], pageDetails: { prevPage: "", nextPage: "" }, + transactions: [], pageDetails: {prevPage: "", nextPage: ""}, }; } @@ -665,7 +667,7 @@ export class FireblocksSDK { * @param requestOptions */ public async activateVaultAsset(vaultAccountId: string, assetId: string, requestOptions?: RequestOptions): Promise { - return await this.apiClient.issuePostRequest(`/v1/vault/accounts/${vaultAccountId}/${assetId}/activate`, {} , requestOptions); + return await this.apiClient.issuePostRequest(`/v1/vault/accounts/${vaultAccountId}/${assetId}/activate`, {}, requestOptions); } /** @@ -702,7 +704,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> { + public async createContractWallet(name: string, requestOptions?: RequestOptions): Promise> { const body = { name, }; @@ -753,7 +755,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 { + public async createContractWalletAsset(walletId: string, assetId: string, address: string, tag?: string, requestOptions?: RequestOptions): Promise { const path = `/v1/contracts/${walletId}/${assetId}`; const body = { @@ -830,7 +832,7 @@ export class FireblocksSDK { * Deletes a single contract wallet * @param walletId The contract wallet ID */ - public async deleteContractWallet(walletId: string): Promise { + public async deleteContractWallet(walletId: string): Promise { return await this.apiClient.issueDeleteRequest(`/v1/contracts/${walletId}`); } @@ -1071,6 +1073,39 @@ export class FireblocksSDK { return this.apiClient.issuePostRequest(`/v1/transactions/${txId}/freeze`, {}, requestOptions); } + /** + * get webhooks, pass an id to get a specific webhook item + */ + public async getWebhooks(id?: number): Promise { + return await this.apiClient.issueGetRequest(`/v1/webhooks${id ? `/${id}` : ""}`); + } + + /** + * Create a webhook url + */ + public async addWebhook(url: string): Promise { + return await this.apiClient.issuePostRequest("/v1/webhooks", { + url + }); + } + + /** + * Create a webhook url + */ + public async updateWebhook(id: number, url: string): Promise { + return await this.apiClient.issuePatchRequest(`/v1/webhooks/${id}`, { + url, + }); + } + + /** + * Delete webhook by id + */ + public async deleteWebhooks(id: number): Promise { + return await this.apiClient.issueDeleteRequest(`/v1/webhooks/${id}`); + } + + /** * Resend failed webhooks */ @@ -1085,8 +1120,8 @@ 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 { - const body = { resendCreated, resendStatusUpdated }; + public async resendTransactionWebhooksById(txId: string, resendCreated?: boolean, resendStatusUpdated?: boolean, requestOptions?: RequestOptions): Promise { + const body = {resendCreated, resendStatusUpdated}; return await this.apiClient.issuePostRequest(`/v1/webhooks/resend/${txId}`, body, requestOptions); } @@ -1155,6 +1190,7 @@ export class FireblocksSDK { public async settlement(settlementRequest: SettlementRequest, requestOptions?: RequestOptions): Promise { return await this.apiClient.issuePostRequest(`/v1/off_exchange/settlements/trader`, settlementRequest, requestOptions); } + /** * Set Fee Payer configuration * @param feePayerConfiguration @@ -1206,18 +1242,18 @@ export class FireblocksSDK { * @returns An object containing the data returned and the cursor for the next page */ public async getWeb3Connections({ - pageCursor, - pageSize, - sort, - filter, - order - }: GetWeb3ConnectionsPayload = {}): Promise> { + pageCursor, + pageSize, + sort, + filter, + order + }: GetWeb3ConnectionsPayload = {}): Promise> { const params = new URLSearchParams({ - ...(pageCursor && { next: pageCursor }), - ...(pageSize && { pageSize: pageSize.toString() }), - ...(sort && { sort }), - ...(filter && { filter: stringify(filter, { delimiter: "," })}), - ...(order && { order }), + ...(pageCursor && {next: pageCursor}), + ...(pageSize && {pageSize: pageSize.toString()}), + ...(sort && {sort}), + ...(filter && {filter: stringify(filter, {delimiter: ","})}), + ...(order && {order}), }); return await this.apiClient.issueGetRequest(`/v1/connections?${params.toString()}`); @@ -1303,7 +1339,7 @@ export class FireblocksSDK { * @param filter.order */ public async getNFTs(filter: GetNFTsFilter): Promise> { - const { pageCursor, pageSize, ids, sort, order } = filter; + const {pageCursor, pageSize, ids, sort, order} = filter; const queryParams = { pageCursor, pageSize, @@ -1328,7 +1364,17 @@ export class FireblocksSDK { public async getOwnedNFTs(filter?: NFTOwnershipFilter): Promise> { let url = "/v1/nfts/ownership/tokens"; if (filter) { - const { blockchainDescriptor, vaultAccountIds, collectionIds, ids, pageCursor, pageSize, sort, order, status } = filter; + const { + blockchainDescriptor, + vaultAccountIds, + collectionIds, + ids, + pageCursor, + pageSize, + sort, + order, + status + } = filter; const requestFilter = { vaultAccountIds: this.getCommaSeparatedList(vaultAccountIds), blockchainDescriptor, @@ -1360,7 +1406,7 @@ export class FireblocksSDK { * @param status Status for update */ public async updateNFTOwnershipStatus(id: string, status: NFTOwnershipStatus): Promise { - return await this.apiClient.issuePutRequest(`/v1/nfts/ownership/tokens/${id}/status`, { status }); + return await this.apiClient.issuePutRequest(`/v1/nfts/ownership/tokens/${id}/status`, {status}); } /** @@ -1410,7 +1456,7 @@ export class FireblocksSDK { * @param assetId */ public async linkToken(assetId: string): Promise { - return await this.apiClient.issuePutRequest(`/v1/tokenization/tokens/${assetId}/link`, { }); + return await this.apiClient.issuePutRequest(`/v1/tokenization/tokens/${assetId}/link`, {}); } /** @@ -1427,7 +1473,7 @@ export class FireblocksSDK { * @param permissions */ public async addLinkedTokenPermissions(assetId: string, permissions: TokenLinkPermissionEntry[]): Promise { - return await this.apiClient.issuePutRequest(`/v1/tokenization/tokens/${assetId}/permissions`, { permissions }); + return await this.apiClient.issuePutRequest(`/v1/tokenization/tokens/${assetId}/permissions`, {permissions}); } /** @@ -1470,7 +1516,7 @@ export class FireblocksSDK { let url = `/v1/screening/travel_rule/vasp`; if (filter) { - const { q, fields, page, per_page, order } = filter; + const {q, fields, page, per_page, order} = filter; const queryParameters = { q, fields: this.getCommaSeparatedList(fields), diff --git a/src/types.ts b/src/types.ts index 29070743..7129dc71 100644 --- a/src/types.ts +++ b/src/types.ts @@ -5,7 +5,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; @@ -318,7 +318,8 @@ interface TROriginator { accountNumber?: string[]; } -interface TROriginatorPersons extends Array {} +interface TROriginatorPersons extends Array { +} interface TROriginatorPerson { naturalPerson?: TRNaturalPerson; @@ -332,7 +333,8 @@ interface TRNaturalPerson { dateAndPlaceOfBirth?: TRDateAndPlaceOfBirth; } -interface TRName extends Array {} +interface TRName extends Array { +} interface TRPersonNameIdentifier { nameIdentifier?: TRNameIdentifier; @@ -344,7 +346,8 @@ interface TRNameIdentifier { nameIdentifierType?: string; } -interface TRGeographicAddress extends Array {} +interface TRGeographicAddress extends Array { +} interface TRGeographicAddressData { streetName?: string; @@ -709,8 +712,14 @@ export interface NoneNetworkRoutingDest { scheme: NetworkScheme.NONE; } -export type NetworkConnectionCryptoRoutingDest = CustomCryptoRoutingDest | DefaultNetworkRoutingDest | NoneNetworkRoutingDest; -export type NetworkConnectionFiatRoutingDest = CustomFiatRoutingDest | DefaultNetworkRoutingDest | NoneNetworkRoutingDest; +export type NetworkConnectionCryptoRoutingDest = + CustomCryptoRoutingDest + | DefaultNetworkRoutingDest + | NoneNetworkRoutingDest; +export type NetworkConnectionFiatRoutingDest = + CustomFiatRoutingDest + | DefaultNetworkRoutingDest + | NoneNetworkRoutingDest; export type NetworkIdCryptoRoutingDest = CustomCryptoRoutingDest | NoneNetworkRoutingDest; export type NetworkIdFiatRoutingDest = CustomFiatRoutingDest | NoneNetworkRoutingDest; @@ -1085,6 +1094,17 @@ export interface ResendWebhooksResponse { webhooksCount: number; } +export interface GetWebhooksResponse { + webhooks: Webhook[]; +} + +export interface Webhook { + id: number; + webHookUrl: string; + urlType: string; + enabled: boolean; +} + export interface OffExchangeEntityResponse { id: string; vaultAccountId: string; @@ -1201,11 +1221,11 @@ export interface GetWeb3ConnectionsPayload { export interface CreateWeb3ConnectionResponse { id: string; sessionMetadata: { - appIcon?: string, - appId?: string, - appName?: string, - appUrl?: string, - appDescription?: string + appIcon?: string, + appId?: string, + appName?: string, + appUrl?: string, + appDescription?: string }; } @@ -1215,7 +1235,7 @@ export interface SessionMetadata { appName?: string; appUrl?: string; appDescription?: string; - } +} export interface Session { id: string; @@ -1226,7 +1246,8 @@ export interface Session { connectionType: Web3ConnectionType; connectionMethod?: Web3ConnectionMethod; sessionMetadata?: SessionMetadata; - } +} + export enum TimePeriod { DAY = "DAY", WEEK = "WEEK" @@ -1351,6 +1372,7 @@ export interface LinkedTokenMetadata { testnet?: boolean; blockchain?: string; } + export interface TokenLink { id: string; assetId: string;