From 34172485996c24492e7d31ff0a3525c18b65b723 Mon Sep 17 00:00:00 2001 From: orman Date: Tue, 28 Nov 2023 21:19:39 +0200 Subject: [PATCH 1/5] Get contract ABI function by contractId --- src/fireblocks-sdk.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) 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 From 936e24dfc25f4233e8aea694aa4549befb9bb2cd Mon Sep 17 00:00:00 2001 From: orman Date: Tue, 28 Nov 2023 21:19:48 +0200 Subject: [PATCH 2/5] types.ts --- src/types.ts | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/types.ts b/src/types.ts index 0da5e140..8a252eca 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1239,7 +1239,7 @@ export interface GetAssetWalletsResponse { paging: { after?: string; before?: string; - } + }; } export interface VaultBalancesFilter { @@ -1561,17 +1561,33 @@ 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 interface ContractUploadRequest { name: string; description: string; longDescription: string; bytecode: string; sourcecode: string; + type?: ContractTemplateType; + implementationContractId?: string; + initializationPhase: ContractInitializationPhase; compilerOutputMetadata?: object; docs?: ContractDoc; abi?: AbiFunction[]; attributes?: Record; } + interface AbiFunction { name?: string; stateMutability?: string; @@ -1643,6 +1659,10 @@ export interface ContractTemplateDto { owner?: string; vendor?: VendorDto; isPublic: boolean; + canDeploy: boolean; + type: ContractTemplateType; + implementationContractId?: string; + initializationPhase: ContractInitializationPhase; } export interface LinkedTokenMetadata { From 1aa1fe339054895ec394ac955cbf18cf3b730983 Mon Sep 17 00:00:00 2001 From: Idan Yael Date: Thu, 30 Nov 2023 12:25:34 +0200 Subject: [PATCH 3/5] add metadata --- src/types.ts | 75 +++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 62 insertions(+), 13 deletions(-) diff --git a/src/types.ts b/src/types.ts index 8a252eca..ead93921 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; @@ -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; @@ -1573,6 +1583,32 @@ export enum ContractInitializationPhase { POST_DEPLOYMENT = "POST_DEPLOYMENT", } +export enum InputFieldMetadataTypes { + EncodedFunctionCallFieldType = "encodedFunctionCall", + DeployedContractAddressFieldType = "deployedContractAddress", + SupportedAssetAddressFieldType = "supportedAssetAddress", +} + +export class EncodedFunctionCallFieldMetadata { + templateId: string; + functionSignature: string; +} + +export class DeployedContractAddressFieldMetadata { + templateId: string; +} + + +export class FieldMetadata { + type: string | InputFieldMetadataTypes; + info: EncodedFunctionCallFieldMetadata | DeployedContractAddressFieldMetadata; +} + + +export interface InputFieldsMetadata { + [contractMethod: string]: Record; +} + export interface ContractUploadRequest { name: string; description: string; @@ -1583,6 +1619,7 @@ export interface ContractUploadRequest { implementationContractId?: string; initializationPhase: ContractInitializationPhase; compilerOutputMetadata?: object; + inputFieldsMetadata?: InputFieldsMetadata; docs?: ContractDoc; abi?: AbiFunction[]; attributes?: Record; @@ -1598,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; @@ -1618,6 +1668,7 @@ interface FunctionDoc { params?: Record; returns?: Record; } + interface VendorDto { id: string; name: string; @@ -1627,7 +1678,7 @@ interface VendorDto { export interface ContractDeployRequest { assetId: string; vaultAccountId: string; - constructorParameters?: object[]; + constructorParameters?: ParameterWithValue[]; } export interface ContractDeployResponse { @@ -1680,10 +1731,12 @@ export interface LinkedTokenMetadata { decimals?: number; vaultAccountId?: string; } + export interface TokenLink { assetId: string; assetMetadata?: LinkedTokenMetadata; } + export interface PendingTokenLinkDto { id: number; txId?: string; @@ -1765,13 +1818,7 @@ interface StellarRippleCreateParamsDto { issuerAddress?: string; } -interface ParameterWithValue { - internalType: string; - name: string; - type: string; - description?: string; - value: any; -} + export type ParameterWithValueList = ParameterWithValue[] | ParameterWithValueList[]; @@ -1823,6 +1870,7 @@ export interface SmartTransfersTicketTermPayload { fromNetworkId: string; toNetworkId: string; } + export interface SmartTransfersTicketCreatePayload { createdByNetworkId: string; type: string; @@ -1975,6 +2023,7 @@ export namespace NCW { blockchainDisplayName?: string; blockchainId?: string; } + export interface WalletAssetAddress { accountName: string; accountId: string; From 10048f9308c9fdfe677788b6e22b8577fec2ff1c Mon Sep 17 00:00:00 2001 From: Idan Yael Date: Thu, 30 Nov 2023 12:26:36 +0200 Subject: [PATCH 4/5] interface instead of class --- src/types.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/types.ts b/src/types.ts index ead93921..8d24475b 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1589,17 +1589,17 @@ export enum InputFieldMetadataTypes { SupportedAssetAddressFieldType = "supportedAssetAddress", } -export class EncodedFunctionCallFieldMetadata { +export interface EncodedFunctionCallFieldMetadata { templateId: string; functionSignature: string; } -export class DeployedContractAddressFieldMetadata { +export interface DeployedContractAddressFieldMetadata { templateId: string; } -export class FieldMetadata { +export interface FieldMetadata { type: string | InputFieldMetadataTypes; info: EncodedFunctionCallFieldMetadata | DeployedContractAddressFieldMetadata; } From 7a62e33daf4e506b92ffc4ca08c443690f47c959 Mon Sep 17 00:00:00 2001 From: Idan Yael Date: Thu, 30 Nov 2023 13:32:48 +0200 Subject: [PATCH 5/5] type --- src/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types.ts b/src/types.ts index 8d24475b..97e418bc 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1600,7 +1600,7 @@ export interface DeployedContractAddressFieldMetadata { export interface FieldMetadata { - type: string | InputFieldMetadataTypes; + type: InputFieldMetadataTypes; info: EncodedFunctionCallFieldMetadata | DeployedContractAddressFieldMetadata; }