Skip to content

Commit

Permalink
Merge pull request #317 from lazars14-f/master
Browse files Browse the repository at this point in the history
Add asset and blockchain beta apis
  • Loading branch information
SlavaSereb authored Dec 19, 2024
2 parents d5ae9f8 + 938df36 commit 92d4927
Show file tree
Hide file tree
Showing 2 changed files with 158 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/fireblocks-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -907,6 +913,38 @@ export class FireblocksSDK {
return await this.apiClient.issuePostRequest(`/v1/assets`, { blockchainId, address, symbol }, requestOptions);
}

/**
* List assets [BETA]
* @param filters
*/
public async listAssets(filters?: ListAssetsFilters): Promise<ListAssetsResponse> {
return await this.apiClient.issueGetRequest(`/v1/assets`, filters);
}

/**
* Get an asset [BETA]
* @param assetId The ID or legacyId of the asset
*/
public async getAssetById(assetId: string): Promise<ListAssetResponse> {
return await this.apiClient.issueGetRequest(`/v1/assets/${assetId}`);
}

/**
* List blockchains [BETA]
* @param filters
*/
public async listBlockchains(filters?: ListBlockchainsFilters): Promise<ListBlockchainsResponse> {
return await this.apiClient.issueGetRequest(`/v1/blockchains`, filters);
}

/**
* Get an blockchain [BETA]
* @param blockchainId The ID or legacyId of the blockchain
*/
public async getBlockchainById(blockchainId: string): Promise<ListBlockchainResponse> {
return await this.apiClient.issueGetRequest(`/v1/blockchains/${blockchainId}`);
}

/**
* Retry to create a vault asset for a vault asset that failed
* @param vaultAccountId The vault account ID
Expand Down
120 changes: 120 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -237,6 +356,7 @@ export interface TransactionArgumentsFeePayerInfo {
feePayerAccountId: string;
}

// example
export interface TransactionArguments {
assetId?: string;
source?: TransferPeerPath;
Expand Down

0 comments on commit 92d4927

Please sign in to comment.