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 registry - update endpoints #230

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
11 changes: 11 additions & 0 deletions src/fireblocks-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1754,6 +1754,17 @@ export class FireblocksSDK {
return await this.apiClient.issueGetRequest(`/v1/contract-service/contract/${blockchainId}/${contractAddress}/abi`);
}

/**
* Get contract ABI function by contractId
* @param contractId
* @param functionSignature
*/
public async getContractAbiFunction(contractId: string, functionSignature: string): Promise<ContractAbiResponseDto> {
return await this.apiClient.issueGetRequest(`/v1/contract-service/contract/${contractId}/function?${queryString.stringify({
functionSignature
})}`);
}

/**
* Call contract read function
* @param blockchainId
Expand Down
97 changes: 83 additions & 14 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface Web3PagedResponse<T> {
paging?: Paging;
}

export type APIResponseHeaders = AxiosResponseHeaders & {"x-request-id"?: string};
export type APIResponseHeaders = AxiosResponseHeaders & { "x-request-id"?: string };

export interface VaultAccountResponse {
id: string;
Expand Down Expand Up @@ -807,8 +807,14 @@ export interface NoneNetworkRoutingDest {
scheme: NetworkScheme.NONE;
}

export type NetworkConnectionCryptoRoutingDest = CustomCryptoRoutingDest | DefaultNetworkRoutingDest | NoneNetworkRoutingDest;
export type NetworkConnectionFiatRoutingDest = CustomFiatRoutingDest | DefaultNetworkRoutingDest | NoneNetworkRoutingDest;
export type NetworkConnectionCryptoRoutingDest =
CustomCryptoRoutingDest
| DefaultNetworkRoutingDest
| NoneNetworkRoutingDest;
export type NetworkConnectionFiatRoutingDest =
CustomFiatRoutingDest
| DefaultNetworkRoutingDest
| NoneNetworkRoutingDest;
export type NetworkIdCryptoRoutingDest = CustomCryptoRoutingDest | NoneNetworkRoutingDest;
export type NetworkIdFiatRoutingDest = CustomFiatRoutingDest | NoneNetworkRoutingDest;

Expand Down Expand Up @@ -1155,6 +1161,7 @@ export interface MaxBip44IndexUsedResponse {
maxBip44AddressIndexUsed?: number;
maxBip44ChangeAddressIndexUsed?: number;
}

export interface AddressResponse {
assetId: string;
address: string;
Expand Down Expand Up @@ -1239,7 +1246,7 @@ export interface GetAssetWalletsResponse {
paging: {
after?: string;
before?: string;
}
};
}

export interface VaultBalancesFilter {
Expand Down Expand Up @@ -1387,6 +1394,7 @@ export interface FeePayerConfiguration {
export interface BaseWeb3ConnectionPayload {
feeLevel: Web3ConnectionFeeLevel;
}

export interface WorkspaceWalletIdentifier {
vaultAccountId: number;
}
Expand All @@ -1401,7 +1409,9 @@ export interface WalletConnectConnectionPayload {
chainIds?: string[];
}

export type CreateWeb3ConnectionPayload = (WorkspaceWalletIdentifier | NonCustodialWalletIdentifier) & BaseWeb3ConnectionPayload;
export type CreateWeb3ConnectionPayload =
(WorkspaceWalletIdentifier | NonCustodialWalletIdentifier)
& BaseWeb3ConnectionPayload;

export type CreateWalletConnectPayload = CreateWeb3ConnectionPayload & WalletConnectConnectionPayload;

Expand Down Expand Up @@ -1561,17 +1571,60 @@ export enum NFTOwnershipWalletType {
"END_USER_WALLET" = "END_USER_WALLET",
}

export enum ContractTemplateType {
FUNGIBLE_TOKEN = "FUNGIBLE_TOKEN",
NON_FUNGIBLE_TOKEN = "NON_FUNGIBLE_TOKEN",
NON_TOKEN = "NON_TOKEN",
UUPS_PROXY = "UUPS_PROXY",
}

export enum ContractInitializationPhase {
ON_DEPLOYMENT = "ON_DEPLOYMENT",
POST_DEPLOYMENT = "POST_DEPLOYMENT",
}

export enum InputFieldMetadataTypes {
EncodedFunctionCallFieldType = "encodedFunctionCall",
DeployedContractAddressFieldType = "deployedContractAddress",
SupportedAssetAddressFieldType = "supportedAssetAddress",
}

export interface EncodedFunctionCallFieldMetadata {
templateId: string;
functionSignature: string;
}

export interface DeployedContractAddressFieldMetadata {
templateId: string;
}


export interface FieldMetadata {
type: InputFieldMetadataTypes;
info: EncodedFunctionCallFieldMetadata | DeployedContractAddressFieldMetadata;
}


export interface InputFieldsMetadata {
[contractMethod: string]: Record<string, FieldMetadata>;
}

export interface ContractUploadRequest {
name: string;
description: string;
longDescription: string;
bytecode: string;
sourcecode: string;
type?: ContractTemplateType;
implementationContractId?: string;
initializationPhase: ContractInitializationPhase;
compilerOutputMetadata?: object;
inputFieldsMetadata?: InputFieldsMetadata;
docs?: ContractDoc;
abi?: AbiFunction[];
attributes?: Record<string, string>;
}

interface AbiFunction {
name?: string;
stateMutability?: string;
Expand All @@ -1582,13 +1635,26 @@ interface AbiFunction {
returns?: Record<string, string>;
}

interface Parameter {
export type ValueType = string | number | boolean | ValueType[];

export interface LeanAbiFunction {
name?: string;
inputs: ParameterWithValue[];
}

export interface Parameter {
name: string;
description?: string;
internalType: string;
type: string;
components?: Parameter[];
}

interface ParameterWithValue extends Parameter {
value?: ValueType | ParameterWithValueList;
functionValue?: LeanAbiFunction;
}

interface ContractDoc {
details?: string;
events?: string;
Expand All @@ -1602,6 +1668,7 @@ interface FunctionDoc {
params?: Record<string, string>;
returns?: Record<string, string>;
}

interface VendorDto {
id: string;
name: string;
Expand All @@ -1611,7 +1678,7 @@ interface VendorDto {
export interface ContractDeployRequest {
assetId: string;
vaultAccountId: string;
constructorParameters?: object[];
constructorParameters?: ParameterWithValue[];
}

export interface ContractDeployResponse {
Expand Down Expand Up @@ -1643,6 +1710,10 @@ export interface ContractTemplateDto {
owner?: string;
vendor?: VendorDto;
isPublic: boolean;
canDeploy: boolean;
type: ContractTemplateType;
implementationContractId?: string;
initializationPhase: ContractInitializationPhase;
}

export interface LinkedTokenMetadata {
Expand All @@ -1660,10 +1731,12 @@ export interface LinkedTokenMetadata {
decimals?: number;
vaultAccountId?: string;
}

export interface TokenLink {
assetId: string;
assetMetadata?: LinkedTokenMetadata;
}

export interface PendingTokenLinkDto {
id: number;
txId?: string;
Expand Down Expand Up @@ -1745,13 +1818,7 @@ interface StellarRippleCreateParamsDto {
issuerAddress?: string;
}

interface ParameterWithValue {
internalType: string;
name: string;
type: string;
description?: string;
value: any;
}

export type ParameterWithValueList = ParameterWithValue[] | ParameterWithValueList[];


Expand Down Expand Up @@ -1803,6 +1870,7 @@ export interface SmartTransfersTicketTermPayload {
fromNetworkId: string;
toNetworkId: string;
}

export interface SmartTransfersTicketCreatePayload {
createdByNetworkId: string;
type: string;
Expand Down Expand Up @@ -1955,6 +2023,7 @@ export namespace NCW {
blockchainDisplayName?: string;
blockchainId?: string;
}

export interface WalletAssetAddress {
accountName: string;
accountId: string;
Expand Down
Loading