diff --git a/src/fireblocks-sdk.ts b/src/fireblocks-sdk.ts index 1b22bbc5..d2119362 100644 --- a/src/fireblocks-sdk.ts +++ b/src/fireblocks-sdk.ts @@ -73,7 +73,6 @@ import { PublicKeyInformation, DropTransactionResponse, TokenLink, - TokenLinkPermissionEntry, IssueTokenRequest, NFTOwnershipStatus, NFTOwnershipStatusUpdatedPayload, @@ -101,14 +100,23 @@ import { UsersGroup, LeanContractTemplateDto, ContractTemplateDto, - BatchTask, BatchJob, JobCreatedResponse, + BatchTask, + BatchJob, + JobCreatedResponse, ContractUploadRequest, ContractDeployResponse, ContractDeployRequest, PendingTokenLinkDto, - TAP, ExchangeAccountsPageFilter, PagedExchangeResponse, + TAP, + WriteCallFunctionDto, + ReadCallFunctionDto, + WriteCallFunctionResponseDto, + ContractAbiResponseDto, + DeployedContractResponseDto, + LeanDeployedContractResponseDto, + ParameterWithValueList, } from "./types"; import { AxiosProxyConfig, AxiosResponse } from "axios"; import { PIIEncryption } from "./pii-client"; @@ -1689,6 +1697,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 { + 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 { + 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 { + 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 { + 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 { + 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 @@ -1737,7 +1794,7 @@ export class FireblocksSDK { /** * Get all pending tokens linked to the tenant */ - public async getPendingLinkedTokens(): Promise { + public async getPendingLinkedTokens(): Promise { return await this.apiClient.issueGetRequest(`/v1/tokenization/tokens/pending`); } diff --git a/src/types.ts b/src/types.ts index 6cf9e8ae..906c0d4c 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1513,7 +1513,6 @@ export interface ContractUploadRequest { docs?: ContractDoc; abi?: AbiFunction[]; attributes?: Record; - vendorId?: string; } interface AbiFunction { name?: string; @@ -1578,6 +1577,7 @@ export interface ContractTemplateDto { id: string; name: string; description: string; + longDescription: string; compilerOutputMetadata?: object; abi: AbiFunction[]; attributes?: Record; @@ -1587,14 +1587,11 @@ export interface ContractTemplateDto { isPublic: boolean; } -export interface TokenLinkPermissionEntry { - permission: "MINT" | "BURN"; - vaultAccountId: string; -} - export interface LinkedTokenMetadata { assetId: string; name?: string; + symbol?: string; + networkProtocol?: string; totalSupply?: string; holdersCount?: number; type?: string; @@ -1602,12 +1599,12 @@ export interface LinkedTokenMetadata { issuerAddress?: string; testnet?: boolean; blockchain?: string; + decimals?: number; + vaultAccountId?: string; } export interface TokenLink { - id: string; assetId: string; assetMetadata?: LinkedTokenMetadata; - permissions: TokenLinkPermissionEntry[]; } export interface PendingTokenLinkDto { id: number; @@ -1618,6 +1615,28 @@ export interface PendingTokenLinkDto { blockchainId?: string; } +export interface LeanDeployedContractResponseDto { + contractAddress: string; + blockchainId: string; + contractTemplateId: string; +} + +export interface DeployedContractResponseDto extends LeanDeployedContractResponseDto { + id: string; + vaultAccountId?: string; +} + +type ContractAbi = AbiFunction[]; + +export interface ContractAbiResponseDto { + abi: ContractAbi; + implementationAbi?: ContractAbi; +} + +export interface WriteCallFunctionResponseDto { + txId: string; +} + export interface IssueTokenRequest { symbol: string; name: string; @@ -1675,12 +1694,26 @@ interface ParameterWithValue { description?: string; value: any; } +export type ParameterWithValueList = ParameterWithValue[] | ParameterWithValueList[]; + interface EVMTokenCreateParamsDto { contractId: string; constructorParams?: Array; } +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",