From 74562dc1d60af76ea94273ae9a0bfaff01228ee8 Mon Sep 17 00:00:00 2001 From: fireblocks_dx_team Date: Wed, 18 Dec 2024 15:51:53 +0000 Subject: [PATCH] Generated SDK #5009 --- .openapi-generator/FILES | 3 + README.md | 8 +- api/openapi.yaml | 146 +++++++-- build.gradle | 2 +- docs/EmbeddedWalletsApi.md | 192 ++++++++++++ docs/PublicKeyInformation.md | 16 +- pom.xml | 2 +- .../com/fireblocks/sdk/Configuration.java | 2 +- .../java/com/fireblocks/sdk/Fireblocks.java | 8 + .../sdk/api/EmbeddedWalletsApi.java | 292 ++++++++++++++++++ .../sdk/model/PublicKeyInformation.java | 90 ++++-- .../com/fireblocks/sdk/FireblocksTest.java | 8 + .../sdk/api/EmbeddedWalletsApiTest.java | 68 ++++ 13 files changed, 768 insertions(+), 69 deletions(-) create mode 100644 docs/EmbeddedWalletsApi.md create mode 100644 src/main/java/com/fireblocks/sdk/api/EmbeddedWalletsApi.java create mode 100644 src/test/java/com/fireblocks/sdk/api/EmbeddedWalletsApiTest.java diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index f13f77f2..ca551fdf 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -177,6 +177,7 @@ docs/DropTransactionRequest.md docs/DropTransactionResponse.md docs/EVMTokenCreateParamsDto.md docs/EditGasStationConfigurationResponse.md +docs/EmbeddedWalletsApi.md docs/ErrorResponse.md docs/ErrorResponseError.md docs/ErrorSchema.md @@ -547,6 +548,7 @@ src/main/java/com/fireblocks/sdk/api/ContractTemplatesApi.java src/main/java/com/fireblocks/sdk/api/ContractsApi.java src/main/java/com/fireblocks/sdk/api/CosignersBetaApi.java src/main/java/com/fireblocks/sdk/api/DeployedContractsApi.java +src/main/java/com/fireblocks/sdk/api/EmbeddedWalletsApi.java src/main/java/com/fireblocks/sdk/api/ExchangeAccountsApi.java src/main/java/com/fireblocks/sdk/api/ExternalWalletsApi.java src/main/java/com/fireblocks/sdk/api/FiatAccountsApi.java @@ -1056,6 +1058,7 @@ src/test/java/com/fireblocks/sdk/api/ContractTemplatesApiTest.java src/test/java/com/fireblocks/sdk/api/ContractsApiTest.java src/test/java/com/fireblocks/sdk/api/CosignersBetaApiTest.java src/test/java/com/fireblocks/sdk/api/DeployedContractsApiTest.java +src/test/java/com/fireblocks/sdk/api/EmbeddedWalletsApiTest.java src/test/java/com/fireblocks/sdk/api/ExchangeAccountsApiTest.java src/test/java/com/fireblocks/sdk/api/ExternalWalletsApiTest.java src/test/java/com/fireblocks/sdk/api/FiatAccountsApiTest.java diff --git a/README.md b/README.md index 278929e2..31e94686 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Add this dependency to your project's POM: com.fireblocks.sdk fireblocks-sdk - 6.0.0 + 0.0.0 compile ``` @@ -42,7 +42,7 @@ Add this dependency to your project's POM: Add this dependency to your project's build file: ```groovy -compile "com.fireblocks.sdk:fireblocks-sdk:6.0.0" +compile "com.fireblocks.sdk:fireblocks-sdk:0.0.0" ``` ### Others @@ -55,7 +55,7 @@ mvn clean package Then manually install the following JARs: -- `target/fireblocks-sdk-6.0.0.jar` +- `target/fireblocks-sdk-0.0.0.jar` - `target/lib/*.jar` @@ -186,6 +186,8 @@ Class | Method | HTTP request | Description *DeployedContractsApi* | [**getDeployedContractByAddress**](docs/DeployedContractsApi.md#getDeployedContractByAddress) | **GET** /tokenization/contracts/{assetId}/{contractAddress} | Return deployed contract data *DeployedContractsApi* | [**getDeployedContractById**](docs/DeployedContractsApi.md#getDeployedContractById) | **GET** /tokenization/contracts/{id} | Return deployed contract data by id *DeployedContractsApi* | [**getDeployedContracts**](docs/DeployedContractsApi.md#getDeployedContracts) | **GET** /tokenization/contracts | List deployed contracts data +*EmbeddedWalletsApi* | [**getPublicKeyInfoForAddressNcw**](docs/EmbeddedWalletsApi.md#getPublicKeyInfoForAddressNcw) | **GET** /ncw/{walletId}/accounts/{accountId}/{assetId}/{change}/{addressIndex}/public_key_info | Get the public key of an asset +*EmbeddedWalletsApi* | [**getPublicKeyInfoNcw**](docs/EmbeddedWalletsApi.md#getPublicKeyInfoNcw) | **GET** /ncw/{walletId}/public_key_info | Get the public key for a derivation path *ExchangeAccountsApi* | [**convertAssets**](docs/ExchangeAccountsApi.md#convertAssets) | **POST** /exchange_accounts/{exchangeAccountId}/convert | Convert exchange account funds from the source asset to the destination asset. *ExchangeAccountsApi* | [**getExchangeAccount**](docs/ExchangeAccountsApi.md#getExchangeAccount) | **GET** /exchange_accounts/{exchangeAccountId} | Find a specific exchange account *ExchangeAccountsApi* | [**getExchangeAccountAsset**](docs/ExchangeAccountsApi.md#getExchangeAccountAsset) | **GET** /exchange_accounts/{exchangeAccountId}/{assetId} | Find an asset for an exchange account diff --git a/api/openapi.yaml b/api/openapi.yaml index 86564670..f6e744ab 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -2407,28 +2407,44 @@ paths: /ncw/{walletId}/public_key_info: get: description: Gets the public key information based on derivation path and signing - algorithm. + algorithm within a Non-Custodial Wallet operationId: getPublicKeyInfoNcw parameters: - - explode: false + - description: The ID of the Non-Custodial wallet + explode: false in: path name: walletId required: true schema: + example: 550e8400-e29b-41d4-a716-446655440000 type: string style: simple - - explode: true + - description: "An array of integers (passed as JSON stringified array) representing\ + \ the full BIP44 derivation path of the requested public key. \nThe first\ + \ element must always be 44.\n" + example: + - 44 + - 0 + - 0 + - 0 + - 0 + explode: true in: query name: derivationPath required: true schema: type: string style: form - - explode: true + - description: Elliptic Curve + explode: true in: query name: algorithm required: true schema: + enum: + - MPC_ECDSA_SECP256K1 + - MPC_ECDSA_SECP256R1 + - MPC_EDDSA_ED25519 type: string style: form - explode: true @@ -2457,64 +2473,94 @@ paths: headers: X-Request-ID: $ref: '#/components/headers/X-Request-ID' - summary: Get the public key information + summary: Get the public key for a derivation path tags: - Embedded Wallets - x-internal: true x-readme: code-samples: - - language: python - code: "pubKey = fireblocks.NCW.get_public_key_info(wallet_id, algorithm,\ - \ derivation_path, compressed)" - name: Fireblocks SDK Python example (Legacy) - language: javascript - code: | - const PublicKeyInfoArgs = { algorithm: 'MPC_ECDSA_SECP256K1', derivationPath: '[44,0,0,0,0]' } const pubKey = await fireblocks.NCW.getPublicKeyInfo(walletId, PublicKeyInfoArgs); + code: "const publicKeyInfoArgs = { \n algorithm: 'MPC_ECDSA_SECP256K1',\n\ + \ derivationPath: [44, 0, 0, 0, 0],\n compressed: true\n};\nconst pubKey\ + \ = await fireblocks.NCW.getPublicKeyInfo(walletId, publicKeyInfoArgs);\n" name: Fireblocks SDK Javascript example + - language: typescript + code: "const response: Promise>\ + \ = fireblocks.embeddedWallets.getPublicKeyInfoNcw(embeddedWalletsApiGetPublicKeyInfoNcwRequest);" + name: Fireblocks SDK TypeScript example + - language: java + code: "CompletableFuture> response = fireblocks.embeddedWallets().getPublicKeyInfoNcw(walletId,\ + \ derivationPath, algorithm, compressed);" + name: Fireblocks SDK Java example + - language: python + code: "response = fireblocks.embedded_wallets.get_public_key_info_ncw(wallet_id,\ + \ derivation_path, algorithm, compressed);" + name: Fireblocks SDK Python example + x-codeSamples: + - lang: TypeScript + source: "const response: Promise>\ + \ = fireblocks.embeddedWallets.getPublicKeyInfoNcw(embeddedWalletsApiGetPublicKeyInfoNcwRequest);" + - lang: Java + source: "CompletableFuture> response = fireblocks.embeddedWallets().getPublicKeyInfoNcw(walletId,\ + \ derivationPath, algorithm, compressed);" + - lang: Python + source: "response = fireblocks.embedded_wallets.get_public_key_info_ncw(wallet_id,\ + \ derivation_path, algorithm, compressed);" x-accepts: application/json /ncw/{walletId}/accounts/{accountId}/{assetId}/{change}/{addressIndex}/public_key_info: get: - description: Gets the public key information for the account asset. + description: Gets the public key of an asset associated with a specific account + within a Non-Custodial Wallet operationId: getPublicKeyInfoForAddressNcw parameters: - - explode: false + - description: The ID of the Non-Custodial wallet + explode: false in: path name: walletId required: true schema: + example: 550e8400-e29b-41d4-a716-446655440000 type: string style: simple - - explode: false + - description: The ID of the account + explode: false in: path name: accountId required: true schema: + example: "0" format: numeric type: string style: simple - - explode: false + - description: The ID of the asset + explode: false in: path name: assetId required: true schema: + example: BTC type: string x-fb-entity: asset style: simple - - explode: false + - description: BIP44 derivation path - change value + explode: false in: path name: change required: true schema: + example: 0 type: number style: simple - - explode: false + - description: BIP44 derivation path - index value + explode: false in: path name: addressIndex required: true schema: + example: 0 type: number style: simple - - explode: true + - description: Compressed/Uncompressed public key format + explode: true in: query name: compressed required: false @@ -2540,20 +2586,39 @@ paths: headers: X-Request-ID: $ref: '#/components/headers/X-Request-ID' - summary: Get the public key for an account asset + summary: Get the public key of an asset tags: - Embedded Wallets - x-internal: true x-readme: code-samples: - - language: python - code: "pubKey = fireblocks.NCW.get_public_key_info_by_account_asset(wallet_id,\ - \ asset_id, account_id, change, address_index, compressed)" - name: Fireblocks SDK Python example (Legacy) - language: javascript - code: | - const PublicKeyInfoByAccountAssetArgs = { assetId: 'ETH', accountId: 0, change: 0, addressIndex: 0, compressed: true } const pubKey = await fireblocks.NCW.getPublicKeyInfoByAccountAsset(walletId, PublicKeyInfoByAccountAssetArgs); + code: "const publicKeyInfoByAccountAssetArgs = {\n assetId: 'ETH',\n accountId:\ + \ 0,\n change: 0,\n addressIndex: 0,\n compressed: true\n}; \ + \ \nconst pubKey = await fireblocks.NCW.getPublicKeyInfoByAccountAsset(walletId,\ + \ publicKeyInfoByAccountAssetArgs);\n" name: Fireblocks SDK Javascript example + - language: typescript + code: "const response: Promise>\ + \ = fireblocks.embeddedWallets.getPublicKeyInfoForAddressNcw(embeddedWalletsApiGetPublicKeyInfoForAddressNcwRequest);" + name: Fireblocks SDK TypeScript example + - language: java + code: "CompletableFuture> response = fireblocks.embeddedWallets().getPublicKeyInfoForAddressNcw(walletId,\ + \ accountId, assetId, change, addressIndex, compressed);" + name: Fireblocks SDK Java example + - language: python + code: "response = fireblocks.embedded_wallets.get_public_key_info_for_address_ncw(wallet_id,\ + \ account_id, asset_id, change, address_index, compressed);" + name: Fireblocks SDK Python example + x-codeSamples: + - lang: TypeScript + source: "const response: Promise>\ + \ = fireblocks.embeddedWallets.getPublicKeyInfoForAddressNcw(embeddedWalletsApiGetPublicKeyInfoForAddressNcwRequest);" + - lang: Java + source: "CompletableFuture> response = fireblocks.embeddedWallets().getPublicKeyInfoForAddressNcw(walletId,\ + \ accountId, assetId, change, addressIndex, compressed);" + - lang: Python + source: "response = fireblocks.embedded_wallets.get_public_key_info_for_address_ncw(wallet_id,\ + \ account_id, asset_id, change, address_index, compressed);" x-accepts: application/json /workspace/freeze: post: @@ -18959,18 +19024,35 @@ components: PublicKeyInformation: example: derivationPath: - - 0.8008281904610115 - - 0.8008281904610115 - publicKey: publicKey - algorithm: algorithm + - 44 + - 0 + - 0 + - 0 + - 0 + publicKey: 1044c36403c1802818b472398f546a43a0d91569d5583a6e807c3825b155c7bd + algorithm: MPC_ECDSA_SECP256K1 properties: algorithm: + description: Elliptic Curve + enum: + - MPC_ECDSA_SECP256K1 + - MPC_ECDSA_SECP256R1 + - MPC_EDDSA_ED25519 type: string derivationPath: + description: BIP44 derivation path + example: + - 44 + - 0 + - 0 + - 0 + - 0 items: - type: number + type: integer type: array publicKey: + description: Compressed/Uncompressed public key value in hex representation + example: 1044c36403c1802818b472398f546a43a0d91569d5583a6e807c3825b155c7bd type: string type: object GetVaultAssetsResponse: diff --git a/build.gradle b/build.gradle index 29c4407e..358eefb7 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ apply plugin: 'eclipse' apply plugin: 'com.diffplug.spotless' group = 'com.fireblocks.sdk' -version = '6.0.0' +version = '0.0.0' buildscript { repositories { diff --git a/docs/EmbeddedWalletsApi.md b/docs/EmbeddedWalletsApi.md new file mode 100644 index 00000000..3b8aa504 --- /dev/null +++ b/docs/EmbeddedWalletsApi.md @@ -0,0 +1,192 @@ +# EmbeddedWalletsApi + +All URIs are relative to https://developers.fireblocks.com/reference/ + +| Method | HTTP request | Description | +|------------- | ------------- | -------------| +| [**getPublicKeyInfoForAddressNcw**](EmbeddedWalletsApi.md#getPublicKeyInfoForAddressNcw) | **GET** /ncw/{walletId}/accounts/{accountId}/{assetId}/{change}/{addressIndex}/public_key_info | Get the public key of an asset | +| [**getPublicKeyInfoNcw**](EmbeddedWalletsApi.md#getPublicKeyInfoNcw) | **GET** /ncw/{walletId}/public_key_info | Get the public key for a derivation path | + + + +## getPublicKeyInfoForAddressNcw + +> CompletableFuture> getPublicKeyInfoForAddressNcw getPublicKeyInfoForAddressNcw(walletId, accountId, assetId, change, addressIndex, compressed) + +Get the public key of an asset + +Gets the public key of an asset associated with a specific account within a Non-Custodial Wallet + +### Example + +```java +// Import classes: +import com.fireblocks.sdk.ApiClient; +import com.fireblocks.sdk.ApiException; +import com.fireblocks.sdk.ApiResponse; +import com.fireblocks.sdk.BasePath; +import com.fireblocks.sdk.Fireblocks; +import com.fireblocks.sdk.ConfigurationOptions; +import com.fireblocks.sdk.model.*; +import com.fireblocks.sdk.api.EmbeddedWalletsApi; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; + +public class Example { + public static void main(String[] args) { + ConfigurationOptions configurationOptions = new ConfigurationOptions() + .basePath(BasePath.Sandbox) + .apiKey("my-api-key") + .secretKey("my-secret-key"); + Fireblocks fireblocks = new Fireblocks(configurationOptions); + + String walletId = "550e8400-e29b-41d4-a716-446655440000"; // String | The ID of the Non-Custodial wallet + String accountId = "0"; // String | The ID of the account + String assetId = "BTC"; // String | The ID of the asset + BigDecimal change = new BigDecimal("0"); // BigDecimal | BIP44 derivation path - change value + BigDecimal addressIndex = new BigDecimal("0"); // BigDecimal | BIP44 derivation path - index value + Boolean compressed = true; // Boolean | Compressed/Uncompressed public key format + try { + CompletableFuture> response = fireblocks.embeddedWallets().getPublicKeyInfoForAddressNcw(walletId, accountId, assetId, change, addressIndex, compressed); + System.out.println("Status code: " + response.get().getStatusCode()); + System.out.println("Response headers: " + response.get().getHeaders()); + System.out.println("Response body: " + response.get().getData()); + } catch (InterruptedException | ExecutionException e) { + ApiException apiException = (ApiException)e.getCause(); + System.err.println("Exception when calling EmbeddedWalletsApi#getPublicKeyInfoForAddressNcw"); + System.err.println("Status code: " + apiException.getCode()); + System.err.println("Response headers: " + apiException.getResponseHeaders()); + System.err.println("Reason: " + apiException.getResponseBody()); + e.printStackTrace(); + } catch (ApiException e) { + System.err.println("Exception when calling EmbeddedWalletsApi#getPublicKeyInfoForAddressNcw"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **walletId** | **String**| The ID of the Non-Custodial wallet | | +| **accountId** | **String**| The ID of the account | | +| **assetId** | **String**| The ID of the asset | | +| **change** | **BigDecimal**| BIP44 derivation path - change value | | +| **addressIndex** | **BigDecimal**| BIP44 derivation path - index value | | +| **compressed** | **Boolean**| Compressed/Uncompressed public key format | [optional] | + +### Return type + +CompletableFuture> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Public Key Information | * X-Request-ID -
| +| **0** | Error Response | * X-Request-ID -
| + + +## getPublicKeyInfoNcw + +> CompletableFuture> getPublicKeyInfoNcw getPublicKeyInfoNcw(walletId, derivationPath, algorithm, compressed) + +Get the public key for a derivation path + +Gets the public key information based on derivation path and signing algorithm within a Non-Custodial Wallet + +### Example + +```java +// Import classes: +import com.fireblocks.sdk.ApiClient; +import com.fireblocks.sdk.ApiException; +import com.fireblocks.sdk.ApiResponse; +import com.fireblocks.sdk.BasePath; +import com.fireblocks.sdk.Fireblocks; +import com.fireblocks.sdk.ConfigurationOptions; +import com.fireblocks.sdk.model.*; +import com.fireblocks.sdk.api.EmbeddedWalletsApi; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; + +public class Example { + public static void main(String[] args) { + ConfigurationOptions configurationOptions = new ConfigurationOptions() + .basePath(BasePath.Sandbox) + .apiKey("my-api-key") + .secretKey("my-secret-key"); + Fireblocks fireblocks = new Fireblocks(configurationOptions); + + String walletId = "550e8400-e29b-41d4-a716-446655440000"; // String | The ID of the Non-Custodial wallet + String derivationPath = "[44,0,0,0,0]"; // String | An array of integers (passed as JSON stringified array) representing the full BIP44 derivation path of the requested public key. The first element must always be 44. + String algorithm = "MPC_ECDSA_SECP256K1"; // String | Elliptic Curve + Boolean compressed = true; // Boolean | + try { + CompletableFuture> response = fireblocks.embeddedWallets().getPublicKeyInfoNcw(walletId, derivationPath, algorithm, compressed); + System.out.println("Status code: " + response.get().getStatusCode()); + System.out.println("Response headers: " + response.get().getHeaders()); + System.out.println("Response body: " + response.get().getData()); + } catch (InterruptedException | ExecutionException e) { + ApiException apiException = (ApiException)e.getCause(); + System.err.println("Exception when calling EmbeddedWalletsApi#getPublicKeyInfoNcw"); + System.err.println("Status code: " + apiException.getCode()); + System.err.println("Response headers: " + apiException.getResponseHeaders()); + System.err.println("Reason: " + apiException.getResponseBody()); + e.printStackTrace(); + } catch (ApiException e) { + System.err.println("Exception when calling EmbeddedWalletsApi#getPublicKeyInfoNcw"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Response headers: " + e.getResponseHeaders()); + System.err.println("Reason: " + e.getResponseBody()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **walletId** | **String**| The ID of the Non-Custodial wallet | | +| **derivationPath** | **String**| An array of integers (passed as JSON stringified array) representing the full BIP44 derivation path of the requested public key. The first element must always be 44. | | +| **algorithm** | **String**| Elliptic Curve | [enum: MPC_ECDSA_SECP256K1, MPC_ECDSA_SECP256R1, MPC_EDDSA_ED25519] | +| **compressed** | **Boolean**| | [optional] | + +### Return type + +CompletableFuture> + + +### Authorization + +No authorization required + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | Public key information | * X-Request-ID -
| +| **0** | Error Response | * X-Request-ID -
| + diff --git a/docs/PublicKeyInformation.md b/docs/PublicKeyInformation.md index 381d8a05..d1fd4037 100644 --- a/docs/PublicKeyInformation.md +++ b/docs/PublicKeyInformation.md @@ -7,9 +7,19 @@ | Name | Type | Description | Notes | |------------ | ------------- | ------------- | -------------| -|**algorithm** | **String** | | [optional] | -|**derivationPath** | **List<BigDecimal>** | | [optional] | -|**publicKey** | **String** | | [optional] | +|**algorithm** | [**AlgorithmEnum**](#AlgorithmEnum) | Elliptic Curve | [optional] | +|**derivationPath** | **List<Integer>** | BIP44 derivation path | [optional] | +|**publicKey** | **String** | Compressed/Uncompressed public key value in hex representation | [optional] | + + + +## Enum: AlgorithmEnum + +| Name | Value | +|---- | -----| +| ECDSA_SECP256K1 | "MPC_ECDSA_SECP256K1" | +| ECDSA_SECP256R1 | "MPC_ECDSA_SECP256R1" | +| EDDSA_ED25519 | "MPC_EDDSA_ED25519" | diff --git a/pom.xml b/pom.xml index f0f57c8d..94938f50 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ fireblocks-sdk jar fireblocks-sdk - 6.0.0 + 0.0.0 https://github.com/fireblocks/java-sdk The Fireblocks Official SDK is a comprehensive software development kit that enables seamless integration and interaction with the Fireblocks platform. Fireblocks is a cutting-edge blockchain infrastructure platform that provides secure and scalable solutions for managing digital assets and transactions. This SDK empowers developers to build robust applications that can interact with the Fireblocks platform's features, including creating and managing vault accounts, initiating secure transactions, managing assets, and more. It abstracts complex interactions with the Fireblocks API, making it easier for developers to leverage the platform's capabilities while adhering to best practices in security and efficiency. diff --git a/src/main/java/com/fireblocks/sdk/Configuration.java b/src/main/java/com/fireblocks/sdk/Configuration.java index 4277714c..9ec56d09 100644 --- a/src/main/java/com/fireblocks/sdk/Configuration.java +++ b/src/main/java/com/fireblocks/sdk/Configuration.java @@ -14,7 +14,7 @@ @jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Configuration { - public static final String VERSION = "6.0.0"; + public static final String VERSION = "0.0.0"; private static ApiClient defaultApiClient = new ApiClient(); diff --git a/src/main/java/com/fireblocks/sdk/Fireblocks.java b/src/main/java/com/fireblocks/sdk/Fireblocks.java index c0032ea7..d5663c46 100644 --- a/src/main/java/com/fireblocks/sdk/Fireblocks.java +++ b/src/main/java/com/fireblocks/sdk/Fireblocks.java @@ -48,6 +48,7 @@ public class Fireblocks { private ContractsApi contracts; private CosignersBetaApi cosignersBeta; private DeployedContractsApi deployedContracts; + private EmbeddedWalletsApi embeddedWallets; private ExchangeAccountsApi exchangeAccounts; private ExternalWalletsApi externalWallets; private FiatAccountsApi fiatAccounts; @@ -297,6 +298,13 @@ public DeployedContractsApi deployedContracts() { return deployedContracts; } + public EmbeddedWalletsApi embeddedWallets() { + if (embeddedWallets == null) { + embeddedWallets = new EmbeddedWalletsApi(apiClient); + } + return embeddedWallets; + } + public ExchangeAccountsApi exchangeAccounts() { if (exchangeAccounts == null) { exchangeAccounts = new ExchangeAccountsApi(apiClient); diff --git a/src/main/java/com/fireblocks/sdk/api/EmbeddedWalletsApi.java b/src/main/java/com/fireblocks/sdk/api/EmbeddedWalletsApi.java new file mode 100644 index 00000000..9f4c777a --- /dev/null +++ b/src/main/java/com/fireblocks/sdk/api/EmbeddedWalletsApi.java @@ -0,0 +1,292 @@ +/* + * Fireblocks API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.6.2 + * Contact: support@fireblocks.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.fireblocks.sdk.api; + + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fireblocks.sdk.ApiClient; +import com.fireblocks.sdk.ApiException; +import com.fireblocks.sdk.ApiResponse; +import com.fireblocks.sdk.Pair; +import com.fireblocks.sdk.ValidationUtils; +import com.fireblocks.sdk.model.PublicKeyInformation; +import java.io.IOException; +import java.io.InputStream; +import java.math.BigDecimal; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.time.Duration; +import java.util.ArrayList; +import java.util.List; +import java.util.StringJoiner; +import java.util.concurrent.CompletableFuture; +import java.util.function.Consumer; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") +public class EmbeddedWalletsApi { + private final HttpClient memberVarHttpClient; + private final ObjectMapper memberVarObjectMapper; + private final String memberVarBaseUri; + private final Consumer memberVarInterceptor; + private final Duration memberVarReadTimeout; + private final Consumer> memberVarResponseInterceptor; + private final Consumer> memberVarAsyncResponseInterceptor; + + public EmbeddedWalletsApi() { + this(new ApiClient()); + } + + public EmbeddedWalletsApi(ApiClient apiClient) { + memberVarHttpClient = apiClient.getHttpClient(); + memberVarObjectMapper = apiClient.getObjectMapper(); + memberVarBaseUri = apiClient.getBaseUri(); + memberVarInterceptor = apiClient.getRequestInterceptor(); + memberVarReadTimeout = apiClient.getReadTimeout(); + memberVarResponseInterceptor = apiClient.getResponseInterceptor(); + memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); + } + + private ApiException getApiException(String operationId, HttpResponse response) { + String message = + formatExceptionMessage(operationId, response.statusCode(), response.body()); + return new ApiException( + response.statusCode(), message, response.headers(), response.body()); + } + + private String formatExceptionMessage(String operationId, int statusCode, String body) { + if (body == null || body.isEmpty()) { + body = "[no body]"; + } + return operationId + " call failed with: " + statusCode + " - " + body; + } + + /** + * Get the public key of an asset Gets the public key of an asset associated with a specific + * account within a Non-Custodial Wallet + * + * @param walletId The ID of the Non-Custodial wallet (required) + * @param accountId The ID of the account (required) + * @param assetId The ID of the asset (required) + * @param change BIP44 derivation path - change value (required) + * @param addressIndex BIP44 derivation path - index value (required) + * @param compressed Compressed/Uncompressed public key format (optional) + * @return CompletableFuture<ApiResponse<PublicKeyInformation>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> getPublicKeyInfoForAddressNcw( + String walletId, + String accountId, + String assetId, + BigDecimal change, + BigDecimal addressIndex, + Boolean compressed) + throws ApiException { + try { + HttpRequest.Builder localVarRequestBuilder = + getPublicKeyInfoForAddressNcwRequestBuilder( + walletId, accountId, assetId, change, addressIndex, compressed); + return memberVarHttpClient + .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()) + .thenComposeAsync( + localVarResponse -> { + if (memberVarAsyncResponseInterceptor != null) { + memberVarAsyncResponseInterceptor.accept(localVarResponse); + } + if (localVarResponse.statusCode() / 100 != 2) { + return CompletableFuture.failedFuture( + getApiException( + "getPublicKeyInfoForAddressNcw", + localVarResponse)); + } + try { + String responseBody = localVarResponse.body(); + return CompletableFuture.completedFuture( + new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody == null || responseBody.isBlank() + ? null + : memberVarObjectMapper.readValue( + responseBody, + new TypeReference< + PublicKeyInformation>() {}))); + } catch (IOException e) { + return CompletableFuture.failedFuture(new ApiException(e)); + } + }); + } catch (ApiException e) { + return CompletableFuture.failedFuture(e); + } + } + + private HttpRequest.Builder getPublicKeyInfoForAddressNcwRequestBuilder( + String walletId, + String accountId, + String assetId, + BigDecimal change, + BigDecimal addressIndex, + Boolean compressed) + throws ApiException { + ValidationUtils.assertParamExistsAndNotEmpty( + "getPublicKeyInfoForAddressNcw", "walletId", walletId); + ValidationUtils.assertParamExistsAndNotEmpty( + "getPublicKeyInfoForAddressNcw", "accountId", accountId); + ValidationUtils.assertParamExistsAndNotEmpty( + "getPublicKeyInfoForAddressNcw", "assetId", assetId); + ValidationUtils.assertParamExists("getPublicKeyInfoForAddressNcw", "change", change); + ValidationUtils.assertParamExists( + "getPublicKeyInfoForAddressNcw", "addressIndex", addressIndex); + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = + "/ncw/{walletId}/accounts/{accountId}/{assetId}/{change}/{addressIndex}/public_key_info" + .replace("{walletId}", ApiClient.urlEncode(walletId.toString())) + .replace("{accountId}", ApiClient.urlEncode(accountId.toString())) + .replace("{assetId}", ApiClient.urlEncode(assetId.toString())) + .replace("{change}", ApiClient.urlEncode(change.toString())) + .replace("{addressIndex}", ApiClient.urlEncode(addressIndex.toString())); + + List localVarQueryParams = new ArrayList<>(); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + String localVarQueryParameterBaseName; + localVarQueryParameterBaseName = "compressed"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("compressed", compressed)); + + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { + StringJoiner queryJoiner = new StringJoiner("&"); + localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); + } + localVarRequestBuilder.uri( + URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); + } else { + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + } + + localVarRequestBuilder.header("Accept", "application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + /** + * Get the public key for a derivation path Gets the public key information based on derivation + * path and signing algorithm within a Non-Custodial Wallet + * + * @param walletId The ID of the Non-Custodial wallet (required) + * @param derivationPath An array of integers (passed as JSON stringified array) representing + * the full BIP44 derivation path of the requested public key. The first element must always + * be 44. (required) + * @param algorithm Elliptic Curve (required) + * @param compressed (optional) + * @return CompletableFuture<ApiResponse<PublicKeyInformation>> + * @throws ApiException if fails to make API call + */ + public CompletableFuture> getPublicKeyInfoNcw( + String walletId, String derivationPath, String algorithm, Boolean compressed) + throws ApiException { + try { + HttpRequest.Builder localVarRequestBuilder = + getPublicKeyInfoNcwRequestBuilder( + walletId, derivationPath, algorithm, compressed); + return memberVarHttpClient + .sendAsync(localVarRequestBuilder.build(), HttpResponse.BodyHandlers.ofString()) + .thenComposeAsync( + localVarResponse -> { + if (memberVarAsyncResponseInterceptor != null) { + memberVarAsyncResponseInterceptor.accept(localVarResponse); + } + if (localVarResponse.statusCode() / 100 != 2) { + return CompletableFuture.failedFuture( + getApiException( + "getPublicKeyInfoNcw", localVarResponse)); + } + try { + String responseBody = localVarResponse.body(); + return CompletableFuture.completedFuture( + new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody == null || responseBody.isBlank() + ? null + : memberVarObjectMapper.readValue( + responseBody, + new TypeReference< + PublicKeyInformation>() {}))); + } catch (IOException e) { + return CompletableFuture.failedFuture(new ApiException(e)); + } + }); + } catch (ApiException e) { + return CompletableFuture.failedFuture(e); + } + } + + private HttpRequest.Builder getPublicKeyInfoNcwRequestBuilder( + String walletId, String derivationPath, String algorithm, Boolean compressed) + throws ApiException { + ValidationUtils.assertParamExistsAndNotEmpty("getPublicKeyInfoNcw", "walletId", walletId); + ValidationUtils.assertParamExistsAndNotEmpty( + "getPublicKeyInfoNcw", "derivationPath", derivationPath); + ValidationUtils.assertParamExistsAndNotEmpty("getPublicKeyInfoNcw", "algorithm", algorithm); + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = + "/ncw/{walletId}/public_key_info" + .replace("{walletId}", ApiClient.urlEncode(walletId.toString())); + + List localVarQueryParams = new ArrayList<>(); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + String localVarQueryParameterBaseName; + localVarQueryParameterBaseName = "derivationPath"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("derivationPath", derivationPath)); + localVarQueryParameterBaseName = "algorithm"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("algorithm", algorithm)); + localVarQueryParameterBaseName = "compressed"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("compressed", compressed)); + + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { + StringJoiner queryJoiner = new StringJoiner("&"); + localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); + } + localVarRequestBuilder.uri( + URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); + } else { + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + } + + localVarRequestBuilder.header("Accept", "application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } +} diff --git a/src/main/java/com/fireblocks/sdk/model/PublicKeyInformation.java b/src/main/java/com/fireblocks/sdk/model/PublicKeyInformation.java index 8427b37f..51bc31a6 100644 --- a/src/main/java/com/fireblocks/sdk/model/PublicKeyInformation.java +++ b/src/main/java/com/fireblocks/sdk/model/PublicKeyInformation.java @@ -13,10 +13,11 @@ package com.fireblocks.sdk.model; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import java.math.BigDecimal; +import com.fasterxml.jackson.annotation.JsonValue; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.ArrayList; @@ -32,46 +33,81 @@ }) @jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class PublicKeyInformation { + /** Elliptic Curve */ + public enum AlgorithmEnum { + ECDSA_SECP256K1("MPC_ECDSA_SECP256K1"), + + ECDSA_SECP256R1("MPC_ECDSA_SECP256R1"), + + EDDSA_ED25519("MPC_EDDSA_ED25519"); + + private String value; + + AlgorithmEnum(String value) { + this.value = value; + } + + @JsonValue + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + @JsonCreator + public static AlgorithmEnum fromValue(String value) { + for (AlgorithmEnum b : AlgorithmEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + } + public static final String JSON_PROPERTY_ALGORITHM = "algorithm"; - private String algorithm; + private AlgorithmEnum algorithm; public static final String JSON_PROPERTY_DERIVATION_PATH = "derivationPath"; - private List derivationPath; + private List derivationPath; public static final String JSON_PROPERTY_PUBLIC_KEY = "publicKey"; private String publicKey; public PublicKeyInformation() {} - public PublicKeyInformation algorithm(String algorithm) { + public PublicKeyInformation algorithm(AlgorithmEnum algorithm) { this.algorithm = algorithm; return this; } /** - * Get algorithm + * Elliptic Curve * * @return algorithm */ @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_ALGORITHM) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public String getAlgorithm() { + public AlgorithmEnum getAlgorithm() { return algorithm; } @JsonProperty(JSON_PROPERTY_ALGORITHM) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setAlgorithm(String algorithm) { + public void setAlgorithm(AlgorithmEnum algorithm) { this.algorithm = algorithm; } - public PublicKeyInformation derivationPath(List derivationPath) { + public PublicKeyInformation derivationPath(List derivationPath) { this.derivationPath = derivationPath; return this; } - public PublicKeyInformation addDerivationPathItem(BigDecimal derivationPathItem) { + public PublicKeyInformation addDerivationPathItem(Integer derivationPathItem) { if (this.derivationPath == null) { this.derivationPath = new ArrayList<>(); } @@ -80,20 +116,20 @@ public PublicKeyInformation addDerivationPathItem(BigDecimal derivationPathItem) } /** - * Get derivationPath + * BIP44 derivation path * * @return derivationPath */ @jakarta.annotation.Nullable @JsonProperty(JSON_PROPERTY_DERIVATION_PATH) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public List getDerivationPath() { + public List getDerivationPath() { return derivationPath; } @JsonProperty(JSON_PROPERTY_DERIVATION_PATH) @JsonInclude(value = JsonInclude.Include.USE_DEFAULTS) - public void setDerivationPath(List derivationPath) { + public void setDerivationPath(List derivationPath) { this.derivationPath = derivationPath; } @@ -103,7 +139,7 @@ public PublicKeyInformation publicKey(String publicKey) { } /** - * Get publicKey + * Compressed/Uncompressed public key value in hex representation * * @return publicKey */ @@ -209,21 +245,19 @@ public String toUrlQueryString(String prefix) { // add `derivationPath` to the URL query string if (getDerivationPath() != null) { for (int i = 0; i < getDerivationPath().size(); i++) { - if (getDerivationPath().get(i) != null) { - joiner.add( - String.format( - "%sderivationPath%s%s=%s", - prefix, - suffix, - "".equals(suffix) - ? "" - : String.format( - "%s%d%s", containerPrefix, i, containerSuffix), - URLEncoder.encode( - String.valueOf(getDerivationPath().get(i)), - StandardCharsets.UTF_8) - .replaceAll("\\+", "%20"))); - } + joiner.add( + String.format( + "%sderivationPath%s%s=%s", + prefix, + suffix, + "".equals(suffix) + ? "" + : String.format( + "%s%d%s", containerPrefix, i, containerSuffix), + URLEncoder.encode( + String.valueOf(getDerivationPath().get(i)), + StandardCharsets.UTF_8) + .replaceAll("\\+", "%20"))); } } diff --git a/src/test/java/com/fireblocks/sdk/FireblocksTest.java b/src/test/java/com/fireblocks/sdk/FireblocksTest.java index d20cfb1a..b49b8e69 100644 --- a/src/test/java/com/fireblocks/sdk/FireblocksTest.java +++ b/src/test/java/com/fireblocks/sdk/FireblocksTest.java @@ -453,6 +453,14 @@ public void testGetDeployedContractsApi() { Assert.assertSame(deployedContracts, fireblocks.deployedContracts()); } + @Test + public void testGetEmbeddedWalletsApi() { + setupFireblocks(true, null, null); + EmbeddedWalletsApi embeddedWallets = fireblocks.embeddedWallets(); + Assert.assertNotNull(embeddedWallets); + Assert.assertSame(embeddedWallets, fireblocks.embeddedWallets()); + } + @Test public void testGetExchangeAccountsApi() { setupFireblocks(true, null, null); diff --git a/src/test/java/com/fireblocks/sdk/api/EmbeddedWalletsApiTest.java b/src/test/java/com/fireblocks/sdk/api/EmbeddedWalletsApiTest.java new file mode 100644 index 00000000..5af6b7b8 --- /dev/null +++ b/src/test/java/com/fireblocks/sdk/api/EmbeddedWalletsApiTest.java @@ -0,0 +1,68 @@ +/* + * Fireblocks API + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 1.6.2 + * Contact: support@fireblocks.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package com.fireblocks.sdk.api; + + +import com.fireblocks.sdk.ApiException; +import com.fireblocks.sdk.ApiResponse; +import com.fireblocks.sdk.model.PublicKeyInformation; +import java.math.BigDecimal; +import java.util.concurrent.CompletableFuture; +import org.junit.Ignore; +import org.junit.Test; + +/** API tests for EmbeddedWalletsApi */ +@Ignore +public class EmbeddedWalletsApiTest { + + private final EmbeddedWalletsApi api = new EmbeddedWalletsApi(); + + /** + * Get the public key of an asset + * + *

Gets the public key of an asset associated with a specific account within a Non-Custodial + * Wallet + * + * @throws ApiException if the Api call fails + */ + @Test + public void getPublicKeyInfoForAddressNcwTest() throws ApiException { + String walletId = null; + String accountId = null; + String assetId = null; + BigDecimal change = null; + BigDecimal addressIndex = null; + Boolean compressed = null; + CompletableFuture> response = + api.getPublicKeyInfoForAddressNcw( + walletId, accountId, assetId, change, addressIndex, compressed); + } + + /** + * Get the public key for a derivation path + * + *

Gets the public key information based on derivation path and signing algorithm within a + * Non-Custodial Wallet + * + * @throws ApiException if the Api call fails + */ + @Test + public void getPublicKeyInfoNcwTest() throws ApiException { + String walletId = null; + String derivationPath = null; + String algorithm = null; + Boolean compressed = null; + CompletableFuture> response = + api.getPublicKeyInfoNcw(walletId, derivationPath, algorithm, compressed); + } +}