Skip to content

Commit cb5ca93

Browse files
authored
feat: include stx-transfer-memo results in /address/<recipient>/stx_inbound endpoint (#1289)
1 parent 67332ce commit cb5ca93

File tree

4 files changed

+42
-2
lines changed

4 files changed

+42
-2
lines changed

docs/entities/transfers/inbound-stx-transfer.schema.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
},
2828
"transfer_type": {
2929
"type": "string",
30-
"enum": ["bulk-send", "stx-transfer"],
30+
"enum": ["bulk-send", "stx-transfer", "stx-transfer-memo"],
3131
"description": "Indicates if the transfer is from a stx-transfer transaction or a contract-call transaction"
3232
},
3333
"tx_index": {

docs/generated.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ export interface InboundStxTransfer {
888888
/**
889889
* Indicates if the transfer is from a stx-transfer transaction or a contract-call transaction
890890
*/
891-
transfer_type: "bulk-send" | "stx-transfer";
891+
transfer_type: "bulk-send" | "stx-transfer" | "stx-transfer-memo";
892892
/**
893893
* Index of the transaction within a block
894894
*/

src/datastore/pg-store.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2677,6 +2677,24 @@ export class PgStore {
26772677
AND stx_events.canonical = true AND stx_events.microblock_canonical = true
26782678
AND contract_logs.canonical = true AND contract_logs.microblock_canonical = true
26792679
UNION ALL
2680+
2681+
SELECT
2682+
stx_events.amount AS amount,
2683+
stx_events.memo AS memo,
2684+
stx_events.sender AS sender,
2685+
stx_events.block_height AS block_height,
2686+
stx_events.tx_id,
2687+
stx_events.microblock_sequence,
2688+
stx_events.tx_index,
2689+
'stx-transfer-memo' as transfer_type
2690+
FROM stx_events
2691+
WHERE
2692+
stx_events.memo IS NOT NULL
2693+
AND canonical = true
2694+
AND microblock_canonical = true
2695+
AND recipient = ${args.stxAddress}
2696+
UNION ALL
2697+
26802698
SELECT
26812699
token_transfer_amount AS amount,
26822700
token_transfer_memo AS memo,

src/tests/tx-tests.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,6 +1265,28 @@ describe('tx tests', () => {
12651265
memo: '0x74657374206d656d6f206669656c64',
12661266
},
12671267
});
1268+
1269+
const req6 = await supertest(api.server).get(
1270+
`/extended/v1/address/${dbStxEvent.recipient}/stx_inbound`
1271+
);
1272+
expect(req6.status).toBe(200);
1273+
expect(req6.type).toBe('application/json');
1274+
expect(req6.body).toEqual({
1275+
limit: 20,
1276+
offset: 0,
1277+
results: [
1278+
{
1279+
amount: '60',
1280+
block_height: 1,
1281+
memo: '0x74657374206d656d6f206669656c64',
1282+
sender: 'STB44HYPYAT2BB2QE513NSP81HTMYWBJP02HPGK6',
1283+
transfer_type: 'stx-transfer-memo',
1284+
tx_id: '0x421234',
1285+
tx_index: 0,
1286+
},
1287+
],
1288+
total: 1,
1289+
});
12681290
});
12691291

12701292
test('tx store and processing', async () => {

0 commit comments

Comments
 (0)