Skip to content

Commit

Permalink
fix: return string for post transactions endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
friedger authored and zone117x committed Nov 12, 2020
1 parent 8d7bdbb commit a132bcb
Show file tree
Hide file tree
Showing 7 changed files with 165 additions and 8 deletions.
16 changes: 10 additions & 6 deletions client/src/generated/apis/TransactionsApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import {
MempoolTransactionListResponse,
MempoolTransactionListResponseFromJSON,
MempoolTransactionListResponseToJSON,
PostCoreNodeTransactionsError,
PostCoreNodeTransactionsErrorFromJSON,
PostCoreNodeTransactionsErrorToJSON,
TransactionResults,
TransactionResultsFromJSON,
TransactionResultsToJSON,
Expand Down Expand Up @@ -232,10 +235,10 @@ export class TransactionsApi extends runtime.BaseAPI implements TransactionsApiI
}

/**
* Broadcast raw transactions on the network. You can use the [stacks-transactions-js](https://github.com/blockstack/stacks-transactions-js) project to generate a raw transaction payload.
* Broadcast raw transactions on the network. You can use the [@stacks/transactions](https://github.com/blockstack/stacks.js) project to generate a raw transaction payload.
* Broadcast raw transaction
*/
async postCoreNodeTransactionsRaw(requestParameters: PostCoreNodeTransactionsRequest): Promise<runtime.ApiResponse<void>> {
async postCoreNodeTransactionsRaw(requestParameters: PostCoreNodeTransactionsRequest): Promise<runtime.ApiResponse<string>> {
const queryParameters: runtime.HTTPQuery = {};

const headerParameters: runtime.HTTPHeaders = {};
Expand All @@ -250,15 +253,16 @@ export class TransactionsApi extends runtime.BaseAPI implements TransactionsApiI
body: requestParameters.body as any,
});

return new runtime.VoidApiResponse(response);
return new runtime.TextApiResponse(response) as any;
}

/**
* Broadcast raw transactions on the network. You can use the [stacks-transactions-js](https://github.com/blockstack/stacks-transactions-js) project to generate a raw transaction payload.
* Broadcast raw transactions on the network. You can use the [@stacks/transactions](https://github.com/blockstack/stacks.js) project to generate a raw transaction payload.
* Broadcast raw transaction
*/
async postCoreNodeTransactions(requestParameters: PostCoreNodeTransactionsRequest): Promise<void> {
await this.postCoreNodeTransactionsRaw(requestParameters);
async postCoreNodeTransactions(requestParameters: PostCoreNodeTransactionsRequest): Promise<string> {
const response = await this.postCoreNodeTransactionsRaw(requestParameters);
return await response.value();
}

}
Expand Down
81 changes: 81 additions & 0 deletions client/src/generated/models/PostCoreNodeTransactionsError.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/* tslint:disable */
/* eslint-disable */
/**
* Stacks 2.0 Blockchain API
* 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#?env%5BStacks%20Blockchain%20API%5D=W3sia2V5Ijoic3R4X2FkZHJlc3MiLCJ2YWx1ZSI6IlNUMlRKUkhESE1ZQlE0MTdIRkIwQkRYNDMwVFFBNVBYUlg2NDk1RzFWIiwiZW5hYmxlZCI6dHJ1ZX0seyJrZXkiOiJibG9ja19pZCIsInZhbHVlIjoiMHgiLCJlbmFibGVkIjp0cnVlfSx7ImtleSI6Im9mZnNldCIsInZhbHVlIjoiMCIsImVuYWJsZWQiOnRydWV9LHsia2V5IjoibGltaXRfdHgiLCJ2YWx1ZSI6IjIwMCIsImVuYWJsZWQiOnRydWV9LHsia2V5IjoibGltaXRfYmxvY2siLCJ2YWx1ZSI6IjMwIiwiZW5hYmxlZCI6dHJ1ZX0seyJrZXkiOiJ0eF9pZCIsInZhbHVlIjoiMHg1NDA5MGMxNmE3MDJiNzUzYjQzMTE0ZTg4NGJjMTlhODBhNzk2MzhmZDQ0OWE0MGY4MDY4Y2RmMDAzY2RlNmUwIiwiZW5hYmxlZCI6dHJ1ZX0seyJrZXkiOiJjb250cmFjdF9pZCIsInZhbHVlIjoiU1RKVFhFSlBKUFBWRE5BOUIwNTJOU1JSQkdRQ0ZOS1ZTMTc4VkdIMS5oZWxsb193b3JsZFxuIiwiZW5hYmxlZCI6dHJ1ZX0seyJrZXkiOiJidGNfYWRkcmVzcyIsInZhbHVlIjoiYWJjIiwiZW5hYmxlZCI6dHJ1ZX0seyJrZXkiOiJjb250cmFjdF9hZGRyZXNzIiwidmFsdWUiOiJTVEpUWEVKUEpQUFZETkE5QjA1Mk5TUlJCR1FDRk5LVlMxNzhWR0gxIiwiZW5hYmxlZCI6dHJ1ZX0seyJrZXkiOiJjb250cmFjdF9uYW1lIiwidmFsdWUiOiJoZWxsb193b3JsZCIsImVuYWJsZWQiOnRydWV9LHsia2V5IjoiY29udHJhY3RfbWFwIiwidmFsdWUiOiJzdG9yZSIsImVuYWJsZWQiOnRydWV9LHsia2V5IjoiY29udHJhY3RfbWV0aG9kIiwidmFsdWUiOiJnZXQtdmFsdWUiLCJlbmFibGVkIjp0cnVlfV0=)
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/

import { exists, mapValues } from '../runtime';
/**
* GET request that returns transactions
* @export
* @interface PostCoreNodeTransactionsError
*/
export interface PostCoreNodeTransactionsError {
/**
* The error
* @type {string}
* @memberof PostCoreNodeTransactionsError
*/
error: string;
/**
* The reason for the error
* @type {string}
* @memberof PostCoreNodeTransactionsError
*/
reason: string;
/**
* More details about the reason
* @type {object}
* @memberof PostCoreNodeTransactionsError
*/
reason_data: object;
/**
* The relevant transaction id
* @type {string}
* @memberof PostCoreNodeTransactionsError
*/
txid: string;
}

export function PostCoreNodeTransactionsErrorFromJSON(json: any): PostCoreNodeTransactionsError {
return PostCoreNodeTransactionsErrorFromJSONTyped(json, false);
}

export function PostCoreNodeTransactionsErrorFromJSONTyped(json: any, ignoreDiscriminator: boolean): PostCoreNodeTransactionsError {
if ((json === undefined) || (json === null)) {
return json;
}
return {

'error': json['error'],
'reason': json['reason'],
'reason_data': json['reason_data'],
'txid': json['txid'],
};
}

export function PostCoreNodeTransactionsErrorToJSON(value?: PostCoreNodeTransactionsError | null): any {
if (value === undefined) {
return undefined;
}
if (value === null) {
return null;
}
return {

'error': value.error,
'reason': value.reason,
'reason_data': value.reason_data,
'txid': value.txid,
};
}


1 change: 1 addition & 0 deletions client/src/generated/models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export * from './NetworkBlockTimeResponse';
export * from './NetworkBlockTimesResponse';
export * from './NetworkBlockTimesResponseMainnet';
export * from './NetworkIdentifier';
export * from './PostCoreNodeTransactionsError';
export * from './ReadOnlyFunctionArgs';
export * from './ReadOnlyFunctionSuccessResponse';
export * from './RosettaAccount';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"error": "transaction rejected",
"reason": "BadNonce",
"reason_data": {
"actual": 4,
"expected": 0,
"is_origin": true,
"principal": "ST2ZRX0K27GW0SP3GJCEMHD95TQGJMKB7G9Y0X1MH"
},
"txid": "caf6fd60ae05b0c2d19ef14ab6a7670b1095d117fa7c80224c74e76214d0a791"
}
25 changes: 25 additions & 0 deletions docs/api/transaction/post-core-node-transactions-error.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "GET request that returns transactions",
"title": "PostCoreNodeTransactionsError",
"type": "object",
"required": ["error", "reason", "reason_data", "txid"],
"properties": {
"error": {
"type": "string",
"description": "The error"
},
"reason": {
"type": "string",
"description": "The reason for the error"
},
"reason_data": {
"type": "object",
"description": "More details about the reason"
},
"txid": {
"type": "string",
"description": "The relevant transaction id"
}
}
}
24 changes: 24 additions & 0 deletions docs/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,30 @@ export interface TransactionResults {
results: Transaction[];
}

/**
* GET request that returns transactions
*/
export interface PostCoreNodeTransactionsError {
/**
* The error
*/
error: string;
/**
* The reason for the error
*/
reason: string;
/**
* More details about the reason
*/
reason_data: {
[k: string]: unknown | undefined;
};
/**
* The relevant transaction id
*/
txid: string;
}

/**
* A block
*/
Expand Down
15 changes: 13 additions & 2 deletions docs/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ paths:
summary: Broadcast raw transaction
tags:
- Transactions
description: Broadcast raw transactions on the network. You can use the [stacks-transactions-js](https://github.com/blockstack/stacks-transactions-js) project to generate a raw transaction payload.
description: Broadcast raw transactions on the network. You can use the [@stacks/transactions](https://github.com/blockstack/stacks.js) project to generate a raw transaction payload.
operationId: post_core_node_transactions
requestBody:
content:
Expand All @@ -192,9 +192,20 @@ paths:
example: binary format of 00000000010400bed38c2aadffa348931bcb542880ff79d607afec000000000000000000000000000000c800012b0b1fff6cccd0974966dcd665835838f0985be508e1322e09fb3d751eca132c492bda720f9ef1768d14fdabed6127560ba52d5e3ac470dcb60b784e97dc88c9030200000000000516df0ba3e79792be7be5e50a370289accfc8c9e032000000000000303974657374206d656d6f00000000000000000000000000000000000000000000000000
responses:
200:
description: Successful post of a raw tx to the node's mempool
description: Transaction id of successful post of a raw tx to the node's mempool
content:
text/plain:
schema:
type: string
example: '"e161978626f216b2141b156ade10501207ae535fa365a13ef5d7a7c9310a09f2"'
400:
description: Rejections result in a 400 error
content:
application/json:
schema:
$ref: ./api/transaction/post-core-node-transactions-error.schema.json
example:
$ref: ./api/transaction/post-core-node-transactions-error.example.json

/extended/v1/block:
get:
Expand Down

0 comments on commit a132bcb

Please sign in to comment.