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

contract-service - adding endpoints #221

Merged
merged 6 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
54 changes: 52 additions & 2 deletions src/fireblocks-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ import {
PublicKeyInformation,
DropTransactionResponse,
TokenLink,
TokenLinkPermissionEntry,
IssueTokenRequest,
NFTOwnershipStatus,
NFTOwnershipStatusUpdatedPayload,
Expand Down Expand Up @@ -106,9 +105,11 @@ import {
ContractDeployResponse,
ContractDeployRequest,
PendingTokenLinkDto,
TAP,
ExchangeAccountsPageFilter,
PagedExchangeResponse,
TAP,
WriteCallFunctionDto,
ReadCallFunctionDto,
} from "./types";
import { AxiosProxyConfig, AxiosResponse } from "axios";
import { PIIEncryption } from "./pii-client";
Expand Down Expand Up @@ -1689,6 +1690,55 @@ export class FireblocksSDK {
return await this.apiClient.issuePostRequest(`/v1/contract-registry/contracts/${contractId}/deploy`, payload);
}

/**
* Get all contracts by blockchain and template
* @param blockchainId
* @param templateId
*/
public async getContractsByFilter(templateId: string, blockchainId?: string): Promise<object> {
const requestFilter = {
templateId,
blockchainId,
};
return await this.apiClient.issueGetRequest(`/v1/contract-service/contract?${queryString.stringify(requestFilter)}`);
}

/**
* Get contract by blockchain and address
* @param blockchainId
* @param templateId
*/
public async getContractByAddress(blockchainId: string, contractAddress: string): Promise<object> {
return await this.apiClient.issueGetRequest(`/v1/contract-service/contract/${blockchainId}/${contractAddress}`);
}

/**
* Get contract's ABI by blockchain and address
* @param blockchainId
* @param templateId
*/
public async getContractAbi(blockchainId: string, contractAddress: string): Promise<object> {
return await this.apiClient.issueGetRequest(`/v1/contract-service/contract/${blockchainId}/${contractAddress}/abi`);
}

/**
* Call contract read function
* @param blockchainId
* @param templateId
*/
public async readContractCallFunction(blockchainId: string, contractAddress: string, payload: ReadCallFunctionDto): Promise<object> {
return await this.apiClient.issuePostRequest(`/v1/contract-service/contract/${blockchainId}/${contractAddress}/function/read`, payload);
}

/**
* Call contract write function
* @param blockchainId
* @param templateId
*/
public async writeContractCallFunction(blockchainId: string, contractAddress: string, payload: WriteCallFunctionDto): Promise<object> {
return await this.apiClient.issuePostRequest(`/v1/contract-service/contract/${blockchainId}/${contractAddress}/function/write`, payload);
}

/**
* Issue a new token and link it to the tenant
* @param payload
Expand Down
14 changes: 13 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1513,7 +1513,6 @@ export interface ContractUploadRequest {
docs?: ContractDoc;
abi?: AbiFunction[];
attributes?: Record<string, string>;
vendorId?: string;
}
interface AbiFunction {
name?: string;
Expand Down Expand Up @@ -1578,6 +1577,7 @@ export interface ContractTemplateDto {
id: string;
name: string;
description: string;
longDescription: string;
compilerOutputMetadata?: object;
abi: AbiFunction[];
attributes?: Record<string, string>;
Expand Down Expand Up @@ -1681,6 +1681,18 @@ interface EVMTokenCreateParamsDto {
constructorParams?: Array<ParameterWithValue>;
}

export interface ReadCallFunctionDto {
abiFunction: AbiFunction;
}

export interface WriteCallFunctionDto {
vaultAccountId: string;
abiFunction: AbiFunction;
amount?: string;
feeLevel?: FeeLevel;
note?: string;
}

export enum SmartTransfersTicketDirection {
EXCHANGE = "EXCHANGE",
SEND = "SEND",
Expand Down
Loading