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)); diff --git a/package.json b/package.json index 48ba883..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", @@ -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; 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)(); + } }