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

Add asset and blockchain beta apis #317

Merged
merged 3 commits into from
Dec 19, 2024
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
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
Loading