From 19efe921ec8bee03f585e14ac8a34456adee528c Mon Sep 17 00:00:00 2001 From: Lazar Stijakovic Date: Thu, 19 Dec 2024 11:58:56 +0100 Subject: [PATCH 1/3] feat: added asset and blockchain beta apis --- src/fireblocks-sdk.ts | 42 +++++++++++++++ src/types.ts | 120 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 162 insertions(+) diff --git a/src/fireblocks-sdk.ts b/src/fireblocks-sdk.ts index 05f3c76..d09a482 100644 --- a/src/fireblocks-sdk.ts +++ b/src/fireblocks-sdk.ts @@ -151,6 +151,12 @@ import { ContractWithABIDto, RescanTx, RescanTxResponse, + ListAssetsResponse, + ListAssetsFilters, + ListAssetResponse, + ListBlockchainResponse, + ListBlockchainsFilters, + ListBlockchainsResponse, } from "./types"; import { AxiosProxyConfig, AxiosResponse, InternalAxiosRequestConfig } from "axios"; import { PIIEncryption } from "./pii-client"; @@ -907,6 +913,42 @@ export class FireblocksSDK { return await this.apiClient.issuePostRequest(`/v1/assets`, { blockchainId, address, symbol }, requestOptions); } + /** + * List assets [BETA] + * @param filters + * @param requestOptions + */ + public async listAssets(filters?: ListAssetsFilters, requestOptions?: RequestOptions): Promise { + return await this.apiClient.issueGetRequest(`/v1/assets`, filters, requestOptions); + } + + /** + * Get an asset [BETA] + * @param assetId The ID or legacyId of the asset + * @param requestOptions + */ + public async getAssetById(assetId: string, requestOptions?: RequestOptions): Promise { + return await this.apiClient.issueGetRequest(`/v1/assets/${assetId}`, {}, requestOptions); + } + + /** + * List blockchains [BETA] + * @param filters + * @param requestOptions + */ + public async listBlockchains(filters?: ListBlockchainsFilters, requestOptions?: RequestOptions): Promise { + return await this.apiClient.issueGetRequest(`/v1/blockchains`, filters, requestOptions); + } + + /** + * Get an blockchain [BETA] + * @param blockchainId The ID or legacyId of the blockchain + * @param requestOptions + */ + public async getBlockchainById(blockchainId: string, requestOptions?: RequestOptions): Promise { + return await this.apiClient.issueGetRequest(`/v1/blockchains/${blockchainId}`, {}, requestOptions); + } + /** * Retry to create a vault asset for a vault asset that failed * @param vaultAccountId The vault account ID diff --git a/src/types.ts b/src/types.ts index 1551e85..cc10cbe 100644 --- a/src/types.ts +++ b/src/types.ts @@ -79,6 +79,14 @@ export enum AssetClass { SFT = "SFT", } +export enum AssetClassBeta { + NATIVE = "NATIVE", + FT = "FT", + FIAT = "FIAT", + NFT = "NFT", + SFT = "SFT", +} + export interface OnchainAsset { symbol: string; name: string; @@ -87,16 +95,127 @@ export interface OnchainAsset { standard: string; } +export interface OnchainAssetBeta { + symbol: string; + name: string; + address?: string; + decimals: number; + standards?: string[]; +} + export interface AssetMetadata { scope: AssetScope; deprecated: boolean; } +export interface AssetMediaAttributes { + monochrome?: boolean; +} + +export interface AssetMedia { + url: string; + type: string; + attributes?: AssetMediaAttributes; +} + +export interface AssetMetadataBeta { + scope: AssetScope; + deprecated: boolean; + deprecationReferralId?: string; + verified: boolean; + website?: string; + media?: AssetMedia[]; +} + export enum AssetScope { GLOBAL = "Global", LOCAL = "Local", } +export interface ListAssetResponse { + id: string; + legacyId: string; + blockchainId?: string; + displayName?: string; + displaySymbol?: string; + assetClass: AssetClassBeta; + onchain?: OnchainAssetBeta; + metadata: AssetMetadataBeta; +} + +export interface ListAssetsResponse { + next: string | null; + data: ListAssetResponse[]; +} + +export interface ListAssetsFilters { + blockchainId?: string; + assetClass?: AssetClassBeta; + symbol?: string; + scope?: AssetScope; + deprecated?: boolean; + pageCursor?: string; + pageSize?: number; +} + +export enum BlockchainSigningAlgo { + ECDSA_SECP256K1 = "ECDSA_SECP256K1", + EDDSA_ED25519 = "EDDSA_ED25519", +} + +export interface BlockchainOnchain { + protocol: string; + chainId?: string; + test: boolean; + signingAlgo: BlockchainSigningAlgo; +} + +export class BlockchainMedia { + url: string; + type: string; +} + +export class BlockchainExplorer { + base: string; + address?: string; + tx?: string; + token?: string; +} + +export enum BlockchainScope { + GLOBAL = "Global", + LOCAL = "Local", +} + +export interface BlockchainMetadata { + scope: BlockchainScope; + deprecated: boolean; + media?: BlockchainMedia[]; + explorer?: BlockchainExplorer; +} + +export interface ListBlockchainResponse { + id: string; + legacyId: string; + displayName: string; + nativeAssetId: string; + onchain: BlockchainOnchain; + metadata: BlockchainMetadata; +} + +export interface ListBlockchainsResponse { + next: string | null; + data: ListBlockchainResponse[]; +} + +export interface ListBlockchainsFilters { + protocol?: string; + deprecated?: boolean; + test?: boolean; + pageCursor?: string; + pageSize?: number; +} + export interface VaultAssetResponse { id: string; address: string; @@ -237,6 +356,7 @@ export interface TransactionArgumentsFeePayerInfo { feePayerAccountId: string; } +// example export interface TransactionArguments { assetId?: string; source?: TransferPeerPath; From 2f6d795bd7b7268bd7236a92f29d50d888c9d793 Mon Sep 17 00:00:00 2001 From: Lazar Stijakovic Date: Thu, 19 Dec 2024 12:13:06 +0100 Subject: [PATCH 2/3] lint: spacing --- src/types.ts | 94 ++++++++++++++++++++++++++-------------------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/src/types.ts b/src/types.ts index cc10cbe..367c280 100644 --- a/src/types.ts +++ b/src/types.ts @@ -114,17 +114,17 @@ export interface AssetMediaAttributes { export interface AssetMedia { url: string; - type: string; - attributes?: AssetMediaAttributes; + type: string; + attributes?: AssetMediaAttributes; } export interface AssetMetadataBeta { - scope: AssetScope; - deprecated: boolean; - deprecationReferralId?: string; - verified: boolean; - website?: string; - media?: AssetMedia[]; + scope: AssetScope; + deprecated: boolean; + deprecationReferralId?: string; + verified: boolean; + website?: string; + media?: AssetMedia[]; } export enum AssetScope { @@ -133,14 +133,14 @@ export enum AssetScope { } export interface ListAssetResponse { - id: string; - legacyId: string; - blockchainId?: string; - displayName?: string; - displaySymbol?: string; - assetClass: AssetClassBeta; - onchain?: OnchainAssetBeta; - metadata: AssetMetadataBeta; + id: string; + legacyId: string; + blockchainId?: string; + displayName?: string; + displaySymbol?: string; + assetClass: AssetClassBeta; + onchain?: OnchainAssetBeta; + metadata: AssetMetadataBeta; } export interface ListAssetsResponse { @@ -150,36 +150,36 @@ export interface ListAssetsResponse { export interface ListAssetsFilters { blockchainId?: string; - assetClass?: AssetClassBeta; - symbol?: string; - scope?: AssetScope; - deprecated?: boolean; - pageCursor?: string; - pageSize?: number; + assetClass?: AssetClassBeta; + symbol?: string; + scope?: AssetScope; + deprecated?: boolean; + pageCursor?: string; + pageSize?: number; } export enum BlockchainSigningAlgo { - ECDSA_SECP256K1 = "ECDSA_SECP256K1", - EDDSA_ED25519 = "EDDSA_ED25519", + ECDSA_SECP256K1 = "ECDSA_SECP256K1", + EDDSA_ED25519 = "EDDSA_ED25519", } export interface BlockchainOnchain { - protocol: string; - chainId?: string; - test: boolean; - signingAlgo: BlockchainSigningAlgo; + protocol: string; + chainId?: string; + test: boolean; + signingAlgo: BlockchainSigningAlgo; } export class BlockchainMedia { - url: string; - type: string; + url: string; + type: string; } export class BlockchainExplorer { - base: string; - address?: string; - tx?: string; - token?: string; + base: string; + address?: string; + tx?: string; + token?: string; } export enum BlockchainScope { @@ -188,19 +188,19 @@ export enum BlockchainScope { } export interface BlockchainMetadata { - scope: BlockchainScope; - deprecated: boolean; - media?: BlockchainMedia[]; - explorer?: BlockchainExplorer; + scope: BlockchainScope; + deprecated: boolean; + media?: BlockchainMedia[]; + explorer?: BlockchainExplorer; } export interface ListBlockchainResponse { id: string; - legacyId: string; - displayName: string; - nativeAssetId: string; - onchain: BlockchainOnchain; - metadata: BlockchainMetadata; + legacyId: string; + displayName: string; + nativeAssetId: string; + onchain: BlockchainOnchain; + metadata: BlockchainMetadata; } export interface ListBlockchainsResponse { @@ -210,10 +210,10 @@ export interface ListBlockchainsResponse { export interface ListBlockchainsFilters { protocol?: string; - deprecated?: boolean; - test?: boolean; - pageCursor?: string; - pageSize?: number; + deprecated?: boolean; + test?: boolean; + pageCursor?: string; + pageSize?: number; } export interface VaultAssetResponse { From 938df36638aba6f89342a7e0b535c0d6132291ca Mon Sep 17 00:00:00 2001 From: Lazar Stijakovic Date: Thu, 19 Dec 2024 13:01:01 +0100 Subject: [PATCH 3/3] fix: removed idempotency key --- src/fireblocks-sdk.ts | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/fireblocks-sdk.ts b/src/fireblocks-sdk.ts index d09a482..293e4a1 100644 --- a/src/fireblocks-sdk.ts +++ b/src/fireblocks-sdk.ts @@ -916,37 +916,33 @@ export class FireblocksSDK { /** * List assets [BETA] * @param filters - * @param requestOptions */ - public async listAssets(filters?: ListAssetsFilters, requestOptions?: RequestOptions): Promise { - return await this.apiClient.issueGetRequest(`/v1/assets`, filters, requestOptions); + public async listAssets(filters?: ListAssetsFilters): Promise { + return await this.apiClient.issueGetRequest(`/v1/assets`, filters); } /** * Get an asset [BETA] * @param assetId The ID or legacyId of the asset - * @param requestOptions */ - public async getAssetById(assetId: string, requestOptions?: RequestOptions): Promise { - return await this.apiClient.issueGetRequest(`/v1/assets/${assetId}`, {}, requestOptions); + public async getAssetById(assetId: string): Promise { + return await this.apiClient.issueGetRequest(`/v1/assets/${assetId}`); } /** * List blockchains [BETA] * @param filters - * @param requestOptions */ - public async listBlockchains(filters?: ListBlockchainsFilters, requestOptions?: RequestOptions): Promise { - return await this.apiClient.issueGetRequest(`/v1/blockchains`, filters, requestOptions); + public async listBlockchains(filters?: ListBlockchainsFilters): Promise { + return await this.apiClient.issueGetRequest(`/v1/blockchains`, filters); } /** * Get an blockchain [BETA] * @param blockchainId The ID or legacyId of the blockchain - * @param requestOptions */ - public async getBlockchainById(blockchainId: string, requestOptions?: RequestOptions): Promise { - return await this.apiClient.issueGetRequest(`/v1/blockchains/${blockchainId}`, {}, requestOptions); + public async getBlockchainById(blockchainId: string): Promise { + return await this.apiClient.issueGetRequest(`/v1/blockchains/${blockchainId}`); } /**