Skip to content

Commit de2dbf9

Browse files
authored
Merge pull request #26 from vespr-wallet/alex/datum
Alex/datum
2 parents aecd8c0 + 51756b8 commit de2dbf9

File tree

5 files changed

+104
-11
lines changed

5 files changed

+104
-11
lines changed

src/api/datum/helpers.ts

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ import {
77
setSearchParams,
88
toPathString,
99
createRequestFunction,
10+
serializeDataIfNeeded,
1011
} from '../../common';
1112
import { Configuration } from '../../configuration';
12-
import { TimestampedDatum } from '../type';
13+
import { TimestampedDatum, TimestampedDatums } from '../type';
1314

1415
/**
1516
* DatumApi - axios parameter creator
@@ -27,7 +28,7 @@ export const DatumApiAxiosParamCreator = function (configuration: Configuration)
2728
lookupDatum: async (datumHash: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
2829
// verify required parameter 'datumHash' is not null or undefined
2930
assertParamExists('lookupDatum', 'datumHash', datumHash);
30-
const localVarPath = `/datum/{datum_hash}`.replace(
31+
const localVarPath = `/datums/{datum_hash}`.replace(
3132
`{${'datum_hash'}}`,
3233
encodeURIComponent(String(datumHash)),
3334
);
@@ -50,6 +51,44 @@ export const DatumApiAxiosParamCreator = function (configuration: Configuration)
5051
...options.headers,
5152
};
5253

54+
return {
55+
url: toPathString(localVarUrlObj),
56+
options: localVarRequestOptions,
57+
};
58+
},
59+
/**
60+
* Returns the datums corresponding to the specified datum hashes, for the datums which have been seen on-chain
61+
* @summary Datums by datum hashes
62+
* @param {Array<string>} requestBody Array of hex encoded datum hashes
63+
* @param {*} [options] Override http request option.
64+
* @throws {RequiredError}
65+
*/
66+
lookupDatums: async (requestBody: Array<string>, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
67+
// verify required parameter 'requestBody' is not null or undefined
68+
assertParamExists('lookupDatums', 'requestBody', requestBody);
69+
const localVarPath = `/datums`;
70+
// use dummy base URL string because the URL constructor only accepts absolute URLs.
71+
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
72+
const { baseOptions } = configuration;
73+
74+
const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options };
75+
const localVarHeaderParameter = {} as any;
76+
const localVarQueryParameter = {} as any;
77+
78+
// authentication api-key required
79+
setApiKeyToObject(localVarHeaderParameter, 'api-key', configuration);
80+
81+
localVarHeaderParameter['Content-Type'] = 'application/json';
82+
83+
setSearchParams(localVarUrlObj, localVarQueryParameter);
84+
const headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
85+
localVarRequestOptions.headers = {
86+
...localVarHeaderParameter,
87+
...headersFromBaseOptions,
88+
...options.headers,
89+
};
90+
localVarRequestOptions.data = serializeDataIfNeeded(requestBody, localVarRequestOptions, configuration);
91+
5392
return {
5493
url: toPathString(localVarUrlObj),
5594
options: localVarRequestOptions,
@@ -79,6 +118,20 @@ export const DatumApiFp = function (configuration: Configuration) {
79118
const localVarAxiosArgs = await localVarAxiosParamCreator.lookupDatum(datumHash, options);
80119
return createRequestFunction(localVarAxiosArgs, configuration);
81120
},
121+
/**
122+
* Returns the datums corresponding to the specified datum hashes, for the datums which have been seen on-chain
123+
* @summary Datums by datum hashes
124+
* @param {Array<string>} requestBody Array of hex encoded datum hashes
125+
* @param {*} [options] Override http request option.
126+
* @throws {RequiredError}
127+
*/
128+
async lookupDatums(
129+
requestBody: Array<string>,
130+
options?: AxiosRequestConfig,
131+
): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<TimestampedDatums>> {
132+
const localVarAxiosArgs = await localVarAxiosParamCreator.lookupDatums(requestBody, options);
133+
return createRequestFunction(localVarAxiosArgs, configuration);
134+
},
82135
};
83136
};
84137

src/api/datum/index.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,21 @@ export class DatumApi extends BaseAPI {
1717
* @throws {RequiredError}
1818
* @memberof DatumApi
1919
*/
20-
public lookupDatum(datumHash: string, options?: AxiosRequestConfig) {
21-
return DatumApiFp(this.configuration)
22-
.lookupDatum(datumHash, options)
23-
.then((request) => request());
20+
public async lookupDatum(datumHash: string, options?: AxiosRequestConfig) {
21+
const request = await DatumApiFp(this.configuration).lookupDatum(datumHash, options);
22+
return request();
23+
}
24+
25+
/**
26+
* Returns the datums corresponding to the specified datum hashes, for the datums which have been seen on-chain
27+
* @summary Datums by datum hashes
28+
* @param {Array<string>} requestBody Array of hex encoded datum hashes
29+
* @param {*} [options] Override http request option.
30+
* @throws {RequiredError}
31+
* @memberof DatumApi
32+
*/
33+
public async lookupDatums(requestBody: Array<string>, options?: AxiosRequestConfig) {
34+
const request = await DatumApiFp(this.configuration).lookupDatums(requestBody, options);
35+
return request();
2436
}
2537
}

src/api/epochs/helpers.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,7 @@ export const EpochsApiAxiosParamCreator = function (configuration: Configuration
5959
epochInfo: async (epochNo: number, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
6060
// verify required parameter 'epochNo' is not null or undefined
6161
assertParamExists('epochInfo', 'epochNo', epochNo);
62-
const localVarPath = `/epochs/{epoch_no}/info`.replace(
63-
`{${'epoch_no'}}`,
64-
encodeURIComponent(String(epochNo)),
65-
);
62+
const localVarPath = `/epochs/{epoch_no}`.replace(`{${'epoch_no'}}`, encodeURIComponent(String(epochNo)));
6663
// use dummy base URL string because the URL constructor only accepts absolute URLs.
6764
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
6865
const { baseOptions } = configuration;

src/api/type.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,18 @@ export interface DelegatorInfo {
10281028
* @interface EpochInfo
10291029
*/
10301030
export interface EpochInfo {
1031+
/**
1032+
* Total active stake in the epoch
1033+
* @type {number}
1034+
* @memberof EpochInfo
1035+
*/
1036+
active_stake?: string | null;
1037+
/**
1038+
* Average reward in the epoch
1039+
* @type {number}
1040+
* @memberof EpochInfo
1041+
*/
1042+
average_reward?: string | null;
10311043
/**
10321044
* Total blocks in the epoch
10331045
* @type {number}
@@ -3213,6 +3225,25 @@ export interface TimestampedDatum {
32133225
*/
32143226
last_updated: LastUpdated;
32153227
}
3228+
/**
3229+
* Timestamped response. Returns the endpoint response data along with the chain-tip of the indexer, which details at which point in the chain\'s history the data was correct as-of.
3230+
* @export
3231+
* @interface TimestampedDatums
3232+
*/
3233+
export interface TimestampedDatums {
3234+
/**
3235+
* Record of Datum by datum hash
3236+
* @type {Record<string, Datum | undefined>}
3237+
* @memberof TimestampedDatum
3238+
*/
3239+
data: Record<string, Datum | undefined>;
3240+
/**
3241+
*
3242+
* @type {LastUpdated}
3243+
* @memberof TimestampedDatum
3244+
*/
3245+
last_updated: LastUpdated;
3246+
}
32163247
/**
32173248
* Timestamped response. Returns the endpoint response data along with the chain-tip of the indexer, which details at which point in the chain\'s history the data was correct as-of.
32183249
* @export

src/common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const DUMMY_BASE_URL = 'https://example.com';
1515
* @export
1616
*/
1717
export const HEADER_AMOUNTS_AS_STRING = {
18-
'amounts-as-string': 'true',
18+
'amounts-as-strings': 'true',
1919
};
2020

2121
/**

0 commit comments

Comments
 (0)