Skip to content

Commit 2e61985

Browse files
committed
chore: update generated doc and client code
1 parent 26f1070 commit 2e61985

File tree

4 files changed

+102
-15
lines changed

4 files changed

+102
-15
lines changed

client/src/generated/apis/SmartContractsApi.ts

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ import {
2121
ContractSourceResponse,
2222
ContractSourceResponseFromJSON,
2323
ContractSourceResponseToJSON,
24+
ReadOnlyFunctionSuccessResponse,
25+
ReadOnlyFunctionSuccessResponseFromJSON,
26+
ReadOnlyFunctionSuccessResponseToJSON,
2427
} from '../models';
2528

2629
export interface CallReadOnlyFunctionRequest {
@@ -33,11 +36,11 @@ export interface GetContractByIdRequest {
3336
contractId: string;
3437
}
3538

36-
export interface GetContractDataMapRequest {
39+
export interface GetContractDataMapEntryRequest {
3740
stacksAddress: string;
3841
contractName: string;
3942
mapName: string;
40-
body: object;
43+
key: string;
4144
proof?: number;
4245
}
4346

@@ -65,7 +68,7 @@ export class SmartContractsApi extends runtime.BaseAPI {
6568
* Call a read-only public function on a given smart contract. The smart contract and function are specified using the URL path. The arguments and the simulated tx-sender are supplied via the POST body in the following JSON format:
6669
* Call read-only function
6770
*/
68-
async callReadOnlyFunctionRaw(requestParameters: CallReadOnlyFunctionRequest): Promise<runtime.ApiResponse<void>> {
71+
async callReadOnlyFunctionRaw(requestParameters: CallReadOnlyFunctionRequest): Promise<runtime.ApiResponse<ReadOnlyFunctionSuccessResponse>> {
6972
if (requestParameters.stacksAddress === null || requestParameters.stacksAddress === undefined) {
7073
throw new runtime.RequiredError('stacksAddress','Required parameter requestParameters.stacksAddress was null or undefined when calling callReadOnlyFunction.');
7174
}
@@ -89,15 +92,16 @@ export class SmartContractsApi extends runtime.BaseAPI {
8992
query: queryParameters,
9093
});
9194

92-
return new runtime.VoidApiResponse(response);
95+
return new runtime.JSONApiResponse(response, (jsonValue) => ReadOnlyFunctionSuccessResponseFromJSON(jsonValue));
9396
}
9497

9598
/**
9699
* Call a read-only public function on a given smart contract. The smart contract and function are specified using the URL path. The arguments and the simulated tx-sender are supplied via the POST body in the following JSON format:
97100
* Call read-only function
98101
*/
99-
async callReadOnlyFunction(requestParameters: CallReadOnlyFunctionRequest): Promise<void> {
100-
await this.callReadOnlyFunctionRaw(requestParameters);
102+
async callReadOnlyFunction(requestParameters: CallReadOnlyFunctionRequest): Promise<ReadOnlyFunctionSuccessResponse> {
103+
const response = await this.callReadOnlyFunctionRaw(requestParameters);
104+
return await response.value();
101105
}
102106

103107
/**
@@ -136,21 +140,21 @@ export class SmartContractsApi extends runtime.BaseAPI {
136140
* Attempt to fetch data from a contract data map. The contract is identified with [Stacks Address] and [Contract Name] in the URL path. The map is identified with [Map Name]. The key to lookup in the map is supplied via the POST body. This should be supplied as the hex string serialization of the key (which should be a Clarity value). Note, this is a JSON string atom. In the response, `data` is the hex serialization of the map response. Note that map responses are Clarity option types, for non-existent values, this is a serialized none, and for all other responses, it is a serialized (some ...) object.
137141
* Get specific data-map inside a contract
138142
*/
139-
async getContractDataMapRaw(requestParameters: GetContractDataMapRequest): Promise<runtime.ApiResponse<void>> {
143+
async getContractDataMapEntryRaw(requestParameters: GetContractDataMapEntryRequest): Promise<runtime.ApiResponse<void>> {
140144
if (requestParameters.stacksAddress === null || requestParameters.stacksAddress === undefined) {
141-
throw new runtime.RequiredError('stacksAddress','Required parameter requestParameters.stacksAddress was null or undefined when calling getContractDataMap.');
145+
throw new runtime.RequiredError('stacksAddress','Required parameter requestParameters.stacksAddress was null or undefined when calling getContractDataMapEntry.');
142146
}
143147

144148
if (requestParameters.contractName === null || requestParameters.contractName === undefined) {
145-
throw new runtime.RequiredError('contractName','Required parameter requestParameters.contractName was null or undefined when calling getContractDataMap.');
149+
throw new runtime.RequiredError('contractName','Required parameter requestParameters.contractName was null or undefined when calling getContractDataMapEntry.');
146150
}
147151

148152
if (requestParameters.mapName === null || requestParameters.mapName === undefined) {
149-
throw new runtime.RequiredError('mapName','Required parameter requestParameters.mapName was null or undefined when calling getContractDataMap.');
153+
throw new runtime.RequiredError('mapName','Required parameter requestParameters.mapName was null or undefined when calling getContractDataMapEntry.');
150154
}
151155

152-
if (requestParameters.body === null || requestParameters.body === undefined) {
153-
throw new runtime.RequiredError('body','Required parameter requestParameters.body was null or undefined when calling getContractDataMap.');
156+
if (requestParameters.key === null || requestParameters.key === undefined) {
157+
throw new runtime.RequiredError('key','Required parameter requestParameters.key was null or undefined when calling getContractDataMapEntry.');
154158
}
155159

156160
const queryParameters: runtime.HTTPQuery = {};
@@ -168,7 +172,7 @@ export class SmartContractsApi extends runtime.BaseAPI {
168172
method: 'POST',
169173
headers: headerParameters,
170174
query: queryParameters,
171-
body: requestParameters.body as any,
175+
body: requestParameters.key as any,
172176
});
173177

174178
return new runtime.VoidApiResponse(response);
@@ -178,8 +182,8 @@ export class SmartContractsApi extends runtime.BaseAPI {
178182
* Attempt to fetch data from a contract data map. The contract is identified with [Stacks Address] and [Contract Name] in the URL path. The map is identified with [Map Name]. The key to lookup in the map is supplied via the POST body. This should be supplied as the hex string serialization of the key (which should be a Clarity value). Note, this is a JSON string atom. In the response, `data` is the hex serialization of the map response. Note that map responses are Clarity option types, for non-existent values, this is a serialized none, and for all other responses, it is a serialized (some ...) object.
179183
* Get specific data-map inside a contract
180184
*/
181-
async getContractDataMap(requestParameters: GetContractDataMapRequest): Promise<void> {
182-
await this.getContractDataMapRaw(requestParameters);
185+
async getContractDataMapEntry(requestParameters: GetContractDataMapEntryRequest): Promise<void> {
186+
await this.getContractDataMapEntryRaw(requestParameters);
183187
}
184188

185189
/**
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/* tslint:disable */
2+
/* eslint-disable */
3+
/**
4+
* Stacks 2.0 Blockchain API
5+
* This is the documentation for the Stacks 2.0 Blockchain API. It is comprised of two parts; the Stacks Blockchain API and the Stacks Core API. [![Run in Postman](https://run.pstmn.io/button.svg)](https://app.getpostman.com/run-collection/614feab5c108d292bffa#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widmFsdWUiOiJnZXQtdmFsdWUiLCJlbmFibGVkIjp0cnVlfV0=) ## Design ### Stacks Core API vs Stacks Blockchain API The blockchain\'s Rust implementation exposes a JSON RPC endpoint (\"Stacks Core API\"), which can be used to interface with the blockchain. It can be used directly. [See the documentation for the `stacks-blockchain` in its Github repository](https://github.com/blockstack/stacks-blockchain/) All `/v2/` routes a proxied to a Blockstack PBC-hosted Stacks Node. For a trustless architecture, you should make these requests to a self-hosted node. All `/extended/` routes are provided by the Stacks 2.0 Blockchain API directly. They extend the Stacks Core API capabilities to make it easier to integrate with. ### Pagination To make API responses more compact, lists returned by the API are paginated. For lists, the response body includes: - `limit`: the number of list items return per response - `offset`: the number of elements to skip (starting from `0`) - `total`: the number of all available list items - `results`: the array of list items (length of array equals the set limit) Using the `limit` and `offset` properties, you can paginate through the entire list by increasing the offset by the limit until you reach the total. ## Client Library A generated JS Client is available for consumption of this API. The client enables typesafe REST and WebSocket communication. Please review the [client documentation](https://blockstack.github.io/stacks-blockchain-api/client/index.html) for more details.
6+
*
7+
* The version of the OpenAPI document: 1.0.0
8+
*
9+
*
10+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
11+
* https://openapi-generator.tech
12+
* Do not edit the class manually.
13+
*/
14+
15+
import { exists, mapValues } from '../runtime';
16+
/**
17+
* GET request to get contract source
18+
* @export
19+
* @interface ReadOnlyFunctionSuccessResponse
20+
*/
21+
export interface ReadOnlyFunctionSuccessResponse {
22+
/**
23+
*
24+
* @type {boolean}
25+
* @memberof ReadOnlyFunctionSuccessResponse
26+
*/
27+
okay: boolean;
28+
/**
29+
*
30+
* @type {string}
31+
* @memberof ReadOnlyFunctionSuccessResponse
32+
*/
33+
result?: string;
34+
/**
35+
*
36+
* @type {string}
37+
* @memberof ReadOnlyFunctionSuccessResponse
38+
*/
39+
cause?: string;
40+
}
41+
42+
export function ReadOnlyFunctionSuccessResponseFromJSON(json: any): ReadOnlyFunctionSuccessResponse {
43+
return ReadOnlyFunctionSuccessResponseFromJSONTyped(json, false);
44+
}
45+
46+
export function ReadOnlyFunctionSuccessResponseFromJSONTyped(json: any, ignoreDiscriminator: boolean): ReadOnlyFunctionSuccessResponse {
47+
if ((json === undefined) || (json === null)) {
48+
return json;
49+
}
50+
return {
51+
52+
'okay': json['okay'],
53+
'result': !exists(json, 'result') ? undefined : json['result'],
54+
'cause': !exists(json, 'cause') ? undefined : json['cause'],
55+
};
56+
}
57+
58+
export function ReadOnlyFunctionSuccessResponseToJSON(value?: ReadOnlyFunctionSuccessResponse | null): any {
59+
if (value === undefined) {
60+
return undefined;
61+
}
62+
if (value === null) {
63+
return null;
64+
}
65+
return {
66+
67+
'okay': value.okay,
68+
'result': value.result,
69+
'cause': value.cause,
70+
};
71+
}
72+
73+

client/src/generated/models/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@ export * from './MempoolTransactionListResponse';
1313
export * from './NetworkBlockTimeResponse';
1414
export * from './NetworkBlockTimesResponse';
1515
export * from './NetworkBlockTimesResponseMainnet';
16+
export * from './ReadOnlyFunctionSuccessResponse';
1617
export * from './RunFaucetResponse';
1718
export * from './TransactionResults';

docs/index.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@ export interface BlockListResponse {
9292
results: Block[];
9393
}
9494

95+
/**
96+
* GET request to get contract source
97+
*/
98+
export interface ReadOnlyFunctionSuccessResponse {
99+
okay: boolean;
100+
result?: string;
101+
cause?: string;
102+
}
103+
95104
/**
96105
* GET request for account data
97106
*/

0 commit comments

Comments
 (0)