From adfa5d7eecddb7bbc6d4676dd1cb2cb2503ca575 Mon Sep 17 00:00:00 2001 From: Varderes Barsegyan Date: Fri, 13 Dec 2024 15:26:05 -0600 Subject: [PATCH 1/4] feat: new handlers --- src/api/blocks/helpers.ts | 43 +++++++++++++++++++++++++++++++++++++++ src/api/blocks/index.ts | 11 ++++++++++ 2 files changed, 54 insertions(+) diff --git a/src/api/blocks/helpers.ts b/src/api/blocks/helpers.ts index 5438aa1..b1a7e62 100644 --- a/src/api/blocks/helpers.ts +++ b/src/api/blocks/helpers.ts @@ -54,6 +54,39 @@ export const BlocksApiAxiosParamCreator = (configuration: Configuration) => ({ options: localVarRequestOptions, }; }, + + /** + * Returns information about the latest block + * @summary Latest block + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + blockLatest: (options: AxiosRequestConfig = {}): RequestArgs => { + const localVarPath = `/blocks/latest`; + // use dummy base URL string because the URL constructor only accepts absolute URLs. + const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); + const { baseOptions } = configuration; + + const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options }; + const localVarHeaderParameter = {} as Record; + const localVarQueryParameter = {} as Record; + + // authentication api-key required + setApiKeyToObject(localVarHeaderParameter, 'api-key', configuration); + + setSearchParams(localVarUrlObj, localVarQueryParameter); + const headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; + localVarRequestOptions.headers = { + ...localVarHeaderParameter, + ...headersFromBaseOptions, + ...options.headers, + }; + + return { + url: toPathString(localVarUrlObj), + options: localVarRequestOptions, + }; + }, }); /** @@ -74,5 +107,15 @@ export const BlocksApiFp = (configuration: Configuration) => { const localVarAxiosArgs = localVarAxiosParamCreator.blockInfo(hashOrHeight, options); return createRequestFunction(localVarAxiosArgs, configuration); }, + /** + * Returns information about the latest block + * @summary Latest block + * @param {*} [options] Override http request option. + * @throws {RequiredError} + */ + blockLatest(options?: AxiosRequestConfig): () => Promise { + const localVarAxiosArgs = localVarAxiosParamCreator.blockLatest(options); + return createRequestFunction(localVarAxiosArgs, configuration); + }, }; }; diff --git a/src/api/blocks/index.ts b/src/api/blocks/index.ts index 3750f69..3aa681f 100644 --- a/src/api/blocks/index.ts +++ b/src/api/blocks/index.ts @@ -20,4 +20,15 @@ export class BlocksApi extends BaseAPI { public blockInfo(hashOrHeight: string, options?: AxiosRequestConfig) { return BlocksApiFp(this.configuration).blockInfo(hashOrHeight, options)(); } + + /** + * Returns information about the latest block + * @summary Latest block + * @param {*} [options] Override http request option. + * @throws {RequiredError} + * @memberof BlocksApi + */ + public blockLatest(options?: AxiosRequestConfig) { + return BlocksApiFp(this.configuration).blockLatest(options)(); + } } From 5b7dd37251805b92bdb1704656abcc3e3455ea65 Mon Sep 17 00:00:00 2001 From: Vardominator Date: Fri, 13 Dec 2024 21:49:08 +0000 Subject: [PATCH 2/4] feat: new handlers --- examples/examples.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 examples/examples.ts diff --git a/examples/examples.ts b/examples/examples.ts new file mode 100644 index 0000000..d6d9afa --- /dev/null +++ b/examples/examples.ts @@ -0,0 +1,10 @@ +import { MaestroClient, Configuration } from '../dist'; + +let maestroClient = new MaestroClient( + new Configuration({ + apiKey: '', + network: 'Preprod', + }), +); + +maestroClient.blocks.blockLatest().then((x) => console.log(x.data)); From 4f473d560401a7134ce2224d3d8008ae4e8dbc97 Mon Sep 17 00:00:00 2001 From: Vardominator Date: Fri, 13 Dec 2024 21:52:58 +0000 Subject: [PATCH 3/4] feat: new handlers --- package.json | 3 +-- src/api/assets/helpers.ts | 5 +---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 5811697..17f56a3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@maestro-org/typescript-sdk", - "version": "1.6.1", + "version": "1.6.2", "description": "TypeScript SDK for the Maestro Dapp Platform", "main": "dist/index.js", "module": "dist/index.mjs", @@ -50,4 +50,3 @@ ] } } - diff --git a/src/api/assets/helpers.ts b/src/api/assets/helpers.ts index 4bdc21b..210d8f2 100644 --- a/src/api/assets/helpers.ts +++ b/src/api/assets/helpers.ts @@ -446,10 +446,7 @@ export const AssetsApiAxiosParamCreator = (configuration: Configuration) => ({ ): RequestArgs => { // verify required parameter 'policy' is not null or undefined assertParamExists('policyUtxos', 'policy', policy); - const localVarPath = `/policy/{policy}/utxos`.replace( - `{${'policy'}}`, - encodeURIComponent(String(policy)), - ); + const localVarPath = `/policy/{policy}/utxos`.replace(`{${'policy'}}`, encodeURIComponent(String(policy))); // use dummy base URL string because the URL constructor only accepts absolute URLs. const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL); const { baseOptions } = configuration; From f3a1ff110f5e02dcc2119e1961ee50525791e22b Mon Sep 17 00:00:00 2001 From: Vardominator Date: Fri, 13 Dec 2024 21:56:32 +0000 Subject: [PATCH 4/4] feat: new handlers --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 17f56a3..a7a5a19 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@maestro-org/typescript-sdk", - "version": "1.6.2", + "version": "1.6.3", "description": "TypeScript SDK for the Maestro Dapp Platform", "main": "dist/index.js", "module": "dist/index.mjs",