Skip to content

Commit b981c49

Browse files
kyranjamiezone117x
authored andcommitted
feat: add mempool openapi docs
1 parent 731fb20 commit b981c49

File tree

2 files changed

+115
-11
lines changed

2 files changed

+115
-11
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
{
2+
"limit": 96,
3+
"offset": 0,
4+
"total": 5,
5+
"results": [
6+
{
7+
"tx_id": "0xb31df5a363dad31723324cb5e0eefa04d491519fd30827a521cbc830114aa50c",
8+
"tx_status": "pending",
9+
"tx_type": "token_transfer",
10+
"receipt_time": 1598288370,
11+
"receipt_time_iso": "2020-08-24T16:59:30.000Z",
12+
"fee_rate": "180",
13+
"sender_address": "STB44HYPYAT2BB2QE513NSP81HTMYWBJP02HPGK6",
14+
"sponsored": false,
15+
"post_condition_mode": "deny",
16+
"token_transfer": {
17+
"recipient_address": "ST1GY25DM8RZV4X15X07THRZ2C5NMWPGQWKFGV87F",
18+
"amount": "500000",
19+
"memo": "0x46617563657400000000000000000000000000000000000000000000000000000000"
20+
}
21+
},
22+
{
23+
"tx_id": "0x5bed8e3f801cb4e2c74d2815a092f7c1c6a35f2fce4a80c80ca70848d34cb395",
24+
"tx_status": "pending",
25+
"tx_type": "token_transfer",
26+
"receipt_time": 1598282326,
27+
"receipt_time_iso": "2020-08-24T15:18:46.000Z",
28+
"fee_rate": "180",
29+
"sender_address": "ST1PS1KF93VBY5A1JV7TM66KN046KP3E3761DBSAG",
30+
"sponsored": false,
31+
"post_condition_mode": "deny",
32+
"token_transfer": {
33+
"recipient_address": "ST2H33S8SEY27QKEKQKR6S5PECYPKY45CQYGGQR8X",
34+
"amount": "1000",
35+
"memo": "0x00000000000000000000000000000000000000000000000000000000000000000000"
36+
}
37+
},
38+
{
39+
"tx_id": "0x9916036fde08a207e581cdcabc18ff55469861cb81194ab0e3e7c9a02cd5a17c",
40+
"tx_status": "pending",
41+
"tx_type": "smart_contract",
42+
"receipt_time": 1598258958,
43+
"receipt_time_iso": "2020-08-24T08:49:18.000Z",
44+
"fee_rate": "2000",
45+
"sender_address": "ST2R1XSFXYHCSFE426HP45TTD8ZWV9XHX2SRP3XA8",
46+
"sponsored": false,
47+
"post_condition_mode": "deny",
48+
"post_conditions": [],
49+
"smart_contract": {
50+
"contract_id": "ST2R1XSFXYHCSFE426HP45TTD8ZWV9XHX2SRP3XA8.test-loans-1",
51+
"source_code": "(define-data-var stx-loaned int 0)\n(define-data-var lockup-period int 0)\n(define-data-var stx-return int 0)\n(define-public (get-stx-return (stx uint) (months uint))\n (ok\n (begin\n (var-set stx-loaned (to-int(stx))\n (var-set lockup-period (to-int(months))\n (calculate-stx-return)\n (print (var-get stx-return))\n (transfer-to-server)\n )\n )\n)\n(define-private (calculate-stx-return)\n (ok\n (begin\n (var-set stx-return (- (+ (* (/ (* (var-get stx-loaned) 5) 100) (var-get lockup-period)) (var-get stx-loaned)) 5))\n )\n )\n)\n(define-private (transfer-to-server)\n (begin\n (unwrap-panic (stx-transfer? (to-uint (var-get stx-loaned)) tx-sender 'ST2R1XSFXYHCSFE426HP45TTD8ZWV9XHX2SRP3XA8))\n (ok (to-uint (var-get stx-loaned)))\n )\n)"
52+
}
53+
},
54+
{
55+
"tx_id": "0x871fb186c8d6ac6ede2822c71074d9884b593c0d7f2d0d6e8516e615484d7501",
56+
"tx_status": "pending",
57+
"tx_type": "smart_contract",
58+
"receipt_time": 1598230365,
59+
"receipt_time_iso": "2020-08-24T00:52:45.000Z",
60+
"fee_rate": "2000",
61+
"sender_address": "ST1FJGMWPGM1P7N0K3N9QEPZK5H1VDC5YWTVMEAZ1",
62+
"sponsored": false,
63+
"post_condition_mode": "deny",
64+
"post_conditions": [],
65+
"smart_contract": {
66+
"contract_id": "ST1FJGMWPGM1P7N0K3N9QEPZK5H1VDC5YWTVMEAZ1.contract-hook-1598230358601",
67+
"source_code": ";; ## CUSTOM FUNCTION TO EXTRACT A SUBSTRING\n\n(define-read-only (subs (source (buff 10)) \n (start int) \n (end int))\n (begin\n (unwrap-panic (if (and (<= 0 start) (<= start 10)) (ok 1) (err \"Out of bounds: start\")))\n (unwrap-panic (if (and (<= 0 end) (<= end 10)) (ok 1) (err \"Out of bounds: end\")))\n (let ((temp1 (fold subs1 source \n {start: start, end: end, cursor: 1, data: \"\"})))\n (let ((data (get data temp1))) \n data))))\n \n;; Call the function to extract the substring between the bounds:\n\n;; (subs \"123456789\" 2 5)\n\n(define-read-only (subs1 \n (ch (buff 1))\n (acc {data: (buff 10), \n start: int,\n end: int,\n cursor: int})) \n (let ((data (get data acc))\n (start (get start acc))\n (cursor (get cursor acc))\n (end (get end acc))) \n (let ((temp2 \n {cursor: (+ 1 cursor),\n data: (default-to \"\"\n (as-max-len?\n (concat data \n (if (let ((temp3 start)\n (temp4 cursor)\n (temp5 end))\n (and (<= temp3 temp4)\n (<= temp4 temp5)))\n ch \n \"\"))\n u10))}))\n {start: (get start acc),\n end: (get end acc),\n cursor: (get cursor temp2),\n data: (get data temp2)})))\n"
68+
}
69+
},
70+
{
71+
"tx_id": "0x66df10d99d3a26018f521d60e9f744b083386c73e47ad39c394d570abee55f1f",
72+
"tx_status": "pending",
73+
"tx_type": "smart_contract",
74+
"receipt_time": 1598230066,
75+
"receipt_time_iso": "2020-08-24T00:47:46.000Z",
76+
"fee_rate": "2000",
77+
"sender_address": "ST1FJGMWPGM1P7N0K3N9QEPZK5H1VDC5YWTVMEAZ1",
78+
"sponsored": false,
79+
"post_condition_mode": "deny",
80+
"post_conditions": [],
81+
"smart_contract": {
82+
"contract_id": "ST1FJGMWPGM1P7N0K3N9QEPZK5H1VDC5YWTVMEAZ1.contract-hook-1598230054238",
83+
"source_code": "(define-read-only (subs1 \n (ch (buff 1))\n (acc {data: (buff 10), \n start: int,\n end: int,\n cursor: int}))\n (begin\n (unwrap-panic (if (and (<= 1 (get start acc)) (<= (get start acc) 10)) (ok 1) (err \"Out of bounds: start\")))\n (unwrap-panic (if (and (<= 1 (get end acc)) (<= (get end acc) 10)) (ok 1) (err \"Out of bounds: end\")))\n (unwrap-panic (if (and (<= 1 (get cursor acc)) (<= (get cursor acc) 10)) (ok 1) (err \"Out of bounds: cursor\")))\n (let ((data (get data acc))\n (start (get start acc))\n (cursor (get cursor acc))\n (end (get end acc))) \n (let ((temp1 \n {cursor: (+ 1 cursor),\n data: (default-to \"\"\n (as-max-len?\n (concat data \n (if (let ((temp2 start)\n (temp3 cursor)\n (temp4 end))\n (and (<= temp2 temp3)\n (<= temp3 temp4)))\n ch \n \"\"))\n u10))}))\n {start: (get start acc),\n end: (get end acc),\n cursor: (get cursor temp1),\n data: (get data temp1)}))))\n"
84+
}
85+
}
86+
]
87+
}

docs/openapi.yaml

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ paths:
5959
example:
6060
$ref: ./api/faucet/run-faucet.example.json
6161
500:
62-
description: Failed to run faucet
62+
description: Failed to run faucet
6363
/extended/v1/faucets/btc:
6464
parameters:
6565
- name: address
@@ -84,17 +84,17 @@ paths:
8484
example:
8585
$ref: ./api/faucet/run-faucet.example.json
8686
500:
87-
description: Failed to run faucet
87+
description: Failed to run faucet
8888

8989
/extended/v1/tx:
9090
get:
9191
summary: Get recent transactions
9292
tags:
9393
- Transactions
9494
operationId: get_transaction_list
95-
description: |
95+
description: |
9696
Get all recently mined transactions
97-
97+
9898
If using TypeScript, import typings for this response from our types package:
9999
100100
`import type { TransactionResults } from '@blockstack/stacks-blockchain-api-types';`
@@ -108,6 +108,23 @@ paths:
108108
example:
109109
$ref: ./api/transaction/get-transactions.example.json
110110

111+
/extended/v1/tx/mempool:
112+
get:
113+
summary: Get mempool transactions
114+
tags:
115+
- Transactions
116+
operationId: get_mempool_transaction_list
117+
description: Get all recently-broadcast mempool transactions
118+
responses:
119+
200:
120+
description: List of mempool transactions
121+
content:
122+
application/json:
123+
schema:
124+
$ref: ./api/transaction/get-mempool-transactions.schema.json
125+
example:
126+
$ref: ./api/transaction/get-mempool-transactions.example.json
127+
111128
/extended/v1/tx/stream:
112129
get:
113130
summary: Stream transaction events
@@ -204,12 +221,12 @@ paths:
204221
$ref: ./api/blocks/get-blocks.example.json
205222
/extended/v1/block/{block_hash}:
206223
parameters:
207-
- name: block_hash
208-
in: path
209-
description: Hash of the block
210-
required: true
211-
schema:
212-
type: string
224+
- name: block_hash
225+
in: path
226+
description: Hash of the block
227+
required: true
228+
schema:
229+
type: string
213230
get:
214231
summary: Get block
215232
description: Get a specific block by hash
@@ -281,7 +298,7 @@ paths:
281298
$ref: ./entities/transaction-events/transaction-event.schema.json
282299
example:
283300
$ref: ./entities/transaction-events/transaction-event-smart-contract-log.example.json
284-
301+
285302
/v2/contracts/interface/{stacks_address}/{contract_name}:
286303
get:
287304
summary: Get contract interface

0 commit comments

Comments
 (0)