diff --git a/src/fireblocks-sdk.ts b/src/fireblocks-sdk.ts index 70a5517b..c8232d20 100644 --- a/src/fireblocks-sdk.ts +++ b/src/fireblocks-sdk.ts @@ -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 { + return await this.apiClient.issueGetRequest(`/v1/contract-service/contract/${contractId}/function?${queryString.stringify({ + functionSignature + })}`); + } + /** * Call contract read function * @param blockchainId diff --git a/src/types.ts b/src/types.ts index 0da5e140..97e418bc 100644 --- a/src/types.ts +++ b/src/types.ts @@ -9,7 +9,7 @@ export interface Web3PagedResponse { paging?: Paging; } -export type APIResponseHeaders = AxiosResponseHeaders & {"x-request-id"?: string}; +export type APIResponseHeaders = AxiosResponseHeaders & { "x-request-id"?: string }; export interface VaultAccountResponse { id: string; @@ -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; @@ -1155,6 +1161,7 @@ export interface MaxBip44IndexUsedResponse { maxBip44AddressIndexUsed?: number; maxBip44ChangeAddressIndexUsed?: number; } + export interface AddressResponse { assetId: string; address: string; @@ -1239,7 +1246,7 @@ export interface GetAssetWalletsResponse { paging: { after?: string; before?: string; - } + }; } export interface VaultBalancesFilter { @@ -1387,6 +1394,7 @@ export interface FeePayerConfiguration { export interface BaseWeb3ConnectionPayload { feeLevel: Web3ConnectionFeeLevel; } + export interface WorkspaceWalletIdentifier { vaultAccountId: number; } @@ -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; @@ -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; +} + 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; } + interface AbiFunction { name?: string; stateMutability?: string; @@ -1582,13 +1635,26 @@ interface AbiFunction { returns?: Record; } -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; @@ -1602,6 +1668,7 @@ interface FunctionDoc { params?: Record; returns?: Record; } + interface VendorDto { id: string; name: string; @@ -1611,7 +1678,7 @@ interface VendorDto { export interface ContractDeployRequest { assetId: string; vaultAccountId: string; - constructorParameters?: object[]; + constructorParameters?: ParameterWithValue[]; } export interface ContractDeployResponse { @@ -1643,6 +1710,10 @@ export interface ContractTemplateDto { owner?: string; vendor?: VendorDto; isPublic: boolean; + canDeploy: boolean; + type: ContractTemplateType; + implementationContractId?: string; + initializationPhase: ContractInitializationPhase; } export interface LinkedTokenMetadata { @@ -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; @@ -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[]; @@ -1803,6 +1870,7 @@ export interface SmartTransfersTicketTermPayload { fromNetworkId: string; toNetworkId: string; } + export interface SmartTransfersTicketCreatePayload { createdByNetworkId: string; type: string; @@ -1955,6 +2023,7 @@ export namespace NCW { blockchainDisplayName?: string; blockchainId?: string; } + export interface WalletAssetAddress { accountName: string; accountId: string;